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
DecodeSll(ThreadVars * tv,DecodeThreadVars * dtv,Packet * p,const uint8_t * pkt,uint32_t len)39 int DecodeSll(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
40 const uint8_t *pkt, uint32_t len)
41 {
42 StatsIncr(tv, dtv->counter_sll);
43
44 if (unlikely(len < SLL_HEADER_LEN)) {
45 ENGINE_SET_INVALID_EVENT(p, SLL_PKT_TOO_SMALL);
46 return TM_ECODE_FAILED;
47 }
48 if (!PacketIncreaseCheckLayers(p)) {
49 return TM_ECODE_FAILED;
50 }
51
52 SllHdr *sllh = (SllHdr *)pkt;
53 if (unlikely(sllh == NULL))
54 return TM_ECODE_FAILED;
55
56 SCLogDebug("p %p pkt %p sll_protocol %04x", p, pkt, SCNtohs(sllh->sll_protocol));
57
58 DecodeNetworkLayer(tv, dtv, SCNtohs(sllh->sll_protocol), p,
59 pkt + SLL_HEADER_LEN, len - SLL_HEADER_LEN);
60
61 return TM_ECODE_OK;
62 }
63 /**
64 * @}
65 */
66