Ethernet frame parsing and manipulation helpers for eBPF programs.
Ethernet frame parsing and manipulation helpers for eBPF programs.
(get-ip-header-ptr ip-ptr-reg data-reg)Calculate pointer to IP header (after Ethernet header).
ip-ptr-reg: Register to store IP header pointer data-reg: Register containing packet data pointer
Calculate pointer to IP header (after Ethernet header). ip-ptr-reg: Register to store IP header pointer data-reg: Register containing packet data pointer
(is-arp ethertype-reg arp-label)Generate instructions to check if packet is ARP. Jumps to arp-label if ARP, falls through otherwise.
ethertype-reg: Register containing ethertype (network order) arp-label: Label offset to jump to if ARP
Generate instructions to check if packet is ARP. Jumps to arp-label if ARP, falls through otherwise. ethertype-reg: Register containing ethertype (network order) arp-label: Label offset to jump to if ARP
(is-ipv4 ethertype-reg ipv4-label)Generate instructions to check if packet is IPv4. Jumps to ipv4-label if IPv4, falls through otherwise. Uses network byte order comparison (no conversion needed).
ethertype-reg: Register containing ethertype (network order) ipv4-label: Label offset to jump to if IPv4
Generate instructions to check if packet is IPv4. Jumps to ipv4-label if IPv4, falls through otherwise. Uses network byte order comparison (no conversion needed). ethertype-reg: Register containing ethertype (network order) ipv4-label: Label offset to jump to if IPv4
(is-ipv6 ethertype-reg ipv6-label)Generate instructions to check if packet is IPv6. Jumps to ipv6-label if IPv6, falls through otherwise.
ethertype-reg: Register containing ethertype (network order) ipv6-label: Label offset to jump to if IPv6
Generate instructions to check if packet is IPv6. Jumps to ipv6-label if IPv6, falls through otherwise. ethertype-reg: Register containing ethertype (network order) ipv6-label: Label offset to jump to if IPv6
(is-not-ipv4 ethertype-reg not-ipv4-label)Generate instructions to check if packet is NOT IPv4. Jumps to not-ipv4-label if not IPv4, falls through if IPv4.
ethertype-reg: Register containing ethertype (network order) not-ipv4-label: Label offset to jump to if not IPv4
Generate instructions to check if packet is NOT IPv4. Jumps to not-ipv4-label if not IPv4, falls through if IPv4. ethertype-reg: Register containing ethertype (network order) not-ipv4-label: Label offset to jump to if not IPv4
(load-dst-mac dst-reg-hi dst-reg-lo data-reg)Load destination MAC address (6 bytes) into two registers. First 4 bytes into dst-reg-hi, last 2 bytes into dst-reg-lo.
dst-reg-hi: Register for first 4 bytes dst-reg-lo: Register for last 2 bytes data-reg: Register pointing to Ethernet header
Load destination MAC address (6 bytes) into two registers. First 4 bytes into dst-reg-hi, last 2 bytes into dst-reg-lo. dst-reg-hi: Register for first 4 bytes dst-reg-lo: Register for last 2 bytes data-reg: Register pointing to Ethernet header
(load-ethertype dst-reg data-reg)Load ethertype into dst-reg (network byte order). For comparison, use the network-order constants. Assumes bounds already checked for ETH_HLEN bytes.
dst-reg: Destination register for ethertype data-reg: Register pointing to packet data start
Load ethertype into dst-reg (network byte order). For comparison, use the network-order constants. Assumes bounds already checked for ETH_HLEN bytes. dst-reg: Destination register for ethertype data-reg: Register pointing to packet data start
(load-ethertype-host dst-reg data-reg)Load ethertype into dst-reg and convert to host byte order. Assumes bounds already checked for ETH_HLEN bytes.
dst-reg: Destination register for ethertype data-reg: Register pointing to packet data start
Load ethertype into dst-reg and convert to host byte order. Assumes bounds already checked for ETH_HLEN bytes. dst-reg: Destination register for ethertype data-reg: Register pointing to packet data start
(load-src-mac src-reg-hi src-reg-lo data-reg)Load source MAC address (6 bytes) into two registers.
src-reg-hi: Register for first 4 bytes src-reg-lo: Register for last 2 bytes data-reg: Register pointing to Ethernet header
Load source MAC address (6 bytes) into two registers. src-reg-hi: Register for first 4 bytes src-reg-lo: Register for last 2 bytes data-reg: Register pointing to Ethernet header
(parse-ethernet data-reg data-end-reg ethertype-reg fail-label scratch-reg)Parse Ethernet header and extract ethertype. Returns instructions that:
data-reg: Register containing packet data pointer data-end-reg: Register containing data_end pointer ethertype-reg: Register to store ethertype fail-label: Label to jump to if bounds check fails scratch-reg: Scratch register for bounds check
Parse Ethernet header and extract ethertype. Returns instructions that: 1. Check bounds for Ethernet header 2. Load ethertype into dst-reg data-reg: Register containing packet data pointer data-end-reg: Register containing data_end pointer ethertype-reg: Register to store ethertype fail-label: Label to jump to if bounds check fails scratch-reg: Scratch register for bounds check
(store-dst-mac data-reg mac-hi mac-lo)Store destination MAC address from two registers.
data-reg: Register pointing to Ethernet header mac-hi: Register containing first 4 bytes mac-lo: Register containing last 2 bytes
Store destination MAC address from two registers. data-reg: Register pointing to Ethernet header mac-hi: Register containing first 4 bytes mac-lo: Register containing last 2 bytes
(store-src-mac data-reg mac-hi mac-lo)Store source MAC address from two registers.
data-reg: Register pointing to Ethernet header mac-hi: Register containing first 4 bytes mac-lo: Register containing last 2 bytes
Store source MAC address from two registers. data-reg: Register pointing to Ethernet header mac-hi: Register containing first 4 bytes mac-lo: Register containing last 2 bytes
(swap-macs data-reg [hi1 lo1 hi2 lo2])Swap source and destination MAC addresses. Uses 6 scratch registers or stack.
data-reg: Register pointing to Ethernet header scratch-regs: Vector of 4 scratch registers [hi1 lo1 hi2 lo2]
Swap source and destination MAC addresses. Uses 6 scratch registers or stack. data-reg: Register pointing to Ethernet header scratch-regs: Vector of 4 scratch registers [hi1 lo1 hi2 lo2]
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |