aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r--src/transport/plugin_transport_http_client.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index 8066fb384..262961a29 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -152,7 +152,7 @@ struct HTTP_Message
152/** 152/**
153 * Session handle for HTTP(S) connections. 153 * Session handle for HTTP(S) connections.
154 */ 154 */
155struct Session; 155struct GNUNET_ATS_Session;
156 156
157 157
158/** 158/**
@@ -174,14 +174,14 @@ struct RequestHandle
174 /** 174 /**
175 * The related session 175 * The related session
176 */ 176 */
177 struct Session *s; 177 struct GNUNET_ATS_Session *s;
178}; 178};
179 179
180 180
181/** 181/**
182 * Session handle for connections. 182 * Session handle for connections.
183 */ 183 */
184struct Session 184struct GNUNET_ATS_Session
185{ 185{
186 /** 186 /**
187 * The URL to connect to 187 * The URL to connect to
@@ -397,7 +397,7 @@ struct HTTP_Client_Plugin
397 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 397 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
398 */ 398 */
399static int 399static int
400http_client_plugin_session_disconnect (void *cls, struct Session *s); 400http_client_plugin_session_disconnect (void *cls, struct GNUNET_ATS_Session *s);
401 401
402 402
403/** 403/**
@@ -410,7 +410,7 @@ http_client_plugin_session_disconnect (void *cls, struct Session *s);
410 */ 410 */
411static void 411static void
412notify_session_monitor (struct HTTP_Client_Plugin *plugin, 412notify_session_monitor (struct HTTP_Client_Plugin *plugin,
413 struct Session *session, 413 struct GNUNET_ATS_Session *session,
414 enum GNUNET_TRANSPORT_SessionState state) 414 enum GNUNET_TRANSPORT_SessionState state)
415{ 415{
416 struct GNUNET_TRANSPORT_SessionInfo info; 416 struct GNUNET_TRANSPORT_SessionInfo info;
@@ -437,7 +437,7 @@ notify_session_monitor (struct HTTP_Client_Plugin *plugin,
437 * @param s the session to delete 437 * @param s the session to delete
438 */ 438 */
439static void 439static void
440client_delete_session (struct Session *s) 440client_delete_session (struct GNUNET_ATS_Session *s)
441{ 441{
442 struct HTTP_Client_Plugin *plugin = s->plugin; 442 struct HTTP_Client_Plugin *plugin = s->plugin;
443 struct HTTP_Message *pos; 443 struct HTTP_Message *pos;
@@ -543,7 +543,7 @@ client_delete_session (struct Session *s)
543 * @param s the session 543 * @param s the session
544 */ 544 */
545static void 545static void
546client_reschedule_session_timeout (struct Session *s) 546client_reschedule_session_timeout (struct GNUNET_ATS_Session *s)
547{ 547{
548 GNUNET_assert (NULL != s->timeout_task); 548 GNUNET_assert (NULL != s->timeout_task);
549 s->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 549 s->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
@@ -708,7 +708,7 @@ client_log (CURL *curl,
708 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 708 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
709 */ 709 */
710static int 710static int
711client_connect_get (struct Session *s); 711client_connect_get (struct GNUNET_ATS_Session *s);
712 712
713 713
714/** 714/**
@@ -718,7 +718,7 @@ client_connect_get (struct Session *s);
718 * @return #GNUNET_SYSERR for hard failure, #GNUNET_OK for success 718 * @return #GNUNET_SYSERR for hard failure, #GNUNET_OK for success
719 */ 719 */
720static int 720static int
721client_connect_put (struct Session *s); 721client_connect_put (struct GNUNET_ATS_Session *s);
722 722
723 723
724/** 724/**
@@ -750,7 +750,7 @@ client_connect_put (struct Session *s);
750 */ 750 */
751static ssize_t 751static ssize_t
752http_client_plugin_send (void *cls, 752http_client_plugin_send (void *cls,
753 struct Session *s, 753 struct GNUNET_ATS_Session *s,
754 const char *msgbuf, 754 const char *msgbuf,
755 size_t msgbuf_size, 755 size_t msgbuf_size,
756 unsigned int priority, 756 unsigned int priority,
@@ -842,7 +842,7 @@ http_client_plugin_send (void *cls,
842 */ 842 */
843static int 843static int
844http_client_plugin_session_disconnect (void *cls, 844http_client_plugin_session_disconnect (void *cls,
845 struct Session *s) 845 struct GNUNET_ATS_Session *s)
846{ 846{
847 struct HTTP_Client_Plugin *plugin = cls; 847 struct HTTP_Client_Plugin *plugin = cls;
848 848
@@ -886,7 +886,7 @@ http_client_query_keepalive_factor (void *cls)
886 * 886 *
887 * @param cls the `struct HTTP_Client_Plugin *` 887 * @param cls the `struct HTTP_Client_Plugin *`
888 * @param peer identity of the peer 888 * @param peer identity of the peer
889 * @param value the `struct Session *` 889 * @param value the `struct GNUNET_ATS_Session *`
890 * @return #GNUNET_OK (continue iterating) 890 * @return #GNUNET_OK (continue iterating)
891 */ 891 */
892static int 892static int
@@ -895,7 +895,7 @@ destroy_session_cb (void *cls,
895 void *value) 895 void *value)
896{ 896{
897 struct HTTP_Client_Plugin *plugin = cls; 897 struct HTTP_Client_Plugin *plugin = cls;
898 struct Session *session = value; 898 struct GNUNET_ATS_Session *session = value;
899 899
900 http_client_plugin_session_disconnect (plugin, session); 900 http_client_plugin_session_disconnect (plugin, session);
901 return GNUNET_OK; 901 return GNUNET_OK;
@@ -929,7 +929,7 @@ http_client_plugin_peer_disconnect (void *cls,
929/** 929/**
930 * Closure for #session_lookup_client_by_address(). 930 * Closure for #session_lookup_client_by_address().
931 */ 931 */
932struct SessionClientCtx 932struct GNUNET_ATS_SessionClientCtx
933{ 933{
934 /** 934 /**
935 * Address we are looking for. 935 * Address we are looking for.
@@ -939,16 +939,16 @@ struct SessionClientCtx
939 /** 939 /**
940 * Session that was found. 940 * Session that was found.
941 */ 941 */
942 struct Session *ret; 942 struct GNUNET_ATS_Session *ret;
943}; 943};
944 944
945 945
946/** 946/**
947 * Locate the seession object for a given address. 947 * Locate the seession object for a given address.
948 * 948 *
949 * @param cls the `struct SessionClientCtx *` 949 * @param cls the `struct GNUNET_ATS_SessionClientCtx *`
950 * @param key peer identity 950 * @param key peer identity
951 * @param value the `struct Session` to check 951 * @param value the `struct GNUNET_ATS_Session` to check
952 * @return #GNUNET_NO if found, #GNUNET_OK if not 952 * @return #GNUNET_NO if found, #GNUNET_OK if not
953 */ 953 */
954static int 954static int
@@ -956,8 +956,8 @@ session_lookup_client_by_address (void *cls,
956 const struct GNUNET_PeerIdentity *key, 956 const struct GNUNET_PeerIdentity *key,
957 void *value) 957 void *value)
958{ 958{
959 struct SessionClientCtx *sc_ctx = cls; 959 struct GNUNET_ATS_SessionClientCtx *sc_ctx = cls;
960 struct Session *s = value; 960 struct GNUNET_ATS_Session *s = value;
961 961
962 if (0 == GNUNET_HELLO_address_cmp (sc_ctx->address, 962 if (0 == GNUNET_HELLO_address_cmp (sc_ctx->address,
963 s->address)) 963 s->address))
@@ -976,11 +976,11 @@ session_lookup_client_by_address (void *cls,
976 * @param address the address 976 * @param address the address
977 * @return the session or NULL 977 * @return the session or NULL
978 */ 978 */
979static struct Session * 979static struct GNUNET_ATS_Session *
980client_lookup_session (struct HTTP_Client_Plugin *plugin, 980client_lookup_session (struct HTTP_Client_Plugin *plugin,
981 const struct GNUNET_HELLO_Address *address) 981 const struct GNUNET_HELLO_Address *address)
982{ 982{
983 struct SessionClientCtx sc_ctx; 983 struct GNUNET_ATS_SessionClientCtx sc_ctx;
984 984
985 sc_ctx.address = address; 985 sc_ctx.address = address;
986 sc_ctx.ret = NULL; 986 sc_ctx.ret = NULL;
@@ -996,14 +996,14 @@ client_lookup_session (struct HTTP_Client_Plugin *plugin,
996 * after a while (so that gnurl stops asking). This task 996 * after a while (so that gnurl stops asking). This task
997 * is the delayed task that actually disconnects the PUT. 997 * is the delayed task that actually disconnects the PUT.
998 * 998 *
999 * @param cls the `struct Session *` with the put 999 * @param cls the `struct GNUNET_ATS_Session *` with the put
1000 * @param tc scheduler context 1000 * @param tc scheduler context
1001 */ 1001 */
1002static void 1002static void
1003client_put_disconnect (void *cls, 1003client_put_disconnect (void *cls,
1004 const struct GNUNET_SCHEDULER_TaskContext *tc) 1004 const struct GNUNET_SCHEDULER_TaskContext *tc)
1005{ 1005{
1006 struct Session *s = cls; 1006 struct GNUNET_ATS_Session *s = cls;
1007 1007
1008 s->put_disconnect_task = NULL; 1008 s->put_disconnect_task = NULL;
1009 LOG (GNUNET_ERROR_TYPE_DEBUG, 1009 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1024,7 +1024,7 @@ client_put_disconnect (void *cls,
1024 * @param stream pointer where to write data 1024 * @param stream pointer where to write data
1025 * @param size size of an individual element 1025 * @param size size of an individual element
1026 * @param nmemb count of elements that can be written to the buffer 1026 * @param nmemb count of elements that can be written to the buffer
1027 * @param cls our `struct Session` 1027 * @param cls our `struct GNUNET_ATS_Session`
1028 * @return bytes written to stream, returning 0 will terminate request! 1028 * @return bytes written to stream, returning 0 will terminate request!
1029 */ 1029 */
1030static size_t 1030static size_t
@@ -1033,7 +1033,7 @@ client_send_cb (void *stream,
1033 size_t nmemb, 1033 size_t nmemb,
1034 void *cls) 1034 void *cls)
1035{ 1035{
1036 struct Session *s = cls; 1036 struct GNUNET_ATS_Session *s = cls;
1037 struct HTTP_Client_Plugin *plugin = s->plugin; 1037 struct HTTP_Client_Plugin *plugin = s->plugin;
1038 struct HTTP_Message *msg = s->msg_head; 1038 struct HTTP_Message *msg = s->msg_head;
1039 size_t len; 1039 size_t len;
@@ -1134,7 +1134,7 @@ static void
1134client_wake_up (void *cls, 1134client_wake_up (void *cls,
1135 const struct GNUNET_SCHEDULER_TaskContext *tc) 1135 const struct GNUNET_SCHEDULER_TaskContext *tc)
1136{ 1136{
1137 struct Session *s = cls; 1137 struct GNUNET_ATS_Session *s = cls;
1138 1138
1139 s->recv_wakeup_task = NULL; 1139 s->recv_wakeup_task = NULL;
1140 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1140 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
@@ -1170,7 +1170,7 @@ client_receive_mst_cb (void *cls,
1170 void *client, 1170 void *client,
1171 const struct GNUNET_MessageHeader *message) 1171 const struct GNUNET_MessageHeader *message)
1172{ 1172{
1173 struct Session *s = cls; 1173 struct GNUNET_ATS_Session *s = cls;
1174 struct HTTP_Client_Plugin *plugin; 1174 struct HTTP_Client_Plugin *plugin;
1175 struct GNUNET_TIME_Relative delay; 1175 struct GNUNET_TIME_Relative delay;
1176 char *stat_txt; 1176 char *stat_txt;
@@ -1242,7 +1242,7 @@ client_receive (void *stream,
1242 size_t nmemb, 1242 size_t nmemb,
1243 void *cls) 1243 void *cls)
1244{ 1244{
1245 struct Session *s = cls; 1245 struct GNUNET_ATS_Session *s = cls;
1246 struct GNUNET_TIME_Absolute now; 1246 struct GNUNET_TIME_Absolute now;
1247 size_t len = size * nmemb; 1247 size_t len = size * nmemb;
1248 1248
@@ -1322,14 +1322,14 @@ client_run (void *cls,
1322 while (NULL != (msg = curl_multi_info_read (plugin->curl_multi_handle, &msgs_left))) 1322 while (NULL != (msg = curl_multi_info_read (plugin->curl_multi_handle, &msgs_left)))
1323 { 1323 {
1324 CURL *easy_h = msg->easy_handle; 1324 CURL *easy_h = msg->easy_handle;
1325 struct Session *s = NULL; 1325 struct GNUNET_ATS_Session *s = NULL;
1326 char *d = NULL; /* curl requires 'd' to be a 'char *' */ 1326 char *d = NULL; /* curl requires 'd' to be a 'char *' */
1327 1327
1328 GNUNET_assert (NULL != easy_h); 1328 GNUNET_assert (NULL != easy_h);
1329 1329
1330 /* Obtain session from easy handle */ 1330 /* Obtain session from easy handle */
1331 GNUNET_assert (CURLE_OK == curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); 1331 GNUNET_assert (CURLE_OK == curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d));
1332 s = (struct Session *) d; 1332 s = (struct GNUNET_ATS_Session *) d;
1333 GNUNET_assert (NULL != s); 1333 GNUNET_assert (NULL != s);
1334 1334
1335 if (msg->msg != CURLMSG_DONE) 1335 if (msg->msg != CURLMSG_DONE)
@@ -1450,7 +1450,7 @@ client_run (void *cls,
1450/** 1450/**
1451 * Open TCP socket with TCP STEALTH enabled. 1451 * Open TCP socket with TCP STEALTH enabled.
1452 * 1452 *
1453 * @param clientp our `struct Session *` 1453 * @param clientp our `struct GNUNET_ATS_Session *`
1454 * @param purpose why does curl want to open a socket 1454 * @param purpose why does curl want to open a socket
1455 * @param address what kind of socket does curl want to have opened? 1455 * @param address what kind of socket does curl want to have opened?
1456 * @return opened socket 1456 * @return opened socket
@@ -1460,7 +1460,7 @@ open_tcp_stealth_socket_cb (void *clientp,
1460 curlsocktype purpose, 1460 curlsocktype purpose,
1461 struct curl_sockaddr *address) 1461 struct curl_sockaddr *address)
1462{ 1462{
1463 struct Session *s = clientp; 1463 struct GNUNET_ATS_Session *s = clientp;
1464 int ret; 1464 int ret;
1465 1465
1466 switch (purpose) 1466 switch (purpose)
@@ -1509,7 +1509,7 @@ open_tcp_stealth_socket_cb (void *clientp,
1509 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 1509 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
1510 */ 1510 */
1511static int 1511static int
1512client_connect_get (struct Session *s) 1512client_connect_get (struct GNUNET_ATS_Session *s)
1513{ 1513{
1514 CURLMcode mret; 1514 CURLMcode mret;
1515 struct HttpAddress *ha; 1515 struct HttpAddress *ha;
@@ -1689,7 +1689,7 @@ client_connect_get (struct Session *s)
1689 * @return #GNUNET_SYSERR for hard failure, #GNUNET_OK for ok 1689 * @return #GNUNET_SYSERR for hard failure, #GNUNET_OK for ok
1690 */ 1690 */
1691static int 1691static int
1692client_connect_put (struct Session *s) 1692client_connect_put (struct GNUNET_ATS_Session *s)
1693{ 1693{
1694 CURLMcode mret; 1694 CURLMcode mret;
1695 struct HttpAddress *ha; 1695 struct HttpAddress *ha;
@@ -1861,7 +1861,7 @@ client_connect_put (struct Session *s)
1861 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 1861 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
1862 */ 1862 */
1863static int 1863static int
1864client_connect (struct Session *s) 1864client_connect (struct GNUNET_ATS_Session *s)
1865{ 1865{
1866 struct HTTP_Client_Plugin *plugin = s->plugin; 1866 struct HTTP_Client_Plugin *plugin = s->plugin;
1867 int res = GNUNET_OK; 1867 int res = GNUNET_OK;
@@ -1935,7 +1935,7 @@ client_connect (struct Session *s)
1935 */ 1935 */
1936static enum GNUNET_ATS_Network_Type 1936static enum GNUNET_ATS_Network_Type
1937http_client_plugin_get_network (void *cls, 1937http_client_plugin_get_network (void *cls,
1938 struct Session *session) 1938 struct GNUNET_ATS_Session *session)
1939{ 1939{
1940 return session->scope; 1940 return session->scope;
1941} 1941}
@@ -1962,14 +1962,14 @@ http_client_plugin_get_network_for_address (void *cls,
1962/** 1962/**
1963 * Session was idle, so disconnect it 1963 * Session was idle, so disconnect it
1964 * 1964 *
1965 * @param cls the `struct Session` of the idle session 1965 * @param cls the `struct GNUNET_ATS_Session` of the idle session
1966 * @param tc scheduler context 1966 * @param tc scheduler context
1967 */ 1967 */
1968static void 1968static void
1969client_session_timeout (void *cls, 1969client_session_timeout (void *cls,
1970 const struct GNUNET_SCHEDULER_TaskContext *tc) 1970 const struct GNUNET_SCHEDULER_TaskContext *tc)
1971{ 1971{
1972 struct Session *s = cls; 1972 struct GNUNET_ATS_Session *s = cls;
1973 struct GNUNET_TIME_Relative left; 1973 struct GNUNET_TIME_Relative left;
1974 1974
1975 s->timeout_task = NULL; 1975 s->timeout_task = NULL;
@@ -2005,12 +2005,12 @@ client_session_timeout (void *cls,
2005 * @param address the address 2005 * @param address the address
2006 * @return the session or NULL of max connections exceeded 2006 * @return the session or NULL of max connections exceeded
2007 */ 2007 */
2008static struct Session * 2008static struct GNUNET_ATS_Session *
2009http_client_plugin_get_session (void *cls, 2009http_client_plugin_get_session (void *cls,
2010 const struct GNUNET_HELLO_Address *address) 2010 const struct GNUNET_HELLO_Address *address)
2011{ 2011{
2012 struct HTTP_Client_Plugin *plugin = cls; 2012 struct HTTP_Client_Plugin *plugin = cls;
2013 struct Session *s; 2013 struct GNUNET_ATS_Session *s;
2014 struct sockaddr *sa; 2014 struct sockaddr *sa;
2015 enum GNUNET_ATS_Network_Type net_type; 2015 enum GNUNET_ATS_Network_Type net_type;
2016 size_t salen = 0; 2016 size_t salen = 0;
@@ -2066,7 +2066,7 @@ http_client_plugin_get_session (void *cls,
2066 return NULL; 2066 return NULL;
2067 } 2067 }
2068 2068
2069 s = GNUNET_new (struct Session); 2069 s = GNUNET_new (struct GNUNET_ATS_Session);
2070 s->plugin = plugin; 2070 s->plugin = plugin;
2071 s->address = GNUNET_HELLO_address_copy (address); 2071 s->address = GNUNET_HELLO_address_copy (address);
2072 s->scope = net_type; 2072 s->scope = net_type;
@@ -2354,7 +2354,7 @@ http_client_plugin_address_to_string (void *cls,
2354static void 2354static void
2355http_client_plugin_update_session_timeout (void *cls, 2355http_client_plugin_update_session_timeout (void *cls,
2356 const struct GNUNET_PeerIdentity *peer, 2356 const struct GNUNET_PeerIdentity *peer,
2357 struct Session *session) 2357 struct GNUNET_ATS_Session *session)
2358{ 2358{
2359 client_reschedule_session_timeout (session); 2359 client_reschedule_session_timeout (session);
2360} 2360}
@@ -2373,7 +2373,7 @@ http_client_plugin_update_session_timeout (void *cls,
2373static void 2373static void
2374http_client_plugin_update_inbound_delay (void *cls, 2374http_client_plugin_update_inbound_delay (void *cls,
2375 const struct GNUNET_PeerIdentity *peer, 2375 const struct GNUNET_PeerIdentity *peer,
2376 struct Session *s, 2376 struct GNUNET_ATS_Session *s,
2377 struct GNUNET_TIME_Relative delay) 2377 struct GNUNET_TIME_Relative delay)
2378{ 2378{
2379 s->next_receive = GNUNET_TIME_relative_to_absolute (delay); 2379 s->next_receive = GNUNET_TIME_relative_to_absolute (delay);
@@ -2396,7 +2396,7 @@ http_client_plugin_update_inbound_delay (void *cls,
2396 * 2396 *
2397 * @param cls the `struct Plugin` with the monitor callback (`sic`) 2397 * @param cls the `struct Plugin` with the monitor callback (`sic`)
2398 * @param peer peer we send information about 2398 * @param peer peer we send information about
2399 * @param value our `struct Session` to send information about 2399 * @param value our `struct GNUNET_ATS_Session` to send information about
2400 * @return #GNUNET_OK (continue to iterate) 2400 * @return #GNUNET_OK (continue to iterate)
2401 */ 2401 */
2402static int 2402static int
@@ -2405,7 +2405,7 @@ send_session_info_iter (void *cls,
2405 void *value) 2405 void *value)
2406{ 2406{
2407 struct HTTP_Client_Plugin *plugin = cls; 2407 struct HTTP_Client_Plugin *plugin = cls;
2408 struct Session *session = value; 2408 struct GNUNET_ATS_Session *session = value;
2409 2409
2410 notify_session_monitor (plugin, 2410 notify_session_monitor (plugin,
2411 session, 2411 session,