-indent, doxygen
[oweals/gnunet.git] / src / nat / nat.c
index 4da4826d8bf461f06504ecf9146a15ba2abce15d..670ae6a27d20c9a94ca1b9ebd96d243f4d47ee49 100644 (file)
@@ -1011,20 +1011,31 @@ resolve_dns (void *cls,
  *     the previous (now invalid) one
  * @param addr either the previous or the new public IP address
  * @param addrlen actual lenght of @a addr
- * @param emsg NULL on success, otherwise an error message
+ * @param ret GNUNET_NAT_ERROR_SUCCESS on success, otherwise an error code
  */
 static void
 upnp_add (void *cls,
           int add_remove,
           const struct sockaddr *addr,
           socklen_t addrlen,
-          const char *emsg)
+          enum GNUNET_NAT_FailureCode ret)
 {
   struct GNUNET_NAT_Handle *h = cls;
   struct LocalAddressList *pos;
   struct LocalAddressList *next;
 
 
+  if (GNUNET_NAT_ERROR_SUCCESS != ret)
+  {
+    /* Error while running upnp client */
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+          _("Error while running upnp client:\n"));
+
+    //FIXME: convert error code to string
+    
+    return;
+  }
+  
   if (GNUNET_YES == add_remove)
   {
     add_to_address_list (h, LAL_UPNP, addr, addrlen);
@@ -1053,17 +1064,6 @@ upnp_add (void *cls,
          GNUNET_a2s(addr, addrlen));
     GNUNET_break (0);
   }
-  else if (GNUNET_SYSERR == add_remove)
-  {
-    /* Error while running upnp client */
-    if (NULL != emsg)
-      LOG (GNUNET_ERROR_TYPE_ERROR,
-          _("Error while running upnp client: `%s'\n"), emsg);
-    else
-      LOG (GNUNET_ERROR_TYPE_ERROR,
-          _("Error while running upnp client \n"));
-    return;
-  }
   else
   {
 
@@ -1289,8 +1289,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
     h->enable_nat_server = GNUNET_NO;
 
   /* Check for UPnP client, disable immediately if not available */
-  if (GNUNET_SYSERR ==
-      GNUNET_OS_check_helper_binary ("upnpc", GNUNET_NO, NULL))
+  if ( (GNUNET_YES == h->enable_upnp) &&
+       (GNUNET_SYSERR ==
+        GNUNET_OS_check_helper_binary ("upnpc", GNUNET_NO, NULL)) )
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
         _("UPnP enabled in configuration, but UPnP client `upnpc` command not found, disabling UPnP \n"));