PPPoE - PPP over Ethernet¶
pcapkit.protocols.link.pppoe.protocol contains
PPPoE,
which implements the extractor for PPP over Ethernet
(PPPoE) [*] of RFC 2516, whose structure is:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Version ( |
0 |
4 |
|
Type ( |
1 |
8 |
|
Code |
2 |
16 |
|
Session ID |
4 |
32 |
|
Length of the payload |
6 |
48 |
|
Tags (discovery stage) |
The Code tells the stages apart: a discovery packet carries tags and no next layer, and a session packet a PPP frame.
Added in version 1.7.0.
- class pcapkit.protocols.link.pppoe.protocol.PPPoE(file, length=None, /, *, layer=None, protocol=None, context=None)[source]¶
-
This class implements PPP over Ethernet.
The packet is dispatched from
Link.__proto__at EtherType0x8863, the discovery stage, and0x8864, the session stage, and fromFrame.__proto__andPCAPNG.__proto__atLINKTYPE_PPP_ETHER. Which stage a packet is in is read from its Code,PPP_Session_Stagebeing the session stage’s (RFC 2516 Section 6), sinceLINKTYPE_PPP_ETHERcarries no EtherType to tell.A discovery packet carries its tags and no next layer. A session packet carries a PPP frame, dispatched as
Link.__proto__dispatches EtherType0x880B. The octets past the Length field are kept astrailer.Added in version 1.7.0.
Properties
Methods
- read(length=None, **kwargs)[source]¶
Read PPP over Ethernet.
Structure of PPPoE header [RFC 2516]:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VER | TYPE | CODE | SESSION_ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LENGTH | payload ~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the version or the type is not
1, or the Length of a discovery packet ends inside a tag. Parsed on its own, a version and type the cut left as zero are the short read’s (#2880).
- make(*, code=Code.PPP_Session_Stage, session_id=0, payload_length=None, tags=None, payload=b'', trailer=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
code (
Code|int) – Code; the session stage’s, or a discovery packet’s.session_id (
int) – Session ID.payload_length (
int|None) – Length field; the length of the payload or of the tags whenNone, which it has to be when given, but in a rebuild of a cut packet.tags (
Iterable[Tag|Mapping[str,Any] |tuple[Tag|int,bytes]] |None) – Tags of a discovery packet, each a(type, value)pair or a mapping of itstype,valueand optionallylength, which has to be that of the value.payload (
bytes|ProtocolBase|Schema) – Payload data, a PPP frame in the session stage.trailer (
bytes) – Octets after the packet, outside the Length field; written as is.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If
codeis a name, or a code its field cannot carry; iftagsis given in the session stage, orpayloadin the discovery stage; iftagsis no iterable of tags, or a tag has notypeorvalue, a type that does not fit, a value that is notbytesor a length other than its value’s; or ifpayload_lengthis not the length of what follows the header.
Data Models
Utilities
- _make_tag(tag)[source]¶
Make a discovery tag.
- Parameters:
tag (
Tag|Mapping[str,Any] |tuple[Tag|int,bytes]) – A(type, value)pair, or a mapping of the tag’stype,valueand optionallylength, by default that of the value.- Return type:
- Returns:
The tag.
- Raises:
ProtocolError – If
tagis neither, or has notypeorvalue; if the type does not fit, or the value is notbytes; or if the length is not the value’s.
Header Schemas¶
- class pcapkit.protocols.link.pppoe.schema.PPPoE(info=NO_VALUE, code=NO_VALUE, session_id=NO_VALUE, length=NO_VALUE, tags=NO_VALUE, payload=NO_VALUE, trailer=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for PPPoE packets.
- info: VersionType = <BitField info>¶
Version and type.
- trailer: bytes = <PayloadField trailer>¶
Octets captured past the Length field, see
L2TP.trailer.
- class pcapkit.protocols.link.pppoe.schema.Tag(type=NO_VALUE, length=NO_VALUE, value=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for PPPoE discovery tags.
Type Stubs¶
Auxiliary Functions¶
- pcapkit.protocols.link.pppoe.schema.pppoe_payload_length(pkt)[source]¶
Length of the
PPPoE.payloadfield.
Data Models¶
- class pcapkit.protocols.link.pppoe.data.PPPoE(version, type, code, session_id, length, tags)[source]¶
Bases:
ProtocolData model for PPPoE packets.
- code: Code¶
Code,
PPP_Session_Stagein the session stage and a discovery packet’s otherwise.
- class pcapkit.protocols.link.pppoe.data.Tag(type, length, value)[source]¶
Bases:
DataData model for PPPoE discovery tags.
Footnotes