sllHeader(): Coder<SllHeader>
Creates a coder for a Linux cooked capture v1 (DLT_LINUX_SLL) header.
Layout: packetType (u16be), arphrdType (u16be), linkLayerAddressLength
(u16be), linkLayerAddress (fixed 8 bytes), protocol (u16be), then
payload as the rest of the buffer.
Nothing is validated or derived on encode — linkLayerAddressLength and
the padding within linkLayerAddress are written exactly as given.
Decode a known-wire ARP-carrying header
Decode a known-wire ARP-carrying header
import { assertEquals } from "@std/assert"; import { sllHeader, SLL_HEADER_SIZE, SLL_PACKET_TYPE } from "@binstruct/sll"; // deno-fmt-ignore const wire = new Uint8Array([ 0x00, 0x00, // packetType: HOST 0x00, 0x01, // arphrdType: ARPHRD_ETHER 0x00, 0x06, // linkLayerAddressLength: 6 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x00, // linkLayerAddress (8 bytes) 0x08, 0x06, // protocol: ARP 0x00, 0x01, 0x08, 0x00, // payload ]); const [decoded, read] = sllHeader().decode(wire); assertEquals(read, wire.length); assertEquals(decoded.packetType, SLL_PACKET_TYPE.HOST); assertEquals(decoded.arphrdType, 1); assertEquals(decoded.linkLayerAddressLength, 6); assertEquals(decoded.protocol, 0x0806); assertEquals(decoded.payload.length, wire.length - SLL_HEADER_SIZE);