Package streamer

Examples of streamer.ByteBuffer


        // packet in bytes.
        int compressedLength = buf.readUnsignedShortLE();
        if (compressedLength != 0)
            throw new RuntimeException("Compression of protocol packets is not supported. Data: " + buf + ".");

        ByteBuffer data = buf.readBytes(uncompressedLength - 18);
        buf.unref();

        switch (type2) {

        case PDUTYPE2_UPDATE: {

            // (2 bytes): A 16-bit, unsigned integer. Type of the graphics update.
            int updateType = data.readUnsignedShortLE();
            ByteBuffer payload = data.readBytes(data.length - data.cursor);
            data.unref();

            switch (updateType) {
            case UPDATETYPE_ORDERS:
                pushDataToPad("orders", payload);
                break;
            case UPDATETYPE_BITMAP:
                pushDataToPad("bitmap", payload);
                break;
            case UPDATETYPE_PALETTE:
                pushDataToPad("palette", payload);
                break;
            case UPDATETYPE_SYNCHRONIZE:
                // Ignore
                payload.unref();
                break;
            }

            break;
        }
View Full Code Here


            return;

        int payloadLength = length - buf.cursor;

        // Extract payload
        ByteBuffer outBuf = buf.slice(buf.cursor, payloadLength, true);
        buf.unref();

        if (verbose) {
            outBuf.putMetadata("source", this);
        }

        pushDataToPad(TPKT_PAD, outBuf);
    }
View Full Code Here

        if (!cap(buf, packetLength, packetLength, link, false))
            // Wait for full packet to arrive
            return;

        // Extract payload (with header)
        ByteBuffer outBuf = buf.slice(headerPosition, packetLength, true);
        buf.unref();

        if (verbose) {
            outBuf.putMetadata("source", this);
        }

        pushDataToPad(CREDSSP_PAD, outBuf);
    }
View Full Code Here

            if (verbose)
                System.out.println("[" + this + "] INFO: FastPath update received. UpdateCode: " + updateCode + ", fragmentation: " + fragmentation + ", compression: "
                        + compression + ", size: " + size + ".");

            ByteBuffer data = buf.readBytes(size);
            buf.putMetadata("fragmentation", fragmentation);
            buf.putMetadata("compression", compression);

            switch (updateCode) {

            case FASTPATH_UPDATETYPE_ORDERS:
                if (verbose)
                    System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_ORDERS.");
                pushDataToPad(ORDERS_PAD, data);
                break;

            case FASTPATH_UPDATETYPE_BITMAP:
                if (verbose)
                    System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_BITMAP.");
                pushDataToPad(BITMAP_PAD, data);
                break;

            case FASTPATH_UPDATETYPE_PALETTE:
                if (verbose)
                    System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_PALETTE.");
                pushDataToPad(PALETTE_PAD, data);
                break;

            case FASTPATH_UPDATETYPE_SYNCHRONIZE:
                // @see http://msdn.microsoft.com/en-us/library/cc240625.aspx
                if (verbose)
                    System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_SYNCHRONIZE.");

                data.unref();

                if (size != 0)
                    throw new RuntimeException("Size of FastPath synchronize packet must be 0. UpdateCode: " + updateCode + ", fragmentation: " + fragmentation
                            + ", compression: " + compression + ", size: " + size + ", data: " + data + ".");
                break;
View Full Code Here

    @Override
    protected void onStart() {
        super.onStart();

        int length = 1;
        ByteBuffer buf = new ByteBuffer(length, true);

        buf.writeByte(0x28); // AttachUserRequest

        pushDataToOTOut(buf);

        switchOff();
    }
View Full Code Here

        }
        order.rectangles = rectangles;

        buf.assertThatBufferIsFullyRead();

        ByteBuffer data = new ByteBuffer(order);
        pushDataToAllOuts(data);

        buf.unref();
    }
View Full Code Here

        // using RDP 6.0 Bitmap Compression and stored inside
        // an RDP 6.0 Bitmap Compressed Stream structure.
        if (!compressed) {
            rectangle.bitmapDataStream = buf.readBytes(bitmapLength);
        } else {
            ByteBuffer compressedImage = buf.readBytes(bitmapLength);
            //* DEBUG */System.out.println("Compressed image: " + compressedImage + ", depth: " + rectangle.bitsPerPixel + ".");
            rectangle.bitmapDataStream = RLEBitmapDecompression.rleDecompress(compressedImage, rectangle.bufferWidth, rectangle.bufferHeight, rectangle.colorDepth);
            compressedImage.unref();
        }

        return rectangle;
    }
View Full Code Here

    /**
     * Example.
     */
    public static void main(String args[]) {
        ByteBuffer packet = new ByteBuffer(new byte[] {0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x10, 0x00,
                0x01, 0x04, 0x0a, 0x00, 0x0c, (byte)0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});

        Element bitmap = new ServerBitmapUpdate("bitmap") {
            {
                verbose = true;
View Full Code Here

    protected void onStart() {
        super.onStart();

        // Length of packet without length field
        int length = 33 + userName.length();
        ByteBuffer buf = new ByteBuffer(length, true);

        // Type (high nibble) = 0xe = CR TPDU; credit (low nibble) = 0
        buf.writeByte(X224_TPDU_CONNECTION_REQUEST);

        buf.writeShort(0); // Destination reference = 0
        buf.writeShort(0); // Source reference = 0
        buf.writeByte(0); // Class and options = 0
        buf.writeString("Cookie: mstshash=" + userName + "\r\n", RdpConstants.CHARSET_8); // Cookie

        // RDP_NEG_REQ::type
        buf.writeByte(RdpConstants.RDP_NEG_REQ_TYPE_NEG_REQ);
        // RDP_NEG_REQ::flags (0)
        buf.writeByte(RdpConstants.RDP_NEG_REQ_FLAGS);
        // RDP_NEG_REQ::length (constant: 8) short int in LE format
        buf.writeByte(0x08);
        buf.writeByte(0x00);

        // RDP_NEG_REQ: Requested protocols: PROTOCOL_SSL
        buf.writeIntLE(protocol);

        // Calculate length of packet and prepend it to buffer
        ByteBuffer data = new ByteBuffer(5);

        // Write length
        data.writeVariableIntLE(buf.length);

        // Reset length of buffer to actual length of data written
        data.length = data.cursor;

        buf.prepend(data);
        data.unref();

        pushDataToOTOut(buf);

        switchOff();
    }
View Full Code Here

    @Override
    public void handleData(ByteBuffer aBuf, Link link) {

        // Body
        ByteBuffer buf = new ByteBuffer(1024, true);
        numberCapabilities = 0;
        writeCapabilities(buf);
        buf.trimAtCursor();

        // Header
        ByteBuffer header = createMCSHeader(buf);

        // Length of source descriptor, including NULL character (LE)
        header.writeShortLE(SOURCE_DESC.length() + 1);

        // Length of combined capabilities + 4 bytes (number of capabilities and
        // padding) (LE)
        header.writeShortLE(buf.length + 4);

        header.writeString(SOURCE_DESC, RdpConstants.CHARSET_8);
        header.writeByte(0);

        // Number of capabilities
        header.writeShortLE(numberCapabilities);

        // Padding 2 bytes
        header.writeShortLE(0);

        header.trimAtCursor();

        // Prepend header to capabilities
        buf.prepend(header);

        // Trim buffer to actual length of data written
View Full Code Here

TOP

Related Classes of streamer.ByteBuffer

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.