aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/Makefile.in2
-rw-r--r--src/vpn/gnunet-service-vpn.c168
-rw-r--r--src/vpn/test_gnunet_vpn.c46
-rw-r--r--src/vpn/test_gnunet_vpn.conf8
-rw-r--r--src/vpn/vpn.h2
-rw-r--r--src/vpn/vpn_api.c4
6 files changed, 120 insertions, 110 deletions
diff --git a/src/vpn/Makefile.in b/src/vpn/Makefile.in
index 575375b..54ca311 100644
--- a/src/vpn/Makefile.in
+++ b/src/vpn/Makefile.in
@@ -246,6 +246,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+JAVAPORT = @JAVAPORT@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
@@ -279,6 +280,7 @@ LT_DLLOADERS = @LT_DLLOADERS@
LT_DLPREOPEN = @LT_DLPREOPEN@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
+MONKEYPREFIX = @MONKEYPREFIX@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 26deeee..b7756a3 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -460,7 +460,7 @@ send_client_reply (struct GNUNET_SERVER_Client *client,
int result_af,
const void *addr)
{
- char buf[sizeof (struct RedirectToIpResponseMessage) + sizeof (struct in6_addr)];
+ char buf[sizeof (struct RedirectToIpResponseMessage) + sizeof (struct in6_addr)] GNUNET_ALIGN;
struct RedirectToIpResponseMessage *res;
size_t rlen;
@@ -605,7 +605,7 @@ tunnel_peer_disconnect_handler (void *cls,
"Peer %s disconnected from tunnel.\n",
GNUNET_i2s (peer));
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# Peers connected to mesh tunnels"),
+ gettext_noop ("# peers connected to mesh tunnels"),
-1, GNUNET_NO);
if (NULL != ts->th)
{
@@ -642,7 +642,7 @@ tunnel_peer_connect_handler (void *cls,
"Peer %s connected to tunnel.\n",
GNUNET_i2s (peer));
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# Peers connected to mesh tunnels"),
+ gettext_noop ("# peers connected to mesh tunnels"),
1, GNUNET_NO);
if (NULL == ts->client)
return; /* nothing to do */
@@ -894,6 +894,8 @@ route_packet (struct DestinationEntry *destination,
GNUNET_break (0);
return;
}
+ tcp = NULL; /* make compiler happy */
+ icmp = NULL; /* make compiler happy */
udp = payload;
if (udp->len < sizeof (struct GNUNET_TUN_UdpHeader))
{
@@ -919,6 +921,8 @@ route_packet (struct DestinationEntry *destination,
GNUNET_break (0);
return;
}
+ udp = NULL; /* make compiler happy */
+ icmp = NULL; /* make compiler happy */
tcp = payload;
if (tcp->off * 4 < sizeof (struct GNUNET_TUN_TcpHeader))
{
@@ -950,6 +954,8 @@ route_packet (struct DestinationEntry *destination,
GNUNET_break (0);
return;
}
+ tcp = NULL; /* make compiler happy */
+ udp = NULL; /* make compiler happy */
icmp = payload;
source_port = 0;
destination_port = 0;
@@ -1498,7 +1504,7 @@ route_packet (struct DestinationEntry *destination,
* @param client NULL
* @param message message we got from the client (VPN tunnel interface)
*/
-static void
+static int
message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
const struct GNUNET_MessageHeader *message)
{
@@ -1515,7 +1521,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
(mlen < sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader)) )
{
GNUNET_break (0);
- return;
+ return GNUNET_OK;
}
tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1];
mlen -= (sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader));
@@ -1529,7 +1535,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
{
/* blame kernel */
GNUNET_break (0);
- return;
+ return GNUNET_OK;
}
pkt6 = (const struct GNUNET_TUN_IPv6Header *) &tun[1];
get_destination_key_from_ip (AF_INET6,
@@ -1551,7 +1557,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
&pkt6->destination_address,
buf,
sizeof (buf)));
- return;
+ return GNUNET_OK;
}
route_packet (de,
AF_INET6,
@@ -1570,7 +1576,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
{
/* blame kernel */
GNUNET_break (0);
- return;
+ return GNUNET_OK;
}
pkt4 = (struct GNUNET_TUN_IPv4Header *) &tun[1];
get_destination_key_from_ip (AF_INET,
@@ -1592,13 +1598,13 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
&pkt4->destination_address,
buf,
sizeof (buf)));
- return;
+ return GNUNET_OK;
}
if (pkt4->header_length * 4 != sizeof (struct GNUNET_TUN_IPv4Header))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Received IPv4 packet with options (dropping it)\n"));
- return;
+ return GNUNET_OK;
}
route_packet (de,
AF_INET,
@@ -1615,6 +1621,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
(unsigned int) ntohs (tun->proto));
break;
}
+ return GNUNET_OK;
}
@@ -1736,7 +1743,7 @@ receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
{
/* reserve some extra space in case we have an ICMP type here where
we will need to make up the payload ourselves */
- char buf[size + sizeof (struct GNUNET_TUN_IPv4Header) + 8];
+ char buf[size + sizeof (struct GNUNET_TUN_IPv4Header) + 8] GNUNET_ALIGN;
struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf;
struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1];
struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1];
@@ -1873,7 +1880,7 @@ receive_icmp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
sizeof (struct GNUNET_TUN_Layer2PacketHeader) +
mlen;
{
- char buf[size + sizeof (struct GNUNET_TUN_IPv6Header) + 8];
+ char buf[size + sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN;
struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf;
struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1];
struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1];
@@ -2077,7 +2084,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
sizeof (struct GNUNET_TUN_Layer2PacketHeader) +
mlen;
{
- char buf[size];
+ char buf[size] GNUNET_ALIGN;
struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf;
struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1];
struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1];
@@ -2122,7 +2129,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
sizeof (struct GNUNET_TUN_Layer2PacketHeader) +
mlen;
{
- char buf[size];
+ char buf[size] GNUNET_ALIGN;
struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf;
struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1];
struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1];
@@ -2235,7 +2242,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
sizeof (struct GNUNET_TUN_Layer2PacketHeader) +
mlen;
{
- char buf[size];
+ char buf[size] GNUNET_ALIGN;
struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf;
struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1];
struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1];
@@ -2274,7 +2281,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
sizeof (struct GNUNET_TUN_Layer2PacketHeader) +
mlen;
{
- char buf[size];
+ char buf[size] GNUNET_ALIGN;
struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf;
struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1];
struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1];
@@ -2477,6 +2484,65 @@ expire_destination (struct DestinationEntry *except)
/**
+ * Allocate an IP address for the response.
+ *
+ * @param result_af desired address family; set to the actual
+ * address family; can initially be AF_UNSPEC if there
+ * is no preference; will be set to AF_UNSPEC if the
+ * allocation failed
+ * @param addr set to either v4 or v6 depending on which
+ * storage location was used; set to NULL if allocation failed
+ * @param v4 storage space for an IPv4 address
+ * @param v6 storage space for an IPv6 address
+ * @return GNUNET_OK normally, GNUNET_SYSERR if '*result_af' was
+ * an unsupported address family (not AF_INET, AF_INET6 or AF_UNSPEC)
+ */
+static int
+allocate_response_ip (int *result_af,
+ void **addr,
+ struct in_addr *v4,
+ struct in6_addr *v6)
+{
+ *addr = NULL;
+ switch (*result_af)
+ {
+ case AF_INET:
+ if (GNUNET_OK !=
+ allocate_v4_address (v4))
+ *result_af = AF_UNSPEC;
+ else
+ *addr = v4;
+ break;
+ case AF_INET6:
+ if (GNUNET_OK !=
+ allocate_v6_address (v6))
+ *result_af = AF_UNSPEC;
+ else
+ *addr = v6;
+ break;
+ case AF_UNSPEC:
+ if (GNUNET_OK ==
+ allocate_v4_address (v4))
+ {
+ *addr = v4;
+ *result_af = AF_INET;
+ }
+ else if (GNUNET_OK ==
+ allocate_v6_address (v6))
+ {
+ *addr = v6;
+ *result_af = AF_INET6;
+ }
+ break;
+ default:
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
* A client asks us to setup a redirection via some exit
* node to a particular IP. Setup the redirection and
* give the client the allocated IP.
@@ -2537,40 +2603,11 @@ service_redirect_to_ip (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Client *cl
}
/* allocate response IP */
- addr = NULL;
result_af = (int) htonl (msg->result_af);
- switch (result_af)
+ if (GNUNET_OK != allocate_response_ip (&result_af,
+ &addr,
+ &v4, &v6))
{
- case AF_INET:
- if (GNUNET_OK !=
- allocate_v4_address (&v4))
- result_af = AF_UNSPEC;
- else
- addr = &v4;
- break;
- case AF_INET6:
- if (GNUNET_OK !=
- allocate_v6_address (&v6))
- result_af = AF_UNSPEC;
- else
- addr = &v6;
- break;
- case AF_UNSPEC:
- if (GNUNET_OK ==
- allocate_v4_address (&v4))
- {
- addr = &v4;
- result_af = AF_INET;
- }
- else if (GNUNET_OK ==
- allocate_v6_address (&v6))
- {
- addr = &v6;
- result_af = AF_INET6;
- }
- break;
- default:
- GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
@@ -2673,40 +2710,11 @@ service_redirect_to_service (void *cls GNUNET_UNUSED, struct GNUNET_SERVER_Clien
msg = (const struct RedirectToServiceRequestMessage *) message;
/* allocate response IP */
- addr = NULL;
result_af = (int) htonl (msg->result_af);
- switch (result_af)
+ if (GNUNET_OK != allocate_response_ip (&result_af,
+ &addr,
+ &v4, &v6))
{
- case AF_INET:
- if (GNUNET_OK !=
- allocate_v4_address (&v4))
- result_af = AF_UNSPEC;
- else
- addr = &v4;
- break;
- case AF_INET6:
- if (GNUNET_OK !=
- allocate_v6_address (&v6))
- result_af = AF_UNSPEC;
- else
- addr = &v6;
- break;
- case AF_UNSPEC:
- if (GNUNET_OK ==
- allocate_v4_address (&v4))
- {
- addr = &v4;
- result_af = AF_INET;
- }
- else if (GNUNET_OK ==
- allocate_v6_address (&v6))
- {
- addr = &v6;
- result_af = AF_INET6;
- }
- break;
- default:
- GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
diff --git a/src/vpn/test_gnunet_vpn.c b/src/vpn/test_gnunet_vpn.c
index 005c7bd..4c941bd 100644
--- a/src/vpn/test_gnunet_vpn.c
+++ b/src/vpn/test_gnunet_vpn.c
@@ -35,7 +35,7 @@
#define VERBOSE GNUNET_NO
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
struct PeerContext
{
@@ -131,9 +131,7 @@ mhd_ahc (void *cls,
return MHD_YES;
}
*unused = NULL;
-#if VERBOSE
- fprintf (stderr, "MHD sends respose for request to URL `%s'\n", url);
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MHD sends respose for request to URL `%s'\n", url);
response = MHD_create_response_from_buffer (strlen (url),
(void *) url,
MHD_RESPMEM_MUST_COPY);
@@ -225,8 +223,9 @@ curl_main ()
{
if (msg->data.result != CURLE_OK)
{
- printf ("%s failed at %s:%d: `%s'\n",
- "curl_multi_perform",
+ fprintf (stderr,
+ "%s failed at %s:%d: `%s'\n",
+ "curl_multi_perform",
__FILE__,
__LINE__, curl_easy_strerror (msg->data.result));
global_ret = 1;
@@ -238,12 +237,16 @@ curl_main ()
curl = NULL;
multi = NULL;
if (cbc.pos != strlen ("/hello_world"))
+ {
+ GNUNET_break (0);
global_ret = 2;
+ }
if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
+ {
+ GNUNET_break (0);
global_ret = 3;
-#if VERBOSE
- fprintf (stderr, "Download complete, shutting down!\n");
-#endif
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n");
do_shutdown ();
return;
}
@@ -260,7 +263,6 @@ curl_main ()
&ws,
max + 1);
curl_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
delay,
&nrs,
&nws,
@@ -313,9 +315,7 @@ allocation_cb (void *cls,
multi = curl_multi_init ();
GNUNET_assert (multi != NULL);
GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl));
-#if VERBOSE
- fprintf (stderr, "Beginning HTTP download from `%s'\n", url);
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Beginning HTTP download from `%s'\n", url);
curl_main ();
}
@@ -343,6 +343,7 @@ ctrl_c_shutdown (void *cls,
{
ctrl_c_task_id = GNUNET_SCHEDULER_NO_TASK;
do_shutdown ();
+ GNUNET_break (0);
global_ret = 1;
}
@@ -378,7 +379,6 @@ mhd_main ()
&ws,
max_fd + 1);
mhd_task_id = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
delay,
&nrs,
&nws,
@@ -443,9 +443,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
p->arm_proc =
GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
"-c", cfgname, NULL);
#endif
GNUNET_assert (NULL != p->arm_proc);
@@ -465,7 +462,7 @@ stop_peer (struct PeerContext *p)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
GNUNET_OS_process_get_pid (p->arm_proc));
- GNUNET_OS_process_close (p->arm_proc);
+ GNUNET_OS_process_destroy (p->arm_proc);
p->arm_proc = NULL;
}
#endif
@@ -507,15 +504,12 @@ main (int argc, char *const *argv)
"test_gnunet_vpn",
"-c",
"test_gnunet_vpn.conf",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
-
+
if (0 != ACCESS ("/dev/net/tun", R_OK))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
@@ -536,6 +530,7 @@ main (int argc, char *const *argv)
"Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n");
return 0;
}
+ GNUNET_CRYPTO_setup_hostkey ("test_gnunet_vpn.conf");
bin = argv[0];
if (NULL != strstr (bin, "lt-"))
bin = strstr (bin, "lt-") + 4;
@@ -585,14 +580,13 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
+ {
+ fprintf (stderr, "failed to initialize curl\n");
return 2;
+ }
setup_peer (&p1, "test_gnunet_vpn.conf");
GNUNET_log_setup ("test_gnunet_vpn",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
"test_gnunet_vpn", "nohelp", options, &run, NULL);
diff --git a/src/vpn/test_gnunet_vpn.conf b/src/vpn/test_gnunet_vpn.conf
index 5aec0c5..bdac1a5 100644
--- a/src/vpn/test_gnunet_vpn.conf
+++ b/src/vpn/test_gnunet_vpn.conf
@@ -2,6 +2,8 @@
SERVICEHOME = /tmp/gnunet-test-vpn/
DEFAULTCONFIG = test_gnunet_vpn.conf
+[transport]
+PLUGINS = tcp
[arm]
DEFAULTSERVICES = statistics exit vpn
@@ -19,7 +21,8 @@ EXIT_IFNAME = eth1
WEAKRANDOM = YES
HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
-
+[nse]
+WORKBITS = 1
# repeating some values from the default configurations
# here as the respective network addresses are also
@@ -35,3 +38,6 @@ IPV6ADDR = FC5A:04E1:C2BA::1
IPV6PREFIX = 96
IPV4ADDR = 169.254.86.1
IPV4MASK = 255.255.255.0
+
+[gns]
+AUTOSTART = NO
diff --git a/src/vpn/vpn.h b/src/vpn/vpn.h
index e937f5e..bec3a5b 100644
--- a/src/vpn/vpn.h
+++ b/src/vpn/vpn.h
@@ -115,7 +115,7 @@ struct RedirectToServiceRequestMessage
/**
* Service descriptor identifying the service.
*/
- GNUNET_HashCode service_descriptor GNUNET_PACKED;
+ GNUNET_HashCode service_descriptor;
/**
* Unique ID to match a future response to this request.
diff --git a/src/vpn/vpn_api.c b/src/vpn/vpn_api.c
index 31d17f8..5b70d19 100644
--- a/src/vpn/vpn_api.c
+++ b/src/vpn/vpn_api.c
@@ -402,7 +402,7 @@ reconnect (struct GNUNET_VPN_Handle *vh)
GNUNET_CLIENT_notify_transmit_ready_cancel (vh->th);
vh->th = NULL;
}
- GNUNET_CLIENT_disconnect (vh->client, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (vh->client);
vh->client = NULL;
vh->request_id_gen = 0;
for (rr = vh->rr_head; NULL != rr; rr = rr->next)
@@ -591,7 +591,7 @@ GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh)
}
if (NULL != vh->client)
{
- GNUNET_CLIENT_disconnect (vh->client, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (vh->client);
vh->client = NULL;
}
if (GNUNET_SCHEDULER_NO_TASK != vh->rt)