From: Christian Grothoff Date: Fri, 18 Jun 2010 15:55:12 +0000 (+0000) Subject: cleanup X-Git-Tag: initial-import-from-subversion-38251~21334 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6d91f133149ea81040340e8853d7d6e94e57947c;p=oweals%2Fgnunet.git cleanup --- diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index f08bb2e5d..ff8ab2e9a 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -128,11 +128,6 @@ static struct GNUNET_TRANSPORT_Handle *transport; */ static char *proxy; -/** - * Buffer for data downloaded via HTTP. - */ -static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; - /** * Number of bytes valid in 'download_buffer'. */ @@ -277,6 +272,7 @@ callback_download (void *ptr, size_t nmemb, void *ctx) { + static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; const char * cbuf = ptr; const struct GNUNET_MessageHeader *msg; size_t total; diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index b564e1e3a..3524b1c86 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -693,14 +693,15 @@ GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topol /** * Get connect topology option from string input. * - * @param topology where to write the retrieved topology + * @param topology_option where to write the retrieved topology * @param topology_string The string to attempt to * get a configuration value from * @return GNUNET_YES if topology string matched a * known topology, GNUNET_NO if not */ int -GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology, char * topology_string); +GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_option, + char * topology_string); /** diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 98610a28b..a54d7f2b6 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -67,99 +67,10 @@ * Prototype of a function called whenever two peers would be connected * in a certain topology. */ -typedef int (*GNUNET_TESTING_ConnectionProcessor) -(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, unsigned int second); +typedef int (*GNUNET_TESTING_ConnectionProcessor)(struct GNUNET_TESTING_PeerGroup *pg, + unsigned int first, + unsigned int second); -/** - * Strings representing topologies in enum - */ -static char * GNUNET_TESTING_TopologyStrings[] = -{ - /** - * A clique (everyone connected to everyone else). - */ - "CLIQUE", - - /** - * Small-world network (2d torus plus random links). - */ - "SMALL_WORLD", - - /** - * Small-world network (ring plus random links). - */ - "SMALL_WORLD_RING", - - /** - * Ring topology. - */ - "RING", - - /** - * 2-d torus. - */ - "2D_TORUS", - - /** - * Random graph. - */ - "ERDOS_RENYI", - - /** - * Certain percentage of peers are unable to communicate directly - * replicating NAT conditions - */ - "INTERNAT", - - /** - * Scale free topology. - */ - "SCALE_FREE", - - /** - * Straight line topology. - */ - "LINE", - - /** - * All peers are disconnected. - */ - "NONE" -}; - -/** - * Options for connecting a topology as strings. - */ -static char * GNUNET_TESTING_TopologyOptionStrings[] = -{ - /** - * Try to connect all peers specified in the topology. - */ - "CONNECT_ALL", - - /** - * Choose a random subset of connections to create. - */ - "CONNECT_RANDOM_SUBSET", - - /** - * Create at least X connections for each peer. - */ - "CONNECT_MINIMUM", - - /** - * Using a depth first search, create one connection - * per peer. If any are missed (graph disconnected) - * start over at those peers until all have at least one - * connection. - */ - "CONNECT_DFS", - - /** - * No options specified. - */ - "CONNECT_NONE" -}; /** * Context for handling churning a peer group @@ -448,60 +359,145 @@ static int outstanding_connects; int GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topology_string) { - int found = 0; - int curr = 0; + /** + * Strings representing topologies in enum + */ + static const char * topology_strings[] = + { + /** + * A clique (everyone connected to everyone else). + */ + "CLIQUE", + + /** + * Small-world network (2d torus plus random links). + */ + "SMALL_WORLD", + + /** + * Small-world network (ring plus random links). + */ + "SMALL_WORLD_RING", + + /** + * Ring topology. + */ + "RING", + + /** + * 2-d torus. + */ + "2D_TORUS", + + /** + * Random graph. + */ + "ERDOS_RENYI", + + /** + * Certain percentage of peers are unable to communicate directly + * replicating NAT conditions + */ + "INTERNAT", + + /** + * Scale free topology. + */ + "SCALE_FREE", + + /** + * Straight line topology. + */ + "LINE", + + /** + * All peers are disconnected. + */ + "NONE", + + NULL + }; + int curr = 0; if (topology_string == NULL) return GNUNET_NO; - - do - { - if (strcmp(GNUNET_TESTING_TopologyStrings[curr], topology_string) == 0) + while (topology_strings[curr] != NULL) { - found = GNUNET_YES; - break; + if (strcmp(topology_strings[curr], topology_string) == 0) + { + *topology = curr; + return GNUNET_YES; + } + curr++; } - curr++; - } while (strcmp(GNUNET_TESTING_TopologyStrings[curr], "NONE") != 0); - *topology = curr; - if (found) - return GNUNET_YES; - else - return GNUNET_NO; + *topology = GNUNET_TESTING_TOPOLOGY_NONE; + return GNUNET_NO; } + /** * Get connect topology option from string input. * - * @param topology where to write the retrieved topology + * @param topology_option where to write the retrieved topology * @param topology_string The string to attempt to * get a configuration value from * @return GNUNET_YES if string matched a known * topology option, GNUNET_NO if not */ int -GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology, char * topology_string) +GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_option, + char * topology_string) { - int found = 0; + /** + * Options for connecting a topology as strings. + */ + static const char * topology_option_strings[] = + { + /** + * Try to connect all peers specified in the topology. + */ + "CONNECT_ALL", + + /** + * Choose a random subset of connections to create. + */ + "CONNECT_RANDOM_SUBSET", + + /** + * Create at least X connections for each peer. + */ + "CONNECT_MINIMUM", + + /** + * Using a depth first search, create one connection + * per peer. If any are missed (graph disconnected) + * start over at those peers until all have at least one + * connection. + */ + "CONNECT_DFS", + + /** + * No options specified. + */ + "CONNECT_NONE", + + NULL + }; int curr = 0; if (topology_string == NULL) return GNUNET_NO; - - do - { - if (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], topology_string) == 0) + while (NULL != topology_option_strings[curr]) { - found = GNUNET_YES; - break; - } - curr++; - } while (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], "CONNECT_NONE") != 0); - *topology = curr; - if (found) - return GNUNET_YES; - else - return GNUNET_NO; + if (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], topology_string) == 0) + { + *topology_option = curr; + return GNUNET_YES; + } + curr++; + } + *topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_NONE; + return GNUNET_NO; } /** diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index a4025a5cd..0e8a8cd7e 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -305,7 +305,8 @@ static CURLM *multi_handle; */ static struct GNUNET_CRYPTO_HashAsciiEncoded my_ascii_hash_ident; -struct GNUNET_TIME_Relative timeout; +// MW: please document (which timeout is this!?) +static struct GNUNET_TIME_Relative timeout; /** * Finds a http session in our linked list using peer identity as a key @@ -1166,7 +1167,8 @@ http_plugin_send (void *cls, /* find session for peer */ ses = find_session_by_pi (target); if (NULL != ses ) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Existing session for peer `%s' found\n", GNUNET_i2s(target)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Existing session for peer `%s' found\n", GNUNET_i2s(target)); if ( ses == NULL) { /* create new session object */ @@ -1190,7 +1192,8 @@ http_plugin_send (void *cls, ses_temp->next = ses; plugin->session_count++; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session `%s' inserted, count %u \n", GNUNET_i2s(target), plugin->session_count); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "New Session `%s' inserted, count %u\n", GNUNET_i2s(target), plugin->session_count); } GNUNET_assert (addr!=NULL); @@ -1202,9 +1205,13 @@ http_plugin_send (void *cls, if (addrlen == (sizeof (struct IPv4HttpAddress))) { address = GNUNET_malloc(INET_ADDRSTRLEN + 14 + strlen ((const char *) (&ses->hash))); - inet_ntop(AF_INET,&((struct IPv4HttpAddress *) addr)->ipv4_addr,address,INET_ADDRSTRLEN); + inet_ntop(AF_INET, &((struct IPv4HttpAddress *) addr)->ipv4_addr,address,INET_ADDRSTRLEN); port = ntohs(((struct IPv4HttpAddress *) addr)->u_port); - GNUNET_asprintf(&address,"http://%s:%u/%s",address,port, (char *) (&ses->hash)); + GNUNET_asprintf (&address, + "http://%s:%u/%s", + address, + port, + (char *) (&ses->hash)); } else if (addrlen == (sizeof (struct IPv6HttpAddress))) { @@ -1643,10 +1650,7 @@ libgnunet_plugin_transport_http_init (void *cls) libgnunet_plugin_transport_http_done (api); return NULL; } - GNUNET_assert ((port > 0) && (port <= 65535)); - GNUNET_assert (&my_ascii_hash_ident != NULL); - plugin->port_inbound = port; gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT; timeout = ( gn_timeout.value / 1000); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 7e3bc080c..5896461f5 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1711,18 +1711,6 @@ handle_tcp_data (void *cls, } -/** - * Handlers for the various TCP messages. - */ -static struct GNUNET_SERVER_MessageHandler my_handlers[] = { - {&handle_tcp_welcome, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME, - sizeof (struct WelcomeMessage)}, - {&handle_tcp_nat_probe, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE, sizeof (struct TCP_NAT_ProbeMessage)}, - {&handle_tcp_data, NULL, GNUNET_MESSAGE_TYPE_ALL, 0}, - {NULL, NULL, 0, 0} -}; - - /** * Functions with this signature are called whenever a peer * is disconnected on the network level. @@ -2150,6 +2138,13 @@ check_gnunet_nat_binary(char *binary) void * libgnunet_plugin_transport_tcp_init (void *cls) { + static const struct GNUNET_SERVER_MessageHandler my_handlers[] = { + {&handle_tcp_welcome, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME, + sizeof (struct WelcomeMessage)}, + {&handle_tcp_nat_probe, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE, sizeof (struct TCP_NAT_ProbeMessage)}, + {&handle_tcp_data, NULL, GNUNET_MESSAGE_TYPE_ALL, 0}, + {NULL, NULL, 0, 0} + }; struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; struct GNUNET_TRANSPORT_PluginFunctions *api; struct Plugin *plugin; diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 5afb804dc..e79daa351 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -61,11 +61,6 @@ */ #define UDP_DIRECT_DISTANCE 1 -/** - * Handle for request of hostname resolution, non-NULL if pending. - */ -static struct GNUNET_RESOLVER_RequestHandle *hostname_dns; - /** * How long until we give up on transmitting the welcome message? */ @@ -1863,10 +1858,10 @@ libgnunet_plugin_transport_udp_done (void *cls) struct Plugin *plugin = api->cls; udp_transport_server_stop (plugin); - if (NULL != hostname_dns) + if (NULL != plugin->hostname_dns) { - GNUNET_RESOLVER_request_cancel (hostname_dns); - hostname_dns = NULL; + GNUNET_RESOLVER_request_cancel (plugin->hostname_dns); + plugin->hostname_dns = NULL; } GNUNET_SERVICE_stop (plugin->service);