ipv4(3)

๐Ÿ’– ipv4 โ€” IPv4 helper functions ๐Ÿ’–

okay bestie, welcome to ipv4(3) from the Library Functions Manual โœจ this is the lil squad of helper functions that deal with your IPv4 headers when you're messing around with libnetfilter_queue. she's short, she's sweet, she's giving "i know exactly what i'm doing" energy ๐ŸŽ€


๐ŸŒธ SYNOPSIS ๐ŸŒธ

๐Ÿฆ‹ Modules

Internal IP functions

๐Ÿฆ‹ Functions

struct iphdr * nfq_ip_get_hdr (struct pkt_buff *pktb)
int nfq_ip_set_transport_header (struct pkt_buff *pktb, struct iphdr
    *iph)
int nfq_ip_mangle (struct pkt_buff *pktb, unsigned int dataoff, unsigned
    int match_offset, unsigned int match_len, const char *rep_buffer,
    unsigned int rep_len)
int nfq_ip_snprintf (char *buf, size_t size, const struct iphdr *iph)

โœจ Detailed Description โœจ

no cap, this is where the real tea lives ๐Ÿ‘‘ scroll down for the actual function docs, they're all here, nothing skipped, we're doing this properly fr fr ๐Ÿ’…


๐Ÿ’œ Function Documentation ๐Ÿ’œ

๐Ÿซถ struct iphdr * nfq_ip_get_hdr (struct pkt_buff * pktb)

nfq_ip_get_hdr โ€” get the IPv4 header ๐ŸŒˆ

Parameters

  • pktb โ€” Pointer to user-space network packet buffer

Returns

a validated pointer to the IPv4 header, or NULL if the IP is malformed or it's not version 4 ๐Ÿ˜ญ

lowkey most programs will not need to call this function. a possible use is to figure out what the layer 4 protocol is ๐Ÿงš the validation here is that the buffer is big enough for the declared lengths in the header, i.e. it's an extra check for packet truncation.

Definition at line 40 of file ipv4.c.


๐Ÿ”ฅ int nfq_ip_mangle (struct pkt_buff * pktb, unsigned int dataoff, unsigned int match_offset, unsigned int match_len, const char * rep_buffer, unsigned int rep_len)

nfq_ip_mangle โ€” mangle IPv4 packet buffer ๐Ÿ’…

Parameters

  • pktb โ€” Pointer to user-space network packet buffer
  • dataoff โ€” Offset to layer 4 header, or zero to mangle IP header
  • match_offset โ€” Offset to content that you want to mangle
  • match_len โ€” Length of the existing content you want to mangle
  • rep_buffer โ€” Pointer to data you want to use to replace current content
  • rep_len โ€” Length of data you want to use to replace current content

Returns

1 for success and 0 for failure. see pktb_mangle() for the failure case ๐Ÿ‘€

Note

this function updates the IPv4 length if necessary and recalculates the IPv4 checksum. so yeah, she's doing the math for you, iconic behavior fr ๐Ÿงฎโœจ

Definition at line 127 of file ipv4.c.


๐ŸŽ€ int nfq_ip_set_transport_header (struct pkt_buff * pktb, struct iphdr * iph)

nfq_ip_set_transport_header โ€” set the transport_header field in pktb ๐Ÿฆ‹

Parameters

  • pktb โ€” Pointer to user-space network packet buffer
  • iph โ€” Pointer to the IPv4 header

Returns

0 on success or -1 if a minimal validation check fails ๐Ÿ˜ฌ

Note

most programs should call nfq_ip_set_transport_header as soon as possible, because most layer 4 helper functions assume the transport_header field is valid. like, they assume it. don't leave them hanging bestie ๐Ÿซถ

Definition at line 73 of file ipv4.c.


โญ int nfq_ip_snprintf (char * buf, size_t size, const struct iphdr * iph)

nfq_pkt_snprintf_ip โ€” print IPv4 header into buffer in iptables LOG format ๐Ÿ“

Parameters

  • buf โ€” Pointer to buffer that will be used to print the header
  • size โ€” Size of the buffer (or remaining room in it)
  • iph โ€” Pointer to a valid IPv4 header

Returns

same as snprintf ๐Ÿ’ซ

See also

snprintf(3)

Definition at line 153 of file ipv4.c.


๐Ÿ‘‘ Author ๐Ÿ‘‘

Generated automatically by Doxygen for libnetfilter_queue from the source code. (yes bestie, a robot wrote this one, and honestly? she ate ๐Ÿค–๐Ÿ’–)


and that's the whole page, no crumbs left, we kept every detail, every param, every return value, every line number ๐Ÿ“

libnetfilter_queue ยท Version 1.0.5 ยท ipv4(3) โ€” mwah, go forth and mangle responsibly, ily ๐Ÿ’œโœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from