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

Class PacketList

scapy/plist.py:741–779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

739
740
741class PacketList(_PacketList[Packet],
742 BasePacketList[Packet],
743 _CanvasDumpExtended):
744 def sr(self, multi=False, lookahead=None):
745 # type: (bool, Optional[int]) -> Tuple[SndRcvList, PacketList]
746 """
747 Matches packets in the list
748
749 :param multi: True if a packet can have multiple answers
750 :param lookahead: Maximum number of packets between packet and answer.
751 If 0 or None, full remaining list is
752 scanned for answers
753 :return: ( (matched couples), (unmatched packets) )
754 """
755 remain = self.res[:]
756 sr = [] # type: List[QueryAnswer]
757 i = 0
758 if lookahead is None or lookahead == 0:
759 lookahead = len(remain)
760 while i < len(remain):
761 s = remain[i]
762 j = i
763 while j < min(lookahead + i, len(remain) - 1):
764 j += 1
765 r = remain[j]
766 if r.answers(s):
767 sr.append(QueryAnswer(s, r))
768 if multi:
769 remain[i]._answered = 1
770 remain[j]._answered = 2
771 continue
772 del remain[j]
773 del remain[i]
774 i -= 1
775 break
776 i += 1
777 if multi:
778 remain = [x for x in remain if not hasattr(x, "_answered")]
779 return SndRcvList(sr), PacketList(remain)
780
781
782_PacketIterable = Union[

Callers 15

__init__Method · 0.90
_do_controlMethod · 0.90
debugClass · 0.90
__init__Method · 0.90
__gen_sendFunction · 0.90
__sr_loopFunction · 0.90
_runMethod · 0.90
__init__Method · 0.90
__init__Method · 0.90
make_replyMethod · 0.90
read_allMethod · 0.90
_defrag_logicFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected