gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 23978c444c61bbf4c36eb99b79b7a0624ed6e8d5
parent 1c0563e59ff5a8a8543901d56d411719472bab92
Author: Bart Polot <bart@net.in.tum.de>
Date:   Wed, 24 Jul 2013 12:12:51 +0000

- new data structures

Diffstat:
Msrc/mesh/gnunet-service-mesh-enc.c | 196++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 93 insertions(+), 103 deletions(-)

diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c @@ -127,8 +127,11 @@ enum MeshTunnelState /******************************************************************************/ /** FWD declaration */ -struct MeshPeer; struct MeshClient; +struct MeshPeer; +struct MeshTunnel2; +struct MeshChannel; +struct MeshChannelReliability; /** @@ -154,7 +157,7 @@ struct MeshPeerQueue /** * Tunnel this message belongs to. */ - struct MeshTunnel *tunnel; + struct MeshTunnel2 *tunnel; /** * Pointer to info stucture used as cls. @@ -173,56 +176,13 @@ struct MeshPeerQueue }; - /** - * Struct containing all information regarding a given peer + * Struct to encapsulate all the Flow Control information to a peer to which + * we are directly connected (on a core level). */ -struct MeshPeer +struct MeshFlowControl { /** - * ID of the peer - */ - GNUNET_PEER_Id id; - - /** - * Last time we heard from this peer - */ - struct GNUNET_TIME_Absolute last_contact; - - /** - * Number of attempts to reconnect so far - */ - int n_reconnect_attempts; - - /** - * Paths to reach the peer, ordered by ascending hop count - */ - struct MeshPeerPath *path_head; - - /** - * Paths to reach the peer, ordered by ascending hop count - */ - struct MeshPeerPath *path_tail; - - /** - * Handle to stop the DHT search for a path to this peer - */ - struct GNUNET_DHT_GetHandle *dhtget; - - /** - * Array of tunnels this peer is the target of. - * Most probably a small amount, therefore not a hashmap. - * When the path to the peer changes, notify these tunnels to let them - * re-adjust their path trees. - */ - struct MeshTunnel **tunnels; - - /** - * Number of tunnels this peers participates in - */ - unsigned int ntunnels; - - /** * Transmission queue to core DLL head */ struct MeshPeerQueue *queue_head; @@ -241,17 +201,7 @@ struct MeshPeer * Handle for queued transmissions */ struct GNUNET_CORE_TransmitHandle *core_transmit; -}; - -/** - * Struct to encapsulate all the Flow Control information to a peer in the - * context of a tunnel: Same peer in different tunnels will have independent - * flow control structures, allowing to choke/free tunnels according to its - * own criteria. - */ -struct MeshFlowControl -{ /** * ID of the last packet sent towards the peer. */ @@ -273,11 +223,6 @@ struct MeshFlowControl uint32_t last_ack_recv; /** - * How many payload messages are in the queue towards this peer. - */ - uint32_t queue_n; - - /** * Task to poll the peer in case of a lost ACK causes stall. */ GNUNET_SCHEDULER_TaskIdentifier poll_task; @@ -286,39 +231,55 @@ struct MeshFlowControl * How frequently to poll for ACKs. */ struct GNUNET_TIME_Relative poll_time; - - /** - * On which tunnel to poll. - * Using an explicit poll_ctx would not help memory wise, - * since the allocated context would have to be stored in the - * fc struct in order to free it upon cancelling poll_task. - */ - struct MeshTunnel *t; }; /** - * Globally unique tunnel identification (owner + number) - * DO NOT USE OVER THE NETWORK + * Struct containing all information regarding a given peer */ -struct MESH_TunnelID +struct MeshPeer { /** - * Tunnel Owner. + * ID of the peer */ - GNUNET_PEER_Id oid; + GNUNET_PEER_Id id; /** - * Tunnel Destination. + * Last time we heard from this peer */ - GNUNET_PEER_Id did; -}; + struct GNUNET_TIME_Absolute last_contact; + /** + * Number of attempts to reconnect so far + */ + int n_reconnect_attempts; -/** - * Data needed for reliable tunnel endpoint retransmission management. - */ -struct MeshChannelReliability; + /** + * Paths to reach the peer, ordered by ascending hop count + */ + struct MeshPeerPath *path_head; + + /** + * Paths to reach the peer, ordered by ascending hop count + */ + struct MeshPeerPath *path_tail; + + /** + * Handle to stop the DHT search for a path to this peer + */ + struct GNUNET_DHT_GetHandle *dhtget; + + /** + * Tunnel to this peer, if any. + */ + struct MeshTunnel2 *tunnel; + + /** + * Flow control information for direct traffic. + */ + struct MeshFlowControl *fc; + +}; /** @@ -354,9 +315,9 @@ struct MeshReliableMessage struct MeshChannelReliability { /** - * Tunnel this is about. + * Channel this is about. */ - struct MeshTunnel *t; + struct MeshChannel *t; /** * DLL of messages sent and not yet ACK'd. @@ -408,6 +369,11 @@ struct MeshChannelReliability struct MeshChannel { /** + * Tunnel this channel is in. + */ + struct MeshTunnel2 *t; + + /** * Port of the channel. */ uint32_t port; @@ -465,16 +431,6 @@ struct MeshChannel GNUNET_PEER_Id prev_hop; /** - * Flow control information about @c next_hop or @c client. - */ - struct MeshFlowControl next_fc; - - /** - * Flow control information about @c prev_hop or @c owner. - */ - struct MeshFlowControl prev_fc; - - /** * Client owner of the tunnel, if any */ struct MeshClient *owner; @@ -513,6 +469,12 @@ struct MeshChannel struct MeshPath { /** + * DLL + */ + struct MeshPath next; + struct MeshPath prev; + + /** * Path being used for the tunnel. */ struct MeshPeerPath *path; @@ -532,9 +494,27 @@ struct MeshPath /** + * Globally unique tunnel identification (owner + number) + * DO NOT USE OVER THE NETWORK + */ +struct MESH_TunnelID +{ + /** + * Tunnel Owner. + */ + GNUNET_PEER_Id oid; + + /** + * Tunnel Destination. + */ + GNUNET_PEER_Id did; +}; + + +/** * Struct containing all information regarding a tunnel to a peer. */ -struct MeshTunnel +struct MeshTunnel2 { /** * Tunnel ID (owner, destination) @@ -549,17 +529,17 @@ struct MeshTunnel /** * Local peer ephemeral private key */ - struct GNUNET_CRYPTO_EccPrivateKey* my_eph_key; + struct GNUNET_CRYPTO_EccPrivateKey *my_eph_key; /** * Local peer ephemeral public key */ - struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded* my_eph; + struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *my_eph; /** * Remote peer's public key. */ - struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded* peers_eph; + struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *peers_eph; /** * Encryption ("our") key. @@ -571,7 +551,18 @@ struct MeshTunnel */ struct GNUNET_CRYPTO_AesSessionKey d_key; -} + /** + * Paths that are actively used to reach the destination peer. + */ + struct MeshPath *connection_head; + struct MeshPath *connection_tail; + + /** + * Channels inside this tunnel. + */ + struct MeshChannel *channel_head; + struct MeshChannel *channel_tail; +}; @@ -595,12 +586,12 @@ struct MeshClient /** * Tunnels that belong to this client, indexed by local id */ - struct GNUNET_CONTAINER_MultiHashMap32 *own_tunnels; + struct GNUNET_CONTAINER_MultiHashMap32 *own_channels; /** * Tunnels this client has accepted, indexed by incoming local id */ - struct GNUNET_CONTAINER_MultiHashMap32 *incoming_tunnels; + struct GNUNET_CONTAINER_MultiHashMap32 *incoming_channels; /** * Handle to communicate with the client @@ -623,7 +614,6 @@ struct MeshClient * ID of the client, mainly for debug messages */ unsigned int id; - };