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

Method loop

scapy/packet.py:1178–1204  ·  view source on GitHub ↗
(todo, done, self=self)

Source from the content-addressed store, hash-verified

1176 # type: () -> Iterator[Packet]
1177 """Iterates through all sub-packets generated by this Packet."""
1178 def loop(todo, done, self=self):
1179 # type: (List[str], Dict[str, Any], Any) -> Iterator[Packet]
1180 if todo:
1181 eltname = todo.pop()
1182 elt = self.getfieldval(eltname)
1183 if not isinstance(elt, Gen):
1184 if self.get_field(eltname).islist:
1185 elt = SetGen([elt])
1186 else:
1187 elt = SetGen(elt)
1188 for e in elt:
1189 done[eltname] = e
1190 for x in loop(todo[:], done):
1191 yield x
1192 else:
1193 if isinstance(self.payload, NoPayload):
1194 payloads = SetGen([None]) # type: SetGen[Packet]
1195 else:
1196 payloads = self.payload
1197 for payl in payloads:
1198 # Let's make sure subpackets are consistent
1199 done2 = done.copy()
1200 for k in done2:
1201 if isinstance(done2[k], VolatileValue):
1202 done2[k] = done2[k]._fix()
1203 pkt = self.clone_with(payload=payl, **done2)
1204 yield pkt
1205
1206 if self.explicit or self.raw_packet_cache is not None:
1207 todo = []

Callers

nothing calls this directly

Calls 7

getfieldvalMethod · 0.95
get_fieldMethod · 0.95
clone_withMethod · 0.95
SetGenClass · 0.90
popMethod · 0.80
copyMethod · 0.45
_fixMethod · 0.45

Tested by

no test coverage detected