FRAD - Frame Relay Access Device¶
pcapkit.protocols.link.frad contains
FRAD
only, which implements the extractor for Frame Relay’s multiprotocol
encapsulation [*], as seen on a LINKTYPE_FRELAY capture, or on a
LINKTYPE_LINUX_SLL/LINKTYPE_LINUX_SLL2 capture whose arphrd_type is
ARPHRD_FRAD. Its structure, the Q.922
LAPF address onward with no trailing FCS, is described as below:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Q.922 Address (2-octet form) |
2 |
16 |
|
Control ( |
3 |
24 |
|
NLPID, or the |
When nlpid is the 0x00 pad, the NLPID follows it as frad.ext_nlpid.
An NLPID of 0x80, with or without the pad, is followed by a SNAP header, a
3-octet OUI and a 2-octet PID, kept as frad.oui and frad.pid.
- class pcapkit.protocols.link.frad.FRAD(file=None, length=None, **kwargs)[source]¶
-
This class implements Frame Relay Access Device (FRAD) frames.
A frame whose NLPID (after resolving any
0x00pad ahead of it) is0xCCor0x8Edispatches toIPv4orIPv6respectively, registered in theself.__proto__attribute. A SNAP header whose OUI is00-00-00carries an EtherType in its PID, resolved instead through the family registry every Ethernet/VLAN/LinuxSLL frame shares,Link.__proto__– which is how an ARP frame (PID0x0806) over Frame Relay is reached. Every other NLPID (Q.933 signalling, ISO CLNP/ES-IS/IS-IS, FRF.9/FRF.12 compression and fragmentation, PPP-in-Frame-Relay, and a SNAP header whose OUI names a bridged medium rather than an EtherType) is kept asRaw, exactly as everyarphrd_typethis module’s docstring lists already was before this class existed. A frame whose Q.922 address is not the 2-octet form is refused:read()raisesProtocolError. It becomesRawonly behind a caller that catches the error, such asLinuxSLLor aLINKTYPE_FRELAYcapture.- read(length=None, **kwargs)[source]¶
Read Frame Relay Access Device (FRAD) frame.
Structure of a direct-NLPID
FRADframe, the common case: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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DLCI (high) |C/R|EA0| DLCI (low) |FECN|BECN|DE|EA1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Control | NLPID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
A SNAP-encapsulated frame inserts a
0x00pad and a0x80NLPID in place of the single NLPID octet above, followed by a 3-octet OUI and a 2-octet PID (RFC 2427 Section 4.1). The pad may precede any NLPID, or be left out ahead of0x80(RFC 2427 Section 3), andpadrecords whether it is there.- Parameters:
- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the address is not the 2-octet Q.922 form, the only one the schema reads (RFC 2427 Section 3): an EA bit other than
0then1. An EA bit the capture cut off is not checked.
- make(dlci=0, cr=0, fecn=0, becn=0, de=0, control=0x03, nlpid=0xCC, pad=None, snap_oui=None, snap_pid=None, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
dlci (
int) – Data Link Connection Identifier, 10 bits (0to1023).cr (
int) – Command/response indication bit.fecn (
int) – Forward explicit congestion notification bit.becn (
int) – Backward explicit congestion notification bit.de (
int) – Discard eligibility bit.control (
int) – Control field;0x03(UI) for ordinary data traffic.nlpid (
int) – NLPID selecting the encapsulated protocol;0xCCfor IPv4,0x8Efor IPv6,0x80for a SNAP header.pad (
bool|None) – Whether a0x00pad octet precedesnlpid(RFC 2427 Section 3). WhenNone, there is one ahead of a SNAP header alone, as RFC 2427 Section 4.1 writes it, and ahead of annlpidof0, which reads as the pad.snap_oui (
bytes|None) – SNAP OUI; required, and only meaningful, whennlpidis0x80.snap_pid (
int|None) – SNAP PID; required, and only meaningful, whennlpidis0x80.payload (
bytes|ProtocolBase|Schema) – Payload data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If
dlcidoes not fit in 10 bits; ifcr,fecn,becnordeis not0or1; ifcontrolornlpiddoes not fit in 8 bits; ifnlpidis0x80andsnap_ouiis not exactly 3 octets orsnap_piddoes not fit in 16 bits; if eithersnap_ouiorsnap_pidis given whilenlpidis not0x80; or ifpadisFalsewith annlpidof0.
Note
nlpidis not refused for being0– the value of the one pad octet RFC 2427 Section 3 allows, if present, ahead of any NLPID, never an NLPID of its own – even though no caller building a frame from scratch should pass it:from_datareplays a capture that ended inside the header through this same method, and a capture cut short of thenlpidoctet reads as0(zero rather than missing). Rejecting it here would make a short capture fail to rebuild, the one invariant every protocol in this package keeps (#1458). It is written as the pad and an NLPID of0, the octets that read back as it, and the schema’s own short read cuts them back to those captured (#2710).
- classmethod register(code, protocol)[source]¶
Register a new protocol class for an NLPID.
Notes
The fully qualified class name of the new protocol class should be
{protocol.module}.{protocol.name}.- Parameters:
code (
int) – NLPID, after resolving any0x00pad ahead of itprotocol (
ModuleDescriptor[ProtocolBase] |Type[ProtocolBase]) – module descriptor or aProtocolBasesubclass
Important
This overrides
Link.registerbecauseself.__proto__is keyed by NLPID rather than by EtherType.- Raises:
pcapkit.utilities.exceptions.RegistryError – If
protocolis not a class, or not aProtocolBasesubclass.- Warns:
pcapkit.utilities.warnings.RegistryWarning– If this NLPID is already registered and the incumbent differs from the replacement; seeProtocol.registerfor the guard, and for the shipped descriptor a restore puts back (#1504).
- __length_hint__()[source]¶
Return an estimated length for the object.
The longest form – a SNAP-encapsulated header, 10 octets – per the reason
L2TPv2.__length_hint__gives for a variable-length header: the shortest form would reject a fully captured longer header as too short.- Return type:
Literal[10]
- classmethod __index__()[source]¶
Numeral registry index of the protocol.
- Return type:
- Returns:
Numeral registry index of the protocol in tcpdump link-layer header types,
LINKTYPE_FRELAY: a Q.922 LAPF frame from the address field on, with no FCS.LinuxSLL.__proto__names its own key for this class,ARPHRD_FRAD(The Registry Index).
- _import_next_layer(proto, length=None, *, packet=None)[source]¶
Import next layer extractor.
- Parameters:
- Return type:
- Returns:
Instance of next layer. A SNAP header whose OUI is
00-00-00is dispatched throughLink.__proto__instead ofself.__proto__, keyed by the PID as an EtherType – seeread(), which records it asself._snap_ethertype.
- __proto__: DefaultDict[int, ModuleDescriptor[ProtocolBase] | Type[ProtocolBase]]¶
Protocol index mapping for decoding next layer, keyed by the resolved NLPID rather than by EtherType, so this class keeps a registry of its own instead of sharing
Link.__proto__– the same reasonLoopbackkeeps one of its own.
Header Schemas¶
- class pcapkit.protocols.schema.link.frad.FRAD(addr=NO_VALUE, control=NO_VALUE, nlpid=NO_VALUE, ext_nlpid=NO_VALUE, oui=NO_VALUE, pid=NO_VALUE, payload=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for a Frame Relay Access Device (FRAD) frame.
The frame is Frame Relay’s multiprotocol encapsulation [RFC 2427, obsoleting RFC 1490] as presented to a
LINKTYPE_FRELAYcapture, or to aLINKTYPE_LINUX_SLL/LINKTYPE_LINUX_SLL2capture whosearphrd_typeisARPHRD_FRAD: the Q.922 LAPF address onward, with no trailing FCS.- addr: AddressType = <BitField addr>¶
Q.922 address field (2-octet form only; see RFC 2427 Section 3).
- ext_nlpid: int | None = <ConditionalField ext_nlpid>¶
NLPID proper, present only when
nlpidis the pad.
- oui: bytes | None = <ConditionalField oui>¶
SNAP OUI, present only when the frame is SNAP-encapsulated.
Data Models¶
- class pcapkit.protocols.data.link.frad.FRAD(dlci, cr, fecn, becn, de, control, nlpid, pad, snap_oui, snap_pid, len)[source]¶
Bases:
ProtocolData model for a Frame Relay Access Device (FRAD) frame.
- nlpid: int¶
NLPID selecting the encapsulated protocol, with any
0x00pad already resolved to the real value that followed it.
- pad: bool¶
Whether a
0x00pad octet precedes the NLPID (RFC 2427 Section 3).
Footnotes