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

Method getfield

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

Source from the content-addressed store, hash-verified

787 """
788
789 def getfield(self, pkt, s):
790 lst = []
791 length = None
792
793 if self.length_from is not None:
794 length = self.length_from(pkt)
795 remain = s
796 if length is not None:
797 remain = s[:length]
798
799 while remain:
800 # block length: afi (2 bytes) + reserved (1 byte) + safi (1 byte) +
801 # orf_number (1 byte) + entries (2 bytes * orf_number)
802 orf_number = orb(remain[4])
803 entries_length = orf_number * 2
804 current = remain[:5 + entries_length]
805 remain = remain[5 + entries_length:]
806 packet = self.m2i(pkt, current)
807 lst.append(packet)
808
809 return remain, lst
810
811
812class BGPCapORF(BGPCapability):

Callers

nothing calls this directly

Calls 4

orbFunction · 0.90
length_fromMethod · 0.45
m2iMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected