MCPcopy Create free account
hub / github.com/ActiveState/code / parse

Method parse

recipes/Python/576662_icmplib/recipe-576662.py:141–153  ·  view source on GitHub ↗

Parse ICMP packet and return an instance of Packet

(cls, packet)

Source from the content-addressed store, hash-verified

139 return ~total
140
141 def parse(cls, packet):
142 """Parse ICMP packet and return an instance of Packet"""
143 string_len = len(packet) - 4 # Ignore IP header
144 pack_format = "!BBH"
145 if string_len:
146 pack_format += "%ss" % string_len
147 unpacked_packet = struct.unpack(pack_format, packet)
148 type, code, checksum = unpacked_packet[:3]
149 try:
150 data = unpacked_packet[3]
151 except IndexError:
152 data = None
153 return cls((type, code), data)
154
155 parse = classmethod(parse)
156

Callers 15

recipe-577549.jsFile · 0.45
do_searchFunction · 0.45
recipe-576750.pyFile · 0.45
xml2objFunction · 0.45
ConvertXmlToDictFunction · 0.45
__init__Method · 0.45
parsefileFunction · 0.45
__init__Method · 0.45
getExifCreationDateFunction · 0.45
recipe-305302.pyFile · 0.45
__init__Method · 0.45
testFunction · 0.45

Calls 2

clsClass · 0.50
unpackMethod · 0.45

Tested by

no test coverage detected