BOOTP - Bootstrap Protocol

pcapkit.protocols.application.bootp.protocol holds BOOTP, the extractor for Bootstrap Protocol (BOOTP) messages [RFC 951, RFC 1542], laid out as protocol gives. Its last field, vend, holds the vendor extensions of RFC 1497 and RFC 2132 sections 3 to 8 where the magic cookie opens it, and is vendor-specific octets otherwise.

Added in version 1.10.0.

class pcapkit.protocols.application.bootp.protocol.BOOTP(file, length=None, /, *, layer=None, protocol=None, context=None)[source]

Bases: DHCP[BOOTP, DHCP]

This class implements the Bootstrap Protocol.

A message whose options carry the DHCP Message Type option is a DHCP one, which DHCPv4 reads, so this class refuses it, on both paths. Its vendor extensions decode as DHCP gives, for the codes of VENDOR_EXTENSIONS alone; the sname and file fields are text, which no Option Overload option overloads here. A vendor extension the area ends inside, as a capture cut leaves one, keeps its octets as the padding, and the cut is recorded as DHCPv4 records it.

Added in version 1.10.0.

Properties

property name: Literal['Bootstrap Protocol']

Name of current protocol.

Methods

classmethod id()[source]

Index ID of the protocol.

Return type:

tuple[Literal['BOOTP']]

Returns:

Index ID of the protocol, narrowed to this member’s canonical name.

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

Read Bootstrap Protocol.

Structure of a BOOTP message [RFC 951 Section 3]:

 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
+---------------+---------------+---------------+---------------+
|     op (1)    |   htype (1)   |   hlen (1)    |   hops (1)    |
+---------------+---------------+---------------+---------------+
|                            xid (4)                            |
+-------------------------------+-------------------------------+
|           secs (2)            |           flags (2)           |
+-------------------------------+-------------------------------+
|                          ciaddr  (4)                          |
+---------------------------------------------------------------+
|                          yiaddr  (4)                          |
+---------------------------------------------------------------+
|                          siaddr  (4)                          |
+---------------------------------------------------------------+
|                          giaddr  (4)                          |
+---------------------------------------------------------------+
|                          chaddr  (16)                         |
+---------------------------------------------------------------+
|                          sname   (64)                         |
+---------------------------------------------------------------+
|                          file    (128)                        |
+---------------------------------------------------------------+
|                          vend    (64)                         |
+---------------------------------------------------------------+
Parameters:
  • length (int | None) – Length of packet data.

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

Return type:

BOOTP

Returns:

Parsed packet data.

Raises:

ProtocolError – If the options carry the DHCP Message Type option.

make(*, op=Opcode.BOOTREQUEST, htype=Hardware.Ethernet, hlen=None, hops=0, xid=0, secs=0, flags=0, ciaddr='0.0.0.0', yiaddr='0.0.0.0', siaddr='0.0.0.0', giaddr='0.0.0.0', chaddr=b'', chaddr_padding=None, sname=b'', file=b'', vend=(), padding=b'', payload=b'', **kwargs)[source]

Make (construct) packet data.

Parameters:
  • op (Opcode | int) – Message op code.

  • htype (Hardware | int) – Hardware address type.

  • hlen (int | None) – Hardware address length; that of chaddr if None.

  • hops (int) – Hops.

  • xid (int) – Transaction ID.

  • secs (int) – Seconds elapsed since the client began.

  • flags (Mapping[str, Any] | int) – Flags, as their data model or a mapping of its keys, or the two octets as an integer.

  • ciaddr (IPv4Address | str | bytes | int) – Client IP address.

  • yiaddr (IPv4Address | str | bytes | int) – Your (client) IP address.

  • siaddr (IPv4Address | str | bytes | int) – Server IP address.

  • giaddr (IPv4Address | str | bytes | int) – Gateway IP address.

  • chaddr (str | bytes) – Client hardware address: a MAC address for an Ethernet or IEEE 802 type, or its octets.

  • chaddr_padding (bytes | None) – Octets of chaddr after the address; zeros filling the field if None.

  • sname (bytes) – Server host name, which NULs fill out.

  • file (bytes) – Boot file name, which NULs fill out.

  • vend (Iterable[Mapping[str, Any]] | bytes) – Vendor area: its vendor extensions, each a mapping as Option holds it, written after the magic cookie, or its raw octets.

  • padding (bytes) – Octets after the End option, or with none, the vendor extension the area ends inside; given with vendor extensions.

  • payload (bytes | ProtocolBase | Schema) – Octets after the message.

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

Return type:

DHCP

Returns:

Constructed packet data.

Raises:

ProtocolError – If a field does not fit its width; if an option is malformed or builds a code outside the vendor extensions from fields; or if the vendor extensions carry the DHCP Message Type option, which makes a DHCP message.

Utilities

classmethod _make_data(data)[source]

Create key-value pairs from data for protocol construction.

Parameters:

data (BOOTP) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

Data Models

class pcapkit.protocols.application.bootp.data.BOOTP(op, htype, hlen, hops, xid, secs, flags, ciaddr, yiaddr, siaddr, giaddr, chaddr, chaddr_padding, sname, file, magic_cookie, vend, padding)[source]

Bases: Protocol

Data model for a BOOTP message (RFC 951 Section 3, RFC 1542).

op: Opcode

Message op code.

htype: Hardware

Hardware address type.

hlen: int

Hardware address length.

hops: int

Hops.

xid: int

Transaction ID.

secs: int

Seconds elapsed since the client began.

flags: Flags

Flags.

ciaddr: IPv4Address

Client IP address.

yiaddr: IPv4Address

Your (client) IP address.

siaddr: IPv4Address

Server IP address.

giaddr: IPv4Address

Gateway IP address.

chaddr: str | bytes

Client hardware address, its first hlen octets; a MAC address for an Ethernet or IEEE 802 type of six octets.

chaddr_padding: bytes

The octets of chaddr after the address.

sname: bytes

Server host name, its trailing NULs removed.

file: bytes

Boot file name, its trailing NULs removed.

The magic cookie opening vend, or None where it holds no vendor extensions.

vend: tuple[Option, ...] | bytes

Vendor area, its vendor extensions (RFC 1497, RFC 2132) where magic_cookie opens it, else its raw octets.

padding: bytes

Octets after the End option, or from the vendor extension the area ends inside.

Constants

pcapkit.protocols.application.bootp.const.VENDOR_EXTENSIONS = frozenset({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 64, 65, 68, 69, 70, 71, 72, 73, 74, 75, 76, 255})

Codes of the vendor extensions a BOOTP message carries, which its option parsers decode: those of RFC 2132 sections 3 to 8, the RFC 1497 extensions and their successors. Section 9 and every later option are DHCP’s.