src: implement API to set per-queue flags
[platform/upstream/libnetfilter_queue.git] / include / libnetfilter_queue / libnetfilter_queue.h
1 /* libnfqnetlink.h: Header file for the Netfilter Queue library.
2  *
3  * (C) 2005 by Harald Welte <laforge@gnumonks.org>
4  *
5  *
6  * Changelog : 
7  *      (2005/08/11)  added  parsing function (Eric Leblond <regit@inl.fr>)
8  * 
9  * This software may be used and distributed according to the terms
10  * of the GNU General Public License, incorporated herein by reference.
11  */
12
13 #ifndef __LIBCTNETLINK_H
14 #define __LIBCTNETLINK_H
15
16 #include <libnfnetlink/libnfnetlink.h>
17 // #include <libnfnetlink/liunx_nfnetlink.h>
18
19 #include <libnetfilter_queue/linux_nfnetlink_queue.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 struct nfq_handle;
26 struct nfq_q_handle;
27 struct nfq_data;
28
29 extern int nfq_errno;
30
31 extern struct nfnl_handle *nfq_nfnlh(struct nfq_handle *h);
32 extern int nfq_fd(struct nfq_handle *h);
33
34 typedef int  nfq_callback(struct nfq_q_handle *gh, struct nfgenmsg *nfmsg,
35                        struct nfq_data *nfad, void *data);
36
37
38 extern struct nfq_handle *nfq_open(void);
39 extern struct nfq_handle *nfq_open_nfnl(struct nfnl_handle *nfnlh);
40 extern int nfq_close(struct nfq_handle *h);
41
42 extern int nfq_bind_pf(struct nfq_handle *h, u_int16_t pf);
43 extern int nfq_unbind_pf(struct nfq_handle *h, u_int16_t pf);
44
45 extern struct nfq_q_handle *nfq_create_queue(struct nfq_handle *h,
46                                                  u_int16_t num,
47                                                  nfq_callback *cb,
48                                                  void *data);
49 extern int nfq_destroy_queue(struct nfq_q_handle *qh);
50
51 extern int nfq_handle_packet(struct nfq_handle *h, char *buf, int len);
52
53 extern int nfq_set_mode(struct nfq_q_handle *qh,
54                           u_int8_t mode, unsigned int len);
55
56 int nfq_set_queue_maxlen(struct nfq_q_handle *qh,
57                         u_int32_t queuelen);
58
59 extern int nfq_set_queue_flags(struct nfq_q_handle *qh,
60                                uint32_t mask, uint32_t flags);
61
62 extern int nfq_set_verdict(struct nfq_q_handle *qh,
63                              u_int32_t id,
64                              u_int32_t verdict,
65                              u_int32_t data_len,
66                              const unsigned char *buf);
67
68 extern int nfq_set_verdict2(struct nfq_q_handle *qh,
69                             u_int32_t id,
70                             u_int32_t verdict, 
71                             u_int32_t mark,
72                             u_int32_t datalen,
73                             const unsigned char *buf);
74
75 extern int nfq_set_verdict_batch(struct nfq_q_handle *qh,
76                             u_int32_t id,
77                             u_int32_t verdict);
78
79 extern int nfq_set_verdict_batch2(struct nfq_q_handle *qh,
80                             u_int32_t id,
81                             u_int32_t verdict,
82                             u_int32_t mark);
83
84 extern __attribute__((deprecated))
85 int nfq_set_verdict_mark(struct nfq_q_handle *qh, 
86                          u_int32_t id,
87                          u_int32_t verdict, 
88                          u_int32_t mark,
89                          u_int32_t datalen,
90                          const unsigned char *buf);
91
92 /* message parsing function */
93
94 extern struct nfqnl_msg_packet_hdr *
95                                 nfq_get_msg_packet_hdr(struct nfq_data *nfad);
96
97 extern u_int32_t nfq_get_nfmark(struct nfq_data *nfad);
98
99 extern int nfq_get_timestamp(struct nfq_data *nfad, struct timeval *tv);
100
101 /* return 0 if not set */
102 extern u_int32_t nfq_get_indev(struct nfq_data *nfad);
103 extern u_int32_t nfq_get_physindev(struct nfq_data *nfad);
104 extern u_int32_t nfq_get_outdev(struct nfq_data *nfad);
105 extern u_int32_t nfq_get_physoutdev(struct nfq_data *nfad);
106
107 extern int nfq_get_indev_name(struct nlif_handle *nlif_handle,
108                               struct nfq_data *nfad, char *name);
109 extern int nfq_get_physindev_name(struct nlif_handle *nlif_handle,
110                                   struct nfq_data *nfad, char *name);
111 extern int nfq_get_outdev_name(struct nlif_handle *nlif_handle,
112                                struct nfq_data *nfad, char *name);
113 extern int nfq_get_physoutdev_name(struct nlif_handle *nlif_handle,
114                                    struct nfq_data *nfad, char *name);
115
116 extern struct nfqnl_msg_packet_hw *nfq_get_packet_hw(struct nfq_data *nfad);
117
118 /* return -1 if problem, length otherwise */
119 extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
120
121 enum {
122         NFQ_XML_HW      = (1 << 0),
123         NFQ_XML_MARK    = (1 << 1),
124         NFQ_XML_DEV     = (1 << 2),
125         NFQ_XML_PHYSDEV = (1 << 3),
126         NFQ_XML_PAYLOAD = (1 << 4),
127         NFQ_XML_TIME    = (1 << 5),
128         NFQ_XML_ALL     = ~0U,
129 };
130
131 extern int nfq_snprintf_xml(char *buf, size_t len, struct nfq_data *tb, int flags);
132
133 #ifdef __cplusplus
134 } /* extern "C" */
135 #endif
136
137 #endif  /* __LIBNFQNETLINK_H */