GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
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  ChallengeNonceP
 Type of a nonce used for challenges. 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  CoreSentContext
 Closure for core_env_sent_cb. 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  ReassemblyContext
 Information we keep for a message that we are reassembling. 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 MAX_CUMMULATIVE_ACKS   64
 Maximum number of messages we acknowledge together in one cummulative 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 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_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 . 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_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_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 void schedule_transmit_on_queue (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 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 (struct CommunicatorMessageContext *cmc)
 Send ACK to communicator (if requested) and free cmc. More...
 
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 update_ephemeral (struct DistanceVector *dv)
 Ensure 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 dh_key_derive_eph_pid (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral, const struct GNUNET_PeerIdentity *target, const struct GNUNET_ShortHashCode *iv, struct DVKeyState *key)
 Derive backchannel encryption key material from priv_ephemeral and target and iv. More...
 
static void dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral, const struct GNUNET_ShortHashCode *iv, struct DVKeyState *key)
 Derive backchannel encryption key material from GST_my_private_key and pub_ephemeral and iv. 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 void 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)
 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 (const struct GNUNET_PeerIdentity *target, 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 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, const struct GNUNET_MessageHeader *msg)
 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 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 cummulative acknowledgement data structure. More...
 
static void transmit_cummulative_ack_cb (void *cls)
 Do the transmission of a cummulative 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 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 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, const 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 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 timestmap. 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 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_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 do_shutdown (void *cls)
 Function called when the service shuts down. More...
 
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(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 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
 Head of a DLL sorted by launch time. More...
 
static struct LearnLaunchEntrylle_tail
 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 PendingAcknowledgementpa_head
 The most recent PA we have created, head of DLL. More...
 
static struct PendingAcknowledgementpa_tail
 The oldest PA we have created, tail of DLL. More...
 
static struct IncomingRequestir_head
 List of incomming 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 unsigned int pa_count
 Number of entries in the pa_head/pa_tail DLL. More...
 
static struct GNUNET_TIME_Absolute hello_mono_time
 Monotonic time we use for HELLOs generated at this time. More...
 

Detailed Description

main for gnunet-service-tng

Author
Christian Grothoff

TODO: Implement next:

Optimizations-Statistics:

Optimizations-DV:

Optimizations-Fragmentation:

Optimizations-internals:

Definition in file gnunet-service-tng.c.

Macro Definition Documentation

◆ MAX_CUMMULATIVE_ACKS

#define MAX_CUMMULATIVE_ACKS   64

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

Larger values may save a bit of bandwidth.

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

Referenced by cummulative_ack().

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

Referenced by handle_flow_control().

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

Referenced by update_pd_age(), and update_performance_data().

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

Referenced by activate_core_visible_dv_path(), and handle_validation_response().

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

Referenced by handle_validation_challenge().

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

Referenced by handle_dv_learn().

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

Referenced by activate_core_visible_dv_path(), and handle_validation_response().

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

Referenced by handle_dv_learn().

◆ MAX_DV_HOPS_ALLOWED

#define MAX_DV_HOPS_ALLOWED   16

Maximum DV distance allowed ever.

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

Referenced by check_dv_learn(), forward_dv_learn(), handle_dv_learn(), and pick_random_dv_hops().

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

Referenced by run(), and start_dv_learn().

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

Referenced by learn_dv_path().

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

Referenced by forward_dv_box().

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

Referenced by check_connection_quality().

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

Referenced by learn_dv_path().

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

Referenced by handle_dv_box().

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

Referenced by learn_dv_path().

◆ EPHEMERAL_VALIDITY

#define EPHEMERAL_VALIDITY   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)

How long are ephemeral keys valid?

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

Referenced by update_ephemeral().

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

Referenced by handle_fragment_box().

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

Referenced by start_address_validation().

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

Referenced by validation_start_cb().

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

Referenced by transmit_cummulative_ack_cb().

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

Referenced by start_dv_learn().

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

Referenced by start_dv_learn().

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

Referenced by handle_validation_response().

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

Referenced by handle_dv_learn(), handle_validation_response(), and start_address_validation().

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

Referenced by update_next_challenge_time().

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

Referenced by handle_validation_response().

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

Referenced by free_queue(), handle_send_message_ack(), queue_send_msg(), and schedule_transmit_on_queue().

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

Referenced by handle_send_message_ack(), queue_send_msg(), and schedule_transmit_on_queue().

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

965 {
969  CT_NONE = 0,
970 
974  CT_CORE = 1,
975 
979  CT_MONITOR = 2,
980 
984  CT_COMMUNICATOR = 3,
985 
989  CT_APPLICATION = 4
990 };
"Application" telling us where to connect (i.e.
We do not know yet (client is fresh).
Is the CORE service, we need to forward traffic to it.
It is a monitor, forward monitor data.
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 997 of file gnunet-service-tng.c.

998 {
1002  RMO_NONE = 0,
1003 
1007  RMO_DV_ALLOWED = 1,
1008 
1013 
1018 
1024  RMO_REDUNDANT = 4
1025 };
We are allowed to use DV routing for this hdr.
Reliable and unreliable, DV and non-DV are all acceptable.
If we have multiple choices, it is OK to send this message over multiple channels at the same time to...
We are allowed to use unconfirmed queues or DV routes for this message.
Only confirmed, non-DV direct neighbours.

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

2028 {
2032  PMT_CORE = 0,
2033 
2037  PMT_FRAGMENT_BOX = 1,
2038 
2042  PMT_RELIABILITY_BOX = 2,
2043 
2047  PMT_DV_BOX = 3
2048 };
Ordinary message received from the CORE service.
Pending message created during forward_dv_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 2795 of file gnunet-service-tng.c.

References GNUNET_TIME_absolute_get(), and GNUNET_TIME_UNIT_MINUTES.

Referenced by update_performance_data().

2796 {
2797  struct GNUNET_TIME_Absolute now;
2798 
2799  now = GNUNET_TIME_absolute_get ();
2800  return now.abs_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us / 15;
2801 }
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Time for absolute times used by GNUnet, in microseconds.
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 2810 of file gnunet-service-tng.c.

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

Referenced by do_shutdown(), and handle_validation_challenge().

2811 {
2813  GNUNET_assert (ir_total > 0);
2814  ir_total--;
2816  GNUNET_free (ir);
2817 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc)
Cancel a watch request.
static struct IncomingRequest * ir_head
List of incomming connections where we are trying to get a connection back established.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PEERSTORE_WatchContext * wc
Handle for watching the peerstore for HELLOs for this peer.
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.
#define GNUNET_free(ptr)
Wrapper around free.
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 2826 of file gnunet-service-tng.c.

References PendingAcknowledgement::ack_uuid, PendingAcknowledgement::dvh, GNUNET_assert, GNUNET_CONTAINER_MDLL_remove, GNUNET_CONTAINER_multiuuidmap_remove(), GNUNET_free, GNUNET_YES, pa_count, DistanceVectorHop::pa_head, Queue::pa_head, PendingMessage::pa_head, DistanceVectorHop::pa_tail, Queue::pa_tail, PendingMessage::pa_tail, pm, PendingAcknowledgement::pm, q, queue(), PendingAcknowledgement::queue, and AcknowledgementUUIDP::value.

Referenced by free_pending_ack_cb(), and handle_acknowledged().

2827 {
2828  struct Queue *q = pa->queue;
2829  struct PendingMessage *pm = pa->pm;
2830  struct DistanceVectorHop *dvh = pa->dvh;
2831 
2833  pa_count--;
2834  if (NULL != q)
2835  {
2837  pa->queue = NULL;
2838  }
2839  if (NULL != pm)
2840  {
2841  GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa);
2842  pa->pm = NULL;
2843  }
2844  if (NULL != dvh)
2845  {
2846  GNUNET_CONTAINER_MDLL_remove (dvh, dvh->pa_head, dvh->pa_tail, pa);
2847  pa->queue = NULL;
2848  }
2851  &pa->ack_uuid.value,
2852  pa));
2853  GNUNET_free (pa);
2854 }
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs that used our path.
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs for this pending message.
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs that used this queue.
struct DistanceVectorHop * dvh
Distance vector path chosen for this transmission, NULL if transmission was to a direct neighbour OR ...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_Uuid value
The UUID value.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs that used this queue.
int 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.
Handle for a queue.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs for this pending message.
static struct GNUNET_CONTAINER_MultiUuidmap * pending_acks
Map of pending acknowledgements, mapping struct AcknowledgementUUID to a struct PendingAcknowledgemen...
static unsigned int pa_count
Number of entries in the pa_head/pa_tail DLL.
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs that used our path.
static struct PendingAcknowledgement * pa_tail
The oldest PA we have created, tail of DLL.
One possible hop towards a DV target.
struct PendingMessage * pm
Message that was transmitted, may be NULL if the message was ACKed via another channel.
List containing all messages that are yet to be send.
struct Queue * queue
Queue used for transmission, NULL if the queue has been destroyed (which may happen before we get an ...
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct PendingAcknowledgement * pa_head
The most recent PA we have created, head of DLL.
struct AcknowledgementUUIDP ack_uuid
Unique identifier for this transmission operation.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
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 2866 of file gnunet-service-tng.c.

References GNUNET_CONTAINER_MDLL_remove, GNUNET_free, PendingMessage::head_frag, PendingMessage::pa_head, PendingMessage::pa_tail, pm, PendingAcknowledgement::pm, and PendingMessage::tail_frag.

Referenced by completed_pending_message(), and free_pending_message().

2867 {
2868  struct PendingMessage *frag;
2869 
2870  while (NULL != (frag = root->head_frag))
2871  {
2872  struct PendingAcknowledgement *pa;
2873 
2874  free_fragment_tree (frag);
2875  while (NULL != (pa = frag->pa_head))
2876  {
2877  GNUNET_CONTAINER_MDLL_remove (pm, frag->pa_head, frag->pa_tail, pa);
2878  pa->pm = NULL;
2879  }
2880  GNUNET_CONTAINER_MDLL_remove (frag, root->head_frag, root->tail_frag, frag);
2881  GNUNET_free (frag);
2882  }
2883 }
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs for this pending message.
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.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs for this pending message.
struct PendingMessage * pm
Message that was transmitted, may be NULL if the message was ACKed via another channel.
List containing all messages that are yet to be send.
struct PendingMessage * head_frag
Head of a MDLL of fragments created for this core message.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
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 2894 of file gnunet-service-tng.c.

References PendingMessage::bpm, PendingMessage::client, TransportClient::core, TransportClient::details, free_fragment_tree(), GNUNET_assert, GNUNET_CONTAINER_MDLL_remove, GNUNET_free, PendingMessage::pa_head, PendingMessage::pa_tail, VirtualLink::pending_msg_head, VirtualLink::pending_msg_tail, PendingAcknowledgement::pm, QueueEntry::pm, PendingMessage::qe, tc, and PendingMessage::vl.

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

2895 {
2896  struct TransportClient *tc = pm->client;
2897  struct VirtualLink *vl = pm->vl;
2898  struct PendingAcknowledgement *pa;
2899 
2900  if (NULL != tc)
2901  {
2903  tc->details.core.pending_msg_head,
2904  tc->details.core.pending_msg_tail,
2905  pm);
2906  }
2907  if (NULL != vl)
2908  {
2910  vl->pending_msg_head,
2911  vl->pending_msg_tail,
2912  pm);
2913  }
2914  while (NULL != (pa = pm->pa_head))
2915  {
2916  GNUNET_CONTAINER_MDLL_remove (pm, pm->pa_head, pm->pa_tail, pa);
2917  pa->pm = NULL;
2918  }
2919 
2920  free_fragment_tree (pm);
2921  if (NULL != pm->qe)
2922  {
2923  GNUNET_assert (pm == pm->qe->pm);
2924  pm->qe->pm = NULL;
2925  }
2926  if (NULL != pm->bpm)
2927  {
2928  free_fragment_tree (pm->bpm);
2929  GNUNET_free (pm->bpm);
2930  }
2931  GNUNET_free (pm);
2932 }
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs for this pending message.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
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 QueueEntry * qe
Set to non-NULL value if this message is currently being given to a communicator and we are awaiting ...
struct PendingMessage * bpm
This message, reliability or DV-boxed.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
struct TransportClient::@72::@73 core
Information for type CT_CORE.
struct PendingMessage * pm
Pending message this entry is for, or NULL for none.
struct TransportClient * client
Client that issued the transmission request, if pmt is PMT_CORE.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs for this pending message.
struct VirtualLink * vl
Target of the request (always the ultimate destination!).
struct PendingMessage * pm
Message that was transmitted, may be NULL if the message was ACKed via another channel.
Client connected to the transport service.
union TransportClient::@72 details
#define GNUNET_free(ptr)
Wrapper around free.
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 2941 of file gnunet-service-tng.c.

References VirtualLink::csc_head, VirtualLink::csc_tail, VirtualLink::dv, VirtualLink::fc_retransmit_task, free_pending_message(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_YES, VirtualLink::n, VirtualLink::pending_msg_head, pm, VirtualLink::target, VirtualLink::visibility_task, and CoreSentContext::vl.

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

2942 {
2943  struct PendingMessage *pm;
2944  struct CoreSentContext *csc;
2945 
2946  while (NULL != (pm = vl->pending_msg_head))
2947  free_pending_message (pm);
2950  if (NULL != vl->visibility_task)
2951  {
2953  vl->visibility_task = NULL;
2954  }
2955  if (NULL != vl->fc_retransmit_task)
2956  {
2958  vl->fc_retransmit_task = NULL;
2959  }
2960  while (NULL != (csc = vl->csc_head))
2961  {
2963  GNUNET_assert (vl == csc->vl);
2964  csc->vl = NULL;
2965  }
2966  GNUNET_break (NULL == vl->n);
2967  GNUNET_break (NULL == vl->dv);
2968  GNUNET_free (vl);
2969 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Closure for core_env_sent_cb.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int 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.
struct VirtualLink * vl
Virtual link this is about.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_CONTAINER_MultiPeerMap * links
Map from PIDs to struct VirtualLink entries describing links CORE knows to exist. ...
List containing all messages that are yet to be send.
#define GNUNET_YES
Definition: gnunet_common.h:77
static void free_pending_message(struct PendingMessage *pm)
Release memory associated with pm and remove pm from associated data structures.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 2978 of file gnunet-service-tng.c.

References GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_PEERSTORE_store_cancel(), GNUNET_YES, and ValidationState::pid.

Referenced by free_validation_state_cb(), and validation_start_cb().

2979 {
2980  GNUNET_assert (
2981  GNUNET_YES ==
2984  vs->hn = NULL;
2985  if (NULL != vs->sc)
2986  {
2988  vs->sc = NULL;
2989  }
2990  GNUNET_free (vs->address);
2991  GNUNET_free (vs);
2992 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int 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.
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...
#define GNUNET_YES
Definition: gnunet_common.h:77
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
#define GNUNET_free(ptr)
Wrapper around free.
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 3002 of file gnunet-service-tng.c.

References GNUNET_CONTAINER_multipeermap_get().

Referenced by find_queue(), handle_add_queue_message(), handle_dv_box(), handle_dv_learn(), handle_fragment_box(), handle_validation_challenge(), learn_dv_path(), and route_control_message_without_fc().

3003 {
3005 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Map from PIDs to struct Neighbour entries.
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.
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 3015 of file gnunet-service-tng.c.

References GNUNET_CONTAINER_multipeermap_get().

Referenced by activate_core_visible_dv_path(), free_queue(), handle_client_recv_ok(), handle_client_send(), handle_flow_control(), handle_raw_message(), handle_validation_challenge(), handle_validation_response(), and route_control_message_without_fc().

3016 {
3018 }
static struct GNUNET_CONTAINER_MultiPeerMap * links
Map from PIDs to struct VirtualLink entries describing links CORE knows to exist. ...
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.
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 .

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

References check_link_down(), 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().

3065 {
3066  struct Neighbour *n = dvh->next_hop;
3067  struct DistanceVector *dv = dvh->dv;
3068  struct PendingAcknowledgement *pa;
3069 
3070  while (NULL != (pa = dvh->pa_head))
3071  {
3072  GNUNET_CONTAINER_MDLL_remove (dvh, dvh->pa_head, dvh->pa_tail, pa);
3073  pa->dvh = NULL;
3074  }
3075  GNUNET_CONTAINER_MDLL_remove (neighbour, n->dv_head, n->dv_tail, dvh);
3076  GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, dvh);
3077  GNUNET_free (dvh);
3078 }
A connected controller which is not our child.
struct PendingAcknowledgement * pa_head
Head of DLL of PAs that used our path.
Entry in our dv_routes table, representing a (set of) distance vector routes to a particular peer...
struct DistanceVectorHop * dvh
Distance vector path chosen for this transmission, NULL if transmission was to a direct neighbour OR ...
struct DistanceVectorHop * dv_tail
Known paths to target.
struct DistanceVectorHop * dv_head
Head of MDLL of DV hops that have this neighbour as next hop.
struct DistanceVector * dv
Distance vector entry this hop belongs with.
Data structure kept when we are waiting for an acknowledgement.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
struct DistanceVectorHop * dv_tail
Tail of MDLL of DV hops that have this neighbour as next hop.
struct Neighbour * next_hop
What would be the next hop to target?
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs that used our path.
struct DistanceVectorHop * dv_head
Known paths to target.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
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 3498 of file gnunet-service-tng.c.

References cores_send_disconnect_info(), VirtualLink::dv, DistanceVector::dv_head, free_virtual_link(), 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_distance_vector_hop(), free_dv_route(), free_neighbour(), free_queue(), and handle_validation_response().

3499 {
3500  struct VirtualLink *vl = cls;
3501  struct DistanceVector *dv = vl->dv;
3502  struct Neighbour *n = vl->n;
3503  struct GNUNET_TIME_Absolute dvh_timeout;
3504  struct GNUNET_TIME_Absolute q_timeout;
3505 
3506  vl->visibility_task = NULL;
3507  dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
3508  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
3509  pos = pos->next_dv)
3510  dvh_timeout = GNUNET_TIME_absolute_max (dvh_timeout, pos->path_valid_until);
3511  if (0 == GNUNET_TIME_absolute_get_remaining (dvh_timeout).rel_value_us)
3512  {
3513  vl->dv->vl = NULL;
3514  vl->dv = NULL;
3515  }
3516  q_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
3517  for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
3518  q_timeout = GNUNET_TIME_absolute_max (q_timeout, q->validated_until);
3519  if (0 == GNUNET_TIME_absolute_get_remaining (q_timeout).rel_value_us)
3520  {
3521  vl->n->vl = NULL;
3522  vl->n = NULL;
3523  }
3524  if ((NULL == vl->n) && (NULL == vl->dv))
3525  {
3527  free_virtual_link (vl);
3528  return;
3529  }
3530  vl->visibility_task =
3531  GNUNET_SCHEDULER_add_at (GNUNET_TIME_absolute_max (q_timeout, dvh_timeout),
3532  &check_link_down,
3533  vl);
3534 }
A connected controller which is not our child.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Entry in our dv_routes table, representing a (set of) distance vector routes to a particular peer...
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...
Handle for a queue.
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:317
static void cores_send_disconnect_info(const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
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...
One possible hop towards a DV target.
struct DistanceVectorHop * next_dv
Kept in a MDLL, sorted by timeout.
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:331
Time for absolute times used by GNUnet, in microseconds.
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:1230
struct DistanceVectorHop * dv_head
Known paths to target.
struct Queue * queue_head
Head of DLL of queues to this peer.
static void free_virtual_link(struct VirtualLink *vl)
Free virtual link.
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 3097 of file gnunet-service-tng.c.

References CT_CORE, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT, GNUNET_MQ_msg, GNUNET_MQ_send(), DisconnectInfoMessage::peer, pid, and tc.

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

3098 {
3100  "Informing CORE clients about disconnect from %s\n",
3101  GNUNET_i2s (pid));
3102  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3103  {
3104  struct GNUNET_MQ_Envelope *env;
3105  struct DisconnectInfoMessage *dim;
3106 
3107  if (CT_CORE != tc->type)
3108  continue;
3110  dim->peer = *pid;
3111  GNUNET_MQ_send (tc->mq, env);
3112  }
3113 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
#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:149
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Is the CORE service, we need to forward traffic to it.
struct GNUNET_PeerIdentity peer
Who got disconnected?
Definition: transport.h:164
Client connected to the transport service.
#define GNUNET_log(kind,...)
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:353
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 3123 of file gnunet-service-tng.c.

References check_link_down(), cores_send_disconnect_info(), VirtualLink::dv, DistanceVector::dv_head, 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().

3124 {
3125  struct DistanceVectorHop *dvh;
3126 
3127  while (NULL != (dvh = dv->dv_head))
3129  if (NULL == dv->dv_head)
3130  {
3131  struct VirtualLink *vl;
3132 
3133  GNUNET_assert (
3134  GNUNET_YES ==
3136  if (NULL != (vl = dv->vl))
3137  {
3138  GNUNET_assert (dv == vl->dv);
3139  vl->dv = NULL;
3140  if (NULL == vl->n)
3141  {
3143  free_virtual_link (vl);
3144  }
3145  else
3146  {
3149  }
3150  dv->vl = NULL;
3151  }
3152 
3153  if (NULL != dv->timeout_task)
3154  {
3156  dv->timeout_task = NULL;
3157  }
3158  GNUNET_free (dv);
3159  }
3160 }
struct VirtualLink * vl
Do we have a confirmed working queue and are thus visible to CORE? If so, this is the virtual link...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int 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.
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:1280
static void cores_send_disconnect_info(const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.
struct GNUNET_SCHEDULER_Task * timeout_task
Task scheduled to purge expired paths from dv_head MDLL.
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...
static void free_distance_vector_hop(struct DistanceVectorHop *dvh)
Free a .
One possible hop towards a DV target.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_PeerIdentity target
To which peer is this a route?
struct DistanceVectorHop * dv_head
Known paths to target.
static void free_virtual_link(struct VirtualLink *vl)
Free virtual link.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 3177 of file gnunet-service-tng.c.

References MonitorEvent::cs, env, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_hton(), MonitorEvent::last_validation, TransportClient::mq, MonitorEvent::next_validation, MonitorEvent::num_bytes_pending, MonitorEvent::num_msg_pending, peer, MonitorEvent::rtt, and MonitorEvent::valid_until.

Referenced by notify_client_queues(), and notify_monitors().

3182 {
3183  struct GNUNET_MQ_Envelope *env;
3184  struct GNUNET_TRANSPORT_MonitorData *md;
3185  size_t addr_len = strlen (address) + 1;
3186 
3187  env = GNUNET_MQ_msg_extra (md,
3188  addr_len,
3190  md->nt = htonl ((uint32_t) nt);
3191  md->peer = *peer;
3192  md->last_validation = GNUNET_TIME_absolute_hton (me->last_validation);
3193  md->valid_until = GNUNET_TIME_absolute_hton (me->valid_until);
3194  md->next_validation = GNUNET_TIME_absolute_hton (me->next_validation);
3195  md->rtt = GNUNET_TIME_relative_hton (me->rtt);
3196  md->cs = htonl ((uint32_t) me->cs);
3197  md->num_msg_pending = htonl (me->num_msg_pending);
3198  md->num_bytes_pending = htonl (me->num_bytes_pending);
3199  memcpy (&md[1], address, addr_len);
3200  GNUNET_MQ_send (tc->mq, env);
3201 }
enum GNUNET_TRANSPORT_ConnectionStatus cs
Connection status.
#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:52
struct GNUNET_TIME_Absolute next_validation
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_DATA
Message sent to indicate to a monitor about events.
struct GNUNET_TIME_Absolute valid_until
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
uint32_t num_msg_pending
Messages pending.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_TIME_Absolute last_validation
uint32_t num_bytes_pending
Bytes pending.
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:353
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:657
static char * address
GNS address for this phone.
struct GNUNET_TIME_Relative rtt
Current round-trip time estimate.
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 3214 of file gnunet-service-tng.c.

References CT_MONITOR, GNUNET_is_zero, GNUNET_memcmp, notify_monitor(), and tc.

Referenced by free_queue(), and handle_add_queue_message().

3218 {
3219  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3220  {
3221  if (CT_MONITOR != tc->type)
3222  continue;
3223  if (tc->details.monitor.one_shot)
3224  continue;
3225  if ((0 != GNUNET_is_zero (&tc->details.monitor.peer)) &&
3226  (0 != GNUNET_memcmp (&tc->details.monitor.peer, peer)))
3227  continue;
3228  notify_monitor (tc, peer, address, nt, me);
3229  }
3230 }
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.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#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.
It is a monitor, forward monitor data.
Client connected to the transport service.
static char * address
GNS address for this phone.
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 3243 of file gnunet-service-tng.c.

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

Referenced by run().

3246 {
3247  struct TransportClient *tc;
3248 
3249  (void) cls;
3250  tc = GNUNET_new (struct TransportClient);
3251  tc->client = client;
3252  tc->mq = mq;
3254  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
3255  return tc;
3256 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SERVICE_Client * client
Handle to the client.
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
Client connected to the transport service.
#define GNUNET_log(kind,...)
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 3265 of file gnunet-service-tng.c.

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

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

3266 {
3267  struct Neighbour *n = rc->neighbour;
3268 
3272  rc->msg_uuid.uuid,
3273  rc));
3274  GNUNET_free (rc);
3275 }
A connected controller which is not our child.
struct Neighbour * neighbour
Which neighbour is this context for?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint64_t uuid
Unique value, generated by incrementing the message_uuid_ctr of struct Neighbour. ...
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_CONTAINER_MultiHashMap32 * reassembly_map
Map with struct ReassemblyContext structs for fragments under reassembly.
struct GNUNET_CONTAINER_HeapNode * hn
Entry in the reassembly heap (sorted by expiration).
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
#define GNUNET_free(ptr)
Wrapper around free.
struct MessageUUIDP msg_uuid
Original message ID for of the message that all the fragments belong to.
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 3284 of file gnunet-service-tng.c.

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

Referenced by handle_fragment_box().

3285 {
3286  struct Neighbour *n = cls;
3287  struct ReassemblyContext *rc;
3288 
3289  n->reassembly_timeout_task = NULL;
3290  while (NULL != (rc = GNUNET_CONTAINER_heap_peek (n->reassembly_heap)))
3291  {
3293  .rel_value_us)
3294  {
3296  continue;
3297  }
3302  n);
3303  return;
3304  }
3305 }
A connected controller which is not our child.
uint64_t rel_value_us
The actual value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void reassembly_cleanup_task(void *cls)
Task run to clean up reassembly context of a neighbour that have expired.
Information we keep for a message that we are reassembling.
struct GNUNET_SCHEDULER_Task * reassembly_timeout_task
Task to free old entries from the reassembly_heap and reassembly_map.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
static void free_reassembly_context(struct ReassemblyContext *rc)
Free rc.
struct GNUNET_CONTAINER_Heap * reassembly_heap
Heap with struct ReassemblyContext structs for fragments under reassembly.
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:331
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:1230
struct GNUNET_TIME_Absolute reassembly_timeout
At what time will we give up reassembly of this message?
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 3317 of file gnunet-service-tng.c.

References free_reassembly_context(), GNUNET_OK, and value.

Referenced by free_neighbour().

3318 {
3319  struct ReassemblyContext *rc = value;
3320 
3321  (void) cls;
3322  (void) key;
3324  return GNUNET_OK;
3325 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Information we keep for a message that we are reassembling.
static char * value
Value of the record to add/remove.
struct GNUNET_HashCode key
The key used in the DHT.
static void free_reassembly_context(struct ReassemblyContext *rc)
Free rc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_neighbour()

static void free_neighbour ( struct Neighbour neighbour)
static

Release memory used by neighbour.

Parameters
neighbourneighbour entry to free

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

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_reassembly_cb(), free_virtual_link(), Neighbour::get, GNUNET_assert, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, VirtualLink::n, Neighbour::pid, Neighbour::queue_head, Neighbour::reassembly_heap, Neighbour::reassembly_map, Neighbour::reassembly_timeout_task, Neighbour::sc, VirtualLink::target, VirtualLink::visibility_task, and Neighbour::vl.

Referenced by free_neighbour_cb(), and free_queue().

3335 {
3336  struct DistanceVectorHop *dvh;
3337  struct VirtualLink *vl;
3338 
3339  GNUNET_assert (NULL == neighbour->queue_head);
3342  &neighbour->pid,
3343  neighbour));
3344  if (NULL != neighbour->reassembly_map)
3345  {
3348  NULL);
3350  neighbour->reassembly_map = NULL;
3352  neighbour->reassembly_heap = NULL;
3353  }
3354  while (NULL != (dvh = neighbour->dv_head))
3355  {
3356  struct DistanceVector *dv = dvh->dv;
3357 
3359  if (NULL == dv->dv_head)
3360  free_dv_route (dv);
3361  }
3362  if (NULL != neighbour->reassembly_timeout_task)
3363  {
3365  neighbour->reassembly_timeout_task = NULL;
3366  }
3367  if (NULL != neighbour->get)
3368  {
3369  GNUNET_PEERSTORE_iterate_cancel (neighbour->get);
3370  neighbour->get = NULL;
3371  }
3372  if (NULL != neighbour->sc)
3373  {
3374  GNUNET_PEERSTORE_store_cancel (neighbour->sc);
3375  neighbour->sc = NULL;
3376  }
3377  if (NULL != (vl = neighbour->vl))
3378  {
3379  GNUNET_assert (neighbour == vl->n);
3380  vl->n = NULL;
3381  if (NULL == vl->dv)
3382  {
3384  free_virtual_link (vl);
3385  }
3386  else
3387  {
3390  }
3391  neighbour->vl = NULL;
3392  }
3393  GNUNET_free (neighbour);
3394 }
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Map from PIDs to struct Neighbour entries.
Entry in our dv_routes table, representing a (set of) distance vector routes to a particular peer...
static int free_reassembly_cb(void *cls, uint32_t key, void *value)
function called to free_reassembly_context().
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
struct VirtualLink * vl
Do we have a confirmed working queue and are thus visible to CORE? If so, this is the virtual link...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PEERSTORE_StoreContext * sc
Handle to a PEERSTORE store operation to store this pid's last_dv_learn_monotime. ...
int 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.
struct DistanceVectorHop * dv_head
Head of MDLL of DV hops that have this neighbour as next hop.
struct DistanceVector * dv
Distance vector entry this hop belongs with.
static void free_dv_route(struct DistanceVector *dv)
Free entry in dv_routes.
struct GNUNET_SCHEDULER_Task * reassembly_timeout_task
Task to free old entries from the reassembly_heap and reassembly_map.
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:1280
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
static void cores_send_disconnect_info(const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
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_CONTAINER_MultiHashMap32 * reassembly_map
Map with struct ReassemblyContext structs for fragments under reassembly.
static void free_distance_vector_hop(struct DistanceVectorHop *dvh)
Free a .
One possible hop towards a DV target.
struct GNUNET_CONTAINER_Heap * reassembly_heap
Heap with struct ReassemblyContext structs for fragments under reassembly.
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_IterateContext * get
Handle for an operation to fetch last_dv_learn_monotime information from the PEERSTORE, or NULL.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct DistanceVectorHop * dv_head
Known paths to target.
struct Queue * queue_head
Head of DLL of queues to this peer.
static void free_virtual_link(struct VirtualLink *vl)
Free virtual link.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PeerIdentity pid
Which peer is this about?
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 3404 of file gnunet-service-tng.c.

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

Referenced by cores_send_connect_info(), and notify_client_connect_info().

3406 {
3407  struct GNUNET_MQ_Envelope *env;
3408  struct ConnectInfoMessage *cim;
3409 
3410  GNUNET_assert (CT_CORE == tc->type);
3412  cim->id = *pid;
3413  GNUNET_MQ_send (tc->mq, env);
3414 }
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:141
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
enum ClientType type
What type of client is this?
#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:117
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Is the CORE service, we need to forward traffic to it.
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:353
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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 3423 of file gnunet-service-tng.c.

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

Referenced by activate_core_visible_dv_path(), and handle_validation_response().

3424 {
3426  "Informing CORE clients about connection to %s\n",
3427  GNUNET_i2s (pid));
3428  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
3429  {
3430  if (CT_CORE != tc->type)
3431  continue;
3432  core_send_connect_info (tc, pid);
3433  }
3434 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
Is the CORE service, we need to forward traffic to it.
Client connected to the transport service.
#define GNUNET_log(kind,...)
static void core_send_connect_info(struct TransportClient *tc, const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 8735 of file gnunet-service-tng.c.

References Queue::address, PerformanceData::aged_rtt, PendingMessageScoreContext::best, PendingMessage::bpm, PendingMessage::bytes_msg, TransportClient::communicator, completed_pending_message(), PendingMessageScoreContext::consideration_counter, TransportClient::details, DistanceVectorHop::dv, Neighbour::dv_head, PendingMessageScoreContext::dvh, encapsulate_for_dv(), extract_box_cb(), PendingMessageScoreContext::frag, fragment_message(), free_pending_message(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_CC_RELIABLE, GNUNET_YES, Queue::idle, PendingMessage::logging_uuid, Queue::neighbour, DistanceVectorHop::next_neighbour, VirtualLink::outbound_fc_window_size_used, Queue::pd, Neighbour::pid, pm, PendingMessage::pmt, PMT_CORE, PMT_DV_BOX, queue(), queue_send_msg(), PendingMessageScoreContext::relb, reliability_box_message(), RMO_NONE, schedule_transmit_on_queue(), select_best_pending_from_link(), Queue::tc, Queue::transmit_task, update_pm_next_attempt(), Neighbour::vl, and PendingMessage::vl.

Referenced by cores_send_connect_info(), and schedule_transmit_on_queue().

8736 {
8737  struct Queue *queue = cls;
8738  struct Neighbour *n = queue->neighbour;
8740  struct PendingMessage *pm;
8741 
8742  queue->transmit_task = NULL;
8743  if (NULL == n->vl)
8744  {
8746  "Virtual link `%s' is down, cannot have PM for queue `%s'\n",
8747  GNUNET_i2s (&n->pid),
8748  queue->address);
8749  queue->idle = GNUNET_YES;
8750  return;
8751  }
8752  memset (&sc, 0, sizeof(sc));
8753  select_best_pending_from_link (&sc, queue, n->vl, NULL, 0);
8754  if (NULL == sc.best)
8755  {
8756  /* Also look at DVH that have the n as first hop! */
8757  for (struct DistanceVectorHop *dvh = n->dv_head; NULL != dvh;
8758  dvh = dvh->next_neighbour)
8759  {
8761  queue,
8762  dvh->dv->vl,
8763  dvh,
8764  sizeof(struct GNUNET_PeerIdentity)
8765  * (1 + dvh->distance)
8766  + sizeof(struct TransportDVBoxMessage)
8767  + sizeof(struct TransportDVBoxPayloadP));
8768  }
8769  }
8770  if (NULL == sc.best)
8771  {
8772  /* no message pending, nothing to do here! */
8774  "No pending messages, queue `%s' to %s now idle\n",
8775  queue->address,
8776  GNUNET_i2s (&n->pid));
8777  queue->idle = GNUNET_YES;
8778  return;
8779  }
8780 
8781  /* Given selection in `sc`, do transmission */
8782  pm = sc.best;
8783  if (NULL != sc.dvh)
8784  {
8785  GNUNET_assert (PMT_DV_BOX != pm->pmt);
8786  if (NULL != sc.best->bpm)
8787  {
8788  /* We did this boxing before, but possibly for a different path!
8789  Discard old DV box! OPTIMIZE-ME: we might want to check if
8790  it is the same and then not re-build the message... */
8791  free_pending_message (sc.best->bpm);
8792  sc.best->bpm = NULL;
8793  }
8794  encapsulate_for_dv (sc.dvh->dv,
8795  1,
8796  &sc.dvh,
8797  (const struct GNUNET_MessageHeader *) &sc.best[1],
8798  &extract_box_cb,
8799  &sc,
8800  RMO_NONE);
8801  GNUNET_assert (NULL != sc.best->bpm);
8802  pm = sc.best->bpm;
8803  }
8804  if (GNUNET_YES == sc.frag)
8805  {
8806  pm = fragment_message (queue, sc.dvh, pm);
8807  if (NULL == pm)
8808  {
8810  "Fragmentation failed queue %s to %s for <%llu>, trying again\n",
8811  queue->address,
8812  GNUNET_i2s (&n->pid),
8813  sc.best->logging_uuid);
8815  return;
8816  }
8817  }
8818  else if (GNUNET_YES == sc.relb)
8819  {
8820  pm = reliability_box_message (queue, sc.dvh, pm);
8821  if (NULL == pm)
8822  {
8823  /* Reliability boxing failed, try next message... */
8824  GNUNET_log (
8826  "Reliability boxing failed queue %s to %s for <%llu>, trying again\n",
8827  queue->address,
8828  GNUNET_i2s (&n->pid),
8829  sc.best->logging_uuid);
8831  return;
8832  }
8833  }
8834 
8835  /* Pass 'pm' for transission to the communicator */
8836  GNUNET_log (
8838  "Passing message <%llu> to queue %s for peer %s (considered %u others)\n",
8839  pm->logging_uuid,
8840  queue->address,
8841  GNUNET_i2s (&n->pid),
8842  sc.consideration_counter);
8843 
8844  /* Flow control: increment amount of traffic sent; if we are routing
8845  via DV (and thus the ultimate target of the pending message is for
8846  a different virtual link than the one of the queue), then we need
8847  to use up not only the window of the direct link but also the
8848  flow control window for the DV link! */pm->vl->outbound_fc_window_size_used += pm->bytes_msg;
8849 
8850  if (pm->vl != queue->neighbour->vl)
8851  {
8852  /* If the virtual link of the queue differs, this better be distance
8853  vector routing! */
8854  GNUNET_assert (NULL != sc.dvh);
8855  /* If we do distance vector routing, we better not do this for a
8856  message that was itself DV-routed */
8857  GNUNET_assert (PMT_DV_BOX != sc.best->pmt);
8858  /* We use the size of the unboxed message here, to avoid counting
8859  the DV-Box header which is eaten up on the way by intermediaries */
8860  queue->neighbour->vl->outbound_fc_window_size_used += sc.best->bytes_msg;
8861  }
8862  else
8863  {
8864  GNUNET_assert (NULL == sc.dvh);
8865  }
8866 
8867  queue_send_msg (queue, pm, &pm[1], pm->bytes_msg);
8868 
8869  /* Check if this transmission somehow conclusively finished handing 'pm'
8870  even without any explicit ACKs */
8871  if ((PMT_CORE == pm->pmt) ||
8873  {
8875  }
8876  else
8877  {
8878  /* Message not finished, waiting for acknowledgement.
8879  Update time by which we might retransmit 's' based on queue
8880  characteristics (i.e. RTT); it takes one RTT for the message to
8881  arrive and the ACK to come back in the best case; but the other
8882  side is allowed to delay ACKs by 2 RTTs, so we use 4 RTT before
8883  retransmitting.
8884 
8885  OPTIMIZE: Note that in the future this heuristic should likely
8886  be improved further (measure RTT stability, consider message
8887  urgency and size when delaying ACKs, etc.) */update_pm_next_attempt (pm,
8890  4)));
8891  }
8892  /* finally, re-schedule queue transmission task itself */
8894 }
A connected controller which is not our child.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
Transmission is reliabile (with ACKs), i.e.
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
Context for select_best_pending_from_link().
struct Neighbour * neighbour
Which neighbour is this queue for?
uint16_t bytes_msg
Size of the original message.
int idle
Set to GNUNET_YES if this queue is idle waiting for some virtual link to give it a pending message...
Ordinary message received from the CORE service.
unsigned long long logging_uuid
UUID we use to identify this message in our logs.
Outer layer of an encapsulated message send over multiple hops.
struct VirtualLink * vl
Do we have a confirmed working queue and are thus visible to CORE? If so, this is the virtual link...
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:246
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Pending message created during forward_dv_box().
struct DistanceVectorHop * dv_head
Head of MDLL of DV hops that have this neighbour as next hop.
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.
struct GNUNET_SCHEDULER_Task * transmit_task
Task scheduled for the time when this queue can (likely) transmit the next message.
Only confirmed, non-DV direct neighbours.
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)
Pick a path of dv under constraints options and schedule transmission of hdr.
struct PerformanceData pd
Performance data for this queue.
Handle for a queue.
enum PendingMessageType pmt
Type of the pending message.
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:442
struct TransportClient * tc
Which communicator offers this queue?
static struct PendingMessage * fragment_message(struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
Fragment the given pm to the given mtu.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
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 ...
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...
struct GNUNET_TIME_Relative aged_rtt
Weighted average for the RTT.
struct DistanceVectorHop * next_neighbour
Kept in a MDLL.
struct VirtualLink * vl
Target of the request (always the ultimate destination!).
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...
The identity of the host (wraps the signing key of the peer).
struct sockaddr * address
Address of the other peer.
One possible hop towards a DV target.
Plaintext of the variable-size payload that is encrypted within a struct TransportBackchannelEncapsul...
static void schedule_transmit_on_queue(struct Queue *queue, enum GNUNET_SCHEDULER_Priority p)
Called whenever something changed that might effect when we try to do the next transmission on queue ...
#define GNUNET_log(kind,...)
List containing all messages that are yet to be send.
static struct PendingMessage * reliability_box_message(struct Queue *queue, struct DistanceVectorHop *dvh, struct PendingMessage *pm)
Reliability-box the given pm.
static void queue_send_msg(struct Queue *queue, struct PendingMessage *pm, const void *payload, size_t payload_size)
Send the message payload on queue.
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
union TransportClient::@72 details
Run with the default priority (normal P2P operations).
static void free_pending_message(struct PendingMessage *pm)
Release memory associated with pm and remove pm from associated data structures.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
struct GNUNET_PeerIdentity pid
Which peer is this about?
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 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 3456 of file gnunet-service-tng.c.

References Queue::address, TransportClient::communicator, COMMUNICATOR_TOTAL_QUEUE_LIMIT, TransportClient::details, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), Queue::idle, Queue::neighbour, Neighbour::pid, Queue::queue_length, QUEUE_LENGTH_LIMIT, Queue::tc, transmit_on_queue(), and Queue::transmit_task.

Referenced by check_vl_transmission(), free_queue(), handle_add_queue_message(), handle_send_message_ack(), and transmit_on_queue().

3458 {
3459  if (queue->tc->details.communicator.total_queue_length >=
3461  {
3463  GST_stats,
3464  "# Transmission throttled due to communicator queue limit",
3465  1,
3466  GNUNET_NO);
3467  queue->idle = GNUNET_NO;
3468  return;
3469  }
3470  if (queue->queue_length >= QUEUE_LENGTH_LIMIT)
3471  {
3473  "# Transmission throttled due to queue queue limit",
3474  1,
3475  GNUNET_NO);
3476  queue->idle = GNUNET_NO;
3477  return;
3478  }
3479  /* queue might indeed be ready, schedule it */
3480  if (NULL != queue->transmit_task)
3482  queue->transmit_task =
3485  "Considering transmission on queue `%s' to %s\n",
3486  queue->address,
3487  GNUNET_i2s (&queue->neighbour->pid));
3488 }
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
#define COMMUNICATOR_TOTAL_QUEUE_LIMIT
How many messages can we have pending for a given communicator process before we start to throttle th...
struct Neighbour * neighbour
Which neighbour is this queue for?
int idle
Set to GNUNET_YES if this queue is idle waiting for some virtual link to give it a pending message...
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_SCHEDULER_Task * transmit_task
Task scheduled for the time when this queue can (likely) transmit the next message.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1207
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static void transmit_on_queue(void *cls)
We believe we are ready to transmit a message on a queue.
struct TransportClient * tc
Which communicator offers this queue?
unsigned int queue_length
Length of the DLL starting at queue_head.
struct sockaddr * address
Address of the other peer.
#define GNUNET_log(kind,...)
union TransportClient::@72 details
#define QUEUE_LENGTH_LIMIT
How many messages can we have pending for a given queue (queue to a particular peer via a communicato...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_PeerIdentity pid
Which peer is this about?
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 3543 of file gnunet-service-tng.c.

References Queue::address, check_link_down(), TransportClient::communicator, COMMUNICATOR_TOTAL_QUEUE_LIMIT, MonitorEvent::cs, TransportClient::details, free_neighbour(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_MDLL_remove, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_CS_DOWN, lookup_virtual_link(), VirtualLink::n, Queue::neighbour, notify_monitors(), Queue::nt, Queue::pa_head, Queue::pa_tail, Neighbour::pid, QueueEntry::pm, qe, PendingMessage::qe, PendingAcknowledgement::queue, Queue::queue_head, Neighbour::queue_head, Queue::queue_length, Queue::queue_tail, Neighbour::queue_tail, schedule_transmit_on_queue(), tc, Queue::tc, Queue::transmit_task, and VirtualLink::visibility_task.

Referenced by client_disconnect_cb(), and handle_del_queue_message().

3544 {
3545  struct Neighbour *neighbour = queue->neighbour;
3546  struct TransportClient *tc = queue->tc;
3547  struct MonitorEvent me = { .cs = GNUNET_TRANSPORT_CS_DOWN,
3549  struct QueueEntry *qe;
3550  int maxxed;
3551  struct PendingAcknowledgement *pa;
3552  struct VirtualLink *vl;
3553 
3554  if (NULL != queue->transmit_task)
3555  {
3557  queue->transmit_task = NULL;
3558  }
3559  while (NULL != (pa = queue->pa_head))
3560  {
3561  GNUNET_CONTAINER_MDLL_remove (queue, queue->pa_head, queue->pa_tail, pa);
3562  pa->queue = NULL;
3563  }
3564 
3565  GNUNET_CONTAINER_MDLL_remove (neighbour,
3566  neighbour->queue_head,
3567  neighbour->queue_tail,
3568  queue);
3570  tc->details.communicator.queue_head,
3571  tc->details.communicator.queue_tail,
3572  queue);
3573  maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >=
3574  tc->details.communicator.total_queue_length);
3575  while (NULL != (qe = queue->queue_head))
3576  {
3577  GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe);
3578  queue->queue_length--;
3579  tc->details.communicator.total_queue_length--;
3580  if (NULL != qe->pm)
3581  {
3582  GNUNET_assert (qe == qe->pm->qe);
3583  qe->pm->qe = NULL;
3584  }
3585  GNUNET_free (qe);
3586  }
3587  GNUNET_assert (0 == queue->queue_length);
3588  if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT <
3589  tc->details.communicator.total_queue_length))
3590  {
3591  /* Communicator dropped below threshold, resume all _other_ queues */
3593  GST_stats,
3594  "# Transmission throttled due to communicator queue limit",
3595  -1,
3596  GNUNET_NO);
3597  for (struct Queue *s = tc->details.communicator.queue_head; NULL != s;
3598  s = s->next_client)
3600  }
3601  notify_monitors (&neighbour->pid, queue->address, queue->nt, &me);
3602  GNUNET_free (queue);
3603 
3604  vl = lookup_virtual_link (&neighbour->pid);
3605  if ((NULL != vl) && (neighbour == vl->n))
3606  {
3608  check_link_down (vl);
3609  }
3610  if (NULL == neighbour->queue_head)
3611  {
3612  free_neighbour (neighbour);
3613  }
3614 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
A connected controller which is not our child.
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
#define COMMUNICATOR_TOTAL_QUEUE_LIMIT
How many messages can we have pending for a given communicator process before we start to throttle th...
struct Neighbour * neighbour
Which neighbour is this queue for?
struct PendingAcknowledgement * pa_tail
Tail of DLL of PAs that used this queue.
struct QueueEntry * queue_head
Head of DLL of unacked transmission requests.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_NO
Definition: gnunet_common.h:78
struct PendingAcknowledgement * pa_head
Head of DLL of PAs that used this queue.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_SCHEDULER_Task * transmit_task
Task scheduled for the time when this queue can (likely) transmit the next message.
static struct VirtualLink * lookup_virtual_link(const struct GNUNET_PeerIdentity *pid)
Lookup virtual link for peer pid.
Data structure kept when we are waiting for an acknowledgement.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct QueueEntry * qe
Set to non-NULL value if this message is currently being given to a communicator and we are awaiting ...
Handle for a queue.
struct QueueEntry * queue_tail
End of DLL of unacked transmission requests.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
Details about what to notify monitors about.
struct Queue * queue_tail
Tail of DLL of queues to this peer.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct TransportClient * tc
Which communicator offers this queue?
struct PendingMessage * pm
Pending message this entry is for, or NULL for none.
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...
unsigned int queue_length
Length of the DLL starting at queue_head.
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&#39;s status with respect to some address to all monitors that care...
An entry in the operation queue.
struct sockaddr * address
Address of the other peer.
static void schedule_transmit_on_queue(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 ...
Client connected to the transport service.
struct Queue * queue
Queue used for transmission, NULL if the queue has been destroyed (which may happen before we get an ...
static void free_neighbour(struct Neighbour *neighbour)
Release memory used by neighbour.
union TransportClient::@72 details
enum GNUNET_NetworkType nt
Which network type does this queue use?
Run with the default priority (normal P2P operations).
struct Queue * queue_head
Head of DLL of queues to this peer.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PeerIdentity pid
Which peer is this about?
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 3623 of file gnunet-service-tng.c.

References TransportClient::communicator, TransportClient::details, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PEERSTORE_store_cancel(), GNUNET_SCHEDULER_cancel(), AddressListEntry::sc, AddressListEntry::st, tc, and AddressListEntry::tc.

Referenced by client_disconnect_cb(), and handle_del_address().

3624 {
3625  struct TransportClient *tc = ale->tc;
3626 
3628  tc->details.communicator.addr_tail,
3629  ale);
3630  if (NULL != ale->sc)
3631  {
3633  ale->sc = NULL;
3634  }
3635  if (NULL != ale->st)
3636  {
3637  GNUNET_SCHEDULER_cancel (ale->st);
3638  ale->st = NULL;
3639  }
3640  GNUNET_free (ale);
3641 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_PEERSTORE_StoreContext * sc
Current context for storing this address in the peerstore.
struct GNUNET_SCHEDULER_Task * st
Task to periodically do st operation.
struct TransportClient * tc
Which communicator provides this address?
void GNUNET_PEERSTORE_store_cancel(struct GNUNET_PEERSTORE_StoreContext *sc)
Cancel a store request.
Client connected to the transport service.
union TransportClient::@72 details
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 3653 of file gnunet-service-tng.c.

References TransportClient::application, TransportClient::details, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_OK, GNUNET_PEERSTORE_watch_cancel(), GNUNET_YES, PeerRequest::pr, tc, value, and PeerRequest::wc.

Referenced by client_disconnect_cb(), and handle_suggest_cancel().

3656 {
3657  struct TransportClient *tc = cls;
3658  struct PeerRequest *pr = value;
3659 
3661  GNUNET_assert (
3662  GNUNET_YES ==
3664  pid,
3665  pr));
3666  GNUNET_free (pr);
3667 
3668  return GNUNET_OK;
3669 }
void GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc)
Cancel a watch request.
Information per peer and request.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GSF_PendingRequest * pr
Handle to generic request (generic: from peer or local client).
int 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.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct TransportClient::@72::@76 application
Information for type CT_APPLICATION.
static char * value
Value of the record to add/remove.
struct GNUNET_PEERSTORE_WatchContext * wc
Handle for watching the peerstore for HELLOs for this peer.
Client connected to the transport service.
#define GNUNET_YES
Definition: gnunet_common.h:77
union TransportClient::@72 details
#define GNUNET_free(ptr)
Wrapper around free.
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 3681 of file gnunet-service-tng.c.

References TransportClient::application, PendingMessage::client, TransportClient::communicator, TransportClient::core, CT_APPLICATION, CT_COMMUNICATOR, CT_CORE, CT_MONITOR, CT_NONE, TransportClient::details, 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_free, GNUNET_log, pm, q, stop_peer_request(), tc, and TransportClient::type.

Referenced by run().

3684 {
3685  struct TransportClient *tc = app_ctx;
3686 
3687  (void) cls;
3688  (void) client;
3690  "Client %p disconnected, cleaning up.\n",
3691  tc);
3693  switch (tc->type)
3694  {
3695  case CT_NONE:
3696  break;
3697 
3698  case CT_CORE: {
3699  struct PendingMessage *pm;
3700 
3701  while (NULL != (pm = tc->details.core.pending_msg_head))
3702  {
3704  tc->details.core.pending_msg_head,
3705  tc->details.core.pending_msg_tail,
3706  pm);
3707  pm->client = NULL;
3708  }
3709  }
3710  break;
3711 
3712  case CT_MONITOR:
3713  break;
3714 
3715  case CT_COMMUNICATOR: {
3716  struct Queue *q;
3717  struct AddressListEntry *ale;
3718 
3719  while (NULL != (q = tc->details.communicator.queue_head))
3720  free_queue (q);
3721  while (NULL != (ale = tc->details.communicator.addr_head))
3723  GNUNET_free (tc->details.communicator.address_prefix);
3724  }
3725  break;
3726 
3727  case CT_APPLICATION:
3730  tc);
3732  break;
3733  }
3734  GNUNET_free (tc);
3735 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
"Application" telling us where to connect (i.e.
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
static void free_address_list_entry(struct AddressListEntry *ale)
Free ale.
enum ClientType type
What type of client is this?
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct TransportClient::@72::@76 application
Information for type CT_APPLICATION.
Handle for a queue.
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
Remove an element from a MDLL.
One of the addresses of this peer.
struct TransportClient::@72::@73 core
Information for type CT_CORE.
struct TransportClient * client
Client that issued the transmission request, if pmt is PMT_CORE.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
We do not know yet (client is fresh).
Is the CORE service, we need to forward traffic to it.
It is a monitor, forward monitor data.
static int stop_peer_request(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Stop the peer request in value.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
Client connected to the transport service.
#define GNUNET_log(kind,...)
List containing all messages that are yet to be send.
union TransportClient::@72 details
It is a communicator, use for communication.
static void free_queue(struct Queue *queue)
Free queue.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
Here is the call graph for this function:
Here is the caller 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 3748 of file gnunet-service-tng.c.

References core_send_connect_info(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_OK, and tc.

Referenced by handle_client_start().

3751 {
3752  struct TransportClient *tc = cls;
3753 
3754  (void) value;
3756  "Telling new CORE client about existing connection to %s\n",
3757  GNUNET_i2s (pid));
3758  core_send_connect_info (tc, pid);
3759  return GNUNET_OK;
3760 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
Client connected to the transport service.
#define GNUNET_log(kind,...)
static void core_send_connect_info(struct TransportClient *tc, const struct GNUNET_PeerIdentity *pid)
Send message to CORE clients that we lost a connection.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 3772 of file gnunet-service-tng.c.

References TransportClient::client, 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, notify_client_connect_info(), options, StartMessage::options, StartMessage::self, tc, and TransportClient::type.

3773 {
3774  struct TransportClient *tc = cls;
3775  uint32_t options;
3776 
3777  options = ntohl (start->options);
3778  if ((0 != (1 & options)) &&
3779  (0 != GNUNET_memcmp (&start->self, &GST_my_identity)))
3780  {
3781  /* client thinks this is a different peer, reject */
3782  GNUNET_break (0);
3784  return;
3785  }
3786  if (CT_NONE != tc->type)
3787  {
3788  GNUNET_break (0);
3790  return;
3791  }
3792  tc->type = CT_CORE;
3794  "New CORE client with PID %s registered\n",
3795  GNUNET_i2s (&start->self));
3798  tc);
3800 }
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
static struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Map from PIDs to struct Neighbour entries.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_PeerIdentity self
Identity we think we have.
Definition: transport.h:109
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic ...
Definition: transport.h:103
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:2324
We do not know yet (client is fresh).
Is the CORE service, we need to forward traffic to it.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
Client connected to the transport service.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
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 3810 of file gnunet-service-tng.c.

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

3811 {
3812  struct TransportClient *tc = cls;
3813  uint16_t size;
3814  const struct GNUNET_MessageHeader *obmm;
3815 
3816  if (CT_CORE != tc->type)
3817  {
3818  GNUNET_break (0);
3819  return GNUNET_SYSERR;
3820  }
3821  size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
3822  if (size < sizeof(struct GNUNET_MessageHeader))
3823  {
3824  GNUNET_break (0);
3825  return GNUNET_SYSERR;
3826  }
3827  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
3828  if (size != ntohs (obmm->size))
3829  {
3830  GNUNET_break (0);
3831  return GNUNET_SYSERR;
3832  }
3833  return GNUNET_OK;
3834 }
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:289
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
Message used to notify the transport service about a message to be transmitted to another peer...
Definition: transport.h:284
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
Is the CORE service, we need to forward traffic to it.
Client connected to the transport service.
Header for all communications.

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

References PendingMessage::client, env, free_pending_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), PendingMessage::logging_uuid, TransportClient::mq, SendOkMessage::peer, VirtualLink::target, tc, and PendingMessage::vl.

Referenced by completed_pending_message(), and reliability_box_message().

3846 {
3847  struct TransportClient *tc = pm->client;
3848  struct VirtualLink *vl = pm->vl;
3849 
3850  if (NULL != tc)
3851  {
3852  struct GNUNET_MQ_Envelope *env;
3853  struct SendOkMessage *som;
3854 
3856  som->peer = vl->target;
3858  "Confirming transmission of <%llu> to %s\n",
3859  pm->logging_uuid,
3860  GNUNET_i2s (&vl->target));
3861  GNUNET_MQ_send (tc->mq, env);
3862  }
3863  free_pending_message (pm);
3864 }
unsigned long long logging_uuid
UUID we use to identify this message in our logs.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct TransportClient * client
Client that issued the transmission request, if pmt is PMT_CORE.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
struct VirtualLink * vl
Target of the request (always the ultimate destination!).
Message used to notify the transport API that it can send another message to the transport service...
Definition: transport.h:216
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:251
Client connected to the transport service.
#define GNUNET_log(kind,...)
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:353
static void free_pending_message(struct PendingMessage *pm)
Release memory associated with pm and remove pm from associated data structures.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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
hops_array[out]set to the result
hops_array_lengthlength of the hops_array
Returns
number of entries set in hops_array

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

References 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, GNUNET_TIME_Relative::rel_value_us, and RMO_UNCONFIRMED_ALLOWED.

Referenced by route_control_message_without_fc().

3881 {
3882  uint64_t choices[hops_array_length];
3883  uint64_t num_dv;
3884  unsigned int dv_count;
3885 
3886  /* Pick random vectors, but weighted by distance, giving more weight
3887  to shorter vectors */
3888  num_dv = 0;
3889  dv_count = 0;
3890  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
3891  pos = pos->next_dv)
3892  {
3893  if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
3894  (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
3895  .rel_value_us == 0))
3896  continue; /* pos unconfirmed and confirmed required */
3897  num_dv += MAX_DV_HOPS_ALLOWED - pos->distance;
3898  dv_count++;
3899  }
3900  if (0 == dv_count)
3901  return 0;
3902  if (dv_count <= hops_array_length)
3903  {
3904  dv_count = 0;
3905  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
3906  pos = pos->next_dv)
3907  hops_array[dv_count++] = pos;
3908  return dv_count;
3909  }
3910  for (unsigned int i = 0; i < hops_array_length; i++)
3911  {
3912  int ok = GNUNET_NO;
3913  while (GNUNET_NO == ok)
3914  {
3915  choices[i] =
3917  ok = GNUNET_YES;
3918  for (unsigned int j = 0; j < i; j++)
3919  if (choices[i] == choices[j])
3920  {
3921  ok = GNUNET_NO;
3922  break;
3923  }
3924  }
3925  }
3926  dv_count = 0;
3927  num_dv = 0;
3928  for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
3929  pos = pos->next_dv)
3930  {
3931  uint32_t delta = MAX_DV_HOPS_ALLOWED - pos->distance;
3932 
3933  if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
3934  (GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
3935  .rel_value_us == 0))
3936  continue; /* pos unconfirmed and confirmed required */
3937  for (unsigned int i = 0; i < hops_array_length; i++)
3938  if ((num_dv <= choices[i]) && (num_dv + delta > choices[i]))
3939  hops_array[dv_count++] = pos;
3940  num_dv += delta;
3941  }
3942  return dv_count;
3943 }
uint64_t rel_value_us
The actual value.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
static int ok
Return value from &#39;main&#39; (0 == success)
#define GNUNET_NO
Definition: gnunet_common.h:78
We are allowed to use unconfirmed queues or DV routes for this message.
#define MAX_DV_HOPS_ALLOWED
Maximum DV distance allowed ever.
One possible hop towards a DV target.
struct DistanceVectorHop * next_dv
Kept in a MDLL, sorted by timeout.
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:331
#define GNUNET_YES
Definition: gnunet_common.h:77
struct DistanceVectorHop * dv_head
Known paths to target.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_communicator_available()

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

Communicator started.

Test message is well-formed.

Parameters
clsthe client
camthe send message that was sent

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

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

3956 {
3957  struct TransportClient *tc = cls;
3958  uint16_t size;
3959 
3960  if (CT_NONE != tc->type)
3961  {
3962  GNUNET_break (0);
3963  return GNUNET_SYSERR;
3964  }
3965  tc->type = CT_COMMUNICATOR;
3966  size = ntohs (cam->header.size) - sizeof(*cam);
3967  if (0 == size)
3968  return GNUNET_OK; /* receive-only communicator */
3970  return GNUNET_OK;
3971 }
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
We do not know yet (client is fresh).
Client connected to the transport service.
It is a communicator, use for communication.

◆ finish_cmc_handling()

static void finish_cmc_handling ( struct CommunicatorMessageContext cmc)
static

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

Parameters
cmccontext for which we are done handling the message

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

References TransportClient::client, env, GNUNET_free, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), CommunicatorMessageContext::im, TransportClient::mq, and CommunicatorMessageContext::tc.

Referenced by backtalker_monotime_cb(), free_backtalker(), 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().

3981 {
3982  if (0 != ntohl (cmc->im.fc_on))
3983  {
3984  /* send ACK when done to communicator for flow control! */
3985  struct GNUNET_MQ_Envelope *env;
3986  struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
3987 
3989  ack->reserved = htonl (0);
3990  ack->fc_id = cmc->im.fc_id;
3991  ack->sender = cmc->im.sender;
3992  GNUNET_MQ_send (cmc->tc->mq, env);
3993  }
3995  GNUNET_free (cmc);
3996 }
struct GNUNET_TRANSPORT_IncomingMessage im
Additional information for flow control and about the sender.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
struct TransportClient * tc
Which communicator provided us with the message.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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:353
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
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 4009 of file gnunet-service-tng.c.

References TransportClient::client, VirtualLink::cmc_head, VirtualLink::cmc_tail, VirtualLink::core_recv_window, CT_CORE, delta, finish_cmc_handling(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), RecvOkMessage::increase_window_delta, lookup_virtual_link(), RecvOkMessage::peer, tc, and TransportClient::type.

4010 {
4011  struct TransportClient *tc = cls;
4012  struct VirtualLink *vl;
4013  uint32_t delta;
4014  struct CommunicatorMessageContext *cmc;
4015 
4016  if (CT_CORE != tc->type)
4017  {
4018  GNUNET_break (0);
4020  return;
4021  }
4022  vl = lookup_virtual_link (&rom->peer);
4023  if (NULL == vl)
4024  {
4026  "# RECV_OK dropped: virtual link unknown",
4027  1,
4028  GNUNET_NO);
4030  return;
4031  }
4032  delta = ntohl (rom->increase_window_delta);
4033  vl->core_recv_window += delta;
4034  if (vl->core_recv_window <= 0)
4035  return;
4036  /* resume communicators */
4037  while (NULL != (cmc = vl->cmc_tail))
4038  {
4040  finish_cmc_handling (cmc);
4041  }
4042 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
Definition: transport.h:276
Context from handle_incoming_msg().
#define GNUNET_NO
Definition: gnunet_common.h:78
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Definition: transport.h:271
struct GNUNET_SERVICE_Client * client
Handle to the client.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
enum ClientType type
What type of client is this?
static struct VirtualLink * lookup_virtual_link(const struct GNUNET_PeerIdentity *pid)
Lookup virtual link for peer pid.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2324
Is the CORE service, we need to forward traffic to it.
Client connected to the transport service.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
static void finish_cmc_handling(struct CommunicatorMessageContext *cmc)
Send ACK to communicator (if requested) and free cmc.
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 4052 of file gnunet-service-tng.c.

References TransportClient::client, TransportClient::communicator, TransportClient::details, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_strdup, size, and tc.

4055 {
4056  struct TransportClient *tc = cls;
4057  uint16_t size;
4058 
4059  size = ntohs (cam->header.size) - sizeof(*cam);
4060  if (0 == size)
4061  {
4063  "Receive-only communicator connected\n");
4064  return; /* receive-only communicator */
4065  }
4066  tc->details.communicator.address_prefix =
4067  GNUNET_strdup ((const char *) &cam[1]);
4068  tc->details.communicator.cc =
4069  (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc);
4071  "Communicator with prefix `%s' connected\n",
4072  tc->details.communicator.address_prefix);
4074 }
GNUNET_TRANSPORT_CommunicatorCharacteristics
What characteristics does this communicator have?
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:418
struct GNUNET_SERVICE_Client * client
Handle to the client.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static unsigned int size
Size of the "table".
Definition: peer.c:67
Client connected to the transport service.
#define GNUNET_log(kind,...)
union TransportClient::@72 details
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
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 4085 of file gnunet-service-tng.c.

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

4088 {
4089  const struct GNUNET_MessageHeader *inbox;
4090  const char *is;
4091  uint16_t msize;
4092  uint16_t isize;
4093 
4094  (void) cls;
4095  msize = ntohs (cb->header.size) - sizeof(*cb);
4096  inbox = (const struct GNUNET_MessageHeader *) &cb[1];
4097  isize = ntohs (inbox->size);
4098  if (isize >= msize)
4099  {
4100  GNUNET_break (0);
4101  return GNUNET_SYSERR;
4102  }
4103  is = (const char *) inbox;
4104  is += isize;
4105  msize -= isize;
4106  GNUNET_assert (0 < msize);
4107  if ('\0' != is[msize - 1])
4108  {
4109  GNUNET_break (0);
4110  return GNUNET_SYSERR;
4111  }
4112  return GNUNET_OK;
4113 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Header for all communications.

◆ update_ephemeral()

static void update_ephemeral ( struct DistanceVector dv)
static

Ensure ephemeral keys in our dv are current.

If no current one exists, set it up.

Parameters
dv[in,out]virtual link to update ephemeral for

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

References EphemeralConfirmationPS::ephemeral_key, DistanceVector::ephemeral_key, EPHEMERAL_VALIDITY, DistanceVector::ephemeral_validity, GNUNET_assert, GNUNET_CRYPTO_ecdhe_key_create2(), GNUNET_CRYPTO_ecdhe_key_get_public(), GNUNET_CRYPTO_eddsa_sign(), GNUNET_OK, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get_monotonic(), GNUNET_TIME_absolute_get_remaining(), DistanceVector::monotime, DistanceVector::private_key, GNUNET_CRYPTO_EccSignaturePurpose::purpose, EphemeralConfirmationPS::purpose, GNUNET_TIME_Relative::rel_value_us, DistanceVector::sender_sig, GNUNET_CRYPTO_EccSignaturePurpose::size, EphemeralConfirmationPS::target, and DistanceVector::target.

Referenced by encapsulate_for_dv().

4124 {
4125  struct EphemeralConfirmationPS ec;
4126 
4127  if (0 !=
4129  return;
4131  dv->ephemeral_validity =
4136  ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
4137  ec.purpose.size = htonl (sizeof(ec));
4138  ec.target = dv->target;
4139  ec.ephemeral_key = dv->ephemeral_key;
4141  &ec.purpose,
4142  &dv->sender_sig));
4143 }
int GNUNET_CRYPTO_ecdhe_key_create2(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:630
struct GNUNET_TIME_Absolute ephemeral_validity
How long is sender_sig valid.
uint64_t rel_value_us
The actual value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CRYPTO_eddsa_sign(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:986
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:395
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key
Our ephemeral key.
struct GNUNET_TIME_Absolute monotime
What time was sender_sig created.
#define EPHEMERAL_VALIDITY
How long are ephemeral keys valid?
Body by which a peer confirms that it is using an ephemeral key.
struct GNUNET_CRYPTO_EcdhePrivateKey private_key
Our private ephemeral key.
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL
Signature by a peer affirming that the given ephemeral key is currently in use by that peer&#39;s transpo...
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:301
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:807
struct GNUNET_CRYPTO_EddsaSignature sender_sig
Signature affirming ephemeral_key of type GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL.
static struct GNUNET_CRYPTO_EddsaPrivateKey * GST_my_private_key
Our private key.
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:331
static const struct GNUNET_CONFIGURATION_Handle * GST_cfg
Configuration handle.
struct GNUNET_PeerIdentity target
To which peer is this a route?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queue_send_msg()

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

Send the message payload on queue.

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

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

References TransportClient::communicator, COMMUNICATOR_TOTAL_QUEUE_LIMIT, CT_COMMUNICATOR, TransportClient::details, env, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, Queue::idle, PendingMessage::logging_uuid, QueueEntry::mid, Queue::mid_gen, TransportClient::mq, Queue::neighbour, Neighbour::pid, pm, QueueEntry::pm, qe, PendingMessage::qe, Queue::qid, queue(), QueueEntry::queue, Queue::queue_head, Queue::queue_length, QUEUE_LENGTH_LIMIT, Queue::queue_tail, Queue::tc, and TransportClient::type.

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

4160 {
4161  struct Neighbour *n = queue->neighbour;
4162  struct GNUNET_TRANSPORT_SendMessageTo *smt;
4163  struct GNUNET_MQ_Envelope *env;
4164 
4165  queue->idle = GNUNET_NO;
4166  GNUNET_log (
4168  "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n",
4169  (unsigned int) payload_size,
4170  (NULL == pm) ? 0 : pm->logging_uuid,
4171  (unsigned long long) queue->qid,
4172  GNUNET_i2s (&queue->neighbour->pid));
4173  env = GNUNET_MQ_msg_extra (smt,
4174  payload_size,
4176  smt->qid = queue->qid;
4177  smt->mid = queue->mid_gen;
4178  smt->receiver = n->pid;
4179  memcpy (&smt[1], payload, payload_size);
4180  {
4181  /* Pass the env to the communicator of queue for transmission. */
4182  struct QueueEntry *qe;
4183 
4184  qe = GNUNET_new (struct QueueEntry);
4185  qe->mid = queue->mid_gen++;
4186  qe->queue = queue;
4187  if (NULL != pm)
4188  {
4189  qe->pm = pm;
4190  GNUNET_assert (NULL == pm->qe);
4191  pm->qe = qe;
4192  }
4193  GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe);
4194  GNUNET_assert (CT_COMMUNICATOR == queue->tc->type);
4195  queue->queue_length++;
4196  queue->tc->details.communicator.total_queue_length++;
4198  queue->tc->details.communicator.total_queue_length)
4199  queue->idle = GNUNET_NO;
4200  if (QUEUE_LENGTH_LIMIT == queue->queue_length)
4201  queue->idle = GNUNET_NO;
4202  GNUNET_MQ_send (queue->tc->mq, env);
4203  }
4204 }
A connected controller which is not our child.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
struct TransportClient::@72::@75 communicator
Information for type CT_COMMUNICATOR.
#define COMMUNICATOR_TOTAL_QUEUE_LIMIT
How many messages can we have pending for a given communicator process before we start to throttle th...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
struct Neighbour * neighbour
Which neighbour is this queue for?
uint32_t qid
Unique identifier of this queue with the communicator.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int idle
Set to GNUNET_YES if this queue is idle waiting for some virtual link to give it a pending message...
unsigned long long logging_uuid
UUID we use to identify this message in our logs.
struct QueueEntry * queue_head
Head of DLL of unacked transmission requests.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
enum ClientType type
What type of client is this?
#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:52
struct QueueEntry * qe
Set to non-NULL value if this message is currently being given to a communicator and we are awaiting ...
struct QueueEntry * queue_tail
End of DLL of unacked transmission requests.
struct Queue * queue
Queue this entry is queued with.
struct TransportClient * tc
Which communicator offers this queue?
struct PendingMessage * pm
Pending message this entry is for, or NULL for none.
unsigned int queue_length
Length of the DLL starting at queue_head.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static unsigned long long payload
How much data are we currently storing in the database?
uint64_t mid_gen
Message ID generator for transmissions on this queue to the communicator.
An entry in the operation queue.
#define GNUNET_log(kind,...)
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:353
union TransportClient::@72 details
#define QUEUE_LENGTH_LIMIT
How many messages can we have pending for a given queue (queue to a particular peer via a communicato...
It is a communicator, use for communication.
uint64_t mid
Message ID used for this message with the queue used for transmission.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
struct GNUNET_PeerIdentity pid
Which peer is this about?
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 4218 of file gnunet-service-tng.c.

References GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_min(), GNUNET_TIME_UNIT_FOREVER_REL, options, queue_send_msg(), RMO_REDUNDANT, RMO_UNCONFIRMED_ALLOWED, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by route_control_message_without_fc(), and send_dv_to_neighbour().

4221 {
4222  struct GNUNET_TIME_Absolute now;
4223  unsigned int candidates;
4224  unsigned int sel1;
4225  unsigned int sel2;
4226  struct GNUNET_TIME_Relative rtt;
4227 
4228  /* Pick one or two 'random' queues from n (under constraints of options) */
4229  now = GNUNET_TIME_absolute_get ();
4230  /* FIXME-OPTIMIZE: give queues 'weights' and pick proportional to
4231  weight in the future; weight could be assigned by observed
4232  bandwidth (note: not sure if we should do this for this type
4233  of control traffic though). */
4234  candidates = 0;
4235  for (struct Queue *pos = n->queue_head; NULL != pos;
4236  pos = pos->next_neighbour)
4237  {
4238  if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) ||
4239  (pos->validated_until.abs_value_us > now.abs_value_us))
4240  candidates++;
4241  }
4242  if (0 == candidates)
4243  {
4244  /* This can happen rarely if the last confirmed queue timed
4245  out just as we were beginning to process this message. */
4247  "Could not route message of type %u to %s: no valid queue\n",
4248  ntohs (hdr->type),
4249  GNUNET_i2s (&n->pid));
4251  "# route selection failed (all no valid queue)",
4252  1,
4253  GNUNET_NO);
4255  }
4256 
4259  if (0 == (options & RMO_REDUNDANT))
4260  sel2 = candidates; /* picks none! */
4261  else
4263  candidates = 0;
4264  for (struct Queue *pos = n->queue_head; NULL != pos;
4265  pos = pos->next_neighbour)
4266  {
4267  if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) ||
4268  (pos->validated_until.abs_value_us > now.abs_value_us))
4269  {
4270  if ((sel1 == candidates) || (sel2 == candidates))
4271  {
4273  "Routing message of type %u to %s using %s (#%u)\n",
4274  ntohs (hdr->type),
4275  GNUNET_i2s (&n->pid),
4276  pos->address,
4277  (sel1 == candidates) ? 1 : 2);
4278  rtt = GNUNET_TIME_relative_min (rtt, pos->pd.aged_rtt);
4279  queue_send_msg (pos, NULL, hdr, ntohs (hdr->size));
4280  }
4281  candidates++;
4282  }
4283  }
4284  return rtt;
4285 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_NO
Definition: gnunet_common.h:78
If we have multiple choices, it is OK to send this message over multiple channels at the same time to...
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
We are allowed to use unconfirmed queues or DV routes for this message.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
Handle for a queue.
struct Queue * next_neighbour
Kept in a MDLL.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
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:272
#define GNUNET_log(kind,...)
static void queue_send_msg(struct Queue *queue, struct PendingMessage *pm, const void *payload, size_t payload_size)
Send the message payload on queue.
Time for absolute times used by GNUnet, in microseconds.
struct Queue * queue_head
Head of DLL of queues to this peer.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_PeerIdentity pid
Which peer is this about?
Here is the call graph for this function:
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
key[out]symmetric cipher and HMAC state to generate

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

References DVKeyState::aes_ctr, DVKeyState::aes_key, DVKeyState::cipher, GNUNET_assert, GNUNET_CRYPTO_kdf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_sh2s(), GNUNET_YES, and DVKeyState::material.

Referenced by dh_key_derive_eph_pid(), and dh_key_derive_eph_pub().

4333 {
4334  /* must match #dh_key_derive_eph_pub */
4336  GNUNET_CRYPTO_kdf (&key->material,
4337  sizeof(key->material),
4338  "transport-backchannel-key",
4339  strlen ("transport-backchannel-key"),
4340  &km,
4341  sizeof(km),
4342  iv,
4343  sizeof(*iv)));
4345  "Deriving backchannel key based on KM %s and IV %s\n",
4346  GNUNET_h2s (km),
4347  GNUNET_sh2s (iv));
4348  gcry_cipher_open (&key->cipher,
4349  GCRY_CIPHER_AES256 /* low level: go for speed */,
4350  GCRY_CIPHER_MODE_CTR,
4351  0 /* flags */);
4352  gcry_cipher_setkey (key->cipher,
4353  &key->material.aes_key,
4354  sizeof(key->material.aes_key));
4355  gcry_cipher_setctr (key->cipher,
4356  &key->material.aes_ctr,
4357  sizeof(key->material.aes_ctr));
4358 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
struct DVKeyState::@77 material
Actual key material.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
gcry_cipher_hd_t cipher
State of our block cipher.
#define GNUNET_log(kind,...)
char aes_ctr[128/8]
Counter value to use during setup.
#define GNUNET_YES
Definition: gnunet_common.h:77
int 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:89
char aes_key[256/8]
Symmetric key to use for encryption.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dh_key_derive_eph_pid()

static void dh_key_derive_eph_pid ( const struct GNUNET_CRYPTO_EcdhePrivateKey priv_ephemeral,
const struct GNUNET_PeerIdentity target,
const struct GNUNET_ShortHashCode iv,
struct DVKeyState key 
)
static

Derive backchannel encryption key material from priv_ephemeral and target and iv.

Parameters
priv_ephemeralephemeral private key to use
targetthe target peer to encrypt to
ivunique IV to use
key[out]set to the key material

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

References dv_setup_key_state_from_km(), GNUNET_assert, GNUNET_CRYPTO_ecdh_eddsa(), GNUNET_YES, and GNUNET_PeerIdentity::public_key.

Referenced by encapsulate_for_dv().

4376 {
4377  struct GNUNET_HashCode km;
4378 
4380  &target->public_key,
4381  &km));
4382  dv_setup_key_state_from_km (&km, iv, key);
4383 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A 512-bit hashcode.
int GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition: crypto_ecc.c:1612
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...
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dh_key_derive_eph_pub()

static void dh_key_derive_eph_pub ( const struct GNUNET_CRYPTO_EcdhePublicKey pub_ephemeral,
const struct GNUNET_ShortHashCode iv,
struct DVKeyState key 
)
static

Derive backchannel encryption key material from GST_my_private_key and pub_ephemeral and iv.

Parameters
priv_ephemeralephemeral private key to use
targetthe target peer to encrypt to
ivunique IV to use
key[out]set to the key material

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

References dv_setup_key_state_from_km(), GNUNET_assert, GNUNET_CRYPTO_eddsa_ecdh(), and GNUNET_YES.

Referenced by handle_dv_box().

4399 {
4400  struct GNUNET_HashCode km;
4401 
4403  pub_ephemeral,
4404  &km));
4405  dv_setup_key_state_from_km (&km, iv, key);
4406 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition: crypto_ecc.c:1502
A 512-bit hashcode.
static struct GNUNET_CRYPTO_EddsaPrivateKey * GST_my_private_key
Our private key.