From 7e629bad0f752f6fb3e3a435666307992e74bee2 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 21 May 2008 13:30:43 +0200 Subject: add full support of SCTP --- src/conntrack/parse.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/conntrack/parse.c') diff --git a/src/conntrack/parse.c b/src/conntrack/parse.c index c21f304..a18e3ad 100644 --- a/src/conntrack/parse.c +++ b/src/conntrack/parse.c @@ -217,6 +217,33 @@ static void __parse_protoinfo_tcp(const struct nfattr *attr, } } +static void __parse_protoinfo_sctp(const struct nfattr *attr, + struct nf_conntrack *ct) +{ + struct nfattr *tb[CTA_PROTOINFO_SCTP_MAX]; + + nfnl_parse_nested(tb, CTA_PROTOINFO_SCTP_MAX, attr); + + if (tb[CTA_PROTOINFO_SCTP_STATE-1]) { + ct->protoinfo.sctp.state = + *(u_int8_t *)NFA_DATA(tb[CTA_PROTOINFO_SCTP_STATE-1]); + set_bit(ATTR_SCTP_STATE, ct->set); + } + + if (tb[CTA_PROTOINFO_SCTP_VTAG_ORIGINAL-1]) { + ct->protoinfo.sctp.vtag[__DIR_ORIG] = + ntohl(*(u_int32_t *)NFA_DATA(tb[CTA_PROTOINFO_SCTP_VTAG_ORIGINAL-1])); + set_bit(ATTR_SCTP_VTAG_ORIG, ct->set); + } + + if (tb[CTA_PROTOINFO_SCTP_VTAG_REPLY-1]) { + ct->protoinfo.sctp.vtag[__DIR_ORIG] = + ntohl(*(u_int32_t *)NFA_DATA(tb[CTA_PROTOINFO_SCTP_VTAG_REPLY-1])); + set_bit(ATTR_SCTP_VTAG_ORIG, ct->set); + } + +} + static void __parse_protoinfo(const struct nfattr *attr, struct nf_conntrack *ct) { @@ -224,10 +251,11 @@ static void __parse_protoinfo(const struct nfattr *attr, nfnl_parse_nested(tb, CTA_PROTOINFO_MAX, attr); - if (!tb[CTA_PROTOINFO_TCP-1]) - return; + if (tb[CTA_PROTOINFO_TCP-1]) + __parse_protoinfo_tcp(tb[CTA_PROTOINFO_TCP-1], ct); - __parse_protoinfo_tcp(tb[CTA_PROTOINFO_TCP-1], ct); + if (tb[CTA_PROTOINFO_SCTP-1]) + __parse_protoinfo_sctp(tb[CTA_PROTOINFO_SCTP-1], ct); } static void __parse_counters(const struct nfattr *attr, -- cgit v1.2.3