Package org.jnode.net

Examples of org.jnode.net.SocketBuffer


        final int srcPort = getLocalPort();
        // final int srcPort = p.getPort(); // or getLocalPort???? TODO Fix
        // srcPort issue
        udpHdr = new UDPHeader(srcPort, p.getPort(), p.getLength());

        final SocketBuffer skbuf = new SocketBuffer(p.getData(), p.getOffset(), p.getLength());
        skbuf.setDevice(getDevice());
        protocol.send(ipHdr, udpHdr, skbuf);
    }
View Full Code Here


        final int maxFragSize = (mtu - hdr.getLength()) & ~IP_MIN_FRAG_SIZE;

        // Now create the fragmented packets and send them
        while (length > 0) {
            final int fragLen = Math.min(maxFragSize, length);
            final SocketBuffer fBuf = new SocketBuffer(packet, offset, fragLen);
            hdr.setFragmentOffset(offset);
            hdr.setMoreFragments((length - fragLen) > 0);
            hdr.setDataLength(fragLen);
            sendPacket(api, dstHwAddr, hdr, fBuf);
            offset += fragLen;
View Full Code Here

     */
    protected final void receive(DatagramPacket p) throws IOException {
        if (closed) {
            throw new SocketException("DatagramSocket has been closed");
        }
        final SocketBuffer skbuf = (SocketBuffer) receiveQueue.get(timeout);
        if (skbuf == null) {
            if (closed) {
                throw new SocketException("DatagramSocket has been closed");
            } else {
                throw new SocketTimeoutException("Timeout in receive");
View Full Code Here

        this.haveFirstFragment |= (myFrOfs == 0);
        this.haveLastFragment |= !hdr.hasMoreFragments();

        // Insert the fragment at the correct index in the list
        for (Iterator<SocketBuffer> i = fragments.iterator(); i.hasNext();) {
            final SocketBuffer f = (SocketBuffer) i.next();
            final IPv4Header fhdr = (IPv4Header) f.getNetworkLayerHeader();
            final int fOfs = fhdr.getFragmentOffset();
            final int fSize = f.getSize();

            if (myFrOfs == (fOfs + fSize)) {
                // skbuf directly follows f, attach it.
                f.append(skbuf);

                // See if we can attach the following fragment directly to me
                if (i.hasNext()) {
                    final SocketBuffer f2 = (SocketBuffer) i.next();
                    final IPv4Header f2hdr = (IPv4Header) f2.getNetworkLayerHeader();
                    final int f2Ofs = f2hdr.getFragmentOffset();
                    if (f2Ofs == (myFrOfs + skbuf.getSize())) {
                        // Yes we can attach it
                        skbuf.append(f2);
                        fragments.remove(f2);
View Full Code Here

     * Create a new header and read it from the given packet
     *
     * @param packet
     */
    public BOOTPHeader(DatagramPacket packet) {
        this(new SocketBuffer(packet.getData(), packet.getOffset(), packet.getLength()));
    }
View Full Code Here

        this(new BOOTPHeader(skbuf));
    }

    public BOOTPMessage(DatagramPacket packet) {
        this(new BOOTPHeader(
                new SocketBuffer(packet.getData(), packet.getOffset(), packet.getLength())));
    }
View Full Code Here

    /**
     * Gets this message as a DatagramPacket
     */
    public DatagramPacket toDatagramPacket() {
        final SocketBuffer skbuf = new SocketBuffer();
        skbuf.insert(OPTIONS_SIZE);

        header.prefixTo(skbuf);
        final byte[] data = skbuf.toByteArray();
        return new DatagramPacket(data, data.length);
    }
View Full Code Here

    private void sendEchoReply(ICMPEchoHeader hdr, SocketBuffer skbuf) throws SocketException {
        final IPv4Header ipHdr = (IPv4Header) skbuf.getNetworkLayerHeader();
        final IPv4Header ipReplyHdr = new IPv4Header(ipHdr);
        ipReplyHdr.swapAddresses();
        ipReplyHdr.setTtl(0xFF);
        send(ipReplyHdr, hdr.createReplyHeader(), new SocketBuffer(skbuf));
    }
View Full Code Here

        // Unpull the original IP header
        srcBuf.unpull(origIpHdr.getLength());

        // Create a response buffer
        final SocketBuffer skbuf = new SocketBuffer();
        // Prefix the ICMP header to the response buffer
        icmpHdr.prefixTo(skbuf);
        // Append the original message to the response buffer
        skbuf.append(srcBuf);
        // / RFC says return as much as we can without exceeding 576 bytes.
        skbuf.trim(576);

        ipService.transmit(ipHdr, skbuf);
    }
View Full Code Here

        }
    }

    private void rxProcess() {
        SocketBuffer skbuf;

        while ((skbuf = bufferManager.getPacket()) != null) {
            try {
                if (skbuf != null)
                    driver.onReceive(skbuf);
View Full Code Here

TOP

Related Classes of org.jnode.net.SocketBuffer

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.