IP Datagram Analysis¶
pcapkit.foundation.analysis.ip contains
ip_datagram() only, which parses the
payload of an IPv4 or IPv6 datagram that
IPv4 or
IPv6 reassembled.
Added in version 1.6.0.
- pcapkit.foundation.analysis.ip.ip_datagram(datagram, *, layer=None, protocol=None, context=None)[source]¶
Parse the payload of an IP datagram reassembled by
IPv4orIPv6.The payload is dispatched on the datagram’s payload protocol type – the Protocol field for IPv4, the Fragment header’s Next Header for IPv6 – by
Protocol.analyzeofIPv4orIPv6, whichever the datagram’s addresses belong to.- Parameters:
datagram (
Datagram) – Reassembled datagram (reasm.ipv4.datagram or reasm.ipv6.datagram).layer (
str|None) – Layer to parse until, by name;Nonesets no stop.protocol (
str|ProtocolBase|Type[ProtocolBase] |None) – Protocol to parse until, by name, class or instance;Nonesets no stop.context (
ContextRegistry|ProtocolContext|Mapping[str,ProtocolContext] |Iterable[ProtocolContext] |None) – Caller supplied parsing context, in any shapeextract()takes (cf.pcapkit.corekit.context);Nonesupplies none.
- Return type:
- Returns:
The parsed payload. A payload reported as one contiguous run is parsed whether or not
datagramis complete, asstrict=Falsereports an incomplete one.Noneif the payload is the tuple of runs received, asstrict=Truereports an incomplete one.
Note
Datagram.packetholds what this returns given the stops and context the extraction’s engine parses its frames with (#2933), parsed on its first read, unless the reassembly’s__protocol_type__names another protocol, which then parses it instead.Changed in version 1.8.0: Takes keyword-only
layer,protocolandcontext, as the parse behindDatagram.packetdoes (#2947). The payload gets the datagram’s addresses and IP version, as a frame’s IP layer hands its next layer, so an ESP Security Association keyed by destination applies as it does to a frame; and a stop at an IPv6 datagram’s Fragment header keeps its payload raw (#2945).