Search in sources :

Example 61 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientConfirmActivePDU method handleData.

@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
    buf.trimAtCursor();
    pushDataToPad(STDOUT, buf);
    sendOtherRequredPackets();
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 62 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientConfirmActivePDU method createMCSHeader.

private ByteBuffer createMCSHeader(ByteBuffer buf) {
    ByteBuffer header = new ByteBuffer(100);
    // MCS Send Data Request
    header.writeByte(0x64);
    // Initiator: 1004 (1001+3)
    header.writeShort(3);
    // Channel ID: 1003 (I/O channel)
    header.writeShort(RdpConstants.CHANNEL_IO);
    // Data priority: high (0x40), segmentation: begin (0x20) | end (0x10)
    header.writeByte(0x70);
    int length = buf.length + 26;
    // User data length: (variable length field, LE)
    header.writeVariableShort(length);
    // Total length: (LE)
    header.writeShortLE(length);
    // PDU type: Confirm Active PDU (0x3), TS_PROTOCOL_VERSION (0x10) (LE)
    header.writeShortLE(0x13);
    // PDU source: 1004 (LE)
    header.writeShortLE(1004);
    // Share ID, e.g. 0x000103ea (LE)
    header.writeIntLE((int) state.serverShareId);
    // Originator ID: 1002 (LE)
    header.writeShortLE(1002);
    return header;
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 63 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientConfirmActivePDU method sendControlPDUActionCooperate.

private void sendControlPDUActionCooperate() {
    // Large enough
    int length = 1024;
    ByteBuffer buf = new ByteBuffer(length, true);
    /* @formatter:off */
    buf.writeBytes(new byte[] { // MCS Send Data Request
    (byte) 0x64, // Initiator: 1004 (1001+3)
    (byte) 0x00, (byte) 0x03, // Channel ID: 1003 (I/O channel)
    (byte) 0x03, (byte) 0xeb, // Data priority: high (0x40), segmentation: begin (0x20) | end (0x10)
    (byte) 0x70, // User data length: 26 bytes (0x1a, variable length field)
    (byte) 0x80, (byte) 0x1a, // Total length: 26 bytes (0x1a, LE)
    (byte) 0x1a, (byte) 0x00, // PDU type: PDUTYPE_DATAPDU (0x7), PDU version: 1 (0x0010) (LE)
    (byte) 0x17, (byte) 0x00, // PDU source: 1004 (LE)
    (byte) 0xec, (byte) 0x03 });
    // Share ID, 4 bytes  (LE)
    buf.writeIntLE((int) state.serverShareId);
    buf.writeBytes(new byte[] { // Padding 1 byte
    (byte) 0x00, // Stream ID: STREAM_LOW (1)
    (byte) 0x01, // uncompressedLength : 12 bytes (LE)
    (byte) 0x0c, (byte) 0x00, // pduType2: PDUTYPE2_CONTROL (20)
    (byte) 0x14, // generalCompressedType: 0
    (byte) 0x00, // generalCompressedLength: 0 (LE?)
    (byte) 0x00, (byte) 0x00, // action: CTRLACTION_COOPERATE (4) (LE)
    (byte) 0x04, (byte) 0x00, // grantId: 0 (LE)
    (byte) 0x00, (byte) 0x00, // controlId: 0
    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 });
    /* @formatter:on */
    buf.trimAtCursor();
    pushDataToPad(STDOUT, buf);
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 64 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientConfirmActivePDU method sendControlPDUActionRequestControl.

private void sendControlPDUActionRequestControl() {
    // Large enough
    int length = 1024;
    ByteBuffer buf = new ByteBuffer(length, true);
    /* @formatter:off */
    buf.writeBytes(new byte[] { // MCS Send Data Request
    (byte) 0x64, // Initiator: 1004 (1001+3)
    (byte) 0x00, (byte) 0x03, // Channel ID: 1003 (I/O channel)
    (byte) 0x03, (byte) 0xeb, // Data priority: high (0x40), segmentation: begin (0x20) | end (0x10)
    (byte) 0x70, // User data length: 26 bytes (0x1a, variable length field)
    (byte) 0x80, (byte) 0x1a, // Total length: 26 bytes (0x1a, LE)
    (byte) 0x1a, (byte) 0x00, // PDU type: PDUTYPE_DATAPDU (0x7), PDU version: 1 (0x0010) (LE)
    (byte) 0x17, (byte) 0x00, // PDU source: 1004 (LE)
    (byte) 0xec, (byte) 0x03 });
    // Share ID, 4 bytes  (LE)
    buf.writeIntLE((int) state.serverShareId);
    buf.writeBytes(new byte[] { // Padding 1 byte
    (byte) 0x00, // Stream ID: STREAM_LOW (1)
    (byte) 0x01, // uncompressedLength : 12 bytes (LE)
    (byte) 0x0c, (byte) 0x00, // pduType2: PDUTYPE2_CONTROL (20)
    (byte) 0x14, // generalCompressedType: 0
    (byte) 0x00, // generalCompressedLength: 0 (LE)
    (byte) 0x00, (byte) 0x00, // action: CTRLACTION_REQUEST_CONTROL (1) (LE)
    (byte) 0x01, (byte) 0x00, // grantId: 0 (LE)
    (byte) 0x00, (byte) 0x00, // controlId: 0 (LE)
    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 });
    /* @formatter:on */
    // Trim buffer to actual length of data written
    buf.trimAtCursor();
    pushDataToPad(STDOUT, buf);
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 65 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientFastPathPDU method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    if (buf.length > 32767 - 3)
        throw new RuntimeException("Packet is too long: " + buf + ".");
    ByteBuffer data = new ByteBuffer(6);
    // FastPath, 1 event, no checksum, not encrypted
    data.writeByte(0x4);
    // Length of full packet, including length field, in network order.
    // Topmost bit of first byte indicates that field has 2 bytes
    data.writeShort((1 + 2 + buf.length) | 0x8000);
    data.trimAtCursor();
    buf.prepend(data);
    pushDataToAllOuts(buf);
}
Also used : ByteBuffer(streamer.ByteBuffer)

Aggregations

ByteBuffer (streamer.ByteBuffer)110 Element (streamer.Element)12 BaseElement (streamer.BaseElement)9 Pipeline (streamer.Pipeline)7 PipelineImpl (streamer.PipelineImpl)7 TSRequest (rdpclient.ntlmssp.asn1.TSRequest)6 MockSink (streamer.debug.MockSink)5 MockSource (streamer.debug.MockSource)5 BitmapRectangle (common.BitmapRectangle)3 ScreenDescription (common.ScreenDescription)3 SyncLink (streamer.SyncLink)3 AssertingByteBuffer (streamer.debug.AssertingByteBuffer)3 BitmapOrder (common.BitmapOrder)2 KeyOrder (common.KeyOrder)2 MouseOrder (common.MouseOrder)2 NegoItem (rdpclient.ntlmssp.asn1.NegoItem)2 Link (streamer.Link)2 FakeSink (streamer.debug.FakeSink)2 BufferedImageCanvas (common.BufferedImageCanvas)1 CopyRectOrder (common.CopyRectOrder)1