summaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-22 21:59:27 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-22 21:59:27 +0000
commitf44c0036572d5557d2496748a4190a61e40e61ff (patch)
treebceb908e8542883ed246f96b4c619c0c49a06782 /src/mesh
parent9d87d51965287d83ee332b8c50baff95bd62649a (diff)
replacing 0-terminated atsi-array with array+length in core API (and the core-connect IPC)
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c38
-rw-r--r--src/mesh/mesh_api.c27
2 files changed, 39 insertions, 26 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 94196be84..19650dcb6 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -2265,6 +2265,7 @@ send_core_path_ack (void *cls, size_t size, void *buf)
* @param message message
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
*
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
@@ -2272,7 +2273,8 @@ send_core_path_ack (void *cls, size_t size, void *buf)
static int
handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
unsigned int own_pos;
uint16_t size;
@@ -2462,6 +2464,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param message message
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
*
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
@@ -2469,7 +2472,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
static int
handle_mesh_path_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_ManipulatePath *msg;
struct GNUNET_PeerIdentity *pi;
@@ -2546,6 +2550,7 @@ handle_mesh_path_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param message message
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
*
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
@@ -2553,7 +2558,8 @@ handle_mesh_path_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
static int
handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_TunnelDestroy *msg;
struct MeshTunnel *t;
@@ -2596,13 +2602,15 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param peer peer identity this notification is about
* @param message message
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_Unicast *msg;
struct MeshTunnel *t;
@@ -2654,6 +2662,7 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param message message
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*
@@ -2662,7 +2671,8 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
static int
handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_Multicast *msg;
struct MeshTunnel *t;
@@ -2707,6 +2717,7 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param message message
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
*
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
@@ -2714,7 +2725,8 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer,
static int
handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_ToOrigin *msg;
struct GNUNET_PeerIdentity id;
@@ -2794,6 +2806,7 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
* @param message message
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
*
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
@@ -2801,7 +2814,8 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
static int
handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_PathACK *msg;
struct GNUNET_PeerIdentity id;
@@ -3739,7 +3753,7 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client,
copy->tid = htonl (t->id.tid);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MESH: calling generic handler...\n");
- handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL);
+ handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL, 0);
}
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
@@ -3825,7 +3839,7 @@ handle_local_to_origin (void *cls, struct GNUNET_SERVER_Client *client,
copy->sender = my_full_id;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MESH: calling generic handler...\n");
- handle_mesh_data_to_orig (NULL, &my_full_id, &copy->header, NULL);
+ handle_mesh_data_to_orig (NULL, &my_full_id, &copy->header, NULL, 0);
}
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
@@ -3896,7 +3910,7 @@ handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client,
copy->tid = htonl(t->id.tid);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MESH: calling generic handler...\n");
- handle_mesh_data_multicast(client, &my_full_id, &copy->header, NULL);
+ handle_mesh_data_multicast(client, &my_full_id, &copy->header, NULL, 0);
}
/* receive done gets called when last copy is sent to a neighbor */
@@ -3961,10 +3975,12 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
* @param cls closure
* @param peer peer identity this notification is about
* @param atsi performance data for the connection
+ * @param atsi_count number of records in 'atsi'
*/
static void
core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct MeshPeerInfo *peer_info;
struct MeshPeerPath *path;
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 2067b7b6c..0f7592056 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -113,7 +113,6 @@ struct peer_list_element
/* list of application-types */
struct type_list_element *type_head, *type_tail;
- struct GNUNET_ATS_Information atsi;
struct peer_list_element *next, *prev;
/* The handle that sends the hellos to this peer */
@@ -154,7 +153,7 @@ send_end_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_MESH_Tunnel *tunnel = cls;
- tunnel->connect_handler (tunnel->handler_cls, NULL, NULL);
+ tunnel->connect_handler (tunnel->handler_cls, NULL, NULL, 0);
}
static void
@@ -165,7 +164,7 @@ send_self_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_MESH_Tunnel *tunnel = cls;
- tunnel->connect_handler (tunnel->handler_cls, &tunnel->handle->myself, NULL);
+ tunnel->connect_handler (tunnel->handler_cls, &tunnel->handle->myself, NULL, 0);
GNUNET_SCHEDULER_add_now (send_end_connect, tunnel);
}
@@ -177,7 +176,7 @@ call_connect_handler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_MESH_Tunnel *tunnel = cls;
- tunnel->connect_handler (tunnel->handler_cls, &tunnel->peer, NULL);
+ tunnel->connect_handler (tunnel->handler_cls, &tunnel->peer, NULL, 0);
GNUNET_SCHEDULER_add_now (send_end_connect, tunnel);
}
@@ -254,7 +253,8 @@ schedule_hello_message (void *cls,
*/
static void
core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_Handle *handle = cls;
@@ -269,11 +269,6 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
/* Send a hello to this peer */
element->sched = GNUNET_SCHEDULER_add_now (schedule_hello_message, element);
-
- if (NULL != atsi)
- memcpy (&element->atsi, atsi,
- sizeof (struct GNUNET_ATS_Information));
-
GNUNET_CONTAINER_DLL_insert_after (handle->connected_peers.head,
handle->connected_peers.tail,
handle->connected_peers.tail, element);
@@ -294,7 +289,7 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
handle->established_tunnels.tail,
handle->established_tunnels.tail,
tunnel);
- tunnel->tunnel.connect_handler (tunnel->tunnel.handler_cls, peer, atsi);
+ tunnel->tunnel.connect_handler (tunnel->tunnel.handler_cls, peer, atsi, atsi_count);
GNUNET_SCHEDULER_add_now (send_end_connect, tunnel);
tunnel = next;
}
@@ -383,7 +378,8 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int
receive_hello (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_Handle *handle = cls;
uint16_t *num = (uint16_t *) (message + 1);
@@ -450,7 +446,7 @@ receive_hello (void *cls, const struct GNUNET_PeerIdentity *other,
memcpy (&tunnel->tunnel.peer, other,
sizeof (struct GNUNET_PeerIdentity));
tunnel->tunnel.connect_handler (tunnel->tunnel.handler_cls,
- &tunnel->tunnel.peer, atsi);
+ &tunnel->tunnel.peer, atsi, atsi_count);
GNUNET_SCHEDULER_add_now (send_end_connect, tunnel);
break;
}
@@ -469,7 +465,8 @@ receive_hello (void *cls, const struct GNUNET_PeerIdentity *other,
static int
core_receive (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GNUNET_MESH_Handle *handle = cls;
struct tunnel_message *tmessage = (struct tunnel_message *) message;
@@ -539,7 +536,7 @@ core_receive (void *cls, const struct GNUNET_PeerIdentity *other,
GNUNET_i2s (other), ntohs (rmessage->type));
return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx,
- other, rmessage, atsi);
+ other, rmessage, atsi, atsi_count);
}
struct GNUNET_MESH_Tunnel *