*/
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'.
*/
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;
/**
* 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);
/**
* 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
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;
}
/**
*/
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
/* 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 */
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);
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)))
{
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);
}
-/**
- * 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.
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;
*/
#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?
*/
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);