X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcadet%2Fgnunet-service-cadet-new_peer.h;h=e1d6fc33a5e3770d81e5a8132c180295c456c7e2;hb=ad22adb15a0c895ac9c25d4c289abf86355a4737;hp=6b4ee1b5669f4e27663f427492b0e7ce6e4e5143;hpb=dfde8ea01a08a32340a47df29ffc2571c031488b;p=oweals%2Fgnunet.git diff --git a/src/cadet/gnunet-service-cadet-new_peer.h b/src/cadet/gnunet-service-cadet-new_peer.h index 6b4ee1b56..e1d6fc33a 100644 --- a/src/cadet/gnunet-service-cadet-new_peer.h +++ b/src/cadet/gnunet-service-cadet-new_peer.h @@ -59,6 +59,20 @@ GCP_get (const struct GNUNET_PeerIdentity *peer_id, int create); +/** + * Calculate how desirable a path is for @a cp if + * @a cp is at offset @a off in the path. + * + * @param cp a peer reachable via a path + * @param off offset of @a cp in a path + * @return score how useful a path is to reach @a cp, + * positive scores mean path is more desirable + */ +double +GCP_get_desirability_of_path (struct CadetPeer *cp, + unsigned int off); + + /** * Obtain the peer identity for a `struct CadetPeer`. * @@ -90,6 +104,16 @@ unsigned int GCP_count_paths (const struct CadetPeer *cp); +/** + * Drop all paths owned by this peer, and do not + * allow new ones to be added: We are shutting down. + * + * @param cp peer to drop paths to + */ +void +GCP_drop_owned_paths (struct CadetPeer *cp); + + /** * Peer path iterator. * @@ -123,14 +147,14 @@ GCP_iterate_paths (struct CadetPeer *cp, * Iterate over the paths to @a peer where * @a peer is at distance @a dist from us. * - * @param peer Peer to get path info. + * @param cp Peer to get path info. * @param dist desired distance of @a peer to us on the path * @param callback Function to call for every path. * @param callback_cls Closure for @a callback. * @return Number of iterated paths. */ unsigned int -GCP_iterate_paths_at (struct CadetPeer *peer, +GCP_iterate_paths_at (struct CadetPeer *cp, unsigned int dist, GCP_PathIterator callback, void *callback_cls); @@ -193,13 +217,15 @@ GCP_drop_tunnel (struct CadetPeer *cp, * @param cp peer to which the @a path leads to * @param path a path looking for an owner; may not be fully initialized yet! * @param off offset of @a cp in @a path + * @param force for attaching the path * @return NULL if this peer does not care to become a new owner, * otherwise the node in the peer's path heap for the @a path. */ struct GNUNET_CONTAINER_HeapNode * GCP_attach_path (struct CadetPeer *cp, struct CadetPeerPath *path, - unsigned int off); + unsigned int off, + int force); /** @@ -262,7 +288,12 @@ GCP_destroy_all_peers (void); /** * Data structure used to track whom we have to notify about changes - * to our message queue. + * in our ability to transmit to a given peer. + * + * All queue managers will be given equal chance for sending messages + * to @a cp. This construct this guarantees fairness for access to @a + * cp among the different message queues. Each connection or route + * will have its respective message queue managers for each direction. */ struct GCP_MessageQueueManager; @@ -271,15 +302,19 @@ struct GCP_MessageQueueManager; * Function to call with updated message queue object. * * @param cls closure - * @param mq NULL if MQ is gone, otherwise an active message queue + * @param available #GNUNET_YES if sending is now possible, + * #GNUNET_NO if sending is no longer possible + * #GNUNET_SYSERR if sending is no longer possible + * and the last envelope was discarded */ typedef void (*GCP_MessageQueueNotificationCallback)(void *cls, - struct GNUNET_MQ_Handle *mq); + int available); /** - * Start message queue change notifications. + * Start message queue change notifications. Will create a new slot + * to manage the message queue to the given @a cp. * * @param cp peer to notify for * @param cb function to call if mq becomes available or unavailable @@ -293,44 +328,67 @@ GCP_request_mq (struct CadetPeer *cp, /** - * Stops message queue change notifications. + * Test if @a cp has a core-level connection * - * @param mqm handle matching request to cancel + * @param cp peer to test + * @return #GNUNET_YES if @a cp has a core-level connection + */ +int +GCP_has_core_connection (struct CadetPeer *cp); + + +/** + * Send the message in @a env via a @a mqm. Must only be called at + * most once after the respective + * #GCP_MessageQueueNotificationCallback was called with `available` + * set to #GNUNET_YES, and not after the callback was called with + * `available` set to #GNUNET_NO or #GNUNET_SYSERR. + * + * @param mqm message queue manager for the transmission + * @param env envelope with the message to send; must NOT + * yet have a #GNUNET_MQ_notify_sent() callback attached to it */ void -GCP_request_mq_cancel (struct GCP_MessageQueueManager *mqm); +GCP_send (struct GCP_MessageQueueManager *mqm, + struct GNUNET_MQ_Envelope *env); /** - * Set the message queue to @a mq for peer @a cp and notify watchers. + * Send the message in @a env to @a cp, overriding queueing logic. + * This function should only be used to send error messages outside + * of flow and congestion control, similar to ICMP. Note that + * the envelope may be silently discarded as well. * - * @param cp peer to modify - * @param mq message queue to set (can be NULL) + * @param cp peer to send the message to + * @param env envelope with the message to send */ void -GCP_set_mq (struct CadetPeer *cp, - struct GNUNET_MQ_Handle *mq); +GCP_send_ooo (struct CadetPeer *cp, + struct GNUNET_MQ_Envelope *env); /** - * Get the message queue for peer @a cp. + * Stops message queue change notifications and sends a last message. + * In practice, this is implemented by sending that @a last_env + * message immediately (if any), ignoring queue order. * - * @param cp peer to modify - * @return message queue (can be NULL) + * @param mqm handle matching request to cancel + * @param last_env final message to transmit, or NULL */ -struct GNUNET_MQ_Handle * -GCP_get_mq (struct CadetPeer *cp); +void +GCP_request_mq_cancel (struct GCP_MessageQueueManager *mqm, + struct GNUNET_MQ_Envelope *last_env); /** - * Send the message in @a env to @a cp. + * Set the message queue to @a mq for peer @a cp and notify watchers. * - * @param cp the peer - * @param env envelope with the message to send + * @param cp peer to modify + * @param mq message queue to set (can be NULL) */ void -GCP_send (struct CadetPeer *cp, - struct GNUNET_MQ_Envelope *env); +GCP_set_mq (struct CadetPeer *cp, + struct GNUNET_MQ_Handle *mq); #endif