suricata
decode-sll.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 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 /**
26  * \file
27  *
28  * \author Victor Julien <victor@inliniac.net>
29  *
30  * Decodes Sll
31  */
32 
33 #include "suricata-common.h"
34 #include "decode.h"
35 #include "decode-sll.h"
36 #include "decode-events.h"
37 #include "util-debug.h"
38 
40  const uint8_t *pkt, uint32_t len)
41 {
43 
44  if (unlikely(len < SLL_HEADER_LEN)) {
46  return TM_ECODE_FAILED;
47  }
48 
49  SllHdr *sllh = (SllHdr *)pkt;
50  if (unlikely(sllh == NULL))
51  return TM_ECODE_FAILED;
52 
53  SCLogDebug("p %p pkt %p sll_protocol %04x", p, pkt, SCNtohs(sllh->sll_protocol));
54 
55  DecodeNetworkLayer(tv, dtv, SCNtohs(sllh->sll_protocol), p,
57 
58  return TM_ECODE_OK;
59 }
60 /**
61  * @}
62  */
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:169
SLL_HEADER_LEN
#define SLL_HEADER_LEN
Definition: decode-sll.h:27
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:81
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:80
decode.h
util-debug.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
Packet_
Definition: decode.h:414
decode-sll.h
DecodeThreadVars_::counter_sll
uint16_t counter_sll
Definition: decode.h:654
decode-events.h
dtv
DecodeThreadVars * dtv
Definition: fuzz_decodepcapfile.c:30
SLL_PKT_TOO_SMALL
@ SLL_PKT_TOO_SMALL
Definition: decode-events.h:108
SCNtohs
#define SCNtohs(x)
Definition: suricata-common.h:398
suricata-common.h
DecodeSll
int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Definition: decode-sll.c:39
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:29
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:631
ENGINE_SET_INVALID_EVENT
#define ENGINE_SET_INVALID_EVENT(p, e)
Definition: decode.h:1011