gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11809 - in gnunet/src: hostlist include testing transport


From: gnunet
Subject: [GNUnet-SVN] r11809 - in gnunet/src: hostlist include testing transport
Date: Fri, 18 Jun 2010 17:55:12 +0200

Author: grothoff
Date: 2010-06-18 17:55:12 +0200 (Fri, 18 Jun 2010)
New Revision: 11809

Modified:
   gnunet/src/hostlist/hostlist-client.c
   gnunet/src/include/gnunet_testing_lib.h
   gnunet/src/testing/testing_group.c
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/plugin_transport_udp.c
Log:
cleanup

Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c       2010-06-18 15:29:45 UTC (rev 
11808)
+++ gnunet/src/hostlist/hostlist-client.c       2010-06-18 15:55:12 UTC (rev 
11809)
@@ -129,11 +129,6 @@
 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'.
  */
 static size_t download_pos;
@@ -277,6 +272,7 @@
                             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;

Modified: gnunet/src/include/gnunet_testing_lib.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib.h     2010-06-18 15:29:45 UTC (rev 
11808)
+++ gnunet/src/include/gnunet_testing_lib.h     2010-06-18 15:55:12 UTC (rev 
11809)
@@ -693,14 +693,15 @@
 /**
  * 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);
 
 
 /**

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2010-06-18 15:29:45 UTC (rev 11808)
+++ gnunet/src/testing/testing_group.c  2010-06-18 15:55:12 UTC (rev 11809)
@@ -67,101 +67,12 @@
  * 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
  */
 struct ChurnContext
@@ -448,60 +359,145 @@
 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;
 }
 
 /**

Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-06-18 15:29:45 UTC 
(rev 11808)
+++ gnunet/src/transport/plugin_transport_http.c        2010-06-18 15:55:12 UTC 
(rev 11809)
@@ -305,7 +305,8 @@
  */
 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 @@
   /* 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 @@
       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 @@
     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_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);

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-06-18 15:29:45 UTC (rev 
11808)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-06-18 15:55:12 UTC (rev 
11809)
@@ -1712,18 +1712,6 @@
 
 
 /**
- * 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 @@
 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;

Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2010-06-18 15:29:45 UTC (rev 
11808)
+++ gnunet/src/transport/plugin_transport_udp.c 2010-06-18 15:55:12 UTC (rev 
11809)
@@ -62,11 +62,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?
  */
 #define HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5)
@@ -1863,10 +1858,10 @@
   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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]