Examples of ARPNetworkLayer


Examples of org.jnode.net.arp.ARPNetworkLayer

     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        final ARPNetworkLayer arp =
                (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP);
        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        final IPv4Address addr = new IPv4Address(args[0]);
        final IPv4Address myAddr = new IPv4Address(args[1]);
        final Device dev = dm.getDevice(args[2]);
        final long timeout = 5000;

        final HardwareAddress hwAddr;
        hwAddr = arp.getHardwareAddress(addr, myAddr, dev, timeout);

        System.out.println("Found hwaddress:" + hwAddr);
    }
View Full Code Here

Examples of org.jnode.net.arp.ARPNetworkLayer

     * @param route
     * @return
     */
    private HardwareAddress findDstHWAddress(IPv4Route route, IPv4Header hdr, SocketBuffer skbuf)
        throws NetworkException {
        final ARPNetworkLayer arp = getARP();
        final IPv4Address dstAddr;
        if (hdr.getDestination().isBroadcast()) {
            return null;
        } else if (route.isGateway()) {
            dstAddr = route.getGateway();
        } else {
            dstAddr = hdr.getDestination();
        }
        try {
            return arp.getHardwareAddress(dstAddr, hdr.getSource(), route.getDevice(), arpTimeout);
        } catch (TimeoutException ex) {
            throw new NetworkException("Cannot find hardware address of " + dstAddr, ex);
        }
    }
View Full Code Here

Examples of org.jnode.net.arp.ARPNetworkLayer

     * @param skbuf
     * @return HardwareAddress
     */
    private HardwareAddress findDstHWAddress(IPv4Address destination, Device device,
            IPv4Header hdr, SocketBuffer skbuf) throws NetworkException {
        final ARPNetworkLayer arp = getARP();
        if (destination.isBroadcast()) {
            return null;
        } else {
            try {
                return arp.getHardwareAddress(destination, hdr.getSource(), device, arpTimeout);
            } catch (TimeoutException ex) {
                throw new NetworkException("Cannot find hardware address of " + destination, ex);
            }
        }
    }
View Full Code Here

Examples of org.jnode.net.arp.ARPNetworkLayer

    public static void main(String[] args) throws Exception {
        new ArpCommand().execute(args);
    }

    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);
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.