From 4c420a8848f956d7f9705bd9fcd976f6ade45fee Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Sun, 19 Jan 2025 22:27:52 +0100 Subject: [PATCH] decode/tcp: fix some macros Ticket: #7509 --- src/decode-tcp.h | 56 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/decode-tcp.h b/src/decode-tcp.h index c0ce5c20d265..b3e23840557e 100644 --- a/src/decode-tcp.h +++ b/src/decode-tcp.h @@ -105,35 +105,35 @@ #define TCP_GET_SACK_CNT(p) (p)->l4.vars.tcp.sack_cnt #define TCP_GET_MSS(p) (p)->l4.vars.tcp.mss -#define TCP_GET_OFFSET(p) TCP_GET_RAW_OFFSET((p)->tcph) -#define TCP_GET_X2(p) TCP_GET_RAW_X2((p)->tcph) +#define TCP_GET_OFFSET(p) TCP_GET_RAW_OFFSET((p)->l4.hdrs.tcph) +#define TCP_GET_X2(p) TCP_GET_RAW_X2((p)->l4.hdrs.tcph) #define TCP_GET_HLEN(p) ((uint8_t)(TCP_GET_OFFSET((p)) << 2)) -#define TCP_GET_SRC_PORT(p) TCP_GET_RAW_SRC_PORT((p)->tcph) -#define TCP_GET_DST_PORT(p) TCP_GET_RAW_DST_PORT((p)->tcph) -#define TCP_GET_SEQ(p) TCP_GET_RAW_SEQ((p)->tcph) -#define TCP_GET_ACK(p) TCP_GET_RAW_ACK((p)->tcph) -#define TCP_GET_WINDOW(p) TCP_GET_RAW_WINDOW((p)->tcph) -#define TCP_GET_URG_POINTER(p) TCP_GET_RAW_URG_POINTER((p)->tcph) -#define TCP_GET_SUM(p) TCP_GET_RAW_SUM((p)->tcph) -#define TCP_GET_FLAGS(p) (p)->tcph->th_flags - -#define TCP_ISSET_FLAG_RAW_FIN(p) ((tcph)->th_flags & TH_FIN) -#define TCP_ISSET_FLAG_RAW_SYN(p) ((tcph)->th_flags & TH_SYN) -#define TCP_ISSET_FLAG_RAW_RST(p) ((tcph)->th_flags & TH_RST) -#define TCP_ISSET_FLAG_RAW_PUSH(p) ((tcph)->th_flags & TH_PUSH) -#define TCP_ISSET_FLAG_RAW_ACK(p) ((tcph)->th_flags & TH_ACK) -#define TCP_ISSET_FLAG_RAW_URG(p) ((tcph)->th_flags & TH_URG) -#define TCP_ISSET_FLAG_RAW_RES2(p) ((tcph)->th_flags & TH_RES2) -#define TCP_ISSET_FLAG_RAW_RES1(p) ((tcph)->th_flags & TH_RES1) - -#define TCP_ISSET_FLAG_FIN(p) ((p)->tcph->th_flags & TH_FIN) -#define TCP_ISSET_FLAG_SYN(p) ((p)->tcph->th_flags & TH_SYN) -#define TCP_ISSET_FLAG_RST(p) ((p)->tcph->th_flags & TH_RST) -#define TCP_ISSET_FLAG_PUSH(p) ((p)->tcph->th_flags & TH_PUSH) -#define TCP_ISSET_FLAG_ACK(p) ((p)->tcph->th_flags & TH_ACK) -#define TCP_ISSET_FLAG_URG(p) ((p)->tcph->th_flags & TH_URG) -#define TCP_ISSET_FLAG_RES2(p) ((p)->tcph->th_flags & TH_RES2) -#define TCP_ISSET_FLAG_RES1(p) ((p)->tcph->th_flags & TH_RES1) +#define TCP_GET_SRC_PORT(p) TCP_GET_RAW_SRC_PORT((p)->l4.hdrs.tcph) +#define TCP_GET_DST_PORT(p) TCP_GET_RAW_DST_PORT((p)->l4.hdrs.tcph) +#define TCP_GET_SEQ(p) TCP_GET_RAW_SEQ((p)->l4.hdrs.tcph) +#define TCP_GET_ACK(p) TCP_GET_RAW_ACK((p)->l4.hdrs.tcph) +#define TCP_GET_WINDOW(p) TCP_GET_RAW_WINDOW((p)->l4.hdrs.tcph) +#define TCP_GET_URG_POINTER(p) TCP_GET_RAW_URG_POINTER((p)->l4.hdrs.tcph) +#define TCP_GET_SUM(p) TCP_GET_RAW_SUM((p)->l4.hdrs.tcph) +#define TCP_GET_FLAGS(p) (p)->l4.hdrs.tcph->th_flags + +#define TCP_ISSET_FLAG_RAW_FIN(tcph) ((tcph)->th_flags & TH_FIN) +#define TCP_ISSET_FLAG_RAW_SYN(tcph) ((tcph)->th_flags & TH_SYN) +#define TCP_ISSET_FLAG_RAW_RST(tcph) ((tcph)->th_flags & TH_RST) +#define TCP_ISSET_FLAG_RAW_PUSH(tcph) ((tcph)->th_flags & TH_PUSH) +#define TCP_ISSET_FLAG_RAW_ACK(tcph) ((tcph)->th_flags & TH_ACK) +#define TCP_ISSET_FLAG_RAW_URG(tcph) ((tcph)->th_flags & TH_URG) +#define TCP_ISSET_FLAG_RAW_RES2(tcph) ((tcph)->th_flags & TH_RES2) +#define TCP_ISSET_FLAG_RAW_RES1(tcph) ((tcph)->th_flags & TH_RES1) + +#define TCP_ISSET_FLAG_FIN(p) ((p)->l4.hdrs.tcph->th_flags & TH_FIN) +#define TCP_ISSET_FLAG_SYN(p) ((p)->l4.hdrs.tcph->th_flags & TH_SYN) +#define TCP_ISSET_FLAG_RST(p) ((p)->l4.hdrs.tcph->th_flags & TH_RST) +#define TCP_ISSET_FLAG_PUSH(p) ((p)->l4.hdrs.tcph->th_flags & TH_PUSH) +#define TCP_ISSET_FLAG_ACK(p) ((p)->l4.hdrs.tcph->th_flags & TH_ACK) +#define TCP_ISSET_FLAG_URG(p) ((p)->l4.hdrs.tcph->th_flags & TH_URG) +#define TCP_ISSET_FLAG_RES2(p) ((p)->l4.hdrs.tcph->th_flags & TH_RES2) +#define TCP_ISSET_FLAG_RES1(p) ((p)->l4.hdrs.tcph->th_flags & TH_RES1) typedef struct TCPOpt_ { uint8_t type;