From: Bart Polot Date: Thu, 4 Aug 2011 23:57:55 +0000 (+0000) Subject: Changed API<->Service messages X-Git-Tag: initial-import-from-subversion-38251~17462 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=857cb6a5341bc27cf1997fc48c2df173c4380fd2;p=oweals%2Fgnunet.git Changed API<->Service messages --- diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index e5e680d58..ce1ae2190 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -796,49 +796,49 @@ extern "C" /******************************************************************************* - * MESH message types (WiP) + * MESH message types START (WiP) ******************************************************************************/ /** * Request the creation of a path */ -#define GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE 256 +#define GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE 256 /** * Request the modification of an existing path */ -#define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGE 257 +#define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGE 257 /** * Request the addition to a new branch to a path */ -#define GNUNET_MESSAGE_TYPE_MESH_PATH_ADD 258 +#define GNUNET_MESSAGE_TYPE_MESH_PATH_ADD 258 /** * At some point, the route will spontaneously change */ -#define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED 259 +#define GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED 259 /** * Transport data in the mesh (origin->end) unicast */ -#define GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN 260 +#define GNUNET_MESSAGE_TYPE_MESH_UNICAST 260 /** * Transport data to all peers in a tunnel */ -#define GNUNET_MESSAGE_TYPE_DATA_MULTICAST 261 +#define GNUNET_MESSAGE_TYPE_MESH_MULTICAST 261 /** * Transport data back in the mesh (end->origin) * (not sure if this is the right way, should be some other solution) */ -#define GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN 262 +#define GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN 262 /** * Send origin an ACK that the path is complete */ -#define GNUNET_MESSAGE_TYPE_PATH_ACK 263 +#define GNUNET_MESSAGE_TYPE_MESH_PATH_ACK 263 /** * We need flow control @@ -848,27 +848,27 @@ extern "C" /** * Connect to the mesh service, specifying subscriptions */ -#define GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 272 +#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 +#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 +#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 +#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 +#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 @@ -890,19 +890,6 @@ extern "C" */ #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 /** * 640kb should be enough for everybody diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index f5cbf8d39..e9fbb20f0 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -833,7 +833,7 @@ send_core_data_to_origin (void *cls, size_t size, void *buf) * @return number of bytes written to buf */ static size_t -send_core_data_to_peer (void *cls, size_t size, void *buf) +send_core_data_unicast (void *cls, size_t size, void *buf) { struct MeshDataDescriptor *info = cls; struct GNUNET_MESH_DataMessageFromOrigin *msg = buf; @@ -849,7 +849,7 @@ send_core_data_to_peer (void *cls, size_t size, void *buf) return 0; } msg->header.size = htons(total_size); - msg->header.type = htons(GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN); + msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_UNICAST); GNUNET_PEER_resolve(info->origin->oid, &msg->oid); GNUNET_PEER_resolve(info->destination, &msg->destination); msg->tid = htonl(info->origin->tid); @@ -894,7 +894,7 @@ send_core_data_multicast (void *cls, size_t size, void *buf) "not enough buffer to send data futher\n"); return 0; } - msg->header.type = htons(GNUNET_MESSAGE_TYPE_DATA_MULTICAST); + msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_MULTICAST); msg->header.size = htons(total_size); GNUNET_PEER_resolve(info->origin->oid, &msg->oid); msg->tid = htonl(info->origin->tid); @@ -934,7 +934,7 @@ send_core_path_ack (void *cls, size_t size, void *buf) { return 0; } msg->header.size = htons(sizeof(struct GNUNET_MESH_PathACK)); - msg->header.type = htons(GNUNET_MESSAGE_TYPE_PATH_ACK); + msg->header.type = htons(GNUNET_MESSAGE_TYPE_MESH_PATH_ACK); GNUNET_PEER_resolve(info->origin->oid, &msg->oid); msg->tid = htonl(info->origin->tid); GNUNET_PEER_resolve(myid, &msg->peer_id); @@ -1526,10 +1526,10 @@ handle_mesh_path_ack (void *cls, */ static struct GNUNET_CORE_MessageHandler core_handlers[] = { {&handle_mesh_path_create, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0}, - {&handle_mesh_data_unicast, GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN, 0}, - {&handle_mesh_data_multicast, GNUNET_MESSAGE_TYPE_DATA_MULTICAST, 0}, - {&handle_mesh_data_to_orig, GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN, 0}, - {&handle_mesh_path_ack, GNUNET_MESSAGE_TYPE_PATH_ACK, + {&handle_mesh_data_unicast, GNUNET_MESSAGE_TYPE_MESH_UNICAST, 0}, + {&handle_mesh_data_multicast, GNUNET_MESSAGE_TYPE_MESH_MULTICAST, 0}, + {&handle_mesh_data_to_orig, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN, 0}, + {&handle_mesh_path_ack, GNUNET_MESSAGE_TYPE_MESH_PATH_ACK, sizeof(struct GNUNET_MESH_PathACK)}, {NULL, 0, 0} }; @@ -2217,7 +2217,7 @@ handle_local_network_traffic (void *cls, /* FIXME re-check types */ message->size - sizeof(struct GNUNET_MESH_Data) + sizeof(struct GNUNET_MESH_DataMessageFromOrigin), - &send_core_data_to_peer, + &send_core_data_unicast, info); return; } @@ -2298,9 +2298,11 @@ static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct GNUNET_MESH_ConnectPeerByType)}, {&handle_local_network_traffic, NULL, - GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, + GNUNET_MESSAGE_TYPE_MESH_UNICAST, 0}, + {&handle_local_network_traffic, NULL, + GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN, 0}, {&handle_local_network_traffic_bcast, NULL, - GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST, 0}, + GNUNET_MESSAGE_TYPE_MESH_MULTICAST, 0}, {NULL, NULL, 0, 0} }; diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index ae100c6a9..60b1ade85 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c @@ -118,7 +118,12 @@ struct GNUNET_MESH_Tunnel { /** * Local ID of the tunnel */ - MESH_TunnelNumber tid; + MESH_TunnelNumber tid; + + /** + * Owner of the tunnel + */ + GNUNET_PEER_Id owner; /** * Callback to execute when peers connect to the tunnel @@ -309,7 +314,7 @@ send_tunnel_create_packet (void *cls, size_t size, void *buf) * Process the new tunnel notification and add it to the tunnels in the handle * * @param h The mesh handle - * @param msh A message with the details of the new incoming tunnel + * @param msg A message with the details of the new incoming tunnel */ static void process_tunnel_create(struct GNUNET_MESH_Handle *h, @@ -320,9 +325,10 @@ process_tunnel_create(struct GNUNET_MESH_Handle *h, tid = ntohl(msg->tunnel_id); if (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: received an incoming tunnel with tid in local range (%X)\n", tid); + GNUNET_break_op(0); return; //FIXME abort? reconnect? } t = GNUNET_malloc(sizeof(struct GNUNET_MESH_Tunnel)); @@ -343,7 +349,7 @@ process_tunnel_create(struct GNUNET_MESH_Handle *h, * @param msh A message encapsulating the data */ static void -process_incoming_data(struct GNUNET_MESH_Handle *h, +process_incoming_data(struct GNUNET_MESH_Handle *h, const struct GNUNET_MESH_Data *msg) { const struct GNUNET_MESH_Data *payload; @@ -409,7 +415,9 @@ msg_received (void *cls, const struct GNUNET_MessageHeader * msg) case GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DISCONNECTED: break; /* Notify of a new data packet in the tunnel */ - case GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA: + case GNUNET_MESSAGE_TYPE_MESH_UNICAST: + case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: + case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: process_incoming_data(h, (struct GNUNET_MESH_Data *)msg); break; /* We shouldn't get any other packages, log and ignore */