-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-chdlc.h"
#include "decode-events.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodeCHDLC(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_chdlc);
if (unlikely(len < CHDLC_HEADER_LEN)) {
}
CHDLCHdr *hdr = (CHDLCHdr *)pkt;
- if (unlikely(hdr == NULL))
- return TM_ECODE_FAILED;
SCLogDebug("p %p pkt %p ether type %04x", p, pkt, SCNtohs(hdr->protocol));
-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-events.h"
#include "decode-erspan.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
*/
int DecodeERSPAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_erspan);
if (len < sizeof(ErspanHdr)) {
-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-esp.h"
#include "flow.h"
+#include "util-validate.h"
+
static int DecodeESPPacket(ThreadVars *tv, Packet *p, const uint8_t *pkt, uint16_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
if (unlikely(len < ESP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, ESP_PKT_TOO_SMALL);
return -1;
*/
int DecodeESP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint16_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_esp);
if (!PacketIncreaseCheckLayers(p)) {
-/* Copyright (C) 2007-2014 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-ethernet.h"
#include "decode-events.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_eth);
if (unlikely(len < ETHERNET_HEADER_LEN)) {
return TM_ECODE_FAILED;
}
p->ethh = (EthernetHdr *)pkt;
- if (unlikely(p->ethh == NULL))
- return TM_ECODE_FAILED;
SCLogDebug("p %p pkt %p ether type %04x", p, pkt, SCNtohs(p->ethh->eth_type));
-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "flow.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
*/
int DecodeGeneve(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
const GeneveHeader *geneve_hdr = (const GeneveHeader *)pkt;
uint16_t eth_type, geneve_hdr_len;
#include "decode-events.h"
#include "decode-gre.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
uint32_t header_len = GRE_HDR_LEN;
GRESreHdr *gsre = NULL;
}
p->greh = (GREHdr *)pkt;
- if(p->greh == NULL)
- return TM_ECODE_FAILED;
SCLogDebug("p %p pkt %p GRE protocol %04x Len: %d GRE version %x",
p, pkt, GRE_GET_PROTO(p->greh), len,GRE_GET_VERSION(p->greh));
-/* Copyright (C) 2014 Open Information Security Foundation
+/* Copyright (C) 2014-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "suricata-common.h"
#include "decode.h"
+
+#include "util-validate.h"
#include "util-unittest.h"
#define MPLS_HEADER_LEN 4
int DecodeMPLS(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
uint32_t shim;
int label;
int event = 0;
-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-events.h"
#include "decode-nsh.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
-/* Copyright (C) 2015 Open Information Security Foundation
+/* Copyright (C) 2015-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-raw.h"
#include "decode-events.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_null);
if (unlikely(len < HDR_SIZE)) {
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "flow.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodePPP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_ppp);
if (unlikely(len < PPP_HEADER_LEN)) {
}
p->ppph = (PPPHdr *)pkt;
- if (unlikely(p->ppph == NULL))
- return TM_ECODE_FAILED;
SCLogDebug("p %p pkt %p PPP protocol %04x Len: %" PRIu32 "",
p, pkt, SCNtohs(p->ppph->protocol), len);
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "flow.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_pppoe);
if (len < PPPOE_DISCOVERY_HEADER_MIN_LEN) {
}
p->pppoedh = (PPPOEDiscoveryHdr *)pkt;
- if (p->pppoedh == NULL)
- return TM_ECODE_FAILED;
/* parse the PPPOE code */
switch (p->pppoedh->pppoe_code)
int DecodePPPOESession(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_pppoe);
if (len < PPPOE_SESSION_HEADER_LEN) {
}
p->pppoesh = (PPPOESessionHdr *)pkt;
- if (p->pppoesh == NULL)
- return TM_ECODE_FAILED;
SCLogDebug("PPPOE VERSION %" PRIu32 " TYPE %" PRIu32 " CODE %" PRIu32 " SESSIONID %" PRIu32 " LENGTH %" PRIu32 "",
PPPOE_SESSION_GET_VERSION(p->pppoesh), PPPOE_SESSION_GET_TYPE(p->pppoesh), p->pppoesh->pppoe_code, SCNtohs(p->pppoesh->session_id), SCNtohs(p->pppoesh->pppoe_length));
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-raw.h"
#include "decode-events.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_raw);
/* If it is ipv4 or ipv6 it should at least be the size of ipv4 */
-/* Copyright (C) 2011 Open Information Security Foundation
+/* Copyright (C) 2011-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode.h"
#include "decode-sctp.h"
#include "decode-events.h"
+
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
#include "util-optimize.h"
static int DecodeSCTPPacket(ThreadVars *tv, Packet *p, const uint8_t *pkt, uint16_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
if (unlikely(len < SCTP_HEADER_LEN)) {
ENGINE_SET_INVALID_EVENT(p, SCTP_PKT_TOO_SMALL);
return -1;
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode.h"
#include "decode-sll.h"
#include "decode-events.h"
+
+#include "util-validate.h"
#include "util-debug.h"
int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_sll);
if (unlikely(len < SLL_HEADER_LEN)) {
}
SllHdr *sllh = (SllHdr *)pkt;
- if (unlikely(sllh == NULL))
- return TM_ECODE_FAILED;
SCLogDebug("p %p pkt %p sll_protocol %04x", p, pkt, SCNtohs(sllh->sll_protocol));
-/* Copyright (C) 2015-2018 Open Information Security Foundation
+/* Copyright (C) 2015-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode-events.h"
#include "decode-template.h"
+#include "util-validate.h"
+
/**
* \brief Function to decode TEMPLATE packets
* \param tv thread vars
int DecodeTEMPLATE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
/* TODO add counter for your type of packet to DecodeThreadVars,
* and register it in DecodeRegisterPerfCounters */
//StatsIncr(tv, dtv->counter_template);
-/* Copyright (C) 2012-2020 Open Information Security Foundation
+/* Copyright (C) 2012-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "decode.h"
#include "decode-ipv6.h"
#include "decode-teredo.h"
+
+#include "util-validate.h"
#include "util-debug.h"
#include "conf.h"
#include "detect-engine-port.h"
int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint16_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
if (!g_teredo_enabled)
return TM_ECODE_FAILED;
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "flow.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
uint32_t proto;
if (p->vlan_idx == 0)
}
VLANHdr *vlan_hdr = (VLANHdr *)pkt;
- if(vlan_hdr == NULL)
- return TM_ECODE_FAILED;
proto = GET_VLAN_PROTO(vlan_hdr);
int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_ieee8021ah);
if (len < IEEE8021AH_HEADER_LEN) {
#include "flow.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"
* \param p pointer to the packet struct
* \param pkt pointer to the raw packet
* \param len packet len
- * \param pq pointer to the packet queue
*
*/
int DecodeVNTag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
{
+ DEBUG_VALIDATE_BUG_ON(pkt == NULL);
+
StatsIncr(tv, dtv->counter_vntag);
if (len < VNTAG_HEADER_LEN) {
}
VNTagHdr *vntag_hdr = (VNTagHdr *)pkt;
- if (vntag_hdr == NULL)
- return TM_ECODE_FAILED;
uint16_t proto = GET_VNTAG_PROTO(vntag_hdr);
-/* Copyright (C) 2019 Open Information Security Foundation
+/* Copyright (C) 2019-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "flow.h"
+#include "util-validate.h"
#include "util-unittest.h"
#include "util-debug.h"