Package org.jnode.net.ipv4

Examples of org.jnode.net.ipv4.IPv4FragmentList


    }

    @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


        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

        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

            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

     * @param skbuf
     * @throws NetworkException
     */
    private void deliverFragment(IPv4Header hdr, SocketBuffer skbuf) throws SocketException {
        final Object key = hdr.getFragmentListKey();
        final IPv4FragmentList flist = (IPv4FragmentList) fragments.get(key);
        if (flist == null) {
            // This is a fragment for a new list
            fragments.put(key, new IPv4FragmentList(skbuf));
        } else {
            if (flist.isAlive()) {
                flist.add(skbuf);
                if (flist.isComplete()) {
                    // The fragmentlist is now complete, deliver it
                    final SocketBuffer pbuf = flist.getPacket();
                    final IPv4Header phdr = (IPv4Header) pbuf.getNetworkLayerHeader();
                    stat.reassembled.inc();
                    deliver(phdr, pbuf);
                }
            } else {
View Full Code Here

            if (log.isDebugEnabled()) {
                log.debug("receive: me=[" + this + "], hdr=[" + hdr + ']');
            }
        }

        final IPv4Header ipHdr = (IPv4Header) skbuf.getNetworkLayerHeader();
        final boolean ack = hdr.isFlagAcknowledgeSet();
        final boolean rst = hdr.isFlagResetSet();

        if (rst) {
            receiveProcessReset(ipHdr, hdr, skbuf);
View Full Code Here

        // Create the FIN TCP reply
        final TCPHeader replyHdr = createOutgoingTCPHeader(extraFlags | TCPF_ACK, ackNr);
        // ACK takes 0 seq-nrs, so don't increment snd_next

        // Create the IP reply header
        final IPv4Header replyIp = createOutgoingIPv4Header();

        // Send the reply
        outChannel.send(replyIp, replyHdr);
    }
View Full Code Here

        // Create the FIN TCP reply
        final TCPHeader replyHdr =
            createOutgoingTCPHeader(TCPF_FIN | TCPF_ACK, inChannel.getRcvNext());

        // Create the IP reply header
        final IPv4Header replyIp = createOutgoingIPv4Header();

        // Send the reply
        outChannel.send(replyIp, replyHdr);
    }
View Full Code Here

        // Create the RST TCP reply
        final TCPHeader replyHdr = createOutgoingTCPHeader(TCPF_RST, 0);
        // RST takes 0 seg-nrs TODO is this correct????

        // Create the IP reply header
        final IPv4Header replyIp = createOutgoingIPv4Header();

        // Send the reply
        outChannel.send(replyIp, replyHdr);
    }
View Full Code Here

        // Create the SYN TCP
        final TCPHeader hdr = createOutgoingTCPHeader(TCPF_SYN, 0);

        // Create the IP reply header
        final IPv4Header ipHdr = createOutgoingIPv4Header();

        // Send the reply
        outChannel.send(ipHdr, hdr);
    }
View Full Code Here

TOP

Related Classes of org.jnode.net.ipv4.IPv4FragmentList

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.