aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-10-30 19:35:13 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-10-30 19:35:13 +0000
commit6813281cd9f9eac5e6d285fb87725d5d71b76ebb (patch)
tree96e754f810fc4b0b7c7735b38b81b95864920983 /src/vpn
parentc1e5a964f324a33a131b27e681ac8e354f8f0624 (diff)
downloadgnunet-6813281cd9f9eac5e6d285fb87725d5d71b76ebb.tar.gz
gnunet-6813281cd9f9eac5e6d285fb87725d5d71b76ebb.zip
gnunet-daemon-vpn uses the new mesh
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/Makefile.am2
-rw-r--r--src/vpn/gnunet-daemon-vpn-dns.c2
-rw-r--r--src/vpn/gnunet-daemon-vpn-helper.c65
-rw-r--r--src/vpn/gnunet-daemon-vpn.c83
-rw-r--r--src/vpn/gnunet-daemon-vpn.h5
5 files changed, 74 insertions, 83 deletions
diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am
index 5627773aa..a81a71838 100644
--- a/src/vpn/Makefile.am
+++ b/src/vpn/Makefile.am
@@ -42,7 +42,7 @@ gnunet_daemon_vpn_LDADD = \
42 $(top_builddir)/src/core/libgnunetcore.la \ 42 $(top_builddir)/src/core/libgnunetcore.la \
43 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 43 $(top_builddir)/src/statistics/libgnunetstatistics.la \
44 $(top_builddir)/src/util/libgnunetutil.la \ 44 $(top_builddir)/src/util/libgnunetutil.la \
45 $(top_builddir)/src/mesh/libgnunetmesh.la \ 45 $(top_builddir)/src/mesh/libgnunetmeshnew.la \
46 $(GN_LIBINTL) 46 $(GN_LIBINTL)
47 47
48gnunet_service_dns_SOURCES = \ 48gnunet_service_dns_SOURCES = \
diff --git a/src/vpn/gnunet-daemon-vpn-dns.c b/src/vpn/gnunet-daemon-vpn-dns.c
index 7f762238c..b3a9929a1 100644
--- a/src/vpn/gnunet-daemon-vpn-dns.c
+++ b/src/vpn/gnunet-daemon-vpn-dns.c
@@ -27,7 +27,7 @@
27#include <gnunet_common.h> 27#include <gnunet_common.h>
28#include <gnunet_client_lib.h> 28#include <gnunet_client_lib.h>
29#include <gnunet_os_lib.h> 29#include <gnunet_os_lib.h>
30#include <gnunet_mesh_service.h> 30#include <gnunet_mesh_service_new.h>
31#include <gnunet_protocols.h> 31#include <gnunet_protocols.h>
32#include <gnunet_server_lib.h> 32#include <gnunet_server_lib.h>
33#include <gnunet_container_lib.h> 33#include <gnunet_container_lib.h>
diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c
index a91a0591f..9ee6021c8 100644
--- a/src/vpn/gnunet-daemon-vpn-helper.c
+++ b/src/vpn/gnunet-daemon-vpn-helper.c
@@ -27,7 +27,7 @@
27#include <gnunet_common.h> 27#include <gnunet_common.h>
28#include <gnunet_client_lib.h> 28#include <gnunet_client_lib.h>
29#include <gnunet_os_lib.h> 29#include <gnunet_os_lib.h>
30#include <gnunet_mesh_service.h> 30#include <gnunet_mesh_service_new.h>
31#include <gnunet_protocols.h> 31#include <gnunet_protocols.h>
32#include <gnunet_server_lib.h> 32#include <gnunet_server_lib.h>
33#include <gnunet_container_lib.h> 33#include <gnunet_container_lib.h>
@@ -152,13 +152,13 @@ start_helper_and_schedule (void *cls,
152 152
153/*}}}*/ 153/*}}}*/
154 154
155void 155static void*
156initialize_tunnel_state(struct GNUNET_MESH_Tunnel* tunnel, int addrlen, struct GNUNET_MESH_TransmitHandle* th) 156initialize_tunnel_state(int addrlen, struct GNUNET_MESH_TransmitHandle* th)
157{ 157{
158 struct tunnel_state* ts = GNUNET_malloc(sizeof *ts); 158 struct tunnel_state* ts = GNUNET_malloc(sizeof *ts);
159 ts->addrlen = addrlen; 159 ts->addrlen = addrlen;
160 ts->th = th; 160 ts->th = th;
161 GNUNET_MESH_tunnel_set_data(tunnel, ts); 161 return ts;
162} 162}
163 163
164/** 164/**
@@ -424,21 +424,19 @@ message_token (void *cls __attribute__ ((unused)), void *client
424 if (me->tunnel == NULL && NULL != cls) 424 if (me->tunnel == NULL && NULL != cls)
425 { 425 {
426 *cls = 426 *cls =
427 GNUNET_MESH_peer_request_connect_all (mesh_handle, 427 GNUNET_MESH_tunnel_create(mesh_handle, initialize_tunnel_state(16, NULL),
428 GNUNET_TIME_UNIT_FOREVER_REL, 428 &send_pkt_to_peer, NULL, cls);
429 1, 429
430 GNUNET_MESH_peer_request_connect_add (*cls,
430 (struct 431 (struct
431 GNUNET_PeerIdentity *) 432 GNUNET_PeerIdentity *)
432 &me->desc.peer, 433 &me->desc.peer);
433 send_pkt_to_peer, NULL,
434 cls);
435 me->tunnel = *cls; 434 me->tunnel = *cls;
436 initialize_tunnel_state(me->tunnel, 16, NULL);
437 } 435 }
438 else if (NULL != cls) 436 else if (NULL != cls)
439 { 437 {
440 *cls = me->tunnel; 438 *cls = me->tunnel;
441 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL, 0); 439 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
443 "Queued to send IPv6 to peer %x, type %d\n", 441 "Queued to send IPv6 to peer %x, type %d\n",
444 *((unsigned int *) &me->desc.peer), ntohs (hdr->type)); 442 *((unsigned int *) &me->desc.peer), ntohs (hdr->type));
@@ -475,13 +473,12 @@ message_token (void *cls __attribute__ ((unused)), void *client
475 if (me->tunnel == NULL && NULL != cls) 473 if (me->tunnel == NULL && NULL != cls)
476 { 474 {
477 *cls = 475 *cls =
478 GNUNET_MESH_peer_request_connect_by_type (mesh_handle, 476 GNUNET_MESH_tunnel_create(mesh_handle, initialize_tunnel_state(16, NULL),
479 GNUNET_TIME_UNIT_FOREVER_REL, 477 &send_pkt_to_peer, NULL, cls);
480 app_type, 478
481 send_pkt_to_peer, 479 GNUNET_MESH_peer_request_connect_by_type (*cls,
482 NULL, cls); 480 app_type);
483 me->tunnel = *cls; 481 me->tunnel = *cls;
484 initialize_tunnel_state(me->tunnel, 16, NULL);
485 if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type) 482 if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type)
486 udp_tunnel = *cls; 483 udp_tunnel = *cls;
487 else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type) 484 else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type)
@@ -490,7 +487,7 @@ message_token (void *cls __attribute__ ((unused)), void *client
490 else if (NULL != cls) 487 else if (NULL != cls)
491 { 488 {
492 *cls = me->tunnel; 489 *cls = me->tunnel;
493 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL, 0); 490 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
494 } 491 }
495 } 492 }
496 } 493 }
@@ -628,22 +625,18 @@ message_token (void *cls __attribute__ ((unused)), void *client
628 } 625 }
629 if (me->tunnel == NULL && NULL != cls) 626 if (me->tunnel == NULL && NULL != cls)
630 { 627 {
631 *cls = 628 *cls = GNUNET_MESH_tunnel_create(mesh_handle,
632 GNUNET_MESH_peer_request_connect_all (mesh_handle, 629 initialize_tunnel_state(4, NULL),
633 GNUNET_TIME_UNIT_FOREVER_REL, 630 send_pkt_to_peer, NULL, cls);
634 1, 631 GNUNET_MESH_peer_request_connect_add (*cls,
635 (struct 632 (struct GNUNET_PeerIdentity *)
636 GNUNET_PeerIdentity *) 633 &me->desc.peer);
637 &me->desc.peer,
638 send_pkt_to_peer, NULL,
639 cls);
640 me->tunnel = *cls; 634 me->tunnel = *cls;
641 initialize_tunnel_state(me->tunnel, 4, NULL);
642 } 635 }
643 else if (NULL != cls) 636 else if (NULL != cls)
644 { 637 {
645 *cls = me->tunnel; 638 *cls = me->tunnel;
646 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL, 0); 639 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 640 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
648 "Queued to send IPv4 to peer %x, type %d\n", 641 "Queued to send IPv4 to peer %x, type %d\n",
649 *((unsigned int *) &me->desc.peer), 642 *((unsigned int *) &me->desc.peer),
@@ -676,18 +669,16 @@ message_token (void *cls __attribute__ ((unused)), void *client
676 if (me->tunnel == NULL && NULL != cls) 669 if (me->tunnel == NULL && NULL != cls)
677 { 670 {
678 *cls = 671 *cls =
679 GNUNET_MESH_peer_request_connect_by_type (mesh_handle, 672 GNUNET_MESH_tunnel_create(mesh_handle, initialize_tunnel_state(4, NULL),
680 GNUNET_TIME_UNIT_FOREVER_REL, 673 send_pkt_to_peer, NULL, cls);
681 app_type, 674
682 send_pkt_to_peer, 675 GNUNET_MESH_peer_request_connect_by_type (*cls, app_type);
683 NULL, cls);
684 me->tunnel = *cls; 676 me->tunnel = *cls;
685 initialize_tunnel_state(me->tunnel, 4, NULL);
686 } 677 }
687 else if (NULL != cls) 678 else if (NULL != cls)
688 { 679 {
689 *cls = me->tunnel; 680 *cls = me->tunnel;
690 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL, 0); 681 send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
691 } 682 }
692 } 683 }
693 } 684 }
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index bd5938604..5b96f201e 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -30,7 +30,7 @@
30#include "gnunet_common.h" 30#include "gnunet_common.h"
31#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
32#include "gnunet_applications.h" 32#include "gnunet_applications.h"
33#include <gnunet_mesh_service.h> 33#include <gnunet_mesh_service_new.h>
34#include "gnunet_client_lib.h" 34#include "gnunet_client_lib.h"
35#include "gnunet_container_lib.h" 35#include "gnunet_container_lib.h"
36#include "gnunet_constants.h" 36#include "gnunet_constants.h"
@@ -300,17 +300,14 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf)
300 else 300 else
301 size = 0; 301 size = 0;
302 302
303 if (NULL != GNUNET_MESH_tunnel_get_head (*tunnel)) 303 if (NULL != ts->head)
304 { 304 {
305 struct tunnel_notify_queue *element = GNUNET_MESH_tunnel_get_head (*tunnel); 305 struct tunnel_notify_queue *element = ts->head;
306 struct tunnel_notify_queue *head = GNUNET_MESH_tunnel_get_head (*tunnel); 306 struct tunnel_notify_queue *head = ts->head;
307 struct tunnel_notify_queue *tail = GNUNET_MESH_tunnel_get_tail (*tunnel); 307 struct tunnel_notify_queue *tail = ts->tail;
308 308
309 GNUNET_CONTAINER_DLL_remove (head, tail, element); 309 GNUNET_CONTAINER_DLL_remove (head, tail, element);
310 310
311 GNUNET_MESH_tunnel_set_head (*tunnel, head);
312 GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
313
314 ts->th = 311 ts->th =
315 GNUNET_MESH_notify_transmit_ready (*tunnel, 312 GNUNET_MESH_notify_transmit_ready (*tunnel,
316 GNUNET_NO, 313 GNUNET_NO,
@@ -340,10 +337,7 @@ port_in_ports (uint64_t ports, uint16_t port)
340 337
341void 338void
342send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer, 339send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
343 const struct GNUNET_ATS_Information *atsi 340 const struct GNUNET_ATS_Information *atsi __attribute__ ((unused)))
344 __attribute__ ((unused)),
345 unsigned int atsi_count
346 __attribute__ ((unused)))
347{ 341{
348 /* peer == NULL means that all peers in this request are connected */ 342 /* peer == NULL means that all peers in this request are connected */
349 if (peer == NULL) 343 if (peer == NULL)
@@ -372,17 +366,14 @@ send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
372 } 366 }
373 else 367 else
374 { 368 {
375 struct tunnel_notify_queue *head = GNUNET_MESH_tunnel_get_head (*tunnel); 369 struct tunnel_notify_queue *head = ts->head;
376 struct tunnel_notify_queue *tail = GNUNET_MESH_tunnel_get_tail (*tunnel); 370 struct tunnel_notify_queue *tail = ts->tail;
377 struct tunnel_notify_queue *element = GNUNET_malloc (sizeof *element); 371 struct tunnel_notify_queue *element = GNUNET_malloc (sizeof *element);
378 372
379 element->cls = cls; 373 element->cls = cls;
380 element->len = ntohs (hdr->size); 374 element->len = ntohs (hdr->size);
381 375
382 GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); 376 GNUNET_CONTAINER_DLL_insert_tail (head, tail, element);
383
384 GNUNET_MESH_tunnel_set_head (*tunnel, head);
385 GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
386 } 377 }
387} 378}
388 379
@@ -865,23 +856,18 @@ add_additional_port (struct map_entry *me, uint16_t port)
865} 856}
866 857
867static int 858static int
868receive_udp_back (void *cls 859receive_udp_back (void *cls __attribute__ ((unused)),
869 __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, 860 struct GNUNET_MESH_Tunnel *tunnel,
870 void **tunnel_ctx 861 void **tunnel_ctx,
871 __attribute__ ((unused)), 862 const struct GNUNET_PeerIdentity *sender,
872 const struct GNUNET_PeerIdentity *sender
873 __attribute__ ((unused)),
874 const struct GNUNET_MessageHeader *message, 863 const struct GNUNET_MessageHeader *message,
875 const struct GNUNET_ATS_Information *atsi 864 const struct GNUNET_ATS_Information *atsi __attribute__ ((unused)))
876 __attribute__ ((unused)),
877 unsigned int atsi_count
878 __attribute__ ((unused)))
879{ 865{
880 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); 866 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
881 struct remote_addr *s = (struct remote_addr *) desc; 867 struct remote_addr *s = (struct remote_addr *) desc;
882 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); 868 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
883 const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel); 869 const struct GNUNET_PeerIdentity *other = sender;
884 struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel); 870 struct tunnel_state *ts = *tunnel_ctx;
885 871
886 if (16 == ts->addrlen) 872 if (16 == ts->addrlen)
887 { 873 {
@@ -1047,23 +1033,18 @@ receive_udp_back (void *cls
1047} 1033}
1048 1034
1049static int 1035static int
1050receive_tcp_back (void *cls 1036receive_tcp_back (void *cls __attribute__ ((unused)),
1051 __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, 1037 struct GNUNET_MESH_Tunnel *tunnel,
1052 void **tunnel_ctx 1038 void **tunnel_ctx,
1053 __attribute__ ((unused)), 1039 const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)),
1054 const struct GNUNET_PeerIdentity *sender
1055 __attribute__ ((unused)),
1056 const struct GNUNET_MessageHeader *message, 1040 const struct GNUNET_MessageHeader *message,
1057 const struct GNUNET_ATS_Information *atsi 1041 const struct GNUNET_ATS_Information *atsi __attribute__ ((unused)))
1058 __attribute__ ((unused)),
1059 unsigned int atsi_count
1060 __attribute__ ((unused)))
1061{ 1042{
1062 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); 1043 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
1063 struct remote_addr *s = (struct remote_addr *) desc; 1044 struct remote_addr *s = (struct remote_addr *) desc;
1064 struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); 1045 struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1);
1065 const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel); 1046 const struct GNUNET_PeerIdentity *other = sender;
1066 struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel); 1047 struct tunnel_state *ts = *tunnel_ctx;
1067 1048
1068 size_t pktlen = 1049 size_t pktlen =
1069 ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - 1050 ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) -
@@ -1236,6 +1217,24 @@ receive_tcp_back (void *cls
1236 return GNUNET_OK; 1217 return GNUNET_OK;
1237} 1218}
1238 1219
1220static void* new_tunnel(void* cls,
1221 struct GNUNET_MESH_Tunnel *tunnel,
1222 const struct GNUNET_PeerIdentity *initiator,
1223 const struct GNUNET_ATS_Information *atsi)
1224{
1225 /* Why should anyone open an inbound tunnel to vpn? */
1226 GNUNET_break(0);
1227 return NULL;
1228}
1229
1230static void cleaner(void *cls,
1231 const struct GNUNET_MESH_Tunnel *tunnel,
1232 void *tunnel_ctx)
1233{
1234 /* Why should anyone open an inbound tunnel to vpn? */
1235 GNUNET_break(0);
1236}
1237
1239/** 1238/**
1240 * Main function that will be run by the scheduler. 1239 * Main function that will be run by the scheduler.
1241 * 1240 *
@@ -1260,7 +1259,7 @@ run (void *cls, char *const *args __attribute__ ((unused)), const char *cfgfilep
1260 GNUNET_APPLICATION_TYPE_END 1259 GNUNET_APPLICATION_TYPE_END
1261 }; 1260 };
1262 1261
1263 mesh_handle = GNUNET_MESH_connect (cfg_, NULL, NULL, handlers, types); 1262 mesh_handle = GNUNET_MESH_connect (cfg_, 42, NULL, new_tunnel, cleaner, handlers, types);
1264 cfg = cfg_; 1263 cfg = cfg_;
1265 restart_hijack = 0; 1264 restart_hijack = 0;
1266 hashmap = GNUNET_CONTAINER_multihashmap_create (65536); 1265 hashmap = GNUNET_CONTAINER_multihashmap_create (65536);
diff --git a/src/vpn/gnunet-daemon-vpn.h b/src/vpn/gnunet-daemon-vpn.h
index 641be914d..95218aa61 100644
--- a/src/vpn/gnunet-daemon-vpn.h
+++ b/src/vpn/gnunet-daemon-vpn.h
@@ -56,8 +56,7 @@ port_in_ports (uint64_t ports, uint16_t port);
56 56
57void 57void
58send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer, 58send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
59 const struct GNUNET_ATS_Information *atsi, 59 const struct GNUNET_ATS_Information *atsi);
60 unsigned int atsi_count);
61 60
62/** 61/**
63 * The configuration to use 62 * The configuration to use
@@ -132,6 +131,8 @@ struct remote_addr
132struct tunnel_state 131struct tunnel_state
133{ 132{
134 struct GNUNET_MESH_TransmitHandle *th; 133 struct GNUNET_MESH_TransmitHandle *th;
134 struct tunnel_notify_queue *head, *tail;
135
135 int addrlen; 136 int addrlen;
136}; 137};
137 138