From 674b0bfae788ed4db007116834534c8effd9e586 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Mon, 28 Feb 2011 17:44:34 +0100 Subject: [PATCH] flow: Add basic SCTP support This patch adds a basic flow support to SCTP. SCTP specificities like the verification tag are not taken into account. --- src/flow-private.h | 1 + src/flow-util.c | 5 +++++ src/flow.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/flow-private.h b/src/flow-private.h index 1d868274fd..fb48791de1 100644 --- a/src/flow-private.h +++ b/src/flow-private.h @@ -62,6 +62,7 @@ enum { FLOW_PROTO_TCP, FLOW_PROTO_UDP, FLOW_PROTO_ICMP, + FLOW_PROTO_SCTP, /* should be last */ FLOW_PROTO_MAX, diff --git a/src/flow-util.c b/src/flow-util.c index b0ee9f857b..8215e20f61 100644 --- a/src/flow-util.c +++ b/src/flow-util.c @@ -100,6 +100,8 @@ uint8_t FlowGetProtoMapping(uint8_t proto) { return FLOW_PROTO_UDP; case IPPROTO_ICMP: return FLOW_PROTO_ICMP; + case IPPROTO_SCTP: + return FLOW_PROTO_SCTP; default: return FLOW_PROTO_DEFAULT; } @@ -142,6 +144,9 @@ void FlowInit(Flow *f, Packet *p) } else if (p->icmpv6h != NULL) { f->type = p->type; f->code = p->code; + } else if (p->sctph != NULL) { /* XXX MACRO */ + SET_SCTP_SRC_PORT(p,&f->sp); + SET_SCTP_DST_PORT(p,&f->dp); } /* XXX handle default */ else { printf("FIXME: %s:%s:%" PRId32 "\n", __FILE__, __FUNCTION__, __LINE__); diff --git a/src/flow.c b/src/flow.c index c69920e64a..520230fdde 100644 --- a/src/flow.c +++ b/src/flow.c @@ -660,7 +660,7 @@ void FlowDecrUsecnt(Flow *f) { * \retval 1 to_client */ int FlowGetPacketDirection(Flow *f, Packet *p) { - if (p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP) { + if (p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP || p->proto == IPPROTO_SCTP) { if (!(CMP_PORT(p->sp,p->dp))) { /* update flags and counters */ if (CMP_PORT(f->sp,p->sp)) {