]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threading: change local packet queue logic
authorVictor Julien <victor@inliniac.net>
Tue, 12 Nov 2019 21:34:51 +0000 (22:34 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 7 Feb 2020 14:43:10 +0000 (15:43 +0100)
Previously each 'TmSlot' had it's own packet queue that was passed
to the registered SlotFunc as an argument. This was used mostly for
tunnel packets by the decoders and by defrag.

This patch removes that in favor of a single queue in the ThreadVars:
decode_pq. This is the non-locked version of the queue as this is
only a temporary store for handling packets within a thread.

This patch removes the PacketQueue pointer argument from the API.
The new queue can be accessed directly through the ThreadVars
pointer.

56 files changed:
src/alert-unified2-alert.c
src/decode-afl.c
src/decode-erspan.c
src/decode-ethernet.c
src/decode-gre.c
src/decode-icmpv4.c
src/decode-icmpv6.c
src/decode-ipv4.c
src/decode-ipv6.c
src/decode-mpls.c
src/decode-null.c
src/decode-ppp.c
src/decode-pppoe.c
src/decode-raw.c
src/decode-sctp.c
src/decode-sll.c
src/decode-tcp.c
src/decode-template.c
src/decode-teredo.c
src/decode-teredo.h
src/decode-udp.c
src/decode-vlan.c
src/decode-vxlan.c
src/decode.c
src/decode.h
src/defrag.c
src/defrag.h
src/detect-content.c
src/detect-csum.c
src/detect-dsize.c
src/detect-fragbits.c
src/detect-icmp-id.c
src/detect-ipproto.c
src/detect-parse.c
src/detect-replace.c
src/flow-worker.c
src/packet-queue.h
src/respond-reject.c
src/source-af-packet.c
src/source-erf-dag.c
src/source-erf-file.c
src/source-ipfw.c
src/source-napatech.c
src/source-netmap.c
src/source-nflog.c
src/source-nfq.c
src/source-pcap-file.c
src/source-pcap.c
src/source-pfring.c
src/source-windivert.c
src/tests/detect.c
src/threadvars.h
src/tm-modules.h
src/tm-threads.c
src/tm-threads.h
src/util-unittest-helper.c

index fd23ed1bd0465d9d85218e7467c694f5349f493a..e2c81d775fa6eadcbde1e2deefaf2ffd162f4282 100644 (file)
@@ -1505,7 +1505,6 @@ static int Unified2Test01(void)
 {
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     void *data = NULL;
     OutputInitResult oc;
     LogFileCtx *lf;
@@ -1530,7 +1529,6 @@ static int Unified2Test01(void)
 
     memset(&dtv, 0, sizeof(DecodeThreadVars));
     memset(&tv, 0, sizeof(ThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&s, 0, sizeof(Signature));
 
     p->alerts.cnt++;
@@ -1542,8 +1540,7 @@ static int Unified2Test01(void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_ipv4_tcp, sizeof(raw_ipv4_tcp), &pq);
-
+    DecodeEthernet(&tv, &dtv, p, raw_ipv4_tcp, sizeof(raw_ipv4_tcp));
 
     oc = Unified2AlertInitCtx(NULL);
     if (oc.ctx == NULL) {
@@ -1594,7 +1591,6 @@ static int Unified2Test02(void)
 {
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     void *data = NULL;
     OutputInitResult oc;
     LogFileCtx *lf;
@@ -1621,7 +1617,6 @@ static int Unified2Test02(void)
 
     memset(&dtv, 0, sizeof(DecodeThreadVars));
     memset(&tv, 0, sizeof(ThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&s, 0, sizeof(Signature));
 
     p->alerts.cnt++;
@@ -1633,7 +1628,7 @@ static int Unified2Test02(void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_ipv6_tcp, sizeof(raw_ipv6_tcp), &pq);
+    DecodeEthernet(&tv, &dtv, p, raw_ipv6_tcp, sizeof(raw_ipv6_tcp));
 
     oc = Unified2AlertInitCtx(NULL);
     if (oc.ctx == NULL) {
@@ -1685,7 +1680,6 @@ static int Unified2Test03(void)
 {
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     void *data = NULL;
     OutputInitResult oc;
     LogFileCtx *lf;
@@ -1718,7 +1712,6 @@ static int Unified2Test03(void)
 
     memset(&dtv, 0, sizeof(DecodeThreadVars));
     memset(&tv, 0, sizeof(ThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&s, 0, sizeof(Signature));
 
     p->alerts.cnt++;
@@ -1730,7 +1723,7 @@ static int Unified2Test03(void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_gre, sizeof(raw_gre), &pq);
+    DecodeEthernet(&tv, &dtv, p, raw_gre, sizeof(raw_gre));
 
     oc = Unified2AlertInitCtx(NULL);
     if (oc.ctx == NULL) {
@@ -1758,11 +1751,11 @@ static int Unified2Test03(void)
 
     Unified2AlertDeInitCtx(oc.ctx);
 
-    pkt = PacketDequeue(&pq);
+    pkt = PacketDequeueNoLock(&tv.decode_pq);
     while (pkt != NULL) {
         PACKET_RECYCLE(pkt);
         SCFree(pkt);
-        pkt = PacketDequeue(&pq);
+        pkt = PacketDequeueNoLock(&tv.decode_pq);
     }
 
     PACKET_RECYCLE(p);
@@ -1771,11 +1764,11 @@ static int Unified2Test03(void)
     return 1;
 
 end:
-    pkt = PacketDequeue(&pq);
+    pkt = PacketDequeueNoLock(&tv.decode_pq);
     while (pkt != NULL) {
         PACKET_RECYCLE(pkt);
         SCFree(pkt);
-        pkt = PacketDequeue(&pq);
+        pkt = PacketDequeueNoLock(&tv.decode_pq);
     }
     PACKET_RECYCLE(p);
     SCFree(p);
@@ -1794,7 +1787,6 @@ static int Unified2Test04(void)
 {
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     void *data = NULL;
     OutputInitResult oc;
     LogFileCtx *lf;
@@ -1815,7 +1807,6 @@ static int Unified2Test04(void)
 
     memset(&dtv, 0, sizeof(DecodeThreadVars));
     memset(&tv, 0, sizeof(ThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&s, 0, sizeof(Signature));
 
     p->alerts.cnt++;
@@ -1827,7 +1818,7 @@ static int Unified2Test04(void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), &pq);
+    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp));
 
     oc = Unified2AlertInitCtx(NULL);
     if (oc.ctx == NULL) {
@@ -1878,7 +1869,6 @@ static int Unified2Test05(void)
 {
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     void *data = NULL;
     OutputInitResult oc;
     LogFileCtx *lf;
@@ -1903,7 +1893,6 @@ static int Unified2Test05(void)
 
     memset(&dtv, 0, sizeof(DecodeThreadVars));
     memset(&tv, 0, sizeof(ThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&s, 0, sizeof(Signature));
 
     p->alerts.cnt++;
@@ -1915,7 +1904,7 @@ static int Unified2Test05(void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_ipv4_tcp, sizeof(raw_ipv4_tcp), &pq);
+    DecodeEthernet(&tv, &dtv, p, raw_ipv4_tcp, sizeof(raw_ipv4_tcp));
 
     p->action = ACTION_DROP;
 
index 878a497f2df6b4a336af9246f0cb1719aeb57856..974ebd61a313d05e17fe6c57146cc986cce6195f 100644 (file)
 
 #ifdef AFLFUZZ_DECODER
 int AFLDecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
-    return DecodeIPV4(tv, dtv, p, pkt, (uint16_t)len, pq);
+    return DecodeIPV4(tv, dtv, p, pkt, (uint16_t)len);
 }
 int AFLDecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
-    return DecodeIPV6(tv, dtv, p, pkt, (uint16_t)len, pq);
+    return DecodeIPV6(tv, dtv, p, pkt, (uint16_t)len);
 }
 
 /* stateful processing of data as packets. Because AFL in case of a
@@ -99,9 +99,9 @@ int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder)
         Packet *p = PacketGetFromAlloc();
         if (p != NULL) {
             PacketSetData(p, buffer, size);
-            (void) Decoder (&tv, dtv, p, buffer, size, &pq);
+            (void) Decoder (&tv, dtv, p, buffer, size);
             while (1) {
-                Packet *extra_p = PacketDequeue(&pq);
+                Packet *extra_p = PacketDequeueNoLock(&tv.decode_pq);
                 if (unlikely(extra_p == NULL))
                     break;
                 PacketFree(extra_p);
@@ -161,9 +161,9 @@ int DecoderParseDataFromFileSerie(char *fileprefix, DecoderFunc Decoder)
         Packet *p = PacketGetFromAlloc();
         if (p != NULL) {
             PacketSetData(p, buffer, size);
-            (void) Decoder (&tv, dtv, p, buffer, size, &pq);
+            (void) Decoder (&tv, dtv, p, buffer, size);
             while (1) {
-                Packet *extra_p = PacketDequeue(&pq);
+                Packet *extra_p = PacketDequeueNoLock(&tv.decode_pq);
                 if (unlikely(extra_p == NULL))
                     break;
                 PacketFree(extra_p);
index d95c93b5047cf9886fd18f031bfa439c09128cdd..41b37d3c6fb8c4a2c861079c211d8ebcdaaeabf6 100644 (file)
@@ -43,7 +43,7 @@
  * \brief Function to decode ERSPAN packets
  */
 
-int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_erspan);
 
@@ -73,7 +73,7 @@ int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t
         p->vlan_idx++;
     }
 
-    return DecodeEthernet(tv, dtv, p, pkt + sizeof(ErspanHdr), len - sizeof(ErspanHdr), pq);
+    return DecodeEthernet(tv, dtv, p, pkt + sizeof(ErspanHdr), len - sizeof(ErspanHdr));
 }
 
 /**
index ff5daead51ff3dc8888dc265cc026882638e56fc..911538ceb4c1e27b8b9e8d8b1d56f4e98d86ffe9 100644 (file)
@@ -39,7 +39,7 @@
 #include "util-debug.h"
 
 int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-                   const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+                   const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_eth);
 
@@ -62,39 +62,39 @@ int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         case ETHERNET_TYPE_IP:
             //printf("DecodeEthernet ip4\n");
             DecodeIPV4(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
-                       len - ETHERNET_HEADER_LEN, pq);
+                       len - ETHERNET_HEADER_LEN);
             break;
         case ETHERNET_TYPE_IPV6:
             //printf("DecodeEthernet ip6\n");
             DecodeIPV6(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
-                       len - ETHERNET_HEADER_LEN, pq);
+                       len - ETHERNET_HEADER_LEN);
             break;
         case ETHERNET_TYPE_PPPOE_SESS:
             //printf("DecodeEthernet PPPOE Session\n");
             DecodePPPOESession(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
-                               len - ETHERNET_HEADER_LEN, pq);
+                               len - ETHERNET_HEADER_LEN);
             break;
         case ETHERNET_TYPE_PPPOE_DISC:
             //printf("DecodeEthernet PPPOE Discovery\n");
             DecodePPPOEDiscovery(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
-                                 len - ETHERNET_HEADER_LEN, pq);
+                                 len - ETHERNET_HEADER_LEN);
             break;
         case ETHERNET_TYPE_VLAN:
         case ETHERNET_TYPE_8021QINQ:
             DecodeVLAN(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
-                                 len - ETHERNET_HEADER_LEN, pq);
+                                 len - ETHERNET_HEADER_LEN);
             break;
         case ETHERNET_TYPE_MPLS_UNICAST:
         case ETHERNET_TYPE_MPLS_MULTICAST:
             DecodeMPLS(tv, dtv, p, pkt + ETHERNET_HEADER_LEN,
-                       len - ETHERNET_HEADER_LEN, pq);
+                       len - ETHERNET_HEADER_LEN);
             break;
         case ETHERNET_TYPE_DCE:
             if (unlikely(len < ETHERNET_DCE_HEADER_LEN)) {
                 ENGINE_SET_INVALID_EVENT(p, DCE_PKT_TOO_SMALL);
             } else {
                 DecodeEthernet(tv, dtv, p, pkt + ETHERNET_DCE_HEADER_LEN,
-                    len - ETHERNET_DCE_HEADER_LEN, pq);
+                    len - ETHERNET_DCE_HEADER_LEN);
             }
             break;
         default:
@@ -141,7 +141,7 @@ static int DecodeEthernetTest01 (void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth));
 
     SCFree(p);
     return 1;
@@ -166,7 +166,7 @@ static int DecodeEthernetTestDceTooSmall(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth));
 
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p, DCE_PKT_TOO_SMALL));
 
@@ -202,7 +202,7 @@ static int DecodeEthernetTestDceNextTooSmall(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth));
 
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p, ETHERNET_PKT_TOO_SMALL));
 
index 969a888243a3b3d8b4e6fd7197ec17caabfa3e1a..384a02c4986953405de8e55155c99a7dc7b59f92 100644 (file)
@@ -43,7 +43,7 @@
  * \brief Function to decode GRE packets
  */
 
-int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
 {
     uint32_t header_len = GRE_HDR_LEN;
     GRESreHdr *gsre = NULL;
@@ -198,82 +198,70 @@ int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *p
     switch (GRE_GET_PROTO(p->greh))
     {
         case ETHERNET_TYPE_IP:
-            {
-                if (pq != NULL) {
-                    Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
-                            len - header_len, DECODE_TUNNEL_IPV4, pq);
-                    if (tp != NULL) {
-                        PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
-                        PacketEnqueue(pq,tp);
-                    }
-                }
-                break;
+        {
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
+                    len - header_len, DECODE_TUNNEL_IPV4);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
             }
+            break;
+        }
 
         case GRE_PROTO_PPP:
-            {
-                if (pq != NULL) {
-                    Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
-                            len - header_len, DECODE_TUNNEL_PPP, pq);
-                    if (tp != NULL) {
-                        PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
-                        PacketEnqueue(pq,tp);
-                    }
-                }
-                break;
+        {
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
+                    len - header_len, DECODE_TUNNEL_PPP);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
             }
+            break;
+        }
 
         case ETHERNET_TYPE_IPV6:
-            {
-                if (pq != NULL) {
-                    Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
-                            len - header_len, DECODE_TUNNEL_IPV6, pq);
-                    if (tp != NULL) {
-                        PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
-                        PacketEnqueue(pq,tp);
-                    }
-                }
-                break;
+        {
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
+                    len - header_len, DECODE_TUNNEL_IPV6);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
             }
+            break;
+        }
 
         case ETHERNET_TYPE_VLAN:
-            {
-                if (pq != NULL) {
-                    Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
-                            len - header_len, DECODE_TUNNEL_VLAN, pq);
-                    if (tp != NULL) {
-                        PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
-                        PacketEnqueue(pq,tp);
-                    }
-                }
-                break;
+        {
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
+                    len - header_len, DECODE_TUNNEL_VLAN);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
             }
+            break;
+        }
 
         case ETHERNET_TYPE_ERSPAN:
         {
-            if (pq != NULL) {
-                Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
-                        len - header_len, DECODE_TUNNEL_ERSPAN, pq);
-                if (tp != NULL) {
-                    PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
-                    PacketEnqueue(pq,tp);
-                }
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
+                    len - header_len, DECODE_TUNNEL_ERSPAN);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
             }
             break;
         }
 
         case ETHERNET_TYPE_BRIDGE:
-            {
-                if (pq != NULL) {
-                    Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
-                            len - header_len, DECODE_TUNNEL_ETHERNET, pq);
-                    if (tp != NULL) {
-                        PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
-                        PacketEnqueue(pq,tp);
-                    }
-                }
-                break;
+        {
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + header_len,
+                    len - header_len, DECODE_TUNNEL_ETHERNET);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_GRE);
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
             }
+            break;
+        }
 
         default:
             return TM_ECODE_OK;
@@ -289,7 +277,6 @@ int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *p
 
 static int DecodeGREtest01 (void)
 {
-
     uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 };
     Packet *p = PacketGetFromAlloc();
     if (unlikely(p == NULL))
@@ -300,7 +287,7 @@ static int DecodeGREtest01 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre), NULL);
+    DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre));
 
     if(ENGINE_ISSET_EVENT(p,GRE_PKT_TOO_SMALL))  {
         SCFree(p);
@@ -341,7 +328,7 @@ static int DecodeGREtest02 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre), NULL);
+    DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre));
 
     if(ENGINE_ISSET_EVENT(p,GRE_WRONG_VERSION))  {
         SCFree(p);
@@ -383,7 +370,7 @@ static int DecodeGREtest03 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre), NULL);
+    DecodeGRE(&tv, &dtv, p, raw_gre, sizeof(raw_gre));
 
     if(p->greh == NULL) {
         SCFree(p);
index 3019ded4157aac3f1294a4840f0200e9c31518d1..e8748cac6f692c8ef119969fe723ae7ba78aa57f 100644 (file)
@@ -152,7 +152,7 @@ static int DecodePartialIPV4(Packet* p, uint8_t* partial_packet, uint16_t len)
 /** DecodeICMPV4
  *  \brief Main ICMPv4 decoding function
  */
-int DecodeICMPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+int DecodeICMPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_icmpv4);
 
@@ -378,7 +378,7 @@ static int DecodeICMPV4test01(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if (NULL!=p->icmpv4h) {
         if (p->icmpv4h->type==8 && p->icmpv4h->code==0) {
@@ -429,7 +429,7 @@ static int DecodeICMPV4test02(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if (NULL!=p->icmpv4h) {
         if (p->icmpv4h->type==0 && p->icmpv4h->code==0) {
@@ -478,7 +478,7 @@ static int DecodeICMPV4test03(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if (NULL == p->icmpv4h) {
            printf("NULL == p->icmpv4h: ");
@@ -558,7 +558,7 @@ static int DecodeICMPV4test04(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if (NULL == p->icmpv4h) {
         goto end;
@@ -628,7 +628,7 @@ static int DecodeICMPV4test05(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if (NULL == p->icmpv4h) {
         goto end;
@@ -735,7 +735,7 @@ static int ICMPV4InvalidType07(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if(ENGINE_ISSET_EVENT(p,ICMPV4_UNKNOWN_TYPE)) {
         ret = 1;
@@ -779,7 +779,7 @@ static int DecodeICMPV4test08(void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&tv, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     if (NULL!=p->icmpv4h) {
         if (p->icmpv4h->type==8 && p->icmpv4h->code==0) {
index 8809fce5eaee36e54485ac212df4872b82aa5c36..db810bd3751e594820579568d686d4cd63fed3b4 100644 (file)
@@ -182,12 +182,11 @@ int ICMPv6GetCounterpart(uint8_t type)
  * \param p Pointer to the packet we are filling
  * \param pkt Pointer to the raw packet buffer
  * \param len the len of the rest of the packet not processed yet
- * \param pq the packet queue were this packet go
  *
  * \retval void No return value
  */
 int DecodeICMPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-                 const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+                 const uint8_t *pkt, uint32_t len)
 {
     int full_hdr = 0;
     StatsIncr(tv, dtv->counter_icmpv6);
@@ -625,7 +624,7 @@ static int ICMPV6ParamProbTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(p->icmpv6h == NULL);
 
@@ -681,7 +680,7 @@ static int ICMPV6PktTooBigTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(p->icmpv6h == NULL);
 
@@ -740,7 +739,7 @@ static int ICMPV6TimeExceedTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->icmpv6h);
 
@@ -799,7 +798,7 @@ static int ICMPV6DestUnreachTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->icmpv6h);
 
@@ -846,7 +845,7 @@ static int ICMPV6EchoReqTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->icmpv6h);
 
@@ -892,7 +891,7 @@ static int ICMPV6EchoRepTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->icmpv6h);
 
@@ -945,7 +944,7 @@ static int ICMPV6ParamProbTest02(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->icmpv6h);
     FAIL_IF(ICMPV6_GET_TYPE(p) != 4 || ICMPV6_GET_CODE(p) != 0);
@@ -988,7 +987,7 @@ static int ICMPV6PktTooBigTest02(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->icmpv6h);
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
@@ -1027,7 +1026,7 @@ static int ICMPV6TimeExceedTest02(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_PKT_TOO_SMALL));
 
@@ -1068,7 +1067,7 @@ static int ICMPV6DestUnreachTest02(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_TRUNC_PKT));
 
@@ -1105,7 +1104,7 @@ static int ICMPV6EchoReqTest02(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1142,7 +1141,7 @@ static int ICMPV6EchoRepTest02(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1182,7 +1181,7 @@ static int ICMPV6PayloadTest01(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF_NULL(p->payload);
     FAIL_IF(p->payload_len != 37);
@@ -1216,7 +1215,7 @@ static int ICMPV6RouterSolicitTestKnownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1249,7 +1248,7 @@ static int ICMPV6RouterSolicitTestUnknownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1282,7 +1281,7 @@ static int ICMPV6RouterAdvertTestKnownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1315,7 +1314,7 @@ static int ICMPV6RouterAdvertTestUnknownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1348,7 +1347,7 @@ static int ICMPV6NeighbourSolicitTestKnownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1381,7 +1380,7 @@ static int ICMPV6NeighbourSolicitTestUnknownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1414,7 +1413,7 @@ static int ICMPV6NeighbourAdvertTestKnownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1447,7 +1446,7 @@ static int ICMPV6NeighbourAdvertTestUnknownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1480,7 +1479,7 @@ static int ICMPV6RedirectTestKnownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1513,7 +1512,7 @@ static int ICMPV6RedirectTestUnknownCode(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6, sizeof(raw_ipv6));
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
@@ -1563,7 +1562,7 @@ static int ICMPV6CalculateValidChecksumWithFCS(void)
     memset(&ip6h, 0, sizeof(IPV6Hdr));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeIPV6(&tv, &dtv, p, raw_ipv6 + 14, sizeof(raw_ipv6) - 14, NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_ipv6 + 14, sizeof(raw_ipv6) - 14);
     FAIL_IF_NULL(p->icmpv6h);
 
     uint16_t icmpv6_len = IPV6_GET_RAW_PLEN(p->ip6h) -
index 47c0e31e7c3a84af8ffb736e8cf0fbe4b6fd3a8f..6c2998cc6d749a956086a67e025c3ffed54870b8 100644 (file)
@@ -515,7 +515,7 @@ static int DecodeIPV4Packet(Packet *p, const uint8_t *pkt, uint16_t len)
 }
 
 int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     StatsIncr(tv, dtv->counter_ipv4);
 
@@ -531,9 +531,9 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 
     /* If a fragment, pass off for re-assembly. */
     if (unlikely(IPV4_GET_IPOFFSET(p) > 0 || IPV4_GET_MF(p) == 1)) {
-        Packet *rp = Defrag(tv, dtv, p, pq);
+        Packet *rp = Defrag(tv, dtv, p);
         if (rp != NULL) {
-            PacketEnqueue(pq, rp);
+            PacketEnqueueNoLock(&tv->decode_pq, rp);
         }
         p->flags |= PKT_IS_FRAGMENT;
         return TM_ECODE_OK;
@@ -557,44 +557,42 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
     switch (IPV4_GET_IPPROTO(p)) {
         case IPPROTO_TCP:
             DecodeTCP(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq);
+                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p));
             break;
         case IPPROTO_UDP:
             DecodeUDP(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq);
+                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p));
             break;
         case IPPROTO_ICMP:
             DecodeICMPV4(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                         IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq);
+                         IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p));
             break;
         case IPPROTO_GRE:
             DecodeGRE(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq);
+                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p));
             break;
         case IPPROTO_SCTP:
             DecodeSCTP(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p), pq);
+                      IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p));
             break;
         case IPPROTO_IPV6:
             {
-                if (pq != NULL) {
-                    /* spawn off tunnel packet */
-                    Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                            IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p),
-                            DECODE_TUNNEL_IPV6, pq);
-                    if (tp != NULL) {
-                        PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV4);
-                        PacketEnqueue(pq,tp);
-                    }
-                    FlowSetupPacket(p);
+                /* spawn off tunnel packet */
+                Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
+                        IPV4_GET_IPLEN(p) - IPV4_GET_HLEN(p),
+                        DECODE_TUNNEL_IPV6);
+                if (tp != NULL) {
+                    PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV4);
+                    PacketEnqueueNoLock(&tv->decode_pq,tp);
                 }
+                FlowSetupPacket(p);
                 break;
             }
         case IPPROTO_IP:
             /* check PPP VJ uncompressed packets and decode tcp dummy */
             if(p->ppph != NULL && SCNtohs(p->ppph->protocol) == PPP_VJ_UCOMP)    {
                 DecodeTCP(tv, dtv, p, pkt + IPV4_GET_HLEN(p),
-                          IPV4_GET_IPLEN(p) -  IPV4_GET_HLEN(p), pq);
+                          IPV4_GET_IPLEN(p) -  IPV4_GET_HLEN(p));
             }
             break;
         case IPPROTO_ICMPV6:
@@ -1247,19 +1245,17 @@ static int DecodeIPV4DefragTest01(void)
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     int result = 1;
 
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
 
     FlowInitConfig(FLOW_QUIET);
     DefragInit();
 
     PacketCopyData(p, pkt1, sizeof(pkt1));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         result = 0;
@@ -1269,7 +1265,7 @@ static int DecodeIPV4DefragTest01(void)
 
     PacketCopyData(p, pkt2, sizeof(pkt2));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         result = 0;
@@ -1279,13 +1275,13 @@ static int DecodeIPV4DefragTest01(void)
 
     PacketCopyData(p, pkt3, sizeof(pkt3));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         result = 0;
         goto end;
     }
-    Packet *tp = PacketDequeue(&pq);
+    Packet *tp = PacketDequeueNoLock(&tv.decode_pq);
     if (tp == NULL) {
         printf("Failed to get defragged pseudo packet\n");
         result = 0;
@@ -1384,19 +1380,17 @@ static int DecodeIPV4DefragTest02(void)
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     int result = 0;
 
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
 
     FlowInitConfig(FLOW_QUIET);
     DefragInit();
 
     PacketCopyData(p, pkt1, sizeof(pkt1));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         goto end;
@@ -1405,7 +1399,7 @@ static int DecodeIPV4DefragTest02(void)
 
     PacketCopyData(p, pkt2, sizeof(pkt2));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         goto end;
@@ -1415,12 +1409,12 @@ static int DecodeIPV4DefragTest02(void)
     p->recursion_level = 3;
     PacketCopyData(p, pkt3, sizeof(pkt3));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         goto end;
     }
-    Packet *tp = PacketDequeue(&pq);
+    Packet *tp = PacketDequeueNoLock(&tv.decode_pq);
     if (tp == NULL) {
         printf("Failed to get defragged pseudo packet\n");
         goto end;
@@ -1511,19 +1505,17 @@ static int DecodeIPV4DefragTest03(void)
         return 0;
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
     int result = 1;
 
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
-    memset(&pq, 0, sizeof(PacketQueue));
 
     FlowInitConfig(FLOW_QUIET);
     DefragInit();
 
     PacketCopyData(p, pkt, sizeof(pkt));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph == NULL) {
         printf("tcp header shouldn't be NULL, but it is\n");
         result = 0;
@@ -1538,7 +1530,7 @@ static int DecodeIPV4DefragTest03(void)
 
     PacketCopyData(p, pkt1, sizeof(pkt1));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         result = 0;
@@ -1548,7 +1540,7 @@ static int DecodeIPV4DefragTest03(void)
 
     PacketCopyData(p, pkt2, sizeof(pkt2));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         result = 0;
@@ -1558,14 +1550,14 @@ static int DecodeIPV4DefragTest03(void)
 
     PacketCopyData(p, pkt3, sizeof(pkt3));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
-               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN, &pq);
+               GET_PKT_LEN(p) - ETHERNET_HEADER_LEN);
     if (p->tcph != NULL) {
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         result = 0;
         goto end;
     }
 
-    Packet *tp = PacketDequeue(&pq);
+    Packet *tp = PacketDequeueNoLock(&tv.decode_pq);
     if (tp == NULL) {
         printf("Failed to get defragged pseudo packet\n");
         result = 0;
@@ -1639,7 +1631,7 @@ static int DecodeEthernetTestIPv4Opt(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth));
 
     SCFree(p);
     DefragDestroy();
index 430712ca9a2a8b76a22dddc29c16ffca51ca7525..f57b1d34e13fee5817dceb1b30e6596c82dd704c 100644 (file)
@@ -48,7 +48,7 @@
  * \brief Function to decode IPv4 in IPv6 packets
  *
  */
-static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t plen, PacketQueue *pq)
+static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t plen)
 {
 
     if (unlikely(plen < IPV4_HEADER_LEN)) {
@@ -56,15 +56,12 @@ static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, c
         return;
     }
     if (IP_GET_RAW_VER(pkt) == 4) {
-        if (pq != NULL) {
-            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt, plen, DECODE_TUNNEL_IPV4, pq);
-            if (tp != NULL) {
-                PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV6);
-                /* add the tp to the packet queue. */
-                PacketEnqueue(pq,tp);
-                StatsIncr(tv, dtv->counter_ipv4inipv6);
-                return;
-            }
+        Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt, plen, DECODE_TUNNEL_IPV4);
+        if (tp != NULL) {
+            PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV6);
+            PacketEnqueueNoLock(&tv->decode_pq,tp);
+            StatsIncr(tv, dtv->counter_ipv4inipv6);
+            return;
         }
     } else {
         ENGINE_SET_EVENT(p, IPV4_IN_IPV6_WRONG_IP_VER);
@@ -77,7 +74,7 @@ static void DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, c
  *
  */
 static int DecodeIP6inIP6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t plen, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t plen)
 {
 
     if (unlikely(plen < IPV6_HEADER_LEN)) {
@@ -85,13 +82,11 @@ static int DecodeIP6inIP6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         return TM_ECODE_FAILED;
     }
     if (IP_GET_RAW_VER(pkt) == 6) {
-        if (unlikely(pq != NULL)) {
-            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt, plen, DECODE_TUNNEL_IPV6, pq);
-            if (tp != NULL) {
-                PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV6);
-                PacketEnqueue(pq,tp);
-                StatsIncr(tv, dtv->counter_ipv6inipv6);
-            }
+        Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt, plen, DECODE_TUNNEL_IPV6);
+        if (tp != NULL) {
+            PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV6);
+            PacketEnqueueNoLock(&tv->decode_pq,tp);
+            StatsIncr(tv, dtv->counter_ipv6inipv6);
         }
     } else {
         ENGINE_SET_EVENT(p, IPV6_IN_IPV6_WRONG_IP_VER);
@@ -144,7 +139,7 @@ void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
 
 static void
 DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     SCEnter();
 
@@ -180,22 +175,22 @@ DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         {
             case IPPROTO_TCP:
                 IPV6_SET_L4PROTO(p,nh);
-                DecodeTCP(tv, dtv, p, pkt, plen, pq);
+                DecodeTCP(tv, dtv, p, pkt, plen);
                 SCReturn;
 
             case IPPROTO_UDP:
                 IPV6_SET_L4PROTO(p,nh);
-                DecodeUDP(tv, dtv, p, pkt, plen, pq);
+                DecodeUDP(tv, dtv, p, pkt, plen);
                 SCReturn;
 
             case IPPROTO_ICMPV6:
                 IPV6_SET_L4PROTO(p,nh);
-                DecodeICMPV6(tv, dtv, p, pkt, plen, pq);
+                DecodeICMPV6(tv, dtv, p, pkt, plen);
                 SCReturn;
 
             case IPPROTO_SCTP:
                 IPV6_SET_L4PROTO(p,nh);
-                DecodeSCTP(tv, dtv, p, pkt, plen, pq);
+                DecodeSCTP(tv, dtv, p, pkt, plen);
                 SCReturn;
 
             case IPPROTO_ROUTING:
@@ -524,7 +519,7 @@ DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
             }
             case IPPROTO_IPIP:
                 IPV6_SET_L4PROTO(p,nh);
-                DecodeIPv4inIPv6(tv, dtv, p, pkt, plen, pq);
+                DecodeIPv4inIPv6(tv, dtv, p, pkt, plen);
                 SCReturn;
             /* none, last header */
             case IPPROTO_NONE:
@@ -582,7 +577,7 @@ static int DecodeIPV6Packet (ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, c
     return 0;
 }
 
-int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
 {
     StatsIncr(tv, dtv->counter_ipv6);
 
@@ -609,29 +604,29 @@ int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *
     switch(IPV6_GET_NH(p)) {
         case IPPROTO_TCP:
             IPV6_SET_L4PROTO (p, IPPROTO_TCP);
-            DecodeTCP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeTCP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             return TM_ECODE_OK;
         case IPPROTO_UDP:
             IPV6_SET_L4PROTO (p, IPPROTO_UDP);
-            DecodeUDP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeUDP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             return TM_ECODE_OK;
         case IPPROTO_ICMPV6:
             IPV6_SET_L4PROTO (p, IPPROTO_ICMPV6);
-            DecodeICMPV6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeICMPV6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             return TM_ECODE_OK;
         case IPPROTO_SCTP:
             IPV6_SET_L4PROTO (p, IPPROTO_SCTP);
-            DecodeSCTP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeSCTP(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             return TM_ECODE_OK;
         case IPPROTO_IPIP:
             IPV6_SET_L4PROTO(p, IPPROTO_IPIP);
-            DecodeIPv4inIPv6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeIPv4inIPv6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             return TM_ECODE_OK;
         case IPPROTO_IPV6:
-            DecodeIP6inIP6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeIP6inIP6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             return TM_ECODE_OK;
         case IPPROTO_GRE:
-            DecodeGRE(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeGRE(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             break;
         case IPPROTO_FRAGMENT:
         case IPPROTO_HOPOPTS:
@@ -643,7 +638,7 @@ int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *
         case IPPROTO_MH:
         case IPPROTO_HIP:
         case IPPROTO_SHIM6:
-            DecodeIPV6ExtHdrs(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
+            DecodeIPV6ExtHdrs(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p));
             break;
         case IPPROTO_ICMP:
             ENGINE_SET_EVENT(p,IPV6_WITH_ICMPV4);
@@ -657,9 +652,9 @@ int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *
 
     /* Pass to defragger if a fragment. */
     if (IPV6_EXTHDR_ISSET_FH(p)) {
-        Packet *rp = Defrag(tv, dtv, p, pq);
+        Packet *rp = Defrag(tv, dtv, p);
         if (rp != NULL) {
-            PacketEnqueue(pq,rp);
+            PacketEnqueueNoLock(&tv->decode_pq,rp);
         }
     }
 
@@ -788,33 +783,31 @@ static int DecodeIPV6FragTest01 (void)
     ThreadVars tv;
     DecodeThreadVars dtv;
     int result = 0;
-    PacketQueue pq;
 
     FlowInitConfig(FLOW_QUIET);
     DefragInit();
 
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
     PacketCopyData(p1, raw_frag1, sizeof(raw_frag1));
     PacketCopyData(p2, raw_frag2, sizeof(raw_frag2));
 
-    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);
+    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1));
 
     if (!(IPV6_EXTHDR_ISSET_FH(p1))) {
         printf("ipv6 frag header not detected: ");
         goto end;
     }
 
-    DecodeIPV6(&tv, &dtv, p2, GET_PKT_DATA(p2), GET_PKT_LEN(p2), &pq);
+    DecodeIPV6(&tv, &dtv, p2, GET_PKT_DATA(p2), GET_PKT_LEN(p2));
 
     if (!(IPV6_EXTHDR_ISSET_FH(p2))) {
         printf("ipv6 frag header not detected: ");
         goto end;
     }
 
-    if (pq.len != 1) {
+    if (tv.decode_pq.len != 1) {
         printf("no reassembled packet: ");
         goto end;
     }
@@ -825,11 +818,11 @@ end:
     PACKET_RECYCLE(p2);
     SCFree(p1);
     SCFree(p2);
-    pkt = PacketDequeue(&pq);
+    pkt = PacketDequeueNoLock(&tv.decode_pq);
     while (pkt != NULL) {
         PACKET_RECYCLE(pkt);
         SCFree(pkt);
-        pkt = PacketDequeue(&pq);
+        pkt = PacketDequeueNoLock(&tv.decode_pq);
     }
     DefragDestroy();
     FlowShutdown();
@@ -857,17 +850,15 @@ static int DecodeIPV6RouteTest01 (void)
     FAIL_IF(unlikely(p1 == NULL));
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
 
     FlowInitConfig(FLOW_QUIET);
 
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
     PacketCopyData(p1, raw_pkt1, sizeof(raw_pkt1));
 
-    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);
+    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1));
 
     FAIL_IF (!(IPV6_EXTHDR_ISSET_RH(p1)));
     FAIL_IF (p1->ip6eh.rh_type != 0);
@@ -894,17 +885,15 @@ static int DecodeIPV6HopTest01 (void)
     FAIL_IF(unlikely(p1 == NULL));
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
 
     FlowInitConfig(FLOW_QUIET);
 
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
     PacketCopyData(p1, raw_pkt1, sizeof(raw_pkt1));
 
-    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);
+    DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1));
 
     FAIL_IF (!(ENGINE_ISSET_EVENT(p1, IPV6_HOPOPTS_UNKNOWN_OPT)));
 
index de23b8dc71c17cb8350687a18e36e63fbda1db3d..e64df63b7f77c55b41138ae06f1cdfba856fc7bc 100644 (file)
@@ -45,7 +45,7 @@
 #define MPLS_PROTO_IPV6         6
 
 int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     uint32_t shim;
     int label;
@@ -68,7 +68,7 @@ int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         if (len > USHRT_MAX) {
             return TM_ECODE_FAILED;
         }
-        return DecodeIPV4(tv, dtv, p, pkt, len, pq);
+        return DecodeIPV4(tv, dtv, p, pkt, len);
     }
     else if (label == MPLS_LABEL_ROUTER_ALERT) {
         /* Not valid at the bottom of the stack. */
@@ -78,7 +78,7 @@ int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         if (len > USHRT_MAX) {
             return TM_ECODE_FAILED;
         }
-        return DecodeIPV6(tv, dtv, p, pkt, len, pq);
+        return DecodeIPV6(tv, dtv, p, pkt, len);
     }
     else if (label == MPLS_LABEL_NULL) {
         /* Shouldn't appear on the wire. */
@@ -105,17 +105,16 @@ int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         if (len > USHRT_MAX) {
             return TM_ECODE_FAILED;
         }
-        DecodeIPV4(tv, dtv, p, pkt, len, pq);
+        DecodeIPV4(tv, dtv, p, pkt, len);
         break;
     case MPLS_PROTO_IPV6:
         if (len > USHRT_MAX) {
             return TM_ECODE_FAILED;
         }
-        DecodeIPV6(tv, dtv, p, pkt, len, pq);
+        DecodeIPV6(tv, dtv, p, pkt, len);
         break;
     case MPLS_PROTO_ETHERNET_PW:
-        DecodeEthernet(tv, dtv, p, pkt + MPLS_PW_LEN, len - MPLS_PW_LEN,
-            pq);
+        DecodeEthernet(tv, dtv, p, pkt + MPLS_PW_LEN, len - MPLS_PW_LEN);
         break;
     default:
         ENGINE_SET_INVALID_EVENT(p, MPLS_UNKNOWN_PAYLOAD_TYPE);
@@ -151,7 +150,7 @@ static int DecodeMPLSTestHeaderTooSmall(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt), NULL);
+    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt));
 
     if (!ENGINE_ISSET_EVENT(p, MPLS_HEADER_TOO_SMALL)) {
         ret = 0;
@@ -172,28 +171,28 @@ static int DecodeMPLSTestPacketTooSmall(void)
     Packet *p0 = SCCalloc(1, SIZE_OF_PACKET);
     memset(p0, 0, SIZE_OF_PACKET);
     uint8_t pkt0[] = { 0x00, 0x01, 0x51, 0xff };
-    DecodeMPLS(&tv, &dtv, p0, pkt0, sizeof(pkt0), NULL);
+    DecodeMPLS(&tv, &dtv, p0, pkt0, sizeof(pkt0));
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p0, MPLS_PKT_TOO_SMALL));
     SCFree(p0);
 
     Packet *p1 = SCCalloc(1, SIZE_OF_PACKET);
     FAIL_IF_NULL(p1);
     uint8_t pkt1[] = { 0x00, 0x01, 0x51, 0xff, 0x45 };
-    DecodeMPLS(&tv, &dtv, p1, pkt1, sizeof(pkt1), NULL);
+    DecodeMPLS(&tv, &dtv, p1, pkt1, sizeof(pkt1));
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p1, MPLS_PKT_TOO_SMALL));
     SCFree(p1);
 
     Packet *p2 = SCCalloc(1, SIZE_OF_PACKET);
     FAIL_IF_NULL(p2);
     uint8_t pkt2[] = { 0x00, 0x01, 0x51, 0xff, 0x45, 0x01 };
-    DecodeMPLS(&tv, &dtv, p2, pkt2, sizeof(pkt2), NULL);
+    DecodeMPLS(&tv, &dtv, p2, pkt2, sizeof(pkt2));
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p2, MPLS_PKT_TOO_SMALL));
     SCFree(p2);
 
     Packet *p3 = SCCalloc(1, SIZE_OF_PACKET);
     FAIL_IF_NULL(p3);
     uint8_t pkt3[] = { 0x00, 0x01, 0x51, 0xff, 0x45, 0x01, 0x02 };
-    DecodeMPLS(&tv, &dtv, p3, pkt3, sizeof(pkt3), NULL);
+    DecodeMPLS(&tv, &dtv, p3, pkt3, sizeof(pkt3));
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p3, MPLS_PKT_TOO_SMALL));
     SCFree(p3);
 
@@ -202,7 +201,7 @@ static int DecodeMPLSTestPacketTooSmall(void)
     Packet *p4 = SCCalloc(1, SIZE_OF_PACKET);
     FAIL_IF_NULL(p4);
     uint8_t pkt4[] = { 0x00, 0x01, 0x51, 0xff, 0x45, 0x01, 0x02, 0x03 };
-    DecodeMPLS(&tv, &dtv, p4, pkt4, sizeof(pkt4), NULL);
+    DecodeMPLS(&tv, &dtv, p4, pkt4, sizeof(pkt4));
     FAIL_IF(ENGINE_ISSET_EVENT(p4, MPLS_PKT_TOO_SMALL));
     SCFree(p4);
 
@@ -239,7 +238,7 @@ static int DecodeMPLSTestBadLabelRouterAlert(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt), NULL);
+    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt));
 
     if (!ENGINE_ISSET_EVENT(p, MPLS_BAD_LABEL_ROUTER_ALERT)) {
         ret = 0;
@@ -279,7 +278,7 @@ static int DecodeMPLSTestBadLabelImplicitNull(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt), NULL);
+    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt));
 
     if (!ENGINE_ISSET_EVENT(p, MPLS_BAD_LABEL_IMPLICIT_NULL)) {
         ret = 0;
@@ -319,7 +318,7 @@ static int DecodeMPLSTestBadLabelReserved(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt), NULL);
+    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt));
 
     if (!ENGINE_ISSET_EVENT(p, MPLS_BAD_LABEL_RESERVED)) {
         ret = 0;
@@ -363,7 +362,7 @@ static int DecodeMPLSTestUnknownPayloadType(void)
     memset(&tv,  0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
 
-    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt), NULL);
+    DecodeMPLS(&tv, &dtv, p, pkt, sizeof(pkt));
 
     if (!ENGINE_ISSET_EVENT(p, MPLS_UNKNOWN_PAYLOAD_TYPE)) {
         ret = 0;
index b42f50a53cc019e946da9afab861c59006c6fdf8..4712f1a643fd203807703c677a7f6c4690d00ebe 100644 (file)
@@ -46,7 +46,7 @@
 #define HDR_SIZE 4
 
 int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_null);
 
@@ -63,11 +63,11 @@ int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
     switch(type) {
         case AF_INET:
             SCLogDebug("IPV4 Packet");
-            DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p)+HDR_SIZE, GET_PKT_LEN(p)-HDR_SIZE, pq);
+            DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p)+HDR_SIZE, GET_PKT_LEN(p)-HDR_SIZE);
             break;
         case AF_INET6:
             SCLogDebug("IPV6 Packet");
-            DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p)+HDR_SIZE, GET_PKT_LEN(p)-HDR_SIZE, pq);
+            DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p)+HDR_SIZE, GET_PKT_LEN(p)-HDR_SIZE);
             break;
         default:
             SCLogDebug("Unknown Null packet type version %" PRIu32 "", type);
index bc12904d8a1118c99acbd2ba82472805e7103866..7a865c5d487bca9ecf4cc8f583f987a3d13efb0c 100644 (file)
@@ -41,7 +41,7 @@
 #include "util-debug.h"
 
 int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_ppp);
 
@@ -71,7 +71,7 @@ int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
             }
 
             if (likely(IPV4_GET_RAW_VER((IPV4Hdr *)(pkt + PPP_HEADER_LEN)) == 4)) {
-                return DecodeIPV4(tv, dtv, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN, pq);
+                return DecodeIPV4(tv, dtv, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN);
             } else
                 return TM_ECODE_FAILED;
             break;
@@ -86,7 +86,7 @@ int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                 return TM_ECODE_FAILED;
             }
 
-            return DecodeIPV4(tv, dtv, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN, pq);
+            return DecodeIPV4(tv, dtv, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN);
 
             /* PPP IPv6 was not tested */
         case PPP_IPV6:
@@ -99,7 +99,7 @@ int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                 return TM_ECODE_FAILED;
             }
 
-            return DecodeIPV6(tv, dtv, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN, pq);
+            return DecodeIPV6(tv, dtv, p, pkt + PPP_HEADER_LEN, len - PPP_HEADER_LEN);
 
         case PPP_VJ_COMP:
         case PPP_IPX:
@@ -159,7 +159,7 @@ static int DecodePPPtest01 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), NULL);
+    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp));
 
     /* Function my returns here with expected value */
 
@@ -192,7 +192,7 @@ static int DecodePPPtest02 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), NULL);
+    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp));
 
     /* Function must returns here */
 
@@ -229,7 +229,7 @@ static int DecodePPPtest03 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), NULL);
+    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp));
 
     FlowShutdown();
 
@@ -287,7 +287,7 @@ static int DecodePPPtest04 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp), NULL);
+    DecodePPP(&tv, &dtv, p, raw_ppp, sizeof(raw_ppp));
 
     FlowShutdown();
 
index 8887a30dba04ec43ac19035ae213d9b712c6c0a9..eef66299495f47519a483b72cac1449545f68d3b 100644 (file)
@@ -48,7 +48,7 @@
  * \brief Main decoding function for PPPOE Discovery packets
  */
 int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_pppoe);
 
@@ -128,7 +128,7 @@ int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
  * \brief Main decoding function for PPPOE Session packets
  */
 int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_pppoe);
 
@@ -193,7 +193,7 @@ int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                 }
 
                 if(IPV4_GET_RAW_VER((IPV4Hdr *)(pkt + PPPOE_SESSION_HEADER_LEN)) == 4) {
-                    DecodeIPV4(tv, dtv, p, pkt + PPPOE_SESSION_HEADER_LEN, len - PPPOE_SESSION_HEADER_LEN, pq );
+                    DecodeIPV4(tv, dtv, p, pkt + PPPOE_SESSION_HEADER_LEN, len - PPPOE_SESSION_HEADER_LEN);
                 }
                 break;
 
@@ -206,7 +206,7 @@ int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                     return TM_ECODE_FAILED;
                 }
 
-                DecodeIPV4(tv, dtv, p, pkt + PPPOE_SESSION_HEADER_LEN, len - PPPOE_SESSION_HEADER_LEN, pq );
+                DecodeIPV4(tv, dtv, p, pkt + PPPOE_SESSION_HEADER_LEN, len - PPPOE_SESSION_HEADER_LEN);
                 break;
 
             /* PPP IPv6 was not tested */
@@ -219,7 +219,7 @@ int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                     return TM_ECODE_FAILED;
                 }
 
-                DecodeIPV6(tv, dtv, p, pkt + PPPOE_SESSION_HEADER_LEN, len - PPPOE_SESSION_HEADER_LEN, pq );
+                DecodeIPV6(tv, dtv, p, pkt + PPPOE_SESSION_HEADER_LEN, len - PPPOE_SESSION_HEADER_LEN);
                 break;
 
             default:
@@ -249,7 +249,7 @@ static int DecodePPPOEtest01 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
+    DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
 
     if (ENGINE_ISSET_EVENT(p,PPPOE_PKT_TOO_SMALL))  {
         SCFree(p);
@@ -290,7 +290,7 @@ static int DecodePPPOEtest02 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
+    DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
 
     if(ENGINE_ISSET_EVENT(p,PPPOE_PKT_TOO_SMALL))  {
         goto end;
@@ -335,7 +335,7 @@ static int DecodePPPOEtest03 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
+    DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
     if (p->pppoedh == NULL) {
     SCFree(p);
     return 0;
@@ -367,7 +367,7 @@ static int DecodePPPOEtest04 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
+    DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
 
     if(ENGINE_ISSET_EVENT(p,PPPOE_WRONG_CODE))  {
         SCFree(p);
@@ -402,7 +402,7 @@ static int DecodePPPOEtest05 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe), NULL);
+    DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe));
 
     if(ENGINE_ISSET_EVENT(p,PPPOE_MALFORMED_TAGS))  {
         SCFree(p);
index c8061e291f22a17cb965110300ddd82d48adccc0..1b9f9eb2b6d8e3687cdf96bf902215d40e12f619 100644 (file)
@@ -44,7 +44,7 @@
 
 
 int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_raw);
 
@@ -61,13 +61,13 @@ int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
             return TM_ECODE_FAILED;
         }
         SCLogDebug("IPV4 Packet");
-        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else if (IP_GET_RAW_VER(pkt) == 6) {
         if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
             return TM_ECODE_FAILED;
         }
         SCLogDebug("IPV6 Packet");
-        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else {
         SCLogDebug("Unknown ip version %d", IP_GET_RAW_VER(pkt));
         ENGINE_SET_EVENT(p,IPRAW_INVALID_IPV);
@@ -114,7 +114,7 @@ static int DecodeRawTest01 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL);
+    DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p));
     if (p->ip6h == NULL) {
         printf("expected a valid ipv6 header but it was NULL: ");
         FlowShutdown();
@@ -160,7 +160,7 @@ static int DecodeRawTest02 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL);
+    DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p));
     if (p->ip4h == NULL) {
         printf("expected a valid ipv4 header but it was NULL: ");
         PACKET_RECYCLE(p);
@@ -208,7 +208,7 @@ static int DecodeRawTest03 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL);
+    DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p));
     if (!ENGINE_ISSET_EVENT(p,IPRAW_INVALID_IPV)) {
         printf("expected IPRAW_INVALID_IPV to be set but it wasn't: ");
         FlowShutdown();
index ba2697b4173800e72e492b7ddc19ea1bf32ba5e6..6de50d41b0fed48afca35ba787b2b4f0d9e21568 100644 (file)
@@ -60,7 +60,7 @@ static int DecodeSCTPPacket(ThreadVars *tv, Packet *p, const uint8_t *pkt, uint1
 }
 
 int DecodeSCTP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     StatsIncr(tv, dtv->counter_sctp);
 
index 41051fe4fd02b150ca604fa94810fa75033f9301..6585608aaa5455bd51c7e78d46b1a32297035e3d 100644 (file)
@@ -37,7 +37,7 @@
 #include "util-debug.h"
 
 int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     StatsIncr(tv, dtv->counter_sll);
 
@@ -58,18 +58,18 @@ int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                 return TM_ECODE_FAILED;
             }
             DecodeIPV4(tv, dtv, p, pkt + SLL_HEADER_LEN,
-                       len - SLL_HEADER_LEN, pq);
+                       len - SLL_HEADER_LEN);
             break;
         case ETHERNET_TYPE_IPV6:
             if (unlikely(len > SLL_HEADER_LEN + USHRT_MAX)) {
                 return TM_ECODE_FAILED;
             }
             DecodeIPV6(tv, dtv, p, pkt + SLL_HEADER_LEN,
-                       len - SLL_HEADER_LEN, pq);
+                       len - SLL_HEADER_LEN);
             break;
         case ETHERNET_TYPE_VLAN:
             DecodeVLAN(tv, dtv, p, pkt + SLL_HEADER_LEN,
-                                 len - SLL_HEADER_LEN, pq);
+                                 len - SLL_HEADER_LEN);
             break;
         default:
             SCLogDebug("p %p pkt %p sll type %04x not supported", p,
index e3824d33515892bbc27fda4ef1904410a09ee14e..b4aeb0e4bf84287d77f4ffdbaf02e16b89398263 100644 (file)
@@ -232,7 +232,7 @@ static int DecodeTCPPacket(ThreadVars *tv, Packet *p, const uint8_t *pkt, uint16
 }
 
 int DecodeTCP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     StatsIncr(tv, dtv->counter_tcp);
 
@@ -372,7 +372,7 @@ static int TCPGetWscaleTest01(void)
 
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp), NULL);
+    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp));
 
     if (p->tcph == NULL) {
         printf("tcp packet decode failed: ");
@@ -418,7 +418,7 @@ static int TCPGetWscaleTest02(void)
     p->ip4h = &ip4h;
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp), NULL);
+    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp));
 
     if (p->tcph == NULL) {
         printf("tcp packet decode failed: ");
@@ -463,7 +463,7 @@ static int TCPGetWscaleTest03(void)
     p->ip4h = &ip4h;
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp), NULL);
+    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp));
 
     if (p->tcph == NULL) {
         printf("tcp packet decode failed: ");
@@ -512,7 +512,7 @@ static int TCPGetSackTest01(void)
     p->ip4h = &ip4h;
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp), NULL);
+    DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp));
 
     if (p->tcph == NULL) {
         printf("tcp packet decode failed: ");
index f2331066956e989a0e5a3c41f20e858fee4f0d26..f47c736929b3bb273386458be4d903ece838d6db 100644 (file)
@@ -47,7 +47,7 @@
  */
 
 int DecodeTEMPLATE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-                   const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+                   const uint8_t *pkt, uint32_t len)
 {
     /* TODO add counter for your type of packet to DecodeThreadVars,
      * and register it in DecodeRegisterPerfCounters */
@@ -82,7 +82,7 @@ int DecodeTEMPLATE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
          */
 
         /* invoke the next decoder on the remainder of the data */
-        return DecodeUDP(tv, dtv, p, (uint8_t *)pkt + hdr_len, len - hdr_len, pq);
+        return DecodeUDP(tv, dtv, p, (uint8_t *)pkt + hdr_len, len - hdr_len);
     } else {
         //ENGINE_SET_EVENT(p,TEMPLATE_UNSUPPORTED_PROTOCOL);
         return TM_ECODE_FAILED;
index cb9602c85e6f2644e5bd8492badead30fc1b4371..93e9711c5198dc0bb87ae3423c7ef6537904cd9a 100644 (file)
@@ -61,7 +61,7 @@ void DecodeTeredoConfig(void)
  * \retval TM_ECODE_FAILED if packet is not a Teredo packet, TM_ECODE_OK if it is
  */
 int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     if (!g_teredo_enabled)
         return TM_ECODE_FAILED;
@@ -120,18 +120,16 @@ int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 
         if (len ==  IPV6_HEADER_LEN +
                 IPV6_GET_RAW_PLEN(thdr) + (start - pkt)) {
-            if (pq != NULL) {
-                int blen = len - (start - pkt);
-                /* spawn off tunnel packet */
-                Packet *tp = PacketTunnelPktSetup(tv, dtv, p, start, blen,
-                                                  DECODE_TUNNEL_IPV6_TEREDO, pq);
-                if (tp != NULL) {
-                    PKT_SET_SRC(tp, PKT_SRC_DECODER_TEREDO);
-                    /* add the tp to the packet queue. */
-                    PacketEnqueue(pq,tp);
-                    StatsIncr(tv, dtv->counter_teredo);
-                    return TM_ECODE_OK;
-                }
+            int blen = len - (start - pkt);
+            /* spawn off tunnel packet */
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, start, blen,
+                    DECODE_TUNNEL_IPV6_TEREDO);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_TEREDO);
+                /* add the tp to the packet queue. */
+                PacketEnqueueNoLock(&tv->decode_pq,tp);
+                StatsIncr(tv, dtv->counter_teredo);
+                return TM_ECODE_OK;
             }
         }
         return TM_ECODE_FAILED;
index 10e596d5cd8595454dd31731ae8eae5d4156d41b..1c414f19bfb7d9c9b6f559e52dfaf12aa82881ca 100644 (file)
@@ -19,7 +19,7 @@
 #define __DECODE_TEREDO_H__
 
 int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-                 const uint8_t *pkt, uint16_t len, PacketQueue *pq);
+                 const uint8_t *pkt, uint16_t len);
 void DecodeTeredoConfig(void);
 
 #endif
index 551f8298f51ddcd8d9e78ab776303fb3c090b510..225a15daa7577fb24de9f96a5e4db763ba8fd5a3 100644 (file)
@@ -72,7 +72,7 @@ static int DecodeUDPPacket(ThreadVars *t, Packet *p, const uint8_t *pkt, uint16_
 }
 
 int DecodeUDP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     StatsIncr(tv, dtv->counter_udp);
 
@@ -84,7 +84,7 @@ int DecodeUDP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
     SCLogDebug("UDP sp: %" PRIu32 " -> dp: %" PRIu32 " - HLEN: %" PRIu32 " LEN: %" PRIu32 "",
         UDP_GET_SRC_PORT(p), UDP_GET_DST_PORT(p), UDP_HEADER_LEN, p->payload_len);
 
-    if (unlikely(DecodeTeredo(tv, dtv, p, p->payload, p->payload_len, pq) == TM_ECODE_OK)) {
+    if (unlikely(DecodeTeredo(tv, dtv, p, p->payload, p->payload_len) == TM_ECODE_OK)) {
         /* Here we have a Teredo packet and don't need to handle app
          * layer */
         FlowSetupPacket(p);
@@ -93,7 +93,7 @@ int DecodeUDP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 
     /* Handle VXLAN if configured */
     if (DecodeVXLANEnabledForPort(p->sp, p->dp) &&
-            unlikely(DecodeVXLAN(tv, dtv, p, p->payload, p->payload_len, pq) == TM_ECODE_OK)) {
+            unlikely(DecodeVXLAN(tv, dtv, p, p->payload, p->payload_len) == TM_ECODE_OK)) {
         /* Here we have a VXLAN packet and don't need to handle app
          * layer */
         FlowSetupPacket(p);
index 979014bc9b67fa575e78c164ed79423037e5d1b2..49f228a8ab28ea417da426aee3fdf718e656bcbb 100644 (file)
@@ -45,7 +45,7 @@
 #include "host.h"
 
 static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq);
+        const uint8_t *pkt, uint16_t len);
 
 /**
  * \internal
@@ -60,7 +60,7 @@ static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
  *
  */
 int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     uint32_t proto;
 
@@ -97,22 +97,22 @@ int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
             }
 
             DecodeIPV4(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                       len - VLAN_HEADER_LEN, pq);
+                       len - VLAN_HEADER_LEN);
             break;
         case ETHERNET_TYPE_IPV6:
             if (unlikely(len > VLAN_HEADER_LEN + USHRT_MAX)) {
                 return TM_ECODE_FAILED;
             }
             DecodeIPV6(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                       len - VLAN_HEADER_LEN, pq);
+                       len - VLAN_HEADER_LEN);
             break;
         case ETHERNET_TYPE_PPPOE_SESS:
             DecodePPPOESession(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                               len - VLAN_HEADER_LEN, pq);
+                               len - VLAN_HEADER_LEN);
             break;
         case ETHERNET_TYPE_PPPOE_DISC:
             DecodePPPOEDiscovery(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                                 len - VLAN_HEADER_LEN, pq);
+                                 len - VLAN_HEADER_LEN);
             break;
         case ETHERNET_TYPE_VLAN:
         case ETHERNET_TYPE_8021AD:
@@ -121,19 +121,19 @@ int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
                 return TM_ECODE_OK;
             } else {
                 DecodeVLAN(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                        len - VLAN_HEADER_LEN, pq);
+                        len - VLAN_HEADER_LEN);
             }
             break;
         case ETHERNET_TYPE_8021AH:
             DecodeIEEE8021ah(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                    len - VLAN_HEADER_LEN, pq);
+                    len - VLAN_HEADER_LEN);
             break;
         case ETHERNET_TYPE_ARP:
             break;
         case ETHERNET_TYPE_MPLS_UNICAST:
         case ETHERNET_TYPE_MPLS_MULTICAST:
             DecodeMPLS(tv, dtv, p, pkt + VLAN_HEADER_LEN,
-                       len - VLAN_HEADER_LEN, pq);
+                       len - VLAN_HEADER_LEN);
             break;
         default:
             SCLogDebug("unknown VLAN type: %" PRIx32 "", proto);
@@ -164,7 +164,7 @@ typedef struct IEEE8021ahHdr_ {
 #define IEEE8021AH_HEADER_LEN sizeof(IEEE8021ahHdr)
 
 static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint16_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint16_t len)
 {
     StatsIncr(tv, dtv->counter_ieee8021ah);
 
@@ -180,7 +180,7 @@ static int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         case ETHERNET_TYPE_VLAN:
         case ETHERNET_TYPE_8021QINQ: {
             DecodeVLAN(tv, dtv, p, pkt + IEEE8021AH_HEADER_LEN,
-                    len - IEEE8021AH_HEADER_LEN, pq);
+                    len - IEEE8021AH_HEADER_LEN);
             break;
         }
     }
@@ -210,7 +210,7 @@ static int DecodeVLANtest01 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan), NULL);
+    DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan));
 
     if(ENGINE_ISSET_EVENT(p,VLAN_HEADER_TOO_SMALL))  {
         SCFree(p);
@@ -246,7 +246,7 @@ static int DecodeVLANtest02 (void)
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
-    DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan), NULL);
+    DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan));
 
 
     if(ENGINE_ISSET_EVENT(p,VLAN_UNKNOWN_TYPE))  {
@@ -285,7 +285,7 @@ static int DecodeVLANtest03 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan), NULL);
+    DecodeVLAN(&tv, &dtv, p, raw_vlan, sizeof(raw_vlan));
 
 
     if(p->vlan_id[0] == 0) {
index 746d9b979224ff8ae9bcac5e2d7d1f1f8f4daafc..ac4c51c085f252a1da9971cbd2cea2887bfa7b17 100644 (file)
@@ -117,7 +117,7 @@ typedef struct VXLANHeader_ {
  *  \param len length in bytes of pkt
  */
 int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq)
+        const uint8_t *pkt, uint32_t len)
 {
     if (unlikely(!g_vxlan_enabled))
         return TM_ECODE_FAILED;
@@ -147,28 +147,26 @@ int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         case ETHERNET_TYPE_ARP:
             SCLogDebug("VXLAN found ARP");
             break;
-        case ETHERNET_TYPE_IP:
+        case ETHERNET_TYPE_IP: {
             SCLogDebug("VXLAN found IPv4");
-            if (pq != NULL) {
-                Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN,
-                        len - (VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN), DECODE_TUNNEL_IPV4, pq);
-                if (tp != NULL) {
-                    PKT_SET_SRC(tp, PKT_SRC_DECODER_VXLAN);
-                    PacketEnqueue(pq, tp);
-                }
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN,
+                    len - (VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN), DECODE_TUNNEL_IPV4);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_VXLAN);
+                PacketEnqueueNoLock(&tv->decode_pq, tp);
             }
             break;
-        case ETHERNET_TYPE_IPV6:
+        }
+        case ETHERNET_TYPE_IPV6: {
             SCLogDebug("VXLAN found IPv6");
-            if (pq != NULL) {
-                Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN,
-                        len - (VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN), DECODE_TUNNEL_IPV6, pq);
-                if (tp != NULL) {
-                    PKT_SET_SRC(tp, PKT_SRC_DECODER_VXLAN);
-                    PacketEnqueue(pq, tp);
-                }
+            Packet *tp = PacketTunnelPktSetup(tv, dtv, p, pkt + VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN,
+                    len - (VXLAN_HEADER_LEN + ETHERNET_HEADER_LEN), DECODE_TUNNEL_IPV6);
+            if (tp != NULL) {
+                PKT_SET_SRC(tp, PKT_SRC_DECODER_VXLAN);
+                PacketEnqueueNoLock(&tv->decode_pq, tp);
             }
             break;
+        }
         default:
             SCLogDebug("VXLAN found no known Ethertype - only checks for IPv4, IPv6, ARP");
             /* ENGINE_SET_INVALID_EVENT(p, VXLAN_UNKNOWN_PAYLOAD_TYPE);*/
@@ -200,21 +198,19 @@ static int DecodeVXLANtest01 (void)
     FAIL_IF_NULL(p);
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
 
     DecodeVXLANConfigPorts("4789");
 
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeUDP(&tv, &dtv, p, raw_vxlan, sizeof(raw_vxlan), &pq);
+    DecodeUDP(&tv, &dtv, p, raw_vxlan, sizeof(raw_vxlan));
 
     FAIL_IF(p->udph == NULL);
-    FAIL_IF(pq.top == NULL);
-    Packet *tp = PacketDequeue(&pq);
+    FAIL_IF(tv.decode_pq.top == NULL);
+    Packet *tp = PacketDequeueNoLock(&tv.decode_pq);
     FAIL_IF(tp->udph == NULL);
     FAIL_IF_NOT(tp->sp == 53);
 
@@ -243,20 +239,18 @@ static int DecodeVXLANtest02 (void)
     FAIL_IF_NULL(p);
     ThreadVars tv;
     DecodeThreadVars dtv;
-    PacketQueue pq;
 
     DecodeVXLANConfigPorts("1");
 
-    memset(&pq, 0, sizeof(PacketQueue));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(p, 0, SIZE_OF_PACKET);
     memset(&dtv, 0, sizeof(DecodeThreadVars));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeUDP(&tv, &dtv, p, raw_vxlan, sizeof(raw_vxlan), &pq);
+    DecodeUDP(&tv, &dtv, p, raw_vxlan, sizeof(raw_vxlan));
 
     FAIL_IF(p->udph == NULL);
-    FAIL_IF(pq.top != NULL);
+    FAIL_IF(tv.decode_pq.top != NULL);
 
     DecodeVXLANConfigPorts("4789"); /* reset */
     FlowShutdown();
index 9d8aace0a75d544860076661f72ae149cbd0a8d2..6d7439f516001308447d7ca2cfbceab060aab7cf 100644 (file)
@@ -73,22 +73,22 @@ const char *stats_decoder_events_prefix;
 extern bool stats_stream_events;
 
 int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq, enum DecodeTunnelProto proto)
+        const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
 {
     switch (proto) {
         case DECODE_TUNNEL_PPP:
-            return DecodePPP(tv, dtv, p, pkt, len, pq);
+            return DecodePPP(tv, dtv, p, pkt, len);
         case DECODE_TUNNEL_IPV4:
-            return DecodeIPV4(tv, dtv, p, pkt, len, pq);
+            return DecodeIPV4(tv, dtv, p, pkt, len);
         case DECODE_TUNNEL_IPV6:
         case DECODE_TUNNEL_IPV6_TEREDO:
-            return DecodeIPV6(tv, dtv, p, pkt, len, pq);
+            return DecodeIPV6(tv, dtv, p, pkt, len);
         case DECODE_TUNNEL_VLAN:
-            return DecodeVLAN(tv, dtv, p, pkt, len, pq);
+            return DecodeVLAN(tv, dtv, p, pkt, len);
         case DECODE_TUNNEL_ETHERNET:
-            return DecodeEthernet(tv, dtv, p, pkt, len, pq);
+            return DecodeEthernet(tv, dtv, p, pkt, len);
         case DECODE_TUNNEL_ERSPAN:
-            return DecodeERSPAN(tv, dtv, p, pkt, len, pq);
+            return DecodeERSPAN(tv, dtv, p, pkt, len);
         default:
             SCLogDebug("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", proto);
             break;
@@ -273,8 +273,7 @@ inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
  *  \retval p the pseudo packet or NULL if out of memory
  */
 Packet *PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent,
-                             const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto,
-                             PacketQueue *pq)
+                             const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
 {
     int ret;
 
@@ -304,7 +303,7 @@ Packet *PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *pare
     SET_TUNNEL_PKT(p);
 
     ret = DecodeTunnel(tv, dtv, p, GET_PKT_DATA(p),
-                       GET_PKT_LEN(p), pq, proto);
+                       GET_PKT_LEN(p), proto);
 
     if (unlikely(ret != TM_ECODE_OK) ||
             (proto == DECODE_TUNNEL_IPV6_TEREDO && (p->flags & PKT_IS_INVALID)))
index a15c193c862f8f1fdf6459cdb7926b7ad6952e8b..338173df23d40e77bf7bdd0da388d48735c90261 100644 (file)
@@ -618,37 +618,6 @@ extern int g_default_mtu;
 uint32_t default_packet_size;
 #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
 
-/** \brief simple fifo queue for packets
- *
- *  \note PacketQueueNoLock and PacketQueue need to keep identical
- *        layouts except for the mutex_q and cond_q fields.
- */
-typedef struct PacketQueueNoLock_ {
-    Packet *top;
-    Packet *bot;
-    uint32_t len;
-#ifdef DBG_PERF
-    uint32_t dbg_maxlen;
-#endif /* DBG_PERF */
-} PacketQueueNoLock;
-
-/** \brief simple fifo queue for packets with mutex and cond
- *  Calling the mutex or triggering the cond is responsibility of the caller
- *
- *  \note PacketQueueNoLock and PacketQueue need to keep identical
- *        layouts except for the mutex_q and cond_q fields.
- */
-typedef struct PacketQueue_ {
-    Packet *top;
-    Packet *bot;
-    uint32_t len;
-#ifdef DBG_PERF
-    uint32_t dbg_maxlen;
-#endif /* DBG_PERF */
-    SCMutex mutex_q;
-    SCCondT cond_q;
-} PacketQueue;
-
 /** \brief Structure to hold thread specific data for all decode modules */
 typedef struct DecodeThreadVars_
 {
@@ -918,7 +887,7 @@ enum DecodeTunnelProto {
 };
 
 Packet *PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent,
-                             const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto, PacketQueue *pq);
+                             const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto);
 Packet *PacketDefragPktSetup(Packet *parent, const uint8_t *pkt, uint32_t len, uint8_t proto);
 void PacketDefragPktSetupParent(Packet *parent);
 void DecodeRegisterPerfCounters(DecodeThreadVars *, ThreadVars *);
@@ -943,27 +912,27 @@ void DecodeUpdatePacketCounters(ThreadVars *tv,
                                 const DecodeThreadVars *dtv, const Packet *p);
 
 /* decoder functions */
-int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *, enum DecodeTunnelProto) __attribute__ ((warn_unused_result));
-int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
-int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
-int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
-int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
-int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t, PacketQueue *);
-int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
-int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, PacketQueue *);
+int DecodeEthernet(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t, enum DecodeTunnelProto) __attribute__ ((warn_unused_result));
+int DecodeNull(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
+int DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
+int DecodeICMPV4(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeICMPV6(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeTCP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
+int DecodeUDP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
+int DecodeSCTP(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint16_t);
+int DecodeGRE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeVLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeVXLAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeMPLS(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeERSPAN(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
+int DecodeTEMPLATE(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t);
 
 #ifdef UNITTESTS
 void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
@@ -974,12 +943,12 @@ void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
 void AddressDebugPrint(Address *);
 
 typedef int (*DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-         const uint8_t *pkt, uint32_t len, PacketQueue *pq);
+         const uint8_t *pkt, uint32_t len);
 #ifdef AFLFUZZ_DECODER
 int AFLDecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq);
+        const uint8_t *pkt, uint32_t len);
 int AFLDecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len, PacketQueue *pq);
+        const uint8_t *pkt, uint32_t len);
 int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder);
 int DecoderParseDataFromFileSerie(char *fileprefix, DecoderFunc Decoder);
 #endif
index d38843838501a50f1f016438d367f8f23c9f0264..fa66ff611e293a1e7f43560e9e4eb11b7668d2d0 100644 (file)
@@ -532,7 +532,7 @@ int DefragRbFragCompare(struct Frag_ *a, struct Frag_ *b) {
  * \todo Allocate packet buffers from a pool.
  */
 static Packet *
-DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker, Packet *p, PacketQueue *pq)
+DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker, Packet *p)
 {
     Packet *r = NULL;
     int ltrim = 0;
@@ -887,8 +887,8 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker,
             r = Defrag4Reassemble(tv, tracker, p);
             if (r != NULL && tv != NULL && dtv != NULL) {
                 StatsIncr(tv, dtv->counter_defrag_ipv4_reassembled);
-                if (pq && DecodeIPV4(tv, dtv, r, (void *)r->ip4h,
-                               IPV4_GET_IPLEN(r), pq) != TM_ECODE_OK) {
+                if (DecodeIPV4(tv, dtv, r, (void *)r->ip4h,
+                               IPV4_GET_IPLEN(r)) != TM_ECODE_OK) {
 
                     UNSET_TUNNEL_PKT(r);
                     r->root = NULL;
@@ -903,9 +903,9 @@ DefragInsertFrag(ThreadVars *tv, DecodeThreadVars *dtv, DefragTracker *tracker,
             r = Defrag6Reassemble(tv, tracker, p);
             if (r != NULL && tv != NULL && dtv != NULL) {
                 StatsIncr(tv, dtv->counter_defrag_ipv6_reassembled);
-                if (pq && DecodeIPV6(tv, dtv, r, (uint8_t *)r->ip6h,
-                               IPV6_GET_PLEN(r) + IPV6_HEADER_LEN,
-                               pq) != TM_ECODE_OK) {
+                if (DecodeIPV6(tv, dtv, r, (uint8_t *)r->ip6h,
+                               IPV6_GET_PLEN(r) + IPV6_HEADER_LEN)
+                               != TM_ECODE_OK) {
 
                     UNSET_TUNNEL_PKT(r);
                     r->root = NULL;
@@ -1019,7 +1019,7 @@ DefragGetTracker(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
  *     NULL is returned.
  */
 Packet *
-Defrag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, PacketQueue *pq)
+Defrag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
 {
     uint16_t frag_offset;
     uint8_t more_frags;
@@ -1058,7 +1058,7 @@ Defrag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, PacketQueue *pq)
     if (tracker == NULL)
         return NULL;
 
-    Packet *rp = DefragInsertFrag(tv, dtv, tracker, p, pq);
+    Packet *rp = DefragInsertFrag(tv, dtv, tracker, p);
     DefragTrackerRelease(tracker);
 
     return rp;
@@ -1263,10 +1263,10 @@ static int DefragInOrderSimpleTest(void)
     p3 = BuildTestPacket(IPPROTO_ICMP, id, 2, 0, 'C', 3);
     FAIL_IF_NULL(p3);
 
-    FAIL_IF(Defrag(NULL, NULL, p1, NULL) != NULL);
-    FAIL_IF(Defrag(NULL, NULL, p2, NULL) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p1) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p2) != NULL);
 
-    reassembled = Defrag(NULL, NULL, p3, NULL);
+    reassembled = Defrag(NULL, NULL, p3);
     FAIL_IF_NULL(reassembled);
 
     FAIL_IF(IPV4_GET_HLEN(reassembled) != 20);
@@ -1315,10 +1315,10 @@ static int DefragReverseSimpleTest(void)
     p3 = BuildTestPacket(IPPROTO_ICMP, id, 2, 0, 'C', 3);
     FAIL_IF_NULL(p3);
 
-    FAIL_IF(Defrag(NULL, NULL, p3, NULL) != NULL);
-    FAIL_IF(Defrag(NULL, NULL, p2, NULL) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p3) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p2) != NULL);
 
-    reassembled = Defrag(NULL, NULL, p1, NULL);
+    reassembled = Defrag(NULL, NULL, p1);
     FAIL_IF_NULL(reassembled);
 
     FAIL_IF(IPV4_GET_HLEN(reassembled) != 20);
@@ -1368,9 +1368,9 @@ static int IPV6DefragInOrderSimpleTest(void)
     p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 2, 0, 'C', 3);
     FAIL_IF_NULL(p3);
 
-    FAIL_IF(Defrag(NULL, NULL, p1, NULL) != NULL);
-    FAIL_IF(Defrag(NULL, NULL, p2, NULL) != NULL);
-    reassembled = Defrag(NULL, NULL, p3, NULL);
+    FAIL_IF(Defrag(NULL, NULL, p1) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p2) != NULL);
+    reassembled = Defrag(NULL, NULL, p3);
     FAIL_IF_NULL(reassembled);
 
     FAIL_IF(IPV6_GET_PLEN(reassembled) != 19);
@@ -1419,9 +1419,9 @@ static int IPV6DefragReverseSimpleTest(void)
     p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, id, 2, 0, 'C', 3);
     FAIL_IF_NULL(p3);
 
-    FAIL_IF(Defrag(NULL, NULL, p3, NULL) != NULL);
-    FAIL_IF(Defrag(NULL, NULL, p2, NULL) != NULL);
-    reassembled = Defrag(NULL, NULL, p1, NULL);
+    FAIL_IF(Defrag(NULL, NULL, p3) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p2) != NULL);
+    reassembled = Defrag(NULL, NULL, p1);
     FAIL_IF_NULL(reassembled);
 
     /* 40 bytes in we should find 8 bytes of A. */
@@ -1527,13 +1527,13 @@ static int DefragDoSturgesNovakTest(int policy, u_char *expected,
 
     /* Send all but the last. */
     for (i = 0; i < 9; i++) {
-        Packet *tp = Defrag(NULL, NULL, packets[i], NULL);
+        Packet *tp = Defrag(NULL, NULL, packets[i]);
         FAIL_IF_NOT_NULL(tp);
         FAIL_IF(ENGINE_ISSET_EVENT(packets[i], IPV4_FRAG_OVERLAP));
     }
     int overlap = 0;
     for (; i < 16; i++) {
-        Packet *tp = Defrag(NULL, NULL, packets[i], NULL);
+        Packet *tp = Defrag(NULL, NULL, packets[i]);
         FAIL_IF_NOT_NULL(tp);
         if (ENGINE_ISSET_EVENT(packets[i], IPV4_FRAG_OVERLAP)) {
             overlap++;
@@ -1542,7 +1542,7 @@ static int DefragDoSturgesNovakTest(int policy, u_char *expected,
     FAIL_IF_NOT(overlap);
 
     /* And now the last one. */
-    Packet *reassembled = Defrag(NULL, NULL, packets[16], NULL);
+    Packet *reassembled = Defrag(NULL, NULL, packets[16]);
     FAIL_IF_NULL(reassembled);
 
     FAIL_IF(IPV4_GET_HLEN(reassembled) != 20);
@@ -1639,13 +1639,13 @@ static int IPV6DefragDoSturgesNovakTest(int policy, u_char *expected,
 
     /* Send all but the last. */
     for (i = 0; i < 9; i++) {
-        Packet *tp = Defrag(NULL, NULL, packets[i], NULL);
+        Packet *tp = Defrag(NULL, NULL, packets[i]);
         FAIL_IF_NOT_NULL(tp);
         FAIL_IF(ENGINE_ISSET_EVENT(packets[i], IPV6_FRAG_OVERLAP));
     }
     int overlap = 0;
     for (; i < 16; i++) {
-        Packet *tp = Defrag(NULL, NULL, packets[i], NULL);
+        Packet *tp = Defrag(NULL, NULL, packets[i]);
         FAIL_IF_NOT_NULL(tp);
         if (ENGINE_ISSET_EVENT(packets[i], IPV6_FRAG_OVERLAP)) {
             overlap++;
@@ -1654,7 +1654,7 @@ static int IPV6DefragDoSturgesNovakTest(int policy, u_char *expected,
     FAIL_IF_NOT(overlap);
 
     /* And now the last one. */
-    Packet *reassembled = Defrag(NULL, NULL, packets[16], NULL);
+    Packet *reassembled = Defrag(NULL, NULL, packets[16]);
     FAIL_IF_NULL(reassembled);
     FAIL_IF(memcmp(GET_PKT_DATA(reassembled) + 40, expected, expected_len) != 0);
 
@@ -2107,7 +2107,7 @@ static int DefragTimeoutTest(void)
         Packet *p = BuildTestPacket(IPPROTO_ICMP,i, 0, 1, 'A' + i, 16);
         FAIL_IF_NULL(p);
 
-        Packet *tp = Defrag(NULL, NULL, p, NULL);
+        Packet *tp = Defrag(NULL, NULL, p);
         SCFree(p);
         FAIL_IF_NOT_NULL(tp);
     }
@@ -2118,7 +2118,7 @@ static int DefragTimeoutTest(void)
     FAIL_IF_NULL(p);
 
     p->ts.tv_sec += (defrag_context->timeout + 1);
-    Packet *tp = Defrag(NULL, NULL, p, NULL);
+    Packet *tp = Defrag(NULL, NULL, p);
     FAIL_IF_NOT_NULL(tp);
 
     DefragTracker *tracker = DefragLookupTrackerFromHash(p);
@@ -2154,7 +2154,7 @@ static int DefragIPv4NoDataTest(void)
     FAIL_IF_NULL(p);
 
     /* We do not expect a packet returned. */
-    FAIL_IF(Defrag(NULL, NULL, p, NULL) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p) != NULL);
 
     /* The fragment should have been ignored so no fragments should
      * have been allocated from the pool. */
@@ -2183,7 +2183,7 @@ static int DefragIPv4TooLargeTest(void)
     FAIL_IF_NULL(p);
 
     /* We do not expect a packet returned. */
-    FAIL_IF(Defrag(NULL, NULL, p, NULL) != NULL);
+    FAIL_IF(Defrag(NULL, NULL, p) != NULL);
 
     /* We do expect an event. */
     FAIL_IF_NOT(ENGINE_ISSET_EVENT(p, IPV4_FRAG_PKT_TOO_LARGE));
@@ -2216,15 +2216,15 @@ static int DefragVlanTest(void)
     FAIL_IF_NULL(p2);
 
     /* With no VLAN IDs set, packets should re-assemble. */
-    FAIL_IF((r = Defrag(NULL, NULL, p1, NULL)) != NULL);
-    FAIL_IF((r = Defrag(NULL, NULL, p2, NULL)) == NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p1)) != NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p2)) == NULL);
     SCFree(r);
 
     /* With mismatched VLANs, packets should not re-assemble. */
     p1->vlan_id[0] = 1;
     p2->vlan_id[0] = 2;
-    FAIL_IF((r = Defrag(NULL, NULL, p1, NULL)) != NULL);
-    FAIL_IF((r = Defrag(NULL, NULL, p2, NULL)) != NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p1)) != NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p2)) != NULL);
 
     SCFree(p1);
     SCFree(p2);
@@ -2248,8 +2248,8 @@ static int DefragVlanQinQTest(void)
     FAIL_IF_NULL(p2);
 
     /* With no VLAN IDs set, packets should re-assemble. */
-    FAIL_IF((r = Defrag(NULL, NULL, p1, NULL)) != NULL);
-    FAIL_IF((r = Defrag(NULL, NULL, p2, NULL)) == NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p1)) != NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p2)) == NULL);
     SCFree(r);
 
     /* With mismatched VLANs, packets should not re-assemble. */
@@ -2257,8 +2257,8 @@ static int DefragVlanQinQTest(void)
     p2->vlan_id[0] = 1;
     p1->vlan_id[1] = 1;
     p2->vlan_id[1] = 2;
-    FAIL_IF((r = Defrag(NULL, NULL, p1, NULL)) != NULL);
-    FAIL_IF((r = Defrag(NULL, NULL, p2, NULL)) != NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p1)) != NULL);
+    FAIL_IF((r = Defrag(NULL, NULL, p2)) != NULL);
 
     SCFree(p1);
     SCFree(p2);
@@ -2329,14 +2329,14 @@ static int DefragMfIpv4Test(void)
     Packet *p3 = BuildTestPacket(IPPROTO_ICMP, ip_id, 1, 0, 'B', 8);
     FAIL_IF(p1 == NULL || p2 == NULL || p3 == NULL);
 
-    p = Defrag(NULL, NULL, p1, NULL);
+    p = Defrag(NULL, NULL, p1);
     FAIL_IF_NOT_NULL(p);
 
-    p = Defrag(NULL, NULL, p2, NULL);
+    p = Defrag(NULL, NULL, p2);
     FAIL_IF_NOT_NULL(p);
 
     /* This should return a packet as MF=0. */
-    p = Defrag(NULL, NULL, p3, NULL);
+    p = Defrag(NULL, NULL, p3);
     FAIL_IF_NULL(p);
 
     /* Expected IP length is 20 + 8 + 8 = 36 as only 2 of the
@@ -2372,14 +2372,14 @@ static int DefragMfIpv6Test(void)
     Packet *p3 = IPV6BuildTestPacket(IPPROTO_ICMPV6, ip_id, 1, 0, 'B', 8);
     FAIL_IF(p1 == NULL || p2 == NULL || p3 == NULL);
 
-    p = Defrag(NULL, NULL, p1, NULL);
+    p = Defrag(NULL, NULL, p1);
     FAIL_IF_NOT_NULL(p);
 
-    p = Defrag(NULL, NULL, p2, NULL);
+    p = Defrag(NULL, NULL, p2);
     FAIL_IF_NOT_NULL(p);
 
     /* This should return a packet as MF=0. */
-    p = Defrag(NULL, NULL, p3, NULL);
+    p = Defrag(NULL, NULL, p3);
     FAIL_IF_NULL(p);
 
     /* For IPv6 the expected length is just the length of the payload
@@ -2412,9 +2412,9 @@ static int DefragTestBadProto(void)
     p3 = BuildTestPacket(IPPROTO_ICMP, id, 2, 0, 'C', 3);
     FAIL_IF_NULL(p3);
 
-    FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p1, NULL));
-    FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p2, NULL));
-    FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p3, NULL));
+    FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p1));
+    FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p2));
+    FAIL_IF_NOT_NULL(Defrag(NULL, NULL, p3));
 
     SCFree(p1);
     SCFree(p2);
@@ -2456,16 +2456,16 @@ static int DefragTestJeremyLinux(void)
     packets[2] = BuildTestPacket(IPPROTO_ICMP, id, 24 >> 3, 1, 'C', 48);
     packets[3] = BuildTestPacket(IPPROTO_ICMP, id, 88 >> 3, 0, 'D', 14);
 
-    Packet *r = Defrag(NULL, NULL, packets[0], NULL);
+    Packet *r = Defrag(NULL, NULL, packets[0]);
     FAIL_IF_NOT_NULL(r);
 
-    r = Defrag(NULL, NULL, packets[1], NULL);
+    r = Defrag(NULL, NULL, packets[1]);
     FAIL_IF_NOT_NULL(r);
 
-    r = Defrag(NULL, NULL, packets[2], NULL);
+    r = Defrag(NULL, NULL, packets[2]);
     FAIL_IF_NOT_NULL(r);
 
-    r = Defrag(NULL, NULL, packets[3], NULL);
+    r = Defrag(NULL, NULL, packets[3]);
     FAIL_IF_NULL(r);
 
     FAIL_IF(memcmp(expected, GET_PKT_DATA(r) + 20, sizeof(expected)) != 0);
index e8869b95de80cc9441137661deb7ec1e35580925..771616e4ddaff22296ac90b8a68f75d93ff23c7d 100644 (file)
@@ -127,7 +127,7 @@ void DefragReload(void); /**< use only in unittests */
 
 uint8_t DefragGetOsPolicy(Packet *);
 void DefragTrackerFreeFrags(DefragTracker *);
-Packet *Defrag(ThreadVars *, DecodeThreadVars *, Packet *, PacketQueue *);
+Packet *Defrag(ThreadVars *, DecodeThreadVars *, Packet *);
 void DefragRegisterTests(void);
 
 #endif /* __DEFRAG_H__ */
index 79cff1dfa95fa66e6417f7db90ea9c332b1ed80d..aea8776b63fd2226201d3fb102a5ec34f5cca05f 100644 (file)
@@ -987,7 +987,7 @@ static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pkts
     memset(&th_v, 0, sizeof(th_v));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, raw_eth_pkt, pktsize, NULL);
+    DecodeEthernet(&th_v, &dtv, p, raw_eth_pkt, pktsize);
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL) {
index 5e36f54ce5d9179ceb9f5c25e688119a01b9adc2..95e40df00bdbc674828ea1c9048697e34bf4e7b4 100644 (file)
@@ -1038,7 +1038,7 @@ static int DetectCsumICMPV6Test01(void)
     FAIL_IF_NULL(s);
     SigGroupBuild(de_ctx);
 
-    DecodeEthernet(&tv, &dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), NULL);
+    DecodeEthernet(&tv, &dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
     DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
 
index c92adfc7ad02fa2f4098fbac9d88cd91f31f0b89..7f6deb216682d177358e0e276b16c08c854f8a74 100644 (file)
@@ -907,7 +907,7 @@ static int DetectDsizeIcmpv6Test01 (void)
     p->dst.family = AF_INET6;
     p->ip6h = &ip6h;
 
-    DecodeIPV6(&tv, &dtv, p, raw_icmpv6, sizeof(raw_icmpv6), NULL);
+    DecodeIPV6(&tv, &dtv, p, raw_icmpv6, sizeof(raw_icmpv6));
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL) {
index 06e5efc375fb6870e2c6b345627aac955ef6f244..6b600d412bb7a631f89b75a6848379577ebd3f9e 100644 (file)
@@ -484,7 +484,7 @@ static int FragBitsTestParse03 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth));
 
     de = DetectFragBitsParse("D");
 
@@ -571,7 +571,7 @@ static int FragBitsTestParse04 (void)
 
     FlowInitConfig(FLOW_QUIET);
 
-    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth));
 
 
     de = DetectFragBitsParse("!D");
index 7faaa8d2e42d96bfcbaa2d628ea0e4422f9e97f3..da9cb3016afc1af24cd5e86df4b581eafbfb27d9 100644 (file)
@@ -498,7 +498,7 @@ static int DetectIcmpIdMatchTest02 (void)
     ip4h.s_ip_dst.s_addr = p->dst.addr_data32[0];
     p->ip4h = &ip4h;
 
-    DecodeICMPV4(&th_v, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4), NULL);
+    DecodeICMPV4(&th_v, &dtv, p, raw_icmpv4, sizeof(raw_icmpv4));
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL) {
index f641f4520d519a811d2efbc5a3782c5a2deffd76..4c23e6ec480da50acc0fecd22cce5c680cad2199 100644 (file)
@@ -1927,7 +1927,7 @@ static int DetectIPProtoTestSig2(void)
     memset(&th_v, 0, sizeof(th_v));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth));
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL) {
@@ -2012,7 +2012,7 @@ static int DetectIPProtoTestSig3(void)
     memset(&th_v, 0, sizeof(th_v));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth));
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL) {
index 544b204ac26b16741edd1ff289240099e281bc6c..f73ba76cec8894cc7f71d94cdc8aa3d075ad8961 100644 (file)
@@ -3574,7 +3574,7 @@ static int SigTestBidirec04 (void)
     memset(p, 0, SIZE_OF_PACKET);
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, rawpkt1_ether, sizeof(rawpkt1_ether), NULL);
+    DecodeEthernet(&th_v, &dtv, p, rawpkt1_ether, sizeof(rawpkt1_ether));
     DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
 
     /* At this point we have a list of 4 signatures. The last one
index d348a4b996d4934d15787ecb7a20b13d958372e9..bb092218308249f623f98e2f7dd7a2b0ca080ee4 100644 (file)
@@ -270,7 +270,7 @@ int DetectReplaceLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize,
     dtv.app_tctx = AppLayerGetCtxThread(&th_v);
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, GET_PKT_DATA(p), pktsize, NULL);
+    DecodeEthernet(&th_v, &dtv, p, GET_PKT_DATA(p), pktsize);
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
     if (de_ctx == NULL) {
index 3373aa37244480064f6b5fb0b4936e4142471171..d857532507d27d726518bcbfcd8de5f6d225e609 100644 (file)
@@ -189,7 +189,7 @@ static void FlowPruneFiles(Packet *p)
     }
 }
 
-static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data, PacketQueue *preq)
+static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data)
 {
     FlowWorkerThreadData *fw = data;
     void *detect_thread = SC_ATOMIC_GET(fw->detect_thread);
@@ -266,7 +266,7 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data, PacketQueue *pr
 
             /* put these packets in the preq queue so that they are
              * by the other thread modules before packet 'p'. */
-            PacketEnqueue(preq, x);
+            PacketEnqueueNoLock(&tv->decode_pq, x);
         }
 
     /* handle the app layer part of the UDP packet payload */
index 77a0d87ef24e097721d74e244e48b893dff89d67..8d11f4a3f49c05e0ef88a9ffe8f1ff9fb0eeb8c5 100644 (file)
 #ifndef __PACKET_QUEUE_H__
 #define __PACKET_QUEUE_H__
 
-#include "threads.h"
+/** \brief simple fifo queue for packets
+ *
+ *  \note PacketQueueNoLock and PacketQueue need to keep identical
+ *        layouts except for the mutex_q and cond_q fields.
+ */
+typedef struct PacketQueueNoLock_ {
+    struct Packet_ *top;
+    struct Packet_ *bot;
+    uint32_t len;
+#ifdef DBG_PERF
+    uint32_t dbg_maxlen;
+#endif /* DBG_PERF */
+} PacketQueueNoLock;
+
+/** \brief simple fifo queue for packets with mutex and cond
+ *  Calling the mutex or triggering the cond is responsibility of the caller
+ *
+ *  \note PacketQueueNoLock and PacketQueue need to keep identical
+ *        layouts except for the mutex_q and cond_q fields.
+ */
+typedef struct PacketQueue_ {
+    struct Packet_ *top;
+    struct Packet_ *bot;
+    uint32_t len;
+#ifdef DBG_PERF
+    uint32_t dbg_maxlen;
+#endif /* DBG_PERF */
+    SCMutex mutex_q;
+    SCCondT cond_q;
+} PacketQueue;
+
 #include "decode.h"
 
-void PacketEnqueueNoLock(PacketQueueNoLock *qnl, Packet *p);
-void PacketEnqueue (PacketQueue *, Packet *);
+void PacketEnqueueNoLock(PacketQueueNoLock *qnl, struct Packet_ *p);
+void PacketEnqueue (PacketQueue *, struct Packet_ *);
 
-Packet *PacketDequeueNoLock (PacketQueueNoLock *qnl);
-Packet *PacketDequeue (PacketQueue *);
+struct Packet_ *PacketDequeueNoLock (PacketQueueNoLock *qnl);
+struct Packet_ *PacketDequeue (PacketQueue *);
 
 #endif /* __PACKET_QUEUE_H__ */
 
index 9fb579595929ef87085fb56612c21d8ddf8fd2a3..84fcd0203a7d7ba834200c2be0ac09e70dbd28d1 100644 (file)
@@ -45,7 +45,7 @@ int RejectSendIPv4TCP(ThreadVars *, Packet *, void *);
 int RejectSendIPv4ICMP(ThreadVars *, Packet *, void *);
 int RejectSendIPv6TCP(ThreadVars *, Packet *, void *);
 int RejectSendIPv6ICMP(ThreadVars *, Packet *, void *);
-static TmEcode RespondRejectFunc(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq);
+static TmEcode RespondRejectFunc(ThreadVars *tv, Packet *p, void *data);
 
 void TmModuleRespondRejectRegister (void)
 {
@@ -57,7 +57,7 @@ void TmModuleRespondRejectRegister (void)
     tmm_modules[TMM_RESPONDREJECT].cap_flags = 0; /* libnet is not compat with caps */
 }
 
-static TmEcode RespondRejectFunc(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+static TmEcode RespondRejectFunc(ThreadVars *tv, Packet *p, void *data)
 {
     int ret = 0;
 
index c2a55099d2678201fd66424a4df31e807a993f1b..f327261597be7ae144362200c401f44a0432a1d9 100644 (file)
@@ -310,7 +310,7 @@ static TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot);
 
 static TmEcode DecodeAFPThreadInit(ThreadVars *, const void *, void **);
 static TmEcode DecodeAFPThreadDeinit(ThreadVars *tv, void *data);
-static TmEcode DecodeAFP(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode DecodeAFP(ThreadVars *, Packet *, void *);
 
 static TmEcode AFPSetBPFFilter(AFPThreadVars *ptv);
 static int AFPGetIfnumByDev(int fd, const char *ifname, int verbose);
@@ -2875,15 +2875,14 @@ TmEcode ReceiveAFPThreadDeinit(ThreadVars *tv, void *data)
 /**
  * \brief This function passes off to link type decoders.
  *
- * DecodeAFP reads packets from the PacketQueue and passes
+ * DecodeAFP decodes packets from AF_PACKET and passes
  * them off to the proper link type decoder.
  *
  * \param t pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into AFPThreadVars for ptv
- * \param pq pointer to the current PacketQueue
  */
-TmEcode DecodeAFP(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode DecodeAFP(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
     DecodeThreadVars *dtv = (DecodeThreadVars *)data;
@@ -2904,20 +2903,20 @@ TmEcode DecodeAFP(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
     /* call the decoder */
     switch (p->datalink) {
         case LINKTYPE_ETHERNET:
-            DecodeEthernet(tv, dtv, p,GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeEthernet(tv, dtv, p,GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_LINUX_SLL:
-            DecodeSll(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeSll(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_PPP:
-            DecodePPP(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodePPP(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_RAW:
         case LINKTYPE_GRE_OVER_IP:
-            DecodeRaw(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeRaw(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_NULL:
-            DecodeNull(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeNull(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         default:
             SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED, "Error: datalink type %" PRId32 " not yet supported in module DecodeAFP", p->datalink);
index c7788e7af4b4e88d86ca75e8c2fb3ba6d3b8c404..554de64e1e46c00117d302e72096981b5ea83a81 100644 (file)
@@ -124,8 +124,7 @@ void ReceiveErfDagThreadExitStats(ThreadVars *, void *);
 TmEcode ReceiveErfDagThreadDeinit(ThreadVars *, void *);
 TmEcode DecodeErfDagThreadInit(ThreadVars *, void *, void **);
 TmEcode DecodeErfDagThreadDeinit(ThreadVars *tv, void *data);
-TmEcode DecodeErfDag(ThreadVars *, Packet *, void *, PacketQueue *,
-    PacketQueue *);
+TmEcode DecodeErfDag(ThreadVars *, Packet *, void *);
 void ReceiveErfDagCloseStream(int dagfd, int stream);
 
 /**
@@ -600,16 +599,15 @@ ReceiveErfDagCloseStream(int dagfd, int stream)
 /**
  * \brief   This function passes off to link type decoders.
  *
- * DecodeErfDag reads packets from the PacketQueue and passes
+ * DecodeErfDag decodes packets from DAG and passes
  * them off to the proper link type decoder.
  *
  * \param t pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into PcapThreadVars for ptv
- * \param pq pointer to the current PacketQueue
  */
 TmEcode
-DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+DecodeErfDag(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
     DecodeThreadVars *dtv = (DecodeThreadVars *)data;
@@ -625,7 +623,7 @@ DecodeErfDag(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
         /* call the decoder */
     switch(p->datalink) {
         case LINKTYPE_ETHERNET:
-            DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         default:
             SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED,
index 85dd452b44f904a5cded5a02a0da5cc80108f29a..bab7b2652fc7282511e8fbecdd3ca93c175e0c39 100644 (file)
@@ -70,7 +70,7 @@ TmEcode ReceiveErfFileThreadDeinit(ThreadVars *, void *);
 
 static TmEcode DecodeErfFileThreadInit(ThreadVars *, const void *, void **);
 static TmEcode DecodeErfFileThreadDeinit(ThreadVars *tv, void *data);
-static TmEcode DecodeErfFile(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode DecodeErfFile(ThreadVars *, Packet *, void *);
 
 /**
  * \brief Register the ERF file receiver (reader) module.
@@ -275,7 +275,7 @@ TmEcode DecodeErfFileThreadDeinit(ThreadVars *tv, void *data)
  * off to the ethernet decoder.
  */
 TmEcode
-DecodeErfFile(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+DecodeErfFile(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
     DecodeThreadVars *dtv = (DecodeThreadVars *)data;
@@ -288,7 +288,7 @@ DecodeErfFile(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
     /* Update counters. */
     DecodeUpdatePacketCounters(tv, dtv, p);
 
-    DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+    DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
     PacketDecodeFinalize(tv, dtv, p);
 
index 478256f145a11e6fe0f413fef8e5499370f0829d..6110e5e0e0736b089f500d910e2250f52504a140 100644 (file)
@@ -131,20 +131,20 @@ static SCMutex ipfw_init_lock;
 /* IPFW Prototypes */
 static void *IPFWGetQueue(int number);
 static TmEcode ReceiveIPFWThreadInit(ThreadVars *, const void *, void **);
-static TmEcode ReceiveIPFW(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode ReceiveIPFW(ThreadVars *, Packet *, void *);
 static TmEcode ReceiveIPFWLoop(ThreadVars *tv, void *data, void *slot);
 static void ReceiveIPFWThreadExitStats(ThreadVars *, void *);
 static TmEcode ReceiveIPFWThreadDeinit(ThreadVars *, void *);
 
 static TmEcode IPFWSetVerdict(ThreadVars *, IPFWThreadVars *, Packet *);
-static TmEcode VerdictIPFW(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode VerdictIPFW(ThreadVars *, Packet *, void *);
 static TmEcode VerdictIPFWThreadInit(ThreadVars *, const void *, void **);
 static void VerdictIPFWThreadExitStats(ThreadVars *, void *);
 static TmEcode VerdictIPFWThreadDeinit(ThreadVars *, void *);
 
 static TmEcode DecodeIPFWThreadInit(ThreadVars *, const void *, void **);
 static TmEcode DecodeIPFWThreadDeinit(ThreadVars *tv, void *data);
-static TmEcode DecodeIPFW(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode DecodeIPFW(ThreadVars *, Packet *, void *);
 
 /**
  * \brief Registration Function for RecieveIPFW.
@@ -430,15 +430,14 @@ TmEcode ReceiveIPFWThreadDeinit(ThreadVars *tv, void *data)
  * \brief This function passes off to link type decoders.
  * \todo Unit tests are needed for this module.
  *
- * DecodeIPFW reads packets from the PacketQueue and passes
+ * DecodeIPFW decodes packets from IPFW and passes
  * them off to the proper link type decoder.
  *
  * \param tv pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into IPFWThreadVars for ptv
- * \param pq pointer to the PacketQueue
  */
-TmEcode DecodeIPFW(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode DecodeIPFW(ThreadVars *tv, Packet *p, void *data)
 {
     IPV4Hdr *ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
     IPV6Hdr *ip6h = (IPV6Hdr *)GET_PKT_DATA(p);
@@ -460,14 +459,14 @@ TmEcode DecodeIPFW(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
             return TM_ECODE_FAILED;
         }
         SCLogDebug("DecodeIPFW ip4 processing");
-        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
     } else if(IPV6_GET_RAW_VER(ip6h) == 6) {
         if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
             return TM_ECODE_FAILED;
         }
         SCLogDebug("DecodeIPFW ip6 processing");
-        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
     } else {
         /* We don't support anything besides IP packets for now, bridged packets? */
@@ -610,9 +609,8 @@ TmEcode IPFWSetVerdict(ThreadVars *tv, IPFWThreadVars *ptv, Packet *p)
  * \param tv pointer to ThreadVars
  * \param p pointer to the Packet
  * \param data pointer that gets cast into IPFWThreadVars for ptv
- * \param pq pointer for the Packet Queue access (Not used)
  */
-TmEcode VerdictIPFW(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode VerdictIPFW(ThreadVars *tv, Packet *p, void *data)
 {
     IPFWThreadVars *ptv = (IPFWThreadVars *)data;
     TmEcode retval = TM_ECODE_OK;
index 15ea3cf5aeed4c62efc749fa723841c1255ab421..3bb23c69e435a2ffd17a77230a1a1e9221e5fbf7 100644 (file)
@@ -97,7 +97,7 @@ TmEcode NapatechPacketLoopZC(ThreadVars *tv, void *data, void *slot);
 
 TmEcode NapatechDecodeThreadInit(ThreadVars *, const void *, void **);
 TmEcode NapatechDecodeThreadDeinit(ThreadVars *tv, void *data);
-TmEcode NapatechDecode(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
+TmEcode NapatechDecode(ThreadVars *, Packet *, void *);
 
 /* These are used as the threads are exiting to get a comprehensive count of
  * all the packets received and dropped.
@@ -533,15 +533,14 @@ TmEcode NapatechStreamThreadDeinit(ThreadVars *tv, void *data)
 /**
  * \brief   This function passes off to link type decoders.
  *
- * NapatechDecode reads packets from the PacketQueue and passes
+ * NapatechDecode decodes packets from Napatech and passes
  * them off to the proper link type decoder.
  *
  * \param t pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into PcapThreadVars for ptv
- * \param pq pointer to the current PacketQueue
  */
-TmEcode NapatechDecode(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode NapatechDecode(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
 
@@ -557,7 +556,7 @@ TmEcode NapatechDecode(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
 
     switch (p->datalink) {
         case LINKTYPE_ETHERNET:
-            DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         default:
             SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED,
index 1fa6bdba68a30299988d21324bf2d5f35aa65f1b..9258fdb7070b04ee31ed938f610c8cf155f6a273 100644 (file)
@@ -735,15 +735,11 @@ static TmEcode DecodeNetmapThreadInit(ThreadVars *tv, const void *initdata, void
 /**
  * \brief This function passes off to link type decoders.
  *
- * DecodeNetmap reads packets from the PacketQueue and passes
- * them off to the proper link type decoder.
- *
  * \param t pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into NetmapThreadVars for ntv
- * \param pq pointer to the current PacketQueue
  */
-static TmEcode DecodeNetmap(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+static TmEcode DecodeNetmap(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
 
@@ -757,7 +753,7 @@ static TmEcode DecodeNetmap(ThreadVars *tv, Packet *p, void *data, PacketQueue *
     /* update counters */
     DecodeUpdatePacketCounters(tv, dtv, p);
 
-    DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+    DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
     PacketDecodeFinalize(tv, dtv, p);
 
index a954634755cafafc6f07e6bba2f972c156be08a9..10f3b826b1e7667c7efa465cf7d85e6835903889 100644 (file)
@@ -75,7 +75,7 @@ void ReceiveNFLOGThreadExitStats(ThreadVars *, void *);
 
 TmEcode DecodeNFLOGThreadInit(ThreadVars *, const void *, void **);
 TmEcode DecodeNFLOGThreadDeinit(ThreadVars *tv, void *data);
-TmEcode DecodeNFLOG(ThreadVars *, Packet *, void *, PacketQueue *);
+TmEcode DecodeNFLOG(ThreadVars *, Packet *, void *);
 
 static int runmode_workers;
 
@@ -496,11 +496,10 @@ void ReceiveNFLOGThreadExitStats(ThreadVars *tv, void *data)
  * \param tv pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into NFLOGThreadVars for ptv
- * \param pq pointer to the current PacketQueue
  *
  * \retval TM_ECODE_OK is always returned
  */
-TmEcode DecodeNFLOG(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode DecodeNFLOG(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
     IPV4Hdr *ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
@@ -514,13 +513,13 @@ TmEcode DecodeNFLOG(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
             return TM_ECODE_FAILED;
         }
         SCLogDebug("IPv4 packet");
-        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else if(IPV6_GET_RAW_VER(ip6h) == 6) {
         if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
             return TM_ECODE_FAILED;
         }
         SCLogDebug("IPv6 packet");
-        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else {
         SCLogDebug("packet unsupported by NFLOG, first byte: %02x", *GET_PKT_DATA(p));
     }
index a083197a8376758512ff1963df546f1a5fff3ffa..a783e03303721eeb4d846f9a44ab7d0bfaf1d02d 100644 (file)
@@ -137,11 +137,11 @@ static TmEcode ReceiveNFQThreadInit(ThreadVars *, const void *, void **);
 static TmEcode ReceiveNFQThreadDeinit(ThreadVars *, void *);
 static void ReceiveNFQThreadExitStats(ThreadVars *, void *);
 
-static TmEcode VerdictNFQ(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode VerdictNFQ(ThreadVars *, Packet *, void *);
 static TmEcode VerdictNFQThreadInit(ThreadVars *, const void *, void **);
 static TmEcode VerdictNFQThreadDeinit(ThreadVars *, void *);
 
-static TmEcode DecodeNFQ(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode DecodeNFQ(ThreadVars *, Packet *, void *);
 static TmEcode DecodeNFQThreadInit(ThreadVars *, const void *, void **);
 static TmEcode DecodeNFQThreadDeinit(ThreadVars *tv, void *data);
 
@@ -1193,7 +1193,7 @@ TmEcode NFQSetVerdict(Packet *p)
 /**
  * \brief NFQ verdict module packet entry function
  */
-TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data)
 {
     NFQThreadVars *ntv = (NFQThreadVars *)data;
     /* update counters */
@@ -1224,7 +1224,7 @@ TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
 /**
  * \brief Decode a packet coming from NFQ
  */
-TmEcode DecodeNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode DecodeNFQ(ThreadVars *tv, Packet *p, void *data)
 {
 
     IPV4Hdr *ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
@@ -1243,13 +1243,13 @@ TmEcode DecodeNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
             return TM_ECODE_FAILED;
         }
         SCLogDebug("IPv4 packet");
-        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV4(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else if (IPV6_GET_RAW_VER(ip6h) == 6) {
         if (unlikely(GET_PKT_LEN(p) > USHRT_MAX)) {
             return TM_ECODE_FAILED;
         }
         SCLogDebug("IPv6 packet");
-        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV6(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else {
         SCLogDebug("packet unsupported by NFQ, first byte: %02x", *GET_PKT_DATA(p));
     }
index 425032b846336fcccef1dd648cf08cc96b7b568a..63fe5b4760840ec4139afd59d8df0f62a1a0cbf3 100644 (file)
@@ -58,7 +58,7 @@ static TmEcode ReceivePcapFileThreadInit(ThreadVars *, const void *, void **);
 static void ReceivePcapFileThreadExitStats(ThreadVars *, void *);
 static TmEcode ReceivePcapFileThreadDeinit(ThreadVars *, void *);
 
-static TmEcode DecodePcapFile(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode DecodePcapFile(ThreadVars *, Packet *, void *);
 static TmEcode DecodePcapFileThreadInit(ThreadVars *, const void *, void **);
 static TmEcode DecodePcapFileThreadDeinit(ThreadVars *tv, void *data);
 
@@ -389,7 +389,7 @@ TmEcode ReceivePcapFileThreadDeinit(ThreadVars *tv, void *data)
 
 static double prev_signaled_ts = 0;
 
-static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
     DecodeThreadVars *dtv = (DecodeThreadVars *)data;
@@ -412,7 +412,7 @@ static TmEcode DecodePcapFile(ThreadVars *tv, Packet *p, void *data, PacketQueue
     if(ValidateLinkType(p->datalink, &decoder) == TM_ECODE_OK) {
 
         /* call the decoder */
-        decoder(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        decoder(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
 #ifdef DEBUG
         BUG_ON(p->pkt_src != PKT_SRC_WIRE && p->pkt_src != PKT_SRC_FFR);
index f49ff0a49c133eb0791c3e67793d84f46eeebafd..0870ec62fe50e2676de01bce4ede00d70964af14 100644 (file)
@@ -97,7 +97,7 @@ static TmEcode ReceivePcapBreakLoop(ThreadVars *tv, void *data);
 
 static TmEcode DecodePcapThreadInit(ThreadVars *, const void *, void **);
 static TmEcode DecodePcapThreadDeinit(ThreadVars *tv, void *data);
-static TmEcode DecodePcap(ThreadVars *, Packet *, void *, PacketQueue *);
+static TmEcode DecodePcap(ThreadVars *, Packet *, void *);
 
 /** protect pcap_compile and pcap_setfilter, as they are not thread safe:
  *  http://seclists.org/tcpdump/2009/q1/62 */
@@ -533,15 +533,14 @@ static void ReceivePcapThreadExitStats(ThreadVars *tv, void *data)
 /**
  * \brief This function passes off to link type decoders.
  *
- * DecodePcap reads packets from the PacketQueue and passes
+ * DecodePcap decodes packets from libpcap and passes
  * them off to the proper link type decoder.
  *
  * \param t pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into PcapThreadVars for ptv
- * \param pq pointer to the current PacketQueue
  */
-static TmEcode DecodePcap(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+static TmEcode DecodePcap(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
     DecodeThreadVars *dtv = (DecodeThreadVars *)data;
@@ -557,20 +556,20 @@ static TmEcode DecodePcap(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq
     /* call the decoder */
     switch(p->datalink) {
         case LINKTYPE_LINUX_SLL:
-            DecodeSll(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeSll(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_ETHERNET:
-            DecodeEthernet(tv, dtv, p,GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeEthernet(tv, dtv, p,GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_PPP:
-            DecodePPP(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodePPP(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_RAW:
         case LINKTYPE_GRE_OVER_IP:
-            DecodeRaw(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeRaw(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         case LINKTYPE_NULL:
-            DecodeNull(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+            DecodeNull(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
             break;
         default:
             SCLogError(SC_ERR_DATALINK_UNIMPLEMENTED, "Error: datalink "
index 0dafecb7763899c74791912060d80db0a3780e95..a07ab14c19d2a1b66e4f438d9587cf5a08bbf1e5 100644 (file)
@@ -53,7 +53,7 @@ void ReceivePfringThreadExitStats(ThreadVars *, void *);
 TmEcode ReceivePfringThreadDeinit(ThreadVars *, void *);
 
 TmEcode DecodePfringThreadInit(ThreadVars *, const void *, void **);
-TmEcode DecodePfring(ThreadVars *, Packet *, void *, PacketQueue *);
+TmEcode DecodePfring(ThreadVars *, Packet *, void *);
 TmEcode DecodePfringThreadDeinit(ThreadVars *tv, void *data);
 
 extern int max_pending_packets;
@@ -705,13 +705,12 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data)
 /**
  * \brief This function passes off to link type decoders.
  *
- * DecodePfring reads packets from the PacketQueue. Inside of libpcap version of
+ * DecodePfring decodes raw packets from PF_RING. Inside of libpcap version of
  * PF_RING all packets are marked as a link type of ethernet so that is what we do here.
  *
  * \param tv pointer to ThreadVars
  * \param p pointer to the current packet
  * \param data pointer that gets cast into PfringThreadVars for ptv
- * \param pq pointer to the current PacketQueue
  *
  * \todo Verify that PF_RING only deals with ethernet traffic
  *
@@ -719,7 +718,7 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data)
  *
  * \retval TM_ECODE_OK is always returned
  */
-TmEcode DecodePfring(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode DecodePfring(ThreadVars *tv, Packet *p, void *data)
 {
     DecodeThreadVars *dtv = (DecodeThreadVars *)data;
 
@@ -736,7 +735,7 @@ TmEcode DecodePfring(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
         StatsIncr(tv, dtv->counter_vlan);
     }
 
-    DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+    DecodeEthernet(tv, dtv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
 
     PacketDecodeFinalize(tv, dtv, p);
 
index 8d7e59cdf850c07ce5b0eb621d68322781a87d4d..bcf37c60543f627b3b2c419356d7f41c32d7a9db 100644 (file)
@@ -347,12 +347,12 @@ TmEcode ReceiveWinDivertThreadDeinit(ThreadVars *, void *);
 void ReceiveWinDivertThreadExitStats(ThreadVars *, void *);
 
 /* Verdict functions */
-TmEcode VerdictWinDivert(ThreadVars *, Packet *, void *, PacketQueue *);
+TmEcode VerdictWinDivert(ThreadVars *, Packet *, void *);
 TmEcode VerdictWinDivertThreadInit(ThreadVars *, const void *, void **);
 TmEcode VerdictWinDivertThreadDeinit(ThreadVars *, void *);
 
 /* Decode functions */
-TmEcode DecodeWinDivert(ThreadVars *, Packet *, void *, PacketQueue *);
+TmEcode DecodeWinDivert(ThreadVars *, Packet *, void *);
 TmEcode DecodeWinDivertThreadInit(ThreadVars *, const void *, void **);
 TmEcode DecodeWinDivertThreadDeinit(ThreadVars *, void *);
 
@@ -731,7 +731,7 @@ void ReceiveWinDivertThreadExitStats(ThreadVars *tv, void *data)
 /**
  * \brief WinDivert verdict module packet entry function
  */
-TmEcode VerdictWinDivert(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq);
+TmEcode VerdictWinDivert(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
 
@@ -855,7 +855,7 @@ TmEcode VerdictWinDivertThreadDeinit(ThreadVars *tv, void *data)
  * to differentiate the two, so instead we must check the version and go
  * from there.
  */
-TmEcode DecodeWinDivert(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
+TmEcode DecodeWinDivert(ThreadVars *tv, Packet *p, void *data)
 {
     SCEnter();
 
@@ -874,10 +874,10 @@ TmEcode DecodeWinDivert(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
 
     if (IPV4_GET_RAW_VER(ip4h) == 4) {
         SCLogDebug("IPv4 packet");
-        DecodeIPV4(tv, d_tv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV4(tv, d_tv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else if (IPV6_GET_RAW_VER(ip6h) == 6) {
         SCLogDebug("IPv6 packet");
-        DecodeIPV6(tv, d_tv, p, GET_PKT_DATA(p), GET_PKT_LEN(p), pq);
+        DecodeIPV6(tv, d_tv, p, GET_PKT_DATA(p), GET_PKT_LEN(p));
     } else {
         SCLogDebug("packet unsupported by WinDivert, first byte: %02x",
                    *GET_PKT_DATA(p));
index c11aaf2b9ea223587b9dbf401eb32f897eb7a94d..34b18cd828faa74c7ce0d0f92e429b34bb93ecae 100644 (file)
@@ -3415,7 +3415,7 @@ static int SigTest36ContentAndIsdataatKeywords01 (void)
     memset(&th_v, 0, sizeof(th_v));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth));
 
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
@@ -3534,7 +3534,7 @@ static int SigTest37ContentAndIsdataatKeywords02 (void)
     memset(&th_v, 0, sizeof(th_v));
 
     FlowInitConfig(FLOW_QUIET);
-    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+    DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth));
 
 
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
@@ -4280,7 +4280,7 @@ static int SigTestWithin01 (void)
     if (unlikely(p1 == NULL))
         return 0;
     memset(p1, 0, SIZE_OF_PACKET);
-    DecodeEthernet(&th_v, &dtv, p1, rawpkt1, sizeof(rawpkt1), NULL);
+    DecodeEthernet(&th_v, &dtv, p1, rawpkt1, sizeof(rawpkt1));
     SigMatchSignatures(&th_v, de_ctx, det_ctx, p1);
     if (!(PacketAlertCheck(p1, 556))) {
         printf("failed to match on packet 1: ");
@@ -4292,7 +4292,7 @@ static int SigTestWithin01 (void)
     if (unlikely(p2 == NULL))
         return 0;
     memset(p2, 0, SIZE_OF_PACKET);
-    DecodeEthernet(&th_v, &dtv, p2, rawpkt2, sizeof(rawpkt2), NULL);
+    DecodeEthernet(&th_v, &dtv, p2, rawpkt2, sizeof(rawpkt2));
     SigMatchSignatures(&th_v, de_ctx, det_ctx, p2);
     if (!(PacketAlertCheck(p2, 556))) {
         printf("failed to match on packet 2: ");
@@ -4304,7 +4304,7 @@ static int SigTestWithin01 (void)
     if (unlikely(p3 == NULL))
         return 0;
     memset(p3, 0, SIZE_OF_PACKET);
-    DecodeEthernet(&th_v, &dtv, p3, rawpkt3, sizeof(rawpkt3), NULL);
+    DecodeEthernet(&th_v, &dtv, p3, rawpkt3, sizeof(rawpkt3));
     SigMatchSignatures(&th_v, de_ctx, det_ctx, p3);
     if (!(PacketAlertCheck(p3, 556))) {
         printf("failed to match on packet 3: ");
@@ -4316,7 +4316,7 @@ static int SigTestWithin01 (void)
     if (unlikely(p4 == NULL))
         return 0;
     memset(p4, 0, SIZE_OF_PACKET);
-    DecodeEthernet(&th_v, &dtv, p4, rawpkt4, sizeof(rawpkt4), NULL);
+    DecodeEthernet(&th_v, &dtv, p4, rawpkt4, sizeof(rawpkt4));
     SigMatchSignatures(&th_v, de_ctx, det_ctx, p4);
     if (!(PacketAlertCheck(p4, 556))) {
         printf("failed to match on packet 4: ");
index a424aaa65f45e1602c5ecae0ad38863f8530dfba..3c18f64e5d857b80a1f6efc4cb1d2d5ef5e6913c 100644 (file)
@@ -28,6 +28,7 @@
 #include "tm-queues.h"
 #include "counters.h"
 #include "threads.h"
+#include "packet-queue.h"
 
 struct TmSlot_;
 
@@ -104,6 +105,10 @@ typedef struct ThreadVars_ {
     void *outctx;
     void (*tmqh_out)(struct ThreadVars_ *, struct Packet_ *);
 
+    /** queue for decoders to temporarily store extra packets they
+     *  generate. */
+    PacketQueueNoLock decode_pq;
+
     /** Stream packet queue for flow time out injection. Either a pointer to the
      *  workers input queue or to stream_pq_local */
     struct PacketQueue_ *stream_pq;
index 072900857b8d5b1af16df83368f11701001aac45..2e896db2abc94b5c4ab20a08bea8c5934f0c0395 100644 (file)
@@ -49,7 +49,7 @@ typedef struct TmModule_ {
     TmEcode (*ThreadDeinit)(ThreadVars *, void *);
 
     /** the packet processing function */
-    TmEcode (*Func)(ThreadVars *, Packet *, void *, PacketQueue *);
+    TmEcode (*Func)(ThreadVars *, Packet *, void *);
 
     TmEcode (*PktAcqLoop)(ThreadVars *, void *, void *);
 
index d1654f0dbef1e0cc0cf71213f4a8776fee179df6..d7904fe5fdeeda2a77d97d732c6c58a136e21e3a 100644 (file)
@@ -114,8 +114,7 @@ TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, TmSlot *slot)
 {
     for (TmSlot *s = slot; s != NULL; s = s->slot_next) {
         PACKET_PROFILING_TMM_START(p, s->tm_id);
-        TmEcode r = s->SlotFunc(tv, p, SC_ATOMIC_GET(s->slot_data),
-                &s->slot_pre_pq);
+        TmEcode r = s->SlotFunc(tv, p, SC_ATOMIC_GET(s->slot_data));
         PACKET_PROFILING_TMM_END(p, s->tm_id);
 
         /* handle error */
@@ -126,8 +125,8 @@ TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, TmSlot *slot)
         }
 
         /* handle new packets */
-        while (s->slot_pre_pq.top != NULL) {
-            Packet *extra_p = PacketDequeue(&s->slot_pre_pq);
+        while (tv->decode_pq.top != NULL) {
+            Packet *extra_p = PacketDequeueNoLock(&tv->decode_pq);
             if (unlikely(extra_p == NULL))
                 continue;
 
@@ -146,23 +145,6 @@ TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, TmSlot *slot)
     return TM_ECODE_OK;
 }
 
-/** \internal
- *  \brief check 'slot' pre_pq and thread cleanup
- *         and dump detailed info about the state of the packets
- *         and threads if in a unexpected state.
- */
-static void CheckSlot(const TmSlot *slot)
-{
-    if (slot->slot_pre_pq.len) {
-        for (Packet *xp = slot->slot_pre_pq.top; xp != NULL; xp = xp->next) {
-            SCLogNotice("pre_pq: slot tm_id %u pre_pq.len %u packet src %s",
-                    slot->tm_id, slot->slot_pre_pq.len, PktSrcToString(xp->pkt_src));
-        }
-        TmThreadDumpThreads();
-        abort();
-    }
-}
-
 #ifndef AFLFUZZ_PCAP_RUNMODE
 
 /** \internal
@@ -288,8 +270,6 @@ static void *TmThreadsSlotPktAcqLoop(void *td)
             }
             (void)SC_ATOMIC_SET(slot->slot_data, slot_data);
         }
-        memset(&slot->slot_pre_pq, 0, sizeof(PacketQueue));
-        SCMutexInit(&slot->slot_pre_pq.mutex_q, NULL);
 
         /* if the flowworker module is the first, get the threads input queue */
         if (slot == (TmSlot *)tv->tm_slots && (slot->tm_id == TMM_FLOWWORKER)) {
@@ -356,7 +336,6 @@ static void *TmThreadsSlotPktAcqLoop(void *td)
                 goto error;
             }
         }
-        CheckSlot(slot);
     }
 
     tv->stream_pq = NULL;
@@ -416,8 +395,6 @@ static void *TmThreadsSlotPktAcqLoopAFL(void *td)
             }
             (void)SC_ATOMIC_SET(slot->slot_data, slot_data);
         }
-        memset(&slot->slot_pre_pq, 0, sizeof(PacketQueue));
-        SCMutexInit(&slot->slot_pre_pq.mutex_q, NULL);
 
         /* if the flowworker module is the first, get the threads input queue */
         if (slot == (TmSlot *)tv->tm_slots && (slot->tm_id == TMM_FLOWWORKER)) {
@@ -476,8 +453,6 @@ static void *TmThreadsSlotPktAcqLoopAFL(void *td)
                 goto error;
             }
         }
-
-        CheckSlot(slot);
     }
 
     tv->stream_pq = NULL;
@@ -529,8 +504,6 @@ static void *TmThreadsSlotVar(void *td)
             }
             (void)SC_ATOMIC_SET(s->slot_data, slot_data);
         }
-        memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
-        SCMutexInit(&s->slot_pre_pq.mutex_q, NULL);
 
         /* special case: we need to access the stream queue
          * from the flow timeout code */
@@ -609,7 +582,6 @@ static void *TmThreadsSlotVar(void *td)
                 goto error;
             }
         }
-        CheckSlot(s);
     }
 
     SCLogDebug("%s ending", tv->name);
@@ -655,7 +627,6 @@ static void *TmThreadsManagement(void *td)
         }
         (void)SC_ATOMIC_SET(s->slot_data, slot_data);
     }
-    memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
 
     StatsSetupPrivate(tv);
 
@@ -2092,10 +2063,6 @@ static void TmThreadDoDumpSlots(const ThreadVars *tv)
         TmModule *m = TmModuleGetById(s->tm_id);
         SCLogNotice("tv %p: -> slot %p tm_id %d name %s",
             tv, s, s->tm_id, m->name);
-        for (Packet *xp = s->slot_pre_pq.top; xp != NULL; xp = xp->next) {
-            SCLogNotice("tv %p: ==> pre_pq: slot tm_id %u pre_pq.len %u packet src %s",
-                    tv, s->tm_id, s->slot_pre_pq.len, PktSrcToString(xp->pkt_src));
-        }
     }
 }
 
@@ -2116,6 +2083,10 @@ void TmThreadDumpThreads(void)
                             tv, tv->stream_pq_local->len, PktSrcToString(xp->pkt_src));
                 }
             }
+            for (Packet *xp = tv->decode_pq.top; xp != NULL; xp = xp->next) {
+                SCLogNotice("tv %p: ==> decode_pq: decode_pq.len %u packet src %s",
+                        tv, tv->decode_pq.len, PktSrcToString(xp->pkt_src));
+            }
             TmThreadDoDumpSlots(tv);
             tv = tv->next;
         }
index 2e4f8a13985b10b1bb4c2e5c8b0428a021d1d79d..54ef9c4c732da1849f4abdde2f3ce7ae679d32ce 100644 (file)
@@ -47,7 +47,7 @@ static inline void SleepUsec(uint64_t usec)
 #define TM_QUEUE_NAME_MAX 16
 #define TM_THREAD_NAME_MAX 16
 
-typedef TmEcode (*TmSlotFunc)(ThreadVars *, Packet *, void *, PacketQueue *);
+typedef TmEcode (*TmSlotFunc)(ThreadVars *, Packet *, void *);
 
 typedef struct TmSlot_ {
     /* function pointers */
@@ -62,11 +62,6 @@ typedef struct TmSlot_ {
 
     SC_ATOMIC_DECLARE(void *, slot_data);
 
-    /* queue filled by the SlotFunc with packets that will
-     * be processed futher _before_ the current packet.
-     * The locks in the queue are NOT used */
-    PacketQueue slot_pre_pq;
-
     TmEcode (*SlotThreadInit)(ThreadVars *, const void *, void **);
     void (*SlotThreadExitPrintStats)(ThreadVars *, void *);
     TmEcode (*SlotThreadDeinit)(ThreadVars *, void *);
@@ -134,12 +129,22 @@ TmSlot *TmThreadGetFirstTmSlotForPartialPattern(const char *);
 
 uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags);
 
+static inline void TmThreadsCleanDecodePQ(PacketQueueNoLock *pq)
+{
+    while (1) {
+        Packet *p = PacketDequeueNoLock(pq);
+        if (unlikely(p == NULL))
+            break;
+        TmqhOutputPacketpool(NULL, p);
+    }
+}
+
 static inline void TmThreadsSlotProcessPktFail(ThreadVars *tv, TmSlot *s, Packet *p)
 {
     if (p != NULL) {
         TmqhOutputPacketpool(tv, p);
     }
-    TmqhReleasePacketsToPacketPool(&s->slot_pre_pq);
+    TmThreadsCleanDecodePQ(&tv->decode_pq);
     if (tv->stream_pq_local) {
         SCMutexLock(&tv->stream_pq_local->mutex_q);
         TmqhReleasePacketsToPacketPool(tv->stream_pq_local);
index a2baf67ee2ffeab1a259e9725f163a4806dfbcf2..ea04be27c2fe89f15139121e3125d99c161cc335 100644 (file)
@@ -302,7 +302,7 @@ Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkt
             SCFree(p);
             return NULL;
         }
-        DecodeEthernet(&th_v, &dtv, p[i], raw_eth[i], pktsize[i], NULL);
+        DecodeEthernet(&th_v, &dtv, p[i], raw_eth[i], pktsize[i]);
     }
     return p;
 }
@@ -326,7 +326,7 @@ Packet *UTHBuildPacketFromEth(uint8_t *raw_eth, uint16_t pktsize)
     memset(&dtv, 0, sizeof(DecodeThreadVars));
     memset(&th_v, 0, sizeof(th_v));
 
-    DecodeEthernet(&th_v, &dtv, p, raw_eth, pktsize, NULL);
+    DecodeEthernet(&th_v, &dtv, p, raw_eth, pktsize);
     return p;
 }