MCPcopy Create free account
hub / github.com/secdev/scapy / getfield

Method getfield

scapy/contrib/bgp.py:1109–1138  ·  view source on GitHub ↗
(self, pkt, s)

Source from the content-addressed store, hash-verified

1107 """
1108
1109 def getfield(self, pkt, s):
1110 lst = []
1111 length = 0
1112
1113 if self.length_from is not None:
1114 length = self.length_from(pkt)
1115 ret = ""
1116 remain = s
1117 if length is not None:
1118 remain, ret = s[:length], s[length:]
1119
1120 while remain:
1121 #
1122 # Get the path attribute flags
1123 flags = orb(remain[0])
1124
1125 attr_len = 0
1126 if has_extended_length(flags):
1127 attr_len = struct.unpack("!H", remain[2:4])[0]
1128 current = remain[:4 + attr_len]
1129 remain = remain[4 + attr_len:]
1130 else:
1131 attr_len = orb(remain[2])
1132 current = remain[:3 + attr_len]
1133 remain = remain[3 + attr_len:]
1134
1135 packet = self.m2i(pkt, current)
1136 lst.append(packet)
1137
1138 return remain + ret, lst
1139
1140
1141#

Callers

nothing calls this directly

Calls 5

orbFunction · 0.90
has_extended_lengthFunction · 0.85
length_fromMethod · 0.45
m2iMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected