From 61787bfa37e0ac5998e01d9c4806600033c19c74 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 23 Nov 2018 17:19:53 +0100 Subject: rename fest: use new libgnunetnt instead of old libgnunetats logic for network type classification --- src/ats/Makefile.am | 3 +- src/ats/ats_api_scanner.c | 382 ------------------------------- src/ats/ats_api_scheduling.c | 6 +- src/ats/gnunet-ats-solver-eval.c | 44 ++-- src/ats/gnunet-service-ats_addresses.c | 4 +- src/ats/gnunet-service-ats_addresses.h | 12 +- src/ats/gnunet-service-ats_performance.c | 6 +- src/ats/gnunet-service-ats_plugins.c | 20 +- src/ats/gnunet-service-ats_scheduling.c | 2 +- src/ats/perf_ats_solver.c | 22 +- src/ats/plugin_ats_mlp.c | 34 +-- src/ats/plugin_ats_proportional.c | 6 +- src/ats/plugin_ats_ril.c | 12 +- src/ats/test_ats_api.c | 8 +- src/ats/test_ats_reservation_api.c | 2 +- 15 files changed, 91 insertions(+), 472 deletions(-) (limited to 'src/ats') 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 libgnunetats_la_SOURCES = \ ats_api_connectivity.c \ - ats_api_scanner.c \ ats_api_scheduling.c \ + ats_api_scanner.c \ ats_api_performance.c libgnunetats_la_LIBADD = \ $(top_builddir)/src/hello/libgnunethello.la \ @@ -90,6 +90,7 @@ gnunet_service_ats_SOURCES = \ gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \ gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h gnunet_service_ats_LDADD = \ + $(top_builddir)/src/nt/libgnunetnt.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la \ 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 @@ -24,41 +24,6 @@ #include "platform.h" #include "gnunet_ats_service.h" -/** - * How frequently do we scan the interfaces for changes to the addresses? - */ -#define INTERFACE_PROCESSING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) - - -/** - * Convert a `enum GNUNET_ATS_Network_Type` to a string - * - * @param net the network type - * @return a string or NULL if invalid - */ -const char * -GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net) -{ - switch (net) - { - case GNUNET_ATS_NET_UNSPECIFIED: - return "UNSPECIFIED"; - case GNUNET_ATS_NET_LOOPBACK: - return "LOOPBACK"; - case GNUNET_ATS_NET_LAN: - return "LAN"; - case GNUNET_ATS_NET_WAN: - return "WAN"; - case GNUNET_ATS_NET_WLAN: - return "WLAN"; - case GNUNET_ATS_NET_BT: - return "BLUETOOTH"; - default: - return NULL; - } -} - - /** * Convert ATS properties from host to network byte order. * @@ -95,351 +60,4 @@ GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo, } -/** - * We keep a list of our local networks so we can answer - * LAN vs. WAN questions. Note: WLAN is not detected yet. - * (maybe we can do that heuristically based on interface - * name in the future?). - */ -struct ATS_Network -{ - /** - * Kept in a DLL. - */ - struct ATS_Network *next; - - /** - * Kept in a DLL. - */ - struct ATS_Network *prev; - - /** - * Network address. - */ - struct sockaddr *network; - - /** - * Netmask to determine what is in the LAN. - */ - struct sockaddr *netmask; - - /** - * How long are @e network and @e netmask? - */ - socklen_t length; -}; - - -/** - * Handle to the interface scanner. - */ -struct GNUNET_ATS_InterfaceScanner -{ - - /** - * Head of LAN networks list. - */ - struct ATS_Network *net_head; - - /** - * Tail of LAN networks list. - */ - struct ATS_Network *net_tail; - - /** - * Task for periodically refreshing our LAN network list. - */ - struct GNUNET_SCHEDULER_Task *interface_task; - -}; - - -/** - * Delete all entries from the current network list. - * - * @param is scanner to clean up - */ -static void -delete_networks (struct GNUNET_ATS_InterfaceScanner *is) -{ - struct ATS_Network *cur; - - while (NULL != (cur = is->net_head)) - { - GNUNET_CONTAINER_DLL_remove (is->net_head, - is->net_tail, - cur); - GNUNET_free (cur); - } -} - - -/** - * Function invoked for each interface found. Adds the interface's - * network addresses to the respective DLL, so we can distinguish - * between LAN and WAN. - * - * @param cls closure with the `struct GNUNET_ATS_InterfaceScanner` - * @param name name of the interface (can be NULL for unknown) - * @param isDefault is this presumably the default interface - * @param addr address of this interface (can be NULL for unknown or unassigned) - * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) - * @param netmask the network mask (can be NULL for unknown or unassigned) - * @param addrlen length of the address - * @return #GNUNET_OK to continue iteration - */ -static int -interface_proc (void *cls, - const char *name, - int isDefault, - const struct sockaddr *addr, - const struct sockaddr *broadcast_addr, - const struct sockaddr *netmask, - socklen_t addrlen) -{ - struct GNUNET_ATS_InterfaceScanner *is = cls; - /* Calculate network */ - struct ATS_Network *net = NULL; - - /* Skipping IPv4 loopback addresses since we have special check */ - if (addr->sa_family == AF_INET) - { - const struct sockaddr_in *a4 = (const struct sockaddr_in *) addr; - - if ((a4->sin_addr.s_addr & htonl(0xff000000)) == htonl (0x7f000000)) - return GNUNET_OK; - } - /* Skipping IPv6 loopback addresses since we have special check */ - if (addr->sa_family == AF_INET6) - { - const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *) addr; - if (IN6_IS_ADDR_LOOPBACK (&a6->sin6_addr)) - return GNUNET_OK; - } - - if (addr->sa_family == AF_INET) - { - const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr; - const struct sockaddr_in *netmask4 = (const struct sockaddr_in *) netmask; - struct sockaddr_in *tmp; - struct sockaddr_in network4; - - net = GNUNET_malloc (sizeof (struct ATS_Network) + 2 * sizeof (struct sockaddr_in)); - tmp = (struct sockaddr_in *) &net[1]; - net->network = (struct sockaddr *) &tmp[0]; - net->netmask = (struct sockaddr *) &tmp[1]; - net->length = addrlen; - - memset (&network4, 0, sizeof (network4)); - network4.sin_family = AF_INET; -#if HAVE_SOCKADDR_IN_SIN_LEN - network4.sin_len = sizeof (network4); -#endif - network4.sin_addr.s_addr = (addr4->sin_addr.s_addr & netmask4->sin_addr.s_addr); - - GNUNET_memcpy (net->netmask, netmask4, sizeof (struct sockaddr_in)); - GNUNET_memcpy (net->network, &network4, sizeof (struct sockaddr_in)); - } - - if (addr->sa_family == AF_INET6) - { - const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr; - const struct sockaddr_in6 *netmask6 = (const struct sockaddr_in6 *) netmask; - struct sockaddr_in6 * tmp; - struct sockaddr_in6 network6; - - net = GNUNET_malloc (sizeof (struct ATS_Network) + 2 * sizeof (struct sockaddr_in6)); - tmp = (struct sockaddr_in6 *) &net[1]; - net->network = (struct sockaddr *) &tmp[0]; - net->netmask = (struct sockaddr *) &tmp[1]; - net->length = addrlen; - - memset (&network6, 0, sizeof (network6)); - network6.sin6_family = AF_INET6; -#if HAVE_SOCKADDR_IN_SIN_LEN - network6.sin6_len = sizeof (network6); -#endif - unsigned int c = 0; - uint32_t *addr_elem = (uint32_t *) &addr6->sin6_addr; - uint32_t *mask_elem = (uint32_t *) &netmask6->sin6_addr; - uint32_t *net_elem = (uint32_t *) &network6.sin6_addr; - for (c = 0; c < 4; c++) - net_elem[c] = addr_elem[c] & mask_elem[c]; - - GNUNET_memcpy (net->netmask, netmask6, sizeof (struct sockaddr_in6)); - GNUNET_memcpy (net->network, &network6, sizeof (struct sockaddr_in6)); - } - if (NULL == net) - return GNUNET_OK; /* odd / unsupported address family */ - - /* Store in list */ -#if VERBOSE_ATS - char * netmask = GNUNET_strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen)); - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "ats-scanner-api", - "Adding network `%s', netmask `%s'\n", - GNUNET_a2s ((struct sockaddr *) net->network, - addrlen), - netmask); - GNUNET_free (netmask); -#endif - GNUNET_CONTAINER_DLL_insert (is->net_head, - is->net_tail, - net); - - return GNUNET_OK; -} - - -/** - * Periodically get list of network addresses from our interfaces. - * - * @param cls closure - */ -static void -get_addresses (void *cls) -{ - struct GNUNET_ATS_InterfaceScanner *is = cls; - - is->interface_task = NULL; - delete_networks (is); - GNUNET_OS_network_interfaces_list (&interface_proc, - is); - is->interface_task = GNUNET_SCHEDULER_add_delayed (INTERFACE_PROCESSING_INTERVAL, - &get_addresses, - is); -} - - -/** - * Returns where the address is located: LAN or WAN or ... - * - * @param is the interface scanner handle - * @param addr address - * @param addrlen address length - * @return type of the network the address belongs to - */ -enum GNUNET_ATS_Network_Type -GNUNET_ATS_scanner_address_get_type (struct GNUNET_ATS_InterfaceScanner *is, - const struct sockaddr *addr, - socklen_t addrlen) -{ - struct ATS_Network *cur = is->net_head; - enum GNUNET_ATS_Network_Type type = GNUNET_ATS_NET_UNSPECIFIED; - - switch (addr->sa_family) - { - case AF_UNIX: - type = GNUNET_ATS_NET_LOOPBACK; - break; - case AF_INET: - { - const struct sockaddr_in *a4 = (const struct sockaddr_in *) addr; - - if ((a4->sin_addr.s_addr & htonl(0xff000000)) == htonl (0x7f000000)) - type = GNUNET_ATS_NET_LOOPBACK; - break; - } - case AF_INET6: - { - const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *) addr; - - if (IN6_IS_ADDR_LOOPBACK (&a6->sin6_addr)) - type = GNUNET_ATS_NET_LOOPBACK; - break; - } - default: - GNUNET_break (0); - break; - } - - /* Check local networks */ - while ((NULL != cur) && (GNUNET_ATS_NET_UNSPECIFIED == type)) - { - if (addrlen != cur->length) - { - cur = cur->next; - continue; - } - if (addr->sa_family == AF_INET) - { - const struct sockaddr_in *a4 = (const struct sockaddr_in *) addr; - const struct sockaddr_in *net4 = (const struct sockaddr_in *) cur->network; - const struct sockaddr_in *mask4 = (const struct sockaddr_in *) cur->netmask; - - if (((a4->sin_addr.s_addr & mask4->sin_addr.s_addr)) == net4->sin_addr.s_addr) - type = GNUNET_ATS_NET_LAN; - } - if (addr->sa_family == AF_INET6) - { - const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *) addr; - const struct sockaddr_in6 *net6 = (const struct sockaddr_in6 *) cur->network; - const struct sockaddr_in6 *mask6 = (const struct sockaddr_in6 *) cur->netmask; - - int res = GNUNET_YES; - int c = 0; - uint32_t *addr_elem = (uint32_t *) &a6->sin6_addr; - uint32_t *mask_elem = (uint32_t *) &mask6->sin6_addr; - uint32_t *net_elem = (uint32_t *) &net6->sin6_addr; - for (c = 0; c < 4; c++) - if ((addr_elem[c] & mask_elem[c]) != net_elem[c]) - res = GNUNET_NO; - - if (res == GNUNET_YES) - type = GNUNET_ATS_NET_LAN; - } - cur = cur->next; - } - - /* no local network found for this address, default: WAN */ - if (type == GNUNET_ATS_NET_UNSPECIFIED) - type = GNUNET_ATS_NET_WAN; - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "ats-scanner-api", - "`%s' is in network `%s'\n", - GNUNET_a2s (addr, - addrlen), - GNUNET_ATS_print_network_type (type)); - return type; -} - - -/** - * Initialize the interface scanner. - * - * @return interface scanner - */ -struct GNUNET_ATS_InterfaceScanner * -GNUNET_ATS_scanner_init () -{ - struct GNUNET_ATS_InterfaceScanner *is; - - is = GNUNET_new (struct GNUNET_ATS_InterfaceScanner); - GNUNET_OS_network_interfaces_list (&interface_proc, - is); - is->interface_task = GNUNET_SCHEDULER_add_delayed (INTERFACE_PROCESSING_INTERVAL, - &get_addresses, - is); - return is; -} - - -/** - * Client is done with the interface scanner, release resources. - * - * @param is handle to release - */ -void -GNUNET_ATS_scanner_done (struct GNUNET_ATS_InterfaceScanner *is) -{ - if (NULL != is->interface_task) - { - GNUNET_SCHEDULER_cancel (is->interface_task); - is->interface_task = NULL; - } - delete_networks (is); - GNUNET_free (is); -} - - /* 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, if (NULL == sh->mq) return; /* disconnected, skip for now */ - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ar->properties.scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != ar->properties.scope); namelen = strlen (ar->address->transport_name) + 1; msize = ar->address->address_length + namelen; 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, GNUNET_break (0); return NULL; } - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); namelen = strlen (address->transport_name) + 1; msize = address->address_length + namelen; if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_MAX_MESSAGE_SIZE) || @@ -755,7 +755,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, ar->address->transport_name, ar->session, ar->slot); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); GNUNET_ATS_properties_hton (&ar->properties, prop); 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, GNUNET_STRINGS_utf8_toupper (op_network,op_network); if (0 == strcmp(op_network, "UNSPECIFIED")) { - o->address_network = GNUNET_ATS_NET_UNSPECIFIED; + o->address_network = GNUNET_NT_UNSPECIFIED; } else if (0 == strcmp(op_network, "LOOPBACK")) { - o->address_network = GNUNET_ATS_NET_LOOPBACK; + o->address_network = GNUNET_NT_LOOPBACK; } else if (0 == strcmp(op_network, "LAN")) { - o->address_network = GNUNET_ATS_NET_LAN; + o->address_network = GNUNET_NT_LAN; } else if (0 == strcmp(op_network, "WAN")) { - o->address_network = GNUNET_ATS_NET_WAN; + o->address_network = GNUNET_NT_WAN; } else if (0 == strcmp(op_network, "WLAN")) { - o->address_network = GNUNET_ATS_NET_WLAN; + o->address_network = GNUNET_NT_WLAN; } else if (0 == strcmp(op_network, "BT")) { - o->address_network = GNUNET_ATS_NET_BT; + o->address_network = GNUNET_NT_BT; } else { @@ -2214,7 +2214,7 @@ enforce_add_address (struct GNUNET_ATS_TEST_Operation *op) GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n", - op->address_id, op->peer_id, GNUNET_ATS_print_network_type(a->network)); + op->address_id, op->peer_id, GNUNET_NT_to_string(a->network)); sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network); @@ -2748,16 +2748,16 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, int c; int res; - for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++) + for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++) { in_dest[c] = 0; out_dest[c] = 0; GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", - GNUNET_ATS_print_network_type (c)); + GNUNET_NT_to_string (c)); GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", - GNUNET_ATS_print_network_type (c)); + GNUNET_NT_to_string (c)); /* quota out */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str)) @@ -2777,7 +2777,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), quota_out_str, GNUNET_ATS_DefaultBandwidth); out_dest[c] = GNUNET_ATS_DefaultBandwidth; @@ -2786,7 +2786,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Outbound quota configure for network `%s' is %llu\n", - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), out_dest[c]); } GNUNET_free (quota_out_str); @@ -2795,7 +2795,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"), - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), GNUNET_ATS_DefaultBandwidth); out_dest[c] = GNUNET_ATS_DefaultBandwidth; } @@ -2818,7 +2818,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), quota_in_str, GNUNET_ATS_DefaultBandwidth); in_dest[c] = GNUNET_ATS_DefaultBandwidth; @@ -2827,7 +2827,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Inbound quota configured for network `%s' is %llu\n", - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), in_dest[c]); } GNUNET_free (quota_in_str); @@ -2836,19 +2836,19 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), GNUNET_ATS_DefaultBandwidth); out_dest[c] = GNUNET_ATS_DefaultBandwidth; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded quota for network `%s' (in/out): %llu %llu\n", - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), in_dest[c], out_dest[c]); GNUNET_free (entry_out); GNUNET_free (entry_in); } - return GNUNET_ATS_NetworkTypeCount; + return GNUNET_NT_COUNT; } @@ -3048,16 +3048,16 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) sh->env.addresses = sh->addresses; sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb; sh->env.get_preferences = &get_preferences_cb; - sh->env.network_count = GNUNET_ATS_NetworkTypeCount; + sh->env.network_count = GNUNET_NT_COUNT; sh->env.info_cb = &solver_info_cb; - sh->env.network_count = GNUNET_ATS_NetworkTypeCount; + sh->env.network_count = GNUNET_NT_COUNT; /* start normalization */ GAS_normalization_start (); /* load quotas */ - if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg, - sh->env.out_quota, sh->env.in_quota, GNUNET_ATS_NetworkTypeCount)) + if (GNUNET_NT_COUNT != GNUNET_ATS_solvers_load_quotas (e->cfg, + sh->env.out_quota, sh->env.in_quota, GNUNET_NT_COUNT)) { GNUNET_break(0); 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, GNUNET_break (0); return; } - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); new_address = create_address (peer, plugin_name, plugin_addr, @@ -293,7 +293,7 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, "Received ADDRESS_UPDATE for peer `%s' slot %u\n", GNUNET_i2s (peer), (unsigned int) session_id); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); /* Update address */ aa->t_last_activity = GNUNET_TIME_absolute_get(); 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 @@ * network an inbound and outbound quota will be specified. The available * networks and addtional helper varaibles are defined in * gnunet_ats_service.h. At the moment 5 networks are defined: - * * GNUNET_ATS_NET_UNSPECIFIED - * * GNUNET_ATS_NET_LOOPBACK - * * GNUNET_ATS_NET_LAN - * * GNUNET_ATS_NET_WAN - * * GNUNET_ATS_NET_WLAN + * * GNUNET_NT_UNSPECIFIED + * * GNUNET_NT_LOOPBACK + * * GNUNET_NT_LAN + * * GNUNET_NT_WAN + * * GNUNET_NT_WLAN * * The total number of networks defined is stored in - * GNUNET_ATS_NetworkTypeCount GNUNET_ATS_NetworkType can be used array + * GNUNET_NT_COUNT GNUNET_ATS_NetworkType can be used array * initializer for an int array, while GNUNET_ATS_NetworkType is an * initializer for a char array containing a string description of all * 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, char *addrp; if (NULL != prop) - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); GNUNET_assert (msize < GNUNET_MAX_MESSAGE_SIZE); msg = (struct PeerInformationMessage *) buf; msg->header.size = htons (msize); @@ -151,7 +151,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) { GNUNET_break ( (NULL == prop) || - (GNUNET_ATS_NET_UNSPECIFIED != prop->scope) ); + (GNUNET_NT_UNSPECIFIED != prop->scope) ); notify_client (NULL, peer, plugin_name, @@ -205,7 +205,7 @@ peerinfo_it (void *cls, plugin_name, (unsigned int) ntohl (bandwidth_out.value__), (unsigned int) ntohl (bandwidth_in.value__)); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); notify_client (client, id, 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, static unsigned long long parse_quota (const char *quota_str, const char *direction, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { int res; unsigned long long ret; @@ -301,7 +301,7 @@ parse_quota (const char *quota_str, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"), direction, - GNUNET_ATS_print_network_type (network), + GNUNET_NT_to_string (network), quota_str, (unsigned long long) GNUNET_ATS_DefaultBandwidth); ret = GNUNET_ATS_DefaultBandwidth; @@ -311,7 +311,7 @@ parse_quota (const char *quota_str, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%s quota configured for network `%s' is %llu\n"), direction, - GNUNET_ATS_print_network_type (network), + GNUNET_NT_to_string (network), ret); } return ret; @@ -329,7 +329,7 @@ parse_quota (const char *quota_str, */ static unsigned long long load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, - enum GNUNET_ATS_Network_Type type, + enum GNUNET_NetworkType type, const char *direction) { char *entry; @@ -338,7 +338,7 @@ load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_asprintf (&entry, "%s_QUOTA_%s", - GNUNET_ATS_print_network_type (type), + GNUNET_NT_to_string (type), direction); if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, @@ -356,7 +356,7 @@ load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No %s-quota configured for network `%s', assigning default bandwidth %llu\n"), direction, - GNUNET_ATS_print_network_type (type), + GNUNET_NT_to_string (type), (unsigned long long) GNUNET_ATS_DefaultBandwidth); ret = GNUNET_ATS_DefaultBandwidth; } @@ -382,7 +382,7 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, { unsigned int c; - for (c = 0; (c < GNUNET_ATS_NetworkTypeCount) && (c < dest_length); c++) + for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++) { in_dest[c] = load_quota (cfg, c, @@ -392,7 +392,7 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, "in"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded quota for network `%s' (in/out): %llu %llu\n", - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), in_dest[c], out_dest[c]); } @@ -431,11 +431,11 @@ GAS_plugin_init (const struct GNUNET_CONFIGURATION_Handle *cfg) env.cfg = cfg; env.stats = GSA_stats; env.addresses = GSA_addresses; - env.network_count = GNUNET_ATS_NetworkTypeCount; + env.network_count = GNUNET_NT_COUNT; load_quotas (cfg, env.out_quota, env.in_quota, - GNUNET_ATS_NetworkTypeCount); + GNUNET_NT_COUNT); GNUNET_asprintf (&plugin, "libgnunet_plugin_ats_%s", 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) GNUNET_NO); GNUNET_ATS_properties_ntoh (&prop, &m->properties); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop.scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop.scope); GAS_addresses_add (&m->peer, plugin_name, 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) /* Add address */ /* Random network selection */ - //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount - 1); + //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_NT_COUNT - 1); /* Random equally distributed network selection */ - net = 1 + (ca % (GNUNET_ATS_NetworkTypeCount - 1)); + net = 1 + (ca % (GNUNET_NT_COUNT - 1)); /* fprintf (stderr, "Network: %u `%s'\n", - * mod_net , GNUNET_ATS_print_network_type(mod_net)); */ + * mod_net , GNUNET_NT_to_string(mod_net)); */ cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information); cur_addr->atsi_count = 1; @@ -1127,7 +1127,7 @@ perf_run_iteration (void) perf_address_initial_update (NULL, ph.addresses, cur_addr); GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Adding address for peer %u address %u in network %s\n", cp, ca, - GNUNET_ATS_print_network_type(net)); + GNUNET_NT_to_string(net)); } /* Notify solver about request */ ph.sf->s_get (ph.sf->cls, &ph.peers[cp].id); @@ -1210,8 +1210,8 @@ run (void *cls, char * const *args, const char *cfgfile, char *solver; char *plugin; struct GNUNET_CONFIGURATION_Handle *solver_cfg; - unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; - unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; + unsigned long long quotas_in[GNUNET_NT_COUNT]; + unsigned long long quotas_out[GNUNET_NT_COUNT]; int c; int c2; @@ -1286,8 +1286,8 @@ run (void *cls, char * const *args, const char *cfgfile, end_now (1); return; } - if (GNUNET_ATS_NetworkTypeCount != load_quotas (solver_cfg, - quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount)) + if (GNUNET_NT_COUNT != load_quotas (solver_cfg, + quotas_out, quotas_in, GNUNET_NT_COUNT)) { GNUNET_break(0); end_now (1); @@ -1306,16 +1306,16 @@ run (void *cls, char * const *args, const char *cfgfile, ph.env.bandwidth_changed_cb = bandwidth_changed_cb; ph.env.get_connectivity = &get_connectivity_cb; ph.env.get_preferences = &get_preferences_cb; - ph.env.network_count = GNUNET_ATS_NetworkTypeCount; + ph.env.network_count = GNUNET_NT_COUNT; ph.env.info_cb = &solver_info_cb; - for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) + for (c = 0; c < GNUNET_NT_COUNT; c++) { ph.env.out_quota[c] = quotas_out[c]; ph.env.in_quota[c] = quotas_in[c]; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loading network quotas: `%s' %llu %llu \n", - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), ph.env.out_quota[c], ph.env.in_quota[c]); } 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 /* Row indices quality metrics */ int r_q[RQ_QUALITY_METRIC_COUNT]; /* Row indices ATS network quotas */ - int r_quota[GNUNET_ATS_NetworkTypeCount]; + int r_quota[GNUNET_NT_COUNT]; /* Column index Diversity (D) column */ int c_d; @@ -211,12 +211,12 @@ struct MLP_Variables /* Quotas */ /* Array mapping array index to ATS network */ - int quota_index[GNUNET_ATS_NetworkTypeCount]; + int quota_index[GNUNET_NT_COUNT]; /* Outbound quotas */ - unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount]; + unsigned long long quota_out[GNUNET_NT_COUNT]; /* Inbound quotas */ - unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount]; + unsigned long long quota_in[GNUNET_NT_COUNT]; /* ATS ressource costs * array with GNUNET_ATS_QualityPropertiesCount elements @@ -601,7 +601,7 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp) mlp->p.r_c9 = MLP_UNDEFINED; for (c = 0; c < RQ_QUALITY_METRIC_COUNT ; c ++) mlp->p.r_q[c] = MLP_UNDEFINED; - for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c ++) + for (c = 0; c < GNUNET_NT_COUNT; c ++) mlp->p.r_quota[c] = MLP_UNDEFINED; mlp->p.ci = MLP_UNDEFINED; @@ -969,20 +969,20 @@ mlp_create_problem_add_address_information (void *cls, } addr_net = address->properties.scope; - for (addr_net_index = 0; addr_net_index < GNUNET_ATS_NetworkTypeCount; addr_net_index++) + for (addr_net_index = 0; addr_net_index < GNUNET_NT_COUNT; addr_net_index++) { if (mlp->pv.quota_index[addr_net_index] == addr_net) break; } - if (addr_net_index >= GNUNET_ATS_NetworkTypeCount) + if (addr_net_index >= GNUNET_NT_COUNT) { GNUNET_break (0); return GNUNET_OK; } max_quota = 0; - for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) + for (c = 0; c < GNUNET_NT_COUNT; c++) { if (mlp->pv.quota_out[c] > max_quota) 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 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); /* Rows for c 10) Enforce network quotas */ - for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) + for (c = 0; c < GNUNET_NT_COUNT; c++) { char * text; GNUNET_asprintf(&text, "c10_quota_ats_%s", - GNUNET_ATS_print_network_type(mlp->pv.quota_index[c])); + GNUNET_NT_to_string(mlp->pv.quota_index[c])); p->r_quota[c] = mlp_create_problem_create_constraint (p, text, GLP_DB, 0.0, mlp->pv.quota_out[c]); GNUNET_free (text); } @@ -1853,7 +1853,7 @@ GAS_mlp_address_add (void *solver, { struct GAS_MLP_Handle *mlp = solver; - if (GNUNET_ATS_NetworkTypeCount <= network) + if (GNUNET_NT_COUNT <= network) { GNUNET_break (0); return; @@ -2651,7 +2651,7 @@ libgnunet_plugin_ats_mlp_init (void *cls) n_min = MLP_DEFAULT_MIN_CONNECTIONS; /* Init network quotas */ - for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) + for (c = 0; c < GNUNET_NT_COUNT; c++) { mlp->pv.quota_index[c] = c; mlp->pv.quota_out[c] = env->out_quota[c]; @@ -2659,7 +2659,7 @@ libgnunet_plugin_ats_mlp_init (void *cls) LOG (GNUNET_ERROR_TYPE_INFO, "Quota for network `%s' (in/out) %llu/%llu\n", - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), mlp->pv.quota_out[c], mlp->pv.quota_in[c]); /* Check if defined quota could make problem unsolvable */ @@ -2667,7 +2667,7 @@ libgnunet_plugin_ats_mlp_init (void *cls) { LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"), - GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), + GNUNET_NT_to_string(mlp->pv.quota_index[c]), mlp->pv.quota_out[c], (n_min * b_min)); mlp->pv.quota_out[c] = (n_min * b_min); @@ -2676,7 +2676,7 @@ libgnunet_plugin_ats_mlp_init (void *cls) { LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"), - GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), + GNUNET_NT_to_string(mlp->pv.quota_index[c]), mlp->pv.quota_in[c], (n_min * b_min)); mlp->pv.quota_in[c] = (n_min * b_min); @@ -2686,7 +2686,7 @@ libgnunet_plugin_ats_mlp_init (void *cls) { LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"), - GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), + GNUNET_NT_to_string(mlp->pv.quota_index[c]), mlp->pv.quota_out[c], mlp->pv.BIG_M); mlp->pv.quota_out[c] = mlp->pv.BIG_M ; @@ -2695,7 +2695,7 @@ libgnunet_plugin_ats_mlp_init (void *cls) { LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"), - GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), + GNUNET_NT_to_string(mlp->pv.quota_index[c]), mlp->pv.quota_in[c], mlp->pv.BIG_M); 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 /** * ATS network type */ - enum GNUNET_ATS_Network_Type type; + enum GNUNET_NetworkType type; /** * Number of active addresses for this network @@ -429,7 +429,7 @@ distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s, { LOG (GNUNET_ERROR_TYPE_DEBUG, "Redistributing bandwidth in network %s with %u active and %u total addresses\n", - GNUNET_ATS_print_network_type(n->type), + GNUNET_NT_to_string(n->type), n->active_addresses, n->total_addresses); s->env->info_cb (s->env->cls, @@ -1181,7 +1181,7 @@ libgnunet_plugin_ats_proportional_init (void *cls) cur->type = c; cur->total_quota_in = env->in_quota[c]; cur->total_quota_out = env->out_quota[c]; - cur->desc = GNUNET_ATS_print_network_type (c); + cur->desc = GNUNET_NT_to_string (c); GNUNET_asprintf (&cur->stat_total, "# ATS addresses %s total", 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 /** * ATS network type */ - enum GNUNET_ATS_Network_Type type; + enum GNUNET_NetworkType type; /** * Total available inbound bandwidth @@ -1593,7 +1593,7 @@ ril_get_network (struct GAS_RIL_Handle *s, uint32_t type) * @return GNUNET_YES if there are theoretically enough resources left */ static int -ril_network_is_not_full (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type network) +ril_network_is_not_full (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType network) { struct RIL_Scope *net; struct RIL_Peer_Agent *agent; @@ -1720,7 +1720,7 @@ ril_network_count_active_agents (struct GAS_RIL_Handle *solver, struct RIL_Scope * @return the sum of the assigned bandwidths */ static unsigned long long -ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type type, int direction_in) +ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType type, int direction_in) { struct RIL_Peer_Agent *cur; struct RIL_Scope *net; @@ -1755,7 +1755,7 @@ ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network * @return the sum of the utilized bandwidths (in bytes/second) */ static unsigned long long -ril_network_get_utilized (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type type, int direction_in) +ril_network_get_utilized (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType type, int direction_in) { struct RIL_Peer_Agent *cur; struct RIL_Scope *net; @@ -2038,7 +2038,7 @@ ril_get_agent (struct GAS_RIL_Handle *solver, const struct GNUNET_PeerIdentity * * @return whether or not the network is considered active */ static int -ril_network_is_active (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network_Type network) +ril_network_is_active (struct GAS_RIL_Handle *solver, enum GNUNET_NetworkType network) { struct RIL_Scope *net; @@ -2786,7 +2786,7 @@ libgnunet_plugin_ats_ril_init (void *cls) cur->bw_out_available = env->out_quota[c]; LOG (GNUNET_ERROR_TYPE_DEBUG, "init() Quotas for %s network: IN %llu - OUT %llu\n", - GNUNET_ATS_print_network_type(cur->type), + GNUNET_NT_to_string(cur->type), cur->bw_in_available/1024, cur->bw_out_available/1024); } 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[] = { .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE, .session = 0, .properties = { - .scope = GNUNET_ATS_NET_LAN + .scope = GNUNET_NT_LAN } } }, @@ -55,7 +55,7 @@ static struct Command test_commands[] = { .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE, .session = 0, .properties = { - .scope = GNUNET_ATS_NET_LAN + .scope = GNUNET_NT_LAN }, .expect_fail = 1 } @@ -155,7 +155,7 @@ static struct Command test_commands[] = { .addr_num = 0, .session = 0, .properties = { - .scope = GNUNET_ATS_NET_LAN + .scope = GNUNET_NT_LAN } } }, @@ -184,7 +184,7 @@ static struct Command test_commands[] = { .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE, .session = 0, .properties = { - .scope = GNUNET_ATS_NET_LAN + .scope = GNUNET_NT_LAN } } }, 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[] = { .session = 0, .properties = { /* use network with 65k quota! */ - .scope = GNUNET_ATS_NET_WAN + .scope = GNUNET_NT_WAN } } }, -- cgit v1.2.3