HTTP/S client transport plugin. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_transport_plugin.h"
#include "plugin_transport_http_common.h"
#include "gnunet_curl_lib.h"
Go to the source code of this file.
Data Structures | |
struct | HTTP_Message |
Message to send using http. More... | |
struct | RequestHandle |
The request handle. More... | |
struct | GNUNET_ATS_Session |
Session handle for connections. More... | |
struct | HTTP_Client_Plugin |
Encapsulation of all of the state of the plugin. More... | |
struct | GNUNET_ATS_SessionClientCtx |
Closure for session_lookup_client_by_address(). More... | |
Macros | |
#define | PLUGIN_NAME "http_client" |
#define | HTTP_STAT_STR_CONNECTIONS "# HTTP client connections" |
#define | LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_http_client_init |
#define | LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_http_client_done |
#define | VERBOSE_CURL GNUNET_NO |
#define | PUT_DISCONNECT_TIMEOUT |
#define | ENABLE_PUT GNUNET_YES |
#define | ENABLE_GET GNUNET_YES |
#define | LOG(kind, ...) GNUNET_log_from (kind, PLUGIN_NAME, __VA_ARGS__) |
Enumerations | |
enum | HTTP_PUT_REQUEST_STATE { H_NOT_CONNECTED , H_CONNECTED , H_PAUSED , H_TMP_DISCONNECTING , H_TMP_RECONNECT_REQUIRED , H_TMP_DISCONNECTED , H_DISCONNECTED } |
State of a HTTP PUT request. More... | |
Functions | |
static int | http_client_plugin_session_disconnect (void *cls, struct GNUNET_ATS_Session *s) |
Disconnect a session. More... | |
static void | notify_session_monitor (struct HTTP_Client_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 void | client_delete_session (struct GNUNET_ATS_Session *s) |
Delete session s. More... | |
static void | client_reschedule_session_timeout (struct GNUNET_ATS_Session *s) |
Increment session timeout due to activity for session s. More... | |
static void | client_run (void *cls) |
Task performing curl operations. More... | |
static int | client_schedule (struct HTTP_Client_Plugin *plugin, int now) |
Function setting up file descriptors and scheduling task to run. More... | |
static int | client_connect_get (struct GNUNET_ATS_Session *s) |
Connect GET request. More... | |
static int | client_connect_put (struct GNUNET_ATS_Session *s) |
Connect a HTTP put request. More... | |
static ssize_t | http_client_plugin_send (void *cls, struct GNUNET_ATS_Session *s, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative to, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
Function that can be used by the transport service to transmit a message using the plugin. More... | |
static unsigned int | http_client_query_keepalive_factor (void *cls) |
Function that is called to get the keepalive factor. More... | |
static int | destroy_session_cb (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
Callback to destroys all sessions on exit. More... | |
static void | http_client_plugin_peer_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) |
Function that can be used to force the plugin to disconnect from the given peer and cancel all previous transmissions (and their continuationc). More... | |
static int | session_lookup_client_by_address (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Locate the seession object for a given address. More... | |
static struct GNUNET_ATS_Session * | client_lookup_session (struct HTTP_Client_Plugin *plugin, const struct GNUNET_HELLO_Address *address) |
Check if a sessions exists for an specific address. More... | |
static void | client_put_disconnect (void *cls) |
When we have nothing to transmit, we pause the HTTP PUT after a while (so that gnurl stops asking). More... | |
static size_t | client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) |
Callback method used with libcurl Method is called when libcurl needs to read data during sending. More... | |
static void | client_wake_up (void *cls) |
Wake up a curl handle which was suspended. More... | |
static int | client_receive_mst_cb (void *cls, const struct GNUNET_MessageHeader *message) |
Callback for message stream tokenizer. More... | |
static size_t | client_receive_put (void *stream, size_t size, size_t nmemb, void *cls) |
Callback method used with libcurl when data for a PUT request are received. More... | |
static size_t | client_receive (void *stream, size_t size, size_t nmemb, void *cls) |
Callback method used with libcurl when data for a GET request are received. More... | |
static int | client_connect (struct GNUNET_ATS_Session *s) |
Connect both PUT and GET request for a session. More... | |
static enum GNUNET_NetworkType | http_client_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) |
Function obtain the network type for a session. More... | |
static enum GNUNET_NetworkType | http_client_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) |
Function obtain the network type for an address. More... | |
static void | client_session_timeout (void *cls) |
Session was idle, so disconnect it. More... | |
static struct GNUNET_ATS_Session * | http_client_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 int | client_start (struct HTTP_Client_Plugin *plugin) |
Setup http_client plugin. More... | |
static int | http_client_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) |
Another peer has suggested an address for this peer and transport plugin. More... | |
void * | libgnunet_plugin_transport_http_client_done (void *cls) |
Exit point from the plugin. More... | |
static int | client_configure_plugin (struct HTTP_Client_Plugin *plugin) |
Configure plugin. More... | |
static const char * | http_client_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) |
Function to convert an address to a human-readable string. More... | |
static void | http_client_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 | http_client_plugin_update_inbound_delay (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *s, struct GNUNET_TIME_Relative delay) |
Function that will be called whenever the transport service wants to notify the plugin that the inbound quota changed and that the plugin should update it's delay for the next receive value. 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 | http_client_plugin_setup_monitor (void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls) |
Begin monitoring sessions of a plugin. More... | |
void * | libgnunet_plugin_transport_http_client_init (void *cls) |
Entry point for the plugin. More... | |
HTTP/S client transport plugin.
Definition in file plugin_transport_http_client.c.
#define PLUGIN_NAME "http_client" |
Definition at line 36 of file plugin_transport_http_client.c.
#define HTTP_STAT_STR_CONNECTIONS "# HTTP client connections" |
Definition at line 37 of file plugin_transport_http_client.c.
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_http_client_init |
Definition at line 38 of file plugin_transport_http_client.c.
#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_http_client_done |
Definition at line 40 of file plugin_transport_http_client.c.
#define VERBOSE_CURL GNUNET_NO |
Definition at line 44 of file plugin_transport_http_client.c.
#define PUT_DISCONNECT_TIMEOUT |
Definition at line 46 of file plugin_transport_http_client.c.
#define ENABLE_PUT GNUNET_YES |
Definition at line 49 of file plugin_transport_http_client.c.
#define ENABLE_GET GNUNET_YES |
Definition at line 50 of file plugin_transport_http_client.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, PLUGIN_NAME, __VA_ARGS__) |
Definition at line 61 of file plugin_transport_http_client.c.
State of a HTTP PUT request.
Definition at line 71 of file plugin_transport_http_client.c.
|
static |
Disconnect a session.
cls | the struct HTTP_Client_Plugin * |
s | session |
Definition at line 849 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, client_delete_session(), client_schedule(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_YES, LOG, and plugin.
Referenced by client_run(), client_session_timeout(), destroy_session_cb(), http_client_plugin_send(), and libgnunet_plugin_transport_http_client_init().
|
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 413 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::bytes_in_queue, GNUNET_NO, info, GNUNET_ATS_Session::msgs_in_queue, GNUNET_ATS_Session::next_receive, plugin, state, and GNUNET_ATS_Session::timeout.
Referenced by client_delete_session(), client_send_cb(), client_session_timeout(), http_client_plugin_get_session(), http_client_plugin_send(), and send_session_info_iter().
|
static |
Delete session s.
s | the session to delete |
Definition at line 441 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::bytes_in_queue, RequestHandle::easyhandle, GNUNET_ATS_Session::get, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_address_free, GNUNET_i2s(), GNUNET_MST_destroy(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_SS_DONE, HTTP_STAT_STR_CONNECTIONS, LOG, GNUNET_ATS_Session::msg_head, GNUNET_ATS_Session::msg_tail, GNUNET_ATS_Session::msg_tk, GNUNET_ATS_Session::msgs_in_queue, HTTP_Message::next, notify_session_monitor(), GNUNET_ATS_Session::overhead, GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::plugin, HTTP_Message::pos, GNUNET_ATS_Session::put, GNUNET_ATS_Session::put_disconnect_task, GNUNET_ATS_Session::recv_wakeup_task, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, and GNUNET_ATS_Session::url.
Referenced by http_client_plugin_get_session(), and http_client_plugin_session_disconnect().
|
static |
Increment session timeout due to activity for session s.
s | the session |
Definition at line 547 of file plugin_transport_http_client.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 client_receive_mst_cb(), and http_client_plugin_update_session_timeout().
|
static |
Task performing curl operations.
cls | plugin as closure |
Definition at line 1292 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, client_connect_get(), client_connect_put(), client_schedule(), RequestHandle::easyhandle, GNUNET_ATS_Session::get, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_YES, H_CONNECTED, H_DISCONNECTED, H_NOT_CONNECTED, H_PAUSED, H_TMP_DISCONNECTED, H_TMP_DISCONNECTING, H_TMP_RECONNECT_REQUIRED, http_client_plugin_session_disconnect(), HTTP_STAT_STR_CONNECTIONS, LOG, msg, GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::put, RequestHandle::s, RequestHandle::state, and GNUNET_ATS_Session::url.
Referenced by client_connect(), and client_schedule().
|
static |
Function setting up file descriptors and scheduling task to run.
plugin | the plugin as closure |
now | schedule task in 1ms, regardless of what curl may say |
Definition at line 572 of file plugin_transport_http_client.c.
References _, client_run(), GNUNET_ERROR_TYPE_ERROR, GNUNET_NETWORK_fdset_copy_native(), GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_OK, GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, LOG, max, plugin, and timeout.
Referenced by client_put_disconnect(), client_run(), http_client_plugin_send(), and http_client_plugin_session_disconnect().
|
static |
Connect GET request.
Connect GET request for a session.
s | the session to connect |
Definition at line 1514 of file plugin_transport_http_client.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, client_receive(), client_send_cb(), RequestHandle::easyhandle, GNUNET_ATS_Session::get, GNUNET_asprintf(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, HTTP_CLIENT_NOT_VALIDATED_TIMEOUT, HTTP_OPTIONS_TCP_STEALTH, HTTP_OPTIONS_VERIFY_CERTIFICATE, LOG, options, HttpAddress::options, GNUNET_ATS_Session::plugin, RequestHandle::s, and GNUNET_ATS_Session::url.
Referenced by client_connect(), and client_run().
|
static |
Connect a HTTP put request.
s | the session to connect |
Definition at line 1690 of file plugin_transport_http_client.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, client_receive_put(), client_send_cb(), RequestHandle::easyhandle, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, H_CONNECTED, H_DISCONNECTED, HTTP_CLIENT_NOT_VALIDATED_TIMEOUT, HTTP_OPTIONS_TCP_STEALTH, HTTP_OPTIONS_VERIFY_CERTIFICATE, LOG, options, HttpAddress::options, GNUNET_ATS_Session::plugin, GNUNET_ATS_Session::put, RequestHandle::s, RequestHandle::state, and GNUNET_ATS_Session::url.
Referenced by client_connect(), client_run(), and http_client_plugin_send().
|
static |
Function that can be used by the transport service to transmit a message using the plugin.
Note that in the case of a peer disconnecting, the continuation MUST be called prior to the disconnect notification itself. This function will be called with this peer's HELLO message to initiate a fresh connection to another peer.
cls | closure |
s | which session must be used |
msgbuf | the message to transmit |
msgbuf_size | number of bytes in msgbuf |
priority | how important is the message (most plugins will ignore message priority and just FIFO) |
to | how long to wait at most for the transmission (does not require plugins to discard the message after the timeout, just advisory for the desired delay; most plugins will ignore this as well) |
cont | continuation to call once the message has been transmitted (or if the transport is ready for the next transmission call; or if the peer disconnected...); can be NULL |
cont_cls | closure for cont |
Definition at line 757 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::bytes_in_queue, client_connect_put(), client_schedule(), RequestHandle::easyhandle, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, H_CONNECTED, H_PAUSED, H_TMP_DISCONNECTED, H_TMP_DISCONNECTING, H_TMP_RECONNECT_REQUIRED, http_client_plugin_session_disconnect(), LOG, msg, GNUNET_ATS_Session::msg_head, GNUNET_ATS_Session::msg_tail, GNUNET_ATS_Session::msgs_in_queue, notify_session_monitor(), GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::plugin, GNUNET_ATS_Session::put, GNUNET_ATS_Session::put_disconnect_task, GNUNET_MessageHeader::size, and RequestHandle::state.
Referenced by libgnunet_plugin_transport_http_client_init().
|
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 883 of file plugin_transport_http_client.c.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Callback to destroys all sessions on exit.
cls | the struct HTTP_Client_Plugin * |
peer | identity of the peer |
value | the struct GNUNET_ATS_Session * |
Definition at line 898 of file plugin_transport_http_client.c.
References GNUNET_OK, http_client_plugin_session_disconnect(), plugin, and value.
Referenced by http_client_plugin_peer_disconnect(), and libgnunet_plugin_transport_http_client_done().
|
static |
Function that can be used to force the plugin to disconnect from the given peer and cancel all previous transmissions (and their continuationc).
cls | closure |
target | peer from which to disconnect |
Definition at line 919 of file plugin_transport_http_client.c.
References destroy_session_cb(), GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), LOG, and plugin.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Locate the seession object for a given address.
cls | the struct GNUNET_ATS_SessionClientCtx * |
key | peer identity |
value | the struct GNUNET_ATS_Session to check |
Definition at line 960 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_SessionClientCtx::address, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, GNUNET_ATS_SessionClientCtx::ret, and value.
Referenced by client_lookup_session().
|
static |
Check if a sessions exists for an specific address.
plugin | the plugin |
address | the address |
Definition at line 985 of file plugin_transport_http_client.c.
References address, GNUNET_ATS_SessionClientCtx::address, GNUNET_CONTAINER_multipeermap_iterate(), plugin, GNUNET_ATS_SessionClientCtx::ret, and session_lookup_client_by_address().
Referenced by http_client_plugin_get_session().
|
static |
When we have nothing to transmit, we pause the HTTP PUT after a while (so that gnurl stops asking).
This task is the delayed task that actually disconnects the PUT.
cls | the struct GNUNET_ATS_Session * with the put |
Definition at line 1007 of file plugin_transport_http_client.c.
References client_schedule(), RequestHandle::easyhandle, GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, H_TMP_DISCONNECTING, LOG, GNUNET_ATS_Session::plugin, GNUNET_ATS_Session::put, GNUNET_ATS_Session::put_disconnect_task, and RequestHandle::state.
Referenced by client_send_cb().
|
static |
Callback method used with libcurl Method is called when libcurl needs to read data during sending.
stream | pointer where to write data |
size | size of an individual element |
nmemb | count of elements that can be written to the buffer |
cls | our struct GNUNET_ATS_Session |
Definition at line 1034 of file plugin_transport_http_client.c.
References GNUNET_ATS_Session::address, GNUNET_ATS_Session::bytes_in_queue, client_put_disconnect(), RequestHandle::easyhandle, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_memcpy, GNUNET_MIN, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, H_PAUSED, H_TMP_DISCONNECTING, len, LOG, msg, GNUNET_ATS_Session::msg_head, GNUNET_ATS_Session::msg_tail, GNUNET_ATS_Session::msgs_in_queue, notify_session_monitor(), GNUNET_ATS_Session::overhead, GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::plugin, GNUNET_ATS_Session::put, GNUNET_ATS_Session::put_disconnect_task, PUT_DISCONNECT_TIMEOUT, GNUNET_MessageHeader::size, size, and RequestHandle::state.
Referenced by client_connect_get(), and client_connect_put().
|
static |
Wake up a curl handle which was suspended.
cls | the session |
Definition at line 1139 of file plugin_transport_http_client.c.
References RequestHandle::easyhandle, GNUNET_ATS_Session::get, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_cancel(), H_CONNECTED, H_PAUSED, LOG, GNUNET_ATS_Session::put, GNUNET_ATS_Session::put_disconnect_task, GNUNET_ATS_Session::recv_wakeup_task, and RequestHandle::state.
Referenced by client_receive(), and http_client_plugin_update_inbound_delay().
|
static |
Callback for message stream tokenizer.
cls | the session |
message | the message received |
Definition at line 1170 of file plugin_transport_http_client.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, client_reschedule_session_timeout(), delay, Plugin::env, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, http_common_plugin_address_to_string(), LOG, GNUNET_ATS_Session::next_receive, GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::plugin, Plugin::protocol, and GNUNET_MessageHeader::size.
Referenced by client_receive().
|
static |
Callback method used with libcurl when data for a PUT request are received.
We do not expect data here, so we just discard it.
stream | pointer where to write data |
size | size of an individual element |
nmemb | count of elements that can be written to the buffer |
cls | destination pointer, passed to the libcurl handle |
Definition at line 1220 of file plugin_transport_http_client.c.
References size.
Referenced by client_connect_put().
|
static |
Callback method used with libcurl when data for a GET request are received.
Forward to MST
stream | pointer where to write data |
size | size of an individual element |
nmemb | count of elements that can be written to the buffer |
cls | destination pointer, passed to the libcurl handle |
Definition at line 1240 of file plugin_transport_http_client.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_ATS_Session::address, client_receive_mst_cb(), client_wake_up(), delta, RequestHandle::easyhandle, GNUNET_ATS_Session::get, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MST_create(), GNUNET_MST_from_buffer(), GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_YES, len, LOG, GNUNET_ATS_Session::msg_tk, GNUNET_ATS_Session::next_receive, GNUNET_HELLO_Address::peer, GNUNET_ATS_Session::recv_wakeup_task, and size.
Referenced by client_connect_get().
|
static |
Connect both PUT and GET request for a session.
s | the session to connect |
Definition at line 1863 of file plugin_transport_http_client.c.
References GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, client_connect_get(), client_connect_put(), client_run(), RequestHandle::easyhandle, GNUNET_ATS_Session::get, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_i2s_full(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_YES, H_TMP_DISCONNECTED, http_common_plugin_address_to_string(), http_common_plugin_address_to_url(), HTTP_STAT_STR_CONNECTIONS, LOG, GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::plugin, GNUNET_ATS_Session::put, res, RequestHandle::state, and GNUNET_ATS_Session::url.
Referenced by http_client_plugin_get_session().
|
static |
Function obtain the network type for a session.
cls | closure (struct Plugin* ) |
session | the session |
Definition at line 1863 of file plugin_transport_http_client.c.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Function obtain the network type for an address.
cls | closure (struct Plugin * ) |
address | the address |
Definition at line 1863 of file plugin_transport_http_client.c.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Session was idle, so disconnect it.
cls | the struct GNUNET_ATS_Session of the idle session |
Definition at line 1968 of file plugin_transport_http_client.c.
References GNUNET_assert, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, http_client_plugin_session_disconnect(), HTTP_CLIENT_SESSION_TIMEOUT, LOG, notify_session_monitor(), GNUNET_ATS_Session::plugin, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_Session::timeout, TIMEOUT_LOG, and GNUNET_ATS_Session::timeout_task.
Referenced by http_client_plugin_get_session().
|
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 2007 of file plugin_transport_http_client.c.
References address, GNUNET_HELLO_Address::address, GNUNET_ATS_Session::address, GNUNET_HELLO_Address::address_length, client_connect(), client_delete_session(), client_lookup_session(), client_session_timeout(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_HELLO_address_copy(), GNUNET_i2s(), GNUNET_new, GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_NT_WAN, GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, GNUNET_YES, H_NOT_CONNECTED, HTTP_CLIENT_SESSION_TIMEOUT, http_common_plugin_address_to_string(), http_common_socket_from_address(), LOG, notify_session_monitor(), GNUNET_HELLO_Address::peer, plugin, GNUNET_ATS_Session::plugin, GNUNET_ATS_Session::put, res, GNUNET_ATS_Session::scope, RequestHandle::state, GNUNET_ATS_Session::timeout, and GNUNET_ATS_Session::timeout_task.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Setup http_client plugin.
plugin | the plugin handle |
Definition at line 2119 of file plugin_transport_http_client.c.
References _, GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, and plugin.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Another peer has suggested an address for this peer and transport plugin.
Check that this could be a valid address. If so, consider adding it to the list of addresses.
cls | closure with the struct Plugin |
addr | pointer to the address |
addrlen | length of addr |
Definition at line 2149 of file plugin_transport_http_client.c.
References GNUNET_NO.
Referenced by libgnunet_plugin_transport_http_client_init().
void* libgnunet_plugin_transport_http_client_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | api as closure |
Definition at line 2165 of file plugin_transport_http_client.c.
References _, GNUNET_TRANSPORT_PluginFunctions::cls, destroy_session_cb(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), LOG, and plugin.
|
static |
Configure plugin.
plugin | the plugin handle |
Definition at line 2213 of file plugin_transport_http_client.c.
References _, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_utf8_toupper(), GNUNET_SYSERR, LOG, HTTP_Client_Plugin::max_requests, plugin, and proxy_type.
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Function to convert an address to a human-readable string.
cls | closure |
addr | address to convert |
addrlen | address length |
Definition at line 2336 of file plugin_transport_http_client.c.
References http_common_plugin_address_to_string(), and PLUGIN_NAME.
Referenced by libgnunet_plugin_transport_http_client_init().
|
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 |
peer | which peer was the session for |
session | which session is being updated |
Definition at line 2356 of file plugin_transport_http_client.c.
References client_reschedule_session_timeout().
Referenced by libgnunet_plugin_transport_http_client_init().
|
static |
Function that will be called whenever the transport service wants to notify the plugin that the inbound quota changed and that the plugin should update it's delay for the next receive value.
cls | closure |
peer | which peer was the session for |
s | which session is being updated |
delay | new delay to use for receiving |
Definition at line 2376 of file plugin_transport_http_client.c.
References client_wake_up(), delay, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_to_absolute(), LOG, GNUNET_ATS_Session::next_receive, and GNUNET_ATS_Session::recv_wakeup_task.
Referenced by libgnunet_plugin_transport_http_client_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 2407 of file plugin_transport_http_client.c.
References GNUNET_OK, GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, notify_session_monitor(), plugin, and value.
Referenced by http_client_plugin_setup_monitor(), and template_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 2437 of file plugin_transport_http_client.c.
References GNUNET_CONTAINER_multipeermap_iterate(), plugin, send_session_info_iter(), HTTP_Client_Plugin::sic, and HTTP_Client_Plugin::sic_cls.
Referenced by libgnunet_plugin_transport_http_client_init().
void* libgnunet_plugin_transport_http_client_init | ( | void * | cls | ) |
Entry point for the plugin.
Definition at line 2460 of file plugin_transport_http_client.c.
References GNUNET_TRANSPORT_PluginFunctions::address_pretty_printer, GNUNET_TRANSPORT_PluginFunctions::address_to_string, GNUNET_TRANSPORT_PluginFunctions::check_address, client_configure_plugin(), client_start(), GNUNET_TRANSPORT_PluginEnvironment::cls, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::disconnect_peer, GNUNET_TRANSPORT_PluginFunctions::disconnect_session, env, GNUNET_TRANSPORT_PluginFunctions::get_network, GNUNET_TRANSPORT_PluginFunctions::get_network_for_address, GNUNET_TRANSPORT_PluginFunctions::get_session, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_SYSERR, GNUNET_YES, http_client_plugin_address_suggested(), http_client_plugin_address_to_string(), http_client_plugin_get_network(), http_client_plugin_get_network_for_address(), http_client_plugin_get_session(), http_client_plugin_peer_disconnect(), http_client_plugin_send(), http_client_plugin_session_disconnect(), http_client_plugin_setup_monitor(), http_client_plugin_update_inbound_delay(), http_client_plugin_update_session_timeout(), http_client_query_keepalive_factor(), http_common_plugin_address_pretty_printer(), http_common_plugin_string_to_address(), LIBGNUNET_PLUGIN_TRANSPORT_DONE, plugin, GNUNET_TRANSPORT_PluginFunctions::query_keepalive_factor, GNUNET_TRANSPORT_PluginFunctions::send, GNUNET_TRANSPORT_PluginFunctions::setup_monitor, GNUNET_TRANSPORT_PluginFunctions::string_to_address, GNUNET_TRANSPORT_PluginFunctions::update_inbound_delay, and GNUNET_TRANSPORT_PluginFunctions::update_session_timeout.