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

Method sr

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

Matches packets in the list :param multi: True if a packet can have multiple answers :param lookahead: Maximum number of packets between packet and answer. If 0 or None, full remaining list is scanned for answers :

(self, multi=False, lookahead=None)

Source from the content-addressed store, hash-verified

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 2

_scanMethod · 0.45

Calls 4

SndRcvListClass · 0.85
PacketListClass · 0.85
answersMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected