MCPcopy Create free account
hub / github.com/FDio/vpp / verify_enough_packet_data_in_pcap

Method verify_enough_packet_data_in_pcap

test/vpp_pg_interface.py:475–499  ·  view source on GitHub ↗

Check if enough data is available in file handled by internal pcap reader so that a whole packet can be read. :returns: True if enough data present, else False

(self)

Source from the content-addressed store, hash-verified

473 break
474
475 def verify_enough_packet_data_in_pcap(self):
476 """
477 Check if enough data is available in file handled by internal pcap
478 reader so that a whole packet can be read.
479
480 :returns: True if enough data present, else False
481 """
482 orig_pos = self._pcap_reader.f.tell() # save file position
483 enough_data = False
484 # read packet header from pcap
485 packet_header_size = 16
486 caplen = None
487 end_pos = None
488 hdr = self._pcap_reader.f.read(packet_header_size)
489 if len(hdr) == packet_header_size:
490 # parse the capture length - caplen
491 sec, usec, caplen, wirelen = struct.unpack(
492 self._pcap_reader.endian + "IIII", hdr
493 )
494 self._pcap_reader.f.seek(0, 2) # seek to end of file
495 end_pos = self._pcap_reader.f.tell() # get position at end
496 if end_pos >= orig_pos + len(hdr) + caplen:
497 enough_data = True # yay, we have enough data
498 self._pcap_reader.f.seek(orig_pos, 0) # restore original position
499 return enough_data
500
501 def wait_for_packet(self, timeout, filter_out_fn=is_ipv6_misc):
502 """

Callers 1

wait_for_packetMethod · 0.95

Calls 2

readMethod · 0.45
unpackMethod · 0.45

Tested by

no test coverage detected