Members
(readonly) ETHERTYPE :number
Enum for Ethernet child protocols.
Type:
Properties- number
| Name | Type | Description |
|---|---|---|
IP | number | Internet protocol |
ARP | number | Address resolution |
ETHBRIDGE | number | Transparent Ethernet Bridging |
REVARP | number | Reverse ARP |
AT | number | AppleTalk protocol |
AARP | number | AppleTalk ARP |
VLAN | number | IEEE 802.1Q VLAN tagging |
IPX | number | IPX |
IPV6 | number | IP protocol version 6 |
LOOPBACK | number | used to test interfaces |
PPPOED | number | PPPoE discovery |
PPPOES | number | PPPoE session |
MPLS | number | MPLS |
PPP | number | Point-to-point protocol (PPP) |
ROCEV1 | number | RDMA over Converged Ethernet (RoCEv1) |
IEEE_802_1AD | number | IEEE 802.1ad Provider Bridge, Q-in-Q |
WAKE_ON_LAN | number | Wake on LAN |
- Source
(readonly) ICMPTypes :number
Enum for ICMP message types.
Type:
Properties- number
| Name | Type | Description |
|---|---|---|
EchoReply | number | Echo Reply |
DestinationUnreachable | number | Destination Unreachable |
SourceQuench | number | Source Quench |
Redirect | number | Redirect Message |
EchoRequest | number | Echo Request |
TimeExceeded | number | Time Exceeded |
ParameterProblem | number | Parameter Problem |
TimestampRequest | number | Timestamp Request |
TimestampReply | number | Timestamp Reply |
InformationRequest | number | Information Request |
InformationReply | number | Information Reply |
AddressMaskRequest | number | Address Mask Request |
AddressMaskReply | number | Address Mask Reply |
- Source
ICMPv6Types :number
ICMPv6 message types
Type:
Properties- number
| Name | Type | Description |
|---|---|---|
Unknown | number | Unknown ICMPv6 message |
DestinationUnreachable | number | Destination Unreachable Message |
PacketTooBig | number | Packet Too Big Message |
TimeExceeded | number | Time Exceeded Message |
ParameterProblem | number | Parameter Problem Message |
EchoRequest | number | Echo Request Message |
EchoReply | number | Echo Reply Message |
MulticastListenerQuery | number | Multicast Listener Query Message |
MulticastListenerReport | number | Multicast Listener Report Message |
MulticastListenerDone | number | Multicast Listener Done Message |
RouterSolicitation | number | Router Solicitation Message |
RouterAdvertisement | number | Router Advertisement Message |
NeighborSolicitation | number | Neighbor Solicitation Message |
NeighborAdvertisement | number | Neighbor Advertisement Message |
RedirectMessage | number | Redirect Message |
- Source
(readonly) IPProtocolTypes :number
Enum for IPv4 child protocols.
Type:
Properties- number
| Name | Type | Description |
|---|---|---|
IP | number | Dummy protocol for TCP |
HOPOPTS | number | IPv6 Hop-by-Hop options |
ICMP | number | Internet Control Message Protocol |
IGMP | number | Internet Gateway Management Protocol |
IPIP | number | IPIP tunnels (older KA9Q tunnels use 94) |
TCP | number | Transmission Control Protocol |
EGP | number | Exterior Gateway Protocol |
PUP | number | PUP protocol |
UDP | number | User Datagram Protocol |
IDP | number | XNS IDP protocol |
IPV6 | number | IPv6 header |
ROUTING | number | IPv6 Routing header |
FRAGMENT | number | IPv6 fragmentation header |
GRE | number | GRE protocol |
ESP | number | encapsulating security payload |
AH | number | authentication header |
ICMPV6 | number | ICMPv6 |
NONE | number | IPv6 no next header |
DSTOPTS | number | IPv6 Destination options |
VRRP | number | VRRP protocol |
RAW | number | Raw IP packets |
MAX | number | Maximum value |
- Source
(readonly) IPv4OptionTypes :number
Enum for IPv4 options.
Type:
Properties- number
| Name | Type | Description |
|---|---|---|
EndOfOptionsList | number | End of Options List |
NOP | number | No Operation |
RecordRoute | number | Record Route |
MTUProbe | number | MTU Probe |
MTUReply | number | MTU Reply |
QuickStart | number | Quick-Start |
Timestamp | number | Timestamp |
Traceroute | number | Traceroute |
Security | number | Security |
LooseSourceRoute | number | Loose Source Route |
ExtendedSecurity | number | Extended Security |
CommercialSecurity | number | Commercial Security |
StreamID | number | Stream ID |
StrictSourceRoute | number | Strict Source Route |
ExtendedInternetProtocol | number | Extended Internet Protocol |
AddressExtension | number | Address Extension |
RouterAlert | number | Router Alert |
SelectiveDirectedBroadcast | number | Selective Directed Broadcast |
DynamicPacketState | number | Dynamic Packet State |
UpstreamMulticastPkt | number | Upstream Multicast Pkt. |
Unknown | number | Unknown IPv4 option |
- Source
(constant) OsiModelLayers :number
Enum for OSI model layers.
Type:
Properties- number
| Name | Type | Description |
|---|---|---|
Physical | number | Physical layer (layer 1) |
DataLink | number | Data link layer (layer 2) |
Network | number | Network layer (layer 3) |
Transport | number | Transport layer (layer 4) |
Sesion | number | Session layer (layer 5) |
Presentation | number | Presentation layer (layer 6) |
Application | number | Application layer (layer 7) |
Unknown | number | Unknown / null layer |
- Source
Methods
byField(fieldName, table)
Forward dispatcher by a header field.
Parameters:
| Name | Type | Description |
|---|---|---|
fieldName | string | Field on the layer instance whose value selects the next layer class via `table`. |
table | Object.<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. |
- Source
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).
- Source
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 }`.
- Source
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:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | string | Layer name (used for class.name and instance.name). | |||||||||||||||||||||
structSrc | string | struct-compile source string. | |||||||||||||||||||||
meta | Object | <optional> | Properties
|
- Source
nameLength()
Length of a serialized (uncompressed) name.
- Source
parseName(message, offset) → {Object}
Parse a domain name starting at `offset` in `message`.
Parameters:
| Name | Type | Description |
|---|---|---|
message | Buffer | |
offset | number |
- Source
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.
- Source
serializeName()
Serialize a domain name without compression. Trailing dots and empty input both serialize to the single null byte (the root name).
- Source
writeNtpTimestamp()
Convert a JS Date to an NTP 64-bit timestamp written into `buf` at `offset`.
- Source
Type Definitions
DeviceStats
Type:
Properties- Object
| Name | Type | Description |
|---|---|---|
packetsDrop | number | The number of packets dropped. |
packetsDropByInterface | number | The number of packets dropped by the interface. |
packetsRecv | number | The number of packets received. |
- Source
GatewayInfo
Result object containing gateway and interface information.
Type:
Properties- Object
| Name | Type | Description |
|---|---|---|
iface | string | The name of the network interface (e.g., 'eth0', 'wlan0'). |
ip | string | The next-hop gateway IP address, or the destination IP itself if on-link. |
family | string | The address family ('AF_INET' for IPv4 or 'AF_INET6' for IPv6). |
- Source
InterfaceInfo
Type:
Properties- Object
| Name | Type | Description |
|---|---|---|
name | string | The name of the network interface. |
description | string | The description of the network interface. |
mac | string | The MAC address of the network interface. |
gateway | string | The gateway address of the network interface. |
mtu | number | The Maximum Transmission Unit size. |
linktype | string | The link type of the network interface. |
dnsServers | Array.<string> | The DNS servers associated with the network interface. |
addresses | Array.<string> | The IP addresses associated with the network interface. |
- Source
LiveDeviceOptions
Type:
Properties- Object
| Name | Type | Attributes | Description |
|---|---|---|---|
mode | string | <optional> | The mode of the device, either "promiscuous" or "normal". |
direction | string | <optional> | The direction of packet capture, either "inout", "in", or "out". |
packetBufferTimeoutMs | number | <optional> | The packet buffer timeout in milliseconds. |
packetBufferSize | number | <optional> | The size of the packet buffer. |
snapshotLength | number | <optional> | The snapshot length for packet capture. |
nflogGroup | number | <optional> | The NFLOG group. |
iface | string | <optional> | The network interface name. |
filter | string | <optional> | The filter string for packet capture. |
- Source
RouteEntry
A single entry in the system routing table.
Type:
Properties- Object
| Name | Type | Description |
|---|---|---|
destination | string | The destination IP, network, or 'default'. |
prefixLength | number | The network mask prefix length (e.g., 24, 64). |
gateway | string | The gateway IP address. |
metric | number | Route metric value. |
flags | Array.<string> | Array of route flags (e.g., ['U', 'G', 'H']). |
family | string | The address family ('AF_INET' or 'AF_INET6'). |
- Source
TCPFlags
Type:
Properties- Object
| Name | Type | Description |
|---|---|---|
reserved | number | Reserved flag (0 or 1). |
cwr | number | Congestion Window Reduced. |
ece | number | ECN-Echo. |
urg | number | Urgent pointer field significant. |
ack | number | Acknowledgment field significant. |
psh | number | Push Function. |
rst | number | Reset the connection. |
syn | number | Synchronize sequence numbers. |
fin | number | No more data from sender. |
- Source
TLVOption
Type:
Properties- Object
| Name | Type | Description |
|---|---|---|
type | number | The TLV option type. |
length | number | The length of the TLV option value. |
value | Buffer | The TLV option value. |
- Source