From: Bart Polot Date: Fri, 11 Mar 2011 03:39:47 +0000 (+0000) Subject: Added more data structures and functions to build the skeleton of mesh X-Git-Tag: initial-import-from-subversion-38251~18997 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=69d9f80b83053162a38a292fc8a024acb6a463a9;p=oweals%2Fgnunet.git Added more data structures and functions to build the skeleton of mesh --- diff --git a/src/include/gnunet_mesh_service.h b/src/include/gnunet_mesh_service.h index 36dbafb86..1677c714c 100644 --- a/src/include/gnunet_mesh_service.h +++ b/src/include/gnunet_mesh_service.h @@ -213,7 +213,7 @@ GNUNET_MESH_peer_request_connect_any (struct GNUNET_MESH_Handle *h, * * @param h mesh handle * @param timeout how long to try to establish a connection - * @param num_peers length of the peers arrray + * @param num_peers length of the peers array * @param peers list of candidates to connect to * @param connect_handler function to call on successful connect (or timeout); * will be called for EACH of the peers in the list and diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index bdfd1a3ac..449b8984c 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -25,6 +25,10 @@ */ #include +#include "gnunet_common.h" +#include "gnunet_util_lib.h" +#include "gnunet_core_service.h" +#include /** * All the states a peer participating in a tunnel can be in. @@ -135,6 +139,11 @@ struct MESH_tunnel */ uint32_t speed_max; + /** + * Last time the tunnel was used + */ + struct GNUNET_TIME_Absolute timestamp; + /** * Peers in the tunnel, for future optimizations */ @@ -172,7 +181,76 @@ struct Clients int fixme; }; +/** + * Handler for requests of creating new path + * + * @param cls closure + * @param client the client this message is from + * @param message the message received + */ +static void +handle_mesh_path_create (void *cls, + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message) +{ + return; +} +/** + * Handler for client disconnection + * + * @param cls closure + * @param client identification of the client; NULL + * for the last call when the server is destroyed + */ +static void +handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) +{ + /* Remove client from list, delete all timers and queues associated */ + return; +} + +/** + * Core handler for mesh network traffic + * + * @param cls closure + * @param message message + * @param peer peer identity this notification is about + * @param atsi performance data + * + */ +static int +handle_mesh_network_traffic (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message, + const struct GNUNET_TRANSPORT_ATS_Information + *atsi) +{ + if(GNUNET_MESSAGE_TYPE_MESH_DATA_GO == ntohs(message->type)) { + /* Retransmit to next in path of tunnel identified by message */ + return 0; + } else { /* GNUNET_MESSAGE_TYPE_MESH_DATA_BACK */ + /* Retransmit to previous in path of tunnel identified by message */ + return 0; + } +} + +/** + * Functions to handle messages from core + */ +static struct GNUNET_CORE_MessageHandler core_handlers[] = { + {&handle_mesh_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_GO, 0}, + {&handle_mesh_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_BACK, 0}, + {NULL, 0, 0} +}; + +/** + * Functions to handle messages from clients + */ +static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { + {&handle_mesh_path_create, NULL, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0}, + {NULL, NULL, 0, 0} +}; /** * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!! @@ -189,17 +267,16 @@ run (void *cls, struct GNUNET_TIME_Relative next_send_time; unsigned long long temp_config_num; char *converge_modifier_buf; + GNUNET_CORE_Handle *coreAPI; - cfg = c; - datacache = GNUNET_DATACACHE_create (cfg, "dhtcache"); GNUNET_SERVER_add_handlers (server, plugin_handlers); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); - coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ - DEFAULT_CORE_QUEUE_SIZE, /* queue size */ + coreAPI = GNUNET_CORE_connect (c, /* Main configuration */ + 32, /* queue size */ NULL, /* Closure passed to DHT functions */ - &core_init, /* Call core_init once connected */ - &handle_core_connect, /* Handle connects */ - &handle_core_disconnect, /* remove peers on disconnects */ + NULL, /* Call core_init once connected */ + NULL, /* Handle connects */ + NULL, /* remove peers on disconnects */ NULL, /* Do we care about "status" updates? */ NULL, /* Don't want notified about all incoming messages */ GNUNET_NO, /* For header only inbound notification */ diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index 57778a352..085f3ef4d 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -27,6 +27,7 @@ #ifndef MESH_H_ #define MESH_H_ #include +#include "gnunet_common.h" /** * Message for mesh path management @@ -80,6 +81,11 @@ struct GNUNET_MESH_Data */ uint32_t tid; + /** + * FIXME Some form of authentication + */ + uint32_t token; + /** * Size of payload * FIXME uint16 enough? diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 3421e2c6f..f714d32bb 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -469,7 +469,7 @@ GNUNET_MESH_connect (const struct ret->connected_peers.tail = NULL; ret->cleaner = cleaner; ret->cls = cls; - + const struct GNUNET_MESH_MessageHandler *it; unsigned int len = 1; for (it = handlers; it->callback != NULL; it++)