Transport plugin using unix domain sockets (!) Clearly, can only be used locally on Unix/Linux hosts... More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.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 | UnixAddress |
Binary format for an UNIX Domain Socket address in GNUnet. More... | |
struct | UNIXMessage |
UNIX Message-Packet header. More... | |
struct | UNIXMessageWrapper |
Information we track for a message awaiting transmission. More... | |
struct | GNUNET_ATS_Session |
Session handle for connections. More... | |
struct | UNIX_Sock_Info |
Information we keep for each of our listen sockets. More... | |
struct | Plugin |
Handle for a plugin. More... | |
struct | LookupCtx |
Closure to lookup_queue_it(). More... | |
Macros | |
#define | RETRY 0 |
Return code we give on 'send' if we failed to send right now but it makes sense to retry later. More... | |
#define | PLUGIN_NAME "unix" |
Name of the plugin. More... | |
#define | HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
How long until we give up on transmitting the welcome message? More... | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "transport-unix", __VA_ARGS__) |
Enumerations | |
enum | UNIX_ADDRESS_OPTIONS { UNIX_OPTIONS_NONE = 0 , UNIX_OPTIONS_USE_ABSTRACT_SOCKETS = 1 } |
Options for UNIX Domain addresses. More... | |
Functions | |
static 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 const char * | unix_plugin_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 | unix_plugin_session_disconnect (void *cls, struct GNUNET_ATS_Session *session) |
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 | session_timeout (void *cls) |
Session was idle for too long, so disconnect it. More... | |
static void | reschedule_session_timeout (struct GNUNET_ATS_Session *session) |
Increment session timeout due to activity. More... | |
static struct sockaddr_un * | unix_address_to_sockaddr (const char *unixpath, socklen_t *sock_len) |
Convert unix path to a struct sockaddr_un * More... | |
static int | lookup_session_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Function called to find a session by address. More... | |
static struct GNUNET_ATS_Session * | lookup_session (struct Plugin *plugin, const struct GNUNET_HELLO_Address *address) |
Find an existing session by address. More... | |
static unsigned int | unix_plugin_query_keepalive_factor (void *cls) |
Function that is called to get the keepalive factor. More... | |
static ssize_t | unix_real_send (void *cls, struct GNUNET_NETWORK_Handle *send_handle, const struct GNUNET_PeerIdentity *target, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Absolute timeout, const struct UnixAddress *addr, size_t addrlen, size_t payload, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
Actually send out the message, assume we've got the address and send_handle squared away! More... | |
static enum GNUNET_NetworkType | unix_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) |
Function obtain the network type for a session. More... | |
static enum GNUNET_NetworkType | unix_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) |
Function obtain the network type for a session. More... | |
static struct GNUNET_ATS_Session * | unix_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 | unix_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 | unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *currhdr, const struct UnixAddress *ua, size_t ua_len) |
Demultiplexer for UNIX messages. More... | |
static void | unix_plugin_do_read (struct Plugin *plugin) |
Read from UNIX domain socket (it is ready). More... | |
static void | unix_plugin_do_write (struct Plugin *plugin) |
Write to UNIX domain socket (it is ready). More... | |
static void | unix_plugin_select_read (void *cls) |
We have been notified that our socket has something to read. More... | |
static void | unix_plugin_select_write (void *cls) |
We have been notified that our socket is ready to write. More... | |
static ssize_t | unix_plugin_send (void *cls, struct GNUNET_ATS_Session *session, 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 | unix_transport_server_start (void *cls) |
Create a slew of UNIX sockets. More... | |
static int | unix_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 | unix_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 | unix_plugin_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 | address_notification (void *cls) |
Notify transport service about address. More... | |
static int | get_session_delete_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Function called on sessions to disconnect. More... | |
static void | unix_plugin_peer_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) |
Disconnect from a remote node. 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 | unix_plugin_setup_monitor (void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls) |
Begin monitoring sessions of a plugin. More... | |
void * | libgnunet_plugin_transport_unix_init (void *cls) |
The exported method. More... | |
void * | libgnunet_plugin_transport_unix_done (void *cls) |
Shutdown the plugin. More... | |
Transport plugin using unix domain sockets (!) Clearly, can only be used locally on Unix/Linux hosts...
ONLY INTENDED FOR TESTING!!!
Definition in file plugin_transport_unix.c.
#define RETRY 0 |
Return code we give on 'send' if we failed to send right now but it makes sense to retry later.
(Note: we might want to move this to the plugin API!?).
Definition at line 44 of file plugin_transport_unix.c.
#define PLUGIN_NAME "unix" |
Name of the plugin.
Definition at line 49 of file plugin_transport_unix.c.
#define HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
How long until we give up on transmitting the welcome message?
Definition at line 71 of file plugin_transport_unix.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "transport-unix", __VA_ARGS__) |
Definition at line 74 of file plugin_transport_unix.c.
enum UNIX_ADDRESS_OPTIONS |
Options for UNIX Domain addresses.
Enumerator | |
---|---|
UNIX_OPTIONS_NONE | No special options. |
UNIX_OPTIONS_USE_ABSTRACT_SOCKETS | Linux abstract domain sockets should be used. |
Definition at line 54 of file plugin_transport_unix.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 333 of file plugin_transport_unix.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::bytes_in_queue, GNUNET_SYSERR, info, GNUNET_ATS_Session::msgs_in_queue, plugin, state, and GNUNET_ATS_Session::timeout.
Referenced by send_session_info_iter(), session_timeout(), unix_plugin_do_write(), unix_plugin_get_session(), unix_plugin_send(), and unix_plugin_session_disconnect().
|
static |
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 |
addrlen | length of the addr |
Definition at line 367 of file plugin_transport_unix.c.
References UnixAddress::addrlen, GNUNET_break, GNUNET_snprintf(), UnixAddress::options, and PLUGIN_NAME.
Referenced by libgnunet_plugin_transport_unix_init(), unix_demultiplexer(), unix_plugin_address_pretty_printer(), unix_plugin_get_session(), unix_plugin_send(), and unix_plugin_session_disconnect().
|
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 * |
session | session to close down |
Definition at line 425 of file plugin_transport_unix.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, GNUNET_ATS_Session::bytes_in_queue, UNIXMessageWrapper::cont, UNIXMessageWrapper::cont_cls, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_address_free, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_SS_DONE, GNUNET_YES, LOG, UNIXMessageWrapper::msg, GNUNET_ATS_Session::msgs_in_queue, UNIXMessageWrapper::msgsize, UNIXMessageWrapper::next, notify_session_monitor(), UNIXMessageWrapper::payload, plugin, UNIXMessageWrapper::session, GNUNET_ATS_Session::target, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, and unix_plugin_address_to_string().
Referenced by get_session_delete_it(), libgnunet_plugin_transport_unix_init(), and session_timeout().
|
static |
Session was idle for too long, so disconnect it.
cls | the struct GNUNET_ATS_Session * to disconnect |
Definition at line 490 of file plugin_transport_unix.c.
References GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 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(), GNUNET_ATS_Session::plugin, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, and unix_plugin_session_disconnect().
Referenced by unix_plugin_get_session().
|
static |
Increment session timeout due to activity.
We do not immediately notify the monitor here as that might generate excessive signalling.
session | session for which the timeout should be rescheduled |
Definition at line 526 of file plugin_transport_unix.c.
References GNUNET_assert, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_TIME_relative_to_absolute(), GNUNET_ATS_Session::timeout, and GNUNET_ATS_Session::timeout_task.
Referenced by unix_demultiplexer(), and unix_plugin_update_session_timeout().
|
static |
Convert unix path to a struct sockaddr_un *
unixpath | path to convert | |
[out] | sock_len | set to the length of the address |
Definition at line 542 of file plugin_transport_unix.c.
References GNUNET_assert, GNUNET_memcpy, and GNUNET_new.
Referenced by unix_plugin_get_network(), and unix_transport_server_start().
|
static |
Function called to find a session by address.
cls | the struct LookupCtx * |
key | peer we are looking for (unused) |
value | a session |
Definition at line 590 of file plugin_transport_unix.c.
References GNUNET_ATS_Session::address, LookupCtx::address, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, LookupCtx::res, and value.
Referenced by lookup_session().
|
static |
Find an existing session by address.
plugin | the plugin |
address | the address to find |
Definition at line 614 of file plugin_transport_unix.c.
References address, LookupCtx::address, GNUNET_CONTAINER_multipeermap_get_multiple(), lookup_session_it(), plugin, and LookupCtx::res.
Referenced by unix_demultiplexer(), and unix_plugin_get_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 638 of file plugin_transport_unix.c.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Actually send out the message, assume we've got the address and send_handle squared away!
cls | closure |
send_handle | which handle to send message on |
target | who should receive this message (ignored by UNIX) |
msgbuf | one or more GNUNET_MessageHeader(s) strung together |
msgbuf_size | the size of the msgbuf to send |
priority | how important is the message (ignored by UNIX) |
timeout | when should we time out (give up) if we can not transmit? |
addr | the addr to send the message to, needs to be a sockaddr for us |
addrlen | the len of addr |
payload | bytes payload to send |
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...) |
cont_cls | closure for cont |
Definition at line 666 of file plugin_transport_unix.c.
Referenced by unix_plugin_do_write().
|
static |
Function obtain the network type for a session.
cls | closure ('struct Plugin*') |
session | the session |
Definition at line 666 of file plugin_transport_unix.c.
References GNUNET_a2s(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror, GNUNET_NETWORK_socket_getsockopt(), GNUNET_NETWORK_socket_sendto(), GNUNET_NETWORK_socket_setsockopt(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, len, LOG, UnixAddress::options, plugin, RETRY, size, unix_address_to_sockaddr(), and UNIX_OPTIONS_USE_ABSTRACT_SOCKETS.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Function obtain the network type for a session.
cls | closure (struct Plugin * ) |
address | the address |
Definition at line 666 of file plugin_transport_unix.c.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Creates a new outbound session the transport service will use to send data to the peer.
cls | the plugin |
address | the address |
Definition at line 819 of file plugin_transport_unix.c.
References address, GNUNET_ATS_Session::address, UnixAddress::addrlen, GNUNET_break, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_copy(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_set(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, LOG, lookup_session(), notify_session_monitor(), UnixAddress::options, plugin, GNUNET_ATS_Session::plugin, session_timeout(), GNUNET_ATS_Session::target, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, UNIX_OPTIONS_USE_ABSTRACT_SOCKETS, and unix_plugin_address_to_string().
Referenced by libgnunet_plugin_transport_unix_init(), and unix_demultiplexer().
|
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 916 of file plugin_transport_unix.c.
References GNUNET_break, GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_OK, plugin, reschedule_session_timeout(), and GNUNET_ATS_Session::target.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Demultiplexer for UNIX messages.
plugin | the main plugin for this transport |
sender | from which peer the message was received |
currhdr | pointer to the header of the message |
ua | address to look for |
ua_len | length of the address ua |
Definition at line 944 of file plugin_transport_unix.c.
References address, GNUNET_ATS_Session::address, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_NO, GNUNET_NT_LOOPBACK, GNUNET_STATISTICS_update(), LOG, lookup_session(), plugin, PLUGIN_NAME, reschedule_session_timeout(), GNUNET_MessageHeader::size, unix_plugin_address_to_string(), and unix_plugin_get_session().
Referenced by unix_plugin_do_read().
|
static |
Read from UNIX domain socket (it is ready).
plugin | the plugin |
Definition at line 994 of file plugin_transport_unix.c.
References UnixAddress::addrlen, buf, csize, GNUNET_ALIGN, GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_socket_recvfrom(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, LOG, msg, UnixAddress::options, plugin, ret, UNIXMessage::sender, GNUNET_MessageHeader::size, unix_demultiplexer(), UNIX_OPTIONS_NONE, and UNIX_OPTIONS_USE_ABSTRACT_SOCKETS.
Referenced by unix_plugin_select_read().
|
static |
Write to UNIX domain socket (it is ready).
plugin | handle to the plugin |
Definition at line 1085 of file plugin_transport_unix.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, GNUNET_ATS_Session::bytes_in_queue, UNIXMessageWrapper::cont, UNIXMessageWrapper::cont_cls, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, LOG, UNIXMessageWrapper::msg, GNUNET_ATS_Session::msgs_in_queue, UNIXMessageWrapper::msgsize, notify_session_monitor(), UNIXMessageWrapper::payload, plugin, UNIXMessageWrapper::priority, GNUNET_TIME_Relative::rel_value_us, RETRY, UNIXMessageWrapper::session, GNUNET_ATS_Session::target, UNIXMessageWrapper::timeout, and unix_real_send().
Referenced by unix_plugin_select_write().
|
static |
We have been notified that our socket has something to read.
Then reschedule this function to be called again once more is available.
cls | the plugin handle |
Definition at line 1207 of file plugin_transport_unix.c.
References GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_READ_READY, GNUNET_TIME_UNIT_FOREVER_REL, plugin, GNUNET_SCHEDULER_TaskContext::reason, tc, and unix_plugin_do_read().
Referenced by unix_transport_server_start().
|
static |
We have been notified that our socket is ready to write.
Then reschedule this function to be called again once more is available.
cls | the plugin handle |
Definition at line 1231 of file plugin_transport_unix.c.
References GNUNET_SCHEDULER_add_write_net(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_WRITE_READY, GNUNET_TIME_UNIT_FOREVER_REL, plugin, GNUNET_SCHEDULER_TaskContext::reason, tc, and unix_plugin_do_write().
Referenced by unix_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 |
session | 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 1278 of file plugin_transport_unix.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, GNUNET_ATS_Session::bytes_in_queue, UNIXMessageWrapper::cont, UNIXMessageWrapper::cont_cls, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_write_net(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_SS_UPDATE, UNIXMessage::header, LOG, UNIXMessageWrapper::msg, GNUNET_ATS_Session::msgs_in_queue, UNIXMessageWrapper::msgsize, notify_session_monitor(), UNIXMessageWrapper::payload, plugin, UNIXMessageWrapper::priority, UNIXMessage::sender, UNIXMessageWrapper::session, GNUNET_MessageHeader::size, GNUNET_ATS_Session::target, UNIXMessageWrapper::timeout, GNUNET_MessageHeader::type, unix_plugin_address_to_string(), and unix_plugin_select_write().
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Create a slew of UNIX sockets.
If possible, use IPv6 and IPv4.
cls | closure for server start, should be a struct Plugin * |
Definition at line 1358 of file plugin_transport_unix.c.
References _, GNUNET_DISK_directory_create_for_file(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, LOG, plugin, unix_address_to_sockaddr(), and unix_plugin_select_read().
Referenced by libgnunet_plugin_transport_unix_init().
|
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 the address |
addrlen | length of addr |
Definition at line 1430 of file plugin_transport_unix.c.
References UnixAddress::addrlen, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, and plugin.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Convert the transports address to a nice, human-readable format.
cls | closure |
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 |
addrlen | length of the addr |
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 1477 of file plugin_transport_unix.c.
References UnixAddress::addrlen, GNUNET_OK, GNUNET_SYSERR, ret, and unix_plugin_address_to_string().
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Function called to convert a string address to a binary address.
cls | closure (struct Plugin * ) |
addr | string address |
addrlen | length of the addr (strlen(addr) + '\0') |
buf | location to store the buffer If the function returns GNUNET_SYSERR, its contents are undefined. |
added | length of created address |
Definition at line 1510 of file plugin_transport_unix.c.
References address, UnixAddress::addrlen, GNUNET_break, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, options, UnixAddress::options, plugin, and PLUGIN_NAME.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Notify transport service about address.
cls | the plugin |
Definition at line 1589 of file plugin_transport_unix.c.
References address, UnixAddress::addrlen, GNUNET_free, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_malloc, GNUNET_memcpy, GNUNET_YES, len, UnixAddress::options, plugin, and PLUGIN_NAME.
Referenced by libgnunet_plugin_transport_unix_init().
|
static |
Function called on sessions to disconnect.
cls | the plugin |
key | peer identity (unused) |
value | the struct GNUNET_ATS_Session * to disconnect |
Definition at line 1627 of file plugin_transport_unix.c.
References GNUNET_YES, plugin, unix_plugin_session_disconnect(), and value.
Referenced by libgnunet_plugin_transport_unix_done(), and unix_plugin_peer_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 1647 of file plugin_transport_unix.c.
References get_session_delete_it(), GNUNET_CONTAINER_multipeermap_get_multiple(), and plugin.
Referenced by libgnunet_plugin_transport_unix_init().
|
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 1669 of file plugin_transport_unix.c.
References GNUNET_OK, GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, notify_session_monitor(), plugin, and value.
Referenced by unix_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 1695 of file plugin_transport_unix.c.
References GNUNET_CONTAINER_multipeermap_iterate(), plugin, send_session_info_iter(), Plugin::sic, and Plugin::sic_cls.
Referenced by libgnunet_plugin_transport_unix_init().
void* libgnunet_plugin_transport_unix_init | ( | void * | cls | ) |
The exported method.
Initializes the plugin and returns a struct with the callbacks.
cls | the plugin's execution environment |
Definition at line 1722 of file plugin_transport_unix.c.
References _, address_notification(), Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_TRANSPORT_PluginEnvironment::cls, env, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_config_missing(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_YES, LOG, plugin, UNIX_OPTIONS_NONE, UNIX_OPTIONS_USE_ABSTRACT_SOCKETS, unix_plugin_address_pretty_printer(), unix_plugin_address_to_string(), unix_plugin_check_address(), unix_plugin_get_network(), unix_plugin_get_network_for_address(), unix_plugin_get_session(), unix_plugin_peer_disconnect(), unix_plugin_query_keepalive_factor(), unix_plugin_send(), unix_plugin_session_disconnect(), unix_plugin_setup_monitor(), unix_plugin_string_to_address(), unix_plugin_update_session_timeout(), and unix_transport_server_start().
void* libgnunet_plugin_transport_unix_done | ( | void * | cls | ) |
Shutdown the plugin.
cls | the plugin API returned from the initialization function |
Definition at line 1806 of file plugin_transport_unix.c.
References address, UnixAddress::addrlen, Plugin::api, GNUNET_ATS_Session::bytes_in_queue, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::cls, UNIXMessageWrapper::cont, UNIXMessageWrapper::cont_cls, get_session_delete_it(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_socket_close(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, len, UNIXMessageWrapper::msg, GNUNET_ATS_Session::msgs_in_queue, UNIXMessageWrapper::msgsize, UnixAddress::options, UNIXMessageWrapper::payload, plugin, PLUGIN_NAME, UNIXMessageWrapper::session, and GNUNET_ATS_Session::target.