GNUnet  0.10.x
Data Structures | Macros | Typedefs | Enumerations | Enumerator | Functions | Variables
MQ library

General-purpose message queue. More...

Data Structures

struct  GNUNET_MQ_MessageHandler
 Message handler for a specific message type. More...
 

Macros

#define GNUNET_MQ_msg_extra(mvar, esize, type)
 Allocate an envelope, with extra space allocated after the space needed by the message struct. More...
 
#define GNUNET_MQ_msg(mvar, type)   GNUNET_MQ_msg_extra(mvar, 0, type)
 Allocate a GNUNET_MQ_Envelope. More...
 
#define GNUNET_MQ_msg_header(type)   GNUNET_MQ_msg_(NULL, sizeof(struct GNUNET_MessageHeader), type)
 Allocate a GNUNET_MQ_Envelope, where the message only consists of a header. More...
 
#define GNUNET_MQ_msg_header_extra(mh, esize, type)   GNUNET_MQ_msg_(&mh, (esize) + sizeof(struct GNUNET_MessageHeader), type)
 Allocate a GNUNET_MQ_Envelope, where the message only consists of a header and extra space. More...
 
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
 Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct. More...
 
#define GNUNET_MQ_extract_nested_mh(var)
 Return a pointer to the message at the end of the given message. More...
 
#define GNUNET_MQ_handler_end()
 End-marker for the handlers array. More...
 

Typedefs

typedef void(* GNUNET_MQ_MessageCallback) (void *cls, const struct GNUNET_MessageHeader *msg)
 Called when a message has been received. More...
 
typedef int(* GNUNET_MQ_MessageValidationCallback) (void *cls, const struct GNUNET_MessageHeader *msg)
 Called when a message needs to be validated. More...
 
typedef void(* GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
 Signature of functions implementing the sending functionality of a message queue. More...
 
typedef void(* GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, void *impl_state)
 Signature of functions implementing the destruction of a message queue. More...
 
typedef void(* GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, void *impl_state)
 Implementation function that cancels the currently sent message. More...
 
typedef void(* GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 

Enumerations

enum  GNUNET_MQ_Error {
  GNUNET_MQ_ERROR_READ = 1, GNUNET_MQ_ERROR_WRITE = 2, GNUNET_MQ_ERROR_TIMEOUT = 4, GNUNET_MQ_ERROR_MALFORMED = 8,
  GNUNET_MQ_ERROR_NO_MATCH = 16
}
 Error codes for the queue. More...
 
enum  GNUNET_MQ_PriorityPreferences {
  GNUNET_MQ_PRIO_BACKGROUND = 0, GNUNET_MQ_PRIO_BEST_EFFORT = 1, GNUNET_MQ_PRIO_URGENT = 2, GNUNET_MQ_PRIO_CRITICAL_CONTROL = 3,
  GNUNET_MQ_PRIORITY_MASK = 3, GNUNET_MQ_PREF_UNRELIABLE = 16, GNUNET_MQ_PREF_LOW_LATENCY = 32, GNUNET_MQ_PREF_CORK_ALLOWED = 64,
  GNUNET_MQ_PREF_GOODPUT = 128, GNUNET_MQ_PREF_OUT_OF_ORDER = 256
}
 Per envelope preferences and priorities. More...
 

Functions

const struct GNUNET_MessageHeaderGNUNET_MQ_extract_nested_mh_ (const struct GNUNET_MessageHeader *mh, uint16_t base_size)
 Implementation of the #GNUNET_MQ_extract_nexted_mh macro. More...
 
const struct GNUNET_MessageHeaderGNUNET_MQ_env_get_msg (const struct GNUNET_MQ_Envelope *env)
 Obtain message contained in envelope. More...
 
const struct GNUNET_MQ_EnvelopeGNUNET_MQ_env_next (const struct GNUNET_MQ_Envelope *env)
 Return next envelope in queue. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, uint16_t base_size, uint16_t type, const struct GNUNET_MessageHeader *nested_mh)
 Implementation of the GNUNET_MQ_msg_nested_mh macro. More...
 
void GNUNET_MQ_dll_insert_head (struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
 Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this function is used with DLLs defined outside of the MQ module. More...
 
void GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
 Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this function is used with DLLs defined outside of the MQ module. More...
 
void GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
 Remove env from the envelope DLL starting at env_head. More...
 
struct GNUNET_MQ_MessageHandlerGNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers)
 Copy an array of handlers. More...
 
struct GNUNET_MQ_MessageHandlerGNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_MessageCallback agpl_handler, void *agpl_cls)
 Copy an array of handlers, appending AGPL handler. More...
 
unsigned int GNUNET_MQ_count_handlers (const struct GNUNET_MQ_MessageHandler *handlers)
 Count the handlers in a handler array. More...
 
struct GNUNET_NotificationContextGNUNET_notification_context_create (unsigned int queue_length)
 Create a new notification context. More...
 
void GNUNET_notification_context_destroy (struct GNUNET_NotificationContext *nc)
 Destroy the context, force disconnect for all subscribers. More...
 
void GNUNET_notification_context_add (struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
 Add a subscriber to the notification context. More...
 
void GNUNET_notification_context_broadcast (struct GNUNET_NotificationContext *nc, const struct GNUNET_MessageHeader *msg, int can_drop)
 Send a message to all subscribers of this context. More...
 
unsigned int GNUNET_notification_context_get_size (struct GNUNET_NotificationContext *nc)
 Return active number of subscribers in this context. More...
 

Variables

GNUNET_MQ_MessageValidationCallback GNUNET_MQ_MessageHandler::mv
 Callback to validate a message of the specified type. More...
 
GNUNET_MQ_MessageCallback GNUNET_MQ_MessageHandler::cb
 Callback, called every time a new message of the specified type has been receied. More...
 
void * GNUNET_MQ_MessageHandler::cls
 Closure for mv and cb. More...
 
uint16_t GNUNET_MQ_MessageHandler::type
 Type of the message this handler covers, in host byte order. More...
 
uint16_t GNUNET_MQ_MessageHandler::expected_size
 Expected size of messages of this type. More...
 

will return a `struct GNUNET_MQ_MessageHandler`

Defines a static function name which takes as a single argument a message handler for fixed-sized messages of type code and with a message type argument of str.

Given such an argument, the function for the given message type.

The macro is to be used as follows: struct GNUNET_MessageTest { ... }; // must be fixed size static void handle_test_message (void *cls, const struct GNUNET_MessageTest *msg) { ... }

struct GNUNET_MQ_MessageHandler handlers[] = { GNUNET_MQ_hd_fixed_size(test_message, GNUNET_MESSAGE_TYPE_TEST, struct GNUNET_MessageTest, "context"), GNUNET_MQ_handler_end() };

Parameters
nameunique basename for the functions
codemessage type constant
strtype of the message (a struct)
ctxcontext for the callbacks

#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
 

will return a `struct

Defines a static function name which takes two arguments and a context-pointer for validating and handling variable-sized messages of type code and with a message type argument of str.

Given such arguments, the function GNUNET_MQ_MessageHandler` for the given message type.

The macro is to be used as follows: struct GNUNET_MessageTest { ... }; // can be variable size static int check_test (void *cls, const struct GNUNET_MessageTest *msg) { const char *ctx = cls; GNUNET_assert (0 == strcmp ("context", ctx)); // ... } static void handle_test (void *cls, const struct GNUNET_MessageTest *msg) { const char *ctx = cls; GNUNET_assert (0 == strcmp ("context", ctx)); // ... }

struct GNUNET_MQ_MessageHandler handlers[] = { GNUNET_MQ_hd_var_size(test_message, GNUNET_MESSAGE_TYPE_TEST, struct GNUNET_MessageTest, "context"), GNUNET_MQ_handler_end() };

Parameters
nameunique basename for the functions
codemessage type constant
strtype of the message (a struct)
ctxcontext for the callbacks

enum  GNUNET_MQ_PreferenceKind { GNUNET_MQ_PREFERENCE_NONE = 0, GNUNET_MQ_PREFERENCE_BANDWIDTH = 1, GNUNET_MQ_PREFERENCE_LATENCY = 2, GNUNET_MQ_PREFERENCE_RELIABILITY }
 Enum defining all known preference categories. More...
 
int GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_MessageHeader *mh)
 Call the message message handler that was registered for the type of the given message in the given handlers list. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type)
 Create a new envelope. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr)
 Create a new envelope by copying an existing message. More...
 
void GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *mqm)
 Discard the message queue message, free all allocated resources. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_get_current_envelope (struct GNUNET_MQ_Handle *mq)
 Function to obtain the current envelope from within GNUNET_MQ_SendImpl implementations. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_env_copy (struct GNUNET_MQ_Envelope *env)
 Function to copy an envelope. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_get_last_envelope (struct GNUNET_MQ_Handle *mq)
 Function to obtain the last envelope in the queue. More...
 
void GNUNET_MQ_env_set_options (struct GNUNET_MQ_Envelope *env, enum GNUNET_MQ_PriorityPreferences pp)
 Set application-specific options for this envelope. More...
 
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options (struct GNUNET_MQ_Envelope *env)
 Get performance preferences set for this envelope. More...
 
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_combine_options (enum GNUNET_MQ_PriorityPreferences p1, enum GNUNET_MQ_PriorityPreferences p2)
 Combine performance preferences set for different envelopes that are being combined into one larger envelope. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_MQ_unsent_head (struct GNUNET_MQ_Handle *mq)
 Remove the first envelope that has not yet been sent from the message queue and return it. More...
 
void GNUNET_MQ_set_options (struct GNUNET_MQ_Handle *mq, enum GNUNET_MQ_PriorityPreferences pp)
 Set application-specific options for this queue. More...
 
unsigned int GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq)
 Obtain the current length of the message queue. More...
 
void GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
 Send a message with the given message queue. More...
 
void GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
 Send a copy of a message with the given message queue. More...
 
void GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev)
 Cancel sending the message. More...
 
uint32_t GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data)
 Associate the assoc_data in mq with a unique request id. More...
 
void * GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id)
 Get the data associated with a request_id in a queue. More...
 
void * GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, uint32_t request_id)
 Remove the association for a request_id. More...
 
struct GNUNET_MQ_HandleGNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
 Create a message queue for the specified handlers. More...
 
void GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq, void *handlers_cls)
 Change the closure argument in all of the handlers of the mq. More...
 
void GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore. More...
 
void GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
 Destroy the message queue. More...
 
struct GNUNET_MQ_DestroyNotificationHandleGNUNET_MQ_destroy_notify (struct GNUNET_MQ_Handle *mq, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Register function to be called whenever mq is being destroyed. More...
 
void GNUNET_MQ_destroy_notify_cancel (struct GNUNET_MQ_DestroyNotificationHandle *dnh)
 Cancel registration from GNUNET_MQ_destroy_notify(). More...
 
void GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *mh)
 Call the message message handler that was registered for the type of the given message in the given message queue. More...
 
void GNUNET_MQ_inject_error (struct GNUNET_MQ_Handle *mq, enum GNUNET_MQ_Error error)
 Call the error handler of a message queue with the given error code. More...
 
void GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq)
 Call the send implementation for the next queued message, if any. More...
 
void GNUNET_MQ_impl_send_in_flight (struct GNUNET_MQ_Handle *mq)
 Call the send notification for the current message, but do not try to send the next message until #gnunet_mq_impl_send_continue is called. More...
 
void * GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq)
 Get the implementation state associated with the message queue. More...
 
const struct GNUNET_MessageHeaderGNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq)
 Get the message that should currently be sent. More...
 
const char * GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type)
 Convert an enum GNUNET_MQ_PreferenceType to a string. More...
 
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
 
#define GNUNET_MQ_check_zero_termination(m)
 Insert code for a "check_" function that verifies that a given variable-length message received over the network is followed by a 0-terminated string. More...
 
#define GNUNET_MQ_check_boxed_message(m)
 Insert code for a "check_" function that verifies that a given variable-length message received over the network is followed by another variable-length message that fits exactly with the given size. More...
 

Detailed Description

General-purpose message queue.

General-purpose broadcast mechanism for message queues.

See also
Documentation
Documentation

Macro Definition Documentation

◆ GNUNET_MQ_msg_extra

#define GNUNET_MQ_msg_extra (   mvar,
  esize,
  type 
)
Value:
GNUNET_MQ_msg_(((struct GNUNET_MessageHeader **)&(mvar)), \
(esize) + sizeof *(mvar), \
(type))
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_(struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type)
Create a new envelope.
Definition: mq.c:630
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.

Allocate an envelope, with extra space allocated after the space needed by the message struct.

The allocated message will already have the type and size field set.

Parameters
mvarvariable to store the allocated message in; must have a header field; can be NULL
esizeextra space to allocate after the message
typetype of the message
Returns
the MQ message

Definition at line 52 of file gnunet_mq_lib.h.

Referenced by add_to_tc(), adv_transmit(), announce_reconnect(), attr_iter_cb(), broadcast_status(), change_service(), client_response_handler(), conclude_autoconfig_request(), consume_result_cb(), create_set_default_message(), create_update_message(), decode_and_send(), dispatch_buffer(), dns_pre_request_handler(), do_send(), forward_reply(), GCCH_handle_channel_plaintext_data(), GCCH_handle_local_data(), GCT_send(), GDS_CLIENTS_process_get(), GDS_CLIENTS_process_get_resp(), GDS_CLIENTS_process_put(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), GNUNET_ATS_performance_change_preference(), GNUNET_ATS_performance_give_feedback(), GNUNET_CONSENSUS_create(), GNUNET_CONSENSUS_insert(), GNUNET_CREDENTIAL_collect(), GNUNET_CREDENTIAL_verify(), GNUNET_DATASTORE_put(), GNUNET_DATASTORE_remove(), GNUNET_DHT_put(), GNUNET_DNS_request_answer(), GNUNET_FS_indexing_send_list(), GNUNET_GNS_lookup(), GNUNET_IDENTITY_create(), GNUNET_IDENTITY_delete(), GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_ego_lookup_by_suffix(), GNUNET_IDENTITY_get(), GNUNET_IDENTITY_rename(), GNUNET_IDENTITY_set(), GNUNET_NAMECACHE_block_cache(), GNUNET_NAMESTORE_records_lookup(), GNUNET_NAMESTORE_records_store(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_NAT_request_reversal(), GNUNET_NAT_stun_handle_packet(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_ticket_issue(), GNUNET_RPS_seed_ids(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SECRETSHARING_create_session(), GNUNET_SECRETSHARING_decrypt(), GNUNET_SET_add_element(), GNUNET_SET_remove_element(), GNUNET_TESTBED_barrier_cancel(), GNUNET_TESTBED_barrier_init_(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTBED_queue_message_(), GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_application_validate(), GNUNET_TRANSPORT_communicator_notify(), GNUNET_TRANSPORT_communicator_receive(), GNUNET_TRANSPORT_TESTING_send(), GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), GNUNET_TRANSPORT_TESTING_transport_communicator_send(), GSC_CLIENTS_deliver_message(), GSC_KX_encrypt_and_transmit(), GSF_pending_request_get_message_(), GST_send_operation_fail_msg(), handle_add_host(), handle_backchannel_encapsulation(), handle_cadet_audio_message(), handle_client_audio_message(), handle_data(), handle_datastore_reply(), handle_list(), handle_lookup_block_it(), handle_p2p_reply(), handle_peer_get_config(), handle_raw_message(), handle_record_lookup(), handle_search_result(), handle_slave_get_config(), handle_start_message(), handle_union_p2p_demand(), handle_zone_to_name_it(), hash_for_index_cb(), icmp_from_helper(), keygen_round2_conclude(), notify_client(), notify_clients_stun_change(), notify_monitor(), opstart_manage_service(), opstart_peer_create(), opstart_peer_reconfigure(), path_info_iterator(), PEERSTORE_create_record_mq_envelope(), process_dns_result(), process_requests(), queue_send_msg(), read_stdio(), reconnect(), return_agpl(), reversal_callback(), route_packet(), schedule_transmit_search_request(), search_reconnect(), send_add_address(), send_add_address_message(), send_add_queue(), send_add_session_message(), send_alices_cryptodata_message(), send_bloomfilter(), send_client_element(), send_client_removed_element(), send_client_reply(), send_client_status_msg(), send_controller_link_response(), send_create(), send_full_element_iterator(), send_get(), send_get_known_results(), send_ibf(), send_lookup_response(), send_missing_full_elements_iter(), send_msg(), send_pull_reply(), send_remaining_elements(), send_reply(), send_request(), send_request_to_client(), send_result_code(), send_stream_peers(), send_to_client_iter(), send_view(), suggest_cb(), suggest_to_connect(), tcp_from_helper(), transmit(), transmit_address_to_client(), transmit_bobs_cryptodata_message(), transmit_bobs_cryptodata_message_multipart(), transmit_call_audio(), transmit_client_response(), transmit_content(), transmit_get(), transmit_item(), transmit_phone_audio(), transmit_req_addr(), transmit_set(), transmit_status(), transmit_watch(), udp_from_helper(), and union_accept().

◆ GNUNET_MQ_msg

#define GNUNET_MQ_msg (   mvar,
  type 
)    GNUNET_MQ_msg_extra(mvar, 0, type)

Allocate a GNUNET_MQ_Envelope.

The contained message will already have the type and size field set.

Parameters
mvarvariable to store the allocated message in; must have a header field; can be NULL
typetype of the message
Returns
the allocated envelope

Definition at line 67 of file gnunet_mq_lib.h.

Referenced by add_to_tc(), addr_cb(), allocate_cb(), attr_iter_finished(), attr_store_cont(), clean_up_channel(), client_request_complete_alice(), client_send_response(), comm_schedule_send(), core_mq_send_impl(), core_send_connect_info(), cores_send_disconnect_info(), create_internal(), create_loc_uri(), decrypt_conclude(), do_blacklist_check(), do_flood(), do_peer_connect(), do_plugin_connect(), fail_intersection_operation(), fail_union_operation(), finish_cmc_handling(), GAS_handle_address_destroyed(), GAS_handle_reservation_request(), GAS_scheduling_transmit_address_suggestion(), GCC_destroy_without_tunnel(), get_all_peers_iterator(), get_all_tunnels_iterator(), GNUNET_ARM_request_service_list(), GNUNET_ATS_address_destroy(), GNUNET_ATS_address_update(), GNUNET_ATS_application_suggest_cancel(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_ATS_performance_list_addresses(), GNUNET_ATS_reserve_bandwidth(), GNUNET_ATS_session_del(), GNUNET_ATS_session_update(), GNUNET_ATS_TEST_traffic_handle_ping(), GNUNET_CADET_channel_create(), GNUNET_CADET_channel_destroy(), GNUNET_CADET_close_port(), GNUNET_CADET_receive_done(), GNUNET_CONVERSATION_call_resume(), GNUNET_CONVERSATION_call_suspend(), GNUNET_CONVERSATION_caller_hang_up(), GNUNET_CONVERSATION_caller_pick_up(), GNUNET_CONVERSATION_caller_resume(), GNUNET_CONVERSATION_caller_suspend(), GNUNET_DATASTORE_disconnect(), GNUNET_DATASTORE_get_for_replication(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_release_reserve(), GNUNET_DATASTORE_reserve(), GNUNET_DHT_get_stop(), GNUNET_DHT_monitor_stop(), GNUNET_DNS_request_drop(), GNUNET_DNS_request_forward(), GNUNET_FS_get_indexed_files(), GNUNET_FS_indexing_send_list(), GNUNET_NAMECACHE_lookup_block(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_PEERSTORE_watch(), GNUNET_PEERSTORE_watch_cancel(), GNUNET_RECLAIM_get_attributes_next(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_RECLAIM_get_attributes_stop(), GNUNET_RECLAIM_ticket_consume(), GNUNET_RECLAIM_ticket_iteration_next(), GNUNET_RECLAIM_ticket_iteration_start(), GNUNET_RECLAIM_ticket_iteration_stop(), GNUNET_RECLAIM_ticket_revoke(), GNUNET_REVOCATION_query(), GNUNET_REVOCATION_revoke(), GNUNET_RPS_stream_request(), GNUNET_RPS_sub_start(), GNUNET_RPS_sub_stop(), GNUNET_RPS_view_request(), GNUNET_SET_accept(), GNUNET_SET_operation_cancel(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_core_get_mq(), GNUNET_TRANSPORT_manipulation_set(), GSC_bind(), GSC_CLIENTS_notify_client_about_neighbour(), GSC_CLIENTS_solicit_request(), GSC_handle_remote_channel_destroy(), GSC_KX_handle_client_monitor_peers(), GSF_block_peer_migration_(), GST_send_operation_success_msg(), handle_add_host(), handle_block_cache(), handle_cadet_hangup_message(), handle_cadet_pickup_message(), handle_cadet_resume_message(), handle_cadet_ring_message(), handle_cadet_suspend_message(), handle_channel_created(), handle_client_accept(), handle_client_address_to_string(), handle_client_call_message(), handle_client_copy_lazy_prepare(), handle_client_hangup_message(), handle_client_init(), handle_client_loc_sign(), handle_client_monitor_peers(), handle_client_pickup_message(), handle_client_resume_message(), handle_client_suspend_message(), handle_client_unindex(), handle_create_queue(), handle_disconnect(), handle_get(), handle_get_all(), handle_get_peers(), handle_gns_response(), handle_info_tunnels(), handle_iter_element(), handle_lookup_block(), handle_notify(), handle_peer_create(), handle_peer_start(), handle_peer_stop(), handle_ping(), handle_query(), handle_query_message(), handle_request(), handle_revoke_message(), handle_show_path(), handle_test(), handle_zone_to_name(), hash_for_index_val(), listen_connect(), monitor_sync(), notify_change(), open_port_cb(), opstart_overlay_connect(), opstart_peer_destroy(), opstart_peer_start(), opstart_peer_stop(), opstart_shutdown_peers(), plugin_session_info_cb(), prepare_client_end_notification(), reconnect(), reconnect_arm(), reconnect_arm_monitor(), reconnect_phone(), record_iterator(), retry_entry(), revoke_result_cb(), rewatch_it(), route_message(), schedule_action(), send_ack(), send_ack_to_client(), send_broken(), send_broken_without_mqm(), send_client_done(), send_client_done_and_destroy(), send_create_ack(), send_del_address(), send_del_queue(), send_delete_response(), send_echo(), send_element_count(), send_end_msg(), send_ic_request(), send_kx(), send_kx_auth(), send_monitor_start(), send_overlay_connect_success_msg(), send_p2p_done(), send_request(), send_start_monitor(), send_store_response(), send_ticket_result(), signal_index_ok(), signal_result(), test_nat_punched(), ticket_iter_cb(), transmit_address_to_client(), transmit_bobs_cryptodata_message(), transmit_item(), transmit_pending(), transmit_suggestion(), unindex_finish(), and zone_iteration_done_client_continue().

◆ GNUNET_MQ_msg_header

#define GNUNET_MQ_msg_header (   type)    GNUNET_MQ_msg_(NULL, sizeof(struct GNUNET_MessageHeader), type)

Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.

The allocated message will already have the type and size field set.

Parameters
typetype of the message

Definition at line 76 of file gnunet_mq_lib.h.

Referenced by cancel_stream(), check_peer_online(), decode_and_send(), GNUNET_CONSENSUS_conclude(), GNUNET_RPS_view_request_cancel(), GNUNET_SET_copy_lazy(), GNUNET_SET_iterate(), handle_union_p2p_full_done(), handle_union_p2p_strata_estimator(), maybe_finish(), send_client_element(), send_full_set(), send_pull_request(), send_push(), and send_to_client_iter().

◆ GNUNET_MQ_msg_header_extra

#define GNUNET_MQ_msg_header_extra (   mh,
  esize,
  type 
)    GNUNET_MQ_msg_(&mh, (esize) + sizeof(struct GNUNET_MessageHeader), type)

Allocate a GNUNET_MQ_Envelope, where the message only consists of a header and extra space.

The allocated message will already have the type and size field set.

Parameters
mhpointer that will changed to point at to the allocated message header
esizeextra space to allocate after the message header
typetype of the message

Definition at line 88 of file gnunet_mq_lib.h.

Referenced by handle_union_p2p_offer(), and send_offers_iterator().

◆ GNUNET_MQ_msg_nested_mh

#define GNUNET_MQ_msg_nested_mh (   mvar,
  type,
  mh 
)
Value:
({ \
struct GNUNET_MQ_Envelope *_ev; \
_ev = GNUNET_MQ_msg_nested_mh_((struct GNUNET_MessageHeader **)&(mvar), \
sizeof(*(mvar)), \
(type), \
(mh)); \
(void)(mvar)->header; /* type check */ \
_ev; \
})
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_nested_mh_(struct GNUNET_MessageHeader **mhp, uint16_t base_size, uint16_t type, const struct GNUNET_MessageHeader *nested_mh)
Implementation of the GNUNET_MQ_msg_nested_mh macro.
Definition: mq.c:673
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.

Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.

Parameters
mvarpointer to a message struct, will be changed to point at the newly allocated message, whose size is 'sizeof(*mvar) + ntohs (mh->size)'
typemessage type of the allocated message, has no effect on the nested message
mhmessage to nest
Returns
a newly allocated 'struct GNUNET_MQ_Envelope *'

Definition at line 102 of file gnunet_mq_lib.h.

Referenced by cadet_mq_send_impl(), core_mq_send_impl(), GNUNET_SET_prepare(), handle_incoming_msg(), intersection_evaluate(), mq_send_impl(), and union_evaluate().

◆ GNUNET_MQ_extract_nested_mh

#define GNUNET_MQ_extract_nested_mh (   var)
Value:
sizeof(*(var)))
const struct GNUNET_MessageHeader * GNUNET_MQ_extract_nested_mh_(const struct GNUNET_MessageHeader *mh, uint16_t base_size)
Implementation of the #GNUNET_MQ_extract_nexted_mh macro.
Definition: mq.c:878
Header for all communications.

Return a pointer to the message at the end of the given message.

Parameters
varpointer to a message struct, the type of the expression determines the base size, the space after the base size is the nested message
Returns
a 'struct GNUNET_MessageHeader *' that points at the nested message of the given message, or NULL if the given message in var does not have any space after the message struct

Definition at line 122 of file gnunet_mq_lib.h.

Referenced by check_incoming_msg(), check_request(), handle_client_evaluate(), handle_incoming_msg(), and handle_request().

◆ GNUNET_MQ_handler_end

#define GNUNET_MQ_handler_end ( )
Value:
{ \
NULL, NULL, NULL, 0, 0 \
}

End-marker for the handlers array.

Definition at line 511 of file gnunet_mq_lib.h.

Referenced by advertise_dns_exit(), client_connect_cb(), client_disconnect_cb(), client_request_complete_alice(), connect_check_run(), connect_task(), core_connect_adapter(), create_channel(), create_internal(), create_loc_uri(), demultiplex_with_cmc(), disconnect_cb(), do_connect(), do_peer_connect(), do_plugin_connect(), do_reconnect(), GCO_init(), GCT_create_tunnel(), GDS_NEIGHBOURS_init(), get_cadet(), get_channel(), GNUNET_CONSENSUS_create(), GNUNET_CONVERSATION_call_start(), GNUNET_FS_get_indexed_files(), GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_ego_lookup_by_suffix(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_REVOCATION_query(), GNUNET_REVOCATION_revoke(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SECRETSHARING_create_session(), GNUNET_SECRETSHARING_decrypt(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_controller_connect(), GNUNET_TRANSPORT_address_to_string(), GSC_KX_init(), GSF_cadet_start_server(), GST_barriers_init(), handle_bob_client_message(), handle_client_call_message(), handle_client_evaluate(), handle_client_listen(), handle_client_register_message(), hash_for_index_cb(), listen_connect(), logger_run(), main(), main_init(), new_sub(), reconnect(), reconnect_arm(), reconnect_arm_monitor(), reconnect_phone(), reconnect_task(), reset_cadet(), run(), search_reconnect(), store_service(), testbed_run(), transport_connect_adapter(), try_connect(), try_open_exit(), try_reconnect(), and unindex_finish().

◆ GNUNET_MQ_hd_fixed_size

#define GNUNET_MQ_hd_fixed_size (   name,
  code,
  str,
  ctx 
)
Value:
({ \
void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \
((struct GNUNET_MQ_MessageHandler){ NULL, \
(ctx), \
(code), \
sizeof(str) }); \
})
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Message handler for a specific message type.
const char * name
void(* GNUNET_MQ_MessageCallback)(void *cls, const struct GNUNET_MessageHeader *msg)
Called when a message has been received.

Definition at line 545 of file gnunet_mq_lib.h.

Referenced by client_connect_cb(), client_disconnect_cb(), client_request_complete_alice(), core_connect_adapter(), create_internal(), create_loc_uri(), demultiplex_with_cmc(), do_peer_connect(), do_plugin_connect(), GCO_init(), GCT_create_tunnel(), get_channel(), GNUNET_CONSENSUS_create(), GNUNET_CONVERSATION_call_start(), GNUNET_FS_get_indexed_files(), GNUNET_REVOCATION_query(), GNUNET_REVOCATION_revoke(), GNUNET_SECRETSHARING_decrypt(), GNUNET_TESTBED_controller_connect(), GSC_KX_init(), GSF_cadet_start_server(), handle_bob_client_message(), handle_client_call_message(), handle_client_evaluate(), handle_client_listen(), handle_client_register_message(), hash_for_index_cb(), main(), main_init(), new_sub(), reconnect(), reconnect_arm(), reconnect_phone(), run(), testbed_run(), transport_communicator_start(), transport_connect_adapter(), try_connect(), try_reconnect(), and unindex_finish().

◆ GNUNET_MQ_hd_var_size

#define GNUNET_MQ_hd_var_size (   name,
  code,
  str,
  ctx 
)
Value:
__extension__({ \
int (*_mv)(void *cls, const str *msg) = &check_ ## name; \
void (*_cb)(void *cls, const str *msg) = &handle_ ## name; \
_mv, \
(ctx), \
(code), \
sizeof(str) }); \
})
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Message handler for a specific message type.
const char * name
void(* GNUNET_MQ_MessageCallback)(void *cls, const struct GNUNET_MessageHeader *msg)
Called when a message has been received.
int(* GNUNET_MQ_MessageValidationCallback)(void *cls, const struct GNUNET_MessageHeader *msg)
Called when a message needs to be validated.

Definition at line 596 of file gnunet_mq_lib.h.

Referenced by advertise_dns_exit(), client_connect_cb(), client_disconnect_cb(), client_request_complete_alice(), connect_check_run(), connect_task(), create_channel(), create_internal(), demultiplex_with_cmc(), disconnect_cb(), do_connect(), do_peer_connect(), do_plugin_connect(), do_reconnect(), GCO_init(), GCT_create_tunnel(), GDS_NEIGHBOURS_init(), get_cadet(), get_channel(), GNUNET_CONSENSUS_create(), GNUNET_CONVERSATION_call_start(), GNUNET_FS_get_indexed_files(), GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_ego_lookup_by_suffix(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SECRETSHARING_create_session(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_controller_connect(), GNUNET_TRANSPORT_address_to_string(), GSC_KX_init(), GST_barriers_init(), handle_bob_client_message(), handle_client_call_message(), handle_client_evaluate(), handle_client_listen(), handle_client_register_message(), hash_for_index_cb(), listen_connect(), logger_run(), main(), main_init(), new_sub(), reconnect(), reconnect_arm(), reconnect_arm_monitor(), reconnect_phone(), reconnect_task(), reset_cadet(), run(), search_reconnect(), store_service(), testbed_run(), transport_communicator_start(), try_connect(), try_open_exit(), and try_reconnect().

◆ GNUNET_MQ_check_zero_termination

#define GNUNET_MQ_check_zero_termination (   m)
Value:
{ \
const char *str = (const char *)&m[1]; \
const struct GNUNET_MessageHeader *hdr = \
(const struct GNUNET_MessageHeader *)m; \
uint16_t slen = ntohs(hdr->size) - sizeof(*m); \
if ((0 == slen) || (memchr(str, 0, slen) != &str[slen - 1])) \
{ \
GNUNET_break(0); \
return GNUNET_NO; \
} \
}
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Header for all communications.

Insert code for a "check_" function that verifies that a given variable-length message received over the network is followed by a 0-terminated string.

If the message m is not followed by a 0-terminated string, an error is logged and the function is returned with GNUNET_NO.

Parameters
anIPC message with proper type to determine the size, starting with a struct GNUNET_MessageHeader

Definition at line 619 of file gnunet_mq_lib.h.

Referenced by check_add_address(), check_add_queue_message(), check_announce(), check_ats_address_suggestion(), check_client_index_start(), check_communicator_available(), check_create_queue(), check_get(), check_identity_result_code(), check_lookup(), check_lookup_by_suffix_message(), check_lookup_message(), check_monitor_data(), check_record_lookup(), check_request_hello_validation(), check_session_add(), check_start(), and check_stop().

◆ GNUNET_MQ_check_boxed_message

#define GNUNET_MQ_check_boxed_message (   m)
Value:
{ \
const struct GNUNET_MessageHeader *inbox = \
(const struct GNUNET_MessageHeader *)&m[1]; \
const struct GNUNET_MessageHeader *hdr = \
(const struct GNUNET_MessageHeader *)m; \
uint16_t slen = ntohs(hdr->size) - sizeof(*m); \
if ((slen < sizeof(struct GNUNET_MessageHeader)) || \
(slen != ntohs(inbox->size))) \
{ \
GNUNET_break(0); \
return GNUNET_NO; \
} \
}
#define GNUNET_NO
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Header for all communications.

Insert code for a "check_" function that verifies that a given variable-length message received over the network is followed by another variable-length message that fits exactly with the given size.

If the message m is not followed by another struct GNUNET_MessageHeader with a size that adds up to the total size, an error is logged and the function is returned with GNUNET_NO.

Parameters
anIPC message with proper type to determine the size, starting with a struct GNUNET_MessageHeader

Definition at line 645 of file gnunet_mq_lib.h.

Referenced by check_backchannel_incoming(), check_incoming_msg(), check_reliability_box(), and check_send_msg().

Typedef Documentation

◆ GNUNET_MQ_MessageCallback

typedef void(* GNUNET_MQ_MessageCallback) (void *cls, const struct GNUNET_MessageHeader *msg)

Called when a message has been received.

Parameters
clsclosure
msgthe received message

Definition at line 306 of file gnunet_mq_lib.h.

◆ GNUNET_MQ_MessageValidationCallback

typedef int(* GNUNET_MQ_MessageValidationCallback) (void *cls, const struct GNUNET_MessageHeader *msg)

Called when a message needs to be validated.

Parameters
clsclosure
msgthe received message
Returns
GNUNET_OK if the message is well-formed, GNUNET_SYSERR if not

Definition at line 319 of file gnunet_mq_lib.h.

◆ GNUNET_MQ_SendImpl

typedef void(* GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)

Signature of functions implementing the sending functionality of a message queue.

Parameters
mqthe message queue
msgthe message to send
impl_statestate of the implementation

Definition at line 332 of file gnunet_mq_lib.h.

◆ GNUNET_MQ_DestroyImpl

typedef void(* GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq, void *impl_state)

Signature of functions implementing the destruction of a message queue.

Implementations must not free mq, but should take care of impl_state.

Parameters
mqthe message queue to destroy
impl_statestate of the implementation

Definition at line 346 of file gnunet_mq_lib.h.

◆ GNUNET_MQ_CancelImpl

typedef void(* GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq, void *impl_state)

Implementation function that cancels the currently sent message.

Parameters
mqmessage queue
impl_statestate specific to the implementation

Definition at line 356 of file gnunet_mq_lib.h.

◆ GNUNET_MQ_ErrorHandler

typedef void(* GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error)

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure
errorerror code

Definition at line 369 of file gnunet_mq_lib.h.

Enumeration Type Documentation

◆ GNUNET_MQ_Error

Error codes for the queue.

Enumerator
GNUNET_MQ_ERROR_READ 

Failed to read message from the network.

FIXME: Likely not properly distinguished from TIMEOUT case in the code!

GNUNET_MQ_ERROR_WRITE 

FIXME: document!

GNUNET_MQ_ERROR_TIMEOUT 

FIXME: document!

GNUNET_MQ_ERROR_MALFORMED 

We received a message that was malformed and thus could not be passed to its handler.

GNUNET_MQ_ERROR_NO_MATCH 

We received a message for which we have no matching handler.

Definition at line 191 of file gnunet_mq_lib.h.

191  {
198 
203 
208 
214 
220 };
We received a message for which we have no matching handler.
FIXME: document!
Failed to read message from the network.
We received a message that was malformed and thus could not be passed to its handler.
FIXME: document!

◆ GNUNET_MQ_PriorityPreferences

Per envelope preferences and priorities.

Enumerator
GNUNET_MQ_PRIO_BACKGROUND 

Lowest priority, i.e.

background traffic (i.e. NSE, FS). This is the default!

GNUNET_MQ_PRIO_BEST_EFFORT 

Best-effort traffic (i.e.

CADET relay, DHT)

GNUNET_MQ_PRIO_URGENT 

Urgent traffic (local peer, i.e.

Conversation).

GNUNET_MQ_PRIO_CRITICAL_CONTROL 

Highest priority, control traffic (i.e.

CORE/CADET KX).

GNUNET_MQ_PRIORITY_MASK 

Bit mask to apply to extract the priority bits.

GNUNET_MQ_PREF_UNRELIABLE 

Flag to indicate that unreliable delivery is acceptable.

This means TRANSPORT will not attempt to receive an acknowledgment. CORE will just pass this flag through. CADET will use unreliable delivery if this flag is set.

Note that even without this flag, messages may be lost by TRANSPORT and CORE.

Thus, how "strong" the semantics of reliable delivery are depends on the layer!

GNUNET_MQ_PREF_LOW_LATENCY 

Flag to indicate that low latency is important.

This flag must generally not be used in combination with #GNUNET_MQ_PREF_CORKING_ALLOWED as it would be a contradiction. When this flags is set, the envelope may skip forward in the queue (depending on priority) and also TRANSPORT should attempt to pick a communicator with particularly low latency.

GNUNET_MQ_PREF_CORK_ALLOWED 

Flag to indicate that CORKing is acceptable.

This allows the receiver to delay transmission in hope of combining this message with other messages into a larger transmission with less per-message overhead.

GNUNET_MQ_PREF_GOODPUT 

Flag to indicate that high bandwidth is desired.

This flag indicates that the method chosen for transmission should focus on overall goodput. It rarely makes sense to combine this flag with GNUNET_MQ_PREF_LOW_LATENCY.

GNUNET_MQ_PREF_OUT_OF_ORDER 

Flag to indicate that out-of-order delivery is OK.

Definition at line 226 of file gnunet_mq_lib.h.

226  {
232 
237 
242 
247 
252 
266 
276 
284 
292 
297 };
Urgent traffic (local peer, i.e.
Flag to indicate that low latency is important.
Best-effort traffic (i.e.
Flag to indicate that high bandwidth is desired.
Lowest priority, i.e.
Bit mask to apply to extract the priority bits.
Flag to indicate that out-of-order delivery is OK.
Flag to indicate that CORKing is acceptable.
Flag to indicate that unreliable delivery is acceptable.
Highest priority, control traffic (i.e.

◆ GNUNET_MQ_PreferenceKind

Enum defining all known preference categories.

Deprecated:
will be replaced by enum GNUNET_MQ_PriorityPreference
Enumerator
GNUNET_MQ_PREFERENCE_NONE 

No preference was expressed.

GNUNET_MQ_PREFERENCE_BANDWIDTH 

The preferred transmission for this envelope focuses on maximizing bandwidth.

GNUNET_MQ_PREFERENCE_LATENCY 

The preferred transmission for this envelope foces on minimizing latency.

GNUNET_MQ_PREFERENCE_RELIABILITY 

The preferred transmission for this envelope foces on reliability.

Definition at line 1062 of file gnunet_mq_lib.h.

1062  {
1067 
1073 
1079 
1085 
1089 #define GNUNET_MQ_PREFERENCE_COUNT 4
1090 };
No preference was expressed.
The preferred transmission for this envelope focuses on maximizing bandwidth.
The preferred transmission for this envelope foces on minimizing latency.
The preferred transmission for this envelope foces on reliability.

Function Documentation

◆ GNUNET_MQ_extract_nested_mh_()

const struct GNUNET_MessageHeader* GNUNET_MQ_extract_nested_mh_ ( const struct GNUNET_MessageHeader mh,
uint16_t  base_size 
)

Implementation of the #GNUNET_MQ_extract_nexted_mh macro.

Parameters
mhmessage header to extract nested message header from
base_sizesize of the message before the nested message's header appears
Returns
pointer to the nested message, does not copy the message OR NULL in case of a malformed message.

Definition at line 878 of file mq.c.

References GNUNET_assert, GNUNET_break_op, and GNUNET_MessageHeader::size.

880 {
881  uint16_t whole_size;
882  uint16_t nested_size;
883  const struct GNUNET_MessageHeader *nested_msg;
884 
885  whole_size = ntohs(mh->size);
886  GNUNET_assert(whole_size >= base_size);
887  nested_size = whole_size - base_size;
888  if (0 == nested_size)
889  return NULL;
890  if (nested_size < sizeof(struct GNUNET_MessageHeader))
891  {
892  GNUNET_break_op(0);
893  return NULL;
894  }
895  nested_msg = (const struct GNUNET_MessageHeader *)((char *)mh + base_size);
896  if (ntohs(nested_msg->size) != nested_size)
897  {
898  GNUNET_break_op(0);
899  return NULL;
900  }
901  return nested_msg;
902 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Header for all communications.

◆ GNUNET_MQ_env_get_msg()

const struct GNUNET_MessageHeader* GNUNET_MQ_env_get_msg ( const struct GNUNET_MQ_Envelope env)

Obtain message contained in envelope.

Parameters
envthe envelope
Returns
message contained in the envelope

Definition at line 1077 of file mq.c.

References GNUNET_MQ_Envelope::mh.

Referenced by do_send(), mqm_execute(), and route_message().

1078 {
1079  return env->mh;
1080 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
Here is the caller graph for this function:

◆ GNUNET_MQ_env_next()

const struct GNUNET_MQ_Envelope* GNUNET_MQ_env_next ( const struct GNUNET_MQ_Envelope env)

Return next envelope in queue.

Parameters
enva queued envelope
Returns
next one, or NULL

Definition at line 1090 of file mq.c.

References GNUNET_MQ_Envelope::next.

Referenced by route_message().

1091 {
1092  return env->next;
1093 }
struct GNUNET_MQ_Envelope * next
Messages are stored in a linked list.
Definition: mq.c:37
Here is the caller graph for this function:

◆ GNUNET_MQ_msg_nested_mh_()

struct GNUNET_MQ_Envelope* GNUNET_MQ_msg_nested_mh_ ( struct GNUNET_MessageHeader **  mhp,
uint16_t  base_size,
uint16_t  type,
const struct GNUNET_MessageHeader nested_mh 
)

Implementation of the GNUNET_MQ_msg_nested_mh macro.

Parameters
mhppointer to the message header pointer that will be changed to allocate at the newly allocated space for the message.
base_sizesize of the data before the nested message
typetype of the message in the envelope
nested_mhthe message to append to the message after base_size

Definition at line 673 of file mq.c.

References GNUNET_memcpy, GNUNET_MQ_msg_(), GNUNET_MQ_Envelope::mh, size, and GNUNET_MessageHeader::size.

677 {
678  struct GNUNET_MQ_Envelope *mqm;
679  uint16_t size;
680 
681  if (NULL == nested_mh)
682  return GNUNET_MQ_msg_(mhp, base_size, type);
683 
684  size = base_size + ntohs(nested_mh->size);
685 
686  /* check for uint16_t overflow */
687  if (size < base_size)
688  return NULL;
689 
690  mqm = GNUNET_MQ_msg_(mhp, size, type);
691  GNUNET_memcpy((char *)mqm->mh + base_size,
692  nested_mh,
693  ntohs(nested_mh->size));
694 
695  return mqm;
696 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_(struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type)
Create a new envelope.
Definition: mq.c:630
static unsigned int size
Size of the "table".
Definition: peer.c:66
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Here is the call graph for this function:

◆ GNUNET_MQ_dll_insert_head()

void GNUNET_MQ_dll_insert_head ( struct GNUNET_MQ_Envelope **  env_head,
struct GNUNET_MQ_Envelope **  env_tail,
struct GNUNET_MQ_Envelope env 
)

Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this function is used with DLLs defined outside of the MQ module.

This is just in case some application needs to also manage a FIFO of envelopes independent of MQ itself and wants to re-use the pointers internal to env. Use with caution.

Parameters

Definition at line 1150 of file mq.c.

References GNUNET_CONTAINER_DLL_insert.

Referenced by route_message().

1153 {
1154  GNUNET_CONTAINER_DLL_insert(*env_head, *env_tail, env);
1155 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Here is the caller graph for this function:

◆ GNUNET_MQ_dll_insert_tail()

void GNUNET_MQ_dll_insert_tail ( struct GNUNET_MQ_Envelope **  env_head,
struct GNUNET_MQ_Envelope **  env_tail,
struct GNUNET_MQ_Envelope env 
)

Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this function is used with DLLs defined outside of the MQ module.

This is just in case some application needs to also manage a FIFO of envelopes independent of MQ itself and wants to re-use the pointers internal to env. Use with caution.

Parameters

Definition at line 1171 of file mq.c.

References GNUNET_CONTAINER_DLL_insert_tail.

Referenced by route_message().

1174 {
1175  GNUNET_CONTAINER_DLL_insert_tail(*env_head, *env_tail, env);
1176 }
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Here is the caller graph for this function:

◆ GNUNET_MQ_dll_remove()

void GNUNET_MQ_dll_remove ( struct GNUNET_MQ_Envelope **  env_head,
struct GNUNET_MQ_Envelope **  env_tail,
struct GNUNET_MQ_Envelope env 
)

Remove env from the envelope DLL starting at env_head.

Note that env must not be in any MQ while this function is used with DLLs defined outside of the MQ module. This is just in case some application needs to also manage a FIFO of envelopes independent of MQ itself and wants to re-use the pointers internal to env. Use with caution.

Parameters

Definition at line 1192 of file mq.c.

References GNUNET_CONTAINER_DLL_remove.

Referenced by dir_ready_cb(), and discard_buffer().

1195 {
1196  GNUNET_CONTAINER_DLL_remove(*env_head, *env_tail, env);
1197 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Here is the caller graph for this function:

◆ GNUNET_MQ_copy_handlers()

struct GNUNET_MQ_MessageHandler* GNUNET_MQ_copy_handlers ( const struct GNUNET_MQ_MessageHandler handlers)

Copy an array of handlers.

Useful if the array has been delared in local memory and needs to be persisted for future use.

Parameters
handlersArray of handlers to be copied.
Returns
A newly allocated array of handlers. Needs to be freed with GNUNET_free.

Useful if the array has been delared in local memory and needs to be persisted for future use.

Parameters
handlersArray of handlers to be copied. Can be NULL (nothing done).
Returns
A newly allocated array of handlers. Needs to be freed with GNUNET_free.

Definition at line 1211 of file mq.c.

References GNUNET_memcpy, GNUNET_MQ_count_handlers(), and GNUNET_new_array.

Referenced by GNUNET_CADET_open_port(), GNUNET_CADET_TEST_ruN(), GNUNET_CORE_connect(), GNUNET_MQ_queue_for_callbacks(), and GNUNET_SERVICE_run_().

1212 {
1213  struct GNUNET_MQ_MessageHandler *copy;
1214  unsigned int count;
1215 
1216  if (NULL == handlers)
1217  return NULL;
1218 
1219  count = GNUNET_MQ_count_handlers(handlers);
1220  copy = GNUNET_new_array(count + 1, struct GNUNET_MQ_MessageHandler);
1221  GNUNET_memcpy(copy,
1222  handlers,
1223  count * sizeof(struct GNUNET_MQ_MessageHandler));
1224  return copy;
1225 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
Message handler for a specific message type.
unsigned int GNUNET_MQ_count_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Count the handlers in a handler array.
Definition: mq.c:1271
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_copy_handlers2()

struct GNUNET_MQ_MessageHandler* GNUNET_MQ_copy_handlers2 ( const struct GNUNET_MQ_MessageHandler handlers,
GNUNET_MQ_MessageCallback  agpl_handler,
void *  agpl_cls 
)

Copy an array of handlers, appending AGPL handler.

Useful if the array has been delared in local memory and needs to be persisted for future use.

Parameters
handlersArray of handlers to be copied. Can be NULL (nothing done).
agpl_handlerfunction to call for AGPL handling
agpl_clsclosure for agpl_handler
Returns
A newly allocated array of handlers. Needs to be freed with GNUNET_free.

Definition at line 1241 of file mq.c.

References GNUNET_MQ_MessageHandler::cb, GNUNET_MQ_MessageHandler::cls, GNUNET_MQ_MessageHandler::expected_size, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_REQUEST_AGPL, GNUNET_MQ_count_handlers(), GNUNET_new_array, GNUNET_MQ_MessageHandler::mv, and GNUNET_MQ_MessageHandler::type.

Referenced by GNUNET_SERVICE_start().

1244 {
1245  struct GNUNET_MQ_MessageHandler *copy;
1246  unsigned int count;
1247 
1248  if (NULL == handlers)
1249  return NULL;
1250  count = GNUNET_MQ_count_handlers(handlers);
1251  copy = GNUNET_new_array(count + 2, struct GNUNET_MQ_MessageHandler);
1252  GNUNET_memcpy(copy,
1253  handlers,
1254  count * sizeof(struct GNUNET_MQ_MessageHandler));
1255  copy[count].mv = NULL;
1256  copy[count].cb = agpl_handler;
1257  copy[count].cls = agpl_cls;
1258  copy[count].type = GNUNET_MESSAGE_TYPE_REQUEST_AGPL;
1259  copy[count].expected_size = sizeof(struct GNUNET_MessageHeader);
1260  return copy;
1261 }
uint16_t expected_size
Expected size of messages of this type.
#define GNUNET_MESSAGE_TYPE_REQUEST_AGPL
Message to request source code link.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t type
Type of the message this handler covers, in host byte order.
void * cls
Closure for mv and cb.
GNUNET_MQ_MessageValidationCallback mv
Callback to validate a message of the specified type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
Message handler for a specific message type.
unsigned int GNUNET_MQ_count_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Count the handlers in a handler array.
Definition: mq.c:1271
Header for all communications.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_count_handlers()

unsigned int GNUNET_MQ_count_handlers ( const struct GNUNET_MQ_MessageHandler handlers)

Count the handlers in a handler array.

Parameters
handlersArray of handlers to be counted.
Returns
The number of handlers in the array.

Definition at line 1271 of file mq.c.

References GNUNET_MQ_MessageHandler::cb.

Referenced by GNUNET_CORE_connect(), GNUNET_MQ_copy_handlers(), and GNUNET_MQ_copy_handlers2().

1272 {
1273  unsigned int i;
1274 
1275  if (NULL == handlers)
1276  return 0;
1277 
1278  for (i = 0; NULL != handlers[i].cb; i++)
1279  ;
1280 
1281  return i;
1282 }
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
Here is the caller graph for this function:

◆ GNUNET_MQ_handle_message()

int GNUNET_MQ_handle_message ( const struct GNUNET_MQ_MessageHandler handlers,
const struct GNUNET_MessageHeader mh 
)

Call the message message handler that was registered for the type of the given message in the given handlers list.

This function is indended to be used for the implementation of message queues.

Parameters
handlersa set of handlers
mhmessage to dispatch
Returns
GNUNET_OK on success, GNUNET_NO if no handler matched, GNUNET_SYSERR if message was rejected by check function

Definition at line 227 of file mq.c.

References GNUNET_MQ_MessageHandler::cb, GNUNET_MQ_MessageHandler::cls, done(), GNUNET_MQ_MessageHandler::expected_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, LOG, GNUNET_MQ_MessageHandler::mv, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and GNUNET_MQ_MessageHandler::type.

Referenced by demultiplex_with_cmc(), and GNUNET_MQ_inject_message().

229 {
230  const struct GNUNET_MQ_MessageHandler *handler;
231  int handled = GNUNET_NO;
232  uint16_t msize = ntohs(mh->size);
233  uint16_t mtype = ntohs(mh->type);
234 
236  "Received message of type %u and size %u\n",
237  mtype,
238  msize);
239 
240  if (NULL == handlers)
241  goto done;
242  for (handler = handlers; NULL != handler->cb; handler++)
243  {
244  if (handler->type == mtype)
245  {
246  handled = GNUNET_YES;
247  if ((handler->expected_size > msize) ||
248  ((handler->expected_size != msize) && (NULL == handler->mv)))
249  {
250  /* Too small, or not an exact size and
251  no 'mv' handler to check rest */
253  "Received malformed message of type %u\n",
254  (unsigned int)handler->type);
255  return GNUNET_SYSERR;
256  }
257  if ((NULL == handler->mv) ||
258  (GNUNET_OK == handler->mv(handler->cls, mh)))
259  {
260  /* message well-formed, pass to handler */
261  handler->cb(handler->cls, mh);
262  }
263  else
264  {
265  /* Message rejected by check routine */
267  "Received malformed message of type %u\n",
268  (unsigned int)handler->type);
269  return GNUNET_SYSERR;
270  }
271  break;
272  }
273  }
274 done:
275  if (GNUNET_NO == handled)
276  {
278  "No handler for message of type %u and size %u\n",
279  mtype,
280  msize);
281  return GNUNET_NO;
282  }
283  return GNUNET_OK;
284 }
static void done()
uint16_t expected_size
Expected size of messages of this type.
#define GNUNET_NO
Definition: gnunet_common.h:78
#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...
uint16_t type
Type of the message this handler covers, in host byte order.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
void * cls
Closure for mv and cb.
GNUNET_MQ_MessageValidationCallback mv
Callback to validate a message of the specified type.
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
Message handler for a specific message type.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define LOG(kind,...)
Definition: mq.c:29
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_msg_()

struct GNUNET_MQ_Envelope* GNUNET_MQ_msg_ ( struct GNUNET_MessageHeader **  mhp,
uint16_t  size,
uint16_t  type 
)

Create a new envelope.

Parameters
mhpmessage header to store the allocated message header in, can be NULL
sizesize of the message to allocate
typetype of the message, will be set in the allocated message
Returns
the allocated MQ message

Definition at line 630 of file mq.c.

References GNUNET_malloc, GNUNET_MQ_Envelope::mh, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GNUNET_MQ_msg_nested_mh_().

631 {
632  struct GNUNET_MQ_Envelope *ev;
633 
634  ev = GNUNET_malloc(size + sizeof(struct GNUNET_MQ_Envelope));
635  ev->mh = (struct GNUNET_MessageHeader *)&ev[1];
636  ev->mh->size = htons(size);
637  ev->mh->type = htons(type);
638  if (NULL != mhp)
639  *mhp = ev->mh;
640  return ev;
641 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static unsigned int size
Size of the "table".
Definition: peer.c:66
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_MQ_msg_copy()

struct GNUNET_MQ_Envelope* GNUNET_MQ_msg_copy ( const struct GNUNET_MessageHeader hdr)

Create a new envelope by copying an existing message.

Parameters
hdrheader of the message to copy
Returns
envelope containing hdr

Definition at line 651 of file mq.c.

References GNUNET_malloc, GNUNET_memcpy, GNUNET_MQ_Envelope::mh, size, and GNUNET_MessageHeader::size.

Referenced by do_connect(), GNUNET_MQ_env_copy(), GNUNET_notification_context_broadcast(), GNUNET_PEERINFO_add_peer(), GNUNET_TRANSPORT_offer_hello(), GST_clients_broadcast_peer_notification(), GST_forwarded_operation_reply_relay(), handle_barrier_status(), handle_send_msg(), handle_start(), notify_client(), plugin_session_info_cb(), route_message(), schedule_next_hello(), send_key(), send_peer_information(), send_ping(), transmit_task_cb(), and unicast().

652 {
653  struct GNUNET_MQ_Envelope *mqm;
654  uint16_t size = ntohs(hdr->size);
655 
656  mqm = GNUNET_malloc(sizeof(*mqm) + size);
657  mqm->mh = (struct GNUNET_MessageHeader *)&mqm[1];
658  GNUNET_memcpy(mqm->mh, hdr, size);
659  return mqm;
660 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static unsigned int size
Size of the "table".
Definition: peer.c:66
Header for all communications.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ GNUNET_MQ_discard()

void GNUNET_MQ_discard ( struct GNUNET_MQ_Envelope ev)

Discard the message queue message, free all allocated resources.

Must be called in the event that a message is created but should not actually be sent.

Parameters
mqmthe message to discard

Definition at line 319 of file mq.c.

References GNUNET_assert, GNUNET_free, and GNUNET_MQ_Envelope::parent_queue.

Referenced by abort_all_requests(), broadcast_status(), cadet_mq_cancel_impl(), core_mq_cancel_impl(), destroy_channel(), discard_buffer(), disconnect_and_free_peer_entry(), free_channel_client(), free_it(), free_op(), free_qe(), free_queue_entry(), free_ze(), GCCH_handle_channel_plaintext_data(), GCP_request_mq_cancel(), GCP_send_ooo(), GCP_set_mq(), GCT_send_cancel(), GNUNET_CREDENTIAL_request_cancel(), GNUNET_GNS_lookup_cancel(), GNUNET_MQ_destroy(), GSF_peer_disconnect_handler(), handle_dns_response(), handle_result(), make_queue_entry(), mqm_execute(), send_client_element(), send_to_channel(), and set_operation_destroy().

320 {
321  GNUNET_assert(NULL == ev->parent_queue);
322  GNUNET_free(ev);
323 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_MQ_get_current_envelope()

struct GNUNET_MQ_Envelope* GNUNET_MQ_get_current_envelope ( struct GNUNET_MQ_Handle mq)

Function to obtain the current envelope from within GNUNET_MQ_SendImpl implementations.

Parameters
mqmessage queue to interrogate
Returns
the current envelope

Definition at line 971 of file mq.c.

References GNUNET_MQ_Handle::current_envelope.

Referenced by cadet_mq_send_impl(), core_mq_send_impl(), and mq_send_impl().

972 {
973  return mq->current_envelope;
974 }
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141
Here is the caller graph for this function:

◆ GNUNET_MQ_env_copy()

struct GNUNET_MQ_Envelope* GNUNET_MQ_env_copy ( struct GNUNET_MQ_Envelope env)

Function to copy an envelope.

The envelope must not yet be in any queue or have any options or callbacks set.

Parameters
envenvelope to copy
Returns
copy of env

Definition at line 412 of file mq.c.

References GNUNET_assert, GNUNET_MQ_msg_copy(), GNUNET_NO, GNUNET_MQ_Envelope::have_custom_options, GNUNET_MQ_Envelope::mh, GNUNET_MQ_Envelope::next, GNUNET_MQ_Envelope::parent_queue, and GNUNET_MQ_Envelope::sent_cb.

Referenced by cadet_channel_end_cb(), and dns_pre_request_handler().

413 {
414  GNUNET_assert(NULL == env->next);
415  GNUNET_assert(NULL == env->parent_queue);
416  GNUNET_assert(NULL == env->sent_cb);
418  return GNUNET_MQ_msg_copy(env->mh);
419 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:651
int have_custom_options
Did the application call GNUNET_MQ_env_set_options()?
Definition: mq.c:77
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
GNUNET_SCHEDULER_TaskCallback sent_cb
Called after the message was sent irrevocably.
Definition: mq.c:60
struct GNUNET_MQ_Envelope * next
Messages are stored in a linked list.
Definition: mq.c:37
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_get_last_envelope()

struct GNUNET_MQ_Envelope* GNUNET_MQ_get_last_envelope ( struct GNUNET_MQ_Handle mq)

Function to obtain the last envelope in the queue.

Parameters
mqmessage queue to interrogate
Returns
the last envelope in the queue

Definition at line 984 of file mq.c.

References GNUNET_MQ_Handle::current_envelope, and GNUNET_MQ_Handle::envelope_tail.

985 {
986  if (NULL != mq->envelope_tail)
987  return mq->envelope_tail;
988 
989  return mq->current_envelope;
990 }
struct GNUNET_MQ_Envelope * envelope_tail
Linked list of messages pending to be sent.
Definition: mq.c:134
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141

◆ GNUNET_MQ_env_set_options()

void GNUNET_MQ_env_set_options ( struct GNUNET_MQ_Envelope env,
enum GNUNET_MQ_PriorityPreferences  pp 
)

Set application-specific options for this envelope.

Overrides the options set for the queue with GNUNET_MQ_set_options() for this message only.

Parameters
envmessage to set options for
pppriority and preferences to set for env

Set application-specific options for this envelope.

Overrides the options set for the queue with GNUNET_MQ_set_options() for this message only.

Parameters
envmessage to set options for
pppriorities and preferences to apply

Definition at line 1002 of file mq.c.

References GNUNET_YES, GNUNET_MQ_Envelope::have_custom_options, and GNUNET_MQ_Envelope::priority.

Referenced by adv_transmit(), client_request_complete_alice(), route_message(), send_to_channel(), and transmit_pending().

1004 {
1005  env->priority = pp;
1007 }
int have_custom_options
Did the application call GNUNET_MQ_env_set_options()?
Definition: mq.c:77
enum GNUNET_MQ_PriorityPreferences priority
Flags that were set for this envelope by GNUNET_MQ_env_set_options().
Definition: mq.c:72
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GNUNET_MQ_env_get_options()

enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options ( struct GNUNET_MQ_Envelope env)

Get performance preferences set for this envelope.

Parameters
envmessage to set options for
Returns
priority and preferences to use

Get performance preferences set for this envelope.

Parameters
envmessage to set options for
Returns
priorities and preferences to apply for env

Definition at line 1017 of file mq.c.

References GNUNET_YES, GNUNET_MQ_Envelope::have_custom_options, mq, GNUNET_MQ_Envelope::parent_queue, GNUNET_MQ_Envelope::priority, and GNUNET_MQ_Handle::priority.

Referenced by cadet_mq_send_impl(), core_mq_send_impl(), mq_send_impl(), and route_message().

1018 {
1019  struct GNUNET_MQ_Handle *mq = env->parent_queue;
1020 
1021  if (GNUNET_YES == env->have_custom_options)
1022  return env->priority;
1023  if (NULL == mq)
1024  return 0;
1025  return mq->priority;
1026 }
int have_custom_options
Did the application call GNUNET_MQ_env_set_options()?
Definition: mq.c:77
enum GNUNET_MQ_PriorityPreferences priority
Flags that were set for this queue by GNUNET_MQ_set_options().
Definition: mq.c:162
Handle to a message queue.
Definition: mq.c:84
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
enum GNUNET_MQ_PriorityPreferences priority
Flags that were set for this envelope by GNUNET_MQ_env_set_options().
Definition: mq.c:72
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GNUNET_MQ_env_combine_options()

enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_combine_options ( enum GNUNET_MQ_PriorityPreferences  p1,
enum GNUNET_MQ_PriorityPreferences  p2 
)

Combine performance preferences set for different envelopes that are being combined into one larger envelope.

Parameters
p1one set of preferences
p2second set of preferences
Returns
combined priority and preferences to use

Definition at line 1038 of file mq.c.

References GNUNET_MAX, GNUNET_MQ_PREF_CORK_ALLOWED, GNUNET_MQ_PREF_GOODPUT, GNUNET_MQ_PREF_LOW_LATENCY, GNUNET_MQ_PREF_OUT_OF_ORDER, GNUNET_MQ_PREF_UNRELIABLE, GNUNET_MQ_PRIORITY_MASK, and ret.

1040 {
1042 
1043  ret = GNUNET_MAX(p1 & GNUNET_MQ_PRIORITY_MASK, p2 & GNUNET_MQ_PRIORITY_MASK);
1044  ret |= ((p1 & GNUNET_MQ_PREF_UNRELIABLE) & (p2 & GNUNET_MQ_PREF_UNRELIABLE));
1045  ret |=
1047  ret |=
1049  ret |= ((p1 & GNUNET_MQ_PREF_GOODPUT) & (p2 & GNUNET_MQ_PREF_GOODPUT));
1050  ret |=
1052  return ret;
1053 }
GNUNET_MQ_PriorityPreferences
Per envelope preferences and priorities.
static int ret
Final status code.
Definition: gnunet-arm.c:89
Flag to indicate that low latency is important.
Flag to indicate that high bandwidth is desired.
#define GNUNET_MAX(a, b)
Definition: gnunet_common.h:82
Bit mask to apply to extract the priority bits.
Flag to indicate that out-of-order delivery is OK.
Flag to indicate that CORKing is acceptable.
Flag to indicate that unreliable delivery is acceptable.

◆ GNUNET_MQ_unsent_head()

struct GNUNET_MQ_Envelope* GNUNET_MQ_unsent_head ( struct GNUNET_MQ_Handle mq)

Remove the first envelope that has not yet been sent from the message queue and return it.

Parameters
mqqueue to remove envelope from
Returns
NULL if queue is empty (or has no envelope that is not under transmission)

Definition at line 392 of file mq.c.

References env, GNUNET_MQ_Handle::envelope_head, GNUNET_MQ_Handle::envelope_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_MQ_Envelope::parent_queue, and GNUNET_MQ_Handle::queue_length.

Referenced by send_to_channel().

393 {
394  struct GNUNET_MQ_Envelope *env;
395 
396  env = mq->envelope_head;
398  mq->queue_length--;
399  env->parent_queue = NULL;
400  return env;
401 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
unsigned int queue_length
Number of entries we have in the envelope-DLL.
Definition: mq.c:174
struct GNUNET_MQ_Envelope * envelope_tail
Linked list of messages pending to be sent.
Definition: mq.c:134
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
struct GNUNET_MQ_Envelope * envelope_head
Linked list of messages pending to be sent.
Definition: mq.c:129
Here is the caller graph for this function:

◆ GNUNET_MQ_set_options()

void GNUNET_MQ_set_options ( struct GNUNET_MQ_Handle mq,
enum GNUNET_MQ_PriorityPreferences  pp 
)

Set application-specific options for this queue.

Parameters
mqmessage queue to set options for
pppriority and preferences to use by default

Set application-specific options for this queue.

Parameters
mqmessage queue to set options for
pppriorities and preferences to apply

Definition at line 1063 of file mq.c.

References GNUNET_MQ_Handle::priority.

Referenced by connect_notify(), and handle_core_connect().

1065 {
1066  mq->priority = pp;
1067 }
enum GNUNET_MQ_PriorityPreferences priority
Flags that were set for this queue by GNUNET_MQ_set_options().
Definition: mq.c:162
Here is the caller graph for this function:

◆ GNUNET_MQ_get_length()

unsigned int GNUNET_MQ_get_length ( struct GNUNET_MQ_Handle mq)

Obtain the current length of the message queue.

Parameters
mqqueue to inspect
Returns
number of queued, non-transmitted messages

Definition at line 333 of file mq.c.

References GNUNET_YES, GNUNET_MQ_Handle::in_flight, and GNUNET_MQ_Handle::queue_length.

Referenced by continue_writing(), GCP_send(), GCP_send_ooo(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), GNUNET_notification_context_broadcast(), GNUNET_STATISTICS_destroy(), GNUNET_TRANSPORT_communicator_receive(), GSC_CLIENTS_deliver_message(), GSC_NEIGHBOURS_get_queue_length(), handle_p2p_get(), schedule_action(), send_to_channel(), transmit_pending(), and unicast().

334 {
335  if (GNUNET_YES != mq->in_flight)
336  {
337  return mq->queue_length;
338  }
339  return mq->queue_length - 1;
340 }
unsigned int queue_length
Number of entries we have in the envelope-DLL.
Definition: mq.c:174
int in_flight
GNUNET_YES if GNUNET_MQ_impl_send_in_flight() was called.
Definition: mq.c:185
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GNUNET_MQ_send()

void GNUNET_MQ_send ( struct GNUNET_MQ_Handle mq,
struct GNUNET_MQ_Envelope ev 
)

Send a message with the given message queue.

May only be called once per message.

Parameters
mqmessage queue
evthe envelope with the message to send.

Definition at line 351 of file mq.c.

References GNUNET_MQ_Handle::current_envelope, GNUNET_MQ_Handle::envelope_head, GNUNET_MQ_Handle::envelope_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MQ_Handle::impl_state, LOG, GNUNET_MQ_Envelope::mh, mq, GNUNET_MQ_Envelope::parent_queue, GNUNET_MQ_Handle::queue_length, GNUNET_MQ_Handle::send_impl, GNUNET_MQ_Handle::send_task, and GNUNET_MessageHeader::type.

Referenced by add_to_tc(), addr_cb(), adv_transmit(), allocate_cb(), announce_reconnect(), attr_iter_cb(), attr_iter_finished(), attr_store_cont(), broadcast_status(), cadet_channel_end_cb(), cadet_mq_send_now(), cancel_stream(), change_service(), check_peer_online(), clean_up_channel(), client_request_complete_alice(), client_response_handler(), client_send_response(), comm_schedule_send(), conclude_autoconfig_request(), connect_cb(), consume_result_cb(), core_mq_send_impl(), core_send_connect_info(), cores_send_disconnect_info(), create_internal(), create_loc_uri(), decode_and_send(), decrypt_conclude(), dispatch_buffer(), dns_pre_request_handler(), do_blacklist_check(), do_connect(), do_flood(), do_peer_connect(), do_plugin_connect(), do_send(), fail_intersection_operation(), fail_union_operation(), finish_cmc_handling(), forward_reply(), GAS_handle_address_destroyed(), GAS_handle_reservation_request(), GAS_scheduling_transmit_address_suggestion(), GCP_request_mq_cancel(), GCP_send_ooo(), GDS_CLIENTS_process_get(), GDS_CLIENTS_process_get_resp(), GDS_CLIENTS_process_put(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GDS_NEIGHBOURS_handle_reply(), get_all_peers_iterator(), get_all_tunnels_iterator(), GNUNET_ARM_request_service_list(), GNUNET_ATS_address_destroy(), GNUNET_ATS_address_update(), GNUNET_ATS_application_suggest_cancel(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_ATS_performance_change_preference(), GNUNET_ATS_performance_give_feedback(), GNUNET_ATS_performance_list_addresses(), GNUNET_ATS_reserve_bandwidth(), GNUNET_ATS_session_del(), GNUNET_ATS_session_update(), GNUNET_ATS_TEST_traffic_handle_ping(), GNUNET_CADET_channel_create(), GNUNET_CADET_channel_destroy(), GNUNET_CADET_close_port(), GNUNET_CADET_receive_done(), GNUNET_CONSENSUS_conclude(), GNUNET_CONSENSUS_create(), GNUNET_CONSENSUS_insert(), GNUNET_CONVERSATION_call_resume(), GNUNET_CONVERSATION_call_suspend(), GNUNET_CONVERSATION_caller_hang_up(), GNUNET_CONVERSATION_caller_pick_up(), GNUNET_CONVERSATION_caller_resume(), GNUNET_CONVERSATION_caller_suspend(), GNUNET_DATASTORE_disconnect(), GNUNET_DHT_get_stop(), GNUNET_DHT_monitor_stop(), GNUNET_DHT_put(), GNUNET_DNS_request_answer(), GNUNET_DNS_request_drop(), GNUNET_DNS_request_forward(), GNUNET_FS_get_indexed_files(), GNUNET_FS_indexing_send_list(), GNUNET_IDENTITY_create(), GNUNET_IDENTITY_delete(), GNUNET_IDENTITY_ego_lookup(), GNUNET_IDENTITY_ego_lookup_by_suffix(), GNUNET_IDENTITY_get(), GNUNET_IDENTITY_rename(), GNUNET_IDENTITY_set(), GNUNET_MQ_send_copy(), GNUNET_NAMECACHE_block_cache(), GNUNET_NAMECACHE_lookup_block(), GNUNET_NAMESTORE_records_lookup(), GNUNET_NAMESTORE_records_store(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_NAT_request_reversal(), GNUNET_NAT_stun_handle_packet(), GNUNET_notification_context_broadcast(), GNUNET_PEERINFO_add_peer(), GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_watch(), GNUNET_PEERSTORE_watch_cancel(), GNUNET_RECLAIM_get_attributes_next(), GNUNET_RECLAIM_get_attributes_start(), GNUNET_RECLAIM_get_attributes_stop(), GNUNET_RECLAIM_ticket_iteration_next(), GNUNET_RECLAIM_ticket_iteration_start(), GNUNET_RECLAIM_ticket_iteration_stop(), GNUNET_RECLAIM_ticket_revoke(), GNUNET_REVOCATION_query(), GNUNET_REVOCATION_revoke(), GNUNET_RPS_seed_ids(), GNUNET_RPS_stream_request(), GNUNET_RPS_sub_start(), GNUNET_RPS_sub_stop(), GNUNET_RPS_view_request(), GNUNET_RPS_view_request_cancel(), GNUNET_SCALARPRODUCT_accept_computation(), GNUNET_SCALARPRODUCT_start_computation(), GNUNET_SECRETSHARING_create_session(), GNUNET_SECRETSHARING_decrypt(), GNUNET_SET_add_element(), GNUNET_SET_commit(), GNUNET_SET_copy_lazy(), GNUNET_SET_iterate(), GNUNET_SET_operation_cancel(), GNUNET_SET_remove_element(), GNUNET_TESTBED_barrier_cancel(), GNUNET_TESTBED_barrier_init_(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTBED_queue_message_(), GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_application_suggest_cancel(), GNUNET_TRANSPORT_application_validate(), GNUNET_TRANSPORT_communicator_notify(), GNUNET_TRANSPORT_communicator_receive(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_core_get_mq(), GNUNET_TRANSPORT_manipulation_set(), GNUNET_TRANSPORT_offer_hello(), GNUNET_TRANSPORT_TESTING_send(), GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), GNUNET_TRANSPORT_TESTING_transport_communicator_send(), GSC_CLIENTS_deliver_message(), GSC_CLIENTS_notify_client_about_neighbour(), GSC_CLIENTS_solicit_request(), GSC_KX_encrypt_and_transmit(), GSC_KX_handle_client_monitor_peers(), GSC_send_to_client(), GST_clients_broadcast_peer_notification(), GST_forwarded_operation_reply_relay(), GST_send_operation_fail_msg(), GST_send_operation_success_msg(), handle_add_host(), handle_backchannel_encapsulation(), handle_barrier_status(), handle_block_cache(), handle_cadet_audio_message(), handle_cadet_hangup_message(), handle_cadet_pickup_message(), handle_cadet_resume_message(), handle_cadet_ring_message(), handle_cadet_suspend_message(), handle_channel_created(), handle_client_accept(), handle_client_address_to_string(), handle_client_audio_message(), handle_client_call_message(), handle_client_copy_lazy_prepare(), handle_client_hangup_message(), handle_client_init(), handle_client_loc_sign(), handle_client_monitor_peers(), handle_client_pickup_message(), handle_client_resume_message(), handle_client_suspend_message(), handle_client_unindex(), handle_create_queue(), handle_data(), handle_datastore_reply(), handle_disconnect(), handle_get(), handle_get_all(), handle_get_default_message(), handle_get_peers(), handle_gns_response(), handle_incoming_msg(), handle_info_tunnels(), handle_iter_element(), handle_list(), handle_lookup_block(), handle_lookup_block_it(), handle_lookup_by_suffix_message(), handle_lookup_message(), handle_notify(), handle_peer_create(), handle_peer_get_config(), handle_peer_start(), handle_peer_stop(), handle_ping(), handle_query(), handle_query_message(), handle_raw_message(), handle_record_lookup(), handle_request(), handle_revoke_message(), handle_search_result(), handle_send_msg(), handle_send_ready(), handle_show_path(), handle_slave_get_config(), handle_start(), handle_start_message(), handle_test(), handle_union_p2p_demand(), handle_union_p2p_full_done(), handle_union_p2p_offer(), handle_union_p2p_strata_estimator(), handle_zone_to_name(), handle_zone_to_name_it(), hash_for_index_cb(), hash_for_index_val(), intersection_evaluate(), keygen_round2_conclude(), listen_connect(), maybe_finish(), monitor_sync(), mq_send_impl(), mqm_execute(), notify_change(), notify_client(), notify_clients_stun_change(), notify_monitor(), open_port_cb(), opstart_manage_service(), opstart_overlay_connect(), opstart_peer_create(), opstart_peer_destroy(), opstart_peer_reconfigure(), opstart_peer_start(), opstart_peer_stop(), opstart_shutdown_peers(), path_info_iterator(), peer_transmit(), plugin_session_info_cb(), prepare_client_end_notification(), process_dns_result(), process_queue(), process_requests(), queue_send_msg(), read_stdio(), reconnect(), reconnect_arm(), reconnect_arm_monitor(), reconnect_phone(), record_iterator(), retry_entry(), return_agpl(), reversal_callback(), revoke_result_cb(), rewatch_it(), schedule_action(), schedule_next_hello(), schedule_transmit_search_request(), search_reconnect(), send_ack(), send_add_address(), send_add_address_message(), send_add_queue(), send_add_session_message(), send_alices_cryptodata_message(), send_bloomfilter(), send_client_done(), send_client_done_and_destroy(), send_client_element(), send_client_removed_element(), send_client_reply(), send_client_status_msg(), send_controller_link_response(), send_del_address(), send_del_queue(), send_delete_response(), send_echo(), send_element_count(), send_end_msg(), send_full_element_iterator(), send_full_set(), send_get(), send_get_known_results(), send_ibf(), send_ic_request(), send_key(), send_lookup_response(), send_message(), send_missing_full_elements_iter(), send_monitor_start(), send_msg(), send_offers_iterator(), send_overlay_connect_success_msg(), send_p2p_done(), send_packet_to_cadet_channel(), send_peer_information(), send_ping(), send_remaining_elements(), send_reply(), send_request(), send_request_to_client(), send_result_code(), send_start_monitor(), send_store_response(), send_stream_peers(), send_ticket_result(), send_to_channel(), send_to_client_iter(), send_view(), signal_index_ok(), signal_result(), suggest_cb(), suggest_to_connect(), test_nat_punched(), ticket_iter_cb(), transmit(), transmit_address_to_client(), transmit_bobs_cryptodata_message(), transmit_bobs_cryptodata_message_multipart(), transmit_call_audio(), transmit_client_response(), transmit_get(), transmit_item(), transmit_pending(), transmit_phone_audio(), transmit_req_addr(), transmit_set(), transmit_status(), transmit_suggestion(), transmit_task_cb(), transmit_watch(), unicast(), unindex_finish(), union_accept(), union_evaluate(), watch_notifier_it(), and zone_iteration_done_client_continue().

352 {
353  GNUNET_assert(NULL != mq);
354  GNUNET_assert(NULL == ev->parent_queue);
355 
356  mq->queue_length++;
357  if (mq->queue_length >= 10000)
358  {
359  /* This would seem like a bug... */
361  "MQ with %u entries extended by message of type %u (FC broken?)\n",
362  (unsigned int)mq->queue_length,
363  (unsigned int)ntohs(ev->mh->type));
364  }
365  ev->parent_queue = mq;
366  /* is the implementation busy? queue it! */
367  if ((NULL != mq->current_envelope) || (NULL != mq->send_task))
368  {
370  return;
371  }
372  GNUNET_assert(NULL == mq->envelope_head);
373  mq->current_envelope = ev;
374 
376  "sending message of type %u, queue empty (MQ: %p)\n",
377  ntohs(ev->mh->type),
378  mq);
379 
380  mq->send_impl(mq, ev->mh, mq->impl_state);
381 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
void * impl_state
Implementation-specific state.
Definition: mq.c:109
unsigned int queue_length
Number of entries we have in the envelope-DLL.
Definition: mq.c:174
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Envelope * envelope_tail
Linked list of messages pending to be sent.
Definition: mq.c:134
GNUNET_MQ_SendImpl send_impl
Actual implementation of message sending, called when a message is added.
Definition: mq.c:94
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_SCHEDULER_Task * send_task
Task to asynchronously run impl_send_continue().
Definition: mq.c:124
#define LOG(kind,...)
Definition: mq.c:29
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
struct GNUNET_MQ_Envelope * envelope_head
Linked list of messages pending to be sent.
Definition: mq.c:129

◆ GNUNET_MQ_send_copy()

void GNUNET_MQ_send_copy ( struct GNUNET_MQ_Handle mq,
const struct GNUNET_MQ_Envelope ev 
)

Send a copy of a message with the given message queue.

Can be called repeatedly on the same envelope.

Parameters
mqmessage queue
evthe envelope with the message to send.

Definition at line 430 of file mq.c.

References env, GNUNET_malloc, GNUNET_memcpy, GNUNET_MQ_send(), GNUNET_MQ_Envelope::mh, GNUNET_MQ_Envelope::sent_cb, GNUNET_MQ_Envelope::sent_cls, and GNUNET_MessageHeader::size.

Referenced by GNUNET_CREDENTIAL_collect(), GNUNET_CREDENTIAL_verify(), GNUNET_GNS_lookup(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_ticket_consume(), GNUNET_RECLAIM_ticket_issue(), and reconnect().

432 {
433  struct GNUNET_MQ_Envelope *env;
434  uint16_t msize;
435 
436  msize = ntohs(ev->mh->size);
437  env = GNUNET_malloc(sizeof(struct GNUNET_MQ_Envelope) + msize);
438  env->mh = (struct GNUNET_MessageHeader *)&env[1];
439  env->sent_cb = ev->sent_cb;
440  env->sent_cls = ev->sent_cls;
441  GNUNET_memcpy(&env[1], ev->mh, msize);
442  GNUNET_MQ_send(mq, env);
443 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
GNUNET_SCHEDULER_TaskCallback sent_cb
Called after the message was sent irrevocably.
Definition: mq.c:60
void * sent_cls
Closure for send_cb.
Definition: mq.c:65
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Header for all communications.
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:351
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_send_cancel()

void GNUNET_MQ_send_cancel ( struct GNUNET_MQ_Envelope ev)

Cancel sending the message.

Message must have been sent with GNUNET_MQ_send before. May not be called after the notify sent callback has been called

Parameters
evqueued envelope to cancel

Definition at line 913 of file mq.c.

References GNUNET_MQ_Handle::cancel_impl, GNUNET_MQ_Handle::current_envelope, GNUNET_MQ_Handle::envelope_head, GNUNET_MQ_Handle::envelope_tail, GNUNET_MQ_Handle::evacuate_called, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_YES, GNUNET_MQ_Handle::impl_state, GNUNET_MQ_Handle::in_flight, LOG, GNUNET_MQ_Envelope::mh, mq, GNUNET_MQ_Envelope::parent_queue, GNUNET_MQ_Handle::queue_length, GNUNET_MQ_Handle::send_impl, and GNUNET_MessageHeader::type.

Referenced by GSF_push_stop_(), handle_client_audio_message(), mq_cancel_impl(), neighbour_delete(), and shutdown_task().

914 {
915  struct GNUNET_MQ_Handle *mq = ev->parent_queue;
916 
917  GNUNET_assert(NULL != mq);
918  GNUNET_assert(NULL != mq->cancel_impl);
919 
921 
922  if (mq->current_envelope == ev)
923  {
924  /* complex case, we already started with transmitting
925  the message using the callbacks. */
927  GNUNET_assert(0 < mq->queue_length);
928  mq->queue_length--;
929  mq->cancel_impl(mq, mq->impl_state);
930  /* continue sending the next message, if any */
932  if (NULL != mq->current_envelope)
933  {
935  mq->envelope_tail,
936  mq->current_envelope);
937 
939  "sending canceled message of type %u queue\n",
940  ntohs(ev->mh->type));
941 
942  mq->send_impl(mq, mq->current_envelope->mh, mq->impl_state);
943  }
944  }
945  else
946  {
947  /* simple case, message is still waiting in the queue */
949  GNUNET_assert(0 < mq->queue_length);
950  mq->queue_length--;
951  }
952 
953  if (GNUNET_YES != mq->evacuate_called)
954  {
955  ev->parent_queue = NULL;
956  ev->mh = NULL;
957  /* also frees ev */
958  GNUNET_free(ev);
959  }
960 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
void * impl_state
Implementation-specific state.
Definition: mq.c:109
unsigned int queue_length
Number of entries we have in the envelope-DLL.
Definition: mq.c:174
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int evacuate_called
GNUNET_YES if GNUNET_MQ_impl_evacuate was called.
Definition: mq.c:180
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_MQ_Envelope * envelope_tail
Linked list of messages pending to be sent.
Definition: mq.c:134
GNUNET_MQ_SendImpl send_impl
Actual implementation of message sending, called when a message is added.
Definition: mq.c:94
int in_flight
GNUNET_YES if GNUNET_MQ_impl_send_in_flight() was called.
Definition: mq.c:185
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
GNUNET_MQ_CancelImpl cancel_impl
Implementation-dependent send cancel function.
Definition: mq.c:104
#define LOG(kind,...)
Definition: mq.c:29
Handle to a message queue.
Definition: mq.c:84
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_MQ_Envelope * envelope_head
Linked list of messages pending to be sent.
Definition: mq.c:129
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_MQ_assoc_add()

uint32_t GNUNET_MQ_assoc_add ( struct GNUNET_MQ_Handle mq,
void *  assoc_data 
)

Associate the assoc_data in mq with a unique request id.

Parameters
mqmessage queue, id will be unique for the queue
assoc_datato associate

Associate the assoc_data in mq with a unique request id.

Parameters
mqmessage queue, id will be unique for the queue
assoc_datato associate

Definition at line 706 of file mq.c.

References GNUNET_MQ_Handle::assoc_id, GNUNET_MQ_Handle::assoc_map, GNUNET_assert, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_OK, and id.

Referenced by GNUNET_SET_commit().

707 {
708  uint32_t id;
709 
710  if (NULL == mq->assoc_map)
711  {
713  mq->assoc_id = 1;
714  }
715  id = mq->assoc_id++;
718  mq->assoc_map,
719  id,
720  assoc_data,
722  return id;
723 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
uint32_t assoc_id
Next id that should be used for the assoc_map, initialized lazily to a random value together with ass...
Definition: mq.c:169
struct GNUNET_CONTAINER_MultiHashMap32 * assoc_map
Map of associations, lazily allocated.
Definition: mq.c:146
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_assoc_get()

void* GNUNET_MQ_assoc_get ( struct GNUNET_MQ_Handle mq,
uint32_t  request_id 
)

Get the data associated with a request_id in a queue.

Parameters
mqthe message queue with the association
request_idthe request id we are interested in
Returns
the associated data

Definition at line 734 of file mq.c.

References GNUNET_MQ_Handle::assoc_map, and GNUNET_CONTAINER_multihashmap32_get().

Referenced by handle_result().

735 {
736  if (NULL == mq->assoc_map)
737  return NULL;
738  return GNUNET_CONTAINER_multihashmap32_get(mq->assoc_map, request_id);
739 }
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap32 * assoc_map
Map of associations, lazily allocated.
Definition: mq.c:146
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_assoc_remove()

void* GNUNET_MQ_assoc_remove ( struct GNUNET_MQ_Handle mq,
uint32_t  request_id 
)

Remove the association for a request_id.

Parameters
mqthe message queue with the association
request_idthe request id we want to remove
Returns
the associated data

Definition at line 750 of file mq.c.

References GNUNET_MQ_Handle::assoc_map, GNUNET_CONTAINER_multihashmap32_get(), and GNUNET_CONTAINER_multihashmap32_remove_all().

Referenced by handle_result(), and set_operation_destroy().

751 {
752  void *val;
753 
754  if (NULL == mq->assoc_map)
755  return NULL;
756  val = GNUNET_CONTAINER_multihashmap32_get(mq->assoc_map, request_id);
758  return val;
759 }
int GNUNET_CONTAINER_multihashmap32_remove_all(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Remove all entries for the given key from the map.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap32 * assoc_map
Map of associations, lazily allocated.
Definition: mq.c:146
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_queue_for_callbacks()

struct GNUNET_MQ_Handle* GNUNET_MQ_queue_for_callbacks ( GNUNET_MQ_SendImpl  send,
GNUNET_MQ_DestroyImpl  destroy,
GNUNET_MQ_CancelImpl  cancel,
void *  impl_state,
const struct GNUNET_MQ_MessageHandler handlers,
GNUNET_MQ_ErrorHandler  error_handler,
void *  error_handler_cls 
)

Create a message queue for the specified handlers.

Parameters
sendfunction the implements sending messages
destroyfunction that implements destroying the queue
cancelfunction that implements canceling a message
impl_statefor the queue, passed to send, destroy and cancel
handlersarray of message handlers
error_handlerhandler for read and write errors
clsclosure for message handlers and error handler
Returns
a new message queue
Parameters
sendfunction the implements sending messages
destroyfunction that implements destroying the queue
cancelfunction that implements canceling a message
impl_statefor the queue, passed to 'send' and 'destroy'
handlersarray of message handlers
error_handlerhandler for read and write errors
error_handler_clsclosure for error_handler
Returns
a new message queue

Definition at line 550 of file mq.c.

References GNUNET_MQ_Handle::cancel_impl, destroy(), GNUNET_MQ_Handle::destroy_impl, GNUNET_MQ_Handle::error_handler, error_handler(), GNUNET_MQ_Handle::error_handler_cls, GNUNET_MQ_copy_handlers(), GNUNET_new, GNUNET_MQ_Handle::handlers, GNUNET_MQ_Handle::impl_state, mq, and GNUNET_MQ_Handle::send_impl.

Referenced by boot_queue(), connect_peer(), GCT_create_tunnel(), GNUNET_CADET_channel_create(), GNUNET_CLIENT_connect(), handle_channel_created(), handle_connect(), setup_queue(), setup_receiver_mq(), and start_client().

557 {
558  struct GNUNET_MQ_Handle *mq;
559 
560  mq = GNUNET_new(struct GNUNET_MQ_Handle);
561  mq->send_impl = send;
562  mq->destroy_impl = destroy;
563  mq->cancel_impl = cancel;
564  mq->handlers = GNUNET_MQ_copy_handlers(handlers);
567  mq->impl_state = impl_state;
568 
569  return mq;
570 }
struct GNUNET_MQ_MessageHandler * handlers
Handlers array, or NULL if the queue should not receive messages.
Definition: mq.c:88
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error handling the MQ to the ATS service.
void * impl_state
Implementation-specific state.
Definition: mq.c:109
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
Definition: mq.c:1211
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_MQ_SendImpl send_impl
Actual implementation of message sending, called when a message is added.
Definition: mq.c:94
GNUNET_MQ_ErrorHandler error_handler
Callback will be called when an error occurs.
Definition: mq.c:114
GNUNET_MQ_DestroyImpl destroy_impl
Implementation-dependent queue destruction function.
Definition: mq.c:99
GNUNET_MQ_CancelImpl cancel_impl
Implementation-dependent send cancel function.
Definition: mq.c:104
void * error_handler_cls
Closure for the error handler.
Definition: mq.c:119
Handle to a message queue.
Definition: mq.c:84
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static void destroy(void *cls)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_set_handlers_closure()

void GNUNET_MQ_set_handlers_closure ( struct GNUNET_MQ_Handle mq,
void *  handlers_cls 
)

Change the closure argument in all of the handlers of the mq.

Parameters
mqto modify
handlers_clsnew closure to use

Definition at line 581 of file mq.c.

References GNUNET_MQ_MessageHandler::cb, GNUNET_MQ_MessageHandler::cls, and GNUNET_MQ_Handle::handlers.

Referenced by connect_peer(), GNUNET_CADET_channel_create(), handle_channel_created(), handle_connect(), and start_client().

582 {
583  if (NULL == mq->handlers)
584  return;
585  for (unsigned int i = 0; NULL != mq->handlers[i].cb; i++)
586  mq->handlers[i].cls = handlers_cls;
587 }
struct GNUNET_MQ_MessageHandler * handlers
Handlers array, or NULL if the queue should not receive messages.
Definition: mq.c:88
void * cls
Closure for mv and cb.
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
Here is the caller graph for this function:

◆ GNUNET_MQ_notify_sent()

void GNUNET_MQ_notify_sent ( struct GNUNET_MQ_Envelope ev,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.

There can be only one notify sent callback per envelope.

Parameters
evmessage to call the notify callback for
cbthe notify callback
cb_clsclosure for the callback

Definition at line 772 of file mq.c.

References GNUNET_assert, GNUNET_MQ_Envelope::sent_cb, and GNUNET_MQ_Envelope::sent_cls.

Referenced by check_peer_online(), comm_schedule_send(), dispatch_buffer(), do_send(), GCP_request_mq_cancel(), GCP_send(), GCP_send_ooo(), GNUNET_ATS_TEST_traffic_handle_ping(), GNUNET_CONSENSUS_insert(), GNUNET_DATASTORE_disconnect(), GNUNET_DHT_put(), GNUNET_DHT_put_cancel(), GNUNET_PEERINFO_add_peer(), GNUNET_PEERSTORE_store(), GNUNET_SET_add_element(), GNUNET_SET_remove_element(), GNUNET_TRANSPORT_offer_hello(), GNUNET_TRANSPORT_TESTING_send(), handle_client_audio_message(), handle_client_hangup_message(), handle_datastore_reply(), handle_raw_message(), handle_send_msg(), mq_send_impl(), read_stdio(), reconnect(), schedule_action(), schedule_peer_transmission(), send_message(), send_msg(), send_p2p_done(), send_remaining_elements(), transmit_bobs_cryptodata_message(), transmit_bobs_cryptodata_message_multipart(), transmit_content(), transmit_get(), transmit_pending(), transmit_set(), and transmit_watch().

775 {
776  /* allow setting *OR* clearing callback */
777  GNUNET_assert((NULL == ev->sent_cb) || (NULL == cb));
778  ev->sent_cb = cb;
779  ev->sent_cls = cb_cls;
780 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
GNUNET_SCHEDULER_TaskCallback sent_cb
Called after the message was sent irrevocably.
Definition: mq.c:60
void * sent_cls
Closure for send_cb.
Definition: mq.c:65
Here is the caller graph for this function:

◆ GNUNET_MQ_destroy()

void GNUNET_MQ_destroy ( struct GNUNET_MQ_Handle mq)

Destroy the message queue.

Parameters
mqmessage queue to destroy

Definition at line 821 of file mq.c.

References GNUNET_MQ_Handle::assoc_map, GNUNET_MQ_DestroyNotificationHandle::cb, GNUNET_MQ_DestroyNotificationHandle::cb_cls, GNUNET_MQ_Handle::current_envelope, GNUNET_MQ_Handle::destroy_impl, GNUNET_MQ_Handle::dnh_head, GNUNET_MQ_Handle::envelope_head, GNUNET_MQ_Handle::envelope_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_MQ_destroy_notify_cancel(), GNUNET_MQ_discard(), GNUNET_SCHEDULER_cancel(), GNUNET_MQ_Handle::handlers, GNUNET_MQ_Handle::impl_state, LOG, GNUNET_MQ_Envelope::mh, GNUNET_MQ_Envelope::parent_queue, GNUNET_MQ_Handle::queue_length, GNUNET_MQ_Handle::send_task, and GNUNET_MessageHeader::type.

Referenced by announce_mq_error_handler(), create_loc_uri(), deactivate_fs_download(), destroy_channel(), destroy_tunnel(), disconnect(), disconnect_and_free_peer_entry(), disconnect_and_schedule_reconnect(), do_disconnect(), do_reconnect(), download_mq_error_handler(), error_handler(), fail_call(), final_disconnect(), finish_client_drop(), force_reconnect(), GNUNET_ARM_disconnect(), GNUNET_ARM_monitor_stop(), GNUNET_ATS_application_done(), GNUNET_ATS_connectivity_done(), GNUNET_ATS_performance_done(), GNUNET_ATS_scheduling_done(), GNUNET_ATS_transport_done(), GNUNET_CADET_disconnect(), GNUNET_CADET_get_channel_cancel(), GNUNET_CADET_get_path_cancel(), GNUNET_CADET_list_peers_cancel(), GNUNET_CADET_list_tunnels_cancel(), GNUNET_CONSENSUS_destroy(), GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_phone_destroy(), GNUNET_CORE_disconnect(), GNUNET_CORE_monitor_stop(), GNUNET_CREDENTIAL_disconnect(), GNUNET_DATASTORE_disconnect(), GNUNET_DHT_disconnect(), GNUNET_DNS_disconnect(), GNUNET_FS_get_indexed_files_cancel(), GNUNET_FS_search_pause(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), GNUNET_FS_unindex_signal_suspend_(), GNUNET_FS_unindex_stop(), GNUNET_GNS_disconnect(), GNUNET_IDENTITY_disconnect(), GNUNET_IDENTITY_ego_lookup_by_suffix_cancel(), GNUNET_IDENTITY_ego_lookup_cancel(), GNUNET_NAMECACHE_disconnect(), GNUNET_NAMESTORE_disconnect(), GNUNET_NAMESTORE_zone_monitor_stop(), GNUNET_NAT_AUTO_autoconfig_cancel(), GNUNET_NAT_AUTO_test_stop(), GNUNET_NAT_autoconfig_cancel(), GNUNET_NAT_test_stop(), GNUNET_NAT_unregister(), GNUNET_NSE_disconnect(), GNUNET_PEERINFO_disconnect(), GNUNET_PEERINFO_notify_cancel(), GNUNET_RECLAIM_disconnect(), GNUNET_REGEX_announce_cancel(), GNUNET_REGEX_search_cancel(), GNUNET_RESOLVER_disconnect(), GNUNET_REVOCATION_query_cancel(), GNUNET_REVOCATION_revoke_cancel(), GNUNET_RPS_disconnect(), GNUNET_SCALARPRODUCT_cancel(), GNUNET_SECRETSHARING_decrypt_cancel(), GNUNET_SECRETSHARING_session_destroy(), GNUNET_SET_destroy(), GNUNET_SET_listen_cancel(), GNUNET_TESTBED_barrier_wait_cancel(), GNUNET_TESTBED_controller_disconnect(), GNUNET_TESTBED_LOGGER_disconnect(), GNUNET_TRANSPORT_address_to_string_cancel(), GNUNET_TRANSPORT_application_done(), GNUNET_TRANSPORT_blacklist_cancel(), GNUNET_TRANSPORT_communicator_mq_del(), GNUNET_TRANSPORT_hello_get_cancel(), GNUNET_TRANSPORT_monitor_peers_cancel(), GNUNET_TRANSPORT_monitor_plugins_cancel(), GNUNET_TRANSPORT_offer_hello_cancel(), GNUNET_VPN_disconnect(), handle_client_listener_error(), handle_conclude_done(), handle_index_start_failed(), handle_index_start_ok(), handle_mq_error(), handle_response(), handle_unindex_response(), index_mq_error_handler(), loc_mq_error_handler(), mq_error_handler(), neighbour_delete(), process_result_with_request(), publish_cleanup(), queue_destroy(), receiver_destroy(), reconnect(), reconnect_arm_later(), reconnect_arm_monitor_later(), reconnect_later(), reconnect_peer_ctx(), reconnect_phone(), reconnect_plugin_ctx(), reschedule_connect(), search_mq_error_handler(), try_reconnect(), and unindex_mq_error_handler().

822 {
824 
825  if (NULL != mq->destroy_impl)
826  {
827  mq->destroy_impl(mq, mq->impl_state);
828  }
829  if (NULL != mq->send_task)
830  {
832  mq->send_task = NULL;
833  }
834  while (NULL != mq->envelope_head)
835  {
836  struct GNUNET_MQ_Envelope *ev;
837 
838  ev = mq->envelope_head;
839  ev->parent_queue = NULL;
841  GNUNET_assert(0 < mq->queue_length);
842  mq->queue_length--;
844  "MQ destroy drops message of type %u\n",
845  ntohs(ev->mh->type));
846  GNUNET_MQ_discard(ev);
847  }
848  if (NULL != mq->current_envelope)
849  {
850  /* we can only discard envelopes that
851  * are not queued! */
852  mq->current_envelope->parent_queue = NULL;
854  "MQ destroy drops current message of type %u\n",
855  ntohs(mq->current_envelope->mh->type));
857  mq->current_envelope = NULL;
858  GNUNET_assert(0 < mq->queue_length);
859  mq->queue_length--;
860  }
861  GNUNET_assert(0 == mq->queue_length);
862  while (NULL != (dnh = mq->dnh_head))
863  {
864  dnh->cb(dnh->cb_cls);
866  }
867  if (NULL != mq->assoc_map)
868  {
870  mq->assoc_map = NULL;
871  }
873  GNUNET_free(mq);
874 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MQ_MessageHandler * handlers
Handlers array, or NULL if the queue should not receive messages.
Definition: mq.c:88
Handle we return for callbacks registered to be notified when GNUNET_MQ_destroy() is called on a queu...
Definition: mq.c:787
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
void * impl_state
Implementation-specific state.
Definition: mq.c:109
unsigned int queue_length
Number of entries we have in the envelope-DLL.
Definition: mq.c:174
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_MQ_Envelope * envelope_tail
Linked list of messages pending to be sent.
Definition: mq.c:134
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
GNUNET_SCHEDULER_TaskCallback cb
Function to call.
Definition: mq.c:806
GNUNET_MQ_DestroyImpl destroy_impl
Implementation-dependent queue destruction function.
Definition: mq.c:99
struct GNUNET_SCHEDULER_Task * send_task
Task to asynchronously run impl_send_continue().
Definition: mq.c:124
struct GNUNET_MQ_DestroyNotificationHandle * dnh_head
Functions to call on queue destruction; kept in a DLL.
Definition: mq.c:151
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *ev)
Discard the message queue message, free all allocated resources.
Definition: mq.c:319
#define LOG(kind,...)
Definition: mq.c:29
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
struct GNUNET_CONTAINER_MultiHashMap32 * assoc_map
Map of associations, lazily allocated.
Definition: mq.c:146
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141
void GNUNET_MQ_destroy_notify_cancel(struct GNUNET_MQ_DestroyNotificationHandle *dnh)
Cancel registration from GNUNET_MQ_destroy_notify().
Definition: mq.c:1127
struct GNUNET_MQ_Envelope * envelope_head
Linked list of messages pending to be sent.
Definition: mq.c:129
void * cb_cls
Closure for cb.
Definition: mq.c:811
#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:956
Here is the call graph for this function:

◆ GNUNET_MQ_destroy_notify()

struct GNUNET_MQ_DestroyNotificationHandle* GNUNET_MQ_destroy_notify ( struct GNUNET_MQ_Handle mq,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Register function to be called whenever mq is being destroyed.

Parameters
mqmessage queue to watch
cbfunction to call on mq destruction
cb_clsclosure for cb
Returns
handle for GNUNET_MQ_destroy_notify_cancel().

Definition at line 1106 of file mq.c.

References GNUNET_MQ_DestroyNotificationHandle::cb, GNUNET_MQ_DestroyNotificationHandle::cb_cls, GNUNET_MQ_Handle::dnh_head, GNUNET_MQ_Handle::dnh_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_new, mq, and GNUNET_MQ_DestroyNotificationHandle::mq.

Referenced by GNUNET_notification_context_add().

1109 {
1111 
1113  dnh->mq = mq;
1114  dnh->cb = cb;
1115  dnh->cb_cls = cb_cls;
1117  return dnh;
1118 }
Handle we return for callbacks registered to be notified when GNUNET_MQ_destroy() is called on a queu...
Definition: mq.c:787
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_MQ_DestroyNotificationHandle * dnh_tail
Functions to call on queue destruction; kept in a DLL.
Definition: mq.c:156
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_SCHEDULER_TaskCallback cb
Function to call.
Definition: mq.c:806
struct GNUNET_MQ_DestroyNotificationHandle * dnh_head
Functions to call on queue destruction; kept in a DLL.
Definition: mq.c:151
struct GNUNET_MQ_Handle * mq
Queue to notify about.
Definition: mq.c:801
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
void * cb_cls
Closure for cb.
Definition: mq.c:811
Here is the caller graph for this function:

◆ GNUNET_MQ_destroy_notify_cancel()

void GNUNET_MQ_destroy_notify_cancel ( struct GNUNET_MQ_DestroyNotificationHandle dnh)

Cancel registration from GNUNET_MQ_destroy_notify().

Parameters
dnhhandle for registration to cancel

Definition at line 1127 of file mq.c.

References GNUNET_MQ_Handle::dnh_head, GNUNET_MQ_Handle::dnh_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, mq, and GNUNET_MQ_DestroyNotificationHandle::mq.

Referenced by GNUNET_MQ_destroy(), and GNUNET_notification_context_destroy().

1129 {
1130  struct GNUNET_MQ_Handle *mq = dnh->mq;
1131 
1133  GNUNET_free(dnh);
1134 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MQ_DestroyNotificationHandle * dnh_tail
Functions to call on queue destruction; kept in a DLL.
Definition: mq.c:156
struct GNUNET_MQ_DestroyNotificationHandle * dnh_head
Functions to call on queue destruction; kept in a DLL.
Definition: mq.c:151
struct GNUNET_MQ_Handle * mq
Queue to notify about.
Definition: mq.c:801
Handle to a message queue.
Definition: mq.c:84
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_MQ_inject_message()

void GNUNET_MQ_inject_message ( struct GNUNET_MQ_Handle mq,
const struct GNUNET_MessageHeader mh 
)

Call the message message handler that was registered for the type of the given message in the given message queue.

This function is indended to be used for the implementation of message queues.

Parameters
mqmessage queue with the handlers
mhmessage to dispatch

Definition at line 200 of file mq.c.

References GNUNET_MQ_ERROR_MALFORMED, GNUNET_MQ_handle_message(), GNUNET_MQ_inject_error(), GNUNET_SYSERR, GNUNET_MQ_Handle::handlers, and ret.

Referenced by handle_decrypted(), handle_local_data(), handle_notify_inbound(), handle_recv(), recv_message(), and service_client_mst_cb().

202 {
203  int ret;
204 
205  ret = GNUNET_MQ_handle_message(mq->handlers, mh);
206  if (GNUNET_SYSERR == ret)
207  {
209  return;
210  }
211 }
struct GNUNET_MQ_MessageHandler * handlers
Handlers array, or NULL if the queue should not receive messages.
Definition: mq.c:88
void GNUNET_MQ_inject_error(struct GNUNET_MQ_Handle *mq, enum GNUNET_MQ_Error error)
Call the error handler of a message queue with the given error code.
Definition: mq.c:298
int GNUNET_MQ_handle_message(const struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_MessageHeader *mh)
Call the message message handler that was registered for the type of the given message in the given h...
Definition: mq.c:227
static int ret
Final status code.
Definition: gnunet-arm.c:89
We received a message that was malformed and thus could not be passed to its handler.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_inject_error()

void GNUNET_MQ_inject_error ( struct GNUNET_MQ_Handle mq,
enum GNUNET_MQ_Error  error 
)

Call the error handler of a message queue with the given error code.

If there is no error handler, log a warning.

This function is intended to be used for the implementation of message queues.

Parameters
mqmessage queue
errorthe error type

If there is no error handler, log a warning.

This function is intended to be used by the implementation of message queues.

Parameters
mqmessage queue
errorthe error type

Definition at line 298 of file mq.c.

References GNUNET_MQ_Handle::error_handler, GNUNET_MQ_Handle::error_handler_cls, GNUNET_ERROR_TYPE_WARNING, and LOG.

Referenced by do_send(), GNUNET_MQ_inject_message(), receive_ready(), and transmit_ready().

299 {
300  if (NULL == mq->error_handler)
301  {
303  "Got error %d, but no handler installed\n",
304  (int)error);
305  return;
306  }
307  mq->error_handler(mq->error_handler_cls, error);
308 }
GNUNET_MQ_ErrorHandler error_handler
Callback will be called when an error occurs.
Definition: mq.c:114
#define LOG(kind,...)
Definition: mq.c:29
void * error_handler_cls
Closure for the error handler.
Definition: mq.c:119
Here is the caller graph for this function:

◆ GNUNET_MQ_impl_send_continue()

void GNUNET_MQ_impl_send_continue ( struct GNUNET_MQ_Handle mq)

Call the send implementation for the next queued message, if any.

Calls the send notification for the current message unless GNUNET_MQ_impl_send_in_flight was called for this envelope.

Only useful for implementing message queues, results in undefined behavior if not used carefully.

Parameters
mqmessage queue to send the next message with

Only useful for implementing message queues, results in undefined behavior if not used carefully.

Parameters
mqmessage queue to send the next message with

Definition at line 484 of file mq.c.

References GNUNET_MQ_Handle::current_envelope, GNUNET_assert, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_add_now(), impl_send_continue(), GNUNET_MQ_Handle::in_flight, GNUNET_MQ_Envelope::parent_queue, GNUNET_MQ_Handle::queue_length, GNUNET_MQ_Handle::send_task, GNUNET_MQ_Envelope::sent_cb, and GNUNET_MQ_Envelope::sent_cls.

Referenced by cadet_mq_send_impl(), cadet_mq_send_now(), core_mq_send_impl(), do_send(), handle_send_ready(), mq_send(), mq_send_impl(), notify_send_done(), notify_send_done_fin(), queue_write(), select_write_cb(), and transmit_ready().

485 {
486  struct GNUNET_MQ_Envelope *current_envelope;
488 
489  GNUNET_assert(0 < mq->queue_length);
490  mq->queue_length--;
491  mq->in_flight = GNUNET_NO;
492  current_envelope = mq->current_envelope;
493  current_envelope->parent_queue = NULL;
494  mq->current_envelope = NULL;
495  GNUNET_assert(NULL == mq->send_task);
497  if (NULL != (cb = current_envelope->sent_cb))
498  {
499  current_envelope->sent_cb = NULL;
500  cb(current_envelope->sent_cls);
501  }
502  GNUNET_free(current_envelope);
503 }
unsigned int queue_length
Number of entries we have in the envelope-DLL.
Definition: mq.c:174
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
int in_flight
GNUNET_YES if GNUNET_MQ_impl_send_in_flight() was called.
Definition: mq.c:185
GNUNET_SCHEDULER_TaskCallback sent_cb
Called after the message was sent irrevocably.
Definition: mq.c:60
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:1264
struct GNUNET_SCHEDULER_Task * send_task
Task to asynchronously run impl_send_continue().
Definition: mq.c:124
void * sent_cls
Closure for send_cb.
Definition: mq.c:65
static void impl_send_continue(void *cls)
Task run to call the send implementation for the next queued message, if any.
Definition: mq.c:454
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MQ_impl_send_in_flight()

void GNUNET_MQ_impl_send_in_flight ( struct GNUNET_MQ_Handle mq)

Call the send notification for the current message, but do not try to send the next message until #gnunet_mq_impl_send_continue is called.

Only useful for implementing message queues, results in undefined behavior if not used carefully.

Parameters
mqmessage queue to send the next message with

Call the send notification for the current message, but do not try to send the next message until #gnunet_mq_impl_send_continue is called.

Only useful for implementing message queues, results in undefined behavior if not used carefully.

Parameters
mqmessage queue to send the next message with

Definition at line 517 of file mq.c.

References GNUNET_MQ_Handle::current_envelope, GNUNET_assert, GNUNET_YES, GNUNET_MQ_Handle::in_flight, GNUNET_MQ_Envelope::parent_queue, GNUNET_MQ_Envelope::sent_cb, and GNUNET_MQ_Envelope::sent_cls.

Referenced by do_send(), notify_send_done(), and transmit_ready().

518 {
519  struct GNUNET_MQ_Envelope *current_envelope;
521 
522  mq->in_flight = GNUNET_YES;
523  /* call is only valid if we're actually currently sending
524  * a message */
525  current_envelope = mq->current_envelope;
526  GNUNET_assert(NULL != current_envelope);
527  /* can't call cancel from now on anymore */
528  current_envelope->parent_queue = NULL;
529  if (NULL != (cb = current_envelope->sent_cb))
530  {
531  current_envelope->sent_cb = NULL;
532  cb(current_envelope->sent_cls);
533  }
534 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
int in_flight
GNUNET_YES if GNUNET_MQ_impl_send_in_flight() was called.
Definition: mq.c:185
GNUNET_SCHEDULER_TaskCallback sent_cb
Called after the message was sent irrevocably.
Definition: mq.c:60
void * sent_cls
Closure for send_cb.
Definition: mq.c:65
struct GNUNET_MQ_Handle * parent_queue
Queue the message is queued in, NULL if message is not queued.
Definition: mq.c:55
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ GNUNET_MQ_impl_state()

void* GNUNET_MQ_impl_state ( struct GNUNET_MQ_Handle mq)

Get the implementation state associated with the message queue.

While the GNUNET_MQ_Impl* callbacks receive the implementation state, continuations that are scheduled by the implementation function often only have one closure argument, with this function it is possible to get at the implementation state when only passing the struct GNUNET_MQ_Handle as closure.

Parameters
mqmessage queue with the current message
Returns
message to send, never NULL

While the GNUNET_MQ_Impl* callbacks receive the implementation state, continuations that are scheduled by the implementation function often only have one closure argument, with this function it is possible to get at the implementation state when only passing the GNUNET_MQ_Handle as closure.

Parameters
mqmessage queue with the current message
Returns
message to send, never NULL

Definition at line 623 of file mq.c.

References GNUNET_MQ_Handle::impl_state.

624 {
625  return mq->impl_state;
626 }
void * impl_state
Implementation-specific state.
Definition: mq.c:109

◆ GNUNET_MQ_impl_current()

const struct GNUNET_MessageHeader* GNUNET_MQ_impl_current ( struct GNUNET_MQ_Handle mq)

Get the message that should currently be sent.

Fails if there is no current message. Only useful for implementing message queues, results in undefined behavior if not used carefully.

Parameters
mqmessage queue with the current message
Returns
message to send, never NULL

Definition at line 600 of file mq.c.

References GNUNET_MQ_Handle::current_envelope, GNUNET_assert, and GNUNET_MQ_Envelope::mh.

601 {
602  GNUNET_assert(NULL != mq->current_envelope);
603  GNUNET_assert(NULL != mq->current_envelope->mh);
604  return mq->current_envelope->mh;
605 }
struct GNUNET_MessageHeader * mh
Actual allocated message header.
Definition: mq.c:50
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Envelope * current_envelope
Message that is currently scheduled to be sent.
Definition: mq.c:141

◆ GNUNET_MQ_preference_to_string()

const char* GNUNET_MQ_preference_to_string ( enum GNUNET_MQ_PreferenceKind  type)

Convert an enum GNUNET_MQ_PreferenceType to a string.

Parameters
typethe preference type
Returns
a string or NULL if invalid
Deprecated:
will be replaced by enum GNUNET_MQ_PriorityPreference
Parameters
typethe preference type
Returns
a string or NULL if invalid

Definition at line 1292 of file mq.c.

References GNUNET_MQ_PREFERENCE_BANDWIDTH, GNUNET_MQ_PREFERENCE_LATENCY, GNUNET_MQ_PREFERENCE_NONE, and GNUNET_MQ_PREFERENCE_RELIABILITY.

1293 {
1294  switch (type)
1295  {
1297  return "NONE";
1298 
1300  return "BANDWIDTH";
1301 
1303  return "LATENCY";
1304 
1306  return "RELIABILITY";
1307  }
1308  ;
1309  return NULL;
1310 }
No preference was expressed.
The preferred transmission for this envelope focuses on maximizing bandwidth.
The preferred transmission for this envelope foces on minimizing latency.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
The preferred transmission for this envelope foces on reliability.

◆ GNUNET_notification_context_create()

struct GNUNET_NotificationContext* GNUNET_notification_context_create ( unsigned int  queue_length)

Create a new notification context.

Parameters
queue_lengthmaximum number of messages to keep in the notification queue; optional messages are dropped if the queue gets longer than this number of messages
Returns
handle to the notification context

Definition at line 119 of file nc.c.

References GNUNET_new, SubscriberList::nc, and GNUNET_NotificationContext::queue_length.

Referenced by GAS_performance_init(), GSC_KX_init(), and run().

120 {
122 
125  return nc;
126 }
The notification context is the key datastructure for a convenience API used for transmission of noti...
Definition: nc.c:74
unsigned int queue_length
Maximum number of optional messages to queue per subscriber.
Definition: nc.c:88
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
Here is the caller graph for this function:

◆ GNUNET_notification_context_destroy()

void GNUNET_notification_context_destroy ( struct GNUNET_NotificationContext nc)

Destroy the context, force disconnect for all subscribers.

Parameters
nccontext to destroy.

Definition at line 135 of file nc.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy_notify_cancel(), SubscriberList::mq_nh, GNUNET_NotificationContext::subscribers_head, and GNUNET_NotificationContext::subscribers_tail.

Referenced by cleanup_task(), do_shutdown(), GAS_performance_done(), GSC_KX_done(), and shutdown_task().

136 {
137  struct SubscriberList *pos;
138 
139  while (NULL != (pos = nc->subscribers_head))
140  {
142  nc->subscribers_tail,
143  pos);
145  GNUNET_free(pos);
146  }
147  GNUNET_free(nc);
148 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct SubscriberList * subscribers_tail
Tail of list of subscribers receiving notifications.
Definition: nc.c:83
Lists of subscribers we manage for notifications.
Definition: nc.c:37
struct SubscriberList * subscribers_head
Head of list of subscribers receiving notifications.
Definition: nc.c:78
void GNUNET_MQ_destroy_notify_cancel(struct GNUNET_MQ_DestroyNotificationHandle *dnh)
Cancel registration from GNUNET_MQ_destroy_notify().
Definition: mq.c:1127
struct GNUNET_MQ_DestroyNotificationHandle * mq_nh
Handle where we registered with mq to be told about the MQ&#39;s destruction.
Definition: nc.c:57
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_notification_context_add()

void GNUNET_notification_context_add ( struct GNUNET_NotificationContext nc,
struct GNUNET_MQ_Handle mq 
)

Add a subscriber to the notification context.

Parameters
nccontext to modify
mqmessage queue add

Definition at line 158 of file nc.c.

References GNUNET_CONTAINER_DLL_insert, GNUNET_MQ_destroy_notify(), GNUNET_new, handle_mq_destroy(), SubscriberList::mq, SubscriberList::mq_nh, SubscriberList::nc, SubscriberList::next, GNUNET_NotificationContext::subscribers_head, and GNUNET_NotificationContext::subscribers_tail.

Referenced by client_connect_cb(), GAS_performance_add_client(), GSC_KX_handle_client_monitor_peers(), handle_client_monitor_plugins(), handle_monitor(), handle_monitor_start(), handle_notify(), handle_start(), and handle_start_message().

160 {
161  struct SubscriberList *cl;
162 
163  for (cl = nc->subscribers_head; NULL != cl; cl = cl->next)
164  if (cl->mq == mq)
165  return;
166  /* already present */
167  cl = GNUNET_new(struct SubscriberList);
169  nc->subscribers_tail,
170  cl);
171  cl->nc = nc;
172  cl->mq = mq;
175  cl);
176 }
struct GNUNET_MQ_DestroyNotificationHandle * GNUNET_MQ_destroy_notify(struct GNUNET_MQ_Handle *mq, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Register function to be called whenever mq is being destroyed.
Definition: mq.c:1106
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_NotificationContext * nc
Overall context this subscriber belongs to.
Definition: nc.c:51
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct SubscriberList * next
This is a doubly linked list.
Definition: nc.c:41
static void handle_mq_destroy(void *cls)
Subscriber has disconnected, clean up.
Definition: nc.c:98
struct SubscriberList * subscribers_tail
Tail of list of subscribers receiving notifications.
Definition: nc.c:83
Lists of subscribers we manage for notifications.
Definition: nc.c:37
struct SubscriberList * subscribers_head
Head of list of subscribers receiving notifications.
Definition: nc.c:78
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Handle * mq
Message queue for the subscriber.
Definition: nc.c:62
struct GNUNET_MQ_DestroyNotificationHandle * mq_nh
Handle where we registered with mq to be told about the MQ&#39;s destruction.
Definition: nc.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_notification_context_broadcast()

void GNUNET_notification_context_broadcast ( struct GNUNET_NotificationContext nc,
const struct GNUNET_MessageHeader msg,
int  can_drop 
)

Send a message to all subscribers of this context.

Parameters
nccontext to modify
msgmessage to send
can_dropcan this message be dropped due to queue length limitations

Definition at line 187 of file nc.c.

References env, GNUNET_MQ_get_length(), GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_YES, SubscriberList::mq, SubscriberList::next, GNUNET_NotificationContext::queue_length, and GNUNET_NotificationContext::subscribers_head.

Referenced by broadcast_status(), monitor_notify_all(), notify_all(), notify_client(), notify_listeners(), plugin_session_info_cb(), and update_network_size_estimate().

190 {
191  struct SubscriberList *pos;
192  struct GNUNET_MQ_Envelope *env;
193 
194  for (pos = nc->subscribers_head; NULL != pos; pos = pos->next)
195  {
196  if ((GNUNET_YES == can_drop) &&
197  (GNUNET_MQ_get_length(pos->mq) > nc->queue_length))
198  continue;
199  env = GNUNET_MQ_msg_copy(msg);
200  GNUNET_MQ_send(pos->mq,
201  env);
202  }
203 }
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:651
unsigned int queue_length
Maximum number of optional messages to queue per subscriber.
Definition: nc.c:88
struct SubscriberList * next
This is a doubly linked list.
Definition: nc.c:41
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:333
Lists of subscribers we manage for notifications.
Definition: nc.c:37
struct SubscriberList * subscribers_head
Head of list of subscribers receiving notifications.
Definition: nc.c:78
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Message queue for the subscriber.
Definition: nc.c:62
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_notification_context_get_size()

unsigned int GNUNET_notification_context_get_size ( struct GNUNET_NotificationContext nc)

Return active number of subscribers in this context.

Parameters
nccontext to query
Returns
number of current subscribers

Definition at line 213 of file nc.c.

References SubscriberList::next, and GNUNET_NotificationContext::subscribers_head.

Referenced by plugin_session_info_cb().

214 {
215  unsigned int num;
216  struct SubscriberList *pos;
217 
218  num = 0;
219  for (pos = nc->subscribers_head; NULL != pos; pos = pos->next)
220  num++;
221  return num;
222 }
struct SubscriberList * next
This is a doubly linked list.
Definition: nc.c:41
Lists of subscribers we manage for notifications.
Definition: nc.c:37
struct SubscriberList * subscribers_head
Head of list of subscribers receiving notifications.
Definition: nc.c:78
Here is the caller graph for this function:

Variable Documentation

◆ mv

GNUNET_MQ_MessageValidationCallback GNUNET_MQ_MessageHandler::mv

Callback to validate a message of the specified type.

The closure given to mv will be this struct (not ctx). Using NULL means only size-validation using expected_size. In this case, expected_size must be non-zero.

Definition at line 479 of file gnunet_mq_lib.h.

Referenced by GNUNET_MQ_copy_handlers2(), and GNUNET_MQ_handle_message().

◆ cb

GNUNET_MQ_MessageCallback GNUNET_MQ_MessageHandler::cb

Callback, called every time a new message of the specified type has been receied.

The closure given to mv will be this struct (not ctx).

Definition at line 486 of file gnunet_mq_lib.h.

Referenced by GNUNET_MQ_copy_handlers2(), GNUNET_MQ_count_handlers(), GNUNET_MQ_handle_message(), GNUNET_MQ_set_handlers_closure(), GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_core_get_mq(), and GNUNET_TRANSPORT_TESTING_start_peer().

◆ cls

void* GNUNET_MQ_MessageHandler::cls

Closure for mv and cb.

Definition at line 491 of file gnunet_mq_lib.h.

Referenced by GNUNET_MQ_copy_handlers2(), GNUNET_MQ_handle_message(), and GNUNET_MQ_set_handlers_closure().

◆ type

uint16_t GNUNET_MQ_MessageHandler::type

Type of the message this handler covers, in host byte order.

Definition at line 496 of file gnunet_mq_lib.h.

Referenced by GNUNET_MQ_copy_handlers2(), GNUNET_MQ_handle_message(), and reconnect().

◆ expected_size

uint16_t GNUNET_MQ_MessageHandler::expected_size

Expected size of messages of this type.

Minimum size of the message if mv is non-NULL. Messages of the given type will be discarded (and the connection closed with an error reported to the application) if they do not have the right size.

Definition at line 504 of file gnunet_mq_lib.h.

Referenced by GNUNET_MQ_copy_handlers2(), and GNUNET_MQ_handle_message().