Compare commits

...

4 Commits

Author SHA1 Message Date
Sergey Fionov
a9147bb332
Merge 5171345eb8 into 86c9f79991 2024-05-17 11:09:56 +08:00
jeans
86c9f79991 refactor: added apple macro for fs handling 2024-05-14 13:53:42 +02:00
jeans
8e1a247c1f refactor: added macOS include file
MacOS supports util.h as well
2024-05-14 13:53:42 +02:00
Sergey Fionov
5171345eb8 tcp: Fix TCP timestamps for big-endian systems
Current parsing code is building reverse-order integer, and then calls htonl()
to assign right value to "ts_recent" field of pcb.

This works correctly on little-endian machines, where htonl() reverses bytes.
However, on big-endian machines, htonl() is no-op, so bytes stay reversed.

This patch fixes it by building non-reversed integer.
2024-03-13 22:16:35 +02:00
3 changed files with 7 additions and 7 deletions

View File

@ -35,7 +35,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(LWIP_UNIX_OPENBSD) #if defined(LWIP_UNIX_OPENBSD) || defined(LWIP_UNIX_MACH)
#include <util.h> #include <util.h>
#endif #endif
#include <termios.h> #include <termios.h>

View File

@ -77,7 +77,7 @@ static int deflate_level; /* default compression level, can be changed via comma
#define CHDIR(path) SetCurrentDirectoryA(path) #define CHDIR(path) SetCurrentDirectoryA(path)
#define CHDIR_SUCCEEDED(ret) (ret == TRUE) #define CHDIR_SUCCEEDED(ret) (ret == TRUE)
#elif __linux__ #elif __linux__ || __APPLE__
#define GETCWD(path, len) getcwd(path, len) #define GETCWD(path, len) getcwd(path, len)
#define GETCWD_SUCCEEDED(ret) (ret != NULL) #define GETCWD_SUCCEEDED(ret) (ret != NULL)

View File

@ -1993,17 +1993,17 @@ tcp_parseopt(struct tcp_pcb *pcb)
return; return;
} }
/* TCP timestamp option with valid length */ /* TCP timestamp option with valid length */
tsval = tcp_get_next_optbyte(); tsval = (tcp_get_next_optbyte() << 24);
tsval |= (tcp_get_next_optbyte() << 8);
tsval |= (tcp_get_next_optbyte() << 16); tsval |= (tcp_get_next_optbyte() << 16);
tsval |= (tcp_get_next_optbyte() << 24); tsval |= (tcp_get_next_optbyte() << 8);
tsval |= tcp_get_next_optbyte();
if (flags & TCP_SYN) { if (flags & TCP_SYN) {
pcb->ts_recent = lwip_ntohl(tsval); pcb->ts_recent = tsval;
/* Enable sending timestamps in every segment now that we know /* Enable sending timestamps in every segment now that we know
the remote host supports it. */ the remote host supports it. */
tcp_set_flags(pcb, TF_TIMESTAMP); tcp_set_flags(pcb, TF_TIMESTAMP);
} else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno + tcplen)) { } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno + tcplen)) {
pcb->ts_recent = lwip_ntohl(tsval); pcb->ts_recent = tsval;
} }
/* Advance to next option (6 bytes already read) */ /* Advance to next option (6 bytes already read) */
tcp_optidx += LWIP_TCP_OPT_LEN_TS - 6; tcp_optidx += LWIP_TCP_OPT_LEN_TS - 6;