From 54cd3552e150f28c607e556bffa0853b2593a906 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 21 May 2011 10:22:24 +0200 Subject: [PATCH] Remove tunnel_proto field from Packet structure. --- src/decode-gre.c | 12 ++++++++---- src/decode-ipv4.c | 3 ++- src/decode.c | 8 ++++---- src/decode.h | 5 +---- src/stream-tcp.c | 1 - 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/decode-gre.c b/src/decode-gre.c index fa31369ebd..01e870ca19 100644 --- a/src/decode-gre.c +++ b/src/decode-gre.c @@ -200,7 +200,8 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u Packet *tp = PacketPseudoPktSetup(p, pkt + header_len, len - header_len, IPPROTO_IP); if (tp != NULL) { - DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), GET_PKT_LEN(tp), pq); + DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), + GET_PKT_LEN(tp), pq, IPPROTO_IP); PacketEnqueue(pq,tp); } } @@ -213,7 +214,8 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u Packet *tp = PacketPseudoPktSetup(p, pkt + header_len, len - header_len, PPP_OVER_GRE); if (tp != NULL) { - DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), GET_PKT_LEN(tp), pq); + DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), + GET_PKT_LEN(tp), pq, PPP_OVER_GRE); PacketEnqueue(pq,tp); } } @@ -226,7 +228,8 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u Packet *tp = PacketPseudoPktSetup(p, pkt + header_len, len - header_len, IPPROTO_IPV6); if (tp != NULL) { - DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), GET_PKT_LEN(tp), pq); + DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), + GET_PKT_LEN(tp), pq, IPPROTO_IPV6); PacketEnqueue(pq,tp); } } @@ -239,7 +242,8 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u Packet *tp = PacketPseudoPktSetup(p, pkt + header_len, len - header_len, VLAN_OVER_GRE); if (tp != NULL) { - DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), GET_PKT_LEN(tp), pq); + DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), + GET_PKT_LEN(tp), pq, VLAN_OVER_GRE); PacketEnqueue(pq,tp); } } diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 608f0bc783..a2eb49c2b8 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -575,7 +575,8 @@ void DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, IPV4_GET_IPPROTO(p)); if (tp != NULL) { /* send that to the Tunnel decoder */ - DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), GET_PKT_LEN(tp), pq); + DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp), + GET_PKT_LEN(tp), pq, IPV4_GET_IPPROTO(p)); /* add the tp to the packet queue. */ PacketEnqueue(pq,tp); diff --git a/src/decode.c b/src/decode.c index fd5f07f8b8..856bdf7f57 100644 --- a/src/decode.c +++ b/src/decode.c @@ -33,9 +33,10 @@ #include "util-error.h" #include "tmqh-packetpool.h" -void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq) +void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, + uint8_t *pkt, uint16_t len, PacketQueue *pq, uint8_t proto) { - switch (p->tunnel_proto) { + switch (proto) { case PPP_OVER_GRE: return DecodePPP(tv, dtv, p, pkt, len, pq); case IPPROTO_IP: @@ -45,7 +46,7 @@ void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt case VLAN_OVER_GRE: return DecodeVLAN(tv, dtv, p, pkt, len, pq); default: - SCLogInfo("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", p->tunnel_proto); + SCLogInfo("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", proto); break; } } @@ -108,7 +109,6 @@ Packet *PacketPseudoPktSetup(Packet *parent, uint8_t *pkt, uint16_t len, uint8_t p->root = parent; /* copy packet and set lenght, proto */ - p->tunnel_proto = proto; PacketCopyData(p, pkt, len); p->recursion_level = parent->recursion_level + 1; p->ts.tv_sec = parent->ts.tv_sec; diff --git a/src/decode.h b/src/decode.h index 482dcf4869..111ab5fcf2 100644 --- a/src/decode.h +++ b/src/decode.h @@ -386,8 +386,6 @@ typedef struct Packet_ /* tunnel packet ref count */ uint8_t tpr_cnt; SCMutex mutex_rtv_cnt; - /* tunnel stuff */ - uint8_t tunnel_proto; /* decoder events */ PacketDecoderEvents events; @@ -582,7 +580,6 @@ typedef struct DecodeThreadVars_ (p)->tpr_cnt = 0; \ SCMutexDestroy(&(p)->mutex_rtv_cnt); \ SCMutexInit(&(p)->mutex_rtv_cnt, NULL); \ - (p)->tunnel_proto = 0; \ (p)->events.cnt = 0; \ (p)->next = NULL; \ (p)->prev = NULL; \ @@ -718,7 +715,7 @@ void DecodeSll(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, void DecodePPP(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); void DecodePPPOESession(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); void DecodePPPOEDiscovery(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); -void DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); +void DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *, uint8_t); void DecodeRaw(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); void DecodeIPV4(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); void DecodeIPV6(ThreadVars *, DecodeThreadVars *, Packet *, uint8_t *, uint16_t, PacketQueue *); diff --git a/src/stream-tcp.c b/src/stream-tcp.c index e072ce8489..9428eddf01 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -4449,7 +4449,6 @@ Packet *StreamTcpPseudoSetup(Packet *parent, uint8_t *pkt, uint32_t len) p->root = parent; /* copy packet and set lenght, proto */ - p->tunnel_proto = parent->proto; p->proto = parent->proto; p->datalink = parent->datalink;