L2TP - Layer Two Tunnelling Protocol

pcapkit.protocols.link.l2tp contains L2TP only, which implements extractor for Layer Two Tunnelling Protocol (L2TP) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

l2tp.flags

Flags and Version Info

0

0

l2tp.flags.type

Type (control / data)

0

1

l2tp.flags.len

Length

0

2

Reserved (must be zero x00)

0

4

l2tp.flags.seq

Sequence

0

5

Reserved (must be zero x00)

0

6

l2tp.flags.offset

Offset

0

7

l2tp.flags.prio

Priority

1

8

Reserved (must be zero x00)

1

12

l2tp.ver

Version (2)

2

16

l2tp.length

Length (optional by len)

4

32

l2tp.tunnelid

Tunnel ID

6

48

l2tp.sessionid

Session ID

8

64

l2tp.ns

Sequence Number (optional by seq)

10

80

l2tp.nr

Next Sequence Number (optional by seq)

12

96

l2tp.offset

Offset Size (optional by offset)


class pcapkit.protocols.link.l2tp.L2TP(file=None, length=None, **kwargs)[source]

Bases: Link[L2TP]

This class implements Layer Two Tunnelling Protocol.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

Return type

NoReturn

property name: Literal['Layer 2 Tunnelling Protocol']

Name of current protocol.

Return type

Literal[‘Layer 2 Tunnelling Protocol’]

property length: int

Header length of current protocol.

Return type

int

property type: Literal['control', 'data']

L2TP type.

Return type

Literal[‘control’, ‘data’]

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)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

L2TP

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

Data Structures

class pcapkit.protocols.data.link.l2tp.L2TP(flags, version, length, tunnelid, sessionid, ns, nr, offset)[source]

Bases: Info

Data model for L2TP packet.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Flags

Flags and version info.

version: int

Version.

length: Optional[int]

Length.

tunnelid: int

Tunnel ID.

sessionid: int

Session ID.

ns: Optional[int]

Sequence Number.

nr: Optional[int]

Next Sequence Number.

offset: Optional[int]

Offset Size.

hdr_len: int

Header length.

class pcapkit.protocols.data.link.l2tp.Flags(type, len, seq, offset, prio)[source]

Bases: Info

Data model for L2TP flags and version info.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Type

Type.

len: bool

Length.

seq: bool

Sequence.

offset: bool

Offset.

prio: bool

Priority.


*

https://en.wikipedia.org/wiki/Layer_2_Tunneling_Protocol