IPv4 packet parsing and manipulation helpers for eBPF programs.
IPv4 packet parsing and manipulation helpers for eBPF programs.
(decrement-ttl ip-hdr-reg ttl-reg drop-label)Decrement TTL by 1 and check for zero. Jumps to drop-label if TTL reaches 0.
ip-hdr-reg: Register pointing to IP header ttl-reg: Register to use for TTL (will be modified) drop-label: Label to jump to if TTL is 0
Decrement TTL by 1 and check for zero. Jumps to drop-label if TTL reaches 0. ip-hdr-reg: Register pointing to IP header ttl-reg: Register to use for TTL (will be modified) drop-label: Label to jump to if TTL is 0
(get-l4-ptr-dynamic l4-ptr-reg ip-hdr-reg ihl-reg)Calculate L4 header pointer using IHL field (handles IP options).
l4-ptr-reg: Register to store L4 header pointer ip-hdr-reg: Register pointing to IP header ihl-reg: Register to store IHL (will be modified)
Calculate L4 header pointer using IHL field (handles IP options). l4-ptr-reg: Register to store L4 header pointer ip-hdr-reg: Register pointing to IP header ihl-reg: Register to store IHL (will be modified)
(get-l4-ptr-fixed l4-ptr-reg ip-hdr-reg)Calculate L4 header pointer assuming fixed 20-byte IP header (no options).
l4-ptr-reg: Register to store L4 header pointer ip-hdr-reg: Register pointing to IP header
Calculate L4 header pointer assuming fixed 20-byte IP header (no options). l4-ptr-reg: Register to store L4 header pointer ip-hdr-reg: Register pointing to IP header
(is-icmp proto-reg icmp-label)Check if IP protocol is ICMP. Jumps to icmp-label if ICMP, falls through otherwise.
proto-reg: Register containing protocol number icmp-label: Label offset to jump to if ICMP
Check if IP protocol is ICMP. Jumps to icmp-label if ICMP, falls through otherwise. proto-reg: Register containing protocol number icmp-label: Label offset to jump to if ICMP
(is-tcp proto-reg tcp-label)Check if IP protocol is TCP. Jumps to tcp-label if TCP, falls through otherwise.
proto-reg: Register containing protocol number tcp-label: Label offset to jump to if TCP
Check if IP protocol is TCP. Jumps to tcp-label if TCP, falls through otherwise. proto-reg: Register containing protocol number tcp-label: Label offset to jump to if TCP
(is-udp proto-reg udp-label)Check if IP protocol is UDP. Jumps to udp-label if UDP, falls through otherwise.
proto-reg: Register containing protocol number udp-label: Label offset to jump to if UDP
Check if IP protocol is UDP. Jumps to udp-label if UDP, falls through otherwise. proto-reg: Register containing protocol number udp-label: Label offset to jump to if UDP
(load-daddr dst-reg ip-hdr-reg)Load destination IP address into dst-reg.
dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
Load destination IP address into dst-reg. dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
(load-field dst-reg ip-hdr-reg field size)Load an IPv4 header field into dst-reg.
dst-reg: Destination register ip-hdr-reg: Register pointing to start of IP header field: Field keyword (:protocol, :saddr, :daddr, etc.) size: :b (byte), :h (half-word), :w (word)
Load an IPv4 header field into dst-reg. dst-reg: Destination register ip-hdr-reg: Register pointing to start of IP header field: Field keyword (:protocol, :saddr, :daddr, etc.) size: :b (byte), :h (half-word), :w (word)
(load-ihl dst-reg ip-hdr-reg)Load IPv4 header length (in bytes) into dst-reg. Extracts IHL field and multiplies by 4.
dst-reg: Destination register for header length ip-hdr-reg: Register pointing to IP header start
Load IPv4 header length (in bytes) into dst-reg. Extracts IHL field and multiplies by 4. dst-reg: Destination register for header length ip-hdr-reg: Register pointing to IP header start
(load-protocol dst-reg ip-hdr-reg)Load IP protocol number into dst-reg.
dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
Load IP protocol number into dst-reg. dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
(load-saddr dst-reg ip-hdr-reg)Load source IP address into dst-reg.
dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
Load source IP address into dst-reg. dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
(load-total-len dst-reg ip-hdr-reg)Load total length field into dst-reg (network byte order).
dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
Load total length field into dst-reg (network byte order). dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
(load-ttl dst-reg ip-hdr-reg)Load TTL field into dst-reg.
dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
Load TTL field into dst-reg. dst-reg: Destination register ip-hdr-reg: Register pointing to IP header
(parse-addrs saddr-reg daddr-reg ip-hdr-reg)Load source and destination IPs into registers.
saddr-reg: Register for source IP daddr-reg: Register for destination IP ip-hdr-reg: Register pointing to IP header
Load source and destination IPs into registers. saddr-reg: Register for source IP daddr-reg: Register for destination IP ip-hdr-reg: Register pointing to IP header
(parse-ipv4-header ip-hdr-reg
data-end-reg
proto-reg
l4-ptr-reg
fail-label
scratch-reg)Parse IPv4 header and check bounds. Returns instructions that:
ip-hdr-reg: Register pointing to IP header start data-end-reg: Register containing data_end pointer proto-reg: Register to store protocol l4-ptr-reg: Register to store L4 header pointer fail-label: Label to jump to on bounds failure scratch-reg: Scratch register for bounds check
Parse IPv4 header and check bounds. Returns instructions that: 1. Check bounds for minimum IP header (20 bytes) 2. Load protocol into proto-reg 3. Calculate L4 header pointer (fixed offset) ip-hdr-reg: Register pointing to IP header start data-end-reg: Register containing data_end pointer proto-reg: Register to store protocol l4-ptr-reg: Register to store L4 header pointer fail-label: Label to jump to on bounds failure scratch-reg: Scratch register for bounds check
(parse-ipv4-header-dynamic ip-hdr-reg
data-end-reg
proto-reg
l4-ptr-reg
ihl-reg
fail-label
scratch-reg)Parse IPv4 header with dynamic IHL (handles IP options). Returns instructions that:
ip-hdr-reg: Register pointing to IP header start data-end-reg: Register containing data_end pointer proto-reg: Register to store protocol l4-ptr-reg: Register to store L4 header pointer ihl-reg: Register for IHL (scratch) fail-label: Label to jump to on bounds failure scratch-reg: Scratch register for bounds check
Parse IPv4 header with dynamic IHL (handles IP options). Returns instructions that: 1. Check bounds for minimum IP header 2. Load IHL and check bounds for actual header size 3. Load protocol 4. Calculate L4 header pointer ip-hdr-reg: Register pointing to IP header start data-end-reg: Register containing data_end pointer proto-reg: Register to store protocol l4-ptr-reg: Register to store L4 header pointer ihl-reg: Register for IHL (scratch) fail-label: Label to jump to on bounds failure scratch-reg: Scratch register for bounds check
(store-daddr ip-hdr-reg addr-reg)Store destination IP address.
ip-hdr-reg: Register pointing to IP header addr-reg: Register containing new destination IP
Store destination IP address. ip-hdr-reg: Register pointing to IP header addr-reg: Register containing new destination IP
(store-field ip-hdr-reg field src-reg size)Store value to IPv4 header field.
ip-hdr-reg: Register pointing to IP header start field: Field keyword src-reg: Register containing value to store size: :b, :h, or :w
Store value to IPv4 header field. ip-hdr-reg: Register pointing to IP header start field: Field keyword src-reg: Register containing value to store size: :b, :h, or :w
(store-saddr ip-hdr-reg addr-reg)Store source IP address.
ip-hdr-reg: Register pointing to IP header addr-reg: Register containing new source IP
Store source IP address. ip-hdr-reg: Register pointing to IP header addr-reg: Register containing new source IP
(store-ttl ip-hdr-reg ttl-reg)Store TTL field.
ip-hdr-reg: Register pointing to IP header ttl-reg: Register containing new TTL value
Store TTL field. ip-hdr-reg: Register pointing to IP header ttl-reg: Register containing new TTL value
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 |