aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-30 17:13:49 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-30 17:13:49 +0000
commit48aec5c799d171609d8ae4918d0b8acbdfbb2bbc (patch)
treef7fa2c29fead558f0cd51deaae876f8a21fc40dc
parentb54a66f94d833dbe98eb0dd9e236a3d7bba3ce20 (diff)
use different enum for HELLO address classes, deploy for DHT
-rw-r--r--src/dht/gnunet-service-dht.c41
-rw-r--r--src/include/gnunet_ats_service.h2
-rw-r--r--src/include/gnunet_transport_hello_service.h59
-rw-r--r--src/transport/transport_api_hello_get.c8
4 files changed, 87 insertions, 23 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 9de76ab7a9..332d48a860 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -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 @@ struct GNUNET_MessageHeader *GDS_my_hello;
/**
* 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 @@ struct GNUNET_TIME_Relative hello_expiration;
* @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 @@ shutdown_task (void *cls)
{
if (NULL != ghh)
{
- GNUNET_TRANSPORT_get_hello_cancel (ghh);
+ GNUNET_TRANSPORT_hello_get_cancel (ghh);
ghh = NULL;
}
GDS_NEIGHBOURS_done ();
@@ -112,14 +112,15 @@ shutdown_task (void *cls)
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 @@ run (void *cls,
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 @@ run (void *cls,
}
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 @@ run (void *cls,
* @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;
}
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index 41e1a1a900..f0d36ff6f9 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -71,7 +71,7 @@ enum GNUNET_ATS_Network_Type
/**
* Bluetooth LAN
*/
- GNUNET_ATS_NET_BT = 5
+ GNUNET_ATS_NET_BT = 5,
/**
* Number of network types supported by ATS
diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h
index 8573613acb..86ff674157 100644
--- a/src/include/gnunet_transport_hello_service.h
+++ b/src/include/gnunet_transport_hello_service.h
@@ -52,6 +52,61 @@ extern "C"
/**
+ * 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,14 +129,14 @@ struct GNUNET_TRANSPORT_HelloGetHandle;
* 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
*/
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);
diff --git a/src/transport/transport_api_hello_get.c b/src/transport/transport_api_hello_get.c
index 9d4209e048..ec7b544d6b 100644
--- a/src/transport/transport_api_hello_get.c
+++ b/src/transport/transport_api_hello_get.c
@@ -77,7 +77,7 @@ struct GNUNET_TRANSPORT_HelloGetHandle
/**
* Type of HELLOs client cares about.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_TRANSPORT_AddressClass ac;
};
@@ -219,7 +219,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
* 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 @@ schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
*/
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 @@ GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
ghh->rec = rec;
ghh->rec_cls = rec_cls;
ghh->cfg = cfg;
- ghh->nt = nt;
+ ghh->ac = ac;
reconnect (ghh);
if (NULL == ghh->mq)
{