pex.proto.tlv.packet

Module Contents

class pex.proto.tlv.packet.TLVPacket(buffer: bytes = b'', endian: str = 'little')

Bases: object

Subclass of pex.proto.tlv module.

This subclass of pex.proto.tlv module is intended for providing an implementation of TLV protocol stack.

__add__(packet: Any) Any

Add one packet to the current packet.

Parameters:

packet (Any) – TLV packet to add

Return Any:

new TLV packet

__sub__(packet: Any) Any

Remove one packet from the current packet.

Parameters:

packet (Any) – TLV packet to remove

Return Any:

new TLV packet

__len__() int

Get count of TLV objects.

Return int:

count of TLV objects

get_raw(type: int) bytes

Get raw data from packet.

Parameters:

type (int) – type

Return bytes:

raw value

get_string(type: int) str

Get string from packet.

Parameters:

type (int) – type

Return str:

string

get_int(type: int) int | None

Get integer from packet.

Parameters:

type (int) – type

Return Union[int, None]:

integer

add_raw(type: int, value: bytes) None

Add raw data to packet.

Parameters:
  • type (int) – type

  • value (bytes) – value

Return None:

None

add_string(type: int, value: str) None

Add string to packet.

Parameters:
  • type (int) – type

  • value (str) – value

Return None:

None

add_int(type: int, value: int) None

Add integer to packet.

Parameters:
  • type (int) – type

  • value (int) – value

Return None:

None

add_from_dict(values: dict) None

Add packets from dictionary.

Parameters:

values (dict) – type as key, value as item

Return None:

None