MH - Mobility Header

pcapkit.protocols.internet.mh contains MH only, which implements extractor for Mobility Header (MH) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

mh.next

Next Header

1

8

mh.length

Header Length

2

16

mh.type

Mobility Header Type

3

24

Reserved

4

32

mh.chksum

Checksum

6

48

mh.data

Message Data


class pcapkit.protocols.internet.mh.MH(file=None, length=None, **kwargs)[source]

Bases: pcapkit.protocols.internet.internet.Internet

This class implements Mobility Header.

classmethod __index__()[source]

Numeral registry index of the protocol.

Returns

Numeral registry index of the protocol in IANA.

Return type

pcapkit.const.reg.transtype.TransType

__length_hint__()[source]

Return an estimated length for the object.

Return type

Literal[6]

__post_init__(file, length=None, *, extension=False, **kwargs)[source]

Post initialisation hook.

Parameters
  • file (io.BytesIO) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

Keyword Arguments
  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

make(**kwargs)[source]

Make (construct) packet data.

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

read(length=None, *, extension=False, **kwargs)[source]

Read Mobility Header.

Structure of MH header [RFC 6275]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Payload Proto |  Header Len   |   MH Type     |   Reserved    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
|                                                               |
.                                                               .
.                       Message Data                            .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters

length (Optional[int]) – Length of packet data.

Keyword Arguments
  • extension (bool) – If the packet is used as an IPv6 extension header.

  • **kwargs – Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_MH

property length

Header length of current protocol.

Return type

int

property name

Name of current protocol.

Return type

Literal[‘Mobility Header’]

property payload

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

pcapkit.protocols.protocol.Protocol

property protocol

Name of next layer protocol.

Return type

pcapkit.const.reg.transtype.TransType

Data Structure

Important

Following classes are only for documentation purpose. They do NOT exist in the pcapkit module.

class pcapkit.protocols.internet.mh.DataType_MH
Bases

TypedDict

next: pcapkit.const.reg.transtype.TransType

Next header.

length: int

Header length.

type: pcapkit.const.mh.packet.Packet

Mobility header type.

chksum: bytes

Checksum.

data: bytes

Message data.


*

https://en.wikipedia.org/wiki/Mobile_IP#Changes_in_IPv6_for_Mobile_IPv6