gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5824 - in GNUnet/src: applications/topology_default includ


From: gnunet
Subject: [GNUnet-SVN] r5824 - in GNUnet/src: applications/topology_default include server setup transports
Date: Sat, 8 Dec 2007 17:19:43 -0700 (MST)

Author: grothoff
Date: 2007-12-08 17:19:42 -0700 (Sat, 08 Dec 2007)
New Revision: 5824

Modified:
   GNUnet/src/applications/topology_default/topology.c
   GNUnet/src/include/gnunet_topology_service.h
   GNUnet/src/server/connection.c
   GNUnet/src/server/gnunet-update.c
   GNUnet/src/setup/gnunet-setup.c
   GNUnet/src/transports/nat.c
   GNUnet/src/transports/smtp.c
Log:
formatting

Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2007-12-09 00:19:28 UTC 
(rev 5823)
+++ GNUnet/src/applications/topology_default/topology.c 2007-12-09 00:19:42 UTC 
(rev 5824)
@@ -408,40 +408,42 @@
   return saturation;
 }
 
-static int 
-is_friend (const GNUNET_PeerIdentity  * peer) {
+static int
+is_friend (const GNUNET_PeerIdentity * peer)
+{
   unsigned int i;
 
-  for (i=0;i<friendCount;i++)
-    if (0 == memcmp (&friends[i], peer, sizeof (GNUNET_PeerIdentity))) 
+  for (i = 0; i < friendCount; i++)
+    if (0 == memcmp (&friends[i], peer, sizeof (GNUNET_PeerIdentity)))
       return 1;
   return 0;
 }
 
 static void
-friend_counter (const GNUNET_PeerIdentity * peer,
-               void * cls) {
-  unsigned int * cnt = cls;
+friend_counter (const GNUNET_PeerIdentity * peer, void *cls)
+{
+  unsigned int *cnt = cls;
 
-  if (is_friend(peer))
+  if (is_friend (peer))
     (*cnt)++;
 }
 
 static unsigned int
-count_connected_friends(GNUNET_ConnectionIterator connectionIterator,
-                       void * cls) {
+count_connected_friends (GNUNET_ConnectionIterator connectionIterator,
+                         void *cls)
+{
   unsigned int i;
 
   i = 0;
-  connectionIterator(&friend_counter, &i, cls);
+  connectionIterator (&friend_counter, &i, cls);
   return i;
 }
 
 static int
-core_wrapper(GNUNET_NodeIteratorCallback callback,
-            void * cb_arg,
-            void * unused) {
-  return coreAPI->forAllConnectedNodes(callback, cb_arg);
+core_wrapper (GNUNET_NodeIteratorCallback callback,
+              void *cb_arg, void *unused)
+{
+  return coreAPI->forAllConnectedNodes (callback, cb_arg);
 }
 
 static int
@@ -450,11 +452,11 @@
   if ((coreAPI->myIdentity != NULL) &&
       (0 == memcmp (coreAPI->myIdentity, peer, sizeof (GNUNET_PeerIdentity))))
     return GNUNET_SYSERR;       /* disallow connections to self */
-  if (is_friend(peer))
+  if (is_friend (peer))
     return GNUNET_OK;
   if (friends_only)
-    return GNUNET_SYSERR; 
-  if (count_connected_friends(&core_wrapper, NULL) >= minimum_friend_count)
+    return GNUNET_SYSERR;
+  if (count_connected_friends (&core_wrapper, NULL) >= minimum_friend_count)
     return GNUNET_OK;
   return GNUNET_SYSERR;
 }
@@ -465,17 +467,19 @@
  */
 static int
 isConnectionGuarded (const GNUNET_PeerIdentity * peer,
-                    GNUNET_ConnectionIterator connectionIterator,
-                    void * cls) {
-  if (! is_friend(peer))
+                     GNUNET_ConnectionIterator connectionIterator, void *cls)
+{
+  if (!is_friend (peer))
     return GNUNET_NO;
-  if (count_connected_friends(connectionIterator, cls) <= minimum_friend_count)
+  if (count_connected_friends (connectionIterator, cls) <=
+      minimum_friend_count)
     return GNUNET_YES;
   return GNUNET_NO;
 }
 
 static unsigned int
-countGuardedConnections() {
+countGuardedConnections ()
+{
   return minimum_friend_count;
 }
 
@@ -499,19 +503,16 @@
   if (0 != strcmp (section, "F2F"))
     return 0;
   friends_only = GNUNET_GC_get_configuration_value_yesno (cfg,
-                                                         "F2F",
-                                                         "FRIENDS-ONLY",
-                                                         GNUNET_NO);
+                                                          "F2F",
+                                                          "FRIENDS-ONLY",
+                                                          GNUNET_NO);
   if (friends_only == GNUNET_SYSERR)
-    return GNUNET_SYSERR; /* invalid */
+    return GNUNET_SYSERR;       /* invalid */
   opt = 0;
   GNUNET_GC_get_configuration_value_number (cfg,
-                                           "F2F",
-                                           "MINIMUM",
-                                           0,
-                                           1024 * 1024,
-                                           0,
-                                           &opt);
+                                            "F2F",
+                                            "MINIMUM",
+                                            0, 1024 * 1024, 0, &opt);
   minimum_friend_count = (unsigned int) opt;
   GNUNET_array_grow (friends, friendCount, 0);
   fn = NULL;
@@ -573,21 +574,20 @@
       while ((pos < size) && isspace (data[pos]))
         pos++;
     }
-  if ( (minimum_friend_count > friendCount)  &&
-       (friends_only == GNUNET_NO) )
+  if ((minimum_friend_count > friendCount) && (friends_only == GNUNET_NO))
     {
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                    _
-                    ("Fewer friends specified than required by minimum friend 
count. Will only connect to friends.\n"));
+                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                     _
+                     ("Fewer friends specified than required by minimum friend 
count. Will only connect to friends.\n"));
     }
-  if ( (minimum_friend_count > coreAPI->getSlotCount())  &&
-       (friends_only == GNUNET_NO) )
+  if ((minimum_friend_count > coreAPI->getSlotCount ()) &&
+      (friends_only == GNUNET_NO))
     {
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                    _
-                    ("More friendly connections required than target total 
number of connections.\n"));
+                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                     _
+                     ("More friendly connections required than target total 
number of connections.\n"));
     }
 
   return 0;
@@ -624,8 +624,8 @@
       transport = NULL;
       return NULL;
     }
- if (0 != GNUNET_GC_attach_change_listener (coreAPI->cfg,
-                                           &rereadConfiguration, NULL))
+  if (0 != GNUNET_GC_attach_change_listener (coreAPI->cfg,
+                                             &rereadConfiguration, NULL))
     {
       GNUNET_GE_BREAK (coreAPI->ectx, 0);
       capi->releaseService (identity);
@@ -636,7 +636,7 @@
       pingpong = NULL;
       return NULL;
     }
- GNUNET_cron_add_job (capi->cron,
+  GNUNET_cron_add_job (capi->cron,
                        &cronCheckLiveness,
                        LIVE_SCAN_FREQUENCY, LIVE_SCAN_FREQUENCY, NULL);
   api.estimateNetworkSize = &estimateNetworkSize;

Modified: GNUnet/src/include/gnunet_topology_service.h
===================================================================
--- GNUnet/src/include/gnunet_topology_service.h        2007-12-09 00:19:28 UTC 
(rev 5823)
+++ GNUnet/src/include/gnunet_topology_service.h        2007-12-09 00:19:42 UTC 
(rev 5824)
@@ -37,9 +37,8 @@
 #endif
 #endif
 
-typedef int (*GNUNET_ConnectionIterator)(GNUNET_NodeIteratorCallback method,
-                                        void * ni_arg,
-                                        void * cls);
+typedef int (*GNUNET_ConnectionIterator) (GNUNET_NodeIteratorCallback method,
+                                          void *ni_arg, void *cls);
 
 /**
  * @brief topology service API
@@ -91,9 +90,8 @@
    *         would like to see the connection dropped.
    */
   int (*isConnectionGuarded) (const GNUNET_PeerIdentity * peer,
-                             GNUNET_ConnectionIterator iterator,
-                             void * cls);
-  
+                              GNUNET_ConnectionIterator iterator, void *cls);
+
   /**
    * How many connections are currently guarded by the
    * topology?

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2007-12-09 00:19:28 UTC (rev 5823)
+++ GNUnet/src/server/connection.c      2007-12-09 00:19:42 UTC (rev 5824)
@@ -2257,22 +2257,21 @@
 }
 
 static int
-remaining_connection_iterator(GNUNET_NodeIteratorCallback callback,
-                             void * cb_arg,
-                             void * cls) {
+remaining_connection_iterator (GNUNET_NodeIteratorCallback callback,
+                               void *cb_arg, void *cls)
+{
   UTL_Closure *utl = cls;
   unsigned int u;
   unsigned int r;
-  
+
   r = 0;
-  for (u = 0; u < utl->pos; u++) 
-    if (utl->e[u]->idealized_limit >= MIN_BPM_PER_PEER) 
+  for (u = 0; u < utl->pos; u++)
+    if (utl->e[u]->idealized_limit >= MIN_BPM_PER_PEER)
       {
-       r++;
-       if (callback != NULL)
-         callback(&utl->e[u]->session.sender,
-                  cb_arg);
-      } 
+        r++;
+        if (callback != NULL)
+          callback (&utl->e[u]->session.sender, cb_arg);
+      }
   return r;
 }
 
@@ -2381,7 +2380,7 @@
 
   /* compute how much bandwidth we can bargain with */
   minCon = minConnect ();
-  guardCon = topology->countGuardedConnections();
+  guardCon = topology->countGuardedConnections ();
   if (guardCon > minCon)
     minCon = guardCon;
   if (minCon > activePeerCount)
@@ -2516,21 +2515,23 @@
               if ((share > adjustedRR[u] * 2) && (firstRound == GNUNET_YES))
                 share = adjustedRR[u] * 2;
               /* always allow allocating MIN_BPM_PER_PEER */
-              if ( (share < MIN_BPM_PER_PEER) && 
-                  ( (minCon > 0) &&
-                    ( (guardCon < minCon) ||
-                      
(topology->isConnectionGuarded(&entries[u]->session.sender,
-                                                     
&remaining_connection_iterator,
-                                                     &utl)) ) ) ) 
-               {
+              if ((share < MIN_BPM_PER_PEER) &&
+                  ((minCon > 0) &&
+                   ((guardCon < minCon) ||
+                    (topology->
+                     isConnectionGuarded (&entries[u]->session.sender,
+                                          &remaining_connection_iterator,
+                                          &utl)))))
+                {
                   /* use one of the minCon's to keep the connection! */
                   share += MIN_BPM_PER_PEER;
                   decrementSB -= MIN_BPM_PER_PEER;      /* do not count */
                   minCon--;
-                 if (topology->isConnectionGuarded(&entries[u]->session.sender,
-                                                   
&remaining_connection_iterator,
-                                                   &utl) )
-                   guardCon--;
+                  if (topology->
+                      isConnectionGuarded (&entries[u]->session.sender,
+                                           &remaining_connection_iterator,
+                                           &utl))
+                    guardCon--;
                 }
               if (share > entries[u]->idealized_limit)
                 {

Modified: GNUnet/src/server/gnunet-update.c
===================================================================
--- GNUnet/src/server/gnunet-update.c   2007-12-09 00:19:28 UTC (rev 5823)
+++ GNUnet/src/server/gnunet-update.c   2007-12-09 00:19:42 UTC (rev 5824)
@@ -184,7 +184,7 @@
 {
   int i;
   struct GNUNET_CronManager *cron;
-  char * topo;
+  char *topo;
 
   uapi.updateModule = &updateModule;
   uapi.requestService = &requestService;
@@ -192,31 +192,26 @@
   uapi.ectx = ectx;
   uapi.cfg = cfg;
 
-  GNUNET_GC_get_configuration_value_string(cfg,
-                                          "MODULES",
-                                          "topology",
-                                          "topology_default",
-                                          &topo);
+  GNUNET_GC_get_configuration_value_string (cfg,
+                                            "MODULES",
+                                            "topology",
+                                            "topology_default", &topo);
   /* Code specific for update from 0.7.2c to 0.7.3 */
-  if (0 == strcmp(topo, "topology_f2f")) 
+  if (0 == strcmp (topo, "topology_f2f"))
     {
-      GNUNET_GC_set_configuration_value_string(cfg,
-                                              ectx,
-                                              "MODULES",
-                                              "topology",
-                                              "topology_default");
-      GNUNET_GC_set_configuration_value_string(cfg,
-                                              ectx,
-                                              "F2F",
-                                              "FRIENDS-ONLY",
-                                              "YES");
-      if (GNUNET_OK == GNUNET_GC_write_configuration(cfg,
-                                                    cfgFilename))
-       fprintf(stdout,
-               "Updated F2F configuration options successfully.\n");
+      GNUNET_GC_set_configuration_value_string (cfg,
+                                                ectx,
+                                                "MODULES",
+                                                "topology",
+                                                "topology_default");
+      GNUNET_GC_set_configuration_value_string (cfg,
+                                                ectx,
+                                                "F2F", "FRIENDS-ONLY", "YES");
+      if (GNUNET_OK == GNUNET_GC_write_configuration (cfg, cfgFilename))
+        fprintf (stdout, "Updated F2F configuration options successfully.\n");
       else
-       fprintf(stdout,
-               "Failed to write configuration with updated F2F 
configuration.\n");
+        fprintf (stdout,
+                 "Failed to write configuration with updated F2F 
configuration.\n");
     }
 
   cron = cron_create (ectx);
@@ -229,8 +224,8 @@
       return;
     }
 
-  
 
+
   /* enforce filesystem limits */
   capFSQuotaSize (ectx, cfg);
 

Modified: GNUnet/src/setup/gnunet-setup.c
===================================================================
--- GNUnet/src/setup/gnunet-setup.c     2007-12-09 00:19:28 UTC (rev 5823)
+++ GNUnet/src/setup/gnunet-setup.c     2007-12-09 00:19:42 UTC (rev 5824)
@@ -50,54 +50,50 @@
 
 static int option_processing;
 
-static char * get_option;
+static char *get_option;
 
-static char * set_option;
+static char *set_option;
 
 static int
 set_option_helper (GNUNET_CommandLineProcessorContext * ctx,
-                  void * unused,
-                  const char *cmdLineOption,
-                  const char *value)
+                   void *unused, const char *cmdLineOption, const char *value)
 {
   option_processing = GNUNET_YES;
-  if (set_option != NULL) 
+  if (set_option != NULL)
     {
-      fprintf (stderr,
-              _("Can only set one option per invocation.\n"));
+      fprintf (stderr, _("Can only set one option per invocation.\n"));
       return GNUNET_SYSERR;
     }
-  if ( (NULL == strstr(value, ":")) ||
-       (NULL == strstr(strstr(value, ":"), "=")) ) 
+  if ((NULL == strstr (value, ":")) ||
+      (NULL == strstr (strstr (value, ":"), "=")))
     {
       fprintf (stderr,
-              _("Invalid synatx, argument to 'set' must have the format 
SECTION:OPTION=VALUE.\n"));
+               _
+               ("Invalid synatx, argument to 'set' must have the format 
SECTION:OPTION=VALUE.\n"));
       return GNUNET_SYSERR;
     }
-  set_option = GNUNET_strdup(value);
+  set_option = GNUNET_strdup (value);
   return GNUNET_OK;
 }
 
 static int
 get_option_helper (GNUNET_CommandLineProcessorContext * ctx,
-           void * unused,
-           const char *cmdLineOption,
-           const char *value)
+                   void *unused, const char *cmdLineOption, const char *value)
 {
   option_processing = GNUNET_YES;
-  if (get_option != NULL) 
+  if (get_option != NULL)
     {
-      fprintf (stderr,
-              _("Can only display one option per invocation.\n"));
+      fprintf (stderr, _("Can only display one option per invocation.\n"));
       return GNUNET_SYSERR;
     }
-  if (NULL == strstr(value, ":")) 
+  if (NULL == strstr (value, ":"))
     {
       fprintf (stderr,
-              _("Invalid synatx, argument to 'get' must have the format 
SECTION:OPTION.\n"));
+               _
+               ("Invalid synatx, argument to 'get' must have the format 
SECTION:OPTION.\n"));
       return GNUNET_SYSERR;
     }
-  get_option = GNUNET_strdup(value);
+  get_option = GNUNET_strdup (value);
   return GNUNET_OK;
 }
 
@@ -112,11 +108,11 @@
    0, &GNUNET_getopt_configure_set_one, &config_daemon},
   {'g', "get", "SECTION:ENTRY",
    gettext_noop ("print a value from the configuration file to stdout"),
-   1, &get_option_helper, NULL },
+   1, &get_option_helper, NULL},
   GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Tool to setup GNUnet.")),    
 /* -h */
   {'s', "set", "SECTION:ENTRY=VALUE",
    gettext_noop ("update a value in the configuration file"),
-   1, &set_option_helper, NULL },
+   1, &set_option_helper, NULL},
   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
   GNUNET_COMMAND_LINE_OPTION_VERBOSE,
   GNUNET_COMMAND_LINE_OPTION_END,
@@ -209,8 +205,8 @@
   int done;
   char *dirname;
   char *specname;
-  char * value;
-  char * option;
+  char *value;
+  char *option;
   int i;
 
   ectx = GNUNET_GE_create_context_stderr (GNUNET_NO,
@@ -234,34 +230,35 @@
       GNUNET_GE_free_context (ectx);
       return -1;
     }
-  if (option_processing) 
+  if (option_processing)
     {
       operation = "options";
     }
-  else 
+  else
     {
       if (i != argc - 1)
-       {
-         if (i < argc - 1)
-           {
-             fprintf (stderr, _("Too many arguments.\n"));
-             return -1;
-           }
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_WARNING | GNUNET_GE_REQUEST | GNUNET_GE_USER,
-                        _("No interface specified, using default\n"));
-         operation = "config";
+        {
+          if (i < argc - 1)
+            {
+              fprintf (stderr, _("Too many arguments.\n"));
+              return -1;
+            }
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_WARNING | GNUNET_GE_REQUEST |
+                         GNUNET_GE_USER,
+                         _("No interface specified, using default\n"));
+          operation = "config";
 #if HAVE_DIALOG
-         operation = "menuconfig";
+          operation = "menuconfig";
 #endif
 #if HAVE_GTK
-         operation = "gconfig";
+          operation = "gconfig";
 #endif
-       }
+        }
       else
-       {
-         operation = argv[i];
-       }
+        {
+          operation = argv[i];
+        }
     }
   if (NULL != strstr (operation, "wizard"))
     config_daemon = GNUNET_YES; /* wizard implies daemon! */
@@ -314,85 +311,83 @@
       return -1;
     }
   gns2cfg (GNUNET_GNS_get_tree_root (gns));
-  if (option_processing) 
+  if (option_processing)
     {
-      if (get_option != NULL) 
-       {
-         option = strstr(get_option, ":");
-         option[0] = '\0';
-         option++;
-         done = 0;
-         if (GNUNET_NO == GNUNET_GC_have_configuration_value(cfg,
-                                                             get_option,
-                                                             option)) 
-           {
-             fprintf(stderr,
-                     _("Undefined option.\n"));
-             done = 1;
-           }
-         else 
-           {
-             GNUNET_GC_get_configuration_value_string(cfg,
-                                                      get_option,
-                                                      option,
-                                                      NULL,
-                                                      &value);
-             fprintf(stdout, "%s\n", value);
-             GNUNET_free(value);
-           }
-         GNUNET_free(get_option);
-       }
-      if (set_option != NULL) 
-       {
-         option = strstr(set_option, ":");
-         option[0] = '\0';
-         option++;
-         value = strstr(option, "=");
-         value[0] = '\0';
-         value++;
-         if ( (GNUNET_OK != GNUNET_GC_set_configuration_value_string(cfg, ectx,
-                                                                   set_option,
-                                                                   option,
-                                                                     value)) ||
-              (GNUNET_OK != GNUNET_GC_write_configuration (cfg, cfgFilename)) )
-           done = 1;
-         GNUNET_free(set_option);
-       }
+      if (get_option != NULL)
+        {
+          option = strstr (get_option, ":");
+          option[0] = '\0';
+          option++;
+          done = 0;
+          if (GNUNET_NO == GNUNET_GC_have_configuration_value (cfg,
+                                                               get_option,
+                                                               option))
+            {
+              fprintf (stderr, _("Undefined option.\n"));
+              done = 1;
+            }
+          else
+            {
+              GNUNET_GC_get_configuration_value_string (cfg,
+                                                        get_option,
+                                                        option, NULL, &value);
+              fprintf (stdout, "%s\n", value);
+              GNUNET_free (value);
+            }
+          GNUNET_free (get_option);
+        }
+      if (set_option != NULL)
+        {
+          option = strstr (set_option, ":");
+          option[0] = '\0';
+          option++;
+          value = strstr (option, "=");
+          value[0] = '\0';
+          value++;
+          if ((GNUNET_OK !=
+               GNUNET_GC_set_configuration_value_string (cfg, ectx,
+                                                         set_option, option,
+                                                         value))
+              || (GNUNET_OK !=
+                  GNUNET_GC_write_configuration (cfg, cfgFilename)))
+            done = 1;
+          GNUNET_free (set_option);
+        }
       GNUNET_GNS_free_specification (gns);
       GNUNET_GC_free (cfg);
       GNUNET_GE_free_context (ectx);
       GNUNET_free (cfgFilename);
       return done;
     }
-  else 
+  else
     {
       done = GNUNET_NO;
       i = 0;
       while ((done == GNUNET_NO) && (modules[i] != NULL))
-       {
-         if (strcmp (operation, modules[i]) == 0)
-           {
-             if (dyn_config (modules[i + 1],
-                             modules[i + 2], argc, argv,
-                             cfgFilename) != GNUNET_YES)
-               {
-                 GNUNET_GE_LOG (ectx,
-                                GNUNET_GE_FATAL | GNUNET_GE_USER |
-                                GNUNET_GE_ADMIN | GNUNET_GE_IMMEDIATE,
-                                _("`%s' is not available."), operation);
-                 GNUNET_GNS_free_specification (gns);
-                 GNUNET_GC_free (cfg);
-                 GNUNET_GE_free_context (ectx);
-                 GNUNET_free (cfgFilename);
-                 return -1;
-               }
-             else
-               {
-                 done = GNUNET_YES;
-               }
-           }
-         i += 3;
-       }
+        {
+          if (strcmp (operation, modules[i]) == 0)
+            {
+              if (dyn_config (modules[i + 1],
+                              modules[i + 2], argc, argv,
+                              cfgFilename) != GNUNET_YES)
+                {
+                  GNUNET_GE_LOG (ectx,
+                                 GNUNET_GE_FATAL | GNUNET_GE_USER |
+                                 GNUNET_GE_ADMIN | GNUNET_GE_IMMEDIATE,
+                                 _("`%s' is not available."), operation);
+                  GNUNET_GNS_free_specification (gns);
+                  GNUNET_GC_free (cfg);
+                  GNUNET_GE_free_context (ectx);
+                  GNUNET_free (cfgFilename);
+                  return -1;
+                }
+              else
+                {
+                  done = GNUNET_YES;
+                }
+            }
+          i += 3;
+        }
     }
   GNUNET_free (cfgFilename);
   if (done == GNUNET_NO)

Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2007-12-09 00:19:28 UTC (rev 5823)
+++ GNUnet/src/transports/nat.c 2007-12-09 00:19:42 UTC (rev 5824)
@@ -39,30 +39,26 @@
 
 static GNUNET_CoreAPIForTransport *coreAPI;
 
-static const char * nat_limited_choices[] = { "YES", "NO", "AUTO", NULL };
+static const char *nat_limited_choices[] = { "YES", "NO", "AUTO", NULL };
 
 
 /* *************** API implementation *************** */
 
 static int
-lan_ip_detected () {
+lan_ip_detected ()
+{
   GNUNET_IPv4Address addr;
   unsigned int anum;
-  
+
   if (GNUNET_SYSERR == getPublicIPAddress (coreAPI->cfg,
-                                          coreAPI->ectx,
-                                          &addr) )
-    return GNUNET_YES; /* kind-of */
-  anum = ntohl(addr.addr);
-  if ( ( (anum >= 0x0a000000) &&
-        (anum <= 0x0affffff) ) || /* 10.x.x.x */
-       ( (anum >= 0xac100000) &&
-        (anum <= 0xac10ffff) ) || /* 172.16.0.0-172.31.0.0 */
-       ( (anum >= 0xc0a80000) &&
-        (anum <= 0xc0a8ffff) ) || /* 192.168.x.x */
-       ( (anum >= 0x7f000000) &&
-        (anum <= 0x7fffffff) ) /* 127.x.x.x */
-       )
+                                           coreAPI->ectx, &addr))
+    return GNUNET_YES;          /* kind-of */
+  anum = ntohl (addr.addr);
+  if (((anum >= 0x0a000000) && (anum <= 0x0affffff)) || /* 10.x.x.x */
+      ((anum >= 0xac100000) && (anum <= 0xac10ffff)) || /* 
172.16.0.0-172.31.0.0 */
+      ((anum >= 0xc0a80000) && (anum <= 0xc0a8ffff)) || /* 192.168.x.x */
+      ((anum >= 0x7f000000) && (anum <= 0x7fffffff))    /* 127.x.x.x */
+    )
     return GNUNET_YES;
   return GNUNET_NO;
 }
@@ -78,7 +74,7 @@
 static int
 verifyHello (const GNUNET_MessageHello * hello)
 {
-  const char * choice;
+  const char *choice;
 
   if ((ntohs (hello->senderAddressSize) != 0) ||
       (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
@@ -87,16 +83,15 @@
 
   choice = "AUTO";
   GNUNET_GC_get_configuration_value_choice (coreAPI->cfg,
-                                           "NAT", "LIMITED",
-                                           nat_limited_choices,
-                                           "AUTO",
-                                           &choice);
-  if ( ( (0 == strcmp(choice, "YES")) ||
-        ( (0 == strcmp(choice, "AUTO")) &&
-          (lan_ip_detected()) ) ) &&
-       (0 != memcmp (&coreAPI->myIdentity->hashPubKey,
-                    &hello->senderIdentity.hashPubKey,
-                    sizeof (GNUNET_HashCode))) )
+                                            "NAT", "LIMITED",
+                                            nat_limited_choices,
+                                            "AUTO", &choice);
+  if (((0 == strcmp (choice, "YES")) ||
+       ((0 == strcmp (choice, "AUTO")) &&
+        (lan_ip_detected ()))) &&
+      (0 != memcmp (&coreAPI->myIdentity->hashPubKey,
+                    &hello->senderIdentity.hashPubKey,
+                    sizeof (GNUNET_HashCode))))
     {
       /* if WE are a NAT and this is not our hello,
          it is invalid since NAT-to-NAT is not possible! */
@@ -115,18 +110,16 @@
 static GNUNET_MessageHello *
 createhello ()
 {
-  const char * choice;
+  const char *choice;
   GNUNET_MessageHello *msg;
 
   choice = "AUTO";
   GNUNET_GC_get_configuration_value_choice (coreAPI->cfg,
-                                           "NAT", "LIMITED",
-                                           nat_limited_choices,
-                                           "AUTO",
-                                           &choice);
-  if ( ( (0 == strcmp(choice, "YES")) ||
-        ( (0 == strcmp(choice, "AUTO")) &&
-          (! lan_ip_detected()) ) ) )
+                                            "NAT", "LIMITED",
+                                            nat_limited_choices,
+                                            "AUTO", &choice);
+  if (((0 == strcmp (choice, "YES")) ||
+       ((0 == strcmp (choice, "AUTO")) && (!lan_ip_detected ()))))
     return NULL;
   msg = GNUNET_malloc (sizeof (GNUNET_MessageHello));
   msg->senderAddressSize = htons (0);

Modified: GNUnet/src/transports/smtp.c
===================================================================
--- GNUnet/src/transports/smtp.c        2007-12-09 00:19:28 UTC (rev 5823)
+++ GNUnet/src/transports/smtp.c        2007-12-09 00:19:42 UTC (rev 5824)
@@ -668,7 +668,7 @@
     GNUNET_network_monitor_notify_transmission (coreAPI->load_monitor,
                                                 GNUNET_ND_UPLOAD,
                                                 gm_cls.esize);
-  smtp_message_reset_status(message); /* this is needed to plug a 
28-byte/message memory leak in libesmtp */
+  smtp_message_reset_status (message);  /* this is needed to plug a 
28-byte/message memory leak in libesmtp */
   smtp_destroy_session (session);
   GNUNET_mutex_unlock (lock);
   GNUNET_free (gm_cls.ebody);





reply via email to

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