Implementation of the UDP transport protocol. More...
#include "platform.h"
#include "plugin_transport_udp.h"
#include "gnunet_hello_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_fragmentation_lib.h"
#include "gnunet_nat_service.h"
#include "gnunet_protocols.h"
#include "gnunet_resolver_service.h"
#include "gnunet_signatures.h"
#include "gnunet_constants.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
#include "transport.h"
Go to the source code of this file.
Data Structures | |
struct | UDPMessage |
UDP Message-Packet header (after defragmentation). More... | |
struct | PrettyPrinterContext |
Closure for append_port(). More... | |
struct | GNUNET_ATS_Session |
Session handle for connections. More... | |
struct | DefragContext |
Data structure to track defragmentation contexts based on the source of the UDP traffic. More... | |
struct | UDP_FragmentationContext |
Context to send fragmented messages. More... | |
struct | UDP_MessageWrapper |
Information we track for each message in the queue. More... | |
struct | UDP_ACK_Message |
UDP ACK Message-Packet header. More... | |
struct | GNUNET_ATS_SessionCompareContext |
Closure for session_cmp_it(). More... | |
struct | FindReceiveContext |
Closure for find_receive_context(). More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
#define | UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) |
After how much inactivity should a UDP session time out? More... | |
#define | UDP_MAX_MESSAGES_IN_DEFRAG 3 |
Number of messages we can defragment in parallel. More... | |
#define | UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128 |
We keep a defragmentation queue per sender address. More... | |
Typedefs | |
typedef void(* | QueueContinuation) (void *cls, struct UDP_MessageWrapper *udpw, int result) |
Function called when a message is removed from the transmission queue. More... | |
Functions | |
static GNUNET_NETWORK_STRUCT_END void | notify_session_monitor (struct Plugin *plugin, struct GNUNET_ATS_Session *session, enum GNUNET_TRANSPORT_SessionState state) |
If a session monitor is attached, notify it about the new session state. More... | |
static int | send_session_info_iter (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
Return information about the given session to the monitor callback. More... | |
static void | udp_plugin_setup_monitor (void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls) |
Begin monitoring sessions of a plugin. More... | |
static void | free_session (struct GNUNET_ATS_Session *s) |
Function to free last resources associated with a session. More... | |
static unsigned int | udp_query_keepalive_factor (void *cls) |
Function that is called to get the keepalive factor. More... | |
static enum GNUNET_NetworkType | udp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) |
Function obtain the network type for a session. More... | |
static enum GNUNET_NetworkType | udp_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) |
Function obtain the network type for an address. More... | |
static void | udp_plugin_select_v4 (void *cls) |
We have been notified that our readset has something to read. More... | |
static void | udp_plugin_select_v6 (void *cls) |
We have been notified that our readset has something to read. More... | |
static void | schedule_select_v4 (struct Plugin *plugin) |
(re)schedule IPv4-select tasks for this plugin. More... | |
static void | schedule_select_v6 (struct Plugin *plugin) |
(re)schedule IPv6-select tasks for this plugin. More... | |
const char * | udp_address_to_string (void *cls, const void *addr, size_t addrlen) |
Function called for a quick conversion of the binary address to a numeric address. More... | |
static int | udp_string_to_address (void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added) |
Function called to convert a string address to a binary address. More... | |
static void | append_port (void *cls, const char *hostname) |
Append our port and forward the result. More... | |
static void | udp_plugin_address_pretty_printer (void *cls, const char *type, const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls) |
Convert the transports address to a nice, human-readable format. More... | |
static int | check_port (const struct Plugin *plugin, uint16_t in_port) |
Check if the given port is plausible (must be either our listen port or our advertised port). More... | |
static int | udp_plugin_check_address (void *cls, const void *addr, size_t addrlen) |
Function that will be called to check if a binary address for this plugin is well-formed and corresponds to an address for THIS peer (as per our configuration). More... | |
static void | udp_nat_port_map_callback (void *cls, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen) |
Our external IP address/port mapping has changed. More... | |
static int | session_cmp_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Find a session with a matching address. More... | |
static struct GNUNET_ATS_Session * | udp_plugin_lookup_session (void *cls, const struct GNUNET_HELLO_Address *address) |
Locate an existing session the transport service is using to send data to another peer. More... | |
static void | reschedule_session_timeout (struct GNUNET_ATS_Session *s) |
Increment session timeout due to activity. More... | |
static void | udp_plugin_update_session_timeout (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session) |
Function that will be called whenever the transport service wants to notify the plugin that a session is still active and in use and therefore the session timeout for this session has to be updated. More... | |
static void | dequeue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw) |
Remove the given message from the transmission queue and update all applicable statistics. More... | |
static void | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw) |
Enqueue a message for transmission and update statistics. More... | |
static void | fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, int result) |
We have completed our (attempt) to transmit a message that had to be fragmented – either because we got an ACK saying that all fragments were received, or because of timeout / disconnect. More... | |
static void | qc_fragment_sent (void *cls, struct UDP_MessageWrapper *udpw, int result) |
We are finished with a fragment in the message queue. More... | |
static void | enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) |
Function that is called with messages created by the fragmentation module. More... | |
static void | qc_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result) |
We are finished with a message from the message queue. More... | |
static ssize_t | udp_plugin_send (void *cls, struct GNUNET_ATS_Session *s, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative to, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
Function that can be used by the transport service to transmit a message using the plugin. More... | |
static int | find_receive_context (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost) |
Scan the heap for a receive context with the given address. More... | |
static int | udp_disconnect_session (void *cls, struct GNUNET_ATS_Session *s) |
Functions with this signature are called whenever we need to close a session due to a disconnect or failure to establish a connection. More... | |
static void | read_process_ack (struct Plugin *plugin, const struct GNUNET_MessageHeader *msg, const union UdpAddress *udp_addr, socklen_t udp_addr_len) |
Handle a GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK message. More... | |
static int | process_inbound_tokenized_messages (void *cls, const struct GNUNET_MessageHeader *hdr) |
Message tokenizer has broken up an incoming message. More... | |
static int | disconnect_and_free_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Destroy a session, plugin is being unloaded. More... | |
static void | udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) |
Disconnect from a remote node. More... | |
static void | session_timeout (void *cls) |
Session was idle, so disconnect it. More... | |
static struct GNUNET_ATS_Session * | udp_plugin_create_session (void *cls, const struct GNUNET_HELLO_Address *address, enum GNUNET_NetworkType network_type) |
Allocate a new session for the given endpoint address. More... | |
static struct GNUNET_ATS_Session * | udp_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address) |
Creates a new outbound session the transport service will use to send data to the peer. More... | |
static void | process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, const union UdpAddress *udp_addr, size_t udp_addr_len, enum GNUNET_NetworkType network_type) |
We've received a UDP Message. More... | |
static void | fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg) |
Process a defragmented message. More... | |
static void | ack_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result) |
We finished sending an acknowledgement. More... | |
static void | ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) |
Transmit an acknowledgement. More... | |
static void | read_process_fragment (struct Plugin *plugin, const struct GNUNET_MessageHeader *msg, const union UdpAddress *udp_addr, size_t udp_addr_len, enum GNUNET_NetworkType network_type) |
We received a fragment, process it. More... | |
static void | udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) |
Read and process a message from the given socket. More... | |
static struct UDP_MessageWrapper * | remove_timeout_messages_and_select (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) |
Removes messages from the transmission queue that have timed out, and then selects a message that should be transmitted next. More... | |
static void | analyze_send_error (struct Plugin *plugin, const struct sockaddr *sa, socklen_t slen, int error) |
We failed to transmit a message via UDP. More... | |
static void | udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) |
It is time to try to transmit a UDP message. More... | |
static unsigned int | setup_sockets (struct Plugin *plugin, const struct sockaddr_in6 *bind_v6, const struct sockaddr_in *bind_v4) |
Setup the UDP sockets (for IPv4 and IPv6) for the plugin. More... | |
void * | libgnunet_plugin_transport_udp_init (void *cls) |
The exported method. More... | |
static int | heap_cleanup_iterator (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost) |
Function called on each entry in the defragmentation heap to clean it up. More... | |
void * | libgnunet_plugin_transport_udp_done (void *cls) |
The exported method. More... | |
Implementation of the UDP transport protocol.
Definition in file plugin_transport_udp.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
Definition at line 43 of file plugin_transport_udp.c.
#define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) |
After how much inactivity should a UDP session time out?
Definition at line 48 of file plugin_transport_udp.c.
#define UDP_MAX_MESSAGES_IN_DEFRAG 3 |
Number of messages we can defragment in parallel.
We only really defragment 1 message at a time, but if messages get re-ordered, we may want to keep knowledge about the previous message to avoid discarding the current message in favor of a single fragment of a previous message. 3 should be good since we don't expect massive message reorderings with UDP.
Definition at line 59 of file plugin_transport_udp.c.
#define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128 |
We keep a defragmentation queue per sender address.
How many sender addresses do we support at the same time? Memory consumption is roughly a factor of 32k * UDP_MAX_MESSAGES_IN_DEFRAG times this value. (So 128 corresponds to 12 MB and should suffice for connecting to roughly 128 peers via UDP).
Definition at line 68 of file plugin_transport_udp.c.
typedef void(* QueueContinuation) (void *cls, struct UDP_MessageWrapper *udpw, int result) |
Function called when a message is removed from the transmission queue.
cls | closure |
udpw | message wrapper finished |
result | GNUNET_OK on success (message was sent) GNUNET_SYSERR if the target disconnected or we had a timeout or other trouble sending |
Definition at line 387 of file plugin_transport_udp.c.
|
static |
If a session monitor is attached, notify it about the new session state.
plugin | our plugin |
session | session that changed state |
state | new state of the session |
Definition at line 515 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::bytes_in_queue, GNUNET_SYSERR, GNUNET_YES, GNUNET_ATS_Session::in_destroy, info, GNUNET_ATS_Session::msgs_in_queue, plugin, state, and GNUNET_ATS_Session::timeout.
Referenced by ack_proc(), fragmented_message_done(), process_udp_message(), remove_timeout_messages_and_select(), send_session_info_iter(), session_timeout(), udp_disconnect_session(), udp_plugin_create_session(), udp_plugin_send(), and udp_select_send().
|
static |
Return information about the given session to the monitor callback.
cls | the struct Plugin with the monitor callback (sic ) |
peer | peer we send information about |
value | our struct GNUNET_ATS_Session to send information about |
Definition at line 548 of file plugin_transport_udp.c.
References GNUNET_OK, GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, notify_session_monitor(), plugin, and value.
Referenced by udp_plugin_setup_monitor().
|
static |
Begin monitoring sessions of a plugin.
There can only be one active monitor per plugin (i.e. if there are multiple monitors, the transport service needs to multiplex the generated events over all of them).
cls | closure of the plugin |
sic | callback to invoke, NULL to disable monitor; plugin will being by iterating over all active sessions immediately and then enter monitor mode |
sic_cls | closure for sic |
Definition at line 574 of file plugin_transport_udp.c.
References GNUNET_CONTAINER_multipeermap_iterate(), plugin, send_session_info_iter(), Plugin::sic, and Plugin::sic_cls.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Function to free last resources associated with a session.
s | session to free |
Definition at line 602 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, UDP_FragmentationContext::frag, GNUNET_ATS_Session::frag_ctx, GNUNET_FRAGMENT_context_destroy(), GNUNET_free, GNUNET_HELLO_address_free, GNUNET_MST_destroy(), and GNUNET_ATS_Session::mst.
Referenced by process_udp_message(), and udp_disconnect_session().
|
static |
Function that is called to get the keepalive factor.
GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to calculate the interval between keepalive packets.
cls | closure with the struct Plugin |
Definition at line 633 of file plugin_transport_udp.c.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Function obtain the network type for a session.
cls | closure (struct Plugin * ) |
session | the session |
Definition at line 633 of file plugin_transport_udp.c.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Function obtain the network type for an address.
cls | closure (struct Plugin * ) |
address | the address |
Definition at line 633 of file plugin_transport_udp.c.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
We have been notified that our readset has something to read.
We don't know which socket needs to be read, so we have to check each one Then reschedule this function to be called again once more is available.
cls | the plugin handle |
Definition at line 3321 of file plugin_transport_udp.c.
References GNUNET_NETWORK_fdset_isset(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_READ_READY, plugin, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_SCHEDULER_TaskContext::reason, schedule_select_v4(), tc, udp_select_read(), and udp_select_send().
Referenced by schedule_select_v4().
|
static |
We have been notified that our readset has something to read.
We don't know which socket needs to be read, so we have to check each one Then reschedule this function to be called again once more is available.
cls | the plugin handle |
Definition at line 3346 of file plugin_transport_udp.c.
References GNUNET_NETWORK_fdset_isset(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_READ_READY, plugin, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_SCHEDULER_TaskContext::reason, schedule_select_v6(), tc, udp_select_read(), and udp_select_send().
Referenced by schedule_select_v6().
|
static |
(re)schedule IPv4-select tasks for this plugin.
plugin | plugin to reschedule |
Definition at line 741 of file plugin_transport_udp.c.
References delay, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, UDP_MessageWrapper::next, plugin, GNUNET_TIME_Relative::rel_value_us, UDP_MessageWrapper::session, GNUNET_ATS_Session::target, UDP_MessageWrapper::transmission_time, and udp_plugin_select_v4().
Referenced by ack_proc(), enqueue_fragment(), setup_sockets(), udp_plugin_select_v4(), and udp_plugin_send().
|
static |
(re)schedule IPv6-select tasks for this plugin.
plugin | plugin to reschedule |
Definition at line 799 of file plugin_transport_udp.c.
References delay, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, UDP_MessageWrapper::next, plugin, GNUNET_TIME_Relative::rel_value_us, UDP_MessageWrapper::session, GNUNET_ATS_Session::target, UDP_MessageWrapper::transmission_time, and udp_plugin_select_v6().
Referenced by ack_proc(), enqueue_fragment(), setup_sockets(), udp_plugin_select_v6(), and udp_plugin_send().
const char* udp_address_to_string | ( | void * | cls, |
const void * | addr, | ||
size_t | addrlen | ||
) |
Function called for a quick conversion of the binary address to a numeric address.
Note that the caller must not free the address and that the next call to this function is allowed to override the address again.
cls | closure |
addr | binary address (a union UdpAddress ) |
addrlen | length of the addr |
Definition at line 864 of file plugin_transport_udp.c.
References buf, GNUNET_break_op, GNUNET_snprintf(), options, PLUGIN_NAME, port, t4, and t6.
Referenced by ack_proc(), broadcast_mst_cb(), libgnunet_plugin_transport_udp_init(), read_process_ack(), read_process_fragment(), udp_disconnect_session(), udp_plugin_create_session(), udp_plugin_lookup_session(), and udp_plugin_send().
|
static |
Function called to convert a string address to a binary address.
cls | closure (struct Plugin * ) |
addr | string address |
addrlen | length of the address |
buf | location to store the buffer |
added | location to store the number of bytes in the buffer. If the function returns GNUNET_SYSERR, its contents are undefined. |
Definition at line 930 of file plugin_transport_udp.c.
References address, buf, GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_to_address_ip(), GNUNET_SYSERR, IPv4UdpAddress::ipv4_addr, IPv6UdpAddress::ipv6_addr, options, IPv4UdpAddress::options, IPv6UdpAddress::options, plugin, IPv4UdpAddress::u4_port, and IPv6UdpAddress::u6_port.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Append our port and forward the result.
cls | a struct PrettyPrinterContext * |
hostname | result from DNS resolver |
Definition at line 1036 of file plugin_transport_udp.c.
References PrettyPrinterContext::asc, PrettyPrinterContext::asc_cls, GNUNET_asprintf(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, GNUNET_YES, hostname, PrettyPrinterContext::ipv6, PrettyPrinterContext::options, plugin, PrettyPrinterContext::plugin, PLUGIN_NAME, PrettyPrinterContext::port, PrettyPrinterContext::resolver_handle, and ret.
Referenced by udp_plugin_address_pretty_printer().
|
static |
Convert the transports address to a nice, human-readable format.
cls | closure with the struct Plugin * |
type | name of the transport that generated the address |
addr | one of the addresses of the host, NULL for the last address the specific address format depends on the transport; a union UdpAddress |
addrlen | length of the address |
numeric | should (IP) addresses be displayed in numeric form? |
timeout | after how long should we give up? |
asc | function to call on each string |
asc_cls | closure for asc |
Definition at line 1087 of file plugin_transport_udp.c.
References append_port(), PrettyPrinterContext::asc, PrettyPrinterContext::asc_cls, GNUNET_break_op, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_RESOLVER_hostname_get(), GNUNET_SYSERR, GNUNET_YES, IPv4UdpAddress::ipv4_addr, PrettyPrinterContext::ipv6, IPv6UdpAddress::ipv6_addr, numeric, options, PrettyPrinterContext::options, IPv4UdpAddress::options, IPv6UdpAddress::options, plugin, PrettyPrinterContext::plugin, port, PrettyPrinterContext::port, PrettyPrinterContext::resolver_handle, timeout, IPv4UdpAddress::u4_port, and IPv6UdpAddress::u6_port.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Check if the given port is plausible (must be either our listen port or our advertised port).
If it is neither, we return GNUNET_SYSERR.
plugin | global variables |
in_port | port number to check |
Definition at line 1175 of file plugin_transport_udp.c.
References GNUNET_OK, GNUNET_SYSERR, and plugin.
Referenced by udp_plugin_check_address().
|
static |
Function that will be called to check if a binary address for this plugin is well-formed and corresponds to an address for THIS peer (as per our configuration).
Naturally, if absolutely necessary, plugins can be a bit conservative in their answer, but in general plugins should make sure that the address does not redirect traffic to a 3rd party that might try to man-in-the-middle our traffic.
cls | closure, should be our handle to the Plugin |
addr | pointer to a union UdpAddress |
addrlen | length of addr |
Definition at line 1199 of file plugin_transport_udp.c.
References check_port(), GNUNET_break_op, GNUNET_NAT_test_address(), GNUNET_OK, GNUNET_SYSERR, and plugin.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Our external IP address/port mapping has changed.
cls | closure, the struct Plugin | |
[in,out] | app_ctx | location where the app can store stuff on add and retrieve it on remove |
add_remove | GNUNET_YES to mean the new public IP address, GNUNET_NO to mean the previous (now invalid) one | |
ac | address class the address belongs to | |
addr | either the previous or the new public IP address | |
addrlen | actual length of the addr |
Definition at line 1266 of file plugin_transport_udp.c.
References address, find_typedefs::arg, consensus-simulation::args, GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_YES, IPv4UdpAddress::ipv4_addr, IPv6UdpAddress::ipv6_addr, LOG, IPv4UdpAddress::options, IPv6UdpAddress::options, plugin, PLUGIN_NAME, IPv4UdpAddress::u4_port, and IPv6UdpAddress::u6_port.
Referenced by setup_sockets().
|
static |
Find a session with a matching address.
cls | the struct GNUNET_ATS_SessionCompareContext * |
key | peer identity (unused) |
value | the struct GNUNET_ATS_Session * |
Definition at line 1365 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_SessionCompareContext::address, GNUNET_assert, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_OK, GNUNET_ATS_Session::in_destroy, GNUNET_ATS_SessionCompareContext::res, and value.
Referenced by udp_plugin_lookup_session().
|
static |
Locate an existing session the transport service is using to send data to another peer.
Performs some basic sanity checks on the address and then tries to locate a matching session.
cls | the plugin |
address | the address we should locate the session by |
Definition at line 1390 of file plugin_transport_udp.c.
References address, GNUNET_ATS_SessionCompareContext::address, GNUNET_break, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), LOG, plugin, GNUNET_ATS_SessionCompareContext::res, session_cmp_it(), IPv4UdpAddress::u4_port, IPv6UdpAddress::u6_port, and udp_address_to_string().
Referenced by ack_proc(), process_udp_message(), read_process_ack(), and udp_plugin_get_session().
|
static |
Increment session timeout due to activity.
s | session to reschedule timeout activity for |
Definition at line 1460 of file plugin_transport_udp.c.
References GNUNET_assert, GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GNUNET_ATS_Session::in_destroy, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, and UDP_SESSION_TIME_OUT.
Referenced by process_inbound_tokenized_messages(), and udp_plugin_update_session_timeout().
|
static |
Function that will be called whenever the transport service wants to notify the plugin that a session is still active and in use and therefore the session timeout for this session has to be updated.
cls | closure with the struct Plugin |
peer | which peer was the session for |
session | which session is being updated |
Definition at line 1479 of file plugin_transport_udp.c.
References GNUNET_break, GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_YES, peer, plugin, and reschedule_session_timeout().
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Remove the given message from the transmission queue and update all applicable statistics.
plugin | the UDP plugin |
udpw | message wrapper to dequeue |
Definition at line 1509 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, GNUNET_ATS_Session::bytes_in_queue, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_NO, GNUNET_STATISTICS_update(), UDP_MessageWrapper::msg_size, GNUNET_ATS_Session::msgs_in_queue, plugin, and UDP_MessageWrapper::session.
Referenced by fragmented_message_done(), remove_timeout_messages_and_select(), udp_disconnect_session(), and udp_select_send().
|
static |
Enqueue a message for transmission and update statistics.
plugin | the UDP plugin |
udpw | message wrapper to queue |
Definition at line 1561 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, GNUNET_ATS_Session::bytes_in_queue, UDP_MessageWrapper::cont, UDP_MessageWrapper::cont_cls, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, GNUNET_ATS_Session::in_destroy, UDP_MessageWrapper::msg_size, GNUNET_ATS_Session::msgs_in_queue, plugin, UDP_MessageWrapper::session, and GNUNET_ATS_Session::target.
Referenced by ack_proc(), enqueue_fragment(), and udp_plugin_send().
|
static |
We have completed our (attempt) to transmit a message that had to be fragmented – either because we got an ACK saying that all fragments were received, or because of timeout / disconnect.
Clean up our state.
frag_ctx | fragmentation context to clean up |
result | GNUNET_OK if we succeeded (got ACK), GNUNET_SYSERR if the transmission failed |
Definition at line 1627 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, UDP_FragmentationContext::cont, UDP_FragmentationContext::cont_cls, delay, dequeue(), UDP_FragmentationContext::frag, GNUNET_ATS_Session::frag_ctx, UDP_MessageWrapper::frag_ctx, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_FRAGMENT_context_destroy(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, GNUNET_ATS_Session::last_expected_ack_delay, GNUNET_ATS_Session::last_expected_msg_delay, LOG, UDP_MessageWrapper::next, UDP_FragmentationContext::next_frag_time, notify_session_monitor(), UDP_FragmentationContext::on_wire_size, UDP_FragmentationContext::payload_size, plugin, GNUNET_ATS_Session::plugin, UDP_FragmentationContext::plugin, GNUNET_TIME_Relative::rel_value_us, result, UDP_FragmentationContext::session, UDP_FragmentationContext::start_time, and GNUNET_ATS_Session::target.
Referenced by qc_fragment_sent(), read_process_ack(), and udp_disconnect_session().
|
static |
We are finished with a fragment in the message queue.
Notify the continuation and update statistics.
cls | the struct Plugin * |
udpw | the queue entry |
result | GNUNET_OK on success, GNUNET_SYSERR on failure |
Definition at line 1764 of file plugin_transport_udp.c.
References UDP_FragmentationContext::frag, UDP_MessageWrapper::frag_ctx, fragmented_message_done(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FRAGMENT_context_transmission_done(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, UDP_MessageWrapper::msg_size, UDP_MessageWrapper::payload_size, plugin, result, UDP_MessageWrapper::session, and GNUNET_ATS_Session::target.
Referenced by enqueue_fragment().
|
static |
Function that is called with messages created by the fragmentation module.
In the case of the proc
callback of the GNUNET_FRAGMENT_context_create() function, this function must eventually call GNUNET_FRAGMENT_context_transmission_done().
cls | closure, the struct UDP_FragmentationContext |
msg | the message that was created |
Definition at line 1816 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, enqueue(), UDP_FragmentationContext::flow_delay_from_other_peer, GNUNET_ATS_Session::frag_ctx, UDP_MessageWrapper::frag_ctx, GNUNET_ERROR_TYPE_DEBUG, GNUNET_malloc, GNUNET_memcpy, GNUNET_TIME_absolute_add(), LOG, msg, UDP_MessageWrapper::msg_buf, UDP_MessageWrapper::msg_size, UDP_FragmentationContext::next_frag_time, UDP_MessageWrapper::payload_size, plugin, UDP_FragmentationContext::plugin, UDP_MessageWrapper::qc, UDP_MessageWrapper::qc_cls, qc_fragment_sent(), schedule_select_v4(), schedule_select_v6(), UDP_FragmentationContext::session, UDP_MessageWrapper::session, GNUNET_MessageHeader::size, UDP_FragmentationContext::start_time, UDP_MessageWrapper::start_time, UDP_FragmentationContext::timeout, UDP_MessageWrapper::timeout, and UDP_MessageWrapper::transmission_time.
Referenced by udp_plugin_send().
|
static |
We are finished with a message from the message queue.
Notify the continuation and update statistics.
cls | the struct Plugin * |
udpw | the queue entry |
result | GNUNET_OK on success, GNUNET_SYSERR on failure |
Definition at line 1858 of file plugin_transport_udp.c.
References UDP_MessageWrapper::cont, UDP_MessageWrapper::cont_cls, delay, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, LOG, UDP_MessageWrapper::msg_size, UDP_MessageWrapper::payload_size, plugin, GNUNET_TIME_Relative::rel_value_us, result, UDP_MessageWrapper::session, UDP_MessageWrapper::start_time, and GNUNET_ATS_Session::target.
Referenced by udp_plugin_send().
|
static |
Function that can be used by the transport service to transmit a message using the plugin.
Note that in the case of a peer disconnecting, the continuation MUST be called prior to the disconnect notification itself. This function will be called with this peer's HELLO message to initiate a fresh connection to another peer.
cls | closure |
s | which session must be used |
msgbuf | the message to transmit |
msgbuf_size | number of bytes in msgbuf |
priority | how important is the message (most plugins will ignore message priority and just FIFO) |
to | how long to wait at most for the transmission (does not require plugins to discard the message after the timeout, just advisory for the desired delay; most plugins will ignore this as well) |
cont | continuation to call once the message has been transmitted (or if the transport is ready for the next transmission call; or if the peer disconnected...); can be NULL |
cont_cls | closure for cont |
Definition at line 1963 of file plugin_transport_udp.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, UDP_FragmentationContext::cont, UDP_MessageWrapper::cont, UDP_FragmentationContext::cont_cls, UDP_MessageWrapper::cont_cls, enqueue(), enqueue_fragment(), GNUNET_ATS_Session::flow_delay_from_other_peer, UDP_FragmentationContext::flow_delay_from_other_peer, UDP_FragmentationContext::frag, GNUNET_ATS_Session::frag_ctx, UDP_MessageWrapper::frag_ctx, GNUNET_ALIGN, GNUNET_break, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_FRAGMENT_context_create(), GNUNET_i2s(), GNUNET_malloc, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, GNUNET_ATS_Session::last_expected_ack_delay, GNUNET_ATS_Session::last_expected_msg_delay, GNUNET_ATS_Session::last_transmit_time, LOG, UDP_MessageWrapper::msg_buf, UDP_MessageWrapper::msg_size, GNUNET_ATS_Session::msgs_in_queue, UDP_FragmentationContext::next_frag_time, notify_session_monitor(), UDP_FragmentationContext::on_wire_size, UDP_FragmentationContext::payload_size, UDP_MessageWrapper::payload_size, plugin, GNUNET_ATS_Session::plugin, UDP_FragmentationContext::plugin, UDP_MessageWrapper::qc, UDP_MessageWrapper::qc_cls, qc_message_sent(), GNUNET_TIME_Relative::rel_value_us, schedule_select_v4(), schedule_select_v6(), UDP_FragmentationContext::session, UDP_MessageWrapper::session, UDP_FragmentationContext::start_time, UDP_MessageWrapper::start_time, GNUNET_ATS_Session::target, UDP_FragmentationContext::timeout, UDP_MessageWrapper::timeout, UDP_MessageWrapper::transmission_time, udp, udp_address_to_string(), and UDP_MTU.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Scan the heap for a receive context with the given address.
cls | the struct FindReceiveContext |
node | internal node of the heap |
element | value stored at the node (a struct ReceiveContext ) |
cost | cost associated with the node |
Definition at line 2160 of file plugin_transport_udp.c.
References e, GNUNET_NO, GNUNET_YES, FindReceiveContext::rc, FindReceiveContext::udp_addr, and FindReceiveContext::udp_addr_len.
Referenced by read_process_fragment(), and udp_disconnect_session().
|
static |
Functions with this signature are called whenever we need to close a session due to a disconnect or failure to establish a connection.
cls | closure with the struct Plugin |
s | session to close down |
Definition at line 2187 of file plugin_transport_udp.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, UDP_FragmentationContext::cont, UDP_FragmentationContext::cont_cls, DefragContext::defrag, dequeue(), find_receive_context(), GNUNET_ATS_Session::frag_ctx, fragmented_message_done(), free_session(), GNUNET_assert, GNUNET_CONTAINER_heap_iterate(), GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_DEFRAGMENT_context_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TRANSPORT_SS_DONE, GNUNET_YES, DefragContext::hnode, GNUNET_ATS_Session::in_destroy, LOG, UDP_MessageWrapper::next, notify_session_monitor(), UDP_FragmentationContext::on_wire_size, UDP_FragmentationContext::payload_size, plugin, GNUNET_ATS_Session::plugin, UDP_MessageWrapper::qc, UDP_MessageWrapper::qc_cls, GNUNET_ATS_Session::rc, FindReceiveContext::rc, UDP_MessageWrapper::session, GNUNET_ATS_Session::target, GNUNET_ATS_Session::timeout_task, FindReceiveContext::udp_addr, FindReceiveContext::udp_addr_len, and udp_address_to_string().
Referenced by disconnect_and_free_it(), libgnunet_plugin_transport_udp_init(), read_process_ack(), and session_timeout().
|
static |
Handle a GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK message.
plugin | the UDP plugin |
msg | the (presumed) UDP ACK message |
udp_addr | sender address |
udp_addr_len | number of bytes in udp_addr |
Definition at line 2290 of file plugin_transport_udp.c.
References address, UDP_ACK_Message::delay, GNUNET_ATS_Session::flow_delay_from_other_peer, UDP_FragmentationContext::frag, GNUNET_ATS_Session::frag_ctx, fragmented_message_done(), GNUNET_break_op, GNUNET_CONSTANTS_LATENCY_WARN, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_FRAGMENT_print_ack(), GNUNET_FRAGMENT_process_ack(), GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_OK, GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, LOG, msg, plugin, PLUGIN_NAME, GNUNET_TIME_Relative::rel_value_us, UDP_ACK_Message::sender, GNUNET_MessageHeader::size, udp_address_to_string(), udp_disconnect_session(), and udp_plugin_lookup_session().
Referenced by udp_select_read().
|
static |
Message tokenizer has broken up an incoming message.
Pass it on to the service.
cls | the struct GNUNET_ATS_Session * |
hdr | the actual message |
Definition at line 2401 of file plugin_transport_udp.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::flow_delay_for_other_peer, GNUNET_OK, GNUNET_YES, GNUNET_ATS_Session::in_destroy, plugin, GNUNET_ATS_Session::plugin, and reschedule_session_timeout().
Referenced by udp_plugin_create_session().
|
static |
Destroy a session, plugin is being unloaded.
cls | the struct Plugin |
key | hash of public key of target peer |
value | a struct PeerSession * to clean up |
Definition at line 2425 of file plugin_transport_udp.c.
References GNUNET_OK, plugin, udp_disconnect_session(), and value.
Referenced by udp_disconnect().
|
static |
Disconnect from a remote node.
Clean up session if we have one for this peer.
cls | closure for this call (should be handle to Plugin) |
target | the peeridentity of the peer to disconnect |
Definition at line 2445 of file plugin_transport_udp.c.
References disconnect_and_free_it(), GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), LOG, and plugin.
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
Session was idle, so disconnect it.
cls | the struct GNUNET_ATS_Session to time out |
Definition at line 2465 of file plugin_transport_udp.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, LOG, notify_session_monitor(), plugin, GNUNET_ATS_Session::plugin, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, udp_disconnect_session(), and UDP_SESSION_TIME_OUT.
Referenced by udp_plugin_create_session().
|
static |
Allocate a new session for the given endpoint address.
Note that this function does not inform the service of the new session, this is the responsibility of the caller (if needed).
cls | the struct Plugin |
address | address of the other peer to use |
network_type | network type the address belongs to |
Definition at line 2503 of file plugin_transport_udp.c.
References address, GNUNET_ATS_Session::address, GNUNET_ATS_Session::flow_delay_for_other_peer, GNUNET_ATS_Session::flow_delay_from_other_peer, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_copy(), GNUNET_i2s(), GNUNET_MST_create(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_set(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TIME_UNIT_ZERO, GNUNET_TRANSPORT_SS_INIT, GNUNET_ATS_Session::last_expected_ack_delay, GNUNET_ATS_Session::last_expected_msg_delay, GNUNET_ATS_Session::last_transmit_time, LOG, GNUNET_ATS_Session::mst, notify_session_monitor(), plugin, GNUNET_ATS_Session::plugin, process_inbound_tokenized_messages(), GNUNET_ATS_Session::scope, session_timeout(), GNUNET_ATS_Session::target, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, udp_address_to_string(), and UDP_SESSION_TIME_OUT.
Referenced by process_udp_message(), and udp_plugin_get_session().
|
static |
Creates a new outbound session the transport service will use to send data to the peer.
cls | the struct Plugin * |
address | the address |
Definition at line 2556 of file plugin_transport_udp.c.
References address, GNUNET_break, GNUNET_break_op, GNUNET_NT_UNSPECIFIED, plugin, udp_plugin_create_session(), and udp_plugin_lookup_session().
Referenced by libgnunet_plugin_transport_udp_init().
|
static |
We've received a UDP Message.
Process it (pass contents to main service).
plugin | plugin context |
msg | the message |
udp_addr | sender address |
udp_addr_len | number of bytes in udp_addr |
network_type | network type the address belongs to |
Definition at line 2626 of file plugin_transport_udp.c.
References address, free_session(), GNUNET_break, GNUNET_break_op, GNUNET_free, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_MST_from_buffer(), GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_TRANSPORT_SS_UP, GNUNET_YES, GNUNET_ATS_Session::in_destroy, msg, GNUNET_ATS_Session::mst, notify_session_monitor(), plugin, PLUGIN_NAME, GNUNET_ATS_Session::rc, GNUNET_ATS_Session::scope, GNUNET_MessageHeader::size, udp_plugin_create_session(), and udp_plugin_lookup_session().
Referenced by fragment_msg_proc(), and udp_select_read().
|
static |
Process a defragmented message.
cls | the struct DefragContext * |
msg | the message |
Definition at line 2680 of file plugin_transport_udp.c.
References dc, GNUNET_break_op, GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE, GNUNET_YES, msg, process_udp_message(), UDPMessage::sender, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by read_process_fragment().
|
static |
We finished sending an acknowledgement.
Update statistics.
cls | the struct Plugin |
udpw | message queue entry of the ACK |
result | GNUNET_OK if the transmission worked, GNUNET_SYSERR if we failed to send the ACK |
Definition at line 2716 of file plugin_transport_udp.c.
References GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), plugin, and result.
Referenced by ack_proc().
|
static |
Transmit an acknowledgement.
cls | the struct DefragContext * |
id | message ID (unused) |
msg | ack to transmit |
Definition at line 2745 of file plugin_transport_udp.c.
References ack_message_sent(), address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, DefragContext::defrag, delay, UDP_ACK_Message::delay, enqueue(), GNUNET_ATS_Session::flow_delay_for_other_peer, GNUNET_CONTAINER_heap_remove_node(), GNUNET_DEFRAGMENT_context_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, DefragContext::have_sender, UDP_ACK_Message::header, DefragContext::hnode, LOG, msg, UDP_MessageWrapper::msg_buf, UDP_MessageWrapper::msg_size, notify_session_monitor(), UDP_MessageWrapper::payload_size, plugin, DefragContext::plugin, PLUGIN_NAME, UDP_MessageWrapper::qc, UDP_MessageWrapper::qc_cls, GNUNET_TIME_Relative::rel_value_us, schedule_select_v4(), schedule_select_v6(), DefragContext::sender, UDP_ACK_Message::sender, UDP_MessageWrapper::session, GNUNET_MessageHeader::size, size, UDP_MessageWrapper::start_time, UDP_MessageWrapper::timeout, GNUNET_MessageHeader::type, DefragContext::udp_addr, DefragContext::udp_addr_len, udp_address_to_string(), and udp_plugin_lookup_session().
Referenced by read_process_fragment().
|
static |
We received a fragment, process it.
plugin | our plugin |
msg | a message of type GNUNET_MESSAGE_TYPE_FRAGMENT |
udp_addr | sender address |
udp_addr_len | number of bytes in udp_addr |
network_type | network type the address belongs to |
Definition at line 2833 of file plugin_transport_udp.c.
References GNUNET_TIME_Absolute::abs_value_us, ack_proc(), DefragContext::defrag, find_receive_context(), fragment_msg_proc(), GNUNET_assert, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_iterate(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_heap_update_cost(), GNUNET_DEFRAGMENT_context_create(), GNUNET_DEFRAGMENT_context_destroy(), GNUNET_DEFRAGMENT_process_fragment(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), DefragContext::hnode, LOG, msg, DefragContext::network_type, plugin, DefragContext::plugin, FindReceiveContext::rc, GNUNET_MessageHeader::size, DefragContext::udp_addr, FindReceiveContext::udp_addr, DefragContext::udp_addr_len, FindReceiveContext::udp_addr_len, udp_address_to_string(), UDP_MAX_MESSAGES_IN_DEFRAG, UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG, and UDP_MTU.
Referenced by udp_select_read().
|
static |
Read and process a message from the given socket.
plugin | the overall plugin |
rsock | socket to read from |
Definition at line 2917 of file plugin_transport_udp.c.
References buf, GNUNET_a2s(), GNUNET_ALIGN, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_FRAGMENT, GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON, GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK, GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE, GNUNET_NAT_stun_handle_packet(), GNUNET_NETWORK_socket_recvfrom(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, IPv4UdpAddress::ipv4_addr, IPv6UdpAddress::ipv6_addr, LOG, msg, IPv4UdpAddress::options, IPv6UdpAddress::options, plugin, process_udp_message(), read_process_ack(), read_process_fragment(), GNUNET_MessageHeader::size, size, GNUNET_MessageHeader::type, IPv4UdpAddress::u4_port, IPv6UdpAddress::u6_port, udp_broadcast_receive(), UdpAddress::v4, and UdpAddress::v6.
Referenced by udp_plugin_select_v4(), and udp_plugin_select_v6().
|
static |
Removes messages from the transmission queue that have timed out, and then selects a message that should be transmitted next.
plugin | the UDP plugin |
sock | which socket should we process the queue for (v4 or v6) |
Definition at line 3067 of file plugin_transport_udp.c.
References dequeue(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_ZERO, GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, LOG, UDP_MessageWrapper::next, notify_session_monitor(), UDP_MessageWrapper::payload_size, plugin, GNUNET_ATS_Session::plugin, UDP_MessageWrapper::qc, UDP_MessageWrapper::qc_cls, GNUNET_TIME_Relative::rel_value_us, UDP_MessageWrapper::session, GNUNET_ATS_Session::target, UDP_MessageWrapper::timeout, and UDP_MessageWrapper::transmission_time.
Referenced by udp_select_send().
|
static |
We failed to transmit a message via UDP.
Generate a descriptive error message.
plugin | our plugin |
sa | target address we were trying to reach |
slen | number of bytes in sa |
error | the errno value returned from the sendto() call |
Definition at line 3152 of file plugin_transport_udp.c.
References _, GNUNET_a2s(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_WARNING, GNUNET_NT_LAN, GNUNET_NT_WAN, LOG, plugin, and type.
Referenced by udp_select_send().
|
static |
It is time to try to transmit a UDP message.
Select one and send.
plugin | the plugin |
sock | which socket (v4/v6) to send on |
Definition at line 3206 of file plugin_transport_udp.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, analyze_send_error(), dequeue(), UDP_MessageWrapper::frag_ctx, GNUNET_a2s(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_NETWORK_socket_sendto(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_max(), GNUNET_TRANSPORT_SS_UPDATE, IPv4UdpAddress::ipv4_addr, IPv6UdpAddress::ipv6_addr, GNUNET_ATS_Session::last_transmit_time, LOG, UDP_MessageWrapper::msg_buf, UDP_MessageWrapper::msg_size, notify_session_monitor(), UDP_FragmentationContext::on_wire_size, plugin, UDP_MessageWrapper::qc, UDP_MessageWrapper::qc_cls, remove_timeout_messages_and_select(), UDP_MessageWrapper::session, GNUNET_ATS_Session::target, IPv4UdpAddress::u4_port, and IPv6UdpAddress::u6_port.
Referenced by udp_plugin_select_v4(), and udp_plugin_select_v6().
|
static |
Setup the UDP sockets (for IPv4 and IPv6) for the plugin.
plugin | the plugin to initialize |
bind_v6 | IPv6 address to bind to (can be NULL, for 'any') |
bind_v4 | IPv4 address to bind to (can be NULL, for 'any') |
Definition at line 3376 of file plugin_transport_udp.c.
References _, bind_v4(), bind_v6(), GNUNET_a2s(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_NAT_register(), GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NO, GNUNET_OK, GNUNET_YES, LOG, plugin, schedule_select_v4(), schedule_select_v6(), and udp_nat_port_map_callback().
Referenced by libgnunet_plugin_transport_udp_init().
void* libgnunet_plugin_transport_udp_init | ( | void * | cls | ) |
The exported method.
Makes the core api available via a global and returns the udp transport API.
cls | our struct GNUNET_TRANSPORT_PluginEnvironment |
struct GNUNET_TRANSPORT_PluginFunctions
Definition at line 3585 of file plugin_transport_udp.c.
References _, GNUNET_TRANSPORT_PluginFunctions::address_pretty_printer, GNUNET_TRANSPORT_PluginFunctions::address_to_string, Plugin::aport, Plugin::bind4_address, Plugin::bind6_address, GNUNET_TRANSPORT_PluginFunctions::check_address, GNUNET_TRANSPORT_PluginEnvironment::cls, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::disconnect_peer, GNUNET_TRANSPORT_PluginFunctions::disconnect_session, Plugin::enable_broadcasting, env, GNUNET_TRANSPORT_PluginFunctions::get_network, GNUNET_TRANSPORT_PluginFunctions::get_network_for_address, GNUNET_TRANSPORT_PluginFunctions::get_session, GNUNET_BANDWIDTH_tracker_init(), GNUNET_BANDWIDTH_value_init(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_invalid(), GNUNET_NAT_unregister(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, interval, LOG, p, port, GNUNET_TRANSPORT_PluginFunctions::query_keepalive_factor, res, GNUNET_TRANSPORT_PluginFunctions::send, setup_broadcast(), GNUNET_TRANSPORT_PluginFunctions::setup_monitor, setup_sockets(), GNUNET_TRANSPORT_PluginFunctions::string_to_address, udp_address_to_string(), udp_disconnect(), udp_disconnect_session(), udp_plugin_address_pretty_printer(), udp_plugin_check_address(), udp_plugin_get_network(), udp_plugin_get_network_for_address(), udp_plugin_get_session(), udp_plugin_send(), udp_plugin_setup_monitor(), udp_plugin_update_session_timeout(), udp_query_keepalive_factor(), udp_string_to_address(), and GNUNET_TRANSPORT_PluginFunctions::update_session_timeout.
|
static |
Function called on each entry in the defragmentation heap to clean it up.
cls | NULL |
node | node in the heap (to be removed) |
element | a struct DefragContext to be cleaned up |
cost | unused |
Definition at line 3792 of file plugin_transport_udp.c.