Package org.jnode.net.arp

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


     * @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

     * @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

    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

Related Classes of org.jnode.net.arp.ARPNetworkLayer

Copyright © 2018 www.massapicom. 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.