Package org.jnode.net

Examples of org.jnode.net.SocketBuffer


            //IOSYNC;
            try {

                Thread.sleep(50);
                if (!rxRing.currentDesc().isOwnBit()) {
                    SocketBuffer packet = rxRing.currentDesc().getPacket();
                    driver.onReceive(packet);
                    log.debug("New packet");
                    log.debug(packet.getLinkLayerHeader().getSourceAddress());
                    log.debug(packet.getLinkLayerHeader().getDestinationAddress());
                    log.debug('\n' + hexDump(packet.toByteArray()) + '\n');
                    rxRing.currentDesc().setOwnBit();
                    rxRing.next();
                }

            } catch (Exception e) {
View Full Code Here


     */
    public void process(Object[] object) {
        try {
            //log.debug("<transmit dev=" + getDevice().getId() + ">");
            final Object[] data = (Object[]) object;
            final SocketBuffer skbuf = (SocketBuffer) data[0];
            final HardwareAddress destination = (HardwareAddress) data[1];
            tx_count += skbuf.getSize();
            doTransmit(skbuf, destination);
            //log.debug("</transmit dev=" + getDevice().getId() + ">");
        } catch (NetworkException ex) {
            log.error("Cannot transmit packet", ex);
        }
View Full Code Here

            optionCode = skbuf.get(i);
        }
    }

    public DHCPMessage(DatagramPacket packet) {
        this(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);
        // magic cookie
        skbuf.set(0, 99);
        skbuf.set(1, 130);
        skbuf.set(2, 83);
        skbuf.set(3, 99);
        // options
        skbuf.set(4, MESSAGE_TYPE_OPTION);
        skbuf.set(5, 1);
        skbuf.set(6, messageType);
        int n = 7;
        for (Map.Entry<Integer, byte[]> entry : options.entrySet()) {
            final int optionCode = entry.getKey();
            final byte optionValue[] = entry.getValue();
            skbuf.set(n, optionCode);
            skbuf.set(n + 1, optionValue.length);
            skbuf.set(n + 2, optionValue, 0, optionValue.length);
            n += optionValue.length + 2;
        }
        skbuf.set(n, END_OPTION);

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

        io.copyFromBAP(fid, 0, frame, 0, hdrLen);
        final int dataLength = Prism2CommFrame.getDataLength(frame, 0);

        // Create the SocketBuffer
        final int ethHLEN = EthernetConstants.ETH_HLEN;
        final SocketBuffer skbuf = new SocketBuffer(ethHLEN + dataLength);
        skbuf.append(frame, Prism2CommFrame.p8023HDR_OFF, ethHLEN);

        // Read the actual data
        if (dataLength > 0) {
            io.copyFromBAP(fid, hdrLen, frame, hdrLen, dataLength);
            skbuf.append(frame, hdrLen, dataLength);
        }

        // Process the received frame
        try {
            driver.onReceive(skbuf);
View Full Code Here

            getNicData(nicAddr2, bbuf, len1, len2);
        } else {
            // We can get the buffer in a single action
            getNicData(nicAddr, bbuf, 0, len);
        }
        final SocketBuffer buf = new SocketBuffer(bbuf, 0, len);

        // Calculate the next bound value
        final int nextBound = hdr.getNextPacketPage() - 1;
        // Set the next bound value
        if (nextBound < rx_start) {
View Full Code Here

    /**
     * Figure out the start page of the NIC's memory and the size of this memory
     */
    private int probeNicMemoryStart() throws DriverException {
        final SocketBuffer testBuf = new SocketBuffer();
        final byte[] testData = new byte[] {
            (byte) 0x23, (byte) 0x34, (byte) 0x56, (byte) 0xf3, (byte) 0x72,
            (byte) 0xa6, (byte) 0xe2, (byte) 0xa1, (byte) 0x23, (byte) 0x34, (byte) 0x56,
            (byte) 0xf3, (byte) 0x72, (byte) 0xa6, (byte) 0xe2, (byte) 0xa1};
        final byte[] returnData = new byte[testData.length];
        testBuf.append(testData, 0, testData.length);

        for (int page = 0; page < 256; page += 16) {
            setNicData(testBuf, 0, (page << 8), testData.length);
            getNicData((page << 8), returnData, 0, testData.length);

View Full Code Here

                // Enable interrupts
                setReg16(REG_INTR_MASK, INTR_MASK);
                return;
            } else {
                final SocketBuffer skbuf = null; // rxRing.getPacket(pktLen);

                try {
                   
                    if (skbuf != null && skbuf.getSize() > 0) {
                        driver.onReceive(skbuf);
                    }
                } catch (NetworkException e) {
                    e.printStackTrace();
                } finally {
View Full Code Here

            throw new IndexOutOfBoundsException("offset " + offset);
        }
        if ((length < 0) || (offset + length > used)) {
            throw new IndexOutOfBoundsException("offset + length" + offset + '+' + length);
        }
        return new SocketBuffer(data, offset, length);
    }
View Full Code Here

    /**
     * @return a packet read from the device in a SocketBuffer
     */
    public SocketBuffer getPacket() {
        int pktLen = this.getCount() & 0x3fff;
        final SocketBuffer skbuf = new SocketBuffer();
        skbuf.append(data, 0, pktLen);
        return 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.