#define GNUNET_MESSAGE_TYPE_MESH_HELLO 216
-/**
+/*******************************************************************************
* MESH message types (WiP)
- */
+ ******************************************************************************/
/**
* Request the creation of a path
*/
#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
/**
*/
#define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 288
-/**
+/*******************************************************************************
* MESH message types END
- */
+ ******************************************************************************/
}
+/**
+ * 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
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
);
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
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;
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 */