Examples of IPv4Address


Examples of org.jnode.net.ipv4.IPv4Address

     * @param skbuf
     * @return
     * @throws NoRouteToHostException
     */
    private IPv4Route findRoute(IPv4Header hdr, SocketBuffer skbuf) throws NoRouteToHostException {
        final IPv4Address destination = hdr.getDestination();
        return rt.search(destination);
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

     * @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 {
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

            try {
                final NetDeviceAPI api = dev.getAPI(NetDeviceAPI.class);
                final IPv4ProtocolAddressInfo addrInfo;
                addrInfo = (IPv4ProtocolAddressInfo) api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP);
                if (addrInfo != null) {
                    final IPv4Address devAddr = (IPv4Address) addrInfo.getDefaultAddress();
                    if (devAddr.matches(target, mask)) {
                        return dev;
                    }
                }
            } catch (ApiNotFoundException ex) {
                // Should not happen, but if it happens anyway, just ignore it.
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

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

    public void execute() throws NetworkException {
        IPv4Address server = argDnsServer.getValue();
        PrintWriter out = getOutput().getPrintWriter();
        if (argAdd.isSet()) {
            // Add a DNS server
            ResolverImpl.addDnsServer(server);
        } else if (argDel.isSet()) {
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

            if (!argIPAddress.isSet()) {
                // Print IP address(es) for device
                out.format(fmt_ip, dev.getId(), api.getProtocolAddressInfo(EthernetConstants.ETH_P_IP));
            } else {
                // Set IP address for device
                final IPv4Address ip = argIPAddress.getValue();
                final IPv4Address mask = argSubnetMask.getValue();
                final IPv4ConfigurationService cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
                cfg.configureDeviceStatic(dev, ip, mask, true);

                // FIXME ... this doesn't show the device's new address because the
                // IPv4 ConfigurationServiceImpl calls processor.apply with the
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

    }

    @Override
    protected IPv4Address doAccept(Token value, int flags) throws CommandSyntaxException {
        try {
            return new IPv4Address(value.text);
        } catch (IllegalArgumentException ex) {
            throw new CommandSyntaxException("invalid hostname or IPv4 address");
        }
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

    }

    @Override
    protected IPv4Address doAccept(Token value, int flags) throws CommandSyntaxException {
        if (value.text.equals("default")) {
            return new IPv4Address(new byte[]{0, 0, 0, 0}, 0);
        }
        final StringTokenizer tok = new StringTokenizer(value.text, ".");
        if (tok.countTokens() != 4) {
            throw new CommandSyntaxException("wrong number of components for an IPv4 address");
        }
        try {
            final byte b1 = parseUnsignedByte(tok.nextToken());
            final byte b2 = parseUnsignedByte(tok.nextToken());
            final byte b3 = parseUnsignedByte(tok.nextToken());
            final byte b4 = parseUnsignedByte(tok.nextToken());
            return new IPv4Address(new byte[]{b1, b2, b3, b4}, 0);
        } catch (NumberFormatException ex) {
            throw new CommandSyntaxException("invalid component in IPv4 address");
        }
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

        try {
            cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
        } catch (NameNotFoundException ex) {
            throw new NetworkException(ex);
        }
        cfg.configureDeviceStatic(device, new IPv4Address(hdr.getYourIPAddress()), null, false);

        final IPv4Address serverAddr = new IPv4Address(hdr.getServerIPAddress());
        final IPv4Address networkAddress = serverAddr.and(serverAddr.getDefaultSubnetmask());

        if (hdr.getGatewayIPAddress().isAnyLocalAddress()) {
            cfg.addRoute(serverAddr, null, device, false);
            cfg.addRoute(networkAddress, null, device, false);
        } else {
            cfg.addRoute(networkAddress, new IPv4Address(hdr.getGatewayIPAddress()), device, false);
        }
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

        super(skbuf);
        final ICMPType type = getType();
        if ((type != ICMPType.ICMP_ADDRESS) && (type != ICMPType.ICMP_ADDRESSREPLY)) {
            throw new IllegalArgumentException("Invalid type " + type);
        }
        this.subnetMask = new IPv4Address(skbuf, 8);
    }
View Full Code Here

Examples of org.jnode.net.ipv4.IPv4Address

            return;
        }

        final int tos = 0;
        final int ttl = 0xFF;
        final IPv4Address dstAddr = origIpHdr.getSource();

        // Build the response ICMP header
        final ICMPHeader icmpHdr = new ICMPUnreachableHeader(code);
        // Build the response IP header
        final IPv4Header ipHdr = new IPv4Header(tos, ttl, IPv4Constants.IPPROTO_ICMP, dstAddr, 0);
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.