Esempio n. 1
0
    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) 
Esempio n. 2
0
def readConferenceCreateRequest(s):
    """
    @summary: Read a response from client
    GCC create request
    @param s: Stream
    @param client settings (Settings)
    """
    per.readChoice(s)
    per.readObjectIdentifier(s, t124_02_98_oid)
    per.readLength(s)
    per.readChoice(s)
    per.readSelection(s)
    per.readNumericString(s, 1)
    per.readPadding(s, 1)

    if per.readNumberOfSet(s) != 1:
        raise InvalidExpectedDataException(
            "Invalid number of set in readConferenceCreateRequest")

    if per.readChoice(s) != 0xc0:
        raise InvalidExpectedDataException(
            "Invalid choice in readConferenceCreateRequest")

    per.readOctetStream(s, h221_cs_key, 4)
    length = per.readLength(s)
    clientSettings = Settings(readLen=CallableValue(length))
    s.readType(clientSettings)
    return clientSettings
Esempio n. 3
0
File: gcc.py Progetto: dnozay/rdpy
def readConferenceCreateRequest(s):
    """
    Read a response from client
    GCC create request
    @param s: Stream
    @param client settings (Settings)
    """
    per.readChoice(s)
    per.readObjectIdentifier(s, t124_02_98_oid)
    per.readLength(s)
    per.readChoice(s)
    per.readSelection(s)
    per.readNumericString(s, 1)
    per.readPadding(s, 1)
    
    if per.readNumberOfSet(s) != 1:
        raise InvalidExpectedDataException("Invalid number of set in readConferenceCreateRequest")
    
    if per.readChoice(s) != 0xc0:
        raise InvalidExpectedDataException("Invalid choice in readConferenceCreateRequest")
    
    per.readOctetStream(s, h221_cs_key, 4)
    length = per.readLength(s)
    clientSettings = Settings(readLen = UInt32Le(length))
    s.readType(clientSettings)
    return clientSettings
Esempio n. 4
0
    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)
Esempio n. 5
0
def readServerDataBlocks(s):
    '''
    read gcc server data blocks
    and return result in Server Settings object
    @param s: Stream
    @return: ServerSettings
    '''
    settings = ServerSettings()
    length = per.readLength(s)
    while length > 0:
        marker = s.readLen()
        blockType = UInt16Le()
        blockLength = UInt16Le()
        s.readType((blockType, blockLength))
        #read core block
        if blockType == ServerToClientMessage.SC_CORE:
            s.readType(settings.core)
        #read network block
        elif blockType == ServerToClientMessage.SC_NET:
            settings.channelsId = readServerSecurityData(s)
        #read security block
        #unused in rdpy because use SSL layer
        elif blockType == ServerToClientMessage.SC_SECURITY:
            s.readType(settings.security)
        else:
            print "Unknow server block %s" % hex(type)
        length -= blockLength.value
        s.seek(marker + blockLength.value)

    return settings
Esempio n. 6
0
File: gcc.py Progetto: anees042/rdpy
def readServerDataBlocks(s):
    '''
    read gcc server data blocks
    and return result in Server Settings object
    @param s: Stream
    @return: ServerSettings
    '''
    settings = ServerSettings()
    length = per.readLength(s)
    while length > 0:
        marker = s.readLen()
        blockType = UInt16Le()
        blockLength = UInt16Le()
        s.readType((blockType, blockLength))
        #read core block
        if blockType == ServerToClientMessage.SC_CORE:
            s.readType(settings.core)
        #read network block
        elif blockType == ServerToClientMessage.SC_NET:
            settings.channelsId = readServerSecurityData(s)
        #read security block
        #unused in rdpy because use SSL layer
        elif blockType == ServerToClientMessage.SC_SECURITY:
            s.readType(settings.security)
        else:
            print "Unknow server block %s"%hex(type)
        length -= blockLength.value
        s.seek(marker + blockLength.value)
        
    return settings
Esempio n. 7
0
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)
Esempio n. 8
0
File: gcc.py Progetto: anees042/rdpy
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)
Esempio n. 9
0
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
Esempio n. 10
0
File: gcc.py Progetto: dnozay/rdpy
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