MCPcopy
hub / github.com/fortra/impacket / decode

Method decode

impacket/ImpactDecoder.py:130–157  ·  view source on GitHub ↗
(self, aBuffer)

Source from the content-addressed store, hash-verified

128 pass
129
130 def decode(self, aBuffer):
131 i = ImpactPacket.IP(aBuffer)
132 self.set_decoded_protocol ( i )
133 off = i.get_header_size()
134 end = i.get_ip_len()
135 # If ip_len == 0 we might be facing TCP segmentation offload, let's calculate the right len
136 if end == 0:
137 LOG.warning('IP len reported as 0, most probably because of TCP segmentation offload. Attempting to fix its size')
138 i.set_ip_len(len(aBuffer))
139 end = i.get_ip_len()
140
141 if i.get_ip_p() == ImpactPacket.UDP.protocol:
142 self.udp_decoder = UDPDecoder()
143 packet = self.udp_decoder.decode(aBuffer[off:end])
144 elif i.get_ip_p() == ImpactPacket.TCP.protocol:
145 self.tcp_decoder = TCPDecoder()
146 packet = self.tcp_decoder.decode(aBuffer[off:end])
147 elif i.get_ip_p() == ImpactPacket.ICMP.protocol:
148 self.icmp_decoder = ICMPDecoder()
149 packet = self.icmp_decoder.decode(aBuffer[off:end])
150 elif i.get_ip_p() == ImpactPacket.IGMP.protocol:
151 self.igmp_decoder = IGMPDecoder()
152 packet = self.igmp_decoder.decode(aBuffer[off:end])
153 else:
154 self.data_decoder = DataDecoder()
155 packet = self.data_decoder.decode(aBuffer[off:end])
156 i.contains(packet)
157 return i
158
159class IP6MultiProtocolDecoder(Decoder):
160 def __init__(self, a_protocol_id):

Callers

nothing calls this directly

Calls 12

get_header_sizeMethod · 0.95
get_ip_lenMethod · 0.95
set_ip_lenMethod · 0.95
get_ip_pMethod · 0.95
UDPDecoderClass · 0.85
TCPDecoderClass · 0.85
ICMPDecoderClass · 0.85
IGMPDecoderClass · 0.85
DataDecoderClass · 0.85
set_decoded_protocolMethod · 0.80
decodeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected