You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by de...@apache.org on 2014/01/02 08:53:10 UTC
[08/21] CLOUDSTACK-5344: Updated to allow rdp console to access
hyper-v vm virtual framebuffer.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java
new file mode 100755
index 0000000..12d9438
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs.java
@@ -0,0 +1,223 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.OneTimeSwitch;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import streamer.debug.MockSink;
+import streamer.debug.MockSource;
+
+/**
+ * The MCS Channel Join Request PDUs are sent sequentially. The first PDU is
+ * sent after receiving the MCS Attach User Confirm PDU and subsequent PDUs are
+ * sent after receiving the MCS Channel Join Confirm PDU for the previous
+ * request. Sending of the MCS Channel Join Request PDUs MUST continue until all
+ * channels have been successfully joined.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/cc240686.aspx
+ */
+public class ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs extends OneTimeSwitch {
+
+ private static final int MCS_CHANNEL_CONFIRM_PDU = 15;
+
+ protected int[] channels;
+ protected int channelRequestsSent = 0;
+
+ protected RdpState state;
+
+ public ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs(String id, int[] channels, RdpState state) {
+ super(id);
+ this.channels = channels;
+ this.state = state;
+ }
+
+ @Override
+ protected void handleOneTimeData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ // Parse channel confirm response
+ int typeAndFlags = buf.readUnsignedByte();
+ int type = typeAndFlags >> 2;
+ // int flags = typeAndFlags & 0x3;
+
+ if (type != MCS_CHANNEL_CONFIRM_PDU)
+ throw new RuntimeException("[" + this + "] ERROR: Incorrect type of MCS AttachUserConfirm PDU. Expected value: 15, actual value: " + type + ", data: " + buf + ".");
+
+ int rtSuccess = buf.readUnsignedByte() >> 4;
+ if (rtSuccess != 0)
+ throw new RuntimeException("[" + this + "] ERROR: Cannot connect to channel: request failed. Error code: " + rtSuccess + ", channel ID: "
+ + channels[channelRequestsSent - 1]
+ + ", data: " + buf + ".");
+
+ // Initiator and requested fields MAY be ignored, however, the channelId
+ // field MUST be examined. If the value of the channelId field does not
+ // correspond with the value of the channelId field sent in the previous MCS
+ // Channel Join Request PDU the connection SHOULD be dropped.
+
+ // Initiator: 1007 (6+1001)
+ // int initator=buf.readUnsignedShort();
+ buf.skipBytes(2);
+
+ // Requested channel
+ // int requestedChannel=buf.readUnsignedShort();
+ buf.skipBytes(2);
+
+ // Actual channel
+ int actualChannel = buf.readUnsignedShort();
+ if (actualChannel != channels[channelRequestsSent - 1])
+ throw new RuntimeException("Unexpeceted channeld ID returned. Expected channeld ID: " + channels[channelRequestsSent - 1] + ", actual channel ID: "
+ + actualChannel + ", data: " + buf + ".");
+
+ state.channelJoined(actualChannel);
+
+ buf.unref();
+
+ if (channelRequestsSent < channels.length)
+ sendChannelRequest(channels[channelRequestsSent++]);
+ else
+ switchOff();
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ sendChannelRequest(channels[channelRequestsSent++]);
+
+ // Switch off after receiving response(s)
+ }
+
+ private void sendChannelRequest(int channel) {
+ ByteBuffer buf = new ByteBuffer(5, true);
+
+ buf.writeByte(0x38); // Channel Join request
+
+ buf.writeShort(state.serverUserChannelId - 1001); // ChannelJoinRequest::initiator: 1004
+ buf.writeShort(channel);
+
+ pushDataToOTOut(buf);
+ }
+
+ /**
+ * Example.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/cc240834.aspx
+ */
+ public static void main(String args[]) {
+ // System.setProperty("streamer.Link.debug", "true");
+ System.setProperty("streamer.Element.debug", "true");
+ // System.setProperty("streamer.Pipeline.debug", "true");
+
+ /* @formatter:off */
+ byte[] clientRequestPacket = new byte[] {
+ 0x03, 0x00, 0x00, 0x0c, // TPKT Header (length = 12 bytes)
+ 0x02, (byte) 0xf0, (byte) 0x80, // X.224 Data TPDU
+
+ // PER encoded (ALIGNED variant of BASIC-PER) PDU contents:
+ 0x38, 0x00, 0x03, 0x03, (byte) 0xef,
+
+ // 0x38:
+ // 0 - --\
+ // 0 - |
+ // 1 - | CHOICE: From DomainMCSPDU select channelJoinRequest (14)
+ // 1 - | of type ChannelJoinRequest
+ // 1 - |
+ // 0 - --/
+ // 0 - padding
+ // 0 - padding
+
+ // 0x00:
+ // 0 - --\
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // | ChannelJoinRequest::initiator = 0x03 + 1001 = 1004
+ // 0x03: |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 1 - |
+ // 1 - |
+ // 0 - --/
+
+ // 0x03:
+ // 0 - --\
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 1 - |
+ // 1 - |
+ // | ChannelJoinRequest::channelId = 0x03ef = 1007
+ // 0xef: |
+ // 1 - |
+ // 1 - |
+ // 1 - |
+ // 0 - |
+ // 1 - |
+ // 1 - |
+ // 1 - |
+ // 1 - --/
+ };
+
+ byte[] serverResponsePacket = new byte[] {
+ // MCS Channel Confirm
+ (byte)0x3e,
+
+ // result: rt-successful (0)
+ (byte)0x00,
+
+ // Initiator: 1007 (6+1001)
+ (byte)0x00, (byte)0x06,
+
+ // Requested channel
+ (byte)0x03, (byte)0xef,
+
+ // Actual channel
+ (byte)0x03, (byte)0xef,
+ };
+ /* @formatter:on */
+
+ RdpState rdpState = new RdpState();
+ rdpState.serverUserChannelId = 1004;
+ MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(serverResponsePacket, new byte[] {1, 2, 3}));
+ Element todo = new ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs("channels", new int[] {1007}, rdpState);
+ Element x224 = new ClientX224DataPDU("x224");
+ Element tpkt = new ClientTpkt("tpkt");
+ Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(clientRequestPacket));
+ Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+
+ Pipeline pipeline = new PipelineImpl("test");
+ pipeline.add(source, todo, x224, tpkt, sink, mainSink);
+ pipeline.link("source", "channels", "mainSink");
+ pipeline.link("channels >" + OTOUT, "x224", "tpkt", "sink");
+ pipeline.runMainLoop("source", STDOUT, false, false);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSConnectInitial.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSConnectInitial.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSConnectInitial.java
new file mode 100755
index 0000000..37730aa
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSConnectInitial.java
@@ -0,0 +1,696 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.OneTimeSwitch;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import streamer.debug.MockSink;
+import streamer.debug.MockSource;
+
+public class ClientMCSConnectInitial extends OneTimeSwitch {
+
+ public ClientMCSConnectInitial(String id) {
+ super(id);
+ }
+
+ @Override
+ protected void handleOneTimeData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ throw new RuntimeException("Unexpected packet: " + buf + ".");
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ int length = 1024; // Large enough
+ ByteBuffer buf = new ByteBuffer(length, true);
+
+ /* @formatter:off */
+ buf.writeBytes(new byte[] {
+ (byte)0x7f, (byte)0x65, (byte)0x82, (byte)0x01, (byte)0x6d, (byte)0x04, (byte)0x01, (byte)0x01, (byte)0x04, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0xff, (byte)0x30, (byte)0x1a,
+ (byte)0x02, (byte)0x01, (byte)0x22, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02,
+ (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x30, (byte)0x19, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02,
+ (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x02,
+ (byte)0x04, (byte)0x20, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x30, (byte)0x20, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xfc,
+ (byte)0x17, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02,
+ (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x82, (byte)0x01, (byte)0x07, (byte)0x00, (byte)0x05, (byte)0x00, (byte)0x14, (byte)0x7c,
+ (byte)0x00, (byte)0x01, (byte)0x80, (byte)0xfe, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x10, (byte)0x00, (byte)0x01, (byte)0xc0, (byte)0x00, (byte)0x44, (byte)0x75, (byte)0x63, (byte)0x61,
+ (byte)0x80, (byte)0xf0, (byte)0x01, (byte)0xc0, (byte)0xd8, (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x03, (byte)0x01, (byte)0xca,
+ (byte)0x03, (byte)0xaa, (byte)0x09, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x28, (byte)0x0a, (byte)0x00, (byte)0x00, (byte)0x61, (byte)0x00, (byte)0x70, (byte)0x00, (byte)0x6f, (byte)0x00,
+ (byte)0x6c, (byte)0x00, (byte)0x6c, (byte)0x00, (byte)0x6f, (byte)0x00, (byte)0x2e, (byte)0x00, (byte)0x76, (byte)0x00, (byte)0x6c, (byte)0x00, (byte)0x69, (byte)0x00, (byte)0x73, (byte)0x00,
+ (byte)0x69, (byte)0x00, (byte)0x76, (byte)0x00, (byte)0x6b, (byte)0x00, (byte)0x61, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x0c, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0xca, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x00,
+ (byte)0x07, (byte)0x00, (byte)0x21, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x00, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0xc0, (byte)0x0c, (byte)0x00, (byte)0x0d, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0xc0, (byte)0x0c, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00,
+ });
+//
+// buf.writeBytes(new byte[] {
+//// - T125: MCSConnect Initial
+//// - MCSConnectInitial: Identifier=Generic Conference Control (0.0.20.124.0.1), ConnectPDULength=254
+//// - ConnectInitialHeader:
+// (byte)0x7F, (byte)0x65,
+//// - AsnId: Application Constructed Tag (101)
+//// - HighTag:
+//// Class: (01......) Application (1)
+//// Type: (..1.....) Constructed
+//// TagNumber: (...11111)
+//// TagValueEnd: 101 (0x65)
+// (byte)0x82, (byte)0x01, (byte)0x6C,
+//// - AsnLen: Length = 364, LengthOfLength = 2
+//// LengthType: LengthOfLength = 2
+//// Length: 364 bytes
+// (byte)0x04, (byte)0x01, (byte)0x01,
+//// - CallingDomainSelector: 0x1
+//// - AsnOctetStringHeader:
+//// - AsnId: OctetString type (Universal 4)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00100) 4
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// OctetStream: 0x1
+// (byte)0x04, (byte)0x01, (byte)0x01,
+//// - CalledDomainSelector: 0x1
+//// - AsnOctetStringHeader:
+//// - AsnId: OctetString type (Universal 4)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00100) 4
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// OctetStream: 0x1
+// (byte)0x01, (byte)0x01, (byte)0xFF,
+//// - UpwardFlag: True
+//// - AsnBooleanHeader:
+//// - AsnId: Boolean type (Universal 1)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00001) 1
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// Tf: 255 (0xFF)
+//
+////
+//// - TargetParameters: Length = 26, LengthOfLength = 0
+// (byte)0x30, (byte)0x1A,
+//// - DomainParametersHeader: 0x1
+//// - AsnId: Sequence and SequenceOf types (Universal 16)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..1.....) Constructed
+//// TagValue: (...10000) 16
+//// - AsnLen: Length = 26, LengthOfLength = 0
+//// Length: 26 bytes, LengthOfLength = 0
+// (byte)0x02, (byte)0x01, (byte)0x22,
+//// - ChannelIds: 34
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 34 (0x22)
+// (byte)0x02, (byte)0x01, (byte)0x02,
+//// - UserIDs: 2
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 2 (0x2)
+// (byte)0x02, (byte)0x01, (byte)0x00,
+//// - TokenIds: 0
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 0 (0x0)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - NumPriorities: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x01, (byte)0x00,
+//// - MinThroughput: 0
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 0 (0x0)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - Height: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xFF, (byte)0xFF,
+//// - MCSPDUsize: 65535
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 3, LengthOfLength = 0
+//// Length: 3 bytes, LengthOfLength = 0
+//// AsnInt: 65535 (0xFFFF)
+// (byte)0x02, (byte)0x01, (byte)0x02,
+//// - protocolVersion: 2
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 2 (0x2)
+//
+////
+//// - MinimumParameters: Length = 25, LengthOfLength = 0
+// (byte)0x30, (byte)0x19,
+//// - DomainParametersHeader: 0x1
+//// - AsnId: Sequence and SequenceOf types (Universal 16)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..1.....) Constructed
+//// TagValue: (...10000) 16
+//// - AsnLen: Length = 25, LengthOfLength = 0
+//// Length: 25 bytes, LengthOfLength = 0
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - ChannelIds: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - UserIDs: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - TokenIds: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - NumPriorities: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x01, (byte)0x00,
+//// - MinThroughput: 0
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 0 (0x0)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - Height: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x02, (byte)0x04, (byte)0x20,
+//// - MCSPDUsize: 1056
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 2, LengthOfLength = 0
+//// Length: 2 bytes, LengthOfLength = 0
+//// AsnInt: 1056 (0x420)
+// (byte)0x02, (byte)0x01, (byte)0x02,
+//// - protocolVersion: 2
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 2 (0x2)
+//// - MaximumParameters: Length = 31, LengthOfLength = 0
+//// - DomainParametersHeader: 0x1
+// (byte)0x30, (byte)0x1F,
+//// - AsnId: Sequence and SequenceOf types (Universal 16)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..1.....) Constructed
+//// TagValue: (...10000) 16
+//// - AsnLen: Length = 31, LengthOfLength = 0
+//// Length: 31 bytes, LengthOfLength = 0
+// (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xFF, (byte)0xFF,
+//// - ChannelIds: 65535
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 3, LengthOfLength = 0
+//// Length: 3 bytes, LengthOfLength = 0
+//// AsnInt: 65535 (0xFFFF)
+// (byte)0x02, (byte)0x02, (byte)0xFC, (byte)0x17,
+//// - UserIDs: 64535
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 2, LengthOfLength = 0
+//// Length: 2 bytes, LengthOfLength = 0
+//// AsnInt: 64535 (0xFC17)
+// (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xFF, (byte)0xFF,
+//// - TokenIds: 65535
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 3, LengthOfLength = 0
+//// Length: 3 bytes, LengthOfLength = 0
+//// AsnInt: 65535 (0xFFFF)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - NumPriorities: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x01, (byte)0x00,
+//// - MinThroughput: 0
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 0 (0x0)
+// (byte)0x02, (byte)0x01, (byte)0x01,
+//// - Height: 1
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 1 (0x1)
+// (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xFF, (byte)0xFF,
+//// - MCSPDUsize: 65535
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 3, LengthOfLength = 0
+//// Length: 3 bytes, LengthOfLength = 0
+//// AsnInt: 65535 (0xFFFF)
+// (byte)0x02, (byte)0x01, (byte)0x02,
+//// - protocolVersion: 2
+//// - AsnIntegerHeader:
+//// - AsnId: Integer type (Universal 2)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00010) 2
+//// - AsnLen: Length = 1, LengthOfLength = 0
+//// Length: 1 bytes, LengthOfLength = 0
+//// AsnInt: 2 (0x2)
+//// - UserData: Identifier=Generic Conference Control (0.0.20.124.0.1), ConnectPDULength=254
+//// - UserDataHeader:
+// (byte)0x04, (byte)0x82, (byte)0x01, (byte)0x07,
+//// - AsnId: OctetString type (Universal 4)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00100) 4
+//// - AsnLen: Length = 263, LengthOfLength = 2
+//// LengthType: LengthOfLength = 2
+//// Length: 263 bytes
+// (byte)0x00, (byte)0x05, (byte)0x00, (byte)0x14, (byte)0x7C, (byte)0x00, (byte)0x01,
+//// - AsnBerObjectIdentifier: Generic Conference Contro (0.0.20.124.0.1)
+//// - AsnObjectIdentifierHeader:
+//// - AsnId: Reserved for use by the encoding rules (Universal 0)
+//// - LowTag:
+//// Class: (00......) Universal (0)
+//// Type: (..0.....) Primitive
+//// TagValue: (...00000) 0
+//// - AsnLen: Length = 5, LengthOfLength = 0
+//// Length: 5 bytes, LengthOfLength = 0
+//// First: 0 (0x0)
+//// Final: 20 (0x14)
+//// Final: 124 (0x7C)
+//// Final: 0 (0x0)
+//// Final: 1 (0x1)
+// (byte)0x80, (byte)0xFE,
+//// - ConnectPDULength: 254
+//// Align: No Padding
+//// Length: 254
+// (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x10,
+//// - ConnectGCCPDU: conferenceCreateRequest
+//// ExtensionBit: 0 (0x0)
+//// - ChoiceValue: conferenceCreateRequest
+//// Value: (000.....) 0x0
+//// - conferenceCreateRequest:
+//// ExtensionBit: 0 (0x0)
+//// convenerPasswordPresent: 0 (0x0)
+//// passwordPresent: 0 (0x0)
+//// conductorPrivilegesPresent: 0 (0x0)
+//// conductedPrivilegesPresent: 0 (0x0)
+//// nonConductedPrivilegesPresent: 0 (0x0)
+//// conferenceDescriptionPresent: 0 (0x0)
+//// callerIdentifierPresent: 0 (0x0)
+//// userDataPresent: 1 (0x1)
+//// - conferenceName:
+//// ExtensionBit: 0 (0x0)
+//// textPresent: 0 (0x0)
+//// - numeric: 1
+//// - SimpleNumericString: 1
+//// - NumericString: 1
+//// - Align: No Padding
+//// Padding1: (0.......) 0x0
+//// - Length: 1
+//// Value: (00000000) 0x0
+//// - Restrictedstr: 1
+//// FourBits: (0001....) 0x1
+//// - lockedConference: False
+//// Value: False 0.......
+//// - listedConference: False
+//// Value: False 0.......
+//// - conductibleConference: False
+//// Value: False 0.......
+//// - TerminationMethod: automatic
+//// ExtensionBit: 0 (0x0)
+//// - RootIndex: 0
+//// Value: (0.......) 0x0
+//// - userData:
+// (byte)0x00, (byte)0x01,
+//// - Size: 1
+//// - Align: No Padding
+//// Padding7: (0000000.) 0x0
+//// Length: 1
+//// - UserData: 0x44756361
+// (byte)0xC0, (byte)0x00, (byte)0x44, (byte)0x75, (byte)0x63, (byte)0x61,
+//// valuePresent: 1 (0x1)
+//// - key: h221NonStandard "Duca"
+//// - ChoiceValue: h221NonStandard
+//// Value: (1.......) 0x1
+//// - h221NonStandard:
+//// - H221NonStandardIdentifier: length: 4
+//// - ConstrainedLength: 4
+//// Value: (00000000) 0x0
+//// - Align: No Padding
+//// Padding6: (000000..) 0x0
+//// Value: Binary Large Object (4 Bytes) "Duca"
+//// - ClientMcsConnectInitialPdu:
+// (byte)0x80, (byte)0xF0,
+//// - RDPGCCUserDataRequestLength: 240
+//// Align: No Padding
+//// Length: 240
+//// - TsUd: CS_CORE
+// (byte)0x01, (byte)0xC0, (byte)0xD8, (byte)0x00,
+//// - TsUdHeader: Type = CS_CORE, Length = 216
+//// Type: CS_CORE
+//// Length: 216 (0xD8)
+//// - TsUdCsCore:
+// (byte)0x04, (byte)0x00, (byte)0x08, (byte)0x00,
+//// Version: RDP 5.0, 5.1, 5.2, 6.0, 6.1, and 7.0
+// (byte)0x00, (byte)0x04,
+//// DesktopWidth: 1024 (0x400)
+// (byte)0x00, (byte)0x03,
+//// DesktopHeight: 768 (0x300)
+// (byte)0x01, (byte)0xCA,
+//// ColorDepth: 8 bpp
+// (byte)0x03, (byte)0xAA,
+//// SASSequence: 0xaa03, SHOULD be set to RNS_UD_SAS_DEL(0xAA03)
+// (byte)0x09, (byte)0x04, (byte)0x00, (byte)0x00,
+//// KeyboardLayout: Language: English, Location: United States
+// (byte)0x28, (byte)0x0A, (byte)0x00, (byte)0x00,
+//// ClientBuild: 2600 (0xA28)
+// (byte)0x61, (byte)0x00, (byte)0x70, (byte)0x00, (byte)0x6F, (byte)0x00, (byte)0x6C, (byte)0x00, (byte)0x6C, (byte)0x00, (byte)0x6F, (byte)0x00, (byte)0x33, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// ClientName: apollo3
+// (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// KeyboardType: Undefined value: 0
+// (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// KeyboardSubType: 0 (0x0)
+// (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// KeyboardFunctionKey: 0 (0x0)
+// (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// ImeFileName:
+// (byte)0x01, (byte)0xCA,
+//// PostBeta2ColorDepth: 8 bpp
+// (byte)0x01, (byte)0x00,
+//// ClientProductId: 0x1, SHOULD be set to initialized to 1
+// (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// SerialNumber: 0x0, SHOULD be set to 0
+// (byte)0x10, (byte)0x00,
+//// HighColorDepth: 16-bit 565 RGB
+// (byte)0x07, (byte)0x00,
+//// - SupportedColorDepth: 7 (0x7)
+//// Support24BPP: (...............1) Support 24BPP
+//// Support16BPP: (..............1.) Support 16BPP
+//// Support15BPP: (.............1..) Support 15BPP
+//// Support32BPP: (............0...) Not Support 32BPP
+//// Reserved: (000000000000....)
+// (byte)0x01, (byte)0x00,
+//// - EarlyCapabilityFlags: 1 (0x1)
+//// SupportSetErrorPdu: (...............1) Indicates that the client supports the Set Error Info PDU
+//// Want32BppSession: (..............0.) Client is not requesting 32BPP session
+//// SupportStatusInfoPdu: (.............0..) Client not supports the Server Status Info PDU
+//// StrongAsymmetricKeys: (............0...) Not support asymmetric keys larger than 512-bits
+//// Unused: (...........0....)
+//// ValidConnection: (..........0.....) Not Indicates ConnectionType field contains valid data
+//// SupportMonitorLayoutPdu: (.........0......) Not Indicates that the client supports the Monitor Layout PDU
+//// Unused2: (000000000.......)
+// (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// ClientDigProductId:
+//(byte)0x00,
+//// connectionType: invalid connection type
+//(byte)0x00,
+//// pad1octet: 0 (0x0)
+//(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00,
+//// ServerSelectedProtocols: TLS 1.0
+////
+//// - TsUd: CS_CLUSTER
+//// - TsUdHeader: Type = CS_CLUSTER, Length = 12
+//(byte)0x04, (byte)0xC0,
+//// Type: CS_CLUSTER
+//(byte)0x0C, (byte)0x00,
+//// Length: 12 (0xC)
+//(byte)0x0D, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// - TsUdCsCluster:
+//// - Flags: 13 (0xD)
+//// RedirectedSupported: (...............................1) Support Redirected
+//// SessionIDFieldValid: (..............................0.) SessionID Field not Valid
+//// SupportedVersion: (..........................0011..) REDIRECTION_VERSION4
+//// RedirectedSmartcard: (.........................0......) Not Logon with Smartcard
+//// Unused: (0000000000000000000000000.......)
+//// RedirectedSessionID: 0 (0x0)
+////
+//// - TsUd: CS_SECURITY
+//// - TsUdHeader: Type = CS_SECURITY, Length = 12
+//(byte)0x02, (byte)0xC0,
+//// Type: CS_SECURITY
+//(byte)0x0C, (byte)0x00,
+//// Length: 12 (0xC)
+////
+//// - TsUdCsSec:
+//(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// - EncryptionMethod:
+//// Support40Bit: (...............................0) Not Support
+//// Support128Bit: (..............................0.) Not Support 128-bit
+//// Reserved1: (.............................0..)
+//// Support56Bit: (............................0...) Not Support 56-bit
+//// SupportFIPS: (...........................0....) Not Support FIPS Compliant
+//// Reserved2: (000000000000000000000000000.....)
+//(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+//// - ExtEncryptionMethod:
+//// Support40Bit: (...............................0) Not Support
+//// Support128Bit: (..............................0.) Not Support 128-bit
+//// Reserved1: (.............................0..)
+//// Support56Bit: (............................0...) Not Support 56-bit
+//// SupportFIPS: (...........................0....) Not Support FIPS Compliant
+//// Reserved2: (000000000000000000000000000.....)
+// });
+ /* @formatter:on */
+
+ buf.trimAtCursor();
+
+ pushDataToOTOut(buf);
+
+ switchOff();
+ }
+
+ /**
+ * Example.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/cc240836.aspx
+ */
+ public static void main(String args[]) {
+ // System.setProperty("streamer.Link.debug", "true");
+ System.setProperty("streamer.Element.debug", "true");
+ // System.setProperty("streamer.Pipeline.debug", "true");
+
+ /* @formatter:off */
+ byte[] packet = new byte[] {
+ // TPKT: TPKT version = 3
+ (byte) 0x03, (byte) 0x00,
+ // TPKT: Packet length: 378 bytes
+ (byte) 0x01, (byte) 0x78,
+
+ // X.224: Length indicator = 2
+ (byte) 0x02,
+ // X.224: Type: Data TPDU
+ (byte) 0xf0,
+ // X.224: EOT
+ (byte) 0x80,
+
+ // Captured packet
+ (byte)0x7f, (byte)0x65, (byte)0x82, (byte)0x01, (byte)0x6c, (byte)0x04, (byte)0x01, (byte)0x01, (byte)0x04,
+ (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0xff, (byte)0x30, (byte)0x1a, (byte)0x02, (byte)0x01, (byte)0x22, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x02, (byte)0x01, (byte)0x00,
+ (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x01,
+ (byte)0x02, (byte)0x30, (byte)0x19, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02,
+ (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x02, (byte)0x04, (byte)0x20, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x30, (byte)0x1f, (byte)0x02, (byte)0x03,
+ (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x02, (byte)0xfc, (byte)0x17, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02,
+ (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x82, (byte)0x01,
+ (byte)0x07, (byte)0x00, (byte)0x05, (byte)0x00, (byte)0x14, (byte)0x7c, (byte)0x00, (byte)0x01, (byte)0x80, (byte)0xfe, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x10, (byte)0x00, (byte)0x01,
+ (byte)0xc0, (byte)0x00, (byte)0x44, (byte)0x75, (byte)0x63, (byte)0x61, (byte)0x80, (byte)0xf0, (byte)0x01, (byte)0xc0, (byte)0xd8, (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x08, (byte)0x00,
+ (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x03, (byte)0x01, (byte)0xca, (byte)0x03, (byte)0xaa, (byte)0x09, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x28, (byte)0x0a, (byte)0x00, (byte)0x00,
+ (byte)0x61, (byte)0x00, (byte)0x70, (byte)0x00, (byte)0x6f, (byte)0x00, (byte)0x6c, (byte)0x00, (byte)0x6c, (byte)0x00, (byte)0x6f, (byte)0x00, (byte)0x33, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0xca, (byte)0x01, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x00, (byte)0x07, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x04, (byte)0xc0, (byte)0x0c, (byte)0x00, (byte)0x0d, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0xc0, (byte)0x0c, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ };
+ /* @formatter:on */
+
+ MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+ Element todo = new ClientMCSConnectInitial("ClientMCSConnectInitial");
+ Element x224 = new ClientX224DataPDU("x224");
+ Element tpkt = new ClientTpkt("tpkt");
+
+ Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(packet));
+
+ Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+
+ Pipeline pipeline = new PipelineImpl("test");
+ pipeline.add(source, todo, x224, tpkt, sink, mainSink);
+ pipeline.link("source", "ClientMCSConnectInitial", "mainSink");
+ pipeline.link("ClientMCSConnectInitial >" + OTOUT, "x224", "tpkt", "sink");
+ pipeline.runMainLoop("source", STDOUT, false, false);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSErectDomainRequest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSErectDomainRequest.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSErectDomainRequest.java
new file mode 100755
index 0000000..a6ea406
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientMCSErectDomainRequest.java
@@ -0,0 +1,189 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.OneTimeSwitch;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import streamer.debug.MockSink;
+import streamer.debug.MockSource;
+
+/**
+ * @see http://msdn.microsoft.com/en-us/library/cc240683.aspx
+ */
+public class ClientMCSErectDomainRequest extends OneTimeSwitch {
+
+ public ClientMCSErectDomainRequest(String id) {
+ super(id);
+ }
+
+ @Override
+ protected void handleOneTimeData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ throw new RuntimeException("Unexpected packet: " + buf + ".");
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ int length = 5;
+ ByteBuffer buf = new ByteBuffer(length, true);
+
+ buf.writeByte(0x04); // Erect Domain Request
+
+ // Client SHOULD initialize both the subHeight and subinterval fields of the MCS Erect Domain Request PDU to zero.
+
+ buf.writeByte(1); // ErectDomainRequest::subHeight length = 1 byte
+ buf.writeByte(0); // ErectDomainRequest::subHeight
+
+ buf.writeByte(1); // ErectDomainRequest::subInterval length = 1 byte
+ buf.writeByte(0); // ErectDomainRequest::subInterval
+
+ pushDataToOTOut(buf);
+
+ switchOff();
+ }
+
+ /**
+ * Example.
+ * @see http://msdn.microsoft.com/en-us/library/cc240837.aspx
+ */
+ public static void main(String args[]) {
+ // System.setProperty("streamer.Link.debug", "true");
+ System.setProperty("streamer.Element.debug", "true");
+ // System.setProperty("streamer.Pipeline.debug", "true");
+
+ /* @formatter:off */
+ byte[] packet = new byte[] {
+
+ 0x03, 0x00, 0x00, 0x0c, // TPKT Header (length = 12 bytes)
+ 0x02, (byte) 0xf0, (byte) 0x80, // X.224 Data TPDU
+
+ // PER encoded (ALIGNED variant of BASIC-PER) PDU contents:
+ 0x04, 0x01, 0x00, 0x01, 0x00,
+
+ // 0x04:
+ // 0 - --\
+ // 0 - |
+ // 0 - | CHOICE: From DomainMCSPDU select erectDomainRequest (1)
+ // 0 - | of type ErectDomainRequest
+ // 0 - |
+ // 1 - --/
+ // 0 - padding
+ // 0 - padding
+
+ // 0x01:
+ // 0 - --\
+ // 0 - |
+ // 0 - |
+ // 0 - | ErectDomainRequest::subHeight length = 1 byte
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 1 - --/
+
+ // 0x00:
+ // 0 - --\
+ // 0 - |
+ // 0 - |
+ // 0 - | ErectDomainRequest::subHeight = 0
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - --/
+
+ // 0x01:
+ // 0 - --\
+ // 0 - |
+ // 0 - |
+ // 0 - | ErectDomainRequest::subInterval length = 1 byte
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 1 - --/
+
+ // 0x00:
+ // 0 - --\
+ // 0 - |
+ // 0 - |
+ // 0 - | ErectDomainRequest::subInterval = 0
+ // 0 - |
+ // 0 - |
+ // 0 - |
+ // 0 - --/
+
+
+ };
+ /* @formatter:on */
+
+ MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+ Element todo = new ClientMCSErectDomainRequest("TODO");
+ Element x224 = new ClientX224DataPDU("x224");
+ Element tpkt = new ClientTpkt("tpkt");
+ Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(packet));
+ Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+
+ Pipeline pipeline = new PipelineImpl("test");
+ pipeline.add(source, todo, x224, tpkt, sink, mainSink);
+ pipeline.link("source", "TODO", "mainSink");
+ pipeline.link("TODO >" + OTOUT, "x224", "tpkt", "sink");
+ pipeline.runMainLoop("source", STDOUT, false, false);
+ }
+
+}
+
+/*
+ * 03 00 00 0C 02 F0 80 04 01 00 01 00
+
+ Frame: Number = 14, Captured Frame Length = 69, MediaType = DecryptedPayloadHeader
++ DecryptedPayloadHeader: FrameCount = 1, ErrorStatus = SUCCESS
+ TLSSSLData: Transport Layer Security (TLS) Payload Data
++ TLS: TLS Rec Layer-1 SSL Application Data
+ ISOTS: TPKTCount = 1
+- TPKT: version: 3, Length: 12
+ version: 3 (0x3)
+ Reserved: 0 (0x0)
+ PacketLength: 12 (0xC)
+- X224: Data
+ Length: 2 (0x2)
+ Type: Data
+ EOT: 128 (0x80)
+- T125: Erect Domain Request, SubHeight = 0, SubInterval = 0
+ - MCSHeader: Type=Erect Domain Request
+ - Type: Erect Domain Request
+ - RootIndex: 1
+ Value: (000001..) 0x1
+ - MCSErectDomainRequest: SubHeight = 0, SubInterval = 0
+ - SubHeight: 0x0
+ - Length: 1
+ - Align: No Padding
+ Padding2: (00......) 0x0
+ Length: 1
+ Value: 0 (0x0)
+ - SubInterval: 0x0
+ - Length: 1
+ Align: No Padding
+ Length: 1
+ Value: 0 (0x0)
+
+ */
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java
new file mode 100755
index 0000000..c9d8d0c
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientSynchronizePDU.java
@@ -0,0 +1,248 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.OneTimeSwitch;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import streamer.debug.MockSink;
+import streamer.debug.MockSource;
+
+/**
+ * @see http://msdn.microsoft.com/en-us/library/cc240489.aspx
+ */
+public class ClientSynchronizePDU extends OneTimeSwitch {
+
+ public ClientSynchronizePDU(String id) {
+ super(id);
+ }
+
+ @Override
+ protected void handleOneTimeData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ throw new RuntimeException("Unexpected packet: " + buf + ".");
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ int length = 1024; // Large enough
+ 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,
+ // Data length: 22 bytes (0x16, variable length field)
+ (byte)0x80, (byte)0x16,
+
+ // RDP: total length: 22 bytes (LE)
+ (byte)0x16, (byte)0x00,
+
+ // PDU type: PDUTYPE_DATAPDU (0x7), TS_PROTOCOL_VERSION (0x10) (LE)
+ (byte)0x17, (byte)0x00,
+
+ // PDU source: 1007 (LE)
+ (byte)0xec, (byte)0x03,
+ // Share ID: 0x000103ea (LE)
+ (byte)0xea, (byte)0x03, (byte)0x01, (byte)0x00,
+ // Padding: 1 byte
+ (byte)0x00,
+ // Stream ID: STREAM_LOW (1)
+ (byte)0x01,
+ // uncompressedLength : 8 bytes (LE)
+ (byte)0x08, (byte)0x00,
+ // pduType2 = PDUTYPE2_SYNCHRONIZE (31)
+ (byte)0x1f,
+ // generalCompressedType: 0
+ (byte)0x00,
+ // generalCompressedLength: 0 (LE?)
+ (byte)0x00, (byte)0x00,
+ // messageType: SYNCMSGTYPE_SYNC (1) (LE)
+ (byte)0x01, (byte)0x00,
+ // targetUser: 0x03ea
+ (byte)0xea, (byte)0x03,
+ });
+ /* @formatter:on */
+
+ // Trim buffer to actual length of data written
+ buf.trimAtCursor();
+
+ pushDataToOTOut(buf);
+
+ switchOff();
+ }
+
+ /**
+ * Example.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/cc240841.aspx
+ */
+ public static void main(String args[]) {
+ // System.setProperty("streamer.Link.debug", "true");
+ System.setProperty("streamer.Element.debug", "true");
+ // System.setProperty("streamer.Pipeline.debug", "true");
+
+ /* @formatter:off */
+ byte[] packet = new byte[] {
+ // TPKT
+ (byte)0x03, (byte)0x00,
+ // TPKT length: 37 bytes
+ (byte)0x00, (byte)0x25,
+ // X224 Data PDU
+ (byte)0x02, (byte)0xf0, (byte)0x80,
+
+ // 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,
+ // Data length: 22 bytes (0x16, variable length field)
+ (byte)0x80, (byte)0x16,
+
+ // RDP: total length: 22 bytes (LE)
+ (byte)0x16, (byte)0x00,
+ // PDU type: PDUTYPE_DATAPDU (0x7), TS_PROTOCOL_VERSION (0x10) (LE)
+ (byte)0x17, (byte)0x00,
+ // PDU source: 1007 (LE)
+ (byte)0xec, (byte)0x03,
+ // Share ID: 0x000103ea (LE)
+ (byte)0xea, (byte)0x03, (byte)0x01, (byte)0x00,
+ // Padding: 1 byte
+ (byte)0x00,
+ // Stream ID: STREAM_LOW (1)
+ (byte)0x01,
+ // uncompressedLength : 8 bytes (LE)
+ (byte)0x08, (byte)0x00,
+ // pduType2 = PDUTYPE2_SYNCHRONIZE (31)
+ (byte)0x1f,
+ // generalCompressedType: 0
+ (byte)0x00,
+ // generalCompressedLength: 0 (LE?)
+ (byte)0x00, (byte)0x00,
+ // messageType: SYNCMSGTYPE_SYNC (1) (LE)
+ (byte)0x01, (byte)0x00,
+ // targetUser: 0x03ea
+ (byte)0xea, (byte)0x03,
+
+ };
+ /* @formatter:on */
+
+ MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+ Element todo = new ClientSynchronizePDU("TODO");
+ Element x224 = new ClientX224DataPDU("x224");
+ Element tpkt = new ClientTpkt("tpkt");
+ Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(packet));
+ Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+
+ Pipeline pipeline = new PipelineImpl("test");
+ pipeline.add(source, todo, x224, tpkt, sink, mainSink);
+ pipeline.link("source", "TODO", "mainSink");
+ pipeline.link("TODO >" + OTOUT, "x224", "tpkt", "sink");
+ pipeline.runMainLoop("source", STDOUT, false, false);
+ }
+
+}
+
+/*
+ * @formatting:off
+
+ * 03 00 00 25 02 F0 80 64 00 03 03 EB 70 80 16 16 00 17 00 EC 03 EA 03 01 00 00 01 08 00 1F 00 00 00 01 00 EA 03
+
+ Frame: Number = 40, Captured Frame Length = 94, MediaType = DecryptedPayloadHeader
++ DecryptedPayloadHeader: FrameCount = 1, ErrorStatus = SUCCESS
+ TLSSSLData: Transport Layer Security (TLS) Payload Data
++ TLS: TLS Rec Layer-1 SSL Application Data
+ ISOTS: TPKTCount = 1
+- TPKT: version: 3, Length: 37
+ version: 3 (0x3)
+ Reserved: 0 (0x0)
+ PacketLength: 37 (0x25)
+- X224: Data
+ Length: 2 (0x2)
+ Type: Data
+ EOT: 128 (0x80)
+- T125: Data Packet
+ - MCSHeader: Type=Send Data Request, UserID=1004, ChannelID=1003
+ - Type: Send Data Request
+ - RootIndex: 25
+ Value: (011001..) 0x19
+ - UserID: 0x3ec
+ - UserID: 0x3ec
+ - ChannelId: 1004
+ - Align: No Padding
+ Padding2: (00......) 0x0
+ Value: 3 (0x3)
+ - Channel: 0x3eb
+ - ChannelId: 1003
+ Align: No Padding
+ Value: 1003 (0x3EB)
+ - DataPriority: high
+ - DataPriority: high
+ - RootIndex: 1
+ Value: (01......) 0x1
+ - Segmentation: Begin End
+ Begin: (1.......) Begin
+ End: (.1......) End
+ - Length: 22
+ - Align: No Padding
+ Padding4: (0000....) 0x0
+ Length: 22
+ RDP: RDPBCGR
+- RDPBCGR: SynchronizePDU
+ - SlowPathPacket: SynchronizePDU
+ - SlowPath: Type = TS_PDUTYPE_DATAPDU
+ - TsShareControlHeader: Type = TS_PDUTYPE_DATAPDU
+ TotalLength: 22 (0x16)
+ - PDUType: 23 (0x17)
+ Type: (............0111) TS_PDUTYPE_DATAPDU
+ ProtocolVersion: (000000000001....) 1
+ PDUSource: 1004 (0x3EC)
+ - SlowPathIoPacket: 0x0
+ - ShareDataHeader: TS_PDUTYPE2_SYNCHRONIZE
+ ShareID: 66538 (0x103EA)
+ Pad1: 0 (0x0)
+ StreamID: TS_STREAM_LOW
+ UncompressedLength: 8 (0x8)
+ PDUType2: TS_PDUTYPE2_SYNCHRONIZE
+ - CompressedType: Not Compressed
+ MPPC: (....0000) MPPC 8K
+ Reserved: (...0....)
+ Compressed: (..0.....) Not Compressed
+ Front: (.0......) Not At Front
+ Flush: (0.......) Not Flushed
+ CompressedLength: 0 (0x0)
+ - TsSynchronizePDU: 0x1
+ MessageType: 0x1, MUST be set to SYNCMSGTYPE_SYNC (1)
+ TargetUser: 1002 (0x3EA)
+ */
+
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientTpkt.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientTpkt.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientTpkt.java
new file mode 100755
index 0000000..926c807
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientTpkt.java
@@ -0,0 +1,54 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.BaseElement;
+import streamer.ByteBuffer;
+import streamer.Link;
+
+public class ClientTpkt extends BaseElement {
+
+ public ClientTpkt(String id) {
+ super(id);
+ }
+
+ @Override
+ public void handleData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ if (verbose)
+ System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
+
+ if (buf.length + 4 > 65535)
+ throw new RuntimeException("Packet is too long for TPKT (max length 65535-4): " + buf + ".");
+
+ ByteBuffer data = new ByteBuffer(4);
+ // TPKT version
+ data.writeByte(3);
+ // Reserved
+ data.writeByte(0);
+ // Packet length, including length of the header
+ data.writeShort(buf.length + 4);
+
+ buf.prepend(data);
+ data.unref();
+
+ pushDataToPad(STDOUT, buf);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224ConnectionRequestPDU.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224ConnectionRequestPDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224ConnectionRequestPDU.java
new file mode 100755
index 0000000..6413432
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224ConnectionRequestPDU.java
@@ -0,0 +1,162 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.ByteBuffer;
+import streamer.Element;
+import streamer.Link;
+import streamer.OneTimeSwitch;
+import streamer.Pipeline;
+import streamer.PipelineImpl;
+import streamer.debug.MockSink;
+import streamer.debug.MockSource;
+
+/**
+ * @see http://msdn.microsoft.com/en-us/library/cc240470.aspx
+ * @see http://msdn.microsoft.com/en-us/library/cc240663.aspx
+ */
+public class ClientX224ConnectionRequestPDU extends OneTimeSwitch {
+
+ public static final int X224_TPDU_CONNECTION_REQUEST = 0xe0;
+ public static final int X224_TPDU_CONNECTION_CONFIRM = 0xd0;
+ public static final int X224_TPDU_DISCONNECTION_REQUEST = 0x80;
+ public static final int X224_TPDU_DISCONNECTION_CONFIRM = 0xc0;
+ public static final int X224_TPDU_EXPEDITED_DATA = 0x10;
+ public static final int X224_TPDU_DATA_ACKNOWLEDGE = 0x61;
+ public static final int X224_TPDU_EXPEDITET_ACKNOWLEDGE = 0x40;
+ public static final int X224_TPDU_REJECT = 0x51;
+ public static final int X224_TPDU_ERROR = 0x70;
+ public static final int X224_TPDU_PROTOCOL_IDENTIFIER = 0x01;
+
+ /**
+ * Reconnection cookie.
+ */
+ protected String userName;
+
+ /**
+ * Protocol to use: RDP_NEG_REQ_PROTOCOL_SSL or RDP_NEG_REQ_PROTOCOL_HYBRID.
+ */
+ protected int protocol;
+
+ public ClientX224ConnectionRequestPDU(String id, String userName, int protocol) {
+ super(id);
+ this.userName = userName;
+ this.protocol = protocol;
+ }
+
+ @Override
+ protected void handleOneTimeData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ throw new RuntimeException("Unexpected packet: " + buf + ".");
+ }
+
+ @Override
+ 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();
+ }
+
+ /**
+ * Example.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/cc240842.aspx
+ * @see http://msdn.microsoft.com/en-us/library/cc240500.aspx
+ */
+ public static void main(String args[]) {
+ // System.setProperty("streamer.Link.debug", "true");
+ System.setProperty("streamer.Element.debug", "true");
+ // System.setProperty("streamer.Pipeline.debug", "true");
+
+ String cookie = "eltons";
+
+ byte[] packet = new byte[] {
+
+ 0x03, // TPKT Header: version = 3
+ 0x00, // TPKT Header: Reserved = 0
+ 0x00, // TPKT Header: Packet length - high part
+ 0x2c, // TPKT Header: Packet length - low part (total = 44 bytes)
+ 0x27, // X.224: Length indicator (39 bytes)
+ (byte)0xe0, // X.224: Type (high nibble) = 0xe = CR TPDU;
+ // credit (low nibble) = 0
+ 0x00, 0x00, // X.224: Destination reference = 0
+ 0x00, 0x00, // X.224: Source reference = 0
+ 0x00, // X.224: Class and options = 0
+
+ 'C', 'o', 'o', 'k', 'i', 'e', ':', ' ', 'm', 's', 't', 's', 'h', 'a', 's', 'h', '=', 'e', 'l', 't', 'o', 'n', 's', // "Cookie: mstshash=eltons"
+ '\r', '\n', // -Cookie terminator sequence
+
+ 0x01, // RDP_NEG_REQ::type (TYPE_RDP_NEG_REQ)
+ 0x00, // RDP_NEG_REQ::flags (0)
+ 0x08, 0x00, // RDP_NEG_REQ::length (8 bytes)
+ 0x01, 0x00, 0x00, 0x00 // RDP_NEG_REQ: Requested protocols
+ // (PROTOCOL_SSL in little endian format)
+ };
+
+ MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+ Element cr = new ClientX224ConnectionRequestPDU("cr", cookie, RdpConstants.RDP_NEG_REQ_PROTOCOL_SSL);
+ Element tpkt = new ClientTpkt("tpkt");
+ Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(packet));
+ Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {1, 2, 3}));
+
+ Pipeline pipeline = new PipelineImpl("test");
+ pipeline.add(source, cr, tpkt, sink, mainSink);
+ pipeline.link("source", "cr", "mainSink");
+ pipeline.link("cr >" + OTOUT, "tpkt", "sink");
+ pipeline.runMainLoop("source", STDOUT, false, false);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c47101/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224DataPDU.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224DataPDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224DataPDU.java
new file mode 100755
index 0000000..b0373ad
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/rdp/ClientX224DataPDU.java
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package rdpclient.rdp;
+
+import streamer.BaseElement;
+import streamer.ByteBuffer;
+import streamer.Link;
+
+public class ClientX224DataPDU extends BaseElement {
+
+ public static final int X224_TPDU_DATA = 0xF0;
+ public static final int X224_TPDU_LAST_DATA_UNIT = 0x80;
+
+ public ClientX224DataPDU(String id) {
+ super(id);
+ }
+
+ @Override
+ public void handleData(ByteBuffer buf, Link link) {
+ if (buf == null)
+ return;
+
+ if (verbose)
+ System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
+
+ ByteBuffer data = new ByteBuffer(3);
+ // X224 header
+ data.writeByte(2); // Header length indicator
+ data.writeByte(X224_TPDU_DATA);
+ data.writeByte(X224_TPDU_LAST_DATA_UNIT);
+
+ buf.prepend(data);
+ data.unref();
+
+ pushDataToPad(STDOUT, buf);
+ }
+
+}