]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Refactor packet manager
authorJosh <jrosenba@cisco.com>
Wed, 30 Apr 2014 19:36:05 +0000 (15:36 -0400)
committerJosh <jrosenba@cisco.com>
Wed, 30 Apr 2014 19:36:05 +0000 (15:36 -0400)
src/codecs/basic/cd_udp.cc
src/managers/packet_manager.cc

index 7cf44976ee3e83d174576f38bf9844a958bf766b..e975f2ce4169be6d55d04fa51b97c0078f6cc9de 100644 (file)
@@ -234,7 +234,6 @@ bool UdpCodec::decode(const uint8_t *raw_pkt, const uint32_t len,
     DEBUG_WRAP(DebugMessage(DEBUG_DECODE, "UDP header starts at: %p\n", p->udph););
 
     lyr_len = udp::header_len();
-    next_prot_id = -1;
 //    PushLayer(PROTO_UDP, p, raw_pkt, udp::header_len());
 
 
index b509788be087950bc4be517b156bccf2202b15f0..39d40f542f9624c923f74009b0d3d96e6be3e3d4 100644 (file)
@@ -296,7 +296,10 @@ void PacketManager::accumulate()
     s_stats[0] = pkt_cnt.total_processed;
     s_stats[1] = pkt_cnt.other_codecs;
     s_stats[2] = pkt_cnt.discards;
-    s_stats[3] = 0; // zeroing out the 'null' codec.
+
+    // zeroing out the null codecs ... these     
+    s_stats[3] = 0;
+    s_stats[s_proto_map[FINISHED_DECODE] + stat_offset] = 0;
 
     sum_stats(&g_stats[0], &s_stats[0], s_stats.size());
 
@@ -330,8 +333,8 @@ void PacketManager::decode(
     {
         PacketClass::PushLayer(p, s_protocols[mapped_prot], pkt, lyr_len);
         s_stats[mapped_prot + stat_offset]++;
+        mapped_prot = s_proto_map[prot_id];
         prev_prot_id = prot_id; // used for 'other_codecs' statistics
-        mapped_prot =  s_proto_map[prot_id];
         prot_id = FINISHED_DECODE;
         len -= lyr_len;
         pkt += lyr_len;
@@ -339,12 +342,13 @@ void PacketManager::decode(
     }
 
     // if the final protocol ID is not the null codec
-    if ((prot_id != FINISHED_DECODE))
-        pkt_cnt.discards++;
-
-    // If a codec attempted to decode another layer but we couldn't find it
     if (prev_prot_id != FINISHED_DECODE)
-        pkt_cnt.other_codecs++;
+    {
+        if(s_proto_map[prev_prot_id])
+            pkt_cnt.other_codecs++;
+        else
+            pkt_cnt.discards++;
+    }
 
     s_stats[mapped_prot + stat_offset]++;
     p->dsize = len;