GNUnet 0.22.0
gnunet-service-transport.c File Reference

main for gnunet-service-transport More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_transport_communication_service.h"
#include "gnunet_nat_service.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_signatures.h"
#include "transport.h"
Include dependency graph for gnunet-service-transport.c:

Go to the source code of this file.

Data Structures

struct  MessageUUIDP
 Unique identifier we attach to a message. More...
 
struct  AcknowledgementUUIDP
 Unique identifier to map an acknowledgement to a transmission. More...
 
struct  TransportBackchannelEncapsulationMessage
 Outer layer of an encapsulated backchannel message. More...
 
struct  EphemeralConfirmationPS
 Body by which a peer confirms that it is using an ephemeral key. More...
 
struct  TransportDVBoxPayloadP
 Plaintext of the variable-size payload that is encrypted within a struct TransportBackchannelEncapsulationMessage More...
 
struct  TransportReliabilityBoxMessage
 Outer layer of an encapsulated unfragmented application message sent over an unreliable channel. More...
 
struct  TransportCummulativeAckPayloadP
 Acknowledgement payload. More...
 
struct  TransportReliabilityAckMessage
 Confirmation that the receiver got a GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX. More...
 
struct  TransportFragmentBoxMessage
 Outer layer of an encapsulated fragmented application message. More...
 
struct  DvInitPS
 Content signed by the initiator during DV learning. More...
 
struct  DvHopPS
 Content signed by each peer during DV learning. More...
 
struct  DVPathEntryP
 An entry describing a peer on a path in a struct TransportDVLearnMessage message. More...
 
struct  TransportDVLearnMessage
 Internal message used by transport for distance vector learning. More...
 
struct  TransportDVBoxMessage
 Outer layer of an encapsulated message send over multiple hops. More...
 
struct  TransportValidationChallengeMessage
 Message send to another peer to validate that it can indeed receive messages at a particular address. More...
 
struct  TransportValidationPS
 Message signed by a peer to confirm that it can indeed receive messages at a particular address. More...
 
struct  TransportValidationResponseMessage
 Message send to a peer to respond to a #GNUNET_MESSAGE_TYPE_ADDRESS_VALIDATION_CHALLENGE. More...
 
struct  TransportGlobalNattedAddress
 
struct  TransportFlowControlMessage
 Message for Transport-to-Transport Flow control. More...
 
struct  LearnLaunchEntry
 When did we launch this DV learning activity? More...
 
struct  TransmissionHistoryEntry
 Information we keep per GOODPUT_AGING_SLOTS about historic (or current) transmission performance. More...
 
struct  PerformanceData
 Performance data for a transmission possibility. More...
 
struct  CommunicatorMessageContext
 Context from handle_incoming_msg(). More...
 
struct  RingBufferEntry
 Entry for the ring buffer caching messages send to core, when virtual link is available. More...
 
struct  CoreSentContext
 Closure for core_env_sent_cb. More...
 
struct  ReassemblyContext
 Information we keep for a message that we are reassembling. More...
 
struct  VirtualLink
 A virtual link is another reachable peer that is known to CORE. More...
 
struct  PendingAcknowledgement
 Data structure kept when we are waiting for an acknowledgement. More...
 
struct  DistanceVectorHop
 One possible hop towards a DV target. More...
 
struct  DistanceVector
 Entry in our dv_routes table, representing a (set of) distance vector routes to a particular peer. More...
 
struct  QueueEntry
 Entry identifying transmission in one of our struct Queue which still awaits an ACK. More...
 
struct  Queue
 Handle for a queue. More...
 
struct  Neighbour
 A neighbour that at least one communicator is connected to. More...
 
struct  IncomingRequest
 Another peer attempted to talk to us, we should try to establish a connection in the other direction. More...
 
struct  PeerRequest
 Information per peer and request. More...
 
struct  PendingMessage
 List containing all messages that are yet to be send. More...
 
struct  TransportCummulativeAckPayload
 Acknowledgement payload. More...
 
struct  AcknowledgementCummulator
 Data structure in which we track acknowledgements still to be sent to the. More...
 
struct  AddressListEntry
 One of the addresses of this peer. More...
 
struct  TransportClient
 Client connected to the transport service. More...
 
struct  ValidationState
 State we keep for validation activities. More...
 
struct  Backtalker
 A Backtalker is a peer sending us backchannel messages. More...
 
struct  MonitorEvent
 Details about what to notify monitors about. More...
 
struct  DVKeyState
 Structure of the key material used to encrypt backchannel messages. More...
 
struct  AddGlobalAddressesContext
 
struct  FindByMessageUuidContext
 Closure for find_by_message_uuid. More...
 
struct  NeighbourSelectionContext
 Closure for dv_neighbour_selection and dv_neighbour_transmission. More...
 
struct  CheckKnownAddressContext
 Closure for check_known_address. More...
 
struct  CheckKnownChallengeContext
 Closure for check_known_challenge. More...
 
struct  PendingMessageScoreContext
 Context for select_best_pending_from_link(). More...
 
struct  QueueQualityContext
 Closure for check_connection_quality. More...
 
struct  TransportGlobalNattedAddressClosure
 

Macros

#define RING_BUFFER_SIZE   16
 Size of ring buffer to cache CORE and forwarded DVBox messages. More...
 
#define MAX_FC_RETRANSMIT_COUNT   1000
 Maximum number of FC retransmissions for a running retransmission task. More...
 
#define MAX_CUMMULATIVE_ACKS   64
 Maximum number of messages we acknowledge together in one cumulative ACK. More...
 
#define FC_NO_CHANGE_REPLY_PROBABILITY   8
 What is the 1:n chance that we send a Flow control response when receiving a flow control message that did not change anything for us? Basically, this is used in the case where both peers are stuck on flow control (no window changes), but one might continue sending flow control messages to the other peer as the first FC message when things stalled got lost, and then subsequently the other peer does usually not respond as nothing changed. More...
 
#define IN_PACKET_SIZE_WITHOUT_MTU   128
 What is the size we assume for a read operation in the absence of an MTU for the purpose of flow control? More...
 
#define GOODPUT_AGING_SLOTS   4
 Number of slots we keep of historic data for computation of goodput / message loss ratio. More...
 
#define DEFAULT_WINDOW_SIZE   (128 * 1024)
 How big is the flow control window size by default; limits per-neighbour RAM utilization. More...
 
#define MAX_INCOMING_REQUEST   16
 For how many incoming connections do we try to create a virtual link for (at the same time!). More...
 
#define MAX_DV_DISCOVERY_SELECTION   16
 Maximum number of peers we select for forwarding DVInit messages at the same time (excluding initiator). More...
 
#define RECV_WINDOW_SIZE   4
 Window size. More...
 
#define MIN_DV_PATH_LENGTH_FOR_INITIATOR   3
 Minimum number of hops we should forward DV learn messages even if they are NOT useful for us in hope of looping back to the initiator? More...
 
#define MAX_DV_HOPS_ALLOWED   16
 Maximum DV distance allowed ever. More...
 
#define MAX_DV_LEARN_PENDING   64
 Maximum number of DV learning activities we may have pending at the same time. More...
 
#define MAX_DV_PATHS_TO_TARGET   3
 Maximum number of DV paths we keep simultaneously to the same target. More...
 
#define DELAY_WARN_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 If a queue delays the next message by more than this number of seconds we log a warning. More...
 
#define DV_FORWARD_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 If a DVBox could not be forwarded after this number of seconds we drop it. More...
 
#define DEFAULT_ACK_WAIT_DURATION    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 Default value for how long we wait for reliability ack. More...
 
#define DV_QUALITY_RTT_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 We only consider queues as "quality" connections when suppressing the generation of DV initiation messages if the latency of the queue is below this threshold. More...
 
#define DV_PATH_VALIDITY_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 How long do we consider a DV path valid if we see no further updates on it? Note: the value chosen here might be too low! More...
 
#define BACKCHANNEL_INACTIVITY_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 How long do we cache backchannel (struct Backtalker) information after a backchannel goes inactive? More...
 
#define DV_PATH_DISCOVERY_FREQUENCY    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
 How long before paths expire would we like to (re)discover DV paths? Should be below DV_PATH_VALIDITY_TIMEOUT. More...
 
#define EPHEMERAL_VALIDITY    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 How long are ephemeral keys valid? More...
 
#define REASSEMBLY_EXPIRATION    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
 How long do we keep partially reassembled messages around before giving up? More...
 
#define FAST_VALIDATION_CHALLENGE_FREQ    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
 What is the fastest rate at which we send challenges if we keep learning an address (gossip, DHT, etc.)? More...
 
#define MAX_VALIDATION_CHALLENGE_FREQ    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
 What is the slowest rate at which we send challenges? More...
 
#define ACK_CUMMULATOR_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 How long until we forget about historic accumulators and thus reset the ACK counter? Should exceed the maximum time an active connection experiences without an ACK. More...
 
#define DV_LEARN_BASE_FREQUENCY   GNUNET_TIME_UNIT_MINUTES
 What is the non-randomized base frequency at which we would initiate DV learn messages? More...
 
#define DV_LEARN_QUALITY_THRESHOLD   100
 How many good connections (confirmed, bi-directional, not DV) do we need to have to suppress initiating DV learn messages? More...
 
#define MAX_ADDRESS_VALID_UNTIL    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
 When do we forget an invalid address for sure? More...
 
#define ADDRESS_VALIDATION_LIFETIME    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 How long do we consider an address valid if we just checked? More...
 
#define MIN_DELAY_ADDRESS_VALIDATION   GNUNET_TIME_UNIT_MILLISECONDS
 What is the maximum frequency at which we do address validation? A random value between 0 and this value is added when scheduling the validation_task (both to ensure we do not validate too often, and to randomize a bit). More...
 
#define VALIDATION_RTT_BUFFER_FACTOR   3
 How many network RTTs before an address validation expires should we begin trying to revalidate? (Note that the RTT used here is the one that we experienced during the last validation, not necessarily the latest RTT observed). More...
 
#define COMMUNICATOR_TOTAL_QUEUE_LIMIT   512
 How many messages can we have pending for a given communicator process before we start to throttle that communicator? More...
 
#define QUEUE_LENGTH_LIMIT   32
 How many messages can we have pending for a given queue (queue to a particular peer via a communicator) process before we start to throttle that queue? More...
 
#define QUEUE_ENTRY_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
#define RTT_DIFF    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 Difference of the average RTT for the DistanceVector calculate by us and the target we are willing to accept for starting the burst. More...
 

Typedefs

typedef void(* DVMessageHandler) (void *cls, struct Neighbour *next_hop, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)
 Function to call to further operate on the now DV encapsulated message hdr, forwarding it via next_hop under respect of options. More...
 

Enumerations

enum  ClientType {
  CT_NONE = 0 , CT_CORE = 1 , CT_MONITOR = 2 , CT_COMMUNICATOR = 3 ,
  CT_APPLICATION = 4
}
 What type of client is the struct TransportClient about? More...
 
enum  RouteMessageOptions {
  RMO_NONE = 0 , RMO_DV_ALLOWED = 1 , RMO_UNCONFIRMED_ALLOWED = 2 , RMO_ANYTHING_GOES = (RMO_DV_ALLOWED | RMO_UNCONFIRMED_ALLOWED) ,
  RMO_REDUNDANT = 4
}
 Which transmission options are allowable for transmission? Interpreted bit-wise! More...
 
enum  PendingMessageType { PMT_CORE = 0 , PMT_FRAGMENT_BOX = 1 , PMT_RELIABILITY_BOX = 2 , PMT_DV_BOX = 3 }
 Types of different pending messages. More...
 

Functions

static unsigned int get_age ()
 Get an offset into the transmission history buffer for struct PerformanceData. More...
 
static void free_incoming_request (struct IncomingRequest *ir)
 Release ir data structure. More...
 
static void free_pending_acknowledgement (struct PendingAcknowledgement *pa)
 Release pa data structure. More...
 
static void free_fragment_tree (struct PendingMessage *root)
 Free fragment tree below root, excluding root itself. More...
 
static void free_pending_message (struct PendingMessage *pm)
 Release memory associated with pm and remove pm from associated data structures. More...
 
static void free_reassembly_context (struct ReassemblyContext *rc)
 Free rc. More...
 
static void reassembly_cleanup_task (void *cls)
 Task run to clean up reassembly context of a neighbour that have expired. More...
 
static int free_reassembly_cb (void *cls, uint32_t key, void *value)
 function called to free_reassembly_context(). More...
 
static void free_virtual_link (struct VirtualLink *vl)
 Free virtual link. More...
 
static void free_validation_state (struct ValidationState *vs)
 Free validation state. More...
 
static struct Neighbourlookup_neighbour (const struct GNUNET_PeerIdentity *pid)
 Lookup neighbour for peer pid. More...
 
static struct VirtualLinklookup_virtual_link (const struct GNUNET_PeerIdentity *pid)
 Lookup virtual link for peer pid. More...
 
static void free_distance_vector_hop (struct DistanceVectorHop *dvh)
 Free a dvh. More...
 
static void check_link_down (void *cls)
 Task run to check whether the hops of the cls still are validated, or if we need to core about disconnection. More...
 
static void cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid)
 Send message to CORE clients that we lost a connection. More...
 
static void free_dv_route (struct DistanceVector *dv)
 Free entry in dv_routes. More...
 
static void notify_monitor (struct TransportClient *tc, const struct GNUNET_PeerIdentity *peer, const char *address, enum GNUNET_NetworkType nt, const struct MonitorEvent *me)
 Notify monitor tc about an event. More...
 
static void notify_monitors (const struct GNUNET_PeerIdentity *peer, const char *address, enum GNUNET_NetworkType nt, const struct MonitorEvent *me)
 Send information in me about a peer's status with respect to some address to all monitors that care. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Called whenever a client connects. More...
 
static enum GNUNET_GenericReturnValue remove_global_addresses (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 
static void free_neighbour (struct Neighbour *neighbour, enum GNUNET_GenericReturnValue drop_link)
 Release memory used by neighbour. More...
 
static void core_send_connect_info (struct TransportClient *tc, const struct GNUNET_PeerIdentity *pid)
 Send message to CORE clients that we lost a connection. More...
 
static void cores_send_connect_info (const struct GNUNET_PeerIdentity *pid)
 Send message to CORE clients that we gained a connection. More...
 
static void transmit_on_queue (void *cls)
 We believe we are ready to transmit a message on a queue. More...
 
static unsigned int check_for_queue_with_higher_prio (struct Queue *queue, struct Queue *queue_head)
 Check if the communicator has another queue with higher prio ready for sending. More...
 
static void schedule_transmit_on_queue (struct GNUNET_TIME_Relative delay, struct Queue *queue, enum GNUNET_SCHEDULER_Priority p)
 Called whenever something changed that might effect when we try to do the next transmission on queue using transmit_on_queue(). More...
 
static void free_queue (struct Queue *queue)
 Free queue. More...
 
static void free_address_list_entry (struct AddressListEntry *ale)
 Free ale. More...
 
static int stop_peer_request (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Stop the peer request in value. More...
 
static void do_shutdown (void *cls)
 Function called when the service shuts down. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected. More...
 
static int notify_client_connect_info (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Iterator telling new CORE client about all existing connections to peers. More...
 
static void finish_cmc_handling_with_continue (struct CommunicatorMessageContext *cmc, unsigned int free_cmc)
 Send ACK to communicator (if requested) and free cmc. More...
 
static enum GNUNET_GenericReturnValue resume_communicators (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 
static void handle_client_start (void *cls, const struct StartMessage *start)
 Initialize a "CORE" client. More...
 
static int check_client_send (void *cls, const struct OutboundMessage *obm)
 Client asked for transmission to a peer. More...
 
static void client_send_response (struct PendingMessage *pm)
 Send a response to the pm that we have processed a "send" request. More...
 
static unsigned int pick_random_dv_hops (const struct DistanceVector *dv, enum RouteMessageOptions options, struct DistanceVectorHop **hops_array, unsigned int hops_array_length)
 Pick hops_array_length random DV paths satisfying options. More...
 
static int check_communicator_available (void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
 Communicator started. More...
 
static void finish_cmc_handling (struct CommunicatorMessageContext *cmc)
 
static void handle_client_recv_ok (void *cls, const struct RecvOkMessage *rom)
 Client confirms that it is done handling message(s) to a particular peer. More...
 
static void handle_communicator_available (void *cls, const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
 Communicator started. More...
 
static int check_communicator_backchannel (void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
 Communicator requests backchannel transmission. More...
 
static void sign_ephemeral (struct DistanceVector *dv)
 Sign ephemeral keys in our dv are current. More...
 
static void free_queue_entry (struct QueueEntry *qe, struct TransportClient *tc)
 
static void free_timedout_queue_entry (void *cls)
 
static void queue_send_msg (struct Queue *queue, struct PendingMessage *pm, const void *payload, size_t payload_size)
 Send the message payload on queue. More...
 
static struct GNUNET_TIME_Relative route_via_neighbour (const struct Neighbour *n, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)
 Pick a queue of n under constraints options and schedule transmission of hdr. More...
 
static void dv_setup_key_state_from_km (const struct GNUNET_ShortHashCode *km, const struct GNUNET_ShortHashCode *iv, struct DVKeyState *key)
 Given the key material in km and the initialization vector iv, setup the key material for the backchannel in key. More...
 
static void dv_hmac (const struct DVKeyState *key, struct GNUNET_HashCode *hmac, const void *data, size_t data_size)
 Do HMAC calculation for backchannel messages over data using key material from key. More...
 
static void dv_encrypt (struct DVKeyState *key, const void *in, void *dst, size_t in_size)
 Perform backchannel encryption using symmetric secret in key to encrypt data from in to dst. More...
 
static enum GNUNET_GenericReturnValue dv_decrypt (struct DVKeyState *key, void *out, const void *ciph, size_t out_size)
 Perform backchannel encryption using symmetric secret in key to encrypt data from in to dst. More...
 
static void dv_key_clean (struct DVKeyState *key)
 Clean up key material in key. More...
 
static struct GNUNET_TIME_Relative encapsulate_for_dv (struct DistanceVector *dv, unsigned int num_dvhs, struct DistanceVectorHop **dvhs, const struct GNUNET_MessageHeader *hdr, DVMessageHandler use, void *use_cls, enum RouteMessageOptions options, enum GNUNET_GenericReturnValue without_fc)
 Pick a path of dv under constraints options and schedule transmission of hdr. More...
 
static void send_dv_to_neighbour (void *cls, struct Neighbour *next_hop, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)
 Wrapper around route_via_neighbour() that matches the DVMessageHandler structure. More...
 
static struct GNUNET_TIME_Relative route_control_message_without_fc (struct VirtualLink *vl, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)
 We need to transmit hdr to target. More...
 
static void consider_sending_fc (void *cls)
 Something changed on the virtual link with respect to flow control. More...
 
static void task_consider_sending_fc (void *cls)
 Something changed on the virtual link with respect to flow control. More...
 
static char * get_address_without_port (const char *address)
 Get the IP address without the port number. More...
 
static enum GNUNET_GenericReturnValue add_global_addresses (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 
static struct GNUNET_TIME_Relative calculate_rtt (struct DistanceVector *dv)
 
static void check_vl_transmission (struct VirtualLink *vl)
 There is a message at the head of the pending messages for vl which may be ready for transmission. More...
 
static void handle_client_send (void *cls, const struct OutboundMessage *obm)
 Client asked for transmission to a peer. More...
 
static void handle_communicator_backchannel (void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
 Communicator requests backchannel transmission. More...
 
static int check_add_address (void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *aam)
 Address of our peer added. More...
 
static void store_pi (void *cls)
 Ask peerstore to store our address. More...
 
static void peerstore_store_own_cb (void *cls, int success)
 Function called when peerstore is done storing our address. More...
 
static void shc_cont (void *cls, int success)
 
static struct AddressListEntrycreate_address_entry (struct TransportClient *tc, struct GNUNET_TIME_Relative expiration, enum GNUNET_NetworkType nt, const char *address, uint32_t aid, size_t slen)
 
static void handle_add_address (void *cls, const struct GNUNET_TRANSPORT_AddAddressMessage *aam)
 Address of our peer added. More...
 
static void handle_del_address (void *cls, const struct GNUNET_TRANSPORT_DelAddressMessage *dam)
 Address of our peer deleted. More...
 
static void demultiplex_with_cmc (struct CommunicatorMessageContext *cmc)
 Given an inbound message msg from a communicator cmc, demultiplex it based on the type calling the right handler. More...
 
static void core_env_sent_cb (void *cls)
 Function called when we are done giving a message of a certain size to CORE and should thus decrement the number of bytes of RAM reserved for that peer's MQ. More...
 
static void finish_handling_raw_message (struct VirtualLink *vl, const struct GNUNET_MessageHeader *mh, struct CommunicatorMessageContext *cmc, unsigned int free_cmc)
 
static void handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
 Communicator gave us an unencapsulated message to pass as-is to CORE. More...
 
static int check_fragment_box (void *cls, const struct TransportFragmentBoxMessage *fb)
 Communicator gave us a fragment box. More...
 
static void destroy_ack_cummulator (void *cls)
 Clean up an idle cumulative acknowledgement data structure. More...
 
static void transmit_cummulative_ack_cb (void *cls)
 Do the transmission of a cumulative acknowledgement now. More...
 
static void cummulative_ack (const struct GNUNET_PeerIdentity *pid, const struct AcknowledgementUUIDP *ack_uuid, struct GNUNET_TIME_Absolute max_delay)
 Transmit an acknowledgement for ack_uuid to pid delaying transmission by at most ack_delay. More...
 
static int find_by_message_uuid (void *cls, uint32_t key, void *value)
 Iterator called to find a reassembly context by the message UUID in the multihashmap32. More...
 
static void handle_fragment_box (void *cls, const struct TransportFragmentBoxMessage *fb)
 Communicator gave us a fragment. More...
 
static int check_reliability_box (void *cls, const struct TransportReliabilityBoxMessage *rb)
 Communicator gave us a reliability box. More...
 
static void handle_reliability_box (void *cls, const struct TransportReliabilityBoxMessage *rb)
 Communicator gave us a reliability box. More...
 
static void update_pd_age (struct PerformanceData *pd, unsigned int age)
 Check if we have advanced to another age since the last time. More...
 
static void update_performance_data (struct PerformanceData *pd, struct GNUNET_TIME_Relative rtt, uint16_t bytes_transmitted_ok)
 Update pd based on the latest rtt and the number of bytes that were confirmed to be successfully transmitted. More...
 
static void update_queue_performance (struct Queue *q, struct GNUNET_TIME_Relative rtt, uint16_t bytes_transmitted_ok)
 We have successfully transmitted data via q, update metrics. More...
 
static void update_dvh_performance (struct DistanceVectorHop *dvh, struct GNUNET_TIME_Relative rtt, uint16_t bytes_transmitted_ok)
 We have successfully transmitted data via dvh, update metrics. More...
 
static void completed_pending_message (struct PendingMessage *pm)
 We have completed transmission of pm, remove it from the transmission queues (and if it is a fragment, continue up the tree as necessary). More...
 
static void handle_acknowledged (struct PendingAcknowledgement *pa, struct GNUNET_TIME_Relative ack_delay)
 The pa was acknowledged, process the acknowledgement. More...
 
static int check_reliability_ack (void *cls, const struct TransportReliabilityAckMessage *ra)
 Communicator gave us a reliability ack. More...
 
static void handle_reliability_ack (void *cls, const struct TransportReliabilityAckMessage *ra)
 Communicator gave us a reliability ack. More...
 
static int check_backchannel_encapsulation (void *cls, const struct TransportBackchannelEncapsulationMessage *be)
 Communicator gave us a backchannel encapsulation. More...
 
static void handle_backchannel_encapsulation (void *cls, const struct TransportBackchannelEncapsulationMessage *be)
 Communicator gave us a backchannel encapsulation. More...
 
static void path_cleanup_cb (void *cls)
 Task called when we should check if any of the DV paths we have learned to a target are due for garbage collection. More...
 
static void send_msg_from_cache (struct VirtualLink *vl)
 
static void activate_core_visible_dv_path (struct DistanceVectorHop *hop)
 The hop is a validated path to the respective target peer and we should tell core about it – and schedule a job to revoke the state. More...
 
static int learn_dv_path (const struct GNUNET_PeerIdentity *path, unsigned int path_len, struct GNUNET_TIME_Relative network_latency, struct GNUNET_TIME_Absolute path_valid_until)
 We have learned a path through the network to some other peer, add it to our DV data structure (returning GNUNET_YES on success). More...
 
static int check_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
 Communicator gave us a DV learn message. More...
 
static void forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop, const struct TransportDVLearnMessage *msg, uint16_t bi_history, uint16_t nhops, const struct DVPathEntryP *hops, struct GNUNET_TIME_Absolute in_time)
 Build and forward a DV learn message to next_hop. More...
 
static int validate_dv_initiator_signature (struct GNUNET_TIME_AbsoluteNBO sender_monotonic_time, const struct GNUNET_PeerIdentity *init, const struct GNUNET_CRYPTO_ChallengeNonceP *challenge, const struct GNUNET_CRYPTO_EddsaSignature *init_sig)
 Check signature of type GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR. More...
 
static int dv_neighbour_selection (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Function called for each neighbour during handle_dv_learn. More...
 
static int dv_neighbour_transmission (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Function called for each neighbour during handle_dv_learn. More...
 
static unsigned int calculate_fork_degree (unsigned int hops_taken, unsigned int neighbour_count, unsigned int eligible_count)
 Computes the number of neighbours we should forward a DVInit message to given that it has so far taken hops_taken hops though the network and that the number of neighbours we have in total is neighbour_count, out of which eligible_count are not yet on the path. More...
 
static void neighbour_store_dvmono_cb (void *cls, int success)
 Function called when peerstore is done storing a DV monotonic time. More...
 
static struct GNUNET_TIME_Relative get_network_latency (const struct TransportDVLearnMessage *dvl)
 
static void handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
 Communicator gave us a DV learn message. More...
 
static int check_dv_box (void *cls, const struct TransportDVBoxMessage *dvb)
 Communicator gave us a DV box. More...
 
static void forward_dv_box (struct Neighbour *next_hop, struct TransportDVBoxMessage *hdr, uint16_t total_hops, uint16_t num_hops, const struct GNUNET_PeerIdentity *hops, const void *enc_payload, uint16_t enc_payload_size)
 Create a DV Box message and queue it for transmission to next_hop. More...
 
static void free_backtalker (struct Backtalker *b)
 Free data structures associated with b. More...
 
static int free_backtalker_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Callback to free backtalker records. More...
 
static void backtalker_timeout_cb (void *cls)
 Function called when it is time to clean up a backtalker. More...
 
static void backtalker_monotime_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Function called with the monotonic time of a backtalker by PEERSTORE. More...
 
static void backtalker_monotime_store_cb (void *cls, int success)
 Function called by PEERSTORE when the store operation of a backtalker's monotonic time is complete. More...
 
static void update_backtalker_monotime (struct Backtalker *b)
 The backtalker b monotonic time changed. More...
 
static void handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb)
 Communicator gave us a DV box. More...
 
static int check_incoming_msg (void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *im)
 Client notified us about transmission from a peer. More...
 
static int check_known_address (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Test if the validation state in value matches the address from cls. More...
 
static void validation_start_cb (void *cls)
 Task run periodically to validate some address based on validation_heap. More...
 
static void update_next_challenge_time (struct ValidationState *vs, struct GNUNET_TIME_Absolute new_time)
 Set the time for next_challenge of vs to new_time. More...
 
static void start_address_validation (const struct GNUNET_PeerIdentity *pid, const char *address)
 Start address validation. More...
 
static struct Queuefind_queue (const struct GNUNET_PeerIdentity *pid, const char *address)
 Find the queue matching pid and address. More...
 
static void suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
 Signature of a function called with a communicator address of a peer pid that an application wants us to connect to. More...
 
static void hello_for_incoming_cb (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
 
static void handle_hello_for_incoming (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Function called by PEERSTORE for each matching record. More...
 
static void hello_for_incoming_error_cb (void *cls)
 
static void hello_for_incoming_sync_cb (void *cls)
 
static void handle_validation_challenge (void *cls, const struct TransportValidationChallengeMessage *tvc)
 Communicator gave us a transport address validation challenge. More...
 
static int check_known_challenge (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Test if the validation state in value matches the challenge from cls. More...
 
static void peerstore_store_validation_cb (void *cls, int success)
 Function called when peerstore is done storing a validated address. More...
 
static void validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs)
 The queue q (which matches the peer and address in vs) is ready for queueing. More...
 
static void revalidation_start_cb (void *cls)
 
static enum GNUNET_GenericReturnValue revalidate_map_it (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void handle_validation_response (void *cls, const struct TransportValidationResponseMessage *tvr)
 Communicator gave us a transport address validation response. More...
 
static void handle_incoming_msg (void *cls, const struct GNUNET_TRANSPORT_IncomingMessage *im)
 Incoming message. More...
 
static int check_flow_control (void *cls, const struct TransportFlowControlMessage *fc)
 Communicator gave us a transport address validation response. More...
 
static void iterate_address_start_burst (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
 
static void check_for_burst_address (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 
static void burst_timeout (void *cls)
 
static void start_burst (void *cls)
 
static void queue_burst (void *cls)
 
static void handle_flow_control (void *cls, const struct TransportFlowControlMessage *fc)
 Communicator gave us a transport address validation response. More...
 
static int check_add_queue_message (void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
 New queue became available. More...
 
static void set_pending_message_uuid (struct PendingMessage *pm)
 If necessary, generates the UUID for a pm. More...
 
static struct PendingAcknowledgementprepare_pending_acknowledgement (struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
 Setup data structure waiting for acknowledgements. More...
 
static struct PendingMessagefragment_message (struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
 Fragment the given pm to the given mtu. More...
 
static struct PendingMessagereliability_box_message (struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
 Reliability-box the given pm. More...
 
static void reorder_root_pm (struct PendingMessage *pm, struct GNUNET_TIME_Absolute next_attempt)
 
static unsigned int check_next_attempt_tree (struct PendingMessage *pm, struct PendingMessage *root)
 
static void harmonize_flight_round (struct PendingMessage *pm)
 
static void update_pm_next_attempt (struct PendingMessage *pm, struct GNUNET_TIME_Absolute next_attempt)
 Change the value of the next_attempt field of pm to next_attempt and re-order pm in the transmission list as required by the new timestamp. More...
 
static void select_best_pending_from_link (struct PendingMessageScoreContext *sc, struct Queue *queue, struct VirtualLink *vl, struct DistanceVectorHop *dvh, size_t overhead)
 Select the best pending message from vl for transmission via queue. More...
 
static void extract_box_cb (void *cls, struct Neighbour *next_hop, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)
 Function to call to further operate on the now DV encapsulated message hdr, forwarding it via next_hop under respect of options. More...
 
static void handle_del_queue_message (void *cls, const struct GNUNET_TRANSPORT_DelQueueMessage *dqm)
 Queue to a peer went down. More...
 
static void handle_send_message_ack (void *cls, const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
 Message was transmitted. More...
 
static void handle_burst_finished ()
 The burst finished. More...
 
static int notify_client_queues (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Iterator telling new MONITOR client about all existing queues to peers. More...
 
static void handle_monitor_start (void *cls, const struct GNUNET_TRANSPORT_MonitorStart *start)
 Initialize a monitor client. More...
 
static struct TransportClientlookup_communicator (const char *prefix)
 Find transport client providing communication service for the protocol prefix. More...
 
static int check_connection_quality (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Check whether any queue to the given neighbour is of a good "quality" and if so, increment the counter. More...
 
static void start_dv_learn (void *cls)
 Task run when we CONSIDER initiating a DV learn process. More...
 
static int check_validation_request_pending (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 A new queue has been created, check if any address validation requests have been waiting for it. More...
 
static void neighbour_dv_monotime_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Function called with the monotonic time of a DV initiator by PEERSTORE. More...
 
static void iterate_address_and_compare_cb (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
 
static enum GNUNET_GenericReturnValue contains_address (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 
static void check_for_global_natted_error_cb (void *cls)
 
static void check_for_global_natted_sync_cb (void *cls)
 
static void check_for_global_natted (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 
static void handle_add_queue_message (void *cls, const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
 New queue became available. More...
 
static void handle_update_queue_message (void *cls, const struct GNUNET_TRANSPORT_UpdateQueueMessage *msg)
 Handle updates to queues. More...
 
static void handle_queue_create_ok (void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
 Communicator tells us that our request to create a queue "worked", that is setting up the queue is now in process. More...
 
static void handle_queue_create_fail (void *cls, const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
 Communicator tells us that our request to create a queue failed. More...
 
static void handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg)
 We have received a struct ExpressPreferenceMessage from an application client. More...
 
static void hello_for_client_cb (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
 
static void handle_hello_for_client (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Function called by PEERSTORE for each matching record. More...
 
static void hello_for_client_error_cb (void *cls)
 
static void hello_for_client_sync_cb (void *cls)
 
static void handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
 We have received a struct ExpressPreferenceMessage from an application client. More...
 
static int check_request_hello_validation (void *cls, const struct RequestHelloValidationMessage *m)
 Check GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION messages. More...
 
static void handle_request_hello_validation (void *cls, const struct RequestHelloValidationMessage *m)
 A client encountered an address of another peer. More...
 
static int free_neighbour_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Free neighbour entry. More...
 
static int free_dv_routes_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Free DV route entry. More...
 
static int free_validation_state_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Free validation state. More...
 
static int free_pending_ack_cb (void *cls, const struct GNUNET_Uuid *key, void *value)
 Free pending acknowledgement. More...
 
static int free_ack_cummulator_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
 Free acknowledgement cummulator. More...
 
static void shutdown_task (void *cls)
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Initiate transport service. More...
 
 GNUNET_SERVICE_MAIN ("transport", GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(suggest, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST, struct ExpressPreferenceMessage, NULL), GNUNET_MQ_hd_fixed_size(suggest_cancel, GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, struct ExpressPreferenceMessage, NULL), GNUNET_MQ_hd_var_size(request_hello_validation, GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, struct RequestHelloValidationMessage, NULL), GNUNET_MQ_hd_fixed_size(client_start, GNUNET_MESSAGE_TYPE_TRANSPORT_START, struct StartMessage, NULL), GNUNET_MQ_hd_var_size(client_send, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, struct OutboundMessage, NULL), GNUNET_MQ_hd_fixed_size(client_recv_ok, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK, struct RecvOkMessage, NULL), GNUNET_MQ_hd_var_size(communicator_available, GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, NULL), GNUNET_MQ_hd_var_size(communicator_backchannel, GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, struct GNUNET_TRANSPORT_CommunicatorBackchannel, NULL), GNUNET_MQ_hd_var_size(add_address, GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, struct GNUNET_TRANSPORT_AddAddressMessage, NULL), GNUNET_MQ_hd_fixed_size(del_address, GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, struct GNUNET_TRANSPORT_DelAddressMessage, NULL), GNUNET_MQ_hd_var_size(incoming_msg, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, struct GNUNET_TRANSPORT_IncomingMessage, NULL), GNUNET_MQ_hd_fixed_size(queue_create_ok, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, struct GNUNET_TRANSPORT_CreateQueueResponse, NULL), GNUNET_MQ_hd_fixed_size(queue_create_fail, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, struct GNUNET_TRANSPORT_CreateQueueResponse, NULL), GNUNET_MQ_hd_var_size(add_queue_message, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, struct GNUNET_TRANSPORT_AddQueueMessage, NULL), GNUNET_MQ_hd_fixed_size(update_queue_message, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE, struct GNUNET_TRANSPORT_UpdateQueueMessage, NULL), GNUNET_MQ_hd_fixed_size(del_queue_message, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, struct GNUNET_TRANSPORT_DelQueueMessage, NULL), GNUNET_MQ_hd_fixed_size(send_message_ack, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, struct GNUNET_TRANSPORT_SendMessageToAck, NULL), GNUNET_MQ_hd_fixed_size(burst_finished, GNUNET_MESSAGE_TYPE_TRANSPORT_BURST_FINISHED, struct GNUNET_TRANSPORT_BurstFinished, NULL), GNUNET_MQ_hd_fixed_size(monitor_start, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START, struct GNUNET_TRANSPORT_MonitorStart, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct RingBufferEntryring_buffer [RING_BUFFER_SIZE]
 Ring buffer for a CORE message we did not deliver to CORE, because of missing virtual link to sender. More...
 
static unsigned int ring_buffer_head
 Head of the ring buffer. More...
 
static unsigned int is_ring_buffer_full
 Is the ring buffer filled up to RING_BUFFER_SIZE. More...
 
static struct PendingMessagering_buffer_dv [RING_BUFFER_SIZE]
 Ring buffer for a forwarded DVBox message we did not deliver to the next hop, because of missing virtual link that hop. More...
 
static unsigned int ring_buffer_dv_head
 Head of the ring buffer. More...
 
static unsigned int is_ring_buffer_dv_full
 Is the ring buffer filled up to RING_BUFFER_SIZE. More...
 
static struct TransportClientclients_head
 Head of linked list of all clients to this service. More...
 
static struct TransportClientclients_tail
 Tail of linked list of all clients to this service. More...
 
static struct GNUNET_STATISTICS_HandleGST_stats
 Statistics handle. More...
 
static const struct GNUNET_CONFIGURATION_HandleGST_cfg
 Configuration handle. More...
 
static struct GNUNET_PeerIdentity GST_my_identity
 Our public key. More...
 
struct GNUNET_HELLO_BuilderGST_my_hello
 Our HELLO. More...
 
static struct GNUNET_CRYPTO_EddsaPrivateKeyGST_my_private_key
 Our private key. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapneighbours
 Map from PIDs to struct Neighbour entries. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapbacktalkers
 Map from PIDs to struct Backtalker entries. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapack_cummulators
 Map from PIDs to struct AcknowledgementCummulators. More...
 
static struct GNUNET_CONTAINER_MultiUuidmappending_acks
 Map of pending acknowledgements, mapping struct AcknowledgementUUID to a struct PendingAcknowledgement. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapdv_routes
 Map from PIDs to struct DistanceVector entries describing known paths to the peer. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapvalidation_map
 Map from PIDs to struct ValidationState entries describing addresses we are aware of and their validity state. More...
 
static struct GNUNET_CONTAINER_MultiHashMaprevalidation_map
 Map from addresses to struct ValidationState entries describing addresses we are aware of and their validity state. More...
 
static struct GNUNET_CONTAINER_MultiPeerMaplinks
 Map from PIDs to struct VirtualLink entries describing links CORE knows to exist. More...
 
static struct GNUNET_CONTAINER_MultiShortmapdvlearn_map
 Map from challenges to struct LearnLaunchEntry values. More...
 
static struct LearnLaunchEntrylle_head = NULL
 Head of a DLL sorted by launch time. More...
 
static struct LearnLaunchEntrylle_tail = NULL
 Tail of a DLL sorted by launch time. More...
 
static struct GNUNET_CONTAINER_Heapvalidation_heap
 MIN Heap sorted by "next_challenge" to struct ValidationState entries sorting addresses we are aware of by when we should next try to (re)validate (or expire) them. More...
 
struct GNUNET_NAT_Handlenh
 Handle for connect to the NAT service. More...
 
static struct GNUNET_PEERSTORE_Handlepeerstore
 Database for peer's HELLOs. More...
 
static struct GNUNET_SCHEDULER_Taskdvlearn_task
 Task run to initiate DV learning. More...
 
static struct GNUNET_SCHEDULER_Taskvalidation_task
 Task to run address validation. More...
 
static struct IncomingRequestir_head
 List of incoming connections where we are trying to get a connection back established. More...
 
static struct IncomingRequestir_tail
 Tail of DLL starting at ir_head. More...
 
static unsigned int ir_total
 Length of the DLL starting at ir_head. More...
 
static unsigned long long logging_uuid_gen
 Generator of logging_uuid in struct PendingMessage. More...
 
static enum GNUNET_GenericReturnValue burst_running
 Is there a burst running? More...
 
static struct GNUNET_TIME_Absolute hello_mono_time
 Monotonic time we use for HELLOs generated at this time. More...
 
static int in_shutdown
 Indication if we have received a shutdown signal and are in the process of cleaning up. More...
 
static struct GNUNET_SCHEDULER_Taskburst_task
 The task to start the burst. More...
 
struct GNUNET_SCHEDULER_Taskburst_timeout_task
 
enum GNUNET_GenericReturnValue use_burst
 

Detailed Description

main for gnunet-service-transport

Author
Christian Grothoff

TODO: Implement next:

  • review retransmission logic, right now there is no smartness there! => congestion control, etc [PERFORMANCE-BASICS]

Optimizations-Statistics:

  • Track ACK losses based on ACK-counter [ROUTING]
  • Need to track total bandwidth per VirtualLink and adjust how frequently we send FC messages based on bandwidth-delay-product (and relation to the window size!). See OPTIMIZE-FC-BDP.
  • Consider more statistics in check_connection_quality() [FIXME-CONQ-STATISTICS]
  • Adapt available_fc_window_size, using larger values for high-bandwidth and high-latency links if we have the RAM [GOODPUT / utilization / stalls]
  • Set last_window_consum_limit promise properly based on latency and bandwidth of the respective connection [GOODPUT / utilization / stalls]

Optimizations-DV:

  • When forwarding DV learn messages, if a peer is reached that has a bidirectional link to the origin beyond 1st hop, do NOT forward it to peers other than the origin, as there is clearly a better path directly from the origin to whatever else we could reach.
  • When we passively learned DV (with unconfirmed freshness), we right now add the path to our list but with a zero path_valid_until time and only use it for unconfirmed routes. However, we could consider triggering an explicit validation mechanism ourselves, specifically routing a challenge-response message over the path [ROUTING] = if available, try to confirm unconfirmed DV paths when trying to establish virtual link for a struct IncomingRequest. (i.e. if DVH is unconfirmed, incoming requests cause us to try to validate a passively learned path (requires new message type!))

Optimizations-Fragmentation:

  • Fragments send over a reliable channel could do without the AcknowledgementUUIDP altogether, as they won't be acked! [BANDWIDTH] (-> have 2nd type of acknowledgment message; low priority, as we do not have an MTU-limited reliable communicator) [FIXME-FRAG-REL-UUID]
  • if messages are below MTU, consider adding ACKs and other stuff to the same transmission to avoid tiny messages (requires planning at receiver, and additional MST-style demultiplex at receiver!) [PACKET COUNT]

Optimizations-internals:

  • queue_send_msg by API design has to make a copy of the payload, and route_message on top of that requires a malloc/free. Change design to approximate "zero" copy better... [CPU]
  • could avoid copying body of message into each fragment and keep fragments as just pointers into the original message and only fully build fragments just before transmission (optimization, should reduce CPU and memory use) [CPU, MEMORY]

Definition in file gnunet-service-transport.c.

Macro Definition Documentation

◆ RING_BUFFER_SIZE

#define RING_BUFFER_SIZE   16

Size of ring buffer to cache CORE and forwarded DVBox messages.

Definition at line 88 of file gnunet-service-transport.c.

◆ MAX_FC_RETRANSMIT_COUNT

#define MAX_FC_RETRANSMIT_COUNT   1000

Maximum number of FC retransmissions for a running retransmission task.

Definition at line 93 of file gnunet-service-transport.c.

◆ MAX_CUMMULATIVE_ACKS

#define MAX_CUMMULATIVE_ACKS   64

Maximum number of messages we acknowledge together in one cumulative ACK.

Larger values may save a bit of bandwidth.

Definition at line 99 of file gnunet-service-transport.c.

◆ FC_NO_CHANGE_REPLY_PROBABILITY

#define FC_NO_CHANGE_REPLY_PROBABILITY   8

What is the 1:n chance that we send a Flow control response when receiving a flow control message that did not change anything for us? Basically, this is used in the case where both peers are stuck on flow control (no window changes), but one might continue sending flow control messages to the other peer as the first FC message when things stalled got lost, and then subsequently the other peer does usually not respond as nothing changed.

So to ensure that eventually the FC messages stop, we do send with 1/8th probability an FC message even if nothing changed. That prevents one peer being stuck in sending (useless) FC messages "forever".

Definition at line 113 of file gnunet-service-transport.c.

◆ IN_PACKET_SIZE_WITHOUT_MTU

#define IN_PACKET_SIZE_WITHOUT_MTU   128

What is the size we assume for a read operation in the absence of an MTU for the purpose of flow control?

Definition at line 119 of file gnunet-service-transport.c.

◆ GOODPUT_AGING_SLOTS

#define GOODPUT_AGING_SLOTS   4

Number of slots we keep of historic data for computation of goodput / message loss ratio.

Definition at line 125 of file gnunet-service-transport.c.

◆ DEFAULT_WINDOW_SIZE

#define DEFAULT_WINDOW_SIZE   (128 * 1024)

How big is the flow control window size by default; limits per-neighbour RAM utilization.

Definition at line 131 of file gnunet-service-transport.c.

◆ MAX_INCOMING_REQUEST

#define MAX_INCOMING_REQUEST   16

For how many incoming connections do we try to create a virtual link for (at the same time!).

This does NOT limit the number of incoming connections, just the number for which we are actively trying to find working addresses in the absence (!) of our own applications wanting the link to go up.

Definition at line 141 of file gnunet-service-transport.c.

◆ MAX_DV_DISCOVERY_SELECTION

#define MAX_DV_DISCOVERY_SELECTION   16

Maximum number of peers we select for forwarding DVInit messages at the same time (excluding initiator).

Definition at line 147 of file gnunet-service-transport.c.

◆ RECV_WINDOW_SIZE

#define RECV_WINDOW_SIZE   4

Window size.

How many messages to the same target do we pass to CORE without a RECV_OK in between? Small values limit throughput, large values will increase latency.

FIXME-OPTIMIZE: find out what good values are experimentally, maybe set adaptively (i.e. to observed available bandwidth).

Definition at line 157 of file gnunet-service-transport.c.

◆ MIN_DV_PATH_LENGTH_FOR_INITIATOR

#define MIN_DV_PATH_LENGTH_FOR_INITIATOR   3

Minimum number of hops we should forward DV learn messages even if they are NOT useful for us in hope of looping back to the initiator?

FIXME: allow initiator some control here instead?

Definition at line 166 of file gnunet-service-transport.c.

◆ MAX_DV_HOPS_ALLOWED

#define MAX_DV_HOPS_ALLOWED   16

Maximum DV distance allowed ever.

Definition at line 171 of file gnunet-service-transport.c.

◆ MAX_DV_LEARN_PENDING

#define MAX_DV_LEARN_PENDING   64

Maximum number of DV learning activities we may have pending at the same time.

Definition at line 177 of file gnunet-service-transport.c.

◆ MAX_DV_PATHS_TO_TARGET

#define MAX_DV_PATHS_TO_TARGET   3

Maximum number of DV paths we keep simultaneously to the same target.

Definition at line 182 of file gnunet-service-transport.c.

◆ DELAY_WARN_THRESHOLD

#define DELAY_WARN_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)

If a queue delays the next message by more than this number of seconds we log a warning.

Note: this is for testing, the value chosen here might be too aggressively low!

Definition at line 189 of file gnunet-service-transport.c.

◆ DV_FORWARD_TIMEOUT

#define DV_FORWARD_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)

If a DVBox could not be forwarded after this number of seconds we drop it.

Definition at line 196 of file gnunet-service-transport.c.

◆ DEFAULT_ACK_WAIT_DURATION

#define DEFAULT_ACK_WAIT_DURATION    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)

Default value for how long we wait for reliability ack.

Definition at line 202 of file gnunet-service-transport.c.

◆ DV_QUALITY_RTT_THRESHOLD

#define DV_QUALITY_RTT_THRESHOLD    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)

We only consider queues as "quality" connections when suppressing the generation of DV initiation messages if the latency of the queue is below this threshold.

Definition at line 210 of file gnunet-service-transport.c.

◆ DV_PATH_VALIDITY_TIMEOUT

#define DV_PATH_VALIDITY_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)

How long do we consider a DV path valid if we see no further updates on it? Note: the value chosen here might be too low!

Definition at line 217 of file gnunet-service-transport.c.

◆ BACKCHANNEL_INACTIVITY_TIMEOUT

#define BACKCHANNEL_INACTIVITY_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)

How long do we cache backchannel (struct Backtalker) information after a backchannel goes inactive?

Definition at line 224 of file gnunet-service-transport.c.

◆ DV_PATH_DISCOVERY_FREQUENCY

#define DV_PATH_DISCOVERY_FREQUENCY    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)

How long before paths expire would we like to (re)discover DV paths? Should be below DV_PATH_VALIDITY_TIMEOUT.

Definition at line 231 of file gnunet-service-transport.c.

◆ EPHEMERAL_VALIDITY

#define EPHEMERAL_VALIDITY    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)

How long are ephemeral keys valid?

Definition at line 237 of file gnunet-service-transport.c.

◆ REASSEMBLY_EXPIRATION

#define REASSEMBLY_EXPIRATION    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)

How long do we keep partially reassembled messages around before giving up?

Definition at line 243 of file gnunet-service-transport.c.

◆ FAST_VALIDATION_CHALLENGE_FREQ

#define FAST_VALIDATION_CHALLENGE_FREQ    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)

What is the fastest rate at which we send challenges if we keep learning an address (gossip, DHT, etc.)?

Definition at line 250 of file gnunet-service-transport.c.

◆ MAX_VALIDATION_CHALLENGE_FREQ

#define MAX_VALIDATION_CHALLENGE_FREQ    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)

What is the slowest rate at which we send challenges?

Definition at line 256 of file gnunet-service-transport.c.

◆ ACK_CUMMULATOR_TIMEOUT

#define ACK_CUMMULATOR_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)

How long until we forget about historic accumulators and thus reset the ACK counter? Should exceed the maximum time an active connection experiences without an ACK.

Definition at line 264 of file gnunet-service-transport.c.

◆ DV_LEARN_BASE_FREQUENCY

#define DV_LEARN_BASE_FREQUENCY   GNUNET_TIME_UNIT_MINUTES

What is the non-randomized base frequency at which we would initiate DV learn messages?

Definition at line 271 of file gnunet-service-transport.c.

◆ DV_LEARN_QUALITY_THRESHOLD

#define DV_LEARN_QUALITY_THRESHOLD   100

How many good connections (confirmed, bi-directional, not DV) do we need to have to suppress initiating DV learn messages?

Definition at line 277 of file gnunet-service-transport.c.

◆ MAX_ADDRESS_VALID_UNTIL

#define MAX_ADDRESS_VALID_UNTIL    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)

When do we forget an invalid address for sure?

Definition at line 282 of file gnunet-service-transport.c.

◆ ADDRESS_VALIDATION_LIFETIME

#define ADDRESS_VALIDATION_LIFETIME    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)

How long do we consider an address valid if we just checked?

Definition at line 288 of file gnunet-service-transport.c.

◆ MIN_DELAY_ADDRESS_VALIDATION

#define MIN_DELAY_ADDRESS_VALIDATION   GNUNET_TIME_UNIT_MILLISECONDS

What is the maximum frequency at which we do address validation? A random value between 0 and this value is added when scheduling the validation_task (both to ensure we do not validate too often, and to randomize a bit).

Definition at line 297 of file gnunet-service-transport.c.

◆ VALIDATION_RTT_BUFFER_FACTOR

#define VALIDATION_RTT_BUFFER_FACTOR   3

How many network RTTs before an address validation expires should we begin trying to revalidate? (Note that the RTT used here is the one that we experienced during the last validation, not necessarily the latest RTT observed).

Definition at line 305 of file gnunet-service-transport.c.

◆ COMMUNICATOR_TOTAL_QUEUE_LIMIT

#define COMMUNICATOR_TOTAL_QUEUE_LIMIT   512

How many messages can we have pending for a given communicator process before we start to throttle that communicator?

Used if a communicator might be CPU-bound and cannot handle the traffic.

Definition at line 313 of file gnunet-service-transport.c.

◆ QUEUE_LENGTH_LIMIT

#define QUEUE_LENGTH_LIMIT   32

How many messages can we have pending for a given queue (queue to a particular peer via a communicator) process before we start to throttle that queue?

Definition at line 320 of file gnunet-service-transport.c.

◆ QUEUE_ENTRY_TIMEOUT

#define QUEUE_ENTRY_TIMEOUT    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)

Definition at line 325 of file gnunet-service-transport.c.

◆ RTT_DIFF

Difference of the average RTT for the DistanceVector calculate by us and the target we are willing to accept for starting the burst.

Definition at line 332 of file gnunet-service-transport.c.

Typedef Documentation

◆ DVMessageHandler

typedef void(* DVMessageHandler) (void *cls, struct Neighbour *next_hop, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)

Function to call to further operate on the now DV encapsulated message hdr, forwarding it via next_hop under respect of options.

Parameters
clsclosure
next_hopnext hop of the DV path
hdrencapsulated message, technically a struct TransportDFBoxMessage
optionsoptions of the original message

Definition at line 5134 of file gnunet-service-transport.c.

Enumeration Type Documentation

◆ ClientType

enum ClientType

What type of client is the struct TransportClient about?

Enumerator
CT_NONE 

We do not know yet (client is fresh).

CT_CORE 

Is the CORE service, we need to forward traffic to it.

CT_MONITOR 

It is a monitor, forward monitor data.

CT_COMMUNICATOR 

It is a communicator, use for communication.

CT_APPLICATION 

"Application" telling us where to connect (i.e.

TOPOLOGY, DHT or CADET).

Definition at line 1022 of file gnunet-service-transport.c.

1023{
1027 CT_NONE = 0,
1028
1032 CT_CORE = 1,
1033
1037 CT_MONITOR = 2,
1038
1042 CT_COMMUNICATOR = 3,
1043
1047 CT_APPLICATION = 4
1048};
@ CT_APPLICATION
"Application" telling us where to connect (i.e.
@ CT_MONITOR
It is a monitor, forward monitor data.
@ CT_NONE
We do not know yet (client is fresh).
@ CT_CORE
Is the CORE service, we need to forward traffic to it.
@ CT_COMMUNICATOR
It is a communicator, use for communication.

◆ RouteMessageOptions

Which transmission options are allowable for transmission? Interpreted bit-wise!

Enumerator
RMO_NONE 

Only confirmed, non-DV direct neighbours.

RMO_DV_ALLOWED 

We are allowed to use DV routing for this hdr.

RMO_UNCONFIRMED_ALLOWED 

We are allowed to use unconfirmed queues or DV routes for this message.

RMO_ANYTHING_GOES 

Reliable and unreliable, DV and non-DV are all acceptable.

RMO_REDUNDANT 

If we have multiple choices, it is OK to send this message over multiple channels at the same time to improve loss tolerance.

(We do at most 2 transmissions.)

Definition at line 1055 of file gnunet-service-transport.c.

1056{
1060 RMO_NONE = 0,
1061
1065 RMO_DV_ALLOWED = 1,
1066
1071
1076
1082 RMO_REDUNDANT = 4
1083};
@ RMO_UNCONFIRMED_ALLOWED
We are allowed to use unconfirmed queues or DV routes for this message.
@ RMO_DV_ALLOWED
We are allowed to use DV routing for this hdr.
@ RMO_REDUNDANT
If we have multiple choices, it is OK to send this message over multiple channels at the same time to...
@ RMO_NONE
Only confirmed, non-DV direct neighbours.
@ RMO_ANYTHING_GOES
Reliable and unreliable, DV and non-DV are all acceptable.

◆ PendingMessageType

Types of different pending messages.

Enumerator
PMT_CORE 

Ordinary message received from the CORE service.

PMT_FRAGMENT_BOX 

Fragment box.

PMT_RELIABILITY_BOX 

Reliability box.

PMT_DV_BOX 

Pending message created during forward_dv_box().

Definition at line 2205 of file gnunet-service-transport.c.

2206{
2210 PMT_CORE = 0,
2211
2215 PMT_FRAGMENT_BOX = 1,
2216
2221
2225 PMT_DV_BOX = 3
2226};
@ PMT_FRAGMENT_BOX
Fragment box.
@ PMT_DV_BOX
Pending message created during forward_dv_box().
@ PMT_CORE
Ordinary message received from the CORE service.
@ PMT_RELIABILITY_BOX
Reliability box.

Function Documentation

◆ get_age()

static unsigned int get_age ( )
static

Get an offset into the transmission history buffer for struct PerformanceData.

Note that the caller must perform the required modulo GOODPUT_AGING_SLOTS operation before indexing into the array!

An 'age' lasts 15 minute slots.

Returns
current age of the world

Definition at line 3081 of file gnunet-service-transport.c.

3082{
3083 struct GNUNET_TIME_Absolute now;
3084
3085 now = GNUNET_TIME_absolute_get ();
3086 return now.abs_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us / 15;
3087}
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
#define GNUNET_TIME_UNIT_MINUTES
One minute.
Time for absolute times used by GNUnet, in microseconds.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TIME_absolute_get(), and GNUNET_TIME_UNIT_MINUTES.

Referenced by update_performance_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_incoming_request()

static void free_incoming_request ( struct IncomingRequest ir)
static

Release ir data structure.

Parameters
irdata structure to release

Definition at line 3096 of file gnunet-service-transport.c.

3097{
3099 GNUNET_assert (ir_total > 0);
3100 ir_total--;
3101 if (NULL != ir->nc)
3103 ir->nc = NULL;
3104 GNUNET_free (ir);
3105}
static struct IncomingRequest * ir_tail
Tail of DLL starting at ir_head.
static unsigned int ir_total
Length of the DLL starting at ir_head.
static struct IncomingRequest * ir_head
List of incoming connections where we are trying to get a connection back established.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_PEERSTORE_monitor_stop(struct GNUNET_PEERSTORE_Monitor *zm)
Stop monitoring.
struct GNUNET_PEERSTORE_Monitor * nc
Notify context for new HELLOs.

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PEERSTORE_monitor_stop(), ir_head, ir_tail, ir_total, and IncomingRequest::nc.

Referenced by do_shutdown(), and handle_validation_challenge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_pending_acknowledgement()

static void free_pending_acknowledgement ( struct PendingAcknowledgement pa)
static

Release pa data structure.

Parameters
padata structure to release

Definition at line 3114 of file gnunet-service-transport.c.

3115{
3116 struct Queue *q = pa->queue;
3117 struct PendingMessage *pm = pa->pm;
3118 struct DistanceVectorHop *dvh = pa->dvh;
3119
3121 "free_pending_acknowledgement\n");
3122 if (NULL != q)
3123 {
3124 GNUNET_CONTAINER_MDLL_remove (queue, q->pa_head, q->pa_tail, pa);
3125 pa->queue = NULL;
3126 }
3127 if (NULL != pm)
3128 {
3130 "remove pa from message\n");
3132 "remove pa from message %" PRIu64 "\n",
3133 pm->logging_uuid);
3135 "remove pa from message %u\n",
3136 pm->pmt);
3138 "remove pa from message %s\n",
3140 GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa);
3141 pa->pm = NULL;
3142 }
3143 if (NULL != dvh)
3144 {
3145 GNUNET_CONTAINER_MDLL_remove (dvh, dvh->pa_head, dvh->pa_tail, pa);
3146 pa->queue = NULL;
3147 }
3150 &pa->ack_uuid.value,
3151 pa));
3152 GNUNET_free (pa);
3153}
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static struct GNUNET_CONTAINER_MultiUuidmap * pending_acks
Map of pending acknowledgements, mapping struct AcknowledgementUUID to a struct PendingAcknowledgemen...
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_remove(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_log(kind,...)
@ GNUNET_YES
const char * GNUNET_uuid2s(const struct GNUNET_Uuid *uuid)
Convert a UUID to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_Uuid value
The UUID value.
One possible hop towards a DV target.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs that used our path.
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs that used our path.
struct AcknowledgementUUIDP ack_uuid
Unique identifier for this transmission operation.
struct PendingMessage * pm
Message that was transmitted, may be NULL if the message was ACKed via another channel.
struct Queue * queue
Queue used for transmission, NULL if the queue has been destroyed (which may happen before we get an ...
struct DistanceVectorHop * dvh
Distance vector path chosen for this transmission, NULL if transmission was to a direct neighbour OR ...
List containing all messages that are yet to be send.
Handle for a queue.

References PendingAcknowledgement::ack_uuid, PendingAcknowledgement::dvh, GNUNET_assert, GNUNET_CONTAINER_MDLL_remove, GNUNET_CONTAINER_multiuuidmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_uuid2s(), GNUNET_YES, DistanceVectorHop::pa_head, DistanceVectorHop::pa_tail, pending_acks, PendingAcknowledgement::pm, pm, q, queue(), PendingAcknowledgement::queue, and AcknowledgementUUIDP::value.

Referenced by free_pending_ack_cb(), and handle_acknowledged().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_fragment_tree()

static void free_fragment_tree ( struct PendingMessage root)
static

Free fragment tree below root, excluding root itself.

FIXME: this does NOT seem to have the intended semantics based on how this is called. Seems we generally DO expect root to be free'ed itself as well!

Parameters
rootroot of the tree to free

Definition at line 3165 of file gnunet-service-transport.c.

3166{
3167 struct PendingMessage *frag;
3168
3169 while (NULL != (frag = root->head_frag))
3170 {
3171 struct PendingAcknowledgement *pa;
3172
3173 free_fragment_tree (frag);
3174 while (NULL != (pa = frag->pa_head))
3175 {
3176 GNUNET_CONTAINER_MDLL_remove (pm, frag->pa_head, frag->pa_tail, pa);
3177 pa->pm = NULL;
3178 }
3179 GNUNET_CONTAINER_MDLL_remove (frag, root->head_frag, root->tail_frag, frag);
3180 if (NULL != frag->qe)
3181 {
3182 GNUNET_assert (frag == frag->qe->pm);
3183 frag->qe->pm = NULL;
3184 }
3186 "Free frag %p\n",
3187 frag);
3188 GNUNET_free (frag);
3189 }
3190}
static void free_fragment_tree(struct PendingMessage *root)
Free fragment tree below root, excluding root itself.
Data structure kept when we are waiting for an acknowledgement.
struct PendingMessage * tail_frag
Tail of a MDLL of fragments created for this core message.
struct QueueEntry * qe
Set to non-NULL value if this message is currently being given to a communicator and we are awaiting ...
struct PendingMessage * head_frag
Head of a MDLL of fragments created for this core message.
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs for this pending message.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs for this pending message.
struct PendingMessage * pm
Pending message this entry is for, or NULL for none.

References free_fragment_tree(), GNUNET_assert, GNUNET_CONTAINER_MDLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, PendingMessage::head_frag, PendingMessage::pa_head, PendingMessage::pa_tail, PendingAcknowledgement::pm, QueueEntry::pm, pm, PendingMessage::qe, and PendingMessage::tail_frag.

Referenced by free_fragment_tree(), and free_pending_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_pending_message()

static void free_pending_message ( struct PendingMessage pm)
static

Release memory associated with pm and remove pm from associated data structures.

pm must be a top-level pending message and not a fragment in the tree. The entire tree is freed (if applicable).

Parameters
pmthe pending message to free

Definition at line 3201 of file gnunet-service-transport.c.

3202{
3203 struct TransportClient *tc = pm->client;
3204 struct VirtualLink *vl = pm->vl;
3205 struct PendingAcknowledgement *pa;
3206
3208 "Freeing pm %p\n",
3209 pm);
3210 if (NULL != tc)
3211 {
3213 tc->details.core.pending_msg_head,
3214 tc->details.core.pending_msg_tail,
3215 pm);
3216 }
3217 if ((NULL != vl) && (NULL == pm->frag_parent))
3218 {
3220 "Removing pm %" PRIu64 "\n",
3221 pm->logging_uuid);
3223 vl->pending_msg_head,
3224 vl->pending_msg_tail,
3225 pm);
3226 }
3227 else if (NULL != pm->frag_parent && PMT_DV_BOX != pm->pmt)
3228 {
3229 struct PendingMessage *root = pm->frag_parent;
3230
3231 while (NULL != root->frag_parent && PMT_DV_BOX != root->pmt)
3232 root = root->frag_parent;
3233
3234 root->frag_count--;
3235 }
3236 while (NULL != (pa = pm->pa_head))
3237 {
3238 if (NULL == pa)
3240 "free pending pa null\n");
3241 if (NULL == pm->pa_tail)
3243 "free pending pa_tail null\n");
3244 if (NULL == pa->prev_pa)
3246 "free pending pa prev null\n");
3247 if (NULL == pa->next_pa)
3249 "free pending pa next null\n");
3250 GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa);
3251 pa->pm = NULL;
3252 }
3253
3255 if (NULL != pm->qe)
3256 {
3257 GNUNET_assert (pm == pm->qe->pm);
3258 pm->qe->pm = NULL;
3259 }
3260 if (NULL != pm->bpm)
3261 {
3262 free_fragment_tree (pm->bpm);
3263 if (NULL != pm->bpm->qe)
3264 {
3265 struct QueueEntry *qe = pm->bpm->qe;
3266
3267 qe->pm = NULL;
3268 }
3269 GNUNET_free (pm->bpm);
3270 }
3271
3272 GNUNET_free (pm);
3274 "Freeing pm done\n");
3275}
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:430
struct PendingAcknowledgement * next_pa
Pointers for the DLL of all pending acknowledgements.
struct PendingAcknowledgement * prev_pa
Pointers for the DLL of all pending acknowledgements.
struct PendingMessage * frag_parent
Our parent in the fragmentation tree.
enum PendingMessageType pmt
Type of the pending message.
uint16_t frag_count
How many fragments do we have?
Entry identifying transmission in one of our struct Queue which still awaits an ACK.
Client connected to the transport service.

References PendingMessage::frag_count, PendingMessage::frag_parent, free_fragment_tree(), GNUNET_assert, GNUNET_CONTAINER_MDLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, PendingAcknowledgement::next_pa, VirtualLink::pending_msg_head, VirtualLink::pending_msg_tail, PendingAcknowledgement::pm, pm, PendingMessage::pmt, PMT_DV_BOX, PendingAcknowledgement::prev_pa, qe, and tc.

Referenced by client_send_response(), completed_pending_message(), free_virtual_link(), and transmit_on_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_reassembly_context()

static void free_reassembly_context ( struct ReassemblyContext rc)
static

Free rc.

Parameters
rcdata structure to free

Definition at line 3284 of file gnunet-service-transport.c.

3285{
3286 struct VirtualLink *vl = rc->virtual_link;
3287
3291 rc->msg_uuid.uuid,
3292 rc));
3293 GNUNET_free (rc);
3294}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
@ GNUNET_OK
uint64_t uuid
Unique value, generated by incrementing the message_uuid_ctr of struct Neighbour.
struct GNUNET_CONTAINER_HeapNode * hn
Entry in the reassembly heap (sorted by expiration).
struct MessageUUIDP msg_uuid
Original message ID for of the message that all the fragments belong to.
struct VirtualLink * virtual_link
Which neighbour is this context for?

References GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_free, GNUNET_OK, ReassemblyContext::hn, ReassemblyContext::msg_uuid, VirtualLink::reassembly_map, MessageUUIDP::uuid, and ReassemblyContext::virtual_link.

Referenced by free_reassembly_cb(), handle_fragment_box(), and reassembly_cleanup_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reassembly_cleanup_task()

static void reassembly_cleanup_task ( void *  cls)
static

Task run to clean up reassembly context of a neighbour that have expired.

Parameters
clsa struct Neighbour

Definition at line 3303 of file gnunet-service-transport.c.

3304{
3305 struct VirtualLink *vl = cls;
3306 struct ReassemblyContext *rc;
3307
3308 vl->reassembly_timeout_task = NULL;
3309 while (NULL != (rc = GNUNET_CONTAINER_heap_peek (vl->reassembly_heap)))
3310 {
3312 .rel_value_us)
3313 {
3315 continue;
3316 }
3321 vl);
3322 return;
3323 }
3324}
static void reassembly_cleanup_task(void *cls)
Task run to clean up reassembly context of a neighbour that have expired.
static void free_reassembly_context(struct ReassemblyContext *rc)
Free rc.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1253
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:406
uint64_t rel_value_us
The actual value.
Information we keep for a message that we are reassembling.
struct GNUNET_TIME_Absolute reassembly_timeout
At what time will we give up reassembly of this message?

References free_reassembly_context(), GNUNET_assert, GNUNET_CONTAINER_heap_peek(), GNUNET_SCHEDULER_add_at(), GNUNET_TIME_absolute_get_remaining(), reassembly_cleanup_task(), VirtualLink::reassembly_heap, ReassemblyContext::reassembly_timeout, VirtualLink::reassembly_timeout_task, and GNUNET_TIME_Relative::rel_value_us.

Referenced by handle_fragment_box(), and reassembly_cleanup_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_reassembly_cb()

static int free_reassembly_cb ( void *  cls,
uint32_t  key,
void *  value 
)
static

function called to free_reassembly_context().

Parameters
clsNULL
keyunused
valuea struct ReassemblyContext to free
Returns
GNUNET_OK (continue iteration)

Definition at line 3336 of file gnunet-service-transport.c.

3337{
3338 struct ReassemblyContext *rc = value;
3339
3340 (void) cls;
3341 (void) key;
3343 return GNUNET_OK;
3344}
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.

References free_reassembly_context(), GNUNET_OK, key, and value.

Referenced by free_virtual_link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_virtual_link()

static void free_virtual_link ( struct VirtualLink vl)
static

Free virtual link.

Parameters
vllink data to free

Definition at line 3353 of file gnunet-service-transport.c.

3354{
3355 struct PendingMessage *pm;
3356 struct CoreSentContext *csc;
3357
3359 "free virtual link %p\n",
3360 vl);
3361
3362 if (NULL != vl->reassembly_map)
3363 {
3366 NULL);
3368 vl->reassembly_map = NULL;
3370 vl->reassembly_heap = NULL;
3371 }
3372 if (NULL != vl->reassembly_timeout_task)
3373 {
3376 }
3377 while (NULL != (pm = vl->pending_msg_head))
3381 if (NULL != vl->visibility_task)
3382 {
3384 vl->visibility_task = NULL;
3385 }
3386 if (NULL != vl->fc_retransmit_task)
3387 {
3389 vl->fc_retransmit_task = NULL;
3390 }
3391 while (NULL != (csc = vl->csc_head))
3392 {
3394 GNUNET_assert (vl == csc->vl);
3395 csc->vl = NULL;
3396 }
3397 GNUNET_break (NULL == vl->n);
3398 GNUNET_break (NULL == vl->dv);
3399 GNUNET_free (vl);
3400}
static void free_pending_message(struct PendingMessage *pm)
Release memory associated with pm and remove pm from associated data structures.
static int free_reassembly_cb(void *cls, uint32_t key, void *value)
function called to free_reassembly_context().
static struct GNUNET_CONTAINER_MultiPeerMap * links
Map from PIDs to struct VirtualLink entries describing links CORE knows to exist.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
Closure for core_env_sent_cb.
struct VirtualLink * vl
Virtual link this is about.

References VirtualLink::csc_head, VirtualLink::csc_tail, VirtualLink::dv, VirtualLink::fc_retransmit_task, free_pending_message(), free_reassembly_cb(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_YES, links, VirtualLink::n, VirtualLink::pending_msg_head, pm, VirtualLink::reassembly_heap, VirtualLink::reassembly_map, VirtualLink::reassembly_timeout_task, VirtualLink::target, VirtualLink::visibility_task, and CoreSentContext::vl.

Referenced by check_link_down(), free_dv_route(), and free_neighbour().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_validation_state()

static void free_validation_state ( struct ValidationState vs)
static

Free validation state.

Parameters
vsvalidation state to free

Definition at line 3409 of file gnunet-service-transport.c.

3410{
3411 if (NULL != vs->revalidation_task)
3412 {
3413 GNUNET_SCHEDULER_cancel (vs->revalidation_task);
3414 vs->revalidation_task = NULL;
3415 }
3416 /*memcpy (&hkey,
3417 &hc,
3418 sizeof (hkey));*/
3420 "Remove key %s for address %s map size %u contains %u during freeing state\n",
3421 GNUNET_h2s (&vs->hc),
3422 vs->address,
3425 &vs->hc));
3428 GNUNET_YES ==
3431 vs->hn = NULL;
3432 if (NULL != vs->sc)
3433 {
3435 "store cancel\n");
3437 vs->sc = NULL;
3438 }
3439 GNUNET_free (vs->address);
3440 GNUNET_free (vs);
3441}
static struct GNUNET_CONTAINER_MultiHashMap * revalidation_map
Map from addresses to struct ValidationState entries describing addresses we are aware of and their v...
static struct GNUNET_CONTAINER_MultiPeerMap * validation_map
Map from PIDs to struct ValidationState entries describing addresses we are aware of and their validi...
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
struct GNUNET_PeerIdentity pid
For which peer is address to be validated (or possibly valid)? Serves as key in the validation_map.

References GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, ValidationState::pid, revalidation_map, and validation_map.

Referenced by free_validation_state_cb(), and validation_start_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_neighbour()

static struct Neighbour * lookup_neighbour ( const struct GNUNET_PeerIdentity pid)
static

Lookup neighbour for peer pid.

Parameters
pidneighbour to look for
Returns
NULL if we do not have this peer as a neighbour

Definition at line 3451 of file gnunet-service-transport.c.

3452{
3454}
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Map from PIDs to struct Neighbour entries.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.

References GNUNET_CONTAINER_multipeermap_get(), neighbours, and pid.

Referenced by find_queue(), forward_dv_learn(), handle_add_queue_message(), handle_communicator_backchannel(), handle_dv_box(), handle_dv_learn(), handle_validation_challenge(), learn_dv_path(), route_control_message_without_fc(), and transmit_cummulative_ack_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_virtual_link()

static struct VirtualLink * lookup_virtual_link ( const struct GNUNET_PeerIdentity pid)
static

Lookup virtual link for peer pid.

Parameters
pidvirtual link to look for
Returns
NULL if we do not have this peer as a virtual link

Definition at line 3464 of file gnunet-service-transport.c.

3465{
3467}

References GNUNET_CONTAINER_multipeermap_get(), links, and pid.

Referenced by activate_core_visible_dv_path(), check_vl_transmission(), forward_dv_learn(), free_queue(), handle_client_recv_ok(), handle_client_send(), handle_communicator_backchannel(), handle_flow_control(), handle_fragment_box(), handle_raw_message(), handle_validation_challenge(), handle_validation_response(), and transmit_cummulative_ack_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_distance_vector_hop()

static void free_distance_vector_hop ( struct DistanceVectorHop dvh)
static

Free a dvh.

Callers MAY want to check if this was the last path to the target, and if so call free_dv_route to also free the associated DV entry in dv_routes (if not, the associated scheduler job should eventually take care of it).

Parameters
dvhhop to free

Definition at line 3513 of file gnunet-service-transport.c.

3514{
3515 struct Neighbour *n = dvh->next_hop;
3516 struct DistanceVector *dv = dvh->dv;
3517 struct PendingAcknowledgement *pa;
3518
3519 while (NULL != (pa = dvh->pa_head))
3520 {
3522 pa->dvh = NULL;
3523 }
3524 GNUNET_CONTAINER_MDLL_remove (neighbour, n->dv_head, n->dv_tail, dvh);
3526 GNUNET_free (dvh);
3527}
struct Neighbour * next_hop
What would be the next hop to target?
struct DistanceVector * dv
Distance vector entry this hop belongs with.
Entry in our dv_routes table, representing a (set of) distance vector routes to a particular peer.
struct DistanceVectorHop * dv_head
Known paths to target.
struct DistanceVectorHop * dv_tail
Known paths to target.
A neighbour that at least one communicator is connected to.
struct DistanceVectorHop * dv_tail
Tail of MDLL of DV hops that have this neighbour as next hop.
struct DistanceVectorHop * dv_head
Head of MDLL of DV hops that have this neighbour as next hop.

References DistanceVectorHop::dv, DistanceVector::dv_head, Neighbour::dv_head, DistanceVector::dv_tail, Neighbour::dv_tail, PendingAcknowledgement::dvh, GNUNET_CONTAINER_MDLL_remove, GNUNET_free, DistanceVectorHop::next_hop, DistanceVectorHop::pa_head, and DistanceVectorHop::pa_tail.

Referenced by free_dv_route(), free_neighbour(), and path_cleanup_cb().

Here is the caller graph for this function:

◆ check_link_down()

static void check_link_down ( void *  cls)
static

Task run to check whether the hops of the cls still are validated, or if we need to core about disconnection.

Parameters
clsa struct VirtualLink

Definition at line 3955 of file gnunet-service-transport.c.

3956{
3957 struct VirtualLink *vl = cls;
3958 struct DistanceVector *dv = vl->dv;
3959 struct Neighbour *n = vl->n;
3960 struct GNUNET_TIME_Absolute dvh_timeout;
3961 struct GNUNET_TIME_Absolute q_timeout;
3962
3964 "Checking if link is down\n");
3965 vl->visibility_task = NULL;
3966 dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
3967 if (NULL != dv)
3968 {
3969 for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
3970 pos = pos->next_dv)
3971 dvh_timeout = GNUNET_TIME_absolute_max (dvh_timeout,
3972 pos->path_valid_until);
3973 if (0 == GNUNET_TIME_absolute_get_remaining (dvh_timeout).rel_value_us)
3974 {
3975 vl->dv->vl = NULL;
3976 vl->dv = NULL;
3977 }
3978 }
3979 q_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
3980 for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
3981 q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until);
3982 if (0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us)
3983 {
3984 vl->n->vl = NULL;
3985 vl->n = NULL;
3986 }
3987 if ((NULL == vl->n) && (NULL == vl->dv))
3988 {
3990 free_virtual_link (vl);
3991 return;
3992 }
3993 vl->visibility_task =
3994 GNUNET_SCHEDULER_add_at (GNUNET_TIME_absolute_max (q_timeout, dvh_timeout),
3996 vl);
3997}
static void cores_send_disconnect_info(const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.
static void free_virtual_link(struct VirtualLink *vl)
Free virtual link.
static void check_link_down(void *cls)
Task run to check whether the hops of the cls still are validated, or if we need to core about discon...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the maximum of two absolute time values.
Definition: time.c:368
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct DistanceVectorHop * next_dv
Kept in a MDLL, sorted by timeout.
struct VirtualLink * vl
Do we have a confirmed working queue and are thus visible to CORE? If so, this is the virtual link,...
struct VirtualLink * vl
Do we have a confirmed working queue and are thus visible to CORE? If so, this is the virtual link,...
struct Queue * queue_head
Head of DLL of queues to this peer.

References check_link_down(), cores_send_disconnect_info(), VirtualLink::dv, DistanceVector::dv_head, free_virtual_link(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_add_at(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_max(), GNUNET_TIME_UNIT_ZERO_ABS, VirtualLink::n, DistanceVectorHop::next_dv, q, Neighbour::queue_head, VirtualLink::target, VirtualLink::visibility_task, DistanceVector::vl, and Neighbour::vl.

Referenced by activate_core_visible_dv_path(), check_link_down(), free_dv_route(), free_neighbour(), free_queue(), and handle_validation_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cores_send_disconnect_info()

static void cores_send_disconnect_info ( const struct GNUNET_PeerIdentity pid)
static

Send message to CORE clients that we lost a connection.

Parameters
pidpeer the connection was for

Definition at line 3546 of file gnunet-service-transport.c.

3547{
3549 "Informing CORE clients about disconnect from %s\n",
3550 GNUNET_i2s (pid));
3551 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3552 {
3553 struct GNUNET_MQ_Envelope *env;
3554 struct DisconnectInfoMessage *dim;
3555
3556 if (CT_CORE != tc->type)
3557 continue;
3559 dim->peer = *pid;
3560 GNUNET_MQ_send (tc->mq, env);
3561 }
3562}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
uint32_t dim
Definition: gnunet_pq_lib.h:3
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
Message from the transport service to the library informing about disconnects.
Definition: transport.h:120

References clients_head, CT_CORE, dim, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT, GNUNET_MQ_msg, GNUNET_MQ_send(), pid, and tc.

Referenced by check_link_down(), free_dv_route(), and free_neighbour().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_dv_route()

static void free_dv_route ( struct DistanceVector dv)
static

Free entry in dv_routes.

First frees all hops to the target, and if there are no entries left, frees dv as well.

Parameters
dvroute to free

Definition at line 3572 of file gnunet-service-transport.c.

3573{
3574 struct DistanceVectorHop *dvh;
3575
3576 while (NULL != (dvh = dv->dv_head))
3578 if (NULL == dv->dv_head)
3579 {
3580 struct VirtualLink *vl;
3581
3583 GNUNET_YES ==
3585 if (NULL != (vl = dv->vl))
3586 {
3587 GNUNET_assert (dv == vl->dv);
3588 vl->dv = NULL;
3589 if (NULL == vl->n)
3590 {
3592 free_virtual_link (vl);
3593 }
3594 else
3595 {
3598 }
3599 dv->vl = NULL;
3600 }
3601
3602 if (NULL != dv->timeout_task)
3603 {
3605 dv->timeout_task = NULL;
3606 }
3607 GNUNET_free (dv->km);
3608 GNUNET_free (dv);
3609 }
3610}
static void free_distance_vector_hop(struct DistanceVectorHop *dvh)
Free a dvh.
static struct GNUNET_CONTAINER_MultiPeerMap * dv_routes
Map from PIDs to struct DistanceVector entries describing known paths to the peer.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1303
struct GNUNET_ShortHashCode * km
Master secret for the setup of the Key material for the backchannel.
struct GNUNET_PeerIdentity target
To which peer is this a route?
struct GNUNET_SCHEDULER_Task * timeout_task
Task scheduled to purge expired paths from dv_head MDLL.

References check_link_down(), cores_send_disconnect_info(), VirtualLink::dv, DistanceVectorHop::dv, DistanceVector::dv_head, dv_routes, free_distance_vector_hop(), free_virtual_link(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, DistanceVector::km, VirtualLink::n, DistanceVector::target, DistanceVector::timeout_task, VirtualLink::visibility_task, and DistanceVector::vl.

Referenced by free_dv_routes_cb(), free_neighbour(), and path_cleanup_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_monitor()

static void notify_monitor ( struct TransportClient tc,
const struct GNUNET_PeerIdentity peer,
const char *  address,
enum GNUNET_NetworkType  nt,
const struct MonitorEvent me 
)
static

Notify monitor tc about an event.

That tc cares about the event has already been checked.

Send tc information in me about a peer's status with respect to some address to all monitors that care.

Parameters
tcmonitor to inform
peerpeer the information is about
addressaddress the information is about
ntnetwork type associated with address
medetailed information to transmit

Definition at line 3627 of file gnunet-service-transport.c.

3632{
3633 struct GNUNET_MQ_Envelope *env;
3635 size_t addr_len = strlen (address) + 1;
3636
3638 addr_len,
3640 md->nt = htonl ((uint32_t) nt);
3641 md->peer = *peer;
3642 md->last_validation = GNUNET_TIME_absolute_hton (me->last_validation);
3643 md->valid_until = GNUNET_TIME_absolute_hton (me->valid_until);
3644 md->next_validation = GNUNET_TIME_absolute_hton (me->next_validation);
3645 md->rtt = GNUNET_TIME_relative_hton (me->rtt);
3646 md->cs = htonl ((uint32_t) me->cs);
3647 md->num_msg_pending = htonl (me->num_msg_pending);
3648 md->num_bytes_pending = htonl (me->num_bytes_pending);
3649 memcpy (&md[1], address, addr_len);
3650 GNUNET_MQ_send (tc->mq, env);
3651}
static char * address
GNS address for this phone.
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA
Message sent to indicate to a monitor about events.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:620
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
uint32_t num_msg_pending
Messages pending (in NBO).
Definition: transport.h:766
struct GNUNET_PeerIdentity peer
Target identifier.
Definition: transport.h:744
struct GNUNET_TIME_AbsoluteNBO valid_until
Definition: transport.h:750
struct GNUNET_TIME_AbsoluteNBO last_validation
Definition: transport.h:749
uint32_t num_bytes_pending
Bytes pending (in NBO).
Definition: transport.h:771
struct GNUNET_TIME_AbsoluteNBO next_validation
Definition: transport.h:751
uint32_t nt
Network type (an enum GNUNET_NetworkType in NBO).
Definition: transport.h:739
struct GNUNET_TIME_RelativeNBO rtt
Current round-trip time estimate.
Definition: transport.h:756
uint32_t cs
Connection status (in NBO).
Definition: transport.h:761

References address, GNUNET_TRANSPORT_MonitorData::cs, env, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_hton(), GNUNET_TRANSPORT_MonitorData::last_validation, me, GNUNET_TRANSPORT_MonitorData::next_validation, nt, GNUNET_TRANSPORT_MonitorData::nt, GNUNET_TRANSPORT_MonitorData::num_bytes_pending, GNUNET_TRANSPORT_MonitorData::num_msg_pending, GNUNET_TRANSPORT_MonitorData::peer, GNUNET_TRANSPORT_MonitorData::rtt, tc, and GNUNET_TRANSPORT_MonitorData::valid_until.

Referenced by notify_client_queues(), and notify_monitors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_monitors()

static void notify_monitors ( const struct GNUNET_PeerIdentity peer,
const char *  address,
enum GNUNET_NetworkType  nt,
const struct MonitorEvent me 
)
static

Send information in me about a peer's status with respect to some address to all monitors that care.

Parameters
peerpeer the information is about
addressaddress the information is about
ntnetwork type associated with address
medetailed information to transmit

Definition at line 3664 of file gnunet-service-transport.c.

3668{
3669 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3670 {
3671 if (CT_MONITOR != tc->type)
3672 continue;
3673 if (tc->details.monitor.one_shot)
3674 continue;
3675 if ((GNUNET_NO == GNUNET_is_zero (&tc->details.monitor.peer)) &&
3676 (0 != GNUNET_memcmp (&tc->details.monitor.peer, peer)))
3677 continue;
3678 notify_monitor (tc, peer, address, nt, me);
3679 }
3680}
static void notify_monitor(struct TransportClient *tc, const struct GNUNET_PeerIdentity *peer, const char *address, enum GNUNET_NetworkType nt, const struct MonitorEvent *me)
Notify monitor tc about an event.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_NO

References address, clients_head, CT_MONITOR, GNUNET_is_zero, GNUNET_memcmp, GNUNET_NO, me, notify_monitor(), nt, GNUNET_TRANSPORT_MonitorData::peer, and tc.

Referenced by free_queue(), and handle_add_queue_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Called whenever a client connects.

Allocates our data structures associated with that client.

Parameters
clsclosure, NULL
clientidentification of the client
mqmessage queue for the client
Returns
our struct TransportClient

Definition at line 3693 of file gnunet-service-transport.c.

3696{
3697 struct TransportClient *tc;
3698
3699 (void) cls;
3700 tc = GNUNET_new (struct TransportClient);
3701 tc->client = client;
3702 tc->mq = mq;
3705 "Client %p of type %u connected\n",
3706 tc,
3707 tc->type);
3708 return tc;
3709}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
Handle to the client.

References TransportClient::client, clients_head, clients_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, mq, and tc.

◆ remove_global_addresses()

static enum GNUNET_GenericReturnValue remove_global_addresses ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Definition at line 3713 of file gnunet-service-transport.c.

3716{
3717 struct TransportGlobalNattedAddress *tgna = value;
3718 (void) cls;
3719
3720 GNUNET_free (tgna);
3721
3722 return GNUNET_OK;
3723}

References GNUNET_free, GNUNET_OK, and value.

Referenced by free_neighbour().

Here is the caller graph for this function:

◆ free_neighbour()

static void free_neighbour ( struct Neighbour neighbour,
enum GNUNET_GenericReturnValue  drop_link 
)
static

Release memory used by neighbour.

Parameters
neighbourneighbour entry to free
drop_linkflag to decide whether to drop its virtual link

Definition at line 3733 of file gnunet-service-transport.c.

3735{
3736 struct DistanceVectorHop *dvh;
3737 struct VirtualLink *vl;
3738
3739 GNUNET_assert (NULL == neighbour->queue_head);
3742 &neighbour->pid,
3743 neighbour));
3745 "Freeing neighbour\n");
3748 NULL);
3750 while (NULL != (dvh = neighbour->dv_head))
3751 {
3752 struct DistanceVector *dv = dvh->dv;
3753
3755 if (NULL == dv->dv_head)
3756 free_dv_route (dv);
3757 }
3758 if (NULL != neighbour->get)
3759 {
3761 neighbour->get = NULL;
3762 }
3763 if (NULL != neighbour->sc)
3764 {
3766 "store cancel\n");
3767 GNUNET_PEERSTORE_store_cancel (neighbour->sc);
3768 neighbour->sc = NULL;
3769 }
3770 if (NULL != (vl = neighbour->vl))
3771 {
3772 GNUNET_assert (neighbour == vl->n);
3773 vl->n = NULL;
3774 if ((GNUNET_YES == drop_link) || (NULL == vl->dv))
3775 {
3778 }
3779 else
3780 {
3783 }
3784 neighbour->vl = NULL;
3785 }
3786 GNUNET_free (neighbour);
3787}
static enum GNUNET_GenericReturnValue remove_global_addresses(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
static void free_dv_route(struct DistanceVector *dv)
Free entry in dv_routes.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_PEERSTORE_iteration_stop(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iteration.
struct GNUNET_CONTAINER_MultiPeerMap * natted_addresses
Map of struct TransportGlobalNattedAddress for this neighbour.
struct GNUNET_PEERSTORE_StoreContext * sc
Handle to a PEERSTORE store operation to store this pid's last_dv_learn_monotime.
struct GNUNET_PeerIdentity pid
Which peer is this about?
struct GNUNET_PEERSTORE_IterateContext * get
Handle for an operation to fetch last_dv_learn_monotime information from the PEERSTORE,...

References check_link_down(), cores_send_disconnect_info(), VirtualLink::dv, DistanceVectorHop::dv, DistanceVector::dv_head, Neighbour::dv_head, free_distance_vector_hop(), free_dv_route(), free_virtual_link(), Neighbour::get, GNUNET_assert, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PEERSTORE_iteration_stop(), GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, VirtualLink::n, Neighbour::natted_addresses, neighbours, Neighbour::pid, Neighbour::queue_head, remove_global_addresses(), Neighbour::sc, VirtualLink::target, VirtualLink::visibility_task, DistanceVector::vl, and Neighbour::vl.

Referenced by free_neighbour_cb(), and free_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_send_connect_info()

static void core_send_connect_info ( struct TransportClient tc,
const struct GNUNET_PeerIdentity pid 
)
static

Send message to CORE clients that we lost a connection.

Parameters
tcclient to inform (must be CORE client)
pidpeer the connection is for

Definition at line 3797 of file gnunet-service-transport.c.

3799{
3800 struct GNUNET_MQ_Envelope *env;
3801 struct ConnectInfoMessage *cim;
3802
3803 GNUNET_assert (CT_CORE == tc->type);
3805 cim->id = *pid;
3806 GNUNET_MQ_send (tc->mq, env);
3807}
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
Message from the transport service to the library informing about neighbors.
Definition: transport.h:88
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:111

References CT_CORE, env, GNUNET_assert, GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT, GNUNET_MQ_msg, GNUNET_MQ_send(), ConnectInfoMessage::id, pid, and tc.

Referenced by cores_send_connect_info(), and notify_client_connect_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cores_send_connect_info()

static void cores_send_connect_info ( const struct GNUNET_PeerIdentity pid)
static

Send message to CORE clients that we gained a connection.

Parameters
pidpeer the queue was for

Definition at line 3816 of file gnunet-service-transport.c.

3817{
3819 "Informing CORE clients about connection to %s\n",
3820 GNUNET_i2s (pid));
3821 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3822 {
3823 if (CT_CORE != tc->type)
3824 continue;
3826 }
3827}
static void core_send_connect_info(struct TransportClient *tc, const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.

References clients_head, core_send_connect_info(), CT_CORE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, pid, and tc.

Referenced by activate_core_visible_dv_path(), and handle_validation_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmit_on_queue()

static void transmit_on_queue ( void *  cls)
static

We believe we are ready to transmit a message on a queue.

We believe we are ready to transmit a struct PendingMessage on a queue, the big question is which one! We need to see if there is one pending that is allowed by flow control and congestion control and (ideally) matches our queue's performance profile.

Gives the message to the communicator for transmission (updating the tracker, and re-scheduling itself if applicable).

Parameters
clsthe struct Queue to process transmissions for

If such a message is found, we give the message to the communicator for transmission (updating the tracker, and re-scheduling ourselves if applicable).

If no such message is found, the queue's idle field must be set to GNUNET_YES.

Parameters
clsthe struct Queue to process transmissions for

Definition at line 10993 of file gnunet-service-transport.c.

10994{
10995 struct Queue *queue = cls;
10996 struct Neighbour *n = queue->neighbour;
10998 struct PendingMessage *pm;
10999
11000 queue->transmit_task = NULL;
11001 if (NULL == n->vl)
11002 {
11004 "Virtual link `%s' is down, cannot have PM for queue `%s'\n",
11005 GNUNET_i2s (&n->pid),
11006 queue->address);
11007 queue->idle = GNUNET_YES;
11008 return;
11009 }
11010 memset (&sc, 0, sizeof(sc));
11011 select_best_pending_from_link (&sc, queue, n->vl, NULL, 0);
11012 if (NULL == sc.best)
11013 {
11014 /* Also look at DVH that have the n as first hop! */
11015 for (struct DistanceVectorHop *dvh = n->dv_head; NULL != dvh;
11016 dvh = dvh->next_neighbour)
11017 {
11019 queue,
11020 dvh->dv->vl,
11021 dvh,
11022 sizeof(struct GNUNET_PeerIdentity)
11023 * (1 + dvh->distance)
11024 + sizeof(struct TransportDVBoxMessage)
11025 + sizeof(struct TransportDVBoxPayloadP));
11026 }
11027 }
11028 if (NULL == sc.best)
11029 {
11030 /* no message pending, nothing to do here! */
11032 "No pending messages, queue `%s' to %s now idle\n",
11033 queue->address,
11034 GNUNET_i2s (&n->pid));
11035 if (GNUNET_YES == sc.to_early)
11036 schedule_transmit_on_queue (sc.to_early_retry_delay,
11037 queue,
11039 queue->idle = GNUNET_YES;
11040 return;
11041 }
11042 /* There is a message pending, we are certainly not idle */
11043 queue->idle = GNUNET_NO;
11044
11045 /* Given selection in `sc`, do transmission */
11046 pm = sc.best;
11048 "Selected message <%" PRIu64 ">\n",
11049 pm->logging_uuid);
11050 if (NULL != sc.dvh)
11051 {
11053 "Is this %u a DV box?\n",
11054 pm->pmt);
11055 GNUNET_assert (PMT_DV_BOX != pm->pmt);
11056 if ((NULL != sc.best->bpm) && (sc.best->bpm->used_dvh != sc.dvh))
11057 {
11059 "Discard old box, because we have a new DV path.\n");
11060 free_pending_message (sc.best->bpm);
11061 sc.best->bpm = NULL;
11062 }
11063
11064 if (NULL == sc.best->bpm)
11065 {
11067 "encapsulate_for_dv 2\n");
11068 encapsulate_for_dv (sc.dvh->dv,
11069 1,
11070 &sc.dvh,
11071 (const struct GNUNET_MessageHeader *) &sc.best[1],
11073 &sc,
11074 RMO_NONE,
11075 GNUNET_NO);
11076 GNUNET_assert (NULL != sc.best->bpm);
11078 "%lu %lu %lu %lu %u\n",
11079 sizeof(struct GNUNET_PeerIdentity),
11080 sizeof(struct TransportDVBoxMessage),
11081 sizeof(struct TransportDVBoxPayloadP),
11082 sizeof(struct TransportFragmentBoxMessage),
11083 ((const struct GNUNET_MessageHeader *) &sc.best[1])->size);
11084 sc.best->bpm->used_dvh = sc.dvh;
11085 }
11086 pm = sc.best->bpm;
11087 }
11088 if (GNUNET_YES == sc.frag)
11089 {
11090 pm = fragment_message (queue, sc.dvh, pm);
11091 if (NULL == pm)
11092 {
11094 "Fragmentation failed queue %s to %s for <%" PRIu64
11095 ">, trying again\n",
11096 queue->address,
11097 GNUNET_i2s (&n->pid),
11098 sc.best->logging_uuid);
11100 queue,
11102 return;
11103 }
11104 }
11105 else if (GNUNET_YES == sc.relb)
11106 {
11108 if (NULL == pm)
11109 {
11110 /* Reliability boxing failed, try next message... */
11111 GNUNET_log (
11113 "Reliability boxing failed queue %s to %s for <%" PRIu64
11114 ">, trying again\n",
11115 queue->address,
11116 GNUNET_i2s (&n->pid),
11117 sc.best->logging_uuid);
11119 queue,
11121 return;
11122 }
11123 }
11124
11125 /* Pass 'pm' for transission to the communicator */
11126 GNUNET_log (
11128 "Passing message <%" PRIu64
11129 "> to queue %s for peer %s (considered %u others)\n",
11130 pm->logging_uuid,
11131 queue->address,
11132 GNUNET_i2s (&n->pid),
11133 sc.consideration_counter);
11134
11135 /* Flow control: increment amount of traffic sent; if we are routing
11136 via DV (and thus the ultimate target of the pending message is for
11137 a different virtual link than the one of the queue), then we need
11138 to use up not only the window of the direct link but also the
11139 flow control window for the DV link! */
11140 pm->vl->outbound_fc_window_size_used += pm->bytes_msg;
11141
11142 if (pm->vl != queue->neighbour->vl)
11143 {
11144 /* If the virtual link of the queue differs, this better be distance
11145 vector routing! */
11146 GNUNET_assert (NULL != sc.dvh);
11147 /* If we do distance vector routing, we better not do this for a
11148 message that was itself DV-routed */
11149 GNUNET_assert (PMT_DV_BOX != sc.best->pmt);
11150 /* We use the size of the unboxed message here, to avoid counting
11151 the DV-Box header which is eaten up on the way by intermediaries */
11152 queue->neighbour->vl->outbound_fc_window_size_used += sc.best->bytes_msg;
11153 }
11154 else
11155 {
11156 GNUNET_assert (NULL == sc.dvh);
11157 }
11158
11159 queue_send_msg (queue, pm, &pm[1], pm->bytes_msg);
11160
11161 /* Check if this transmission somehow conclusively finished handing 'pm'
11162 even without any explicit ACKs */
11163 if ((PMT_CORE == pm->pmt) ||
11164 (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc))
11165 {
11167 }
11168 else
11169 {
11170 struct GNUNET_TIME_Relative wait_duration;
11171 unsigned int wait_multiplier;
11172
11173 if (PMT_FRAGMENT_BOX == pm->pmt)
11174 {
11175 struct PendingMessage *root;
11176
11177 root = pm->frag_parent;
11178 while (NULL != root->frag_parent && PMT_DV_BOX != root->pmt)
11179 root = root->frag_parent;
11180
11181 wait_multiplier = (unsigned int) ceil ((double) root->bytes_msg
11182 / ((double) root->frag_off
11183 / (double) root->frag_count))
11184 * 4;
11185 }
11186 else
11187 {
11188 // No fragments, we use 4 RTT before retransmitting.
11189 wait_multiplier = 4;
11190 }
11191
11192 // Depending on how much pending message the VirtualLink is queueing, we wait longer.
11193 // wait_multiplier = wait_multiplier * pm->vl->pending_msg_num;
11194
11196 "Wait multiplier %u\n",
11197 wait_multiplier);
11198
11199 /* Message not finished, waiting for acknowledgement.
11200 Update time by which we might retransmit 's' based on queue
11201 characteristics (i.e. RTT); it takes one RTT for the message to
11202 arrive and the ACK to come back in the best case; but the other
11203 side is allowed to delay ACKs by 2 RTTs, so we use 4 RTT before
11204 retransmitting.
11205
11206 OPTIMIZE: Note that in the future this heuristic should likely
11207 be improved further (measure RTT stability, consider message
11208 urgency and size when delaying ACKs, etc.) */
11209
11210 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us !=
11211 queue->pd.aged_rtt.rel_value_us)
11212 wait_duration = queue->pd.aged_rtt;
11213 else
11214 {
11215 wait_duration = DEFAULT_ACK_WAIT_DURATION;
11216 wait_multiplier = 4;
11217 }
11218 {
11221 wait_duration, wait_multiplier));
11223 wait_duration, wait_multiplier);
11225 "Waiting %s for ACK until %s\n",
11230 GNUNET_TIME_relative_multiply (wait_duration,
11231 wait_multiplier))
11232 );
11233 }
11234 }
11235 /* finally, re-schedule queue transmission task itself */
11237 queue,
11239}
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
static void completed_pending_message(struct PendingMessage *pm)
We have completed transmission of pm, remove it from the transmission queues (and if it is a fragment...
static struct PendingMessage * fragment_message(struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
Fragment the given pm to the given mtu.
static void extract_box_cb(void *cls, struct Neighbour *next_hop, const struct GNUNET_MessageHeader *hdr, enum RouteMessageOptions options)
Function to call to further operate on the now DV encapsulated message hdr, forwarding it via next_ho...
static void select_best_pending_from_link(struct PendingMessageScoreContext *sc, struct Queue *queue, struct VirtualLink *vl, struct DistanceVectorHop *dvh, size_t overhead)
Select the best pending message from vl for transmission via queue.
static void schedule_transmit_on_queue(struct GNUNET_TIME_Relative delay, struct Queue *queue, enum GNUNET_SCHEDULER_Priority p)
Called whenever something changed that might effect when we try to do the next transmission on queue ...
#define DEFAULT_ACK_WAIT_DURATION
Default value for how long we wait for reliability ack.
static struct PendingMessage * reliability_box_message(struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
Reliability-box the given pm.
static struct GNUNET_TIME_Relative encapsulate_for_dv(struct DistanceVector *dv, unsigned int num_dvhs, struct DistanceVectorHop **dvhs, const struct GNUNET_MessageHeader *hdr, DVMessageHandler use, void *use_cls, enum RouteMessageOptions options, enum GNUNET_GenericReturnValue without_fc)
Pick a path of dv under constraints options and schedule transmission of hdr.
static void queue_send_msg(struct Queue *queue, struct PendingMessage *pm, const void *payload, size_t payload_size)
Send the message payload on queue.
static void update_pm_next_attempt(struct PendingMessage *pm, struct GNUNET_TIME_Absolute next_attempt)
Change the value of the next_attempt field of pm to next_attempt and re-order pm in the transmission ...
@ GNUNET_TRANSPORT_CC_RELIABLE
Transmission is reliabile (with ACKs), e.g.
@ GNUNET_SCHEDULER_PRIORITY_DEFAULT
Run with the default priority (normal P2P operations).
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:579
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:316
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:486
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:640
struct DistanceVectorHop * next_neighbour
Kept in a MDLL.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Time for relative time used by GNUnet, in microseconds.
Context for select_best_pending_from_link().
uint16_t bytes_msg
Size of the original message.
uint16_t frag_off
Offset at which we should generate the next fragment.
Outer layer of an encapsulated message send over multiple hops.
Plaintext of the variable-size payload that is encrypted within a struct TransportBackchannelEncapsul...
Outer layer of an encapsulated fragmented application message.

References PendingMessage::bytes_msg, completed_pending_message(), DEFAULT_ACK_WAIT_DURATION, Neighbour::dv_head, encapsulate_for_dv(), extract_box_cb(), PendingMessage::frag_count, PendingMessage::frag_off, PendingMessage::frag_parent, fragment_message(), free_pending_message(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TRANSPORT_CC_RELIABLE, GNUNET_YES, consensus-simulation::int, DistanceVectorHop::next_neighbour, Neighbour::pid, pm, PendingMessage::pmt, PMT_CORE, PMT_DV_BOX, PMT_FRAGMENT_BOX, queue(), queue_send_msg(), reliability_box_message(), RMO_NONE, sc, schedule_transmit_on_queue(), select_best_pending_from_link(), update_pm_next_attempt(), and Neighbour::vl.

Referenced by schedule_transmit_on_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_for_queue_with_higher_prio()

static unsigned int check_for_queue_with_higher_prio ( struct Queue queue,
struct Queue queue_head 
)
static

Check if the communicator has another queue with higher prio ready for sending.

Definition at line 3845 of file gnunet-service-transport.c.

3846{
3847 for (struct Queue *s = queue_head; NULL != s;
3848 s = s->next_client)
3849 {
3850 if (s->tc->details.communicator.address_prefix !=
3851 queue->tc->details.communicator.address_prefix)
3852 {
3854 "queue address %s qid %u compare with queue: address %s qid %u\n",
3855 queue->address,
3856 queue->qid,
3857 s->address,
3858 s->qid);
3859 if ((s->priority > queue->priority) && (0 < s->q_capacity) &&
3860 (QUEUE_LENGTH_LIMIT > s->queue_length) )
3861 return GNUNET_YES;
3863 "Lower prio\n");
3864 }
3865 }
3866 return GNUNET_NO;
3867}
static struct Queue * queue_head
Head of queue of messages to transmit.
#define QUEUE_LENGTH_LIMIT
How many messages can we have pending for a given queue (queue to a particular peer via a communicato...
struct Queue * next_client
Kept in a MDLL.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, Queue::next_client, queue(), queue_head, and QUEUE_LENGTH_LIMIT.

Referenced by schedule_transmit_on_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedule_transmit_on_queue()

static void schedule_transmit_on_queue ( struct GNUNET_TIME_Relative  delay,
struct Queue queue,
enum GNUNET_SCHEDULER_Priority  p 
)
static

Called whenever something changed that might effect when we try to do the next transmission on queue using transmit_on_queue().

Parameters
queuethe queue to do scheduling for
ptask priority to use, if queue is scheduled

Definition at line 3878 of file gnunet-service-transport.c.

3881{
3883
3884 if (queue->validated_until.abs_value_us < now.abs_value_us)
3885 return;
3887 queue->tc->details.communicator.
3888 queue_head))
3889 return;
3890
3891 if (queue->tc->details.communicator.total_queue_length >=
3893 {
3895 "Transmission on queue %s (QID %u) throttled due to communicator queue limit\n",
3896 queue->address,
3897 queue->qid);
3899 GST_stats,
3900 "# Transmission throttled due to communicator queue limit",
3901 1,
3902 GNUNET_NO);
3903 queue->idle = GNUNET_NO;
3904 return;
3905 }
3906 if (queue->queue_length >= QUEUE_LENGTH_LIMIT)
3907 {
3909 "Transmission on queue %s (QID %u) throttled due to communicator queue length limit\n",
3910 queue->address,
3911 queue->qid);
3913 "# Transmission throttled due to queue queue limit",
3914 1,
3915 GNUNET_NO);
3916 queue->idle = GNUNET_NO;
3917 return;
3918 }
3919 if (0 == queue->q_capacity)
3920 {
3922 "Transmission on queue %s (QID %u) throttled due to communicator message has capacity %"
3923 PRIu64 ".\n",
3924 queue->address,
3925 queue->qid,
3926 queue->q_capacity);
3928 "# Transmission throttled due to message queue capacity",
3929 1,
3930 GNUNET_NO);
3931 queue->idle = GNUNET_NO;
3932 return;
3933 }
3934 /* queue might indeed be ready, schedule it */
3935 if (NULL != queue->transmit_task)
3936 GNUNET_SCHEDULER_cancel (queue->transmit_task);
3937 queue->transmit_task =
3939 queue);
3941 "Considering transmission on queue `%s' QID %llu to %s\n",
3942 queue->address,
3943 (unsigned long long) queue->qid,
3944 GNUNET_i2s (&queue->neighbour->pid));
3945}
static unsigned int check_for_queue_with_higher_prio(struct Queue *queue, struct Queue *queue_head)
Check if the communicator has another queue with higher prio ready for sending.
#define COMMUNICATOR_TOTAL_QUEUE_LIMIT
How many messages can we have pending for a given communicator process before we start to throttle th...
static void transmit_on_queue(void *cls)
We believe we are ready to transmit a message on a queue.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1206
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
uint64_t abs_value_us
The actual value.

References GNUNET_TIME_Absolute::abs_value_us, check_for_queue_with_higher_prio(), COMMUNICATOR_TOTAL_QUEUE_LIMIT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GST_stats, p, queue(), queue_head, QUEUE_LENGTH_LIMIT, and transmit_on_queue().

Referenced by check_vl_transmission(), free_queue(), free_queue_entry(), handle_update_queue_message(), and transmit_on_queue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_queue()

static void free_queue ( struct Queue queue)
static

Free queue.

Parameters
queuethe queue to free

Definition at line 4006 of file gnunet-service-transport.c.

4007{
4008 struct Neighbour *neighbour = queue->neighbour;
4009 struct TransportClient *tc = queue->tc;
4010 struct MonitorEvent me = { .cs = GNUNET_TRANSPORT_CS_DOWN,
4012 struct QueueEntry *qe;
4013 int maxxed;
4014 struct PendingAcknowledgement *pa;
4015 struct VirtualLink *vl;
4016
4018 "Cleaning up queue %u\n", queue->qid);
4019 if (NULL != queue->mo)
4020 {
4022 queue->mo = NULL;
4023 }
4024 if (NULL != queue->transmit_task)
4025 {
4026 GNUNET_SCHEDULER_cancel (queue->transmit_task);
4027 queue->transmit_task = NULL;
4028 }
4029 while (NULL != (pa = queue->pa_head))
4030 {
4031 GNUNET_CONTAINER_MDLL_remove (queue, queue->pa_head, queue->pa_tail, pa);
4032 pa->queue = NULL;
4033 }
4034
4036 neighbour->queue_head,
4037 neighbour->queue_tail,
4038 queue);
4040 tc->details.communicator.queue_head,
4041 tc->details.communicator.queue_tail,
4042 queue);
4044 tc->details.communicator.total_queue_length);
4046 "Cleaning up queue with length %u\n",
4047 queue->queue_length);
4048 while (NULL != (qe = queue->queue_head))
4049 {
4050 GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe);
4051 queue->queue_length--;
4052 tc->details.communicator.total_queue_length--;
4053 if (NULL != qe->pm)
4054 {
4055 GNUNET_assert (qe == qe->pm->qe);
4056 qe->pm->qe = NULL;
4057 }
4058 GNUNET_free (qe);
4059 }
4060 GNUNET_assert (0 == queue->queue_length);
4061 if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT >
4062 tc->details.communicator.total_queue_length))
4063 {
4064 /* Communicator dropped below threshold, resume all _other_ queues */
4066 GST_stats,
4067 "# Transmission throttled due to communicator queue limit",
4068 -1,
4069 GNUNET_NO);
4070 for (struct Queue *s = tc->details.communicator.queue_head; NULL != s;
4071 s = s->next_client)
4073 s,
4075 }
4076 notify_monitors (&neighbour->pid, queue->address, queue->nt, &me);
4078
4079 vl = lookup_virtual_link (&neighbour->pid);
4080 if ((NULL != vl) && (neighbour == vl->n))
4081 {
4083 check_link_down (vl);
4084 }
4085 if (NULL == neighbour->queue_head)
4086 {
4087 free_neighbour (neighbour, GNUNET_NO);
4088 }
4089}
static void free_neighbour(struct Neighbour *neighbour, enum GNUNET_GenericReturnValue drop_link)
Release memory used by neighbour.
static void notify_monitors(const struct GNUNET_PeerIdentity *peer, const char *address, enum GNUNET_NetworkType nt, const struct MonitorEvent *me)
Send information in me about a peer's status with respect to some address to all monitors that care.
static struct VirtualLink * lookup_virtual_link(const struct GNUNET_PeerIdentity *pid)
Lookup virtual link for peer pid.
@ GNUNET_TRANSPORT_CS_DOWN
Connection is down.
Details about what to notify monitors about.
struct Queue * queue_tail
Tail of DLL of queues to this peer.

References check_link_down(), COMMUNICATOR_TOTAL_QUEUE_LIMIT, free_neighbour(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_MDLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_PEERSTORE_monitor_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_ZERO, GNUNET_TRANSPORT_CS_DOWN, GST_stats, lookup_virtual_link(), me, VirtualLink::n, notify_monitors(), Neighbour::pid, qe, queue(), PendingAcknowledgement::queue, Neighbour::queue_head, Neighbour::queue_tail, schedule_transmit_on_queue(), tc, and VirtualLink::visibility_task.

Referenced by client_disconnect_cb(), and handle_del_queue_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_address_list_entry()

static void free_address_list_entry ( struct AddressListEntry ale)
static

Free ale.

Parameters
aleaddress list entry to free

Definition at line 4098 of file gnunet-service-transport.c.

4099{
4100 struct TransportClient *tc = ale->tc;
4101
4102 GNUNET_CONTAINER_DLL_remove (tc->details.communicator.addr_head,
4103 tc->details.communicator.addr_tail,
4104 ale);
4105 if (NULL != ale->sc)
4106 {
4108 "store cancel\n");
4110 ale->sc = NULL;
4111 }
4112 if (NULL != ale->st)
4113 {
4115 ale->st = NULL;
4116 }
4117 if (NULL != ale->signed_address)
4119 GNUNET_free (ale);
4120}
struct TransportClient * tc
Which communicator provides this address?
void * signed_address
Signed address.
struct GNUNET_SCHEDULER_Task * st
Task to periodically do st operation.
struct GNUNET_PEERSTORE_StoreContext * sc
Current context for storing this address in the peerstore.

References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_cancel(), AddressListEntry::sc, AddressListEntry::signed_address, AddressListEntry::st, tc, and AddressListEntry::tc.

Referenced by client_disconnect_cb(), and handle_del_address().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_peer_request()

static int stop_peer_request ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Stop the peer request in value.

Parameters
clsa struct TransportClient that no longer makes the request
pidthe peer's identity
valuea struct PeerRequest
Returns
GNUNET_YES (always)

Definition at line 4132 of file gnunet-service-transport.c.

4135{
4136 struct TransportClient *tc = cls;
4137 struct PeerRequest *pr = value;
4138
4139 if (NULL != pr->nc)
4141 pr->nc = NULL;
4143 GNUNET_YES ==
4144 GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests,
4145 pid,
4146 pr));
4147 GNUNET_free (pr);
4148
4149 return GNUNET_OK;
4150}
Information per peer and request.
struct GSF_PendingRequest * pr
Handle to generic request (generic: from peer or local client).

References GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_OK, GNUNET_PEERSTORE_monitor_stop(), GNUNET_YES, pid, PeerRequest::pr, tc, and value.

Referenced by client_disconnect_cb(), and handle_suggest_cancel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Function called when the service shuts down.

Unloads our plugins and cancels pending validations.

Parameters
clsclosure, unused

Definition at line 12878 of file gnunet-service-transport.c.

12879{
12880 struct LearnLaunchEntry *lle;
12881 (void) cls;
12882
12884 "shutdown logic\n");
12887 &free_neighbour_cb, NULL);
12888 if (NULL != validation_task)
12889 {
12891 validation_task = NULL;
12892 }
12893 if (NULL != dvlearn_task)
12894 {
12896 dvlearn_task = NULL;
12897 }
12898 if (NULL != GST_stats)
12899 {
12901 GST_stats = NULL;
12902 }
12903 if (NULL != GST_my_hello)
12904 {
12906 GST_my_hello = NULL;
12907 }
12908 if (NULL != GST_my_private_key)
12909 {
12911 GST_my_private_key = NULL;
12912 }
12915 NULL);
12917 ack_cummulators = NULL;
12920 NULL);
12922 pending_acks = NULL;
12925 neighbours = NULL;
12928 links = NULL;
12931 NULL);
12933 backtalkers = NULL;
12936 NULL);
12938 validation_map = NULL;
12940 revalidation_map = NULL;
12941 while (NULL != ir_head)
12943 GNUNET_assert (0 == ir_total);
12944 while (NULL != (lle = lle_head))
12945 {
12947 GNUNET_free (lle);
12948 }
12949 if (NULL != peerstore)
12950 {
12952 "Disconnecting from PEERSTORE service\n");
12954 peerstore = NULL;
12955 }
12957 dvlearn_map = NULL;
12959 validation_heap = NULL;
12962 dv_routes = NULL;
12964}
static struct GNUNET_SCHEDULER_Task * dvlearn_task
Task run to initiate DV learning.
static struct LearnLaunchEntry * lle_tail
Tail of a DLL sorted by launch time.
static struct GNUNET_CONTAINER_Heap * validation_heap
MIN Heap sorted by "next_challenge" to struct ValidationState entries sorting addresses we are aware ...
static struct LearnLaunchEntry * lle_head
Head of a DLL sorted by launch time.
static int free_pending_ack_cb(void *cls, const struct GNUNET_Uuid *key, void *value)
Free pending acknowledgement.
struct GNUNET_NAT_Handle * nh
Handle for connect to the NAT service.
static struct GNUNET_SCHEDULER_Task * validation_task
Task to run address validation.
static struct GNUNET_CRYPTO_EddsaPrivateKey * GST_my_private_key
Our private key.
static struct GNUNET_PEERSTORE_Handle * peerstore
Database for peer's HELLOs.
static int free_validation_state_cb(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free validation state.
static int free_neighbour_cb(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free neighbour entry.
struct GNUNET_HELLO_Builder * GST_my_hello
Our HELLO.
static struct GNUNET_CONTAINER_MultiShortmap * dvlearn_map
Map from challenges to struct LearnLaunchEntry values.
static struct GNUNET_CONTAINER_MultiPeerMap * backtalkers
Map from PIDs to struct Backtalker entries.
static int free_backtalker_cb(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Callback to free backtalker records.
static struct GNUNET_CONTAINER_MultiPeerMap * ack_cummulators
Map from PIDs to struct AcknowledgementCummulators.
static int free_dv_routes_cb(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free DV route entry.
static int free_ack_cummulator_cb(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Free acknowledgement cummulator.
static void free_incoming_request(struct IncomingRequest *ir)
Release ir data structure.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multiuuidmap_destroy(struct GNUNET_CONTAINER_MultiUuidmap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_iterate(struct GNUNET_CONTAINER_MultiUuidmap *map, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
Definition: hello-uri.c:453
void GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh)
Stop port redirection and public IP address detection for the given handle.
Definition: nat_api.c:703
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:566
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
When did we launch this DV learning activity?

References ack_cummulators, backtalkers, dv_routes, dvlearn_map, dvlearn_task, free_ack_cummulator_cb(), free_backtalker_cb(), free_dv_routes_cb(), free_incoming_request(), free_neighbour_cb(), free_pending_ack_cb(), free_validation_state_cb(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multiuuidmap_destroy(), GNUNET_CONTAINER_multiuuidmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_builder_free(), GNUNET_log, GNUNET_NAT_unregister(), GNUNET_NO, GNUNET_PEERSTORE_disconnect(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_destroy(), GST_my_hello, GST_my_private_key, GST_stats, ir_head, ir_total, links, lle_head, lle_tail, neighbours, nh, peerstore, pending_acks, revalidation_map, validation_heap, validation_map, and validation_task.

Referenced by client_disconnect_cb(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Called whenever a client is disconnected.

Frees our resources associated with that client.

Parameters
clsclosure, NULL
clientidentification of the client
app_ctxour struct TransportClient

Definition at line 4165 of file gnunet-service-transport.c.

4168{
4169 struct TransportClient *tc = app_ctx;
4170
4171 (void) cls;
4172 (void) client;
4174 switch (tc->type)
4175 {
4176 case CT_NONE:
4178 "Unknown Client %p disconnected, cleaning up.\n",
4179 tc);
4180 break;
4181
4182 case CT_CORE: {
4183 struct PendingMessage *pm;
4185 "CORE Client %p disconnected, cleaning up.\n",
4186 tc);
4187
4188
4189 while (NULL != (pm = tc->details.core.pending_msg_head))
4190 {
4192 tc->details.core.pending_msg_head,
4193 tc->details.core.pending_msg_tail,
4194 pm);
4195 pm->client = NULL;
4196 }
4197 }
4198 break;
4199
4200 case CT_MONITOR:
4202 "MONITOR Client %p disconnected, cleaning up.\n",
4203 tc);
4204
4205 break;
4206
4207 case CT_COMMUNICATOR: {
4208 struct Queue *q;
4209 struct AddressListEntry *ale;
4210
4212 "COMMUNICATOR Client %p disconnected, cleaning up.\n",
4213 tc);
4214
4215 if (NULL != tc->details.communicator.free_queue_entry_task)
4217 tc->details.communicator.free_queue_entry_task);
4218 while (NULL != (q = tc->details.communicator.queue_head))
4219 free_queue (q);
4220 while (NULL != (ale = tc->details.communicator.addr_head))
4222 GNUNET_free (tc->details.communicator.address_prefix);
4223 }
4224 break;
4225
4226 case CT_APPLICATION:
4228 "APPLICATION Client %p disconnected, cleaning up.\n",
4229 tc);
4230
4231 GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
4233 tc);
4234 GNUNET_CONTAINER_multipeermap_destroy (tc->details.application.requests);
4235 break;
4236 }
4237 GNUNET_free (tc);
4238 if ((GNUNET_YES == in_shutdown) && (NULL == clients_head))
4239 {
4241 "Our last client disconnected\n");
4242 do_shutdown (cls);
4243 }
4244}
static void free_queue(struct Queue *queue)
Free queue.
static int stop_peer_request(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Stop the peer request in value.
static int in_shutdown
Indication if we have received a shutdown signal and are in the process of cleaning up.
static void do_shutdown(void *cls)
Function called when the service shuts down.
static void free_address_list_entry(struct AddressListEntry *ale)
Free ale.
@ GNUNET_ERROR_TYPE_ERROR
One of the addresses of this peer.
struct TransportClient * client
Client that issued the transmission request, if pmt is PMT_CORE.

References PendingMessage::client, TransportClient::client, clients_head, clients_tail, CT_APPLICATION, CT_COMMUNICATOR, CT_CORE, CT_MONITOR, CT_NONE, do_shutdown(), free_address_list_entry(), free_queue(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_MDLL_remove, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_YES, in_shutdown, pm, q, stop_peer_request(), and tc.

Here is the call graph for this function:

◆ notify_client_connect_info()

static int notify_client_connect_info ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Iterator telling new CORE client about all existing connections to peers.

Parameters
clsthe new struct TransportClient
pida connected peer
valuethe struct Neighbour with more information
Returns
GNUNET_OK (continue to iterate)

Definition at line 4257 of file gnunet-service-transport.c.

4260{
4261 struct TransportClient *tc = cls;
4262 struct VirtualLink *vl = value;
4263
4264 if ((NULL == vl) || (GNUNET_NO == vl->confirmed))
4265 return GNUNET_OK;
4266
4268 "Telling new CORE client about existing connection to %s\n",
4269 GNUNET_i2s (pid));
4271 return GNUNET_OK;
4272}

References VirtualLink::confirmed, core_send_connect_info(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, pid, tc, and value.

Referenced by handle_client_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finish_cmc_handling_with_continue()

static void finish_cmc_handling_with_continue ( struct CommunicatorMessageContext cmc,
unsigned int  free_cmc 
)
static

Send ACK to communicator (if requested) and free cmc.

Parameters
cmccontext for which we are done handling the message

Definition at line 4526 of file gnunet-service-transport.c.

4529{
4530 if (0 != ntohl (cmc->im.fc_on))
4531 {
4532 /* send ACK when done to communicator for flow control! */
4533 struct GNUNET_MQ_Envelope *env;
4535
4537 "Acknowledge message with flow control id %" PRIu64 "\n",
4538 cmc->im.fc_id);
4540 ack->reserved = htonl (0);
4541 ack->fc_id = cmc->im.fc_id;
4542 ack->sender = cmc->im.neighbour_sender;
4543 GNUNET_MQ_send (cmc->tc->mq, env);
4544 }
4545
4547
4548 if (GNUNET_YES == free_cmc)
4549 {
4550 GNUNET_free (cmc);
4551 }
4552}
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2348
struct GNUNET_TRANSPORT_IncomingMessage im
Additional information for flow control and about the sender.
struct TransportClient * tc
Which communicator provided us with the message.
Transport informs us about being done with an incoming message.
Definition: transport.h:374
struct GNUNET_PeerIdentity sender
Sender identifier of the original message.
Definition: transport.h:393
uint64_t fc_id
Which message is being ACKed?
Definition: transport.h:388
uint32_t reserved
Reserved (0)
Definition: transport.h:383
struct GNUNET_PeerIdentity neighbour_sender
Direct neighbour sender identifier.
Definition: transport.h:363
uint32_t fc_on
Do we use flow control or not?
Definition: transport.h:342
uint64_t fc_id
64-bit number to identify the matching ACK.
Definition: transport.h:347
struct GNUNET_MQ_Handle * mq
Message queue to the client.

References TransportClient::client, env, GNUNET_TRANSPORT_IncomingMessage::fc_id, GNUNET_TRANSPORT_IncomingMessageAck::fc_id, GNUNET_TRANSPORT_IncomingMessage::fc_on, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_YES, CommunicatorMessageContext::im, TransportClient::mq, GNUNET_TRANSPORT_IncomingMessage::neighbour_sender, GNUNET_TRANSPORT_IncomingMessageAck::reserved, GNUNET_TRANSPORT_IncomingMessageAck::sender, and CommunicatorMessageContext::tc.

Referenced by finish_cmc_handling(), finish_handling_raw_message(), handle_client_recv_ok(), handle_raw_message(), and resume_communicators().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resume_communicators()

static enum GNUNET_GenericReturnValue resume_communicators ( void *  cls,
const struct GNUNET_PeerIdentity pid,
void *  value 
)
static

Definition at line 4286 of file gnunet-service-transport.c.

4289{
4290 struct VirtualLink *vl = value;
4291 struct CommunicatorMessageContext *cmc;
4292
4293 /* resume communicators */
4294 while (NULL != (cmc = vl->cmc_tail))
4295 {
4297 if (GNUNET_NO == cmc->continue_send)
4299 }
4300 return GNUNET_OK;
4301}
static void finish_cmc_handling_with_continue(struct CommunicatorMessageContext *cmc, unsigned int free_cmc)
Send ACK to communicator (if requested) and free cmc.
Context from handle_incoming_msg().
unsigned int continue_send
Did we already call GNUNET_SERVICE_client_continue and send ACK to communicator?

References VirtualLink::cmc_head, VirtualLink::cmc_tail, CommunicatorMessageContext::continue_send, finish_cmc_handling_with_continue(), GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_OK, GNUNET_YES, and value.

Referenced by handle_client_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_start()

static void handle_client_start ( void *  cls,
const struct StartMessage start 
)
static

Initialize a "CORE" client.

We got a start message from this client, so add it to the list of clients for broadcasting of inbound messages.

Parameters
clsthe client
startthe start message that was sent

Definition at line 4313 of file gnunet-service-transport.c.

4314{
4315 struct TransportClient *tc = cls;
4316 uint32_t options;
4317
4318 options = ntohl (start->options);
4319 if ((0 != (1 & options)) &&
4320 (0 != GNUNET_memcmp (&start->self, &GST_my_identity)))
4321 {
4322 /* client thinks this is a different peer, reject */
4323 GNUNET_break (0);
4325 return;
4326 }
4327 if (CT_NONE != tc->type)
4328 {
4329 GNUNET_break (0);
4331 return;
4332 }
4333 tc->type = CT_CORE;
4335 "New CORE client with PID %s registered\n",
4336 GNUNET_i2s (&start->self));
4339 tc);
4342 NULL);
4344}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:38
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
static enum GNUNET_GenericReturnValue resume_communicators(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
static int notify_client_connect_info(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Iterator telling new CORE client about all existing connections to peers.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2377

References CT_CORE, CT_NONE, GNUNET_break, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_memcmp, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GST_my_identity, links, notify_client_connect_info(), options, resume_communicators(), start, and tc.

Here is the call graph for this function:

◆ check_client_send()

static int check_client_send ( void *  cls,
const struct OutboundMessage obm 
)
static

Client asked for transmission to a peer.

Process the request.

Parameters
clsthe client
obmthe send message that was sent

Definition at line 4354 of file gnunet-service-transport.c.

4355{
4356 struct TransportClient *tc = cls;
4357 uint16_t size;
4358 const struct GNUNET_MessageHeader *obmm;
4359
4360 if (CT_CORE != tc->type)
4361 {
4362 GNUNET_break (0);
4363 return GNUNET_SYSERR;
4364 }
4365 size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
4366 if (size < sizeof(struct GNUNET_MessageHeader))
4367 {
4368 GNUNET_break (0);
4369 return GNUNET_SYSERR;
4370 }
4371 obmm = (const struct GNUNET_MessageHeader *) &obm[1];
4372 if (size != ntohs (obmm->size))
4373 {
4374 GNUNET_break (0);
4375 return GNUNET_SYSERR;
4376 }
4377 return GNUNET_OK;
4378}
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SYSERR
static unsigned int size
Size of the "table".
Definition: peer.c:68
Message used to notify the transport service about a message to be transmitted to another peer.
Definition: transport.h:229
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:233

References CT_CORE, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, OutboundMessage::header, GNUNET_MessageHeader::size, size, and tc.

◆ client_send_response()

static void client_send_response ( struct PendingMessage pm)
static

Send a response to the pm that we have processed a "send" request.

Sends a confirmation to the "core" client responsible for the original request and free's pm.

Parameters
pmhandle to the original pending message

Definition at line 4389 of file gnunet-service-transport.c.

4390{
4391 struct TransportClient *tc = pm->client;
4392 struct VirtualLink *vl = pm->vl;
4393
4395 "client send response\n");
4396 if (NULL != tc)
4397 {
4398 struct GNUNET_MQ_Envelope *env;
4399 struct SendOkMessage *so_msg;
4400
4402 so_msg->peer = vl->target;
4404 "Confirming transmission of <%" PRIu64 "> to %s\n",
4405 pm->logging_uuid,
4406 GNUNET_i2s (&vl->target));
4407 GNUNET_MQ_send (tc->mq, env);
4408 }
4410}
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
Message used to notify the transport API that it can send another message to the transport service.
Definition: transport.h:161
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:195

References env, free_pending_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), SendOkMessage::peer, pm, VirtualLink::target, and tc.

Referenced by completed_pending_message(), and reliability_box_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pick_random_dv_hops()

static unsigned int pick_random_dv_hops ( const struct DistanceVector dv,
enum RouteMessageOptions  options,
struct DistanceVectorHop **  hops_array,
unsigned int  hops_array_length 
)
static

Pick hops_array_length random DV paths satisfying options.

Parameters
dvdata structure to pick paths from
optionsconstraints to satisfy
[out]hops_arrayset to the result
hops_array_lengthlength of the hops_array
Returns
number of entries set in hops_array

Definition at line 4423 of file gnunet-service-transport.c.

4427{
4428 uint64_t choices[hops_array_length];
4429 uint64_t num_dv;
4430 unsigned int dv_count;
4431
4432 /* Pick random vectors, but weighted by distance, giving more weight
4433 to shorter vectors */
4434 num_dv = 0;
4435 dv_count = 0;
4436 for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
4437 pos = pos->next_dv)
4438 {
4439 if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
4440 (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
4441 .rel_value_us == 0))
4442 continue; /* pos unconfirmed and confirmed required */
4443 num_dv += MAX_DV_HOPS_ALLOWED - pos->distance;
4444 dv_count++;
4445 }
4446 if (0 == dv_count)
4447 return 0;
4448 if (dv_count <= hops_array_length)
4449 {
4450 dv_count = 0;
4451 for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
4452 pos = pos->next_dv)
4453 hops_array[dv_count++] = pos;
4454 return dv_count;
4455 }
4456 for (unsigned int i = 0; i < hops_array_length; i++)
4457 {
4458 int ok = GNUNET_NO;
4459 while (GNUNET_NO == ok)
4460 {
4461 choices[i] =
4463 ok = GNUNET_YES;
4464 for (unsigned int j = 0; j < i; j++)
4465 if (choices[i] == choices[j])
4466 {
4467 ok = GNUNET_NO;
4468 break;
4469 }
4470 }
4471 }
4472 dv_count = 0;
4473 num_dv = 0;
4474 for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
4475 pos = pos->next_dv)
4476 {
4477 uint32_t delta = MAX_DV_HOPS_ALLOWED - pos->distance;
4478
4479 if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
4480 (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
4481 .rel_value_us == 0))
4482 continue; /* pos unconfirmed and confirmed required */
4483 for (unsigned int i = 0; i < hops_array_length; i++)
4484 if ((num_dv <= choices[i]) && (num_dv + delta > choices[i]))
4485 hops_array[dv_count++] = pos;
4486 num_dv += delta;
4487 }
4488 return dv_count;
4489}
#define MAX_DV_HOPS_ALLOWED
Maximum DV distance allowed ever.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36

References warningfilter::choices, delta, DistanceVector::dv_head, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64(), GNUNET_NO, GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, MAX_DV_HOPS_ALLOWED, DistanceVectorHop::next_dv, options, GNUNET_TIME_Relative::rel_value_us, and RMO_UNCONFIRMED_ALLOWED.

Referenced by route_control_message_without_fc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_communicator_available()

static int check_communicator_available ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage cam 
)
static

Communicator started.

Test message is well-formed.

Parameters
clsthe client
camthe send message that was sent

Definition at line 4499 of file gnunet-service-transport.c.

4502{
4503 struct TransportClient *tc = cls;
4504 uint16_t size;
4505
4506 if (CT_NONE != tc->type)
4507 {
4508 GNUNET_break (0);
4509 return GNUNET_SYSERR;
4510 }
4511 tc->type = CT_COMMUNICATOR;
4512 size = ntohs (cam->header.size) - sizeof(*cam);
4513 if (0 == size)
4514 return GNUNET_OK; /* receive-only communicator */
4516 return GNUNET_OK;
4517}
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR.
Definition: transport.h:267

References CT_COMMUNICATOR, CT_NONE, GNUNET_break, GNUNET_MQ_check_zero_termination, GNUNET_OK, GNUNET_SYSERR, GNUNET_TRANSPORT_CommunicatorAvailableMessage::header, GNUNET_MessageHeader::size, size, and tc.

◆ finish_cmc_handling()

static void finish_cmc_handling ( struct CommunicatorMessageContext cmc)
static

Definition at line 4556 of file gnunet-service-transport.c.

References finish_cmc_handling_with_continue(), and GNUNET_YES.

Referenced by backtalker_monotime_cb(), free_backtalker(), handle_backchannel_encapsulation(), handle_dv_box(), handle_dv_learn(), handle_flow_control(), handle_fragment_box(), handle_raw_message(), handle_reliability_ack(), handle_validation_challenge(), and handle_validation_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_recv_ok()

static void handle_client_recv_ok ( void *  cls,
const struct RecvOkMessage rom 
)
static

Client confirms that it is done handling message(s) to a particular peer.

We may now provide more messages to CORE for this peer.

Notifies the respective queues that more messages can now be received.

Parameters
clsthe client
romthe message that was sent

Definition at line 4572 of file gnunet-service-transport.c.

4573{
4574 struct TransportClient *tc = cls;
4575 struct VirtualLink *vl;
4576 uint32_t delta;
4577 struct CommunicatorMessageContext *cmc;
4578
4579 if (CT_CORE != tc->type)
4580 {
4581 GNUNET_break (0);
4583 return;
4584 }
4585 vl = lookup_virtual_link (&rom->peer);
4586 if ((NULL == vl) || (GNUNET_NO == vl->confirmed))
4587 {
4589 "# RECV_OK dropped: virtual link unknown",
4590 1,
4591 GNUNET_NO);
4593 return;
4594 }
4595 delta = ntohl (rom->increase_window_delta);
4596 vl->core_recv_window += delta;
4598 "CORE ack receiving message, increased CORE recv window to %d\n",
4599 vl->core_recv_window);
4601 if (vl->core_recv_window <= 0)
4602 return;
4603 /* resume communicators */
4604 while (NULL != (cmc = vl->cmc_tail))
4605 {
4607 if (GNUNET_NO == cmc->continue_send)
4609 }
4610}
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
Definition: transport.h:220
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Definition: transport.h:215

References VirtualLink::cmc_head, VirtualLink::cmc_tail, VirtualLink::confirmed, CommunicatorMessageContext::continue_send, VirtualLink::core_recv_window, CT_CORE, delta, finish_cmc_handling_with_continue(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), GNUNET_YES, GST_stats, RecvOkMessage::increase_window_delta, lookup_virtual_link(), RecvOkMessage::peer, and tc.

Here is the call graph for this function:

◆ handle_communicator_available()

static void handle_communicator_available ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage cam 
)
static

Communicator started.

Process the request.

Parameters
clsthe client
camthe send message that was sent

Definition at line 4620 of file gnunet-service-transport.c.

4623{
4624 struct TransportClient *tc = cls;
4625 uint16_t size;
4626
4627 size = ntohs (cam->header.size) - sizeof(*cam);
4628 if (0 == size)
4629 {
4631 "Receive-only communicator connected\n");
4632 return; /* receive-only communicator */
4633 }
4634 tc->details.communicator.address_prefix =
4635 GNUNET_strdup ((const char *) &cam[1]);
4636 tc->details.communicator.cc = ntohl (cam->cc);
4637 tc->details.communicator.can_burst = ntohl (cam->can_burst);
4639 "Communicator for peer %s with prefix '%s' connected %s\n",
4641 tc->details.communicator.address_prefix,
4642 tc->details.communicator.can_burst ? "can burst" :
4643 "can not burst");
4645}
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
uint32_t cc
NBO encoding of enum GNUNET_TRANSPORT_CommunicatorCharacteristics
Definition: transport.h:272
uint32_t can_burst
The communicator can do burst msgs.
Definition: transport.h:277

References GNUNET_TRANSPORT_CommunicatorAvailableMessage::can_burst, GNUNET_TRANSPORT_CommunicatorAvailableMessage::cc, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GST_my_identity, GNUNET_TRANSPORT_CommunicatorAvailableMessage::header, GNUNET_MessageHeader::size, size, and tc.

Here is the call graph for this function:

◆ check_communicator_backchannel()

static int check_communicator_backchannel ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorBackchannel cb 
)
static

Communicator requests backchannel transmission.

Check the request.

Parameters
clsthe client
cbthe send message that was sent
Returns
GNUNET_OK if message is well-formed

Definition at line 4656 of file gnunet-service-transport.c.

4659{
4660 const struct GNUNET_MessageHeader *inbox;
4661 const char *is;
4662 uint16_t msize;
4663 uint16_t isize;
4664
4665 (void) cls;
4666 msize = ntohs (cb->header.size) - sizeof(*cb);
4667 inbox = (const struct GNUNET_MessageHeader *) &cb[1];
4668 isize = ntohs (inbox->size);
4669 if (isize >= msize)
4670 {
4671 GNUNET_break (0);
4672 return GNUNET_SYSERR;
4673 }
4674 is = (const char *) inbox;
4675 is += isize;
4676 msize -= isize;
4677 GNUNET_assert (0 < msize);
4678 if ('\0' != is[msize - 1])
4679 {
4680 GNUNET_break (0);
4681 return GNUNET_SYSERR;
4682 }
4683 return GNUNET_OK;
4684}
static struct GNUNET_TESTING_Interpreter * is
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL.
Definition: transport.h:630

References GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_TRANSPORT_CommunicatorBackchannel::header, is, and GNUNET_MessageHeader::size.

◆ sign_ephemeral()

static void sign_ephemeral ( struct DistanceVector dv)
static

Sign ephemeral keys in our dv are current.

Parameters
[in,out]dvvirtual link to update ephemeral for

Definition at line 4693 of file gnunet-service-transport.c.

4694{
4695 struct EphemeralConfirmationPS ec;
4696
4698 dv->ephemeral_validity =
4700 ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
4701 ec.target = dv->target;
4702 ec.ephemeral_key = dv->ephemeral_key;
4703 ec.sender_monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime);
4704 ec.purpose.size = htonl (sizeof(ec));
4706 &ec,
4707 &dv->sender_sig);
4708}
#define EPHEMERAL_VALIDITY
How long are ephemeral keys valid?
static const struct GNUNET_CONFIGURATION_Handle * GST_cfg
Configuration handle.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:452
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_monotonic(const struct GNUNET_CONFIGURATION_Handle *cfg)
Obtain the current time and make sure it is monotonically increasing.
Definition: time.c:862
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL
Signature by a peer affirming that the given ephemeral key is currently in use by that peer's transpo...
struct GNUNET_TIME_Absolute monotime
What time was sender_sig created.
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Signature affirming ephemeral_key of type GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL.
struct GNUNET_CRYPTO_HpkeEncapsulation ephemeral_key
Our ephemeral key.
struct GNUNET_TIME_Absolute ephemeral_validity
How long is sender_sig valid.
Body by which a peer confirms that it is using an ephemeral key.

References EphemeralConfirmationPS::ephemeral_key, DistanceVector::ephemeral_key, EPHEMERAL_VALIDITY, DistanceVector::ephemeral_validity, GNUNET_CRYPTO_eddsa_sign, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_hton(), GST_cfg, GST_my_private_key, DistanceVector::monotime, GNUNET_CRYPTO_EccSignaturePurpose::purpose, EphemeralConfirmationPS::purpose, EphemeralConfirmationPS::sender_monotonic_time, DistanceVector::sender_sig, GNUNET_CRYPTO_EccSignaturePurpose::size, EphemeralConfirmationPS::target, and DistanceVector::target.

Referenced by encapsulate_for_dv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_queue_entry()

static void free_queue_entry ( struct QueueEntry qe,
struct TransportClient tc 
)
static

Definition at line 11282 of file gnunet-service-transport.c.

11284{
11285 struct PendingMessage *pm;
11286
11287 GNUNET_CONTAINER_DLL_remove (qe->queue->queue_head,
11288 qe->queue->queue_tail,
11289 qe);
11290 qe->queue->queue_length--;
11291 tc->details.communicator.total_queue_length--;
11293 "Received ACK on queue %s (QID %u) to peer %s (new length: %u/%u)\n",
11294 qe->queue->address,
11295 qe->queue->qid,
11296 GNUNET_i2s (&qe->queue->neighbour->pid),
11297 qe->queue->queue_length,
11298 tc->details.communicator.total_queue_length);
11299
11300 /* if applicable, resume transmissions that waited on ACK */
11302 tc->details.communicator.total_queue_length)
11303 {
11304 /* Communicator dropped below threshold, resume all queues
11305 incident with this client! */
11307 GST_stats,
11308 "# Transmission throttled due to communicator queue limit",
11309 -1,
11310 GNUNET_NO);
11311 for (struct Queue *queue = tc->details.communicator.queue_head;
11312 NULL != queue;
11313 queue = queue->next_client)
11314 {
11316 queue,
11318 }
11319 }
11320 else if (QUEUE_LENGTH_LIMIT - 1 == qe->queue->queue_length)
11321 {
11322 /* queue dropped below threshold; only resume this one queue */
11324 "# Transmission throttled due to queue queue limit",
11325 -1,
11326 GNUNET_NO);
11328 qe->queue,
11330 }
11331 else if (1 == qe->queue->q_capacity)
11332 {
11333 // TODO I guess this will never happen, because the communicator triggers this by updating its queue length itself.
11335 "Transmission rescheduled due to communicator message queue with qid %u has capacity %"
11336 PRIu64 ".\n",
11337 qe->queue->qid,
11338 qe->queue->q_capacity);
11339 /* message queue has capacity; only resume this one queue */
11340 /* queue dropped below threshold; only resume this one queue */
11342 "# Transmission throttled due to message queue capacity",
11343 -1,
11344 GNUNET_NO);
11346 qe->queue,
11348 }
11349
11350 if (NULL != (pm = qe->pm))
11351 {
11352 struct VirtualLink *vl;
11353
11354 // GNUNET_assert (qe == pm->qe);
11355 pm->qe = NULL;
11356 /* If waiting for this communicator may have blocked transmission
11357 of pm on other queues for this neighbour, force schedule
11358 transmit on queue for queues of the neighbour */
11359 if (NULL == pm->frag_parent)
11360 {
11361 vl = pm->vl;
11362 if ((NULL != vl) &&
11363 (NULL != vl->pending_msg_head) &&
11364 (vl->pending_msg_head == pm))
11366 }
11367 }
11368 GNUNET_free (qe);
11369}
static void check_vl_transmission(struct VirtualLink *vl)
There is a message at the head of the pending messages for vl which may be ready for transmission.

References check_vl_transmission(), COMMUNICATOR_TOTAL_QUEUE_LIMIT, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_ZERO, GST_stats, VirtualLink::pending_msg_head, pm, qe, queue(), QUEUE_LENGTH_LIMIT, schedule_transmit_on_queue(), and tc.

Referenced by free_timedout_queue_entry(), and handle_send_message_ack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_timedout_queue_entry()

static void free_timedout_queue_entry ( void *  cls)
static

Definition at line 4717 of file gnunet-service-transport.c.

4718{
4719 struct TransportClient *tc = cls;
4721
4723 "freeing timedout queue entries\n");
4724
4725 tc->details.communicator.free_queue_entry_task = NULL;
4726 for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue;
4727 queue = queue->next_client)
4728 {
4729 struct QueueEntry *qep = queue->queue_head;
4730
4732 "checking QID %u for timedout queue entries\n",
4733 queue->qid);
4734 while (NULL != qep)
4735 {
4736 struct QueueEntry *pos = qep;
4738 pos->creation_timestamp, now);
4739 qep = qep->next;
4740
4742 "diff to now %s \n",
4745 {
4747 "Freeing timed out QueueEntry with MID %" PRIu64
4748 " and QID %u\n",
4749 pos->mid,
4750 queue->qid);
4751 free_queue_entry (pos, tc);
4752 }
4753 }
4754 }
4755}
#define QUEUE_ENTRY_TIMEOUT
static void free_queue_entry(struct QueueEntry *qe, struct TransportClient *tc)
const char * GNUNET_TIME_relative2s(struct GNUNET_TIME_Relative delta, bool do_round)
Give relative time in human-readable fancy format.
Definition: time.c:264
#define GNUNET_TIME_relative_cmp(t1, op, t2)
Compare two relative times.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:423
struct QueueEntry * next
Kept as a DLL.
struct GNUNET_TIME_Absolute creation_timestamp
Timestamp this QueueEntry was created.
uint64_t mid
Message ID used for this message with the queue used for transmission.

References QueueEntry::creation_timestamp, free_queue_entry(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_relative2s(), GNUNET_TIME_relative_cmp, QueueEntry::mid, QueueEntry::next, queue(), QUEUE_ENTRY_TIMEOUT, and tc.

Referenced by queue_send_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ queue_send_msg()

static void queue_send_msg ( struct Queue queue,
struct PendingMessage pm,
const void *  payload,
size_t  payload_size 
)
static

Send the message payload on queue.

Parameters
queuethe queue to use for transmission
pmpending message to update once transmission is done, may be NULL!
payloadthe payload to send (encapsulated in a GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG).
payload_sizenumber of bytes in payload

Definition at line 4768 of file gnunet-service-transport.c.

4772{
4773 struct Neighbour *n = queue->neighbour;
4775 struct GNUNET_MQ_Envelope *env;
4776 struct PendingAcknowledgement *pa;
4777
4778 GNUNET_log (
4780 "Queueing %u bytes of payload for transmission <%" PRIu64
4781 "> on queue %llu to %s\n",
4782 (unsigned int) payload_size,
4783 (NULL == pm) ? 0 : pm->logging_uuid,
4784 (unsigned long long) queue->qid,
4785 GNUNET_i2s (&queue->neighbour->pid));
4786 env = GNUNET_MQ_msg_extra (smt,
4787 payload_size,
4789 smt->qid = htonl (queue->qid);
4790 smt->mid = GNUNET_htonll (queue->mid_gen);
4791 smt->receiver = n->pid;
4792 memcpy (&smt[1], payload, payload_size);
4793 {
4794 /* Pass the env to the communicator of queue for transmission. */
4795 struct QueueEntry *qe;
4796
4797 qe = GNUNET_new (struct QueueEntry);
4798 qe->creation_timestamp = GNUNET_TIME_absolute_get ();
4799 qe->mid = queue->mid_gen;
4801 "Create QueueEntry with MID %" PRIu64
4802 " and QID %u and prefix %s\n",
4803 qe->mid,
4804 queue->qid,
4805 queue->tc->details.communicator.address_prefix);
4806 queue->mid_gen++;
4807 qe->queue =