From: Bart Polot Date: Thu, 19 May 2011 13:34:47 +0000 (+0000) Subject: WiP X-Git-Tag: initial-import-from-subversion-38251~18443 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b302b2971e868fdfb93bf885366483b511581b5f;p=oweals%2Fgnunet.git WiP --- diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index e6099dfd8..35eb7d0b4 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -791,9 +791,9 @@ extern "C" #define GNUNET_MESSAGE_TYPE_MESH_HELLO 216 -/** +/******************************************************************************* * MESH message types (WiP) - */ + ******************************************************************************/ /** * Request the creation of a path @@ -831,21 +831,63 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_MESH_SPEED_NOTIFY 262 -/* FIXME: Document */ +/** + * Connect to the mesh service, specifying subscriptions + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 272 + +/** + * Ask the mesh service to create a new tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE 273 + +/** + * Ask the mesh service to destroy a tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY 274 +/** + * Ask the mesh service to add a peer to an existing tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD 275 + +/** + * Ask the mesh service to remove a peer from a tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL 276 + +/** + * Ask the mesh service to add a peer offering a service to an existing tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE 277 + +/** + * Ask the mesh service to cancel a peer connection request + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL 278 + +/** + * Notify a mesh client that a peer has connected to a tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_CONNECTED 279 + +/** + * Notify a mesh client that a peer has disconnected from a tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DISCONNECTED 280 +/* FIXME needed? */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_REQUEST_TRANSMIT_READY 281 #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_NOTIFY_TRANSMIT_READY 282 + +/** + * Message client <-> mesh service to transport payload + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 283 + +/** + * Message client->mesh to send data to all peers connected to a tunnel + */ #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST 284 /** @@ -853,9 +895,9 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 288 -/** +/******************************************************************************* * MESH message types END - */ + ******************************************************************************/ diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 4865ed7e8..ca2d652e7 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -489,6 +489,31 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) } +/** + * Send another peer a notification to destroy a tunnel + * @param cls The tunnel to destroy + * @param size Size in the buffer + * @param buf Memory where to put the data to transmit + * @return Size of data put in buffer + */ +static size_t +send_p2p_tunnel_destroy(void *cls, size_t size, void *buf) +{ + struct MeshTunnel *t = cls; + struct MeshClient *c; + struct GNUNET_MESH_TunnelMessage *msg; + + c = t->client; + msg = buf; + msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); /*FIXME*/ + msg->header.size = htons(sizeof(struct GNUNET_MESH_TunnelMessage)); + msg->tunnel_id = htonl(t->tid); + + destroy_tunnel(c, t); + return sizeof(struct GNUNET_MESH_TunnelMessage); +} + + /** * Core handler for path creation * struct GNUNET_CORE_MessageHandler @@ -636,7 +661,7 @@ dht_get_response_handler(void *cls, GNUNET_SERVER_notify_transmit_ready( t->client->handle, sizeof(struct GNUNET_MESH_PeerControl), - GNUNET_TIME_relative_get_forever(), + GNUNET_TIME_UNIT_FOREVER_REL, ¬ify_client_connection_failure, peer_info ); @@ -664,7 +689,7 @@ dht_get_response_handler(void *cls, GNUNET_CORE_notify_transmit_ready(core_handle, 0, 0, - GNUNET_TIME_relative_get_forever(), + GNUNET_TIME_UNIT_FOREVER_REL, get_path[1], sizeof(struct GNUNET_MESH_ManipulatePath) + (p->length @@ -885,7 +910,14 @@ handle_local_tunnel_destroy (void *cls, GNUNET_CRYPTO_hash(&tid, sizeof(MESH_TunnelID), &hash); t = GNUNET_CONTAINER_multihashmap_get(c->tunnel_ids, &hash); GNUNET_CONTAINER_multihashmap_remove_all(c->tunnel_ids, &hash); - destroy_tunnel(c, t); + GNUNET_CORE_notify_transmit_ready(core_handle, + 1, + 1, + GNUNET_TIME_UNIT_FOREVER_REL, + NULL, + sizeof(struct GNUNET_MESH_TunnelMessage), + &send_p2p_tunnel_destroy, + t); GNUNET_SERVER_receive_done(client, GNUNET_OK); return; @@ -961,7 +993,7 @@ handle_local_connect_add (void *cls, sizeof(struct GNUNET_PeerIdentity), &key); peer_info->dhtget = GNUNET_DHT_get_start(dht_handle, - GNUNET_TIME_relative_get_forever(), + GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_BLOCK_TYPE_ANY, &key, 4, /* replication level */