[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19916 - gnunet/src/tun
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19916 - gnunet/src/tun |
Date: |
Wed, 22 Feb 2012 11:15:02 +0100 |
Author: grothoff
Date: 2012-02-22 11:15:02 +0100 (Wed, 22 Feb 2012)
New Revision: 19916
Added:
gnunet/src/tun/test_tun.c
Modified:
gnunet/src/tun/Makefile.am
Log:
-initial testcase
Modified: gnunet/src/tun/Makefile.am
===================================================================
--- gnunet/src/tun/Makefile.am 2012-02-22 10:10:18 UTC (rev 19915)
+++ gnunet/src/tun/Makefile.am 2012-02-22 10:15:02 UTC (rev 19916)
@@ -18,3 +18,17 @@
libgnunettun_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
+
+check_PROGRAMS = \
+ test_tun
+
+
+if ENABLE_TEST_RUN
+TESTS = $(check_PROGRAMS)
+endif
+
+test_tun_SOURCES = \
+ test_tun.c
+test_tun_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/tun/libgnunettun.la
Added: gnunet/src/tun/test_tun.c
===================================================================
--- gnunet/src/tun/test_tun.c (rev 0)
+++ gnunet/src/tun/test_tun.c 2012-02-22 10:15:02 UTC (rev 19916)
@@ -0,0 +1,59 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010, 2011, 2012 Christian Grothoff
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file tun/test_tun.c
+ * @brief test for tun.c
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_tun_lib.h"
+
+static void
+test_udp (size_t pll)
+{
+ struct GNUNET_TUN_IPv4Header ip;
+ struct GNUNET_TUN_UdpHeader udp;
+ char payload[pll];
+ struct in_addr src;
+ struct in_addr dst;
+
+ inet_pton (AF_INET, "1.2.3.4", &src);
+ inet_pton (AF_INET, "122.2.3.5", &dst);
+ memset (payload, 42, sizeof (payload));
+ GNUNET_TUN_initialize_ipv4_header (&ip,
+ IPPROTO_UDP,
+ pll + sizeof (udp),
+ &src,
+ &dst);
+ GNUNET_TUN_calculate_udp4_checksum (&ip,
+ &udp,
+ payload,
+ pll);
+ fprintf (stderr, "CRC: %u\n",
+ ntohs (udp.crc));
+}
+
+int main (int argc,
+ char **argv)
+{
+ test_udp (4);
+ return 0;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19916 - gnunet/src/tun,
gnunet <=