Documentation
¶
Overview ¶
Package mcs implements the Multipoint Communication Service (T.125) protocol and GCC (Generic Conference Control, T.124) conference structures used in RDP.
This file contains GCC client and server data block types used within MCS Connect Initial/Response PDUs.
Index ¶
- Constants
- func DecodeAttachUserConfirm(log *slog.Logger, data []byte) (uint16, error)
- func DecodeChannelJoinConfirm(log *slog.Logger, data []byte) (uint16, error)
- func DecodeDisconnectProviderUltimatum(log *slog.Logger, data []byte) (reason int, err error)
- func DecodeGCCConferenceCreateResponse(data []byte) ([]byte, error)
- func DecodeSendDataIndication(log *slog.Logger, data []byte) (channelID uint16, userData []byte, err error)
- func DecodeServerData(log *slog.Logger, data []byte) (*ServerCoreData, *ServerSecurityData, *ServerNetworkData, error)
- func EncodeAttachUserRequest() []byte
- func EncodeChannelJoinRequest(userID, channelID uint16) []byte
- func EncodeErectDomainRequest() []byte
- func EncodeGCCConferenceCreateRequest(clientData []byte) []byte
- func EncodeSendDataRequest(userID, channelID uint16, data []byte) []byte
- func PDUType(data []byte) byte
- type ChannelDef
- type ClientClusterData
- type ClientCoreData
- type ClientMonitorData
- type ClientNetworkData
- type ClientSecurityData
- type ConnectInitial
- type ConnectResponse
- type MonitorDef
- type ServerCoreData
- type ServerNetworkData
- type ServerSecurityData
Constants ¶
const ( ClientCoreDataType uint16 = 0xC001 ClientSecurityDataType uint16 = 0xC002 ClientNetworkDataType uint16 = 0xC003 ClientClusterDataType uint16 = 0xC004 ClientMonitorDataType uint16 = 0xC005 )
GCC data block types — client to server
const ( ServerCoreDataType uint16 = 0x0C01 ServerSecurityDataType uint16 = 0x0C02 ServerNetworkDataType uint16 = 0x0C03 )
GCC data block types — server to client
const ( VersionRDP4 uint32 = 0x00080001 VersionRDP5 uint32 = 0x00080004 VersionRDP10 uint32 = 0x00080005 VersionRDP61 uint32 = 0x00080006 )
RDP version constants
const ( ColorDepthRNS_UD_COLOR_4BPP uint16 = 0xCA00 ColorDepthRNS_UD_COLOR_8BPP uint16 = 0xCA01 ColorDepthRNS_UD_COLOR_16BPP uint16 = 0xCA02 ColorDepthRNS_UD_COLOR_24BPP uint16 = 0xCA03 )
Color depth constants
const ( HighColor4BPP uint16 = 0x0004 HighColor8BPP uint16 = 0x0008 HighColor15BPP uint16 = 0x000F HighColor16BPP uint16 = 0x0010 HighColor24BPP uint16 = 0x0018 )
High color depth constants
const ( SupportColor24BPP uint16 = 0x0001 SupportColor16BPP uint16 = 0x0002 SupportColor15BPP uint16 = 0x0004 SupportColor32BPP uint16 = 0x0008 )
Supported color depth flags
const ( EarlyCapSupportErrInfoPDU uint16 = 0x0001 EarlyCapWant32BPPSession uint16 = 0x0002 EarlyCapSupportStatusInfoPDU uint16 = 0x0004 EarlyCapStrongAsymmetricKeys uint16 = 0x0008 EarlyCapValidConnectionType uint16 = 0x0020 EarlyCapSupportMonitorLayout uint16 = 0x0040 EarlyCapSupportDynvcGfxProtocol uint16 = 0x0100 )
Early capability flags
const ( KeyboardIBMPC uint32 = 0x00000001 KeyboardIBMAT uint32 = 0x00000002 KeyboardJapan uint32 = 0x00000003 KeyboardEnhanced uint32 = 0x00000004 KeyboardNokia1050 uint32 = 0x00000005 KeyboardNokia9140 uint32 = 0x00000006 KeyboardJapanese uint32 = 0x00000007 )
Keyboard types
const ( ConnectionTypeModem uint8 = 0x01 ConnectionTypeBroadLow uint8 = 0x02 ConnectionTypeSatellite uint8 = 0x03 ConnectionTypeBroadHigh uint8 = 0x04 ConnectionTypeWAN uint8 = 0x05 ConnectionTypeLAN uint8 = 0x06 ConnectionTypeAutoDetect uint8 = 0x07 )
Connection type constants
const ( ChannelOptionInitialized uint32 = 0x80000000 ChannelOptionEncryptRDP uint32 = 0x40000000 ChannelOptionEncryptSC uint32 = 0x20000000 ChannelOptionEncryptCS uint32 = 0x10000000 ChannelOptionPriHigh uint32 = 0x08000000 ChannelOptionPriMed uint32 = 0x04000000 ChannelOptionPriLow uint32 = 0x02000000 ChannelOptionCompressRDP uint32 = 0x00800000 ChannelOptionCompress uint32 = 0x00400000 ChannelOptionShowProtocol uint32 = 0x00200000 )
Channel option flags
const ( RedirectionSupported uint32 = 0x00000001 RedirectedSessionIDFieldValid uint32 = 0x00000002 RedirectionVersion5 uint32 = 0x04 // shifted left 2 in flags field )
Cluster redirection flags (MS-RDPBCGR 2.2.1.3.6)
const ( // BER Application tags for MCS Connect PDUs TagConnectInitial = 101 // Application 101, Constructed TagConnectResponse = 102 // Application 102, Constructed // PER-encoded MCS domain PDU types (first byte) DomainMCSPDUErectDomainRequest = 0x04 DomainMCSPDUAttachUserRequest = 0x28 DomainMCSPDUAttachUserConfirm = 0x2C // top 6 bits: 001011, bottom 2 bits vary DomainMCSPDUChannelJoinRequest = 0x38 DomainMCSPDUChannelJoinConfirm = 0x3C // top 6 bits: 001111, bottom 2 bits vary DomainMCSPDUDisconnectProviderUltimatum = 0x20 // top 6 bits: 001000, bottom 2 bits = reason[2:1] DomainMCSPDUSendDataRequest = 0x64 DomainMCSPDUSendDataIndication = 0x68 )
MCS PDU tag constants (Application class, Constructed)
const MonitorPrimary uint32 = 0x00000001
MonitorPrimary is the flag indicating the primary monitor in MonitorDef.
const SASSequenceRDP uint16 = 0xAA03
SAS (Secure Attention Sequence) constant
Variables ¶
This section is empty.
Functions ¶
func DecodeAttachUserConfirm ¶
DecodeAttachUserConfirm parses an MCS Attach User Confirm PDU. Returns the assigned user channel ID.
func DecodeChannelJoinConfirm ¶
DecodeChannelJoinConfirm parses an MCS Channel Join Confirm PDU. Returns the confirmed channel ID.
func DecodeDisconnectProviderUltimatum ¶
DecodeDisconnectProviderUltimatum parses an MCS Disconnect Provider Ultimatum. Returns the reason code (0=domain-not-hierarchical, 1=user-requested, 2=token-purged, 3=provider-initiated). The DPU is 2 bytes: byte0[1:0] || byte1[7] = 3-bit reason.
func DecodeGCCConferenceCreateResponse ¶
DecodeGCCConferenceCreateResponse extracts server user data from a GCC Conference Create Response.
func DecodeSendDataIndication ¶
func DecodeSendDataIndication(log *slog.Logger, data []byte) (channelID uint16, userData []byte, err error)
DecodeSendDataIndication parses an MCS Send Data Indication PDU (PER-encoded). Returns the channel ID and user data payload.
PER layout:
- Byte 0: type (0x68, top 6 bits = 011010)
- Bytes 1-2: initiator (uint16 BE, offset by 1001) — skipped
- Bytes 3-4: channelID (uint16 BE)
- Byte 5: dataPriority + segmentation
- Remaining: PER length determinant + user data
func DecodeServerData ¶
func DecodeServerData(log *slog.Logger, data []byte) (*ServerCoreData, *ServerSecurityData, *ServerNetworkData, error)
DecodeServerData parses GCC server data blocks from the Conference Create Response userData. Returns server core, security, and network data blocks.
func EncodeAttachUserRequest ¶
func EncodeAttachUserRequest() []byte
EncodeAttachUserRequest builds an MCS Attach User Request PDU (PER-encoded).
func EncodeChannelJoinRequest ¶
EncodeChannelJoinRequest builds an MCS Channel Join Request PDU (PER-encoded).
func EncodeErectDomainRequest ¶
func EncodeErectDomainRequest() []byte
EncodeErectDomainRequest builds an MCS Erect Domain Request PDU (PER-encoded). subHeight=0, subInterval=0
func EncodeGCCConferenceCreateRequest ¶
EncodeGCCConferenceCreateRequest builds the GCC Conference Create Request with client data blocks embedded as PER-encoded user data.
func EncodeSendDataRequest ¶
EncodeSendDataRequest builds an MCS Send Data Request PDU header (PER-encoded).
Types ¶
type ChannelDef ¶
ChannelDef represents a channel definition in the network data.
type ClientClusterData ¶
ClientClusterData represents the TS_UD_CS_CLUSTER client data block.
func (*ClientClusterData) Encode ¶
func (c *ClientClusterData) Encode() []byte
Encode serializes ClientClusterData to bytes (without header).
func (*ClientClusterData) EncodeBlock ¶
func (c *ClientClusterData) EncodeBlock() []byte
EncodeBlock serializes ClientClusterData with type+length header.
type ClientCoreData ¶
type ClientCoreData struct {
Version uint32
DesktopWidth uint16
DesktopHeight uint16
ColorDepth uint16
SASSequence uint16
KeyboardLayout uint32
ClientBuild uint32
ClientName string // max 15 chars, encoded as UTF-16LE (32 bytes)
KeyboardType uint32
KeyboardSubType uint32
KeyboardFunctionKey uint32
ImeFileName string // 64 bytes UTF-16LE
PostBeta2ColorDepth uint16
ClientProductID uint16
SerialNumber uint32
HighColorDepth uint16
SupportedColorDepths uint16
EarlyCapabilityFlags uint16
ClientDigProductID string // 64 bytes UTF-16LE
ConnectionType uint8
Pad1Octet uint8
ServerSelectedProtocol uint32
// Optional DPI fields (RDP 10.0+, MS-RDPBCGR 2.2.1.3.2).
// Set DesktopScaleFactor > 0 to include these in the encoded block.
DesktopPhysicalWidth uint32 // Physical width in mm
DesktopPhysicalHeight uint32 // Physical height in mm
DesktopOrientation uint16 // 0, 90, 180, or 270
DesktopScaleFactor uint32 // 100–500 percent
DeviceScaleFactor uint32 // 100, 140, or 180
}
ClientCoreData represents the TS_UD_CS_CORE client data block.
func DefaultClientCoreData ¶
func DefaultClientCoreData(width, height, depth uint16, selectedProtocol uint32) *ClientCoreData
DefaultClientCoreData returns a ClientCoreData with sensible RDP defaults.
func (*ClientCoreData) Encode ¶
func (c *ClientCoreData) Encode() []byte
Encode serializes ClientCoreData to bytes (without the block header).
func (*ClientCoreData) EncodeBlock ¶
func (c *ClientCoreData) EncodeBlock() []byte
EncodeBlock serializes ClientCoreData with type+length header.
type ClientMonitorData ¶
type ClientMonitorData struct {
Monitors []MonitorDef
}
ClientMonitorData represents the TS_UD_CS_MONITOR client data block (MS-RDPBCGR 2.2.1.3.6).
func (*ClientMonitorData) Encode ¶
func (c *ClientMonitorData) Encode() []byte
Encode serializes ClientMonitorData to bytes (without the block header). Wire format: flags(u32) + monitorCount(u32) + monitorDefArray[](20 bytes each)
func (*ClientMonitorData) EncodeBlock ¶
func (c *ClientMonitorData) EncodeBlock() []byte
EncodeBlock serializes ClientMonitorData with type+length header. Single allocation: header(4) + flags(4) + count(4) + monitors(20*n).
type ClientNetworkData ¶
type ClientNetworkData struct {
Channels []ChannelDef
}
ClientNetworkData represents the TS_UD_CS_NET client network data block.
func (*ClientNetworkData) Encode ¶
func (c *ClientNetworkData) Encode() []byte
Encode serializes ClientNetworkData to bytes (without header).
func (*ClientNetworkData) EncodeBlock ¶
func (c *ClientNetworkData) EncodeBlock() []byte
EncodeBlock serializes ClientNetworkData with type+length header.
type ClientSecurityData ¶
ClientSecurityData represents the TS_UD_CS_SEC client security data block.
func (*ClientSecurityData) Encode ¶
func (c *ClientSecurityData) Encode() []byte
Encode serializes ClientSecurityData to bytes (without header).
func (*ClientSecurityData) EncodeBlock ¶
func (c *ClientSecurityData) EncodeBlock() []byte
EncodeBlock serializes ClientSecurityData with type+length header.
type ConnectInitial ¶
type ConnectInitial struct {
CallingDomainSelector []byte
CalledDomainSelector []byte
UpwardFlag bool
TargetParameters ber.DomainParameters
MinimumParameters ber.DomainParameters
MaximumParameters ber.DomainParameters
UserData []byte // GCC Conference Create Request (encoded)
}
ConnectInitial represents an MCS Connect Initial PDU.
func (*ConnectInitial) Encode ¶
func (ci *ConnectInitial) Encode() []byte
Encode serializes the MCS Connect Initial as BER with Application 101 tag.
type ConnectResponse ¶
type ConnectResponse struct {
Result int
CalledConnectID int
DomainParameters ber.DomainParameters
UserData []byte // GCC Conference Create Response data
}
ConnectResponse represents an MCS Connect Response PDU (parsed from server).
func DecodeConnectResponse ¶
func DecodeConnectResponse(log *slog.Logger, data []byte) (*ConnectResponse, error)
DecodeConnectResponse parses an MCS Connect Response from BER-encoded data.
type MonitorDef ¶
MonitorDef represents a single monitor in TS_MONITOR_DEF (MS-RDPBCGR 2.2.1.3.6).
type ServerCoreData ¶
type ServerCoreData struct {
Version uint32
ClientRequestedProto uint32
EarlyCapabilityFlags uint32
}
ServerCoreData represents the TS_UD_SC_CORE server core data block.
type ServerNetworkData ¶
ServerNetworkData represents the TS_UD_SC_NET server network data block.
type ServerSecurityData ¶
type ServerSecurityData struct {
EncryptionMethod uint32
EncryptionLevel uint32
RawData []byte // Rest of the data (random, certificate, etc.)
}
ServerSecurityData represents the TS_UD_SC_SEC server security data block.