Example #1
0
 public void execute() throws NoSuchProtocolException, NetworkException {
   ARPNetworkLayer arp =
       (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
   PrintWriter out = getOutput().getPrintWriter();
   if (argClear.isSet()) {
     arp.getCache().clear();
     out.println(str_cleared);
   } else {
     for (ARPCacheEntry entry : arp.getCache().entries()) {
       out.println(entry);
     }
   }
 }
 private void updateARPCache(HardwareAddress hwAddr, ProtocolAddress pAddr) {
   if (arp == null) {
     try {
       arp = (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
     } catch (NoSuchProtocolException ex) {
       log.error("Cannot find ARP layer", ex);
     } catch (NetworkException ex) {
       log.error("Cannot network layer manager", ex);
     }
   }
   if (arp != null) {
     arp.getCache().set(hwAddr, pAddr, true);
   }
 }