Lines Matching refs:ct

21 #include <netlink/netfilter/ct.h>
58 struct nfnl_ct *ct = (struct nfnl_ct *) c;
60 if (ct == NULL)
63 nl_addr_put(ct->ct_orig.src);
64 nl_addr_put(ct->ct_orig.dst);
65 nl_addr_put(ct->ct_repl.src);
66 nl_addr_put(ct->ct_repl.dst);
119 static void dump_icmp(struct nl_dump_params *p, struct nfnl_ct *ct, int reply)
121 if (nfnl_ct_test_icmp_type(ct, reply))
122 nl_dump(p, "icmp type %d ", nfnl_ct_get_icmp_type(ct, reply));
124 if (nfnl_ct_test_icmp_type(ct, reply))
125 nl_dump(p, "code %d ", nfnl_ct_get_icmp_code(ct, reply));
127 if (nfnl_ct_test_icmp_type(ct, reply))
128 nl_dump(p, "id %d ", nfnl_ct_get_icmp_id(ct, reply));
131 static void ct_dump_tuples(struct nfnl_ct *ct, struct nl_dump_params *p)
137 orig_src = nfnl_ct_get_src(ct, 0);
138 orig_dst = nfnl_ct_get_dst(ct, 0);
139 reply_src = nfnl_ct_get_src(ct, 1);
140 reply_dst = nfnl_ct_get_dst(ct, 1);
142 if (nfnl_ct_test_src_port(ct, 0))
143 orig_sport = nfnl_ct_get_src_port(ct, 0);
145 if (nfnl_ct_test_dst_port(ct, 0))
146 orig_dport = nfnl_ct_get_dst_port(ct, 0);
148 if (nfnl_ct_test_src_port(ct, 1))
149 reply_sport = nfnl_ct_get_src_port(ct, 1);
151 if (nfnl_ct_test_dst_port(ct, 1))
152 reply_dport = nfnl_ct_get_dst_port(ct, 1);
163 dump_icmp(p, ct, 0);
169 dump_icmp(p, ct, 1);
176 struct nfnl_ct *ct = (struct nfnl_ct *) a;
181 if (nfnl_ct_test_proto(ct))
183 nl_ip_proto2str(nfnl_ct_get_proto(ct), buf, sizeof(buf)));
185 if (nfnl_ct_test_tcp_state(ct))
187 nfnl_ct_tcp_state2str(nfnl_ct_get_tcp_state(ct),
190 ct_dump_tuples(ct, p);
192 if (nfnl_ct_test_mark(ct) && nfnl_ct_get_mark(ct))
193 nl_dump(p, "mark %u ", nfnl_ct_get_mark(ct));
200 struct nfnl_ct *ct = (struct nfnl_ct *) a;
206 nl_dump(p, " id 0x%x ", ct->ct_id);
208 nl_af2str(ct->ct_family, buf, sizeof(buf)));
210 if (nfnl_ct_test_use(ct))
211 nl_dump(p, "refcnt %u ", nfnl_ct_get_use(ct));
213 if (nfnl_ct_test_timeout(ct)) {
214 uint64_t timeout_ms = nfnl_ct_get_timeout(ct) * 1000UL;
219 if (ct->ct_status)
225 if (ct->ct_status & IPS_EXPECTED)
227 if (!(ct->ct_status & IPS_SEEN_REPLY))
229 if (ct->ct_status & IPS_ASSURED)
231 if (!(ct->ct_status & IPS_CONFIRMED))
233 if (ct->ct_status & IPS_SRC_NAT)
235 if (ct->ct_status & IPS_DST_NAT)
237 if (ct->ct_status & IPS_SEQ_ADJUST)
239 if (!(ct->ct_status & IPS_SRC_NAT_DONE))
241 if (!(ct->ct_status & IPS_DST_NAT_DONE))
243 if (ct->ct_status & IPS_DYING)
245 if (ct->ct_status & IPS_FIXED_TIMEOUT)
249 if (ct->ct_status)
256 struct nfnl_ct *ct = (struct nfnl_ct *) a;
264 res = nl_cancel_down_bytes(nfnl_ct_get_bytes(ct, 1), &unit);
266 nfnl_ct_get_packets(ct, 1), res, unit);
268 res = nl_cancel_down_bytes(nfnl_ct_get_bytes(ct, 0), &unit);
270 nfnl_ct_get_packets(ct, 0), res, unit);
370 void nfnl_ct_get(struct nfnl_ct *ct)
372 nl_object_get((struct nl_object *) ct);
375 void nfnl_ct_put(struct nfnl_ct *ct)
377 nl_object_put((struct nl_object *) ct);
387 void nfnl_ct_set_family(struct nfnl_ct *ct, uint8_t family)
389 ct->ct_family = family;
390 ct->ce_mask |= CT_ATTR_FAMILY;
393 uint8_t nfnl_ct_get_family(const struct nfnl_ct *ct)
395 if (ct->ce_mask & CT_ATTR_FAMILY)
396 return ct->ct_family;
401 void nfnl_ct_set_proto(struct nfnl_ct *ct, uint8_t proto)
403 ct->ct_proto = proto;
404 ct->ce_mask |= CT_ATTR_PROTO;
407 int nfnl_ct_test_proto(const struct nfnl_ct *ct)
409 return !!(ct->ce_mask & CT_ATTR_PROTO);
412 uint8_t nfnl_ct_get_proto(const struct nfnl_ct *ct)
414 return ct->ct_proto;
417 void nfnl_ct_set_tcp_state(struct nfnl_ct *ct, uint8_t state)
419 ct->ct_protoinfo.tcp.state = state;
420 ct->ce_mask |= CT_ATTR_TCP_STATE;
423 int nfnl_ct_test_tcp_state(const struct nfnl_ct *ct)
425 return !!(ct->ce_mask & CT_ATTR_TCP_STATE);
428 uint8_t nfnl_ct_get_tcp_state(const struct nfnl_ct *ct)
430 return ct->ct_protoinfo.tcp.state;
456 void nfnl_ct_set_status(struct nfnl_ct *ct, uint32_t status)
458 ct->ct_status_mask |= status;
459 ct->ct_status |= status;
460 ct->ce_mask |= CT_ATTR_STATUS;
463 void nfnl_ct_unset_status(struct nfnl_ct *ct, uint32_t status)
465 ct->ct_status_mask |= status;
466 ct->ct_status &= ~status;
467 ct->ce_mask |= CT_ATTR_STATUS;
470 uint32_t nfnl_ct_get_status(const struct nfnl_ct *ct)
472 return ct->ct_status;
500 void nfnl_ct_set_timeout(struct nfnl_ct *ct, uint32_t timeout)
502 ct->ct_timeout = timeout;
503 ct->ce_mask |= CT_ATTR_TIMEOUT;
506 int nfnl_ct_test_timeout(const struct nfnl_ct *ct)
508 return !!(ct->ce_mask & CT_ATTR_TIMEOUT);
511 uint32_t nfnl_ct_get_timeout(const struct nfnl_ct *ct)
513 return ct->ct_timeout;
516 void nfnl_ct_set_mark(struct nfnl_ct *ct, uint32_t mark)
518 ct->ct_mark = mark;
519 ct->ce_mask |= CT_ATTR_MARK;
522 int nfnl_ct_test_mark(const struct nfnl_ct *ct)
524 return !!(ct->ce_mask & CT_ATTR_MARK);
527 uint32_t nfnl_ct_get_mark(const struct nfnl_ct *ct)
529 return ct->ct_mark;
532 void nfnl_ct_set_use(struct nfnl_ct *ct, uint32_t use)
534 ct->ct_use = use;
535 ct->ce_mask |= CT_ATTR_USE;
538 int nfnl_ct_test_use(const struct nfnl_ct *ct)
540 return !!(ct->ce_mask & CT_ATTR_USE);
543 uint32_t nfnl_ct_get_use(const struct nfnl_ct *ct)
545 return ct->ct_use;
548 void nfnl_ct_set_id(struct nfnl_ct *ct, uint32_t id)
550 ct->ct_id = id;
551 ct->ce_mask |= CT_ATTR_ID;
554 int nfnl_ct_test_id(const struct nfnl_ct *ct)
556 return !!(ct->ce_mask & CT_ATTR_ID);
559 uint32_t nfnl_ct_get_id(const struct nfnl_ct *ct)
561 return ct->ct_id;
564 static int ct_set_addr(struct nfnl_ct *ct, struct nl_addr *addr,
567 if (ct->ce_mask & CT_ATTR_FAMILY) {
568 if (addr->a_family != ct->ct_family)
571 nfnl_ct_set_family(ct, addr->a_family);
578 ct->ce_mask |= attr;
583 int nfnl_ct_set_src(struct nfnl_ct *ct, int repl, struct nl_addr *addr)
585 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
587 return ct_set_addr(ct, addr, attr, &dir->src);
590 int nfnl_ct_set_dst(struct nfnl_ct *ct, int repl, struct nl_addr *addr)
592 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
594 return ct_set_addr(ct, addr, attr, &dir->dst);
597 struct nl_addr *nfnl_ct_get_src(const struct nfnl_ct *ct, int repl)
599 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
601 if (!(ct->ce_mask & attr))
606 struct nl_addr *nfnl_ct_get_dst(const struct nfnl_ct *ct, int repl)
608 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
610 if (!(ct->ce_mask & attr))
615 void nfnl_ct_set_src_port(struct nfnl_ct *ct, int repl, uint16_t port)
617 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
621 ct->ce_mask |= attr;
624 int nfnl_ct_test_src_port(const struct nfnl_ct *ct, int repl)
627 return !!(ct->ce_mask & attr);
630 uint16_t nfnl_ct_get_src_port(const struct nfnl_ct *ct, int repl)
632 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
637 void nfnl_ct_set_dst_port(struct nfnl_ct *ct, int repl, uint16_t port)
639 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
643 ct->ce_mask |= attr;
646 int nfnl_ct_test_dst_port(const struct nfnl_ct *ct, int repl)
649 return !!(ct->ce_mask & attr);
652 uint16_t nfnl_ct_get_dst_port(const struct nfnl_ct *ct, int repl)
654 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
659 void nfnl_ct_set_icmp_id(struct nfnl_ct *ct, int repl, uint16_t id)
661 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
665 ct->ce_mask |= attr;
668 int nfnl_ct_test_icmp_id(const struct nfnl_ct *ct, int repl)
671 return !!(ct->ce_mask & attr);
674 uint16_t nfnl_ct_get_icmp_id(const struct nfnl_ct *ct, int repl)
676 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
681 void nfnl_ct_set_icmp_type(struct nfnl_ct *ct, int repl, uint8_t type)
683 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
687 ct->ce_mask |= attr;
690 int nfnl_ct_test_icmp_type(const struct nfnl_ct *ct, int repl)
693 return !!(ct->ce_mask & attr);
696 uint8_t nfnl_ct_get_icmp_type(const struct nfnl_ct *ct, int repl)
698 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
703 void nfnl_ct_set_icmp_code(struct nfnl_ct *ct, int repl, uint8_t code)
705 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
709 ct->ce_mask |= attr;
712 int nfnl_ct_test_icmp_code(const struct nfnl_ct *ct, int repl)
715 return !!(ct->ce_mask & attr);
718 uint8_t nfnl_ct_get_icmp_code(const struct nfnl_ct *ct, int repl)
720 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
725 void nfnl_ct_set_packets(struct nfnl_ct *ct, int repl, uint64_t packets)
727 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
731 ct->ce_mask |= attr;
734 int nfnl_ct_test_packets(const struct nfnl_ct *ct, int repl)
737 return !!(ct->ce_mask & attr);
740 uint64_t nfnl_ct_get_packets(const struct nfnl_ct *ct, int repl)
742 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
747 void nfnl_ct_set_bytes(struct nfnl_ct *ct, int repl, uint64_t bytes)
749 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
753 ct->ce_mask |= attr;
756 int nfnl_ct_test_bytes(const struct nfnl_ct *ct, int repl)
759 return !!(ct->ce_mask & attr);
762 uint64_t nfnl_ct_get_bytes(const struct nfnl_ct *ct, int repl)
764 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
772 .oo_name = "netfilter/ct",