IP - Internet Protocol¶
pcapkit.protocols.internet.ip.protocol contains
IP only,
which is a base class for Internet Protocol (IP)
protocol family [*], e.g.
IPv4 and
IPv6. Constructing the base gives the one
its version keyword names; without it, octets give the one their Version field
names, and fields are refused. Its
from_data() reads the version of its
data (#2574).
- class pcapkit.protocols.internet.ip.protocol.IP[_PT: Data, _ST: Schema](file=None, length=None, **kwargs)[source]¶
Bases:
Internet[_PT,_ST],Generic[_PT,_ST]Base class for the IP protocol family.
The IPsec protocols (
AHandESP) derive fromIPsecinstead.It dispatches on both paths, never giving an instance of this class (#2574).
versionnames the member; without it, octets give the one their Version field names, and fields are refused, since no field picks a member.from_data()reads theversionof its data. See__new__().- classmethod from_data(data, **kwargs)[source]¶
Create protocol instance from data.
- Parameters:
**kwargs (
Any) – AsProtocol.from_data.
- Return type:
- Returns:
Protocol instance; on this class, an instance of the member the
versionofdatanames, which both data models carry.- Raises:
ProtocolError – If that
versionis neither4nor6, on this class.
- __init__(file=None, length=None, *, version=None, **kwargs)[source]¶
Initialisation.
- Parameters:
version (
Literal[4,6] |None) – Version of IP,4or6: the member__new__()picks. Building from fields, it must be this class’s own. Parsing, it is handed on unread, as the enclosing IP layer passes its own version under this name to the layer it carries.**kwargs (
Any) – AsProtocol.__init__.
- Raises:
ProtocolError – If, building from fields,
versionnames neither member, or is not this class’s own version: that of the member it is or derives from, which a subclass outside the members does not have.
- static __new__(cls, file=None, length=None, **kwargs)[source]¶
Create the member a construction of this class describes.
The
versionkeyword names the member, on either path. Without it, parsing octets gives the member the Version field in their first four bits names, and building from fields is refused, since no field picks a member. That member’s__init__then runs with the same arguments. A subclass of this class is created as itself.- Parameters:
- Return type:
- Returns:
An uninitialised instance of the member.
- Raises:
ProtocolError – If
versionnames neither member; or, without it, if building from fields, or if the octets are empty or name neither version.
Footnotes