예제 #1
0
파일: traps.py 프로젝트: bharathi26/pycopia
 def read_handler(self):
     ip = struct.unpack("!I", self.recv(4))[0]  # network byte-order
     port = struct.unpack("!H", self.recv(2))[0]  # network byte-order
     length = struct.unpack("i", self.recv(4))[0]  # host byte-order
     src = IpAddress(ip)
     src.port = port
     msg = self.recv(length)
     assert length == len(msg)
     tlv = BER_decode.get_tlv(msg)  # should be community based message
     version, community, pdu = tlv.decode()
     if version == 0:
         pdu = _translate2v2(ip, community, pdu)
     tr = TrapRecord(now(), src, community, pdu)
     for handler in self._handlers:
         # handler returns False/None.  If other handlers may run
         # return False. Return True if handled, and no further processing required.
         if handler(tr):
             break
예제 #2
0
 def handle_read(self):
     ip = struct.unpack("!I", self.recv(4))[0] # network byte-order
     port = struct.unpack("!H", self.recv(2))[0] # network byte-order
     length = struct.unpack("i", self.recv(4))[0] # host byte-order
     src = IpAddress(ip)
     src.port = port
     msg = self.recv(length)
     assert length == len(msg)
     tlv = BER_decode.get_tlv(msg) # should be community based message
     version, community, pdu = tlv.decode()
     if version == 0:
         pdu = _translate2v2(ip, community, pdu)
     arglist = (now(), src, community, pdu)
     for handler in self._handlers:
         # handler returns False/None if other handlers may run,
         # returns True if handled, and no further processing required.
         if handler(*arglist):
             break
예제 #3
0
파일: SNMP.py 프로젝트: bharathi26/pycopia
 def _decode_message(self, message):
     tlv = BER_decode.get_tlv(message)
     version, community, pdu = tlv.decode()
     return CommunityBasedMessage(community, pdu, version)
예제 #4
0
파일: SNMP.py 프로젝트: tijmengit/pycopia
 def _decode_message(self, message):
     tlv = BER_decode.get_tlv(message)
     version, community, pdu = tlv.decode()
     return CommunityBasedMessage(community, pdu, version)
예제 #5
0
 def decode(self):
     from pycopia.SNMP import BER_decode
     tlv = BER_decode.get_tlv(self.tostring())
     return tlv.decode()