Padding Arithmetic

pcapkit.corekit.schema.padding counts the octets of padding that take a length to a boundary, for the padding fields, the schemas’ length callbacks, the protocols’ makers and the capture engines alike.

Added in version 1.6.0.

pcapkit.corekit.schema.padding.pad_length(length, align)[source]

Octets of padding that take length octets to an align-octet boundary.

Parameters:
  • length (int) – Octets to be padded.

  • align (int) – Boundary, in octets.

Returns:

from 0, where length is already a multiple of align, to align - 1.

Return type:

int

Raises:

A schema’s length callbacks are handed the packet data, not a protocol, so this is a plain function and not a protocol method. PaddingField sizes itself by it when given align.

Added in version 1.6.0.