Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
test_tcp_oos.c
00001 #include "test_tcp_oos.h" 00002 00003 #include "lwip/priv/tcp_priv.h" 00004 #include "lwip/stats.h" 00005 #include "tcp_helper.h" 00006 00007 #if !LWIP_STATS || !TCP_STATS || !MEMP_STATS 00008 #error "This tests needs TCP- and MEMP-statistics enabled" 00009 #endif 00010 #if !TCP_QUEUE_OOSEQ 00011 #error "This tests needs TCP_QUEUE_OOSEQ enabled" 00012 #endif 00013 00014 /** CHECK_SEGMENTS_ON_OOSEQ: 00015 * 1: check count, seqno and len of segments on pcb->ooseq (strict) 00016 * 0: only check that bytes are received in correct order (less strict) */ 00017 #define CHECK_SEGMENTS_ON_OOSEQ 1 00018 00019 #if CHECK_SEGMENTS_ON_OOSEQ 00020 #define EXPECT_OOSEQ(x) EXPECT(x) 00021 #else 00022 #define EXPECT_OOSEQ(x) 00023 #endif 00024 00025 /* helper functions */ 00026 00027 /** Get the numbers of segments on the ooseq list */ 00028 static int tcp_oos_count(struct tcp_pcb* pcb) 00029 { 00030 int num = 0; 00031 struct tcp_seg* seg = pcb->ooseq; 00032 while(seg != NULL) { 00033 num++; 00034 seg = seg->next; 00035 } 00036 return num; 00037 } 00038 00039 #if TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_PBUFS < ((TCP_WND / TCP_MSS) + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) 00040 /** Get the numbers of pbufs on the ooseq list */ 00041 static int tcp_oos_pbuf_count(struct tcp_pcb* pcb) 00042 { 00043 int num = 0; 00044 struct tcp_seg* seg = pcb->ooseq; 00045 while(seg != NULL) { 00046 num += pbuf_clen(seg->p); 00047 seg = seg->next; 00048 } 00049 return num; 00050 } 00051 #endif 00052 00053 /** Get the seqno of a segment (by index) on the ooseq list 00054 * 00055 * @param pcb the pcb to check for ooseq segments 00056 * @param seg_index index of the segment on the ooseq list 00057 * @return seqno of the segment 00058 */ 00059 static u32_t 00060 tcp_oos_seg_seqno(struct tcp_pcb* pcb, int seg_index) 00061 { 00062 int num = 0; 00063 struct tcp_seg* seg = pcb->ooseq; 00064 00065 /* then check the actual segment */ 00066 while(seg != NULL) { 00067 if(num == seg_index) { 00068 return seg->tcphdr->seqno; 00069 } 00070 num++; 00071 seg = seg->next; 00072 } 00073 fail(); 00074 return 0; 00075 } 00076 00077 /** Get the tcplen (datalen + SYN/FIN) of a segment (by index) on the ooseq list 00078 * 00079 * @param pcb the pcb to check for ooseq segments 00080 * @param seg_index index of the segment on the ooseq list 00081 * @return tcplen of the segment 00082 */ 00083 static int 00084 tcp_oos_seg_tcplen(struct tcp_pcb* pcb, int seg_index) 00085 { 00086 int num = 0; 00087 struct tcp_seg* seg = pcb->ooseq; 00088 00089 /* then check the actual segment */ 00090 while(seg != NULL) { 00091 if(num == seg_index) { 00092 return TCP_TCPLEN(seg); 00093 } 00094 num++; 00095 seg = seg->next; 00096 } 00097 fail(); 00098 return -1; 00099 } 00100 00101 /** Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list 00102 * 00103 * @param pcb the pcb to check for ooseq segments 00104 * @return tcplen of all segment 00105 */ 00106 static int 00107 tcp_oos_tcplen(struct tcp_pcb* pcb) 00108 { 00109 int len = 0; 00110 struct tcp_seg* seg = pcb->ooseq; 00111 00112 /* then check the actual segment */ 00113 while(seg != NULL) { 00114 len += TCP_TCPLEN(seg); 00115 seg = seg->next; 00116 } 00117 return len; 00118 } 00119 00120 /* Setup/teardown functions */ 00121 static struct netif *old_netif_list; 00122 static struct netif *old_netif_default; 00123 00124 static void 00125 tcp_oos_setup(void) 00126 { 00127 old_netif_list = netif_list; 00128 old_netif_default = netif_default; 00129 netif_list = NULL; 00130 netif_default = NULL; 00131 tcp_remove_all(); 00132 lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT)); 00133 } 00134 00135 static void 00136 tcp_oos_teardown(void) 00137 { 00138 netif_list = NULL; 00139 netif_default = NULL; 00140 tcp_remove_all(); 00141 /* restore netif_list for next tests (e.g. loopif) */ 00142 netif_list = old_netif_list; 00143 netif_default = old_netif_default; 00144 lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT)); 00145 } 00146 00147 00148 00149 /* Test functions */ 00150 00151 /** create multiple segments and pass them to tcp_input in a wrong 00152 * order to see if ooseq-caching works correctly 00153 * FIN is received in out-of-sequence segments only */ 00154 START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ) 00155 { 00156 struct test_tcp_counters counters; 00157 struct tcp_pcb* pcb; 00158 struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq; 00159 char data[] = { 00160 1, 2, 3, 4, 00161 5, 6, 7, 8, 00162 9, 10, 11, 12, 00163 13, 14, 15, 16}; 00164 u16_t data_len; 00165 struct netif netif; 00166 LWIP_UNUSED_ARG(_i); 00167 00168 /* initialize local vars */ 00169 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00170 data_len = sizeof(data); 00171 /* initialize counter struct */ 00172 memset(&counters, 0, sizeof(counters)); 00173 counters.expected_data_len = data_len; 00174 counters.expected_data = data; 00175 00176 /* create and initialize the pcb */ 00177 pcb = test_tcp_new_counters_pcb(&counters); 00178 EXPECT_RET(pcb != NULL); 00179 tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00180 00181 /* create segments */ 00182 /* pinseq is sent as last segment! */ 00183 pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK); 00184 /* p1: 8 bytes before FIN */ 00185 /* seqno: 8..16 */ 00186 p_8_9 = tcp_create_rx_segment(pcb, &data[8], 8, 8, 0, TCP_ACK|TCP_FIN); 00187 /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */ 00188 /* seqno: 4..11 */ 00189 p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK); 00190 /* p3: same as p2 but 2 bytes longer */ 00191 /* seqno: 4..13 */ 00192 p_4_10 = tcp_create_rx_segment(pcb, &data[4], 10, 4, 0, TCP_ACK); 00193 /* p4: 14 bytes before FIN, includes data from p1 and p2, plus partly from pinseq */ 00194 /* seqno: 2..15 */ 00195 p_2_14 = tcp_create_rx_segment(pcb, &data[2], 14, 2, 0, TCP_ACK); 00196 /* FIN, seqno 16 */ 00197 p_fin = tcp_create_rx_segment(pcb, NULL, 0,16, 0, TCP_ACK|TCP_FIN); 00198 EXPECT(pinseq != NULL); 00199 EXPECT(p_8_9 != NULL); 00200 EXPECT(p_4_8 != NULL); 00201 EXPECT(p_4_10 != NULL); 00202 EXPECT(p_2_14 != NULL); 00203 EXPECT(p_fin != NULL); 00204 if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) { 00205 /* pass the segment to tcp_input */ 00206 test_tcp_input(p_8_9, &netif); 00207 /* check if counters are as expected */ 00208 EXPECT(counters.close_calls == 0); 00209 EXPECT(counters.recv_calls == 0); 00210 EXPECT(counters.recved_bytes == 0); 00211 EXPECT(counters.err_calls == 0); 00212 /* check ooseq queue */ 00213 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); 00214 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 8); 00215 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */ 00216 00217 /* pass the segment to tcp_input */ 00218 test_tcp_input(p_4_8, &netif); 00219 /* check if counters are as expected */ 00220 EXPECT(counters.close_calls == 0); 00221 EXPECT(counters.recv_calls == 0); 00222 EXPECT(counters.recved_bytes == 0); 00223 EXPECT(counters.err_calls == 0); 00224 /* check ooseq queue */ 00225 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); 00226 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4); 00227 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4); 00228 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8); 00229 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */ 00230 00231 /* pass the segment to tcp_input */ 00232 test_tcp_input(p_4_10, &netif); 00233 /* check if counters are as expected */ 00234 EXPECT(counters.close_calls == 0); 00235 EXPECT(counters.recv_calls == 0); 00236 EXPECT(counters.recved_bytes == 0); 00237 EXPECT(counters.err_calls == 0); 00238 /* ooseq queue: unchanged */ 00239 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); 00240 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4); 00241 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4); 00242 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8); 00243 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */ 00244 00245 /* pass the segment to tcp_input */ 00246 test_tcp_input(p_2_14, &netif); 00247 /* check if counters are as expected */ 00248 EXPECT(counters.close_calls == 0); 00249 EXPECT(counters.recv_calls == 0); 00250 EXPECT(counters.recved_bytes == 0); 00251 EXPECT(counters.err_calls == 0); 00252 /* check ooseq queue */ 00253 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); 00254 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2); 00255 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */ 00256 00257 /* pass the segment to tcp_input */ 00258 test_tcp_input(p_fin, &netif); 00259 /* check if counters are as expected */ 00260 EXPECT(counters.close_calls == 0); 00261 EXPECT(counters.recv_calls == 0); 00262 EXPECT(counters.recved_bytes == 0); 00263 EXPECT(counters.err_calls == 0); 00264 /* ooseq queue: unchanged */ 00265 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); 00266 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2); 00267 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */ 00268 00269 /* pass the segment to tcp_input */ 00270 test_tcp_input(pinseq, &netif); 00271 /* check if counters are as expected */ 00272 EXPECT(counters.close_calls == 1); 00273 EXPECT(counters.recv_calls == 1); 00274 EXPECT(counters.recved_bytes == data_len); 00275 EXPECT(counters.err_calls == 0); 00276 EXPECT(pcb->ooseq == NULL); 00277 } 00278 00279 /* make sure the pcb is freed */ 00280 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00281 tcp_abort(pcb); 00282 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00283 } 00284 END_TEST 00285 00286 00287 /** create multiple segments and pass them to tcp_input in a wrong 00288 * order to see if ooseq-caching works correctly 00289 * FIN is received IN-SEQUENCE at the end */ 00290 START_TEST(test_tcp_recv_ooseq_FIN_INSEQ) 00291 { 00292 struct test_tcp_counters counters; 00293 struct tcp_pcb* pcb; 00294 struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN; 00295 char data[] = { 00296 1, 2, 3, 4, 00297 5, 6, 7, 8, 00298 9, 10, 11, 12, 00299 13, 14, 15, 16}; 00300 u16_t data_len; 00301 struct netif netif; 00302 LWIP_UNUSED_ARG(_i); 00303 00304 /* initialize local vars */ 00305 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00306 data_len = sizeof(data); 00307 /* initialize counter struct */ 00308 memset(&counters, 0, sizeof(counters)); 00309 counters.expected_data_len = data_len; 00310 counters.expected_data = data; 00311 00312 /* create and initialize the pcb */ 00313 pcb = test_tcp_new_counters_pcb(&counters); 00314 EXPECT_RET(pcb != NULL); 00315 tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00316 00317 /* create segments */ 00318 /* p1: 7 bytes - 2 before FIN */ 00319 /* seqno: 1..2 */ 00320 p_1_2 = tcp_create_rx_segment(pcb, &data[1], 2, 1, 0, TCP_ACK); 00321 /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */ 00322 /* seqno: 4..11 */ 00323 p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK); 00324 /* p3: same as p2 but 2 bytes longer and one byte more at the front */ 00325 /* seqno: 3..13 */ 00326 p_3_11 = tcp_create_rx_segment(pcb, &data[3], 11, 3, 0, TCP_ACK); 00327 /* p4: 13 bytes - 2 before FIN - should be ignored as contained in p1 and p3 */ 00328 /* seqno: 2..13 */ 00329 p_2_12 = tcp_create_rx_segment(pcb, &data[2], 12, 2, 0, TCP_ACK); 00330 /* pinseq is the first segment that is held back to create ooseq! */ 00331 /* seqno: 0..3 */ 00332 pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK); 00333 /* p5: last byte before FIN */ 00334 /* seqno: 15 */ 00335 p_15_1 = tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK); 00336 /* p6: same as p5, should be ignored */ 00337 p_15_1a= tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK); 00338 /* pinseqFIN: last 2 bytes plus FIN */ 00339 /* only segment containing seqno 14 and FIN */ 00340 pinseqFIN = tcp_create_rx_segment(pcb, &data[14], 2, 14, 0, TCP_ACK|TCP_FIN); 00341 EXPECT(pinseq != NULL); 00342 EXPECT(p_1_2 != NULL); 00343 EXPECT(p_4_8 != NULL); 00344 EXPECT(p_3_11 != NULL); 00345 EXPECT(p_2_12 != NULL); 00346 EXPECT(p_15_1 != NULL); 00347 EXPECT(p_15_1a != NULL); 00348 EXPECT(pinseqFIN != NULL); 00349 if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL) 00350 && (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) { 00351 /* pass the segment to tcp_input */ 00352 test_tcp_input(p_1_2, &netif); 00353 /* check if counters are as expected */ 00354 EXPECT(counters.close_calls == 0); 00355 EXPECT(counters.recv_calls == 0); 00356 EXPECT(counters.recved_bytes == 0); 00357 EXPECT(counters.err_calls == 0); 00358 /* check ooseq queue */ 00359 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); 00360 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); 00361 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); 00362 00363 /* pass the segment to tcp_input */ 00364 test_tcp_input(p_4_8, &netif); 00365 /* check if counters are as expected */ 00366 EXPECT(counters.close_calls == 0); 00367 EXPECT(counters.recv_calls == 0); 00368 EXPECT(counters.recved_bytes == 0); 00369 EXPECT(counters.err_calls == 0); 00370 /* check ooseq queue */ 00371 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); 00372 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); 00373 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); 00374 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 4); 00375 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8); 00376 00377 /* pass the segment to tcp_input */ 00378 test_tcp_input(p_3_11, &netif); 00379 /* check if counters are as expected */ 00380 EXPECT(counters.close_calls == 0); 00381 EXPECT(counters.recv_calls == 0); 00382 EXPECT(counters.recved_bytes == 0); 00383 EXPECT(counters.err_calls == 0); 00384 /* check ooseq queue */ 00385 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); 00386 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); 00387 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2); 00388 /* p_3_11 has removed p_4_8 from ooseq */ 00389 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 3); 00390 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11); 00391 00392 /* pass the segment to tcp_input */ 00393 test_tcp_input(p_2_12, &netif); 00394 /* check if counters are as expected */ 00395 EXPECT(counters.close_calls == 0); 00396 EXPECT(counters.recv_calls == 0); 00397 EXPECT(counters.recved_bytes == 0); 00398 EXPECT(counters.err_calls == 0); 00399 /* check ooseq queue */ 00400 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2); 00401 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1); 00402 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); 00403 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 2); 00404 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12); 00405 00406 /* pass the segment to tcp_input */ 00407 test_tcp_input(pinseq, &netif); 00408 /* check if counters are as expected */ 00409 EXPECT(counters.close_calls == 0); 00410 EXPECT(counters.recv_calls == 1); 00411 EXPECT(counters.recved_bytes == 14); 00412 EXPECT(counters.err_calls == 0); 00413 EXPECT(pcb->ooseq == NULL); 00414 00415 /* pass the segment to tcp_input */ 00416 test_tcp_input(p_15_1, &netif); 00417 /* check if counters are as expected */ 00418 EXPECT(counters.close_calls == 0); 00419 EXPECT(counters.recv_calls == 1); 00420 EXPECT(counters.recved_bytes == 14); 00421 EXPECT(counters.err_calls == 0); 00422 /* check ooseq queue */ 00423 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); 00424 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15); 00425 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); 00426 00427 /* pass the segment to tcp_input */ 00428 test_tcp_input(p_15_1a, &netif); 00429 /* check if counters are as expected */ 00430 EXPECT(counters.close_calls == 0); 00431 EXPECT(counters.recv_calls == 1); 00432 EXPECT(counters.recved_bytes == 14); 00433 EXPECT(counters.err_calls == 0); 00434 /* check ooseq queue: unchanged */ 00435 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1); 00436 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15); 00437 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1); 00438 00439 /* pass the segment to tcp_input */ 00440 test_tcp_input(pinseqFIN, &netif); 00441 /* check if counters are as expected */ 00442 EXPECT(counters.close_calls == 1); 00443 EXPECT(counters.recv_calls == 2); 00444 EXPECT(counters.recved_bytes == data_len); 00445 EXPECT(counters.err_calls == 0); 00446 EXPECT(pcb->ooseq == NULL); 00447 } 00448 00449 /* make sure the pcb is freed */ 00450 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00451 tcp_abort(pcb); 00452 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00453 } 00454 END_TEST 00455 00456 static char data_full_wnd[TCP_WND + TCP_MSS]; 00457 00458 /** create multiple segments and pass them to tcp_input with the first segment missing 00459 * to simulate overruning the rxwin with ooseq queueing enabled */ 00460 START_TEST(test_tcp_recv_ooseq_overrun_rxwin) 00461 { 00462 #if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS 00463 int i, k; 00464 struct test_tcp_counters counters; 00465 struct tcp_pcb* pcb; 00466 struct pbuf *pinseq, *p_ovr; 00467 struct netif netif; 00468 int datalen = 0; 00469 int datalen2; 00470 00471 for(i = 0; i < (int)sizeof(data_full_wnd); i++) { 00472 data_full_wnd[i] = (char)i; 00473 } 00474 00475 /* initialize local vars */ 00476 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00477 /* initialize counter struct */ 00478 memset(&counters, 0, sizeof(counters)); 00479 counters.expected_data_len = TCP_WND; 00480 counters.expected_data = data_full_wnd; 00481 00482 /* create and initialize the pcb */ 00483 pcb = test_tcp_new_counters_pcb(&counters); 00484 EXPECT_RET(pcb != NULL); 00485 tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00486 pcb->rcv_nxt = 0x8000; 00487 00488 /* create segments */ 00489 /* pinseq is sent as last segment! */ 00490 pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); 00491 00492 for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) { 00493 int count, expected_datalen; 00494 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], 00495 TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); 00496 EXPECT_RET(p != NULL); 00497 /* pass the segment to tcp_input */ 00498 test_tcp_input(p, &netif); 00499 /* check if counters are as expected */ 00500 EXPECT(counters.close_calls == 0); 00501 EXPECT(counters.recv_calls == 0); 00502 EXPECT(counters.recved_bytes == 0); 00503 EXPECT(counters.err_calls == 0); 00504 /* check ooseq queue */ 00505 count = tcp_oos_count(pcb); 00506 EXPECT_OOSEQ(count == k+1); 00507 datalen = tcp_oos_tcplen(pcb); 00508 if (i + TCP_MSS < TCP_WND) { 00509 expected_datalen = (k+1)*TCP_MSS; 00510 } else { 00511 expected_datalen = TCP_WND - TCP_MSS; 00512 } 00513 if (datalen != expected_datalen) { 00514 EXPECT_OOSEQ(datalen == expected_datalen); 00515 } 00516 } 00517 00518 /* pass in one more segment, cleary overrunning the rxwin */ 00519 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); 00520 EXPECT_RET(p_ovr != NULL); 00521 /* pass the segment to tcp_input */ 00522 test_tcp_input(p_ovr, &netif); 00523 /* check if counters are as expected */ 00524 EXPECT(counters.close_calls == 0); 00525 EXPECT(counters.recv_calls == 0); 00526 EXPECT(counters.recved_bytes == 0); 00527 EXPECT(counters.err_calls == 0); 00528 /* check ooseq queue */ 00529 EXPECT_OOSEQ(tcp_oos_count(pcb) == k); 00530 datalen2 = tcp_oos_tcplen(pcb); 00531 EXPECT_OOSEQ(datalen == datalen2); 00532 00533 /* now pass inseq */ 00534 test_tcp_input(pinseq, &netif); 00535 EXPECT(pcb->ooseq == NULL); 00536 00537 /* make sure the pcb is freed */ 00538 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00539 tcp_abort(pcb); 00540 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00541 #endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */ 00542 LWIP_UNUSED_ARG(_i); 00543 } 00544 END_TEST 00545 00546 /** similar to above test, except seqno starts near the max rxwin */ 00547 START_TEST(test_tcp_recv_ooseq_overrun_rxwin_edge) 00548 { 00549 #if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS 00550 int i, k; 00551 struct test_tcp_counters counters; 00552 struct tcp_pcb* pcb; 00553 struct pbuf *pinseq, *p_ovr; 00554 struct netif netif; 00555 int datalen = 0; 00556 int datalen2; 00557 00558 for(i = 0; i < (int)sizeof(data_full_wnd); i++) { 00559 data_full_wnd[i] = (char)i; 00560 } 00561 00562 /* initialize local vars */ 00563 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00564 /* initialize counter struct */ 00565 memset(&counters, 0, sizeof(counters)); 00566 counters.expected_data_len = TCP_WND; 00567 counters.expected_data = data_full_wnd; 00568 00569 /* create and initialize the pcb */ 00570 pcb = test_tcp_new_counters_pcb(&counters); 00571 EXPECT_RET(pcb != NULL); 00572 tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00573 pcb->rcv_nxt = 0xffffffff - (TCP_WND / 2); 00574 00575 /* create segments */ 00576 /* pinseq is sent as last segment! */ 00577 pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); 00578 00579 for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) { 00580 int count, expected_datalen; 00581 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], 00582 TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); 00583 EXPECT_RET(p != NULL); 00584 /* pass the segment to tcp_input */ 00585 test_tcp_input(p, &netif); 00586 /* check if counters are as expected */ 00587 EXPECT(counters.close_calls == 0); 00588 EXPECT(counters.recv_calls == 0); 00589 EXPECT(counters.recved_bytes == 0); 00590 EXPECT(counters.err_calls == 0); 00591 /* check ooseq queue */ 00592 count = tcp_oos_count(pcb); 00593 EXPECT_OOSEQ(count == k+1); 00594 datalen = tcp_oos_tcplen(pcb); 00595 if (i + TCP_MSS < TCP_WND) { 00596 expected_datalen = (k+1)*TCP_MSS; 00597 } else { 00598 expected_datalen = TCP_WND - TCP_MSS; 00599 } 00600 if (datalen != expected_datalen) { 00601 EXPECT_OOSEQ(datalen == expected_datalen); 00602 } 00603 } 00604 00605 /* pass in one more segment, cleary overrunning the rxwin */ 00606 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK); 00607 EXPECT_RET(p_ovr != NULL); 00608 /* pass the segment to tcp_input */ 00609 test_tcp_input(p_ovr, &netif); 00610 /* check if counters are as expected */ 00611 EXPECT(counters.close_calls == 0); 00612 EXPECT(counters.recv_calls == 0); 00613 EXPECT(counters.recved_bytes == 0); 00614 EXPECT(counters.err_calls == 0); 00615 /* check ooseq queue */ 00616 EXPECT_OOSEQ(tcp_oos_count(pcb) == k); 00617 datalen2 = tcp_oos_tcplen(pcb); 00618 EXPECT_OOSEQ(datalen == datalen2); 00619 00620 /* now pass inseq */ 00621 test_tcp_input(pinseq, &netif); 00622 EXPECT(pcb->ooseq == NULL); 00623 00624 /* make sure the pcb is freed */ 00625 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00626 tcp_abort(pcb); 00627 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00628 #endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */ 00629 LWIP_UNUSED_ARG(_i); 00630 } 00631 END_TEST 00632 00633 START_TEST(test_tcp_recv_ooseq_max_bytes) 00634 { 00635 #if TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) 00636 int i, k; 00637 struct test_tcp_counters counters; 00638 struct tcp_pcb* pcb; 00639 struct pbuf *p_ovr; 00640 struct netif netif; 00641 int datalen = 0; 00642 int datalen2; 00643 00644 for(i = 0; i < sizeof(data_full_wnd); i++) { 00645 data_full_wnd[i] = (char)i; 00646 } 00647 00648 /* initialize local vars */ 00649 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00650 /* initialize counter struct */ 00651 memset(&counters, 0, sizeof(counters)); 00652 counters.expected_data_len = TCP_WND; 00653 counters.expected_data = data_full_wnd; 00654 00655 /* create and initialize the pcb */ 00656 pcb = test_tcp_new_counters_pcb(&counters); 00657 EXPECT_RET(pcb != NULL); 00658 tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00659 pcb->rcv_nxt = 0x8000; 00660 00661 /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */ 00662 00663 /* create segments and 'recv' them */ 00664 for(k = 1, i = 1; k < TCP_OOSEQ_MAX_BYTES; k += TCP_MSS, i++) { 00665 int count; 00666 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[k], 00667 TCP_MSS, k, 0, TCP_ACK); 00668 EXPECT_RET(p != NULL); 00669 EXPECT_RET(p->next == NULL); 00670 /* pass the segment to tcp_input */ 00671 test_tcp_input(p, &netif); 00672 /* check if counters are as expected */ 00673 EXPECT(counters.close_calls == 0); 00674 EXPECT(counters.recv_calls == 0); 00675 EXPECT(counters.recved_bytes == 0); 00676 EXPECT(counters.err_calls == 0); 00677 /* check ooseq queue */ 00678 count = tcp_oos_pbuf_count(pcb); 00679 EXPECT_OOSEQ(count == i); 00680 datalen = tcp_oos_tcplen(pcb); 00681 EXPECT_OOSEQ(datalen == (i * TCP_MSS)); 00682 } 00683 00684 /* pass in one more segment, overrunning the limit */ 00685 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[k+1], 1, k+1, 0, TCP_ACK); 00686 EXPECT_RET(p_ovr != NULL); 00687 /* pass the segment to tcp_input */ 00688 test_tcp_input(p_ovr, &netif); 00689 /* check if counters are as expected */ 00690 EXPECT(counters.close_calls == 0); 00691 EXPECT(counters.recv_calls == 0); 00692 EXPECT(counters.recved_bytes == 0); 00693 EXPECT(counters.err_calls == 0); 00694 /* check ooseq queue (ensure the new segment was not accepted) */ 00695 EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1)); 00696 datalen2 = tcp_oos_tcplen(pcb); 00697 EXPECT_OOSEQ(datalen2 == ((i-1) * TCP_MSS)); 00698 00699 /* make sure the pcb is freed */ 00700 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00701 tcp_abort(pcb); 00702 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00703 #endif /* TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */ 00704 LWIP_UNUSED_ARG(_i); 00705 } 00706 END_TEST 00707 00708 START_TEST(test_tcp_recv_ooseq_max_pbufs) 00709 { 00710 #if TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_PBUFS < ((TCP_WND / TCP_MSS) + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) 00711 int i; 00712 struct test_tcp_counters counters; 00713 struct tcp_pcb* pcb; 00714 struct pbuf *p_ovr; 00715 struct netif netif; 00716 int datalen = 0; 00717 int datalen2; 00718 00719 for(i = 0; i < sizeof(data_full_wnd); i++) { 00720 data_full_wnd[i] = (char)i; 00721 } 00722 00723 /* initialize local vars */ 00724 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00725 /* initialize counter struct */ 00726 memset(&counters, 0, sizeof(counters)); 00727 counters.expected_data_len = TCP_WND; 00728 counters.expected_data = data_full_wnd; 00729 00730 /* create and initialize the pcb */ 00731 pcb = test_tcp_new_counters_pcb(&counters); 00732 EXPECT_RET(pcb != NULL); 00733 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00734 pcb->rcv_nxt = 0x8000; 00735 00736 /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */ 00737 00738 /* create segments and 'recv' them */ 00739 for(i = 1; i <= TCP_OOSEQ_MAX_PBUFS; i++) { 00740 int count; 00741 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[i], 00742 1, i, 0, TCP_ACK); 00743 EXPECT_RET(p != NULL); 00744 EXPECT_RET(p->next == NULL); 00745 /* pass the segment to tcp_input */ 00746 test_tcp_input(p, &netif); 00747 /* check if counters are as expected */ 00748 EXPECT(counters.close_calls == 0); 00749 EXPECT(counters.recv_calls == 0); 00750 EXPECT(counters.recved_bytes == 0); 00751 EXPECT(counters.err_calls == 0); 00752 /* check ooseq queue */ 00753 count = tcp_oos_pbuf_count(pcb); 00754 EXPECT_OOSEQ(count == i); 00755 datalen = tcp_oos_tcplen(pcb); 00756 EXPECT_OOSEQ(datalen == i); 00757 } 00758 00759 /* pass in one more segment, overrunning the limit */ 00760 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[i+1], 1, i+1, 0, TCP_ACK); 00761 EXPECT_RET(p_ovr != NULL); 00762 /* pass the segment to tcp_input */ 00763 test_tcp_input(p_ovr, &netif); 00764 /* check if counters are as expected */ 00765 EXPECT(counters.close_calls == 0); 00766 EXPECT(counters.recv_calls == 0); 00767 EXPECT(counters.recved_bytes == 0); 00768 EXPECT(counters.err_calls == 0); 00769 /* check ooseq queue (ensure the new segment was not accepted) */ 00770 EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1)); 00771 datalen2 = tcp_oos_tcplen(pcb); 00772 EXPECT_OOSEQ(datalen2 == (i-1)); 00773 00774 /* make sure the pcb is freed */ 00775 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00776 tcp_abort(pcb); 00777 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00778 #endif /* TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */ 00779 LWIP_UNUSED_ARG(_i); 00780 } 00781 END_TEST 00782 00783 static void 00784 check_rx_counters(struct tcp_pcb *pcb, struct test_tcp_counters *counters, u32_t exp_close_calls, u32_t exp_rx_calls, 00785 u32_t exp_rx_bytes, u32_t exp_err_calls, int exp_oos_count, int exp_oos_len) 00786 { 00787 int oos_len; 00788 EXPECT(counters->close_calls == exp_close_calls); 00789 EXPECT(counters->recv_calls == exp_rx_calls); 00790 EXPECT(counters->recved_bytes == exp_rx_bytes); 00791 EXPECT(counters->err_calls == exp_err_calls); 00792 /* check that pbuf is queued in ooseq */ 00793 EXPECT_OOSEQ(tcp_oos_count(pcb) == exp_oos_count); 00794 oos_len = tcp_oos_tcplen(pcb); 00795 EXPECT_OOSEQ(exp_oos_len == oos_len); 00796 } 00797 00798 /* this test uses 4 packets: 00799 * - data (len=TCP_MSS) 00800 * - FIN 00801 * - data after FIN (len=1) (invalid) 00802 * - 2nd FIN (invalid) 00803 * 00804 * the parameter 'delay_packet' is a bitmask that choses which on these packets is ooseq 00805 */ 00806 static void test_tcp_recv_ooseq_double_FINs(int delay_packet) 00807 { 00808 int i, k; 00809 struct test_tcp_counters counters; 00810 struct tcp_pcb* pcb; 00811 struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq; 00812 struct netif netif; 00813 u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0; 00814 int first_dropped = 0xff; 00815 00816 for(i = 0; i < (int)sizeof(data_full_wnd); i++) { 00817 data_full_wnd[i] = (char)i; 00818 } 00819 00820 /* initialize local vars */ 00821 test_tcp_init_netif(&netif, NULL, &test_local_ip, &test_netmask); 00822 /* initialize counter struct */ 00823 memset(&counters, 0, sizeof(counters)); 00824 counters.expected_data_len = TCP_WND; 00825 counters.expected_data = data_full_wnd; 00826 00827 /* create and initialize the pcb */ 00828 pcb = test_tcp_new_counters_pcb(&counters); 00829 EXPECT_RET(pcb != NULL); 00830 tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); 00831 pcb->rcv_nxt = 0x8000; 00832 00833 /* create segments */ 00834 p = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK); 00835 p_normal_fin = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS, 0, TCP_ACK|TCP_FIN); 00836 k = 1; 00837 p_data_after_fin = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS+1], k, TCP_MSS+1, 0, TCP_ACK); 00838 p_2nd_fin_ooseq = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS+1+k, 0, TCP_ACK|TCP_FIN); 00839 00840 if(delay_packet & 1) { 00841 /* drop normal data */ 00842 first_dropped = 1; 00843 } else { 00844 /* send normal data */ 00845 test_tcp_input(p, &netif); 00846 exp_rx_calls++; 00847 exp_rx_bytes += TCP_MSS; 00848 } 00849 /* check if counters are as expected */ 00850 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00851 00852 if(delay_packet & 2) { 00853 /* drop FIN */ 00854 if(first_dropped > 2) { 00855 first_dropped = 2; 00856 } 00857 } else { 00858 /* send FIN */ 00859 test_tcp_input(p_normal_fin, &netif); 00860 if (first_dropped < 2) { 00861 /* already dropped packets, this one is ooseq */ 00862 exp_oos_pbufs++; 00863 exp_oos_tcplen++; 00864 } else { 00865 /* inseq */ 00866 exp_close_calls++; 00867 } 00868 } 00869 /* check if counters are as expected */ 00870 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00871 00872 if(delay_packet & 4) { 00873 /* drop data-after-FIN */ 00874 if(first_dropped > 3) { 00875 first_dropped = 3; 00876 } 00877 } else { 00878 /* send data-after-FIN */ 00879 test_tcp_input(p_data_after_fin, &netif); 00880 if (first_dropped < 3) { 00881 /* already dropped packets, this one is ooseq */ 00882 if (delay_packet & 2) { 00883 /* correct FIN was ooseq */ 00884 exp_oos_pbufs++; 00885 exp_oos_tcplen += k; 00886 } 00887 } else { 00888 /* inseq: no change */ 00889 } 00890 } 00891 /* check if counters are as expected */ 00892 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00893 00894 if(delay_packet & 8) { 00895 /* drop 2nd-FIN */ 00896 if(first_dropped > 4) { 00897 first_dropped = 4; 00898 } 00899 } else { 00900 /* send 2nd-FIN */ 00901 test_tcp_input(p_2nd_fin_ooseq, &netif); 00902 if (first_dropped < 3) { 00903 /* already dropped packets, this one is ooseq */ 00904 if (delay_packet & 2) { 00905 /* correct FIN was ooseq */ 00906 exp_oos_pbufs++; 00907 exp_oos_tcplen++; 00908 } 00909 } else { 00910 /* inseq: no change */ 00911 } 00912 } 00913 /* check if counters are as expected */ 00914 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00915 00916 if(delay_packet & 1) { 00917 /* dropped normal data before */ 00918 test_tcp_input(p, &netif); 00919 exp_rx_calls++; 00920 exp_rx_bytes += TCP_MSS; 00921 if((delay_packet & 2) == 0) { 00922 /* normal FIN was NOT delayed */ 00923 exp_close_calls++; 00924 exp_oos_pbufs = exp_oos_tcplen = 0; 00925 } 00926 } 00927 /* check if counters are as expected */ 00928 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00929 00930 if(delay_packet & 2) { 00931 /* dropped normal FIN before */ 00932 test_tcp_input(p_normal_fin, &netif); 00933 exp_close_calls++; 00934 exp_oos_pbufs = exp_oos_tcplen = 0; 00935 } 00936 /* check if counters are as expected */ 00937 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00938 00939 if(delay_packet & 4) { 00940 /* dropped data-after-FIN before */ 00941 test_tcp_input(p_data_after_fin, &netif); 00942 } 00943 /* check if counters are as expected */ 00944 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00945 00946 if(delay_packet & 8) { 00947 /* dropped 2nd-FIN before */ 00948 test_tcp_input(p_2nd_fin_ooseq, &netif); 00949 } 00950 /* check if counters are as expected */ 00951 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen); 00952 00953 /* check that ooseq data has been dumped */ 00954 EXPECT(pcb->ooseq == NULL); 00955 00956 /* make sure the pcb is freed */ 00957 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1); 00958 tcp_abort(pcb); 00959 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); 00960 } 00961 00962 /** create multiple segments and pass them to tcp_input with the first segment missing 00963 * to simulate overruning the rxwin with ooseq queueing enabled */ 00964 #define FIN_TEST(name, num) \ 00965 START_TEST(name) \ 00966 { \ 00967 LWIP_UNUSED_ARG(_i); \ 00968 test_tcp_recv_ooseq_double_FINs(num); \ 00969 } \ 00970 END_TEST 00971 FIN_TEST(test_tcp_recv_ooseq_double_FIN_0, 0) 00972 FIN_TEST(test_tcp_recv_ooseq_double_FIN_1, 1) 00973 FIN_TEST(test_tcp_recv_ooseq_double_FIN_2, 2) 00974 FIN_TEST(test_tcp_recv_ooseq_double_FIN_3, 3) 00975 FIN_TEST(test_tcp_recv_ooseq_double_FIN_4, 4) 00976 FIN_TEST(test_tcp_recv_ooseq_double_FIN_5, 5) 00977 FIN_TEST(test_tcp_recv_ooseq_double_FIN_6, 6) 00978 FIN_TEST(test_tcp_recv_ooseq_double_FIN_7, 7) 00979 FIN_TEST(test_tcp_recv_ooseq_double_FIN_8, 8) 00980 FIN_TEST(test_tcp_recv_ooseq_double_FIN_9, 9) 00981 FIN_TEST(test_tcp_recv_ooseq_double_FIN_10, 10) 00982 FIN_TEST(test_tcp_recv_ooseq_double_FIN_11, 11) 00983 FIN_TEST(test_tcp_recv_ooseq_double_FIN_12, 12) 00984 FIN_TEST(test_tcp_recv_ooseq_double_FIN_13, 13) 00985 FIN_TEST(test_tcp_recv_ooseq_double_FIN_14, 14) 00986 FIN_TEST(test_tcp_recv_ooseq_double_FIN_15, 15) 00987 00988 00989 /** Create the suite including all tests for this module */ 00990 Suite * 00991 tcp_oos_suite(void) 00992 { 00993 testfunc tests[] = { 00994 TESTFUNC(test_tcp_recv_ooseq_FIN_OOSEQ), 00995 TESTFUNC(test_tcp_recv_ooseq_FIN_INSEQ), 00996 TESTFUNC(test_tcp_recv_ooseq_overrun_rxwin), 00997 TESTFUNC(test_tcp_recv_ooseq_overrun_rxwin_edge), 00998 TESTFUNC(test_tcp_recv_ooseq_max_bytes), 00999 TESTFUNC(test_tcp_recv_ooseq_max_pbufs), 01000 TESTFUNC(test_tcp_recv_ooseq_double_FIN_0), 01001 TESTFUNC(test_tcp_recv_ooseq_double_FIN_1), 01002 TESTFUNC(test_tcp_recv_ooseq_double_FIN_2), 01003 TESTFUNC(test_tcp_recv_ooseq_double_FIN_3), 01004 TESTFUNC(test_tcp_recv_ooseq_double_FIN_4), 01005 TESTFUNC(test_tcp_recv_ooseq_double_FIN_5), 01006 TESTFUNC(test_tcp_recv_ooseq_double_FIN_6), 01007 TESTFUNC(test_tcp_recv_ooseq_double_FIN_7), 01008 TESTFUNC(test_tcp_recv_ooseq_double_FIN_8), 01009 TESTFUNC(test_tcp_recv_ooseq_double_FIN_9), 01010 TESTFUNC(test_tcp_recv_ooseq_double_FIN_10), 01011 TESTFUNC(test_tcp_recv_ooseq_double_FIN_11), 01012 TESTFUNC(test_tcp_recv_ooseq_double_FIN_12), 01013 TESTFUNC(test_tcp_recv_ooseq_double_FIN_13), 01014 TESTFUNC(test_tcp_recv_ooseq_double_FIN_14), 01015 TESTFUNC(test_tcp_recv_ooseq_double_FIN_15) 01016 }; 01017 return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(testfunc), tcp_oos_setup, tcp_oos_teardown); 01018 }
Generated on Tue Jul 12 2022 13:54:56 by
1.7.2