aboutsummaryrefslogtreecommitdiff
path: root/src/tun
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-22 10:17:11 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-22 10:17:11 +0000
commit9a95c9be3058fb417ca6848a8d8acbd09c7c08dd (patch)
tree048186a0fe7d9f3d9802024da8403c4db01fe45f /src/tun
parent4a38d8a0c3f2d0e3cf9388b010f91fdaa6ca8140 (diff)
downloadgnunet-9a95c9be3058fb417ca6848a8d8acbd09c7c08dd.tar.gz
gnunet-9a95c9be3058fb417ca6848a8d8acbd09c7c08dd.zip
-extended test
Diffstat (limited to 'src/tun')
-rw-r--r--src/tun/test_tun.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/tun/test_tun.c b/src/tun/test_tun.c
index 0177ea462..91173c628 100644
--- a/src/tun/test_tun.c
+++ b/src/tun/test_tun.c
@@ -26,8 +26,12 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_tun_lib.h" 27#include "gnunet_tun_lib.h"
28 28
29static int ret;
30
29static void 31static void
30test_udp (size_t pll) 32test_udp (size_t pll,
33 int pl_fill,
34 uint16_t crc)
31{ 35{
32 struct GNUNET_TUN_IPv4Header ip; 36 struct GNUNET_TUN_IPv4Header ip;
33 struct GNUNET_TUN_UdpHeader udp; 37 struct GNUNET_TUN_UdpHeader udp;
@@ -37,7 +41,7 @@ test_udp (size_t pll)
37 41
38 inet_pton (AF_INET, "1.2.3.4", &src); 42 inet_pton (AF_INET, "1.2.3.4", &src);
39 inet_pton (AF_INET, "122.2.3.5", &dst); 43 inet_pton (AF_INET, "122.2.3.5", &dst);
40 memset (payload, 42, sizeof (payload)); 44 memset (payload, pl_fill, sizeof (payload));
41 GNUNET_TUN_initialize_ipv4_header (&ip, 45 GNUNET_TUN_initialize_ipv4_header (&ip,
42 IPPROTO_UDP, 46 IPPROTO_UDP,
43 pll + sizeof (udp), 47 pll + sizeof (udp),
@@ -47,13 +51,20 @@ test_udp (size_t pll)
47 &udp, 51 &udp,
48 payload, 52 payload,
49 pll); 53 pll);
50 fprintf (stderr, "CRC: %u\n", 54 if (crc != ntohs (udp.crc))
51 ntohs (udp.crc)); 55 {
56 fprintf (stderr, "Got CRC: %u, wanted: %u\n",
57 ntohs (udp.crc),
58 crc);
59 ret = 1;
60 }
52} 61}
53 62
54int main (int argc, 63int main (int argc,
55 char **argv) 64 char **argv)
56{ 65{
57 test_udp (4); 66 test_udp (4, 3, 30799);
58 return 0; 67 test_udp (4, 1, 31827);
68 test_udp (7, 17, 14879);
69 return ret;
59} 70}