From: Victor Julien Date: Fri, 22 Mar 2024 08:39:11 +0000 (+0100) Subject: decode: rename IP_GET_IPPROTO to PacketGetIPProto X-Git-Tag: suricata-8.0.0-beta1~1410 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=813147755d9aa554c015f4972abe63ceacdda76b;p=thirdparty%2Fsuricata.git decode: rename IP_GET_IPPROTO to PacketGetIPProto To match function naming style. Ticket: #5517. --- diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 7b4a22a859..91f2c5b85d 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -129,15 +129,15 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p) char proto[16] = ""; const char *protoptr; - if (SCProtoNameValid(IP_GET_IPPROTO(p))) { - protoptr = known_proto[IP_GET_IPPROTO(p)]; + if (SCProtoNameValid(PacketGetIPProto(p))) { + protoptr = known_proto[PacketGetIPProto(p)]; } else { - snprintf(proto, sizeof(proto), "PROTO:%03" PRIu32, IP_GET_IPPROTO(p)); + snprintf(proto, sizeof(proto), "PROTO:%03" PRIu32, PacketGetIPProto(p)); protoptr = proto; } uint16_t src_port_or_icmp = p->sp; uint16_t dst_port_or_icmp = p->dp; - if (IP_GET_IPPROTO(p) == IPPROTO_ICMP || IP_GET_IPPROTO(p) == IPPROTO_ICMPV6) { + if (PacketGetIPProto(p) == IPPROTO_ICMP || PacketGetIPProto(p) == IPPROTO_ICMPV6) { src_port_or_icmp = p->icmp_s.type; dst_port_or_icmp = p->icmp_s.code; } diff --git a/src/decode.h b/src/decode.h index cf8981a2db..df9649e693 100644 --- a/src/decode.h +++ b/src/decode.h @@ -676,7 +676,7 @@ extern uint32_t default_packet_size; #define SIZE_OF_PACKET (default_packet_size + sizeof(Packet)) /* Retrieve proto regardless of IP version */ -static inline uint8_t IP_GET_IPPROTO(const Packet *p) +static inline uint8_t PacketGetIPProto(const Packet *p) { if (p->proto != 0) { return p->proto; diff --git a/src/defrag-hash.c b/src/defrag-hash.c index 52169515eb..41e79bf84e 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -134,7 +134,7 @@ static void DefragTrackerInit(DefragTracker *dt, Packet *p) dt->id = (int32_t)IPV6_EXTHDR_GET_FH_ID(p); dt->af = AF_INET6; } - dt->proto = IP_GET_IPPROTO(p); + dt->proto = PacketGetIPProto(p); memcpy(&dt->vlan_id[0], &p->vlan_id[0], sizeof(dt->vlan_id)); dt->policy = DefragGetOsPolicy(p); dt->host_timeout = DefragPolicyGetHostTimeout(p); @@ -443,7 +443,7 @@ static inline uint32_t DefragHashGetKey(Packet *p) #define CMP_DEFRAGTRACKER(d1, d2, id) \ (((CMP_ADDR(&(d1)->src_addr, &(d2)->src) && CMP_ADDR(&(d1)->dst_addr, &(d2)->dst)) || \ (CMP_ADDR(&(d1)->src_addr, &(d2)->dst) && CMP_ADDR(&(d1)->dst_addr, &(d2)->src))) && \ - (d1)->proto == IP_GET_IPPROTO(d2) && (d1)->id == (id) && \ + (d1)->proto == PacketGetIPProto(d2) && (d1)->id == (id) && \ (d1)->vlan_id[0] == (d2)->vlan_id[0] && (d1)->vlan_id[1] == (d2)->vlan_id[1] && \ (d1)->vlan_id[2] == (d2)->vlan_id[2]) diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index 28cd88e297..778cdd857e 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -1057,7 +1057,7 @@ void IPOnlyMatchPacket(ThreadVars *tv, const DetectEngineCtx *de_ctx, SCLogDebug("ip version didn't match"); continue; } - if (DetectProtoContainsProto(&s->proto, IP_GET_IPPROTO(p)) == 0) { + if (DetectProtoContainsProto(&s->proto, PacketGetIPProto(p)) == 0) { SCLogDebug("proto didn't match"); continue; } diff --git a/src/detect.c b/src/detect.c index 0fc08ee532..c46da04fb5 100644 --- a/src/detect.c +++ b/src/detect.c @@ -232,7 +232,7 @@ const SigGroupHead *SigMatchSignaturesGetSgh(const DetectEngineCtx *de_ctx, /* select the flow_gh */ const int dir = (p->flowflags & FLOW_PKT_TOCLIENT) == 0; - int proto = IP_GET_IPPROTO(p); + int proto = PacketGetIPProto(p); if (proto == IPPROTO_TCP) { DetectPort *list = de_ctx->flow_gh[dir].tcp; SCLogDebug("tcp toserver %p, tcp toclient %p: going to use %p", de_ctx->flow_gh[1].tcp, @@ -513,7 +513,7 @@ static inline void DetectRunGetRuleGroup( bool use_flow_sgh = false; /* Get the stored sgh from the flow (if any). Make sure we're not using * the sgh for icmp error packets part of the same stream. */ - if (IP_GET_IPPROTO(p) == pflow->proto) { /* filter out icmp */ + if (PacketGetIPProto(p) == pflow->proto) { /* filter out icmp */ PACKET_PROFILING_DETECT_START(p, PROF_DETECT_GETSGH); if ((p->flowflags & FLOW_PKT_TOSERVER) && (pflow->flags & FLOW_SGH_TOSERVER)) { sgh = pflow->sgh_toserver; @@ -617,7 +617,7 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co return false; } - if (DetectProtoContainsProto(&s->proto, IP_GET_IPPROTO(p)) == 0) { + if (DetectProtoContainsProto(&s->proto, PacketGetIPProto(p)) == 0) { SCLogDebug("proto didn't match"); return false; } diff --git a/src/output-json.c b/src/output-json.c index af041c0ac0..fe46d1ca01 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -571,10 +571,10 @@ void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddr break; } - if (SCProtoNameValid(IP_GET_IPPROTO(p))) { - strlcpy(addr->proto, known_proto[IP_GET_IPPROTO(p)], sizeof(addr->proto)); + if (SCProtoNameValid(PacketGetIPProto(p))) { + strlcpy(addr->proto, known_proto[PacketGetIPProto(p)], sizeof(addr->proto)); } else { - snprintf(addr->proto, sizeof(addr->proto), "%" PRIu32, IP_GET_IPPROTO(p)); + snprintf(addr->proto, sizeof(addr->proto), "%" PRIu32, PacketGetIPProto(p)); } }