29 #define PLUGIN_NAME "https_client"
30 #define HTTP_STAT_STR_CONNECTIONS "# HTTPS client connections"
31 #define LIBGNUNET_PLUGIN_TRANSPORT_INIT \
32 libgnunet_plugin_transport_https_client_init
33 #define LIBGNUNET_PLUGIN_TRANSPORT_DONE \
34 libgnunet_plugin_transport_https_client_done
36 #define PLUGIN_NAME "http_client"
37 #define HTTP_STAT_STR_CONNECTIONS "# HTTP client connections"
38 #define LIBGNUNET_PLUGIN_TRANSPORT_INIT \
39 libgnunet_plugin_transport_http_client_init
40 #define LIBGNUNET_PLUGIN_TRANSPORT_DONE \
41 libgnunet_plugin_transport_http_client_done
44 #define VERBOSE_CURL GNUNET_NO
46 #define PUT_DISCONNECT_TIMEOUT GNUNET_TIME_relative_multiply ( \
47 GNUNET_TIME_UNIT_SECONDS, 1)
49 #define ENABLE_PUT GNUNET_YES
50 #define ENABLE_GET GNUNET_YES
61 #define LOG(kind, ...) GNUNET_log_from (kind, PLUGIN_NAME, __VA_ARGS__)
471 "Session %p/request %p: disconnecting PUT request to peer `%s'\n",
477 mret = curl_multi_remove_handle (
plugin->curl_multi_handle,
488 "Session %p/request %p: disconnecting GET request to peer `%s'\n",
492 mret = curl_multi_remove_handle (
plugin->curl_multi_handle,
516 if (NULL !=
pos->transmit_cont)
517 pos->transmit_cont (
pos->transmit_cont_cls,
586 if (
plugin->client_perform_task != NULL)
589 plugin->client_perform_task = NULL;
595 mret = curl_multi_fdset (
plugin->curl_multi_handle, &rs, &ws, &es, &
max);
596 if (mret != CURLM_OK)
599 _ (
"%s failed at %s:%d: `%s'\n"),
603 curl_multi_strerror (mret));
606 mret = curl_multi_timeout (
plugin->curl_multi_handle, &to);
614 if (CURLM_OK != mret)
617 _ (
"%s failed at %s:%d: `%s'\n"),
618 "curl_multi_timeout", __FILE__, __LINE__,
619 curl_multi_strerror (mret));
629 plugin->client_perform_task =
651 client_log (CURL *
curl,
658 const char *ttype =
"UNSPECIFIED";
661 if (! ((CURLINFO_TEXT ==
type) ||
662 (CURLINFO_HEADER_IN ==
type) ||
663 (CURLINFO_HEADER_OUT ==
type)))
671 case CURLINFO_HEADER_IN:
675 case CURLINFO_HEADER_OUT:
676 ttype =
"HEADER_OUT";
685 ttype =
"UNSPECIFIED";
689 if (text[
size - 1] ==
'\n')
696 text[
size + 1] =
'\0';
761 unsigned int priority,
771 "Session %p/request %p: Sending message with %lu to peer `%s' \n",
774 (
unsigned long) msgbuf_size,
780 msg->buf = (
char *) &
msg[1];
781 msg->transmit_cont = cont;
782 msg->transmit_cont_cls = cont_cls;
793 "# bytes currently in %s_client buffers",
806 "Session %p/request %p: currently disconnecting, reconnecting immediately\n",
818 "Session %p/request %p: unpausing request\n",
855 "Session %p: notifying transport about ending session\n",
863 if (NULL !=
plugin->client_perform_task)
866 plugin->client_perform_task = NULL;
925 "Transport tells me to disconnect `%s'\n",
1013 "Session %p/request %p: will be disconnected due to no activity\n",
1048 "Session %p/request %p: disconnect due to inactivity\n",
1058 "Session %p/request %p: PUT request finished\n",
1067 "Session %p/request %p: nothing to send, suspending\n",
1075 return CURL_READFUNC_PAUSE;
1089 "Session %p/request %p: sent message with %lu bytes sent, removing message from queue\n",
1101 if (NULL !=
msg->transmit_cont)
1102 msg->transmit_cont (
msg->transmit_cont_cls,
1114 "# bytes currently in %s_client buffers",
1122 "# bytes transmitted via %s_client",
1145 "Session %p/request %p: Waking up GET handle\n",
1184 "# bytes received via %s_client",
1188 ntohs (message->
size),
1196 "Client: peer `%s' address `%s' next read delayed for %s\n",
1225 return size * nmemb;
1250 "Session %p / request %p: Received %lu bytes from peer `%s'\n",
1253 (
unsigned long)
len,
1263 "Session %p / request %p: No inbound bandwidth available! Next read was delayed for %s\n",
1277 return CURL_WRITEFUNC_PAUSE;
1296 long http_statuscode;
1302 plugin->client_perform_task = NULL;
1308 mret = curl_multi_perform (
plugin->curl_multi_handle, &running);
1311 while (NULL != (
msg = curl_multi_info_read (
plugin->curl_multi_handle,
1314 CURL *easy_h =
msg->easy_handle;
1321 GNUNET_assert (CURLE_OK == curl_easy_getinfo (easy_h, CURLINFO_PRIVATE,
1326 if (
msg->msg != CURLMSG_DONE)
1331 CURLINFO_RESPONSE_CODE,
1340 if ((0 !=
msg->data.result) || (http_statuscode != 200))
1342 "Session %p/request %p: %s request to `%s' ended with status %li reason %i: `%s'\n",
1343 s,
msg->easy_handle,
1348 curl_easy_strerror (
msg->data.result));
1351 "Session %p/request %p: %s request to `%s' ended normal\n",
1352 s,
msg->easy_handle,
1357 curl_multi_remove_handle (
plugin->curl_multi_handle, easy_h);
1360 curl_easy_cleanup (easy_h);
1366 "%s request to %s done, number of requests decreased to %u\n",
1441 while (mret == CURLM_CALL_MULTI_PERFORM);
1455 static curl_socket_t
1456 open_tcp_stealth_socket_cb (
void *clientp,
1457 curlsocktype purpose,
1458 struct curl_sockaddr *
address)
1465 case CURLSOCKTYPE_IPCXN:
1470 return CURL_SOCKET_BAD;
1471 if (((SOCK_STREAM !=
address->socktype) ||
1473 (IPPROTO_TCP !=
address->protocol))))
1474 return (curl_socket_t)
ret;
1475 if ((0 != setsockopt (
ret,
1482 _ (
"TCP_STEALTH not supported on this platform.\n"));
1484 return CURL_SOCKET_BAD;
1486 return (curl_socket_t)
ret;
1488 case CURLSOCKTYPE_ACCEPT:
1490 return CURL_SOCKET_BAD;
1493 case CURLSOCKTYPE_LAST:
1495 return CURL_SOCKET_BAD;
1499 return CURL_SOCKET_BAD;
1529 CURLOPT_OPENSOCKETFUNCTION,
1530 &open_tcp_stealth_socket_cb);
1532 CURLOPT_OPENSOCKETDATA,
1536 "Cannot connect, TCP STEALTH needed and not supported by kernel.\n");
1549 CURLOPT_DEBUGFUNCTION,
1557 CURL_SSLVERSION_TLSv1);
1563 CURLOPT_SSL_VERIFYPEER, 1L);
1565 CURLOPT_SSL_VERIFYHOST,
1571 CURLOPT_SSL_VERIFYPEER,
1574 CURLOPT_SSL_VERIFYHOST,
1582 CURLOPT_REDIR_PROTOCOLS,
1589 CURLOPT_REDIR_PROTOCOLS,
1593 if (NULL != s->
plugin->proxy_hostname)
1597 s->
plugin->proxy_hostname);
1601 if (NULL != s->
plugin->proxy_username)
1603 CURLOPT_PROXYUSERNAME,
1604 s->
plugin->proxy_username);
1605 if (NULL != s->
plugin->proxy_password)
1607 CURLOPT_PROXYPASSWORD,
1608 s->
plugin->proxy_password);
1611 CURLOPT_HTTPPROXYTUNNEL,
1612 s->
plugin->proxy_use_httpproxytunnel);
1634 CURLOPT_READFUNCTION,
1640 CURLOPT_WRITEFUNCTION,
1650 CURLOPT_PRIVATE, s);
1652 CURLOPT_CONNECTTIMEOUT_MS,
1657 #if CURL_TCP_NODELAY
1658 curl_easy_setopt (ps->recv_endpoint,
1659 CURLOPT_TCP_NODELAY,
1663 CURLOPT_FOLLOWLOCATION,
1666 mret = curl_multi_add_handle (s->
plugin->curl_multi_handle,
1668 if (CURLM_OK != mret)
1671 "Session %p : Failed to add GET handle to multihandle: `%s'\n",
1673 curl_multi_strerror (mret));
1680 s->
plugin->cur_requests++;
1682 "GET request `%s' established, number of requests increased to %u\n",
1684 s->
plugin->cur_requests);
1700 "Session %p: Init PUT handle\n",
1709 CURLOPT_DEBUGFUNCTION,
1719 CURLOPT_OPENSOCKETFUNCTION,
1720 &open_tcp_stealth_socket_cb);
1722 CURLOPT_OPENSOCKETDATA,
1726 "Cannot connect, TCP STEALTH needed and not supported by kernel.\n");
1737 CURL_SSLVERSION_TLSv1);
1746 CURLOPT_SSL_VERIFYPEER,
1749 CURLOPT_SSL_VERIFYHOST,
1755 CURLOPT_SSL_VERIFYPEER,
1758 CURLOPT_SSL_VERIFYHOST,
1766 CURLOPT_REDIR_PROTOCOLS,
1773 CURLOPT_REDIR_PROTOCOLS,
1776 if (NULL != s->
plugin->proxy_hostname)
1780 s->
plugin->proxy_hostname);
1784 if (NULL != s->
plugin->proxy_username)
1786 CURLOPT_PROXYUSERNAME,
1787 s->
plugin->proxy_username);
1788 if (NULL != s->
plugin->proxy_password)
1790 CURLOPT_PROXYPASSWORD,
1791 s->
plugin->proxy_password);
1794 CURLOPT_HTTPPROXYTUNNEL,
1795 s->
plugin->proxy_use_httpproxytunnel);
1805 CURLOPT_READFUNCTION,
1811 CURLOPT_WRITEFUNCTION,
1824 CURLOPT_CONNECTTIMEOUT_MS,
1829 #if CURL_TCP_NODELAY
1830 curl_easy_setopt (s->
put.
easyhandle, CURLOPT_TCP_NODELAY, 1);
1832 mret = curl_multi_add_handle (s->
plugin->curl_multi_handle,
1834 if (CURLM_OK != mret)
1837 "Session %p : Failed to add PUT handle to multihandle: `%s'\n",
1838 s, curl_multi_strerror (mret));
1846 s->
plugin->cur_requests++;
1849 "PUT request `%s' established, number of requests increased to %u\n",
1875 "Invalid address peer `%s'\n",
1890 "Initiating outbound session peer `%s' using address `%s'\n",
1906 "Session %p: connected with GET %p and PUT %p\n",
1915 if (NULL !=
plugin->client_perform_task)
1918 plugin->client_perform_task = NULL;
1939 return session->
scope;
1988 "Session %p was idle for %s, disconnecting\n",
2012 struct sockaddr *sa;
2028 "Maximum number of requests (%u) reached: "
2029 "cannot connect to peer `%s'\n",
2045 if (AF_INET == sa->sa_family)
2047 salen =
sizeof(
struct sockaddr_in);
2049 else if (AF_INET6 == sa->sa_family)
2051 salen =
sizeof(
struct sockaddr_in6);
2053 net_type =
plugin->env->get_address_type (
plugin->env->cls, sa, salen);
2070 s->
scope = net_type;
2078 "Created new session %p for `%s' address `%s''\n",
2094 "Cannot connect to peer `%s' address `%s''\n",
2121 curl_global_init (CURL_GLOBAL_ALL);
2122 plugin->curl_multi_handle = curl_multi_init ();
2124 if (NULL ==
plugin->curl_multi_handle)
2128 "Could not initialize curl multi handle, failed to start %s plugin!\n"),
2170 if (NULL == api->
cls)
2177 _ (
"Shutting down plugin `%s'\n"),
2182 if (NULL !=
plugin->client_perform_task)
2185 plugin->client_perform_task = NULL;
2187 if (NULL !=
plugin->curl_multi_handle)
2189 curl_multi_cleanup (
plugin->curl_multi_handle);
2190 plugin->curl_multi_handle = NULL;
2192 curl_global_cleanup ();
2194 _ (
"Shutdown for plugin `%s' complete\n"),
2228 _ (
"Maximum number of requests is %u\n"),
2236 &
plugin->proxy_hostname))
2239 "Found proxy host: `%s'\n",
2246 &
plugin->proxy_username))
2249 "Found proxy username name: `%s'\n",
2258 &
plugin->proxy_password))
2261 "Found proxy password name: `%s'\n",
2275 plugin->proxytype = CURLPROXY_HTTP;
2277 plugin->proxytype = CURLPROXY_SOCKS4;
2279 plugin->proxytype = CURLPROXY_SOCKS5;
2280 else if (0 == strcmp (
proxy_type,
"SOCKS4A"))
2281 plugin->proxytype = CURLPROXY_SOCKS4A;
2282 else if (0 == strcmp (
proxy_type,
"SOCKS5_HOSTNAME "))
2283 plugin->proxytype = CURLPROXY_SOCKS5_HOSTNAME;
2288 "Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
2293 plugin->proxy_hostname = NULL;
2295 plugin->proxy_username = NULL;
2297 plugin->proxy_password = NULL;
2303 "Found proxy type: `%s'\n",
2308 plugin->proxy_use_httpproxytunnel
2311 "PROXY_HTTP_TUNNELING");
2383 "New inbound delay %s\n",
2466 if (NULL ==
env->receive)
2499 plugin->name =
"transport-https_client";
2500 plugin->protocol =
"https";
2502 plugin->name =
"transport-http_client";
2503 plugin->protocol =
"http";
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static int ret
Return value of the commandline.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static struct GNUNET_CADET_Channel * ch
Channel handle.
struct TestcasePlugin * plugin
The process handle to the testbed service.
static char * address
GNS address for this phone.
static CURL * curl
Current CURL handle.
static curl_proxytype proxy_type
Proxy type we are using (can be NULL).
struct GNUNET_HashCode key
The key used in the DHT.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * value
Value of the record to add/remove.
enum State state
current state of profiling
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
library to make it easy to download JSON replies over HTTP
Constants for network protocols.
Transport service plugin API.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don't receive messages from the peer?
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_HELLO_address_free(addr)
Free an address.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_SCHEDULER_PRIORITY_DEFAULT
Run with the default priority (normal P2P operations).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
void GNUNET_NETWORK_fdset_copy_native(struct GNUNET_NETWORK_FDSet *to, const fd_set *from, int nfds)
Copy a native fd set into the GNUnet representation.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
@ GNUNET_NT_WAN
Wide area network (i.e.
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
enum GNUNET_GenericReturnValue GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
void(* GNUNET_TRANSPORT_SessionInfoCallback)(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
void(* GNUNET_TRANSPORT_TransmitContinuation)(void *cls, const struct GNUNET_PeerIdentity *target, int result, size_t size_payload, size_t size_on_wire)
Function called by the GNUNET_TRANSPORT_TransmitFunction upon "completion".
GNUNET_TRANSPORT_SessionState
Possible states of a session in a plugin.
@ GNUNET_TRANSPORT_SS_INIT
The session was created (first call for each session object).
@ GNUNET_TRANSPORT_SS_DONE
Session is being torn down and about to disappear.
@ GNUNET_TRANSPORT_SS_UP
Session is fully UP.
@ GNUNET_TRANSPORT_SS_UPDATE
This is just an update about the session, the state did not change.
static unsigned int size
Size of the "table".
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.
static int client_connect_put(struct GNUNET_ATS_Session *s)
Connect a HTTP put request.
static int session_lookup_client_by_address(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Locate the seession object for a given address.
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.
static enum GNUNET_NetworkType http_client_plugin_get_network(void *cls, struct GNUNET_ATS_Session *session)
Function obtain the network type for a session.
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.
#define LIBGNUNET_PLUGIN_TRANSPORT_DONE
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.
static int client_configure_plugin(struct HTTP_Client_Plugin *plugin)
Configure plugin.
static void client_session_timeout(void *cls)
Session was idle, so disconnect it.
HTTP_PUT_REQUEST_STATE
State of a HTTP PUT request.
@ H_TMP_RECONNECT_REQUIRED
Send request while temporary disconnect, reconnect.
@ H_PAUSED
Paused, nothing to send.
@ H_DISCONNECTED
Disconnected.
@ H_TMP_DISCONNECTING
Temporary disconnect in progress due to inactivity.
@ H_NOT_CONNECTED
Just created, not yet connected.
@ H_TMP_DISCONNECTED
Temporarily disconnected.
#define PUT_DISCONNECT_TIMEOUT
static int client_start(struct HTTP_Client_Plugin *plugin)
Setup http_client plugin.
static int client_schedule(struct HTTP_Client_Plugin *plugin, int now)
Function setting up file descriptors and scheduling task to run.
static int http_client_plugin_session_disconnect(void *cls, struct GNUNET_ATS_Session *s)
Disconnect a session.
static unsigned int http_client_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
static int destroy_session_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Callback to destroys all sessions on exit.
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.
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.
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...
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT
static int client_connect(struct GNUNET_ATS_Session *s)
Connect both PUT and GET request for a session.
#define HTTP_STAT_STR_CONNECTIONS
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.
static void http_client_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
static int client_receive_mst_cb(void *cls, const struct GNUNET_MessageHeader *message)
Callback for message stream tokenizer.
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 previo...
static void client_reschedule_session_timeout(struct GNUNET_ATS_Session *s)
Increment session timeout due to activity for session s.
static int client_connect_get(struct GNUNET_ATS_Session *s)
Connect GET request.
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 inbou...
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.
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.
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.
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.
static void client_run(void *cls)
Task performing curl operations.
static void client_wake_up(void *cls)
Wake up a curl handle which was suspended.
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).
static void client_delete_session(struct GNUNET_ATS_Session *s)
Delete session s.
const char * http_common_plugin_address_to_string(const char *plugin, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
int http_common_plugin_string_to_address(void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added)
Function called to convert a string address to a binary address.
void http_common_plugin_address_pretty_printer(void *cls, const char *type, const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls)
Convert the transports address to a nice, human-readable format.
const char * http_common_plugin_address_to_url(void *cls, const void *addr, size_t addrlen)
FIXME.
enum GNUNET_NetworkType http_common_get_network_for_address(struct GNUNET_TRANSPORT_PluginEnvironment *env, const struct GNUNET_HELLO_Address *address)
Function obtain the network type for an address.
struct sockaddr * http_common_socket_from_address(const void *addr, size_t addrlen, int *res)
Create a socketaddr from a HTTP address.
#define HTTP_CLIENT_SESSION_TIMEOUT
@ HTTP_OPTIONS_VERIFY_CERTIFICATE
Verify X509 server certificate, it should be valid.
@ HTTP_OPTIONS_TCP_STEALTH
Enable TCP Stealth-style port knocking.
#define HTTP_CLIENT_NOT_VALIDATED_TIMEOUT
static struct GNUNET_TIME_Relative delta
Closure for session_lookup_client_by_address().
const struct GNUNET_HELLO_Address * address
Address we are looking for.
struct GNUNET_ATS_Session * ret
Session that was found.
Session handle for connections.
struct GNUNET_PeerIdentity target
To whom are we talking to.
struct Plugin * plugin
Pointer to the global plugin struct.
unsigned int msgs_in_queue
Number of messages waiting for transmission to this peer.
struct GNUNET_MessageStreamTokenizer * msg_tk
Message stream tokenizer for incoming data.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
struct HTTP_Message * msg_tail
previous pointer for double linked list
struct GNUNET_HELLO_Address * address
Address.
struct HTTP_Message * msg_head
next pointer for double linked list
enum GNUNET_NetworkType scope
ATS network type.
struct RequestHandle get
Handle for the HTTP GET request.
unsigned long long bytes_in_queue
Number of bytes waiting for transmission to this peer.
char * url
The URL to connect to.
struct RequestHandle put
Handle for the HTTP PUT request.
size_t overhead
Outbound overhead due to HTTP connection Add to next message of this session when calling callback.
struct GNUNET_SCHEDULER_Task * recv_wakeup_task
Task to wake up client receive handle when receiving is allowed again.
struct GNUNET_SCHEDULER_Task * put_disconnect_task
Session timeout task.
struct GNUNET_TIME_Absolute next_receive
Absolute time when to receive data again Used for receive throttling.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
struct GNUNET_SERVER_MessageStreamTokenizer * msg_tk
Message stream tokenizer for incoming data.
Internal representation of the hash map.
An address for communicating with a peer.
size_t address_length
Number of bytes in address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
const void * address
Binary representation of the address (plugin-specific).
Handle to a message stream tokenizer.
collection of IO descriptors
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
void * cls
Closure for the various callbacks.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.
GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor
Function to monitor the sessions managed by the plugin.
GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address
Function to obtain the network type for an address.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only).
GNUNET_TRANSPORT_GetNetworkType get_network
Function to obtain the network type for a session.
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.
GNUNET_TRANSPORT_CheckAddress check_address
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only).
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
Information about a plugin's session.
Encapsulation of all of the state of the plugin.
int emulate_xhr
Should we emulate an XHR client for testing?
unsigned int cur_requests
Current number of sockets the plugin can use Each http connections are two requests.
CURLM * curl_multi_handle
cURL Multihandle
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
uint32_t options
My options to be included in the address.
char * proxy_hostname
Proxy configuration: hostname or ip of the proxy server.
int proxy_use_httpproxytunnel
Use proxy tunneling: Tunnel all operations through a given HTTP instead of have the proxy evaluate th...
curl_proxytype proxytype
Type of proxy server:
char * proxy_password
Password for the proxy server.
void * sic_cls
Closure for sic.
struct GNUNET_TRANSPORT_PluginEnvironment * env
Our environment.
struct GNUNET_CONTAINER_MultiPeerMap * sessions
Open sessions.
uint16_t use_ipv6
use IPv6
uint16_t use_ipv4
use IPv4
struct GNUNET_SCHEDULER_Task * client_perform_task
curl perform task
char * proxy_username
Username for the proxy server.
uint32_t last_tag
Last used unique HTTP connection tag.
unsigned int max_requests
Maximum number of sockets the plugin can use Each http connections are two requests.
Message to send using http.
struct HTTP_Message * next
next pointer for double linked list
size_t pos
amount of data already sent
GNUNET_TRANSPORT_TransmitContinuation transmit_cont
Continuation function to call once the transmission buffer has again space available.
void * transmit_cont_cls
Closure for transmit_cont.
char * buf
buffer containing data to send
struct HTTP_Message * prev
previous pointer for double linked list
HTTP addresses including a full URI.
uint32_t options
Address options see enum HttpAddressOptions
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
char * protocol
Plugin protocol http, https.
enum HTTP_PUT_REQUEST_STATE state
Current state of this request.
struct GNUNET_ATS_Session * s
The related session.
CURL * easyhandle
The curl easy handle.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.