variable PCAP_DEFAULT_ENDIANNESS

Byte order assumed by the pcap coder factories when none is supplied.

Little-endian is the byte order written by libpcap on every mainstream capture host (x86 and ARM alike), so it is what an arbitrary .pcap file is overwhelmingly likely to use. Decoding can do better than a guess — see pcapFile, which sniffs the magic — but encoding has no data to inspect, so it commits to this value.

Examples

The default matches the explicit little-endian layout

import { assertEquals } from "@std/assert";
import { PCAP_DEFAULT_ENDIANNESS, pcapGlobalHeader } from "@binstruct/pcap";

assertEquals(PCAP_DEFAULT_ENDIANNESS, "le");

const value = {
  magic: 0xa1b2c3d4,
  versionMajor: 2,
  versionMinor: 4,
  thisZone: 0,
  sigFigs: 0,
  snapLen: 65535,
  network: 1,
};

const implicit = new Uint8Array(24);
const explicit = new Uint8Array(24);
pcapGlobalHeader().encode(value, implicit);
pcapGlobalHeader(PCAP_DEFAULT_ENDIANNESS).encode(value, explicit);

assertEquals(implicit, explicit);

Type

Usage

import { PCAP_DEFAULT_ENDIANNESS } from ".";