clang and documentation updates
cover clang and documentation updates
This series is a mixture of patches to enable clang build and correct / insert doxygen comments. It ended up that way after git merges of local branches where they were originally developed.
Hopefully they are all uncontroversial so can just be applied.
Duncan Roe (4):
src: doc: Miscellaneous documentation updates
src: Enable clang build
src: Fix invalid conversion specifier
src: doc: Minor fix
Pablo Neira Ayuso (1):
doxygen: remove EXPORT_SYMBOL from the output
doxygen.cfg.in | 2 +- src/extra/ipv4.c | 33 +++++---- src/extra/ipv6.c | 16 ++--- src/extra/pktbuff.c | 80 ++++++++++++---------- src/extra/tcp.c | 24 +++---- src/extra/udp.c | 53 +++++++-------- src/internal.h | 3 +- src/libnetfilter_queue.c | 173 +++++++++++++++++++++++------------------------ src/nlmsg.c | 63 ++++++++++------- 9 files changed, 236 insertions(+), 211 deletions(-)
Signature · 1 line
2.14.5
PATCH 1/5 src: doc: Miscellaneous updates
(These updates only cover functions used in a recent project)
src/extra/ipv4.c: - nfq_ip_set_transport_header(): Add explanatory notes
- nfq_ip_mangle()
- Advise that there is a return code
- Note that IPv4 length is updated as well as checksum
src/extra/pktbuff.c: - pktb_alloc(): Minor rewording (English usage)
- pktb_mangle(): Document
src/extra/udp.c: - nfq_udp_get_hdr(): Fix params
- nfq_udp_get_payload(): Fix params
- nfq_udp_get_payload_len(): Fix params
- nfq_udp_mangle_ipv4(): Rewrite documentation
src/nlmsg.c: - nfq_nlmsg_verdict_put(): Document
- nfq_nlmsg_cfg_put_cmd():
- Change name (was: nfq_nlmsg_cfg_build_request)
- Fix params
- Delete function return documentation (void fn)
- nfq_nlmsg_cfg_put_params(); Document (params only)
- nfq_nlmsg_cfg_put_qmaxlen(): Document (params only)
- nfq_nlmsg_parse:
- Change name (was: nfq_pkt_parse)
- Fix params
--- src/extra/ipv4.c | 9 +++++++-- src/extra/pktbuff.c | 15 ++++++++++++++- src/extra/udp.c | 28 +++++++++++++++------------- src/nlmsg.c | 36 +++++++++++++++++++++++++++--------- 4 files changed, 63 insertions(+), 25 deletions(-)
src/extra/ipv4.c +7 -2
@@ -59,6 +59,10 @@ EXPORT_SYMBOL(nfq_ip_get_hdr);* nfq_ip_set_transport_header - set transport header * \param pktb: pointer to network packet buffer * \param iph: pointer to the IPv4 header +* +* Sets the \b transport_header field in \b pktb +* +* Level 4 helper functions need this to be set. */ int nfq_ip_set_transport_header (struct pkt_buff *pktb,struct iphdr *iph) {
@@ -97,8 +101,9 @@ EXPORT_SYMBOL(nfq_ip_set_checksum);* \param match_len: length of the existing content you want to mangle * \param rep_buffer: pointer to data you want to use to replace current content * \param rep_len: length of data you want to use to replace current content -* -* \note This function recalculates the IPv4 checksum (if needed). +* \returns 1 for success and 0 for failure. See pktb_mangle() for failure case +* \note This function updates the IPv4 length and recalculates the IPv4 +* checksum (if necessary) */ int nfq_ip_mangle(struct pkt_buff *pkt, unsigned int dataoff, unsigned int match_offset, unsigned int match_len,
src/extra/pktbuff.c +14 -1
@@ -36,7 +36,7 @@* \param 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 (in case of requested). +* some extra memory room in the tail (if requested). * * \return a pointer to a new queue handle or NULL on failure. */
@@ -224,6 +224,19 @@ static int enlarge_pkt(struct pkt_buff *pkt, unsigned int extra)return 1 ; } +/** +* pktb_mangle - adjust contents of a packet +* \param pkt Pointer to packet buffer +* \param dataoff Offset to layer 3 header. Specify zero to access layer 2 (IP) +* header +* \param match_offset Further offset to content that you want to mangle +* \param match_len Length of the existing content you want to mangle +* \param rep_buffer Pointer to data you want to use to replace current content +* \param 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 \b extra +* argument to the pktb_alloc() call that created \b pkt is less than the excess +* of \b rep_len over \b match_len +*/ int pktb_mangle(struct pkt_buff *pkt, unsigned int dataoff, unsigned int match_offset,
src/extra/udp.c +15 -13
@@ -31,8 +31,7 @@/** * nfq_udp_get_hdr - get the UDP header. -* \param head: pointer to the beginning of the packet -* \param tail: pointer to the tail of the packet +* \param pktb: Pointer to network packet buffer * * This function returns NULL if invalid UDP header is found. On success, * it returns the UDP header.
@@ -52,8 +51,8 @@ EXPORT_SYMBOL(nfq_udp_get_hdr);/** * nfq_udp_get_payload - get the UDP packet payload. -* \param udph: the pointer to the UDP header. -* \param tail: pointer to the tail of the packet +* \param udph: Pointer to UDP header +* \param pktb: Pointer to network packet buffer */ void *nfq_udp_get_payload (struct udphdr *udph,struct pkt_buff *pktb) {
@@ -73,7 +72,8 @@ EXPORT_SYMBOL(nfq_udp_get_payload);/** * nfq_udp_get_payload_len - get the udp packet payload. -* \param udp: the pointer to the udp header. +* \param udph: Pointer to UDP header +* \param pktb: Pointer to network packet buffer */ unsigned int nfq_udp_get_payload_len (struct udphdr *udph,struct pkt_buff *pktb) {
@@ -120,14 +120,16 @@ nfq_udp_compute_checksum_ipv6(struct udphdr *udph, struct ip6_hdr *ip6h)EXPORT_SYMBOL (nfq_udp_compute_checksum_ipv6);/** -* nfq_tcp_mangle_ipv4 - mangle TCP/IPv4 packet buffer -* \param pktb: pointer to network packet buffer -* \param match_offset: offset to content that you want to mangle -* \param match_len: length of the existing content you want to mangle -* \param rep_buffer: pointer to data you want to use to replace current content -* \param rep_len: length of data you want to use to replace current content -* -* \note This function recalculates the IPv4 and TCP checksums for you. +* nfq_udp_mangle_ipv4 - Mangle UDP/IPv4 packet buffer +* \param pktb: Pointer to network packet buffer +* \param match_offset: Offset from start of UDP data of content that you want +* to mangle +* \param match_len: Length of the existing content you want to mangle +* \param rep_buffer: Pointer to data you want to use to replace current content +* \param rep_len: Length of data you want to use to replace current content +* \returns 1 for success and 0 for failure. See pktb_mangle() for failure case +* \note This function updates the IPv4 and UDP lengths and recalculates their +* checksums for you. */ int nfq_udp_mangle_ipv4(struct pkt_buff *pkt,
src/nlmsg.c +27 -9
@@ -30,6 +30,16 @@* @{ */ +/** +* nfq_nlmsg_verdict_put - Put a verdict into a Netlink header +* \param nlh Pointer to netlink message +* \param id ID assigned to packet by netfilter +* \param verdict verdict to return to netfilter (NF_ACCEPT, NF_DROP) +* +* See examples/nf-queue.c, line 46 for an example of how to use this function. +* The calling sequence is \b main --> \b mnl_cb_run --> \b queue_cb --> +* \b nfq_send_verdict --> \b nfq_nlmsg_verdict_put +*/ void nfq_nlmsg_verdict_put (struct nlmsghdr *nlh,int id,int verdict) {struct nfqnl_msg_verdict_hdr vh = {
@@ -63,13 +73,10 @@ EXPORT_SYMBOL(nfq_nlmsg_verdict_put_pkt);*/ /** -* nfq_nlmsg_cfg_build_request- build netlink config message -* \param buf Buffer where netlink message is going to be written. -* \param cfg Structure that contains the config parameters. -* \param command nfqueue nfnetlink command. -* -* This function returns a pointer to the netlink message. If something goes -* wrong it returns NULL. +* nfq_nlmsg_cfg_put_cmd Add netlink config command to netlink message +* \param nlh Pointer to netlink message +* \param pf Packet family (e.g. AF_INET) +* \param cmd nfqueue nfnetlink command. * * Possible commands are: *
@@ -95,6 +102,12 @@ void nfq_nlmsg_cfg_put_cmd(struct nlmsghdr *nlh, uint16_t pf, uint8_t cmd) }EXPORT_SYMBOL (nfq_nlmsg_cfg_put_cmd); +/** +* nfq_nlmsg_cfg_put_params Add parameter to netlink message +* \param nlh Pointer to netlink message +* \param mode one of NFQNL_COPY_NONE, NFQNL_COPY_META or NFQNL_COPY_PACKET +* \param range value of parameter +*/ void nfq_nlmsg_cfg_put_params (struct nlmsghdr *nlh,uint8_t mode,int range) {struct nfqnl_msg_config_params params = {
@@ -105,6 +118,11 @@ void nfq_nlmsg_cfg_put_params(struct nlmsghdr *nlh, uint8_t mode, int range) }EXPORT_SYMBOL (nfq_nlmsg_cfg_put_params); +/** +* nfq_nlmsg_cfg_put_qmaxlen Add queue maximum length to netlink message +* \param nlh Pointer to netlink message +* \param queue_maxlen Maximum queue length +*/ void nfq_nlmsg_cfg_put_qmaxlen (struct nlmsghdr *nlh,uint32_t queue_maxlen) {mnl_attr_put_u32 (nlh,NFQA_CFG_QUEUE_MAXLEN ,htonl (queue_maxlen));
@@ -172,9 +190,9 @@ static int nfq_pkt_parse_attr_cb(const struct nlattr *attr, void *data) }/** -* nfq_pkt_parse - set packet attributes from netlink message +* nfq_nlmsg_parse - set packet attributes from netlink message * \param nlh netlink message that you want to read. -* \param pkt pointer to the packet to set. +* \param attr pointer to array of attributes to set. * * This function returns MNL_CB_ERROR if any error occurs, or MNL_CB_OK on * success.
Signature · 1 line
2.14.5
PATCH 2/5 src: Enable clang build
In reply to Duncan RoeModify the definition and use of EXPORT_SYMBOL as was done for libmnl in commit 444d6dc9.
Additionally, avoid generating long (>80ch) lines when inserting EXPORT_SYMBOL by splitting these lines at start of function name (was already done in a few places).
Finally, re-align multi-line parameter blocks with opening parenthesis.
--- src/extra/ipv4.c | 24 +++---- src/extra/ipv6.c | 14 ++-- src/extra/pktbuff.c | 65 +++++++++--------- src/extra/tcp.c | 24 +++---- src/extra/udp.c | 25 +++---- src/internal.h | 3 +- src/libnetfilter_queue.c | 173 +++++++++++++++++++++++------------------------ src/nlmsg.c | 27 ++++---- 8 files changed, 171 insertions(+), 184 deletions(-)
src/extra/ipv4.c +12 -12
@@ -32,7 +32,8 @@* This funcion returns NULL if the IPv4 is malformed or the protocol version * is not 4. On success, it returns a valid pointer to the IPv4 header. */ -struct iphdr *nfq_ip_get_hdr (struct pkt_buff *pktb) +EXPORT_SYMBOL struct iphdr * +nfq_ip_get_hdr (struct pkt_buff *pktb) {struct iphdr *iph;unsigned int pktlen = pktb->tail - pktb->network_header;
@@ -53,7 +54,6 @@ struct iphdr *nfq_ip_get_hdr(struct pkt_buff *pktb)return iph; } -EXPORT_SYMBOL (nfq_ip_get_hdr);/** * nfq_ip_set_transport_header - set transport header
@@ -64,7 +64,8 @@ EXPORT_SYMBOL(nfq_ip_get_hdr);* * Level 4 helper functions need this to be set. */ -int nfq_ip_set_transport_header (struct pkt_buff *pktb,struct iphdr *iph) +EXPORT_SYMBOL int +nfq_ip_set_transport_header (struct pkt_buff *pktb,struct iphdr *iph) {int doff = iph->ihl *4 ;
@@ -75,7 +76,6 @@ int nfq_ip_set_transport_header(struct pkt_buff *pktb, struct iphdr *iph) pktb->transport_header = pktb->network_header + doff;return 0 ; } -EXPORT_SYMBOL (nfq_ip_set_transport_header);/** * nfq_ip_set_checksum - set IPv4 checksum
@@ -84,14 +84,14 @@ EXPORT_SYMBOL(nfq_ip_set_transport_header);* \note Call to this function if you modified the IPv4 header to update the * checksum. */ -void nfq_ip_set_checksum (struct iphdr *iph) +EXPORT_SYMBOL void +nfq_ip_set_checksum (struct iphdr *iph) {uint32_t iph_len = iph->ihl *4 ; iph->check =0 ; iph->check =nfq_checksum (0 , (uint16_t *)iph, iph_len); } -EXPORT_SYMBOL (nfq_ip_set_checksum);/** * nfq_ip_mangle - mangle IPv4 packet buffer
@@ -105,9 +105,10 @@ EXPORT_SYMBOL(nfq_ip_set_checksum);* \note This function updates the IPv4 length and recalculates the IPv4 * checksum (if necessary) */ -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) +EXPORT_SYMBOL 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;
@@ -121,7 +122,6 @@ int nfq_ip_mangle(struct pkt_buff *pkt, unsigned int dataoff,return 1 ; } -EXPORT_SYMBOL (nfq_ip_mangle);/** * nfq_pkt_snprintf_ip - print IPv4 header into buffer in iptables LOG format
@@ -133,7 +133,8 @@ EXPORT_SYMBOL(nfq_ip_mangle);* case that there is enough room in the buffer. Read snprintf manpage for more * information to know more about this strange behaviour. */ -int nfq_ip_snprintf (char *buf,size_t size,const struct iphdr *iph) +EXPORT_SYMBOL int +nfq_ip_snprintf (char *buf,size_t size,const struct iphdr *iph) {int ret;struct in_addr src = { iph->saddr };
@@ -152,7 +153,6 @@ int nfq_ip_snprintf(char *buf, size_t size, const struct iphdr *iph)return ret; } -EXPORT_SYMBOL (nfq_ip_snprintf);/** * @}
src/extra/ipv6.c +7 -7
@@ -33,7 +33,8 @@* This funcion returns NULL if an invalid header is found. On sucess, it * returns a valid pointer to the header. */ -struct ip6_hdr *nfq_ip6_get_hdr (struct pkt_buff *pktb) +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;
@@ -50,7 +51,6 @@ struct ip6_hdr *nfq_ip6_get_hdr(struct pkt_buff *pktb)return ip6h; } -EXPORT_SYMBOL (nfq_ip6_get_hdr);/** * nfq_ip6_set_transport_header - set transport header pointer for IPv6 packet
@@ -61,8 +61,9 @@ EXPORT_SYMBOL(nfq_ip6_get_hdr);* This function returns 1 if the protocol has been found and the transport * header has been set. Otherwise, it returns 0. */ -int nfq_ip6_set_transport_header (struct pkt_buff *pktb,struct ip6_hdr *ip6h, -uint8_t target) +EXPORT_SYMBOL int +nfq_ip6_set_transport_header (struct pkt_buff *pktb,struct ip6_hdr *ip6h, +uint8_t target) {uint8_t nexthdr = ip6h->ip6_nxt;uint8_t *cur = (uint8_t *)ip6h +sizeof (struct ip6_hdr );
@@ -115,7 +116,6 @@ int nfq_ip6_set_transport_header(struct pkt_buff *pktb, struct ip6_hdr *ip6h, pktb->transport_header = cur;return cur ?1 :0 ; } -EXPORT_SYMBOL (nfq_ip6_set_transport_header);/** * nfq_ip6_snprintf - print IPv6 header into one buffer in iptables LOG format
@@ -124,7 +124,8 @@ EXPORT_SYMBOL(nfq_ip6_set_transport_header);* \param ip6_hdr: pointer to a valid IPv6 header. * */ -int nfq_ip6_snprintf (char *buf,size_t size,const struct ip6_hdr *ip6h) +EXPORT_SYMBOL int +nfq_ip6_snprintf (char *buf,size_t size,const struct ip6_hdr *ip6h) {int ret;char src[INET6_ADDRSTRLEN ];
@@ -143,7 +144,6 @@ int nfq_ip6_snprintf(char *buf, size_t size, const struct ip6_hdr *ip6h)return ret; } -EXPORT_SYMBOL (nfq_ip6_snprintf);/** * @}
src/extra/pktbuff.c +32 -33
188 lines not on this page · raw message
src/extra/tcp.c +10 -14
@@ -40,7 +40,8 @@* \note You have to call nfq_ip_set_transport_header or * nfq_ip6_set_transport_header first to access the TCP header. */ -struct tcphdr *nfq_tcp_get_hdr (struct pkt_buff *pktb) +EXPORT_SYMBOL struct tcphdr * +nfq_tcp_get_hdr (struct pkt_buff *pktb) {if (pktb->transport_header ==NULL )return NULL ;
@@ -51,14 +52,14 @@ struct tcphdr *nfq_tcp_get_hdr(struct pkt_buff *pktb)return (struct tcphdr *)pktb->transport_header; } -EXPORT_SYMBOL (nfq_tcp_get_hdr);/** * nfq_tcp_get_payload - get the TCP packet payload * \param tcph: pointer to the TCP header * \param pktb: pointer to user-space network packet buffer */ -void *nfq_tcp_get_payload (struct tcphdr *tcph,struct pkt_buff *pktb) +EXPORT_SYMBOL void * +nfq_tcp_get_payload (struct tcphdr *tcph,struct pkt_buff *pktb) {unsigned int len = tcph->doff *4 ;
@@ -72,47 +73,43 @@ void *nfq_tcp_get_payload(struct tcphdr *tcph, struct pkt_buff *pktb)return pktb->transport_header + len; } -EXPORT_SYMBOL (nfq_tcp_get_payload);/** * nfq_tcp_get_payload_len - get the tcp packet payload * \param tcph: pointer to the TCP header * \param pktb: pointer to user-space network packet buffer */ -unsigned int +EXPORT_SYMBOL unsigned intnfq_tcp_get_payload_len (struct tcphdr *tcph,struct pkt_buff *pktb) {return pktb->tail - pktb->transport_header; } -EXPORT_SYMBOL (nfq_tcp_get_payload_len);/** * nfq_tcp_set_checksum_ipv4 - computes IPv4/TCP packet checksum * \param tcph: pointer to the TCP header * \param iph: pointer to the IPv4 header */ -void +EXPORT_SYMBOL voidnfq_tcp_compute_checksum_ipv4 (struct tcphdr *tcph,struct iphdr *iph) {/* checksum field in header needs to be zero for calculation. */ tcph->check =0 ; tcph->check =nfq_checksum_tcpudp_ipv4 (iph,IPPROTO_TCP ); } -EXPORT_SYMBOL (nfq_tcp_compute_checksum_ipv4);/** * nfq_tcp_set_checksum_ipv6 - computes IPv6/TCP packet checksum * \param tcph: pointer to the TCP header * \param iph: pointer to the IPv6 header */ -void +EXPORT_SYMBOL voidnfq_tcp_compute_checksum_ipv6 (struct tcphdr *tcph,struct ip6_hdr *ip6h) {/* checksum field in header needs to be zero for calculation. */ tcph->check =0 ; tcph->check =nfq_checksum_tcpudp_ipv6 (ip6h, tcph,IPPROTO_TCP ); } -EXPORT_SYMBOL (nfq_tcp_compute_checksum_ipv6);/* * The union cast uses a gcc extension to avoid aliasing problems
@@ -134,7 +131,8 @@ union tcp_word_hdr {* \param tcp: pointer to a valid tcp header. * */ -int nfq_tcp_snprintf (char *buf,size_t size,const struct tcphdr *tcph) +EXPORT_SYMBOL int +nfq_tcp_snprintf (char *buf,size_t size,const struct tcphdr *tcph) {int ret, len =0 ;
@@ -177,7 +175,6 @@ int nfq_tcp_snprintf(char *buf, size_t size, const struct tcphdr *tcph)return ret; } -EXPORT_SYMBOL (nfq_tcp_snprintf);/** * nfq_tcp_mangle_ipv4 - mangle TCP/IPv4 packet buffer
@@ -189,7 +186,7 @@ EXPORT_SYMBOL(nfq_tcp_snprintf);* * \note This function recalculates the IPv4 and TCP checksums for you. */ -int +EXPORT_SYMBOL intnfq_tcp_mangle_ipv4 (struct pkt_buff *pkt,unsigned int match_offset,unsigned int match_len,const char *rep_buffer,unsigned int rep_len)
@@ -208,7 +205,6 @@ nfq_tcp_mangle_ipv4(struct pkt_buff *pkt,return 1 ; } -EXPORT_SYMBOL (nfq_tcp_mangle_ipv4);/** * @}
src/extra/udp.c +11 -14
@@ -36,7 +36,8 @@* This function returns NULL if invalid UDP header is found. On success, * it returns the UDP header. */ -struct udphdr *nfq_udp_get_hdr (struct pkt_buff *pktb) +EXPORT_SYMBOL struct udphdr * +nfq_udp_get_hdr (struct pkt_buff *pktb) {if (pktb->transport_header ==NULL )return NULL ;
@@ -47,14 +48,14 @@ struct udphdr *nfq_udp_get_hdr(struct pkt_buff *pktb)return (struct udphdr *)pktb->transport_header; } -EXPORT_SYMBOL (nfq_udp_get_hdr);/** * nfq_udp_get_payload - get the UDP packet payload. * \param udph: Pointer to UDP header * \param pktb: Pointer to network packet buffer */ -void *nfq_udp_get_payload (struct udphdr *udph,struct pkt_buff *pktb) +EXPORT_SYMBOL void * +nfq_udp_get_payload (struct udphdr *udph,struct pkt_buff *pktb) {uint16_t len =ntohs (udph->len);
@@ -68,18 +69,17 @@ void *nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)return pktb->transport_header +sizeof (struct udphdr ); } -EXPORT_SYMBOL (nfq_udp_get_payload);/** * nfq_udp_get_payload_len - get the udp packet payload. * \param udph: Pointer to UDP header * \param pktb: Pointer to network packet buffer */ -unsigned int nfq_udp_get_payload_len (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; } -EXPORT_SYMBOL (nfq_udp_get_payload_len);/** * nfq_udp_set_checksum_ipv4 - computes a IPv4/TCP packet's segment
@@ -91,14 +91,13 @@ EXPORT_SYMBOL(nfq_udp_get_payload_len);* \see nfq_pkt_compute_ip_checksum * \see nfq_pkt_compute_udp_checksum */ -void +EXPORT_SYMBOL voidnfq_udp_compute_checksum_ipv4 (struct udphdr *udph,struct iphdr *iph) {/* checksum field in header needs to be zero for calculation. */ udph->check =0 ; udph->check =nfq_checksum_tcpudp_ipv4 (iph,IPPROTO_UDP ); } -EXPORT_SYMBOL (nfq_udp_compute_checksum_ipv4);/** * nfq_udp_set_checksum_ipv6 - computes a IPv6/TCP packet's segment
@@ -110,14 +109,13 @@ EXPORT_SYMBOL(nfq_udp_compute_checksum_ipv4);* \see nfq_pkt_compute_ip_checksum * \see nfq_pkt_compute_udp_checksum */ -void +EXPORT_SYMBOL voidnfq_udp_compute_checksum_ipv6 (struct udphdr *udph,struct ip6_hdr *ip6h) {/* checksum field in header needs to be zero for calculation. */ udph->check =0 ; udph->check =nfq_checksum_tcpudp_ipv6 (ip6h, udph,IPPROTO_UDP ); } -EXPORT_SYMBOL (nfq_udp_compute_checksum_ipv6);/** * nfq_udp_mangle_ipv4 - Mangle UDP/IPv4 packet buffer
@@ -131,7 +129,7 @@ EXPORT_SYMBOL(nfq_udp_compute_checksum_ipv6);* \note This function updates the IPv4 and UDP lengths and recalculates their * checksums for you. */ -int +EXPORT_SYMBOL intnfq_udp_mangle_ipv4 (struct pkt_buff *pkt,unsigned int match_offset,unsigned int match_len,const char *rep_buffer,unsigned int rep_len)
@@ -152,7 +150,6 @@ nfq_udp_mangle_ipv4(struct pkt_buff *pkt,return 1 ; } -EXPORT_SYMBOL (nfq_udp_mangle_ipv4);/** * nfq_pkt_snprintf_udp_hdr - print udp header into one buffer in a humnan
@@ -162,12 +159,12 @@ EXPORT_SYMBOL(nfq_udp_mangle_ipv4);* \param udp: pointer to a valid udp header. * */ -int nfq_udp_snprintf (char *buf,size_t size,const struct udphdr *udph) +EXPORT_SYMBOL int +nfq_udp_snprintf (char *buf,size_t size,const struct udphdr *udph) {return snprintf (buf, size,"SPT=%u DPT=%u " ,htons (udph->source),htons (udph->dest)); } -EXPORT_SYMBOL (nfq_udp_snprintf);/** * @}
src/internal.h +1 -2
@@ -5,8 +5,7 @@#include <stdint.h> #include <stdbool.h> #ifdef HAVE_VISIBILITY_HIDDEN -# define __visible __attribute__((visibility("default"))) -# define EXPORT_SYMBOL (x) typeof(x) (x) __visible +# define EXPORT_SYMBOL __attribute__((visibility("default")))#else # define EXPORT_SYMBOL #endif
src/libnetfilter_queue.c +85 -88
549 lines not on this page · raw message
src/nlmsg.c +13 -14
@@ -40,7 +40,8 @@* The calling sequence is \b main --> \b mnl_cb_run --> \b queue_cb --> * \b nfq_send_verdict --> \b nfq_nlmsg_verdict_put */ -void nfq_nlmsg_verdict_put (struct nlmsghdr *nlh,int id,int verdict) +EXPORT_SYMBOL void +nfq_nlmsg_verdict_put (struct nlmsghdr *nlh,int id,int verdict) {struct nfqnl_msg_verdict_hdr vh = { .verdict =htonl (verdict),
@@ -48,20 +49,18 @@ void nfq_nlmsg_verdict_put(struct nlmsghdr *nlh, int id, int verdict) };mnl_attr_put (nlh,NFQA_VERDICT_HDR ,sizeof (vh), &vh); } -EXPORT_SYMBOL (nfq_nlmsg_verdict_put); -void nfq_nlmsg_verdict_put_mark (struct nlmsghdr *nlh,uint32_t mark) +EXPORT_SYMBOL void +nfq_nlmsg_verdict_put_mark (struct nlmsghdr *nlh,uint32_t mark) {mnl_attr_put_u32 (nlh,NFQA_MARK ,htonl (mark)); } -EXPORT_SYMBOL (nfq_nlmsg_verdict_put_mark); -void +EXPORT_SYMBOL voidnfq_nlmsg_verdict_put_pkt (struct nlmsghdr *nlh,const void *pkt,uint32_t plen) {mnl_attr_put (nlh,NFQA_PAYLOAD , plen, pkt); } -EXPORT_SYMBOL (nfq_nlmsg_verdict_put_pkt);/** * @}
@@ -92,7 +91,8 @@ EXPORT_SYMBOL(nfq_nlmsg_verdict_put_pkt);* given protocol family. Both commands are ignored by Linux kernel 3.8 and * later versions. */ -void nfq_nlmsg_cfg_put_cmd (struct nlmsghdr *nlh,uint16_t pf,uint8_t cmd) +EXPORT_SYMBOL void +nfq_nlmsg_cfg_put_cmd (struct nlmsghdr *nlh,uint16_t pf,uint8_t cmd) {struct nfqnl_msg_config_cmd command = { .command = cmd,
@@ -100,7 +100,6 @@ void nfq_nlmsg_cfg_put_cmd(struct nlmsghdr *nlh, uint16_t pf, uint8_t cmd) };mnl_attr_put (nlh,NFQA_CFG_CMD ,sizeof (command), &command); } -EXPORT_SYMBOL (nfq_nlmsg_cfg_put_cmd);/** * nfq_nlmsg_cfg_put_params Add parameter to netlink message
@@ -108,7 +107,8 @@ EXPORT_SYMBOL(nfq_nlmsg_cfg_put_cmd);* \param mode one of NFQNL_COPY_NONE, NFQNL_COPY_META or NFQNL_COPY_PACKET * \param range value of parameter */ -void nfq_nlmsg_cfg_put_params (struct nlmsghdr *nlh,uint8_t mode,int range) +EXPORT_SYMBOL void +nfq_nlmsg_cfg_put_params (struct nlmsghdr *nlh,uint8_t mode,int range) {struct nfqnl_msg_config_params params = { .copy_range =htonl (range),
@@ -116,18 +116,17 @@ void nfq_nlmsg_cfg_put_params(struct nlmsghdr *nlh, uint8_t mode, int range) };mnl_attr_put (nlh,NFQA_CFG_PARAMS ,sizeof (params), ¶ms); } -EXPORT_SYMBOL (nfq_nlmsg_cfg_put_params);/** * nfq_nlmsg_cfg_put_qmaxlen Add queue maximum length to netlink message * \param nlh Pointer to netlink message * \param queue_maxlen Maximum queue length */ -void nfq_nlmsg_cfg_put_qmaxlen (struct nlmsghdr *nlh,uint32_t queue_maxlen) +EXPORT_SYMBOL void +nfq_nlmsg_cfg_put_qmaxlen (struct nlmsghdr *nlh,uint32_t queue_maxlen) {mnl_attr_put_u32 (nlh,NFQA_CFG_QUEUE_MAXLEN ,htonl (queue_maxlen)); } -EXPORT_SYMBOL (nfq_nlmsg_cfg_put_qmaxlen);/** * @}
@@ -197,12 +196,12 @@ static int nfq_pkt_parse_attr_cb(const struct nlattr *attr, void *data)* This function returns MNL_CB_ERROR if any error occurs, or MNL_CB_OK on * success. */ -int nfq_nlmsg_parse (const struct nlmsghdr *nlh,struct nlattr **attr) +EXPORT_SYMBOL int +nfq_nlmsg_parse (const struct nlmsghdr *nlh,struct nlattr **attr) {return mnl_attr_parse (nlh,sizeof (struct nfgenmsg ), nfq_pkt_parse_attr_cb, attr); } -EXPORT_SYMBOL (nfq_nlmsg_parse);/** * @}
Signature · 1 line
2.14.5
PATCH 3/5 doxygen: remove EXPORT_SYMBOL from the output
In reply to Duncan RoeFrom: Pablo Neira Ayuso <[email protected]>
Add input filter to remove the internal EXPORT_SYMBOL macro that turns on the compiler visibility attribute.
--- doxygen.cfg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
doxygen.cfg.in +1 -1
@@ -77,7 +77,7 @@ EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = -INPUT_FILTER = +INPUT_FILTER = "sed 's/EXPORT_SYMBOL//g'" FILTER_PATTERNS = FILTER_SOURCE_FILES = NO SOURCE_BROWSER = YES
Signature · 1 line
2.14.5
PATCH 4/5 src: Fix invalid conversion specifier
In reply to Duncan RoeClang (but not gcc) warned about this. Gcc (but not clang) used to warn that nfq_set_verdict_mark is deprecated, but this has stopped since re-defining EXPORT_SYMBOL.
--- src/extra/ipv6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/extra/ipv6.c +1 -1
@@ -134,7 +134,7 @@ nfq_ip6_snprintf(char *buf, size_t size, const struct ip6_hdr *ip6h)inet_ntop (AF_INET6 , &ip6h->ip6_src, src,INET6_ADDRSTRLEN );inet_ntop (AF_INET6 , &ip6h->ip6_dst, dst,INET6_ADDRSTRLEN ); - ret = snprintf(buf, size, "SRC=%s DST=%s LEN=%Zu TC=0x%X " + ret = snprintf(buf, size, "SRC=%s DST=%s LEN=%zu TC=0x%X " "HOPLIMIT=%u FLOWLBL=%u ", src, dst, ntohs(ip6h->ip6_plen) + sizeof(struct ip6_hdr),
Signature · 1 line
2.14.5
PATCH 5/5 src: doc: Minor fix
In reply to Duncan RoeThe documentation generally uses OSI layer numbering, where TCP (i.e. Transport) is layer 4 so that IP is layer 3.
Bring pktb_mangle documentation into line with this.
--- src/extra/pktbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/extra/pktbuff.c +1 -1
@@ -226,7 +226,7 @@ static int enlarge_pkt(struct pkt_buff *pkt, unsigned int extra)/** * pktb_mangle - adjust contents of a packet * \param pkt Pointer to packet buffer -* \param dataoff Offset to layer 3 header. Specify zero to access layer 2 (IP) +* \param dataoff Offset to layer 4 header. Specify zero to access layer 3 (IP) * header * \param match_offset Further offset to content that you want to mangle * \param match_len Length of the existing content you want to mangle
Signature · 1 line
2.14.5
Pablo Neira Ayuso
maintainerQuoted 5 lines · Duncan Roe
This series is a mixture of patches to enable clang build and correct / insert doxygen comments. It ended up that way after git merges of local branches where they were originally developed.
Hopefully they are all uncontroversial so can just be applied.
Series applied, thanks.
I have just mangled "src: Enable clang build" not to split the function definition from its return value, it's a personal preference, I like to git grep for function definitions occasionally when searching for symbols. This is something in between your original proposal and what it's done in libmnl.
Thanks.