MCPcopy Index your code
hub / github.com/secdev/scapy / guess_payload_class

Method guess_payload_class

scapy/packet.py:1111–1128  ·  view source on GitHub ↗

DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism. :param str payload: the layer's payload :return: the payload class

(self, payload)

Source from the content-addressed store, hash-verified

1109 self.add_payload(conf.padding_layer(pad))
1110
1111 def guess_payload_class(self, payload):
1112 # type: (bytes) -> Type[Packet]
1113 """
1114 DEV: Guesses the next payload class from layer bonds.
1115 Can be overloaded to use a different mechanism.
1116
1117 :param str payload: the layer's payload
1118 :return: the payload class
1119 """
1120 for t in self.aliastypes:
1121 for fval, cls in t.payload_guess:
1122 try:
1123 if all(v == self.getfieldval(k)
1124 for k, v in fval.items()):
1125 return cls # type: ignore
1126 except AttributeError:
1127 pass
1128 return self.default_payload_class(payload)
1129
1130 def default_payload_class(self, payload):
1131 # type: (bytes) -> Type[Packet]

Callers 2

do_dissect_payloadMethod · 0.95
processMethod · 0.45

Calls 3

getfieldvalMethod · 0.95
default_payload_classMethod · 0.95
itemsMethod · 0.80

Tested by

no test coverage detected