[Oisf-devel] [PATCH 8/9] flow: Add basic SCTP support

Eric Leblond eric at regit.org
Mon Feb 28 16:44:34 UTC 2011


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 deletions(-)

diff --git a/src/flow-private.h b/src/flow-private.h
index 1d86827..fb48791 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 b0ee9f8..8215e20 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 c69920e..520230f 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)) {
-- 
1.7.1




More information about the Oisf-devel mailing list