99 |
{ |
{ |
100 |
struct tcp_pcb *pcb, *prev; |
struct tcp_pcb *pcb, *prev; |
101 |
struct tcp_pcb_listen *lpcb; |
struct tcp_pcb_listen *lpcb; |
102 |
u8_t offset; |
u8_t hdrlen; |
103 |
err_t err; |
err_t err; |
104 |
|
|
105 |
|
|
113 |
iphdr = p->payload; |
iphdr = p->payload; |
114 |
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4); |
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4); |
115 |
|
|
116 |
|
#if TCP_INPUT_DEBUG |
117 |
|
tcp_debug_print(tcphdr); |
118 |
|
#endif |
119 |
|
|
120 |
/* remove header from payload */ |
/* remove header from payload */ |
121 |
if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { |
if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { |
122 |
/* drop short packets */ |
/* drop short packets */ |
158 |
|
|
159 |
/* Move the payload pointer in the pbuf so that it points to the |
/* Move the payload pointer in the pbuf so that it points to the |
160 |
TCP data instead of the TCP header. */ |
TCP data instead of the TCP header. */ |
161 |
offset = TCPH_OFFSET(tcphdr) >> 4; |
hdrlen = TCPH_HDRLEN(tcphdr); |
162 |
pbuf_header(p, -(offset * 4)); |
pbuf_header(p, -(hdrlen * 4)); |
163 |
|
|
164 |
/* Convert fields in TCP header to host byte order. */ |
/* Convert fields in TCP header to host byte order. */ |
165 |
tcphdr->src = ntohs(tcphdr->src); |
tcphdr->src = ntohs(tcphdr->src); |
938 |
inseg.p = NULL; |
inseg.p = NULL; |
939 |
} |
} |
940 |
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { |
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { |
941 |
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.")); |
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.\n")); |
942 |
recv_flags = TF_GOT_FIN; |
recv_flags = TF_GOT_FIN; |
943 |
} |
} |
944 |
|
|
969 |
cseg->p = NULL; |
cseg->p = NULL; |
970 |
} |
} |
971 |
if (flags & TCP_FIN) { |
if (flags & TCP_FIN) { |
972 |
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.")); |
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.\n")); |
973 |
recv_flags = TF_GOT_FIN; |
recv_flags = TF_GOT_FIN; |
974 |
} |
} |
975 |
|
|
1126 |
opts = (u8_t *)tcphdr + TCP_HLEN; |
opts = (u8_t *)tcphdr + TCP_HLEN; |
1127 |
|
|
1128 |
/* Parse the TCP MSS option, if present. */ |
/* Parse the TCP MSS option, if present. */ |
1129 |
if ((TCPH_OFFSET(tcphdr) & 0xf0) > 0x50) { |
if(TCPH_HDRLEN(tcphdr) > 0x5) { |
1130 |
for(c = 0; c < ((TCPH_OFFSET(tcphdr) >> 4) - 5) << 2 ;) { |
for(c = 0; c < (TCPH_HDRLEN(tcphdr) - 5) << 2 ;) { |
1131 |
opt = opts[c]; |
opt = opts[c]; |
1132 |
if (opt == 0x00) { |
if (opt == 0x00) { |
1133 |
/* End of options. */ |
/* End of options. */ |