This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 433a2b27d9e375359f46f8dcbaaa1e4f9f73cb98 Author: YAMAMOTO Takashi <[email protected]> AuthorDate: Tue Jun 1 13:48:47 2021 +0900 tcp: add macros to deal with sequence number wraparound --- net/tcp/tcp.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index fc43dd6..c83f832 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -86,6 +86,15 @@ # endif #endif +/* 32-bit modular arithmetics for tcp sequence numbers */ + +#define TCP_SEQ_LT(a, b) ((int32_t)((a) - (b)) < 0) +#define TCP_SEQ_GT(a, b) TCP_SEQ_LT(b, a) +#define TCP_SEQ_LTE(a, b) (!TCP_SEQ_GT(a, b)) +#define TCP_SEQ_GTE(a, b) (!TCP_SEQ_LT(a, b)) + +#define TCP_SEQ_SUB(a, b) ((uint32_t)((a) - (b))) + /**************************************************************************** * Public Type Definitions ****************************************************************************/
