GNUnet  0.20.0
gnunet-service-tng.c File Reference

main for gnunet-service-tng More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_monitor_service.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_signatures.h"
#include "transport.h"
Include dependency graph for gnunet-service-tng.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 initator 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  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 avaliable. 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
 An entry in the operation queue. More...
 
struct  Queue
 Handle for a queue. More...
 
struct  Neighbour
 A connected controller which is not our child. 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  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...
 

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...
 

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 , CT_NONE = 0 , CT_CORE = 1 , CT_MONITOR = 2 ,
  CT_BLACKLIST = 3 , CT_CORE_NO_HANDLERS = 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 void free_neighbour (struct Neighbour *neighbour)
 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 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_with_continue (struct CommunicatorMessageContext *cmc, unsigned int continue_client)
 Send ACK to communicator (if requested) and free cmc. 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 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_HashCode *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 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 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 continue_client)
 
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 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 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 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 struct Queuefind_queue (const struct GNUNET_PeerIdentity *pid, const char *address)
 Find the queue matching pid and address. More...
 
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 meessage. More...
 
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 GNUNET_TIME_Absolute next_attempt)
 
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 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 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 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 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 char * get_address_without_port (const char *address)
 Get the IP address without the port number. 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 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 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 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(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...
 
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_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...
 
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 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...
 

Detailed Description

main for gnunet-service-tng

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-tng.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 87 of file gnunet-service-tng.c.

◆ MAX_FC_RETRANSMIT_COUNT

#define MAX_FC_RETRANSMIT_COUNT   1000

Maximum number of FC retransmissions for a running retransmission task.

Definition at line 92 of file gnunet-service-tng.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 98 of file gnunet-service-tng.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 112 of file gnunet-service-tng.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 118 of file gnunet-service-tng.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 124 of file gnunet-service-tng.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 130 of file gnunet-service-tng.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 140 of file gnunet-service-tng.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 146 of file gnunet-service-tng.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 thoughput, 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 156 of file gnunet-service-tng.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 165 of file gnunet-service-tng.c.

◆ MAX_DV_HOPS_ALLOWED

#define MAX_DV_HOPS_ALLOWED   16

Maximum DV distance allowed ever.

Definition at line 170 of file gnunet-service-tng.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 176 of file gnunet-service-tng.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 181 of file gnunet-service-tng.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 188 of file gnunet-service-tng.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 195 of file gnunet-service-tng.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 201 of file gnunet-service-tng.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 209 of file gnunet-service-tng.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 216 of file gnunet-service-tng.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 223 of file gnunet-service-tng.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 230 of file gnunet-service-tng.c.

◆ EPHEMERAL_VALIDITY

#define EPHEMERAL_VALIDITY    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)

How long are ephemeral keys valid?

Definition at line 236 of file gnunet-service-tng.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 242 of file gnunet-service-tng.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 249 of file gnunet-service-tng.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 255 of file gnunet-service-tng.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 263 of file gnunet-service-tng.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 270 of file gnunet-service-tng.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 276 of file gnunet-service-tng.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 281 of file gnunet-service-tng.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 287 of file gnunet-service-tng.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 296 of file gnunet-service-tng.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 304 of file gnunet-service-tng.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 312 of file gnunet-service-tng.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 319 of file gnunet-service-tng.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 4769 of file gnunet-service-tng.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).

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_BLACKLIST 

It is a blacklist, query about allowed connections.

CT_CORE_NO_HANDLERS 

CORE client without any handlers.

Definition at line 979 of file gnunet-service-tng.c.

980 {
984  CT_NONE = 0,
985 
989  CT_CORE = 1,
990 
994  CT_MONITOR = 2,
995 
999  CT_COMMUNICATOR = 3,
1000 
1004  CT_APPLICATION = 4
1005 };
@ 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 1012 of file gnunet-service-tng.c.

1013 {
1017  RMO_NONE = 0,
1018 
1022  RMO_DV_ALLOWED = 1,
1023 
1028 
1033 
1039  RMO_REDUNDANT = 4
1040 };
@ 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 2091 of file gnunet-service-tng.c.

2092 {
2096  PMT_CORE = 0,
2097 
2101  PMT_FRAGMENT_BOX = 1,
2102 
2106  PMT_RELIABILITY_BOX = 2,
2107 
2111  PMT_DV_BOX = 3
2112 };
@ 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 2897 of file gnunet-service-tng.c.

2898 {
2899  struct GNUNET_TIME_Absolute now;
2900 
2901  now = GNUNET_TIME_absolute_get ();
2902  return now.abs_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us / 15;
2903 }
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 2912 of file gnunet-service-tng.c.

2913 {
2915  GNUNET_assert (ir_total > 0);
2916  ir_total--;
2918  ir->wc = NULL;
2919  GNUNET_free (ir);
2920 }
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_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc)
Cancel a watch request.
struct GNUNET_PEERSTORE_WatchContext * wc
Handle for watching the peerstore for HELLOs for this peer.

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PEERSTORE_watch_cancel(), ir_head, ir_tail, ir_total, and IncomingRequest::wc.

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 2929 of file gnunet-service-tng.c.

2930 {
2931  struct Queue *q = pa->queue;
2932  struct PendingMessage *pm = pa->pm;
2933  struct DistanceVectorHop *dvh = pa->dvh;
2934 
2936  "free_pending_acknowledgement\n");
2937  if (NULL != q)
2938  {
2939  GNUNET_CONTAINER_MDLL_remove (queue, q->pa_head, q->pa_tail, pa);
2940  pa->queue = NULL;
2941  }
2942  if (NULL != pm)
2943  {
2945  "remove pa from message\n");
2947  "remove pa from message %llu\n",
2948  pm->logging_uuid);
2950  "remove pa from message %u\n",
2951  pm->pmt);
2953  "remove pa from message %s\n",
2954  GNUNET_uuid2s (&pa->ack_uuid.value));
2955  GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa);
2956  pa->pm = NULL;
2957  }
2958  if (NULL != dvh)
2959  {
2960  GNUNET_CONTAINER_MDLL_remove (dvh, dvh->pa_head, dvh->pa_tail, pa);
2961  pa->queue = NULL;
2962  }
2965  &pa->ack_uuid.value,
2966  pa));
2967  GNUNET_free (pa);
2968 }
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 2980 of file gnunet-service-tng.c.

2981 {
2982  struct PendingMessage *frag;
2983 
2984  while (NULL != (frag = root->head_frag))
2985  {
2986  struct PendingAcknowledgement *pa;
2987 
2988  free_fragment_tree (frag);
2989  while (NULL != (pa = frag->pa_head))
2990  {
2991  GNUNET_CONTAINER_MDLL_remove (pm, frag->pa_head, frag->pa_tail, pa);
2992  pa->pm = NULL;
2993  }
2994  GNUNET_CONTAINER_MDLL_remove (frag, root->head_frag, root->tail_frag, frag);
2995  if (NULL != frag->qe)
2996  {
2997  GNUNET_assert (frag == frag->qe->pm);
2998  frag->qe->pm = NULL;
2999  }
3001  "Free frag %p\n",
3002  frag);
3003  GNUNET_free (frag);
3004  }
3005 }
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 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_pending_message().

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 3016 of file gnunet-service-tng.c.

3017 {
3018  struct TransportClient *tc = pm->client;
3019  struct VirtualLink *vl = pm->vl;
3020  struct PendingAcknowledgement *pa;
3021 
3023  "Freeing pm %p\n",
3024  pm);
3025  if (NULL != tc)
3026  {
3028  tc->details.core.pending_msg_head,
3029  tc->details.core.pending_msg_tail,
3030  pm);
3031  }
3032  if ((NULL != vl) && (NULL == pm->frag_parent))
3033  {
3035  "Removing pm %llu\n",
3036  pm->logging_uuid);
3038  vl->pending_msg_head,
3039  vl->pending_msg_tail,
3040  pm);
3041  }
3042  while (NULL != (pa = pm->pa_head))
3043  {
3044  if (NULL == pa)
3046  "free pending pa null\n");
3047  if (NULL == pm->pa_tail)
3049  "free pending pa_tail null\n");
3050  if (NULL == pa->prev_pa)
3052  "free pending pa prev null\n");
3053  if (NULL == pa->next_pa)
3055  "free pending pa next null\n");
3056  GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa);
3057  pa->pm = NULL;
3058  }
3059 
3061  if (NULL != pm->qe)
3062  {
3063  GNUNET_assert (pm == pm->qe->pm);
3064  pm->qe->pm = NULL;
3065  }
3066  if (NULL != pm->bpm)
3067  {
3068  free_fragment_tree (pm->bpm);
3069  GNUNET_free (pm->bpm);
3070  }
3071 
3072  GNUNET_free (pm);
3074  "Freeing pm done\n");
3075 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:431
struct PendingAcknowledgement * next_pa
Pointers for the DLL of all pending acknowledgements.
struct PendingAcknowledgement * prev_pa
Pointers for the DLL of all pending acknowledgements.
Client connected to the transport service.

References 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, PendingAcknowledgement::prev_pa, 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 3084 of file gnunet-service-tng.c.

3085 {
3086  struct VirtualLink *vl = rc->virtual_link;
3087 
3091  rc->msg_uuid.uuid,
3092  rc));
3093  GNUNET_free (rc);
3094 }
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 3103 of file gnunet-service-tng.c.

3104 {
3105  struct VirtualLink *vl = cls;
3106  struct ReassemblyContext *rc;
3107 
3108  vl->reassembly_timeout_task = NULL;
3109  while (NULL != (rc = GNUNET_CONTAINER_heap_peek (vl->reassembly_heap)))
3110  {
3112  .rel_value_us)
3113  {
3115  continue;
3116  }
3117  GNUNET_assert (NULL == vl->reassembly_timeout_task);
3121  vl);
3122  return;
3123  }
3124 }
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:1249
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:405
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(), VirtualLink::reassembly_heap, ReassemblyContext::reassembly_timeout, VirtualLink::reassembly_timeout_task, and GNUNET_TIME_Relative::rel_value_us.

Referenced by handle_fragment_box().

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 3136 of file gnunet-service-tng.c.

3137 {
3138  struct ReassemblyContext *rc = value;
3139 
3140  (void) cls;
3141  (void) key;
3143  return GNUNET_OK;
3144 }
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 3153 of file gnunet-service-tng.c.

3154 {
3155  struct PendingMessage *pm;
3156  struct CoreSentContext *csc;
3157 
3159  "free virtual link %p\n",
3160  vl);
3161 
3162  if (NULL != vl->reassembly_map)
3163  {
3166  NULL);
3168  vl->reassembly_map = NULL;
3170  vl->reassembly_heap = NULL;
3171  }
3172  if (NULL != vl->reassembly_timeout_task)
3173  {
3175  vl->reassembly_timeout_task = NULL;
3176  }
3177  while (NULL != (pm = vl->pending_msg_head))
3181  if (NULL != vl->visibility_task)
3182  {
3184  vl->visibility_task = NULL;
3185  }
3186  if (NULL != vl->fc_retransmit_task)
3187  {
3189  vl->fc_retransmit_task = NULL;
3190  }
3191  while (NULL != (csc = vl->csc_head))
3192  {
3194  GNUNET_assert (vl == csc->vl);
3195  csc->vl = NULL;
3196  }
3197  GNUNET_break (NULL == vl->n);
3198  GNUNET_break (NULL == vl->dv);
3199  GNUNET_free (vl);
3200 }
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:975
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 3209 of file gnunet-service-tng.c.

3210 {
3211  GNUNET_assert (
3212  GNUNET_YES ==
3215  vs->hn = NULL;
3216  if (NULL != vs->sc)
3217  {
3219  "store cancel\n");
3221  vs->sc = NULL;
3222  }
3223  GNUNET_free (vs->address);
3224  GNUNET_free (vs);
3225 }
static struct GNUNET_CONTAINER_MultiPeerMap * validation_map
Map from PIDs to struct ValidationState entries describing addresses we are aware of and their validi...
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_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PEERSTORE_store_cancel(), GNUNET_YES, ValidationState::pid, 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 3235 of file gnunet-service-tng.c.

3236 {
3238 }
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(), 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 3248 of file gnunet-service-tng.c.

3249 {
3251 }

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 3297 of file gnunet-service-tng.c.

3298 {
3299  struct Neighbour *n = dvh->next_hop;
3300  struct DistanceVector *dv = dvh->dv;
3301  struct PendingAcknowledgement *pa;
3302 
3303  while (NULL != (pa = dvh->pa_head))
3304  {
3306  pa->dvh = NULL;
3307  }
3308  GNUNET_CONTAINER_MDLL_remove (neighbour, n->dv_head, n->dv_tail, dvh);
3310  GNUNET_free (dvh);
3311 }
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 connected controller which is not our child.
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 3709 of file gnunet-service-tng.c.

3710 {
3711  struct VirtualLink *vl = cls;
3712  struct DistanceVector *dv = vl->dv;
3713  struct Neighbour *n = vl->n;
3714  struct GNUNET_TIME_Absolute dvh_timeout;
3715  struct GNUNET_TIME_Absolute q_timeout;
3716 
3718  "Checking if link is down\n");
3719  vl->visibility_task = NULL;
3720  dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
3721  if (NULL != dv)
3722  {
3723  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
3724  pos = pos->next_dv)
3725  dvh_timeout = GNUNET_TIME_absolute_max (dvh_timeout,
3726  pos->path_valid_until);
3727  if (0 == GNUNET_TIME_absolute_get_remaining (dvh_timeout).rel_value_us)
3728  {
3729  vl->dv->vl = NULL;
3730  vl->dv = NULL;
3731  }
3732  }
3733  q_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
3734  for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
3735  q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until);
3736  if (0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us)
3737  {
3738  vl->n->vl = NULL;
3739  vl->n = NULL;
3740  }
3741  if ((NULL == vl->n) && (NULL == vl->dv))
3742  {
3744  free_virtual_link (vl);
3745  return;
3746  }
3747  vl->visibility_task =
3748  GNUNET_SCHEDULER_add_at (GNUNET_TIME_absolute_max (q_timeout, dvh_timeout),
3749  &check_link_down,
3750  vl);
3751 }
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:367
#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 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(), 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 3330 of file gnunet-service-tng.c.

3331 {
3333  "Informing CORE clients about disconnect from %s\n",
3334  GNUNET_i2s (pid));
3335  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3336  {
3337  struct GNUNET_MQ_Envelope *env;
3338  struct DisconnectInfoMessage *dim;
3339 
3340  if (CT_CORE != tc->type)
3341  continue;
3343  dim->peer = *pid;
3344  GNUNET_MQ_send (tc->mq, env);
3345  }
3346 }
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:304
#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:150

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 3356 of file gnunet-service-tng.c.

3357 {
3358  struct DistanceVectorHop *dvh;
3359 
3360  while (NULL != (dvh = dv->dv_head))
3362  if (NULL == dv->dv_head)
3363  {
3364  struct VirtualLink *vl;
3365 
3366  GNUNET_assert (
3367  GNUNET_YES ==
3369  if (NULL != (vl = dv->vl))
3370  {
3371  GNUNET_assert (dv == vl->dv);
3372  vl->dv = NULL;
3373  if (NULL == vl->n)
3374  {
3376  free_virtual_link (vl);
3377  }
3378  else
3379  {
3382  }
3383  dv->vl = NULL;
3384  }
3385 
3386  if (NULL != dv->timeout_task)
3387  {
3389  dv->timeout_task = NULL;
3390  }
3391  GNUNET_free (dv);
3392  }
3393 }
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:1299
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, 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 3410 of file gnunet-service-tng.c.

3415 {
3416  struct GNUNET_MQ_Envelope *env;
3417  struct GNUNET_TRANSPORT_MonitorData *md;
3418  size_t addr_len = strlen (address) + 1;
3419 
3420  env = GNUNET_MQ_msg_extra (md,
3421  addr_len,
3423  md->nt = htonl ((uint32_t) nt);
3424  md->peer = *peer;
3425  md->last_validation = GNUNET_TIME_absolute_hton (me->last_validation);
3426  md->valid_until = GNUNET_TIME_absolute_hton (me->valid_until);
3427  md->next_validation = GNUNET_TIME_absolute_hton (me->next_validation);
3428  md->rtt = GNUNET_TIME_relative_hton (me->rtt);
3429  md->cs = htonl ((uint32_t) me->cs);
3430  md->num_msg_pending = htonl (me->num_msg_pending);
3431  md->num_bytes_pending = htonl (me->num_bytes_pending);
3432  memcpy (&md[1], address, addr_len);
3433  GNUNET_MQ_send (tc->mq, env);
3434 }
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:618
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:638
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References address, env, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_hton(), me, nt, peer, and tc.

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 3447 of file gnunet-service-tng.c.

3451 {
3452  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3453  {
3454  if (CT_MONITOR != tc->type)
3455  continue;
3456  if (tc->details.monitor.one_shot)
3457  continue;
3458  if ((GNUNET_NO == GNUNET_is_zero (&tc->details.monitor.peer)) &&
3459  (0 != GNUNET_memcmp (&tc->details.monitor.peer, peer)))
3460  continue;
3462  }
3463 }
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, 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 3476 of file gnunet-service-tng.c.

3479 {
3480  struct TransportClient *tc;
3481 
3482  (void) cls;
3483  tc = GNUNET_new (struct TransportClient);
3484  tc->client = client;
3485  tc->mq = mq;
3488  "Client %p of type %u connected\n",
3489  tc,
3490  tc->type);
3491  return tc;
3492 }
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.

◆ free_neighbour()

static void free_neighbour ( struct Neighbour neighbour)
static

Release memory used by neighbour.

Parameters
neighbourneighbour entry to free

Definition at line 3501 of file gnunet-service-tng.c.

3502 {
3503  struct DistanceVectorHop *dvh;
3504  struct VirtualLink *vl;
3505 
3506  GNUNET_assert (NULL == neighbour->queue_head);
3509  &neighbour->pid,
3510  neighbour));
3512  "Freeing neighbour\n");
3513  while (NULL != (dvh = neighbour->dv_head))
3514  {
3515  struct DistanceVector *dv = dvh->dv;
3516 
3518  if (NULL == dv->dv_head)
3519  free_dv_route (dv);
3520  }
3521  if (NULL != neighbour->get)
3522  {
3523  GNUNET_PEERSTORE_iterate_cancel (neighbour->get);
3524  neighbour->get = NULL;
3525  }
3526  if (NULL != neighbour->sc)
3527  {
3529  "store cancel\n");
3530  GNUNET_PEERSTORE_store_cancel (neighbour->sc);
3531  neighbour->sc = NULL;
3532  }
3533  if (NULL != (vl = neighbour->vl))
3534  {
3535  GNUNET_assert (neighbour == vl->n);
3536  vl->n = NULL;
3537  if (NULL == vl->dv)
3538  {
3541  }
3542  else
3543  {
3546  }
3547  neighbour->vl = NULL;
3548  }
3549  GNUNET_free (neighbour);
3550 }
static void free_dv_route(struct DistanceVector *dv)
Free entry in dv_routes.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
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_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, VirtualLink::n, neighbours, Neighbour::pid, Neighbour::queue_head, 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 3560 of file gnunet-service-tng.c.

3562 {
3563  struct GNUNET_MQ_Envelope *env;
3564  struct ConnectInfoMessage *cim;
3565 
3566  GNUNET_assert (CT_CORE == tc->type);
3568  cim->id = *pid;
3569  GNUNET_MQ_send (tc->mq, env);
3570 }
#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:118
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:141

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 3579 of file gnunet-service-tng.c.

3580 {
3582  "Informing CORE clients about connection to %s\n",
3583  GNUNET_i2s (pid));
3584  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3585  {
3586  if (CT_CORE != tc->type)
3587  continue;
3589  }
3590 }
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 9903 of file gnunet-service-tng.c.

9904 {
9905  struct Queue *queue = cls;
9906  struct Neighbour *n = queue->neighbour;
9908  struct PendingMessage *pm;
9909 
9910  queue->transmit_task = NULL;
9911  if (NULL == n->vl)
9912  {
9914  "Virtual link `%s' is down, cannot have PM for queue `%s'\n",
9915  GNUNET_i2s (&n->pid),
9916  queue->address);
9917  queue->idle = GNUNET_YES;
9918  return;
9919  }
9920  memset (&sc, 0, sizeof(sc));
9921  select_best_pending_from_link (&sc, queue, n->vl, NULL, 0);
9922  if (NULL == sc.best)
9923  {
9924  /* Also look at DVH that have the n as first hop! */
9925  for (struct DistanceVectorHop *dvh = n->dv_head; NULL != dvh;
9926  dvh = dvh->next_neighbour)
9927  {
9929  queue,
9930  dvh->dv->vl,
9931  dvh,
9932  sizeof(struct GNUNET_PeerIdentity)
9933  * (1 + dvh->distance)
9934  + sizeof(struct TransportDVBoxMessage)
9935  + sizeof(struct TransportDVBoxPayloadP));
9936  }
9937  }
9938  if (NULL == sc.best)
9939  {
9940  /* no message pending, nothing to do here! */
9942  "No pending messages, queue `%s' to %s now idle\n",
9943  queue->address,
9944  GNUNET_i2s (&n->pid));
9945  if (GNUNET_YES == sc.to_early)
9946  schedule_transmit_on_queue (sc.to_early_retry_delay,
9947  queue,
9949  queue->idle = GNUNET_YES;
9950  return;
9951  }
9952  /* There is a message pending, we are certainly not idle */
9953  queue->idle = GNUNET_NO;
9954 
9955  /* Given selection in `sc`, do transmission */
9956  pm = sc.best;
9958  "Selected message <%llu>\n",
9959  pm->logging_uuid);
9960  if (NULL != sc.dvh)
9961  {
9963  "Is this %u a DV box?\n",
9964  pm->pmt);
9965  GNUNET_assert (PMT_DV_BOX != pm->pmt);
9966  if ((NULL != sc.best->bpm) && (sc.best->bpm->used_dvh != sc.dvh))
9967  {
9969  "Discard old box, because we have a new DV path.\n");
9970  free_pending_message (sc.best->bpm);
9971  sc.best->bpm = NULL;
9972  }
9973 
9974  if (NULL == sc.best->bpm)
9975  {
9977  "encapsulate_for_dv 2\n");
9978  encapsulate_for_dv (sc.dvh->dv,
9979  1,
9980  &sc.dvh,
9981  (const struct GNUNET_MessageHeader *) &sc.best[1],
9982  &extract_box_cb,
9983  &sc,
9984  RMO_NONE,
9985  GNUNET_NO);
9986  GNUNET_assert (NULL != sc.best->bpm);
9988  "%lu %lu %lu %lu %u\n",
9989  sizeof(struct GNUNET_PeerIdentity),
9990  sizeof(struct TransportDVBoxMessage),
9991  sizeof(struct TransportDVBoxPayloadP),
9992  sizeof(struct TransportFragmentBoxMessage),
9993  ((const struct GNUNET_MessageHeader *) &sc.best[1])->size);
9994  sc.best->bpm->used_dvh = sc.dvh;
9995  }
9996  pm = sc.best->bpm;
9997  }
9998  if (GNUNET_YES == sc.frag)
9999  {
10000  pm = fragment_message (queue, sc.dvh, pm);
10001  if (NULL == pm)
10002  {
10004  "Fragmentation failed queue %s to %s for <%llu>, trying again\n",
10005  queue->address,
10006  GNUNET_i2s (&n->pid),
10007  sc.best->logging_uuid);
10009  queue,
10011  return;
10012  }
10013  }
10014  else if (GNUNET_YES == sc.relb)
10015  {
10016  pm = reliability_box_message (queue, sc.dvh, pm);
10017  if (NULL == pm)
10018  {
10019  /* Reliability boxing failed, try next message... */
10020  GNUNET_log (
10022  "Reliability boxing failed queue %s to %s for <%llu>, trying again\n",
10023  queue->address,
10024  GNUNET_i2s (&n->pid),
10025  sc.best->logging_uuid);
10027  queue,
10029  return;
10030  }
10031  }
10032 
10033  /* Pass 'pm' for transission to the communicator */
10034  GNUNET_log (
10036  "Passing message <%llu> to queue %s for peer %s (considered %u others)\n",
10037  pm->logging_uuid,
10038  queue->address,
10039  GNUNET_i2s (&n->pid),
10040  sc.consideration_counter);
10041 
10042  /* Flow control: increment amount of traffic sent; if we are routing
10043  via DV (and thus the ultimate target of the pending message is for
10044  a different virtual link than the one of the queue), then we need
10045  to use up not only the window of the direct link but also the
10046  flow control window for the DV link! */
10047  pm->vl->outbound_fc_window_size_used += pm->bytes_msg;
10048 
10049  if (pm->vl != queue->neighbour->vl)
10050  {
10051  /* If the virtual link of the queue differs, this better be distance
10052  vector routing! */
10053  GNUNET_assert (NULL != sc.dvh);
10054  /* If we do distance vector routing, we better not do this for a
10055  message that was itself DV-routed */
10056  GNUNET_assert (PMT_DV_BOX != sc.best->pmt);
10057  /* We use the size of the unboxed message here, to avoid counting
10058  the DV-Box header which is eaten up on the way by intermediaries */
10059  queue->neighbour->vl->outbound_fc_window_size_used += sc.best->bytes_msg;
10060  }
10061  else
10062  {
10063  GNUNET_assert (NULL == sc.dvh);
10064  }
10065 
10066  queue_send_msg (queue, pm, &pm[1], pm->bytes_msg);
10067 
10068  /* Check if this transmission somehow conclusively finished handing 'pm'
10069  even without any explicit ACKs */
10070  if ((PMT_CORE == pm->pmt) ||
10071  (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc))
10072  {
10074  }
10075  else
10076  {
10077  struct GNUNET_TIME_Relative wait_duration;
10078  unsigned int wait_multiplier;
10079 
10080  if (PMT_FRAGMENT_BOX == pm->pmt)
10081  {
10082  struct PendingMessage *root;
10083 
10084  root = pm->frag_parent;
10085  while (NULL != root->frag_parent)
10086  root = root->frag_parent;
10087 
10088  root->frag_count++;
10089  wait_multiplier = (unsigned int) ceil (root->bytes_msg
10090  / (root->frag_off
10091  / root->frag_count)) * 4;
10092  }
10093  else
10094  {
10095  // No fragments, we use 4 RTT before retransmitting.
10096  wait_multiplier = 4;
10097  }
10098 
10099  // Depending on how much pending message the VirtualLink is queueing, we wait longer.
10100  // wait_multiplier = wait_multiplier * pm->vl->pending_msg_num;
10101 
10103  "Wait multiplier %u\n",
10104  wait_multiplier);
10105 
10106  /* Message not finished, waiting for acknowledgement.
10107  Update time by which we might retransmit 's' based on queue
10108  characteristics (i.e. RTT); it takes one RTT for the message to
10109  arrive and the ACK to come back in the best case; but the other
10110  side is allowed to delay ACKs by 2 RTTs, so we use 4 RTT before
10111  retransmitting.
10112 
10113  OPTIMIZE: Note that in the future this heuristic should likely
10114  be improved further (measure RTT stability, consider message
10115  urgency and size when delaying ACKs, etc.) */
10116 
10117  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us !=
10118  queue->pd.aged_rtt.rel_value_us)
10119  wait_duration = queue->pd.aged_rtt;
10120  else
10121  {
10122  wait_duration = DEFAULT_ACK_WAIT_DURATION;
10123  wait_multiplier = 4;
10124  }
10127  wait_duration, wait_multiplier));
10129  wait_duration, wait_multiplier);
10131  "Waiting %s (%s) for ACK until %s\n",
10134  queue->pd.aged_rtt, wait_multiplier), GNUNET_NO),
10139  GNUNET_TIME_relative_multiply (wait_duration,
10140  wait_multiplier)));
10141  }
10142  /* finally, re-schedule queue transmission task itself */
10144  queue,
10146 }
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
static struct PendingMessage * reliability_box_message(struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
Reliability-box the given pm.
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 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 ...
static struct PendingMessage * fragment_message(struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
Fragment the given pm to the given mtu.
#define DEFAULT_ACK_WAIT_DURATION
Default value for how long we wait for reliability ack.
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_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:616
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:484
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
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:569
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().
struct PendingMessage * frag_parent
Our parent in the fragmentation tree.
uint16_t bytes_msg
Size of the original message.
uint16_t frag_off
Offset at which we should generate the next fragment.
uint16_t frag_count
How many fragments do we have?
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, 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 3608 of file gnunet-service-tng.c.

3609 {
3610  for (struct Queue *s = queue_head; NULL != s;
3611  s = s->next_client)
3612  {
3613  if (s->tc->details.communicator.address_prefix !=
3614  queue->tc->details.communicator.address_prefix)
3615  {
3617  "queue address %s qid %u compare with queue: address %s qid %u\n",
3618  queue->address,
3619  queue->qid,
3620  s->address,
3621  s->qid);
3622  if ((s->priority > queue->priority) && (0 < s->q_capacity) &&
3623  (QUEUE_LENGTH_LIMIT > s->queue_length) )
3624  return GNUNET_YES;
3626  "Lower prio\n");
3627  }
3628  }
3629  return GNUNET_NO;
3630 }
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 3641 of file gnunet-service-tng.c.

3644 {
3646  queue->tc->details.communicator.
3647  queue_head))
3648  return;
3649 
3650  if (queue->tc->details.communicator.total_queue_length >=
3652  {
3654  "Transmission throttled due to communicator queue limit\n");
3656  GST_stats,
3657  "# Transmission throttled due to communicator queue limit",
3658  1,
3659  GNUNET_NO);
3660  queue->idle = GNUNET_NO;
3661  return;
3662  }
3663  if (queue->queue_length >= QUEUE_LENGTH_LIMIT)
3664  {
3666  "Transmission throttled due to communicator queue length limit\n");
3668  "# Transmission throttled due to queue queue limit",
3669  1,
3670  GNUNET_NO);
3671  queue->idle = GNUNET_NO;
3672  return;
3673  }
3674  if (0 == queue->q_capacity)
3675  {
3677  "Transmission throttled due to communicator message queue qid %u has capacity %"
3678  PRIu64 ".\n",
3679  queue->qid,
3680  queue->q_capacity);
3682  "# Transmission throttled due to message queue capacity",
3683  1,
3684  GNUNET_NO);
3685  queue->idle = GNUNET_NO;
3686  return;
3687  }
3688  /* queue might indeed be ready, schedule it */
3689  if (NULL != queue->transmit_task)
3690  GNUNET_SCHEDULER_cancel (queue->transmit_task);
3691  queue->transmit_task =
3693  queue);
3695  "Considering transmission on queue `%s' QID %llu to %s\n",
3696  queue->address,
3697  (unsigned long long) queue->qid,
3698  GNUNET_i2s (&queue->neighbour->pid));
3699 }
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
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:1202
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.

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

Referenced by check_vl_transmission(), free_queue(), handle_add_queue_message(), handle_send_message_ack(), 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 3760 of file gnunet-service-tng.c.

3761 {
3762  struct Neighbour *neighbour = queue->neighbour;
3763  struct TransportClient *tc = queue->tc;
3764  struct MonitorEvent me = { .cs = GNUNET_TRANSPORT_CS_DOWN,
3766  struct QueueEntry *qe;
3767  int maxxed;
3768  struct PendingAcknowledgement *pa;
3769  struct VirtualLink *vl;
3770 
3772  "Cleaning up queue %u\n", queue->qid);
3773  if (NULL != queue->transmit_task)
3774  {
3775  GNUNET_SCHEDULER_cancel (queue->transmit_task);
3776  queue->transmit_task = NULL;
3777  }
3778  while (NULL != (pa = queue->pa_head))
3779  {
3780  GNUNET_CONTAINER_MDLL_remove (queue, queue->pa_head, queue->pa_tail, pa);
3781  pa->queue = NULL;
3782  }
3783 
3784  GNUNET_CONTAINER_MDLL_remove (neighbour,
3785  neighbour->queue_head,
3786  neighbour->queue_tail,
3787  queue);
3789  tc->details.communicator.queue_head,
3790  tc->details.communicator.queue_tail,
3791  queue);
3792  maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT <=
3793  tc->details.communicator.
3794  total_queue_length);
3796  "Cleaning up queue with length %u\n",
3797  queue->queue_length);
3798  while (NULL != (qe = queue->queue_head))
3799  {
3800  GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe);
3801  queue->queue_length--;
3802  tc->details.communicator.total_queue_length--;
3803  if (NULL != qe->pm)
3804  {
3805  GNUNET_assert (qe == qe->pm->qe);
3806  qe->pm->qe = NULL;
3807  }
3808  GNUNET_free (qe);
3809  }
3811  "Cleaning up queue with length %u\n",
3812  queue->queue_length);
3813  GNUNET_assert (0 == queue->queue_length);
3814  if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT >
3815  tc->details.communicator.total_queue_length))
3816  {
3817  /* Communicator dropped below threshold, resume all _other_ queues */
3819  GST_stats,
3820  "# Transmission throttled due to communicator queue limit",
3821  -1,
3822  GNUNET_NO);
3823  for (struct Queue *s = tc->details.communicator.queue_head; NULL != s;
3824  s = s->next_client)
3826  s,
3828  }
3829  notify_monitors (&neighbour->pid, queue->address, queue->nt, &me);
3830  GNUNET_free (queue);
3831 
3832  vl = lookup_virtual_link (&neighbour->pid);
3833  if ((NULL != vl) && (neighbour == vl->n))
3834  {
3836  check_link_down (vl);
3837  }
3838  if (NULL == neighbour->queue_head)
3839  {
3840  free_neighbour (neighbour);
3841  }
3842 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void free_neighbour(struct Neighbour *neighbour)
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.
An entry in the operation queue.

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_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 3851 of file gnunet-service-tng.c.

3852 {
3853  struct TransportClient *tc = ale->tc;
3854 
3855  GNUNET_CONTAINER_DLL_remove (tc->details.communicator.addr_head,
3856  tc->details.communicator.addr_tail,
3857  ale);
3858  if (NULL != ale->sc)
3859  {
3861  "store cancel\n");
3863  ale->sc = NULL;
3864  }
3865  if (NULL != ale->st)
3866  {
3867  GNUNET_SCHEDULER_cancel (ale->st);
3868  ale->st = NULL;
3869  }
3870  GNUNET_free (ale);
3871 }
struct TransportClient * tc
Which communicator provides this 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::st, AddressListEntry::tc, and 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 3883 of file gnunet-service-tng.c.

3886 {
3887  struct TransportClient *tc = cls;
3888  struct PeerRequest *pr = value;
3889 
3891  pr->wc = NULL;
3892  GNUNET_assert (
3893  GNUNET_YES ==
3894  GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests,
3895  pid,
3896  pr));
3897  GNUNET_free (pr);
3898 
3899  return GNUNET_OK;
3900 }
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_watch_cancel(), 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 11364 of file gnunet-service-tng.c.

11365 {
11366  struct LearnLaunchEntry *lle;
11367 
11369  "shutdown logic\n");
11370  (void) cls;
11372  &free_neighbour_cb, NULL);
11373  if (NULL != validation_task)
11374  {
11376  validation_task = NULL;
11377  }
11378  if (NULL != dvlearn_task)
11379  {
11381  dvlearn_task = NULL;
11382  }
11383  if (NULL != GST_stats)
11384  {
11386  GST_stats = NULL;
11387  }
11388  if (NULL != GST_my_private_key)
11389  {
11391  GST_my_private_key = NULL;
11392  }
11395  NULL);
11397  ack_cummulators = NULL;
11400  NULL);
11402  pending_acks = NULL;
11405  neighbours = NULL;
11408  links = NULL;
11411  NULL);
11413  backtalkers = NULL;
11416  NULL);
11418  validation_map = NULL;
11419  while (NULL != ir_head)
11421  GNUNET_assert (0 == ir_total);
11422  while (NULL != (lle = lle_head))
11423  {
11425  GNUNET_free (lle);
11426  }
11427  if (NULL != peerstore)
11428  {
11430  "Disconnecting from PEERSTORE service\n");
11432  peerstore = NULL;
11433  }
11435  dvlearn_map = NULL;
11437  validation_heap = NULL;
11440  dv_routes = NULL;
11442 }
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.
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.
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_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_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_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h, int sync_first)
Disconnect from the PEERSTORE service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
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_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_log, GNUNET_NO, GNUNET_PEERSTORE_disconnect(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_destroy(), GST_my_private_key, GST_stats, ir_head, ir_total, links, lle_head, lle_tail, neighbours, peerstore, pending_acks, 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 3915 of file gnunet-service-tng.c.

3918 {
3919  struct TransportClient *tc = app_ctx;
3920 
3921  (void) cls;
3922  (void) client;
3924  switch (tc->type)
3925  {
3926  case CT_NONE:
3928  "Unknown Client %p disconnected, cleaning up.\n",
3929  tc);
3930  break;
3931 
3932  case CT_CORE: {
3934  "CORE Client %p disconnected, cleaning up.\n",
3935  tc);
3936 
3937  struct PendingMessage *pm;
3938 
3939  while (NULL != (pm = tc->details.core.pending_msg_head))
3940  {
3942  tc->details.core.pending_msg_head,
3943  tc->details.core.pending_msg_tail,
3944  pm);
3945  pm->client = NULL;
3946  }
3947  }
3948  break;
3949 
3950  case CT_MONITOR:
3952  "MONITOR Client %p disconnected, cleaning up.\n",
3953  tc);
3954 
3955  break;
3956 
3957  case CT_COMMUNICATOR: {
3959  "COMMUNICATOR Client %p disconnected, cleaning up.\n",
3960  tc);
3961 
3962  struct Queue *q;
3963  struct AddressListEntry *ale;
3964 
3965  while (NULL != (q = tc->details.communicator.queue_head))
3966  free_queue (q);
3967  while (NULL != (ale = tc->details.communicator.addr_head))
3969  GNUNET_free (tc->details.communicator.address_prefix);
3970  }
3971  break;
3972 
3973  case CT_APPLICATION:
3975  "APPLICATION Client %p disconnected, cleaning up.\n",
3976  tc);
3977 
3978  GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
3980  tc);
3981  GNUNET_CONTAINER_multipeermap_destroy (tc->details.application.requests);
3982  break;
3983  }
3984  GNUNET_free (tc);
3985  if ((GNUNET_YES == in_shutdown) && (NULL == clients_head))
3986  {
3988  "Our last client disconnected\n");
3989  do_shutdown (cls);
3990  }
3991 }
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_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 4004 of file gnunet-service-tng.c.

4007 {
4008  struct TransportClient *tc = cls;
4009 
4010  (void) value;
4012  "Telling new CORE client about existing connection to %s\n",
4013  GNUNET_i2s (pid));
4015  return GNUNET_OK;
4016 }

References core_send_connect_info(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, 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:

◆ 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 4028 of file gnunet-service-tng.c.

4029 {
4030  struct TransportClient *tc = cls;
4031  uint32_t options;
4032 
4033  options = ntohl (start->options);
4034  if ((0 != (1 & options)) &&
4035  (0 != GNUNET_memcmp (&start->self, &GST_my_identity)))
4036  {
4037  /* client thinks this is a different peer, reject */
4038  GNUNET_break (0);
4039  GNUNET_SERVICE_client_drop (tc->client);
4040  return;
4041  }
4042  if (CT_NONE != tc->type)
4043  {
4044  GNUNET_break (0);
4045  GNUNET_SERVICE_client_drop (tc->client);
4046  return;
4047  }
4048  tc->type = CT_CORE;
4050  "New CORE client with PID %s registered\n",
4051  GNUNET_i2s (&start->self));
4054  tc);
4056 }
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:39
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
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:2330
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2249

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, neighbours, notify_client_connect_info(), options, 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 4066 of file gnunet-service-tng.c.

4067 {
4068  struct TransportClient *tc = cls;
4069  uint16_t size;
4070  const struct GNUNET_MessageHeader *obmm;
4071 
4072  if (CT_CORE != tc->type)
4073  {
4074  GNUNET_break (0);
4075  return GNUNET_SYSERR;
4076  }
4077  size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
4078  if (size < sizeof(struct GNUNET_MessageHeader))
4079  {
4080  GNUNET_break (0);
4081  return GNUNET_SYSERR;
4082  }
4083  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
4084  if (size != ntohs (obmm->size))
4085  {
4086  GNUNET_break (0);
4087  return GNUNET_SYSERR;
4088  }
4089  return GNUNET_OK;
4090 }
@ GNUNET_SYSERR
static unsigned int size
Size of the "table".
Definition: peer.c:68
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Message used to notify the transport service about a message to be transmitted to another peer.
Definition: transport.h:285
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:289

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 4101 of file gnunet-service-tng.c.

4102 {
4103  struct TransportClient *tc = pm->client;
4104  struct VirtualLink *vl = pm->vl;
4105 
4107  "client send response\n");
4108  if (NULL != tc)
4109  {
4110  struct GNUNET_MQ_Envelope *env;
4111  struct SendOkMessage *so_msg;
4112 
4114  so_msg->peer = vl->target;
4116  "Confirming transmission of <%llu> to %s\n",
4117  pm->logging_uuid,
4118  GNUNET_i2s (&vl->target));
4119  GNUNET_MQ_send (tc->mq, env);
4120  }
4122 }
#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:217
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:251

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 4135 of file gnunet-service-tng.c.

4139 {
4140  uint64_t choices[hops_array_length];
4141  uint64_t num_dv;
4142  unsigned int dv_count;
4143 
4144  /* Pick random vectors, but weighted by distance, giving more weight
4145  to shorter vectors */
4146  num_dv = 0;
4147  dv_count = 0;
4148  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
4149  pos = pos->next_dv)
4150  {
4151  if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
4152  (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
4153  .rel_value_us == 0))
4154  continue; /* pos unconfirmed and confirmed required */
4155  num_dv += MAX_DV_HOPS_ALLOWED - pos->distance;
4156  dv_count++;
4157  }
4158  if (0 == dv_count)
4159  return 0;
4160  if (dv_count <= hops_array_length)
4161  {
4162  dv_count = 0;
4163  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
4164  pos = pos->next_dv)
4165  hops_array[dv_count++] = pos;
4166  return dv_count;
4167  }
4168  for (unsigned int i = 0; i < hops_array_length; i++)
4169  {
4170  int ok = GNUNET_NO;
4171  while (GNUNET_NO == ok)
4172  {
4173  choices[i] =
4175  ok = GNUNET_YES;
4176  for (unsigned int j = 0; j < i; j++)
4177  if (choices[i] == choices[j])
4178  {
4179  ok = GNUNET_NO;
4180  break;
4181  }
4182  }
4183  }
4184  dv_count = 0;
4185  num_dv = 0;
4186  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
4187  pos = pos->next_dv)
4188  {
4189  uint32_t delta = MAX_DV_HOPS_ALLOWED - pos->distance;
4190 
4191  if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
4192  (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
4193  .rel_value_us == 0))
4194  continue; /* pos unconfirmed and confirmed required */
4195  for (unsigned int i = 0; i < hops_array_length; i++)
4196  if ((num_dv <= choices[i]) && (num_dv + delta > choices[i]))
4197  hops_array[dv_count++] = pos;
4198  num_dv += delta;
4199  }
4200  return dv_count;
4201 }
static int ok
Return value from 'main' (0 == success)
#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, ok, options, GNUNET_TIME_Relative::rel_value_us, and RMO_UNCONFIRMED_ALLOWED.

Here is the call 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 4211 of file gnunet-service-tng.c.

4214 {
4215  struct TransportClient *tc = cls;
4216  uint16_t size;
4217 
4218  if (CT_NONE != tc->type)
4219  {
4220  GNUNET_break (0);
4221  return GNUNET_SYSERR;
4222  }
4223  tc->type = CT_COMMUNICATOR;
4224  size = ntohs (cam->header.size) - sizeof(*cam);
4225  if (0 == size)
4226  return GNUNET_OK; /* receive-only communicator */
4228  return GNUNET_OK;
4229 }
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

References CT_COMMUNICATOR, CT_NONE, GNUNET_break, GNUNET_MQ_check_zero_termination, GNUNET_OK, GNUNET_SYSERR, size, and tc.

◆ finish_cmc_handling_with_continue()

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

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

Parameters
cmccontext for which we are done handling the message

Definition at line 4238 of file gnunet-service-tng.c.

4241 {
4242  if (0 != ntohl (cmc->im.fc_on))
4243  {
4244  /* send ACK when done to communicator for flow control! */
4245  struct GNUNET_MQ_Envelope *env;
4246  struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
4247 
4249  "Acknowledge message with flow control id %" PRIu64 "\n",
4250  cmc->im.fc_id);
4252  ack->reserved = htonl (0);
4253  ack->fc_id = cmc->im.fc_id;
4254  ack->sender = cmc->im.neighbour_sender;
4255  GNUNET_MQ_send (cmc->tc->mq, env);
4256  }
4257 
4258  if (GNUNET_YES == continue_client)
4259  {
4261  }
4262  GNUNET_free (cmc);
4263 }
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
struct GNUNET_TRANSPORT_IncomingMessage im
Additional information for flow control and about the sender.
struct TransportClient * tc
Which communicator provided us with the message.
struct GNUNET_MQ_Handle * mq
Message queue to the client.

References TransportClient::client, env, 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, and CommunicatorMessageContext::tc.

Referenced by finish_cmc_handling(), and finish_handling_raw_message().

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

◆ finish_cmc_handling()

static void finish_cmc_handling ( struct CommunicatorMessageContext cmc)
static

Definition at line 4267 of file gnunet-service-tng.c.

4268 {
4270 }
static void finish_cmc_handling_with_continue(struct CommunicatorMessageContext *cmc, unsigned int continue_client)
Send ACK to communicator (if requested) and free cmc.

References finish_cmc_handling_with_continue(), and GNUNET_YES.

Referenced by backtalker_monotime_cb(), free_backtalker(), handle_backchannel_encapsulation(), handle_client_recv_ok(), 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 4283 of file gnunet-service-tng.c.

4284 {
4285  struct TransportClient *tc = cls;
4286  struct VirtualLink *vl;
4287  uint32_t delta;
4288  struct CommunicatorMessageContext *cmc;
4289 
4290  if (CT_CORE != tc->type)
4291  {
4292  GNUNET_break (0);
4293  GNUNET_SERVICE_client_drop (tc->client);
4294  return;
4295  }
4296  vl = lookup_virtual_link (&rom->peer);
4297  if ((NULL == vl) || (GNUNET_NO == vl->confirmed))
4298  {
4300  "# RECV_OK dropped: virtual link unknown",
4301  1,
4302  GNUNET_NO);
4304  return;
4305  }
4306  delta = ntohl (rom->increase_window_delta);
4307  vl->core_recv_window += delta;
4309  "CORE ack receiving message, increased CORE recv window to %u\n",
4310  vl->core_recv_window);
4312  if (vl->core_recv_window <= 0)
4313  return;
4314  /* resume communicators */
4315  while (NULL != (cmc = vl->cmc_tail))
4316  {
4318  finish_cmc_handling (cmc);
4319  }
4320 }
static void finish_cmc_handling(struct CommunicatorMessageContext *cmc)
Context from handle_incoming_msg().
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
Definition: transport.h:276
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Definition: transport.h:271

References VirtualLink::cmc_head, VirtualLink::cmc_tail, VirtualLink::confirmed, VirtualLink::core_recv_window, CT_CORE, delta, finish_cmc_handling(), 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(), 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 4330 of file gnunet-service-tng.c.

4333 {
4334  struct TransportClient *tc = cls;
4335  uint16_t size;
4336 
4337  size = ntohs (cam->header.size) - sizeof(*cam);
4338  if (0 == size)
4339  {
4341  "Receive-only communicator connected\n");
4342  return; /* receive-only communicator */
4343  }
4344  tc->details.communicator.address_prefix =
4345  GNUNET_strdup ((const char *) &cam[1]);
4346  tc->details.communicator.cc =
4347  (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc);
4349  "Communicator with prefix `%s' connected\n",
4350  tc->details.communicator.address_prefix);
4352 }
GNUNET_TRANSPORT_CommunicatorCharacteristics
What characteristics does this communicator have?
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_strdup, 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 4363 of file gnunet-service-tng.c.

4366 {
4367  const struct GNUNET_MessageHeader *inbox;
4368  const char *is;
4369  uint16_t msize;
4370  uint16_t isize;
4371 
4372  (void) cls;
4373  msize = ntohs (cb->header.size) - sizeof(*cb);
4374  inbox = (const struct GNUNET_MessageHeader *) &cb[1];
4375  isize = ntohs (inbox->size);
4376  if (isize >= msize)
4377  {
4378  GNUNET_break (0);
4379  return GNUNET_SYSERR;
4380  }
4381  is = (const char *) inbox;
4382  is += isize;
4383  msize -= isize;
4384  GNUNET_assert (0 < msize);
4385  if ('\0' != is[msize - 1])
4386  {
4387  GNUNET_break (0);
4388  return GNUNET_SYSERR;
4389  }
4390  return GNUNET_OK;
4391 }
struct GNUNET_TESTING_Interpreter * is

References GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, 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 4400 of file gnunet-service-tng.c.

4401 {
4402  struct EphemeralConfirmationPS ec;
4403 
4405  dv->ephemeral_validity =
4407  ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
4408  ec.target = dv->target;
4409  ec.ephemeral_key = dv->ephemeral_key;
4410  ec.sender_monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime);
4411  ec.purpose.size = htonl (sizeof(ec));
4413  &ec,
4414  &dv->sender_sig);
4415 }
#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...
#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:450
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:860
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_EcdhePublicKey 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.

Here is the call 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 4428 of file gnunet-service-tng.c.

4432 {
4433  struct Neighbour *n = queue->neighbour;
4434  struct GNUNET_TRANSPORT_SendMessageTo *smt;
4435  struct GNUNET_MQ_Envelope *env;
4436  struct PendingAcknowledgement *pa;
4437 
4438  GNUNET_log (
4440  "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n",
4441  (unsigned int) payload_size,
4442  (NULL == pm) ? 0 : pm->logging_uuid,
4443  (unsigned long long) queue->qid,
4444  GNUNET_i2s (&queue->neighbour->pid));
4445  env = GNUNET_MQ_msg_extra (smt,
4446  payload_size,
4448  smt->qid = htonl (queue->qid);
4449  smt->mid = GNUNET_htonll (queue->mid_gen);
4450  smt->receiver = n->pid;
4451  memcpy (&smt[1], payload, payload_size);
4452  {
4453  /* Pass the env to the communicator of queue for transmission. */
4454  struct QueueEntry *qe;
4455 
4456  qe = GNUNET_new (struct QueueEntry);
4457  qe->mid = queue->mid_gen;
4459  "Create QueueEntry with MID %" PRIu64
4460  " and QID %u and prefix %s\n",
4461  qe->mid,
4462  queue->qid,
4463  queue->tc->details.communicator.address_prefix);
4464  queue->mid_gen++;
4465  qe->queue = queue;
4466  if (NULL != pm)
4467  {
4468  qe->pm = pm;
4469  // TODO Why do we have a retransmission. When we know, make decision if we still want this.
4470  // GNUNET_assert (NULL == pm->qe);
4471  if (NULL != pm->qe)
4472  {
4474  "Retransmitting message <%llu> remove pm from qe with MID: %llu \n",
4475  pm->logging_uuid,
4476  (unsigned long long) pm->qe->mid);
4477  pm->qe->pm = NULL;
4478  }
4479  pm->qe = qe;
4480  }
4481  GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe);
4482  GNUNET_assert (CT_COMMUNICATOR == queue->tc->type);
4483  if (0 == queue->q_capacity)
4484  {
4485  // Messages without FC or fragments can get here.
4486  if (NULL != pm)
4488  "Message %llu (pm type %u) was not send because queue has no capacity.\n",
4489  pm->logging_uuid,
4490  pm->pmt);
4491  GNUNET_free (env);
4492  return;
4493  }
4494  queue->queue_length++;
4495  queue->tc->details.communicator.total_queue_length++;
4496  if (GNUNET_NO == queue->unlimited_length)
4497  queue->q_capacity--;
4499  "Queue %s with qid %u has capacity %" PRIu64 "\n",
4500  queue->address,
4501  queue->qid,
4502  queue->q_capacity);
4504  queue->tc->details.communicator.total_queue_length)
4505  queue->idle = GNUNET_NO;
4506  if (QUEUE_LENGTH_LIMIT == queue->queue_length)
4507  queue->idle = GNUNET_NO;
4508  if (0 == queue->q_capacity)
4509  queue->idle = GNUNET_NO;
4510 
4511  if (NULL != pm && NULL != (pa = pm->pa_head))
4512  {
4513  while (pm != pa->pm)
4514  pa = pa->next_pa;
4515  pa->num_send++;
4516  }
4517  // GNUNET_CONTAINER_multiuuidmap_get (pending_acks, &ack[i].ack_uuid.value);
4519  "Sending message MID %" PRIu64
4520  " of type %u (%u) and size %lu with MQ %p QID %u\n",
4521  GNUNET_ntohll (smt->mid),
4522  ntohs (((const struct GNUNET_MessageHeader *) payload)->type),
4523  ntohs (smt->header.size),
4524  (unsigned long) payload_size,
4525  queue->tc->mq,
4526  queue->qid);
4527  GNUNET_MQ_send (queue->tc->mq, env);
4528  }
4529 }
static unsigned long long payload
How much data are we currently storing in the database?
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
unsigned int num_send
How often the PendingMessage was send via the Queue of this PendingAcknowledgement.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References COMMUNICATOR_TOTAL_QUEUE_LIMIT, CT_COMMUNICATOR, env, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_htonll(), GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_ntohll(), PendingAcknowledgement::next_pa, PendingAcknowledgement::num_send, payload, Neighbour::pid, PendingAcknowledgement::pm, pm, qe, queue(), QUEUE_LENGTH_LIMIT, and type.

Referenced by start_dv_learn(), transmit_on_queue(), and validation_transmit_on_queue().

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

◆ route_via_neighbour()

static struct GNUNET_TIME_Relative route_via_neighbour ( const struct Neighbour n,
const struct GNUNET_MessageHeader hdr,
enum RouteMessageOptions  options 
)
static

Pick a queue of n under constraints options and schedule transmission of hdr.

Parameters
nneighbour to send to
hdrmessage to send as payload
optionswhether queues must be confirmed or not, and whether we may pick multiple (2) queues
Returns
expected RTT for transmission, GNUNET_TIME_UNIT_FOREVER_REL if sending failed

Definition at line 4428 of file gnunet-service-tng.c.

4546 {
4547  struct GNUNET_TIME_Absolute now;
4548  unsigned int candidates;
4549  unsigned int sel1;
4550  unsigned int sel2;
4551  struct GNUNET_TIME_Relative rtt;
4552 
4553  /* Pick one or two 'random' queues from n (under constraints of options) */
4554  now = GNUNET_TIME_absolute_get ();
4555  /* FIXME-OPTIMIZE: give queues 'weights' and pick proportional to
4556  weight in the future; weight could be assigned by observed
4557  bandwidth (note: not sure if we should do this for this type
4558  of control traffic though). */
4559  candidates = 0;
4560  for (struct Queue *pos = n->queue_head; NULL != pos;
4561  pos = pos->next_neighbour)
4562  {
4563  if ((0 != (options & RMO_UNCONFIRMED_ALLOWED)) ||
4564  (pos->validated_until.abs_value_us > now.abs_value_us))
4565  candidates++;
4566  }
4567  if (0 == candidates)
4568  {
4569  /* This can happen rarely if the last confirmed queue timed
4570  out just as we were beginning to process this message. */
4572  "Could not route message of type %u to %s: no valid queue\n",
4573  ntohs (hdr->type),
4574  GNUNET_i2s (&n->pid));
4576  "# route selection failed (all no valid queue)",
4577  1,
4578  GNUNET_NO);
4580  }
4581 
4584  if (0 == (options & RMO_REDUNDANT))
4585  sel2 = candidates; /* picks none! */
4586  else
4588  candidates = 0;
4589  for (struct Queue *pos = n->queue_head; NULL != pos;
4590  pos = pos->next_neighbour)
4591  {
4592  if ((0 != (options & RMO_UNCONFIRMED_ALLOWED)) ||
4593  (pos->validated_until.abs_value_us > now.abs_value_us))
4594  {
4595  if ((sel1 == candidates) || (sel2 == candidates))
4596  {
4598  "Routing message of type %u to %s using %s (#%u)\n",
4599  ntohs (hdr->type),
4600  GNUNET_i2s (&n->pid),
4601  pos->address,
4602  (sel1 == candidates) ? 1 : 2);
4603  rtt = GNUNET_TIME_relative_min (rtt, pos->pd.aged_rtt);
4604  queue_send_msg (pos, NULL, hdr, ntohs (hdr->size));
4605  }
4606  candidates++;
4607  }
4608  }
4609  return rtt;
4610 }
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_ERROR_TYPE_INFO
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition: time.c:343
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct Queue * next_neighbour
Kept in a MDLL.

Referenced by forward_dv_box(), forward_dv_learn(), handle_communicator_backchannel(), handle_validation_challenge(), route_control_message_without_fc(), and transmit_cummulative_ack_cb().

Here is the caller graph for this function:

◆ dv_setup_key_state_from_km()

static void dv_setup_key_state_from_km ( const struct GNUNET_HashCode km,
const struct GNUNET_ShortHashCode iv,
struct DVKeyState key 
)
static

Given the key material in km and the initialization vector iv, setup the key material for the backchannel in key.

Parameters
kmraw master secret
ivinitialization vector
[out]keysymmetric cipher and HMAC state to generate

Definition at line 4655 of file gnunet-service-tng.c.

4658 {
4659  /* must match what we defive from decapsulated key */
4661  GNUNET_CRYPTO_kdf (&key->material,
4662  sizeof(key->material),
4663  "transport-backchannel-key",
4664  strlen ("transport-backchannel-key"),
4665  km,
4666  sizeof(*km),
4667  iv,
4668  sizeof(*iv),
4669  NULL));
4671  "Deriving backchannel key based on KM %s and IV %s\n",
4672  GNUNET_h2s (km),
4673  GNUNET_sh2s (iv));
4674  GNUNET_assert (0 == gcry_cipher_open (&key->cipher,
4675  GCRY_CIPHER_AES256 /* low level: go for speed */,
4676  GCRY_CIPHER_MODE_CTR,
4677  0 /* flags */));
4678  GNUNET_assert (0 == gcry_cipher_setkey (key->cipher,
4679  &key->material.aes_key,
4680  sizeof(key->material.aes_key)));
4681  gcry_cipher_setctr (key->cipher,
4682  &key->material.aes_ctr,
4683  sizeof(key->material.aes_ctr));
4684 }
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
Definition: crypto_kdf.c:70
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).

References GNUNET_assert, GNUNET_CRYPTO_kdf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_sh2s(), GNUNET_YES, and key.

Referenced by handle_dv_box().

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

◆ dv_hmac()

static void dv_hmac ( const struct DVKeyState key,
struct GNUNET_HashCode hmac,
const void *  data,
size_t  data_size 
)
static

Do HMAC calculation for backchannel messages over data using key material from key.

Parameters
keykey material (from DH)
[out]hmacset to the HMAC
datadata to perform HMAC calculation over
data_sizenumber of bytes in data

Definition at line 4697 of file gnunet-service-tng.c.

4701 {
4702  GNUNET_CRYPTO_hmac (&key->material.hmac_key, data, data_size, hmac);
4703 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t data
The data value.
void GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104)
Definition: crypto_hash.c:330

References data, data_size, GNUNET_CRYPTO_hmac(), and key.

Referenced by handle_dv_box().

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

◆ dv_encrypt()

static void dv_encrypt ( struct DVKeyState key,
const void *  in,
void *  dst,
size_t  in_size 
)
static

Perform backchannel encryption using symmetric secret in key to encrypt data from in to dst.

Parameters
[in,out]keykey material to use
dstwhere to write the result
ininput data to encrypt (plaintext)
in_sizenumber of bytes of input in in and available at dst

Definition at line 4716 of file gnunet-service-tng.c.

4717 {
4718  GNUNET_assert (0 ==
4719  gcry_cipher_encrypt (key->cipher, dst, in_size, in, in_size));
4720 }

◆ dv_decrypt()

static enum GNUNET_GenericReturnValue dv_decrypt ( struct DVKeyState key,
void *  out,
const void *  ciph,
size_t  out_size 
)
static

Perform backchannel encryption using symmetric secret in key to encrypt data from in to dst.

Parameters
[in,out]keykey material to use
ciphcipher text to decrypt
[out]outoutput data to generate (plaintext)
out_sizenumber of bytes of input in ciph and available in out
Returns
GNUNET_OK on success

Definition at line 4716 of file gnunet-service-tng.c.

4738 {
4739  return (0 ==
4740  gcry_cipher_decrypt (key->cipher,
4741  out, out_size,
4742  ciph, out_size)) ? GNUNET_OK : GNUNET_SYSERR;
4743 }

References GNUNET_assert, and key.

Referenced by handle_dv_box().

Here is the caller graph for this function:

◆ dv_key_clean()

static void dv_key_clean ( struct DVKeyState key)
static

Clean up key material in key.

Parameters
keykey material to clean up (memory must not be free'd!)

Definition at line 4752 of file gnunet-service-tng.c.

4753 {
4754  gcry_cipher_close (key->cipher);
4755  GNUNET_CRYPTO_zero_keys (&key->material, sizeof(key->material));
4756 }
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.

References GNUNET_CRYPTO_zero_keys(), and key.

Referenced by handle_dv_box().

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

◆ encapsulate_for_dv()

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 
)
static

Pick a path of dv under constraints options and schedule transmission of hdr.

Parameters
targetneighbour to ultimately send to
num_dvhslength of the dvhs array
dvhsarray of hops to send the message to
hdrmessage to send as payload
usefunction to call with the encapsulated message
use_clsclosure for use
optionswhether path must be confirmed or not, to be passed to use
without_fcshall this TransportDVBoxMessage be forwarded without flow control.
Returns
expected RTT for transmission, GNUNET_TIME_UNIT_FOREVER_REL if sending failed

Definition at line 4769 of file gnunet-service-tng.c.

4797 {
4798  struct TransportDVBoxMessage box_hdr;
4799  struct TransportDVBoxPayloadP payload_hdr;
4800  uint16_t enc_body_size = ntohs (hdr->size);
4801  char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN;
4802  struct DVKeyState *key;
4803  struct GNUNET_TIME_Relative rtt;
4804  struct GNUNET_HashCode k;
4805 
4806  key = GNUNET_new (struct DVKeyState);
4807  /* Encrypt payload */
4808  box_hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX);
4809  box_hdr.total_hops = htons (0);
4810  box_hdr.without_fc = htons (without_fc);
4811  // update_ephemeral (dv);
4812  if (0 ==
4814  {
4816  &dv->ephemeral_key,
4817  &k);
4818  sign_ephemeral (dv);
4819  }
4820  box_hdr.ephemeral_key = dv->ephemeral_key;
4821  payload_hdr.sender_sig = dv->sender_sig;
4822 
4824  &box_hdr.iv,
4825  sizeof(box_hdr.iv));
4826  // We are creating this key, so this must work.
4827  // FIXME: Possibly also add return values here. We are processing
4828  // Input from other peers...
4829  dv_setup_key_state_from_km (&k, &box_hdr.iv, key);
4830  payload_hdr.sender = GST_my_identity;
4831  payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime);
4832  dv_encrypt (key, &payload_hdr, enc, sizeof(payload_hdr));
4833  dv_encrypt (key,
4834  hdr,
4835  &enc[sizeof(struct TransportDVBoxPayloadP)],
4836  enc_body_size);
4837  dv_hmac (key, &box_hdr.hmac, enc, sizeof(enc));
4838  dv_key_clean (key);
4840  /* For each selected path, take the pre-computed header and body
4841  and add the path in the middle of the message; then send it. */
4842  for (unsigned int i = 0; i < num_dvhs; i++)
4843  {
4844  struct DistanceVectorHop *dvh = dvhs[i];
4845  unsigned int num_hops = dvh->distance + 1;
4846  char buf[sizeof(struct TransportDVBoxMessage)
4847  + sizeof(struct GNUNET_PeerIdentity) * num_hops
4848  + sizeof(struct TransportDVBoxPayloadP)
4849  + enc_body_size] GNUNET_ALIGN;
4850  struct GNUNET_PeerIdentity *dhops;
4851 
4852  box_hdr.header.size = htons (sizeof(buf));
4853  box_hdr.orig_size = htons (sizeof(buf));
4854  box_hdr.num_hops = htons (num_hops);
4855  memcpy (buf, &box_hdr, sizeof(box_hdr));
4856  dhops = (struct GNUNET_PeerIdentity *) &buf[sizeof(box_hdr)];
4857  memcpy (dhops,
4858  dvh->path,
4859  dvh->distance * sizeof(struct GNUNET_PeerIdentity));
4860  dhops[dvh->distance] = dv->target;
4861  if (GNUNET_EXTRA_LOGGING > 0)
4862  {
4863  char *path;
4864 
4866  for (unsigned int j = 0; j < num_hops; j++)
4867  {
4868  char *tmp;
4869 
4870  GNUNET_asprintf (&tmp, "%s-%s", path, GNUNET_i2s (&dhops[j]));
4871  GNUNET_free (path);
4872  path = tmp;
4873  }
4875  "Routing message of type %u to %s using DV (#%u/%u) via %s\n",
4876  ntohs (hdr->type),
4877  GNUNET_i2s (&dv->target),
4878  i + 1,
4879  num_dvhs,
4880  path);
4881  GNUNET_free (path);
4882  }
4883  rtt = GNUNET_TIME_relative_min (rtt, dvh->pd.aged_rtt);
4884  memcpy (&dhops[num_hops], enc, sizeof(enc));
4885  use (use_cls,
4886  dvh->next_hop,
4887  (const struct GNUNET_MessageHeader *) buf,
4888  options);
4889  GNUNET_free (key);
4890  }
4891  return rtt;
4892 }
static OpusEncoder * enc
OPUS encoder.
static char buf[2048]
static void dv_key_clean(struct DVKeyState *key)
Clean up key material in key.
static void sign_ephemeral(struct DistanceVector *dv)
Sign ephemeral keys in our dv are current.
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.
static void dv_setup_key_state_from_km(const struct GNUNET_HashCode *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 backcha...
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.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_encaps(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *c, struct GNUNET_HashCode *key_material)
Encapsulate key material for a EdDSA public key.
Definition: crypto_ecc.c:794
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_EXTRA_LOGGING
define GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source tree where gnunet_config....
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX
Source-routed transport message based DV information gathered.
Structure of the key material used to encrypt backchannel messages.
struct PerformanceData pd
Performance data for this transmission possibility.
unsigned int distance
Number of hops in total to the target (excluding next_hop and target itself).
const struct GNUNET_PeerIdentity * path
Array of distance hops to the target, excluding next_hop.
A 512-bit hashcode.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
struct GNUNET_TIME_Relative aged_rtt
Weighted average for the RTT.
uint16_t num_hops
Number of hops this messages includes.

Referenced by transmit_on_queue().

Here is the caller graph for this function:

◆ send_dv_to_neighbour()

static void send_dv_to_neighbour ( void *  cls,
struct Neighbour next_hop,
const struct GNUNET_MessageHeader hdr,
enum RouteMessageOptions  options 
)
static

Wrapper around route_via_neighbour() that matches the DVMessageHandler structure.

Parameters
clsunused
next_hopwhere to send next
hdrheader of the message to send
optionsmessage options for queue selection

Definition at line 4905 of file gnunet-service-tng.c.

4909 {
4910  (void) cls;
4911  (void) route_via_neighbour (next_hop, hdr, RMO_UNCONFIRMED_ALLOWED);
4912 }
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.

◆ route_control_message_without_fc()

static struct GNUNET_TIME_Relative route_control_message_without_fc ( struct VirtualLink vl,
const struct GNUNET_MessageHeader hdr,
enum RouteMessageOptions  options 
)
static

We need to transmit hdr to target.

If necessary, this may involve DV routing. This function routes without applying flow control or congestion control and should only be used for control traffic.

Parameters
targetpeer to receive hdr
hdrheader of the message to route and GNUNET_free()
optionswhich transmission channels are allowed
Returns
expected RTT for transmission, GNUNET_TIME_UNIT_FOREVER_REL if sending failed

Definition at line 4905 of file gnunet-service-tng.c.

4931 {
4932  // struct VirtualLink *vl;
4933  struct Neighbour *n;
4934  struct DistanceVector *dv;
4935  struct GNUNET_TIME_Relative rtt1;
4936  struct GNUNET_TIME_Relative rtt2;
4937  const struct GNUNET_PeerIdentity *target = &vl->target;
4938 
4940  "Trying to route message of type %u to %s without fc\n",
4941  ntohs (hdr->type),
4942  GNUNET_i2s (target));
4943 
4944  // TODO Do this elsewhere. vl should be given as parameter to method.
4945  // vl = lookup_virtual_link (target);
4946  GNUNET_assert (NULL != vl && GNUNET_YES == vl->confirmed);
4947  if (NULL == vl)
4948  return