diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-23 19:13:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-23 19:13:45 +0000 |
commit | cb2ba3aea878701a9bf816892de389eb45ca9aa4 (patch) | |
tree | cc7bdcb698f9baa7a627ac5adec6a2d9b0258d54 /src/transport/plugin_transport_http_server.c | |
parent | cb0dcdd39476f0d8d8b599a8b8673c8b7b10fe32 (diff) | |
download | gnunet-cb2ba3aea878701a9bf816892de389eb45ca9aa4.tar.gz gnunet-cb2ba3aea878701a9bf816892de389eb45ca9aa4.zip |
-avoid passing ambiguously typed 'cls' pointer to address_to_string routine in http_common, code cleanup
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index a45a25fbd..aba4b5ed0 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -1183,9 +1183,9 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
1183 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1183 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1184 | "Creating new session %p for peer `%s' connecting from `%s'\n", | 1184 | "Creating new session %p for peer `%s' connecting from `%s'\n", |
1185 | s, GNUNET_i2s (&target), | 1185 | s, GNUNET_i2s (&target), |
1186 | http_common_plugin_address_to_string (NULL, | 1186 | http_common_plugin_address_to_string (plugin->protocol, |
1187 | plugin->protocol, | 1187 | addr, |
1188 | addr, addr_len)); | 1188 | addr_len)); |
1189 | GNUNET_free_non_null (addr); | 1189 | GNUNET_free_non_null (addr); |
1190 | } | 1190 | } |
1191 | sc = GNUNET_new (struct ServerConnection); | 1191 | sc = GNUNET_new (struct ServerConnection); |
@@ -1374,8 +1374,8 @@ server_receive_mst_cb (void *cls, void *client, | |||
1374 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1374 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1375 | "Peer `%s' address `%s' next read delayed for %s\n", | 1375 | "Peer `%s' address `%s' next read delayed for %s\n", |
1376 | GNUNET_i2s (&s->target), | 1376 | GNUNET_i2s (&s->target), |
1377 | http_common_plugin_address_to_string (NULL, | 1377 | http_common_plugin_address_to_string (plugin->protocol, |
1378 | plugin->protocol, s->address->address, | 1378 | s->address->address, |
1379 | s->address->address_length), | 1379 | s->address->address_length), |
1380 | GNUNET_STRINGS_relative_time_to_string (delay, | 1380 | GNUNET_STRINGS_relative_time_to_string (delay, |
1381 | GNUNET_YES)); | 1381 | GNUNET_YES)); |
@@ -1513,8 +1513,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
1513 | "Session %p / Connection %p: Peer `%s' PUT on address `%s' connected\n", | 1513 | "Session %p / Connection %p: Peer `%s' PUT on address `%s' connected\n", |
1514 | s, sc, | 1514 | s, sc, |
1515 | GNUNET_i2s (&s->target), | 1515 | GNUNET_i2s (&s->target), |
1516 | http_common_plugin_address_to_string (NULL, | 1516 | http_common_plugin_address_to_string (plugin->protocol, |
1517 | plugin->protocol, s->address->address, | 1517 | s->address->address, |
1518 | s->address->address_length)); | 1518 | s->address->address_length)); |
1519 | sc->connected = GNUNET_YES; | 1519 | sc->connected = GNUNET_YES; |
1520 | return MHD_YES; | 1520 | return MHD_YES; |
@@ -1526,8 +1526,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
1526 | "Session %p / Connection %p: Peer `%s' PUT on address `%s' finished upload\n", | 1526 | "Session %p / Connection %p: Peer `%s' PUT on address `%s' finished upload\n", |
1527 | s, sc, | 1527 | s, sc, |
1528 | GNUNET_i2s (&s->target), | 1528 | GNUNET_i2s (&s->target), |
1529 | http_common_plugin_address_to_string (NULL, | 1529 | http_common_plugin_address_to_string (plugin->protocol, |
1530 | plugin->protocol, s->address->address, | 1530 | s->address->address, |
1531 | s->address->address_length)); | 1531 | s->address->address_length)); |
1532 | sc->connected = GNUNET_NO; | 1532 | sc->connected = GNUNET_NO; |
1533 | /* Sent HTTP/1.1: 200 OK as PUT Response\ */ | 1533 | /* Sent HTTP/1.1: 200 OK as PUT Response\ */ |
@@ -1546,8 +1546,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
1546 | "Session %p / Connection %p: Peer `%s' PUT on address `%s' received %u bytes\n", | 1546 | "Session %p / Connection %p: Peer `%s' PUT on address `%s' received %u bytes\n", |
1547 | s, sc, | 1547 | s, sc, |
1548 | GNUNET_i2s (&s->target), | 1548 | GNUNET_i2s (&s->target), |
1549 | http_common_plugin_address_to_string (NULL, | 1549 | http_common_plugin_address_to_string (plugin->protocol, |
1550 | plugin->protocol, s->address->address, | 1550 | s->address->address, |
1551 | s->address->address_length), | 1551 | s->address->address_length), |
1552 | *upload_data_size); | 1552 | *upload_data_size); |
1553 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 1553 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
@@ -1622,8 +1622,8 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
1622 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1622 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1623 | "Peer `%s' connection %p, GET on address `%s' disconnected\n", | 1623 | "Peer `%s' connection %p, GET on address `%s' disconnected\n", |
1624 | GNUNET_i2s (&s->target), s->server_send, | 1624 | GNUNET_i2s (&s->target), s->server_send, |
1625 | http_common_plugin_address_to_string (NULL, | 1625 | http_common_plugin_address_to_string (plugin->protocol, |
1626 | plugin->protocol, s->address->address, | 1626 | s->address->address, |
1627 | s->address->address_length)); | 1627 | s->address->address_length)); |
1628 | s->server_send = NULL; | 1628 | s->server_send = NULL; |
1629 | if (!(sc->options & OPTION_LONG_POLL) && NULL != (s->server_recv)) | 1629 | if (!(sc->options & OPTION_LONG_POLL) && NULL != (s->server_recv)) |
@@ -1642,8 +1642,8 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
1642 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1642 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1643 | "Peer `%s' connection %p PUT on address `%s' disconnected\n", | 1643 | "Peer `%s' connection %p PUT on address `%s' disconnected\n", |
1644 | GNUNET_i2s (&s->target), s->server_recv, | 1644 | GNUNET_i2s (&s->target), s->server_recv, |
1645 | http_common_plugin_address_to_string (NULL, | 1645 | http_common_plugin_address_to_string (plugin->protocol, |
1646 | plugin->protocol, s->address->address, | 1646 | s->address->address, |
1647 | s->address->address_length)); | 1647 | s->address->address_length)); |
1648 | s->server_recv = NULL; | 1648 | s->server_recv = NULL; |
1649 | if (s->msg_tk != NULL) | 1649 | if (s->msg_tk != NULL) |
@@ -1661,8 +1661,8 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
1661 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1661 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1662 | "Peer `%s' on address `%s' disconnected\n", | 1662 | "Peer `%s' on address `%s' disconnected\n", |
1663 | GNUNET_i2s (&s->target), | 1663 | GNUNET_i2s (&s->target), |
1664 | http_common_plugin_address_to_string (NULL, | 1664 | http_common_plugin_address_to_string (plugin->protocol, |
1665 | plugin->protocol, s->address->address, | 1665 | s->address->address, |
1666 | s->address->address_length)); | 1666 | s->address->address_length)); |
1667 | 1667 | ||
1668 | if ((GNUNET_YES == s->session_passed) && (GNUNET_NO == s->session_ended)) | 1668 | if ((GNUNET_YES == s->session_passed) && (GNUNET_NO == s->session_ended)) |
@@ -2247,9 +2247,9 @@ server_add_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
2247 | GNUNET_CONTAINER_DLL_insert(plugin->addr_head, plugin->addr_tail, w); | 2247 | GNUNET_CONTAINER_DLL_insert(plugin->addr_head, plugin->addr_tail, w); |
2248 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2248 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2249 | "Notifying transport to add address `%s'\n", | 2249 | "Notifying transport to add address `%s'\n", |
2250 | http_common_plugin_address_to_string (NULL, | 2250 | http_common_plugin_address_to_string (plugin->protocol, |
2251 | plugin->protocol, | 2251 | w->address, |
2252 | w->address, w->addrlen)); | 2252 | w->addrlen)); |
2253 | /* modify our published address list */ | 2253 | /* modify our published address list */ |
2254 | #if BUILD_HTTPS | 2254 | #if BUILD_HTTPS |
2255 | address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | 2255 | address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, |
@@ -2298,9 +2298,9 @@ server_remove_address (void *cls, int add_remove, const struct sockaddr *addr, | |||
2298 | 2298 | ||
2299 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2299 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2300 | "Notifying transport to remove address `%s'\n", | 2300 | "Notifying transport to remove address `%s'\n", |
2301 | http_common_plugin_address_to_string (NULL, | 2301 | http_common_plugin_address_to_string (plugin->protocol, |
2302 | plugin->protocol, | 2302 | w->address, |
2303 | w->address, w->addrlen)); | 2303 | w->addrlen)); |
2304 | 2304 | ||
2305 | 2305 | ||
2306 | GNUNET_CONTAINER_DLL_remove (plugin->addr_head, plugin->addr_tail, w); | 2306 | GNUNET_CONTAINER_DLL_remove (plugin->addr_head, plugin->addr_tail, w); |
@@ -3049,8 +3049,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
3049 | { | 3049 | { |
3050 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3050 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3051 | "Notifying transport to remove address `%s'\n", | 3051 | "Notifying transport to remove address `%s'\n", |
3052 | http_common_plugin_address_to_string (NULL, | 3052 | http_common_plugin_address_to_string (plugin->protocol, |
3053 | plugin->protocol, | ||
3054 | plugin->ext_addr->address, | 3053 | plugin->ext_addr->address, |
3055 | plugin->ext_addr->address_length)); | 3054 | plugin->ext_addr->address_length)); |
3056 | #if BUILD_HTTPS | 3055 | #if BUILD_HTTPS |
@@ -3103,16 +3102,26 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
3103 | } | 3102 | } |
3104 | 3103 | ||
3105 | 3104 | ||
3105 | /** | ||
3106 | * Function called by the pretty printer for the resolved address for | ||
3107 | * each human-readable address obtained. The callback can be called | ||
3108 | * several times. The last invocation must be with a @a address of | ||
3109 | * NULL and a @a res of #GNUNET_OK. Thus, to indicate conversion | ||
3110 | * errors, the callback might be called first with @a address NULL and | ||
3111 | * @a res being #GNUNET_SYSERR. In that case, there must still be a | ||
3112 | * subsequent call later with @a address NULL and @a res #GNUNET_OK. | ||
3113 | * | ||
3114 | * @param cls closure | ||
3115 | * @param address one of the names for the host, NULL on last callback | ||
3116 | * @param res #GNUNET_OK if conversion was successful, #GNUNET_SYSERR on failure, | ||
3117 | * #GNUNET_OK on last callback | ||
3118 | */ | ||
3106 | static const char * | 3119 | static const char * |
3107 | http_plugin_address_to_string (void *cls, | 3120 | http_server_plugin_address_to_string (void *cls, |
3108 | const void *addr, | 3121 | const void *addr, |
3109 | size_t addrlen) | 3122 | size_t addrlen) |
3110 | { | 3123 | { |
3111 | #if BUILD_HTTPS | 3124 | return http_common_plugin_address_to_string (PLUGIN_NAME, addr, addrlen); |
3112 | return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen); | ||
3113 | #else | ||
3114 | return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen); | ||
3115 | #endif | ||
3116 | } | 3125 | } |
3117 | 3126 | ||
3118 | 3127 | ||
@@ -3151,7 +3160,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3151 | initialze the plugin or the API */ | 3160 | initialze the plugin or the API */ |
3152 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); | 3161 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
3153 | api->cls = NULL; | 3162 | api->cls = NULL; |
3154 | api->address_to_string = &http_plugin_address_to_string; | 3163 | api->address_to_string = &http_server_plugin_address_to_string; |
3155 | api->string_to_address = &http_common_plugin_string_to_address; | 3164 | api->string_to_address = &http_common_plugin_string_to_address; |
3156 | api->address_pretty_printer = &http_common_plugin_address_pretty_printer; | 3165 | api->address_pretty_printer = &http_common_plugin_address_pretty_printer; |
3157 | return api; | 3166 | return api; |
@@ -3167,7 +3176,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3167 | api->check_address = &http_server_plugin_address_suggested; | 3176 | api->check_address = &http_server_plugin_address_suggested; |
3168 | api->get_session = &http_server_plugin_get_session; | 3177 | api->get_session = &http_server_plugin_get_session; |
3169 | 3178 | ||
3170 | api->address_to_string = &http_plugin_address_to_string; | 3179 | api->address_to_string = &http_server_plugin_address_to_string; |
3171 | api->string_to_address = &http_common_plugin_string_to_address; | 3180 | api->string_to_address = &http_common_plugin_string_to_address; |
3172 | api->address_pretty_printer = &http_common_plugin_address_pretty_printer; | 3181 | api->address_pretty_printer = &http_common_plugin_address_pretty_printer; |
3173 | api->get_network = &http_server_get_network; | 3182 | api->get_network = &http_server_get_network; |