Secure Communication with other peers. More...
Data Structures | |
struct | PeerConnectCls |
Closure used for the peer_connect_task. More... | |
struct | QueuedMessage |
struct | Connection |
Used to keep track of context of peer. More... | |
struct | GNUNET_CORE_UNDERLAY_DUMMY_Handle |
Opaque handle to the service. More... | |
Macros | |
#define | GNUNET_CORE_UNDERLAY_DUMMY_VERSION 0x00000000 |
Version number of the core underlay dummy. More... | |
Typedefs | |
typedef void *(* | GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect) (void *cls, uint32_t num_addresses, const char *addresses[static num_addresses], struct GNUNET_MQ_Handle *mq, const struct GNUNET_PeerIdentity *peer_id) |
Function called to notify core underlay dummy users that another peer connected to us. More... | |
typedef void(* | GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect) (void *cls, void *handler_cls) |
Function called to notify core underlay dummy users that another peer disconnected from us. More... | |
typedef void(* | GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange) (void *cls, uint32_t num_addresses, const char *addresses[static num_addresses]) |
Function called to notify core of the now available addresses. More... | |
Enumerations | |
enum | ConnectionStatus { CONNECTION_INITIALIZING , CONNECTION_INITIALIZING_SEND , CONNECTION_INITIALIZING_RECV , CONNECTION_LIVE , CONNECTION_DESTROY } |
Functions | |
static const char * | status2string (enum ConnectionStatus status) |
static void | do_read (void *cls) |
Callback scheduled to run when there is something to read from the socket. More... | |
static void | connection_destroy (struct Connection *connection) |
Destroy a connection. More... | |
static void | set_handlers_closure (struct GNUNET_MQ_MessageHandler *handlers, void *handlers_cls) |
Set the closures for mq handlers. More... | |
static void | do_handle_message (void *cls) |
static void | check_for_messages (struct Connection *connection) |
static void | do_notify_connect (void *cls) |
Notify the api caller about a new connection. More... | |
static void | try_notify_connect (struct Connection *connection) |
static void | cancle_initiating_connections (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, struct Connection *connection) |
static void | write_cb (void *cls) |
Callback scheduled to run once the socket is ready for writing. More... | |
static void | send_init (struct Connection *connection) |
static void | mq_send_impl (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state) |
Callback called from the MQ to send a message over a socket. More... | |
static void | mq_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Callback to destroy the message queue. More... | |
static void | mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Callback to cancel sending a message. More... | |
static void | mq_error_handler_impl (void *cls, enum GNUNET_MQ_Error error) |
Handle mq errors. More... | |
static void | do_accept (void *cls) |
Accept a connection on the dummy's socket. More... | |
static void | do_connect_to_peer (void *cls) |
Connect to another peer. More... | |
static void | do_notify_address_change (void *cls) |
Notify core about address change. More... | |
static void | try_connect (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, const char *address) |
static enum GNUNET_GenericReturnValue | discovered_socket_cb (void *cls, const char *filename) |
Handle the discovery of a certain socket. More... | |
static void | do_discover_peers (void *cls) |
Discover sockets of other peers. More... | |
static enum GNUNET_GenericReturnValue | try_open_listening_socket (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *h, char *sock_name) |
static void | do_open_listening_socket (void *cls, uint64_t sock_name_ctr_start) |
Opens UNIX domain socket. More... | |
static void | do_close_listening_socket (void *cls) |
static void | do_change_address (void *cls) |
struct GNUNET_CORE_UNDERLAY_DUMMY_Handle * | GNUNET_CORE_UNDERLAY_DUMMY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect nc, GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect nd, GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange na) |
Connect to the core underlay dummy service. More... | |
void | GNUNET_CORE_UNDERLAY_DUMMY_disconnect (struct GNUNET_CORE_UNDERLAY_DUMMY_Handle *handle) |
Disconnect from the core underlay dummy service. More... | |
Secure Communication with other peers.
#define GNUNET_CORE_UNDERLAY_DUMMY_VERSION 0x00000000 |
Version number of the core underlay dummy.
Definition at line 57 of file gnunet_core_underlay_dummy.h.
typedef void *(* GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect) (void *cls, uint32_t num_addresses, const char *addresses[static num_addresses], struct GNUNET_MQ_Handle *mq, const struct GNUNET_PeerIdentity *peer_id) |
Function called to notify core underlay dummy users that another peer connected to us.
If the underlay knows the peer id, it should include it in the addresses
cls | closure |
num_addresses | number of addresses of the connecting peer |
addresses | address URIs of the connecting peer |
mq | message queue to use to transmit to peer |
peer_id | (optional, may be NULL) the peer id of the connecting peer |
Definition at line 79 of file gnunet_core_underlay_dummy.h.
typedef void(* GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect) (void *cls, void *handler_cls) |
Function called to notify core underlay dummy users that another peer disconnected from us.
The message queue that was given to the connect notification will be destroyed and must not be used henceforth.
cls | closure from GNUNET_CORE_UNDERLAY_DUMMY_connect |
handlers_cls | closure of the handlers, was returned from the connect notification callback |
Definition at line 97 of file gnunet_core_underlay_dummy.h.
typedef void(* GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange) (void *cls, uint32_t num_addresses, const char *addresses[static num_addresses]) |
Function called to notify core of the now available addresses.
Core will update its peer identity accordingly.
cls | closure from GNUNET_CORE_UNDERLAY_DUMMY_connect |
num_addresses | number of addresses now available to this peer |
addresses | current addresses of this peer |
Definition at line 110 of file gnunet_core_underlay_dummy.h.
enum ConnectionStatus |
Enumerator | |
---|---|
CONNECTION_INITIALIZING | |
CONNECTION_INITIALIZING_SEND | |
CONNECTION_INITIALIZING_RECV | |
CONNECTION_LIVE | |
CONNECTION_DESTROY |
Definition at line 104 of file gnunet_core_underlay_dummy.c.
|
static |
Definition at line 315 of file gnunet_core_underlay_dummy.c.
References CONNECTION_DESTROY, CONNECTION_INITIALIZING, CONNECTION_INITIALIZING_RECV, CONNECTION_INITIALIZING_SEND, CONNECTION_LIVE, and status.
Referenced by cancle_initiating_connections(), do_read(), try_connect(), and write_cb().
|
static |
Callback scheduled to run when there is something to read from the socket.
Reads the data from the socket and passes it to the message queue.
cls | Closure: Information for this socket |
Definition at line 583 of file gnunet_core_underlay_dummy.c.
References cancle_initiating_connections(), Connection::client_ready_to_receive, CONNECTION_DESTROY, CONNECTION_INITIALIZING, CONNECTION_INITIALIZING_RECV, CONNECTION_INITIALIZING_SEND, CONNECTION_LIVE, GNUNET_CORE_UNDERLAY_DUMMY_Handle::connections_head, do_read(), GNUNET_ALIGN, GNUNET_assert, GNUNET_break_op, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_malloc, GNUNET_memcpy, GNUNET_MQ_destroy(), GNUNET_MQ_handle_message(), GNUNET_NETWORK_socket_recv(), GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, Connection::handle, Connection::handlers, id, LOG, Connection::mq, msg, QueuedMessage::msg, Connection::next, Connection::notify_connect_called, Connection::peer_addr, Connection::queued_recv_messages_head, Connection::queued_recv_messages_tail, Connection::recv_task, ret, GNUNET_MessageHeader::size, Connection::sock, Connection::status, status2string(), try_notify_connect(), and GNUNET_MessageHeader::type.
Referenced by check_for_messages(), do_accept(), do_connect_to_peer(), and do_read().
|
static |
Destroy a connection.
cancel all tasks, remove its memory, close sockets, remove it from the DLL, ...
connection | The Connection to destroy |
Definition at line 362 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, Connection::cls_mq, GNUNET_CORE_UNDERLAY_DUMMY_Handle::connections_head, GNUNET_CORE_UNDERLAY_DUMMY_Handle::connections_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, Connection::handle, Connection::handle_message_task, Connection::handlers, LOG, Connection::notify_connect_called, Connection::notify_connect_task, GNUNET_CORE_UNDERLAY_DUMMY_Handle::notify_disconnect, Connection::peer_addr, Connection::recv_task, Connection::sock, and Connection::write_task.
Referenced by GCO_init(), and mq_destroy_impl().
|
static |
Set the closures for mq handlers.
This is a utility function that sets the closures of the given mq handlers to a given closure
handlers | the list of handlers |
handlers_cls | the new closure for the handlers |
Definition at line 425 of file gnunet_core_underlay_dummy.c.
References GNUNET_assert, and handlers.
Referenced by do_notify_connect().
|
static |
Definition at line 436 of file gnunet_core_underlay_dummy.c.
References Connection::client_ready_to_receive, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_handle_message(), GNUNET_NO, Connection::handle_message_task, Connection::handlers, msg, QueuedMessage::msg, Connection::queued_recv_messages_head, and Connection::queued_recv_messages_tail.
Referenced by check_for_messages().
|
static |
Definition at line 459 of file gnunet_core_underlay_dummy.c.
References do_handle_message(), do_read(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, Connection::handle_message_task, LOG, Connection::queued_recv_messages_head, Connection::recv_task, and Connection::sock.
Referenced by do_notify_connect().
|
static |
Notify the api caller about a new connection.
This connection could either be initiated by us or the connecting peer. The function is supposed to be called through the scheduler.
cls |
Definition at line 489 of file gnunet_core_underlay_dummy.c.
References check_for_messages(), Connection::client_ready_to_receive, Connection::cls_mq, GNUNET_MQ_copy_handlers(), GNUNET_YES, h, Connection::handle, Connection::handlers, Connection::mq, Connection::notify_connect_called, Connection::notify_connect_task, Connection::peer_addr, and set_handlers_closure().
Referenced by try_notify_connect().
|
static |
Definition at line 527 of file gnunet_core_underlay_dummy.c.
References CONNECTION_LIVE, do_notify_connect(), GNUNET_SCHEDULER_add_now(), Connection::handle, GNUNET_CORE_UNDERLAY_DUMMY_Handle::notify_connect, Connection::notify_connect_task, Connection::peer_addr, and Connection::status.
Referenced by do_read(), and write_cb().
|
static |
Definition at line 541 of file gnunet_core_underlay_dummy.c.
References CONNECTION_INITIALIZING, CONNECTION_INITIALIZING_RECV, CONNECTION_INITIALIZING_SEND, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_destroy(), h, LOG, Connection::next, Connection::peer_addr, and status2string().
Referenced by do_read(), and write_cb().
|
static |
Callback scheduled to run once the socket is ready for writing.
Writes the message to the socket.
cls | Closure: The handle of the underlay dummy |
Definition at line 828 of file gnunet_core_underlay_dummy.c.
References cancle_initiating_connections(), CONNECTION_DESTROY, CONNECTION_INITIALIZING, CONNECTION_INITIALIZING_RECV, CONNECTION_INITIALIZING_SEND, CONNECTION_LIVE, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MQ_destroy(), GNUNET_MQ_impl_send_continue(), GNUNET_NETWORK_socket_send(), GNUNET_ntohll(), GNUNET_SCHEDULER_add_write_net(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, Connection::handle, id, LOG, Connection::message_to_send, Connection::mq, Connection::peer_addr, GNUNET_MessageHeader::size, Connection::sock, Connection::status, status2string(), try_notify_connect(), write_cb(), and Connection::write_task.
Referenced by mq_send_impl(), and write_cb().
|
static |
Definition at line 922 of file gnunet_core_underlay_dummy.c.
References env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MQ_msg_header_extra, GNUNET_MQ_send(), Connection::handle, LOG, Connection::mq, msg, GNUNET_CORE_UNDERLAY_DUMMY_Handle::sock_name, and strnlen().
Referenced by do_accept(), and do_connect_to_peer().
|
static |
Callback called from the MQ to send a message over a socket.
Schedules the sending of the message once the socket is ready.
mq | The message queue |
msg | The message to send |
impl_state | The handle of the underlay dummy |
Definition at line 950 of file gnunet_core_underlay_dummy.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ntohll(), GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_UNIT_FOREVER_REL, id, LOG, Connection::message_to_send, msg, Connection::sock, write_cb(), and Connection::write_task.
Referenced by do_accept(), and do_connect_to_peer().
|
static |
Callback to destroy the message queue.
mq | message queue to destroy |
impl_state | The handle of the underlay dummy |
Definition at line 994 of file gnunet_core_underlay_dummy.c.
References connection_destroy(), GNUNET_ERROR_TYPE_DEBUG, and LOG.
Referenced by do_accept(), and do_connect_to_peer().
|
static |
Callback to cancel sending a message.
mq | The message queue the message was supposed to be sent over. |
impl_state | The handle of the underlay dummy |
Definition at line 1010 of file gnunet_core_underlay_dummy.c.
References GNUNET_SCHEDULER_cancel(), and Connection::write_task.
Referenced by do_accept(), and do_connect_to_peer().
|
static |
Handle mq errors.
This is currently a stub that only logs.
cls | closure is unused |
error | the kind of error |
Definition at line 1031 of file gnunet_core_underlay_dummy.c.
References GNUNET_ERROR_TYPE_ERROR, and LOG.
Referenced by do_accept(), and do_connect_to_peer().
|
static |
Accept a connection on the dummy's socket.
cls | the hanlde to the dummy passed as closure |
Definition at line 1045 of file gnunet_core_underlay_dummy.c.
References Connection::client_ready_to_receive, GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, Connection::cls_mq, CONNECTION_INITIALIZING, do_accept(), do_read(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_MQ_queue_for_callbacks(), GNUNET_NETWORK_socket_accept(), GNUNET_NETWORK_socket_set_blocking(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, h, Connection::handle, LOG, Connection::mq, mq_cancel_impl(), mq_destroy_impl(), mq_error_handler_impl(), mq_send_impl(), Connection::notify_connect_called, Connection::peer_addr, Connection::recv_task, send_init(), Connection::sock, and Connection::status.
Referenced by do_accept(), and do_open_listening_socket().
|
static |
Connect to another peer.
This function is scheduled and pays attention that it's not called unnecessarily.
cls |
Definition at line 1118 of file gnunet_core_underlay_dummy.c.
References Connection::client_ready_to_receive, Connection::cls_mq, CONNECTION_INITIALIZING, do_read(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_memcpy, GNUNET_MQ_queue_for_callbacks(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_connect(), GNUNET_NETWORK_socket_create(), GNUNET_NETWORK_socket_set_blocking(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, h, PeerConnectCls::h, Connection::handle, LOG, Connection::mq, mq_cancel_impl(), mq_destroy_impl(), mq_error_handler_impl(), mq_send_impl(), Connection::notify_connect_called, Connection::peer_addr, GNUNET_CORE_UNDERLAY_DUMMY_Handle::peer_connect_cls_head, GNUNET_CORE_UNDERLAY_DUMMY_Handle::peer_connect_cls_tail, PeerConnectCls::peer_connect_task, Connection::recv_task, send_init(), Connection::sock, PeerConnectCls::sock_name, and Connection::status.
Referenced by try_connect().
|
static |
Notify core about address change.
This is in an extra function so the callback gets called after the GNUNET_CORE_UNDERLAY_DUMMY_connect() finishes.
cls | Closure: The handle of the dummy underlay. |
Definition at line 1205 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, and h.
Referenced by do_open_listening_socket().
|
static |
Check whether we are already connected to this peer
This is limited as we don't always have the socket name of the other peer
Definition at line 1217 of file gnunet_core_underlay_dummy.c.
References address, CONNECTION_LIVE, do_connect_to_peer(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_strdup, h, PeerConnectCls::h, LOG, PeerConnectCls::peer_connect_task, PeerConnectCls::sock_name, and status2string().
Referenced by discovered_socket_cb().
|
static |
Handle the discovery of a certain socket.
This is called from within the discovery of file names with the correct pattern. It checks whether we are already connected to this socket, are waiting for a reply, it's our own socket. Issue a connection if the conditions are given.
cls | handle to the dummy service |
filename | the discovered filename |
Definition at line 1295 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, filename, GNUNET_OK, h, and try_connect().
Referenced by do_discover_peers().
|
static |
Discover sockets of other peers.
Sockets with a certain file name pattern are treated as candidates.
cls |
Definition at line 1314 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, discovered_socket_cb(), do_discover_peers(), GNUNET_DISK_glob(), GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, h, LOG, and ret.
Referenced by do_discover_peers(), and do_open_listening_socket().
|
static |
Definition at line 1335 of file gnunet_core_underlay_dummy.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_memcpy, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, h, LOG, and ret.
Referenced by do_open_listening_socket().
|
static |
Opens UNIX domain socket.
It start trying with a default name and successively increases a number within it, when it encounters already used sockets.
cls | Closure: The handle of the dummy underlay. |
sock_name_ctr | TODO Append to the socket name to avoid collisions TODO |
Definition at line 1397 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, do_accept(), do_discover_peers(), do_notify_address_change(), GNUNET_asprintf(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_listen(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, h, LOG, ret, GNUNET_CORE_UNDERLAY_DUMMY_Handle::sock_name, and try_open_listening_socket().
Referenced by GNUNET_CORE_UNDERLAY_DUMMY_connect().
|
static |
Definition at line 1454 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, CONNECTION_DESTROY, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NETWORK_socket_close(), GNUNET_SCHEDULER_cancel(), h, LOG, PeerConnectCls::next, and Connection::next.
Referenced by GNUNET_CORE_UNDERLAY_DUMMY_disconnect().
|
static |
Definition at line 1513 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, do_change_address(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, and h.
Referenced by do_change_address().
struct GNUNET_CORE_UNDERLAY_DUMMY_Handle * GNUNET_CORE_UNDERLAY_DUMMY_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const struct GNUNET_MQ_MessageHandler * | handlers, | ||
void * | cls, | ||
GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect | nc, | ||
GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect | nd, | ||
GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange | na | ||
) |
Connect to the core underlay dummy service.
Note that the connection may complete (or fail) asynchronously.
cfg | configuration to use |
handlers | array of message handlers or NULL; note that the closures provided will be ignored and replaced with the respective return value from nc |
cls | closure for the nc, nd and na callbacks |
nc | function to call on connect events, or NULL. Returns the closure for message handlers for this opened connection. |
nd | function to call on disconnect events, or NULL |
na | function to call on address changes, or NULL |
Note that the connection may complete (or fail) asynchronously.
cfg | configuration to use |
handlers | array of message handlers or NULL; note that the closures provided will be ignored and replaced with the respective return value from nc |
cls | closure for the nc, nd and na callbacks |
nc | function to call on connect events, or NULL |
nd | function to call on disconnect events, or NULL |
na | function to call on address changes, or NULL |
Definition at line 1540 of file gnunet_core_underlay_dummy.c.
References GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls, do_open_listening_socket(), GNUNET_ERROR_TYPE_INFO, GNUNET_malloc, GNUNET_MQ_copy_handlers(), h, handlers, LOG, and nc.
void GNUNET_CORE_UNDERLAY_DUMMY_disconnect | ( | struct GNUNET_CORE_UNDERLAY_DUMMY_Handle * | handle | ) |
Disconnect from the core underlay dummy service.
handle | handle returned from connect |
Definition at line 1576 of file gnunet_core_underlay_dummy.c.
References do_close_listening_socket(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_SCHEDULER_cancel(), handle, and LOG.
struct PeerConnectCls* PeerConnectCls::next |
Linked list next.
Definition at line 71 of file gnunet_core_underlay_dummy.c.
Referenced by do_close_listening_socket().
struct PeerConnectCls* PeerConnectCls::prev |
Linked list previous.
Definition at line 76 of file gnunet_core_underlay_dummy.c.
struct GNUNET_CORE_UNDERLAY_DUMMY_Handle* PeerConnectCls::h |
The handle for the service.
Definition at line 81 of file gnunet_core_underlay_dummy.c.
Referenced by do_connect_to_peer(), and try_connect().
char* PeerConnectCls::sock_name |
The file name to connect to.
Definition at line 86 of file gnunet_core_underlay_dummy.c.
Referenced by do_connect_to_peer(), and try_connect().
struct GNUNET_SCHEDULER_Task* PeerConnectCls::peer_connect_task |
Task to connect to another peer.
Definition at line 91 of file gnunet_core_underlay_dummy.c.
Referenced by do_connect_to_peer(), and try_connect().
struct QueuedMessage* QueuedMessage::next |
Definition at line 97 of file gnunet_core_underlay_dummy.c.
struct QueuedMessage* QueuedMessage::prev |
Definition at line 98 of file gnunet_core_underlay_dummy.c.
struct GNUNET_MessageHeader* QueuedMessage::msg |
Definition at line 100 of file gnunet_core_underlay_dummy.c.
Referenced by do_handle_message(), and do_read().
struct Connection* Connection::next |
Linked list next.
Definition at line 131 of file gnunet_core_underlay_dummy.c.
Referenced by cancle_initiating_connections(), do_close_listening_socket(), and do_read().
struct Connection* Connection::prev |
Linked list previous.
Definition at line 136 of file gnunet_core_underlay_dummy.c.
struct GNUNET_MQ_Handle* Connection::mq |
Message queue towards the connected peer.
Definition at line 141 of file gnunet_core_underlay_dummy.c.
Referenced by do_accept(), do_connect_to_peer(), do_notify_connect(), do_read(), send_init(), and write_cb().
struct GNUNET_MQ_MessageHandler* Connection::handlers |
Handlers for mq.
Definition at line 146 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), do_handle_message(), do_notify_connect(), and do_read().
void* Connection::cls_mq |
Closure for the mq towards the client.
Connection-specific, given to handlers and disconnect_cb/notify_disconnect
Definition at line 153 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), do_accept(), do_connect_to_peer(), and do_notify_connect().
struct GNUNET_NETWORK_Handle* Connection::sock |
Socket for the connected peer.
Definition at line 158 of file gnunet_core_underlay_dummy.c.
Referenced by check_for_messages(), connection_destroy(), do_accept(), do_connect_to_peer(), do_read(), mq_send_impl(), and write_cb().
char* Connection::peer_addr |
Address of the connected peer.
Definition at line 163 of file gnunet_core_underlay_dummy.c.
Referenced by cancle_initiating_connections(), connection_destroy(), do_accept(), do_connect_to_peer(), do_notify_connect(), do_read(), try_notify_connect(), and write_cb().
struct GNUNET_SCHEDULER_Task* Connection::recv_task |
Task waiting for incoming messages.
Definition at line 168 of file gnunet_core_underlay_dummy.c.
Referenced by check_for_messages(), connection_destroy(), do_accept(), do_connect_to_peer(), and do_read().
struct GNUNET_SCHEDULER_Task* Connection::write_task |
Task waiting until the socket becomes ready to be written to.
Definition at line 173 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), mq_cancel_impl(), mq_send_impl(), and write_cb().
struct GNUNET_SCHEDULER_Task* Connection::notify_connect_task |
Task to notify the client about an open connection.
Definition at line 178 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), do_notify_connect(), and try_notify_connect().
struct GNUNET_SCHEDULER_Task* Connection::handle_message_task |
Task to pass the message to the client's handlers.
Definition at line 183 of file gnunet_core_underlay_dummy.c.
Referenced by check_for_messages(), connection_destroy(), and do_handle_message().
enum GNUNET_GenericReturnValue Connection::notify_connect_called |
Whether notify_connect was called already It is used to check whether to call notify_disconnect or not.
Definition at line 189 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), do_accept(), do_connect_to_peer(), do_notify_connect(), and do_read().
enum GNUNET_GenericReturnValue Connection::client_ready_to_receive |
Indicating whether the client is ready to receive new messages.
This is set to GNUNET_YES after the client called #GNUNET_CORE_UNDERLAY_DUMMY_receive_continue() and to GNUNET_NO after GNUNET_MQ_handle_message() was called. TODO might be a duplicate to handle_message_task being NULL or not
Definition at line 198 of file gnunet_core_underlay_dummy.c.
Referenced by do_accept(), do_connect_to_peer(), do_handle_message(), do_notify_connect(), and do_read().
enum ConnectionStatus Connection::status |
Status of the connection: Initializing, Live, Destroy.
Definition at line 203 of file gnunet_core_underlay_dummy.c.
Referenced by do_accept(), do_connect_to_peer(), do_read(), try_notify_connect(), and write_cb().
const struct GNUNET_MessageHeader* Connection::message_to_send |
Message about to be sent, given by the message queue, waiting for the socket to be ready.
Definition at line 209 of file gnunet_core_underlay_dummy.c.
Referenced by mq_send_impl(), and write_cb().
struct QueuedMessage* Connection::queued_recv_messages_head |
Queued received messages in a DLL TODO implement cleanup TODO replace with a performant queue.
Definition at line 216 of file gnunet_core_underlay_dummy.c.
Referenced by check_for_messages(), do_handle_message(), and do_read().
struct QueuedMessage* Connection::queued_recv_messages_tail |
Definition at line 217 of file gnunet_core_underlay_dummy.c.
Referenced by do_handle_message(), and do_read().
struct GNUNET_CORE_UNDERLAY_DUMMY_Handle* Connection::handle |
Handle to the service.
Definition at line 222 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), do_accept(), do_connect_to_peer(), do_notify_connect(), do_read(), send_init(), try_notify_connect(), and write_cb().
GNUNET_CORE_UNDERLAY_DUMMY_NotifyConnect GNUNET_CORE_UNDERLAY_DUMMY_Handle::notify_connect |
Callback (from/to client) to call when another peer connects.
Definition at line 234 of file gnunet_core_underlay_dummy.c.
Referenced by try_notify_connect().
GNUNET_CORE_UNDERLAY_DUMMY_NotifyDisconnect GNUNET_CORE_UNDERLAY_DUMMY_Handle::notify_disconnect |
Callback (from/to client) to call when a peer disconnects.
Definition at line 239 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy().
GNUNET_CORE_UNDERLAY_DUMMY_NotifyAddressChange GNUNET_CORE_UNDERLAY_DUMMY_Handle::notify_address_change |
Callback (from/to client) to call when our address changes.
Definition at line 244 of file gnunet_core_underlay_dummy.c.
struct GNUNET_MQ_MessageHandler* GNUNET_CORE_UNDERLAY_DUMMY_Handle::handlers |
Array of message handlers given by the client.
Don't use for handling of messages - this discards the per-mq-cls;
Definition at line 250 of file gnunet_core_underlay_dummy.c.
void* GNUNET_CORE_UNDERLAY_DUMMY_Handle::cls |
Closure for handlers given by the client - connection-independant (notify_connect, notify_disconnect, notify_address_change) TODO what's the doxygen way of linking to other members of this struct?
Definition at line 257 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), discovered_socket_cb(), do_accept(), do_change_address(), do_close_listening_socket(), do_discover_peers(), do_notify_address_change(), do_open_listening_socket(), and GNUNET_CORE_UNDERLAY_DUMMY_connect().
char* GNUNET_CORE_UNDERLAY_DUMMY_Handle::sock_name |
Name of the listening socket.
Definition at line 262 of file gnunet_core_underlay_dummy.c.
Referenced by do_open_listening_socket(), and send_init().
uint64_t GNUNET_CORE_UNDERLAY_DUMMY_Handle::sock_name_index_start |
Definition at line 265 of file gnunet_core_underlay_dummy.c.
uint64_t GNUNET_CORE_UNDERLAY_DUMMY_Handle::sock_name_index |
Definition at line 267 of file gnunet_core_underlay_dummy.c.
struct GNUNET_NETWORK_Handle* GNUNET_CORE_UNDERLAY_DUMMY_Handle::sock_listen |
Socket on which we listen for incoming connections.
Definition at line 272 of file gnunet_core_underlay_dummy.c.
struct GNUNET_SCHEDULER_Task* GNUNET_CORE_UNDERLAY_DUMMY_Handle::listen_task |
Task that waits for incoming connections.
Definition at line 277 of file gnunet_core_underlay_dummy.c.
struct GNUNET_SCHEDULER_Task* GNUNET_CORE_UNDERLAY_DUMMY_Handle::notify_address_change_task |
Task to notify core about address changes.
Definition at line 282 of file gnunet_core_underlay_dummy.c.
struct GNUNET_SCHEDULER_Task* GNUNET_CORE_UNDERLAY_DUMMY_Handle::peer_discovery_task |
Task to discover other peers.
Definition at line 287 of file gnunet_core_underlay_dummy.c.
struct GNUNET_SCHEDULER_Task* GNUNET_CORE_UNDERLAY_DUMMY_Handle::address_change_task |
Definition at line 290 of file gnunet_core_underlay_dummy.c.
struct PeerConnectCls* GNUNET_CORE_UNDERLAY_DUMMY_Handle::peer_connect_cls_head |
Head of linked list with peer connect closures.
Definition at line 295 of file gnunet_core_underlay_dummy.c.
Referenced by do_connect_to_peer().
struct PeerConnectCls* GNUNET_CORE_UNDERLAY_DUMMY_Handle::peer_connect_cls_tail |
Tail of linked list with peer connect closures.
Definition at line 300 of file gnunet_core_underlay_dummy.c.
Referenced by do_connect_to_peer().
struct Connection* GNUNET_CORE_UNDERLAY_DUMMY_Handle::connections_head |
Head of linked list with peer connect closures.
Definition at line 305 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy(), and do_read().
struct Connection* GNUNET_CORE_UNDERLAY_DUMMY_Handle::connections_tail |
Tail of linked list with peer connect closures.
Definition at line 310 of file gnunet_core_underlay_dummy.c.
Referenced by connection_destroy().