aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vpn/Makefile.am2
-rw-r--r--src/vpn/gnunet-daemon-exit.c43
-rw-r--r--src/vpn/gnunet-daemon-vpn-dns.c2
-rw-r--r--src/vpn/gnunet-daemon-vpn-helper.c28
-rw-r--r--src/vpn/gnunet-daemon-vpn.c46
-rw-r--r--src/vpn/gnunet-daemon-vpn.h9
6 files changed, 69 insertions, 61 deletions
diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am
index 1f5f5c5c0..9100fd900 100644
--- a/src/vpn/Makefile.am
+++ b/src/vpn/Makefile.am
@@ -43,6 +43,7 @@ gnunet_daemon_vpn_LDADD = \
43 $(top_builddir)/src/core/libgnunetcore.la \ 43 $(top_builddir)/src/core/libgnunetcore.la \
44 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 44 $(top_builddir)/src/statistics/libgnunetstatistics.la \
45 $(top_builddir)/src/util/libgnunetutil.la \ 45 $(top_builddir)/src/util/libgnunetutil.la \
46 $(top_builddir)/src/mesh/libgnunetmesh.la \
46 $(GN_LIBINTL) 47 $(GN_LIBINTL)
47 48
48gnunet_service_dns_SOURCES = \ 49gnunet_service_dns_SOURCES = \
@@ -62,6 +63,7 @@ gnunet_daemon_exit_LDADD = \
62 $(top_builddir)/src/core/libgnunetcore.la \ 63 $(top_builddir)/src/core/libgnunetcore.la \
63 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 64 $(top_builddir)/src/statistics/libgnunetstatistics.la \
64 $(top_builddir)/src/util/libgnunetutil.la \ 65 $(top_builddir)/src/util/libgnunetutil.la \
66 $(top_builddir)/src/mesh/libgnunetmesh.la \
65 $(GN_LIBINTL) 67 $(GN_LIBINTL)
66 68
67#check_PROGRAMS = \ 69#check_PROGRAMS = \
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c
index 68c32eaec..909f67842 100644
--- a/src/vpn/gnunet-daemon-exit.c
+++ b/src/vpn/gnunet-daemon-exit.c
@@ -27,7 +27,7 @@
27#include <gnunet_common.h> 27#include <gnunet_common.h>
28#include <gnunet_program_lib.h> 28#include <gnunet_program_lib.h>
29#include <gnunet_protocols.h> 29#include <gnunet_protocols.h>
30#include <gnunet_core_service.h> 30#include <gnunet_mesh_service.h>
31#include <gnunet_constants.h> 31#include <gnunet_constants.h>
32 32
33#include "gnunet-vpn-packet.h" 33#include "gnunet-vpn-packet.h"
@@ -38,9 +38,9 @@
38static int ret; 38static int ret;
39 39
40/** 40/**
41 * The handle to core 41 * The handle to mesh
42 */ 42 */
43static struct GNUNET_CORE_Handle *core_handle; 43static struct GNUNET_MESH_Handle *mesh_handle;
44 44
45/** 45/**
46 * This hashmap contains the mapping from peer, service-descriptor, 46 * This hashmap contains the mapping from peer, service-descriptor,
@@ -54,6 +54,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *udp_connections;
54struct udp_state 54struct udp_state
55{ 55{
56 struct GNUNET_PeerIdentity peer; 56 struct GNUNET_PeerIdentity peer;
57 struct GNUNET_MESH_Tunnel *tunnel;
57 GNUNET_HashCode desc; 58 GNUNET_HashCode desc;
58 short spt; 59 short spt;
59 short dpt; 60 short dpt;
@@ -75,10 +76,10 @@ static void
75cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { 76cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
76 GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); 77 GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
77 78
78 if (core_handle != NULL) 79 if (mesh_handle != NULL)
79 { 80 {
80 GNUNET_CORE_disconnect(core_handle); 81 GNUNET_MESH_disconnect(mesh_handle);
81 core_handle = NULL; 82 mesh_handle = NULL;
82 } 83 }
83} 84}
84 85
@@ -137,9 +138,10 @@ receive_from_network (void *cls,
137 memcpy (desc, &data->state.desc, sizeof (GNUNET_HashCode)); 138 memcpy (desc, &data->state.desc, sizeof (GNUNET_HashCode));
138 memcpy (pkt + 1, buf, len); 139 memcpy (pkt + 1, buf, len);
139 140
140 GNUNET_CORE_notify_transmit_ready (core_handle, 42, 141 GNUNET_MESH_notify_transmit_ready (data->state.tunnel, 42,
142 GNUNET_NO,
141 GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2), 143 GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
142 &data->state.peer, len_pkt, 144 len_pkt,
143 send_udp_service, hdr); 145 send_udp_service, hdr);
144 146
145out: 147out:
@@ -169,13 +171,16 @@ send_to_network (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
169 171
170} 172}
171 173
174/**
175 * The messages are one GNUNET_HashCode for the service, followed by a struct udp_pkt
176 */
172static int 177static int
173receive_udp_service (void *cls, const struct GNUNET_PeerIdentity *other, 178receive_udp_service (void *cls,
179 struct GNUNET_MESH_Tunnel *tunnel,
180 void **tunnel_ctx,
174 const struct GNUNET_MessageHeader *message, 181 const struct GNUNET_MessageHeader *message,
175 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 182 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
176{ 183{
177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received UDP-Packet from peer %s\n",
178 GNUNET_i2s (other));
179 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); 184 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
180 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); 185 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
181 186
@@ -191,7 +196,7 @@ receive_udp_service (void *cls, const struct GNUNET_PeerIdentity *other,
191 struct udp_state *state = &send->state; 196 struct udp_state *state = &send->state;
192 unsigned int new = GNUNET_NO; 197 unsigned int new = GNUNET_NO;
193 198
194 memcpy (&state->peer, other, sizeof (struct GNUNET_PeerIdentity)); 199 state->tunnel = tunnel;
195 memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); 200 memcpy (&state->desc, desc, sizeof (GNUNET_HashCode));
196 state->spt = ntohs (pkt->spt); 201 state->spt = ntohs (pkt->spt);
197 202
@@ -250,21 +255,13 @@ run (void *cls,
250 const char *cfgfile, 255 const char *cfgfile,
251 const struct GNUNET_CONFIGURATION_Handle *cfg_) 256 const struct GNUNET_CONFIGURATION_Handle *cfg_)
252{ 257{
253 const static struct GNUNET_CORE_MessageHandler handlers[] = { 258 const static struct GNUNET_MESH_MessageHandler handlers[] = {
254 {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0}, 259 {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
255 {NULL, 0, 0} 260 {NULL, 0, 0}
256 }; 261 };
257 core_handle = GNUNET_CORE_connect(cfg_, 262 mesh_handle = GNUNET_MESH_connect(cfg_,
258 42,
259 NULL,
260 NULL,
261 NULL,
262 NULL,
263 NULL,
264 NULL,
265 0,
266 NULL, 263 NULL,
267 0, 264 NULL, /* FIXME */
268 handlers); 265 handlers);
269 266
270 udp_connections = GNUNET_CONTAINER_multihashmap_create(65536); 267 udp_connections = GNUNET_CONTAINER_multihashmap_create(65536);
diff --git a/src/vpn/gnunet-daemon-vpn-dns.c b/src/vpn/gnunet-daemon-vpn-dns.c
index d0b407667..0149f3323 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_core_service.h> 30#include <gnunet_mesh_service.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 8c4eb593d..880a53b81 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_core_service.h> 30#include <gnunet_mesh_service.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>
@@ -243,18 +243,28 @@ message_token(void *cls,
243 (port_in_ports(me->desc.ports, pkt6_udp->udp_hdr.dpt) || 243 (port_in_ports(me->desc.ports, pkt6_udp->udp_hdr.dpt) ||
244 port_in_ports(me->additional_ports, pkt6_udp->udp_hdr.dpt))) 244 port_in_ports(me->additional_ports, pkt6_udp->udp_hdr.dpt)))
245 { 245 {
246 size_t size = sizeof(struct GNUNET_PeerIdentity) + sizeof(struct GNUNET_MessageHeader) + sizeof(GNUNET_HashCode) + ntohs(pkt6_udp->udp_hdr.len); 246 size_t size = sizeof(struct GNUNET_MESH_Tunnel*) + sizeof(struct GNUNET_MessageHeader) + sizeof(GNUNET_HashCode) + ntohs(pkt6_udp->udp_hdr.len);
247 struct GNUNET_PeerIdentity *cls = GNUNET_malloc(size); 247 struct GNUNET_MESH_Tunnel **cls = GNUNET_malloc(size);
248 struct GNUNET_MessageHeader *hdr = (struct GNUNET_MessageHeader*)(cls+1); 248 struct GNUNET_MessageHeader *hdr = (struct GNUNET_MessageHeader*)(cls+1);
249 GNUNET_HashCode* hc = (GNUNET_HashCode*)(hdr + 1); 249 GNUNET_HashCode* hc = (GNUNET_HashCode*)(hdr + 1);
250 memcpy(cls, &me->desc.peer, sizeof(struct GNUNET_PeerIdentity)); 250
251 memcpy(hc, &me->desc.service_descriptor, sizeof(GNUNET_HashCode)); 251 memcpy(hc, &me->desc.service_descriptor, sizeof(GNUNET_HashCode));
252 memcpy(hc+1, &pkt6_udp->udp_hdr, ntohs(pkt6_udp->udp_hdr.len)); 252 memcpy(hc+1, &pkt6_udp->udp_hdr, ntohs(pkt6_udp->udp_hdr.len));
253 GNUNET_CORE_peer_request_connect(core_handle, 253
254 GNUNET_TIME_UNIT_FOREVER_REL, 254 if (me->tunnel == NULL)
255 (struct GNUNET_PeerIdentity*)&me->desc.peer, 255 {
256 send_udp_to_peer, 256 *cls = GNUNET_MESH_peer_request_connect_all(mesh_handle,
257 cls); 257 GNUNET_TIME_UNIT_FOREVER_REL,
258 1,
259 (struct GNUNET_PeerIdentity*)&me->desc.peer,
260 send_udp_to_peer,
261 NULL,
262 cls);
263 me->tunnel = *cls;
264 }
265 else
266 *cls = me->tunnel;
267 //FIXME: somehow call send_udp_to_peer
258 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Queued to send to peer %x\n", *((unsigned int*)&me->desc.peer)); 268 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Queued to send to peer %x\n", *((unsigned int*)&me->desc.peer));
259 } 269 }
260 } 270 }
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index b67e4670c..604bb6e1a 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -32,7 +32,7 @@
32#include "gnunet_common.h" 32#include "gnunet_common.h"
33#include <gnunet_os_lib.h> 33#include <gnunet_os_lib.h>
34#include "gnunet_protocols.h" 34#include "gnunet_protocols.h"
35#include <gnunet_core_service.h> 35#include <gnunet_mesh_service.h>
36#include "gnunet_client_lib.h" 36#include "gnunet_client_lib.h"
37#include "gnunet_container_lib.h" 37#include "gnunet_container_lib.h"
38#include "gnunet_constants.h" 38#include "gnunet_constants.h"
@@ -78,10 +78,10 @@ cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
78 dns_connection = NULL; 78 dns_connection = NULL;
79 } 79 }
80 80
81 if (core_handle != NULL) 81 if (mesh_handle != NULL)
82 { 82 {
83 GNUNET_CORE_disconnect(core_handle); 83 GNUNET_MESH_disconnect(mesh_handle);
84 core_handle = NULL; 84 mesh_handle = NULL;
85 } 85 }
86} 86}
87/*}}}*/ 87/*}}}*/
@@ -199,17 +199,18 @@ port_in_ports (uint64_t ports, uint16_t port)
199 199
200void 200void
201send_udp_to_peer (void *cls, 201send_udp_to_peer (void *cls,
202 int success) 202 const struct GNUNET_PeerIdentity *peer,
203 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
203{ 204{
204 struct GNUNET_PeerIdentity *peer = cls; 205 struct GNUNET_MESH_Tunnel **tunnel = cls;
205 struct GNUNET_MessageHeader *hdr = 206 struct GNUNET_MessageHeader *hdr =
206 (struct GNUNET_MessageHeader *) (peer + 1); 207 (struct GNUNET_MessageHeader *) (tunnel + 1);
207 GNUNET_HashCode *hc = (GNUNET_HashCode *) (hdr + 1); 208 GNUNET_HashCode *hc = (GNUNET_HashCode *) (hdr + 1);
208 struct udp_pkt *udp = (struct udp_pkt *) (hc + 1); 209 struct udp_pkt *udp = (struct udp_pkt *) (hc + 1);
209 GNUNET_CORE_notify_transmit_ready (core_handle, 210 GNUNET_MESH_notify_transmit_ready (*tunnel,
211 GNUNET_NO,
210 42, 212 42,
211 GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2), 213 GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
212 peer,
213 htons (sizeof 214 htons (sizeof
214 (struct GNUNET_MessageHeader) + 215 (struct GNUNET_MessageHeader) +
215 sizeof (GNUNET_HashCode) + 216 sizeof (GNUNET_HashCode) +
@@ -374,13 +375,16 @@ add_additional_port (struct map_entry *me, uint16_t port)
374} 375}
375 376
376static int 377static int
377receive_udp_back (void *cls, const struct GNUNET_PeerIdentity *other, 378receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel,
378 const struct GNUNET_MessageHeader *message, 379 void **tunnel_ctx,
379 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 380 const struct GNUNET_MessageHeader *message,
381 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
380{ 382{
381 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); 383 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
382 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); 384 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
383 char addr[16]; 385 char addr[16];
386 const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel);
387
384 new_ip6addr(addr, &other->hashPubKey, desc); 388 new_ip6addr(addr, &other->hashPubKey, desc);
385 389
386 size_t size = sizeof(struct ip6_udp) + ntohs(pkt->len) - 1 - sizeof(struct udp_pkt); 390 size_t size = sizeof(struct ip6_udp) + ntohs(pkt->len) - 1 - sizeof(struct udp_pkt);
@@ -444,11 +448,11 @@ receive_udp_back (void *cls, const struct GNUNET_PeerIdentity *other,
444 return GNUNET_OK; 448 return GNUNET_OK;
445} 449}
446 450
447void init_core (void* cls, struct GNUNET_CORE_Handle* server, const struct GNUNET_PeerIdentity* my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey) { 451void init_mesh (void* cls, struct GNUNET_MESH_Handle* server, const struct GNUNET_PeerIdentity* my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey) {
448 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to CORE, I am %x\n", *((unsigned long*)my_identity)); 452 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to MESH, I am %x\n", *((unsigned long*)my_identity));
449} 453}
450 454
451void connect_core (void* cls, const struct GNUNET_PeerIdentity* peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { 455void connect_mesh (void* cls, const struct GNUNET_PeerIdentity* peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) {
452 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %x\n", *((unsigned long*)peer)); 456 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %x\n", *((unsigned long*)peer));
453} 457}
454 458
@@ -466,21 +470,13 @@ run (void *cls,
466 const char *cfgfile, 470 const char *cfgfile,
467 const struct GNUNET_CONFIGURATION_Handle *cfg_) 471 const struct GNUNET_CONFIGURATION_Handle *cfg_)
468{ 472{
469 const static struct GNUNET_CORE_MessageHandler handlers[] = { 473 const static struct GNUNET_MESH_MessageHandler handlers[] = {
470 {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0}, 474 {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
471 {NULL, 0, 0} 475 {NULL, 0, 0}
472 }; 476 };
473 core_handle = GNUNET_CORE_connect(cfg_, 477 mesh_handle = GNUNET_MESH_connect(cfg_,
474 42,
475 NULL,
476 init_core,
477 connect_core,
478 NULL,
479 NULL,
480 NULL, 478 NULL,
481 0,
482 NULL, 479 NULL,
483 0,
484 handlers); 480 handlers);
485 mst = GNUNET_SERVER_mst_create(&message_token, NULL); 481 mst = GNUNET_SERVER_mst_create(&message_token, NULL);
486 cfg = cfg_; 482 cfg = cfg_;
diff --git a/src/vpn/gnunet-daemon-vpn.h b/src/vpn/gnunet-daemon-vpn.h
index cec47ae76..382ac9a72 100644
--- a/src/vpn/gnunet-daemon-vpn.h
+++ b/src/vpn/gnunet-daemon-vpn.h
@@ -55,7 +55,9 @@ GNUNET_HashCode* address_mapping_exists(unsigned char addr[]);
55unsigned int port_in_ports (uint64_t ports, uint16_t port); 55unsigned int port_in_ports (uint64_t ports, uint16_t port);
56 56
57void 57void
58send_udp_to_peer (void *cls, int success); 58send_udp_to_peer (void *cls,
59 const struct GNUNET_PeerIdentity *peer,
60 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
59 61
60/** 62/**
61 * The configuration to use 63 * The configuration to use
@@ -63,9 +65,9 @@ send_udp_to_peer (void *cls, int success);
63const struct GNUNET_CONFIGURATION_Handle *cfg; 65const struct GNUNET_CONFIGURATION_Handle *cfg;
64 66
65/** 67/**
66 * The handle to core 68 * The handle to mesh
67 */ 69 */
68struct GNUNET_CORE_Handle *core_handle; 70struct GNUNET_MESH_Handle *mesh_handle;
69 71
70/** 72/**
71 * The hashmap containing the mappings from ipv6-addresses to gnunet-descriptors 73 * The hashmap containing the mappings from ipv6-addresses to gnunet-descriptors
@@ -74,6 +76,7 @@ struct GNUNET_CONTAINER_MultiHashMap* hashmap;
74 76
75struct map_entry { 77struct map_entry {
76 struct GNUNET_vpn_service_descriptor desc; 78 struct GNUNET_vpn_service_descriptor desc;
79 struct GNUNET_MESH_Tunnel *tunnel;
77 uint16_t namelen; 80 uint16_t namelen;
78 uint64_t additional_ports; 81 uint64_t additional_ports;
79 /** 82 /**