abstract 'nfattr' in 'nfnl_q_data'
[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
18 #include <linux/netfilter/nfnetlink.h>
19 #include <linux/netfilter/nfnetlink_queue.h>
20
21 struct nfqnl_handle;
22 struct nfqnl_q_handle;
23 struct nfnl_q_data;
24
25 extern int nfqnl_errno;
26
27 extern struct nfnl_handle *nfqnl_nfnlh(struct nfqnl_handle *h);
28 extern int nfqnl_fd(struct nfqnl_handle *h);
29
30 typedef int  nfqnl_callback(struct nfqnl_q_handle *gh, struct nfgenmsg *nfmsg,
31                        struct nfnl_q_data *nfad, void *data);
32
33
34 extern struct nfqnl_handle *nfqnl_open(void);
35 extern int nfqnl_close(struct nfqnl_handle *h);
36
37 extern int nfqnl_bind_pf(struct nfqnl_handle *h, u_int16_t pf);
38 extern int nfqnl_unbind_pf(struct nfqnl_handle *h, u_int16_t pf);
39
40 extern struct nfqnl_q_handle *nfqnl_create_queue(struct nfqnl_handle *h,
41                                                  u_int16_t num,
42                                                  nfqnl_callback *cb,
43                                                  void *data);
44 extern int nfqnl_destroy_queue(struct nfqnl_q_handle *qh);
45
46 extern int nfqnl_handle_packet(struct nfqnl_handle *h, char *buf, int len);
47
48 extern int nfqnl_set_mode(struct nfqnl_q_handle *qh,
49                           u_int8_t mode, unsigned int len);
50
51 extern int nfqnl_set_verdict(struct nfqnl_q_handle *qh,
52                              u_int32_t id,
53                              u_int32_t verdict,
54                              u_int32_t data_len,
55                              unsigned char *buf);
56
57 extern int nfqnl_set_verdict_mark(struct nfqnl_q_handle *qh, 
58                                   u_int32_t id,
59                                   u_int32_t verdict, 
60                                   u_int32_t mark,
61                                   u_int32_t datalen,
62                                   unsigned char *buf);
63
64 /* message parsing function */
65
66 extern struct nfqnl_msg_packet_hdr *
67                                 nfqnl_get_msg_packet_hdr(struct nfnl_q_data *nfad);
68
69 extern u_int32_t nfqnl_get_nfmark(struct nfnl_q_data *nfad);
70
71 extern struct nfqnl_msg_packet_timestamp *
72                                 nfqnl_get_timestamp(struct nfnl_q_data *nfad);
73
74 /* return 0 if not set */
75 extern u_int32_t nfqnl_get_indev(struct nfnl_q_data *nfad);
76 extern u_int32_t nfqnl_get_physindev(struct nfnl_q_data *nfad);
77 extern u_int32_t nfqnl_get_outdev(struct nfnl_q_data *nfad);
78 extern u_int32_t nfqnl_get_physoutdev(struct nfnl_q_data *nfad);
79
80 extern struct nfqnl_msg_packet_hw *nfqnl_get_packet_hw(struct nfnl_q_data *nfad);
81
82 /* return 0 if problem */
83 extern int nfqnl_get_payload(struct nfnl_q_data *nfad,
84                              char ** data, unsigned int* datalen);
85
86
87
88 #endif  /* __LIBNFQNETLINK_H */