diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:21:41 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-09-09 22:21:41 -0700 |
commit | 8879b125d26e8db1a5633de5a9c692eb2d1c4f83 (patch) | |
tree | c7259d85a991b83dfa85ab2e339360669fc1f58e /framework/src/suricata/src/decode-gre.h | |
parent | 13d05bc8458758ee39cb829098241e89616717ee (diff) |
suricata checkin based on commit id a4bce14770beee46a537eda3c3f6e8e8565d5d0a
Change-Id: I9a214fa0ee95e58fc640e50bd604dac7f42db48f
Diffstat (limited to 'framework/src/suricata/src/decode-gre.h')
-rw-r--r-- | framework/src/suricata/src/decode-gre.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/framework/src/suricata/src/decode-gre.h b/framework/src/suricata/src/decode-gre.h new file mode 100644 index 00000000..6f3db29d --- /dev/null +++ b/framework/src/suricata/src/decode-gre.h @@ -0,0 +1,83 @@ +/* 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 <breno.silva@gmail.com> + * + * 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__ */ + |