decode/ipv6: track length of ext hdrs

pull/3988/head
Victor Julien 7 years ago
parent 9252400f68
commit 3c9a557810

@ -159,6 +159,8 @@ DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt
while(1)
{
IPV6_SET_EXTHDRS_LEN(p, (len - plen));
if (nh == IPPROTO_NONE) {
if (plen > 0) {
/* No upper layer, but we do have data. Suspicious. */

@ -69,7 +69,8 @@ typedef struct IPV6Hdr_
#define IPV6_SET_RAW_VER(ip6h, value) ((ip6h)->s_ip6_vfc = (((ip6h)->s_ip6_vfc & 0x0f) | (value << 4)))
#define IPV6_SET_RAW_NH(ip6h, value) ((ip6h)->s_ip6_nxt = (value))
#define IPV6_SET_L4PROTO(p,proto) (p)->ip6vars.l4proto = proto
#define IPV6_SET_L4PROTO(p,proto) (p)->ip6vars.l4proto = (proto)
#define IPV6_SET_EXTHDRS_LEN(p,len) (p)->ip6vars.exthdrs_len = (len)
/* ONLY call these functions after making sure that:
@ -88,9 +89,11 @@ typedef struct IPV6Hdr_
IPV6_GET_RAW_PLEN((p)->ip6h)
#define IPV6_GET_HLIM(p) \
(IPV6_GET_RAW_HLIM((p)->ip6h))
/* XXX */
#define IPV6_GET_L4PROTO(p) \
((p)->ip6vars.l4proto)
#define IPV6_GET_EXTHDRS_LEN(p) \
((p)->ip6vars.exthdrs_len)
/** \brief get the highest proto/next header field we know */
//#define IPV6_GET_UPPER_PROTO(p) (p)->ip6eh.ip6_exthdrs_cnt ?
@ -99,14 +102,16 @@ typedef struct IPV6Hdr_
/* helper structure with parsed ipv6 info */
typedef struct IPV6Vars_
{
uint8_t l4proto; /* the proto after the extension headers
* store while decoding so we don't have
* to loop through the exthdrs all the time */
uint8_t l4proto; /**< the proto after the extension headers
* store while decoding so we don't have
* to loop through the exthdrs all the time */
uint16_t exthdrs_len; /**< length of the exthdrs */
} IPV6Vars;
#define CLEAR_IPV6_PACKET(p) do { \
(p)->ip6h = NULL; \
(p)->ip6vars.l4proto = 0; \
(p)->ip6vars.exthdrs_len = 0; \
memset(&(p)->ip6eh, 0x00, sizeof((p)->ip6eh)); \
} while (0)

Loading…
Cancel
Save