forked from OISF/suricata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode-gre.h
83 lines (69 loc) · 2.5 KB
/
decode-gre.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Copyright (C) 2007-2010 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* \file decode-gre.h
*
* \author Breno Silva <[email protected]>
*
* Generic Route Encapsulation (GRE) from RFC 1701.
*/
#ifndef __DECODE_GRE_H__
#define __DECODE_GRE_H__
#ifndef IPPROTO_GRE
#define IPPROTO_GRE 47
#endif
#include "decode.h"
#include "threadvars.h"
typedef struct GREHdr_
{
uint8_t flags; /**< GRE packet flags */
uint8_t version; /**< GRE version */
uint16_t ether_type; /**< ether type of the encapsulated traffic */
} __attribute__((__packed__)) GREHdr;
/* Generic Routing Encapsulation Source Route Entries (SREs).
* The header is followed by a variable amount of Routing Information.
*/
typedef struct GRESreHdr_
{
uint16_t af; /**< Address family */
uint8_t sre_offset;
uint8_t sre_length;
} __attribute__((__packed__)) GRESreHdr;
#define GRE_VERSION_0 0x0000
#define GRE_VERSION_1 0x0001
#define GRE_HDR_LEN 4
#define GRE_CHKSUM_LEN 2
#define GRE_OFFSET_LEN 2
#define GRE_KEY_LEN 4
#define GRE_SEQ_LEN 4
#define GRE_SRE_HDR_LEN 4
#define GRE_PROTO_PPP 0x880b
#define GRE_FLAG_ISSET_CHKSUM(r) (r->flags & 0x80)
#define GRE_FLAG_ISSET_ROUTE(r) (r->flags & 0x40)
#define GRE_FLAG_ISSET_KY(r) (r->flags & 0x20)
#define GRE_FLAG_ISSET_SQ(r) (r->flags & 0x10)
#define GRE_FLAG_ISSET_SSR(r) (r->flags & 0x08)
#define GRE_FLAG_ISSET_RECUR(r) (r->flags & 0x07)
#define GRE_GET_VERSION(r) (r->version & 0x07)
#define GRE_GET_FLAGS(r) (r->version & 0xF8)
#define GRE_GET_PROTO(r) ntohs(r->ether_type)
#define GREV1_HDR_LEN 8
#define GREV1_ACK_LEN 4
#define GREV1_FLAG_ISSET_FLAGS(r) (r->version & 0x78)
#define GREV1_FLAG_ISSET_ACK(r) (r->version & 0x80)
void DecodeGRERegisterTests(void);
#endif /* __DECODE_GRE_H__ */