From: Victor Julien Date: Fri, 22 Mar 2024 09:34:31 +0000 (+0100) Subject: decode: reduce PKT_IS_IPV4/PKT_IS_IPV6 use X-Git-Tag: suricata-8.0.0-beta1~1409 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb3ca643c1dd7c8e2fe9e9141145a6165fd9d368;p=thirdparty%2Fsuricata.git decode: reduce PKT_IS_IPV4/PKT_IS_IPV6 use Replace it with inline functions. Adds inline functions to wrap PKT_IS_IPV4/PKT_IS_IPV6. This is in preparation of removing the macro's, and cleaning up the header pointers. Ticket: #5517. --- diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index aaba84cc6e..1d1c28301d 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -173,11 +173,11 @@ static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_da MemBufferWriteString(aft->buffer, "PKT SRC: %s\n", pkt_src_str); char srcip[46], dstip[46]; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); } else { - DEBUG_VALIDATE_BUG_ON(!(PKT_IS_IPV6(p))); + DEBUG_VALIDATE_BUG_ON(!(PacketIsIPv6(p))); PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip)); } @@ -473,7 +473,7 @@ static bool AlertDebugLogCondition(ThreadVars *tv, void *thread_data, const Pack static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet *p) { - if (PKT_IS_IPV4(p) || PKT_IS_IPV6(p)) { + if (PacketIsIPv4(p) || PacketIsIPv6(p)) { return AlertDebugLogger(tv, p, thread_data); } else if (p->events.cnt > 0) { return AlertDebugLogDecoderEvent(tv, p, thread_data); diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 91f2c5b85d..29f3e9dc0a 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -109,10 +109,10 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p) CreateTimeString(p->ts, timebuf, sizeof(timebuf)); char srcip[46], dstip[46]; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip)); } else { diff --git a/src/alert-syslog.c b/src/alert-syslog.c index 8d749af3fc..7b89150766 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -364,9 +364,9 @@ static bool AlertSyslogCondition(ThreadVars *tv, void *thread_data, const Packet static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { return AlertSyslogIPv4(tv, p, thread_data); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { return AlertSyslogIPv6(tv, p, thread_data); } else if (p->events.cnt > 0) { return AlertSyslogDecoderEvent(tv, p, thread_data); diff --git a/src/decode-chdlc.c b/src/decode-chdlc.c index 1306114b8d..10fe3fec0f 100644 --- a/src/decode-chdlc.c +++ b/src/decode-chdlc.c @@ -88,7 +88,7 @@ static int DecodeCHDLCTest01 (void) DecodeCHDLC(&tv, &dtv, p, raw, sizeof(raw)); - FAIL_IF_NOT(PKT_IS_IPV4(p)); + FAIL_IF_NOT(PacketIsIPv4(p)); FAIL_IF_NOT(PKT_IS_TCP(p)); FAIL_IF_NOT(p->dp == 80); diff --git a/src/decode-raw.c b/src/decode-raw.c index 1a64f1adf9..73d0ee726b 100644 --- a/src/decode-raw.c +++ b/src/decode-raw.c @@ -113,12 +113,7 @@ static int DecodeRawTest01 (void) FlowInitConfig(FLOW_QUIET); DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p)); - if (p->ip6h == NULL) { - printf("expected a valid ipv6 header but it was NULL: "); - FlowShutdown(); - SCFree(p); - return 0; - } + FAIL_IF_NOT(PacketIsIPv6(p)); PacketRecycle(p); FlowShutdown(); @@ -159,13 +154,7 @@ static int DecodeRawTest02 (void) FlowInitConfig(FLOW_QUIET); DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p)); - if (p->ip4h == NULL) { - printf("expected a valid ipv4 header but it was NULL: "); - PacketRecycle(p); - FlowShutdown(); - SCFree(p); - return 0; - } + FAIL_IF_NOT(PacketIsIPv4(p)); PacketRecycle(p); FlowShutdown(); diff --git a/src/decode.h b/src/decode.h index df9649e693..ddc02a7758 100644 --- a/src/decode.h +++ b/src/decode.h @@ -690,6 +690,16 @@ static inline uint8_t PacketGetIPProto(const Packet *p) } } +static inline bool PacketIsIPv4(const Packet *p) +{ + return PKT_IS_IPV4(p); +} + +static inline bool PacketIsIPv6(const Packet *p) +{ + return PKT_IS_IPV6(p); +} + /** \brief Structure to hold thread specific data for all decode modules */ typedef struct DecodeThreadVars_ { diff --git a/src/defrag-config.c b/src/defrag-config.c index adb8847049..5054ec289b 100644 --- a/src/defrag-config.c +++ b/src/defrag-config.c @@ -93,9 +93,9 @@ int DefragPolicyGetHostTimeout(Packet *p) { int timeout = 0; - if (PKT_IS_IPV4(p)) + if (PacketIsIPv4(p)) timeout = DefragPolicyGetIPv4HostTimeout((uint8_t *)GET_IPV4_DST_ADDR_PTR(p)); - else if (PKT_IS_IPV6(p)) + else if (PacketIsIPv6(p)) timeout = DefragPolicyGetIPv6HostTimeout((uint8_t *)GET_IPV6_DST_ADDR(p)); if (timeout <= 0) diff --git a/src/defrag-hash.c b/src/defrag-hash.c index 41e79bf84e..a1355007fa 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -127,7 +127,7 @@ static void DefragTrackerInit(DefragTracker *dt, Packet *p) COPY_ADDRESS(&p->src, &dt->src_addr); COPY_ADDRESS(&p->dst, &dt->dst_addr); - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { dt->id = (int32_t)IPV4_GET_IPID(p); dt->af = AF_INET; } else { @@ -450,7 +450,7 @@ static inline uint32_t DefragHashGetKey(Packet *p) static inline int DefragTrackerCompare(DefragTracker *t, Packet *p) { uint32_t id; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { id = (uint32_t)IPV4_GET_IPID(p); } else { id = IPV6_EXTHDR_GET_FH_ID(p); diff --git a/src/defrag.c b/src/defrag.c index fede1b927a..05ecbf385d 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -971,10 +971,9 @@ DefragGetOsPolicy(Packet *p) { int policy = -1; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { policy = SCHInfoGetIPv4HostOSFlavour((uint8_t *)GET_IPV4_DST_ADDR_PTR(p)); - } - else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { policy = SCHInfoGetIPv6HostOSFlavour((uint8_t *)GET_IPV6_DST_ADDR(p)); } @@ -1053,17 +1052,15 @@ Defrag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p) DefragTracker *tracker; int af; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { af = AF_INET; more_frags = IPV4_GET_MF(p); frag_offset = IPV4_GET_IPOFFSET(p); - } - else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { af = AF_INET6; frag_offset = IPV6_EXTHDR_GET_FH_OFFSET(p); more_frags = IPV6_EXTHDR_GET_FH_FLAG(p); - } - else { + } else { return NULL; } diff --git a/src/detect-csum.c b/src/detect-csum.c index ba2088a61e..142a5c7f64 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -417,7 +417,7 @@ static int DetectTCPV6CsumMatch(DetectEngineThreadCtx *det_ctx, { const DetectCsumData *cd = (const DetectCsumData *)ctx; - if (p->ip6h == NULL || p->tcph == NULL || p->proto != IPPROTO_TCP || PKT_IS_PSEUDOPKT(p)) + if (!PacketIsIPv6(p) || p->tcph == NULL || p->proto != IPPROTO_TCP || PKT_IS_PSEUDOPKT(p)) return 0; if (p->flags & PKT_IGNORE_CHECKSUM) { @@ -597,7 +597,7 @@ static int DetectUDPV6CsumMatch(DetectEngineThreadCtx *det_ctx, { const DetectCsumData *cd = (const DetectCsumData *)ctx; - if (p->ip6h == NULL || p->udph == NULL || p->proto != IPPROTO_UDP || PKT_IS_PSEUDOPKT(p)) + if (!PacketIsIPv6(p) || p->udph == NULL || p->proto != IPPROTO_UDP || PKT_IS_PSEUDOPKT(p)) return 0; if (p->flags & PKT_IGNORE_CHECKSUM) { @@ -775,8 +775,9 @@ static int DetectICMPV6CsumMatch(DetectEngineThreadCtx *det_ctx, { const DetectCsumData *cd = (const DetectCsumData *)ctx; - if (p->ip6h == NULL || p->icmpv6h == NULL || p->proto != IPPROTO_ICMPV6 || PKT_IS_PSEUDOPKT(p) || - (GET_PKT_LEN(p) - ((uint8_t *)p->icmpv6h - GET_PKT_DATA(p))) <= 0) { + if (!PacketIsIPv6(p) || p->icmpv6h == NULL || p->proto != IPPROTO_ICMPV6 || + PKT_IS_PSEUDOPKT(p) || + (GET_PKT_LEN(p) - ((uint8_t *)p->icmpv6h - GET_PKT_DATA(p))) <= 0) { return 0; } diff --git a/src/detect-engine-alert.c b/src/detect-engine-alert.c index 39ce79818c..2ef1e19ca5 100644 --- a/src/detect-engine-alert.c +++ b/src/detect-engine-alert.c @@ -77,7 +77,7 @@ static int PacketAlertHandle(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det const DetectThresholdData *td = NULL; const SigMatchData *smd; - if (!(PKT_IS_IPV4(p) || PKT_IS_IPV6(p))) { + if (!(PacketIsIPv4(p) || PacketIsIPv6(p))) { SCReturnInt(1); } diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index 778cdd857e..b4d8b86aa1 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -1049,11 +1049,11 @@ void IPOnlyMatchPacket(ThreadVars *tv, const DetectEngineCtx *de_ctx, if (bitarray & 0x01) { const Signature *s = de_ctx->sig_array[io_ctx->sig_mapping[u * 8 + i]]; - if ((s->proto.flags & DETECT_PROTO_IPV4) && !PKT_IS_IPV4(p)) { + if ((s->proto.flags & DETECT_PROTO_IPV4) && !PacketIsIPv4(p)) { SCLogDebug("ip version didn't match"); continue; } - if ((s->proto.flags & DETECT_PROTO_IPV6) && !PKT_IS_IPV6(p)) { + if ((s->proto.flags & DETECT_PROTO_IPV6) && !PacketIsIPv6(p)) { SCLogDebug("ip version didn't match"); continue; } diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index b528892301..26635d2e01 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -142,7 +142,7 @@ FragBitsMatch(const uint8_t pbits, const uint8_t modifier, static int DetectFragBitsMatch (DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx) { - if (!ctx || !PKT_IS_IPV4(p) || PKT_IS_PSEUDOPKT(p)) + if (!ctx || !PacketIsIPv4(p) || PKT_IS_PSEUDOPKT(p)) return 0; uint8_t fragbits = 0; @@ -321,7 +321,7 @@ PrefilterPacketFragBitsMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const vo { const PrefilterPacketHeaderCtx *ctx = pectx; - if (!PKT_IS_IPV4(p) || PKT_IS_PSEUDOPKT(p)) + if (!PacketIsIPv4(p) || PKT_IS_PSEUDOPKT(p)) return; uint8_t fragbits = 0; diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index b4b21ff58e..2151c3c8b1 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -114,9 +114,9 @@ static int DetectFragOffsetMatch (DetectEngineThreadCtx *det_ctx, if (PKT_IS_PSEUDOPKT(p)) return 0; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { frag = IPV4_GET_IPOFFSET(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { if (IPV6_EXTHDR_ISSET_FH(p)) { frag = IPV6_EXTHDR_GET_FH_OFFSET(p); } else { @@ -268,9 +268,9 @@ PrefilterPacketFragOffsetMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const uint16_t frag; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { frag = IPV4_GET_IPOFFSET(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { if (IPV6_EXTHDR_ISSET_FH(p)) { frag = IPV6_EXTHDR_GET_FH_OFFSET(p); } else { diff --git a/src/detect-geoip.c b/src/detect-geoip.c index 9198b9e451..92fb2072a2 100644 --- a/src/detect-geoip.c +++ b/src/detect-geoip.c @@ -253,8 +253,7 @@ static int DetectGeoipMatch(DetectEngineThreadCtx *det_ctx, if (PKT_IS_PSEUDOPKT(p)) return 0; - if (PKT_IS_IPV4(p)) - { + if (PacketIsIPv4(p)) { if (geoipdata->flags & ( GEOIP_MATCH_SRC_FLAG | GEOIP_MATCH_BOTH_FLAG )) { if (CheckGeoMatchIPv4(geoipdata, GET_IPV4_SRC_ADDR_U32(p))) diff --git a/src/detect-id.c b/src/detect-id.c index 6725b7c136..75634b0569 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -98,7 +98,7 @@ static int DetectIdMatch (DetectEngineThreadCtx *det_ctx, Packet *p, /** * To match a ipv4 packet with a "id" rule */ - if (!PKT_IS_IPV4(p) || PKT_IS_PSEUDOPKT(p)) { + if (!PacketIsIPv4(p) || PKT_IS_PSEUDOPKT(p)) { return 0; } @@ -225,7 +225,7 @@ PrefilterPacketIdMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pe { const PrefilterPacketHeaderCtx *ctx = pectx; - if (!PKT_IS_IPV4(p) || PKT_IS_PSEUDOPKT(p)) { + if (!PacketIsIPv4(p) || PKT_IS_PSEUDOPKT(p)) { return; } diff --git a/src/detect-ipaddr.c b/src/detect-ipaddr.c index d2dd6ceb2a..aeac80f71d 100644 --- a/src/detect-ipaddr.c +++ b/src/detect-ipaddr.c @@ -120,10 +120,10 @@ static InspectionBuffer *GetDataSrc(DetectEngineThreadCtx *det_ctx, { InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id); if (buffer->inspect == NULL) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { /* Suricata stores the IPv4 at the beginning of the field */ InspectionBufferSetup(det_ctx, list_id, buffer, p->src.address.address_un_data8, 4); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { InspectionBufferSetup(det_ctx, list_id, buffer, p->src.address.address_un_data8, 16); } else { return NULL; @@ -144,10 +144,10 @@ static InspectionBuffer *GetDataDst(DetectEngineThreadCtx *det_ctx, { InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id); if (buffer->inspect == NULL) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { /* Suricata stores the IPv4 at the beginning of the field */ InspectionBufferSetup(det_ctx, list_id, buffer, p->dst.address.address_un_data8, 4); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { InspectionBufferSetup(det_ctx, list_id, buffer, p->dst.address.address_un_data8, 16); } else { return NULL; diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index 9af6660fe5..0c69b7e539 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -159,7 +159,7 @@ static int DetectIpOptsMatch (DetectEngineThreadCtx *det_ctx, Packet *p, { const DetectIpOptsData *de = (const DetectIpOptsData *)ctx; - if (!de || !PKT_IS_IPV4(p) || PKT_IS_PSEUDOPKT(p)) + if (!de || !PacketIsIPv4(p) || PKT_IS_PSEUDOPKT(p)) return 0; return (p->ip4vars.opts_set & de->ipopt) == de->ipopt; diff --git a/src/detect-ipv6hdr.c b/src/detect-ipv6hdr.c index eacff043a9..b796294400 100644 --- a/src/detect-ipv6hdr.c +++ b/src/detect-ipv6hdr.c @@ -100,8 +100,7 @@ static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id); if (buffer->inspect == NULL) { - if (p->ip6h == NULL) { - // DETECT_PROTO_IPV6 does not prefilter + if (!PacketIsIPv6(p)) { return NULL; } uint32_t hlen = IPV6_HEADER_LEN + IPV6_GET_EXTHDRS_LEN(p); diff --git a/src/detect-template.c b/src/detect-template.c index 5e09170d82..980607f0c3 100644 --- a/src/detect-template.c +++ b/src/detect-template.c @@ -96,9 +96,9 @@ static int DetectTemplateMatch (DetectEngineThreadCtx *det_ctx, Packet *p, /* fake pkt */ } - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { /* ipv4 pkt */ - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { /* ipv6 pkt */ } else { SCLogDebug("packet is of not IPv4 or IPv6"); diff --git a/src/detect-template2.c b/src/detect-template2.c index df93a535e6..411a2a1ae9 100644 --- a/src/detect-template2.c +++ b/src/detect-template2.c @@ -83,9 +83,9 @@ static int DetectTemplate2Match (DetectEngineThreadCtx *det_ctx, Packet *p, /* TODO replace this */ uint8_t ptemplate2; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { ptemplate2 = IPV4_GET_IPTTL(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { ptemplate2 = IPV6_GET_HLIM(p); } else { SCLogDebug("Packet is of not IPv4 or IPv6"); @@ -143,9 +143,9 @@ PrefilterPacketTemplate2Match(DetectEngineThreadCtx *det_ctx, Packet *p, const v uint8_t ptemplate2; /* TODO update */ - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { ptemplate2 = IPV4_GET_IPTTL(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { ptemplate2 = IPV6_GET_HLIM(p); } else { SCLogDebug("Packet is of not IPv4 or IPv6"); diff --git a/src/detect-tos.c b/src/detect-tos.c index e8c1fe6f62..c268e7946c 100644 --- a/src/detect-tos.c +++ b/src/detect-tos.c @@ -96,7 +96,7 @@ static int DetectTosMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const DetectTosData *tosd = (const DetectTosData *)ctx; int result = 0; - if (!PKT_IS_IPV4(p) || PKT_IS_PSEUDOPKT(p)) { + if (!PacketIsIPv4(p) || PKT_IS_PSEUDOPKT(p)) { return 0; } diff --git a/src/detect-ttl.c b/src/detect-ttl.c index 6d0a253118..763f655330 100644 --- a/src/detect-ttl.c +++ b/src/detect-ttl.c @@ -87,9 +87,9 @@ static int DetectTtlMatch (DetectEngineThreadCtx *det_ctx, Packet *p, return 0; uint8_t pttl; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { pttl = IPV4_GET_IPTTL(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { pttl = IPV6_GET_HLIM(p); } else { SCLogDebug("Packet is not IPv4 or IPv6"); @@ -145,9 +145,9 @@ PrefilterPacketTtlMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *p } uint8_t pttl; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { pttl = IPV4_GET_IPTTL(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { pttl = IPV6_GET_HLIM(p); } else { SCLogDebug("Packet is not IPv4 or IPv6"); diff --git a/src/detect.c b/src/detect.c index c46da04fb5..1575d9d81c 100644 --- a/src/detect.c +++ b/src/detect.c @@ -223,7 +223,7 @@ const SigGroupHead *SigMatchSignaturesGetSgh(const DetectEngineCtx *de_ctx, if (p->proto == 0 && p->events.cnt > 0) { SCReturnPtr(de_ctx->decoder_event_sgh, "SigGroupHead"); } else if (p->proto == 0) { - if (!(PKT_IS_IPV4(p) || PKT_IS_IPV6(p))) { + if (!(PacketIsIPv4(p) || PacketIsIPv6(p))) { /* not IP, so nothing to do */ SCReturnPtr(NULL, "SigGroupHead"); } @@ -608,11 +608,11 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co } } - if ((s_proto_flags & DETECT_PROTO_IPV4) && !PKT_IS_IPV4(p)) { + if ((s_proto_flags & DETECT_PROTO_IPV4) && !PacketIsIPv4(p)) { SCLogDebug("ip version didn't match"); return false; } - if ((s_proto_flags & DETECT_PROTO_IPV6) && !PKT_IS_IPV6(p)) { + if ((s_proto_flags & DETECT_PROTO_IPV6) && !PacketIsIPv6(p)) { SCLogDebug("ip version didn't match"); return false; } @@ -649,20 +649,20 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co /* check the destination address */ if (!(sflags & SIG_FLAG_DST_ANY)) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { if (DetectAddressMatchIPv4(s->addr_dst_match4, s->addr_dst_match4_cnt, &p->dst) == 0) return false; - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { if (DetectAddressMatchIPv6(s->addr_dst_match6, s->addr_dst_match6_cnt, &p->dst) == 0) return false; } } /* check the source address */ if (!(sflags & SIG_FLAG_SRC_ANY)) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { if (DetectAddressMatchIPv4(s->addr_src_match4, s->addr_src_match4_cnt, &p->src) == 0) return false; - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { if (DetectAddressMatchIPv6(s->addr_src_match6, s->addr_src_match6_cnt, &p->src) == 0) return false; } diff --git a/src/flow-util.c b/src/flow-util.c index 672abc23d2..32df988170 100644 --- a/src/flow-util.c +++ b/src/flow-util.c @@ -153,12 +153,12 @@ void FlowInit(Flow *f, const Packet *p) f->vlan_idx = p->vlan_idx; f->livedev = p->livedev; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { FLOW_SET_IPV4_SRC_ADDR_FROM_PACKET(p, &f->src); FLOW_SET_IPV4_DST_ADDR_FROM_PACKET(p, &f->dst); f->min_ttl_toserver = f->max_ttl_toserver = IPV4_GET_IPTTL((p)); f->flags |= FLOW_IPV4; - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { FLOW_SET_IPV6_SRC_ADDR_FROM_PACKET(p, &f->src); FLOW_SET_IPV6_DST_ADDR_FROM_PACKET(p, &f->dst); f->min_ttl_toserver = f->max_ttl_toserver = IPV6_GET_HLIM((p)); diff --git a/src/flow.c b/src/flow.c index ce09ccfe7c..ae61506b11 100644 --- a/src/flow.c +++ b/src/flow.c @@ -437,9 +437,9 @@ void FlowHandlePacketUpdate(Flow *f, Packet *p, ThreadVars *tv, DecodeThreadVars } FlowUpdateEthernet(tv, dtv, f, p->ethh, true); /* update flow's ttl fields if needed */ - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { FlowUpdateTtlTS(f, p, IPV4_GET_IPTTL(p)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { FlowUpdateTtlTS(f, p, IPV6_GET_HLIM(p)); } } else { @@ -459,9 +459,9 @@ void FlowHandlePacketUpdate(Flow *f, Packet *p, ThreadVars *tv, DecodeThreadVars } FlowUpdateEthernet(tv, dtv, f, p->ethh, false); /* update flow's ttl fields if needed */ - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { FlowUpdateTtlTC(f, p, IPV4_GET_IPTTL(p)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { FlowUpdateTtlTC(f, p, IPV6_GET_HLIM(p)); } } diff --git a/src/log-httplog.c b/src/log-httplog.c index 68fa62e95b..0284bde227 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -492,9 +492,9 @@ int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, v } int r = 0; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { r = LogHttpLogIPWrapper(tv, thread_data, p, f, (HtpState *)state, (htp_tx_t *)tx, tx_id, AF_INET); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { r = LogHttpLogIPWrapper(tv, thread_data, p, f, (HtpState *)state, (htp_tx_t *)tx, tx_id, AF_INET6); } diff --git a/src/log-tlslog.c b/src/log-tlslog.c index 6217c5fe98..2c0c862756 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -478,7 +478,7 @@ static int LogTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p, { LogTlsLogThread *aft = (LogTlsLogThread *)thread_data; LogTlsFileCtx *hlog = aft->tlslog_ctx; - int ipproto = (PKT_IS_IPV4(p)) ? AF_INET : AF_INET6; + int ipproto = (PacketIsIPv4(p)) ? AF_INET : AF_INET6; SSLState *ssl_state = (SSLState *)state; if (unlikely(ssl_state == NULL)) { diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index 50e6c6e5c4..9c9e35c7ed 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -259,7 +259,7 @@ static int LogTlsStoreLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *state, void *tx, uint64_t tx_id) { LogTlsStoreLogThread *aft = (LogTlsStoreLogThread *)thread_data; - int ipproto = (PKT_IS_IPV4(p)) ? AF_INET : AF_INET6; + int ipproto = (PacketIsIPv4(p)) ? AF_INET : AF_INET6; SSLState *ssl_state = (SSLState *)state; if (unlikely(ssl_state == NULL)) { diff --git a/src/output-eve-stream.c b/src/output-eve-stream.c index 51296c657a..e6cae76911 100644 --- a/src/output-eve-stream.c +++ b/src/output-eve-stream.c @@ -321,12 +321,12 @@ static int EveStreamLogger(ThreadVars *tv, void *thread_data, const Packet *p) jb_open_object(js, "stream_tcp"); jb_open_object(js, "packet"); - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { jb_set_uint(js, "len", IPV4_GET_IPLEN(p)); jb_set_uint(js, "tos", IPV4_GET_IPTOS(p)); jb_set_uint(js, "ttl", IPV4_GET_IPTTL(p)); jb_set_uint(js, "ipid", IPV4_GET_IPID(p)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { jb_set_uint(js, "len", IPV6_GET_PLEN(p)); jb_set_uint(js, "tc", IPV6_GET_CLASS(p)); jb_set_uint(js, "hoplimit", IPV6_GET_HLIM(p)); diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 99ffbc251d..40a6c17011 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -764,7 +764,7 @@ static int JsonAlertLogger(ThreadVars *tv, void *thread_data, const Packet *p) { JsonAlertLogThread *aft = thread_data; - if (PKT_IS_IPV4(p) || PKT_IS_IPV6(p)) { + if (PacketIsIPv4(p) || PacketIsIPv6(p)) { return AlertJson(tv, aft, p); } else if (p->alerts.cnt > 0) { return AlertJsonDecoderEvent(tv, aft, p); diff --git a/src/output-json-drop.c b/src/output-json-drop.c index edce3793d1..42c6dd05e7 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -107,13 +107,13 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p) jb_open_object(js, "drop"); uint16_t proto = 0; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { jb_set_uint(js, "len", IPV4_GET_IPLEN(p)); jb_set_uint(js, "tos", IPV4_GET_IPTOS(p)); jb_set_uint(js, "ttl", IPV4_GET_IPTTL(p)); jb_set_uint(js, "ipid", IPV4_GET_IPID(p)); proto = IPV4_GET_IPPROTO(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { jb_set_uint(js, "len", IPV6_GET_PLEN(p)); jb_set_uint(js, "tc", IPV6_GET_CLASS(p)); jb_set_uint(js, "hoplimit", IPV6_GET_HLIM(p)); diff --git a/src/output-json.c b/src/output-json.c index fe46d1ca01..56a26d9538 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -472,12 +472,12 @@ void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddr switch (dir) { case LOG_DIR_PACKET: - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), @@ -492,12 +492,12 @@ void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddr case LOG_DIR_FLOW: case LOG_DIR_FLOW_TOSERVER: if ((PKT_IS_TOSERVER(p))) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), @@ -506,12 +506,12 @@ void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddr sp = p->sp; dp = p->dp; } else { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), @@ -523,12 +523,12 @@ void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddr break; case LOG_DIR_FLOW_TOCLIENT: if ((PKT_IS_TOCLIENT(p))) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), @@ -537,12 +537,12 @@ void JsonAddrInfoInit(const Packet *p, enum OutputJsonLogDirection dir, JsonAddr sp = p->sp; dp = p->dp; } else { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), diff --git a/src/output-lua.c b/src/output-lua.c index 776cf51b9c..d2f35e8053 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -175,7 +175,7 @@ static int LuaPacketLoggerAlerts(ThreadVars *tv, void *thread_data, const Packet char timebuf[64]; CreateTimeString(p->ts, timebuf, sizeof(timebuf)); - if (!(PKT_IS_IPV4(p)) && !(PKT_IS_IPV6(p))) { + if (!(PacketIsIPv4(p)) && !(PacketIsIPv6(p))) { /* decoder event */ goto not_supported; } @@ -237,7 +237,7 @@ static int LuaPacketLogger(ThreadVars *tv, void *thread_data, const Packet *p) char timebuf[64]; - if ((!(PKT_IS_IPV4(p))) && (!(PKT_IS_IPV6(p)))) { + if ((!(PacketIsIPv4(p))) && (!(PacketIsIPv6(p)))) { goto not_supported; } @@ -281,7 +281,7 @@ static int LuaFileLogger(ThreadVars *tv, void *thread_data, const Packet *p, con SCEnter(); LogLuaThreadCtx *td = (LogLuaThreadCtx *)thread_data; - if ((!(PKT_IS_IPV4(p))) && (!(PKT_IS_IPV6(p)))) + if ((!(PacketIsIPv4(p))) && (!(PacketIsIPv6(p)))) return 0; BUG_ON(ff->flags & FILE_LOGGED); diff --git a/src/reputation.c b/src/reputation.c index 17f43ca371..67a180a324 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -149,9 +149,9 @@ uint8_t SRepCIDRGetIPRepSrc(SRepCIDRTree *cidr_ctx, Packet *p, uint8_t cat, uint { uint8_t rep = 0; - if (PKT_IS_IPV4(p)) + if (PacketIsIPv4(p)) rep = SRepCIDRGetIPv4IPRep(cidr_ctx, (uint8_t *)GET_IPV4_SRC_ADDR_PTR(p), cat); - else if (PKT_IS_IPV6(p)) + else if (PacketIsIPv6(p)) rep = SRepCIDRGetIPv6IPRep(cidr_ctx, (uint8_t *)GET_IPV6_SRC_ADDR(p), cat); return rep; @@ -161,9 +161,9 @@ uint8_t SRepCIDRGetIPRepDst(SRepCIDRTree *cidr_ctx, Packet *p, uint8_t cat, uint { uint8_t rep = 0; - if (PKT_IS_IPV4(p)) + if (PacketIsIPv4(p)) rep = SRepCIDRGetIPv4IPRep(cidr_ctx, (uint8_t *)GET_IPV4_DST_ADDR_PTR(p), cat); - else if (PKT_IS_IPV6(p)) + else if (PacketIsIPv6(p)) rep = SRepCIDRGetIPv6IPRep(cidr_ctx, (uint8_t *)GET_IPV6_DST_ADDR(p), cat); return rep; diff --git a/src/respond-reject.c b/src/respond-reject.c index e395880ef5..d6e4a8ba30 100644 --- a/src/respond-reject.c +++ b/src/respond-reject.c @@ -73,13 +73,13 @@ static TmEcode RespondRejectFunc(ThreadVars *tv, Packet *p, void *data) return TM_ECODE_OK; } - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { if (PKT_IS_TCP(p)) { (void)RejectSendIPv4TCP(tv, p, data); } else { (void)RejectSendIPv4ICMP(tv, p, data); } - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { if (PKT_IS_TCP(p)) { (void)RejectSendIPv6TCP(tv, p, data); } else { diff --git a/src/source-af-packet.c b/src/source-af-packet.c index cf4cff1925..203e76564f 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -2197,7 +2197,7 @@ static int AFPBypassCallback(Packet *p) if (PacketIsTunnel(p)) { return 0; } - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCLogDebug("add an IPv4"); if (p->afp_v.v4_map_fd == -1) { return 0; @@ -2254,8 +2254,7 @@ static int AFPBypassCallback(Packet *p) return AFPSetFlowStorage(p, p->afp_v.v4_map_fd, keys[0], keys[1], AF_INET); } /* For IPv6 case we don't handle extended header in eBPF */ - if (PKT_IS_IPV6(p) && - ((IPV6_GET_NH(p) == IPPROTO_TCP) || (IPV6_GET_NH(p) == IPPROTO_UDP))) { + if (PacketIsIPv6(p) && ((IPV6_GET_NH(p) == IPPROTO_TCP) || (IPV6_GET_NH(p) == IPPROTO_UDP))) { int i; if (p->afp_v.v6_map_fd == -1) { return 0; @@ -2352,7 +2351,7 @@ static int AFPXDPBypassCallback(Packet *p) if (PacketIsTunnel(p)) { return 0; } - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { struct flowv4_keys *keys[2]; keys[0]= SCCalloc(1, sizeof(struct flowv4_keys)); if (keys[0] == NULL) { @@ -2409,8 +2408,7 @@ static int AFPXDPBypassCallback(Packet *p) return AFPSetFlowStorage(p, p->afp_v.v4_map_fd, keys[0], keys[1], AF_INET); } /* For IPv6 case we don't handle extended header in eBPF */ - if (PKT_IS_IPV6(p) && - ((IPV6_GET_NH(p) == IPPROTO_TCP) || (IPV6_GET_NH(p) == IPPROTO_UDP))) { + if (PacketIsIPv6(p) && ((IPV6_GET_NH(p) == IPPROTO_TCP) || (IPV6_GET_NH(p) == IPPROTO_UDP))) { SCLogDebug("add an IPv6"); if (p->afp_v.v6_map_fd == -1) { return 0; diff --git a/src/stream-tcp.c b/src/stream-tcp.c index df2f7d26a0..5152660660 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -940,7 +940,7 @@ static void StreamTcpPacketSetState(Packet *p, TcpSession *ssn, */ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { /* Get the OS policy based on destination IP address, as destination OS will decide how to react on the anomalies of newly received packets */ @@ -950,7 +950,7 @@ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p) else stream->os_policy = OS_POLICY_DEFAULT; - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { /* Get the OS policy based on destination IP address, as destination OS will decide how to react on the anomalies of newly received packets */ @@ -5679,13 +5679,13 @@ static inline int StreamTcpValidateChecksum(Packet *p) return ret; if (p->level4_comp_csum == -1) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { p->level4_comp_csum = TCPChecksum(p->ip4h->s_ip_addrs, (uint16_t *)p->tcph, (p->payload_len + TCP_GET_HLEN(p)), p->tcph->th_sum); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { p->level4_comp_csum = TCPV6Checksum(p->ip6h->s_ip6_addrs, (uint16_t *)p->tcph, (p->payload_len + diff --git a/src/util-checksum.c b/src/util-checksum.c index 53a4c425b6..98c2b439de 100644 --- a/src/util-checksum.c +++ b/src/util-checksum.c @@ -28,7 +28,7 @@ int ReCalculateChecksum(Packet *p) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { if (PKT_IS_TCP(p)) { /* TCP */ p->tcph->th_sum = 0; @@ -43,7 +43,7 @@ int ReCalculateChecksum(Packet *p) p->ip4h->ip_csum = 0; p->ip4h->ip_csum = IPV4Checksum((uint16_t *)p->ip4h, IPV4_GET_RAW_HLEN(p->ip4h), 0); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { /* just TCP for IPV6 */ if (PKT_IS_TCP(p)) { p->tcph->th_sum = 0; diff --git a/src/util-lua-common.c b/src/util-lua-common.c index bb0f7899eb..0be1f5071f 100644 --- a/src/util-lua-common.c +++ b/src/util-lua-common.c @@ -328,9 +328,9 @@ static int LuaCallbackFlowHasAlerts(lua_State *luastate) static int LuaCallbackTuplePushToStackFromPacket(lua_State *luastate, const Packet *p) { int ipver = 0; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { ipver = 4; - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { ipver = 6; } lua_pushinteger(luastate, ipver); @@ -338,10 +338,10 @@ static int LuaCallbackTuplePushToStackFromPacket(lua_State *luastate, const Pack return 1; char srcip[46] = "", dstip[46] = ""; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip)); PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip)); } diff --git a/src/util-profiling.c b/src/util-profiling.c index e8a2dfa633..2d344ceadd 100644 --- a/src/util-profiling.c +++ b/src/util-profiling.c @@ -893,7 +893,7 @@ static void SCProfilingUpdatePacketDetectRecords(Packet *p) PktProfilingDetectData *pdt = &p->profile->detect[i]; if (pdt->ticks_spent > 0) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCProfilingUpdatePacketDetectRecord(i, p->proto, pdt, 4); } else { SCProfilingUpdatePacketDetectRecord(i, p->proto, pdt, 6); @@ -951,7 +951,7 @@ static void SCProfilingUpdatePacketAppRecords(Packet *p) PktProfilingAppData *pdt = &p->profile->app[i]; if (pdt->ticks_spent > 0) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCProfilingUpdatePacketAppRecord(i, p->proto, pdt, 4); } else { SCProfilingUpdatePacketAppRecord(i, p->proto, pdt, 6); @@ -960,7 +960,7 @@ static void SCProfilingUpdatePacketAppRecords(Packet *p) } if (p->profile->proto_detect > 0) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCProfilingUpdatePacketAppPdRecord(p->proto, p->profile->proto_detect, 4); } else { SCProfilingUpdatePacketAppPdRecord(p->proto, p->profile->proto_detect, 6); @@ -1011,7 +1011,7 @@ static void SCProfilingUpdatePacketTmmRecords(Packet *p) continue; } - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCProfilingUpdatePacketTmmRecord(i, p->proto, pdt, 4); } else { SCProfilingUpdatePacketTmmRecord(i, p->proto, pdt, 6); @@ -1052,7 +1052,7 @@ static void SCProfilingUpdatePacketGenericRecords(Packet *p, PktProfilingData *p struct ProfileProtoRecords *r = &records[i]; SCProfilePacketData *store = NULL; - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { store = &(r->records4[p->proto]); } else { store = &(r->records6[p->proto]); @@ -1092,7 +1092,7 @@ static void SCProfilingUpdatePacketLogRecords(Packet *p) PktProfilingLoggerData *pdt = &p->profile->logger[i]; if (pdt->ticks_spent > 0) { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCProfilingUpdatePacketLogRecord(i, p->proto, pdt, 4); } else { SCProfilingUpdatePacketLogRecord(i, p->proto, pdt, 6); @@ -1111,7 +1111,7 @@ void SCProfilingAddPacket(Packet *p) pthread_mutex_lock(&packet_profile_lock); { - if (PKT_IS_IPV4(p)) { + if (PacketIsIPv4(p)) { SCProfilePacketData *pd = &packet_profile_data4[p->proto]; uint64_t delta = p->profile->ticks_end - p->profile->ticks_start; @@ -1147,7 +1147,7 @@ void SCProfilingAddPacket(Packet *p) SCProfilingUpdatePacketDetectRecords(p); SCProfilingUpdatePacketLogRecords(p); - } else if (PKT_IS_IPV6(p)) { + } else if (PacketIsIPv6(p)) { SCProfilePacketData *pd = &packet_profile_data6[p->proto]; uint64_t delta = p->profile->ticks_end - p->profile->ticks_start;