Home | History | Annotate | Download | only in netfilter

Lines Matching refs:ct

21 #include <netlink/netfilter/ct.h>
60 struct nfnl_ct *ct = (struct nfnl_ct *) c;
62 if (ct == NULL)
65 nl_addr_put(ct->ct_orig.src);
66 nl_addr_put(ct->ct_orig.dst);
67 nl_addr_put(ct->ct_repl.src);
68 nl_addr_put(ct->ct_repl.dst);
121 static void dump_icmp(struct nl_dump_params *p, struct nfnl_ct *ct, int reply)
123 if (nfnl_ct_test_icmp_type(ct, reply))
124 nl_dump(p, "icmp type %d ", nfnl_ct_get_icmp_type(ct, reply));
126 if (nfnl_ct_test_icmp_code(ct, reply))
127 nl_dump(p, "code %d ", nfnl_ct_get_icmp_code(ct, reply));
129 if (nfnl_ct_test_icmp_id(ct, reply))
130 nl_dump(p, "id %d ", nfnl_ct_get_icmp_id(ct, reply));
133 static void ct_dump_tuples(struct nfnl_ct *ct, struct nl_dump_params *p)
139 orig_src = nfnl_ct_get_src(ct, 0);
140 orig_dst = nfnl_ct_get_dst(ct, 0);
141 reply_src = nfnl_ct_get_src(ct, 1);
142 reply_dst = nfnl_ct_get_dst(ct, 1);
144 if (nfnl_ct_test_src_port(ct, 0))
145 orig_sport = nfnl_ct_get_src_port(ct, 0);
147 if (nfnl_ct_test_dst_port(ct, 0))
148 orig_dport = nfnl_ct_get_dst_port(ct, 0);
150 if (nfnl_ct_test_src_port(ct, 1))
151 reply_sport = nfnl_ct_get_src_port(ct, 1);
153 if (nfnl_ct_test_dst_port(ct, 1))
154 reply_dport = nfnl_ct_get_dst_port(ct, 1);
165 dump_icmp(p, ct, 0);
171 dump_icmp(p, ct, 1);
178 struct nfnl_ct *ct = (struct nfnl_ct *) a;
183 if (nfnl_ct_test_proto(ct))
185 nl_ip_proto2str(nfnl_ct_get_proto(ct), buf, sizeof(buf)));
187 if (nfnl_ct_test_tcp_state(ct))
189 nfnl_ct_tcp_state2str(nfnl_ct_get_tcp_state(ct),
192 ct_dump_tuples(ct, p);
194 if (nfnl_ct_test_mark(ct) && nfnl_ct_get_mark(ct))
195 nl_dump(p, "mark %u ", nfnl_ct_get_mark(ct));
197 if (nfnl_ct_test_zone(ct))
198 nl_dump(p, "zone %hu ", nfnl_ct_get_zone(ct));
200 if (nfnl_ct_test_timestamp(ct)) {
201 const struct nfnl_ct_timestamp *tstamp = nfnl_ct_get_timestamp(ct);
216 struct nfnl_ct *ct = (struct nfnl_ct *) a;
222 nl_dump(p, " id 0x%x ", ct->ct_id);
224 nl_af2str(ct->ct_family, buf, sizeof(buf)));
226 if (nfnl_ct_test_use(ct))
227 nl_dump(p, "refcnt %u ", nfnl_ct_get_use(ct));
229 if (nfnl_ct_test_timeout(ct)) {
230 uint64_t timeout_ms = nfnl_ct_get_timeout(ct) * 1000UL;
235 if (ct->ct_status)
241 if (ct->ct_status & IPS_EXPECTED)
243 if (!(ct->ct_status & IPS_SEEN_REPLY))
245 if (ct->ct_status & IPS_ASSURED)
247 if (!(ct->ct_status & IPS_CONFIRMED))
249 if (ct->ct_status & IPS_SRC_NAT)
251 if (ct->ct_status & IPS_DST_NAT)
253 if (ct->ct_status & IPS_SEQ_ADJUST)
255 if (!(ct->ct_status & IPS_SRC_NAT_DONE))
257 if (!(ct->ct_status & IPS_DST_NAT_DONE))
259 if (ct->ct_status & IPS_DYING)
261 if (ct->ct_status & IPS_FIXED_TIMEOUT)
265 if (ct->ct_status)
272 struct nfnl_ct *ct = (struct nfnl_ct *) a;
281 if (!nfnl_ct_test_bytes(ct, 0) ||
282 !nfnl_ct_test_packets(ct, 0) ||
283 !nfnl_ct_test_bytes(ct, 1) ||
284 !nfnl_ct_test_packets(ct, 1))
294 res = nl_cancel_down_bytes(nfnl_ct_get_bytes(ct, i), &unit);
295 packets = nfnl_ct_get_packets(ct, i);
397 void nfnl_ct_get(struct nfnl_ct *ct)
399 nl_object_get((struct nl_object *) ct);
402 void nfnl_ct_put(struct nfnl_ct *ct)
404 nl_object_put((struct nl_object *) ct);
414 void nfnl_ct_set_family(struct nfnl_ct *ct, uint8_t family)
416 ct->ct_family = family;
417 ct->ce_mask |= CT_ATTR_FAMILY;
420 uint8_t nfnl_ct_get_family(const struct nfnl_ct *ct)
422 if (ct->ce_mask & CT_ATTR_FAMILY)
423 return ct->ct_family;
428 void nfnl_ct_set_proto(struct nfnl_ct *ct, uint8_t proto)
430 ct->ct_proto = proto;
431 ct->ce_mask |= CT_ATTR_PROTO;
434 int nfnl_ct_test_proto(const struct nfnl_ct *ct)
436 return !!(ct->ce_mask & CT_ATTR_PROTO);
439 uint8_t nfnl_ct_get_proto(const struct nfnl_ct *ct)
441 return ct->ct_proto;
444 void nfnl_ct_set_tcp_state(struct nfnl_ct *ct, uint8_t state)
446 ct->ct_protoinfo.tcp.state = state;
447 ct->ce_mask |= CT_ATTR_TCP_STATE;
450 int nfnl_ct_test_tcp_state(const struct nfnl_ct *ct)
452 return !!(ct->ce_mask & CT_ATTR_TCP_STATE);
455 uint8_t nfnl_ct_get_tcp_state(const struct nfnl_ct *ct)
457 return ct->ct_protoinfo.tcp.state;
483 void nfnl_ct_set_status(struct nfnl_ct *ct, uint32_t status)
485 ct->ct_status_mask |= status;
486 ct->ct_status |= status;
487 ct->ce_mask |= CT_ATTR_STATUS;
490 void nfnl_ct_unset_status(struct nfnl_ct *ct, uint32_t status)
492 ct->ct_status_mask |= status;
493 ct->ct_status &= ~status;
494 ct->ce_mask |= CT_ATTR_STATUS;
497 int nfnl_ct_test_status(const struct nfnl_ct *ct)
499 return !!(ct->ce_mask & CT_ATTR_STATUS);
502 uint32_t nfnl_ct_get_status(const struct nfnl_ct *ct)
504 return ct->ct_status;
532 void nfnl_ct_set_timeout(struct nfnl_ct *ct, uint32_t timeout)
534 ct->ct_timeout = timeout;
535 ct->ce_mask |= CT_ATTR_TIMEOUT;
538 int nfnl_ct_test_timeout(const struct nfnl_ct *ct)
540 return !!(ct->ce_mask & CT_ATTR_TIMEOUT);
543 uint32_t nfnl_ct_get_timeout(const struct nfnl_ct *ct)
545 return ct->ct_timeout;
548 void nfnl_ct_set_mark(struct nfnl_ct *ct, uint32_t mark)
550 ct->ct_mark = mark;
551 ct->ce_mask |= CT_ATTR_MARK;
554 int nfnl_ct_test_mark(const struct nfnl_ct *ct)
556 return !!(ct->ce_mask & CT_ATTR_MARK);
559 uint32_t nfnl_ct_get_mark(const struct nfnl_ct *ct)
561 return ct->ct_mark;
564 void nfnl_ct_set_use(struct nfnl_ct *ct, uint32_t use)
566 ct->ct_use = use;
567 ct->ce_mask |= CT_ATTR_USE;
570 int nfnl_ct_test_use(const struct nfnl_ct *ct)
572 return !!(ct->ce_mask & CT_ATTR_USE);
575 uint32_t nfnl_ct_get_use(const struct nfnl_ct *ct)
577 return ct->ct_use;
580 void nfnl_ct_set_id(struct nfnl_ct *ct, uint32_t id)
582 ct->ct_id = id;
583 ct->ce_mask |= CT_ATTR_ID;
586 int nfnl_ct_test_id(const struct nfnl_ct *ct)
588 return !!(ct->ce_mask & CT_ATTR_ID);
591 uint32_t nfnl_ct_get_id(const struct nfnl_ct *ct)
593 return ct->ct_id;
596 void nfnl_ct_set_zone(struct nfnl_ct *ct, uint16_t zone)
598 ct->ct_zone = zone;
599 ct->ce_mask |= CT_ATTR_ZONE;
602 int nfnl_ct_test_zone(const struct nfnl_ct *ct)
604 return !!(ct->ce_mask & CT_ATTR_ZONE);
607 uint16_t nfnl_ct_get_zone(const struct nfnl_ct *ct)
609 return ct->ct_zone;
612 static int ct_set_addr(struct nfnl_ct *ct, struct nl_addr *addr,
615 if (ct->ce_mask & CT_ATTR_FAMILY) {
616 if (addr->a_family != ct->ct_family)
619 nfnl_ct_set_family(ct, addr->a_family);
626 ct->ce_mask |= attr;
631 int nfnl_ct_set_src(struct nfnl_ct *ct, int repl, struct nl_addr *addr)
633 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
635 return ct_set_addr(ct, addr, attr, &dir->src);
638 int nfnl_ct_set_dst(struct nfnl_ct *ct, int repl, struct nl_addr *addr)
640 struct nfnl_ct_dir *dir = repl ? &ctct->ct_orig;
642 return ct_set_addr(ct, addr, attr, &dir->dst);
645 struct nl_addr *nfnl_ct_get_src(const struct nfnl_ct *ct, int repl)
647 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
649 if (!(ct->ce_mask & attr))
654 struct nl_addr *nfnl_ct_get_dst(const struct nfnl_ct *ct, int repl)
656 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
658 if (!(ct->ce_mask & attr))
663 void nfnl_ct_set_src_port(struct nfnl_ct *ct, int repl, uint16_t port)
665 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
669 ct->ce_mask |= attr;
672 int nfnl_ct_test_src_port(const struct nfnl_ct *ct, int repl)
675 return !!(ct->ce_mask & attr);
678 uint16_t nfnl_ct_get_src_port(const struct nfnl_ct *ct, int repl)
680 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
685 void nfnl_ct_set_dst_port(struct nfnl_ct *ct, int repl, uint16_t port)
687 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
691 ct->ce_mask |= attr;
694 int nfnl_ct_test_dst_port(const struct nfnl_ct *ct, int repl)
697 return !!(ct->ce_mask & attr);
700 uint16_t nfnl_ct_get_dst_port(const struct nfnl_ct *ct, int repl)
702 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
707 void nfnl_ct_set_icmp_id(struct nfnl_ct *ct, int repl, uint16_t id)
709 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
713 ct->ce_mask |= attr;
716 int nfnl_ct_test_icmp_id(const struct nfnl_ct *ct, int repl)
719 return !!(ct->ce_mask & attr);
722 uint16_t nfnl_ct_get_icmp_id(const struct nfnl_ct *ct, int repl)
724 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
729 void nfnl_ct_set_icmp_type(struct nfnl_ct *ct, int repl, uint8_t type)
731 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
735 ct->ce_mask |= attr;
738 int nfnl_ct_test_icmp_type(const struct nfnl_ct *ct, int repl)
741 return !!(ct->ce_mask & attr);
744 uint8_t nfnl_ct_get_icmp_type(const struct nfnl_ct *ct, int repl)
746 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
751 void nfnl_ct_set_icmp_code(struct nfnl_ct *ct, int repl, uint8_t code)
753 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
757 ct->ce_mask |= attr;
760 int nfnl_ct_test_icmp_code(const struct nfnl_ct *ct, int repl)
763 return !!(ct->ce_mask & attr);
766 uint8_t nfnl_ct_get_icmp_code(const struct nfnl_ct *ct, int repl)
768 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
773 void nfnl_ct_set_packets(struct nfnl_ct *ct, int repl, uint64_t packets)
775 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
779 ct->ce_mask |= attr;
782 int nfnl_ct_test_packets(const struct nfnl_ct *ct, int repl)
785 return !!(ct->ce_mask & attr);
788 uint64_t nfnl_ct_get_packets(const struct nfnl_ct *ct, int repl)
790 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
795 void nfnl_ct_set_bytes(struct nfnl_ct *ct, int repl, uint64_t bytes)
797 struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
801 ct->ce_mask |= attr;
804 int nfnl_ct_test_bytes(const struct nfnl_ct *ct, int repl)
807 return !!(ct->ce_mask & attr);
810 uint64_t nfnl_ct_get_bytes(const struct nfnl_ct *ct, int repl)
812 const struct nfnl_ct_dir *dir = repl ? &ct->ct_repl : &ct->ct_orig;
817 void nfnl_ct_set_timestamp(struct nfnl_ct *ct, uint64_t start, uint64_t stop)
819 ct->ct_tstamp.start = start;
820 ct->ct_tstamp.stop = stop;
821 ct->ce_mask |= CT_ATTR_TIMESTAMP;
824 int nfnl_ct_test_timestamp(const struct nfnl_ct *ct)
826 return !!(ct->ce_mask & CT_ATTR_TIMESTAMP);
829 const struct nfnl_ct_timestamp *nfnl_ct_get_timestamp(const struct nfnl_ct *ct)
831 return &ct->ct_tstamp;
837 .oo_name = "netfilter/ct",