summaryrefslogtreecommitdiffstats
path: root/src/extra/ipv4.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-05-31 10:52:46 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-08-06 14:54:27 +0200
commitffa83b5968b534f679bc34acc506801db3d28d58 (patch)
treeced3718e02b9e43e3174c55146bf967e9bd5ffce /src/extra/ipv4.c
parentf40eabb01163f383e2471942da45f32361031e39 (diff)
add mangle functions for IPv4/TCP and IPv4/UDP
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/extra/ipv4.c')
-rw-r--r--src/extra/ipv4.c19
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