X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmesh%2Fmesh.h;h=7011bd51ac6ebf495b58ef6603c064d527e22c64;hb=e43078b68951ad8a3daa3a193473e9c321549e1d;hp=803bf903320230eb727dc1fe318ce16993efaad0;hpb=24e2461fbd550593fabffc2044ca0a7cbcc771ca;p=oweals%2Fgnunet.git diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index 803bf9033..7011bd51a 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -39,61 +39,22 @@ extern "C" #define MESH_DEBUG GNUNET_YES #include "platform.h" -#include "gnunet_common.h" #include "gnunet_util_lib.h" #include "gnunet_peer_lib.h" #include "gnunet_core_service.h" #include "gnunet_protocols.h" #include -/******************************************************************************/ -/******************** MESH LOCAL MESSAGES *************************/ -/******************************************************************************/ -/* Any API call should be documented in the folowing table under API CALL. - * Also, any message type should be documented in the following table, with the - * associated event. - * - * API CALL (GNUNET_MESH_*) MESSAGE USED - * ------------------------ ------------ - * connect GNUNET_MESH_ClientConnect - * disconnect None (network level disconnect) - * - * tunnel_create GNUNET_MESH_TunnelMessage - * tunnel_destroy GNUNET_MESH_TunnelMessage - * tunnel_buffer GNUNET_MESH_TunnelMessage - * - * notify_transmit_ready None (queue / GNUNET_CLIENT_ntf_tmt_rdy) - * notify_transmit_ready_cancel None (clear of internal data structures) - * - * - * EVENT MESSAGE USED - * ----- ------------ - * data GNUNET_MESH_Unicast OR - * GNUNET_MESH_Multicast OR - * GNUNET_MESH_ToOrigin - * data ack GNUNET_MESH_LocalAck - * - * new incoming tunnel GNUNET_MESH_PeerControl - * peer connects to a tunnel FIXME - * peer disconnects from a tunnel FIXME - */ - /******************************************************************************/ /************************** CONSTANTS ******************************/ /******************************************************************************/ -#define GNUNET_MESH_LOCAL_TUNNEL_ID_CLI 0x80000000 -#define GNUNET_MESH_LOCAL_TUNNEL_ID_SERV 0xB0000000 +#define GNUNET_MESH_LOCAL_CHANNEL_ID_CLI 0x80000000 +#define GNUNET_MESH_LOCAL_CHANNEL_ID_SERV 0xB0000000 #define HIGH_PID 0xFFFF0000 #define LOW_PID 0x0000FFFF -/** - * Value in tunnel info: *int (GNUNET_YES/GNUNET_NO) - */ -#define GNUNET_MESH_OPTION_NOBUFFER 0x1 -#define GNUNET_MESH_OPTION_RELIABLE 0x2 - #define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID) /******************************************************************************/ @@ -120,78 +81,44 @@ struct GNUNET_MESH_ClientConnect /** - * Type for tunnel numbering. - * - Local tunnel numbers given by the service (incoming) are >= 0xB0000000 - * - Local tunnel numbers given by the client (created) are >= 0x80000000 - * - Global tunnel numbers are < 0x80000000 + * Type for channel numbering. + * - Local channel numbers given by the service (incoming) are >= 0xB0000000 + * - Local channel numbers given by the client (created) are >= 0x80000000 + * - Global channel numbers are < 0x80000000 */ -typedef uint32_t MESH_TunnelNumber; +typedef uint32_t MESH_ChannelNumber; /** - * Message for a client to create and destroy tunnels. + * Message for a client to create and destroy channels. */ -struct GNUNET_MESH_TunnelMessage +struct GNUNET_MESH_ChannelMessage { /** * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY] * - * Size: sizeof(struct GNUNET_MESH_TunnelMessage) + * Size: sizeof(struct GNUNET_MESH_ChannelMessage) */ struct GNUNET_MessageHeader header; /** - * ID of a tunnel controlled by this client. + * ID of a channel controlled by this client. */ - MESH_TunnelNumber tunnel_id GNUNET_PACKED; + MESH_ChannelNumber channel_id GNUNET_PACKED; /** - * Tunnel's peer + * Channel's peer */ struct GNUNET_PeerIdentity peer; /** - * Port of the tunnel. + * Port of the channel. */ uint32_t port GNUNET_PACKED; /** * Options. */ - int32_t options GNUNET_PACKED; -}; - - -/** - * Message for the service to let a client know about created tunnels. - */ -struct GNUNET_MESH_TunnelNotification -{ - /** - * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE - * - * Size: sizeof(struct GNUNET_MESH_TunnelMessage) - */ - struct GNUNET_MessageHeader header; - - /** - * ID of a tunnel controlled by this client. - */ - MESH_TunnelNumber tunnel_id GNUNET_PACKED; - - /** - * Peer at the other end. - */ - struct GNUNET_PeerIdentity peer; - - /** - * Port for this tunnel - */ - uint32_t port GNUNET_PACKED; - - /** - * Tunnel options (speed, buffering) - */ uint32_t opt GNUNET_PACKED; }; @@ -207,9 +134,9 @@ struct GNUNET_MESH_LocalData struct GNUNET_MessageHeader header; /** - * TID of the tunnel + * ID of the channel */ - uint32_t tid GNUNET_PACKED; + uint32_t id GNUNET_PACKED; /** * Payload follows @@ -229,81 +156,92 @@ struct GNUNET_MESH_LocalAck struct GNUNET_MessageHeader header; /** - * ID of the tunnel allowed to send more data. + * ID of the channel allowed to send more data. */ - MESH_TunnelNumber tunnel_id GNUNET_PACKED; + MESH_ChannelNumber channel_id GNUNET_PACKED; }; /** - * Message to inform the client about tunnels in the service. + * Message to inform the client about channels in the service. */ -struct GNUNET_MESH_LocalMonitor +struct GNUNET_MESH_LocalInfo { /** - * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_MONITOR[_TUNNEL] + * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO[_TUNNEL] */ struct GNUNET_MessageHeader header; /** - * ID of the tunnel allowed to send more data. + * ID of the channel allowed to send more data. + */ + MESH_ChannelNumber channel_id GNUNET_PACKED; + + /** + * ID of the owner of the channel (can be local peer). + */ +// struct GNUNET_PeerIdentity owner; + + /** + * ID of the destination of the channel (can be local peer). */ - MESH_TunnelNumber tunnel_id GNUNET_PACKED; + struct GNUNET_PeerIdentity peer; +}; +/** + * Message to inform the client about one of the tunnels in the service. + */ +struct GNUNET_MESH_LocalInfoTunnel +{ /** - * Alignment. + * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL[S] */ - uint32_t reserved GNUNET_PACKED; + struct GNUNET_MessageHeader header; /** - * ID of the owner of the tunnel (can be local peer). + * Number of channels. */ - struct GNUNET_PeerIdentity owner; + uint32_t channels GNUNET_PACKED; /** * ID of the destination of the tunnel (can be local peer). */ struct GNUNET_PeerIdentity destination; -}; + /** + * Number of connections. + */ + uint32_t connections GNUNET_PACKED; -GNUNET_NETWORK_STRUCT_END + /** + * Encryption state. + */ + uint16_t estate GNUNET_PACKED; -/******************************************************************************/ -/************************ ENUMERATIONS ****************************/ -/******************************************************************************/ + /** + * Connection state. + */ + uint16_t cstate GNUNET_PACKED; -/** - * All the states a tunnel can be in. - */ -enum MeshTunnelState -{ - /** - * Uninitialized status, should never appear in operation. - */ - MESH_TUNNEL_NEW, + /* If TUNNEL (no 'S'): GNUNET_PeerIdentity connection_ids[connections] */ + /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */ +}; - /** - * Path to the peer not known yet - */ - MESH_TUNNEL_SEARCHING, - /** - * Request sent, not yet answered. - */ - MESH_TUNNEL_WAITING, +GNUNET_NETWORK_STRUCT_END - /** - * Peer connected and ready to accept data - */ - MESH_TUNNEL_READY, - /** - * Peer connected previosly but not responding - */ - MESH_TUNNEL_RECONNECTING -}; + +/** + * @brief Translate a fwd variable into a string representation, for logging. + * + * @param fwd Is FWD? (#GNUNET_YES or #GNUNET_NO) + * + * @return String representing FWD or BCK. + */ +char * +GM_f2s (int fwd); /** @@ -315,7 +253,7 @@ enum MeshTunnelState * @return True if bigger (arg1) has a higher value than smaller (arg 2). */ int -GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller); +GM_is_pid_bigger (uint32_t bigger, uint32_t smaller); /** @@ -327,7 +265,7 @@ GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller); * @return Highest ACK value from the two. */ uint32_t -GMC_max_pid (uint32_t a, uint32_t b); +GM_max_pid (uint32_t a, uint32_t b); /** @@ -339,7 +277,7 @@ GMC_max_pid (uint32_t a, uint32_t b); * @return Lowest ACK value from the two. */ uint32_t -GMC_min_pid (uint32_t a, uint32_t b); +GM_min_pid (uint32_t a, uint32_t b); /** @@ -347,13 +285,13 @@ GMC_min_pid (uint32_t a, uint32_t b); * Generated with: * FIND: "#define ([^ ]+)[ ]*([0-9]+)" * REPLACE: " case \2: return "\1"; break;" - * + * * @param m Message type. - * + * * @return Human readable string description. */ const char * -GNUNET_MESH_DEBUG_M2S (uint16_t m); +GM_m2s (uint16_t m); #if 0 /* keep Emacsens' auto-indent happy */ {