Debian Codegraph @

src/obj/ct_timeout.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-or-later */cxx . . $ `<file>/src/obj/ct_timeout.c`/
2 /*
3 * (C) 2018 by Harsha Sharma <[email protected]>
4 */
5
6 #include <stdio.h>
7 #include <stdint.h>
8 #include <arpa/inet.h>
9 #include <errno.h>
10 #include <inttypes.h>
11
12 #include <linux/netfilter/nf_tables.h>cxx . . $ `<file>/include/linux/netfilter/nf_tables.h`/
13
14 #include "internal.h"cxx . . $ `<file>/include/internal.h`/
15 #include <libmnl/libmnl.h>
16 #include <libnftnl/object.h>cxx . . $ `<file>/include/libnftnl/object.h`/
17
18 #include "obj.h"cxx . . $ `<file>/include/obj.h`/
19
20 static const char *const tcp_state_to_namecxx . . $ tcp_state_to_name.[NFTNL_CTTIMEOUT_TCP_MAXcxx . . $ NFTNL_CTTIMEOUT_TCP_MAX.] = {
21 [NFTNL_CTTIMEOUT_TCP_SYN_SENTcxx . . $ NFTNL_CTTIMEOUT_TCP_SYN_SENT.] = "SYN_SENT",
22 [NFTNL_CTTIMEOUT_TCP_SYN_RECVcxx . . $ NFTNL_CTTIMEOUT_TCP_SYN_RECV.] = "SYN_RECV",
23 [NFTNL_CTTIMEOUT_TCP_ESTABLISHEDcxx . . $ NFTNL_CTTIMEOUT_TCP_ESTABLISHED.] = "ESTABLISHED",
24 [NFTNL_CTTIMEOUT_TCP_FIN_WAITcxx . . $ NFTNL_CTTIMEOUT_TCP_FIN_WAIT.] = "FIN_WAIT",
25 [NFTNL_CTTIMEOUT_TCP_CLOSE_WAITcxx . . $ NFTNL_CTTIMEOUT_TCP_CLOSE_WAIT.] = "CLOSE_WAIT",
26 [NFTNL_CTTIMEOUT_TCP_LAST_ACKcxx . . $ NFTNL_CTTIMEOUT_TCP_LAST_ACK.] = "LAST_ACK",
27 [NFTNL_CTTIMEOUT_TCP_TIME_WAITcxx . . $ NFTNL_CTTIMEOUT_TCP_TIME_WAIT.] = "TIME_WAIT",
28 [NFTNL_CTTIMEOUT_TCP_CLOSEcxx . . $ NFTNL_CTTIMEOUT_TCP_CLOSE.] = "CLOSE",
29 [NFTNL_CTTIMEOUT_TCP_SYN_SENT2cxx . . $ NFTNL_CTTIMEOUT_TCP_SYN_SENT2.] = "SYN_SENT2",
30 [NFTNL_CTTIMEOUT_TCP_RETRANScxx . . $ NFTNL_CTTIMEOUT_TCP_RETRANS.] = "RETRANS",
31 [NFTNL_CTTIMEOUT_TCP_UNACKcxx . . $ NFTNL_CTTIMEOUT_TCP_UNACK.] = "UNACKNOWLEDGED",
32 };
33
34 static uint32_tcxx . . $ uint32_t# tcp_dflt_timeoutcxx . . $ tcp_dflt_timeout.[NFTNL_CTTIMEOUT_TCP_MAXcxx . . $ NFTNL_CTTIMEOUT_TCP_MAX.] = {
35 [NFTNL_CTTIMEOUT_TCP_SYN_SENTcxx . . $ NFTNL_CTTIMEOUT_TCP_SYN_SENT.] = 120,
36 [NFTNL_CTTIMEOUT_TCP_SYN_RECVcxx . . $ NFTNL_CTTIMEOUT_TCP_SYN_RECV.] = 60,
37 [NFTNL_CTTIMEOUT_TCP_ESTABLISHEDcxx . . $ NFTNL_CTTIMEOUT_TCP_ESTABLISHED.] = 432000,
38 [NFTNL_CTTIMEOUT_TCP_FIN_WAITcxx . . $ NFTNL_CTTIMEOUT_TCP_FIN_WAIT.] = 120,
39 [NFTNL_CTTIMEOUT_TCP_CLOSE_WAITcxx . . $ NFTNL_CTTIMEOUT_TCP_CLOSE_WAIT.] = 60,
40 [NFTNL_CTTIMEOUT_TCP_LAST_ACKcxx . . $ NFTNL_CTTIMEOUT_TCP_LAST_ACK.] = 30,
41 [NFTNL_CTTIMEOUT_TCP_TIME_WAITcxx . . $ NFTNL_CTTIMEOUT_TCP_TIME_WAIT.] = 120,
42 [NFTNL_CTTIMEOUT_TCP_CLOSEcxx . . $ NFTNL_CTTIMEOUT_TCP_CLOSE.] = 10,
43 [NFTNL_CTTIMEOUT_TCP_SYN_SENT2cxx . . $ NFTNL_CTTIMEOUT_TCP_SYN_SENT2.] = 120,
44 [NFTNL_CTTIMEOUT_TCP_RETRANScxx . . $ NFTNL_CTTIMEOUT_TCP_RETRANS.] = 300,
45 [NFTNL_CTTIMEOUT_TCP_UNACKcxx . . $ NFTNL_CTTIMEOUT_TCP_UNACK.] = 300,
46 };
47
48 static const char *const udp_state_to_namecxx . . $ udp_state_to_name.[NFTNL_CTTIMEOUT_UDP_MAXcxx . . $ NFTNL_CTTIMEOUT_UDP_MAX.] = {
49 [NFTNL_CTTIMEOUT_UDP_UNREPLIEDcxx . . $ NFTNL_CTTIMEOUT_UDP_UNREPLIED.] = "UNREPLIED",
50 [NFTNL_CTTIMEOUT_UDP_REPLIEDcxx . . $ NFTNL_CTTIMEOUT_UDP_REPLIED.] = "REPLIED",
51 };
52
53 static uint32_tcxx . . $ uint32_t# udp_dflt_timeoutcxx . . $ udp_dflt_timeout.[NFTNL_CTTIMEOUT_UDP_MAXcxx . . $ NFTNL_CTTIMEOUT_UDP_MAX.] = {
54 [NFTNL_CTTIMEOUT_UDP_UNREPLIEDcxx . . $ NFTNL_CTTIMEOUT_UDP_UNREPLIED.] = 30,
55 [NFTNL_CTTIMEOUT_UDP_REPLIEDcxx . . $ NFTNL_CTTIMEOUT_UDP_REPLIED.] = 180,
56 };
57
58 static structcxx . . $ $anonymous_type_4766018635dc2f23_0# {
59 uint32_tcxx . . $ uint32_t# attr_maxcxx . . $ $anonymous_type_4766018635dc2f23_0#attr_max.;
60 const char *const *state_to_namecxx . . $ $anonymous_type_4766018635dc2f23_0#state_to_name.;
61 uint32_tcxx . . $ uint32_t# *dflt_timeoutcxx . . $ $anonymous_type_4766018635dc2f23_0#dflt_timeout.;
62 } timeout_protocolcxx . . $ timeout_protocol.[IPPROTO_MAXcxx . . $ IPPROTO_MAX.] = {
63 [IPPROTO_TCPcxx . . $ `<external>/9581057695539925927/in.h:51:9`!] = {
64 .attr_max = NFTNL_CTTIMEOUT_TCP_MAXcxx . . $ NFTNL_CTTIMEOUT_TCP_MAX.,
65 .state_to_name = tcp_state_to_namecxx . . $ tcp_state_to_name.,
66 .dflt_timeout = tcp_dflt_timeoutcxx . . $ tcp_dflt_timeout.,
67 },
68 [IPPROTO_UDPcxx . . $ `<external>/9581057695539925927/in.h:57:9`!] = {
69 .attr_max = NFTNL_CTTIMEOUT_UDP_MAXcxx . . $ NFTNL_CTTIMEOUT_UDP_MAX.,
70 .state_to_name = udp_state_to_namecxx . . $ udp_state_to_name.,
71 .dflt_timeout = udp_dflt_timeoutcxx . . $ udp_dflt_timeout.,
72 },
73 };
74
75 struct _container_policy_cbcxx . . $ _container_policy_cb# {
76 unsigned int nlattr_maxcxx . . $ _container_policy_cb#nlattr_max.;
77 void *tbcxx . . $ _container_policy_cb#tb.;
78 };
79
80 static int
81 nftnl_timeout_policy_attr_set_u32cxx . . $ nftnl_timeout_policy_attr_set_u32(7072f647009475a9).(struct nftnl_objcxx . . $ nftnl_obj# *e,
82 uint32_tcxx . . $ uint32_t# type, uint32_tcxx . . $ uint32_t# data)
83 {
84 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *t = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
85
86 if (type >= NFTNL_CTTIMEOUT_ARRAY_MAXcxx . . $ `include/libnftnl/object.h:69:9`!)
87 return -1;
88
89 t->timeoutcxx . . $ nftnl_obj_ct_timeout#timeout.[type] = data;
90
91 if (!(e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.)))
92 e->flagscxx . . $ nftnl_obj#flags. |= (1 << NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.);
93
94 return 0;
95 }
96
97 static int
98 parse_timeout_attr_policy_cbcxx . . $ parse_timeout_attr_policy_cb(de2ef18c48fd675c).(const struct nlattrcxx . . $ nlattr# *attr, void *data)
99 {
100 struct _container_policy_cbcxx . . $ _container_policy_cb# *data_cb = data;
101 const struct nlattrcxx . . $ nlattr# **tb = data_cb->tbcxx . . $ _container_policy_cb#tb.;
102 uint16_tcxx . . $ uint16_t# type = mnl_attr_get_typecxx . . $ mnl_attr_get_type(1da47bcc4c4b975).(attr);
103
104 if (mnl_attr_type_validcxx . . $ mnl_attr_type_valid(47df1cce1c7be855).(attr, data_cb->nlattr_maxcxx . . $ _container_policy_cb#nlattr_max.) < 0)
105 return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!;
106
107 if (type > 0 && type <= data_cb->nlattr_maxcxx . . $ _container_policy_cb#nlattr_max.) {
108 if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U32cxx . . $ MNL_TYPE_U32.) < 0)
109 abi_breakagecxx . . $ `include/utils.h:28:9`!();
110 tb[type - 1] = attr;
111 }
112 return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!;
113 }
114
115 static int
116 timeout_parse_attr_datacxx . . $ timeout_parse_attr_data(9581fc018b643f31).(struct nftnl_objcxx . . $ nftnl_obj# *e,
117 const struct nlattrcxx . . $ nlattr# *nest)
118 {
119 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *t = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
120 unsigned int attr_max = timeout_protocolcxx . . $ timeout_protocol.[t->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.].attr_maxcxx . . $ $anonymous_type_4766018635dc2f23_0#attr_max.;
121 struct nlattrcxx . . $ nlattr# *tb[attr_max];
122 struct _container_policy_cbcxx . . $ _container_policy_cb# cnt = {
123 .nlattr_max = attr_max,
124 .tb = tb,
125 };
126 unsigned int i;
127
128 memsetcxx . . $ memset(d1de1e4fb215f1c6).(tb, 0, sizeof(struct nlattrcxx . . $ nlattr# *) * attr_max);
129
130 if (mnl_attr_parse_nestedcxx . . $ mnl_attr_parse_nested(f99c0e9fa94f99d9).(nest, parse_timeout_attr_policy_cbcxx . . $ parse_timeout_attr_policy_cb(de2ef18c48fd675c)., &cnt) < 0)
131 return -1;
132
133 for (i = 0; i < array_sizecxx . . $ `include/utils.h:69:9`!(tb); i++) {
134 if (tb[i]) {
135 nftnl_timeout_policy_attr_set_u32cxx . . $ nftnl_timeout_policy_attr_set_u32(7072f647009475a9).(e, i,
136 ntohlcxx . . $ `<external>/9581057695539925927/in.h:428:12`!(mnl_attr_get_u32(tb[i])));
137 }
138 }
139 return 0;
140 }
141
142 static int nftnl_obj_ct_timeout_setcxx . . $ nftnl_obj_ct_timeout_set(96c901c785434bf1).(struct nftnl_objcxx . . $ nftnl_obj# *e, uint16_tcxx . . $ uint16_t# type,
143 const void *data, uint32_tcxx . . $ uint32_t# data_len)
144 {
145 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *timeout = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
146
147 switch (type) {
148 case NFTNL_OBJ_CT_TIMEOUT_L3PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L3PROTO.:
149 memcpycxx . . $ memcpy(cc817cb175f282d).(&timeout->l3protocxx . . $ nftnl_obj_ct_timeout#l3proto., data, data_len);
150 break;
151 case NFTNL_OBJ_CT_TIMEOUT_L4PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L4PROTO.:
152 memcpycxx . . $ memcpy(cc817cb175f282d).(&timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto., data, data_len);
153 break;
154 case NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.:
155 if (data_len < sizeof(uint32_tcxx . . $ uint32_t#) * NFTNL_CTTIMEOUT_ARRAY_MAXcxx . . $ `include/libnftnl/object.h:69:9`!)
156 return -1;
157
158 memcpycxx . . $ memcpy(cc817cb175f282d).(timeout->timeoutcxx . . $ nftnl_obj_ct_timeout#timeout., data,
159 sizeof(uint32_tcxx . . $ uint32_t#) * NFTNL_CTTIMEOUT_ARRAY_MAXcxx . . $ `include/libnftnl/object.h:69:9`!);
160 break;
161 }
162 return 0;
163 }
164
165 static const void *nftnl_obj_ct_timeout_getcxx . . $ nftnl_obj_ct_timeout_get(d22e54b888e7c4b).(const struct nftnl_objcxx . . $ nftnl_obj# *e,
166 uint16_tcxx . . $ uint16_t# type, uint32_tcxx . . $ uint32_t# *data_len)
167 {
168 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *timeout = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
169
170 switch (type) {
171 case NFTNL_OBJ_CT_TIMEOUT_L3PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L3PROTO.:
172 *data_len = sizeof(timeout->l3protocxx . . $ nftnl_obj_ct_timeout#l3proto.);
173 return &timeout->l3protocxx . . $ nftnl_obj_ct_timeout#l3proto.;
174 case NFTNL_OBJ_CT_TIMEOUT_L4PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L4PROTO.:
175 *data_len = sizeof(timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.);
176 return &timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.;
177 case NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.:
178 *data_len = sizeof(uint32_tcxx . . $ uint32_t#) * NFTNL_CTTIMEOUT_ARRAY_MAXcxx . . $ `include/libnftnl/object.h:69:9`!;
179 return timeout->timeoutcxx . . $ nftnl_obj_ct_timeout#timeout.;
180 }
181 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
182 }
183
184 static int nftnl_obj_ct_timeout_cbcxx . . $ nftnl_obj_ct_timeout_cb(de2ef18c48fd675c).(const struct nlattrcxx . . $ nlattr# *attr, void *data)
185 {
186 int type = mnl_attr_get_typecxx . . $ mnl_attr_get_type(1da47bcc4c4b975).(attr);
187 const struct nlattrcxx . . $ nlattr# **tb = data;
188
189 if (mnl_attr_type_validcxx . . $ mnl_attr_type_valid(47df1cce1c7be855).(attr, NFTA_CT_TIMEOUT_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:1645:9`!) < 0)
190 return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!;
191
192 switch (type) {
193 case NFTA_CT_TIMEOUT_L3PROTOcxx . . $ NFTA_CT_TIMEOUT_L3PROTO.:
194 if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U16cxx . . $ MNL_TYPE_U16.) < 0)
195 abi_breakagecxx . . $ `include/utils.h:28:9`!();
196 break;
197 case NFTA_CT_TIMEOUT_L4PROTOcxx . . $ NFTA_CT_TIMEOUT_L4PROTO.:
198 if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_U8cxx . . $ MNL_TYPE_U8.) < 0)
199 abi_breakagecxx . . $ `include/utils.h:28:9`!();
200 break;
201 case NFTA_CT_TIMEOUT_DATAcxx . . $ NFTA_CT_TIMEOUT_DATA.:
202 if (mnl_attr_validatecxx . . $ mnl_attr_validate(e419697a5e1ae2b1).(attr, MNL_TYPE_NESTEDcxx . . $ MNL_TYPE_NESTED.) < 0)
203 abi_breakagecxx . . $ `include/utils.h:28:9`!();
204 break;
205 }
206
207 tb[type] = attr;
208 return MNL_CB_OKcxx . . $ `<external>/12386019527593959648/libmnl.h:174:9`!;
209 }
210
211 static void
212 nftnl_obj_ct_timeout_buildcxx . . $ nftnl_obj_ct_timeout_build(3650aba98805b449).(struct nlmsghdrcxx . . $ nlmsghdr# *nlh, const struct nftnl_objcxx . . $ nftnl_obj# *e)
213 {
214 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *timeout = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
215 struct nlattrcxx . . $ nlattr# *nest;
216
217 if (e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_L3PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L3PROTO.))
218 mnl_attr_put_u16cxx . . $ mnl_attr_put_u16(951fb5ebe92f4b45).(nlh, NFTA_CT_TIMEOUT_L3PROTOcxx . . $ NFTA_CT_TIMEOUT_L3PROTO., htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(timeout->l3proto));
219 if (e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_L4PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L4PROTO.))
220 mnl_attr_put_u8cxx . . $ mnl_attr_put_u8(897b09f57801d77).(nlh, NFTA_CT_TIMEOUT_L4PROTOcxx . . $ NFTA_CT_TIMEOUT_L4PROTO., timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.);
221 if (e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.)) {
222 int i;
223
224 nest = mnl_attr_nest_startcxx . . $ mnl_attr_nest_start(c8ed348a075426e7).(nlh, NFTA_CT_TIMEOUT_DATAcxx . . $ NFTA_CT_TIMEOUT_DATA.);
225 for (i = 0; i < timeout_protocolcxx . . $ timeout_protocol.[timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.].attr_maxcxx . . $ $anonymous_type_4766018635dc2f23_0#attr_max.; i++)
226 mnl_attr_put_u32cxx . . $ mnl_attr_put_u32(b46fd0aeb0cfb96d).(nlh, i+1, htonlcxx . . $ `<external>/9581057695539925927/in.h:430:12`!(timeout->timeout[i]));
227
228 mnl_attr_nest_endcxx . . $ mnl_attr_nest_end(564f73625c62ba58).(nlh, nest);
229 }
230 }
231
232 static int
233 nftnl_obj_ct_timeout_parsecxx . . $ nftnl_obj_ct_timeout_parse(f22ac2b7a2342b3a).(struct nftnl_objcxx . . $ nftnl_obj# *e, struct nlattrcxx . . $ nlattr# *attr)
234 {
235 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *timeout = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
236 struct nlattrcxx . . $ nlattr# *tb[NFTA_CT_TIMEOUT_MAXcxx . . $ `include/linux/netfilter/nf_tables.h:1645:9`! + 1] = {};
237
238 if (mnl_attr_parse_nestedcxx . . $ mnl_attr_parse_nested(f99c0e9fa94f99d9).(attr, nftnl_obj_ct_timeout_cbcxx . . $ nftnl_obj_ct_timeout_cb(de2ef18c48fd675c)., tb) < 0)
239 return -1;
240
241 if (tb[NFTA_CT_TIMEOUT_L3PROTOcxx . . $ NFTA_CT_TIMEOUT_L3PROTO.]) {
242 timeout->l3protocxx . . $ nftnl_obj_ct_timeout#l3proto. = ntohscxx . . $ `<external>/9581057695539925927/in.h:429:12`!(mnl_attr_get_u16(tb[NFTA_CT_TIMEOUT_L3PROTO]));
243 e->flagscxx . . $ nftnl_obj#flags. |= (1 << NFTNL_OBJ_CT_TIMEOUT_L3PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L3PROTO.);
244 }
245 if (tb[NFTA_CT_TIMEOUT_L4PROTOcxx . . $ NFTA_CT_TIMEOUT_L4PROTO.]) {
246 timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto. = mnl_attr_get_u8cxx . . $ mnl_attr_get_u8(68d72702597f1127).(tb[NFTA_CT_TIMEOUT_L4PROTOcxx . . $ NFTA_CT_TIMEOUT_L4PROTO.]);
247 e->flagscxx . . $ nftnl_obj#flags. |= (1 << NFTNL_OBJ_CT_TIMEOUT_L4PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L4PROTO.);
248 }
249 if (tb[NFTA_CT_TIMEOUT_DATAcxx . . $ NFTA_CT_TIMEOUT_DATA.]) {
250 if (timeout_parse_attr_datacxx . . $ timeout_parse_attr_data(9581fc018b643f31).(e, tb[NFTA_CT_TIMEOUT_DATAcxx . . $ NFTA_CT_TIMEOUT_DATA.]) < 0)
251 return -1;
252 e->flagscxx . . $ nftnl_obj#flags. |= (1 << NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.);
253 }
254 return 0;
255 }
256
257 static int nftnl_obj_ct_timeout_snprintfcxx . . $ nftnl_obj_ct_timeout_snprintf(58da6fcd2536b16e).(char *buf, size_t remain,
258 uint32_tcxx . . $ uint32_t# flags,
259 const struct nftnl_objcxx . . $ nftnl_obj# *e)
260 {
261 int ret = 0, offset = 0;
262
263 struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout# *timeout = nftnl_obj_datacxx . . $ `include/obj.h:117:9`!(e);
264
265 if (e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_L3PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L3PROTO.)) {
266 ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + offset, remain, "family %d ",
267 timeout->l3protocxx . . $ nftnl_obj_ct_timeout#l3proto.);
268 SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset);
269 }
270 if (e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_L4PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L4PROTO.)) {
271 ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + offset, remain, "protocol %d ",
272 timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.);
273 SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset);
274 }
275 if (e->flagscxx . . $ nftnl_obj#flags. & (1 << NFTNL_OBJ_CT_TIMEOUT_ARRAYcxx . . $ NFTNL_OBJ_CT_TIMEOUT_ARRAY.)) {
276 uint8_tcxx . . $ uint8_t# l4num = timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.;
277 int i;
278
279 /* default to generic protocol tracker. */
280 if (timeout_protocolcxx . . $ timeout_protocol.[timeout->l4protocxx . . $ nftnl_obj_ct_timeout#l4proto.].attr_maxcxx . . $ $anonymous_type_4766018635dc2f23_0#attr_max. == 0)
281 l4num = IPPROTO_RAWcxx . . $ `<external>/9581057695539925927/in.h:95:9`!;
282
283 ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + offset, remain, "policy = {");
284 SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset);
285
286 for (i = 0; i < timeout_protocolcxx . . $ timeout_protocol.[l4num].attr_maxcxx . . $ $anonymous_type_4766018635dc2f23_0#attr_max.; i++) {
287 const char *state_name =
288 timeout_protocolcxx . . $ timeout_protocol.[l4num].state_to_namecxx . . $ $anonymous_type_4766018635dc2f23_0#state_to_name.[i][0] ?
289 timeout_protocolcxx . . $ timeout_protocol.[l4num].state_to_namecxx . . $ $anonymous_type_4766018635dc2f23_0#state_to_name.[i] :
290 "UNKNOWN";
291
292 if (timeout->timeoutcxx . . $ nftnl_obj_ct_timeout#timeout.[i] != timeout_protocolcxx . . $ timeout_protocol.[l4num].dflt_timeoutcxx . . $ $anonymous_type_4766018635dc2f23_0#dflt_timeout.[i]) {
293 ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + offset, remain,
294 "%s = %u,", state_name, timeout->timeoutcxx . . $ nftnl_obj_ct_timeout#timeout.[i]);
295 SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset);
296 }
297 }
298
299 ret = snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf + offset, remain, "}");
300 SNPRINTF_BUFFER_SIZEcxx . . $ `include/utils.h:55:9`!(ret, remain, offset);
301 }
302 buf[offset] = '\0';
303
304 return offset;
305 }
306
307 static struct attr_policycxx . . $ attr_policy#
308 obj_ct_timeout_attr_policycxx . . $ obj_ct_timeout_attr_policy.[__NFTNL_OBJ_CT_TIMEOUT_MAXcxx . . $ __NFTNL_OBJ_CT_TIMEOUT_MAX.] = {
309 [NFTNL_OBJ_CT_TIMEOUT_L3PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L3PROTO.] = { .maxlen = sizeof(uint16_tcxx . . $ uint16_t#) },
310 [NFTNL_OBJ_CT_TIMEOUT_L4PROTOcxx . . $ NFTNL_OBJ_CT_TIMEOUT_L4PROTO.] = { .maxlen = sizeof(uint8_tcxx . . $ uint8_t#) },
311 };
312
313 struct obj_opscxx . . $ obj_ops# obj_ops_ct_timeoutcxx . . $ obj_ops_ct_timeout. = {
314 .name = "ct_timeout",
315 .type = NFT_OBJECT_CT_TIMEOUTcxx . . $ `include/linux/netfilter/nf_tables.h:1665:9`!,
316 .alloc_len = sizeof(struct nftnl_obj_ct_timeoutcxx . . $ nftnl_obj_ct_timeout#),
317 .nftnl_max_attr = __NFTNL_OBJ_CT_TIMEOUT_MAXcxx . . $ __NFTNL_OBJ_CT_TIMEOUT_MAX. - 1,
318 .attr_policy = obj_ct_timeout_attr_policycxx . . $ obj_ct_timeout_attr_policy.,
319 .set = nftnl_obj_ct_timeout_setcxx . . $ nftnl_obj_ct_timeout_set(96c901c785434bf1).,
320 .get = nftnl_obj_ct_timeout_getcxx . . $ nftnl_obj_ct_timeout_get(d22e54b888e7c4b).,
321 .parse = nftnl_obj_ct_timeout_parsecxx . . $ nftnl_obj_ct_timeout_parse(f22ac2b7a2342b3a).,
322 .build = nftnl_obj_ct_timeout_buildcxx . . $ nftnl_obj_ct_timeout_build(3650aba98805b449).,
323 .output = nftnl_obj_ct_timeout_snprintfcxx . . $ nftnl_obj_ct_timeout_snprintf(58da6fcd2536b16e).,
324 };