diff options
Diffstat (limited to 'src/extra/ipv4.c')
-rw-r--r-- | src/extra/ipv4.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/extra/ipv4.c b/src/extra/ipv4.c index 200a20e..ce101ef 100644 --- a/src/extra/ipv4.c +++ b/src/extra/ipv4.c @@ -10,6 +10,7 @@ */ #include <stdio.h> +#include <stdbool.h> #include <arpa/inet.h> #include <netinet/ip.h> @@ -90,6 +91,24 @@ void nfq_ip_set_checksum(struct iphdr *iph) } EXPORT_SYMBOL(nfq_ip_set_checksum); +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 iphdr *iph = (struct iphdr *) pkt->network_header; + + if (!pktb_mangle(pkt, dataoff, match_offset, match_len, + rep_buffer, rep_len)) + return 0; + + /* fix IP hdr checksum information */ + iph->tot_len = htons(pkt->len); + nfq_ip_set_checksum(iph); + + return 1; +} +EXPORT_SYMBOL(nfq_ip_mangle); + /** * nfq_pkt_snprintf_ip - print IPv4 header into buffer in iptables LOG format * \param buf: pointer to buffer that will be used to print the header |