52 GRESreHdr *gsre = NULL;
53 GREPPtPHd *gre_pptp_h = NULL;
61 if (!PacketIncreaseCheckLayers(p)) {
65 GREHdr *
greh = PacketSetGRE(p, pkt);
103 if (header_len >
len) {
117 gsre = (GRESreHdr *)(pkt + header_len);
121 if ((
SCNtohs(gsre->af) == 0) && (gsre->sre_length == 0))
124 header_len += gsre->sre_length;
125 if (header_len >
len) {
182 gre_pptp_h = (GREPPtPHd *)pkt;
192 if (header_len >
len) {
217 if (gre_pptp_h && !gre_pptp_h->payload_length)
299static int DecodeGREtest01 (
void)
301 uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 };
321static int DecodeGREtest02 (
void)
323 uint8_t raw_gre[] = {
324 0x00, 0x6e, 0x62, 0xac, 0x40, 0x00, 0x40, 0x2f,
325 0xc2, 0xc7, 0x0a, 0x00, 0x00, 0x64, 0x0a, 0x00,
326 0x00, 0x8a, 0x30, 0x01, 0x0b, 0x00, 0x4e, 0x00,
327 0x00, 0x00, 0x18, 0x4a, 0x50, 0xff, 0x03, 0x00,
328 0x21, 0x45, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x40,
329 0x00, 0x40, 0x11, 0x94, 0x22, 0x50, 0x7e, 0x2b,
330 0x2d, 0xc2, 0x6d, 0x68, 0x68, 0x80, 0x0e, 0x00,
331 0x35, 0x00, 0x36, 0x9f, 0x18, 0xdb, 0xc4, 0x01,
332 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
333 0x01, 0x03, 0x73, 0x31, 0x36, 0x09, 0x73, 0x69,
334 0x74, 0x65, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x03,
335 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01,
336 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
358static int DecodeGREtest03 (
void)
360 uint8_t raw_gre[] = {
361 0x00, 0x6e, 0x62, 0xac, 0x40, 0x00, 0x40, 0x2f,
362 0xc2, 0xc7, 0x0a, 0x00, 0x00, 0x64, 0x0a, 0x00,
363 0x00, 0x8a, 0x30, 0x01, 0x88, 0x0b, 0x00, 0x4e,
364 0x00, 0x00, 0x00, 0x18, 0x4a, 0x50, 0xff, 0x03,
365 0x00, 0x21, 0x45, 0x00, 0x00, 0x4a, 0x00, 0x00,
366 0x40, 0x00, 0x40, 0x11, 0x94, 0x22, 0x50, 0x7e,
367 0x2b, 0x2d, 0xc2, 0x6d, 0x68, 0x68, 0x80, 0x0e,
368 0x00, 0x35, 0x00, 0x36, 0x9f, 0x18, 0xdb, 0xc4,
369 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
370 0x00, 0x01, 0x03, 0x73, 0x31, 0x36, 0x09, 0x73,
371 0x69, 0x74, 0x65, 0x6d, 0x65, 0x74, 0x65, 0x72,
372 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00,
373 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00,
374 0x00, 0x00, 0x00, 0x00 };
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
#define ETHERNET_TYPE_ARP
#define ETHERNET_TYPE_BRIDGE
#define ETHERNET_TYPE_IPV6
#define ETHERNET_TYPE_ERSPAN
@ GRE_VERSION0_HDR_TOO_BIG
@ GRE_VERSION1_HDR_TOO_BIG
@ GRE_VERSION1_WRONG_PROTOCOL
@ GRE_VERSION0_MALFORMED_SRE_HDR
int DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *pkt, uint32_t len)
Function to decode GRE packets.
void DecodeGRERegisterTests(void)
this function registers unit tests for GRE decoder
#define GRE_FLAG_ISSET_SQ(r)
#define GREV1_FLAG_ISSET_ACK(r)
#define GRE_FLAG_ISSET_CHKSUM(r)
#define GRE_FLAG_ISSET_ROUTE(r)
#define GRE_FLAG_ISSET_KY(r)
#define GRE_FLAG_ISSET_SSR(r)
#define GRE_FLAG_ISSET_RECUR(r)
#define GREV1_FLAG_ISSET_FLAGS(r)
#define GRE_GET_VERSION(r)
#define ETHERNET_TYPE_VLAN
#define PKT_SET_SRC(p, src_val)
#define ENGINE_SET_INVALID_EVENT(p, e)
#define ENGINE_ISSET_EVENT(p, e)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Packet * PacketTunnelPktSetup(ThreadVars *tv, DecodeThreadVars *dtv, Packet *parent, const uint8_t *pkt, uint32_t len, enum DecodeTunnelProto proto)
Setup a pseudo packet (tunnel)
void PacketEnqueueNoLock(PacketQueueNoLock *qnl, Packet *p)
Structure to hold thread specific data for all decode modules.
Per thread variable structure.
PacketQueueNoLock decode_pq
#define DEBUG_VALIDATE_BUG_ON(exp)