L2TPv2 - Layer Two Tunnelling Protocol version 2¶
pcapkit.protocols.link.l2tpv2 contains
L2TPv2 only, which implements extractor
for the Layer Two Tunnelling Protocol version 2 (L2TPv2) [*] as specified by
RFC 2661 – a 16-bit tunnel ID and a 16-bit session ID, with the version nibble
reading 2. It is dispatched from
UDP.__proto__ at port
1701. Its structure is described as below:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Flags and Version Info |
0 |
0 |
|
Type (control / data) |
0 |
1 |
|
Length |
0 |
2 |
Reserved (must be zero |
|
0 |
4 |
|
Sequence |
0 |
5 |
Reserved (must be zero |
|
0 |
6 |
|
Offset |
0 |
7 |
|
Priority |
1 |
8 |
Reserved (must be zero |
|
1 |
12 |
|
Version ( |
2 |
16 |
|
Length (optional by |
4 |
32 |
|
Tunnel ID |
6 |
48 |
|
Session ID |
8 |
64 |
|
Sequence Number (optional by |
10 |
80 |
|
Next Sequence Number (optional by |
12 |
96 |
|
Offset Size (optional by |
Note
The parsed datagram appears under l2tp, not l2tpv2:
info_name is declared on the
version-agnostic base so that a consumer finds the data at the same key
whichever version was on the wire. The version is reported by
alias instead.
IANA protocol number 115 (L2TP) is deliberately left unbound. It
references RFC 3931, i.e. L2TPv3, whose session and control message
headers are a different shape – so the binding waits on an L2TPv3 class
rather than on this one. See pcapkit.protocols.link.l2tp.
- class pcapkit.protocols.link.l2tpv2.L2TPv2(file=None, length=None, **kwargs)[source]¶
-
This class implements Layer Two Tunnelling Protocol version 2.
The protocol is dispatched from
UDP.__proto__at port 1701.Note
IANA protocol number 115 (
L2TP) is deliberately left unbound. It references RFC 3931, i.e. L2TPv3, whose session and control message headers are a different shape – so the binding waits on anL2TPv3class rather than on this one.As with
OSPF, the class subclassesLinkand so reportslayer == 'Link'even though it is carried inside UDP. That is a pre-existing classification, kept because moving the module would change its public import path.- property version: Literal[2]¶
Version of current protocol.
Always
2: RFC 2661 fixes the version nibble, and a datagram carrying any other value is a different protocol reached through a different class. c.f.L2TP.
- read(length=None, **kwargs)[source]¶
Read Layer Two Tunnelling Protocol.
Structure of L2TP header [RFC 2661]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |T|L|x|x|S|x|O|P|x|x|x|x| Ver | Length (opt) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Tunnel ID | Session ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Ns (opt) | Nr (opt) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Offset Size (opt) | Offset pad... (opt) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(version=2, type=<Type.Data: 1>, type_default=None, type_namespace=None, type_reversed=False, priority=False, length=None, tunnel_id=0, session_id=0, ns=None, nr=None, offset=None, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
version (
Literal[2]) – L2TP version.type_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – Namespace of type.type_reversed (
bool) – Reversed namespace of type.priority (
bool) – Priority flag.tunnel_id (
int) – Tunnel ID.session_id (
int) – Session ID.payload (
bytes|ProtocolBase|Schema) – Payload data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- classmethod __index__()[source]¶
Numeral registry index of the protocol.
- Raises:
UnsupportedCall – This protocol has no registry entry.
Note
L2TPv2 is reached through UDP port 1701, and a port is not an
__index__value anywhere in this package – every non-raising__index__returns aTransType,EtherTypeorLinkType, andApplication.__index__raises for exactly this reason. So there is no index to return here.L2TPv3will be the first class in this family with one, IANA protocol number 115.- Return type:
Header Schemas¶
- class pcapkit.protocols.schema.link.l2tp.L2TP(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SchemaHeader schema for L2TP packet.
Type Stubs¶
Data Models¶
- class pcapkit.protocols.data.link.l2tp.L2TP(*args: VT, **kwargs: VT)[source]¶
Bases:
ProtocolData model for L2TP packet.
- class pcapkit.protocols.data.link.l2tp.Flags(*args: VT, **kwargs: VT)[source]¶
Bases:
DataData model for L2TP flags and version info.
Footnotes