aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-06-28 14:34:55 +0000
committerBart Polot <bart@net.in.tum.de>2013-06-28 14:34:55 +0000
commitcf19b5082fe8de33e38957f54d28647635b46b60 (patch)
treee6e41da7d5cb14d9a342ef6533633ecb2f34b18d /src
parent166d8f9122bf7ebbaa2a662d09a3fa4d34f6d092 (diff)
Replace mesh with new version
Diffstat (limited to 'src')
-rw-r--r--src/exit/gnunet-daemon-exit.c115
-rw-r--r--src/fs/gnunet-service-fs_mesh.c2
-rw-r--r--src/include/block_mesh.h4
-rw-r--r--src/include/gnunet_mesh2_service.h398
-rw-r--r--src/include/gnunet_mesh_service.h327
-rw-r--r--src/include/gnunet_stream_lib.h4
-rw-r--r--src/mesh/Makefile.am279
-rw-r--r--src/mesh/gnunet-mesh.c28
-rw-r--r--src/mesh/gnunet-service-mesh-new.c5205
-rw-r--r--src/mesh/gnunet-service-mesh.c5695
-rw-r--r--src/mesh/mesh.h185
-rw-r--r--src/mesh/mesh2.h349
-rw-r--r--src/mesh/mesh2_api.c1787
-rw-r--r--src/mesh/mesh2_protocol.h316
-rw-r--r--src/mesh/mesh2_test_lib.c283
-rw-r--r--src/mesh/mesh2_test_lib.h106
-rw-r--r--src/mesh/mesh_api.c1188
-rw-r--r--src/mesh/mesh_path.c2
-rw-r--r--src/mesh/mesh_path.h2
-rw-r--r--src/mesh/mesh_protocol.h116
-rw-r--r--src/mesh/mesh_test_lib.c30
-rw-r--r--src/mesh/mesh_test_lib.h4
-rw-r--r--src/mesh/plugin_block_mesh.c5
-rw-r--r--src/mesh/test_mesh.conf33
-rw-r--r--src/mesh/test_mesh2.conf89
-rw-r--r--src/mesh/test_mesh2_small.c833
-rw-r--r--src/mesh/test_mesh_2dtorus.c128
-rw-r--r--src/mesh/test_mesh_2dtorus.conf71
-rw-r--r--src/mesh/test_mesh_api.c138
-rw-r--r--src/mesh/test_mesh_local.c (renamed from src/mesh/test_mesh2_local.c)8
-rw-r--r--src/mesh/test_mesh_local_1.c294
-rw-r--r--src/mesh/test_mesh_local_2.c290
-rw-r--r--src/mesh/test_mesh_local_traffic.c526
-rw-r--r--src/mesh/test_mesh_small.c336
-rw-r--r--src/mesh/test_mesh_small.conf78
-rw-r--r--src/mesh/test_mesh_tree_api.c409
-rw-r--r--src/pt/gnunet-daemon-pt.c41
-rw-r--r--src/set/Makefile.am2
-rw-r--r--src/set/gnunet-service-set.h2
-rw-r--r--src/stream/stream_api.c276
-rw-r--r--src/vpn/gnunet-service-vpn.c81
41 files changed, 2005 insertions, 18060 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 4e94ea5968..f26ddf7347 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -209,6 +209,12 @@ struct TunnelState
struct GNUNET_MESH_Tunnel *tunnel;
/**
+ * Who is the other end of this tunnel.
+ * FIXME is this needed? Only used for debugging messages
+ */
+ struct GNUNET_PeerIdentity peer;
+
+ /**
* Active tunnel transmission request (or NULL).
*/
struct GNUNET_MESH_TransmitHandle *th;
@@ -493,7 +499,6 @@ process_dns_result (void *cls,
ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel,
GNUNET_NO,
GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
sizeof (struct GNUNET_MessageHeader) + r,
&transmit_reply_to_mesh,
ts);
@@ -506,18 +511,15 @@ process_dns_result (void *cls,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *ts = *tunnel_ctx;
const struct GNUNET_TUN_DnsHeader *dns;
@@ -782,7 +784,6 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
s->th = GNUNET_MESH_notify_transmit_ready (tunnel,
GNUNET_NO /* corking */,
GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
tnq->len,
&send_to_peer_notify_callback,
s);
@@ -799,7 +800,6 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
s->th = GNUNET_MESH_notify_transmit_ready (tunnel,
GNUNET_NO /* corking */,
GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
tnq->len,
&send_to_peer_notify_callback,
s);
@@ -817,19 +817,19 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
* @param tnq message to queue
*/
static void
-send_packet_to_mesh_tunnel (struct GNUNET_MESH_Tunnel *mesh_tunnel,
+send_packet_to_mesh_tunnel (struct TunnelState *s,
struct TunnelMessageQueue *tnq)
{
- struct TunnelState *s;
+ struct GNUNET_MESH_Tunnel *mesh_tunnel;
- s = GNUNET_MESH_tunnel_get_data (mesh_tunnel);
+ mesh_tunnel = s->tunnel;
GNUNET_assert (NULL != s);
GNUNET_CONTAINER_DLL_insert_tail (s->specifics.tcp_udp.head, s->specifics.tcp_udp.tail, tnq);
if (NULL == s->th)
s->th = GNUNET_MESH_notify_transmit_ready (mesh_tunnel,
GNUNET_NO /* cork */,
GNUNET_TIME_UNIT_FOREVER_REL,
- NULL, tnq->len,
+ tnq->len,
&send_to_peer_notify_callback,
s);
}
@@ -1019,8 +1019,7 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
memcpy (&i2v->icmp_header,
icmp,
pktlen);
- send_packet_to_mesh_tunnel (state->tunnel,
- tnq);
+ send_packet_to_mesh_tunnel (state, tnq);
}
@@ -1097,8 +1096,7 @@ udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
memcpy (&urm[1],
&udp[1],
pktlen - sizeof (struct GNUNET_TUN_UdpHeader));
- send_packet_to_mesh_tunnel (state->tunnel,
- tnq);
+ send_packet_to_mesh_tunnel (state, tnq);
}
@@ -1186,8 +1184,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
memcpy (&tdm->tcp_header,
buf,
pktlen);
- send_packet_to_mesh_tunnel (state->tunnel,
- tnq);
+ send_packet_to_mesh_tunnel (state, tnq);
}
@@ -1796,18 +1793,15 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx GNUNET_UNUSED,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_TcpServiceStartMessage *start;
@@ -1853,7 +1847,7 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
/* setup fresh connection */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received data from %s for forwarding to TCP service %s on port %u\n",
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
GNUNET_h2s (&start->service_descriptor),
(unsigned int) ntohs (start->tcp_header.destination_port));
if (NULL == (state->specifics.tcp_udp.serv = find_service (tcp_services, &start->service_descriptor,
@@ -1884,18 +1878,15 @@ receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx GNUNET_UNUSED,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_TcpInternetStartMessage *start;
@@ -1984,7 +1975,7 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
char buf[INET6_ADDRSTRLEN];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received data from %s for starting TCP stream to %s:%u\n",
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
inet_ntop (af,
&state->specifics.tcp_udp.ri.remote_address.address,
buf, sizeof (buf)),
@@ -2008,18 +1999,15 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx GNUNET_UNUSED,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_TcpDataMessage *data;
@@ -2069,7 +2057,7 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received additional %u bytes of data from %s for TCP stream to %s:%u\n",
pkt_len,
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
inet_ntop (state->specifics.tcp_udp.ri.remote_address.af,
&state->specifics.tcp_udp.ri.remote_address.address,
buf, sizeof (buf)),
@@ -2244,18 +2232,15 @@ make_up_icmpv6_payload (struct TunnelState *state,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx GNUNET_UNUSED,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_IcmpInternetMessage *msg;
@@ -2428,7 +2413,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
char buf[INET6_ADDRSTRLEN];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received ICMP data from %s for forwarding to %s\n",
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
inet_ntop (af,
&state->specifics.tcp_udp.ri.remote_address.address,
buf, sizeof (buf)));
@@ -2498,18 +2483,15 @@ make_up_icmp_service_payload (struct TunnelState *state,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_IcmpServiceMessage *msg;
@@ -2544,7 +2526,7 @@ receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel
pkt_len -= sizeof (struct GNUNET_EXIT_IcmpServiceMessage);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received data from %s for forwarding to ICMP service %s\n",
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
GNUNET_h2s (&msg->service_descriptor));
if (NULL == state->specifics.tcp_udp.serv)
{
@@ -2789,18 +2771,15 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx GNUNET_UNUSED,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_UdpInternetMessage *msg;
@@ -2877,7 +2856,7 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
char buf[INET6_ADDRSTRLEN];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received data from %s for forwarding to UDP %s:%u\n",
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
inet_ntop (af,
&state->specifics.tcp_udp.ri.remote_address.address,
buf, sizeof (buf)),
@@ -2903,18 +2882,15 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
* @param cls closure, NULL
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
- * @param sender who sent the message
* @param message the actual message
- * @param atsi performance data for the connection
+ *
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
const struct GNUNET_EXIT_UdpServiceMessage *msg;
@@ -2946,7 +2922,7 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
pkt_len -= sizeof (struct GNUNET_EXIT_UdpServiceMessage);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received data from %s for forwarding to UDP service %s on port %u\n",
- GNUNET_i2s (sender),
+ GNUNET_i2s (&state->peer),
GNUNET_h2s (&msg->service_descriptor),
(unsigned int) ntohs (msg->destination_port));
if (NULL == (state->specifics.tcp_udp.serv = find_service (udp_services, &msg->service_descriptor,
@@ -2978,17 +2954,17 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
* @param cls closure
* @param tunnel new handle to the tunnel
* @param initiator peer that started the tunnel
- * @param atsi performance information for the tunnel
+ * @param port destination port
* @return initial tunnel context for the tunnel
*/
static void *
new_tunnel (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- const struct GNUNET_PeerIdentity *initiator GNUNET_UNUSED,
- const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
+ const struct GNUNET_PeerIdentity *initiator, uint32_t port)
{
struct TunnelState *s = GNUNET_malloc (sizeof (struct TunnelState));
s->is_dns = GNUNET_SYSERR;
+ s->peer = *initiator;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Inbound MESH tunnels created"),
1, GNUNET_NO);
@@ -3338,7 +3314,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
{NULL, 0, 0}
};
- static GNUNET_MESH_ApplicationType apptypes[] = {
+ static uint32_t apptypes[] = {
GNUNET_APPLICATION_TYPE_END,
GNUNET_APPLICATION_TYPE_END,
GNUNET_APPLICATION_TYPE_END,
@@ -3413,7 +3389,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("No useful service enabled. Exiting.\n"));
GNUNET_SCHEDULER_shutdown ();
- return;
+ return;
}
dns_exit = NULL;
@@ -3436,18 +3412,21 @@ run (void *cls, char *const *args GNUNET_UNUSED,
app_idx = 0;
- if (GNUNET_YES == ipv4_exit)
+ if (GNUNET_YES == ipv4_exit)
{
+ // FIXME use regex to put info
apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
app_idx++;
}
- if (GNUNET_YES == ipv6_exit)
+ if (GNUNET_YES == ipv6_exit)
{
+ // FIXME use regex to put info
apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
app_idx++;
}
if (NULL != dns_exit)
{
+ // FIXME use regex to put info
apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER;
app_idx++;
}
@@ -3568,7 +3547,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
= GNUNET_MESH_connect (cfg, NULL,
&new_tunnel,
&clean_tunnel, handlers,
- apptypes);
+ apptypes); // FIXME use ports
if (NULL == mesh_handle)
{
GNUNET_SCHEDULER_shutdown ();
diff --git a/src/fs/gnunet-service-fs_mesh.c b/src/fs/gnunet-service-fs_mesh.c
index 10b29fa844..9eda536a9f 100644
--- a/src/fs/gnunet-service-fs_mesh.c
+++ b/src/fs/gnunet-service-fs_mesh.c
@@ -41,7 +41,7 @@
#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_util_lib.h"
-#include "gnunet_mesh2_service.h"
+#include "gnunet_mesh_service.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
#include "gnunet-service-fs.h"
diff --git a/src/include/block_mesh.h b/src/include/block_mesh.h
index 9dfb859454..508f52699b 100644
--- a/src/include/block_mesh.h
+++ b/src/include/block_mesh.h
@@ -48,10 +48,6 @@ struct PBlock
*/
struct GNUNET_PeerIdentity id;
- /**
- * Type of service offered
- */
- GNUNET_MESH_ApplicationType type;
};
#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_mesh2_service.h b/src/include/gnunet_mesh2_service.h
deleted file mode 100644
index 019dc8431f..0000000000
--- a/src/include/gnunet_mesh2_service.h
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2009, 2010, 2011, 2012, 2013 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file include/gnunet_mesh2_service.h
- * @brief mesh service; establish tunnels to distant peers
- * @author Christian Grothoff
- *
- * TODO:
- * - need to do sanity check that this is consistent
- * with current ideas for the multicast layer's needs
- */
-
-#ifndef GNUNET_MESH_SERVICE_H
-#define GNUNET_MESH_SERVICE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-#include "gnunet_util_lib.h"
-#include "gnunet_transport_service.h"
-
-/**
- * Version number of GNUnet-mesh API.
- */
-#define GNUNET_MESH_VERSION 0x00000001
-
-
-/**
- * Opaque handle to the service.
- */
-struct GNUNET_MESH_Handle;
-
-/**
- * Opaque handle to a tunnel.
- */
-struct GNUNET_MESH_Tunnel;
-
-
-/**
- * Functions with this signature are called whenever a message is
- * received.
- *
- * Each time the function must call GNUNET_MESH_receive_done on the tunnel
- * in order to receive the next message. This doesn't need to be immediate:
- * can be delayed if some processing is done on the message.
- *
- * @param cls Closure (set from GNUNET_MESH_connect).
- * @param tunnel Connection to the other end.
- * @param tunnel_ctx Place to store local state associated with the tunnel.
- * @param message The actual message.
- *
- * @return GNUNET_OK to keep the tunnel open,
- * GNUNET_SYSERR to close it (signal serious error).
- */
-typedef int (*GNUNET_MESH_MessageCallback) (void *cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
- const struct GNUNET_MessageHeader *message);
-
-
-/**
- * Message handler. Each struct specifies how to handle on particular
- * type of message received.
- */
-struct GNUNET_MESH_MessageHandler
-{
- /**
- * Function to call for messages of "type".
- */
- GNUNET_MESH_MessageCallback callback;
-
- /**
- * Type of the message this handler covers.
- */
- uint16_t type;
-
- /**
- * Expected size of messages of this type. Use 0 for variable-size.
- * If non-zero, messages of the given type will be discarded if they
- * do not have the right size.
- */
- uint16_t expected_size;
-};
-
-
-/**
- * Method called whenever another peer has added us to a tunnel
- * the other peer initiated.
- * Only called (once) upon reception of data with a message type which was
- * subscribed to in GNUNET_MESH_connect. A call to GNUNET_MESH_tunnel_destroy
- * causes te tunnel to be ignored and no further notifications are sent about
- * the same tunnel.
- *
- * @param cls closure
- * @param tunnel new handle to the tunnel
- * @param initiator peer that started the tunnel
- * @param port Port this tunnel is for.
- * @return initial tunnel context for the tunnel
- * (can be NULL -- that's not an error)
- */
-typedef void *(GNUNET_MESH_InboundTunnelNotificationHandler) (void *cls,
- struct
- GNUNET_MESH_Tunnel
- * tunnel,
- const struct
- GNUNET_PeerIdentity
- * initiator,
- uint32_t port);
-
-
-/**
- * Function called whenever a tunnel is destroyed. Should clean up
- * any associated state.
- *
- * It must NOT call GNUNET_MESH_tunnel_destroy on the tunnel.
- *
- * @param cls closure (set from GNUNET_MESH_connect)
- * @param tunnel connection to the other end (henceforth invalid)
- * @param tunnel_ctx place where local state associated
- * with the tunnel is stored
- */
-typedef void (GNUNET_MESH_TunnelEndHandler) (void *cls,
- const struct GNUNET_MESH_Tunnel *
- tunnel, void *tunnel_ctx);
-
-
-/**
- * Connect to the mesh service.
- *
- * @param cfg Configuration to use.
- * @param cls Closure for the various callbacks that follow (including
- * handlers in the handlers array).
- * @param new_tunnel Function called when an *inbound* tunnel is created.
- * Can be NULL if no inbound tunnels are desired.
- * @param cleaner Function called when a tunnel is destroyed by the remote peer.
- * It is NOT called if GNUNET_MESH_tunnel_destroy is called on
- * the tunnel.
- * @param handlers Callbacks for messages we care about, NULL-terminated. Each
- * one must call GNUNET_MESH_receive_done on the tunnel to
- * receive the next message. Messages of a type that is not
- * in the handlers array are ignored if received.
- * @param ports NULL or 0-terminated array of port numbers for incoming tunnels.
- *
- * @return handle to the mesh service NULL on error
- * (in this case, init is never called)
- */
-struct GNUNET_MESH_Handle *
-GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
- GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel,
- GNUNET_MESH_TunnelEndHandler cleaner,
- const struct GNUNET_MESH_MessageHandler *handlers,
- const uint32_t *ports);
-
-
-/**
- * Disconnect from the mesh service. All tunnels will be destroyed. All tunnel
- * disconnect callbacks will be called on any still connected peers, notifying
- * about their disconnection. The registered inbound tunnel cleaner will be
- * called should any inbound tunnels still exist.
- *
- * @param handle connection to mesh to disconnect
- */
-void
-GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle);
-
-
-/**
- * Create a new tunnel (we're initiator and will be allowed to add/remove peers
- * and to broadcast).
- *
- * @param h mesh handle
- * @param tunnel_ctx client's tunnel context to associate with the tunnel
- * @param peer peer identity the tunnel should go to
- * @param port Port number.
- * @return handle to the tunnel
- */
-struct GNUNET_MESH_Tunnel *
-GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
- void *tunnel_ctx,
- const struct GNUNET_PeerIdentity *peer,
- uint32_t port);
-
-
-/**
- * Destroy an existing tunnel.
- *
- * The existing end callback for the tunnel will be called immediately.
- * Any pending outgoing messages will be sent but no incoming messages will be
- * accepted and no data callbacks will be called.
- *
- * @param tunnel Tunnel handle, becomes invalid after this call.
- */
-void
-GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel);
-
-
-/**
- * Turn on/off the buffering status of the tunnel.
- *
- * @param tunnel Tunnel affected.
- * @param buffer GNUNET_YES to turn buffering on (default),
- * GNUNET_NO otherwise.
- */
-void
-GNUNET_MESH_tunnel_buffer (struct GNUNET_MESH_Tunnel *tunnel, int buffer);
-
-
-/**
- * Handle for a transmission request.
- */
-struct GNUNET_MESH_TransmitHandle;
-
-
-/**
- * Ask the mesh to call "notify" once it is ready to transmit the
- * given number of bytes to the specified tunnel.
- * Only one call can be active at any time, to issue another request,
- * wait for the callback or cancel the current request.
- *
- * @param tunnel tunnel to use for transmission
- * @param cork is corking allowed for this transmission?
- * @param maxdelay how long can the message wait?
- * @param notify_size how many bytes of buffer space does notify want?
- * @param notify function to call when buffer space is available;
- * will be called with NULL on timeout or if the overall queue
- * for this peer is larger than queue_size and this is currently
- * the message with the lowest priority
- * @param notify_cls closure for notify
- * @return non-NULL if the notify callback was queued,
- * NULL if we can not even queue the request (insufficient
- * memory); if NULL is returned, "notify" will NOT be called.
- */
-struct GNUNET_MESH_TransmitHandle *
-GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork,
- struct GNUNET_TIME_Relative maxdelay,
- size_t notify_size,
- GNUNET_CONNECTION_TransmitReadyNotify notify,
- void *notify_cls);
-
-