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

Method _raw_packet_cache_field_value

scapy/packet.py:683–697  ·  view source on GitHub ↗

Get a value representative of a mutable field to detect changes

(self, fld, val, copy=False)

Source from the content-addressed store, hash-verified

681 for fname, fval in fields.items()}
682
683 def _raw_packet_cache_field_value(self, fld, val, copy=False):
684 # type: (AnyField, Any, bool) -> Optional[Any]
685 """Get a value representative of a mutable field to detect changes"""
686 _cpy = lambda x: fld.do_copy(x) if copy else x # type: Callable[[Any], Any]
687 if fld.holds_packets:
688 # avoid copying whole packets (perf: #GH3894)
689 if fld.islist:
690 return [
691 (_cpy(x.fields), x.payload.raw_packet_cache) for x in val
692 ]
693 else:
694 return (_cpy(val.fields), val.payload.raw_packet_cache)
695 elif fld.islist or fld.ismutable:
696 return _cpy(val)
697 return None
698
699 def clear_cache(self):
700 # type: () -> None

Callers 2

self_buildMethod · 0.95
do_dissectMethod · 0.95

Calls 1

do_copyMethod · 0.45

Tested by

no test coverage detected