[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17865 - gnunet/src/vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17865 - gnunet/src/vpn |
Date: |
Sun, 30 Oct 2011 20:35:13 +0100 |
Author: toelke
Date: 2011-10-30 20:35:13 +0100 (Sun, 30 Oct 2011)
New Revision: 17865
Modified:
gnunet/src/vpn/Makefile.am
gnunet/src/vpn/gnunet-daemon-vpn-dns.c
gnunet/src/vpn/gnunet-daemon-vpn-helper.c
gnunet/src/vpn/gnunet-daemon-vpn.c
gnunet/src/vpn/gnunet-daemon-vpn.h
Log:
gnunet-daemon-vpn uses the new mesh
Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am 2011-10-30 19:35:07 UTC (rev 17864)
+++ gnunet/src/vpn/Makefile.am 2011-10-30 19:35:13 UTC (rev 17865)
@@ -42,7 +42,7 @@
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/mesh/libgnunetmesh.la \
+ $(top_builddir)/src/mesh/libgnunetmeshnew.la \
$(GN_LIBINTL)
gnunet_service_dns_SOURCES = \
Modified: gnunet/src/vpn/gnunet-daemon-vpn-dns.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-dns.c 2011-10-30 19:35:07 UTC (rev
17864)
+++ gnunet/src/vpn/gnunet-daemon-vpn-dns.c 2011-10-30 19:35:13 UTC (rev
17865)
@@ -27,7 +27,7 @@
#include <gnunet_common.h>
#include <gnunet_client_lib.h>
#include <gnunet_os_lib.h>
-#include <gnunet_mesh_service.h>
+#include <gnunet_mesh_service_new.h>
#include <gnunet_protocols.h>
#include <gnunet_server_lib.h>
#include <gnunet_container_lib.h>
Modified: gnunet/src/vpn/gnunet-daemon-vpn-helper.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn-helper.c 2011-10-30 19:35:07 UTC (rev
17864)
+++ gnunet/src/vpn/gnunet-daemon-vpn-helper.c 2011-10-30 19:35:13 UTC (rev
17865)
@@ -27,7 +27,7 @@
#include <gnunet_common.h>
#include <gnunet_client_lib.h>
#include <gnunet_os_lib.h>
-#include <gnunet_mesh_service.h>
+#include <gnunet_mesh_service_new.h>
#include <gnunet_protocols.h>
#include <gnunet_server_lib.h>
#include <gnunet_container_lib.h>
@@ -152,13 +152,13 @@
/*}}}*/
-void
-initialize_tunnel_state(struct GNUNET_MESH_Tunnel* tunnel, int addrlen, struct
GNUNET_MESH_TransmitHandle* th)
+static void*
+initialize_tunnel_state(int addrlen, struct GNUNET_MESH_TransmitHandle* th)
{
struct tunnel_state* ts = GNUNET_malloc(sizeof *ts);
ts->addrlen = addrlen;
ts->th = th;
- GNUNET_MESH_tunnel_set_data(tunnel, ts);
+ return ts;
}
/**
@@ -424,21 +424,19 @@
if (me->tunnel == NULL && NULL != cls)
{
*cls =
- GNUNET_MESH_peer_request_connect_all (mesh_handle,
-
GNUNET_TIME_UNIT_FOREVER_REL,
- 1,
+ GNUNET_MESH_tunnel_create(mesh_handle,
initialize_tunnel_state(16, NULL),
+ &send_pkt_to_peer, NULL, cls);
+
+ GNUNET_MESH_peer_request_connect_add (*cls,
(struct
GNUNET_PeerIdentity *)
- &me->desc.peer,
- send_pkt_to_peer, NULL,
- cls);
+ &me->desc.peer);
me->tunnel = *cls;
- initialize_tunnel_state(me->tunnel, 16, NULL);
}
else if (NULL != cls)
{
*cls = me->tunnel;
- send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL, 0);
+ send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queued to send IPv6 to peer %x, type %d\n",
*((unsigned int *) &me->desc.peer), ntohs (hdr->type));
@@ -475,13 +473,12 @@
if (me->tunnel == NULL && NULL != cls)
{
*cls =
- GNUNET_MESH_peer_request_connect_by_type (mesh_handle,
-
GNUNET_TIME_UNIT_FOREVER_REL,
- app_type,
- send_pkt_to_peer,
- NULL, cls);
+ GNUNET_MESH_tunnel_create(mesh_handle,
initialize_tunnel_state(16, NULL),
+ &send_pkt_to_peer, NULL, cls);
+
+ GNUNET_MESH_peer_request_connect_by_type (*cls,
+ app_type);
me->tunnel = *cls;
- initialize_tunnel_state(me->tunnel, 16, NULL);
if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type)
udp_tunnel = *cls;
else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type)
@@ -490,7 +487,7 @@
else if (NULL != cls)
{
*cls = me->tunnel;
- send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL, 0);
+ send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
}
}
}
@@ -628,22 +625,18 @@
}
if (me->tunnel == NULL && NULL != cls)
{
- *cls =
- GNUNET_MESH_peer_request_connect_all (mesh_handle,
-
GNUNET_TIME_UNIT_FOREVER_REL,
- 1,
- (struct
- GNUNET_PeerIdentity *)
- &me->desc.peer,
- send_pkt_to_peer, NULL,
- cls);
+ *cls = GNUNET_MESH_tunnel_create(mesh_handle,
+ initialize_tunnel_state(4,
NULL),
+ send_pkt_to_peer, NULL, cls);
+ GNUNET_MESH_peer_request_connect_add (*cls,
+ (struct
GNUNET_PeerIdentity *)
+ &me->desc.peer);
me->tunnel = *cls;
- initialize_tunnel_state(me->tunnel, 4, NULL);
}
else if (NULL != cls)
{
*cls = me->tunnel;
- send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL,
0);
+ send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queued to send IPv4 to peer %x, type %d\n",
*((unsigned int *) &me->desc.peer),
@@ -676,18 +669,16 @@
if (me->tunnel == NULL && NULL != cls)
{
*cls =
- GNUNET_MESH_peer_request_connect_by_type (mesh_handle,
-
GNUNET_TIME_UNIT_FOREVER_REL,
- app_type,
- send_pkt_to_peer,
- NULL, cls);
+ GNUNET_MESH_tunnel_create(mesh_handle,
initialize_tunnel_state(4, NULL),
+ send_pkt_to_peer, NULL, cls);
+
+ GNUNET_MESH_peer_request_connect_by_type (*cls, app_type);
me->tunnel = *cls;
- initialize_tunnel_state(me->tunnel, 4, NULL);
}
else if (NULL != cls)
{
*cls = me->tunnel;
- send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL,
0);
+ send_pkt_to_peer (cls, (struct GNUNET_PeerIdentity *) 1, NULL);
}
}
}
Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c 2011-10-30 19:35:07 UTC (rev 17864)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c 2011-10-30 19:35:13 UTC (rev 17865)
@@ -30,7 +30,7 @@
#include "gnunet_common.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
-#include <gnunet_mesh_service.h>
+#include <gnunet_mesh_service_new.h>
#include "gnunet_client_lib.h"
#include "gnunet_container_lib.h"
#include "gnunet_constants.h"
@@ -300,17 +300,14 @@
else
size = 0;
- if (NULL != GNUNET_MESH_tunnel_get_head (*tunnel))
+ if (NULL != ts->head)
{
- struct tunnel_notify_queue *element = GNUNET_MESH_tunnel_get_head
(*tunnel);
- struct tunnel_notify_queue *head = GNUNET_MESH_tunnel_get_head (*tunnel);
- struct tunnel_notify_queue *tail = GNUNET_MESH_tunnel_get_tail (*tunnel);
+ struct tunnel_notify_queue *element = ts->head;
+ struct tunnel_notify_queue *head = ts->head;
+ struct tunnel_notify_queue *tail = ts->tail;
GNUNET_CONTAINER_DLL_remove (head, tail, element);
- GNUNET_MESH_tunnel_set_head (*tunnel, head);
- GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
-
ts->th =
GNUNET_MESH_notify_transmit_ready (*tunnel,
GNUNET_NO,
@@ -340,10 +337,7 @@
void
send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi
- __attribute__ ((unused)),
- unsigned int atsi_count
- __attribute__ ((unused)))
+ const struct GNUNET_ATS_Information *atsi __attribute__
((unused)))
{
/* peer == NULL means that all peers in this request are connected */
if (peer == NULL)
@@ -372,17 +366,14 @@
}
else
{
- struct tunnel_notify_queue *head = GNUNET_MESH_tunnel_get_head (*tunnel);
- struct tunnel_notify_queue *tail = GNUNET_MESH_tunnel_get_tail (*tunnel);
+ struct tunnel_notify_queue *head = ts->head;
+ struct tunnel_notify_queue *tail = ts->tail;
struct tunnel_notify_queue *element = GNUNET_malloc (sizeof *element);
element->cls = cls;
element->len = ntohs (hdr->size);
GNUNET_CONTAINER_DLL_insert_tail (head, tail, element);
-
- GNUNET_MESH_tunnel_set_head (*tunnel, head);
- GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
}
}
@@ -865,23 +856,18 @@
}
static int
-receive_udp_back (void *cls
- __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx
- __attribute__ ((unused)),
- const struct GNUNET_PeerIdentity *sender
- __attribute__ ((unused)),
+receive_udp_back (void *cls __attribute__ ((unused)),
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
+ const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi
- __attribute__ ((unused)),
- unsigned int atsi_count
- __attribute__ ((unused)))
+ const struct GNUNET_ATS_Information *atsi __attribute__
((unused)))
{
GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
struct remote_addr *s = (struct remote_addr *) desc;
struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
- const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
- struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
+ const struct GNUNET_PeerIdentity *other = sender;
+ struct tunnel_state *ts = *tunnel_ctx;
if (16 == ts->addrlen)
{
@@ -1047,23 +1033,18 @@
}
static int
-receive_tcp_back (void *cls
- __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx
- __attribute__ ((unused)),
- const struct GNUNET_PeerIdentity *sender
- __attribute__ ((unused)),
+receive_tcp_back (void *cls __attribute__ ((unused)),
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
+ const struct GNUNET_PeerIdentity *sender __attribute__
((unused)),
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi
- __attribute__ ((unused)),
- unsigned int atsi_count
- __attribute__ ((unused)))
+ const struct GNUNET_ATS_Information *atsi __attribute__
((unused)))
{
GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
struct remote_addr *s = (struct remote_addr *) desc;
struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1);
- const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
- struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
+ const struct GNUNET_PeerIdentity *other = sender;
+ struct tunnel_state *ts = *tunnel_ctx;
size_t pktlen =
ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) -
@@ -1236,6 +1217,24 @@
return GNUNET_OK;
}
+static void* new_tunnel(void* cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ const struct GNUNET_PeerIdentity *initiator,
+ const struct GNUNET_ATS_Information *atsi)
+{
+ /* Why should anyone open an inbound tunnel to vpn? */
+ GNUNET_break(0);
+ return NULL;
+}
+
+static void cleaner(void *cls,
+ const struct GNUNET_MESH_Tunnel *tunnel,
+ void *tunnel_ctx)
+{
+ /* Why should anyone open an inbound tunnel to vpn? */
+ GNUNET_break(0);
+}
+
/**
* Main function that will be run by the scheduler.
*
@@ -1260,7 +1259,7 @@
GNUNET_APPLICATION_TYPE_END
};
- mesh_handle = GNUNET_MESH_connect (cfg_, NULL, NULL, handlers, types);
+ mesh_handle = GNUNET_MESH_connect (cfg_, 42, NULL, new_tunnel, cleaner,
handlers, types);
cfg = cfg_;
restart_hijack = 0;
hashmap = GNUNET_CONTAINER_multihashmap_create (65536);
Modified: gnunet/src/vpn/gnunet-daemon-vpn.h
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.h 2011-10-30 19:35:07 UTC (rev 17864)
+++ gnunet/src/vpn/gnunet-daemon-vpn.h 2011-10-30 19:35:13 UTC (rev 17865)
@@ -56,8 +56,7 @@
void
send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count);
+ const struct GNUNET_ATS_Information *atsi);
/**
* The configuration to use
@@ -132,6 +131,8 @@
struct tunnel_state
{
struct GNUNET_MESH_TransmitHandle *th;
+ struct tunnel_notify_queue *head, *tail;
+
int addrlen;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17865 - gnunet/src/vpn,
gnunet <=