Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B23F010BDC for ; Mon, 23 Dec 2013 09:16:06 +0000 (UTC) Received: (qmail 47141 invoked by uid 500); 23 Dec 2013 09:13:57 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 46664 invoked by uid 500); 23 Dec 2013 09:13:14 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 46550 invoked by uid 99); 23 Dec 2013 09:12:58 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Dec 2013 09:12:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 60C6C82BC6E; Mon, 23 Dec 2013 09:12:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: devdeep@apache.org To: commits@cloudstack.apache.org Date: Mon, 23 Dec 2013 09:13:10 -0000 Message-Id: <1ef47a222ada4d5e8e6315cfc8d9ff95@git.apache.org> In-Reply-To: <33588344be7742c7825dfb633d396983@git.apache.org> References: <33588344be7742c7825dfb633d396983@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/22] CLOUDSTACK-5344: Update to allow rdp console to access hyper-v vm virtual framebuffer. http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerDemandActivePDU.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerDemandActivePDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerDemandActivePDU.java deleted file mode 100644 index 9ce87d3..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerDemandActivePDU.java +++ /dev/null @@ -1,661 +0,0 @@ -// 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; - -import streamer.BaseElement; -import streamer.ByteBuffer; -import streamer.Element; -import streamer.FakeSink; -import streamer.Link; -import streamer.MockSource; -import streamer.Order; -import streamer.Pipeline; -import streamer.PipelineImpl; - -import common.ScreenDescription; - -/** - * @see http://msdn.microsoft.com/en-us/library/cc240669.aspx - * @see http://msdn.microsoft.com/en-us/library/cc240484.aspx - */ -public class ServerDemandActivePDU extends BaseElement { - - /** - * Demand Active PDU. - */ - public static final int PDUTYPE_DEMANDACTIVEPDU = 0x1; - - protected RdpState state; - protected ScreenDescription screen; - - public ServerDemandActivePDU(String id, ScreenDescription screen, RdpState state) { - super(id); - this.state = state; - this.screen = screen; - } - - @Override - public void handleData(ByteBuffer buf, Link link) { - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - // Total length of packet - int length = buf.readSignedShortLE(); // Ignore - if (buf.length != length) - throw new RuntimeException("Incorrect length of packet. Length: " + length + ", data: " + buf + "."); - - int type = buf.readSignedShortLE() & 0xf; - if (type != PDUTYPE_DEMANDACTIVEPDU) - throw new RuntimeException("Unknown PDU type. Expected type: Demand Active PDU (0x1), actual tyoe: " + type + ", data: " + buf + "."); - - // TS_SHARECONTROLHEADER::pduSource = 0x03ea (1002) - int pduSource = buf.readSignedShortLE(); - if (pduSource != 1002) - throw new RuntimeException("Unexepcted source of demand active PDU. Expected source: 1002, actual source: " + pduSource + "."); - - // (4 bytes): A 32-bit, unsigned integer. The share identifier for the - // packet (see [T128] section 8.4.2 for more information regarding share - // IDs). - long shareId = buf.readUnsignedIntLE(); - state.serverShareId = shareId; - - // Ignore rest of server data because it is not used by this client. - // (2 bytes): A 16-bit, unsigned integer. The size in bytes of the - // sourceDescriptor field. - int lengthSourceDescriptor = buf.readUnsignedShortLE(); - - // (2 bytes): A 16-bit, unsigned integer. The combined size in bytes of the - // numberCapabilities, pad2Octets, and capabilitySets fields. - int lengthCombinedCapabilities = buf.readUnsignedShortLE(); - - // (variable): A variable-length array of bytes containing a source - // descriptor, - // ByteBuffer sourceDescriptor = buf.readBytes(lengthSourceDescriptor); - buf.skipBytes(lengthSourceDescriptor); - - // (variable): An array of Capability Set (section 2.2.1.13.1.1.1) - // structures. The number of capability sets is specified by the - // numberCapabilities field. - handleCapabiltySets(buf.readBytes(lengthCombinedCapabilities)); - - // (4 bytes): A 32-bit, unsigned integer. The session identifier. This field - // is ignored by the client. - buf.skipBytes(4); - - /* DEBUG */buf.assertThatBufferIsFullyRead(); - - buf.unref(); - - sendHandshakePackets(); - } - - /** - * General Capability Set - */ - public static final int CAPSTYPE_GENERAL = 0x0001; - /** - * Bitmap Capability Set - */ - public static final int CAPSTYPE_BITMAP = 0x0002; - /** - * Order Capability Set - */ - public static final int CAPSTYPE_ORDER = 0x0003; - /** - * Revision 1 Bitmap Cache Capability Set - */ - public static final int CAPSTYPE_BITMAPCACHE = 0x0004; - /** - * Control Capability Set - */ - public static final int CAPSTYPE_CONTROL = 0x0005; - /** - * Window Activation Capability Set - */ - public static final int CAPSTYPE_ACTIVATION = 0x0007; - /** - * Pointer Capability Set - */ - public static final int CAPSTYPE_POINTER = 0x0008; - /** - * Share Capability Set - */ - public static final int CAPSTYPE_SHARE = 0x0009; - /** - * Color Table Cache Capability Set - */ - public static final int CAPSTYPE_COLORCACHE = 0x000A; - /** - * Sound Capability Set - */ - public static final int CAPSTYPE_SOUND = 0x000C; - /** - * Input Capability Set - */ - public static final int CAPSTYPE_INPUT = 0x000D; - /** - * Font Capability Set - */ - public static final int CAPSTYPE_FONT = 0x000E; - /** - * Brush Capability Set - */ - public static final int CAPSTYPE_BRUSH = 0x000F; - /** - * Glyph Cache Capability Set - */ - public static final int CAPSTYPE_GLYPHCACHE = 0x0010; - /** - * Offscreen Bitmap Cache Capability Set - */ - public static final int CAPSTYPE_OFFSCREENCACHE = 0x0011; - /** - * Bitmap Cache Host Support Capability Set - */ - public static final int CAPSTYPE_BITMAPCACHE_HOSTSUPPORT = 0x0012; - /** - * Revision 2 Bitmap Cache Capability Set - */ - public static final int CAPSTYPE_BITMAPCACHE_REV2 = 0x0013; - /** - * Virtual Channel Capability Set - */ - public static final int CAPSTYPE_VIRTUALCHANNEL = 0x0014; - /** - * DrawNineGrid Cache Capability Set - */ - public static final int CAPSTYPE_DRAWNINEGRIDCACHE = 0x0015; - /** - * Draw GDI+ Cache Capability Set - */ - public static final int CAPSTYPE_DRAWGDIPLUS = 0x0016; - /** - * Remote Programs Capability Set - */ - public static final int CAPSTYPE_RAIL = 0x0017; - /** - * Window List Capability Set - */ - public static final int CAPSTYPE_WINDOW = 0x0018; - /** - * Desktop Composition Extension Capability Set - */ - public static final int CAPSETTYPE_COMPDESK = 0x0019; - /** - * Multifragment Update Capability Set - */ - public static final int CAPSETTYPE_MULTIFRAGMENTUPDATE = 0x001A; - /** - * Large Pointer Capability Set - */ - public static final int CAPSETTYPE_LARGE_POINTER = 0x001B; - /** - * Surface Commands Capability Set - */ - public static final int CAPSETTYPE_SURFACE_COMMANDS = 0x001C; - /** - * Bitmap Codecs Capability Set - */ - public static final int CAPSETTYPE_BITMAP_CODECS = 0x001D; - /** - * Frame Acknowledge Capability Set - */ - public static final int CAPSSETTYPE_FRAME_ACKNOWLEDGE = 0x001E; - - /** - * @see http://msdn.microsoft.com/en-us/library/cc240486.aspx - */ - protected void handleCapabiltySets(ByteBuffer buf) { - // (2 bytes): A 16-bit, unsigned integer. The number of capability sets - // included in the Demand Active PDU. - int numberCapabilities = buf.readSignedShortLE(); - - // (2 bytes): Padding. - buf.skipBytes(2); - - for (int i = 0; i < numberCapabilities; i++) { - // (2 bytes): A 16-bit, unsigned integer. The type identifier of the - // capability set. - int capabilitySetType = buf.readUnsignedShortLE(); - - // (2 bytes): A 16-bit, unsigned integer. The length in bytes of the - // capability data, including the size of the capabilitySetType and - // lengthCapability fields. - int lengthCapability = buf.readUnsignedShortLE(); - - // (variable): Capability set data which conforms to the structure of the - // type given by the capabilitySetType field. - ByteBuffer capabilityData = buf.readBytes(lengthCapability - 4); - - switch (capabilitySetType) { - case CAPSTYPE_GENERAL: - break; - case CAPSTYPE_BITMAP: - handleBitmapCapabilities(capabilityData); - break; - case CAPSTYPE_ORDER: - break; - case CAPSTYPE_BITMAPCACHE: - break; - case CAPSTYPE_CONTROL: - break; - case CAPSTYPE_ACTIVATION: - break; - case CAPSTYPE_POINTER: - break; - case CAPSTYPE_SHARE: - break; - case CAPSTYPE_COLORCACHE: - break; - case CAPSTYPE_SOUND: - break; - case CAPSTYPE_INPUT: - break; - case CAPSTYPE_FONT: - break; - case CAPSTYPE_BRUSH: - break; - case CAPSTYPE_GLYPHCACHE: - break; - case CAPSTYPE_OFFSCREENCACHE: - break; - case CAPSTYPE_BITMAPCACHE_HOSTSUPPORT: - break; - case CAPSTYPE_BITMAPCACHE_REV2: - break; - case CAPSTYPE_VIRTUALCHANNEL: - break; - case CAPSTYPE_DRAWNINEGRIDCACHE: - break; - case CAPSTYPE_DRAWGDIPLUS: - break; - case CAPSTYPE_RAIL: - break; - case CAPSTYPE_WINDOW: - break; - case CAPSETTYPE_COMPDESK: - break; - case CAPSETTYPE_MULTIFRAGMENTUPDATE: - break; - case CAPSETTYPE_LARGE_POINTER: - break; - case CAPSETTYPE_SURFACE_COMMANDS: - break; - case CAPSETTYPE_BITMAP_CODECS: - break; - case CAPSSETTYPE_FRAME_ACKNOWLEDGE: - break; - default: - // Ignore - break; - } - - capabilityData.unref(); - } - - // TODO - - buf.unref(); - } - - /** - * @see http://msdn.microsoft.com/en-us/library/cc240554.aspx - */ - protected void handleBitmapCapabilities(ByteBuffer buf) { - - // (2 bytes): A 16-bit, unsigned integer. The server MUST set this field to - // the color depth of the session, while the client SHOULD set this field to - // the color depth requested in the Client Core Data (section 2.2.1.3.2). - int preferredBitsPerPixel = buf.readUnsignedShortLE(); - screen.setPixelFormatRGBTrueColor(preferredBitsPerPixel); - - // receive1BitPerPixel (2 bytes): A 16-bit, unsigned integer. Indicates - // whether the client can receive 1 bpp. This field is ignored and SHOULD be - // set to TRUE (0x0001). - buf.skipBytes(2); - - // receive4BitsPerPixel(2 bytes): A 16-bit, unsigned integer. Indicates - // whether the client can receive 4 bpp. This field is ignored and SHOULD be - // set to TRUE (0x0001). - buf.skipBytes(2); - - // receive8BitsPerPixel (2 bytes): A 16-bit, unsigned integer. Indicates - // whether the client can receive 8 bpp. This field is ignored and SHOULD be - // set to TRUE (0x0001). - buf.skipBytes(2); - - // (2 bytes): A 16-bit, unsigned integer. The width of the desktop in the - // session. - int desktopWidth = buf.readUnsignedShortLE(); - - // (2 bytes): A 16-bit, unsigned integer. The height of the desktop in the - // session. - int desktopHeight = buf.readUnsignedShortLE(); - - screen.setFramebufferSize(desktopWidth, desktopHeight); - - // pad2octets (2 bytes): A 16-bit, unsigned integer. Padding. Values in this - // field MUST be ignored. - - // desktopResizeFlag (2 bytes): A 16-bit, unsigned integer. Indicates - // whether resizing the desktop by using a Deactivation-Reactivation - // Sequence is supported. - - // bitmapCompressionFlag (2 bytes): A 16-bit, unsigned integer. Indicates - // whether bitmap compression is supported. This field MUST be set to TRUE - // (0x0001) because support for compressed bitmaps is required for a - // connection to proceed. - - // highColorFlags (1 byte): An 8-bit, unsigned integer. Client support for - // 16 bpp color modes. This field is ignored and SHOULD be set to zero. - - // drawingFlags (1 byte): An 8-bit, unsigned integer. Flags describing - // support for 32 bpp bitmaps. - - // multipleRectangleSupport (2 bytes): A 16-bit, unsigned integer. Indicates - // whether the use of multiple bitmap rectangles is supported in the Bitmap - // Update (section 2.2.9.1.1.3.1.2). This field MUST be set to TRUE (0x0001) - // because multiple rectangle support is required for a connection to - // proceed. - - // pad2octetsB (2 bytes): A 16-bit, unsigned integer. Padding. Values in - // this field MUST be ignored. - } - - /** - * Send all client requests in one hop, to simplify logic. - */ - protected void sendHandshakePackets() { - // Send reactivation sequence in bulk - pushDataToPad("confirm_active", new ByteBuffer((Order) null)); - } - - /** - * Example. - * - */ - 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[] { - 0x67, 0x01, // TS_SHARECONTROLHEADER::totalLength = 0x0167 = 359 bytes - 0x11, 0x00, // TS_SHARECONTROLHEADER::pduType = 0x0011 0x0011 = 0x0010 | 0x0001 = TS_PROTOCOL_VERSION | PDUTYPE_DEMANDACTIVEPDU - - (byte) 0xea, 0x03, // TS_SHARECONTROLHEADER::pduSource = 0x03ea (1002) - - (byte) 0xea, 0x03, 0x01, 0x00, // TS_DEMAND_ACTIVE_PDU::shareId - 0x04, 0x00, // TS_DEMAND_ACTIVE_PDU::lengthSourceDescriptor = 4 bytes - 0x51, 0x01, // TS_DEMAND_ACTIVE_PDU::lengthCombinedCapabilities = 0x151 = 337 bytes - - 0x52, 0x44, 0x50, 0x00, // TS_DEMAND_ACTIVE_PDU::sourceDescriptor = "RDP" - - 0x0d, 0x00, // TS_DEMAND_ACTIVE_PDU::numberCapabilities = 13 - 0x00, 0x00, // TS_DEMAND_ACTIVE_PDU::pad2octets - - // Share Capability Set (8 bytes) - // 0x09, 0x00, 0x08, 0x00, (byte) 0xea, 0x03, (byte) 0xdc, (byte) 0xe2, - // - 0x09, 0x00, // TS_SHARE_CAPABILITYSET::capabilitySetType = CAPSTYPE_SHARE (9) - 0x08, 0x00, // TS_SHARE_CAPABILITYSET::lengthCapability = 8 bytes - (byte) 0xea, 0x03, // TS_SHARE_CAPABILITYSET::nodeID = 0x03ea (1002) - (byte) 0xdc, (byte) 0xe2, // TS_SHARE_CAPABILITYSET::pad2octets - - // General Capability Set (24 bytes) - // 0x01, 0x00, 0x18, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x04, - // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - // - 0x01, 0x00, // TS_GENERAL_CAPABILITYSET::capabilitySetType = CAPSTYPE_GENERAL (1) - 0x18, 0x00, // TS_GENERAL_CAPABILITYSET::lengthCapability = 24 bytes - - 0x01, 0x00, // TS_GENERAL_CAPABILITYSET::osMajorType = TS_OSMAJORTYPE_WINDOWS (1) - 0x03, 0x00, // TS_GENERAL_CAPABILITYSET::osMinorType = TS_OSMINORTYPE_WINDOWS_NT (3) - 0x00, 0x02, // TS_GENERAL_CAPABILITYSET::protocolVersion = TS_CAPS_PROTOCOLVERSION (0x0200) - 0x00, 0x00, // TS_GENERAL_CAPABILITYSET::pad2octetsA - 0x00, 0x00, // TS_GENERAL_CAPABILITYSET::generalCompressionTypes = 0 - 0x1d, 0x04, // TS_GENERAL_CAPABILITYSET::extraFlags = 0x041d = 0x0400 | 0x0010 | 0x0008 | 0x0004 | 0x0001 = NO_BITMAP_COMPRESSION_HDR | ENC_SALTED_CHECKSUM | AUTORECONNECT_SUPPORTED | LONG_CREDENTIALS_SUPPORTED | FASTPATH_OUTPUT_SUPPORTED - - 0x00, 0x00, // TS_GENERAL_CAPABILITYSET::updateCapabilityFlag = 0 - 0x00, 0x00, // TS_GENERAL_CAPABILITYSET::remoteUnshareFlag = 0 - 0x00, 0x00, // TS_GENERAL_CAPABILITYSET::generalCompressionLevel = 0 - 0x01, // TS_GENERAL_CAPABILITYSET::refreshRectSupport = TRUE - 0x01, // TS_GENERAL_CAPABILITYSET::suppressOutputSupport = TRUE - - // Virtual Channel Capability Set (8 bytes) - // 0x14, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, - // - 0x14, 0x00, // TS_VIRTUALCHANNEL_CAPABILITYSET::capabilitySetType = CAPSTYPE_VIRTUALCHANNEL (20) - 0x08, 0x00, // TS_VIRTUALCHANNEL_CAPABILITYSET::lengthCapability = 8 bytes - - 0x02, 0x00, 0x00, 0x00, // TS_VIRTUALCHANNEL_CAPABILITYSET::vccaps1 = 0x00000002 = VCCAPS_COMPR_CS_8K - - // DrawGdiPlus Capability Set (40 bytes) - // 0x16, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, (byte) 0xf6, 0x13, (byte) 0xf3, 0x01, 0x00, 0x00, 0x00, - // 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, (byte) 0x9c, (byte) 0xf6, 0x13, (byte) 0xf3, 0x61, (byte) 0xa6, (byte) 0x82, (byte) 0x80, - // 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, (byte) 0x91, (byte) 0xbf, - // - 0x16, 0x00, // TS_DRAW_GDIPLUS_CAPABILITYSET::capabilitySetType = CAPSTYPE_DRAWGDIPLUS (22) - 0x28, 0x00, // TS_DRAW_GDIPLUS_CAPABILITYSET::lengthCapability = 40 bytes - - 0x00, 0x00, 0x00, 0x00, // TS_DRAW_GDIPLUS_CAPABILITYSET::drawGdiplusSupportLevel = TS_DRAW_GDIPLUS_DEFAULT (0) - 0x70, (byte) 0xf6, 0x13, (byte) 0xf3, // TS_DRAW_GDIPLUS_CAPABILITYSET::GdipVersion (not initialized by server) - 0x01, 0x00, 0x00, 0x00, // TS_DRAW_GDIPLUS_CAPABILITYSET::drawGdiplusCacheLevel = TS_DRAW_GDIPLUS_CACHE_LEVEL_ONE (1) - - 0x01, 0x00, // TS_GDIPLUS_CACHE_ENTRIES::GdipGraphicsCacheEntries (not initialized by server) - 0x00, 0x00, // TS_GDIPLUS_CACHE_ENTRIES::GdipObjectBrushCacheEntries (not initialized by server) - 0x18, 0x00, // TS_GDIPLUS_CACHE_ENTRIES::GdipObjectPenCacheEntries (not initialized by server) - 0x00, 0x00, // TS_GDIPLUS_CACHE_ENTRIES::GdipObjectImageCacheEntries (not initialized by server) - (byte) 0x9c, (byte) 0xf6, // TS_GDIPLUS_CACHE_ENTRIES::GdipObjectImageAttributesCacheEntries (not initialized by server) - - 0x13, (byte) 0xf3, // TS_GDIPLUS_CACHE_CHUNK_SIZE::GdipGraphicsCacheChunkSize (not initialized by server) - 0x61, (byte) 0xa6, // TS_GDIPLUS_CACHE_CHUNK_SIZE::GdipObjectBrushCacheChunkSize (not initialized by server) - (byte) 0x82, (byte) 0x80, // TS_GDIPLUS_CACHE_CHUNK_SIZE::GdipObjectPenCacheChunkSize (not initialized by server) - 0x00, 0x00, // TS_GDIPLUS_CACHE_CHUNK_SIZE::GdipObjectImageAttributesCacheChunkSize (not initialized by server) - - 0x00, 0x00, // TS_GDIPLUS_IMAGE_CACHE_PROPERTIES::GdipObjectImageCacheChunkSize (not initialized by server) - 0x00, 0x50, // TS_GDIPLUS_IMAGE_CACHE_PROPERTIES::GdipObjectImageCacheTotalSize (not initialized by server) - (byte) 0x91, (byte) 0xbf, // TS_GDIPLUS_IMAGE_CACHE_PROPERTIES::GdipObjectImageCacheMaxSize (not initialized by server) - - // Font Capability Set (4 bytes) - // 0x0e, 0x00, 0x04, 0x00, - // - // Due to a bug, the TS_FONT_CAPABILITYSET capability set size is incorrectly set to 4 bytes (it must be 8 bytes). As a result of this bug, the fontSupportFlags and pad2octets fields are missing. - 0x0e, 0x00, // TS_FONT_CAPABILITYSET::capabilitySetType = CAPSTYPE_FONT (14) - 0x04, 0x00, // TS_FONT_CAPABILITYSET::lengthCapability = 4 bytes - - - // Bitmap Capability Set (28 bytes) - // 0x02, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, - // 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - // - 0x02, 0x00, // TS_BITMAP_CAPABILITYSET::capabilitySetType = CAPSTYPE_BITMAP (2) - 0x1c, 0x00, // TS_BITMAP_CAPABILITYSET::lengthCapability = 28 bytes - - 0x18, 0x00, // TS_BITMAP_CAPABILITYSET::preferredBitsPerPixel = 24 bpp - 0x01, 0x00, // TS_BITMAP_CAPABILITYSET::receive1BitPerPixel = TRUE - 0x01, 0x00, // TS_BITMAP_CAPABILITYSET::receive4BitsPerPixel = TRUE - 0x01, 0x00, // TS_BITMAP_CAPABILITYSET::receive8BitsPerPixel = TRUE - 0x00, 0x05, // TS_BITMAP_CAPABILITYSET::desktopWidth = 1280 pixels - 0x00, 0x04, // TS_BITMAP_CAPABILITYSET::desktopHeight = 1024 pixels - 0x00, 0x00, // TS_BITMAP_CAPABILITYSET::pad2octets - 0x01, 0x00, // TS_BITMAP_CAPABILITYSET::desktopResizeFlag = TRUE - 0x01, 0x00, // TS_BITMAP_CAPABILITYSET::bitmapCompressionFlag = TRUE - 0x00, // TS_BITMAP_CAPABILITYSET::highColorFlags = 0 - 0x00, // TS_BITMAP_CAPABILITYSET::pad1octet - 0x01, 0x00, // TS_BITMAP_CAPABILITYSET::multipleRectangleSupport = TRUE - 0x00, 0x00, // TS_BITMAP_CAPABILITYSET::pad2octetsB - - // Order Capability Set (88 bytes) - // 0x03, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // 0x00, 0x00, 0x00, 0x00, 0x40, 0x42, 0x0f, 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, - // 0x00, 0x00, 0x22, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - // 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - // 0x00, 0x00, 0x00, 0x00, (byte) 0xa1, 0x06, 0x00, 0x00, 0x40, 0x42, 0x0f, 0x00, 0x40, 0x42, 0x0f, 0x00, - // 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // - 0x03, 0x00, // TS_ORDER_CAPABILITYSET::capabilitySetType = CAPSTYPE_ORDER (3) - 0x58, 0x00, // TS_ORDER_CAPABILITYSET::lengthCapability = 88 bytes - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // TS_ORDER_CAPABILITYSET::terminalDescriptor = "" - 0x40, 0x42, 0x0f, 0x00, // TS_ORDER_CAPABILITYSET::pad4octetsA - - 0x01, 0x00, // TS_ORDER_CAPABILITYSET::desktopSaveXGranularity = 1 - 0x14, 0x00, // TS_ORDER_CAPABILITYSET::desktopSaveYGranularity = 20 - 0x00, 0x00, // TS_ORDER_CAPABILITYSET::pad2octetsA - 0x01, 0x00, // TS_ORDER_CAPABILITYSET::maximumOrderLevel = ORD_LEVEL_1_ORDERS (1) - 0x00, 0x00, // TS_ORDER_CAPABILITYSET::numberFonts = 0 - - 0x22, 0x00, // TS_ORDER_CAPABILITYSET::orderFlags = 0x0022 = 0x0020 | 0x0002 = COLORINDEXSUPPORT | NEGOTIATEORDERSUPPORT - - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_DSTBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_PATBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_SCRBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MEMBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MEM3BLT_INDEX] = TRUE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_ATEXTOUT_INDEX] = FALSE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_AEXTTEXTOUT_INDEX] = FALSE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_DRAWNINEGRID_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_LINETO_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MULTI_DRAWNINEGRID_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_OPAQUERECT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_SAVEBITMAP_INDEX] = TRUE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_WTEXTOUT_INDEX] = FALSE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MEMBLT_R2_INDEX] = FALSE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MEM3BLT_R2_INDEX] = FALSE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MULTIDSTBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MULTIPATBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MULTISCRBLT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_MULTIOPAQUERECT_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_FAST_INDEX_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_POLYGON_SC_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_POLYGON_CB_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_POLYLINE_INDEX] = TRUE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[23] = 0 - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_FAST_GLYPH_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_ELLIPSE_SC_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_ELLIPSE_CB_INDEX] = TRUE - 0x01, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_INDEX_INDEX] = TRUE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_WEXTTEXTOUT_INDEX] = FALSE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_WLONGTEXTOUT_INDEX] = FALSE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[TS_NEG_WLONGEXTTEXTOUT_INDEX] = FALSE - 0x00, // TS_ORDER_CAPABILITYSET::orderSupport[24] = 0 - - (byte) 0xa1, 0x06, // TS_ORDER_CAPABILITYSET::textFlags = 0x06a1 - - 0x00, 0x00, // TS_ORDER_CAPABILITYSET::pad2octetsB - 0x40, 0x42, 0x0f, 0x00, // TS_ORDER_CAPABILITYSET::pad4octetsB - - 0x40, 0x42, 0x0f, 0x00, // TS_ORDER_CAPABILITYSET::desktopSaveSize = 0xf4240 = 1000000 - 0x01, 0x00, // TS_ORDER_CAPABILITYSET::pad2octetsC - 0x00, 0x00, // TS_ORDER_CAPABILITYSET::pad2octetsD - 0x00, 0x00, // TS_ORDER_CAPABILITYSET::textANSICodePage - 0x00, 0x00, // TS_ORDER_CAPABILITYSET::pad2octetsE - - // Color Table Cache Capability Set (8 bytes) - // 0x0a, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - // - 0x0a, 0x00, // TS_COLORTABLECACHE_CAPABILITYSET::capabilitySetType = CAPSTYPE_COLORCACHE (10) - 0x08, 0x00, // TS_COLORTABLECACHE_CAPABILITYSET::lengthCapability = 8 bytes - - 0x06, 0x00, // TS_COLORTABLECACHE_CAPABILITYSET::colorTableCacheSize = 6 - 0x00, 0x00, // TS_COLORTABLECACHE_CAPABILITYSET::pad2octets - - // Bitmap Cache Host Support Capability Set (8 bytes) - // 0x12, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, - // - 0x12, 0x00, // TS_BITMAPCACHE_CAPABILITYSET_HOSTSUPPORT::capabilitySetType = CAPSTYPE_BITMAPCACHE_HOSTSUPPORT (18) - 0x08, 0x00, // TS_BITMAPCACHE_CAPABILITYSET_HOSTSUPPORT::lengthCapability = 8 bytes - - 0x01, // TS_BITMAPCACHE_CAPABILITYSET_HOSTSUPPORT::CacheVersion = 1 (corresponds to rev. 2 capabilities) - 0x00, // TS_BITMAPCACHE_CAPABILITYSET_HOSTSUPPORT::Pad1 - 0x00, 0x00, // TS_BITMAPCACHE_CAPABILITYSET_HOSTSUPPORT::Pad2 - - // Pointer Capability Set (10 bytes) - // 0x08, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x19, 0x00, 0x19, 0x00, - // - 0x08, 0x00, // TS_POINTER_CAPABILITYSET::capabilitySetType = CAPSTYPE_POINTER (8) - 0x0a, 0x00, // TS_POINTER_CAPABILITYSET::lengthCapability = 10 bytes - - 0x01, 0x00, // TS_POINTER_CAPABILITYSET::colorPointerFlag = TRUE - 0x19, 0x00, // TS_POINTER_CAPABILITYSET::colorPointerCacheSize = 25 - 0x19, 0x00, // TS_POINTER_CAPABILITYSET::pointerCacheSize = 25 - - // Input Capability Set (88 bytes) - // 0x0d, 0x00, 0x58, 0x00, 0x35, 0x00, 0x00, 0x00, (byte) 0xa1, 0x06, 0x00, 0x00, 0x40, 0x42, 0x0f, 0x00, - // 0x0c, (byte) 0xf6, 0x13, (byte) 0xf3, (byte) 0x93, 0x5a, 0x37, (byte) 0xf3, 0x00, (byte) 0x90, 0x30, (byte) 0xe1, 0x34, 0x1c, 0x38, (byte) 0xf3, - // 0x40, (byte) 0xf6, 0x13, (byte) 0xf3, 0x04, 0x00, 0x00, 0x00, 0x4c, 0x54, (byte) 0xdc, (byte) 0xe2, 0x08, 0x50, (byte) 0xdc, (byte) 0xe2, - // 0x01, 0x00, 0x00, 0x00, 0x08, 0x50, (byte) 0xdc, (byte) 0xe2, 0x00, 0x00, 0x00, 0x00, 0x38, (byte) 0xf6, 0x13, (byte) 0xf3, - // 0x2e, 0x05, 0x38, (byte) 0xf3, 0x08, 0x50, (byte) 0xdc, (byte) 0xe2, 0x2c, (byte) 0xf6, 0x13, (byte) 0xf3, 0x00, 0x00, 0x00, 0x00, - // 0x08, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x19, 0x00, - // - 0x0d, 0x00, // TS_INPUT_CAPABILITYSET::capabilitySetType = CAPSTYPE_INPUT (13) - 0x58, 0x00, // TS_INPUT_CAPABILITYSET::lengthCapability = 88 bytes - - 0x35, 0x00, // TS_INPUT_CAPABILITYSET::inputFlags = 0x0035 = 0x0020 | 0x0010 | 0x0004 | 0x0001 = INPUT_FLAG_FASTPATH_INPUT2 | INPUT_FLAG_VKPACKET | INPUT_FLAG_MOUSEX | INPUT_FLAG_SCANCODES - - 0x00, 0x00, // TS_INPUT_CAPABILITYSET::pad2octetsA - (byte) 0xa1, 0x06, 0x00, 0x00, // TS_INPUT_CAPABILITYSET::keyboardLayout (not initialized by server) - 0x40, 0x42, 0x0f, 0x00, // TS_INPUT_CAPABILITYSET::keyboardType (not initialized by server) - 0x0c, (byte) 0xf6, 0x13, (byte) 0xf3, // TS_INPUT_CAPABILITYSET::keyboardSubType (not initialized by server) - (byte) 0x93, 0x5a, 0x37, (byte) 0xf3, // TS_INPUT_CAPABILITYSET::keyboardFunctionKey (not initialized by server) - - // TS_INPUT_CAPABILITYSET::imeFileName (not initialized by server) - 0x00, (byte) 0x90, 0x30, (byte) 0xe1, 0x34, 0x1c, 0x38, (byte) 0xf3, 0x40, (byte) 0xf6, 0x13, (byte) 0xf3, 0x04, 0x00, 0x00, 0x00, - 0x4c, 0x54, (byte) 0xdc, (byte) 0xe2, 0x08, 0x50, (byte) 0xdc, (byte) 0xe2, 0x01, 0x00, 0x00, 0x00, 0x08, 0x50, (byte) 0xdc, (byte) 0xe2, - 0x00, 0x00, 0x00, 0x00, 0x38, (byte) 0xf6, 0x13, (byte) 0xf3, 0x2e, 0x05, 0x38, (byte) 0xf3, 0x08, 0x50, (byte) 0xdc, (byte) 0xe2, - 0x2c, (byte) 0xf6, 0x13, (byte) 0xf3, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x19, 0x00, - - // RAIL Capability Set (8 bytes) - // 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, - // - 0x17, 0x00, // TS_RAIL_CAPABILITYSET::capabilitySetType = CAPSTYPE_RAIL (23) - 0x08, 0x00, // TS_RAIL_CAPABILITYSET::lengthCapability = 8 bytes - - 0x00, 0x00, 0x00, 0x00, // TS_RAIL_CAPABILITYSET::railSupportLevel = TS_RAIL_LEVEL_DEFAULT (0) - - // Windowing Capability Set (11 bytes) - // 0x18, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // - 0x18, 0x00, // TS_WINDOW_CAPABILITYSET::capabilitySetType = CAPSTYPE_WINDOW (24) - 0x0b, 0x00, // TS_WINDOW_CAPABILITYSET::lengthCapability = 11 bytes - - 0x00, 0x00, 0x00, 0x00, // TS_WINDOW_CAPABILITYSET::wndSupportLevel = TS_WINDOW_LEVEL_DEFAULT (0) - 0x00, // TS_WINDOW_CAPABILITYSET::nIconCaches = 0 - 0x00, 0x00, // TS_WINDOW_CAPABILITYSET::nIconCacheEntries = 0 - - // Remainder of Demand Active PDU: - - 0x00, 0x00, 0x00, 0x00, // TS_DEMAND_ACTIVE_PDU::sessionId = 0 - }; - /* @formatter:on */ - - RdpState rdpState = new RdpState(); - ScreenDescription screenDescription = new ScreenDescription(); - - MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet)); - Element demandActive = new ServerDemandActivePDU("demand_active", screenDescription, rdpState); - Element sink = new FakeSink("sink"); - - Pipeline pipeline = new PipelineImpl("test"); - pipeline.add(source, demandActive, sink); - pipeline.link("source", "demand_active", "sink"); - pipeline.runMainLoop("source", STDOUT, false, false); - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerFastPath.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerFastPath.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerFastPath.java deleted file mode 100644 index fbec1ce..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerFastPath.java +++ /dev/null @@ -1,259 +0,0 @@ -// 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; - -import streamer.BaseElement; -import streamer.ByteBuffer; -import streamer.Link; - -/** - * @see http://msdn.microsoft.com/en-us/library/cc240621.aspx - */ -public class ServerFastPath extends BaseElement { - - /** - * TPKT protocol version (first byte). - */ - public static final int PROTOCOL_TPKT = 3; - - /** - * Fast path protocol version (first two bits of first byte). - */ - public static final int PROTOCOL_FASTPATH = 0; - - - /** - * TPKT packets will be pushed to that pad. - */ - public static final String TPKT_PAD = "tpkt"; - - private static final String ORDERS_PAD = "orders"; - private static final String BITMAP_PAD = "bitmap"; - private static final String PALETTE_PAD = "palette"; - - /** - * Indicates that packet contains 8 byte secure checksum at top of packet. Top - * two bits of first byte. - */ - public static final int FASTPATH_OUTPUT_SECURE_CHECKSUM = 1; - - /** - * Indicates that packet contains 8 byte secure checksum at top of packet and - * packet content is encrypted. Top two bits of first byte. - */ - public static final int FASTPATH_OUTPUT_ENCRYPTED = 2; - - public static final int FASTPATH_UPDATETYPE_ORDERS = 0; - public static final int FASTPATH_UPDATETYPE_BITMAP = 1; - public static final int FASTPATH_UPDATETYPE_PALETTE = 2; - public static final int FASTPATH_UPDATETYPE_SYNCHRONIZE = 3; - public static final int FASTPATH_UPDATETYPE_SURFCMDS = 4; - public static final int FASTPATH_UPDATETYPE_PTR_NULL = 5; - public static final int FASTPATH_UPDATETYPE_PTR_DEFAULT = 6; - public static final int FASTPATH_UPDATETYPE_PTR_POSITION = 8; - public static final int FASTPATH_UPDATETYPE_COLOR = 9; - public static final int FASTPATH_UPDATETYPE_CACHED = 0xa; - public static final int FASTPATH_UPDATETYPE_POINTER = 0xb; - - public static final int FASTPATH_FRAGMENT_SINGLE = 0; - public static final int FASTPATH_FRAGMENT_LAST = 1; - public static final int FASTPATH_FRAGMENT_FIRST = 2; - public static final int FASTPATH_FRAGMENT_NEXT = 3; - - public static final int FASTPATH_OUTPUT_COMPRESSION_USED = 2; - - public ServerFastPath(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 + "."); - - //* DEBUG */System.out.println(buf.toHexString(buf.length)); - - // We need at 4 bytes to read packet type (TPKT or FastPath) and packet - // length - if (!cap(buf, 4, UNLIMITED, link, false)) - return; - - int typeAndFlags = buf.readUnsignedByte(); - - if (typeAndFlags == PROTOCOL_TPKT) { - // - // TPKT - // - - // Reserved - buf.skipBytes(1); - - // Read TPKT length - int length = buf.readUnsignedShort(); - - if (!cap(buf, length, length, link, false)) - // Wait for full packet to arrive - return; - - pushDataToPad(TPKT_PAD, buf); - - // TPKT is handled - return; - } - - // - // FastPath - // - // Number of bytes in updateData field (including header (1+1 or 2 - // bytes)) - int length = buf.readVariableUnsignedShort(); - - // Length is the size of payload, so we need to calculate from cursor - if (!cap(buf, length, length, link, false)) - // Wait for full packet to arrive - return; - - int type = typeAndFlags & 0x3; - int securityFlags = (typeAndFlags >> 6) & 0x3; - - // Assertions - { - if (type != PROTOCOL_FASTPATH) - throw new RuntimeException("Unknown protocol. Expected protocol: 0 (FastPath). Actual protocol: " + type + ", data: " + buf + "."); - - switch (securityFlags) { - case FASTPATH_OUTPUT_SECURE_CHECKSUM: - // TODO - throw new RuntimeException("Secure checksum is not supported in FastPath packets."); - case FASTPATH_OUTPUT_ENCRYPTED: - // TODO - throw new RuntimeException("Encryption is not supported in FastPath packets."); - } - } - - // TODO: optional FIPS information, when FIPS is selected - // TODO: optional data signature (checksum), when checksum or FIPS is - // selected - - // Array of FastPath update fields - while (buf.cursor < buf.length) { - - int updateHeader = buf.readUnsignedByte(); - - int size = buf.readUnsignedShortLE(); - - int updateCode = updateHeader & 0xf; - int fragmentation = (updateHeader >> 4) & 0x3; - int compression = (updateHeader >> 6) & 0x3; - - 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; - - case FASTPATH_UPDATETYPE_SURFCMDS: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_SURFCMDS."); - - break; - - case FASTPATH_UPDATETYPE_PTR_NULL: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_PTR_NULL."); - - break; - - case FASTPATH_UPDATETYPE_PTR_DEFAULT: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_PTR_DEFAULT."); - - break; - - case FASTPATH_UPDATETYPE_PTR_POSITION: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_PTR_POSITION."); - - break; - - case FASTPATH_UPDATETYPE_COLOR: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_COLOR."); - - break; - - case FASTPATH_UPDATETYPE_CACHED: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_CACHED."); - - break; - - case FASTPATH_UPDATETYPE_POINTER: - if (verbose) - System.out.println("[" + this + "] INFO: FASTPATH_UPDATETYPE_POINTER."); - - break; - - default: - throw new RuntimeException("Unknown FastPath update. UpdateCode: " + updateCode + ", fragmentation: " + fragmentation + ", compression: " + compression - + ", size: " + size + ", data: " + data + "."); - - } - - } - - buf.unref(); - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerLicenseErrorPDUValidClient.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerLicenseErrorPDUValidClient.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerLicenseErrorPDUValidClient.java deleted file mode 100644 index 194ffe6..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerLicenseErrorPDUValidClient.java +++ /dev/null @@ -1,121 +0,0 @@ -// 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; - -import streamer.ByteBuffer; -import streamer.Link; -import streamer.OneTimeSwitch; - -public class ServerLicenseErrorPDUValidClient extends OneTimeSwitch { - - public ServerLicenseErrorPDUValidClient(String id) { - super(id); - } - - @Override - protected void handleOneTimeData(ByteBuffer buf, Link link) { - if (buf == null) - return; - - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - // Ignore packet - buf.unref(); - switchOff(); - } - - /* @formatter:off */ -// * Server Error alert -// -//03 00 00 22 02 F0 80 68 00 01 03 EB 70 14 80 00 F1 BC FF 03 10 00 07 00 00 00 02 00 00 00 04 00 00 00 -// -// -// Frame: Number = 30, Captured Frame Length = 91, 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: 34 -// version: 3 (0x3) -// Reserved: 0 (0x0) -// PacketLength: 34 (0x22) -//- X224: Data -// Length: 2 (0x2) -// Type: Data -// EOT: 128 (0x80) -//- T125: Data Packet -// - MCSHeader: Type=Send Data Indication, UserID=1002, ChannelID=1003 -// - Type: Send Data Indication -// - RootIndex: 26 -// Value: (011010..) 0x1a -// - UserID: 0x3ea -// - UserID: 0x3ea -// - ChannelId: 1002 -// - Align: No Padding -// Padding2: (00......) 0x0 -// Value: 1 (0x1) -// - 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: 20 -// - Align: No Padding -// Padding4: (0000....) 0x0 -// Length: 20 -// RDP: RDPBCGR -//- RDPBCGR: RDPELE -// - SecurityHeader: License Packet -// - Flags: 128 (0x80) -// SecurityExchange: (...............0) Not Security Exchange PDU -// Reserved1: (.............00.) Reserved -// Encrypted: (............0...) Not Encrypted packet -// ResetSeqNumber: (...........0....) MUST be ignored. -// IgnoreSeqNumber: (..........0.....) MUST be ignored. -// InfoPacket: (.........0......) Not Client Info PDU -// LicensePacket: (........1.......) License Packet -// Reserved2: (.......0........) Reserved -// LicensePacketEncryption: (......0.........) Not License Packet Encryption -// ServerRedirectionPacket: (.....0..........) Not Standard Security Server Redirection PDU -// ImprovedChecksumForMACG: (....0...........) Not Improved Checksum for MAC Generation -// Reserved3: (.000............) Reserved -// FlagsHiValid: (0...............) FlagsHi should be ignored -// FlagsHi: Should be ignored -//- RDPELE: GM_ERROR_ALERT -// - TsPreambleHeader: Type = GM_ERROR_ALERT -// MsgType: GM_ERROR_ALERT -// - Flags: 3 (0x3) -// LicenseProtocolVersionMask: (....0011) RDP 5.0, 5.1, 5.2, 6.0, 6.1, and 7.0 -// Unused: (.000....) -// ExtendedErrorMSGsupported: (0.......) that extended error information using the License Error Message is NOT supported. -// MsgSize: 16 (0x10) -// - TsLicenseErrorMessage: ErrorCode = STATUS_VALID_CLIENT -// ErrorCode: STATUS_VALID_CLIENT -// StateTransition: ST_NO_TRANSITION -// - LiceseBinaryBlob: Type = Not Available -// RandomData: This value should be ignored -// BlobLen: 0 (0x0) -// - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSAttachUserConfirmPDU.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSAttachUserConfirmPDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSAttachUserConfirmPDU.java deleted file mode 100644 index 8373b83..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSAttachUserConfirmPDU.java +++ /dev/null @@ -1,133 +0,0 @@ -// 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; - -import streamer.ByteBuffer; -import streamer.Element; -import streamer.Link; -import streamer.MockSink; -import streamer.MockSource; -import streamer.OneTimeSwitch; -import streamer.Pipeline; -import streamer.PipelineImpl; - -/** - * Server response to MCS Attach User request. - * - * Once the User Channel ID has been extracted, the client MUST send an MCS - * Channel Join Request PDU for the user channel. - * - * @see http://msdn.microsoft.com/en-us/library/cc240685.aspx - */ -public class ServerMCSAttachUserConfirmPDU extends OneTimeSwitch { - - public static final int MCS_ATTACH_USER_CONFIRM_PDU = 0xb; - - public static final int INITIATOR_PRESENT = 0x2; - - protected RdpState state; - - public ServerMCSAttachUserConfirmPDU(String id, RdpState state) { - super(id); - this.state = state; - } - - @Override - protected void handleOneTimeData(ByteBuffer buf, Link link) { - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - int typeAndFlags = buf.readUnsignedByte(); - int type = typeAndFlags >> 2; - int flags = typeAndFlags & 0x3; - - if (type != MCS_ATTACH_USER_CONFIRM_PDU) - throw new RuntimeException("["+this+"] ERROR: Incorrect type of MCS AttachUserConfirm PDU. Expected value: 11, actual value: " + type + ", data: " + buf + "."); - - if (flags != INITIATOR_PRESENT) - throw new RuntimeException("Initator field is not present in MCS AttachUserConfirm PDU. Data: " + buf + "."); - - int rtSuccess = buf.readUnsignedByte() >> 4; - if (rtSuccess != 0) - throw new RuntimeException("["+this+"] ERROR: Cannot attach user: request failed. Error code: " + rtSuccess + ", data: " + buf + "."); - - // If the initiator field is present, the client stores the value of the - // initiator in the User Channel ID store , because the initiator specifies - // the User Channel ID. - state.serverUserChannelId = buf.readUnsignedShort() + 1001; - - buf.unref(); - - // Next: client MCS Channel Join Request PDU (s) - switchOff(); - } - - /** - * Example. - */ - /** - * 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"); - - byte[] packet = new byte[] { (byte) 0x2E, // MCS user confirm (001011.., - // 0xb), InitiatorPresent: 1 - // (......01, 0x1) - (byte) 0x00, // RT successfull (0000...., 0x0) - // Initiator: 1001+3 = 1004 - (byte) 0x00, (byte) 0x03, }; - - RdpState rdpState = new RdpState(); - MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet, new byte[] { 1, 2, 3 })); - Element atachUserConfirm = new ServerMCSAttachUserConfirmPDU("attach_user_confirm", rdpState); - Element sink = new MockSink("sink"); - Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 })); - - Pipeline pipeline = new PipelineImpl("test"); - pipeline.add(source, atachUserConfirm, sink, mainSink); - pipeline.link("source", "attach_user_confirm", "mainSink"); - pipeline.link("attach_user_confirm >" + OTOUT, "sink"); - pipeline.runMainLoop("source", STDOUT, false, false); - - if (rdpState.serverUserChannelId != 1004) - System.err.println("Incorrect user channel ID. Expected value: 1004, actual value: " + rdpState.serverUserChannelId + "."); - } - -} - -/* - * 03 00 00 0B 02 F0 80 2E 00 00 03. - * - * Frame: Number = 18, Captured Frame Length = 68, 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: 11 version: 3 (0x3) Reserved: 0 (0x0) PacketLength: 11 (0xB) - X224: - * Data Length: 2 (0x2) Type: Data EOT: 128 (0x80) - T125: Attach User Confirm, - * Result = rt-successful, Indicator = 0x3ec - MCSHeader: Type=Attach User - * Confirm - Type: Attach User Confirm - RootIndex: 11 Value: (001011..) 0xb - - * MCSAttachUserConfirm: Result = rt-successful, Indicator = 0x3ec - * InitiatorPresent: 1 (0x1) - Result: rt-successful - Result: rt-successful - - * RootIndex: 0 Value: (0000....) 0x0 - Initiator: 0x3ec - UserID: 0x3ec - - * ChannelId: 1004 - Align: No Padding Padding5: (00000...) 0x0 Value: 3 (0x3) - */ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSChannelJoinConfirmPDU.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSChannelJoinConfirmPDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSChannelJoinConfirmPDU.java deleted file mode 100644 index d0a8e81..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSChannelJoinConfirmPDU.java +++ /dev/null @@ -1,89 +0,0 @@ -// 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; - -import streamer.ByteBuffer; -import streamer.Link; -import streamer.OneTimeSwitch; - -public class ServerMCSChannelJoinConfirmPDU extends OneTimeSwitch { - - protected int channel; - - public ServerMCSChannelJoinConfirmPDU(String id, int channel) { - super(id); - this.channel=channel; - } - - @Override - protected void handleOneTimeData(ByteBuffer buf, Link link) { - if (buf == null) - return; - - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - // Ignore packet - buf.unref(); - switchOff(); - } - -} - -/* - * 03 00 00 0F 02 F0 80 3E 00 00 03 03 EC 03 EC - - Frame: Number = 22, Captured Frame Length = 72, 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: 15 - version: 3 (0x3) - Reserved: 0 (0x0) - PacketLength: 15 (0xF) -- X224: Data - Length: 2 (0x2) - Type: Data - EOT: 128 (0x80) -- T125: Channel Join Confirm, ChannelId = 1004, Result = rt-successful - - MCSHeader: Type=Channel Join Confirm - - Type: Channel Join Confirm - - RootIndex: 15 - Value: (001111..) 0xf - - MCSChannelJoinConfirm: ChannelId = 1004, Result = rt-successful - ChannelIdPresent: 1 (0x1) - - Result: rt-successful - - Result: rt-successful - - RootIndex: 0 - Value: (0000....) 0x0 - - Initiator: 0x3ec - - UserID: 0x3ec - - ChannelId: 1004 - - Align: No Padding - Padding5: (00000...) 0x0 - Value: 3 (0x3) - - Requested: 0x3ec - - ChannelId: 1004 - Align: No Padding - Value: 1004 (0x3EC) - - ChannelId: 0x3ec - - ChannelId: 1004 - Align: No Padding - Value: 1004 (0x3EC) - - */ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSConnectResponse.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSConnectResponse.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSConnectResponse.java deleted file mode 100644 index 30b196b..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSConnectResponse.java +++ /dev/null @@ -1,283 +0,0 @@ -// 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; - -import streamer.ByteBuffer; -import streamer.Link; -import streamer.OneTimeSwitch; - -/** - * Once the basic server settings data blocks have been processed successfully, the client MUST send the MCS Attach User Request PDU to the server. - * - * @see http://msdn.microsoft.com/en-us/library/cc240682.aspx - */ -public class ServerMCSConnectResponse extends OneTimeSwitch { - - public ServerMCSConnectResponse(String id) { - super(id); - } - - @Override - protected void handleOneTimeData(ByteBuffer buf, Link link) { - if (buf == null) - return; - - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - // Ignore packet - buf.unref(); - switchOff(); - } - -} - -/* - * @formatter:off - * 03 00 00 64 02 F0 80 7F 66 5A 0A 01 00 02 01 00 30 1A 02 01 22 02 01 03 02 01 00 02 01 01 02 01 00 02 01 01 02 03 00 FF F8 02 01 02 04 36 00 05 00 14 7C 00 01 2A 14 76 0A 01 01 00 01 C0 00 4D 63 44 6E 20 01 0C 0C 00 04 00 08 00 01 00 00 00 03 0C 08 00 EB 03 00 00 02 0C 0C 00 00 00 00 00 00 00 00 00 - - Frame: Number = 12, Captured Frame Length = 157, 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: 100 - version: 3 (0x3) - Reserved: 0 (0x0) - PacketLength: 100 (0x64) -- X224: Data - Length: 2 (0x2) - Type: Data - EOT: 128 (0x80) -- T125: MCSConnect Response - - MCSConnectResponse: Result = rt-successful - - ConnectResponseHeader: - - AsnId: Application Constructed Tag (102) - - HighTag: - Class: (01......) Application (1) - Type: (..1.....) Constructed - TagNumber: (...11111) - TagValueEnd: 102 (0x66) - - AsnLen: Length = 90, LengthOfLength = 0 - Length: 90 bytes, LengthOfLength = 0 - - Result: rt-successful - - Value: 0 - - AsnIntegerHeader: - - AsnId: Enumerated type (Universal 10) - - LowTag: - Class: (00......) Universal (0) - Type: (..0.....) Primitive - TagValue: (...01010) 10 - - AsnLen: Length = 1, LengthOfLength = 0 - Length: 1 bytes, LengthOfLength = 0 - AsnInt: 0 (0x0) - - CalledConnectId: 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) - - DomainParameters: Length = 26, LengthOfLength = 0 - - 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 - - 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) - - UserIDs: 3 - - 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: 3 (0x3) - - 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) - - 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) - - 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) - - 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) - - MCSPDUsize: 65528 - - 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: 65528 (0xFFF8) - - 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 Contro (0.0.20.124.0.1) - - UserDataHeader: - - AsnId: OctetString type (Universal 4) - - LowTag: - Class: (00......) Universal (0) - Type: (..0.....) Primitive - TagValue: (...00100) 4 - - AsnLen: Length = 54, LengthOfLength = 0 - Length: 54 bytes, LengthOfLength = 0 - - 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) - - ConnectPDULength: 42 - Align: No Padding - Length: 42 - - ConnectGCCPDU: conferenceCreateResponse - ExtensionBit: 0 (0x0) - - ChoiceValue: conferenceCreateResponse - Value: (001.....) 0x1 - - conferenceCreateResponse: - ExtensionBit: 0 (0x0) - userDataPresent: 1 (0x1) - - nodeID: 0x79f3 - - UserID: 31219 - - Align: No Padding - Padding2: (00......) 0x0 - Value: 30218 (0x760A) - - tag: 1 (0x1) - - Length: 1 - Align: No Padding - Length: 1 - Value: 1 (0x1) - - result: success - ExtensionBit: 0 (0x0) - - RootIndex: 0 - Value: (000.....) 0x0 - - userData: - - Size: 1 - - Align: No Padding - Padding4: (0000....) 0x0 - Length: 1 - - UserData: 0x4d63446e - valuePresent: 1 (0x1) - - key: h221NonStandard - - 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) - - ServerMcsConnectResponsePdu: - - RDPGCCUserDataResponseLength: 32 - Align: No Padding - Length: 32 - - TsUd: SC_CORE - - TsUdHeader: Type = SC_CORE, Length = 12 - Type: SC_CORE - Length: 12 (0xC) - - TsUdScCore: - Version: RDP 5.0, 5.1, 5.2, 6.0, 6.1, and 7.0 - ClientRequestedProtocols: TLS 1.0 - - TsUd: SC_NET - - TsUdHeader: Type = SC_NET, Length = 8 - Type: SC_NET - Length: 8 (0x8) - - TsUdScNet: - MCSChannelID: 1003 (0x3EB) - ChannelCount: 0 (0x0) - Pad: 0 Bytes - - TsUd: SC_SECURITY - - TsUdHeader: Type = SC_SECURITY, Length = 12 - Type: SC_SECURITY - Length: 12 (0xC) - - TsUdSCSec1: - - 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.....) - EncryptionLevel: TS_ENCRYPTION_NONE - */ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSPDU.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSPDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSPDU.java deleted file mode 100644 index 5862e19..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerMCSPDU.java +++ /dev/null @@ -1,149 +0,0 @@ -// 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; - -import streamer.BaseElement; -import streamer.ByteBuffer; -import streamer.Element; -import streamer.Link; -import streamer.MockSink; -import streamer.MockSource; -import streamer.Pipeline; -import streamer.PipelineImpl; - -public class ServerMCSPDU extends BaseElement { - - public ServerMCSPDU(String id) { - super(id); - } - - @Override - public void handleData(ByteBuffer buf, Link link) { - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - byte headerByte = buf.readSignedByte(); - int type = headerByte >> 2; - - switch (type) { - // Expected type: send data indication: 26 (0x1a, top 6 bits, or 0x68) - case 0x1a: { - // int userId = buf.readUnsignedShort() + 1001; // User ID: 1002 (1001+1) - buf.skipBytes(2); // Ignore user ID - - int channelId = buf.readUnsignedShort(); // Channel ID: 1003 - - int flags = buf.readSignedByte(); - if ((flags & 0x30) != 0x30) - throw new RuntimeException("Fragmented MCS packets are not supported."); - - int payloadLength = buf.readVariableUnsignedShort(); - - ByteBuffer data = buf.readBytes(payloadLength); - - buf.unref(); - - pushDataToPad("channel_" + channelId, data); - break; - } - - case 0x8: { - // Disconnection sequence. - buf.unref(); - break; - } - - default: - throw new RuntimeException("Unsupported MCS packet type: " + type + "(" + headerByte + "), data: " + buf + "."); - } - - } - - /** - * Example. - * - */ - public static void main(String args[]) { - // System.setProperty("streamer.Link.debug", "true"); - // System.setProperty("streamer.Element.debug", "true"); - // System.setProperty("streamer.Pipeline.debug", "true"); - - byte[] packet = new byte[] { - // TPKT - (byte) 0x03, (byte) 0x00, // TPKT Header: TPKT version = 3 - (byte) 0x00, (byte) 0x1B, // TPKT length: 27 bytes - - // X224 - (byte) 0x02, // X224 Length: 2 bytes - (byte) 0xF0, // X224 Type: Data - (byte) 0x80, // X224 EOT - - // MCS - // Type: send data indication: 26 (0x1a, top 6 bits) - (byte) 0x68, // ?? - - (byte) 0x00, (byte) 0x01, // User ID: 1002 (1001+1) - (byte) 0x03, (byte) 0xEB, // Channel ID: 1003 - (byte) 0x70, // Data priority: high, segmentation: begin|end - (byte) 0x0D, // Payload length: 13 bytes - - // Deactivate all PDU - (byte) 0x0D, (byte) 0x00, // Length: 13 bytes (LE) - - // - PDUType: 22 (0x16, LE) - // Type: (............0110) TS_PDUTYPE_DEACTIVATEALLPDU - // ProtocolVersion: (000000000001....) 1 - (byte) 0x16, (byte) 0x00, - - (byte) 0xEA, (byte) 0x03, // PDU source: 1002 (LE) - (byte) 0xEA, (byte) 0x03, (byte) 0x01, (byte) 0x00, // ShareID = 66538 - - (byte) 0x01, (byte) 0x00, // Length if source descriptor: 1 (LE) - (byte) 0x00, // Source descriptor (should be set to 0): 0 - }; - - MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet)); - Element mcs = new ServerMCSPDU("mcs") { - { - verbose = true; - } - }; - Element tpkt = new ServerTpkt("tpkt"); - Element x224 = new ServerX224DataPdu("x224"); - Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { - // Deactivate all PDU - (byte) 0x0D, (byte) 0x00, // Length: 13 bytes (LE) - - // - PDUType: 22 (0x16, LE) - // Type: (............0110) TS_PDUTYPE_DEACTIVATEALLPDU - // ProtocolVersion: (000000000001....) 1 - (byte) 0x16, (byte) 0x00, - - (byte) 0xEA, (byte) 0x03, // PDU source: 1002 (LE) - (byte) 0xEA, (byte) 0x03, (byte) 0x01, (byte) 0x00, // ShareID = 66538 - - (byte) 0x01, (byte) 0x00, // Length if source descriptor: 1 (LE) - (byte) 0x00, // Source descriptor (should be set to 0): 0 - })); - - Pipeline pipeline = new PipelineImpl("test"); - pipeline.add(source, tpkt, x224, mcs, sink); - pipeline.link("source", "tpkt", "x224", "mcs >channel_1003", "sink"); - pipeline.runMainLoop("source", STDOUT, false, false); - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPacketSniffer.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPacketSniffer.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPacketSniffer.java deleted file mode 100644 index 8c39a02..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPacketSniffer.java +++ /dev/null @@ -1,52 +0,0 @@ -// 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; - - -/** - * Try to determine packet content by it header fingerprint. - */ -public class ServerPacketSniffer extends PacketSniffer { - - private static final Pair[] serverRegexps = new Pair[] { - // @formatter:off - new Pair("Server FastPath update", "04"), - new Pair("Server X224ConnectionRequest", "03 00 XX XX 0E D0"), - new Pair("Server MCSConnectResponse", "03 00 XX XX 02 F0 80 7F 66 5A"), - new Pair("Server AttachUserConfirm", "03 00 XX XX 02 F0 80 2E"), - new Pair("Server ChannelJoinConfirm", "03 00 XX XX 02 F0 80 3E"), - new Pair("Server ErrorAlert", "03 00 XX XX 02 F0 80 68 00 01 03 EB 70 14 80 00"), - new Pair("Server DemandActivePDU", "03 00 XX XX 02 F0 80 68 00 01 03 EB 70 XX XX XX XX 11"), - new Pair("Server ControlPDU", "03 00 XX XX 02 F0 80 68 00 01 03 EB 70 XX XX XX 17 00 EA 03 EA 03 XX 00 XX XX XX XX 14"), - new Pair("Server SynchronizePDU", "03 00 XX XX 02 F0 80 68 00 01 03 EB 70 XX XX XX 17 00 EA 03 EA 03 XX 00 XX XX XX XX 1F"), - new Pair("Server FontMapPDU", "03 00 XX XX 02 F0 80 68 00 01 03 EB 70 XX XX XX 17 00 EA 03 EA 03 XX 00 XX XX XX XX 28"), - new Pair("Server SET_ERROR_INFO_PDU", "03 00 XX XX 02 F0 80 68 00 01 03 EB 30 XX XX XX 17 00 00 00 EA 03 XX 00 XX XX XX XX 2F"), - new Pair("Server DeactivateAllPDU", "03 00 XX XX 02 F0 80 68 00 01 03 EB 70 XX XX XX 16 00"), - new Pair("Server CloseConnection", "03 00 00 09 02 F0 80 21 80"), - -// new Pair("Server TPKT unknown packet", "03"), -// new Pair("Server FastPath update with flags or continuation", ".*"), - // @formatter:on - - }; - - public ServerPacketSniffer(String id) { - super(id, serverRegexps); - } - - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPaletteUpdate.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPaletteUpdate.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPaletteUpdate.java deleted file mode 100644 index 3b0762e..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerPaletteUpdate.java +++ /dev/null @@ -1,78 +0,0 @@ -// 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; - -import java.awt.image.IndexColorModel; - -import common.ScreenDescription; - -import streamer.BaseElement; -import streamer.ByteBuffer; -import streamer.Link; - -/** - * @see http://msdn.microsoft.com/en-us/library/cc240623.aspx - */ -public class ServerPaletteUpdate extends BaseElement { - - public static final int UPDATETYPE_PALETTE = 0x0002; - protected ScreenDescription screen; - - public ServerPaletteUpdate(String id, ScreenDescription screen) { - super(id); - this.screen = screen; - } - - @Override - public void handleData(ByteBuffer buf, Link link) { - - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - // (2 bytes): A 16-bit, unsigned integer. The update type. This field MUST - // be set to UPDATETYPE_PALETTE (0x0002). - int updateType = buf.readUnsignedShortLE(); - if (updateType != UPDATETYPE_PALETTE) - throw new RuntimeException("Unexpected update type. Expected type: UPDATETYPE_PALETTE (0x0002), actual value: " + updateType + ", data: " + buf + "."); - - // pad2Octets (2 bytes): A 16-bit, unsigned integer. Padding. Values in this - // field MUST be ignored. - buf.skipBytes(2); - - // (4 bytes): A 32-bit, unsigned integer. The number of RGB triplets in the - // paletteData field. This field MUST be set to 256 (the number of entries - // in an 8 bpp palette). - int numberColors = (int) buf.readUnsignedIntLE(); - if (numberColors != 256) - throw new RuntimeException("Unexpected value for number of color field in server Palette Update packet. Expected value: 256 colors, actual value: " - + numberColors + ", data: " + buf + "."); - - // (variable): An array of palette entries in RGB triplet format packed on - // byte boundaries. The number of triplet entries is given by the - // numberColors field. - ByteBuffer paletteEntries = buf.readBytes(numberColors * 3); - - // In the case of a Palette Update, the client MUST update the global - // palette on all drawing surfaces - screen.colorMap = new IndexColorModel(8, numberColors, paletteEntries.data, paletteEntries.offset, false); - - /* DEBUG */buf.assertThatBufferIsFullyRead(); - - buf.unref(); - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerSynchronizePDU.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerSynchronizePDU.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerSynchronizePDU.java deleted file mode 100644 index 315fbfe..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerSynchronizePDU.java +++ /dev/null @@ -1,115 +0,0 @@ -// 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; - -import streamer.ByteBuffer; -import streamer.Link; -import streamer.OneTimeSwitch; - -public class ServerSynchronizePDU extends OneTimeSwitch { - - public ServerSynchronizePDU(String id) { - super(id); - } - - @Override - protected void handleOneTimeData(ByteBuffer buf, Link link) { - if (buf == null) - return; - - if (verbose) - System.out.println("[" + this + "] INFO: Data received: " + buf + "."); - - // Ignore packet - buf.unref(); - switchOff(); - } - -} - -/* @formatter:off */ -/* - - * 03 00 00 24 02 F0 80 68 00 01 03 EB 70 16 16 00 17 00 EA 03 EA 03 01 00 08 00 16 00 1F 00 00 00 01 00 86 A4 - - Frame: Number = 36, Captured Frame Length = 93, 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: 36 - version: 3 (0x3) - Reserved: 0 (0x0) - PacketLength: 36 (0x24) -- X224: Data - Length: 2 (0x2) - Type: Data - EOT: 128 (0x80) -- T125: Data Packet - - MCSHeader: Type=Send Data Indication, UserID=1002, ChannelID=1003 - - Type: Send Data Indication - - RootIndex: 26 - Value: (011010..) 0x1a - - UserID: 0x3ea - - UserID: 0x3ea - - ChannelId: 1002 - - Align: No Padding - Padding2: (00......) 0x0 - Value: 1 (0x1) - - 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: 1002 (0x3EA) - - SlowPathIoPacket: 0x0 - - ShareDataHeader: TS_PDUTYPE2_SYNCHRONIZE - ShareID: 66538 (0x103EA) - Pad1: 8 (0x8) - StreamID: STREAM_UNDEFINED - UncompressedLength: 22 (0x16) - 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: 42118 (0xA486) - */ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3611f9/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerTpkt.java ---------------------------------------------------------------------- diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerTpkt.java b/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerTpkt.java deleted file mode 100644 index 0d19fa4..0000000 --- a/services/console-proxy-rdp/rdpconsole/src/main/java/rdpclient/ServerTpkt.java +++ /dev/null @@ -1,70 +0,0 @@ -// 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; - -import streamer.BaseElement; -import streamer.ByteBuffer; -import streamer.Link; - -public class ServerTpkt extends BaseElement { - - /** - * TPKT protocol version (first byte). - */ - public static final int PROTOCOL_TPKT = 3; - - public ServerTpkt(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 + "."); - - // We need at least 4 bytes to get packet length - if(!cap(buf, 4, UNLIMITED, link, false)) - return; - - int version = buf.readUnsignedByte(); - if (version != PROTOCOL_TPKT) - throw new RuntimeException("Unexpected data in TPKT header. Expected TPKT version: 0x03, actual value: " + buf + "."); - - buf.skipBytes(1); // Reserved byte - - // Length of whole packet, including header - int length = buf.readUnsignedShort(); - if(!cap(buf, length, length, link, false)) - return; - - int payloadLength = length - buf.cursor; - - // Extract payload - ByteBuffer outBuf = buf.slice(buf.cursor, payloadLength, true); - buf.unref(); - - if(verbose) { - outBuf.putMetadata("source", this); - } - - pushDataToAllOuts(outBuf); - } - -}