structpkt_buff*pktb_alloc(intfamily,void*data,size_tlen,size_textra)
pktb_alloc - allocate a new packet buffer
Parametersfamily Indicate what family. Currently supported families are AF_BRIDGE, AF_INET & AF_INET6.
data Pointer to packet data
len Packet length
extra Extra memory in the tail to be allocated (for mangling)
This function returns a packet buffer that contains the packet data and some extra memory room in the
tail (if requested).
Returns
Pointer to a new userspace packet buffer or NULL on failure.
ErrorsENOMEM From calloc()
EPROTONOSUPPORTfamily was AF_BRIDGE and this is not an IP packet (v4 or v6)
Seealsocalloc(3)
Definition at line 52 of file pktbuff.c.
uint8_t*pktb_data(structpkt_buff*pktb)
pktb_data - get pointer to network packet
Parameterspktb Pointer to userspace packet buffer
Returns
Pointer to start of network packet data within pktb
It is appropriate to use pktb_data as the second argument of nfq_nlmsg_verdict_put_pkt()
Definition at line 105 of file pktbuff.c.
voidpktb_free(structpkt_buff*pktb)
pktb_free - release packet buffer
Parameterspktb Pointer to userspace packet buffer
Definition at line 129 of file pktbuff.c.
uint32_tpktb_len(structpkt_buff*pktb)
pktb_len - get length of packet buffer
Parameterspktb Pointer to userspace packet buffer
Returns
Length of packet contained within pktb
It is appropriate to use pktb_len as the third argument of nfq_nlmsg_verdict_put_pkt()
Definition at line 119 of file pktbuff.c.
intpktb_mangle(structpkt_buff*pktb,intdataoff,unsignedintmatch_offset,unsignedintmatch_len,constchar*rep_buffer,unsignedintrep_len)
pktb_mangle - adjust contents of a packet
Parameterspktb Pointer to userspace packet buffer
dataoff Supplementary offset, usually offset from layer 3 (IP) header to the layer 4 (TCP or UDP)
header. Specify zero to access the layer 3 header. If pktb was created in family AF_BRIDGE, specify
-ETH_HLEN (a negative offset) to access the layer 2 (MAC) header.
match_offset Further 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. Failure will occur if the extra argument to the pktb_alloc() call
that created pktb is less than the excess of rep_len over match_lenWarning
pktb_mangle does not update any checksums. Developers should use the appropriate mangler for the
protocol level: nfq_ip_mangle(), nfq_tcp_mangle_ipv4() or nfq_udp_mangle_ipv4(). IPv6 versions are
planned.
It is appropriate to use pktb_mangle to change the MAC header.
Definition at line 314 of file pktbuff.c.
boolpktb_mangled(conststructpkt_buff*pktb)
pktb_mangled - test whether packet has been mangled
Parameterspktb Pointer to userspace packet buffer
Returnstrue if packet has been mangled (modified), else false
When assembling a verdict, it is not necessary to return the contents of un-modified packets. Use
pktb_mangled to decide whether packet contents need to be returned.
Definition at line 359 of file pktbuff.c.