Пример #1
0
    def wireDecode(self, wire):
        self.m_hasName = False
        self.m_hasStartBlockId = False
        self.m_hasEndBlockId = False
        self.m_hasProcessId = False
        self.m_hasMaxInterestNum = False
        self.m_hasWatchTimeout = False
        self.m_hasInterestLifetime = False

        #self.m_wire = wire

        decoder = TlvDecoder(wire)

        endOffset = decoder.readNestedTlvsStart(repoTlv.RepoCommandParameter)

        # Name
        if (decoder.peekType(Tlv.Name)):
            self.m_hasName = True
            Tlv0_1WireFormat._decodeName(self.m_name, decoder)

        # Selectors
        if (decoder.peekType(Tlv.Selectors)):
            Tlv0_1WireFormat._decodeSelectors(self.m_selector, decoder)
            self.m_selectors.wireDecode(*val)

        # StartBlockId
        if (decoder.peekType(repoTlv.StartBlockId)):
            self.m_hasStartBlockId = True
            self.m_startBlockId = decoder.readNonNegativeIntegerTlv(
                repoTlv.StartBlockId)

        # EndBlockId
        if (decoder.peekType(repoTlv.EndBlockId)):
            self.m_hasEndBlockId = True
            self.m_endBlockId = decoder.readNonNegativeIntegerTlv(
                repoTlv.EndBlockId)

        # ProcessId
        if (decoder.peekType(repoTlv.ProcessId)):
            self.m_hasProcessId = True
            self.m_processId = decoder.readNonNegativeInteger(
                repoTlv.ProcessId)

        # MaxInterestNum
        if (decoder.peekType(repoTlv.MaxInterestNum)):
            self.m_hasMaxInterestNum = True
            self.m_maxInterestNum = decoder.readNonNegativeInteger(
                repoTlv.MaxInterestNum)

        # WatchTimeout
        if (decoder.peekType(repoTlv.WatchTimeout)):
            self.m_hasWatchTimeout = True
            self.m_watchTimeout = milliseconds(
                decoder.readNonNegativeInteger(repoTlv.WatchTimeout))

        # InterestLifeTime
        if (decoder.peekType(Tlv.InterestLifetime)):
            self.m_hasInterestLifetime = True
            self.m_interestLifetime = milliseconds(
                decoder.readNonNegativeInteger(Tlv.InterestLifetime))
Пример #2
0
 def wireEncodeX(self, encoder):
     # it could be optional non-negative integer, double check
     if self.m_hasProcessId:
         encoder.writeNonNegativeIntegerTlv(repoTlv.ProcessId, self.m_processId)
     
     if self.m_hasEndBlockId:
         encoder.writeNonNegativeIntegerTlv(repoTlv.EndBlockId, self.m_endBlockId)
     
     if self.m_hasStartBlockId:
         encoder.writeNonNegativeIntegerTlv(repoTlv.StartBlockId, self.m_startBlockId)
     
     if self.m_hasMaxInterestNum:
         encoder.writeNonNegativeIntegerTlv(repoTlv.MaxInterestNum, self.m_maxInterestNum)
     
     if self.m_hasWatchTimeout:
         encoder.writeNonNegativeIntegerTlv(repoTlv.WatchTimeout, self.m_watchTimeout)
     
     if self.m_hasInterestLifetime:
         encoder.writeNonNegativeIntegerTlv(repoTlv.InterestLifetime, self.m_interestLifetime)
     
     #if self.m_hasSelectors
     #   encoding interest selectors
     
     if self.m_hasName:
         Tlv0_1WireFormat._encodeName(self.m_name, encoder)
         
     # Get the length of encoder using len(encoder)
     encoder.writeVarNumber(len(encoder))
     encoder.writeVarNumber(repoTlv.RepoCommandParameter)
Пример #3
0
    def wireEncodeX(self, encoder):
        # it could be optional non-negative integer, double check
        if self.m_hasProcessId:
            encoder.writeNonNegativeIntegerTlv(repoTlv.ProcessId,
                                               self.m_processId)

        if self.m_hasEndBlockId:
            encoder.writeNonNegativeIntegerTlv(repoTlv.EndBlockId,
                                               self.m_endBlockId)

        if self.m_hasStartBlockId:
            encoder.writeNonNegativeIntegerTlv(repoTlv.StartBlockId,
                                               self.m_startBlockId)

        if self.m_hasMaxInterestNum:
            encoder.writeNonNegativeIntegerTlv(repoTlv.MaxInterestNum,
                                               self.m_maxInterestNum)

        if self.m_hasWatchTimeout:
            encoder.writeNonNegativeIntegerTlv(repoTlv.WatchTimeout,
                                               self.m_watchTimeout)

        if self.m_hasInterestLifetime:
            encoder.writeNonNegativeIntegerTlv(repoTlv.InterestLifetime,
                                               self.m_interestLifetime)

        #if self.m_hasSelectors
        #   encoding interest selectors

        if self.m_hasName:
            Tlv0_1WireFormat._encodeName(self.m_name, encoder)

        # Get the length of encoder using len(encoder)
        encoder.writeVarNumber(len(encoder))
        encoder.writeVarNumber(repoTlv.RepoCommandParameter)
Пример #4
0
    def wireDecode(self, wire):
        self.m_hasName = False
        self.m_hasStartBlockId = False
        self.m_hasEndBlockId = False
        self.m_hasProcessId = False
        self.m_hasMaxInterestNum = False
        self.m_hasWatchTimeout = False
        self.m_hasInterestLifetime = False

        #self.m_wire = wire
        
        decoder = TlvDecoder(wire)

        endOffset = decoder.readNestedTlvsStart(repoTlv.RepoCommandParameter)
  
        # Name
        if (decoder.peekType(Tlv.Name)):
            self.m_hasName = True
            Tlv0_1WireFormat._decodeName(self.m_name, decoder)

        # Selectors
        if (decoder.peekType(Tlv.Selectors)):
            Tlv0_1WireFormat._decodeSelectors(self.m_selector, decoder)
            self.m_selectors.wireDecode(*val)
      
        # StartBlockId
        if (decoder.peekType(repoTlv.StartBlockId)):
            self.m_hasStartBlockId = True
            self.m_startBlockId = decoder.readNonNegativeIntegerTlv(repoTlv.StartBlockId)
  
        # EndBlockId
        if (decoder.peekType(repoTlv.EndBlockId)):
            self.m_hasEndBlockId = True
            self.m_endBlockId = decoder.readNonNegativeIntegerTlv(repoTlv.EndBlockId)

        # ProcessId
        if (decoder.peekType(repoTlv.ProcessId)):
            self.m_hasProcessId = True
            self.m_processId = decoder.readNonNegativeInteger(repoTlv.ProcessId)

        # MaxInterestNum
        if (decoder.peekType(repoTlv.MaxInterestNum)):
            self.m_hasMaxInterestNum = True
            self.m_maxInterestNum = decoder.readNonNegativeInteger(repoTlv.MaxInterestNum)

        # WatchTimeout
        if (decoder.peekType(repoTlv.WatchTimeout)):
            self.m_hasWatchTimeout = True
            self.m_watchTimeout = milliseconds(decoder.readNonNegativeInteger(repoTlv.WatchTimeout))

        # InterestLifeTime
        if (decoder.peekType(Tlv.InterestLifetime)):
            self.m_hasInterestLifetime = True
            self.m_interestLifetime = milliseconds(decoder.readNonNegativeInteger(Tlv.InterestLifetime))