Lines Matching refs:ct
46 ct_build_u8(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
49 memcpy(ptr, nfct_get_attr(ct, a), sizeof(uint8_t));
53 ct_build_u16(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
55 uint16_t data = nfct_get_attr_u16(ct, a);
61 ct_build_u32(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
63 uint32_t data = nfct_get_attr_u32(ct, a);
69 ct_build_str(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
71 const char *data = nfct_get_attr(ct, a);
76 ct_build_group(const struct nf_conntrack *ct, int a, struct nethdr *n,
80 nfct_get_attr_grp(ct, a, ptr);
84 ct_build_natseqadj(const struct nf_conntrack *ct, struct nethdr *n)
88 htonl(nfct_get_attr_u32(ct, ATTR_ORIG_NAT_SEQ_CORRECTION_POS)),
90 htonl(nfct_get_attr_u32(ct, ATTR_ORIG_NAT_SEQ_OFFSET_BEFORE)),
92 htonl(nfct_get_attr_u32(ct, ATTR_ORIG_NAT_SEQ_OFFSET_AFTER)),
94 htonl(nfct_get_attr_u32(ct, ATTR_REPL_NAT_SEQ_CORRECTION_POS)),
96 htonl(nfct_get_attr_u32(ct, ATTR_REPL_NAT_SEQ_OFFSET_BEFORE)),
98 htonl(nfct_get_attr_u32(ct, ATTR_REPL_NAT_SEQ_OFFSET_AFTER))
108 static void build_l4proto_tcp(const struct nf_conntrack *ct, struct nethdr *n)
110 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, NTA_PORT,
113 if (!nfct_attr_is_set(ct, ATTR_TCP_STATE))
116 ct_build_u8(ct, ATTR_TCP_STATE, n, NTA_TCP_STATE);
118 ct_build_u8(ct, ATTR_TCP_WSCALE_ORIG, n, NTA_TCP_WSCALE_ORIG);
119 ct_build_u8(ct, ATTR_TCP_WSCALE_REPL, n, NTA_TCP_WSCALE_REPL);
123 static void build_l4proto_sctp(const struct nf_conntrack *ct, struct nethdr *n)
125 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, NTA_PORT,
128 if (!nfct_attr_is_set(ct, ATTR_SCTP_STATE))
131 ct_build_u8(ct, ATTR_SCTP_STATE, n, NTA_SCTP_STATE);
132 ct_build_u32(ct, ATTR_SCTP_VTAG_ORIG, n, NTA_SCTP_VTAG_ORIG);
133 ct_build_u32(ct, ATTR_SCTP_VTAG_REPL, n, NTA_SCTP_VTAG_REPL);
136 static void build_l4proto_dccp(const struct nf_conntrack *ct, struct nethdr *n)
138 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, NTA_PORT,
141 if (!nfct_attr_is_set(ct, ATTR_DCCP_STATE))
144 ct_build_u8(ct, ATTR_DCCP_STATE, n, NTA_DCCP_STATE);
145 ct_build_u8(ct, ATTR_DCCP_ROLE, n, NTA_DCCP_ROLE);
148 static void build_l4proto_icmp(const struct nf_conntrack *ct, struct nethdr *n)
150 ct_build_u8(ct, ATTR_ICMP_TYPE, n, NTA_ICMP_TYPE);
151 ct_build_u8(ct, ATTR_ICMP_CODE, n, NTA_ICMP_CODE);
152 ct_build_u16(ct, ATTR_ICMP_ID, n, NTA_ICMP_ID);
155 static void build_l4proto_udp(const struct nf_conntrack *ct, struct nethdr *n)
157 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, NTA_PORT,
176 void ct2msg(const struct nf_conntrack *ct, struct nethdr *n)
178 uint8_t l4proto = nfct_get_attr_u8(ct, ATTR_L4PROTO);
180 if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV4)) {
181 ct_build_group(ct, ATTR_GRP_ORIG_IPV4, n, NTA_IPV4,
183 } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV6)) {
184 ct_build_group(ct, ATTR_GRP_ORIG_IPV6, n, NTA_IPV6,
188 ct_build_u32(ct, ATTR_STATUS, n, NTA_STATUS);
189 ct_build_u8(ct, ATTR_L4PROTO, n, NTA_L4PROTO);
192 l4proto_fcn[l4proto].build(ct, n);
194 if (!CONFIG(commit_timeout) && nfct_attr_is_set(ct, ATTR_TIMEOUT))
195 ct_build_u32(ct, ATTR_TIMEOUT, n, NTA_TIMEOUT);
196 if (nfct_attr_is_set(ct, ATTR_MARK))
197 ct_build_u32(ct, ATTR_MARK, n, NTA_MARK);
200 if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_IPV4)) {
201 ct_build_group(ct, ATTR_GRP_MASTER_IPV4, n, NTA_MASTER_IPV4,
203 ct_build_u8(ct, ATTR_MASTER_L4PROTO, n, NTA_MASTER_L4PROTO);
204 if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_PORT)) {
205 ct_build_group(ct, ATTR_GRP_MASTER_PORT,
209 } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_IPV6)) {
210 ct_build_group(ct, ATTR_GRP_MASTER_IPV6, n, NTA_MASTER_IPV6,
212 ct_build_u8(ct, ATTR_MASTER_L4PROTO, n, NTA_MASTER_L4PROTO);
213 if (nfct_attr_grp_is_set(ct, ATTR_GRP_MASTER_PORT)) {
214 ct_build_group(ct, ATTR_GRP_MASTER_PORT,
221 if (nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT))
222 ct_build_u32(ct, ATTR_REPL_IPV4_DST, n, NTA_SNAT_IPV4);
223 if (nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT))
224 ct_build_u32(ct, ATTR_REPL_IPV4_SRC, n, NTA_DNAT_IPV4);
225 if (nfct_getobjopt(ct, NFCT_GOPT_IS_SPAT))
226 ct_build_u16(ct, ATTR_REPL_PORT_DST, n, NTA_SPAT_PORT);
227 if (nfct_getobjopt(ct, NFCT_GOPT_IS_DPAT))
228 ct_build_u16(ct, ATTR_REPL_PORT_SRC, n, NTA_DPAT_PORT);
231 if (nfct_attr_is_set_array(ct, nat_type, 6))
232 ct_build_natseqadj(ct, n);
234 if (nfct_attr_is_set(ct, ATTR_HELPER_NAME))
235 ct_build_str(ct, ATTR_HELPER_NAME, n, NTA_HELPER_NAME);
239 exp_build_l4proto_tcp(const struct nf_conntrack *ct, struct nethdr *n, int a)
241 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, a,
246 exp_build_l4proto_sctp(const struct nf_conntrack *ct, struct nethdr *n, int a)
248 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, a,
253 exp_build_l4proto_dccp(const struct nf_conntrack *ct, struct nethdr *n, int a)
255 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, a,
260 exp_build_l4proto_udp(const struct nf_conntrack *ct, struct nethdr *n, int a)
262 ct_build_group(ct, ATTR_GRP_ORIG_PORT, n, a,
292 const struct nf_conntrack *ct = nfexp_get_attr(exp, ATTR_EXP_MASTER);
293 uint8_t l4proto = nfct_get_attr_u8(ct, ATTR_L4PROTO);
296 if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV4)) {
297 ct_build_group(ct, ATTR_GRP_ORIG_IPV4, n, NTA_EXP_MASTER_IPV4,
299 } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV6)) {
300 ct_build_group(ct, ATTR_GRP_ORIG_IPV6, n, NTA_EXP_MASTER_IPV6,
303 ct_build_u8(ct, ATTR_L4PROTO, n, NTA_EXP_MASTER_L4PROTO);
306 exp_l4proto_fcn[l4proto].build(ct, n, NTA_EXP_MASTER_PORT);
309 ct = nfexp_get_attr(exp, ATTR_EXP_EXPECTED);
311 if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV4)) {
312 ct_build_group(ct, ATTR_GRP_ORIG_IPV4, n, NTA_EXP_EXPECT_IPV4,
314 } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV6)) {
315 ct_build_group(ct, ATTR_GRP_ORIG_IPV6, n, NTA_EXP_EXPECT_IPV6,
318 ct_build_u8(ct, ATTR_L4PROTO, n, NTA_EXP_EXPECT_L4PROTO);
321 exp_l4proto_fcn[l4proto].build(ct, n, NTA_EXP_EXPECT_PORT);
324 ct = nfexp_get_attr(exp, ATTR_EXP_MASK);
326 if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV4)) {
327 ct_build_group(ct, ATTR_GRP_ORIG_IPV4, n, NTA_EXP_MASK_IPV4,
329 } else if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV6)) {
330 ct_build_group(ct, ATTR_GRP_ORIG_IPV6, n, NTA_EXP_MASK_IPV6,
333 ct_build_u8(ct, ATTR_L4PROTO, n, NTA_EXP_MASK_L4PROTO);
336 exp_l4proto_fcn[l4proto].build(ct, n, NTA_EXP_MASK_PORT);
346 ct = nfexp_get_attr(exp, ATTR_EXP_NAT_TUPLE);
347 if (ct != NULL) {
348 if (nfct_attr_grp_is_set(ct, ATTR_GRP_ORIG_IPV4)) {
349 ct_build_group(ct, ATTR_GRP_ORIG_IPV4, n,
353 ct_build_u8(ct, ATTR_L4PROTO, n, NTA_EXP_NAT_L4PROTO);
355 exp_l4proto_fcn[l4proto].build(ct, n, NTA_EXP_NAT_PORT);