From: Victor Julien Date: Wed, 27 Mar 2024 11:07:51 +0000 (+0100) Subject: decode/icmpv6: remove embedded address storage X-Git-Tag: suricata-8.0.0-beta1~1390 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b492c2dedf96a4c8e331dc8860545a90b63e0f9;p=thirdparty%2Fsuricata.git decode/icmpv6: remove embedded address storage Only used in tests. For the tests, switch to getting headers from embedded IPv6 header. Part of effort to make Packet more compact. Ticket: #6938. --- diff --git a/src/decode-icmpv6.c b/src/decode-icmpv6.c index 665bdc9fa8..0832414979 100644 --- a/src/decode-icmpv6.c +++ b/src/decode-icmpv6.c @@ -68,18 +68,6 @@ static void DecodePartialIPV6(Packet *p, uint8_t *partial_packet, uint16_t len ) /** We need to fill icmpv6vars */ p->icmpv6vars.emb_ipv6h = icmp6_ip6h; - - /** Get the IP6 address */ - p->icmpv6vars.emb_ip6_src[0] = icmp6_ip6h->s_ip6_src[0]; - p->icmpv6vars.emb_ip6_src[1] = icmp6_ip6h->s_ip6_src[1]; - p->icmpv6vars.emb_ip6_src[2] = icmp6_ip6h->s_ip6_src[2]; - p->icmpv6vars.emb_ip6_src[3] = icmp6_ip6h->s_ip6_src[3]; - - p->icmpv6vars.emb_ip6_dst[0] = icmp6_ip6h->s_ip6_dst[0]; - p->icmpv6vars.emb_ip6_dst[1] = icmp6_ip6h->s_ip6_dst[1]; - p->icmpv6vars.emb_ip6_dst[2] = icmp6_ip6h->s_ip6_dst[2]; - p->icmpv6vars.emb_ip6_dst[3] = icmp6_ip6h->s_ip6_dst[3]; - /** Get protocol and ports inside the embedded ipv6 packet and set the pointers */ p->icmpv6vars.emb_ip6_proto_next = icmp6_ip6h->s_ip6_nxt; @@ -132,8 +120,8 @@ static void DecodePartialIPV6(Packet *p, uint8_t *partial_packet, uint16_t len ) /* debug print */ #ifdef DEBUG char s[46], d[46]; - PrintInet(AF_INET6, (const void *)p->icmpv6vars.emb_ip6_src, s, sizeof(s)); - PrintInet(AF_INET6, (const void *)p->icmpv6vars.emb_ip6_dst, d, sizeof(d)); + PrintInet(AF_INET6, (const void *)ICMPV6_GET_EMB_IPV6(p)->s_ip6_src, s, sizeof(s)); + PrintInet(AF_INET6, (const void *)ICMPV6_GET_EMB_IPV6(p)->s_ip6_dst, d, sizeof(d)); SCLogDebug("ICMPv6 embedding IPV6 %s->%s - CLASS: %" PRIu32 " FLOW: " "%" PRIu32 " NH: %" PRIu32 " PLEN: %" PRIu32 " HLIM: %" PRIu32, s, d, IPV6_GET_RAW_CLASS(icmp6_ip6h), IPV6_GET_RAW_FLOW(icmp6_ip6h), @@ -627,10 +615,9 @@ static int ICMPV6ParamProbTest01(void) ICMPV6_GET_EMB_PROTO(p) != IPPROTO_ICMPV6); /* Let's check if we retrieved the embedded ipv6 addresses correctly */ - uint32_t i=0; - for (i = 0; i < 4; i++) { - FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] || - p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]); + for (int i = 0; i < 4; i++) { + FAIL_IF(ICMPV6_GET_EMB_IPV6(p)->s_ip6_src[i] != ipv6src[i] || + ICMPV6_GET_EMB_IPV6(p)->s_ip6_dst[i] != ipv6dst[i]); } PacketRecycle(p); @@ -683,10 +670,9 @@ static int ICMPV6PktTooBigTest01(void) FAIL_IF(ICMPV6_GET_TYPE(p) != 2 || ICMPV6_GET_CODE(p) != 0 ); /* Let's check if we retrieved the embedded ipv6 addresses correctly */ - uint32_t i=0; - for (i = 0; i < 4; i++) { - FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] || - p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]); + for (int i = 0; i < 4; i++) { + FAIL_IF(ICMPV6_GET_EMB_IPV6(p)->s_ip6_src[i] != ipv6src[i] || + ICMPV6_GET_EMB_IPV6(p)->s_ip6_dst[i] != ipv6dst[i]); } SCLogDebug("ICMPV6 IPV6 src and dst properly set"); @@ -741,10 +727,9 @@ static int ICMPV6TimeExceedTest01(void) ICMPV6_GET_EMB_PROTO(p) != IPPROTO_NONE); /* Let's check if we retrieved the embedded ipv6 addresses correctly */ - uint32_t i=0; - for (i = 0; i < 4; i++) { - FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] || - p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]); + for (int i = 0; i < 4; i++) { + FAIL_IF(ICMPV6_GET_EMB_IPV6(p)->s_ip6_src[i] != ipv6src[i] || + ICMPV6_GET_EMB_IPV6(p)->s_ip6_dst[i] != ipv6dst[i]); } SCLogDebug("ICMPV6 IPV6 src and dst properly set"); @@ -799,10 +784,9 @@ static int ICMPV6DestUnreachTest01(void) ICMPV6_GET_EMB_PROTO(p) != IPPROTO_NONE); /* Let's check if we retrieved the embedded ipv6 addresses correctly */ - uint32_t i=0; - for (i = 0; i < 4; i++) { - FAIL_IF(p->icmpv6vars.emb_ip6_src[i] != ipv6src[i] || - p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]); + for (int i = 0; i < 4; i++) { + FAIL_IF(ICMPV6_GET_EMB_IPV6(p)->s_ip6_src[i] != ipv6src[i] || + ICMPV6_GET_EMB_IPV6(p)->s_ip6_dst[i] != ipv6dst[i]); } PacketRecycle(p); diff --git a/src/decode-icmpv6.h b/src/decode-icmpv6.h index b4d7124a39..f12dc10043 100644 --- a/src/decode-icmpv6.h +++ b/src/decode-icmpv6.h @@ -162,9 +162,6 @@ typedef struct ICMPV6Vars_ { /** Pointers to the embedded packet headers */ IPV6Hdr *emb_ipv6h; - /** IPv6 src and dst address */ - uint32_t emb_ip6_src[4]; - uint32_t emb_ip6_dst[4]; uint8_t emb_ip6_proto_next; bool emb_ports_set;