gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r37625 - in gnunet/src: dht include transport


From: gnunet
Subject: [GNUnet-SVN] r37625 - in gnunet/src: dht include transport
Date: Sat, 30 Jul 2016 19:13:49 +0200

Author: grothoff
Date: 2016-07-30 19:13:49 +0200 (Sat, 30 Jul 2016)
New Revision: 37625

Modified:
   gnunet/src/dht/gnunet-service-dht.c
   gnunet/src/include/gnunet_ats_service.h
   gnunet/src/include/gnunet_transport_hello_service.h
   gnunet/src/transport/transport_api_hello_get.c
Log:
use different enum for HELLO address classes, deploy for DHT

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2016-07-30 16:51:51 UTC (rev 37624)
+++ gnunet/src/dht/gnunet-service-dht.c 2016-07-30 17:13:49 UTC (rev 37625)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009, 2010, 2011 GNUnet e.V.
+     Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
 #include "gnunet_block_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_transport_service.h"
+#include "gnunet_transport_hello_service.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet_dht_service.h"
 #include "gnunet_statistics_service.h"
@@ -40,7 +41,6 @@
 #include "gnunet-service-dht_routing.h"
 
 
-
 /**
  * Handle for the statistics service.
  */
@@ -69,7 +69,7 @@
 /**
  * Handle to get our current HELLO.
  */
-static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+static struct GNUNET_TRANSPORT_HelloGetHandle *ghh;
 
 /**
  * Hello address expiration
@@ -85,9 +85,9 @@
  * @param message HELLO message of peer
  */
 static void
-process_hello (void *cls, const struct GNUNET_MessageHeader *message)
+process_hello (void *cls,
+              const struct GNUNET_MessageHeader *message)
 {
-  GNUNET_assert (message != NULL);
   GNUNET_free_non_null (GDS_my_hello);
   GDS_my_hello = GNUNET_malloc (ntohs (message->size));
   GNUNET_memcpy (GDS_my_hello, message, ntohs (message->size));
@@ -104,7 +104,7 @@
 {
   if (NULL != ghh)
   {
-    GNUNET_TRANSPORT_get_hello_cancel (ghh);
+    GNUNET_TRANSPORT_hello_get_cancel (ghh);
     ghh = NULL;
   }
   GDS_NEIGHBOURS_done ();
@@ -112,14 +112,15 @@
   GDS_ROUTING_done ();
   GDS_HELLO_done ();
   GDS_NSE_done ();
-  if (GDS_block_context != NULL)
+  if (NULL != GDS_block_context)
   {
     GNUNET_BLOCK_context_destroy (GDS_block_context);
     GDS_block_context = NULL;
   }
-  if (GDS_stats != NULL)
+  if (NULL != GDS_stats)
   {
-    GNUNET_STATISTICS_destroy (GDS_stats, GNUNET_YES);
+    GNUNET_STATISTICS_destroy (GDS_stats,
+                              GNUNET_YES);
     GDS_stats = NULL;
   }
   GNUNET_free_non_null (GDS_my_hello);
@@ -143,7 +144,10 @@
   GDS_server = server;
   GNUNET_SERVER_suspend (server);
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", 
&hello_expiration))
+      GNUNET_CONFIGURATION_get_value_time (c,
+                                          "transport",
+                                          "HELLO_EXPIRATION",
+                                          &hello_expiration))
   {
     hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION;
   }
@@ -160,7 +164,8 @@
   }
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
                                 NULL);
-  ghh = GNUNET_TRANSPORT_get_hello (GDS_cfg,
+  ghh = GNUNET_TRANSPORT_hello_get (GDS_cfg,
+                                   GNUNET_TRANSPORT_AC_GLOBAL,
                                     &process_hello,
                                     NULL);
 }
@@ -174,14 +179,18 @@
  * @return 0 ok, 1 on error
  */
 int
-main (int argc, char *const *argv)
+main (int argc,
+      char *const *argv)
 {
   int ret;
 
-  ret =
-      (GNUNET_OK ==
-       GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run,
-                           NULL)) ? 0 : 1;
+  ret = (GNUNET_OK ==
+        GNUNET_SERVICE_run (argc,
+                            argv,
+                            "dht",
+                            GNUNET_SERVICE_OPTION_NONE,
+                            &run,
+                            NULL)) ? 0 : 1;
   GDS_CLIENTS_done ();
   return ret;
 }

Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h     2016-07-30 16:51:51 UTC (rev 
37624)
+++ gnunet/src/include/gnunet_ats_service.h     2016-07-30 17:13:49 UTC (rev 
37625)
@@ -71,7 +71,7 @@
   /**
    * Bluetooth LAN
    */
-  GNUNET_ATS_NET_BT = 5
+  GNUNET_ATS_NET_BT = 5,
 
 /**
  * Number of network types supported by ATS

Modified: gnunet/src/include/gnunet_transport_hello_service.h
===================================================================
--- gnunet/src/include/gnunet_transport_hello_service.h 2016-07-30 16:51:51 UTC 
(rev 37624)
+++ gnunet/src/include/gnunet_transport_hello_service.h 2016-07-30 17:13:49 UTC 
(rev 37625)
@@ -52,6 +52,61 @@
 
 
 /**
+ * Some addresses contain sensitive information or are
+ * not suitable for global distribution.  We use address
+ * classes to filter addresses by which domain they make
+ * sense to be used in.  These are used in a bitmask.
+ */
+enum GNUNET_TRANSPORT_AddressClass
+{
+
+  /**
+   * No address.
+   */
+  GNUNET_TRANSPORT_AC_NONE = 0,
+
+  /**
+   * Addresses that fall into no other category
+   * (i.e. incoming which we cannot use elsewhere).
+   */
+  GNUNET_TRANSPORT_AC_OTHER = 1,
+
+  /**
+   * Addresses that are global and are insensitive
+   * (i.e. IPv4).
+   */
+  GNUNET_TRANSPORT_AC_GLOBAL = 2,
+
+  /**
+   * Addresses that are global and are sensitive
+   * (i.e. IPv6 with our MAC).
+   */
+  GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4,
+
+  /**
+   * Addresses useful in the local wired network,
+   * i.e. a MAC.  Sensitive, but obvious to people nearby.
+   * Useful for broadcasts.
+   */
+  GNUNET_TRANSPORT_AC_LAN = 8,
+
+  /**
+   * Addresses useful in the local wireless network,
+   * i.e. a MAC.  Sensitive, but obvious to people nearby.
+   * Useful for broadcasts.
+   */
+  GNUNET_TRANSPORT_AC_WLAN = 16,
+
+  /**
+   * Addresses useful in the local bluetooth network.  Sensitive, but
+   * obvious to people nearby.  Useful for broadcasts.
+   */
+  GNUNET_TRANSPORT_AC_BT = 32
+  
+};
+
+
+/**
  * Function called whenever there is an update to the
  * HELLO of this peer.
  *
@@ -74,7 +129,7 @@
  * given in this function is never called synchronously.
  *
  * @param cfg configuration to use
- * @param nt which network type should the addresses from the HELLO belong to?
+ * @param ac which network type should the addresses from the HELLO belong to?
  * @param rec function to call with the HELLO
  * @param rec_cls closure for @a rec
  * @return handle to cancel the operation
@@ -81,7 +136,7 @@
  */
 struct GNUNET_TRANSPORT_HelloGetHandle *
 GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                            enum GNUNET_ATS_Network_Type nt,
+                            enum GNUNET_TRANSPORT_AddressClass ac,
                             GNUNET_TRANSPORT_HelloUpdateCallback rec,
                             void *rec_cls);
 

Modified: gnunet/src/transport/transport_api_hello_get.c
===================================================================
--- gnunet/src/transport/transport_api_hello_get.c      2016-07-30 16:51:51 UTC 
(rev 37624)
+++ gnunet/src/transport/transport_api_hello_get.c      2016-07-30 17:13:49 UTC 
(rev 37625)
@@ -77,7 +77,7 @@
   /**
    * Type of HELLOs client cares about.
    */
-  enum GNUNET_ATS_Network_Type nt;
+  enum GNUNET_TRANSPORT_AddressClass ac;
 };
 
 
@@ -219,7 +219,7 @@
  * is never called synchronously.
  *
  * @param cfg configuration
- * @param nt which network type should the addresses from the HELLO belong to?
+ * @param ac which network type should the addresses from the HELLO belong to?
  * @param rec function to call with the HELLO, sender will be our peer
  *            identity; message and sender will be NULL on timeout
  *            (handshake with transport service pending/failed).
@@ -229,7 +229,7 @@
  */
 struct GNUNET_TRANSPORT_HelloGetHandle *
 GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                            enum GNUNET_ATS_Network_Type nt,
+                            enum GNUNET_TRANSPORT_AddressClass ac,
                             GNUNET_TRANSPORT_HelloUpdateCallback rec,
                             void *rec_cls)
 {
@@ -239,7 +239,7 @@
   ghh->rec = rec;
   ghh->rec_cls = rec_cls;
   ghh->cfg = cfg;
-  ghh->nt = nt;
+  ghh->ac = ac;
   reconnect (ghh);
   if (NULL == ghh->mq)
   {




reply via email to

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