summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac10
-rw-r--r--doxygen/Makefile.am23
-rwxr-xr-xfixmanpages.sh62
-rw-r--r--src/extra/ipv4.c4
-rw-r--r--src/extra/ipv6.c8
-rw-r--r--src/extra/pktbuff.c14
-rw-r--r--src/extra/tcp.c6
-rw-r--r--src/extra/udp.c6
-rw-r--r--src/internal.h6
10 files changed, 116 insertions, 25 deletions
diff --git a/Makefile.am b/Makefile.am
index 6b4ef77..a5b347b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = $(man_MANS) include/linux
-SUBDIRS = src utils include examples
+SUBDIRS = src utils include examples doxygen
man_MANS = #nfnetlink_queue.3 nfnetlink_queue.7
diff --git a/configure.ac b/configure.ac
index 0c08459..e99b07a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,5 +33,15 @@ dnl Output the makefiles
AC_CONFIG_FILES([Makefile src/Makefile utils/Makefile examples/Makefile
libnetfilter_queue.pc doxygen.cfg
include/Makefile include/libnetfilter_queue/Makefile
+ doxygen/Makefile
include/linux/Makefile include/linux/netfilter/Makefile])
AC_OUTPUT
+
+dnl Only run doxygen Makefile if doxygen installed
+
+AC_CHECK_PROGS([DOXYGEN], [doxygen])
+if test -z "$DOXYGEN";
+ then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
+fi
+
+ AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
diff --git a/doxygen/Makefile.am b/doxygen/Makefile.am
new file mode 100644
index 0000000..ef468e0
--- /dev/null
+++ b/doxygen/Makefile.am
@@ -0,0 +1,23 @@
+if HAVE_DOXYGEN
+doc_srcs = $(top_srcdir)/src/libnetfilter_queue.c \
+ $(top_srcdir)/src/nlmsg.c \
+ $(top_srcdir)/src/extra/checksum.c \
+ $(top_srcdir)/src/extra/ipv6.c \
+ $(top_srcdir)/src/extra/ipv4.c \
+ $(top_srcdir)/src/extra/tcp.c \
+ $(top_srcdir)/src/extra/udp.c \
+ $(top_srcdir)/src/extra/pktbuff.c
+
+doxyfile.stamp: $(doc_srcs) $(top_srcdir)/fixmanpages.sh
+ rm -rf html man && cd .. && doxygen doxygen.cfg && ./fixmanpages.sh
+ touch doxyfile.stamp
+
+CLEANFILES = doxyfile.stamp
+
+all-local: doxyfile.stamp
+clean-local:
+ rm -rf $(top_srcdir)/doxygen/man $(top_srcdir)/doxygen/html
+install-data-local:
+ mkdir -p $(DESTDIR)$(mandir)/man3
+ cp --no-dereference --preserve=links,mode,timestamps man/man3/*.3 $(DESTDIR)$(mandir)/man3/
+endif
diff --git a/fixmanpages.sh b/fixmanpages.sh
new file mode 100755
index 0000000..897086b
--- /dev/null
+++ b/fixmanpages.sh
@@ -0,0 +1,62 @@
+#!/bin/bash -p
+#set -x
+function main
+{
+ set -e
+ cd doxygen/man/man3
+ rm -f _*
+ setgroup LibrarySetup nfq_open
+ add2group nfq_close nfq_bind_pf nfq_unbind_pf
+ setgroup Parsing nfq_get_msg_packet_hdr
+ add2group nfq_get_nfmark nfq_get_timestamp nfq_get_indev nfq_get_physindev
+ add2group nfq_get_outdev nfq_get_physoutdev nfq_get_indev_name
+ add2group nfq_get_physindev_name nfq_get_outdev_name
+ add2group nfq_get_physoutdev_name nfq_get_packet_hw nfq_get_uid
+ add2group nfq_get_gid nfq_get_secctx nfq_get_payload
+ setgroup Queue nfq_fd
+ add2group nfq_create_queue nfq_destroy_queue nfq_handle_packet nfq_set_mode
+ add2group nfq_set_queue_flags nfq_set_queue_maxlen nfq_set_verdict
+ add2group nfq_set_verdict2 nfq_set_verdict_batch
+ add2group nfq_set_verdict_batch2 nfq_set_verdict_mark
+ setgroup ipv4 nfq_ip_get_hdr
+ add2group nfq_ip_set_transport_header nfq_ip_mangle nfq_ip_snprintf
+ setgroup ip_internals nfq_ip_set_checksum
+ setgroup ipv6 nfq_ip6_get_hdr
+ add2group nfq_ip6_set_transport_header nfq_ip6_mangle nfq_ip6_snprintf
+ setgroup nfq_cfg nfq_nlmsg_cfg_put_cmd
+ add2group nfq_nlmsg_cfg_put_params nfq_nlmsg_cfg_put_qmaxlen
+ setgroup nfq_verd nfq_nlmsg_verdict_put
+ add2group nfq_nlmsg_verdict_put_mark nfq_nlmsg_verdict_put_pkt
+ setgroup nlmsg nfq_nlmsg_parse
+ setgroup pktbuff pktb_alloc
+ add2group pktb_data pktb_len pktb_mangle pktb_mangled
+ add2group pktb_free
+ setgroup otherfns pktb_tailroom
+ add2group pktb_mac_header pktb_network_header pktb_transport_header
+ setgroup uselessfns pktb_push
+ add2group pktb_pull pktb_put pktb_trim
+ setgroup tcp nfq_tcp_get_hdr
+ add2group nfq_tcp_get_payload nfq_tcp_get_payload_len
+ add2group nfq_tcp_snprintf nfq_tcp_mangle_ipv4 nfq_tcp_mangle_ipv6
+ setgroup tcp_internals nfq_tcp_compute_checksum_ipv4
+ add2group nfq_tcp_compute_checksum_ipv6
+ setgroup udp nfq_udp_get_hdr
+ add2group nfq_udp_get_payload nfq_udp_get_payload_len
+ add2group nfq_udp_mangle_ipv4 nfq_udp_mangle_ipv6 nfq_udp_snprintf
+ setgroup udp_internals nfq_udp_compute_checksum_ipv4
+ add2group nfq_udp_compute_checksum_ipv6
+ setgroup Printing nfq_snprintf_xml
+}
+function setgroup
+{
+ mv $1.3 $2.3
+ BASE=$2
+}
+function add2group
+{
+ for i in $@
+ do
+ ln -sf $BASE.3 $i.3
+ done
+}
+main
diff --git a/src/extra/ipv4.c b/src/extra/ipv4.c
index caafd37..797bab1 100644
--- a/src/extra/ipv4.c
+++ b/src/extra/ipv4.c
@@ -40,7 +40,7 @@ EXPORT_SYMBOL
struct iphdr *nfq_ip_get_hdr(struct pkt_buff *pktb)
{
struct iphdr *iph;
- unsigned int pktlen = pktb->tail - pktb->network_header;
+ unsigned int pktlen = pktb_tail(pktb) - pktb->network_header;
/* Not enough room for IPv4 header. */
if (pktlen < sizeof(struct iphdr))
@@ -135,7 +135,7 @@ int nfq_ip_mangle(struct pkt_buff *pktb, unsigned int dataoff,
return 0;
/* fix IP hdr checksum information */
- iph->tot_len = htons(pktb->tail - pktb->network_header);
+ iph->tot_len = htons(pktb_tail(pktb) - pktb->network_header);
nfq_ip_set_checksum(iph);
return 1;
diff --git a/src/extra/ipv6.c b/src/extra/ipv6.c
index 6e8820c..42c5e25 100644
--- a/src/extra/ipv6.c
+++ b/src/extra/ipv6.c
@@ -36,7 +36,7 @@ EXPORT_SYMBOL
struct ip6_hdr *nfq_ip6_get_hdr(struct pkt_buff *pktb)
{
struct ip6_hdr *ip6h;
- unsigned int pktlen = pktb->tail - pktb->network_header;
+ unsigned int pktlen = pktb_tail(pktb) - pktb->network_header;
/* Not enough room for IPv6 header. */
if (pktlen < sizeof(struct ip6_hdr))
@@ -77,7 +77,7 @@ int nfq_ip6_set_transport_header(struct pkt_buff *pktb, struct ip6_hdr *ip6h,
break;
}
/* No room for extension, bad packet. */
- if (pktb->tail - cur < sizeof(struct ip6_ext)) {
+ if (pktb_tail(pktb) - cur < sizeof(struct ip6_ext)) {
cur = NULL;
break;
}
@@ -87,7 +87,7 @@ int nfq_ip6_set_transport_header(struct pkt_buff *pktb, struct ip6_hdr *ip6h,
uint16_t *frag_off;
/* No room for full fragment header, bad packet. */
- if (pktb->tail - cur < sizeof(struct ip6_frag)) {
+ if (pktb_tail(pktb) - cur < sizeof(struct ip6_frag)) {
cur = NULL;
break;
}
@@ -140,7 +140,7 @@ int nfq_ip6_mangle(struct pkt_buff *pktb, unsigned int dataoff,
/* Fix IPv6 hdr length information */
ip6h->ip6_plen =
- htons(pktb->tail - pktb->network_header - sizeof *ip6h);
+ htons(pktb_tail(pktb) - pktb->network_header - sizeof *ip6h);
return 1;
}
diff --git a/src/extra/pktbuff.c b/src/extra/pktbuff.c
index 37f6bc0..6dd0ca9 100644
--- a/src/extra/pktbuff.c
+++ b/src/extra/pktbuff.c
@@ -52,6 +52,7 @@ EXPORT_SYMBOL
struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra)
{
struct pkt_buff *pktb;
+ struct ethhdr *ethhdr;
void *pkt_data;
pktb = calloc(1, sizeof(struct pkt_buff) + len + extra);
@@ -65,18 +66,15 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra)
pktb->len = len;
pktb->data_len = len + extra;
- pktb->head = pkt_data;
pktb->data = pkt_data;
- pktb->tail = pktb->head + len;
switch(family) {
case AF_INET:
case AF_INET6:
pktb->network_header = pktb->data;
break;
- case AF_BRIDGE: {
- struct ethhdr *ethhdr = (struct ethhdr *)pktb->data;
-
+ case AF_BRIDGE:
+ ethhdr = (struct ethhdr *)pktb->data;
pktb->mac_header = pktb->data;
switch(ethhdr->h_proto) {
@@ -92,7 +90,6 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra)
}
break;
}
- }
return pktb;
}
@@ -192,7 +189,6 @@ void pktb_pull(struct pkt_buff *pktb, unsigned int len)
EXPORT_SYMBOL
void pktb_put(struct pkt_buff *pktb, unsigned int len)
{
- pktb->tail += len;
pktb->len += len;
}
@@ -205,7 +201,6 @@ EXPORT_SYMBOL
void pktb_trim(struct pkt_buff *pktb, unsigned int len)
{
pktb->len = len;
- pktb->tail = pktb->head + len;
}
/**
@@ -281,7 +276,6 @@ static int pktb_expand_tail(struct pkt_buff *pktb, int extra)
return 0;
pktb->len += extra;
- pktb->tail = pktb->tail + extra;
return 1;
}
@@ -336,7 +330,7 @@ int pktb_mangle(struct pkt_buff *pktb,
/* move post-replacement */
memmove(data + match_offset + rep_len,
data + match_offset + match_len,
- pktb->tail - (pktb->network_header + dataoff +
+ pktb_tail(pktb) - (pktb->network_header + dataoff +
match_offset + match_len));
/* insert data from buffer */
diff --git a/src/extra/tcp.c b/src/extra/tcp.c
index cca20e7..933c6ee 100644
--- a/src/extra/tcp.c
+++ b/src/extra/tcp.c
@@ -46,7 +46,7 @@ struct tcphdr *nfq_tcp_get_hdr(struct pkt_buff *pktb)
return NULL;
/* No room for the TCP header. */
- if (pktb->tail - pktb->transport_header < sizeof(struct tcphdr))
+ if (pktb_tail(pktb) - pktb->transport_header < sizeof(struct tcphdr))
return NULL;
return (struct tcphdr *)pktb->transport_header;
@@ -68,7 +68,7 @@ void *nfq_tcp_get_payload(struct tcphdr *tcph, struct pkt_buff *pktb)
return NULL;
/* malformed TCP data offset. */
- if (pktb->transport_header + len > pktb->tail)
+ if (pktb->transport_header + len > pktb_tail(pktb))
return NULL;
return pktb->transport_header + len;
@@ -83,7 +83,7 @@ void *nfq_tcp_get_payload(struct tcphdr *tcph, struct pkt_buff *pktb)
EXPORT_SYMBOL
unsigned int nfq_tcp_get_payload_len(struct tcphdr *tcph, struct pkt_buff *pktb)
{
- return pktb->tail - pktb->transport_header - (tcph->doff * 4);
+ return pktb_tail(pktb) - pktb->transport_header - (tcph->doff * 4);
}
/**
diff --git a/src/extra/udp.c b/src/extra/udp.c
index dc476d4..f232127 100644
--- a/src/extra/udp.c
+++ b/src/extra/udp.c
@@ -46,7 +46,7 @@ struct udphdr *nfq_udp_get_hdr(struct pkt_buff *pktb)
return NULL;
/* No room for the UDP header. */
- if (pktb->tail - pktb->transport_header < sizeof(struct udphdr))
+ if (pktb_tail(pktb) - pktb->transport_header < sizeof(struct udphdr))
return NULL;
return (struct udphdr *)pktb->transport_header;
@@ -68,7 +68,7 @@ void *nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)
return NULL;
/* malformed UDP packet. */
- if (pktb->transport_header + len > pktb->tail)
+ if (pktb->transport_header + len > pktb_tail(pktb))
return NULL;
return pktb->transport_header + sizeof(struct udphdr);
@@ -83,7 +83,7 @@ void *nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)
EXPORT_SYMBOL
unsigned int nfq_udp_get_payload_len(struct udphdr *udph, struct pkt_buff *pktb)
{
- return pktb->tail - pktb->transport_header - sizeof(struct udphdr);
+ return pktb_tail(pktb) - pktb->transport_header - sizeof(struct udphdr);
}
/**
diff --git a/src/internal.h b/src/internal.h
index d968325..ae849d6 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -23,9 +23,7 @@ struct pkt_buff {
uint8_t *network_header;
uint8_t *transport_header;
- uint8_t *head;
uint8_t *data;
- uint8_t *tail;
uint32_t len;
uint32_t data_len;
@@ -33,4 +31,8 @@ struct pkt_buff {
bool mangled;
};
+static inline uint8_t *pktb_tail(struct pkt_buff *pktb)
+{
+ return pktb->data + pktb->len;
+}
#endif