tcp: add a define for maximum option bytes

This commit is contained in:
goldsimon 2018-01-31 21:55:23 +01:00
parent 2c3c578475
commit 9fb86f6e4b
2 changed files with 3 additions and 1 deletions

View File

@ -1137,7 +1137,7 @@ tcp_get_num_sacks(struct tcp_pcb *pcb, u8_t optlen)
optlen += 12;
/* Max options size = 40, number of SACK array entries = LWIP_TCP_MAX_SACK_NUM */
for (i = 0; (i < LWIP_TCP_MAX_SACK_NUM) && (optlen <= 40) && LWIP_TCP_SACK_VALID(pcb, i); ++i) {
for (i = 0; (i < LWIP_TCP_MAX_SACK_NUM) && (optlen <= TCP_MAX_OPTION_BYTES) && LWIP_TCP_SACK_VALID(pcb, i); ++i) {
++num_sacks;
optlen += 8;
}

View File

@ -80,6 +80,8 @@ PACK_STRUCT_END
/* Valid TCP header flags */
#define TCP_FLAGS 0x3fU
#define TCP_MAX_OPTION_BYTES 40
#define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12))
#define TCPH_HDRLEN_BYTES(phdr) ((u8_t)(TCPH_HDRLEN(phdr) << 2))
#define TCPH_FLAGS(phdr) ((u8_t)((lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)))