Members

(readonly) ETHERTYPE :number

Enum for Ethernet child protocols.
Type:
  • number
Properties
NameTypeDescription
IPnumberInternet protocol
ARPnumberAddress resolution
ETHBRIDGEnumberTransparent Ethernet Bridging
REVARPnumberReverse ARP
ATnumberAppleTalk protocol
AARPnumberAppleTalk ARP
VLANnumberIEEE 802.1Q VLAN tagging
IPXnumberIPX
IPV6numberIP protocol version 6
LOOPBACKnumberused to test interfaces
PPPOEDnumberPPPoE discovery
PPPOESnumberPPPoE session
MPLSnumberMPLS
PPPnumberPoint-to-point protocol (PPP)
ROCEV1numberRDMA over Converged Ethernet (RoCEv1)
IEEE_802_1ADnumberIEEE 802.1ad Provider Bridge, Q-in-Q
WAKE_ON_LANnumberWake on LAN

(readonly) ICMPTypes :number

Enum for ICMP message types.
Type:
  • number
Properties
NameTypeDescription
EchoReplynumberEcho Reply
DestinationUnreachablenumberDestination Unreachable
SourceQuenchnumberSource Quench
RedirectnumberRedirect Message
EchoRequestnumberEcho Request
TimeExceedednumberTime Exceeded
ParameterProblemnumberParameter Problem
TimestampRequestnumberTimestamp Request
TimestampReplynumberTimestamp Reply
InformationRequestnumberInformation Request
InformationReplynumberInformation Reply
AddressMaskRequestnumberAddress Mask Request
AddressMaskReplynumberAddress Mask Reply

ICMPv6Types :number

ICMPv6 message types
Type:
  • number
Properties
NameTypeDescription
UnknownnumberUnknown ICMPv6 message
DestinationUnreachablenumberDestination Unreachable Message
PacketTooBignumberPacket Too Big Message
TimeExceedednumberTime Exceeded Message
ParameterProblemnumberParameter Problem Message
EchoRequestnumberEcho Request Message
EchoReplynumberEcho Reply Message
MulticastListenerQuerynumberMulticast Listener Query Message
MulticastListenerReportnumberMulticast Listener Report Message
MulticastListenerDonenumberMulticast Listener Done Message
RouterSolicitationnumberRouter Solicitation Message
RouterAdvertisementnumberRouter Advertisement Message
NeighborSolicitationnumberNeighbor Solicitation Message
NeighborAdvertisementnumberNeighbor Advertisement Message
RedirectMessagenumberRedirect Message

(readonly) IPProtocolTypes :number

Enum for IPv4 child protocols.
Type:
  • number
Properties
NameTypeDescription
IPnumberDummy protocol for TCP
HOPOPTSnumberIPv6 Hop-by-Hop options
ICMPnumberInternet Control Message Protocol
IGMPnumberInternet Gateway Management Protocol
IPIPnumberIPIP tunnels (older KA9Q tunnels use 94)
TCPnumberTransmission Control Protocol
EGPnumberExterior Gateway Protocol
PUPnumberPUP protocol
UDPnumberUser Datagram Protocol
IDPnumberXNS IDP protocol
IPV6numberIPv6 header
ROUTINGnumberIPv6 Routing header
FRAGMENTnumberIPv6 fragmentation header
GREnumberGRE protocol
ESPnumberencapsulating security payload
AHnumberauthentication header
ICMPV6numberICMPv6
NONEnumberIPv6 no next header
DSTOPTSnumberIPv6 Destination options
VRRPnumberVRRP protocol
RAWnumberRaw IP packets
MAXnumberMaximum value

(readonly) IPv4OptionTypes :number

Enum for IPv4 options.
Type:
  • number
Properties
NameTypeDescription
EndOfOptionsListnumberEnd of Options List
NOPnumberNo Operation
RecordRoutenumberRecord Route
MTUProbenumberMTU Probe
MTUReplynumberMTU Reply
QuickStartnumberQuick-Start
TimestampnumberTimestamp
TraceroutenumberTraceroute
SecuritynumberSecurity
LooseSourceRoutenumberLoose Source Route
ExtendedSecuritynumberExtended Security
CommercialSecuritynumberCommercial Security
StreamIDnumberStream ID
StrictSourceRoutenumberStrict Source Route
ExtendedInternetProtocolnumberExtended Internet Protocol
AddressExtensionnumberAddress Extension
RouterAlertnumberRouter Alert
SelectiveDirectedBroadcastnumberSelective Directed Broadcast
DynamicPacketStatenumberDynamic Packet State
UpstreamMulticastPktnumberUpstream Multicast Pkt.
UnknownnumberUnknown IPv4 option

(constant) OsiModelLayers :number

Enum for OSI model layers.
Type:
  • number
Properties
NameTypeDescription
PhysicalnumberPhysical layer (layer 1)
DataLinknumberData link layer (layer 2)
NetworknumberNetwork layer (layer 3)
TransportnumberTransport layer (layer 4)
SesionnumberSession layer (layer 5)
PresentationnumberPresentation layer (layer 6)
ApplicationnumberApplication layer (layer 7)
UnknownnumberUnknown / null layer

Methods

byField(fieldName, table)

Forward dispatcher by a header field.
Parameters:
NameTypeDescription
fieldNamestringField on the layer instance whose value selects the next layer class via `table`.
tableObject.<number, string>Map field-value -> layer-name. Returns: - apply(proto): wires proto.nextProto to look up the next layer class in the runtime `layers` map by table[this[fieldName]]. Falls back to layers.Payload when the value is unknown. The function body is generated via new Function so that `this.${fieldName}` is a named property load (LdaNamedProperty) rather than a keyed one. - reverseDefault(fallback): builds a defaults-table function that, on build, picks the field value back from this.next.name. Removes the duplication between forward (parse) and reverse (build) maps that was previously split between child.lookupChild / child.lookupKey.

byPort()

Port-based dispatcher (UDP). Looks up the child layer class by destination port first, then source port, and bounds the slice by `this.totalLength` so trailing Ethernet padding doesn't bleed into the child layer. Codegen hardcodes the `this.dst` / `this.src` / `this.totalLength` named property loads for V8 inline-cache friendliness. No reverseDefault: there's no canonical inverse mapping (which port a UDP datagram should advertise depends on direction).

macAddress()

Descriptor factories for `attach.virtualField`. Centralise the MAC/IPv4/IPv6 read/write boilerplate so per-protocol IIFEs read as a declarative list of accessors instead of repeating byte-buffer slicing. Each factory takes the byte offset of the address inside the layer's underlying buffer (`this._buf`) and returns `{ get, set }`.

makeLayer(name, structSrc, metaopt)

Creates a Layer class on top of a struct-compile-generated header. The generated constructor follows the immutable-packet pattern shared by every layer: take a Buffer or an object, allocate the header buffer via toAlloc when given an object, run mixins.ctor for prev/next links, and then set this.length. Returns { Layer, proto, Header, baseLength } so that mixins (attach.*) can wire additional behaviour into the prototype after construction.
Parameters:
NameTypeAttributesDescription
namestringLayer name (used for class.name and instance.name).
structSrcstringstruct-compile source string.
metaObject<optional>
Properties
NameTypeAttributesDescription
osinumber<optional>
OsiModelLayers value.
linktypenumber<optional>
LinkLayerType value (for L2 layers).
lengthfunction | false<optional>
`(self) => number` for runtime length (e.g. headerLength*4). `false` to skip the assignment entirely when the layer installs its own length getter on the prototype (ICMP/ICMPv6, where length depends on `type`). Defaults to baseLength.
toAllocfunction<optional>
`(data) => number` for allocation size when constructing from an object. Defaults to constant baseLength. `attach.options.tlv8` wraps this to add the serialized options length.

nameLength()

Length of a serialized (uncompressed) name.

parseName(message, offset) → {Object}

Parse a domain name starting at `offset` in `message`.
Parameters:
NameTypeDescription
messageBuffer
offsetnumber
Returns:
`next` is the offset right after the name in the original (uncompressed) stream; not where pointer-following landed.
Type: 
Object

readNtpTimestamp()

Read an NTP 64-bit timestamp from `buf` at `offset` and return a JS Date. Returns `null` for the all-zero "unspecified" timestamp.

serializeName()

Serialize a domain name without compression. Trailing dots and empty input both serialize to the single null byte (the root name).

writeNtpTimestamp()

Convert a JS Date to an NTP 64-bit timestamp written into `buf` at `offset`.

Type Definitions

DeviceStats

Type:
  • Object
Properties
NameTypeDescription
packetsDropnumberThe number of packets dropped.
packetsDropByInterfacenumberThe number of packets dropped by the interface.
packetsRecvnumberThe number of packets received.

GatewayInfo

Result object containing gateway and interface information.
Type:
  • Object
Properties
NameTypeDescription
ifacestringThe name of the network interface (e.g., 'eth0', 'wlan0').
ipstringThe next-hop gateway IP address, or the destination IP itself if on-link.
familystringThe address family ('AF_INET' for IPv4 or 'AF_INET6' for IPv6).

InterfaceInfo

Type:
  • Object
Properties
NameTypeDescription
namestringThe name of the network interface.
descriptionstringThe description of the network interface.
macstringThe MAC address of the network interface.
gatewaystringThe gateway address of the network interface.
mtunumberThe Maximum Transmission Unit size.
linktypestringThe link type of the network interface.
dnsServersArray.<string>The DNS servers associated with the network interface.
addressesArray.<string>The IP addresses associated with the network interface.

LiveDeviceOptions

Type:
  • Object
Properties
NameTypeAttributesDescription
modestring<optional>
The mode of the device, either "promiscuous" or "normal".
directionstring<optional>
The direction of packet capture, either "inout", "in", or "out".
packetBufferTimeoutMsnumber<optional>
The packet buffer timeout in milliseconds.
packetBufferSizenumber<optional>
The size of the packet buffer.
snapshotLengthnumber<optional>
The snapshot length for packet capture.
nflogGroupnumber<optional>
The NFLOG group.
ifacestring<optional>
The network interface name.
filterstring<optional>
The filter string for packet capture.

RouteEntry

A single entry in the system routing table.
Type:
  • Object
Properties
NameTypeDescription
destinationstringThe destination IP, network, or 'default'.
prefixLengthnumberThe network mask prefix length (e.g., 24, 64).
gatewaystringThe gateway IP address.
metricnumberRoute metric value.
flagsArray.<string>Array of route flags (e.g., ['U', 'G', 'H']).
familystringThe address family ('AF_INET' or 'AF_INET6').

TCPFlags

Type:
  • Object
Properties
NameTypeDescription
reservednumberReserved flag (0 or 1).
cwrnumberCongestion Window Reduced.
ecenumberECN-Echo.
urgnumberUrgent pointer field significant.
acknumberAcknowledgment field significant.
pshnumberPush Function.
rstnumberReset the connection.
synnumberSynchronize sequence numbers.
finnumberNo more data from sender.

TLVOption

Type:
  • Object
Properties
NameTypeDescription
typenumberThe TLV option type.
lengthnumberThe length of the TLV option value.
valueBufferThe TLV option value.