Changed message declaration location, added api messages
authorBart Polot <bart@net.in.tum.de>
Tue, 29 Mar 2011 09:36:22 +0000 (09:36 +0000)
committerBart Polot <bart@net.in.tum.de>
Tue, 29 Mar 2011 09:36:22 +0000 (09:36 +0000)
src/mesh/gnunet-service-mesh.c
src/mesh/mesh.h

index e63b1ba4049620094396102f923b7f85608a0426..1598603a64bc8e0573ca486fb1a624f09d49f376 100644 (file)
  * @file mesh/gnunet-service-mesh.c
  * @brief GNUnet MESH service
  * @author Bartlomiej Polot
+ *
+ * TODO:
+ * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue
+ * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
+ * - partial disconnect reporting -- same as error reporting?
+ * - add vs create? change vs. keep-alive? same msg or different ones? -- thinking...
+ * - speed requirement specification (change?) in mesh API -- API call
  */
 
 #include <stdint.h>
 #include "gnunet_core_service.h"
 #include <netinet/in.h>
 
+
+/******************************************************************************/
+/********************      MESH NETWORK MESSAGES     **************************/
+/******************************************************************************/
+
+/**
+ * Message for mesh path management
+ */
+struct GNUNET_MESH_ManipulatePath
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
+     *
+     * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity)
+     */
+    struct GNUNET_MessageHeader header;
+
+    /**
+     * Id of the tunnel this path belongs to, unique in conjunction with the origin.
+     */
+    uint32_t tid GNUNET_PACKED;
+
+    /**
+     * Information about speed requirements.  If the tunnel cannot sustain the 
+     * minimum bandwidth, packets are to be dropped.
+     */
+    uint32_t speed_min GNUNET_PACKED;
+
+    /**
+     * path_length structs defining the *whole* path from the origin [0] to the
+     * final destination [path_length-1].
+     */
+  // struct GNUNET_PeerIdentity peers[path_length];
+};
+
+/**
+ * Message for mesh data traffic to all tunnel targets.
+ */
+struct GNUNET_MESH_OriginMulticast
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST
+     */
+    struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+    uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+    struct GNUNET_PeerIdentity oid;
+
+    /**
+     * FIXME: Some form of authentication
+     */
+    // uint32_t token;
+
+    /**
+     * Payload follows
+     */
+};
+
+
+/**
+ * Message for mesh data traffic to a particular destination from origin.
+ */
+struct GNUNET_MESH_DataMessageFromOrigin
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN
+     */
+    struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+    uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+    struct GNUNET_PeerIdentity oid;
+
+    /**
+     * Destination.
+     */
+    struct GNUNET_PeerIdentity destination;
+
+    /**
+     * FIXME: Some form of authentication
+     */
+    // uint32_t token;
+
+    /**
+     * Payload follows
+     */
+};
+
+
+/**
+ * Message for mesh data traffic from a tunnel participant to origin.
+ */
+struct GNUNET_MESH_DataMessageToOrigin
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN
+     */
+    struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+    uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+    struct GNUNET_PeerIdentity oid;
+
+    /**
+     * Sender of the message.
+     */
+    struct GNUNET_PeerIdentity sender;
+
+    /**
+     * FIXME: Some form of authentication
+     */
+    // uint32_t token;
+
+    /**
+     * Payload follows
+     */
+};
+
+/**
+ * Message for mesh flow control
+ */
+struct GNUNET_MESH_SpeedNotify
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY
+     */
+    struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+    uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+    struct GNUNET_PeerIdentity oid;
+
+    /**
+     * Slowest link down the path (above minimum speed requirement).
+     */
+    uint32_t speed_min;
+
+};
+
+/******************************************************************************/
+/************************      DATA STRUCTURES     ****************************/
+/******************************************************************************/
+
 /**
  * All the states a peer participating in a tunnel can be in.
  */
@@ -183,6 +358,7 @@ struct Clients
 
 /**
  * Handler for requests of creating new path
+ * type: struct GNUNET_CORE_MessageHandler
  *
  * @param cls closure
  * @param client the client this message is from
@@ -212,6 +388,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
 
 /**
  * Core handler for path creation
+ * struct GNUNET_CORE_MessageHandler
  *
  * @param cls closure
  * @param message message
@@ -227,6 +404,10 @@ handle_mesh_path_create (void *cls,
                               *atsi)
 {
     /* Extract path */
+    /* Find origin & self */
+    /* Search for origin in local tunnels */
+    /* Create tunnel / add path */
+    /* Retransmit to next link in chain, if any (core_notify + callback) */
     return GNUNET_OK;
 }
 
@@ -269,9 +450,9 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = {
  * Functions to handle messages from clients
  */
 static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
-  {&handle_local_path_create, NULL, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0},
-  {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_GO, 0},
-  {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_BACK, 0},
+  {&handle_local_path_create, NULL, GNUNET_MESSAGE_TYPE_LOCAL_PATH_CREATE, 0},
+  {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_LOCAL_DATA_GO, 0},
+  {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_LOCAL_DATA_BACK, 0},
   {NULL, NULL, 0, 0}
 };
 
index e51b0c890e50a4b250a7c6b91e39fe020e643029..dda3e2fccbf54c35dee2f288e402224b9192e659 100644 (file)
  * @file mesh/mesh.h
  *
  * TODO:
- * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue
- * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
- * - partial disconnect reporting -- same as error reporting?
- * - add vs create? change vs. keep-alive? same msg or different ones? -- thinking...
- * - speed requirement specification (change?) in mesh API -- API call
- *
  * - API messages!
  */
 
-
 #ifndef MESH_H_
 #define MESH_H_
 #include <stdint.h>
 #include "gnunet_common.h"
 
-/**
- * Message for mesh path management
+/******************************************************************************/
+/********************      MESH NETWORK MESSAGES     **************************/
+/******************************************************************************/
+/* API CALL                         MESSAGE USED
+ * --------                         ------------
+ * connect                          GNUNET_MESH_Connect    / Server_connect? FIXME
+ * disconnect                       GNUNET_MESH_Disconnect / Server_disconnect? FIXME
+ * 
+ * peer_request_connect_any         GNUNET_MESH_ConnectPeer
+ * peer_request_connect_all         GNUNET_MESH_ConnectPeer
+ * peer_request_connect_add         GNUNET_MESH_ConnectPeer
+ * peer_request_connect_del         GNUNET_MESH_ConnectPeer
+ * peer_request_connect_by_type     GNUNET_MESH_ConnectPeerByType
+ * peer_request_connect_cancel      GNUNET_MESH_Control
+ * 
+ * notify_tranmit_ready             GNUNET_MESH_Control? FIXME
+ * notify_tranmit_ready_cancel      GNUNET_MESH_Control? FIXME
  */
-struct GNUNET_MESH_ManipulatePath
-{
-    /**
-     * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
-     *
-     * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity)
-     */
-    struct GNUNET_MessageHeader header;
-
-    /**
-     * Id of the tunnel this path belongs to, unique in conjunction with the origin.
-     */
-    uint32_t tid GNUNET_PACKED;
 
-    /**
-     * Information about speed requirements.  If the tunnel cannot sustain the 
-     * minimum bandwidth, packets are to be dropped.
+// struct GNUNET_MESH_Connect {
+//     /**
+//      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
+//      *
+//      * Size: sizeof(struct GNUNET_MESH_Connect) + messages_subscribed * sizeof (message_type)
+//      */
+//     struct GNUNET_MessageHeader header;
+// 
+//     /* uint16_t messages_subscribed[] */
+// };
+//
+// struct GNUNET_MESH_Disconnect {
+//     /**
+//      * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DISCONNECT
+//      */
+//     struct GNUNET_MessageHeader header;
+//
+// };
+
+struct GNUNET_MESH_ConnectPeer {
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ANY|ALL|ADD|DEL]
+     * 
+     * Size: sizeof(struct GNUNET_MESH_ConnectPeer) + npeers * sizeof (struct GNUNET_PeerIdentity)
      */
-    uint32_t speed_min GNUNET_PACKED;
+    struct GNUNET_MessageHeader header;
 
-    /**
-     * 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[] */
 };
 
-/**
- * Message for mesh data traffic to all tunnel targets.
- */
-struct GNUNET_MESH_OriginMulticast
-{
+struct GNUNET_MESH_ConnectPeerByType {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST
+     * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
      */
     struct GNUNET_MessageHeader header;
 
-    /**
-     * TID of the tunnel
-     */
-    uint32_t tid GNUNET_PACKED;
-
-    /**
-     * OID of the tunnel
-     */
-    struct GNUNET_PeerIdentity oid;
-
-    /**
-     * FIXME: Some form of authentication
-     */
-    // uint32_t token;
-
-    /**
-     * Payload follows
-     */
+    /* FIXME Type specification */
+    uint32_t type;
 };
 
-
-/**
- * Message for mesh data traffic to a particular destination from origin.
- */
-struct GNUNET_MESH_DataMessageFromOrigin
-{
+struct GNUNET_MESH_Control {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN
+     * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL
+     *       more? transmit_ready?
      */
     struct GNUNET_MessageHeader header;
 
-    /**
-     * TID of the tunnel
-     */
-    uint32_t tid GNUNET_PACKED;
-
-    /**
-     * OID of the tunnel
-     */
-    struct GNUNET_PeerIdentity oid;
-
-    /**
-     * Destination.
-     */
-    struct GNUNET_PeerIdentity destination;
-
-    /**
-     * FIXME: Some form of authentication
-     */
-    // uint32_t token;
-
-    /**
-     * Payload follows
-     */
+    uint32_t tunnel_id GNUNET_PACKED;
+    uint32_t variable GNUNET_PACKED; /* Size of data to transmit? */
 };
 
-
-/**
- * Message for mesh data traffic from a tunnel participant to origin.
- */
-struct GNUNET_MESH_DataMessageToOrigin
-{
+struct GNUNET_MESH_TunnelEvent {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN
+     * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATED\DESTROYED]
      */
     struct GNUNET_MessageHeader header;
 
-    /**
-     * TID of the tunnel
-     */
-    uint32_t tid GNUNET_PACKED;
-
-    /**
-     * OID of the tunnel
-     */
-    struct GNUNET_PeerIdentity oid;
-
-    /**
-     * Sender of the message.
-     */
-    struct GNUNET_PeerIdentity sender;
-
-    /**
-     * FIXME: Some form of authentication
-     */
-    // uint32_t token;
-
-    /**
-     * Payload follows
-     */
+    uint32_t tunnel_id GNUNET_PACKED;
+    uint32_t reason GNUNET_PACKED; /* incoming, connect, timeout, disconnect */
 };
 
-/**
- * Message for mesh flow control
- */
-struct GNUNET_MESH_SpeedNotify
-{
+struct GNUNET_MESH_Data {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY
+     * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
+     *
+     * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
      */
     struct GNUNET_MessageHeader header;
 
-    /**
-     * TID of the tunnel
-     */
-    uint32_t tid GNUNET_PACKED;
-
-    /**
-     * OID of the tunnel
-     */
-    struct GNUNET_PeerIdentity oid;
+    uint32_t tunnel_id GNUNET_PACKED;
 
-    /**
-     * Slowest link down the path (above minimum speed requirement).
-     */
-    uint32_t speed_min;
+    /* FIXME: Broadcast? New Type / NULL destination ? */
+    /* FIXME: Reverese order for alignment? 1st ID, 2nd t_id? */
+    struct GNUNET_PeerIdentity destination GNUNET_PACKED;
 
+    /* uint8_t data[] */
 };
 
 #endif