1 /*
2  * netlink/netfilter/ct.h	Conntrack
3  *
4  *	This library is free software; you can redistribute it and/or
5  *	modify it under the terms of the GNU Lesser General Public
6  *	License as published by the Free Software Foundation version 2.1
7  *	of the License.
8  *
9  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
10  * Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
11  * Copyright (c) 2007 Secure Computing Corporation
12  */
13 
14 #ifndef NETLINK_CT_H_
15 #define NETLINK_CT_H_
16 
17 #include <netlink/netlink.h>
18 #include <netlink/addr.h>
19 #include <netlink/cache.h>
20 #include <netlink/msg.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 struct nfnl_ct;
27 
28 struct nfnl_ct_timestamp {
29 	uint64_t		start;
30 	uint64_t		stop;
31 };
32 
33 extern struct nl_object_ops ct_obj_ops;
34 
35 extern struct nfnl_ct *	nfnl_ct_alloc(void);
36 extern int	nfnl_ct_alloc_cache(struct nl_sock *, struct nl_cache **);
37 
38 extern int	nfnlmsg_ct_group(struct nlmsghdr *);
39 extern int	nfnlmsg_ct_parse(struct nlmsghdr *, struct nfnl_ct **);
40 
41 extern void	nfnl_ct_get(struct nfnl_ct *);
42 extern void	nfnl_ct_put(struct nfnl_ct *);
43 
44 extern int	nfnl_ct_dump_request(struct nl_sock *);
45 
46 extern int	nfnl_ct_build_add_request(const struct nfnl_ct *, int,
47 					  struct nl_msg **);
48 extern int	nfnl_ct_add(struct nl_sock *, const struct nfnl_ct *, int);
49 
50 extern int	nfnl_ct_build_delete_request(const struct nfnl_ct *, int,
51 					     struct nl_msg **);
52 extern int	nfnl_ct_del(struct nl_sock *, const struct nfnl_ct *, int);
53 
54 extern int	nfnl_ct_build_query_request(const struct nfnl_ct *, int,
55 					    struct nl_msg **);
56 extern int	nfnl_ct_query(struct nl_sock *, const struct nfnl_ct *, int);
57 
58 extern void	nfnl_ct_set_family(struct nfnl_ct *, uint8_t);
59 extern uint8_t	nfnl_ct_get_family(const struct nfnl_ct *);
60 
61 extern void	nfnl_ct_set_proto(struct nfnl_ct *, uint8_t);
62 extern int	nfnl_ct_test_proto(const struct nfnl_ct *);
63 extern uint8_t	nfnl_ct_get_proto(const struct nfnl_ct *);
64 
65 extern void	nfnl_ct_set_tcp_state(struct nfnl_ct *, uint8_t);
66 extern int	nfnl_ct_test_tcp_state(const struct nfnl_ct *);
67 extern uint8_t	nfnl_ct_get_tcp_state(const struct nfnl_ct *);
68 extern char *	nfnl_ct_tcp_state2str(uint8_t, char *, size_t);
69 extern int	nfnl_ct_str2tcp_state(const char *name);
70 
71 extern void	nfnl_ct_set_status(struct nfnl_ct *, uint32_t);
72 extern void	nfnl_ct_unset_status(struct nfnl_ct *, uint32_t);
73 extern int	nfnl_ct_test_status(const struct nfnl_ct *ct);
74 extern uint32_t	nfnl_ct_get_status(const struct nfnl_ct *);
75 extern char *	nfnl_ct_status2str(int, char *, size_t);
76 extern int	nfnl_ct_str2status(const char *);
77 
78 extern void	nfnl_ct_set_timeout(struct nfnl_ct *, uint32_t);
79 extern int	nfnl_ct_test_timeout(const struct nfnl_ct *);
80 extern uint32_t	nfnl_ct_get_timeout(const struct nfnl_ct *);
81 
82 extern void	nfnl_ct_set_mark(struct nfnl_ct *, uint32_t);
83 extern int	nfnl_ct_test_mark(const struct nfnl_ct *);
84 extern uint32_t	nfnl_ct_get_mark(const struct nfnl_ct *);
85 
86 extern void	nfnl_ct_set_use(struct nfnl_ct *, uint32_t);
87 extern int	nfnl_ct_test_use(const struct nfnl_ct *);
88 extern uint32_t	nfnl_ct_get_use(const struct nfnl_ct *);
89 
90 extern void	nfnl_ct_set_id(struct nfnl_ct *, uint32_t);
91 extern int	nfnl_ct_test_id(const struct nfnl_ct *);
92 extern uint32_t	nfnl_ct_get_id(const struct nfnl_ct *);
93 
94 extern void	nfnl_ct_set_zone(struct nfnl_ct *, uint16_t);
95 extern int	nfnl_ct_test_zone(const struct nfnl_ct *);
96 extern uint16_t	nfnl_ct_get_zone(const struct nfnl_ct *);
97 
98 extern int	nfnl_ct_set_src(struct nfnl_ct *, int, struct nl_addr *);
99 extern struct nl_addr *	nfnl_ct_get_src(const struct nfnl_ct *, int);
100 
101 extern int	nfnl_ct_set_dst(struct nfnl_ct *, int, struct nl_addr *);
102 extern struct nl_addr *	nfnl_ct_get_dst(const struct nfnl_ct *, int);
103 
104 extern void	nfnl_ct_set_src_port(struct nfnl_ct *, int, uint16_t);
105 extern int	nfnl_ct_test_src_port(const struct nfnl_ct *, int);
106 extern uint16_t	nfnl_ct_get_src_port(const struct nfnl_ct *, int);
107 
108 extern void	nfnl_ct_set_dst_port(struct nfnl_ct *, int, uint16_t);
109 extern int	nfnl_ct_test_dst_port(const struct nfnl_ct *, int);
110 extern uint16_t	nfnl_ct_get_dst_port(const struct nfnl_ct *, int);
111 
112 extern void	nfnl_ct_set_icmp_id(struct nfnl_ct *, int, uint16_t);
113 extern int	nfnl_ct_test_icmp_id(const struct nfnl_ct *, int);
114 extern uint16_t	nfnl_ct_get_icmp_id(const struct nfnl_ct *, int);
115 
116 extern void	nfnl_ct_set_icmp_type(struct nfnl_ct *, int, uint8_t);
117 extern int	nfnl_ct_test_icmp_type(const struct nfnl_ct *, int);
118 extern uint8_t	nfnl_ct_get_icmp_type(const struct nfnl_ct *, int);
119 
120 extern void	nfnl_ct_set_icmp_code(struct nfnl_ct *, int, uint8_t);
121 extern int	nfnl_ct_test_icmp_code(const struct nfnl_ct *, int);
122 extern uint8_t	nfnl_ct_get_icmp_code(const struct nfnl_ct *, int);
123 
124 extern void	nfnl_ct_set_packets(struct nfnl_ct *, int, uint64_t);
125 extern int	nfnl_ct_test_packets(const struct nfnl_ct *, int);
126 extern uint64_t	nfnl_ct_get_packets(const struct nfnl_ct *,int);
127 
128 extern void	nfnl_ct_set_bytes(struct nfnl_ct *, int, uint64_t);
129 extern int	nfnl_ct_test_bytes(const struct nfnl_ct *, int);
130 extern uint64_t	nfnl_ct_get_bytes(const struct nfnl_ct *, int);
131 
132 extern void nfnl_ct_set_timestamp(struct nfnl_ct *, uint64_t, uint64_t);
133 extern int nfnl_ct_test_timestamp(const struct nfnl_ct *);
134 extern const struct nfnl_ct_timestamp *nfnl_ct_get_timestamp(const struct nfnl_ct *);
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif
141