suricata
decode-sll2.c
Go to the documentation of this file.
1/* Copyright (C) 2025 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \ingroup decode
20 *
21 * @{
22 */
23
24/**
25 * \file
26 *
27 * \author Jeff Lucovsky <jeff.lucovsky@corelight.com>
28 *
29 * Decodes Sll2
30 */
31
32#include "suricata-common.h"
33#include "decode.h"
34#include "decode-sll2.h"
35#include "decode-events.h"
36
37#include "util-validate.h"
38#include "util-debug.h"
39
40int DecodeSll2(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
41{
42 DEBUG_VALIDATE_BUG_ON(pkt == NULL);
43
45
48 return TM_ECODE_FAILED;
49 }
50 if (!PacketIncreaseCheckLayers(p)) {
51 return TM_ECODE_FAILED;
52 }
53
54 Sll2Hdr *sll2h = (Sll2Hdr *)pkt;
55
56 SCLogDebug("p %p pkt %p sll2_protocol %04x", p, pkt, SCNtohs(sll2h->sll_protocol));
57
58 DecodeNetworkLayer(
59 tv, dtv, SCNtohs(sll2h->sll_protocol), p, pkt + SLL2_HEADER_LEN, len - SLL2_HEADER_LEN);
60
61 return TM_ECODE_OK;
62}
63/**
64 * @}
65 */
uint8_t len
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
Definition counters.c:166
@ SLL2_PKT_TOO_SMALL
int DecodeSll2(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition decode-sll2.c:40
#define SLL2_HEADER_LEN
Definition decode-sll2.h:27
#define ENGINE_SET_INVALID_EVENT(p, e)
Definition decode.h:1194
DecodeThreadVars * dtv
ThreadVars * tv
Structure to hold thread specific data for all decode modules.
Definition decode.h:963
uint16_t counter_sll2
Definition decode.h:993
Per thread variable structure.
Definition threadvars.h:58
#define SCNtohs(x)
@ TM_ECODE_FAILED
@ TM_ECODE_OK
#define SCLogDebug(...)
Definition util-debug.h:275
#define unlikely(expr)
#define DEBUG_VALIDATE_BUG_ON(exp)