Examples of IPv4Address


Examples of org.jnode.net.ipv4.IPv4Address

     */
    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);
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

            System.out.println("SendBufferSize=" + socket.getSendBufferSize());
            final byte[] buf = new byte[size];
            final DatagramPacket dp = new DatagramPacket(buf, buf.length);

            dp.setPort(2237);
            dp.setAddress(new IPv4Address(args[0]).toInetAddress());

            System.out.println("Sending packet of size " + dp.getLength());
            socket.send(dp);
        } finally {
            socket.close();
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

    }

    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);
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

        hardwareAddressSize = skbuf.get(4);
        protocolAddressSize = skbuf.get(5);
        operation = ARPOperation.getType(skbuf.get16(6));
        if ((hardwareType == 1) && (protocolType == EthernetConstants.ETH_P_IP)) {
            sourceHardwareAddress = new EthernetAddress(skbuf, 8);
            sourceProtocolAddress = new IPv4Address(skbuf, 14);
            destinationHardwareAddress = new EthernetAddress(skbuf, 18);
            destinationProtocolAddress = new IPv4Address(skbuf, 24);
        } else {
            throw new SocketException("Unknown hw,ptype: " + hardwareType + ',' + protocolType);
        }
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

        new PingCommand().execute(args);
    }
   
    public void execute() throws SocketException, InterruptedException {
        try {
            this.dst = new IPv4Address(argHost.getAsInetAddress());
        } catch (UnknownHostException ex) {
            getError().getPrintWriter().format(fmt_unknown_host, ex.getLocalizedMessage());
            exit(1);
        }
        final PrintWriter out = getOutput().getPrintWriter();
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

                            protocolAddresses = new ProtocolAddress[recordCount];

                            for (int i = 0; i < recordCount; i++) {
                                final Record record = records[i];
                                protocolAddresses[i] = new IPv4Address(record.rdataToString());
                            }
                        } else {
                            throw new UnknownHostException(lookup.getErrorString());
                        }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

    private final IPv4Address loadAddress(Preferences prefs, String key) {
        final String addrStr = prefs.get(key, null);
        if (addrStr == null) {
            return null;
        } else {
            return new IPv4Address(addrStr);
        }
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

        if (myAddrInfo == null) {
            stat.nodevaddr.inc();
        }

        // Should I process this packet, or is it for somebody else?
        final IPv4Address dstAddr = hdr.getDestination();
        final boolean shouldProcess;
        if (myAddrInfo != null) {
            shouldProcess = myAddrInfo.contains(dstAddr);
        } else {
            // I don't have an IP address yet, if the linklayer says
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

            try {
                final NetDeviceAPI api = dev.getAPI(NetDeviceAPI.class);
                final IPv4ProtocolAddressInfo addrInfo =
                        (IPv4ProtocolAddressInfo) api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP);
                if (addrInfo != null) {
                    final IPv4Address addr = (IPv4Address) addrInfo.getDefaultAddress();
                    if (addr != null) {
                        return addr;
                    }
                }
            } catch (ApiNotFoundException ex) {
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

    /**
     * @see java.net.DatagramSocketImpl#send(java.net.DatagramPacket)
     */
    protected void send(DatagramPacket p) throws IOException {

        final IPv4Address dstAddress = new IPv4Address(p.getAddress());
        final IPv4Header ipHdr;
        ipHdr = new IPv4Header(getTos(), getTimeToLive(), IPPROTO_UDP, dstAddress, p.getLength() + UDP_HLEN);
        if (!getLocalAddress().isAnyLocalAddress() || (getDevice() != null)) {
            ipHdr.setSource(new IPv4Address(getLocalAddress()));
        }
        final UDPHeader udpHdr;
        final int srcPort = getLocalPort();
        // final int srcPort = p.getPort(); // or getLocalPort???? TODO Fix
        // srcPort issue
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.