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)
downloadgnunet-48aec5c799d171609d8ae4918d0b8acbdfbb2bbc.tar.gz
gnunet-48aec5c799d171609d8ae4918d0b8acbdfbb2bbc.zip
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 9de76ab7a..332d48a86 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2011 GNUnet e.V. 3 Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
28#include "gnunet_block_lib.h" 28#include "gnunet_block_lib.h"
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
31#include "gnunet_transport_hello_service.h"
31#include "gnunet_hello_lib.h" 32#include "gnunet_hello_lib.h"
32#include "gnunet_dht_service.h" 33#include "gnunet_dht_service.h"
33#include "gnunet_statistics_service.h" 34#include "gnunet_statistics_service.h"
@@ -40,7 +41,6 @@
40#include "gnunet-service-dht_routing.h" 41#include "gnunet-service-dht_routing.h"
41 42
42 43
43
44/** 44/**
45 * Handle for the statistics service. 45 * Handle for the statistics service.
46 */ 46 */
@@ -69,7 +69,7 @@ struct GNUNET_MessageHeader *GDS_my_hello;
69/** 69/**
70 * Handle to get our current HELLO. 70 * Handle to get our current HELLO.
71 */ 71 */
72static struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 72static struct GNUNET_TRANSPORT_HelloGetHandle *ghh;
73 73
74/** 74/**
75 * Hello address expiration 75 * Hello address expiration
@@ -85,9 +85,9 @@ struct GNUNET_TIME_Relative hello_expiration;
85 * @param message HELLO message of peer 85 * @param message HELLO message of peer
86 */ 86 */
87static void 87static void
88process_hello (void *cls, const struct GNUNET_MessageHeader *message) 88process_hello (void *cls,
89 const struct GNUNET_MessageHeader *message)
89{ 90{
90 GNUNET_assert (message != NULL);
91 GNUNET_free_non_null (GDS_my_hello); 91 GNUNET_free_non_null (GDS_my_hello);
92 GDS_my_hello = GNUNET_malloc (ntohs (message->size)); 92 GDS_my_hello = GNUNET_malloc (ntohs (message->size));
93 GNUNET_memcpy (GDS_my_hello, message, ntohs (message->size)); 93 GNUNET_memcpy (GDS_my_hello, message, ntohs (message->size));
@@ -104,7 +104,7 @@ shutdown_task (void *cls)
104{ 104{
105 if (NULL != ghh) 105 if (NULL != ghh)
106 { 106 {
107 GNUNET_TRANSPORT_get_hello_cancel (ghh); 107 GNUNET_TRANSPORT_hello_get_cancel (ghh);
108 ghh = NULL; 108 ghh = NULL;
109 } 109 }
110 GDS_NEIGHBOURS_done (); 110 GDS_NEIGHBOURS_done ();
@@ -112,14 +112,15 @@ shutdown_task (void *cls)
112 GDS_ROUTING_done (); 112 GDS_ROUTING_done ();
113 GDS_HELLO_done (); 113 GDS_HELLO_done ();
114 GDS_NSE_done (); 114 GDS_NSE_done ();
115 if (GDS_block_context != NULL) 115 if (NULL != GDS_block_context)
116 { 116 {
117 GNUNET_BLOCK_context_destroy (GDS_block_context); 117 GNUNET_BLOCK_context_destroy (GDS_block_context);
118 GDS_block_context = NULL; 118 GDS_block_context = NULL;
119 } 119 }
120 if (GDS_stats != NULL) 120 if (NULL != GDS_stats)
121 { 121 {
122 GNUNET_STATISTICS_destroy (GDS_stats, GNUNET_YES); 122 GNUNET_STATISTICS_destroy (GDS_stats,
123 GNUNET_YES);
123 GDS_stats = NULL; 124 GDS_stats = NULL;
124 } 125 }
125 GNUNET_free_non_null (GDS_my_hello); 126 GNUNET_free_non_null (GDS_my_hello);
@@ -143,7 +144,10 @@ run (void *cls,
143 GDS_server = server; 144 GDS_server = server;
144 GNUNET_SERVER_suspend (server); 145 GNUNET_SERVER_suspend (server);
145 if (GNUNET_OK != 146 if (GNUNET_OK !=
146 GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration)) 147 GNUNET_CONFIGURATION_get_value_time (c,
148 "transport",
149 "HELLO_EXPIRATION",
150 &hello_expiration))
147 { 151 {
148 hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; 152 hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION;
149 } 153 }
@@ -160,7 +164,8 @@ run (void *cls,
160 } 164 }
161 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 165 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
162 NULL); 166 NULL);
163 ghh = GNUNET_TRANSPORT_get_hello (GDS_cfg, 167 ghh = GNUNET_TRANSPORT_hello_get (GDS_cfg,
168 GNUNET_TRANSPORT_AC_GLOBAL,
164 &process_hello, 169 &process_hello,
165 NULL); 170 NULL);
166} 171}
@@ -174,14 +179,18 @@ run (void *cls,
174 * @return 0 ok, 1 on error 179 * @return 0 ok, 1 on error
175 */ 180 */
176int 181int
177main (int argc, char *const *argv) 182main (int argc,
183 char *const *argv)
178{ 184{
179 int ret; 185 int ret;
180 186
181 ret = 187 ret = (GNUNET_OK ==
182 (GNUNET_OK == 188 GNUNET_SERVICE_run (argc,
183 GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, 189 argv,
184 NULL)) ? 0 : 1; 190 "dht",
191 GNUNET_SERVICE_OPTION_NONE,
192 &run,
193 NULL)) ? 0 : 1;
185 GDS_CLIENTS_done (); 194 GDS_CLIENTS_done ();
186 return ret; 195 return ret;
187} 196}
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index 41e1a1a90..f0d36ff6f 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -71,7 +71,7 @@ enum GNUNET_ATS_Network_Type
71 /** 71 /**
72 * Bluetooth LAN 72 * Bluetooth LAN
73 */ 73 */
74 GNUNET_ATS_NET_BT = 5 74 GNUNET_ATS_NET_BT = 5,
75 75
76/** 76/**
77 * Number of network types supported by ATS 77 * 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 8573613ac..86ff67415 100644
--- a/src/include/gnunet_transport_hello_service.h
+++ b/src/include/gnunet_transport_hello_service.h
@@ -52,6 +52,61 @@ extern "C"
52 52
53 53
54/** 54/**
55 * Some addresses contain sensitive information or are
56 * not suitable for global distribution. We use address
57 * classes to filter addresses by which domain they make
58 * sense to be used in. These are used in a bitmask.
59 */
60enum GNUNET_TRANSPORT_AddressClass
61{
62
63 /**
64 * No address.
65 */
66 GNUNET_TRANSPORT_AC_NONE = 0,
67
68 /**
69 * Addresses that fall into no other category
70 * (i.e. incoming which we cannot use elsewhere).
71 */
72 GNUNET_TRANSPORT_AC_OTHER = 1,
73
74 /**
75 * Addresses that are global and are insensitive
76 * (i.e. IPv4).
77 */
78 GNUNET_TRANSPORT_AC_GLOBAL = 2,
79
80 /**
81 * Addresses that are global and are sensitive
82 * (i.e. IPv6 with our MAC).
83 */
84 GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4,
85
86 /**
87 * Addresses useful in the local wired network,
88 * i.e. a MAC. Sensitive, but obvious to people nearby.
89 * Useful for broadcasts.
90 */
91 GNUNET_TRANSPORT_AC_LAN = 8,
92
93 /**
94 * Addresses useful in the local wireless network,
95 * i.e. a MAC. Sensitive, but obvious to people nearby.
96 * Useful for broadcasts.
97 */
98 GNUNET_TRANSPORT_AC_WLAN = 16,
99
100 /**
101 * Addresses useful in the local bluetooth network. Sensitive, but
102 * obvious to people nearby. Useful for broadcasts.
103 */
104 GNUNET_TRANSPORT_AC_BT = 32
105
106};
107
108
109/**
55 * Function called whenever there is an update to the 110 * Function called whenever there is an update to the
56 * HELLO of this peer. 111 * HELLO of this peer.
57 * 112 *
@@ -74,14 +129,14 @@ struct GNUNET_TRANSPORT_HelloGetHandle;
74 * given in this function is never called synchronously. 129 * given in this function is never called synchronously.
75 * 130 *
76 * @param cfg configuration to use 131 * @param cfg configuration to use
77 * @param nt which network type should the addresses from the HELLO belong to? 132 * @param ac which network type should the addresses from the HELLO belong to?
78 * @param rec function to call with the HELLO 133 * @param rec function to call with the HELLO
79 * @param rec_cls closure for @a rec 134 * @param rec_cls closure for @a rec
80 * @return handle to cancel the operation 135 * @return handle to cancel the operation
81 */ 136 */
82struct GNUNET_TRANSPORT_HelloGetHandle * 137struct GNUNET_TRANSPORT_HelloGetHandle *
83GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg, 138GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
84 enum GNUNET_ATS_Network_Type nt, 139 enum GNUNET_TRANSPORT_AddressClass ac,
85 GNUNET_TRANSPORT_HelloUpdateCallback rec, 140 GNUNET_TRANSPORT_HelloUpdateCallback rec,
86 void *rec_cls); 141 void *rec_cls);
87 142
diff --git a/src/transport/transport_api_hello_get.c b/src/transport/transport_api_hello_get.c
index 9d4209e04..ec7b544d6 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
77 /** 77 /**
78 * Type of HELLOs client cares about. 78 * Type of HELLOs client cares about.
79 */ 79 */
80 enum GNUNET_ATS_Network_Type nt; 80 enum GNUNET_TRANSPORT_AddressClass ac;
81}; 81};
82 82
83 83
@@ -219,7 +219,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
219 * is never called synchronously. 219 * is never called synchronously.
220 * 220 *
221 * @param cfg configuration 221 * @param cfg configuration
222 * @param nt which network type should the addresses from the HELLO belong to? 222 * @param ac which network type should the addresses from the HELLO belong to?
223 * @param rec function to call with the HELLO, sender will be our peer 223 * @param rec function to call with the HELLO, sender will be our peer
224 * identity; message and sender will be NULL on timeout 224 * identity; message and sender will be NULL on timeout
225 * (handshake with transport service pending/failed). 225 * (handshake with transport service pending/failed).
@@ -229,7 +229,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
229 */ 229 */
230struct GNUNET_TRANSPORT_HelloGetHandle * 230struct GNUNET_TRANSPORT_HelloGetHandle *
231GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg, 231GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
232 enum GNUNET_ATS_Network_Type nt, 232 enum GNUNET_TRANSPORT_AddressClass ac,
233 GNUNET_TRANSPORT_HelloUpdateCallback rec, 233 GNUNET_TRANSPORT_HelloUpdateCallback rec,
234 void *rec_cls) 234 void *rec_cls)
235{ 235{
@@ -239,7 +239,7 @@ GNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg,
239 ghh->rec = rec; 239 ghh->rec = rec;
240 ghh->rec_cls = rec_cls; 240 ghh->rec_cls = rec_cls;
241 ghh->cfg = cfg; 241 ghh->cfg = cfg;
242 ghh->nt = nt; 242 ghh->ac = ac;
243 reconnect (ghh); 243 reconnect (ghh);
244 if (NULL == ghh->mq) 244 if (NULL == ghh->mq)
245 { 245 {