aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-11-23 17:19:53 +0100
committerChristian Grothoff <christian@grothoff.org>2018-11-23 17:19:53 +0100
commit61787bfa37e0ac5998e01d9c4806600033c19c74 (patch)
tree1ceb843f63aa076682ebfa2de2250dc32ee65004 /src/ats
parent4a3be482811fe8ed1502fea2c12a8449b560a99e (diff)
downloadgnunet-61787bfa37e0ac5998e01d9c4806600033c19c74.tar.gz
gnunet-61787bfa37e0ac5998e01d9c4806600033c19c74.zip
rename fest: use new libgnunetnt instead of old libgnunetats logic for network type classification
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/Makefile.am3
-rw-r--r--src/ats/ats_api_scanner.c382
-rw-r--r--src/ats/ats_api_scheduling.c6
-rw-r--r--src/ats/gnunet-ats-solver-eval.c44
-rw-r--r--src/ats/gnunet-service-ats_addresses.c4
-rw-r--r--src/ats/gnunet-service-ats_addresses.h12
-rw-r--r--src/ats/gnunet-service-ats_performance.c6
-rw-r--r--src/ats/gnunet-service-ats_plugins.c20
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c2
-rw-r--r--src/ats/perf_ats_solver.c22
-rw-r--r--src/ats/plugin_ats_mlp.c34
-rw-r--r--src/ats/plugin_ats_proportional.c6
-rw-r--r--src/ats/plugin_ats_ril.c12
-rw-r--r--src/ats/test_ats_api.c8
-rw-r--r--src/ats/test_ats_reservation_api.c2
15 files changed, 91 insertions, 472 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 759dac0be..6a5c924e0 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -34,8 +34,8 @@ endif
34 34
35libgnunetats_la_SOURCES = \ 35libgnunetats_la_SOURCES = \
36 ats_api_connectivity.c \ 36 ats_api_connectivity.c \
37 ats_api_scanner.c \
38 ats_api_scheduling.c \ 37 ats_api_scheduling.c \
38 ats_api_scanner.c \
39 ats_api_performance.c 39 ats_api_performance.c
40libgnunetats_la_LIBADD = \ 40libgnunetats_la_LIBADD = \
41 $(top_builddir)/src/hello/libgnunethello.la \ 41 $(top_builddir)/src/hello/libgnunethello.la \
@@ -90,6 +90,7 @@ gnunet_service_ats_SOURCES = \
90 gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \ 90 gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \
91 gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h 91 gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h
92gnunet_service_ats_LDADD = \ 92gnunet_service_ats_LDADD = \
93 $(top_builddir)/src/nt/libgnunetnt.la \
93 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 94 $(top_builddir)/src/statistics/libgnunetstatistics.la \
94 $(top_builddir)/src/util/libgnunetutil.la \ 95 $(top_builddir)/src/util/libgnunetutil.la \
95 libgnunetats.la \ 96 libgnunetats.la \
diff --git a/src/ats/ats_api_scanner.c b/src/ats/ats_api_scanner.c
index 46afb46f0..7fb125e6f 100644
--- a/src/ats/ats_api_scanner.c
+++ b/src/ats/ats_api_scanner.c
@@ -25,41 +25,6 @@
25#include "gnunet_ats_service.h" 25#include "gnunet_ats_service.h"
26 26
27/** 27/**
28 * How frequently do we scan the interfaces for changes to the addresses?
29 */
30#define INTERFACE_PROCESSING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
31
32
33/**
34 * Convert a `enum GNUNET_ATS_Network_Type` to a string
35 *
36 * @param net the network type
37 * @return a string or NULL if invalid
38 */
39const char *
40GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net)
41{
42 switch (net)
43 {
44 case GNUNET_ATS_NET_UNSPECIFIED:
45 return "UNSPECIFIED";
46 case GNUNET_ATS_NET_LOOPBACK:
47 return "LOOPBACK";
48 case GNUNET_ATS_NET_LAN:
49 return "LAN";
50 case GNUNET_ATS_NET_WAN:
51 return "WAN";
52 case GNUNET_ATS_NET_WLAN:
53 return "WLAN";
54 case GNUNET_ATS_NET_BT:
55 return "BLUETOOTH";
56 default:
57 return NULL;
58 }
59}
60
61
62/**
63 * Convert ATS properties from host to network byte order. 28 * Convert ATS properties from host to network byte order.
64 * 29 *
65 * @param nbo[OUT] value written 30 * @param nbo[OUT] value written
@@ -95,351 +60,4 @@ GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo,
95} 60}
96 61
97 62
98/**
99 * We keep a list of our local networks so we can answer
100 * LAN vs. WAN questions. Note: WLAN is not detected yet.
101 * (maybe we can do that heuristically based on interface
102 * name in the future?).
103 */
104struct ATS_Network
105{
106 /**
107 * Kept in a DLL.
108 */
109 struct ATS_Network *next;
110
111 /**
112 * Kept in a DLL.
113 */
114 struct ATS_Network *prev;
115
116 /**
117 * Network address.
118 */
119 struct sockaddr *network;
120
121 /**
122 * Netmask to determine what is in the LAN.
123 */
124 struct sockaddr *netmask;
125
126 /**
127 * How long are @e network and @e netmask?
128 */
129 socklen_t length;
130};
131
132
133/**
134 * Handle to the interface scanner.
135 */
136struct GNUNET_ATS_InterfaceScanner
137{
138
139 /**
140 * Head of LAN networks list.
141 */
142 struct ATS_Network *net_head;
143
144 /**
145 * Tail of LAN networks list.
146 */
147 struct ATS_Network *net_tail;
148
149 /**
150 * Task for periodically refreshing our LAN network list.
151 */
152 struct GNUNET_SCHEDULER_Task *interface_task;
153
154};
155
156
157/**
158 * Delete all entries from the current network list.
159 *
160 * @param is scanner to clean up
161 */
162static void
163delete_networks (struct GNUNET_ATS_InterfaceScanner *is)
164{
165 struct ATS_Network *cur;
166
167 while (NULL != (cur = is->net_head))
168 {
169 GNUNET_CONTAINER_DLL_remove (is->net_head,
170 is->net_tail,
171 cur);
172 GNUNET_free (cur);
173 }
174}
175
176
177/**
178 * Function invoked for each interface found. Adds the interface's
179 * network addresses to the respective DLL, so we can distinguish
180 * between LAN and WAN.
181 *
182 * @param cls closure with the `struct GNUNET_ATS_InterfaceScanner`
183 * @param name name of the interface (can be NULL for unknown)
184 * @param isDefault is this presumably the default interface
185 * @param addr address of this interface (can be NULL for unknown or unassigned)
186 * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned)
187 * @param netmask the network mask (can be NULL for unknown or unassigned)
188 * @param addrlen length of the address
189 * @return #GNUNET_OK to continue iteration
190 */
191static int
192interface_proc (void *cls,
193 const char *name,
194 int isDefault,
195 const struct sockaddr *addr,
196 const struct sockaddr *broadcast_addr,
197 const struct sockaddr *netmask,
198 socklen_t addrlen)
199{
200 struct GNUNET_ATS_InterfaceScanner *is = cls;
201 /* Calculate network */
202 struct ATS_Network *net = NULL;
203
204 /* Skipping IPv4 loopback addresses since we have special check */
205 if (addr->sa_family == AF_INET)
206 {
207 const struct sockaddr_in *a4 = (const struct sockaddr_in *) addr;
208
209 if ((a4->sin_addr.s_addr & htonl(0xff000000)) == htonl (0x7f000000))
210 return GNUNET_OK;
211 }
212 /* Skipping IPv6 loopback addresses since we have special check */
213 if (addr->sa_family == AF_INET6)
214 {
215 const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *) addr;
216 if (IN6_IS_ADDR_LOOPBACK (&a6->sin6_addr))
217 return GNUNET_OK;
218 }
219
220 if (addr->sa_family == AF_INET)
221 {
222 const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
223 const struct sockaddr_in *netmask4 = (const struct sockaddr_in *) netmask;
224 struct sockaddr_in *tmp;
225 struct sockaddr_in network4;
226
227 net = GNUNET_malloc (sizeof (struct ATS_Network) + 2 * sizeof (struct sockaddr_in));
228 tmp = (struct sockaddr_in *) &net[1];
229 net->network = (struct sockaddr *) &tmp[0];
230 net->netmask = (struct sockaddr *) &tmp[1];
231 net->length = addrlen;
232
233 memset (&network4, 0, sizeof (network4));
234 network4.sin_family = AF_INET;
235#if HAVE_SOCKADDR_IN_SIN_LEN
236 network4.sin_len = sizeof (network4);
237#endif
238 network4.sin_addr.s_addr = (addr4->sin_addr.s_addr & netmask4->sin_addr.s_addr);
239
240 GNUNET_memcpy (net->netmask, netmask4, sizeof (struct sockaddr_in));
241 GNUNET_memcpy (net->network, &network4, sizeof (struct sockaddr_in));
242 }
243
244 if (addr->sa_family == AF_INET6)
245 {
246 const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr;
247 const struct sockaddr_in6 *netmask6 = (const struct sockaddr_in6 *) netmask;
248 struct sockaddr_in6 * tmp;
249 struct sockaddr_in6 network6;
250
251 net = GNUNET_malloc (sizeof (struct ATS_Network) + 2 * sizeof (struct sockaddr_in6));
252 tmp = (struct sockaddr_in6 *) &net[1];
253 net->network = (struct sockaddr *) &tmp[0];
254 net->netmask = (struct sockaddr *) &tmp[1];
255 net->length = addrlen;
256
257 memset (&network6, 0, sizeof (network6));
258 network6.sin6_family = AF_INET6;
259#if HAVE_SOCKADDR_IN_SIN_LEN
260 network6.sin6_len = sizeof (network6);
261#endif
262 unsigned int c = 0;
263 uint32_t *addr_elem = (uint32_t *) &addr6->sin6_addr;
264 uint32_t *mask_elem = (uint32_t *) &netmask6->sin6_addr;
265 uint32_t *net_elem = (uint32_t *) &network6.sin6_addr;
266 for (c = 0; c < 4; c++)
267 net_elem[c] = addr_elem[c] & mask_elem[c];
268
269 GNUNET_memcpy (net->netmask, netmask6, sizeof (struct sockaddr_in6));
270 GNUNET_memcpy (net->network, &network6, sizeof (struct sockaddr_in6));
271 }
272 if (NULL == net)
273 return GNUNET_OK; /* odd / unsupported address family */
274
275 /* Store in list */
276#if VERBOSE_ATS
277 char * netmask = GNUNET_strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen));
278 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
279 "ats-scanner-api",
280 "Adding network `%s', netmask `%s'\n",
281 GNUNET_a2s ((struct sockaddr *) net->network,
282 addrlen),
283 netmask);
284 GNUNET_free (netmask);
285#endif
286 GNUNET_CONTAINER_DLL_insert (is->net_head,
287 is->net_tail,
288 net);
289
290 return GNUNET_OK;
291}
292
293
294/**
295 * Periodically get list of network addresses from our interfaces.
296 *
297 * @param cls closure
298 */
299static void
300get_addresses (void *cls)
301{
302 struct GNUNET_ATS_InterfaceScanner *is = cls;
303
304 is->interface_task = NULL;
305 delete_networks (is);
306 GNUNET_OS_network_interfaces_list (&interface_proc,
307 is);
308 is->interface_task = GNUNET_SCHEDULER_add_delayed (INTERFACE_PROCESSING_INTERVAL,
309 &get_addresses,
310 is);
311}
312
313
314/**
315 * Returns where the address is located: LAN or WAN or ...
316 *
317 * @param is the interface scanner handle
318 * @param addr address
319 * @param addrlen address length
320 * @return type of the network the address belongs to
321 */
322enum GNUNET_ATS_Network_Type
323GNUNET_ATS_scanner_address_get_type (struct GNUNET_ATS_InterfaceScanner *is,
324 const struct sockaddr *addr,
325 socklen_t addrlen)
326{
327 struct ATS_Network *cur = is->net_head;
328 enum GNUNET_ATS_Network_Type type = GNUNET_ATS_NET_UNSPECIFIED;
329
330 switch (addr->sa_family)
331 {
332 case AF_UNIX:
333 type = GNUNET_ATS_NET_LOOPBACK;
334 break;
335 case AF_INET:
336 {
337 const struct sockaddr_in *a4 = (const struct sockaddr_in *) addr;
338
339 if ((a4->sin_addr.s_addr & htonl(0xff000000)) == htonl (0x7f000000))
340 type = GNUNET_ATS_NET_LOOPBACK;
341 break;
342 }
343 case AF_INET6:
344 {
345 const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *) addr;
346
347 if (IN6_IS_ADDR_LOOPBACK (&a6->sin6_addr))
348 type = GNUNET_ATS_NET_LOOPBACK;
349 break;
350 }
351 default:
352 GNUNET_break (0);
353 break;
354 }
355
356 /* Check local networks */
357 while ((NULL != cur) && (GNUNET_ATS_NET_UNSPECIFIED == type))
358 {
359 if (addrlen != cur->length)
360 {
361 cur = cur->next;
362 continue;
363 }
364 if (addr->sa_family == AF_INET)
365 {
366 const struct sockaddr_in *a4 = (const struct sockaddr_in *) addr;
367 const struct sockaddr_in *net4 = (const struct sockaddr_in *) cur->network;
368 const struct sockaddr_in *mask4 = (const struct sockaddr_in *) cur->netmask;
369
370 if (((a4->sin_addr.s_addr & mask4->sin_addr.s_addr)) == net4->sin_addr.s_addr)
371 type = GNUNET_ATS_NET_LAN;
372 }
373 if (addr->sa_family == AF_INET6)
374 {
375 const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *) addr;
376 const struct sockaddr_in6 *net6 = (const struct sockaddr_in6 *) cur->network;
377 const struct sockaddr_in6 *mask6 = (const struct sockaddr_in6 *) cur->netmask;
378
379 int res = GNUNET_YES;
380 int c = 0;
381 uint32_t *addr_elem = (uint32_t *) &a6->sin6_addr;
382 uint32_t *mask_elem = (uint32_t *) &mask6->sin6_addr;
383 uint32_t *net_elem = (uint32_t *) &net6->sin6_addr;
384 for (c = 0; c < 4; c++)
385 if ((addr_elem[c] & mask_elem[c]) != net_elem[c])
386 res = GNUNET_NO;
387
388 if (res == GNUNET_YES)
389 type = GNUNET_ATS_NET_LAN;
390 }
391 cur = cur->next;
392 }
393
394 /* no local network found for this address, default: WAN */
395 if (type == GNUNET_ATS_NET_UNSPECIFIED)
396 type = GNUNET_ATS_NET_WAN;
397 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
398 "ats-scanner-api",
399 "`%s' is in network `%s'\n",
400 GNUNET_a2s (addr,
401 addrlen),
402 GNUNET_ATS_print_network_type (type));
403 return type;
404}
405
406
407/**
408 * Initialize the interface scanner.
409 *
410 * @return interface scanner
411 */
412struct GNUNET_ATS_InterfaceScanner *
413GNUNET_ATS_scanner_init ()
414{
415 struct GNUNET_ATS_InterfaceScanner *is;
416
417 is = GNUNET_new (struct GNUNET_ATS_InterfaceScanner);
418 GNUNET_OS_network_interfaces_list (&interface_proc,
419 is);
420 is->interface_task = GNUNET_SCHEDULER_add_delayed (INTERFACE_PROCESSING_INTERVAL,
421 &get_addresses,
422 is);
423 return is;
424}
425
426
427/**
428 * Client is done with the interface scanner, release resources.
429 *
430 * @param is handle to release
431 */
432void
433GNUNET_ATS_scanner_done (struct GNUNET_ATS_InterfaceScanner *is)
434{
435 if (NULL != is->interface_task)
436 {
437 GNUNET_SCHEDULER_cancel (is->interface_task);
438 is->interface_task = NULL;
439 }
440 delete_networks (is);
441 GNUNET_free (is);
442}
443
444
445/* end of ats_api_scanner.c */ 63/* end of ats_api_scanner.c */
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 783b9f596..2ce6aed3d 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -476,7 +476,7 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh,
476 476
477 if (NULL == sh->mq) 477 if (NULL == sh->mq)
478 return; /* disconnected, skip for now */ 478 return; /* disconnected, skip for now */
479 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ar->properties.scope); 479 GNUNET_break (GNUNET_NT_UNSPECIFIED != ar->properties.scope);
480 namelen = strlen (ar->address->transport_name) + 1; 480 namelen = strlen (ar->address->transport_name) + 1;
481 msize = ar->address->address_length + namelen; 481 msize = ar->address->address_length + namelen;
482 ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD); 482 ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD);
@@ -652,7 +652,7 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
652 GNUNET_break (0); 652 GNUNET_break (0);
653 return NULL; 653 return NULL;
654 } 654 }
655 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); 655 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope);
656 namelen = strlen (address->transport_name) + 1; 656 namelen = strlen (address->transport_name) + 1;
657 msize = address->address_length + namelen; 657 msize = address->address_length + namelen;
658 if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) || 658 if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
@@ -755,7 +755,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar,
755 ar->address->transport_name, 755 ar->address->transport_name,
756 ar->session, 756 ar->session,
757 ar->slot); 757 ar->slot);
758 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); 758 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope);
759 GNUNET_ATS_properties_hton (&ar->properties, 759 GNUNET_ATS_properties_hton (&ar->properties,
760 prop); 760 prop);
761 if (NULL == sh->mq) 761 if (NULL == sh->mq)
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index 13119dea0..e1a01207d 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-solver-eval.c
@@ -1315,27 +1315,27 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
1315 GNUNET_STRINGS_utf8_toupper (op_network,op_network); 1315 GNUNET_STRINGS_utf8_toupper (op_network,op_network);
1316 if (0 == strcmp(op_network, "UNSPECIFIED")) 1316 if (0 == strcmp(op_network, "UNSPECIFIED"))
1317 { 1317 {
1318 o->address_network = GNUNET_ATS_NET_UNSPECIFIED; 1318 o->address_network = GNUNET_NT_UNSPECIFIED;
1319 } 1319 }
1320 else if (0 == strcmp(op_network, "LOOPBACK")) 1320 else if (0 == strcmp(op_network, "LOOPBACK"))
1321 { 1321 {
1322 o->address_network = GNUNET_ATS_NET_LOOPBACK; 1322 o->address_network = GNUNET_NT_LOOPBACK;
1323 } 1323 }
1324 else if (0 == strcmp(op_network, "LAN")) 1324 else if (0 == strcmp(op_network, "LAN"))
1325 { 1325 {
1326 o->address_network = GNUNET_ATS_NET_LAN; 1326 o->address_network = GNUNET_NT_LAN;
1327 } 1327 }
1328 else if (0 == strcmp(op_network, "WAN")) 1328 else if (0 == strcmp(op_network, "WAN"))
1329 { 1329 {
1330 o->address_network = GNUNET_ATS_NET_WAN; 1330 o->address_network = GNUNET_NT_WAN;
1331 } 1331 }
1332 else if (0 == strcmp(op_network, "WLAN")) 1332 else if (0 == strcmp(op_network, "WLAN"))
1333 { 1333 {
1334 o->address_network = GNUNET_ATS_NET_WLAN; 1334 o->address_network = GNUNET_NT_WLAN;
1335 } 1335 }
1336 else if (0 == strcmp(op_network, "BT")) 1336 else if (0 == strcmp(op_network, "BT"))
1337 { 1337 {
1338 o->address_network = GNUNET_ATS_NET_BT; 1338 o->address_network = GNUNET_NT_BT;
1339 } 1339 }
1340 else 1340 else
1341 { 1341 {
@@ -2214,7 +2214,7 @@ enforce_add_address (struct GNUNET_ATS_TEST_Operation *op)
2214 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2214 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2215 2215
2216 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n", 2216 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2217 op->address_id, op->peer_id, GNUNET_ATS_print_network_type(a->network)); 2217 op->address_id, op->peer_id, GNUNET_NT_to_string(a->network));
2218 2218
2219 sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network); 2219 sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network);
2220 2220
@@ -2748,16 +2748,16 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2748 int c; 2748 int c;
2749 int res; 2749 int res;
2750 2750
2751 for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++) 2751 for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
2752 { 2752 {
2753 in_dest[c] = 0; 2753 in_dest[c] = 0;
2754 out_dest[c] = 0; 2754 out_dest[c] = 0;
2755 GNUNET_asprintf (&entry_out, 2755 GNUNET_asprintf (&entry_out,
2756 "%s_QUOTA_OUT", 2756 "%s_QUOTA_OUT",
2757 GNUNET_ATS_print_network_type (c)); 2757 GNUNET_NT_to_string (c));
2758 GNUNET_asprintf (&entry_in, 2758 GNUNET_asprintf (&entry_in,
2759 "%s_QUOTA_IN", 2759 "%s_QUOTA_IN",
2760 GNUNET_ATS_print_network_type (c)); 2760 GNUNET_NT_to_string (c));
2761 2761
2762 /* quota out */ 2762 /* quota out */
2763 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str)) 2763 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
@@ -2777,7 +2777,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2777 { 2777 {
2778 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2778 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2779 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 2779 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2780 GNUNET_ATS_print_network_type (c), 2780 GNUNET_NT_to_string (c),
2781 quota_out_str, 2781 quota_out_str,
2782 GNUNET_ATS_DefaultBandwidth); 2782 GNUNET_ATS_DefaultBandwidth);
2783 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2783 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
@@ -2786,7 +2786,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2786 { 2786 {
2787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2788 "Outbound quota configure for network `%s' is %llu\n", 2788 "Outbound quota configure for network `%s' is %llu\n",
2789 GNUNET_ATS_print_network_type (c), 2789 GNUNET_NT_to_string (c),
2790 out_dest[c]); 2790 out_dest[c]);
2791 } 2791 }
2792 GNUNET_free (quota_out_str); 2792 GNUNET_free (quota_out_str);
@@ -2795,7 +2795,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2795 { 2795 {
2796 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2796 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2797 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), 2797 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
2798 GNUNET_ATS_print_network_type (c), 2798 GNUNET_NT_to_string (c),
2799 GNUNET_ATS_DefaultBandwidth); 2799 GNUNET_ATS_DefaultBandwidth);
2800 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2800 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2801 } 2801 }
@@ -2818,7 +2818,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2818 { 2818 {
2819 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2819 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2820 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 2820 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2821 GNUNET_ATS_print_network_type (c), 2821 GNUNET_NT_to_string (c),
2822 quota_in_str, 2822 quota_in_str,
2823 GNUNET_ATS_DefaultBandwidth); 2823 GNUNET_ATS_DefaultBandwidth);
2824 in_dest[c] = GNUNET_ATS_DefaultBandwidth; 2824 in_dest[c] = GNUNET_ATS_DefaultBandwidth;
@@ -2827,7 +2827,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2827 { 2827 {
2828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2829 "Inbound quota configured for network `%s' is %llu\n", 2829 "Inbound quota configured for network `%s' is %llu\n",
2830 GNUNET_ATS_print_network_type (c), 2830 GNUNET_NT_to_string (c),
2831 in_dest[c]); 2831 in_dest[c]);
2832 } 2832 }
2833 GNUNET_free (quota_in_str); 2833 GNUNET_free (quota_in_str);
@@ -2836,19 +2836,19 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2836 { 2836 {
2837 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2837 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2838 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), 2838 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
2839 GNUNET_ATS_print_network_type (c), 2839 GNUNET_NT_to_string (c),
2840 GNUNET_ATS_DefaultBandwidth); 2840 GNUNET_ATS_DefaultBandwidth);
2841 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2841 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2842 } 2842 }
2843 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2843 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2844 "Loaded quota for network `%s' (in/out): %llu %llu\n", 2844 "Loaded quota for network `%s' (in/out): %llu %llu\n",
2845 GNUNET_ATS_print_network_type (c), 2845 GNUNET_NT_to_string (c),
2846 in_dest[c], 2846 in_dest[c],
2847 out_dest[c]); 2847 out_dest[c]);
2848 GNUNET_free (entry_out); 2848 GNUNET_free (entry_out);
2849 GNUNET_free (entry_in); 2849 GNUNET_free (entry_in);
2850 } 2850 }
2851 return GNUNET_ATS_NetworkTypeCount; 2851 return GNUNET_NT_COUNT;
2852} 2852}
2853 2853
2854 2854
@@ -3048,16 +3048,16 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
3048 sh->env.addresses = sh->addresses; 3048 sh->env.addresses = sh->addresses;
3049 sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb; 3049 sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb;
3050 sh->env.get_preferences = &get_preferences_cb; 3050 sh->env.get_preferences = &get_preferences_cb;
3051 sh->env.network_count = GNUNET_ATS_NetworkTypeCount; 3051 sh->env.network_count = GNUNET_NT_COUNT;
3052 sh->env.info_cb = &solver_info_cb; 3052 sh->env.info_cb = &solver_info_cb;
3053 sh->env.network_count = GNUNET_ATS_NetworkTypeCount; 3053 sh->env.network_count = GNUNET_NT_COUNT;
3054 3054
3055 /* start normalization */ 3055 /* start normalization */
3056 GAS_normalization_start (); 3056 GAS_normalization_start ();
3057 3057
3058 /* load quotas */ 3058 /* load quotas */
3059 if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg, 3059 if (GNUNET_NT_COUNT != GNUNET_ATS_solvers_load_quotas (e->cfg,
3060 sh->env.out_quota, sh->env.in_quota, GNUNET_ATS_NetworkTypeCount)) 3060 sh->env.out_quota, sh->env.in_quota, GNUNET_NT_COUNT))
3061 { 3061 {
3062 GNUNET_break(0); 3062 GNUNET_break(0);
3063 GNUNET_free (sh->plugin); 3063 GNUNET_free (sh->plugin);
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 55fa22681..345409d54 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -223,7 +223,7 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
223 GNUNET_break (0); 223 GNUNET_break (0);
224 return; 224 return;
225 } 225 }
226 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); 226 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope);
227 new_address = create_address (peer, 227 new_address = create_address (peer,
228 plugin_name, 228 plugin_name,
229 plugin_addr, 229 plugin_addr,
@@ -293,7 +293,7 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
293 "Received ADDRESS_UPDATE for peer `%s' slot %u\n", 293 "Received ADDRESS_UPDATE for peer `%s' slot %u\n",
294 GNUNET_i2s (peer), 294 GNUNET_i2s (peer),
295 (unsigned int) session_id); 295 (unsigned int) session_id);
296 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); 296 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope);
297 /* Update address */ 297 /* Update address */
298 aa->t_last_activity = GNUNET_TIME_absolute_get(); 298 aa->t_last_activity = GNUNET_TIME_absolute_get();
299 aa->properties = *prop; 299 aa->properties = *prop;
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index d4dc483eb..7b9472a67 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -57,14 +57,14 @@
57 * network an inbound and outbound quota will be specified. The available 57 * network an inbound and outbound quota will be specified. The available
58 * networks and addtional helper varaibles are defined in 58 * networks and addtional helper varaibles are defined in
59 * gnunet_ats_service.h. At the moment 5 networks are defined: 59 * gnunet_ats_service.h. At the moment 5 networks are defined:
60 * * GNUNET_ATS_NET_UNSPECIFIED 60 * * GNUNET_NT_UNSPECIFIED
61 * * GNUNET_ATS_NET_LOOPBACK 61 * * GNUNET_NT_LOOPBACK
62 * * GNUNET_ATS_NET_LAN 62 * * GNUNET_NT_LAN
63 * * GNUNET_ATS_NET_WAN 63 * * GNUNET_NT_WAN
64 * * GNUNET_ATS_NET_WLAN 64 * * GNUNET_NT_WLAN
65 * 65 *
66 * The total number of networks defined is stored in 66 * The total number of networks defined is stored in
67 * GNUNET_ATS_NetworkTypeCount GNUNET_ATS_NetworkType can be used array 67 * GNUNET_NT_COUNT GNUNET_ATS_NetworkType can be used array
68 * initializer for an int array, while GNUNET_ATS_NetworkType is an 68 * initializer for an int array, while GNUNET_ATS_NetworkType is an
69 * initializer for a char array containing a string description of all 69 * initializer for a char array containing a string description of all
70 * networks 70 * networks
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 92a9aca6d..e3a863f2a 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -82,7 +82,7 @@ notify_client (struct GNUNET_SERVICE_Client *client,
82 char *addrp; 82 char *addrp;
83 83
84 if (NULL != prop) 84 if (NULL != prop)
85 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); 85 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope);
86 GNUNET_assert (msize < GNUNET_MAX_MESSAGE_SIZE); 86 GNUNET_assert (msize < GNUNET_MAX_MESSAGE_SIZE);
87 msg = (struct PeerInformationMessage *) buf; 87 msg = (struct PeerInformationMessage *) buf;
88 msg->header.size = htons (msize); 88 msg->header.size = htons (msize);
@@ -151,7 +151,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
151 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 151 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
152{ 152{
153 GNUNET_break ( (NULL == prop) || 153 GNUNET_break ( (NULL == prop) ||
154 (GNUNET_ATS_NET_UNSPECIFIED != prop->scope) ); 154 (GNUNET_NT_UNSPECIFIED != prop->scope) );
155 notify_client (NULL, 155 notify_client (NULL,
156 peer, 156 peer,
157 plugin_name, 157 plugin_name,
@@ -205,7 +205,7 @@ peerinfo_it (void *cls,
205 plugin_name, 205 plugin_name,
206 (unsigned int) ntohl (bandwidth_out.value__), 206 (unsigned int) ntohl (bandwidth_out.value__),
207 (unsigned int) ntohl (bandwidth_in.value__)); 207 (unsigned int) ntohl (bandwidth_in.value__));
208 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); 208 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope);
209 notify_client (client, 209 notify_client (client,
210 id, 210 id,
211 plugin_name, 211 plugin_name,
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c
index 4b998b982..1ca39ff15 100644
--- a/src/ats/gnunet-service-ats_plugins.c
+++ b/src/ats/gnunet-service-ats_plugins.c
@@ -274,7 +274,7 @@ bandwidth_changed_cb (void *cls,
274static unsigned long long 274static unsigned long long
275parse_quota (const char *quota_str, 275parse_quota (const char *quota_str,
276 const char *direction, 276 const char *direction,
277 enum GNUNET_ATS_Network_Type network) 277 enum GNUNET_NetworkType network)
278{ 278{
279 int res; 279 int res;
280 unsigned long long ret; 280 unsigned long long ret;
@@ -301,7 +301,7 @@ parse_quota (const char *quota_str,
301 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 301 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
302 _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"), 302 _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"),
303 direction, 303 direction,
304 GNUNET_ATS_print_network_type (network), 304 GNUNET_NT_to_string (network),
305 quota_str, 305 quota_str,
306 (unsigned long long) GNUNET_ATS_DefaultBandwidth); 306 (unsigned long long) GNUNET_ATS_DefaultBandwidth);
307 ret = GNUNET_ATS_DefaultBandwidth; 307 ret = GNUNET_ATS_DefaultBandwidth;
@@ -311,7 +311,7 @@ parse_quota (const char *quota_str,
311 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 311 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
312 _("%s quota configured for network `%s' is %llu\n"), 312 _("%s quota configured for network `%s' is %llu\n"),
313 direction, 313 direction,
314 GNUNET_ATS_print_network_type (network), 314 GNUNET_NT_to_string (network),
315 ret); 315 ret);
316 } 316 }
317 return ret; 317 return ret;
@@ -329,7 +329,7 @@ parse_quota (const char *quota_str,
329 */ 329 */
330static unsigned long long 330static unsigned long long
331load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, 331load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg,
332 enum GNUNET_ATS_Network_Type type, 332 enum GNUNET_NetworkType type,
333 const char *direction) 333 const char *direction)
334{ 334{
335 char *entry; 335 char *entry;
@@ -338,7 +338,7 @@ load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg,
338 338
339 GNUNET_asprintf (&entry, 339 GNUNET_asprintf (&entry,
340 "%s_QUOTA_%s", 340 "%s_QUOTA_%s",
341 GNUNET_ATS_print_network_type (type), 341 GNUNET_NT_to_string (type),
342 direction); 342 direction);
343 if (GNUNET_OK == 343 if (GNUNET_OK ==
344 GNUNET_CONFIGURATION_get_value_string (cfg, 344 GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -356,7 +356,7 @@ load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg,
356 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 356 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
357 _("No %s-quota configured for network `%s', assigning default bandwidth %llu\n"), 357 _("No %s-quota configured for network `%s', assigning default bandwidth %llu\n"),
358 direction, 358 direction,
359 GNUNET_ATS_print_network_type (type), 359 GNUNET_NT_to_string (type),
360 (unsigned long long) GNUNET_ATS_DefaultBandwidth); 360 (unsigned long long) GNUNET_ATS_DefaultBandwidth);
361 ret = GNUNET_ATS_DefaultBandwidth; 361 ret = GNUNET_ATS_DefaultBandwidth;
362 } 362 }
@@ -382,7 +382,7 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
382{ 382{
383 unsigned int c; 383 unsigned int c;
384 384
385 for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++) 385 for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
386 { 386 {
387 in_dest[c] = load_quota (cfg, 387 in_dest[c] = load_quota (cfg,
388 c, 388 c,
@@ -392,7 +392,7 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
392 "in"); 392 "in");
393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
394 "Loaded quota for network `%s' (in/out): %llu %llu\n", 394 "Loaded quota for network `%s' (in/out): %llu %llu\n",
395 GNUNET_ATS_print_network_type (c), 395 GNUNET_NT_to_string (c),
396 in_dest[c], 396 in_dest[c],
397 out_dest[c]); 397 out_dest[c]);
398 } 398 }
@@ -431,11 +431,11 @@ GAS_plugin_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
431 env.cfg = cfg; 431 env.cfg = cfg;
432 env.stats = GSA_stats; 432 env.stats = GSA_stats;
433 env.addresses = GSA_addresses; 433 env.addresses = GSA_addresses;
434 env.network_count = GNUNET_ATS_NetworkTypeCount; 434 env.network_count = GNUNET_NT_COUNT;
435 load_quotas (cfg, 435 load_quotas (cfg,
436 env.out_quota, 436 env.out_quota,
437 env.in_quota, 437 env.in_quota,
438 GNUNET_ATS_NetworkTypeCount); 438 GNUNET_NT_COUNT);
439 GNUNET_asprintf (&plugin, 439 GNUNET_asprintf (&plugin,
440 "libgnunet_plugin_ats_%s", 440 "libgnunet_plugin_ats_%s",
441 mode_str); 441 mode_str);
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index 0a1ad99cd..aeea162cc 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -139,7 +139,7 @@ GAS_handle_address_add (const struct AddressAddMessage *m)
139 GNUNET_NO); 139 GNUNET_NO);
140 GNUNET_ATS_properties_ntoh (&prop, 140 GNUNET_ATS_properties_ntoh (&prop,
141 &m->properties); 141 &m->properties);
142 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop.scope); 142 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop.scope);
143 GAS_addresses_add (&m->peer, 143 GAS_addresses_add (&m->peer,
144 plugin_name, 144 plugin_name,
145 address, 145 address,
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index c2885bbef..73871c053 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -1111,11 +1111,11 @@ perf_run_iteration (void)
1111 /* Add address */ 1111 /* Add address */
1112 1112
1113 /* Random network selection */ 1113 /* Random network selection */
1114 //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount - 1); 1114 //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_NT_COUNT - 1);
1115 /* Random equally distributed network selection */ 1115 /* Random equally distributed network selection */
1116 net = 1 + (ca % (GNUNET_ATS_NetworkTypeCount - 1)); 1116 net = 1 + (ca % (GNUNET_NT_COUNT - 1));
1117 /* fprintf (stderr, "Network: %u `%s'\n", 1117 /* fprintf (stderr, "Network: %u `%s'\n",
1118 * mod_net , GNUNET_ATS_print_network_type(mod_net)); */ 1118 * mod_net , GNUNET_NT_to_string(mod_net)); */
1119 1119
1120 cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information); 1120 cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information);
1121 cur_addr->atsi_count = 1; 1121 cur_addr->atsi_count = 1;
@@ -1127,7 +1127,7 @@ perf_run_iteration (void)
1127 perf_address_initial_update (NULL, ph.addresses, cur_addr); 1127 perf_address_initial_update (NULL, ph.addresses, cur_addr);
1128 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1128 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1129 "Adding address for peer %u address %u in network %s\n", cp, ca, 1129 "Adding address for peer %u address %u in network %s\n", cp, ca,
1130 GNUNET_ATS_print_network_type(net)); 1130 GNUNET_NT_to_string(net));
1131 } 1131 }
1132 /* Notify solver about request */ 1132 /* Notify solver about request */
1133 ph.sf->s_get (ph.sf->cls, &ph.peers[cp].id); 1133 ph.sf->s_get (ph.sf->cls, &ph.peers[cp].id);
@@ -1210,8 +1210,8 @@ run (void *cls, char * const *args, const char *cfgfile,
1210 char *solver; 1210 char *solver;
1211 char *plugin; 1211 char *plugin;
1212 struct GNUNET_CONFIGURATION_Handle *solver_cfg; 1212 struct GNUNET_CONFIGURATION_Handle *solver_cfg;
1213 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; 1213 unsigned long long quotas_in[GNUNET_NT_COUNT];
1214 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; 1214 unsigned long long quotas_out[GNUNET_NT_COUNT];
1215 int c; 1215 int c;
1216 int c2; 1216 int c2;
1217 1217
@@ -1286,8 +1286,8 @@ run (void *cls, char * const *args, const char *cfgfile,
1286 end_now (1); 1286 end_now (1);
1287 return; 1287 return;
1288 } 1288 }
1289 if (GNUNET_ATS_NetworkTypeCount != load_quotas (solver_cfg, 1289 if (GNUNET_NT_COUNT != load_quotas (solver_cfg,
1290 quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount)) 1290 quotas_out, quotas_in, GNUNET_NT_COUNT))
1291 { 1291 {
1292 GNUNET_break(0); 1292 GNUNET_break(0);
1293 end_now (1); 1293 end_now (1);
@@ -1306,16 +1306,16 @@ run (void *cls, char * const *args, const char *cfgfile,
1306 ph.env.bandwidth_changed_cb = bandwidth_changed_cb; 1306 ph.env.bandwidth_changed_cb = bandwidth_changed_cb;
1307 ph.env.get_connectivity = &get_connectivity_cb; 1307 ph.env.get_connectivity = &get_connectivity_cb;
1308 ph.env.get_preferences = &get_preferences_cb; 1308 ph.env.get_preferences = &get_preferences_cb;
1309 ph.env.network_count = GNUNET_ATS_NetworkTypeCount; 1309 ph.env.network_count = GNUNET_NT_COUNT;
1310 ph.env.info_cb = &solver_info_cb; 1310 ph.env.info_cb = &solver_info_cb;
1311 1311
1312 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 1312 for (c = 0; c < GNUNET_NT_COUNT; c++)
1313 { 1313 {
1314 ph.env.out_quota[c] = quotas_out[c]; 1314 ph.env.out_quota[c] = quotas_out[c];
1315 ph.env.in_quota[c] = quotas_in[c]; 1315 ph.env.in_quota[c] = quotas_in[c];
1316 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1316 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1317 "Loading network quotas: `%s' %llu %llu \n", 1317 "Loading network quotas: `%s' %llu %llu \n",
1318 GNUNET_ATS_print_network_type (c), 1318 GNUNET_NT_to_string (c),
1319 ph.env.out_quota[c], 1319 ph.env.out_quota[c],
1320 ph.env.in_quota[c]); 1320 ph.env.in_quota[c]);
1321 } 1321 }
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 544b8d97f..8d2a872ab 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -148,7 +148,7 @@ struct MLP_Problem
148 /* Row indices quality metrics */ 148 /* Row indices quality metrics */
149 int r_q[RQ_QUALITY_METRIC_COUNT]; 149 int r_q[RQ_QUALITY_METRIC_COUNT];
150 /* Row indices ATS network quotas */ 150 /* Row indices ATS network quotas */
151 int r_quota[GNUNET_ATS_NetworkTypeCount]; 151 int r_quota[GNUNET_NT_COUNT];
152 152
153 /* Column index Diversity (D) column */ 153 /* Column index Diversity (D) column */
154 int c_d; 154 int c_d;
@@ -211,12 +211,12 @@ struct MLP_Variables
211 211
212 /* Quotas */ 212 /* Quotas */
213 /* Array mapping array index to ATS network */ 213 /* Array mapping array index to ATS network */
214 int quota_index[GNUNET_ATS_NetworkTypeCount]; 214 int quota_index[GNUNET_NT_COUNT];
215 /* Outbound quotas */ 215 /* Outbound quotas */
216 unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount]; 216 unsigned long long quota_out[GNUNET_NT_COUNT];
217 /* Inbound quotas */ 217 /* Inbound quotas */
218 218
219 unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount]; 219 unsigned long long quota_in[GNUNET_NT_COUNT];
220 220
221 /* ATS ressource costs 221 /* ATS ressource costs
222 * array with GNUNET_ATS_QualityPropertiesCount elements 222 * array with GNUNET_ATS_QualityPropertiesCount elements
@@ -601,7 +601,7 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp)
601 mlp->p.r_c9 = MLP_UNDEFINED; 601 mlp->p.r_c9 = MLP_UNDEFINED;
602 for (c = 0; c < RQ_QUALITY_METRIC_COUNT ; c ++) 602 for (c = 0; c < RQ_QUALITY_METRIC_COUNT ; c ++)
603 mlp->p.r_q[c] = MLP_UNDEFINED; 603 mlp->p.r_q[c] = MLP_UNDEFINED;
604 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c ++) 604 for (c = 0; c < GNUNET_NT_COUNT; c ++)
605 mlp->p.r_quota[c] = MLP_UNDEFINED; 605 mlp->p.r_quota[c] = MLP_UNDEFINED;
606 mlp->p.ci = MLP_UNDEFINED; 606 mlp->p.ci = MLP_UNDEFINED;
607 607
@@ -969,20 +969,20 @@ mlp_create_problem_add_address_information (void *cls,
969 } 969 }
970 970
971 addr_net = address->properties.scope; 971 addr_net = address->properties.scope;
972 for (addr_net_index = 0; addr_net_index < GNUNET_ATS_NetworkTypeCount; addr_net_index++) 972 for (addr_net_index = 0; addr_net_index < GNUNET_NT_COUNT; addr_net_index++)
973 { 973 {
974 if (mlp->pv.quota_index[addr_net_index] == addr_net) 974 if (mlp->pv.quota_index[addr_net_index] == addr_net)
975 break; 975 break;
976 } 976 }
977 977
978 if (addr_net_index >= GNUNET_ATS_NetworkTypeCount) 978 if (addr_net_index >= GNUNET_NT_COUNT)
979 { 979 {
980 GNUNET_break (0); 980 GNUNET_break (0);
981 return GNUNET_OK; 981 return GNUNET_OK;
982 } 982 }
983 983
984 max_quota = 0; 984 max_quota = 0;
985 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 985 for (c = 0; c < GNUNET_NT_COUNT; c++)
986 { 986 {
987 if (mlp->pv.quota_out[c] > max_quota) 987 if (mlp->pv.quota_out[c] > max_quota)
988 max_quota = mlp->pv.quota_out[c]; 988 max_quota = mlp->pv.quota_out[c];
@@ -1131,11 +1131,11 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr
1131 p->r_c4 = mlp_create_problem_create_constraint (p, "c4", GLP_LO, (mlp->pv.n_min > p->num_peers) ? p->num_peers : mlp->pv.n_min, 0.0); 1131 p->r_c4 = mlp_create_problem_create_constraint (p, "c4", GLP_LO, (mlp->pv.n_min > p->num_peers) ? p->num_peers : mlp->pv.n_min, 0.0);
1132 1132
1133 /* Rows for c 10) Enforce network quotas */ 1133 /* Rows for c 10) Enforce network quotas */
1134 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 1134 for (c = 0; c < GNUNET_NT_COUNT; c++)
1135 { 1135 {
1136 char * text; 1136 char * text;
1137 GNUNET_asprintf(&text, "c10_quota_ats_%s", 1137 GNUNET_asprintf(&text, "c10_quota_ats_%s",
1138 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c])); 1138 GNUNET_NT_to_string(mlp->pv.quota_index[c]));
1139 p->r_quota[c] = mlp_create_problem_create_constraint (p, text, GLP_DB, 0.0, mlp->pv.quota_out[c]); 1139 p->r_quota[c] = mlp_create_problem_create_constraint (p, text, GLP_DB, 0.0, mlp->pv.quota_out[c]);
1140 GNUNET_free (text); 1140 GNUNET_free (text);
1141 } 1141 }
@@ -1853,7 +1853,7 @@ GAS_mlp_address_add (void *solver,
1853{ 1853{
1854 struct GAS_MLP_Handle *mlp = solver; 1854 struct GAS_MLP_Handle *mlp = solver;
1855 1855
1856 if (GNUNET_ATS_NetworkTypeCount <= network) 1856 if (GNUNET_NT_COUNT <= network)
1857 { 1857 {
1858 GNUNET_break (0); 1858 GNUNET_break (0);
1859 return; 1859 return;
@@ -2651,7 +2651,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2651 n_min = MLP_DEFAULT_MIN_CONNECTIONS; 2651 n_min = MLP_DEFAULT_MIN_CONNECTIONS;
2652 2652
2653 /* Init network quotas */ 2653 /* Init network quotas */
2654 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 2654 for (c = 0; c < GNUNET_NT_COUNT; c++)
2655 { 2655 {
2656 mlp->pv.quota_index[c] = c; 2656 mlp->pv.quota_index[c] = c;
2657 mlp->pv.quota_out[c] = env->out_quota[c]; 2657 mlp->pv.quota_out[c] = env->out_quota[c];
@@ -2659,7 +2659,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2659 2659
2660 LOG (GNUNET_ERROR_TYPE_INFO, 2660 LOG (GNUNET_ERROR_TYPE_INFO,
2661 "Quota for network `%s' (in/out) %llu/%llu\n", 2661 "Quota for network `%s' (in/out) %llu/%llu\n",
2662 GNUNET_ATS_print_network_type (c), 2662 GNUNET_NT_to_string (c),
2663 mlp->pv.quota_out[c], 2663 mlp->pv.quota_out[c],
2664 mlp->pv.quota_in[c]); 2664 mlp->pv.quota_in[c]);
2665 /* Check if defined quota could make problem unsolvable */ 2665 /* Check if defined quota could make problem unsolvable */
@@ -2667,7 +2667,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2667 { 2667 {
2668 LOG (GNUNET_ERROR_TYPE_INFO, 2668 LOG (GNUNET_ERROR_TYPE_INFO,
2669 _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"), 2669 _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2670 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), 2670 GNUNET_NT_to_string(mlp->pv.quota_index[c]),
2671 mlp->pv.quota_out[c], 2671 mlp->pv.quota_out[c],
2672 (n_min * b_min)); 2672 (n_min * b_min));
2673 mlp->pv.quota_out[c] = (n_min * b_min); 2673 mlp->pv.quota_out[c] = (n_min * b_min);
@@ -2676,7 +2676,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2676 { 2676 {
2677 LOG (GNUNET_ERROR_TYPE_INFO, 2677 LOG (GNUNET_ERROR_TYPE_INFO,
2678 _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"), 2678 _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2679 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), 2679 GNUNET_NT_to_string(mlp->pv.quota_index[c]),
2680 mlp->pv.quota_in[c], 2680 mlp->pv.quota_in[c],
2681 (n_min * b_min)); 2681 (n_min * b_min));
2682 mlp->pv.quota_in[c] = (n_min * b_min); 2682 mlp->pv.quota_in[c] = (n_min * b_min);
@@ -2686,7 +2686,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2686 { 2686 {
2687 LOG (GNUNET_ERROR_TYPE_INFO, 2687 LOG (GNUNET_ERROR_TYPE_INFO,
2688 _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"), 2688 _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
2689 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), 2689 GNUNET_NT_to_string(mlp->pv.quota_index[c]),
2690 mlp->pv.quota_out[c], 2690 mlp->pv.quota_out[c],
2691 mlp->pv.BIG_M); 2691 mlp->pv.BIG_M);
2692 mlp->pv.quota_out[c] = mlp->pv.BIG_M ; 2692 mlp->pv.quota_out[c] = mlp->pv.BIG_M ;
@@ -2695,7 +2695,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2695 { 2695 {
2696 LOG (GNUNET_ERROR_TYPE_INFO, 2696 LOG (GNUNET_ERROR_TYPE_INFO,
2697 _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"), 2697 _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
2698 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), 2698 GNUNET_NT_to_string(mlp->pv.quota_index[c]),
2699 mlp->pv.quota_in[c], 2699 mlp->pv.quota_in[c],
2700 mlp->pv.BIG_M); 2700 mlp->pv.BIG_M);
2701 mlp->pv.quota_in[c] = mlp->pv.BIG_M ; 2701 mlp->pv.quota_in[c] = mlp->pv.BIG_M ;
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 08fb7a9a7..b3299b9f0 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -139,7 +139,7 @@ struct Network
139 /** 139 /**
140 * ATS network type 140 * ATS network type
141 */ 141 */
142 enum GNUNET_ATS_Network_Type type; 142 enum GNUNET_NetworkType type;
143 143
144 /** 144 /**
145 * Number of active addresses for this network 145 * Number of active addresses for this network
@@ -429,7 +429,7 @@ distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s,
429 { 429 {
430 LOG (GNUNET_ERROR_TYPE_DEBUG, 430 LOG (GNUNET_ERROR_TYPE_DEBUG,
431 "Redistributing bandwidth in network %s with %u active and %u total addresses\n", 431 "Redistributing bandwidth in network %s with %u active and %u total addresses\n",
432 GNUNET_ATS_print_network_type(n->type), 432 GNUNET_NT_to_string(n->type),
433 n->active_addresses, 433 n->active_addresses,
434 n->total_addresses); 434 n->total_addresses);
435 s->env->info_cb (s->env->cls, 435 s->env->info_cb (s->env->cls,
@@ -1181,7 +1181,7 @@ libgnunet_plugin_ats_proportional_init (void *cls)
1181 cur->type = c; 1181 cur->type = c;
1182 cur->total_quota_in = env->in_quota[c]; 1182 cur->total_quota_in = env->in_quota[c];
1183 cur->total_quota_out = env->out_quota[c]; 1183 cur->total_quota_out = env->out_quota[c];
1184 cur->desc = GNUNET_ATS_print_network_type (c); 1184 cur->desc = GNUNET_NT_to_string (c);
1185 GNUNET_asprintf (&cur->stat_total, 1185 GNUNET_asprintf (&cur->stat_total,
1186 "# ATS addresses %s total", 1186 "# ATS addresses %s total",
1187 cur->desc); 1187 cur->desc);
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c
index 204852085..44c60d1dd 100644
--- a/src/ats/plugin_ats_ril.c
+++ b/src/ats/plugin_ats_ril.c
@@ -340,7 +340,7 @@ struct RIL_Scope
340 /** 340 /**
341 * ATS network type 341 * ATS network type
342 */ 342 */
343 enum GNUNET_ATS_Network_Type type; 343 enum GNUNET_NetworkType type;
344 344
345 /** 345 /**
346 * Total available inbound bandwidth 346 * Total available inbound bandwidth
@@ -1593,7 +1593,7 @@ ril_get_network (struct GAS_RIL_Handle *s, uint32_t type)
1593 * @return GNUNET_YES if there are theoretically enough resources left 1593 * @return GNUNET_YES if there are theoretically enough resources left
1594 */ 1594 */
1595static int 1595static int
1596ril_network_is_not_full (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type network) 1596ril_network_is_not_full (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType network)
1597{ 1597{
1598 struct RIL_Scope *net; 1598 struct RIL_Scope *net;
1599 struct RIL_Peer_Agent *agent; 1599 struct RIL_Peer_Agent *agent;
@@ -1720,7 +1720,7 @@ ril_network_count_active_agents (struct GAS_RIL_Handle *solver, struct RIL_Scope
1720 * @return the sum of the assigned bandwidths 1720 * @return the sum of the assigned bandwidths
1721 */ 1721 */
1722static unsigned long long 1722static unsigned long long
1723ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type type, int direction_in) 1723ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType type, int direction_in)
1724{ 1724{
1725 struct RIL_Peer_Agent *cur; 1725 struct RIL_Peer_Agent *cur;
1726 struct RIL_Scope *net; 1726 struct RIL_Scope *net;
@@ -1755,7 +1755,7 @@ ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network
1755 * @return the sum of the utilized bandwidths (in bytes/second) 1755 * @return the sum of the utilized bandwidths (in bytes/second)
1756 */ 1756 */
1757static unsigned long long 1757static unsigned long long
1758ril_network_get_utilized (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type type, int direction_in) 1758ril_network_get_utilized (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType type, int direction_in)
1759{ 1759{
1760 struct RIL_Peer_Agent *cur; 1760 struct RIL_Peer_Agent *cur;
1761 struct RIL_Scope *net; 1761 struct RIL_Scope *net;
@@ -2038,7 +2038,7 @@ ril_get_agent (struct GAS_RIL_Handle *solver, const struct GNUNET_PeerIdentity *
2038 * @return whether or not the network is considered active 2038 * @return whether or not the network is considered active
2039 */ 2039 */
2040static int 2040static int
2041ril_network_is_active (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type network) 2041ril_network_is_active (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType network)
2042{ 2042{
2043 struct RIL_Scope *net; 2043 struct RIL_Scope *net;
2044 2044
@@ -2786,7 +2786,7 @@ libgnunet_plugin_ats_ril_init (void *cls)
2786 cur->bw_out_available = env->out_quota[c]; 2786 cur->bw_out_available = env->out_quota[c];
2787 LOG (GNUNET_ERROR_TYPE_DEBUG, 2787 LOG (GNUNET_ERROR_TYPE_DEBUG,
2788 "init() Quotas for %s network: IN %llu - OUT %llu\n", 2788 "init() Quotas for %s network: IN %llu - OUT %llu\n",
2789 GNUNET_ATS_print_network_type(cur->type), 2789 GNUNET_NT_to_string(cur->type),
2790 cur->bw_in_available/1024, 2790 cur->bw_in_available/1024,
2791 cur->bw_out_available/1024); 2791 cur->bw_out_available/1024);
2792 } 2792 }
diff --git a/src/ats/test_ats_api.c b/src/ats/test_ats_api.c
index b449e5066..e049ebe16 100644
--- a/src/ats/test_ats_api.c
+++ b/src/ats/test_ats_api.c
@@ -41,7 +41,7 @@ static struct Command test_commands[] = {
41 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE, 41 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
42 .session = 0, 42 .session = 0,
43 .properties = { 43 .properties = {
44 .scope = GNUNET_ATS_NET_LAN 44 .scope = GNUNET_NT_LAN
45 } 45 }
46 } 46 }
47 }, 47 },
@@ -55,7 +55,7 @@ static struct Command test_commands[] = {
55 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE, 55 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
56 .session = 0, 56 .session = 0,
57 .properties = { 57 .properties = {
58 .scope = GNUNET_ATS_NET_LAN 58 .scope = GNUNET_NT_LAN
59 }, 59 },
60 .expect_fail = 1 60 .expect_fail = 1
61 } 61 }
@@ -155,7 +155,7 @@ static struct Command test_commands[] = {
155 .addr_num = 0, 155 .addr_num = 0,
156 .session = 0, 156 .session = 0,
157 .properties = { 157 .properties = {
158 .scope = GNUNET_ATS_NET_LAN 158 .scope = GNUNET_NT_LAN
159 } 159 }
160 } 160 }
161 }, 161 },
@@ -184,7 +184,7 @@ static struct Command test_commands[] = {
184 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE, 184 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
185 .session = 0, 185 .session = 0,
186 .properties = { 186 .properties = {
187 .scope = GNUNET_ATS_NET_LAN 187 .scope = GNUNET_NT_LAN
188 } 188 }
189 } 189 }
190 }, 190 },
diff --git a/src/ats/test_ats_reservation_api.c b/src/ats/test_ats_reservation_api.c
index 19028cb3c..d175aff48 100644
--- a/src/ats/test_ats_reservation_api.c
+++ b/src/ats/test_ats_reservation_api.c
@@ -42,7 +42,7 @@ static struct Command test_commands[] = {
42 .session = 0, 42 .session = 0,
43 .properties = { 43 .properties = {
44 /* use network with 65k quota! */ 44 /* use network with 65k quota! */
45 .scope = GNUNET_ATS_NET_WAN 45 .scope = GNUNET_NT_WAN
46 } 46 }
47 } 47 }
48 }, 48 },