7 #if !LWIP_STATS || !TCP_STATS || !MEMP_STATS
8 #error "This tests needs TCP- and MEMP-statistics enabled"
11 #error "This tests needs TCP_QUEUE_OOSEQ enabled"
17 #define CHECK_SEGMENTS_ON_OOSEQ 1
19 #if CHECK_SEGMENTS_ON_OOSEQ
20 #define EXPECT_OOSEQ(x) EXPECT(x)
22 #define EXPECT_OOSEQ(x)
28 static int tcp_oos_count(
struct tcp_pcb* pcb)
31 struct tcp_seg* seg = pcb->ooseq;
46 tcp_oos_seg_seqno(
struct tcp_pcb* pcb,
int seg_index)
49 struct tcp_seg* seg = pcb->ooseq;
53 if(num == seg_index) {
54 return seg->tcphdr->seqno;
70 tcp_oos_seg_tcplen(
struct tcp_pcb* pcb,
int seg_index)
73 struct tcp_seg* seg = pcb->ooseq;
77 if(num == seg_index) {
78 return TCP_TCPLEN(seg);
93 tcp_oos_tcplen(
struct tcp_pcb* pcb)
96 struct tcp_seg* seg = pcb->ooseq;
100 len += TCP_TCPLEN(seg);
115 tcp_oos_teardown(
void)
131 struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq;
139 u16_t remote_port = 0x100, local_port = 0x101;
144 memset(&netif, 0,
sizeof(netif));
145 IP4_ADDR(&local_ip, 192, 168, 1, 1);
146 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
147 data_len =
sizeof(data);
149 memset(&counters, 0,
sizeof(counters));
156 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
181 if ((pinseq !=
NULL) && (p_8_9 !=
NULL) && (p_4_8 !=
NULL) && (p_4_10 !=
NULL) && (p_2_14 !=
NULL) && (p_fin !=
NULL)) {
183 tcp_input(p_8_9, &netif);
195 tcp_input(p_4_8, &netif);
209 tcp_input(p_4_10, &netif);
223 tcp_input(p_2_14, &netif);
235 tcp_input(p_fin, &netif);
247 tcp_input(pinseq, &netif);
257 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
259 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
271 struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN;
279 u16_t remote_port = 0x100, local_port = 0x101;
284 memset(&netif, 0,
sizeof(netif));
285 IP4_ADDR(&local_ip, 192, 168, 1, 1);
286 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
287 data_len =
sizeof(data);
289 memset(&counters, 0,
sizeof(counters));
296 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
330 if ((pinseq !=
NULL) && (p_1_2 !=
NULL) && (p_4_8 !=
NULL) && (p_3_11 !=
NULL) && (p_2_12 !=
NULL)
331 && (p_15_1 !=
NULL) && (p_15_1a !=
NULL) && (pinseqFIN !=
NULL)) {
333 tcp_input(p_1_2, &netif);
345 tcp_input(p_4_8, &netif);
359 tcp_input(p_3_11, &netif);
374 tcp_input(p_2_12, &netif);
388 tcp_input(pinseq, &netif);
397 tcp_input(p_15_1, &netif);
409 tcp_input(p_15_1a, &netif);
421 tcp_input(pinseqFIN, &netif);
431 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
433 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
437 static char data_full_wnd[
TCP_WND];
446 struct pbuf *pinseq, *p_ovr;
448 u16_t remote_port = 0x100, local_port = 0x101;
454 for(i = 0; i <
sizeof(data_full_wnd); i++) {
455 data_full_wnd[i] = (char)i;
459 memset(&netif, 0,
sizeof(netif));
460 IP4_ADDR(&local_ip, 192, 168, 1, 1);
461 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
463 memset(&counters, 0,
sizeof(counters));
470 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
471 pcb->rcv_nxt = 0x8000;
478 int count, expected_datalen;
483 tcp_input(p, &netif);
490 count = tcp_oos_count(pcb);
492 datalen = tcp_oos_tcplen(pcb);
494 expected_datalen = (k+1)*
TCP_MSS;
496 expected_datalen = TCP_WND -
TCP_MSS;
498 if (datalen != expected_datalen) {
507 tcp_input(p_ovr, &netif);
515 datalen2 = tcp_oos_tcplen(pcb);
519 tcp_input(pinseq, &netif);
523 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
525 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
535 test_tcp_recv_ooseq_FIN_OOSEQ,
536 test_tcp_recv_ooseq_FIN_INSEQ,
537 test_tcp_recv_ooseq_overrun_rxwin,
539 return create_suite(
"TCP_OOS", tests,
sizeof(tests)/
sizeof(TFun), tcp_oos_setup, tcp_oos_teardown);