From: Victor Julien Date: Thu, 11 Apr 2024 15:37:15 +0000 (+0200) Subject: decode/icmpv4: rename ICMPV4_GET_EMB_IPV4 to PacketGetICMPv4EmbIPv4 X-Git-Tag: suricata-8.0.0-beta1~1363 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dfa5793dbb3ab1b7f1a730490a786f858650b46;p=thirdparty%2Fsuricata.git decode/icmpv4: rename ICMPV4_GET_EMB_IPV4 to PacketGetICMPv4EmbIPv4 Follows function nameing style. Ticket: #5517. --- diff --git a/src/decode-icmpv4.c b/src/decode-icmpv4.c index cd5708a626..33ed09ada4 100644 --- a/src/decode-icmpv4.c +++ b/src/decode-icmpv4.c @@ -506,8 +506,8 @@ static int DecodeICMPV4test03(void) FAIL_IF(p->l4.vars.icmpv4.emb_dport != 33450); /* check the src,dst IPs contained inside */ - uint32_t src_ip = IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p)); - uint32_t dst_ip = IPV4_GET_RAW_IPDST_U32(ICMPV4_GET_EMB_IPV4(p)); + uint32_t src_ip = IPV4_GET_RAW_IPSRC_U32(PacketGetICMPv4EmbIPv4(p)); + uint32_t dst_ip = IPV4_GET_RAW_IPDST_U32(PacketGetICMPv4EmbIPv4(p)); char s[16], d[16]; PrintInet(AF_INET, &src_ip, s, sizeof(s)); PrintInet(AF_INET, &dst_ip, d, sizeof(d)); @@ -574,8 +574,8 @@ static int DecodeICMPV4test04(void) } // check the src,dst IPs contained inside - uint32_t src_ip = IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p)); - uint32_t dst_ip = IPV4_GET_RAW_IPDST_U32(ICMPV4_GET_EMB_IPV4(p)); + uint32_t src_ip = IPV4_GET_RAW_IPSRC_U32(PacketGetICMPv4EmbIPv4(p)); + uint32_t dst_ip = IPV4_GET_RAW_IPDST_U32(PacketGetICMPv4EmbIPv4(p)); char s[16], d[16]; PrintInet(AF_INET, &src_ip, s, sizeof(s)); PrintInet(AF_INET, &dst_ip, d, sizeof(d)); @@ -642,8 +642,8 @@ static int DecodeICMPV4test05(void) } // check the src,dst IPs contained inside - uint32_t src_ip = IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p)); - uint32_t dst_ip = IPV4_GET_RAW_IPDST_U32(ICMPV4_GET_EMB_IPV4(p)); + uint32_t src_ip = IPV4_GET_RAW_IPSRC_U32(PacketGetICMPv4EmbIPv4(p)); + uint32_t dst_ip = IPV4_GET_RAW_IPDST_U32(PacketGetICMPv4EmbIPv4(p)); char s[16], d[16]; PrintInet(AF_INET, &src_ip, s, sizeof(s)); PrintInet(AF_INET, &dst_ip, d, sizeof(d)); diff --git a/src/decode-icmpv4.h b/src/decode-icmpv4.h index 920d896f92..730f78ffd4 100644 --- a/src/decode-icmpv4.h +++ b/src/decode-icmpv4.h @@ -252,7 +252,7 @@ typedef struct ICMPV4Timestamp_ { */ #define ICMPV4_DEST_UNREACH_IS_VALID(p) \ ((!((p)->flags & PKT_IS_INVALID)) && PacketIsICMPv4((p)) && \ - ((p)->icmp_s.type == ICMP_DEST_UNREACH) && (ICMPV4_GET_EMB_IPV4((p)) != NULL) && \ + ((p)->icmp_s.type == ICMP_DEST_UNREACH) && (PacketGetICMPv4EmbIPv4((p)) != NULL) && \ (p)->l4.vars.icmpv4.emb_ports_set) /** diff --git a/src/decode.h b/src/decode.h index e8c86a13b0..9175f6cc3c 100644 --- a/src/decode.h +++ b/src/decode.h @@ -845,7 +845,7 @@ static inline bool PacketIsICMPv4(const Packet *p) return p->l4.type == PACKET_L4_ICMPV4; } -static inline const IPV4Hdr *ICMPV4_GET_EMB_IPV4(const Packet *p) +static inline const IPV4Hdr *PacketGetICMPv4EmbIPv4(const Packet *p) { const uint8_t *start = (const uint8_t *)PacketGetICMPv4(p); const uint8_t *ip = start + p->l4.vars.icmpv4.emb_ip4h_offset; diff --git a/src/flow-hash.c b/src/flow-hash.c index 88d44d6fc2..c5063f7d37 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -218,8 +218,8 @@ static inline uint32_t FlowGetHash(const Packet *p) hash = hashword(fhk.u32, ARRAY_SIZE(fhk.u32), flow_config.hash_rand); } else if (ICMPV4_DEST_UNREACH_IS_VALID(p)) { - uint32_t psrc = IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p)); - uint32_t pdst = IPV4_GET_RAW_IPDST_U32(ICMPV4_GET_EMB_IPV4(p)); + uint32_t psrc = IPV4_GET_RAW_IPSRC_U32(PacketGetICMPv4EmbIPv4(p)); + uint32_t pdst = IPV4_GET_RAW_IPDST_U32(PacketGetICMPv4EmbIPv4(p)); FlowHashKey4 fhk = { .pad[0] = 0 }; const int ai = (psrc > pdst); @@ -468,8 +468,8 @@ static inline int FlowCompareICMPv4(Flow *f, const Packet *p) /* first check the direction of the flow, in other words, the client -> * server direction as it's most likely the ICMP error will be a * response to the clients traffic */ - if ((f->src.addr_data32[0] == IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p))) && - (f->dst.addr_data32[0] == IPV4_GET_RAW_IPDST_U32(ICMPV4_GET_EMB_IPV4(p))) && + if ((f->src.addr_data32[0] == IPV4_GET_RAW_IPSRC_U32(PacketGetICMPv4EmbIPv4(p))) && + (f->dst.addr_data32[0] == IPV4_GET_RAW_IPDST_U32(PacketGetICMPv4EmbIPv4(p))) && f->sp == p->l4.vars.icmpv4.emb_sport && f->dp == p->l4.vars.icmpv4.emb_dport && f->proto == ICMPV4_GET_EMB_PROTO(p) && f->recursion_level == p->recursion_level && CmpVlanIds(f->vlan_id, p->vlan_id) && @@ -478,8 +478,8 @@ static inline int FlowCompareICMPv4(Flow *f, const Packet *p) /* check the less likely case where the ICMP error was a response to * a packet from the server. */ - } else if ((f->dst.addr_data32[0] == IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p))) && - (f->src.addr_data32[0] == IPV4_GET_RAW_IPDST_U32(ICMPV4_GET_EMB_IPV4(p))) && + } else if ((f->dst.addr_data32[0] == IPV4_GET_RAW_IPSRC_U32(PacketGetICMPv4EmbIPv4(p))) && + (f->src.addr_data32[0] == IPV4_GET_RAW_IPDST_U32(PacketGetICMPv4EmbIPv4(p))) && f->dp == p->l4.vars.icmpv4.emb_sport && f->sp == p->l4.vars.icmpv4.emb_dport && f->proto == ICMPV4_GET_EMB_PROTO(p) && f->recursion_level == p->recursion_level && CmpVlanIds(f->vlan_id, p->vlan_id) &&