Gcc used in MCSConnectInitial.
예제 #1
0
 public MCSConnectInitial()
 {
     gccPdu = new ConnectGCC();
 }
예제 #2
0
        /// <summary>
        /// Encode GCC Conference Create Request according to [T124].
        /// </summary>
        /// <param name="gccPdu">The data to be encoded.</param>
        /// <returns>The encoded data.</returns>
        private static byte[] EncodeGccData(ConnectGCC gccPdu)
        {
            if (gccPdu == null)
            {
                return null;
            }

            #region Encode userData
            List<byte> userData = new List<byte>();

            #region Encode clientCoreData structure TS_UD_CS_CORE
            if (gccPdu.clientCoreData != null)
            {
                List<byte> coreData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.header);
                RdpbcgrEncoder.EncodeStructure(coreData, (uint)gccPdu.clientCoreData.version);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.desktopWidth);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.desktopHeight);
                RdpbcgrEncoder.EncodeStructure(coreData, (ushort)gccPdu.clientCoreData.colorDepth);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.SASSequence);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.keyboardLayout);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.clientBuild);
                RdpbcgrEncoder.EncodeUnicodeString(coreData, gccPdu.clientCoreData.clientName,
                                                   ConstValue.CLIENT_CORE_DATA_CLIENT_NAME_SIZE);
                RdpbcgrEncoder.EncodeStructure(coreData, (uint)gccPdu.clientCoreData.keyboardType);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.keyboardSubType);
                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.keyboardFunctionKey);
                RdpbcgrEncoder.EncodeUnicodeString(coreData, gccPdu.clientCoreData.imeFileName,
                                                   ConstValue.CLIENT_CORE_DATA_IME_FILE_NAME_SIZE);

                if (gccPdu.clientCoreData.postBeta2ColorDepth == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.postBeta2ColorDepth.actualData);

                if (gccPdu.clientCoreData.clientProductId == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.clientProductId.actualData);

                if (gccPdu.clientCoreData.serialNumber == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.serialNumber.actualData);

                if (gccPdu.clientCoreData.highColorDepth == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.highColorDepth.actualData);

                if (gccPdu.clientCoreData.supportedColorDepths == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.supportedColorDepths.actualData);

                if (gccPdu.clientCoreData.earlyCapabilityFlags == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.earlyCapabilityFlags.actualData);

                if (gccPdu.clientCoreData.clientDigProductId == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeUnicodeString(coreData, gccPdu.clientCoreData.clientDigProductId,
                                                   ConstValue.CLIENT_CORE_DATA_CLIENT_DIG_PRODUCT_ID_SIZE);

                if (gccPdu.clientCoreData.connnectionType == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.connnectionType.actualData);

                if (gccPdu.clientCoreData.pad1octets == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.pad1octets.actualData);

                if (gccPdu.clientCoreData.serverSelectedProtocol == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.serverSelectedProtocol.actualData);

                if (gccPdu.clientCoreData.desktopPhysicalWidth == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.desktopPhysicalWidth.actualData);

                if (gccPdu.clientCoreData.desktopPhysicalHeight == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.desktopPhysicalHeight.actualData);

                RdpbcgrEncoder.EncodeStructure(coreData, (ushort)gccPdu.clientCoreData.desktopOrientation);

                if (gccPdu.clientCoreData.desktopScaleFactor == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.desktopScaleFactor.actualData);

                if (gccPdu.clientCoreData.deviceScaleFactor == null)
                {
                    goto labelCoreEnd;
                }

                RdpbcgrEncoder.EncodeStructure(coreData, gccPdu.clientCoreData.deviceScaleFactor.actualData);

            labelCoreEnd:
                userData.AddRange(coreData.ToArray());
            }
            #endregion Encode clientCoreData structure TS_UD_CS_CORE

            #region Encode clientSecurityData TS_UD_CS_SEC
            if (gccPdu.clientSecurityData != null)
            {
                List<byte> securityData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(securityData, gccPdu.clientSecurityData.header);
                RdpbcgrEncoder.EncodeStructure(securityData, (uint)gccPdu.clientSecurityData.encryptionMethods);
                RdpbcgrEncoder.EncodeStructure(securityData, gccPdu.clientSecurityData.extEncryptionMethods);
                userData.AddRange(securityData.ToArray());
            }
            #endregion Encode clientSecurityData TS_UD_CS_SEC

            #region Encode clientNetworkData TS_UD_CS_NET
            if (gccPdu.clientNetworkData != null)
            {
                List<byte> networkData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(networkData, gccPdu.clientNetworkData.header);
                RdpbcgrEncoder.EncodeStructure(networkData, gccPdu.clientNetworkData.channelCount);
                for (int i = 0; i < gccPdu.clientNetworkData.channelCount; ++i)
                {
                    RdpbcgrEncoder.EncodeAnsiString(networkData,
                                                    gccPdu.clientNetworkData.channelDefArray[i].name,
                                                    ConstValue.CHANNEL_DEF_NAME_SIZE);
                    RdpbcgrEncoder.EncodeStructure(networkData,
                                                   (uint)gccPdu.clientNetworkData.channelDefArray[i].options);
                }

                userData.AddRange(networkData.ToArray());
            }
            #endregion Encode clientNetworkData TS_UD_CS_NET

            #region Encode clientClusterData TS_UD_CS_CLUSTER
            if (gccPdu.clientClusterData != null)
            {
                List<byte> clusterData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(clusterData, gccPdu.clientClusterData.header);
                RdpbcgrEncoder.EncodeStructure(clusterData, (uint)gccPdu.clientClusterData.Flags);
                RdpbcgrEncoder.EncodeStructure(clusterData, gccPdu.clientClusterData.RedirectedSessionID);
                userData.AddRange(clusterData.ToArray());
            }
            #endregion Encode clientClusterData TS_UD_CS_CLUSTER

            #region Encode clientMonitorData TS_UD_CS_MONITOR
            if (gccPdu.clientMonitorData != null)
            {
                List<byte> monitorData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(monitorData, gccPdu.clientMonitorData.header);
                RdpbcgrEncoder.EncodeStructure(monitorData, gccPdu.clientMonitorData.Flags);
                RdpbcgrEncoder.EncodeStructure(monitorData, gccPdu.clientMonitorData.monitorCount);

                for (int i = 0; i < gccPdu.clientMonitorData.monitorCount; ++i)
                {
                    RdpbcgrEncoder.EncodeStructure(monitorData,
                                                   gccPdu.clientMonitorData.monitorDefArray[i].left);
                    RdpbcgrEncoder.EncodeStructure(monitorData,
                                                   gccPdu.clientMonitorData.monitorDefArray[i].top);
                    RdpbcgrEncoder.EncodeStructure(monitorData,
                                                   gccPdu.clientMonitorData.monitorDefArray[i].right);
                    RdpbcgrEncoder.EncodeStructure(monitorData,
                                                   gccPdu.clientMonitorData.monitorDefArray[i].bottom);
                    RdpbcgrEncoder.EncodeStructure(monitorData,
                                                   (uint)gccPdu.clientMonitorData.monitorDefArray[i].flags);
                }

                userData.AddRange(monitorData.ToArray());
            }
            #endregion Encode clientMonitorData TS_UD_CS_MONITOR

            #region Encode clientMessageChannelData TS_UD_CS_MCS_MSGCHANNEL
            if (gccPdu.clientMessageChannelData != null)
            {
                List<byte> messageChannelData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(messageChannelData, gccPdu.clientMessageChannelData.header);
                RdpbcgrEncoder.EncodeStructure(messageChannelData, (uint)gccPdu.clientMessageChannelData.flags);
                userData.AddRange(messageChannelData.ToArray());
            }
            #endregion Encode clientMessageChannelData TS_UD_CS_MCS_MSGCHANNEL

            #region Encode clientMultitransportChannelData TS_UD_CS_MULTITRANSPORT
            if (gccPdu.clientMultitransportChannelData != null)
            {
                List<byte> multitransportChannelData = new List<byte>();
                RdpbcgrEncoder.EncodeStructure(multitransportChannelData, gccPdu.clientMultitransportChannelData.header);
                RdpbcgrEncoder.EncodeStructure(multitransportChannelData, (uint)gccPdu.clientMultitransportChannelData.flags);
                userData.AddRange(multitransportChannelData.ToArray());
            }
            #endregion Encode clientMultitransportChannelData TS_UD_CS_MONITOR_EX

            #region Encode clientMonitorExtendedData TS_UD_CS_MULTITRANSPORT

            if (gccPdu.clientMonitorExtendedData != null)
            {
                List<byte> monitorExtendData = new List<byte>();

                RdpbcgrEncoder.EncodeStructure(monitorExtendData, gccPdu.clientMonitorExtendedData.header);
                RdpbcgrEncoder.EncodeStructure(monitorExtendData, gccPdu.clientMonitorExtendedData.flags);
                RdpbcgrEncoder.EncodeStructure(monitorExtendData, gccPdu.clientMonitorExtendedData.monitorAttributeSize);
                RdpbcgrEncoder.EncodeStructure(monitorExtendData, gccPdu.clientMonitorExtendedData.monitorCount);

                foreach (var attribute in gccPdu.clientMonitorExtendedData.monitorAttributesArray)
                {
                    RdpbcgrEncoder.EncodeStructure(monitorExtendData, attribute.physicalWidth);
                    RdpbcgrEncoder.EncodeStructure(monitorExtendData, attribute.physicalHeight);
                    RdpbcgrEncoder.EncodeStructure(monitorExtendData, (uint)attribute.orientation);
                    RdpbcgrEncoder.EncodeStructure(monitorExtendData, attribute.desktopScaleFactor);
                    RdpbcgrEncoder.EncodeStructure(monitorExtendData, attribute.deviceScaleFactor);
                }

            }
            #endregion Encode clientMonitorExtendedData TS_UD_CS_MONITOR_EX

            #endregion Encode userData

            #region Filling GCC Conference Create Request
            ConferenceCreateRequest gccCCrq = new ConferenceCreateRequest();
            if (gccPdu.conferenceName != null)
            {
                gccCCrq.conferenceName = new ConferenceName(gccPdu.conferenceName);
            }

            if (gccPdu.convenerPassword != null)
            {
                gccCCrq.convenerPassword = new Password(gccPdu.convenerPassword);
            }

            if (gccPdu.password != null)
            {
                gccCCrq.password = new Password(gccPdu.password);
            }

            gccCCrq.lockedConference = new Asn1Boolean(gccPdu.lockedConference);
            gccCCrq.listedConference = new Asn1Boolean(gccPdu.listedConference);
            gccCCrq.conductibleConference = new Asn1Boolean(gccPdu.conductibleConference);
            gccCCrq.terminationMethod = new TerminationMethod(gccPdu.terminationMethod);

            if (gccPdu.conductorPrivileges != null)
            {
                List<Privilege> privilege = new List<Privilege>();
                foreach (int i in gccPdu.conductorPrivileges)
                {
                    privilege.Add(new Privilege(i));
                }

                gccCCrq.conductorPrivileges = new Asn1SetOf<Privilege>(privilege.ToArray());
            }

            if (gccPdu.conductedPrivileges != null)
            {
                List<Privilege> privilege = new List<Privilege>();
                foreach (int i in gccPdu.conductedPrivileges)
                {
                    privilege.Add(new Privilege(i));
                }

                gccCCrq.conductedPrivileges = new Asn1SetOf<Privilege>(privilege.ToArray());
            }

            if (gccPdu.nonConductedPrivileges != null)
            {
                List<Privilege> privilege = new List<Privilege>();
                foreach (int i in gccPdu.nonConductedPrivileges)
                {
                    privilege.Add(new Privilege(i));
                }

                gccCCrq.nonConductedPrivileges = new  Asn1SetOf<Privilege>(privilege.ToArray());
            }

            if (gccPdu.conferenceDescription != null)
            {
                gccCCrq.conferenceDescription = new TextString(gccPdu.conferenceDescription);
            }

            if (gccPdu.callerIdentifier != null)
            {
                gccCCrq.callerIdentifier = new TextString(gccPdu.callerIdentifier);
            }

            //gccCCrq.extElem1 = new Asn1OpenExt();

            UserDataElement[] dataElements = new UserDataElement[1];
            dataElements[0] = new UserDataElement();
            dataElements[0].key = new Key(Key.h221NonStandard,
                                          new H221NonStandardIdentifier(ConstValue.H221_NON_STANDARD_KEY));
            dataElements[0].value = new Asn1OctetString(userData.ToArray());
            gccCCrq.userData = new UserData(dataElements);

            ConnectGCCPDU cGccPdu = new ConnectGCCPDU(ConnectGCCPDU.conferenceCreateRequest, gccCCrq);
            #endregion Filling GCC Conference Create Request

            #region Encode ConnectData
            Asn1PerEncodingBuffer perBuffer = new Asn1PerEncodingBuffer(true);
            cGccPdu.PerEncode(perBuffer);
            byte[] asnEncodedData = perBuffer.ByteArrayData;
            Key key = new Key(Key.obj, new Asn1ObjectIdentifier(ConstValue.MCS_ATTRIBUTE_ID));
            ConnectData connectData = new ConnectData(key, new Asn1OctetString(asnEncodedData));
            Asn1PerEncodingBuffer perBuffer2 = new Asn1PerEncodingBuffer(true);
            connectData.PerEncode(perBuffer2);
            #endregion Encode ConnectData

            return perBuffer2.ByteArrayData;
        }