[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14914 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14914 - gnunet/src/mesh |
Date: |
Thu, 7 Apr 2011 13:36:07 +0200 |
Author: bartpolot
Date: 2011-04-07 13:36:07 +0200 (Thu, 07 Apr 2011)
New Revision: 14914
Added:
gnunet/src/mesh/mesh_api_new.c
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
Work in progress
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2011-04-07 11:30:55 UTC (rev
14913)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2011-04-07 11:36:07 UTC (rev
14914)
@@ -23,6 +23,14 @@
* @brief GNUnet MESH service
* @author Bartlomiej Polot
*
+ * STRUCTURE:
+ * - MESH NETWORK MESSAGES
+ * - DATA STRUCTURES
+ * - GLOBAL VARIABLES
+ * - MESH NETWORK HANDLES
+ * - MESH LOCAL HANDLES
+ * - MAIN FUNCTIONS (main & run)
+ *
* TODO:
* - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a
message issue
* - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
@@ -52,12 +60,14 @@
/**
* Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
*
- * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof
(struct GNUNET_PeerIdentity)
+ * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
+ * path_length * sizeof (struct GNUNET_PeerIdentity)
*/
struct GNUNET_MessageHeader header;
/**
- * (global) Id of the tunnel this path belongs to, unique in conjunction
with the origin.
+ * Global id of the tunnel this path belongs to,
+ * unique in conjunction with the origin.
*/
uint32_t tid GNUNET_PACKED;
@@ -76,7 +86,7 @@
* path_length structs defining the *whole* path from the origin [0] to the
* final destination [path_length-1].
*/
- // struct GNUNET_PeerIdentity peers[path_length];
+ /* struct GNUNET_PeerIdentity peers[path_length]; */
};
/**
@@ -215,12 +225,8 @@
/**
* Peer connected previosly but not responding
*/
- MESH_PEER_UNAVAILABLE,
+ MESH_PEER_RECONNECTING,
- /**
- * Peer requested but not ever connected
- */
- MESH_PEER_UNREACHABLE
};
/**
@@ -231,7 +237,7 @@
/**
* ID of the peer
*/
- GNUNET_PEER_Id id;
+ GNUNET_PEER_Id id;
/**
* Is the peer reachable? Is the peer even connected?
@@ -241,14 +247,15 @@
/**
* Who to send the data to --- what about multiple (alternate) paths?
*/
- GNUNET_PEER_Id first_hop;
+ GNUNET_PEER_Id first_hop;
/**
* Max data rate to this peer
*/
- uint32_t max_speed;
+ uint32_t max_speed;
};
+typedef uint32_t MESH_PathID;
/**
* Information regarding a path
*/
@@ -257,19 +264,20 @@
/**
* Id of the path, in case it's needed
*/
- uint32_t id;
+ MESH_PathID id;
/**
* Whether the path is serving traffic in a tunnel or is a backup
*/
- int in_use;
+ int in_use;
/**
* List of all the peers that form the path from origin to target
*/
- GNUNET_PEER_Id *peers;
+ GNUNET_PEER_Id *peers;
};
+typedef uint32_t MESH_TunnelID;
/**
* Struct containing all information regarding a tunnel
* For an intermediate node the improtant info used will be:
@@ -282,34 +290,36 @@
struct MESH_tunnel
{
- struct MESH_tunnel *next;
+ /**
+ * Double linked list
+ */
+ struct MESH_tunnel *next;
+ struct MESH_tunnel *prev;
- struct MESH_tunnel *prev;
-
/**
* Origin ID: Node that created the tunnel
*/
- GNUNET_PEER_Id oid;
+ GNUNET_PEER_Id oid;
/**
* Tunnel number (unique for a given oid)
*/
- uint32_t tid;
+ MESH_TunnelID tid;
/**
- * Whether the tunnel is in a state to transmit data
+ * Whether the tunnel is in a state to transmit data
*/
- int ready;
+ int ready;
/**
* Minimal speed for this tunnel in kb/s
*/
- uint32_t speed_min;
+ uint32_t speed_min;
/**
* Maximal speed for this tunnel in kb/s
*/
- uint32_t speed_max;
+ uint32_t speed_max;
/**
* Last time the tunnel was used
@@ -319,20 +329,20 @@
/**
* Peers in the tunnel, for future optimizations
*/
- struct PeerInfo *peers;
+ struct PeerInfo *peers;
/**
* Paths (used and backup)
*/
- struct Path *paths;
+ struct Path *paths;
/**
- * Messages ready to transmit??? -- real queues needed
+ * Messages ready to transmit??? -- FIXME real queues needed
*/
struct GNUNET_MessageHeader *msg_out;
/**
- * Messages received and not processed??? -- real queues needed
+ * Messages received and not processed??? -- FIXME real queues needed
*/
struct GNUNET_MessageHeader *msg_in;
@@ -348,34 +358,48 @@
*/
struct Client
{
+ /**
+ * Double linked list
+ */
+ struct Client *next;
+ struct Client *prev;
- struct Client *next;
+ /**
+ * Tunnels that belong to this client
+ */
+ struct MESH_tunnel *my_tunnels_head;
+ struct MESH_tunnel *my_tunnels_tail;
- struct Client *prev;
-
- struct MESH_tunnel *my_tunnels_head;
-
- struct MESH_tunnel *my_tunnels_tail;
-
/**
* If this tunnel was created by a local client, what's its handle?
*/
struct GNUNET_SERVER_Client *handle;
- unsigned int messages_subscribed_counter;
+ /**
+ * Messages that this client has declared interest in
+ */
+ uint16_t *messages_subscribed;
+ unsigned int messages_subscribed_counter;
- uint16_t *messages_subscribed;
-
};
+/******************************************************************************/
+/*********************** GLOBAL VARIABLES
****************************/
+/******************************************************************************/
-// static struct MESH_tunnel *tunnel_participation_head;
+/**
+ * All the clients
+ */
+// static struct Client clients_head;
+// static struct Client clients_tail;
-// static struct MESH_tunnel *tunnel_participation_tail;
+/**
+ * All the tunnels
+ */
+// static struct MESH_tunnel *tunnel_participation_head;
+// static struct MESH_tunnel *tunnel_participation_tail;
-
-
/******************************************************************************/
/******************** MESH NETWORK HANDLERS
**************************/
/******************************************************************************/
@@ -549,8 +573,6 @@
*/
static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
{&handle_local_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0},
- {&handle_local_connect, NULL,
GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ANY, 0},
- {&handle_local_connect, NULL,
GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ALL, 0},
{&handle_local_connect, NULL,
GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD, 0},
{&handle_local_connect, NULL,
GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_DEL, 0},
{&handle_local_connect, NULL,
GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE, sizeof(struct
GNUNET_MESH_ConnectPeerByType)},
@@ -608,6 +630,10 @@
return;
}
+/******************************************************************************/
+/************************ MAIN FUNCTIONS
****************************/
+/******************************************************************************/
+
/**
* Process mesh requests. FIXME NON FUNCTIONAL, SKELETON
*
@@ -624,17 +650,17 @@
GNUNET_SERVER_add_handlers (server, plugin_handlers);
GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
- core = GNUNET_CORE_connect (c, /* Main configuration */
- 32, /* queue size */
- NULL, /* Closure passed to MESH functions */
- &core_init, /* Call core_init once connected */
- &core_connect, /* Handle connects */
- &core_disconnect, /* 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 */
- NULL, /* Don't want notified about all outbound
messages */
- GNUNET_NO, /* For header only outbound
notification */
+ core = GNUNET_CORE_connect (c, /* Main configuration
*/
+ 32, /* queue size
*/
+ NULL, /* Closure passed to MESH functions
*/
+ &core_init, /* Call core_init once connected
*/
+ &core_connect, /* Handle connects
*/
+ &core_disconnect, /* remove peers on disconnects
*/
+ NULL, /* Do we care about "status" updates?
*/
+ NULL, /* Don't notify about all incoming messages
*/
+ GNUNET_NO, /* For header only in notification
*/
+ NULL, /* Don't notify about all outbound messages
*/
+ GNUNET_NO, /* For header-only out notification
*/
core_handlers); /* Register these handlers
*/
if (core == NULL)
Added: gnunet/src/mesh/mesh_api_new.c
===================================================================
--- gnunet/src/mesh/mesh_api_new.c (rev 0)
+++ gnunet/src/mesh/mesh_api_new.c 2011-04-07 11:36:07 UTC (rev 14914)
@@ -0,0 +1,125 @@
+/*
+ This file is part of GNUnet.
+ (C) 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file mesh/mesh_api_new.c
+ * @brief mesh api: client implementation of mesh service
+ * @author Bartlomiej Polot
+ */
+
+#ifdef __cplusplus
+
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+#include <stdint.h>
+#include "gnunet_mesh_service.h"
+
+/**
+ * Opaque handle to the service.
+ */
+struct GNUNET_MESH_Handle {
+ struct GNUNET_MESH_Tunnel *head;
+ struct GNUNET_MESH_Tunnel *tail;
+ GNUNET_MESH_TunnelEndHandler cleaner;
+};
+
+/**
+ * Opaque handle to a tunnel.
+ */
+struct GNUNET_MESH_Tunnel {
+ GNUNET_PEER_Id owner;
+ GNUNET_PEER_Id destination;
+ GNUNET_MESH_TunnelConnectHandler connect_handler;
+ GNUNET_MESH_TunnelDisconnectHandler disconnect_handler;
+ GNUNET_PEER_Id *peers;
+};
+
+
+/**
+ * Connect to the mesh service.
+ *
+ * @param cfg configuration to use
+ * @param cls closure for the various callbacks that follow (including
handlers in the handlers array)
+ * @param cleaner function called when an *inbound* tunnel is destroyed
+ * @param handlers callbacks for messages we care about, NULL-terminated
+ * note that the mesh is allowed to drop notifications about
inbound
+ * messages if the client does not process them fast enough
(for this
+ * notification type, a bounded queue is used)
+ * @return handle to the mesh service
+ * NULL on error (in this case, init is never called)
+ */
+struct GNUNET_MESH_Handle *
+GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ void *cls,
+ GNUNET_MESH_TunnelEndHandler cleaner,
+ const struct GNUNET_MESH_MessageHandler *handlers,
+ const GNUNET_MESH_ApplicationType *stypes) {
+ GNUNET_MESH_Handle *h;
+ h = GNUNET_malloc(sizeof(GNUNET_MESH_Handle));
+
+ h->cleaner = cleaner;
+ return h;
+}
+
+/**
+ * Disconnect from the mesh service.
+ *
+ * @param handle connection to mesh to disconnect
+ */
+void GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) {
+ return;
+}
+
+/**
+ * Create a new tunnel (we're initiator and will be allowed to add/remove
peers and
+ * to broadcast).
+ *
+ * @param h mesh handle
+ * @param connect_handler function to call when peers are actually connected
+ * @param disconnect_handler function to call when peers are disconnected
+ * @param handler_cls closure for connect/disconnect handlers
+ */
+struct GNUNET_MESH_Tunnel *
+GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
+ GNUNET_MESH_TunnelConnectHandler connect_handler,
+ GNUNET_MESH_TunnelDisconnectHandler
disconnect_handler,
+ void *handler_cls) {
+ GNUNET_MESH_Tunnel *tunnel;
+ tunnel = GNUNET_malloc(sizeof(GNUNET_MESH_Tunnel));
+
+ tunnel->connect_handler = connect_handler;
+ tunnel->disconnect_handler = disconnect_handler;
+ tunnel->peers = NULL;
+
+ return tunnel;
+}
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14914 - gnunet/src/mesh,
gnunet <=