/*
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
#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"
#include "gnunet-service-dht_routing.h"
-
/**
* Handle for the statistics service.
*/
/**
* Handle to get our current HELLO.
*/
-static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+static struct GNUNET_TRANSPORT_HelloGetHandle *ghh;
/**
* Hello address 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));
{
if (NULL != ghh)
{
- GNUNET_TRANSPORT_get_hello_cancel (ghh);
+ GNUNET_TRANSPORT_hello_get_cancel (ghh);
ghh = NULL;
}
GDS_NEIGHBOURS_done ();
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);
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;
}
}
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);
}
* @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;
}
/**
* Bluetooth LAN
*/
- GNUNET_ATS_NET_BT = 5
+ GNUNET_ATS_NET_BT = 5,
/**
* Number of network types supported by ATS
#define GNUNET_TRANSPORT_HELLO_VERSION 0x00000000
+/**
+ * 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.
* 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);
/**
* Type of HELLOs client cares about.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_TRANSPORT_AddressClass ac;
};
* 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).
*/
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)
{
ghh->rec = rec;
ghh->rec_cls = rec_cls;
ghh->cfg = cfg;
- ghh->nt = nt;
+ ghh->ac = ac;
reconnect (ghh);
if (NULL == ghh->mq)
{