suricata
decode-vntag.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 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  * \file
20  *
21  * \author Jeff Lucovsky <jeff@lucovsky.org>
22  */
23 
24 #ifndef __DECODE_VNTAG_H__
25 #define __DECODE_VNTAG_H__
26 
27 /* https://www.ieee802.org/1/files/public/docs2009/new-pelissier-vntag-seminar-0508.pdf */
28 /** VNTag macros to access VNTag direction, dst vif_id, dest, looped, version, src vif_id **/
29 #define GET_VNTAG_DIR(vntagh) ((SCNtohl((vntagh)->tag) & 0x80000000) >> 31)
30 #define GET_VNTAG_PTR(vntagh) ((SCNtohl((vntagh)->tag) & 0x40000000) >> 30)
31 #define GET_VNTAG_DEST(vntagh) ((SCNtohl((vntagh)->tag) & 0x3FFF0000) >> 16)
32 #define GET_VNTAG_LOOPED(vntagh) ((SCNtohl((vntagh)->tag) & 0x00008000) >> 15)
33 #define GET_VNTAG_VERSION(vntagh) ((SCNtohl((vntagh)->tag) & 0x00003000) >> 12)
34 #define GET_VNTAG_SRC(vntagh) ((SCNtohl((vntagh)->tag) & 0x00000FFF))
35 #define GET_VNTAG_PROTO(vntagh) ((SCNtohs((vntagh)->protocol)))
36 
37 /** VNTag header struct */
38 typedef struct VNTagHdr_ {
39  uint32_t tag;
40  uint16_t protocol; /**< protocol field */
41 } __attribute__((__packed__)) VNTagHdr;
42 
43 /** VNTag header length */
44 #define VNTAG_HEADER_LEN 6
45 
46 void DecodeVNTagRegisterTests(void);
47 
48 #endif /* __DECODE_VNTAG_H__ */
DecodeVNTagRegisterTests
void DecodeVNTagRegisterTests(void)
Definition: decode-vntag.c:179
__attribute__
struct VNTagHdr_ __attribute__((__packed__)) VNTagHdr
DNP3 link header.
Definition: decode-vlan.c:117
VNTagHdr_
Definition: decode-vntag.h:38
VNTagHdr_::protocol
uint16_t protocol
Definition: decode-vntag.h:40
VNTagHdr_::tag
uint32_t tag
Definition: decode-vntag.h:39