14 #include <arpa/inet.h>
15 #include <netinet/ip.h>
16 #include <netinet/ip6.h>
18 #include <netinet/udp.h>
20 #include <libnetfilter_queue/libnetfilter_queue.h>
21 #include <libnetfilter_queue/libnetfilter_queue_udp.h>
22 #include <libnetfilter_queue/libnetfilter_queue_ipv4.h>
23 #include <libnetfilter_queue/pktbuff.h>
42 if (pktb->transport_header == NULL)
46 if (pktb->tail - pktb->transport_header <
sizeof(
struct udphdr))
49 return (
struct udphdr *)pktb->transport_header;
60 uint16_t len = ntohs(udph->len);
63 if (len <
sizeof(
struct udphdr))
67 if (pktb->transport_header + len > pktb->tail)
70 return pktb->transport_header +
sizeof(
struct udphdr);
80 return pktb->tail - pktb->transport_header;
99 udph->check = nfq_checksum_tcpudp_ipv4(iph);
118 udph->check = nfq_checksum_tcpudp_ipv6(ip6h, udph);
134 unsigned int match_offset,
unsigned int match_len,
135 const char *rep_buffer,
unsigned int rep_len)
140 iph = (
struct iphdr *)pkt->network_header;
141 udph = (
struct udphdr *)(pkt->network_header + iph->ihl*4);
144 match_offset, match_len, rep_buffer, rep_len))
163 return snprintf(buf, size,
"SPT=%u DPT=%u ",
164 htons(udph->source), htons(udph->dest));
void nfq_udp_compute_checksum_ipv6(struct udphdr *udph, struct ip6_hdr *ip6h)
unsigned int nfq_udp_get_payload_len(struct udphdr *udph, struct pkt_buff *pktb)
int nfq_udp_snprintf(char *buf, size_t size, const struct udphdr *udph)
void nfq_udp_compute_checksum_ipv4(struct udphdr *udph, struct iphdr *iph)
int nfq_udp_mangle_ipv4(struct pkt_buff *pkt, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
void * nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)
int nfq_ip_mangle(struct pkt_buff *pkt, unsigned int dataoff, unsigned int match_offset, unsigned int match_len, const char *rep_buffer, unsigned int rep_len)
struct udphdr * nfq_udp_get_hdr(struct pkt_buff *pktb)