예제 #1
0
GETREQUEST              = Enum(0x00|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'GetRequest-PDU')
GETNEXTREQUEST          = Enum(0x01|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'GetNextRequest-PDU')
GETRESPONSE             = Enum(0x02|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'Response-PDU')
SETREQUEST              = Enum(0x03|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'SetRequest-PDU')
TRAPREQUEST             = Enum(0x04|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'Trap-PDU') # obsolete
GETBULKREQUEST          = Enum(0x05|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'GetBulkRequest-PDU')
INFORMREQUEST           = Enum(0x06|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'InformRequest-PDU')
SNMPV2TRAP              = Enum(0x07|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'SNMPv2-Trap-PDU')
REPORT                  = Enum(0x08|_FLAGS['CONTEXT']|_FLAGS['CONSTRUCTOR'], 'Report-PDU')
TAGGEDSEQUENCE          = Enum(0x10|_FLAGS['CONSTRUCTOR'], 'TAGGEDSEQUENCE')

# SNMPv2 errorvalues
NOSUCHOBJECT            = Enum(0x00|_FLAGS['CONTEXT'], 'noSuchObject')
NOSUCHINSTANCE          = Enum(0x01|_FLAGS['CONTEXT'], 'noSuchInstance')
ENDOFMIBVIEW            = Enum(0x02|_FLAGS['CONTEXT'], 'endOfMibView')



if __name__ == "__main__":
    import sys
    from pycopia.aid import str2hex
    print "%20s | %6s | %6.6s | %s" % ("Token name", "intval", "hexstr", "Enum name")
    print "--------------------------------------------------------------------------"
    for _tn in dir(sys.modules[__name__]):
        if _tn.startswith("_"):
            continue
        val = getattr(sys.modules[__name__], _tn)
        if type(val) is Enum:
            print "%20s | %6d | %6.6s | %s" % (_tn, val, str2hex(chr(val)), val)

예제 #2
0
 def __str__(self):
     return "<TLV: tag='%s', length=%d, value='%s'>" % (str2hex(self.tag), self.length, str2hex(self.value))
예제 #3
0
 def decode(self):
     try:
         return DECODE_METHODS[self.tag](self.length, self.value)
     except KeyError:
         raise BERUnknownTag("TLV.decode: tag %r is unknown" % (str2hex(self.tag),))
예제 #4
0
                   'Trap-PDU')  # obsolete
GETBULKREQUEST = Enum(0x05 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                      'GetBulkRequest-PDU')
INFORMREQUEST = Enum(0x06 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                     'InformRequest-PDU')
SNMPV2TRAP = Enum(0x07 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                  'SNMPv2-Trap-PDU')
REPORT = Enum(0x08 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'], 'Report-PDU')
TAGGEDSEQUENCE = Enum(0x10 | _FLAGS['CONSTRUCTOR'], 'TAGGEDSEQUENCE')

# SNMPv2 errorvalues
NOSUCHOBJECT = Enum(0x00 | _FLAGS['CONTEXT'], 'noSuchObject')
NOSUCHINSTANCE = Enum(0x01 | _FLAGS['CONTEXT'], 'noSuchInstance')
ENDOFMIBVIEW = Enum(0x02 | _FLAGS['CONTEXT'], 'endOfMibView')

if __name__ == "__main__":
    import sys
    from pycopia.aid import str2hex
    print("%20s | %6s | %6.6s | %s" %
          ("Token name", "intval", "hexstr", "Enum name"))
    print(
        "--------------------------------------------------------------------------"
    )
    for _tn in dir(sys.modules[__name__]):
        if _tn.startswith("_"):
            continue
        val = getattr(sys.modules[__name__], _tn)
        if type(val) is Enum:
            print("%20s | %6d | %6.6s | %s" %
                  (_tn, val, str2hex(chr(val)), val))
예제 #5
0
파일: headers.py 프로젝트: wildone/pycopia
    def __getitem__(self, name):
        return self._data[name]

    def __delitem__(self, name):
        del self._data[name]



if __name__ == "__main__":

    from pycopia import aid
    from pycopia import autodebug

    pdu = LoginPDU()
    pdu.ISID = ISID(0, 0x023d, 3, 0)
    buf = pdu.encode()
    print aid.str2hex(buf)
    pdu.transit = True
    pdu.next_stage = FULL_FEATURE_PHASE
    pdu.next_stage = OP_PARMS_NEGOTIATION_STAGE
    pdu["SessionType"] = "Normal"
    pdu["AuthMethod"] = "Chap,None"
    buf = pdu.encode()
    print aid.str2hex(buf)
    assert buf[0] == chr(0x03 + 0x40)
    assert buf[1] == chr(0x81)
    assert len(buf) % 4 == 0


예제 #6
0
 def decode(self):
     try:
         return DECODE_METHODS[self.tag](self.length, self.value)
     except KeyError:
         raise BERUnknownTag("TLV.decode: tag %r is unknown" %
                             (str2hex(self.tag), ))
예제 #7
0
 def __str__(self):
     return "<TLV: tag='%s', length=%d, value='%s'>" % (str2hex(
         self.tag), self.length, str2hex(self.value))
예제 #8
0
                  'SetRequest-PDU')
TRAPREQUEST = Enum(0x04 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                   'Trap-PDU')  # obsolete
GETBULKREQUEST = Enum(0x05 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                      'GetBulkRequest-PDU')
INFORMREQUEST = Enum(0x06 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                     'InformRequest-PDU')
SNMPV2TRAP = Enum(0x07 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'],
                  'SNMPv2-Trap-PDU')
REPORT = Enum(0x08 | _FLAGS['CONTEXT'] | _FLAGS['CONSTRUCTOR'], 'Report-PDU')
TAGGEDSEQUENCE = Enum(0x10 | _FLAGS['CONSTRUCTOR'], 'TAGGEDSEQUENCE')

# SNMPv2 errorvalues
NOSUCHOBJECT = Enum(0x00 | _FLAGS['CONTEXT'], 'noSuchObject')
NOSUCHINSTANCE = Enum(0x01 | _FLAGS['CONTEXT'], 'noSuchInstance')
ENDOFMIBVIEW = Enum(0x02 | _FLAGS['CONTEXT'], 'endOfMibView')

if __name__ == "__main__":
    import sys
    from pycopia.aid import str2hex
    print "%20s | %6s | %6.6s | %s" % ("Token name", "intval", "hexstr",
                                       "Enum name")
    print "--------------------------------------------------------------------------"
    for _tn in dir(sys.modules[__name__]):
        if _tn.startswith("_"):
            continue
        val = getattr(sys.modules[__name__], _tn)
        if type(val) is Enum:
            print "%20s | %6d | %6.6s | %s" % (_tn, val, str2hex(
                chr(val)), val)