From 25b2d74cebc9680dde4028f2f50aec396b29559e Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=pablo/emailAddress=pablo@netfilter.org" Date: Sat, 3 Dec 2005 22:50:27 +0000 Subject: o Fixed bugs in UDP and SCTP protocol handlers (parse_proto) o Added the comparison infrastructure for layer-4 protocols o Added libnetfilter_conntrack_[tcp|udp|icmp|sctp].h that contains the protocol flags used by the comparison infrastructure o Added nfct_conntrack_compare to compare two conntracks based on flags o Killed nfct_event_netlink_handler o nfct_event_[conntrack|expect] requires ROOT privileges (reason: netlink multicast) o Bumped version to 0.29 --- extensions/libnetfilter_conntrack_sctp.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'extensions/libnetfilter_conntrack_sctp.c') diff --git a/extensions/libnetfilter_conntrack_sctp.c b/extensions/libnetfilter_conntrack_sctp.c index 81a2467..aa06f6d 100644 --- a/extensions/libnetfilter_conntrack_sctp.c +++ b/extensions/libnetfilter_conntrack_sctp.c @@ -15,6 +15,7 @@ #include #include #include +#include static void parse_proto(struct nfattr *cda[], struct nfct_tuple *tuple) { @@ -38,9 +39,9 @@ static void build_tuple_proto(struct nfnlhdr *req, int size, struct nfct_tuple *t) { nfnl_addattr_l(&req->nlh, size, CTA_PROTO_SRC_PORT, - &t->l4src.tcp.port, sizeof(u_int16_t)); + &t->l4src.sctp.port, sizeof(u_int16_t)); nfnl_addattr_l(&req->nlh, size, CTA_PROTO_DST_PORT, - &t->l4dst.tcp.port, sizeof(u_int16_t)); + &t->l4dst.sctp.port, sizeof(u_int16_t)); } static int print_protoinfo(char *buf, union nfct_protoinfo *protoinfo) @@ -55,6 +56,32 @@ static int print_proto(char *buf, struct nfct_tuple *tuple) htons(tuple->l4dst.sctp.port))); } +static int compare(struct nfct_conntrack *ct1, + struct nfct_conntrack *ct2, + unsigned int flags) +{ + int ret = 1; + + if (flags & SCTP_ORIG_SPORT) + if (ct1->tuple[NFCT_DIR_ORIGINAL].l4src.sctp.port != + ct2->tuple[NFCT_DIR_ORIGINAL].l4src.sctp.port) + ret = 0; + if (flags & SCTP_ORIG_DPORT) + if (ct1->tuple[NFCT_DIR_ORIGINAL].l4dst.sctp.port != + ct2->tuple[NFCT_DIR_ORIGINAL].l4dst.sctp.port) + ret = 0; + if (flags & SCTP_REPL_SPORT) + if (ct1->tuple[NFCT_DIR_REPLY].l4src.sctp.port != + ct2->tuple[NFCT_DIR_REPLY].l4src.sctp.port) + ret = 0; + if (flags & SCTP_REPL_DPORT) + if (ct1->tuple[NFCT_DIR_REPLY].l4dst.sctp.port != + ct2->tuple[NFCT_DIR_REPLY].l4dst.sctp.port) + ret = 0; + + return ret; +} + static struct nfct_proto sctp = { .name = "sctp", .protonum = IPPROTO_SCTP, @@ -63,6 +90,7 @@ static struct nfct_proto sctp = { .build_tuple_proto = build_tuple_proto, .print_proto = print_proto, .print_protoinfo = print_protoinfo, + .compare = compare, .version = VERSION }; -- cgit v1.2.3