Examples of IPv4NetworkLayer


Examples of org.jnode.net.ipv4.layer.IPv4NetworkLayer

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

    public void execute() throws NoSuchProtocolException, NetworkException, NameNotFoundException {
        final IPv4NetworkLayer ipNL =
                (IPv4NetworkLayer) NetUtils.getNLM().getNetworkLayer(ETH_P_IP);
        final IPv4Address target = argTarget.getValue();
        final IPv4Address gateway = argGateway.getValue();
        final Device device = argDevice.getValue();
        final IPv4ConfigurationService cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);

        if (argAdd.isSet()) {
            cfg.addRoute(target, gateway, device, true);
        } else if (argDel.isSet()) {
            cfg.deleteRoute(target, gateway, device);
        } else {
            PrintWriter out = getOutput().getPrintWriter();
            out.println(str_table);
            out.println(ipNL.getRoutingTable());
        }
    }
View Full Code Here

Examples of org.jnode.net.ipv4.layer.IPv4NetworkLayer

       
        final IPv4Header netHeader =
                new IPv4Header(0, this.ttl, IPv4Constants.IPPROTO_ICMP, this.dst, 8);
        netHeader.setDontFragment(this.dontFragment);

        final IPv4NetworkLayer netLayer =
                (IPv4NetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_IP);
        final ICMPProtocol icmpProtocol =
                (ICMPProtocol) netLayer.getProtocol(ICMPProtocol.IPPROTO_ICMP);
        icmpProtocol.addListener(this);
        try {
            int id_count = 0;
            int seq_count = 0;
            while (this.count != 0) {
                out.format(fmt_ping, dst, seq_count);

                if (!this.flood) {
                    this.wait = true;
                }

                SocketBuffer packet = new SocketBuffer();
                packet.insert(this.size);
                ICMPEchoHeader transportHeader = new ICMPEchoHeader(id_count, seq_count);
                transportHeader.prefixTo(packet);

                Request r =
                        new Request(this.stat, this.timeout, System.currentTimeMillis(), id_count,
                                seq_count);
                registerRequest(r);
                netLayer.transmit(netHeader, packet);

                while (this.wait) {
                    long time = System.currentTimeMillis() - r.getTimestamp();
                    if (time > this.interval) {
                        this.wait = false;
View Full Code Here

Examples of org.jnode.net.ipv4.layer.IPv4NetworkLayer

                throw new NetworkException("Cannot find DeviceManager", ex);
            }
            device = findDevice(dm, target, target.getDefaultSubnetmask());
        }

        final IPv4NetworkLayer ipNL;
        try {
            ipNL = (IPv4NetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_IP);
        } catch (NoSuchProtocolException ex) {
            throw new NetworkException("Cannot find IPv4 network layer", ex);
        }
        final IPv4RoutingTable rt = ipNL.getRoutingTable();
        rt.add(new IPv4Route(target, null, gateway, device));
    }
View Full Code Here

Examples of org.jnode.net.ipv4.layer.IPv4NetworkLayer

     * @param device
     * @throws NetworkException
     */
    public static void delRoute(IPv4Address target, IPv4Address gateway, Device device)
        throws NetworkException {
        final IPv4NetworkLayer ipNL;
        try {
            ipNL = (IPv4NetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_IP);
        } catch (NoSuchProtocolException ex) {
            throw new NetworkException("Cannot find IPv4 network layer", ex);
        }
        final IPv4RoutingTable rt = ipNL.getRoutingTable();

        for (IPv4Route route : rt.entries()) {
            if (!route.getDestination().equals(target)) {
                continue;
            }
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.