def recvChannelJoinConfirm(self, data): """ @summary: Receive a channel join confirm from server client automata function @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.CHANNEL_JOIN_CONFIRM): raise InvalidExpectedDataException("Invalid MCS PDU : CHANNEL_JOIN_CONFIRM expected") confirm = per.readEnumerates(data) userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) if self._userId != userId: raise InvalidExpectedDataException("Invalid MCS User Id") channelId = per.readInteger16(data) #must confirm global channel and user channel if (confirm != 0) and (channelId == Channel.MCS_GLOBAL_CHANNEL or channelId == self._userId): raise InvalidExpectedDataException("Server must confirm static channel") if confirm == 0: serverNet = self._serverSettings.getBlock(gcc.MessageType.SC_NET) for i in range(0, serverNet.channelCount.value): if channelId == serverNet.channelIdArray[i].value: self._channels[channelId] = self._virtualChannels[i][1] self.connectNextChannel()
def recvData(self, data): """ @summary: Main receive method @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if self.readMCSPDUHeader(opcode.value, DomainMCSPDU.DISCONNECT_PROVIDER_ULTIMATUM): log.info("MCS DISCONNECT_PROVIDER_ULTIMATUM") self._transport.close() return #client case elif not self.readMCSPDUHeader(opcode.value, self._receiveOpcode): raise InvalidExpectedDataException("Invalid expected MCS opcode receive data") #server user id per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) channelId = per.readInteger16(data) per.readEnumerates(data) per.readLength(data) #channel id doesn't match a requested layer if not self._channels.has_key(channelId): log.error("receive data for an unconnected layer") return self._channels[channelId].recv(data)
def recvChannelJoinRequest(self, data): """ @summary: Receive for each client channel a request Send Channel Join Confirm or Connect upper layer when all channel are joined @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.CHANNEL_JOIN_REQUEST): raise InvalidExpectedDataException( "Invalid MCS PDU : CHANNEL_JOIN_REQUEST expected") userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) if self._userId != userId: raise InvalidExpectedDataException("Invalid MCS User Id") channelId = per.readInteger16(data) #actually algo support virtual channel but RDPY have no virtual channel confirm = 0 if channelId in self._channels.keys( ) or channelId == self._userId else 1 self.sendChannelJoinConfirm(channelId, confirm) self._nbChannelConfirmed += 1 if self._nbChannelConfirmed == self._serverSettings.getBlock( gcc.MessageType.SC_NET).channelCount.value + 2: self.allChannelConnected()
def recvChannelJoinConfirm(self, data): """ @summary: Receive a channel join confirm from server client automata function @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.CHANNEL_JOIN_CONFIRM): raise InvalidExpectedDataException( "Invalid MCS PDU : CHANNEL_JOIN_CONFIRM expected") confirm = per.readEnumerates(data) userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) if self._userId != userId: raise InvalidExpectedDataException("Invalid MCS User Id") channelId = per.readInteger16(data) #must confirm global channel and user channel if (confirm != 0) and (channelId == Channel.MCS_GLOBAL_CHANNEL or channelId == self._userId): raise InvalidExpectedDataException( "Server must confirm static channel") if confirm == 0: serverNet = self._serverSettings.getBlock(gcc.MessageType.SC_NET) for i in range(0, serverNet.channelCount.value): if channelId == serverNet.channelIdArray[i].value: self._channels[channelId] = self._virtualChannels[i][1] self.connectNextChannel()
def recvData(self, data): """ @summary: Main receive method @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if self.readMCSPDUHeader(opcode.value, DomainMCSPDU.DISCONNECT_PROVIDER_ULTIMATUM): log.info("MCS DISCONNECT_PROVIDER_ULTIMATUM") self._transport.close() return #client case elif not self.readMCSPDUHeader(opcode.value, self._receiveOpcode): raise InvalidExpectedDataException( "Invalid expected MCS opcode receive data") #server user id per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) channelId = per.readInteger16(data) per.readEnumerates(data) per.readLength(data) #channel id doesn't match a requested layer if not self._channels.has_key(channelId): log.error("receive data for an unconnected layer") return self._channels[channelId].recv(data)
def readConferenceCreateResponse(s): ''' read response from server and return server settings read from this response @param s: Stream @return: ServerSettings ''' per.readChoice(s) per.readObjectIdentifier(s, t124_02_98_oid) per.readLength(s) per.readChoice(s) per.readInteger16(s, 1001) per.readInteger(s) per.readEnumerates(s) per.readNumberOfSet(s) per.readChoice(s) if not per.readOctetStream(s, h221_sc_key, 4): raise InvalidExpectedDataException("cannot read h221_sc_key") return readServerDataBlocks(s)
def readConferenceCreateResponse(s): """ @summary: Read response from server and return server settings read from this response @param s: Stream @return: ServerSettings """ per.readChoice(s) per.readObjectIdentifier(s, t124_02_98_oid) per.readLength(s) per.readChoice(s) per.readInteger16(s, 1001) per.readInteger(s) per.readEnumerates(s) per.readNumberOfSet(s) per.readChoice(s) if not per.readOctetStream(s, h221_sc_key, 4): raise InvalidExpectedDataException("cannot read h221_sc_key") length = per.readLength(s) serverSettings = Settings(readLen=CallableValue(length)) s.readType(serverSettings) return serverSettings
def readConferenceCreateResponse(s): """ Read response from server and return server settings read from this response @param s: Stream @return: ServerSettings """ per.readChoice(s) per.readObjectIdentifier(s, t124_02_98_oid) per.readLength(s) per.readChoice(s) per.readInteger16(s, 1001) per.readInteger(s) per.readEnumerates(s) per.readNumberOfSet(s) per.readChoice(s) if not per.readOctetStream(s, h221_sc_key, 4): raise InvalidExpectedDataException("cannot read h221_sc_key") length = per.readLength(s) serverSettings = Settings(readLen = UInt32Le(length)) s.readType(serverSettings) return serverSettings
def recvChannelJoinRequest(self, data): """ @summary: Receive for each client channel a request Send Channel Join Confirm or Connect upper layer when all channel are joined @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.CHANNEL_JOIN_REQUEST): raise InvalidExpectedDataException("Invalid MCS PDU : CHANNEL_JOIN_REQUEST expected") userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) if self._userId != userId: raise InvalidExpectedDataException("Invalid MCS User Id") channelId = per.readInteger16(data) #actually algo support virtual channel but RDPY have no virtual channel confirm = 0 if channelId in self._channels.keys() or channelId == self._userId else 1 self.sendChannelJoinConfirm(channelId, confirm) self._nbChannelConfirmed += 1 if self._nbChannelConfirmed == self._serverSettings.getBlock(gcc.MessageType.SC_NET).channelCount.value + 2: self.allChannelConnected()
def recvAttachUserConfirm(self, data): """ @summary: Receive an attach user confirm Send Connect Channel @param data: {Stream} """ opcode = UInt8() data.readType(opcode) if not self.readMCSPDUHeader(opcode.value, DomainMCSPDU.ATTACH_USER_CONFIRM): raise InvalidExpectedDataException("Invalid MCS PDU : ATTACH_USER_CONFIRM expected") if per.readEnumerates(data) != 0: raise InvalidExpectedDataException("Server reject user") self._userId = per.readInteger16(data, Channel.MCS_USERCHANNEL_BASE) self.connectNextChannel()