Container Fields¶
Generic List Fields¶
- class pcapkit.corekit.fields.collections.ListField(length=<function ListField.<lambda>>, item_type=None, callback=<function ListField.<lambda>>)[source]¶
Bases:
FieldBase[list[_TL]],Generic[_TL]Field list for protocol fields.
- Parameters:
length (
Union[int,Callable[[dict[str,Any]],int]]) – Field size (in bytes); if a callable is given, it should return an integer value and accept the current packet as its only argument.item_type (
Optional[FieldBase]) – Field type of the contained items.callback (
Callable[[Self,dict[str,Any]],None]) – Callback function to be called uponself.__call__.
This field is used to represent a list of fields, as in the case of lists of constrant-length-field items in a protocol.
- __call__(packet)[source]¶
Update field attributes.
- Parameters:
- Return type:
Self- Returns:
Updated field instance.
This method will return a new instance of
ListFieldinstead of updating the current instance.
Option List Fields¶
- class pcapkit.corekit.fields.collections.OptionField(length=<function OptionField.<lambda>>, base_schema=None, type_name='type', registry=None, eool=None, callback=<function OptionField.<lambda>>)[source]¶
Bases:
ListField,Generic[_TS]Field list for protocol options.
- Parameters:
length (
Union[int,Callable[[dict[str,Any]],int]]) – Field size (in bytes); if a callable is given, it should return an integer value and accept the current packet as its only argument.base_schema (
Optional[Type[TypeVar(_TS, bound= Schema)]]) – Base schema for option fields.type_name (
str) – Name of the option type field.registry (
Optional[defaultdict[int|IntEnum|IntEnum,Type[TypeVar(_TS, bound= Schema)]]]) – Option registry, as in a mapping from option types (enumeration values) to option schemas, with the default value being the unknown option schema.eool (
Union[int,IntEnum,IntEnum,None]) – Enumeration of the EOOL (end-of-option-list, or equivalent) optioncallback (
Callable[[Self,dict[str,Any]],None]) – Callback function to be called uponself.__call__.
This field is used to represent a list of fields, as in the case of lists of options and/or parameters in a protocol.
- property registry: defaultdict[int | IntEnum | IntEnum, Type[_TS]]¶
Option registry.
- unpack(buffer, packet)[source]¶
Unpack field value from
bytes.- Parameters:
- Return type:
- Returns:
Unpacked field value.
Important
If the option list ended before the specified size limit, set
self.option_paddingas the remaining length to thepacketargument such that the next fields can be aware of such informations.
Type Variables¶
- pcapkit.corekit.fields.collections._TL: pcapkit.protocols.schema.schema.Schema | pcapkit.corekit.fields.field.FieldBase | bytes¶
- pcapkit.corekit.fields.collections._TS: pcapkit.protocols.schema.schema.Schema¶