Go to the source code of this file.
Data Structures | |
struct | GNUNET_CONNECTION_TransmitHandle |
Transmission handle. More... | |
struct | AddressProbe |
During connect, we try multiple possible IP addresses to find out which one might work. More... | |
struct | GNUNET_CONNECTION_Handle |
handle for a network connection More... | |
Macros | |
#define | CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
Timeout we use on TCP connect before trying another result from the DNS resolver. More... | |
#define | LOG_STRERROR(kind, syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall) |
Functions | |
void | GNUNET_CONNECTION_persist_ (struct GNUNET_CONNECTION_Handle *connection) |
Set the persist option on this connection handle. More... | |
int | GNUNET_CONNECTION_disable_corking (struct GNUNET_CONNECTION_Handle *connection) |
Disable the "CORK" feature for communication with the given connection, forcing the OS to immediately flush the buffer on transmission instead of potentially buffering multiple messages. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_create_from_existing (struct GNUNET_NETWORK_Handle *osSocket) |
Create a connection handle by boxing an existing OS socket. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, void *access_cb_cls, struct GNUNET_NETWORK_Handle *lsock) |
Create a connection handle by accepting on a listen socket. More... | |
int | GNUNET_CONNECTION_get_address (struct GNUNET_CONNECTION_Handle *connection, void **addr, size_t *addrlen) |
Obtain the network address of the other party. More... | |
static void | signal_receive_error (struct GNUNET_CONNECTION_Handle *connection, int errcode) |
Tell the receiver callback that we had an IO error. More... | |
static void | signal_receive_timeout (struct GNUNET_CONNECTION_Handle *connection) |
Tell the receiver callback that a timeout was reached. More... | |
static void | signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection, int ecode) |
We failed to transmit data to the service, signal the error. More... | |
static void | connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection) |
We've failed for good to establish a connection (timeout or no more addresses to try). More... | |
static void | transmit_ready (void *cls) |
We are ready to transmit (or got a timeout). More... | |
static void | receive_ready (void *cls) |
This function is called once we either timeout or have data ready to read. More... | |
static void | connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection) |
We've succeeded in establishing a connection. More... | |
static void | connect_probe_continuation (void *cls) |
Scheduler let us know that we're either ready to write on the socket OR connect timed out. More... | |
static void | try_connect_using_address (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
Try to establish a connection given the specified address. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, uint16_t port) |
Create a connection handle by (asynchronously) connecting to a host. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *unixpath) |
Create a connection handle by connecting to a UNIX domain service. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_connect_socket (struct GNUNET_NETWORK_Handle *s, const struct sockaddr *serv_addr, socklen_t addrlen) |
Create a connection handle by (asynchronously) connecting to a host. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_create_from_sockaddr (int af_family, const struct sockaddr *serv_addr, socklen_t addrlen) |
Create a connection handle by creating a socket and (asynchronously) connecting to a host. More... | |
int | GNUNET_CONNECTION_check (struct GNUNET_CONNECTION_Handle *connection) |
Check if connection is valid (no fatal errors have happened so far). More... | |
void | GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection) |
Close the connection and free associated resources. More... | |
int | GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection, size_t max, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_Receiver receiver, void *receiver_cls) |
Receive data from the given connection. More... | |
void * | GNUNET_CONNECTION_receive_cancel (struct GNUNET_CONNECTION_Handle *connection) |
Cancel receive job on the given connection. More... | |
static int | process_notify (struct GNUNET_CONNECTION_Handle *connection) |
Try to call the transmit notify method (check if we do have enough space available first)! More... | |
static void | transmit_timeout (void *cls) |
Task invoked by the scheduler when a call to transmit is timing out (we never got enough buffer space to call the callback function before the specified timeout expired). More... | |
static void | connect_error (void *cls) |
Task invoked by the scheduler when we failed to connect at the time of being asked to transmit. More... | |
struct GNUNET_CONNECTION_TransmitHandle * | GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connection, size_t size, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify notify, void *notify_cls) |
Ask the connection to call us once the specified number of bytes are free in the transmission buffer. More... | |
void | GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_TransmitHandle *th) |
Cancel the specified transmission-ready notification. More... | |
struct GNUNET_CONNECTION_Handle * | GNUNET_CONNECTION_create_proxied_from_handshake (struct GNUNET_CONNECTION_Handle *cph) |
Create a connection to be proxied using a given connection. More... | |
void | GNUNET_CONNECTION_acivate_proxied (struct GNUNET_CONNECTION_Handle *proxied) |
Activate proxied connection and destroy initial proxy handshake connection. More... | |
#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
Timeout we use on TCP connect before trying another result from the DNS resolver.
Actual value used is this value divided by the number of address families. Default is 5s.
Definition at line 44 of file tcp_connection_legacy.c.
#define LOG_STRERROR | ( | kind, | |
syscall | |||
) | GNUNET_log_from_strerror (kind, "util-connection", syscall) |
Definition at line 48 of file tcp_connection_legacy.c.
void GNUNET_CONNECTION_persist_ | ( | struct GNUNET_CONNECTION_Handle * | connection | ) |
Set the persist option on this connection handle.
Indicates that the underlying socket or fd should never really be closed. Used for indicating process death.
connection | the connection to set persistent |
Definition at line 274 of file tcp_connection_legacy.c.
References GNUNET_YES, and GNUNET_CONNECTION_Handle::persist.
Referenced by GNUNET_SERVER_client_disconnect().
int GNUNET_CONNECTION_disable_corking | ( | struct GNUNET_CONNECTION_Handle * | connection | ) |
Disable the "CORK" feature for communication with the given connection, forcing the OS to immediately flush the buffer on transmission instead of potentially buffering multiple messages.
Essentially reduces the OS send buffers to zero. Used to make sure that the last messages sent through the connection reach the other side before the process is terminated.
connection | the connection to make flushing and blocking |
Definition at line 292 of file tcp_connection_legacy.c.
References GNUNET_NETWORK_socket_disable_corking(), and GNUNET_CONNECTION_Handle::sock.
Referenced by GNUNET_SERVER_client_disable_corking().
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_create_from_existing | ( | struct GNUNET_NETWORK_Handle * | osSocket | ) |
Create a connection handle by boxing an existing OS socket.
The OS socket should henceforth be no longer used directly. #GNUNET_connection_destroy() will close it.
osSocket | existing socket to box |
Definition at line 307 of file tcp_connection_legacy.c.
References GNUNET_malloc, GNUNET_MIN_MESSAGE_SIZE, GNUNET_new, GNUNET_CONNECTION_Handle::sock, GNUNET_CONNECTION_Handle::write_buffer, and GNUNET_CONNECTION_Handle::write_buffer_size.
Referenced by GNUNET_CONNECTION_connect_socket(), and GNUNET_CONNECTION_create_proxied_from_handshake().
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_create_from_accept | ( | GNUNET_CONNECTION_AccessCheck | access_cb, |
void * | access_cb_cls, | ||
struct GNUNET_NETWORK_Handle * | lsock | ||
) |
Create a connection handle by accepting on a listen socket.
This function may block if the listen socket has no connection ready.
access_cb | function to use to check if access is allowed |
access_cb_cls | closure for access_cb |
lsock | listen socket |
Definition at line 329 of file tcp_connection_legacy.c.
References _, GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_CONNECTION_Credentials::gid, GNUNET_a2s(), GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MIN_MESSAGE_SIZE, GNUNET_NETWORK_get_fd(), GNUNET_NETWORK_socket_accept(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_shutdown(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, LOG, LOG_STRERROR, GNUNET_CONNECTION_Handle::sock, uc, GNUNET_CONNECTION_Credentials::uid, GNUNET_CONNECTION_Handle::write_buffer, and GNUNET_CONNECTION_Handle::write_buffer_size.
Referenced by process_listen_socket().
int GNUNET_CONNECTION_get_address | ( | struct GNUNET_CONNECTION_Handle * | connection, |
void ** | addr, | ||
size_t * | addrlen | ||
) |
Obtain the network address of the other party.
connection | the client to get the address for |
addr | where to store the address |
addrlen | where to store the length of the addr |
Definition at line 471 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, and GNUNET_OK.
Referenced by GNUNET_SERVER_client_get_address().
|
static |
Tell the receiver callback that we had an IO error.
connection | connection to signal error |
errcode | error code to send |
Definition at line 491 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, LOG, GNUNET_CONNECTION_Handle::receiver, receiver(), and GNUNET_CONNECTION_Handle::receiver_cls.
Referenced by connect_fail_continuation(), and receive_ready().
|
static |
Tell the receiver callback that a timeout was reached.
connection | connection to signal for |
Definition at line 516 of file tcp_connection_legacy.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, LOG, GNUNET_CONNECTION_Handle::receiver, receiver(), and GNUNET_CONNECTION_Handle::receiver_cls.
Referenced by receive_ready(), and signal_transmit_error().
|
static |
We failed to transmit data to the service, signal the error.
connection | handle that had trouble |
ecode | error code (errno) |
Definition at line 536 of file tcp_connection_legacy.c.
References GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_shutdown(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), LOG, notify, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::notify_ready_cls, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::read_task, signal_receive_timeout(), GNUNET_CONNECTION_Handle::sock, and GNUNET_CONNECTION_Handle::write_task.
Referenced by connect_fail_continuation(), and transmit_ready().
|
static |
We've failed for good to establish a connection (timeout or no more addresses to try).
connection | the connection we tried to establish |
Definition at line 574 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::ap_head, GNUNET_CONNECTION_Handle::ap_tail, GNUNET_CONNECTION_Handle::destroy_later, GNUNET_CONNECTION_Handle::dns_active, GNUNET_assert, GNUNET_break, GNUNET_CONNECTION_destroy(), GNUNET_ERROR_TYPE_INFO, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_CONNECTION_Handle::hostname, LOG, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::port, GNUNET_CONNECTION_Handle::proxy_handshake, GNUNET_CONNECTION_Handle::receiver, signal_receive_error(), signal_transmit_error(), GNUNET_CONNECTION_Handle::sock, GNUNET_CONNECTION_TransmitHandle::timeout_task, and GNUNET_CONNECTION_Handle::write_task.
Referenced by connect_probe_continuation(), and try_connect_using_address().
|
static |
We are ready to transmit (or got a timeout).
cls | our connection handle |
Definition at line 1348 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_a2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NETWORK_fdset_isset(), GNUNET_NETWORK_socket_send(), GNUNET_realloc, GNUNET_SCHEDULER_add_write_net(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_TIMEOUT, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_REL, LOG, notify, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::notify_ready_cls, GNUNET_CONNECTION_TransmitHandle::notify_size, GNUNET_CONNECTION_Handle::nth, process_notify(), GNUNET_SCHEDULER_TaskContext::reason, ret, RETRY, signal_transmit_error(), GNUNET_CONNECTION_Handle::sock, tc, GNUNET_CONNECTION_TransmitHandle::timeout_task, GNUNET_CONNECTION_TransmitHandle::transmit_timeout, GNUNET_CONNECTION_Handle::write_buffer, GNUNET_CONNECTION_Handle::write_buffer_off, GNUNET_CONNECTION_Handle::write_buffer_pos, GNUNET_CONNECTION_Handle::write_buffer_size, GNUNET_SCHEDULER_TaskContext::write_ready, and GNUNET_CONNECTION_Handle::write_task.
Referenced by connect_success_continuation(), and GNUNET_CONNECTION_notify_transmit_ready().
|
static |
This function is called once we either timeout or have data ready to read.
cls | connection to read from |
Definition at line 1105 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_a2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NETWORK_fdset_isset(), GNUNET_NETWORK_socket_recv(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_TIMEOUT, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, LOG, GNUNET_CONNECTION_Handle::max, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_CONNECTION_Handle::read_task, GNUNET_SCHEDULER_TaskContext::reason, GNUNET_CONNECTION_Handle::receive_timeout, GNUNET_CONNECTION_Handle::receiver, receiver(), GNUNET_CONNECTION_Handle::receiver_cls, ret, RETRY, signal_receive_error(), signal_receive_timeout(), GNUNET_CONNECTION_Handle::sock, and tc.
Referenced by connect_success_continuation(), and GNUNET_CONNECTION_receive().
|
static |
We've succeeded in establishing a connection.
connection | the connection we tried to establish |
Definition at line 634 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_a2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_write_net(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get_remaining(), LOG, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::read_task, receive_ready(), GNUNET_CONNECTION_Handle::receive_timeout, GNUNET_CONNECTION_Handle::receiver, GNUNET_CONNECTION_Handle::sock, GNUNET_CONNECTION_TransmitHandle::timeout_task, transmit_ready(), GNUNET_CONNECTION_TransmitHandle::transmit_timeout, and GNUNET_CONNECTION_Handle::write_task.
Referenced by connect_probe_continuation(), GNUNET_CONNECTION_acivate_proxied(), and GNUNET_CONNECTION_create_from_connect_to_unixpath().
|
static |
Scheduler let us know that we're either ready to write on the socket OR connect timed out.
Do the right thing.
cls | the struct AddressProbe * with the address that we are probing |
Definition at line 680 of file tcp_connection_legacy.c.
References AddressProbe::addr, GNUNET_CONNECTION_Handle::addr, AddressProbe::addrlen, GNUNET_CONNECTION_Handle::addrlen, GNUNET_CONNECTION_Handle::ap_head, GNUNET_CONNECTION_Handle::ap_tail, connect_fail_continuation(), connect_success_continuation(), AddressProbe::connection, GNUNET_CONNECTION_Handle::dns_active, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_getsockopt(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_WRITE_READY, len, GNUNET_CONNECTION_Handle::proxy_handshake, GNUNET_SCHEDULER_TaskContext::reason, AddressProbe::sock, GNUNET_CONNECTION_Handle::sock, AddressProbe::task, and tc.
Referenced by try_connect_using_address().
|
static |
Try to establish a connection given the specified address.
This function is called by the resolver once we have a DNS reply.
cls | our struct GNUNET_CONNECTION_Handle * |
addr | address to try, NULL for "last call" |
addrlen | length of addr |
Definition at line 739 of file tcp_connection_legacy.c.
References AddressProbe::addr, GNUNET_CONNECTION_Handle::addr, AddressProbe::addrlen, GNUNET_CONNECTION_Handle::ap_head, GNUNET_CONNECTION_Handle::ap_tail, connect_fail_continuation(), connect_probe_continuation(), CONNECT_RETRY_TIMEOUT, AddressProbe::connection, delay, GNUNET_CONNECTION_Handle::dns_active, GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_connect(), GNUNET_NETWORK_socket_create(), GNUNET_OK, GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_min(), GNUNET_CONNECTION_Handle::hostname, LOG, LOG_STRERROR, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::port, GNUNET_CONNECTION_Handle::proxy_handshake, GNUNET_CONNECTION_Handle::receive_timeout, GNUNET_CONNECTION_Handle::receiver, AddressProbe::sock, GNUNET_CONNECTION_Handle::sock, AddressProbe::task, and GNUNET_CONNECTION_TransmitHandle::transmit_timeout.
Referenced by GNUNET_CONNECTION_create_from_connect().
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_create_from_connect | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const char * | hostname, | ||
uint16_t | port | ||
) |
Create a connection handle by (asynchronously) connecting to a host.
This function returns immediately, even if the connection has not yet been established. This function only creates TCP connections.
cfg | configuration to use |
hostname | name of the host to connect to |
port | port to connect to |
Definition at line 834 of file tcp_connection_legacy.c.
References cfg, GNUNET_CONNECTION_Handle::cfg, CONNECT_RETRY_TIMEOUT, GNUNET_CONNECTION_Handle::dns_active, GNUNET_assert, GNUNET_malloc, GNUNET_MIN_MESSAGE_SIZE, GNUNET_new, GNUNET_RESOLVER_ip_get(), GNUNET_strdup, hostname, GNUNET_CONNECTION_Handle::hostname, port, GNUNET_CONNECTION_Handle::port, try_connect_using_address(), GNUNET_CONNECTION_Handle::write_buffer, and GNUNET_CONNECTION_Handle::write_buffer_size.
Referenced by GNUNET_SOCKS_do_connect().
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_create_from_connect_to_unixpath | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const char * | unixpath | ||
) |
Create a connection handle by connecting to a UNIX domain service.
This function returns immediately, even if the connection has not yet been established. This function only creates UNIX connections.
cfg | configuration to use |
unixpath | path to connect to |
Definition at line 867 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, cfg, GNUNET_CONNECTION_Handle::cfg, connect_success_continuation(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_free, GNUNET_malloc, GNUNET_MIN_MESSAGE_SIZE, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_connect(), GNUNET_NETWORK_socket_create(), GNUNET_new, GNUNET_OK, GNUNET_strlcpy(), GNUNET_YES, GNUNET_CONNECTION_Handle::hostname, GNUNET_CONNECTION_Handle::port, GNUNET_CONNECTION_Handle::sock, GNUNET_CONNECTION_Handle::write_buffer, and GNUNET_CONNECTION_Handle::write_buffer_size.
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_connect_socket | ( | struct GNUNET_NETWORK_Handle * | s, |
const struct sockaddr * | serv_addr, | ||
socklen_t | addrlen | ||
) |
Create a connection handle by (asynchronously) connecting to a host.
This function returns immediately, even if the connection has not yet been established. This function only creates TCP connections.
s | socket to connect |
serv_addr | server address |
addrlen | length of serv_addr |
Definition at line 938 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_a2s(), GNUNET_break, GNUNET_CONNECTION_create_from_existing(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_connect(), GNUNET_OK, LOG, and LOG_STRERROR.
Referenced by GNUNET_CONNECTION_create_from_sockaddr(), and tcp_plugin_get_session().
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_create_from_sockaddr | ( | int | af_family, |
const struct sockaddr * | serv_addr, | ||
socklen_t | addrlen | ||
) |
Create a connection handle by creating a socket and (asynchronously) connecting to a host.
This function returns immediately, even if the connection has not yet been established. This function only creates TCP connections.
af_family | address family to use |
serv_addr | server address |
addrlen | length of serv_addr |
Definition at line 979 of file tcp_connection_legacy.c.
References GNUNET_NETWORK_Handle::addrlen, GNUNET_CONNECTION_connect_socket(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_WARNING, GNUNET_NETWORK_socket_create(), and LOG_STRERROR.
Referenced by tcp_plugin_get_network(), and tcp_plugin_get_session().
int GNUNET_CONNECTION_check | ( | struct GNUNET_CONNECTION_Handle * | connection | ) |
Check if connection is valid (no fatal errors have happened so far).
Note that a connection that is still trying to connect is considered valid.
connection | connection to check |
Definition at line 1004 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::ap_head, GNUNET_CONNECTION_Handle::destroy_later, GNUNET_CONNECTION_Handle::dns_active, GNUNET_NO, GNUNET_YES, GNUNET_CONNECTION_Handle::proxy_handshake, and GNUNET_CONNECTION_Handle::sock.
Referenced by process_incoming().
void GNUNET_CONNECTION_destroy | ( | struct GNUNET_CONNECTION_Handle * | connection | ) |
Close the connection and free associated resources.
There must not be any pending requests for reading or writing to the connection at this time.
connection | connection to destroy |
Definition at line 1023 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::ap_head, GNUNET_CONNECTION_Handle::ap_tail, AddressProbe::connection, GNUNET_CONNECTION_Handle::destroy_later, GNUNET_CONNECTION_Handle::dns_active, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_free_memory_only_(), GNUNET_NETWORK_socket_shutdown(), GNUNET_OK, GNUNET_RESOLVER_request_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_CONNECTION_Handle::hostname, LOG, LOG_STRERROR, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::persist, GNUNET_CONNECTION_Handle::proxy_handshake, GNUNET_CONNECTION_Handle::read_task, GNUNET_CONNECTION_Handle::receiver, AddressProbe::sock, GNUNET_CONNECTION_Handle::sock, AddressProbe::task, GNUNET_CONNECTION_TransmitHandle::timeout_task, GNUNET_CONNECTION_Handle::write_buffer, GNUNET_CONNECTION_Handle::write_buffer_off, and GNUNET_CONNECTION_Handle::write_task.
Referenced by connect_fail_continuation(), GNUNET_CONNECTION_acivate_proxied(), GNUNET_SERVER_client_disconnect(), libgnunet_plugin_transport_tcp_done(), and notify_send_probe().
int GNUNET_CONNECTION_receive | ( | struct GNUNET_CONNECTION_Handle * | connection, |
size_t | max, | ||
struct GNUNET_TIME_Relative | timeout, | ||
GNUNET_CONNECTION_Receiver | receiver, | ||
void * | receiver_cls | ||
) |
Receive data from the given connection.
Note that this function will call receiver asynchronously using the scheduler. It will "immediately" return. Note that there MUST only be one active receive call per connection at any given point in time (so do not call receive again until the receiver callback has been invoked).
connection | connection handle |
max | maximum number of bytes to read |
timeout | maximum amount of time to wait |
receiver | function to call with received data |
receiver_cls | closure for receiver |
Definition at line 1177 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::ap_head, GNUNET_CONNECTION_Handle::dns_active, GNUNET_assert, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_to_absolute(), max, GNUNET_CONNECTION_Handle::max, GNUNET_CONNECTION_Handle::proxy_handshake, GNUNET_CONNECTION_Handle::read_task, receive_ready(), GNUNET_CONNECTION_Handle::receive_timeout, GNUNET_CONNECTION_Handle::receiver, receiver(), GNUNET_CONNECTION_Handle::receiver_cls, GNUNET_CONNECTION_Handle::sock, and timeout.
Referenced by GNUNET_SERVER_connect_socket(), process_incoming(), process_mst(), register_reciever(), and restart_processing().
void* GNUNET_CONNECTION_receive_cancel | ( | struct GNUNET_CONNECTION_Handle * | connection | ) |
Cancel receive job on the given connection.
Note that the receiver callback must not have been called yet in order for the cancellation to be valid.
connection | connection handle |
Definition at line 1220 of file tcp_connection_legacy.c.
References GNUNET_assert, GNUNET_SCHEDULER_cancel(), GNUNET_CONNECTION_Handle::read_task, GNUNET_CONNECTION_Handle::receiver, and GNUNET_CONNECTION_Handle::receiver_cls.
Referenced by GNUNET_SERVER_client_disconnect().
|
static |
Try to call the transmit notify method (check if we do have enough space available first)!
connection | connection for which we should do this processing |
Definition at line 1241 of file tcp_connection_legacy.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_YES, LOG, notify, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::notify_ready_cls, GNUNET_CONNECTION_TransmitHandle::notify_size, GNUNET_CONNECTION_Handle::nth, size, GNUNET_CONNECTION_Handle::write_buffer, GNUNET_CONNECTION_Handle::write_buffer_off, GNUNET_CONNECTION_Handle::write_buffer_pos, GNUNET_CONNECTION_Handle::write_buffer_size, and GNUNET_CONNECTION_Handle::write_task.
Referenced by transmit_ready().
|
static |
Task invoked by the scheduler when a call to transmit is timing out (we never got enough buffer space to call the callback function before the specified timeout expired).
This task notifies the client about the timeout.
cls | the struct GNUNET_CONNECTION_Handle |
Definition at line 1296 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::addr, GNUNET_CONNECTION_Handle::addrlen, GNUNET_a2s(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_CONNECTION_Handle::hostname, LOG, notify, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::notify_ready_cls, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::port, and GNUNET_CONNECTION_TransmitHandle::timeout_task.
Referenced by GNUNET_CONNECTION_notify_transmit_ready().
|
static |
Task invoked by the scheduler when we failed to connect at the time of being asked to transmit.
This task notifies the client about the error.
cls | the struct GNUNET_CONNECTION_Handle |
Definition at line 1324 of file tcp_connection_legacy.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_CONNECTION_Handle::hostname, LOG, notify, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::notify_ready_cls, GNUNET_CONNECTION_TransmitHandle::notify_size, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::port, and GNUNET_CONNECTION_Handle::write_task.
Referenced by GNUNET_CONNECTION_notify_transmit_ready().
struct GNUNET_CONNECTION_TransmitHandle* GNUNET_CONNECTION_notify_transmit_ready | ( | struct GNUNET_CONNECTION_Handle * | connection, |
size_t | size, | ||
struct GNUNET_TIME_Relative | timeout, | ||
GNUNET_CONNECTION_TransmitReadyNotify | notify, | ||
void * | notify_cls | ||
) |
Ask the connection to call us once the specified number of bytes are free in the transmission buffer.
Will never call the notify callback in this task, but always first go into the scheduler.
connection | connection |
size | number of bytes to send |
timeout | after how long should we give up (and call notify with buf NULL and size 0)? |
notify | function to call |
notify_cls | closure for notify |
Definition at line 1475 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_Handle::ap_head, connect_error(), GNUNET_CONNECTION_TransmitHandle::connection, GNUNET_CONNECTION_Handle::dns_active, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_write_net(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_to_absolute(), LOG, notify, GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::notify_ready_cls, GNUNET_CONNECTION_TransmitHandle::notify_size, GNUNET_CONNECTION_Handle::nth, GNUNET_CONNECTION_Handle::proxy_handshake, size, GNUNET_CONNECTION_Handle::sock, timeout, GNUNET_CONNECTION_TransmitHandle::timeout_task, transmit_ready(), GNUNET_CONNECTION_TransmitHandle::transmit_timeout, transmit_timeout(), GNUNET_CONNECTION_Handle::write_buffer_off, GNUNET_CONNECTION_Handle::write_buffer_pos, GNUNET_CONNECTION_Handle::write_buffer_size, and GNUNET_CONNECTION_Handle::write_task.
Referenced by GNUNET_SERVER_notify_transmit_ready(), register_sender(), and tcp_plugin_get_network().
void GNUNET_CONNECTION_notify_transmit_ready_cancel | ( | struct GNUNET_CONNECTION_TransmitHandle * | th | ) |
Cancel the specified transmission-ready notification.
th | notification to cancel |
Definition at line 1539 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_TransmitHandle::connection, GNUNET_assert, GNUNET_SCHEDULER_cancel(), GNUNET_CONNECTION_TransmitHandle::notify_ready, GNUNET_CONNECTION_TransmitHandle::timeout_task, and GNUNET_CONNECTION_Handle::write_task.
Referenced by GNUNET_SERVER_notify_transmit_ready_cancel().
struct GNUNET_CONNECTION_Handle* GNUNET_CONNECTION_create_proxied_from_handshake | ( | struct GNUNET_CONNECTION_Handle * | cph | ) |
Create a connection to be proxied using a given connection.
cph | connection to proxy server |
Definition at line 1564 of file tcp_connection_legacy.c.
References GNUNET_CONNECTION_create_from_existing(), and GNUNET_CONNECTION_Handle::proxy_handshake.
Referenced by GNUNET_SOCKS_run_handshake().
void GNUNET_CONNECTION_acivate_proxied | ( | struct GNUNET_CONNECTION_Handle * | proxied | ) |
Activate proxied connection and destroy initial proxy handshake connection.
There must not be any pending requests for reading or writing to the proxy hadshake connection at this time.
proxied | connection connection to proxy server |
Definition at line 1583 of file tcp_connection_legacy.c.
References connect_success_continuation(), GNUNET_assert, GNUNET_CONNECTION_destroy(), GNUNET_CONNECTION_Handle::proxy_handshake, and GNUNET_CONNECTION_Handle::sock.
Referenced by SOCKS5_handshake_done().