]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: pass TcpSession to StreamTcpReassembleProcessAppLayer
authorVictor Julien <victor@inliniac.net>
Tue, 17 Dec 2013 15:19:16 +0000 (16:19 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 10 Jan 2014 15:21:55 +0000 (16:21 +0100)
Preparation for removing flow pointer from StreamMsg. Instead of
getting the ssn indirectly through StreamMsg->flow, we pass it
directly as all callers have it already.

src/app-layer.c
src/app-layer.h
src/flow-timeout.c
src/stream-tcp-reassemble.c
src/stream-tcp-reassemble.h
src/stream-tcp.c

index ad4c21aaeb61bd81457429bc2b99163537d64384..490df796dcae2870090a9287e938ac0699e127b7 100644 (file)
@@ -351,11 +351,20 @@ int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
     SCReturnInt(r);
 }
 
-int AppLayerHandleTCPMsg(StreamMsg *smsg)
+/**
+ *  \brief Attach a stream message to the TCP session for inspection
+ *         in the detection engine.
+ *
+ *  \param dp_ctx Thread app layer detect context
+ *  \param smsg Stream message
+ *
+ *  \retval 0 ok
+ *  \retval -1 error
+ */
+int AppLayerHandleTCPMsg(StreamMsg *smsg, TcpSession *ssn)
 {
     SCEnter();
 
-    TcpSession *ssn;
     StreamMsg *cur;
 
 #ifdef PRINT
@@ -368,7 +377,6 @@ int AppLayerHandleTCPMsg(StreamMsg *smsg)
     SCLogDebug("smsg %p", smsg);
     BUG_ON(smsg->flow == NULL);
 
-    ssn = smsg->flow->protoctx;
     if (ssn != NULL) {
         SCLogDebug("storing smsg %p in the tcp session", smsg);
 
index aabcc2d25ac8dbbf588192398a75fc4e520e27e3..a5e49d94c1653fc53aa18b5b9e8909f8050c20f6 100644 (file)
@@ -55,7 +55,7 @@ int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
  * \retval 0 On success.
  * \retval -1 On failure.
  */
-int AppLayerHandleTCPMsg(StreamMsg *smsg);
+int AppLayerHandleTCPMsg(StreamMsg *smsg, TcpSession *ssn);
 
 /**
  * \brief Handles an udp chunk.
index ae815126b3cd339892194ab1fbb01ece4fc9a2a6..56c3832cdb4bd4d7013b3034106a766506bcda3b 100644 (file)
@@ -563,7 +563,7 @@ static inline void FlowForceReassemblyForHash(void)
                         stt->ra_ctx, ssn, &ssn->server,
                         reassemble_p, NULL);
                 FlowDeReference(&reassemble_p->flow);
-                if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
+                if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx, ssn) < 0) {
                     SCLogDebug("shutdown flow timeout "
                                "StreamTcpReassembleProcessAppLayer() erroring "
                                "over something");
@@ -581,7 +581,7 @@ static inline void FlowForceReassemblyForHash(void)
                         stt->ra_ctx, ssn, &ssn->client,
                         reassemble_p, NULL);
                 FlowDeReference(&reassemble_p->flow);
-                if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
+                if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx, ssn) < 0) {
                     SCLogDebug("shutdown flow timeout "
                                "StreamTcpReassembleProcessAppLayer() erroring "
                                "over something");
index 696253025427e2fe44d3b90604a60f76f04daa13..b942281f6a28934258d9fc86665bbf2e9030044f 100644 (file)
@@ -3393,7 +3393,7 @@ int StreamTcpReassembleHandleSegmentUpdateACK (ThreadVars *tv,
  *  \retval 0 ok
  *  \retval -1 error
  */
-int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *ra_ctx)
+int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *ra_ctx, TcpSession *ssn)
 {
     SCEnter();
 
@@ -3417,7 +3417,7 @@ int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *ra_ctx)
                 /* Handle the stream msg. No need to use locking, flow is
                  * already locked at this point. Don't break out of the
                  * loop if we encounter an error. */
-                if (AppLayerHandleTCPMsg(smsg) != 0)
+                if (AppLayerHandleTCPMsg(smsg, ssn) != 0)
                     r = -1;
             }
 
@@ -5281,7 +5281,7 @@ static int StreamTcpReassembleTest28 (void) {
     }
 
     /* Process stream smsgs we may have in queue */
-    if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (3): ");
         goto end;
     }
@@ -5365,7 +5365,7 @@ static int StreamTcpReassembleTest29 (void) {
     }
 
     /* Process stream smsgs we may have in queue */
-    if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs\n");
         goto end;
     }
@@ -5450,7 +5450,7 @@ static int StreamTcpReassembleTest30 (void) {
     }
 
     /* Process stream smsgs we may have in queue */
-    if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs\n");
         goto end;
     }
@@ -5474,7 +5474,7 @@ static int StreamTcpReassembleTest30 (void) {
     }
 
     /* Process stream smsgs we may have in queue */
-    if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs\n");
         goto end;
     }
@@ -6867,7 +6867,7 @@ static int StreamTcpReassembleTest40 (void) {
     }
 
     /* Process stream smsgs we may have in queue */
-    if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (4): ");
         goto end;
     }
@@ -6914,7 +6914,7 @@ static int StreamTcpReassembleTest40 (void) {
                 "been sent (8): ");
         goto end;
     /* Process stream smsgs we may have in queue */
-    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (9): ");
         goto end;
     }
@@ -6953,7 +6953,7 @@ static int StreamTcpReassembleTest40 (void) {
                 "been sent (12): ");
         goto end;
     /* Process stream smsgs we may have in queue */
-    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (13): ");
         goto end;
     }
@@ -6993,7 +6993,7 @@ static int StreamTcpReassembleTest40 (void) {
     /* Process stream smsgs we may have in queue */
     }
 
-    if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (17): ");
         goto end;
     }
@@ -7130,7 +7130,7 @@ static int StreamTcpReassembleTest43 (void) {
         printf("there should be a stream smsgs in the queue (6): ");
         goto end;
     /* Process stream smsgs we may have in queue */
-    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (7): ");
         goto end;
     }
@@ -7184,7 +7184,7 @@ static int StreamTcpReassembleTest43 (void) {
                 " been unpaused now (12): ");
         goto end;
     /* Process stream smsgs we may have in queue */
-    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+    } else if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
         printf("failed in processing stream smsgs (13): ");
         goto end;
     }
@@ -7572,7 +7572,7 @@ static int StreamTcpReassembleTest47 (void) {
         }
 
         /* Process stream smsgs we may have in queue */
-        if (StreamTcpReassembleProcessAppLayer(ra_ctx) < 0) {
+        if (StreamTcpReassembleProcessAppLayer(ra_ctx, &ssn) < 0) {
             printf("failed in processing stream smsgs\n");
             goto end;
         }
index 888a050330c0505a94c217802e1554742be4c56c..17a1f9913f0304608571ae54d50d65d320500be6 100644 (file)
@@ -84,7 +84,7 @@ int StreamTcpReassembleInlineAppLayer(ThreadVars *tv,
                                       TcpReassemblyThreadCtx *ra_ctx,
                                       TcpSession *ssn, TcpStream *stream,
                                       Packet *p);
-int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *);
+int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *, TcpSession *);
 
 void StreamTcpCreateTestPacket(uint8_t *, uint8_t, uint8_t, uint8_t);
 
index 97178d66b1eb74b1328e84c542e25b4067439650..03d61c1d32b0ba7a776216cfafb97949bcf75e44 100644 (file)
@@ -4374,7 +4374,7 @@ int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
         }
 
         /* Process stream smsgs we may have in queue */
-        if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
+        if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx, ssn) < 0) {
             goto error;
         }