#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>
/*}}}*/
-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;
}
/**
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));
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)
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);
}
}
}
}
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),
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);
}
}
}
#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"
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,
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)
}
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);
}
}
}
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)
{
}
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) -
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.
*
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);