]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: add size debug code
authorVictor Julien <victor@inliniac.net>
Tue, 5 Nov 2013 13:41:31 +0000 (14:41 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 2 Dec 2013 14:50:04 +0000 (15:50 +0100)
src/stream-tcp-reassemble.c

index 0ee90070e82d72bfe6b4326798a56c888f959fcb..1ce3ecdbf7f902d8059137401e229688cc15023b 100644 (file)
@@ -2590,6 +2590,39 @@ void StreamTcpPruneSession(Flow *f, uint8_t flags) {
     }
 }
 
+#ifdef DEBUG
+static uint64_t GetStreamSize(TcpStream *stream) {
+    if (stream) {
+        uint64_t size = 0;
+        uint32_t cnt = 0;
+
+        TcpSegment *seg = stream->seg_list;
+        while (seg) {
+            cnt++;
+            size += (uint64_t)seg->payload_len;
+
+            seg = seg->next;
+        }
+
+        SCLogDebug("size %"PRIu64", cnt %"PRIu32, size, cnt);
+        return size;
+    }
+    return (uint64_t)0;
+}
+
+static void GetSessionSize(TcpSession *ssn, Packet *p) {
+    uint64_t size = 0;
+    if (ssn) {
+        size = GetStreamSize(&ssn->client);
+        size += GetStreamSize(&ssn->server);
+
+        //if (size > 900000)
+        //    SCLogInfo("size %"PRIu64", packet %"PRIu64, size, p->pcap_cnt);
+        SCLogDebug("size %"PRIu64", packet %"PRIu64, size, p->pcap_cnt);
+    }
+}
+#endif
+
 /**
  *  \brief Update the stream reassembly upon receiving an ACK packet.
  *
@@ -2623,6 +2656,7 @@ int StreamTcpReassembleAppLayer (ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
     SCLogDebug("stream->seg_list %p", stream->seg_list);
 #ifdef DEBUG
     PrintList(stream->seg_list);
+    GetSessionSize(ssn, p);
 #endif
 
     /* if no segments are in the list or all are already processed,