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)
31 struct tcp_seg* seg = pcb->ooseq;
43 struct tcp_seg* seg = pcb->ooseq;
61 struct tcp_seg* seg = pcb->ooseq;
65 if(
num == seg_index) {
66 return seg->tcphdr->seqno;
85 struct tcp_seg* seg = pcb->ooseq;
89 if(
num == seg_index) {
90 return TCP_TCPLEN(seg);
108 struct tcp_seg* seg = pcb->ooseq;
112 len += TCP_TCPLEN(seg);
143 struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq;
151 u16_t remote_port = 0x100, local_port = 0x101;
157 IP4_ADDR(&local_ip, 192, 168, 1, 1);
158 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
159 data_len =
sizeof(
data);
162 counters.expected_data_len = data_len;
168 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
193 if ((pinseq !=
NULL) && (p_8_9 !=
NULL) && (p_4_8 !=
NULL) && (p_4_10 !=
NULL) && (p_2_14 !=
NULL) && (p_fin !=
NULL)) {
269 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
271 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
283 struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN;
291 u16_t remote_port = 0x100, local_port = 0x101;
297 IP4_ADDR(&local_ip, 192, 168, 1, 1);
298 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
299 data_len =
sizeof(
data);
302 counters.expected_data_len = data_len;
308 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
342 if ((pinseq !=
NULL) && (p_1_2 !=
NULL) && (p_4_8 !=
NULL) && (p_3_11 !=
NULL) && (p_2_12 !=
NULL)
343 && (p_15_1 !=
NULL) && (p_15_1a !=
NULL) && (pinseqFIN !=
NULL)) {
443 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
445 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
455#if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS
459 struct pbuf *pinseq, *p_ovr;
461 u16_t remote_port = 0x100, local_port = 0x101;
472 IP4_ADDR(&local_ip, 192, 168, 1, 1);
473 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
482 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
483 pcb->rcv_nxt = 0x8000;
490 int count, expected_datalen;
510 if (
datalen != expected_datalen) {
535 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
537 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
545#if TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
551 u16_t remote_port = 0x100, local_port = 0x101;
562 IP4_ADDR(&local_ip, 192, 168, 1, 1);
563 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
572 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
573 pcb->rcv_nxt = 0x8000;
614 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
616 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
624#if TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_PBUFS < ((TCP_WND / TCP_MSS) + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
630 u16_t remote_port = 0x100, local_port = 0x101;
641 IP4_ADDR(&local_ip, 192, 168, 1, 1);
642 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
651 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
652 pcb->rcv_nxt = 0x8000;
693 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
695 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
703 u32_t exp_rx_bytes,
u32_t exp_err_calls,
int exp_oos_count,
int exp_oos_len)
729 struct pbuf *p_normal_fin, *p_data_after_fin, *
p, *p_2nd_fin_ooseq;
731 u16_t remote_port = 0x100, local_port = 0x101;
733 u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0;
734 int first_dropped = 0xff;
735 int last_dropped = 0;
743 IP4_ADDR(&local_ip, 192, 168, 1, 1);
744 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
753 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
754 pcb->rcv_nxt = 0x8000;
763 if(delay_packet & 1) {
776 if(delay_packet & 2) {
778 if(first_dropped > 2) {
785 if (first_dropped < 2) {
797 if(delay_packet & 4) {
799 if(first_dropped > 3) {
806 if (first_dropped < 3) {
808 if (delay_packet & 2) {
820 if(delay_packet & 8) {
822 if(first_dropped > 4) {
829 if (first_dropped < 3) {
831 if (delay_packet & 2) {
843 if(delay_packet & 1) {
848 if((delay_packet & 2) == 0) {
851 exp_oos_pbufs = exp_oos_tcplen = 0;
857 if(delay_packet & 2) {
861 exp_oos_pbufs = exp_oos_tcplen = 0;
866 if(delay_packet & 4) {
873 if(delay_packet & 8) {
884 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
886 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
891#define FIN_TEST(name, num) \
894 LWIP_UNUSED_ARG(_i); \
895 test_tcp_recv_ooseq_double_FINs(num); \
898FIN_TEST(test_tcp_recv_ooseq_double_FIN_0, 0)
899FIN_TEST(test_tcp_recv_ooseq_double_FIN_1, 1)
900FIN_TEST(test_tcp_recv_ooseq_double_FIN_2, 2)
901FIN_TEST(test_tcp_recv_ooseq_double_FIN_3, 3)
902FIN_TEST(test_tcp_recv_ooseq_double_FIN_4, 4)
903FIN_TEST(test_tcp_recv_ooseq_double_FIN_5, 5)
904FIN_TEST(test_tcp_recv_ooseq_double_FIN_6, 6)
905FIN_TEST(test_tcp_recv_ooseq_double_FIN_7, 7)
906FIN_TEST(test_tcp_recv_ooseq_double_FIN_8, 8)
907FIN_TEST(test_tcp_recv_ooseq_double_FIN_9, 9)
908FIN_TEST(test_tcp_recv_ooseq_double_FIN_10, 10)
909FIN_TEST(test_tcp_recv_ooseq_double_FIN_11, 11)
910FIN_TEST(test_tcp_recv_ooseq_double_FIN_12, 12)
911FIN_TEST(test_tcp_recv_ooseq_double_FIN_13, 13)
912FIN_TEST(test_tcp_recv_ooseq_double_FIN_14, 14)
913FIN_TEST(test_tcp_recv_ooseq_double_FIN_15, 15)
921 test_tcp_recv_ooseq_FIN_OOSEQ,
922 test_tcp_recv_ooseq_FIN_INSEQ,
923 test_tcp_recv_ooseq_overrun_rxwin,
924 test_tcp_recv_ooseq_max_bytes,
925 test_tcp_recv_ooseq_max_pbufs,
926 test_tcp_recv_ooseq_double_FIN_0,
927 test_tcp_recv_ooseq_double_FIN_1,
928 test_tcp_recv_ooseq_double_FIN_2,
929 test_tcp_recv_ooseq_double_FIN_3,
930 test_tcp_recv_ooseq_double_FIN_4,
931 test_tcp_recv_ooseq_double_FIN_5,
932 test_tcp_recv_ooseq_double_FIN_6,
933 test_tcp_recv_ooseq_double_FIN_7,
934 test_tcp_recv_ooseq_double_FIN_8,
935 test_tcp_recv_ooseq_double_FIN_9,
936 test_tcp_recv_ooseq_double_FIN_10,
937 test_tcp_recv_ooseq_double_FIN_11,
938 test_tcp_recv_ooseq_double_FIN_12,
939 test_tcp_recv_ooseq_double_FIN_13,
940 test_tcp_recv_ooseq_double_FIN_14,
941 test_tcp_recv_ooseq_double_FIN_15
#define LWIP_UNUSED_ARG(x)
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLuint * counters
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
#define IP4_ADDR(ipaddr, a, b, c, d)
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
int const JOCTET unsigned int datalen
static Suite * create_suite(const char *name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
static struct test_info tests[]
#define TCP_OOSEQ_MAX_PBUFS
#define TCP_OOSEQ_MAX_BYTES
u8_t pbuf_clen(struct pbuf *p)
void test_tcp_input(struct pbuf *p, struct netif *inp)
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)
struct tcp_pcb * test_tcp_new_counters_pcb(struct test_tcp_counters *counters)
void tcp_remove_all(void)
static __inline void tcp_set_state(struct sock *sk, int state)
static int tcp_oos_seg_tcplen(struct tcp_pcb *pcb, int seg_index)
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)
#define FIN_TEST(name, num)
Suite * tcp_oos_suite(void)
static int tcp_oos_tcplen(struct tcp_pcb *pcb)
static void tcp_oos_setup(void)
static int tcp_oos_pbuf_count(struct tcp_pcb *pcb)
static void tcp_oos_teardown(void)
static int tcp_oos_count(struct tcp_pcb *pcb)
static u32_t tcp_oos_seg_seqno(struct tcp_pcb *pcb, int seg_index)
static END_TEST char data_full_wnd[TCP_WND]