From 3df4b7da2b4ed7dc9356cde161777195b767c0b1 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 16 Aug 2008 21:32:57 +0200 Subject: [PATCH] Set p->proto and add TCP, UDP, etc macros. --- src/decode-icmpv4.c | 1 + src/decode-icmpv6.c | 1 + src/decode-tcp.c | 2 ++ src/decode.h | 8 ++++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/decode-icmpv4.c b/src/decode-icmpv4.c index de5430da07..9cc6107a42 100644 --- a/src/decode-icmpv4.c +++ b/src/decode-icmpv4.c @@ -15,6 +15,7 @@ void DecodeICMPV4(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t len ) printf("ICMPV4 TYPE %u CODE %u\n", p->icmpv4h->type, p->icmpv4h->code); #endif + p->proto = IPPROTO_ICMP; return; } diff --git a/src/decode-icmpv6.c b/src/decode-icmpv6.c index e8eeb42c9a..0734545820 100644 --- a/src/decode-icmpv6.c +++ b/src/decode-icmpv6.c @@ -15,6 +15,7 @@ void DecodeICMPV6(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t len) printf("ICMPV6 TYPE %u CODE %u\n", p->icmpv6h->type, p->icmpv6h->code); #endif + p->proto = IPPROTO_ICMPV6; return; } diff --git a/src/decode-tcp.c b/src/decode-tcp.c index da39adddbb..0a4f419104 100644 --- a/src/decode-tcp.c +++ b/src/decode-tcp.c @@ -129,6 +129,8 @@ static int DecodeTCPPacket(ThreadVars *t, Packet *p, u_int8_t *pkt, u_int16_t le p->tcp_payload = pkt + p->tcpvars.hlen; p->tcp_payload_len = len - p->tcpvars.hlen; + p->proto = IPPROTO_TCP; + return 0; } diff --git a/src/decode.h b/src/decode.h index 2c81bc2a03..f99b5ccd41 100644 --- a/src/decode.h +++ b/src/decode.h @@ -122,6 +122,12 @@ typedef u_int16_t Port; #define PKT_IS_IPV4(p) (((p)->ip4h != NULL)) #define PKT_IS_IPV6(p) (((p)->ip6h != NULL)) +#define PKT_IS_TCP(p) (((p)->tcph != NULL)) +/* XXX */ +#define PKT_IS_UDP(p) (0) +#define PKT_IS_ICMPV4 (((p)->icmpv4 != NULL)) +#define PKT_IS_ICMPV6 (((p)->icmpv6 != NULL)) + /* structure to store the sids/gids/etc the detection engine * found in this packet */ @@ -294,8 +300,6 @@ typedef struct _Packet #define IS_TUNNEL_ROOT_PKT(p) (((p)->root == NULL && (p)->tunnel_pkt == 1)) #define IS_TUNNEL_PKT(p) (((p)->tunnel_pkt == 1)) #define SET_TUNNEL_PKT(p) ((p)->tunnel_pkt = 1) -#define IS_IPV4_PKT(p) ((p)->ip4h ? 1 : 0) -#define IS_IPV6_PKT(p) ((p)->ip6h ? 1 : 0) /* decoder functions */