ReactOS 0.4.16-dev-597-gdbf7844
test_tcp_oos.c File Reference
#include "test_tcp_oos.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/stats.h"
#include "tcp_helper.h"
Include dependency graph for test_tcp_oos.c:

Go to the source code of this file.

Macros

#define CHECK_SEGMENTS_ON_OOSEQ   1
 
#define EXPECT_OOSEQ(x)   EXPECT(x)
 
#define FIN_TEST(name, num)
 

Functions

static int tcp_oos_count (struct tcp_pcb *pcb)
 
static u32_t tcp_oos_seg_seqno (struct tcp_pcb *pcb, int seg_index)
 
static int tcp_oos_seg_tcplen (struct tcp_pcb *pcb, int seg_index)
 
static int tcp_oos_tcplen (struct tcp_pcb *pcb)
 
static void tcp_oos_setup (void)
 
static void tcp_oos_teardown (void)
 
 START_TEST (test_tcp_recv_ooseq_FIN_OOSEQ)
 
END_TEST START_TEST (test_tcp_recv_ooseq_FIN_INSEQ)
 
 START_TEST (test_tcp_recv_ooseq_overrun_rxwin)
 
END_TEST START_TEST (test_tcp_recv_ooseq_overrun_rxwin_edge)
 
END_TEST START_TEST (test_tcp_recv_ooseq_max_bytes)
 
END_TEST START_TEST (test_tcp_recv_ooseq_max_pbufs)
 
static END_TEST void check_rx_counters (struct tcp_pcb *pcb, struct test_tcp_counters *counters, u32_t exp_close_calls, u32_t exp_rx_calls, u32_t exp_rx_bytes, u32_t exp_err_calls, int exp_oos_count, int exp_oos_len)
 
static void test_tcp_recv_ooseq_double_FINs (int delay_packet)
 
Suite * tcp_oos_suite (void)
 

Variables

static struct netifold_netif_list
 
static struct netifold_netif_default
 
static END_TEST char data_full_wnd [TCP_WND+TCP_MSS]
 

Macro Definition Documentation

◆ CHECK_SEGMENTS_ON_OOSEQ

#define CHECK_SEGMENTS_ON_OOSEQ   1

CHECK_SEGMENTS_ON_OOSEQ: 1: check count, seqno and len of segments on pcb->ooseq (strict) 0: only check that bytes are received in correct order (less strict)

Definition at line 17 of file test_tcp_oos.c.

◆ EXPECT_OOSEQ

#define EXPECT_OOSEQ (   x)    EXPECT(x)

Definition at line 20 of file test_tcp_oos.c.

◆ FIN_TEST

#define FIN_TEST (   name,
  num 
)
Value:
{ \
LWIP_UNUSED_ARG(_i); \
test_tcp_recv_ooseq_double_FINs(num); \
} \
END_TEST
#define START_TEST(x)
Definition: atltest.h:75
GLuint GLuint num
Definition: glext.h:9618
Definition: name.c:39

create multiple segments and pass them to tcp_input with the first segment missing to simulate overruning the rxwin with ooseq queueing enabled

Definition at line 964 of file test_tcp_oos.c.

Function Documentation

◆ check_rx_counters()

static END_TEST void check_rx_counters ( struct tcp_pcb *  pcb,
struct test_tcp_counters counters,
u32_t  exp_close_calls,
u32_t  exp_rx_calls,
u32_t  exp_rx_bytes,
u32_t  exp_err_calls,
int  exp_oos_count,
int  exp_oos_len 
)
static

Definition at line 784 of file test_tcp_oos.c.

786{
787 int oos_len;
788 EXPECT(counters->close_calls == exp_close_calls);
789 EXPECT(counters->recv_calls == exp_rx_calls);
790 EXPECT(counters->recved_bytes == exp_rx_bytes);
791 EXPECT(counters->err_calls == exp_err_calls);
792 /* check that pbuf is queued in ooseq */
793 EXPECT_OOSEQ(tcp_oos_count(pcb) == exp_oos_count);
794 oos_len = tcp_oos_tcplen(pcb);
795 EXPECT_OOSEQ(exp_oos_len == oos_len);
796}
GLint GLint GLsizei GLuint * counters
Definition: glext.h:11114
#define EXPECT(x)
Definition: lwip_check.h:11
static int tcp_oos_tcplen(struct tcp_pcb *pcb)
Definition: test_tcp_oos.c:107
#define EXPECT_OOSEQ(x)
Definition: test_tcp_oos.c:20
static int tcp_oos_count(struct tcp_pcb *pcb)
Definition: test_tcp_oos.c:28

Referenced by test_tcp_recv_ooseq_double_FINs().

◆ START_TEST() [1/6]

END_TEST START_TEST ( test_tcp_recv_ooseq_FIN_INSEQ  )

create multiple segments and pass them to tcp_input in a wrong order to see if ooseq-caching works correctly FIN is received IN-SEQUENCE at the end

Definition at line 290 of file test_tcp_oos.c.

291{
293 struct tcp_pcb* pcb;
294 struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN;
295 char data[] = {
296 1, 2, 3, 4,
297 5, 6, 7, 8,
298 9, 10, 11, 12,
299 13, 14, 15, 16};
300 u16_t data_len;
301 struct netif netif;
302 LWIP_UNUSED_ARG(_i);
303
304 /* initialize local vars */
306 data_len = sizeof(data);
307 /* initialize counter struct */
308 memset(&counters, 0, sizeof(counters));
309 counters.expected_data_len = data_len;
310 counters.expected_data = data;
311
312 /* create and initialize the pcb */
314 EXPECT_RET(pcb != NULL);
316
317 /* create segments */
318 /* p1: 7 bytes - 2 before FIN */
319 /* seqno: 1..2 */
320 p_1_2 = tcp_create_rx_segment(pcb, &data[1], 2, 1, 0, TCP_ACK);
321 /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */
322 /* seqno: 4..11 */
323 p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK);
324 /* p3: same as p2 but 2 bytes longer and one byte more at the front */
325 /* seqno: 3..13 */
326 p_3_11 = tcp_create_rx_segment(pcb, &data[3], 11, 3, 0, TCP_ACK);
327 /* p4: 13 bytes - 2 before FIN - should be ignored as contained in p1 and p3 */
328 /* seqno: 2..13 */
329 p_2_12 = tcp_create_rx_segment(pcb, &data[2], 12, 2, 0, TCP_ACK);
330 /* pinseq is the first segment that is held back to create ooseq! */
331 /* seqno: 0..3 */
332 pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK);
333 /* p5: last byte before FIN */
334 /* seqno: 15 */
335 p_15_1 = tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK);
336 /* p6: same as p5, should be ignored */
337 p_15_1a= tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK);
338 /* pinseqFIN: last 2 bytes plus FIN */
339 /* only segment containing seqno 14 and FIN */
340 pinseqFIN = tcp_create_rx_segment(pcb, &data[14], 2, 14, 0, TCP_ACK|TCP_FIN);
341 EXPECT(pinseq != NULL);
342 EXPECT(p_1_2 != NULL);
343 EXPECT(p_4_8 != NULL);
344 EXPECT(p_3_11 != NULL);
345 EXPECT(p_2_12 != NULL);
346 EXPECT(p_15_1 != NULL);
347 EXPECT(p_15_1a != NULL);
348 EXPECT(pinseqFIN != NULL);
349 if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL)
350 && (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) {
351 /* pass the segment to tcp_input */
352 test_tcp_input(p_1_2, &netif);
353 /* check if counters are as expected */
354 EXPECT(counters.close_calls == 0);
355 EXPECT(counters.recv_calls == 0);
356 EXPECT(counters.recved_bytes == 0);
357 EXPECT(counters.err_calls == 0);
358 /* check ooseq queue */
359 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
360 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
361 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
362
363 /* pass the segment to tcp_input */
364 test_tcp_input(p_4_8, &netif);
365 /* check if counters are as expected */
366 EXPECT(counters.close_calls == 0);
367 EXPECT(counters.recv_calls == 0);
368 EXPECT(counters.recved_bytes == 0);
369 EXPECT(counters.err_calls == 0);
370 /* check ooseq queue */
371 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
372 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
373 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
374 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 4);
375 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8);
376
377 /* pass the segment to tcp_input */
378 test_tcp_input(p_3_11, &netif);
379 /* check if counters are as expected */
380 EXPECT(counters.close_calls == 0);
381 EXPECT(counters.recv_calls == 0);
382 EXPECT(counters.recved_bytes == 0);
383 EXPECT(counters.err_calls == 0);
384 /* check ooseq queue */
385 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
386 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
387 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
388 /* p_3_11 has removed p_4_8 from ooseq */
389 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 3);
390 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11);
391
392 /* pass the segment to tcp_input */
393 test_tcp_input(p_2_12, &netif);
394 /* check if counters are as expected */
395 EXPECT(counters.close_calls == 0);
396 EXPECT(counters.recv_calls == 0);
397 EXPECT(counters.recved_bytes == 0);
398 EXPECT(counters.err_calls == 0);
399 /* check ooseq queue */
400 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
401 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
402 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
403 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 2);
404 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12);
405
406 /* pass the segment to tcp_input */
407 test_tcp_input(pinseq, &netif);
408 /* check if counters are as expected */
409 EXPECT(counters.close_calls == 0);
410 EXPECT(counters.recv_calls == 1);
411 EXPECT(counters.recved_bytes == 14);
412 EXPECT(counters.err_calls == 0);
413 EXPECT(pcb->ooseq == NULL);
414
415 /* pass the segment to tcp_input */
416 test_tcp_input(p_15_1, &netif);
417 /* check if counters are as expected */
418 EXPECT(counters.close_calls == 0);
419 EXPECT(counters.recv_calls == 1);
420 EXPECT(counters.recved_bytes == 14);
421 EXPECT(counters.err_calls == 0);
422 /* check ooseq queue */
423 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
424 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15);
425 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
426
427 /* pass the segment to tcp_input */
428 test_tcp_input(p_15_1a, &netif);
429 /* check if counters are as expected */
430 EXPECT(counters.close_calls == 0);
431 EXPECT(counters.recv_calls == 1);
432 EXPECT(counters.recved_bytes == 14);
433 EXPECT(counters.err_calls == 0);
434 /* check ooseq queue: unchanged */
435 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
436 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15);
437 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
438
439 /* pass the segment to tcp_input */
440 test_tcp_input(pinseqFIN, &netif);
441 /* check if counters are as expected */
442 EXPECT(counters.close_calls == 1);
443 EXPECT(counters.recv_calls == 2);
444 EXPECT(counters.recved_bytes == data_len);
445 EXPECT(counters.err_calls == 0);
446 EXPECT(pcb->ooseq == NULL);
447 }
448
449 /* make sure the pcb is freed */
450 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
451 tcp_abort(pcb);
452 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
453}
static int used
Definition: adh-main.c:39
#define NULL
Definition: types.h:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:373
uint16_t u16_t
Definition: arch.h:127
#define TCP_ACK
Definition: tcp.h:76
#define TCP_FIN
Definition: tcp.h:72
#define EXPECT_RET(x)
Definition: lwip_check.h:12
#define memset(x, y, z)
Definition: compat.h:39
#define MEMP_STATS_GET(x, i)
Definition: stats.h:409
Definition: netif.h:269
Definition: pbuf.h:186
void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, const ip_addr_t *ip_addr, const ip_addr_t *netmask)
Definition: tcp_helper.c:305
void test_tcp_input(struct pbuf *p, struct netif *inp)
Definition: tcp_helper.c:259
struct pbuf * tcp_create_rx_segment(struct tcp_pcb *pcb, void *data, size_t data_len, u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags)
Definition: tcp_helper.c:130
struct tcp_pcb * test_tcp_new_counters_pcb(struct test_tcp_counters *counters)
Definition: tcp_helper.c:244
const ip_addr_t test_local_ip
Definition: tcp_helper.c:14
const ip_addr_t test_remote_ip
Definition: tcp_helper.c:15
#define TEST_REMOTE_PORT
Definition: tcp_helper.h:32
#define TEST_LOCAL_PORT
Definition: tcp_helper.h:33
static __inline void tcp_set_state(struct sock *sk, int state)
Definition: tcpcore.h:3256
static ip4_addr_t test_netmask
Definition: test_etharp.c:18
static int tcp_oos_seg_tcplen(struct tcp_pcb *pcb, int seg_index)
Definition: test_tcp_oos.c:84
static u32_t tcp_oos_seg_seqno(struct tcp_pcb *pcb, int seg_index)
Definition: test_tcp_oos.c:60

◆ START_TEST() [2/6]

START_TEST ( test_tcp_recv_ooseq_FIN_OOSEQ  )

create multiple segments and pass them to tcp_input in a wrong order to see if ooseq-caching works correctly FIN is received in out-of-sequence segments only

Definition at line 154 of file test_tcp_oos.c.

155{
157 struct tcp_pcb* pcb;
158 struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq;
159 char data[] = {
160 1, 2, 3, 4,
161 5, 6, 7, 8,
162 9, 10, 11, 12,
163 13, 14, 15, 16};
164 u16_t data_len;
165 struct netif netif;
166 LWIP_UNUSED_ARG(_i);
167
168 /* initialize local vars */
170 data_len = sizeof(data);
171 /* initialize counter struct */
172 memset(&counters, 0, sizeof(counters));
173 counters.expected_data_len = data_len;
174 counters.expected_data = data;
175
176 /* create and initialize the pcb */
178 EXPECT_RET(pcb != NULL);
180
181 /* create segments */
182 /* pinseq is sent as last segment! */
183 pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK);
184 /* p1: 8 bytes before FIN */
185 /* seqno: 8..16 */
186 p_8_9 = tcp_create_rx_segment(pcb, &data[8], 8, 8, 0, TCP_ACK|TCP_FIN);
187 /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */
188 /* seqno: 4..11 */
189 p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK);
190 /* p3: same as p2 but 2 bytes longer */
191 /* seqno: 4..13 */
192 p_4_10 = tcp_create_rx_segment(pcb, &data[4], 10, 4, 0, TCP_ACK);
193 /* p4: 14 bytes before FIN, includes data from p1 and p2, plus partly from pinseq */
194 /* seqno: 2..15 */
195 p_2_14 = tcp_create_rx_segment(pcb, &data[2], 14, 2, 0, TCP_ACK);
196 /* FIN, seqno 16 */
197 p_fin = tcp_create_rx_segment(pcb, NULL, 0,16, 0, TCP_ACK|TCP_FIN);
198 EXPECT(pinseq != NULL);
199 EXPECT(p_8_9 != NULL);
200 EXPECT(p_4_8 != NULL);
201 EXPECT(p_4_10 != NULL);
202 EXPECT(p_2_14 != NULL);
203 EXPECT(p_fin != NULL);
204 if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) {
205 /* pass the segment to tcp_input */
206 test_tcp_input(p_8_9, &netif);
207 /* check if counters are as expected */
208 EXPECT(counters.close_calls == 0);
209 EXPECT(counters.recv_calls == 0);
210 EXPECT(counters.recved_bytes == 0);
211 EXPECT(counters.err_calls == 0);
212 /* check ooseq queue */
213 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
214 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 8);
215 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */
216
217 /* pass the segment to tcp_input */
218 test_tcp_input(p_4_8, &netif);
219 /* check if counters are as expected */
220 EXPECT(counters.close_calls == 0);
221 EXPECT(counters.recv_calls == 0);
222 EXPECT(counters.recved_bytes == 0);
223 EXPECT(counters.err_calls == 0);
224 /* check ooseq queue */
225 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
226 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4);
227 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4);
228 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8);
229 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
230
231 /* pass the segment to tcp_input */
232 test_tcp_input(p_4_10, &netif);
233 /* check if counters are as expected */
234 EXPECT(counters.close_calls == 0);
235 EXPECT(counters.recv_calls == 0);
236 EXPECT(counters.recved_bytes == 0);
237 EXPECT(counters.err_calls == 0);
238 /* ooseq queue: unchanged */
239 EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
240 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4);
241 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4);
242 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8);
243 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
244
245 /* pass the segment to tcp_input */
246 test_tcp_input(p_2_14, &netif);
247 /* check if counters are as expected */
248 EXPECT(counters.close_calls == 0);
249 EXPECT(counters.recv_calls == 0);
250 EXPECT(counters.recved_bytes == 0);
251 EXPECT(counters.err_calls == 0);
252 /* check ooseq queue */
253 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
254 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2);
255 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
256
257 /* pass the segment to tcp_input */
258 test_tcp_input(p_fin, &netif);
259 /* check if counters are as expected */
260 EXPECT(counters.close_calls == 0);
261 EXPECT(counters.recv_calls == 0);
262 EXPECT(counters.recved_bytes == 0);
263 EXPECT(counters.err_calls == 0);
264 /* ooseq queue: unchanged */
265 EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
266 EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2);
267 EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
268
269 /* pass the segment to tcp_input */
270 test_tcp_input(pinseq, &netif);
271 /* check if counters are as expected */
272 EXPECT(counters.close_calls == 1);
273 EXPECT(counters.recv_calls == 1);
274 EXPECT(counters.recved_bytes == data_len);
275 EXPECT(counters.err_calls == 0);
276 EXPECT(pcb->ooseq == NULL);
277 }
278
279 /* make sure the pcb is freed */
280 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
281 tcp_abort(pcb);
282 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
283}

◆ START_TEST() [3/6]

END_TEST START_TEST ( test_tcp_recv_ooseq_max_bytes  )

Definition at line 633 of file test_tcp_oos.c.

634{
635#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))
636 int i, k;
638 struct tcp_pcb* pcb;
639 struct pbuf *p_ovr;
640 struct netif netif;
641 int datalen = 0;
642 int datalen2;
643
644 for(i = 0; i < sizeof(data_full_wnd); i++) {
645 data_full_wnd[i] = (char)i;
646 }
647
648 /* initialize local vars */
650 /* initialize counter struct */
651 memset(&counters, 0, sizeof(counters));
652 counters.expected_data_len = TCP_WND;
653 counters.expected_data = data_full_wnd;
654
655 /* create and initialize the pcb */
657 EXPECT_RET(pcb != NULL);
659 pcb->rcv_nxt = 0x8000;
660
661 /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */
662
663 /* create segments and 'recv' them */
664 for(k = 1, i = 1; k < TCP_OOSEQ_MAX_BYTES; k += TCP_MSS, i++) {
665 int count;
666 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[k],
667 TCP_MSS, k, 0, TCP_ACK);
668 EXPECT_RET(p != NULL);
669 EXPECT_RET(p->next == NULL);
670 /* pass the segment to tcp_input */
672 /* check if counters are as expected */
673 EXPECT(counters.close_calls == 0);
674 EXPECT(counters.recv_calls == 0);
675 EXPECT(counters.recved_bytes == 0);
676 EXPECT(counters.err_calls == 0);
677 /* check ooseq queue */
678 count = tcp_oos_pbuf_count(pcb);
679 EXPECT_OOSEQ(count == i);
680 datalen = tcp_oos_tcplen(pcb);
682 }
683
684 /* pass in one more segment, overrunning the limit */
685 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[k+1], 1, k+1, 0, TCP_ACK);
686 EXPECT_RET(p_ovr != NULL);
687 /* pass the segment to tcp_input */
688 test_tcp_input(p_ovr, &netif);
689 /* check if counters are as expected */
690 EXPECT(counters.close_calls == 0);
691 EXPECT(counters.recv_calls == 0);
692 EXPECT(counters.recved_bytes == 0);
693 EXPECT(counters.err_calls == 0);
694 /* check ooseq queue (ensure the new segment was not accepted) */
695 EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1));
696 datalen2 = tcp_oos_tcplen(pcb);
697 EXPECT_OOSEQ(datalen2 == ((i-1) * TCP_MSS));
698
699 /* make sure the pcb is freed */
700 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
701 tcp_abort(pcb);
702 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
703#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)) */
704 LWIP_UNUSED_ARG(_i);
705}
unsigned char
Definition: typeof.h:29
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TCP_OOSEQ_MAX_BYTES
Definition: opt.h:1400
#define TCP_WND
Definition: lwipopts.h:48
#define TCP_MSS
Definition: lwipopts.h:46
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1031
int k
Definition: mpi.c:3369
static END_TEST char data_full_wnd[TCP_WND+TCP_MSS]
Definition: test_tcp_oos.c:456

◆ START_TEST() [4/6]

END_TEST START_TEST ( test_tcp_recv_ooseq_max_pbufs  )

Definition at line 708 of file test_tcp_oos.c.

709{
710#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))
711 int i;
713 struct tcp_pcb* pcb;
714 struct pbuf *p_ovr;
715 struct netif netif;
716 int datalen = 0;
717 int datalen2;
718
719 for(i = 0; i < sizeof(data_full_wnd); i++) {
720 data_full_wnd[i] = (char)i;
721 }
722
723 /* initialize local vars */
725 /* initialize counter struct */
726 memset(&counters, 0, sizeof(counters));
727 counters.expected_data_len = TCP_WND;
728 counters.expected_data = data_full_wnd;
729
730 /* create and initialize the pcb */
732 EXPECT_RET(pcb != NULL);
733 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT);
734 pcb->rcv_nxt = 0x8000;
735
736 /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */
737
738 /* create segments and 'recv' them */
739 for(i = 1; i <= TCP_OOSEQ_MAX_PBUFS; i++) {
740 int count;
741 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[i],
742 1, i, 0, TCP_ACK);
743 EXPECT_RET(p != NULL);
744 EXPECT_RET(p->next == NULL);
745 /* pass the segment to tcp_input */
747 /* check if counters are as expected */
748 EXPECT(counters.close_calls == 0);
749 EXPECT(counters.recv_calls == 0);
750 EXPECT(counters.recved_bytes == 0);
751 EXPECT(counters.err_calls == 0);
752 /* check ooseq queue */
753 count = tcp_oos_pbuf_count(pcb);
754 EXPECT_OOSEQ(count == i);
755 datalen = tcp_oos_tcplen(pcb);
757 }
758
759 /* pass in one more segment, overrunning the limit */
760 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[i+1], 1, i+1, 0, TCP_ACK);
761 EXPECT_RET(p_ovr != NULL);
762 /* pass the segment to tcp_input */
763 test_tcp_input(p_ovr, &netif);
764 /* check if counters are as expected */
765 EXPECT(counters.close_calls == 0);
766 EXPECT(counters.recv_calls == 0);
767 EXPECT(counters.recved_bytes == 0);
768 EXPECT(counters.err_calls == 0);
769 /* check ooseq queue (ensure the new segment was not accepted) */
770 EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1));
771 datalen2 = tcp_oos_tcplen(pcb);
772 EXPECT_OOSEQ(datalen2 == (i-1));
773
774 /* make sure the pcb is freed */
775 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
776 tcp_abort(pcb);
777 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
778#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)) */
779 LWIP_UNUSED_ARG(_i);
780}
#define TCP_OOSEQ_MAX_PBUFS
Definition: opt.h:1423

◆ START_TEST() [5/6]

START_TEST ( test_tcp_recv_ooseq_overrun_rxwin  )

create multiple segments and pass them to tcp_input with the first segment missing to simulate overruning the rxwin with ooseq queueing enabled

Definition at line 460 of file test_tcp_oos.c.

461{
462#if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS
463 int i, k;
465 struct tcp_pcb* pcb;
466 struct pbuf *pinseq, *p_ovr;
467 struct netif netif;
468 int datalen = 0;
469 int datalen2;
470
471 for(i = 0; i < (int)sizeof(data_full_wnd); i++) {
472 data_full_wnd[i] = (char)i;
473 }
474
475 /* initialize local vars */
477 /* initialize counter struct */
478 memset(&counters, 0, sizeof(counters));
479 counters.expected_data_len = TCP_WND;
480 counters.expected_data = data_full_wnd;
481
482 /* create and initialize the pcb */
484 EXPECT_RET(pcb != NULL);
486 pcb->rcv_nxt = 0x8000;
487
488 /* create segments */
489 /* pinseq is sent as last segment! */
490 pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK);
491
492 for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) {
493 int count, expected_datalen;
494 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)],
495 TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
496 EXPECT_RET(p != NULL);
497 /* pass the segment to tcp_input */
499 /* check if counters are as expected */
500 EXPECT(counters.close_calls == 0);
501 EXPECT(counters.recv_calls == 0);
502 EXPECT(counters.recved_bytes == 0);
503 EXPECT(counters.err_calls == 0);
504 /* check ooseq queue */
505 count = tcp_oos_count(pcb);
506 EXPECT_OOSEQ(count == k+1);
507 datalen = tcp_oos_tcplen(pcb);
508 if (i + TCP_MSS < TCP_WND) {
509 expected_datalen = (k+1)*TCP_MSS;
510 } else {
511 expected_datalen = TCP_WND - TCP_MSS;
512 }
513 if (datalen != expected_datalen) {
514 EXPECT_OOSEQ(datalen == expected_datalen);
515 }
516 }
517
518 /* pass in one more segment, cleary overrunning the rxwin */
519 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
520 EXPECT_RET(p_ovr != NULL);
521 /* pass the segment to tcp_input */
522 test_tcp_input(p_ovr, &netif);
523 /* check if counters are as expected */
524 EXPECT(counters.close_calls == 0);
525 EXPECT(counters.recv_calls == 0);
526 EXPECT(counters.recved_bytes == 0);
527 EXPECT(counters.err_calls == 0);
528 /* check ooseq queue */
530 datalen2 = tcp_oos_tcplen(pcb);
531 EXPECT_OOSEQ(datalen == datalen2);
532
533 /* now pass inseq */
534 test_tcp_input(pinseq, &netif);
535 EXPECT(pcb->ooseq == NULL);
536
537 /* make sure the pcb is freed */
538 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
539 tcp_abort(pcb);
540 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
541#endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */
542 LWIP_UNUSED_ARG(_i);
543}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ START_TEST() [6/6]

END_TEST START_TEST ( test_tcp_recv_ooseq_overrun_rxwin_edge  )

similar to above test, except seqno starts near the max rxwin

Definition at line 547 of file test_tcp_oos.c.

548{
549#if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS
550 int i, k;
552 struct tcp_pcb* pcb;
553 struct pbuf *pinseq, *p_ovr;
554 struct netif netif;
555 int datalen = 0;
556 int datalen2;
557
558 for(i = 0; i < (int)sizeof(data_full_wnd); i++) {
559 data_full_wnd[i] = (char)i;
560 }
561
562 /* initialize local vars */
564 /* initialize counter struct */
565 memset(&counters, 0, sizeof(counters));
566 counters.expected_data_len = TCP_WND;
567 counters.expected_data = data_full_wnd;
568
569 /* create and initialize the pcb */
571 EXPECT_RET(pcb != NULL);
573 pcb->rcv_nxt = 0xffffffff - (TCP_WND / 2);
574
575 /* create segments */
576 /* pinseq is sent as last segment! */
577 pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK);
578
579 for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) {
580 int count, expected_datalen;
581 struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)],
582 TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
583 EXPECT_RET(p != NULL);
584 /* pass the segment to tcp_input */
586 /* check if counters are as expected */
587 EXPECT(counters.close_calls == 0);
588 EXPECT(counters.recv_calls == 0);
589 EXPECT(counters.recved_bytes == 0);
590 EXPECT(counters.err_calls == 0);
591 /* check ooseq queue */
592 count = tcp_oos_count(pcb);
593 EXPECT_OOSEQ(count == k+1);
594 datalen = tcp_oos_tcplen(pcb);
595 if (i + TCP_MSS < TCP_WND) {
596 expected_datalen = (k+1)*TCP_MSS;
597 } else {
598 expected_datalen = TCP_WND - TCP_MSS;
599 }
600 if (datalen != expected_datalen) {
601 EXPECT_OOSEQ(datalen == expected_datalen);
602 }
603 }
604
605 /* pass in one more segment, cleary overrunning the rxwin */
606 p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
607 EXPECT_RET(p_ovr != NULL);
608 /* pass the segment to tcp_input */
609 test_tcp_input(p_ovr, &netif);
610 /* check if counters are as expected */
611 EXPECT(counters.close_calls == 0);
612 EXPECT(counters.recv_calls == 0);
613 EXPECT(counters.recved_bytes == 0);
614 EXPECT(counters.err_calls == 0);
615 /* check ooseq queue */
617 datalen2 = tcp_oos_tcplen(pcb);
618 EXPECT_OOSEQ(datalen == datalen2);
619
620 /* now pass inseq */
621 test_tcp_input(pinseq, &netif);
622 EXPECT(pcb->ooseq == NULL);
623
624 /* make sure the pcb is freed */
625 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
626 tcp_abort(pcb);
627 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
628#endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */
629 LWIP_UNUSED_ARG(_i);
630}

◆ tcp_oos_count()

static int tcp_oos_count ( struct tcp_pcb *  pcb)
static

Get the numbers of segments on the ooseq list

Definition at line 28 of file test_tcp_oos.c.

29{
30 int num = 0;
31 struct tcp_seg* seg = pcb->ooseq;
32 while(seg != NULL) {
33 num++;
34 seg = seg->next;
35 }
36 return num;
37}

Referenced by check_rx_counters(), and START_TEST().

◆ tcp_oos_seg_seqno()

static u32_t tcp_oos_seg_seqno ( struct tcp_pcb *  pcb,
int  seg_index 
)
static

Get the seqno of a segment (by index) on the ooseq list

Parameters
pcbthe pcb to check for ooseq segments
seg_indexindex of the segment on the ooseq list
Returns
seqno of the segment

Definition at line 60 of file test_tcp_oos.c.

61{
62 int num = 0;
63 struct tcp_seg* seg = pcb->ooseq;
64
65 /* then check the actual segment */
66 while(seg != NULL) {
67 if(num == seg_index) {
68 return seg->tcphdr->seqno;
69 }
70 num++;
71 seg = seg->next;
72 }
73 fail();
74 return 0;
75}

Referenced by START_TEST().

◆ tcp_oos_seg_tcplen()

static int tcp_oos_seg_tcplen ( struct tcp_pcb *  pcb,
int  seg_index 
)
static

Get the tcplen (datalen + SYN/FIN) of a segment (by index) on the ooseq list

Parameters
pcbthe pcb to check for ooseq segments
seg_indexindex of the segment on the ooseq list
Returns
tcplen of the segment

Definition at line 84 of file test_tcp_oos.c.

85{
86 int num = 0;
87 struct tcp_seg* seg = pcb->ooseq;
88
89 /* then check the actual segment */
90 while(seg != NULL) {
91 if(num == seg_index) {
92 return TCP_TCPLEN(seg);
93 }
94 num++;
95 seg = seg->next;
96 }
97 fail();
98 return -1;
99}

Referenced by START_TEST().

◆ tcp_oos_setup()

static void tcp_oos_setup ( void  )
static

Definition at line 125 of file test_tcp_oos.c.

126{
132 lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT));
133}
#define SKIP_POOL(x)
Definition: lwip_check.h:48
void lwip_check_ensure_no_alloc(unsigned int skip)
struct netif * netif_list
Definition: netif.c:113
struct netif * netif_default
Definition: netif.c:115
void tcp_remove_all(void)
Definition: tcp_helper.c:38
static struct netif * old_netif_list
Definition: test_tcp_oos.c:121
static struct netif * old_netif_default
Definition: test_tcp_oos.c:122

Referenced by tcp_oos_suite().

◆ tcp_oos_suite()

Suite * tcp_oos_suite ( void  )

Create the suite including all tests for this module

Definition at line 991 of file test_tcp_oos.c.

992{
993 testfunc tests[] = {
994 TESTFUNC(test_tcp_recv_ooseq_FIN_OOSEQ),
995 TESTFUNC(test_tcp_recv_ooseq_FIN_INSEQ),
996 TESTFUNC(test_tcp_recv_ooseq_overrun_rxwin),
997 TESTFUNC(test_tcp_recv_ooseq_overrun_rxwin_edge),
998 TESTFUNC(test_tcp_recv_ooseq_max_bytes),
999 TESTFUNC(test_tcp_recv_ooseq_max_pbufs),
1000 TESTFUNC(test_tcp_recv_ooseq_double_FIN_0),
1001 TESTFUNC(test_tcp_recv_ooseq_double_FIN_1),
1002 TESTFUNC(test_tcp_recv_ooseq_double_FIN_2),
1003 TESTFUNC(test_tcp_recv_ooseq_double_FIN_3),
1004 TESTFUNC(test_tcp_recv_ooseq_double_FIN_4),
1005 TESTFUNC(test_tcp_recv_ooseq_double_FIN_5),
1006 TESTFUNC(test_tcp_recv_ooseq_double_FIN_6),
1007 TESTFUNC(test_tcp_recv_ooseq_double_FIN_7),
1008 TESTFUNC(test_tcp_recv_ooseq_double_FIN_8),
1009 TESTFUNC(test_tcp_recv_ooseq_double_FIN_9),
1010 TESTFUNC(test_tcp_recv_ooseq_double_FIN_10),
1011 TESTFUNC(test_tcp_recv_ooseq_double_FIN_11),
1012 TESTFUNC(test_tcp_recv_ooseq_double_FIN_12),
1013 TESTFUNC(test_tcp_recv_ooseq_double_FIN_13),
1014 TESTFUNC(test_tcp_recv_ooseq_double_FIN_14),
1015 TESTFUNC(test_tcp_recv_ooseq_double_FIN_15)
1016 };
1017 return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(testfunc), tcp_oos_setup, tcp_oos_teardown);
1018}
Suite * create_suite(const char *name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown)
#define TESTFUNC(x)
Definition: lwip_check.h:22
static struct test_info tests[]
static void tcp_oos_setup(void)
Definition: test_tcp_oos.c:125
static void tcp_oos_teardown(void)
Definition: test_tcp_oos.c:136

Referenced by main().

◆ tcp_oos_tcplen()

static int tcp_oos_tcplen ( struct tcp_pcb *  pcb)
static

Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list

Parameters
pcbthe pcb to check for ooseq segments
Returns
tcplen of all segment

Definition at line 107 of file test_tcp_oos.c.

108{
109 int len = 0;
110 struct tcp_seg* seg = pcb->ooseq;
111
112 /* then check the actual segment */
113 while(seg != NULL) {
114 len += TCP_TCPLEN(seg);
115 seg = seg->next;
116 }
117 return len;
118}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by check_rx_counters(), and START_TEST().

◆ tcp_oos_teardown()

static void tcp_oos_teardown ( void  )
static

Definition at line 136 of file test_tcp_oos.c.

137{
141 /* restore netif_list for next tests (e.g. loopif) */
144 lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT));
145}

Referenced by tcp_oos_suite().

◆ test_tcp_recv_ooseq_double_FINs()

static void test_tcp_recv_ooseq_double_FINs ( int  delay_packet)
static

Definition at line 806 of file test_tcp_oos.c.

807{
808 int i, k;
810 struct tcp_pcb* pcb;
811 struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq;
812 struct netif netif;
813 u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0;
814 int first_dropped = 0xff;
815
816 for(i = 0; i < (int)sizeof(data_full_wnd); i++) {
817 data_full_wnd[i] = (char)i;
818 }
819
820 /* initialize local vars */
822 /* initialize counter struct */
823 memset(&counters, 0, sizeof(counters));
824 counters.expected_data_len = TCP_WND;
825 counters.expected_data = data_full_wnd;
826
827 /* create and initialize the pcb */
829 EXPECT_RET(pcb != NULL);
831 pcb->rcv_nxt = 0x8000;
832
833 /* create segments */
835 p_normal_fin = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS, 0, TCP_ACK|TCP_FIN);
836 k = 1;
837 p_data_after_fin = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS+1], k, TCP_MSS+1, 0, TCP_ACK);
838 p_2nd_fin_ooseq = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS+1+k, 0, TCP_ACK|TCP_FIN);
839
840 if(delay_packet & 1) {
841 /* drop normal data */
842 first_dropped = 1;
843 } else {
844 /* send normal data */
846 exp_rx_calls++;
847 exp_rx_bytes += TCP_MSS;
848 }
849 /* check if counters are as expected */
850 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
851
852 if(delay_packet & 2) {
853 /* drop FIN */
854 if(first_dropped > 2) {
855 first_dropped = 2;
856 }
857 } else {
858 /* send FIN */
859 test_tcp_input(p_normal_fin, &netif);
860 if (first_dropped < 2) {
861 /* already dropped packets, this one is ooseq */
862 exp_oos_pbufs++;
863 exp_oos_tcplen++;
864 } else {
865 /* inseq */
866 exp_close_calls++;
867 }
868 }
869 /* check if counters are as expected */
870 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
871
872 if(delay_packet & 4) {
873 /* drop data-after-FIN */
874 if(first_dropped > 3) {
875 first_dropped = 3;
876 }
877 } else {
878 /* send data-after-FIN */
879 test_tcp_input(p_data_after_fin, &netif);
880 if (first_dropped < 3) {
881 /* already dropped packets, this one is ooseq */
882 if (delay_packet & 2) {
883 /* correct FIN was ooseq */
884 exp_oos_pbufs++;
885 exp_oos_tcplen += k;
886 }
887 } else {
888 /* inseq: no change */
889 }
890 }
891 /* check if counters are as expected */
892 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
893
894 if(delay_packet & 8) {
895 /* drop 2nd-FIN */
896 if(first_dropped > 4) {
897 first_dropped = 4;
898 }
899 } else {
900 /* send 2nd-FIN */
901 test_tcp_input(p_2nd_fin_ooseq, &netif);
902 if (first_dropped < 3) {
903 /* already dropped packets, this one is ooseq */
904 if (delay_packet & 2) {
905 /* correct FIN was ooseq */
906 exp_oos_pbufs++;
907 exp_oos_tcplen++;
908 }
909 } else {
910 /* inseq: no change */
911 }
912 }
913 /* check if counters are as expected */
914 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
915
916 if(delay_packet & 1) {
917 /* dropped normal data before */
919 exp_rx_calls++;
920 exp_rx_bytes += TCP_MSS;
921 if((delay_packet & 2) == 0) {
922 /* normal FIN was NOT delayed */
923 exp_close_calls++;
924 exp_oos_pbufs = exp_oos_tcplen = 0;
925 }
926 }
927 /* check if counters are as expected */
928 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
929
930 if(delay_packet & 2) {
931 /* dropped normal FIN before */
932 test_tcp_input(p_normal_fin, &netif);
933 exp_close_calls++;
934 exp_oos_pbufs = exp_oos_tcplen = 0;
935 }
936 /* check if counters are as expected */
937 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
938
939 if(delay_packet & 4) {
940 /* dropped data-after-FIN before */
941 test_tcp_input(p_data_after_fin, &netif);
942 }
943 /* check if counters are as expected */
944 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
945
946 if(delay_packet & 8) {
947 /* dropped 2nd-FIN before */
948 test_tcp_input(p_2nd_fin_ooseq, &netif);
949 }
950 /* check if counters are as expected */
951 check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
952
953 /* check that ooseq data has been dumped */
954 EXPECT(pcb->ooseq == NULL);
955
956 /* make sure the pcb is freed */
957 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 1);
958 tcp_abort(pcb);
959 EXPECT(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0);
960}
uint32_t u32_t
Definition: arch.h:129
static END_TEST void check_rx_counters(struct tcp_pcb *pcb, struct test_tcp_counters *counters, u32_t exp_close_calls, u32_t exp_rx_calls, u32_t exp_rx_bytes, u32_t exp_err_calls, int exp_oos_count, int exp_oos_len)
Definition: test_tcp_oos.c:784

Variable Documentation

◆ data_full_wnd

END_TEST char data_full_wnd[TCP_WND+TCP_MSS]
static

Definition at line 456 of file test_tcp_oos.c.

Referenced by START_TEST(), and test_tcp_recv_ooseq_double_FINs().

◆ old_netif_default

struct netif* old_netif_default
static

Definition at line 122 of file test_tcp_oos.c.

Referenced by tcp_oos_setup(), and tcp_oos_teardown().

◆ old_netif_list

struct netif* old_netif_list
static

Definition at line 121 of file test_tcp_oos.c.

Referenced by tcp_oos_setup(), and tcp_oos_teardown().