diff options
author | Duncan Roe <duncan_roe@optusnet.com.au> | 2019-10-08 11:49:45 +1100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-10-08 12:19:10 +0200 |
commit | 24ba8cd8e4cebb0faeddff68498b5fdad7f1dd6b (patch) | |
tree | e3551c29b5ad1e24a85ebca386ae9d88888765a0 /src/libnetfilter_queue.c | |
parent | ae497107eb8b44e2ad8429a0ffa971ded1fe801c (diff) | |
download | libnetfilter_queue-24ba8cd8e4cebb0faeddff68498b5fdad7f1dd6b.tar.gz |
src: Enable clang build
Modify 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.
Finally, re-align multi-line parameter blocks with opening parenthesis.
[ I have mangled the original patch to not split the function definition and
its return value. --pablo ]
Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/libnetfilter_queue.c')
-rw-r--r-- | src/libnetfilter_queue.c | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/src/libnetfilter_queue.c b/src/libnetfilter_queue.c index 673e3b0..7014878 100644 --- a/src/libnetfilter_queue.c +++ b/src/libnetfilter_queue.c @@ -133,8 +133,7 @@ struct nfq_data { struct nfattr **data; }; -int nfq_errno; -EXPORT_SYMBOL(nfq_errno); +EXPORT_SYMBOL int nfq_errno; /*********************************************************************** * low level stuff @@ -218,11 +217,11 @@ static int __nfq_rcv_pkt(struct nlmsghdr *nlh, struct nfattr *nfa[], /* public interface */ +EXPORT_SYMBOL struct nfnl_handle *nfq_nfnlh(struct nfq_handle *h) { return h->nfnlh; } -EXPORT_SYMBOL(nfq_nfnlh); /** * @@ -294,11 +293,11 @@ EXPORT_SYMBOL(nfq_nfnlh); * over the netlink connection associated with the given queue connection * handle. */ +EXPORT_SYMBOL int nfq_fd(struct nfq_handle *h) { return nfnl_fd(nfq_nfnlh(h)); } -EXPORT_SYMBOL(nfq_fd); /** * @} */ @@ -349,6 +348,7 @@ EXPORT_SYMBOL(nfq_fd); * * \return a pointer to a new queue handle or NULL on failure. */ +EXPORT_SYMBOL struct nfq_handle *nfq_open(void) { struct nfnl_handle *nfnlh = nfnl_open(); @@ -366,7 +366,6 @@ struct nfq_handle *nfq_open(void) return qh; } -EXPORT_SYMBOL(nfq_open); /** * @} @@ -382,6 +381,7 @@ EXPORT_SYMBOL(nfq_open); * * \return a pointer to a new queue handle or NULL on failure. */ +EXPORT_SYMBOL struct nfq_handle *nfq_open_nfnl(struct nfnl_handle *nfnlh) { struct nfnl_callback pkt_cb = { @@ -419,7 +419,6 @@ out_free: free(h); return NULL; } -EXPORT_SYMBOL(nfq_open_nfnl); /** * \addtogroup LibrarySetup @@ -438,16 +437,16 @@ EXPORT_SYMBOL(nfq_open_nfnl); * * \return 0 on success, non-zero on failure. */ +EXPORT_SYMBOL int nfq_close(struct nfq_handle *h) { int ret; - + ret = nfnl_close(h->nfnlh); if (ret == 0) free(h); return ret; } -EXPORT_SYMBOL(nfq_close); /** * nfq_bind_pf - bind a nfqueue handler to a given protocol family @@ -460,11 +459,11 @@ EXPORT_SYMBOL(nfq_close); * * \return integer inferior to 0 in case of failure */ +EXPORT_SYMBOL int nfq_bind_pf(struct nfq_handle *h, uint16_t pf) { return __build_send_cfg_msg(h, NFQNL_CFG_CMD_PF_BIND, 0, pf); } -EXPORT_SYMBOL(nfq_bind_pf); /** * nfq_unbind_pf - unbind nfqueue handler from a protocol family @@ -476,11 +475,11 @@ EXPORT_SYMBOL(nfq_bind_pf); * * This call is obsolete, Linux kernels from 3.8 onwards ignore it. */ +EXPORT_SYMBOL int nfq_unbind_pf(struct nfq_handle *h, uint16_t pf) { return __build_send_cfg_msg(h, NFQNL_CFG_CMD_PF_UNBIND, 0, pf); } -EXPORT_SYMBOL(nfq_unbind_pf); /** @@ -524,10 +523,9 @@ typedef int nfq_callback(struct nfq_q_handle *qh, * The callback should return < 0 to stop processing. */ -struct nfq_q_handle *nfq_create_queue(struct nfq_handle *h, - uint16_t num, - nfq_callback *cb, - void *data) +EXPORT_SYMBOL +struct nfq_q_handle *nfq_create_queue(struct nfq_handle *h, uint16_t num, + nfq_callback *cb, void *data) { int ret; struct nfq_q_handle *qh; @@ -555,7 +553,6 @@ struct nfq_q_handle *nfq_create_queue(struct nfq_handle *h, add_qh(qh); return qh; } -EXPORT_SYMBOL(nfq_create_queue); /** * @} @@ -573,6 +570,7 @@ EXPORT_SYMBOL(nfq_create_queue); * Removes the binding for the specified queue handle. This call also unbind * from the nfqueue handler, so you don't have to call nfq_unbind_pf. */ +EXPORT_SYMBOL int nfq_destroy_queue(struct nfq_q_handle *qh) { int ret = __build_send_cfg_msg(qh->h, NFQNL_CFG_CMD_UNBIND, qh->id, 0); @@ -583,7 +581,6 @@ int nfq_destroy_queue(struct nfq_q_handle *qh) return ret; } -EXPORT_SYMBOL(nfq_destroy_queue); /** * nfq_handle_packet - handle a packet received from the nfqueue subsystem @@ -597,11 +594,11 @@ EXPORT_SYMBOL(nfq_destroy_queue); * * \return 0 on success, non-zero on failure. */ +EXPORT_SYMBOL int nfq_handle_packet(struct nfq_handle *h, char *buf, int len) { return nfnl_handle_packet(h->nfnlh, buf, len); } -EXPORT_SYMBOL(nfq_handle_packet); /** * nfq_set_mode - set the amount of packet data that nfqueue copies to userspace @@ -618,8 +615,8 @@ EXPORT_SYMBOL(nfq_handle_packet); * * \return -1 on error; >=0 otherwise. */ -int nfq_set_mode(struct nfq_q_handle *qh, - uint8_t mode, uint32_t range) +EXPORT_SYMBOL +int nfq_set_mode(struct nfq_q_handle *qh, uint8_t mode, uint32_t range) { union { char buf[NFNL_HEADER_LEN @@ -638,7 +635,6 @@ int nfq_set_mode(struct nfq_q_handle *qh, return nfnl_query(qh->h->nfnlh, &u.nmh); } -EXPORT_SYMBOL(nfq_set_mode); /** * nfq_set_queue_flags - set flags (options) for the kernel queue @@ -708,8 +704,8 @@ EXPORT_SYMBOL(nfq_set_mode); * * \return -1 on error with errno set appropriately; =0 otherwise. */ -int nfq_set_queue_flags(struct nfq_q_handle *qh, - uint32_t mask, uint32_t flags) +EXPORT_SYMBOL +int nfq_set_queue_flags(struct nfq_q_handle *qh, uint32_t mask, uint32_t flags) { union { char buf[NFNL_HEADER_LEN @@ -729,7 +725,6 @@ int nfq_set_queue_flags(struct nfq_q_handle *qh, return nfnl_query(qh->h->nfnlh, &u.nmh); } -EXPORT_SYMBOL(nfq_set_queue_flags); /** * nfq_set_queue_maxlen - Set kernel queue maximum length parameter @@ -742,8 +737,8 @@ EXPORT_SYMBOL(nfq_set_queue_flags); * * \return -1 on error; >=0 otherwise. */ -int nfq_set_queue_maxlen(struct nfq_q_handle *qh, - uint32_t queuelen) +EXPORT_SYMBOL +int nfq_set_queue_maxlen(struct nfq_q_handle *qh, uint32_t queuelen) { union { char buf[NFNL_HEADER_LEN @@ -760,7 +755,6 @@ int nfq_set_queue_maxlen(struct nfq_q_handle *qh, return nfnl_query(qh->h->nfnlh, &u.nmh); } -EXPORT_SYMBOL(nfq_set_queue_maxlen); /** * @} @@ -847,14 +841,14 @@ static int __set_verdict(struct nfq_q_handle *qh, uint32_t id, * * \return -1 on error; >= 0 otherwise. */ +EXPORT_SYMBOL int nfq_set_verdict(struct nfq_q_handle *qh, uint32_t id, - uint32_t verdict, uint32_t data_len, - const unsigned char *buf) + uint32_t verdict, uint32_t data_len, + const unsigned char *buf) { return __set_verdict(qh, id, verdict, 0, 0, data_len, buf, NFQNL_MSG_VERDICT); } -EXPORT_SYMBOL(nfq_set_verdict); /** * nfq_set_verdict2 - like nfq_set_verdict, but you can set the mark. @@ -865,6 +859,7 @@ EXPORT_SYMBOL(nfq_set_verdict); * \param data_len number of bytes of data pointed to by #buf * \param buf the buffer that contains the packet data */ +EXPORT_SYMBOL int nfq_set_verdict2(struct nfq_q_handle *qh, uint32_t id, uint32_t verdict, uint32_t mark, uint32_t data_len, const unsigned char *buf) @@ -872,7 +867,6 @@ int nfq_set_verdict2(struct nfq_q_handle *qh, uint32_t id, return __set_verdict(qh, id, verdict, htonl(mark), 1, data_len, buf, NFQNL_MSG_VERDICT); } -EXPORT_SYMBOL(nfq_set_verdict2); /** * nfq_set_verdict_batch - issue verdicts on several packets at once @@ -886,13 +880,13 @@ EXPORT_SYMBOL(nfq_set_verdict2); * batch support was added in Linux 3.1. * These functions will fail silently on older kernels. */ +EXPORT_SYMBOL int nfq_set_verdict_batch(struct nfq_q_handle *qh, uint32_t id, - uint32_t verdict) + uint32_t verdict) { return __set_verdict(qh, id, verdict, 0, 0, 0, NULL, NFQNL_MSG_VERDICT_BATCH); } -EXPORT_SYMBOL(nfq_set_verdict_batch); /** * nfq_set_verdict_batch2 - like nfq_set_verdict_batch, but you can set a mark. @@ -901,13 +895,13 @@ EXPORT_SYMBOL(nfq_set_verdict_batch); * \param verdict verdict to return to netfilter (NF_ACCEPT, NF_DROP) * \param mark mark to put on packet */ +EXPORT_SYMBOL int nfq_set_verdict_batch2(struct nfq_q_handle *qh, uint32_t id, - uint32_t verdict, uint32_t mark) + uint32_t verdict, uint32_t mark) { return __set_verdict(qh, id, verdict, htonl(mark), 1, 0, NULL, NFQNL_MSG_VERDICT_BATCH); } -EXPORT_SYMBOL(nfq_set_verdict_batch2); /** * nfq_set_verdict_mark - like nfq_set_verdict, but you can set the mark. @@ -923,14 +917,14 @@ EXPORT_SYMBOL(nfq_set_verdict_batch2); * This function is deprecated since it is broken, its use is highly * discouraged. Please, use nfq_set_verdict2 instead. */ +EXPORT_SYMBOL int nfq_set_verdict_mark(struct nfq_q_handle *qh, uint32_t id, - uint32_t verdict, uint32_t mark, - uint32_t data_len, const unsigned char *buf) + uint32_t verdict, uint32_t mark, + uint32_t data_len, const unsigned char *buf) { return __set_verdict(qh, id, verdict, mark, 1, data_len, buf, NFQNL_MSG_VERDICT); } -EXPORT_SYMBOL(nfq_set_verdict_mark); /** * @} @@ -965,12 +959,12 @@ EXPORT_SYMBOL(nfq_set_verdict_mark); } __attribute__ ((packed)); \endverbatim */ +EXPORT_SYMBOL struct nfqnl_msg_packet_hdr *nfq_get_msg_packet_hdr(struct nfq_data *nfad) { return nfnl_get_pointer_to_data(nfad->data, NFQA_PACKET_HDR, struct nfqnl_msg_packet_hdr); } -EXPORT_SYMBOL(nfq_get_msg_packet_hdr); /** * nfq_get_nfmark - get the packet mark @@ -978,11 +972,11 @@ EXPORT_SYMBOL(nfq_get_msg_packet_hdr); * * \return the netfilter mark currently assigned to the given queued packet. */ +EXPORT_SYMBOL uint32_t nfq_get_nfmark(struct nfq_data *nfad) { return ntohl(nfnl_get_data(nfad->data, NFQA_MARK, uint32_t)); } -EXPORT_SYMBOL(nfq_get_nfmark); /** * nfq_get_timestamp - get the packet timestamp @@ -993,6 +987,7 @@ EXPORT_SYMBOL(nfq_get_nfmark); * * \return 0 on success, non-zero on failure. */ +EXPORT_SYMBOL int nfq_get_timestamp(struct nfq_data *nfad, struct timeval *tv) { struct nfqnl_msg_packet_timestamp *qpt; @@ -1006,7 +1001,6 @@ int nfq_get_timestamp(struct nfq_data *nfad, struct timeval *tv) return 0; } -EXPORT_SYMBOL(nfq_get_timestamp); /** * nfq_get_indev - get the interface that the packet was received through @@ -1019,11 +1013,11 @@ EXPORT_SYMBOL(nfq_get_timestamp); * \warning all nfq_get_dev() functions return 0 if not set, since linux * only allows ifindex >= 1, see net/core/dev.c:2600 (in 2.6.13.1) */ +EXPORT_SYMBOL uint32_t nfq_get_indev(struct nfq_data *nfad) { return ntohl(nfnl_get_data(nfad->data, NFQA_IFINDEX_INDEV, uint32_t)); } -EXPORT_SYMBOL(nfq_get_indev); /** * nfq_get_physindev - get the physical interface that the packet was received @@ -1033,11 +1027,11 @@ EXPORT_SYMBOL(nfq_get_indev); * If the returned index is 0, the packet was locally generated or the * physical input interface is no longer known (ie. POSTROUTING?). */ +EXPORT_SYMBOL uint32_t nfq_get_physindev(struct nfq_data *nfad) { return ntohl(nfnl_get_data(nfad->data, NFQA_IFINDEX_PHYSINDEV, uint32_t)); } -EXPORT_SYMBOL(nfq_get_physindev); /** * nfq_get_outdev - gets the interface that the packet will be routed out @@ -1047,11 +1041,11 @@ EXPORT_SYMBOL(nfq_get_physindev); * returned index is 0, the packet is destined for localhost or the output * interface is not yet known (ie. PREROUTING?). */ +EXPORT_SYMBOL uint32_t nfq_get_outdev(struct nfq_data *nfad) { return ntohl(nfnl_get_data(nfad->data, NFQA_IFINDEX_OUTDEV, uint32_t)); } -EXPORT_SYMBOL(nfq_get_outdev); /** * nfq_get_physoutdev - get the physical interface that the packet output @@ -1063,11 +1057,11 @@ EXPORT_SYMBOL(nfq_get_outdev); * * \return The index of physical interface that the packet output will be routed out. */ +EXPORT_SYMBOL uint32_t nfq_get_physoutdev(struct nfq_data *nfad) { return ntohl(nfnl_get_data(nfad->data, NFQA_IFINDEX_PHYSOUTDEV, uint32_t)); } -EXPORT_SYMBOL(nfq_get_physoutdev); /** * nfq_get_indev_name - get the name of the interface the packet @@ -1107,13 +1101,13 @@ EXPORT_SYMBOL(nfq_get_physoutdev); \endverbatim * */ +EXPORT_SYMBOL int nfq_get_indev_name(struct nlif_handle *nlif_handle, - struct nfq_data *nfad, char *name) + struct nfq_data *nfad, char *name) { uint32_t ifindex = nfq_get_indev(nfad); return nlif_index2name(nlif_handle, ifindex, name); } -EXPORT_SYMBOL(nfq_get_indev_name); /** * nfq_get_physindev_name - get the name of the physical interface the @@ -1127,13 +1121,13 @@ EXPORT_SYMBOL(nfq_get_indev_name); * * \return -1 in case of error, > 0 if it succeed. */ +EXPORT_SYMBOL int nfq_get_physindev_name(struct nlif_handle *nlif_handle, struct nfq_data *nfad, char *name) { uint32_t ifindex = nfq_get_physindev(nfad); return nlif_index2name(nlif_handle, ifindex, name); } -EXPORT_SYMBOL(nfq_get_physindev_name); /** * nfq_get_outdev_name - get the name of the physical interface the @@ -1147,13 +1141,13 @@ EXPORT_SYMBOL(nfq_get_physindev_name); * * \return -1 in case of error, > 0 if it succeed. */ +EXPORT_SYMBOL int nfq_get_outdev_name(struct nlif_handle *nlif_handle, struct nfq_data *nfad, char *name) { uint32_t ifindex = nfq_get_outdev(nfad); return nlif_index2name(nlif_handle, ifindex, name); } -EXPORT_SYMBOL(nfq_get_outdev_name); /** * nfq_get_physoutdev_name - get the name of the interface the @@ -1168,13 +1162,13 @@ EXPORT_SYMBOL(nfq_get_outdev_name); * \return -1 in case of error, > 0 if it succeed. */ +EXPORT_SYMBOL int nfq_get_physoutdev_name(struct nlif_handle *nlif_handle, struct nfq_data *nfad, char *name) { uint32_t ifindex = nfq_get_physoutdev(nfad); return nlif_index2name(nlif_handle, ifindex, name); } -EXPORT_SYMBOL(nfq_get_physoutdev_name); /** * nfq_get_packet_hw @@ -1198,12 +1192,12 @@ EXPORT_SYMBOL(nfq_get_physoutdev_name); } __attribute__ ((packed)); \endverbatim */ +EXPORT_SYMBOL struct nfqnl_msg_packet_hw *nfq_get_packet_hw(struct nfq_data *nfad) { return nfnl_get_pointer_to_data(nfad->data, NFQA_HWADDR, struct nfqnl_msg_packet_hw); } -EXPORT_SYMBOL(nfq_get_packet_hw); /** * nfq_get_uid - get the UID of the user the packet belongs to @@ -1215,6 +1209,7 @@ EXPORT_SYMBOL(nfq_get_packet_hw); * * \return 1 if there is a UID available, 0 otherwise. */ +EXPORT_SYMBOL int nfq_get_uid(struct nfq_data *nfad, uint32_t *uid) { if (!nfnl_attr_present(nfad->data, NFQA_UID)) @@ -1223,7 +1218,6 @@ int nfq_get_uid(struct nfq_data *nfad, uint32_t *uid) *uid = ntohl(nfnl_get_data(nfad->data, NFQA_UID, uint32_t)); return 1; } -EXPORT_SYMBOL(nfq_get_uid); /** * nfq_get_gid - get the GID of the user the packet belongs to @@ -1235,6 +1229,7 @@ EXPORT_SYMBOL(nfq_get_uid); * * \return 1 if there is a GID available, 0 otherwise. */ +EXPORT_SYMBOL int nfq_get_gid(struct nfq_data *nfad, uint32_t *gid) { if (!nfnl_attr_present(nfad->data, NFQA_GID)) @@ -1243,7 +1238,6 @@ int nfq_get_gid(struct nfq_data *nfad, uint32_t *gid) *gid = ntohl(nfnl_get_data(nfad->data, NFQA_GID, uint32_t)); return 1; } -EXPORT_SYMBOL(nfq_get_gid); /** * nfq_get_secctx - get the security context for this packet @@ -1256,6 +1250,7 @@ EXPORT_SYMBOL(nfq_get_gid); * * \return -1 on error, otherwise > 0 */ +EXPORT_SYMBOL int nfq_get_secctx(struct nfq_data *nfad, unsigned char **secdata) { if (!nfnl_attr_present(nfad->data, NFQA_SECCTX)) @@ -1269,7 +1264,6 @@ int nfq_get_secctx(struct nfq_data *nfad, unsigned char **secdata) return 0; } -EXPORT_SYMBOL(nfq_get_secctx); /** * nfq_get_payload - get payload @@ -1282,6 +1276,7 @@ EXPORT_SYMBOL(nfq_get_secctx); * * \return -1 on error, otherwise > 0. */ +EXPORT_SYMBOL int nfq_get_payload(struct nfq_data *nfad, unsigned char **data) { *data = (unsigned char *) @@ -1291,7 +1286,6 @@ int nfq_get_payload(struct nfq_data *nfad, unsigned char **data) return -1; } -EXPORT_SYMBOL(nfq_get_payload); /** * @} @@ -1336,6 +1330,7 @@ do { \ * would have been printed into the buffer (in case that there is enough * room in it). See snprintf() return value for more information. */ +EXPORT_SYMBOL int nfq_snprintf_xml(char *buf, size_t rem, struct nfq_data *tb, int flags) { struct nfqnl_msg_packet_hdr *ph; @@ -1489,7 +1484,6 @@ int nfq_snprintf_xml(char *buf, size_t rem, struct nfq_data *tb, int flags) return len; } -EXPORT_SYMBOL(nfq_snprintf_xml); /** * @} |