]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
Fixed tcp unit tests after introducing ip_addr_p_t and letting tcp_input check for...
authorgoldsimon <goldsimon>
Wed, 30 Mar 2011 18:50:00 +0000 (18:50 +0000)
committergoldsimon <goldsimon>
Wed, 30 Mar 2011 18:50:00 +0000 (18:50 +0000)
test/unit/tcp/tcp_helper.c
test/unit/tcp/tcp_helper.h
test/unit/tcp/test_tcp.c
test/unit/tcp/test_tcp_oos.c

index bccc69dde0f2bee5811b3b1c9ebdc94cecc4444f..b28254088f793159a78e3714836a4bec8bbf64a9 100644 (file)
@@ -88,7 +88,8 @@ tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip,
   memcpy((char*)tcphdr + sizeof(struct tcp_hdr), data, data_len);
 
   /* calculate checksum */
-  tcphdr->chksum = inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest),
+
+  tcphdr->chksum = inet_chksum_pseudo(p, src_ip, dst_ip,
           IP_PROTO_TCP, p->tot_len);
 
   pbuf_header(p, sizeof(struct ip_hdr));
@@ -193,3 +194,20 @@ test_tcp_new_counters_pcb(struct test_tcp_counters* counters)
   }
   return pcb;
 }
+
+/** Calls tcp_input() after adjusting current_iphdr_dest */
+void test_tcp_input(struct pbuf *p, struct netif *inp)
+{
+  struct ip_hdr *iphdr = (struct ip_hdr*)p->payload;
+  ip_addr_copy(current_iphdr_dest, iphdr->dest);
+  ip_addr_copy(current_iphdr_src, iphdr->src);
+  current_netif = inp;
+  current_header = iphdr;
+
+  tcp_input(p, inp);
+
+  current_iphdr_dest.addr = 0;
+  current_iphdr_src.addr = 0;
+  current_netif = NULL;
+  current_header = NULL;
+}
index 2bf6d73f7b2fc12ece3181d82db2275ad47cf8b8..af546dc6c28ac0bdcc0e02ed3bebe8178a7fec20 100644 (file)
@@ -33,4 +33,6 @@ err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err
 
 struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters);
 
+void test_tcp_input(struct pbuf *p, struct netif *inp);
+
 #endif
index 50498ea9f267c84ce9bf76559433a6890d36ae37..0eec3cca7258c400be3d3f1551755eee3f6cabd4 100644 (file)
@@ -76,7 +76,7 @@ START_TEST(test_tcp_recv_inseq)
   EXPECT(p != NULL);
   if (p != NULL) {
     /* pass the segment to tcp_input */
-    tcp_input(p, &netif);
+    test_tcp_input(p, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 1);
index 8f90fff1c428107e33c9c9d6a4085175c42e309d..56944e202e264138a0234b7382c65c8b6b376419 100644 (file)
@@ -180,7 +180,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
   EXPECT(p_fin != NULL);
   if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) {
     /* pass the segment to tcp_input */
-    tcp_input(p_8_9, &netif);
+    test_tcp_input(p_8_9, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -192,7 +192,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */
 
     /* pass the segment to tcp_input */
-    tcp_input(p_4_8, &netif);
+    test_tcp_input(p_4_8, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -206,7 +206,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
 
     /* pass the segment to tcp_input */
-    tcp_input(p_4_10, &netif);
+    test_tcp_input(p_4_10, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -220,7 +220,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
 
     /* pass the segment to tcp_input */
-    tcp_input(p_2_14, &netif);
+    test_tcp_input(p_2_14, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -232,7 +232,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
 
     /* pass the segment to tcp_input */
-    tcp_input(p_fin, &netif);
+    test_tcp_input(p_fin, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -244,7 +244,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
 
     /* pass the segment to tcp_input */
-    tcp_input(pinseq, &netif);
+    test_tcp_input(pinseq, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 1);
     EXPECT(counters.recv_calls == 1);
@@ -330,7 +330,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
   if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL)
     && (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) {
     /* pass the segment to tcp_input */
-    tcp_input(p_1_2, &netif);
+    test_tcp_input(p_1_2, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -342,7 +342,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
 
     /* pass the segment to tcp_input */
-    tcp_input(p_4_8, &netif);
+    test_tcp_input(p_4_8, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -356,7 +356,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8);
 
     /* pass the segment to tcp_input */
-    tcp_input(p_3_11, &netif);
+    test_tcp_input(p_3_11, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -371,7 +371,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11);
 
     /* pass the segment to tcp_input */
-    tcp_input(p_2_12, &netif);
+    test_tcp_input(p_2_12, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -385,7 +385,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12);
 
     /* pass the segment to tcp_input */
-    tcp_input(pinseq, &netif);
+    test_tcp_input(pinseq, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 1);
@@ -394,7 +394,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT(pcb->ooseq == NULL);
 
     /* pass the segment to tcp_input */
-    tcp_input(p_15_1, &netif);
+    test_tcp_input(p_15_1, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 1);
@@ -406,7 +406,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
 
     /* pass the segment to tcp_input */
-    tcp_input(p_15_1a, &netif);
+    test_tcp_input(p_15_1a, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 1);
@@ -418,7 +418,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
     EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
 
     /* pass the segment to tcp_input */
-    tcp_input(pinseqFIN, &netif);
+    test_tcp_input(pinseqFIN, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 1);
     EXPECT(counters.recv_calls == 2);
@@ -480,7 +480,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
                                            TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
     EXPECT(p != NULL);
     /* pass the segment to tcp_input */
-    tcp_input(p, &netif);
+    test_tcp_input(p, &netif);
     /* check if counters are as expected */
     EXPECT(counters.close_calls == 0);
     EXPECT(counters.recv_calls == 0);
@@ -504,7 +504,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
   p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
   EXPECT(p_ovr != NULL);
   /* pass the segment to tcp_input */
-  tcp_input(p_ovr, &netif);
+  test_tcp_input(p_ovr, &netif);
   /* check if counters are as expected */
   EXPECT(counters.close_calls == 0);
   EXPECT(counters.recv_calls == 0);
@@ -516,7 +516,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
   EXPECT_OOSEQ(datalen == datalen2);
 
   /* now pass inseq */
-  tcp_input(pinseq, &netif);
+  test_tcp_input(pinseq, &netif);
   EXPECT(pcb->ooseq == NULL);
 
   /* make sure the pcb is freed */