From: Victor Julien Date: Thu, 28 Mar 2024 10:26:36 +0000 (+0100) Subject: decode/tcp: add and use PacketIsTCP inline func X-Git-Tag: suricata-8.0.0-beta1~1383 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca912e9b37fa388e3a5e0579ebab4b864ea6c2c;p=thirdparty%2Fsuricata.git decode/tcp: add and use PacketIsTCP inline func To prepare future changes to the Packet header pointers. Ticket: #5517. --- diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index 1d1c28301d..a9973cdb0b 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -186,11 +186,11 @@ static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_da "DST IP: %s\n" "PROTO: %" PRIu32 "\n", srcip, dstip, p->proto); - if (PKT_IS_TCP(p) || PKT_IS_UDP(p)) { + if (PacketIsTCP(p) || PKT_IS_UDP(p)) { MemBufferWriteString(aft->buffer, "SRC PORT: %" PRIu32 "\n" "DST PORT: %" PRIu32 "\n", p->sp, p->dp); - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { MemBufferWriteString(aft->buffer, "TCP SEQ: %"PRIu32"\n" "TCP ACK: %"PRIu32"\n", TCP_GET_SEQ(p), TCP_GET_ACK(p)); @@ -286,8 +286,7 @@ static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_da /* This is an app layer or stream alert */ int ret; uint8_t flag; - if (!(PKT_IS_TCP(p)) || p->flow == NULL || - p->flow->protoctx == NULL) { + if (!(PacketIsTCP(p)) || p->flow == NULL || p->flow->protoctx == NULL) { return TM_ECODE_OK; } /* IDS mode reverse the data */ diff --git a/src/decode-chdlc.c b/src/decode-chdlc.c index 10fe3fec0f..83edf38e08 100644 --- a/src/decode-chdlc.c +++ b/src/decode-chdlc.c @@ -89,7 +89,7 @@ static int DecodeCHDLCTest01 (void) DecodeCHDLC(&tv, &dtv, p, raw, sizeof(raw)); FAIL_IF_NOT(PacketIsIPv4(p)); - FAIL_IF_NOT(PKT_IS_TCP(p)); + FAIL_IF_NOT(PacketIsTCP(p)); FAIL_IF_NOT(p->dp == 80); SCFree(p); diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 22134655a7..094d9ed729 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -1294,24 +1294,24 @@ static int DecodeIPV4DefragTest01(void) PacketCopyData(p, pkt1, sizeof(pkt1)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); PacketRecycle(p); PacketCopyData(p, pkt2, sizeof(pkt2)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); PacketRecycle(p); PacketCopyData(p, pkt3, sizeof(pkt3)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); Packet *tp = PacketDequeueNoLock(&tv.decode_pq); FAIL_IF_NULL(tp); FAIL_IF(tp->recursion_level != p->recursion_level); FAIL_IF_NOT(PacketIsIPv4(tp)); - FAIL_IF_NOT(PKT_IS_TCP(tp)); + FAIL_IF_NOT(PacketIsTCP(tp)); FAIL_IF(GET_PKT_LEN(tp) != sizeof(tunnel_pkt)); FAIL_IF(memcmp(GET_PKT_DATA(tp), tunnel_pkt, sizeof(tunnel_pkt)) != 0); PacketRecycle(tp); @@ -1390,25 +1390,25 @@ static int DecodeIPV4DefragTest02(void) PacketCopyData(p, pkt1, sizeof(pkt1)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); PacketRecycle(p); PacketCopyData(p, pkt2, sizeof(pkt2)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); PacketRecycle(p); p->recursion_level = 3; PacketCopyData(p, pkt3, sizeof(pkt3)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); Packet *tp = PacketDequeueNoLock(&tv.decode_pq); FAIL_IF_NULL(tp); FAIL_IF(tp->recursion_level != p->recursion_level); FAIL_IF_NOT(PacketIsIPv4(tp)); - FAIL_IF_NOT(PKT_IS_TCP(tp)); + FAIL_IF_NOT(PacketIsTCP(tp)); FAIL_IF(GET_PKT_LEN(tp) != sizeof(tunnel_pkt)); FAIL_IF(memcmp(GET_PKT_DATA(tp), tunnel_pkt, sizeof(tunnel_pkt)) != 0); PacketRecycle(tp); @@ -1481,26 +1481,26 @@ static int DecodeIPV4DefragTest03(void) PacketCopyData(p, pkt, sizeof(pkt)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF_NOT(PKT_IS_TCP(p)); + FAIL_IF_NOT(PacketIsTCP(p)); FAIL_IF(!(p->flags & PKT_WANTS_FLOW)); PacketRecycle(p); PacketCopyData(p, pkt1, sizeof(pkt1)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); PacketRecycle(p); PacketCopyData(p, pkt2, sizeof(pkt2)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); PacketRecycle(p); PacketCopyData(p, pkt3, sizeof(pkt3)); DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN, GET_PKT_LEN(p) - ETHERNET_HEADER_LEN); - FAIL_IF(PKT_IS_TCP(p)); + FAIL_IF(PacketIsTCP(p)); Packet *tp = PacketDequeueNoLock(&tv.decode_pq); FAIL_IF_NULL(tp); @@ -1508,7 +1508,7 @@ static int DecodeIPV4DefragTest03(void) FAIL_IF(tp->flow_hash != p->flow_hash); FAIL_IF(tp->recursion_level != p->recursion_level); FAIL_IF_NOT(PacketIsIPv4(tp)); - FAIL_IF_NOT(PKT_IS_TCP(tp)); + FAIL_IF_NOT(PacketIsTCP(tp)); FAIL_IF(GET_PKT_LEN(tp) != sizeof(tunnel_pkt)); FAIL_IF(memcmp(GET_PKT_DATA(tp), tunnel_pkt, sizeof(tunnel_pkt)) != 0); PacketRecycle(tp); diff --git a/src/decode-tcp.c b/src/decode-tcp.c index 97ebf8a905..61c5540f15 100644 --- a/src/decode-tcp.c +++ b/src/decode-tcp.c @@ -401,7 +401,7 @@ static int TCPGetWscaleTest01(void) FlowInitConfig(FLOW_QUIET); DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp)); - FAIL_IF_NOT(PKT_IS_TCP(p)); + FAIL_IF_NOT(PacketIsTCP(p)); uint8_t wscale = TCP_GET_WSCALE(p); FAIL_IF(wscale != 2); @@ -436,7 +436,7 @@ static int TCPGetWscaleTest02(void) FlowInitConfig(FLOW_QUIET); DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp)); - FAIL_IF_NOT(PKT_IS_TCP(p)); + FAIL_IF_NOT(PacketIsTCP(p)); uint8_t wscale = TCP_GET_WSCALE(p); FAIL_IF(wscale != 0); @@ -469,7 +469,7 @@ static int TCPGetWscaleTest03(void) FlowInitConfig(FLOW_QUIET); DecodeTCP(&tv, &dtv, p, raw_tcp, sizeof(raw_tcp)); - FAIL_IF_NOT(PKT_IS_TCP(p)); + FAIL_IF_NOT(PacketIsTCP(p)); uint8_t wscale = TCP_GET_WSCALE(p); FAIL_IF(wscale != 0); diff --git a/src/decode.h b/src/decode.h index 4fec994dc4..92f6fdd1ca 100644 --- a/src/decode.h +++ b/src/decode.h @@ -759,6 +759,11 @@ static inline void PacketClearL4(Packet *p) memset(&p->l4, 0, sizeof(p->l4)); } +static inline bool PacketIsTCP(const Packet *p) +{ + return PKT_IS_TCP(p); +} + /** \brief Structure to hold thread specific data for all decode modules */ typedef struct DecodeThreadVars_ { diff --git a/src/detect-csum.c b/src/detect-csum.c index 095ad28831..082dedd820 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -328,7 +328,7 @@ static int DetectTCPV4CsumMatch(DetectEngineThreadCtx *det_ctx, { const DetectCsumData *cd = (const DetectCsumData *)ctx; - if (!PacketIsIPv4(p) || !PKT_IS_TCP(p) || p->proto != IPPROTO_TCP || PKT_IS_PSEUDOPKT(p)) + if (!PacketIsIPv4(p) || !PacketIsTCP(p) || p->proto != IPPROTO_TCP || PKT_IS_PSEUDOPKT(p)) return 0; if (p->flags & PKT_IGNORE_CHECKSUM) { @@ -417,7 +417,7 @@ static int DetectTCPV6CsumMatch(DetectEngineThreadCtx *det_ctx, { const DetectCsumData *cd = (const DetectCsumData *)ctx; - if (!PacketIsIPv6(p) || !PKT_IS_TCP(p) || p->proto != IPPROTO_TCP || PKT_IS_PSEUDOPKT(p)) + if (!PacketIsIPv6(p) || !PacketIsTCP(p) || p->proto != IPPROTO_TCP || PKT_IS_PSEUDOPKT(p)) return 0; if (p->flags & PKT_IGNORE_CHECKSUM) { diff --git a/src/detect-engine-build.c b/src/detect-engine-build.c index 3f3f96a32c..cd42296766 100644 --- a/src/detect-engine-build.c +++ b/src/detect-engine-build.c @@ -422,7 +422,7 @@ PacketCreateMask(Packet *p, SignatureMask *mask, AppProto alproto, (*mask) |= SIG_MASK_REQUIRE_ENGINE_EVENT; } - if (!(PKT_IS_PSEUDOPKT(p)) && PKT_IS_TCP(p)) { + if (!(PKT_IS_PSEUDOPKT(p)) && PacketIsTCP(p)) { if ((p->tcph->th_flags & MASK_TCP_INITDEINIT_FLAGS) != 0) { (*mask) |= SIG_MASK_REQUIRE_FLAGS_INITDEINIT; } diff --git a/src/detect-rpc.c b/src/detect-rpc.c index 07f2956900..fcea1644dd 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -96,7 +96,7 @@ static int DetectRpcMatch (DetectEngineThreadCtx *det_ctx, Packet *p, const DetectRpcData *rd = (const DetectRpcData *)ctx; char *rpcmsg = (char *)p->payload; - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { /* if Rpc msg too small */ if (p->payload_len < 28) { SCLogDebug("TCP packet to small for the rpc msg (%u)", p->payload_len); diff --git a/src/detect-stream_size.c b/src/detect-stream_size.c index 5466480212..e8ce4336a3 100644 --- a/src/detect-stream_size.c +++ b/src/detect-stream_size.c @@ -121,7 +121,7 @@ static int DetectStreamSizeMatch( const DetectStreamSizeData *sd = (const DetectStreamSizeData *)ctx; - if (!(PKT_IS_TCP(p))) + if (!(PacketIsTCP(p))) return 0; if (p->flow == NULL || p->flow->protoctx == NULL) return 0; @@ -170,7 +170,7 @@ void DetectStreamSizeFree(DetectEngineCtx *de_ctx, void *ptr) static void PrefilterPacketStreamsizeMatch( DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx) { - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) return; if (p->flow == NULL || p->flow->protoctx == NULL) diff --git a/src/detect-tcp-ack.c b/src/detect-tcp-ack.c index 85f4a3d210..e5d656954a 100644 --- a/src/detect-tcp-ack.c +++ b/src/detect-tcp-ack.c @@ -88,7 +88,7 @@ static int DetectAckMatch(DetectEngineThreadCtx *det_ctx, const DetectAckData *data = (const DetectAckData *)ctx; /* This is only needed on TCP packets */ - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) { + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) { return 0; } @@ -156,7 +156,7 @@ PrefilterPacketAckMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *p if (!PrefilterPacketHeaderExtraMatch(ctx, p)) return; - if (p->proto == IPPROTO_TCP && !(PKT_IS_PSEUDOPKT(p)) && PKT_IS_TCP(p) && + if (p->proto == IPPROTO_TCP && !(PKT_IS_PSEUDOPKT(p)) && PacketIsTCP(p) && (TCP_GET_ACK(p) == ctx->v1.u32[0])) { SCLogDebug("packet matches TCP ack %u", ctx->v1.u32[0]); PrefilterAddSids(&det_ctx->pmq, ctx->sigs_array, ctx->sigs_cnt); diff --git a/src/detect-tcp-flags.c b/src/detect-tcp-flags.c index a3bccdef8b..0dddd0dc00 100644 --- a/src/detect-tcp-flags.c +++ b/src/detect-tcp-flags.c @@ -151,7 +151,7 @@ static int DetectFlagsMatch (DetectEngineThreadCtx *det_ctx, Packet *p, { SCEnter(); - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) { + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) { SCReturnInt(0); } @@ -552,7 +552,7 @@ int DetectFlagsSignatureNeedsSynOnlyPackets(const Signature *s) static void PrefilterPacketFlagsMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx) { - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) { + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) { SCReturn; } diff --git a/src/detect-tcp-seq.c b/src/detect-tcp-seq.c index 57e763d853..60c060d3f5 100644 --- a/src/detect-tcp-seq.c +++ b/src/detect-tcp-seq.c @@ -84,7 +84,7 @@ static int DetectSeqMatch(DetectEngineThreadCtx *det_ctx, const DetectSeqData *data = (const DetectSeqData *)ctx; /* This is only needed on TCP packets */ - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) { + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) { return 0; } @@ -151,7 +151,7 @@ PrefilterPacketSeqMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *p if (!PrefilterPacketHeaderExtraMatch(ctx, p)) return; - if (p->proto == IPPROTO_TCP && !(PKT_IS_PSEUDOPKT(p)) && PKT_IS_TCP(p) && + if (p->proto == IPPROTO_TCP && !(PKT_IS_PSEUDOPKT(p)) && PacketIsTCP(p) && (TCP_GET_SEQ(p) == ctx->v1.u32[0])) { SCLogDebug("packet matches TCP seq %u", ctx->v1.u32[0]); PrefilterAddSids(&det_ctx->pmq, ctx->sigs_array, ctx->sigs_cnt); diff --git a/src/detect-tcp-window.c b/src/detect-tcp-window.c index c0a7bb7e1b..4714f6ba4a 100644 --- a/src/detect-tcp-window.c +++ b/src/detect-tcp-window.c @@ -87,7 +87,7 @@ static int DetectWindowMatch(DetectEngineThreadCtx *det_ctx, Packet *p, { const DetectWindowData *wd = (const DetectWindowData *)ctx; - if ( !(PKT_IS_TCP(p)) || wd == NULL || PKT_IS_PSEUDOPKT(p)) { + if (!(PacketIsTCP(p)) || wd == NULL || PKT_IS_PSEUDOPKT(p)) { return 0; } diff --git a/src/detect-tcphdr.c b/src/detect-tcphdr.c index 18969ca7a0..16a46a4b62 100644 --- a/src/detect-tcphdr.c +++ b/src/detect-tcphdr.c @@ -101,7 +101,7 @@ static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id); if (buffer->inspect == NULL) { - if (!PKT_IS_TCP(p)) { + if (!PacketIsTCP(p)) { // may happen when DecodeTCPPacket fails // for instance with invalid header length return NULL; diff --git a/src/detect-tcpmss.c b/src/detect-tcpmss.c index c04a9be09e..b1a1ffd72a 100644 --- a/src/detect-tcpmss.c +++ b/src/detect-tcpmss.c @@ -77,7 +77,7 @@ static int DetectTcpmssMatch (DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx) { - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) return 0; if (!(TCP_HAS_MSS(p))) @@ -130,7 +130,7 @@ void DetectTcpmssFree(DetectEngineCtx *de_ctx, void *ptr) static void PrefilterPacketTcpmssMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx) { - if (!(PKT_IS_TCP(p)) || PKT_IS_PSEUDOPKT(p)) + if (!(PacketIsTCP(p)) || PKT_IS_PSEUDOPKT(p)) return; if (!(TCP_HAS_MSS(p))) diff --git a/src/detect.c b/src/detect.c index 2786c47d70..2c46114477 100644 --- a/src/detect.c +++ b/src/detect.c @@ -407,7 +407,7 @@ static inline void DetectPrefilterBuildNonPrefilterList( static inline void DetectPrefilterSetNonPrefilterList(const Packet *p, DetectEngineThreadCtx *det_ctx, DetectRunScratchpad *scratch) { - if ((p->proto == IPPROTO_TCP) && PKT_IS_TCP(p) && (p->tcph->th_flags & TH_SYN)) { + if ((p->proto == IPPROTO_TCP) && PacketIsTCP(p) && (p->tcph->th_flags & TH_SYN)) { det_ctx->non_pf_store_ptr = scratch->sgh->non_pf_syn_store_array; det_ctx->non_pf_store_cnt = scratch->sgh->non_pf_syn_store_cnt; } else { diff --git a/src/flow-hash.c b/src/flow-hash.c index 4f78c5a684..da1cc51cd8 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -192,7 +192,7 @@ static inline uint32_t FlowGetHash(const Packet *p) uint32_t hash = 0; if (PacketIsIPv4(p)) { - if (PKT_IS_TCP(p) || PKT_IS_UDP(p)) { + if (PacketIsTCP(p) || PKT_IS_UDP(p)) { FlowHashKey4 fhk = { .pad[0] = 0 }; int ai = (p->src.addr_data32[0] > p->dst.addr_data32[0]); @@ -550,7 +550,7 @@ static inline int FlowCreateCheck(const Packet *p, const bool emerg) /* if we're in emergency mode, don't try to create a flow for a TCP * that is not a TCP SYN packet. */ if (emerg) { - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { if (((p->tcph->th_flags & (TH_SYN | TH_ACK | TH_RST | TH_FIN)) == TH_SYN) || !stream_config.midstream) { ; diff --git a/src/flow-util.c b/src/flow-util.c index ce6a54d7be..c43448eaf6 100644 --- a/src/flow-util.c +++ b/src/flow-util.c @@ -170,7 +170,7 @@ void FlowInit(Flow *f, const Packet *p) DEBUG_VALIDATE_BUG_ON(1); } - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { SET_TCP_SRC_PORT(p,&f->sp); SET_TCP_DST_PORT(p,&f->dp); } else if (PKT_IS_UDP(p)) { diff --git a/src/flow-worker.c b/src/flow-worker.c index 828ce5854e..fdc584df5d 100644 --- a/src/flow-worker.c +++ b/src/flow-worker.c @@ -430,7 +430,7 @@ static void FlowWorkerFlowTimeout(ThreadVars *tv, Packet *p, FlowWorkerThreadDat DEBUG_VALIDATE_BUG_ON(p->pkt_src != PKT_SRC_FFR); SCLogDebug("packet %"PRIu64" is TCP. Direction %s", p->pcap_cnt, PKT_IS_TOSERVER(p) ? "TOSERVER" : "TOCLIENT"); - DEBUG_VALIDATE_BUG_ON(!(p->flow && PKT_IS_TCP(p))); + DEBUG_VALIDATE_BUG_ON(!(p->flow && PacketIsTCP(p))); DEBUG_ASSERT_FLOW_LOCKED(p->flow); /* handle TCP and app layer */ @@ -583,7 +583,7 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) /* handle TCP and app layer */ if (p->flow) { - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { SCLogDebug("packet %" PRIu64 " is TCP. Direction %s", p->pcap_cnt, PKT_IS_TOSERVER(p) ? "TOSERVER" : "TOCLIENT"); DEBUG_ASSERT_FLOW_LOCKED(p->flow); diff --git a/src/log-httplog.c b/src/log-httplog.c index 0284bde227..17a01442da 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -487,7 +487,7 @@ int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, v { SCEnter(); - if (!(PKT_IS_TCP(p))) { + if (!(PacketIsTCP(p))) { SCReturnInt(TM_ECODE_OK); } diff --git a/src/log-pcap.c b/src/log-pcap.c index 5eb77f9e32..4442a0f4dd 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -650,7 +650,7 @@ static int PcapLog (ThreadVars *t, void *thread_data, const Packet *p) /* if we are using alerted logging and if packet is first one with alert in flow * then we need to dump in the pcap the stream acked by the packet */ if ((p->flags & PKT_FIRST_ALERTS) && (td->pcap_log->conditional != LOGMODE_COND_ALL)) { - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { /* dump fake packets for all segments we have on acked by packet */ #ifdef HAVE_LIBLZ4 PcapLogDumpSegments(td, comp, p); diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index 9c9e35c7ed..f54723aeac 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -173,7 +173,7 @@ static void LogTlsLogPem(LogTlsStoreLogThread *aft, const Packet *p, SSLState *s goto end_fwrite_fpmeta; if (fprintf(fpmeta, "PROTO: %" PRIu32 "\n", p->proto) < 0) goto end_fwrite_fpmeta; - if (PKT_IS_TCP(p) || PKT_IS_UDP(p)) { + if (PacketIsTCP(p) || PKT_IS_UDP(p)) { if (fprintf(fpmeta, "SRC PORT: %" PRIu16 "\n", sp) < 0) goto end_fwrite_fpmeta; if (fprintf(fpmeta, "DST PORT: %" PRIu16 "\n", dp) < 0) @@ -233,7 +233,7 @@ static bool LogTlsStoreCondition( return false; } - if (!(PKT_IS_TCP(p))) { + if (!(PacketIsTCP(p))) { return false; } diff --git a/src/output-eve-stream.c b/src/output-eve-stream.c index 8a5d9252dd..3fb906b3c5 100644 --- a/src/output-eve-stream.c +++ b/src/output-eve-stream.c @@ -334,7 +334,7 @@ static int EveStreamLogger(ThreadVars *tv, void *thread_data, const Packet *p) jb_set_uint(js, "hoplimit", IPV6_GET_RAW_HLIM(ip6h)); jb_set_uint(js, "flowlbl", IPV6_GET_RAW_FLOW(ip6h)); } - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { jb_set_uint(js, "tcpseq", TCP_GET_SEQ(p)); jb_set_uint(js, "tcpack", TCP_GET_ACK(p)); jb_set_uint(js, "tcpwin", TCP_GET_WINDOW(p)); diff --git a/src/output-json-drop.c b/src/output-json-drop.c index 38810626ee..b4b77deb4b 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -124,7 +124,7 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p) } switch (proto) { case IPPROTO_TCP: - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { jb_set_uint(js, "tcpseq", TCP_GET_SEQ(p)); jb_set_uint(js, "tcpack", TCP_GET_ACK(p)); jb_set_uint(js, "tcpwin", TCP_GET_WINDOW(p)); diff --git a/src/respond-reject-libnet11.c b/src/respond-reject-libnet11.c index 2325c8dfda..7b9d34d5a9 100644 --- a/src/respond-reject-libnet11.c +++ b/src/respond-reject-libnet11.c @@ -282,7 +282,7 @@ int RejectSendLibnet11IPv4TCP(ThreadVars *tv, Packet *p, void *data, enum Reject lpacket.flow = 0; lpacket.class = 0; - if (!PKT_IS_TCP(p)) + if (!PacketIsTCP(p)) return 1; libnet_t *c = GetCtx(p, LIBNET_RAW4); @@ -425,7 +425,7 @@ int RejectSendLibnet11IPv6TCP(ThreadVars *tv, Packet *p, void *data, enum Reject lpacket.flow = 0; lpacket.class = 0; - if (!PKT_IS_TCP(p)) + if (!PacketIsTCP(p)) return 1; libnet_t *c = GetCtx(p, LIBNET_RAW6); diff --git a/src/respond-reject.c b/src/respond-reject.c index d6e4a8ba30..b9eac5d525 100644 --- a/src/respond-reject.c +++ b/src/respond-reject.c @@ -74,13 +74,13 @@ static TmEcode RespondRejectFunc(ThreadVars *tv, Packet *p, void *data) } if (PacketIsIPv4(p)) { - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { (void)RejectSendIPv4TCP(tv, p, data); } else { (void)RejectSendIPv4ICMP(tv, p, data); } } else if (PacketIsIPv6(p)) { - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { (void)RejectSendIPv6TCP(tv, p, data); } else { (void)RejectSendIPv6ICMP(tv, p, data); diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 203e76564f..d4454ec3fd 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -2181,7 +2181,7 @@ static int AFPBypassCallback(Packet *p) { SCLogDebug("Calling af_packet callback function"); /* Only bypass TCP and UDP */ - if (!(PKT_IS_TCP(p) || PKT_IS_UDP(p))) { + if (!(PacketIsTCP(p) || PKT_IS_UDP(p))) { return 0; } @@ -2335,7 +2335,7 @@ static int AFPXDPBypassCallback(Packet *p) { SCLogDebug("Calling af_packet callback function"); /* Only bypass TCP and UDP */ - if (!(PKT_IS_TCP(p) || PKT_IS_UDP(p))) { + if (!(PacketIsTCP(p) || PKT_IS_UDP(p))) { return 0; } diff --git a/src/source-napatech.c b/src/source-napatech.c index 7036178ad1..b2ddc8b0d3 100644 --- a/src/source-napatech.c +++ b/src/source-napatech.c @@ -462,9 +462,9 @@ static int ProgramFlow(Packet *p, int inline_mode) SC_ATOMIC_ADD(flow_callback_cnt, 1); /* Only bypass TCP and UDP */ - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { SC_ATOMIC_ADD(flow_callback_tcp_pkts, 1); - } else if PKT_IS_UDP(p) { + } else if PKT_IS_UDP (p) { SC_ATOMIC_ADD(flow_callback_udp_pkts, 1); } else { SC_ATOMIC_ADD(flow_callback_unhandled_pkts, 1); diff --git a/src/source-pfring.c b/src/source-pfring.c index f39574b753..c1878489e3 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -305,7 +305,7 @@ static int PfringBypassCallback(Packet *p) hw_filtering_rule r; /* Only bypass TCP and UDP */ - if (!(PKT_IS_TCP(p) || PKT_IS_UDP(p))) { + if (!(PacketIsTCP(p) || PKT_IS_UDP(p))) { return 0; } diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 2a969545c3..389e028ce4 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -1958,7 +1958,7 @@ int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ { SCEnter(); - DEBUG_VALIDATE_BUG_ON(!PKT_IS_TCP(p)); + DEBUG_VALIDATE_BUG_ON(!PacketIsTCP(p)); SCLogDebug("ssn %p, stream %p, p %p, p->payload_len %"PRIu16"", ssn, stream, p, p->payload_len); diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 57ab8bda52..7be5f9bef1 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -5851,7 +5851,7 @@ static int TcpSessionReuseDoneEnough(const Packet *p, const Flow *f, const TcpSe int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn) { - if (p->proto == IPPROTO_TCP && PKT_IS_TCP(p)) { + if (p->proto == IPPROTO_TCP && PacketIsTCP(p)) { if (TcpSessionPacketIsStreamStarter(p) == 1) { if (TcpSessionReuseDoneEnough(p, f, tcp_ssn) == 1) { return 1; @@ -5876,7 +5876,7 @@ TmEcode StreamTcp (ThreadVars *tv, Packet *p, void *data, PacketQueueNoLock *pq) PktSrcToString(p->pkt_src)); t_pcapcnt = p->pcap_cnt; - if (!(PKT_IS_TCP(p))) { + if (!(PacketIsTCP(p))) { return TM_ECODE_OK; } diff --git a/src/tmqh-flow.c b/src/tmqh-flow.c index e6e422deec..54fb63725b 100644 --- a/src/tmqh-flow.c +++ b/src/tmqh-flow.c @@ -282,8 +282,8 @@ static void TmqhOutputFlowFTPHash(ThreadVars *tv, Packet *p) if (p->flags & PKT_WANTS_FLOW) { uint32_t hash = p->flow_hash; - if (PKT_IS_TCP(p) && ((p->sp >= 1024 && p->dp >= 1024) || p->dp == 21 || p->sp == 21 || - p->dp == 20 || p->sp == 20)) { + if (PacketIsTCP(p) && ((p->sp >= 1024 && p->dp >= 1024) || p->dp == 21 || p->sp == 21 || + p->dp == 20 || p->sp == 20)) { hash = FlowGetIpPairProtoHash(p); } qid = hash % ctx->size; diff --git a/src/util-checksum.c b/src/util-checksum.c index 12ae5aa8e9..ae3e8dd6d1 100644 --- a/src/util-checksum.c +++ b/src/util-checksum.c @@ -30,7 +30,7 @@ int ReCalculateChecksum(Packet *p) { if (PacketIsIPv4(p)) { IPV4Hdr *ip4h = p->l3.hdrs.ip4h; - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { /* TCP */ p->tcph->th_sum = 0; p->tcph->th_sum = TCPChecksum( @@ -45,7 +45,7 @@ int ReCalculateChecksum(Packet *p) ip4h->ip_csum = IPV4Checksum((uint16_t *)ip4h, IPV4_GET_RAW_HLEN(ip4h), 0); } else if (PacketIsIPv6(p)) { IPV6Hdr *ip6h = p->l3.hdrs.ip6h; - if (PKT_IS_TCP(p)) { + if (PacketIsTCP(p)) { p->tcph->th_sum = 0; p->tcph->th_sum = TCPV6Checksum( ip6h->s_ip6_addrs, (uint16_t *)p->tcph, (p->payload_len + TCP_GET_HLEN(p)), 0);