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
40
int
DecodeSll2
(
ThreadVars
*
tv
,
DecodeThreadVars
*
dtv
,
Packet
*p,
const
uint8_t *pkt, uint32_t
len
)
41
{
42
DEBUG_VALIDATE_BUG_ON
(pkt == NULL);
43
44
StatsIncr
(
tv
,
dtv
->
counter_sll2
);
45
46
if
(
unlikely
(
len
<
SLL2_HEADER_LEN
)) {
47
ENGINE_SET_INVALID_EVENT
(p,
SLL2_PKT_TOO_SMALL
);
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
*/
len
uint8_t len
Definition:
app-layer-dnp3.h:2
StatsIncr
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
Definition:
counters.c:166
unlikely
#define unlikely(expr)
Definition:
util-optimize.h:35
decode-sll2.h
SCLogDebug
#define SCLogDebug(...)
Definition:
util-debug.h:270
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition:
tm-threads-common.h:82
DecodeThreadVars_::counter_sll2
uint16_t counter_sll2
Definition:
decode.h:984
TM_ECODE_OK
@ TM_ECODE_OK
Definition:
tm-threads-common.h:81
decode.h
util-debug.h
ThreadVars_
Per thread variable structure.
Definition:
threadvars.h:58
Packet_
Definition:
decode.h:492
SLL2_HEADER_LEN
#define SLL2_HEADER_LEN
Definition:
decode-sll2.h:27
decode-events.h
dtv
DecodeThreadVars * dtv
Definition:
fuzz_decodepcapfile.c:33
SCNtohs
#define SCNtohs(x)
Definition:
suricata-common.h:431
suricata-common.h
tv
ThreadVars * tv
Definition:
fuzz_decodepcapfile.c:32
util-validate.h
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition:
decode.h:954
SLL2_PKT_TOO_SMALL
@ SLL2_PKT_TOO_SMALL
Definition:
decode-events.h:115
ENGINE_SET_INVALID_EVENT
#define ENGINE_SET_INVALID_EVENT(p, e)
Definition:
decode.h:1183
DecodeSll2
int DecodeSll2(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition:
decode-sll2.c:40
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition:
util-validate.h:102
src
decode-sll2.c
Generated on Sun Jun 1 2025 23:30:27 for suricata by
1.8.18