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-tests/ats-testing-log.c | 2 +- src/ats-tests/ats-testing.c | 2 +- src/ats-tool/Makefile.am | 1 + src/ats-tool/gnunet-ats.c | 16 +- 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 +- src/dv/dv_api.c | 4 +- src/dv/gnunet-dv.c | 4 +- src/dv/gnunet-service-dv.c | 16 +- src/dv/plugin_transport_dv.c | 18 +- src/hello/hello-ng.c | 6 +- src/include/gnunet_ats_plugin.h | 4 +- src/include/gnunet_ats_service.h | 93 +---- src/include/gnunet_dv_service.h | 4 +- src/include/gnunet_hello_lib.h | 10 +- .../gnunet_transport_communication_service.h | 4 +- src/include/gnunet_transport_hello_service.h | 2 +- src/include/gnunet_transport_monitor_service.h | 2 +- src/include/gnunet_transport_plugin.h | 8 +- src/nt/nt.c | 9 +- src/transport/Makefile.am | 1 + src/transport/gnunet-communicator-unix.c | 4 +- src/transport/gnunet-service-tng.c | 12 +- src/transport/gnunet-service-transport.c | 10 +- src/transport/gnunet-service-transport.h | 2 +- src/transport/gnunet-service-transport_ats.c | 6 +- src/transport/gnunet-service-transport_plugins.c | 6 +- .../gnunet-service-transport_validation.c | 8 +- src/transport/plugin_transport_http_client.c | 14 +- src/transport/plugin_transport_http_common.c | 6 +- src/transport/plugin_transport_http_common.h | 2 +- src/transport/plugin_transport_http_server.c | 8 +- src/transport/plugin_transport_tcp.c | 16 +- src/transport/plugin_transport_template.c | 8 +- src/transport/plugin_transport_udp.c | 30 +- src/transport/plugin_transport_udp.h | 2 +- src/transport/plugin_transport_udp_broadcasting.c | 8 +- src/transport/plugin_transport_unix.c | 10 +- src/transport/plugin_transport_wlan.c | 16 +- src/transport/plugin_transport_xt.c | 16 +- src/transport/plugin_transport_xu.c | 26 +- src/transport/test_plugin_transport.c | 4 +- src/transport/test_quota_compliance.c | 6 +- src/transport/transport.h | 6 +- src/transport/transport_api2_communication.c | 8 +- src/transport/transport_api2_monitor.c | 2 +- 59 files changed, 267 insertions(+), 738 deletions(-) diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c index 3d409d53a..1099a4b36 100644 --- a/src/ats-tests/ats-testing-log.c +++ b/src/ats-tests/ats-testing-log.c @@ -131,7 +131,7 @@ struct PartnerLoggingTimestep uint32_t ats_utilization_in; - enum GNUNET_ATS_Network_Type ats_network_type; + enum GNUNET_NetworkType ats_network_type; double pref_bandwidth; double pref_delay; diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index 058e29cde..967f6213d 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c @@ -850,7 +850,7 @@ main_run (void *cls, /* Initialize properties */ top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO; top->sps[c_s].partners[c_m].props.distance = 0; - top->sps[c_s].partners[c_m].props.scope = GNUNET_ATS_NET_UNSPECIFIED; + top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED; top->sps[c_s].partners[c_m].props.utilization_in = 0; top->sps[c_s].partners[c_m].props.utilization_out = 0; } diff --git a/src/ats-tool/Makefile.am b/src/ats-tool/Makefile.am index 02a21591b..55bfe1322 100644 --- a/src/ats-tool/Makefile.am +++ b/src/ats-tool/Makefile.am @@ -17,6 +17,7 @@ gnunet_ats_SOURCES = \ gnunet_ats_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/ats/libgnunetats.la \ + $(top_builddir)/src/nt/libgnunetnt.la \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/hello/libgnunethello.la \ $(GN_LIBINTL) diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 2db0a47d9..0d26ba5d9 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c @@ -394,7 +394,7 @@ transport_addr_to_str_cb (void *cls, GNUNET_i2s (&pr->address->peer), pr->address->transport_name, address, - GNUNET_ATS_print_network_type (pr->properties.scope), + GNUNET_NT_to_string (pr->properties.scope), ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__), pr->active ? _("active ") : _("inactive ")); @@ -641,15 +641,15 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg) unsigned long long int quota_in; int c; - for (c = 0; (c < GNUNET_ATS_NetworkTypeCount); c++) + for (c = 0; (c < GNUNET_NT_COUNT); c++) { 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 == @@ -671,7 +671,7 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg) { FPRINTF (stderr, "Outbound quota for network `%11s' not configured!\n", - GNUNET_ATS_print_network_type (c)); + GNUNET_NT_to_string (c)); GNUNET_asprintf ("a_out_str, "-"); } GNUNET_free (entry_out); @@ -694,20 +694,20 @@ print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg) { FPRINTF (stderr, "Inbound quota for network `%11s' not configured!\n", - GNUNET_ATS_print_network_type (c)); + GNUNET_NT_to_string (c)); GNUNET_asprintf ("a_in_str, "-"); } GNUNET_free(entry_in); FPRINTF (stdout, _("Quota for network `%11s' (in/out): %10s / %10s\n"), - GNUNET_ATS_print_network_type (c), + GNUNET_NT_to_string (c), quota_in_str, quota_out_str); GNUNET_free(quota_out_str); GNUNET_free(quota_in_str); } - return GNUNET_ATS_NetworkTypeCount; + return GNUNET_NT_COUNT; } 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 } } }, diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 9d73a40c1..17ee2f783 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c @@ -165,7 +165,7 @@ handle_connect (void *cls, sh->connect_cb (sh->cls, &cm->peer, ntohl (cm->distance), - (enum GNUNET_ATS_Network_Type) ntohl (cm->network)); + (enum GNUNET_NetworkType) ntohl (cm->network)); } @@ -222,7 +222,7 @@ handle_distance_update (void *cls, sh->distance_cb (sh->cls, &dum->peer, ntohl (dum->distance), - (enum GNUNET_ATS_Network_Type) ntohl (dum->network)); + (enum GNUNET_NetworkType) ntohl (dum->network)); } diff --git a/src/dv/gnunet-dv.c b/src/dv/gnunet-dv.c index ee60d592f..6f5323c65 100644 --- a/src/dv/gnunet-dv.c +++ b/src/dv/gnunet-dv.c @@ -47,7 +47,7 @@ static void connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { fprintf (stderr, "Connect: %s at %u\n", GNUNET_i2s (peer), @@ -67,7 +67,7 @@ static void change_cb (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { fprintf (stderr, "Change: %s at %u\n", GNUNET_i2s (peer), diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 907963252..f183c77fd 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -222,7 +222,7 @@ struct DirectNeighbor /** * The network this peer is in */ - enum GNUNET_ATS_Network_Type network; + enum GNUNET_NetworkType network; /** * Is this neighbor connected at the core level? @@ -439,11 +439,11 @@ send_control_to_plugin (const struct GNUNET_MessageHeader *message) static void send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { struct GNUNET_DV_DistanceUpdateMessage du_msg; - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Delivering DISTANCE_CHANGED for message about peer `%s'\n", GNUNET_i2s (peer)); @@ -466,7 +466,7 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, static void send_connect_to_plugin (const struct GNUNET_PeerIdentity *target, uint32_t distance, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { struct GNUNET_DV_ConnectMessage cm; @@ -833,7 +833,7 @@ handle_core_connect (void *cls, peer); if (NULL != neighbor) { - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != neighbor->network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != neighbor->network); GNUNET_break (GNUNET_YES != neighbor->connected); neighbor->connected = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -857,7 +857,7 @@ handle_core_connect (void *cls, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); neighbor->connected = GNUNET_YES; neighbor->distance = 0; /* unknown */ - neighbor->network = GNUNET_ATS_NET_UNSPECIFIED; + neighbor->network = GNUNET_NT_UNSPECIFIED; return neighbor; } @@ -1123,7 +1123,7 @@ handle_ats_update (void *cls, { struct DirectNeighbor *neighbor; uint32_t distance; - enum GNUNET_ATS_Network_Type network; + enum GNUNET_NetworkType network; if (NULL == address) { @@ -1138,7 +1138,7 @@ handle_ats_update (void *cls, } distance = prop->distance; network = prop->scope; - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network); /* check if entry exists */ neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, &address->peer); diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 6c815735e..ca4908e95 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c @@ -82,7 +82,7 @@ struct GNUNET_ATS_Session /** * Current network the next hop peer is located in */ - enum GNUNET_ATS_Network_Type network; + enum GNUNET_NetworkType network; /** * Does the transport service know about this session (and we thus @@ -288,12 +288,12 @@ static void handle_dv_connect (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { struct Plugin *plugin = cls; struct GNUNET_ATS_Session *session; - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network); /** * This requires transport plugin to be linked to libgnunetats. * If you remove it, also remove libgnunetats linkage from Makefile.am @@ -301,7 +301,7 @@ handle_dv_connect (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Received DV_CONNECT message for peer `%s' with next hop in network %s\n", GNUNET_i2s (peer), - GNUNET_ATS_print_network_type (network)); + GNUNET_NT_to_string (network)); session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, peer); @@ -359,12 +359,12 @@ static void handle_dv_distance_changed (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network) + enum GNUNET_NetworkType network) { struct Plugin *plugin = cls; struct GNUNET_ATS_Session *session; - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network); LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for peer `%s': new distance %u\n", "DV_DISTANCE_CHANGED", @@ -715,7 +715,7 @@ dv_plugin_update_session_timeout (void *cls, * @param session the session * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType dv_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -731,11 +731,11 @@ dv_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType dv_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { - return GNUNET_ATS_NET_WAN; /* FOR NOW */ + return GNUNET_NT_WAN; /* FOR NOW */ } diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c index fcd1808f4..a16ceb944 100644 --- a/src/hello/hello-ng.c +++ b/src/hello/hello-ng.c @@ -62,7 +62,7 @@ struct SignedAddress */ void GNUNET_HELLO_sign_address (const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute expiration, const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, void **result, @@ -110,7 +110,7 @@ char * GNUNET_HELLO_extract_address (const void *raw, size_t raw_size, const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, - enum GNUNET_ATS_Network_Type *nt, + enum GNUNET_NetworkType *nt, struct GNUNET_TIME_Absolute *expiration) { const char *raws = raw; @@ -188,6 +188,6 @@ GNUNET_HELLO_extract_address (const void *raw, } GNUNET_free (sig); *expiration = raw_expiration; - *nt = (enum GNUNET_ATS_Network_Type) raw_nt; + *nt = (enum GNUNET_NetworkType) raw_nt; return GNUNET_strdup (raw_addr); } diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h index d414d5f4c..16711c852 100644 --- a/src/include/gnunet_ats_plugin.h +++ b/src/include/gnunet_ats_plugin.h @@ -467,13 +467,13 @@ struct GNUNET_ATS_PluginEnvironment * Array of configured outbound quotas * Order according to networks in network array */ - unsigned long long out_quota[GNUNET_ATS_NetworkTypeCount]; + unsigned long long out_quota[GNUNET_NT_COUNT]; /** * Array of configured inbound quotas * Order according to networks in network array */ - unsigned long long in_quota[GNUNET_ATS_NetworkTypeCount]; + unsigned long long in_quota[GNUNET_NT_COUNT]; }; #endif diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index a9fd519d4..b25cf3ec0 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -36,48 +36,6 @@ #include "gnunet_util_lib.h" #include "gnunet_hello_lib.h" -/** - * Types of networks (with separate quotas) we support. - */ -enum GNUNET_ATS_Network_Type -{ - /** - * Category of last resort. - */ - GNUNET_ATS_NET_UNSPECIFIED = 0, - - /** - * Loopback (same host). - */ - GNUNET_ATS_NET_LOOPBACK = 1, - - /** - * Local area network. - */ - GNUNET_ATS_NET_LAN = 2, - - /** - * Wide area network (i.e. Internet) - */ - GNUNET_ATS_NET_WAN = 3, - - /** - * Wireless LAN (i.e. 802.11abgn) - */ - GNUNET_ATS_NET_WLAN = 4, - - /** - * Bluetooth LAN - */ - GNUNET_ATS_NET_BT = 5, - -/** - * Number of network types supported by ATS - */ -#define GNUNET_ATS_NetworkTypeCount 6 - -}; - /** * Default bandwidth assigned to a network : 64 KB/s @@ -143,7 +101,7 @@ struct GNUNET_ATS_Properties * Which network scope does the respective address belong to? * This property does not change. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; }; @@ -220,55 +178,6 @@ GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo, -/** - * 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); - - -/** - * Handle for the LAN Characterization library. - */ -struct GNUNET_ATS_InterfaceScanner; - - -/** - * Returns where the address is located: loopback, LAN or WAN. - * - * @param is handle from #GNUNET_ATS_interface_scanner_init() - * @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); - - -/** - * Initialize the ATS address characterization client handle. - * - * @return scanner handle, NULL on error - */ -struct GNUNET_ATS_InterfaceScanner * -GNUNET_ATS_scanner_init (void); - - -/** - * Terminate interface scanner. - * - * @param is scanner we are done with - */ -void -GNUNET_ATS_scanner_done (struct GNUNET_ATS_InterfaceScanner *is); - - - /* ********************Connection Suggestion API ***************************** */ /** diff --git a/src/include/gnunet_dv_service.h b/src/include/gnunet_dv_service.h index aa8d6af61..b97a2629f 100644 --- a/src/include/gnunet_dv_service.h +++ b/src/include/gnunet_dv_service.h @@ -47,7 +47,7 @@ typedef void (*GNUNET_DV_ConnectCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network); + enum GNUNET_NetworkType network); /** @@ -63,7 +63,7 @@ typedef void (*GNUNET_DV_DistanceChangedCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - enum GNUNET_ATS_Network_Type network); + enum GNUNET_NetworkType network); /** diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index ceaa60466..8a405a25e 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h @@ -474,11 +474,7 @@ GNUNET_HELLO_parse_uri (const char *uri, /* NG API */ -/** - * Defined in gnunet_ats_service.h, but here we do not care about - * the details so are just giving the declaration. - */ -enum GNUNET_ATS_Network_Type; +#include "gnunet_nt_lib.h" /** @@ -493,7 +489,7 @@ enum GNUNET_ATS_Network_Type; */ void GNUNET_HELLO_sign_address (const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute expiration, const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, void **result, @@ -514,7 +510,7 @@ char * GNUNET_HELLO_extract_address (const void *raw, size_t raw_size, const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, - enum GNUNET_ATS_Network_Type *nt, + enum GNUNET_NetworkType *nt, struct GNUNET_TIME_Absolute *expiration); diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index e80ba85cf..1d0add99f 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h @@ -226,7 +226,7 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle const struct GNUNET_PeerIdentity *peer, const char *address, uint32_t mtu, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, uint32_t distance, enum GNUNET_TRANSPORT_ConnectionStatus cs, struct GNUNET_MQ_Handle *mq); @@ -261,7 +261,7 @@ struct GNUNET_TRANSPORT_AddressIdentifier; struct GNUNET_TRANSPORT_AddressIdentifier * GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, struct GNUNET_TIME_Relative expiration); diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h index a21358a9c..50734f957 100644 --- a/src/include/gnunet_transport_hello_service.h +++ b/src/include/gnunet_transport_hello_service.h @@ -166,7 +166,7 @@ typedef void (*GNUNET_TRANSPORT_AddressCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute expiration); diff --git a/src/include/gnunet_transport_monitor_service.h b/src/include/gnunet_transport_monitor_service.h index 799434016..ef599f902 100644 --- a/src/include/gnunet_transport_monitor_service.h +++ b/src/include/gnunet_transport_monitor_service.h @@ -65,7 +65,7 @@ struct GNUNET_TRANSPORT_MonitorInformation /** * Network type of the address. */ - enum GNUNET_ATS_Network_Type nt; + enum GNUNET_NetworkType nt; /** * Connection status. diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index 1f7b46baa..d1f8db445 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h @@ -89,7 +89,7 @@ typedef void (*GNUNET_TRANSPORT_SessionStart) (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, - enum GNUNET_ATS_Network_Type net); + enum GNUNET_NetworkType net); /** @@ -131,7 +131,7 @@ typedef struct GNUNET_TIME_Relative * @param addrlen length of the @a addr * @return type of the network the address belongs to */ -typedef enum GNUNET_ATS_Network_Type +typedef enum GNUNET_NetworkType (*GNUNET_TRANSPORT_AddressToType) (void *cls, const struct sockaddr *addr, size_t addrlen); @@ -547,7 +547,7 @@ typedef int * @param session the session * @return the network type */ -typedef enum GNUNET_ATS_Network_Type +typedef enum GNUNET_NetworkType (*GNUNET_TRANSPORT_GetNetworkType) (void *cls, struct GNUNET_ATS_Session *session); @@ -559,7 +559,7 @@ typedef enum GNUNET_ATS_Network_Type * @param address the address * @return the network type */ -typedef enum GNUNET_ATS_Network_Type +typedef enum GNUNET_NetworkType (*GNUNET_TRANSPORT_GetNetworkTypeForAddress) (void *cls, const struct GNUNET_HELLO_Address *address); diff --git a/src/nt/nt.c b/src/nt/nt.c index 5764f8f4a..ae0fef119 100644 --- a/src/nt/nt.c +++ b/src/nt/nt.c @@ -165,6 +165,9 @@ interface_proc (void *cls, struct GNUNET_NT_InterfaceScanner *is = cls; /* Calculate network */ struct NT_Network *net = NULL; + (void) name; + (void) isDefault; + (void) broadcast_addr; /* Skipping IPv4 loopback addresses since we have special check */ if (addr->sa_family == AF_INET) @@ -285,9 +288,9 @@ get_addresses (void *cls) * @return type of the network the address belongs to */ enum GNUNET_NetworkType -GNUNET_NT_scanner_address_get_type (struct GNUNET_NT_InterfaceScanner *is, - const struct sockaddr *addr, - socklen_t addrlen) +GNUNET_NT_scanner_get_type (struct GNUNET_NT_InterfaceScanner *is, + const struct sockaddr *addr, + socklen_t addrlen) { struct NT_Network *cur = is->net_head; enum GNUNET_NetworkType type = GNUNET_NT_UNSPECIFIED; diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 0693a0b9f..73296abf9 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -314,6 +314,7 @@ gnunet_service_transport_LDADD = \ libgnunettransport.la \ $(top_builddir)/src/ats/libgnunetats.la \ $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/nt/libgnunetnt.la \ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la \ diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c index a97560ad4..0df3fd45d 100644 --- a/src/transport/gnunet-communicator-unix.c +++ b/src/transport/gnunet-communicator-unix.c @@ -680,7 +680,7 @@ setup_queue (const struct GNUNET_PeerIdentity *target, &queue->target, foreign_addr, UNIX_MTU, - GNUNET_ATS_NET_LOOPBACK, + GNUNET_NT_LOOPBACK, 0 /* distance */, cs, queue->mq); @@ -1100,7 +1100,7 @@ run (void *cls, GNUNET_free (unix_socket_path); ai = GNUNET_TRANSPORT_communicator_address_add (ch, my_addr, - GNUNET_ATS_NET_LOOPBACK, + GNUNET_NT_LOOPBACK, GNUNET_TIME_UNIT_FOREVER_REL); GNUNET_free (my_addr); } diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 3e08900bb..b184a0600 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c @@ -162,7 +162,7 @@ struct Queue /** * Network type offered by this queue. */ - enum GNUNET_ATS_Network_Type nt; + enum GNUNET_NetworkType nt; /** * Connection status for this queue. @@ -322,7 +322,7 @@ struct AddressListEntry /** * Network type offered by this address. */ - enum GNUNET_ATS_Network_Type nt; + enum GNUNET_NetworkType nt; }; @@ -549,7 +549,7 @@ static void notify_monitor (struct TransportClient *tc, const struct GNUNET_PeerIdentity *peer, const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, const struct MonitorEvent *me) { struct GNUNET_MQ_Envelope *env; @@ -588,7 +588,7 @@ notify_monitor (struct TransportClient *tc, static void notify_monitors (const struct GNUNET_PeerIdentity *peer, const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, const struct MonitorEvent *me) { static struct GNUNET_PeerIdentity zero; @@ -1255,7 +1255,7 @@ handle_add_address (void *cls, ale->address = (const char *) &ale[1]; ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration); ale->aid = aam->aid; - ale->nt = (enum GNUNET_ATS_Network_Type) ntohl (aam->nt); + ale->nt = (enum GNUNET_NetworkType) ntohl (aam->nt); memcpy (&ale[1], &aam[1], slen); @@ -1427,7 +1427,7 @@ handle_add_queue_message (void *cls, queue->qid = aqm->qid; queue->mtu = ntohl (aqm->mtu); queue->distance = ntohl (aqm->distance); - queue->nt = (enum GNUNET_ATS_Network_Type) ntohl (aqm->nt); + queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); queue->neighbour = neighbour; memcpy (&queue[1], diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 2d9803651..2c1ee12fe 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -415,7 +415,7 @@ static struct GNUNET_ATS_SessionKiller *sk_tail; /** * Interface scanner determines our LAN address range(s). */ -struct GNUNET_ATS_InterfaceScanner *GST_is; +struct GNUNET_NT_InterfaceScanner *GST_is; /** @@ -1975,7 +1975,7 @@ static void plugin_env_session_start (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, - enum GNUNET_ATS_Network_Type scope) + enum GNUNET_NetworkType scope) { struct GNUNET_ATS_Properties prop; @@ -2005,7 +2005,7 @@ plugin_env_session_start (void *cls, memset (&prop, 0, sizeof (prop)); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != scope); prop.scope = scope; GST_ats_add_inbound_address (address, session, @@ -2261,7 +2261,7 @@ shutdown_task (void *cls) GST_ats = NULL; GNUNET_ATS_connectivity_done (GST_ats_connect); GST_ats_connect = NULL; - GNUNET_ATS_scanner_done (GST_is); + GNUNET_NT_scanner_done (GST_is); GST_is = NULL; while (NULL != (cur = a2s_head)) { @@ -2859,7 +2859,7 @@ run (void *cls, /* start subsystems */ read_blacklist_configuration (GST_cfg, &GST_my_identity); - GST_is = GNUNET_ATS_scanner_init (); + GST_is = GNUNET_NT_scanner_init (); GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h index fd852f027..253b785e3 100644 --- a/src/transport/gnunet-service-transport.h +++ b/src/transport/gnunet-service-transport.h @@ -69,7 +69,7 @@ extern struct GNUNET_ATS_ConnectivityHandle *GST_ats_connect; /** * Interface scanner determines our LAN address range(s). */ -extern struct GNUNET_ATS_InterfaceScanner *GST_is; +extern struct GNUNET_NT_InterfaceScanner *GST_is; /** diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index 8b3b998c8..358ed95c3 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c @@ -442,7 +442,7 @@ GST_ats_add_inbound_address (const struct GNUNET_HELLO_Address *address, GNUNET_break(0); return; } - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); GNUNET_assert (GNUNET_YES == GNUNET_HELLO_address_check_option (address, GNUNET_HELLO_ADDRESS_INFO_INBOUND)); @@ -461,7 +461,7 @@ GST_ats_add_inbound_address (const struct GNUNET_HELLO_Address *address, GNUNET_i2s (&address->peer), GST_plugins_a2s (address), session, - GNUNET_ATS_print_network_type (prop->scope)); + GNUNET_NT_to_string (prop->scope)); ar = GNUNET_ATS_address_add (GST_ats, address, session, @@ -510,7 +510,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, GNUNET_HELLO_ADDRESS_INFO_INBOUND)); ai = find_ai_no_session (address); GNUNET_assert (NULL == ai); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != prop->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != prop->scope); /* address seems sane, let's tell ATS */ LOG (GNUNET_ERROR_TYPE_INFO, diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index 9c3044450..6ea59e29c 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c @@ -104,7 +104,7 @@ plugin_env_update_distance (void *cls, * @param addrlen length of the @a addr * @return type of the network @a addr belongs to */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType plugin_env_address_to_type (void *cls, const struct sockaddr *addr, size_t addrlen) @@ -112,9 +112,9 @@ plugin_env_address_to_type (void *cls, if (NULL == GST_is) { GNUNET_break(0); - return GNUNET_ATS_NET_UNSPECIFIED; + return GNUNET_NT_UNSPECIFIED; } - return GNUNET_ATS_scanner_address_get_type (GST_is, + return GNUNET_NT_scanner_get_type (GST_is, addr, addrlen); } diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index eecc54efa..fc02da5b4 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -317,7 +317,7 @@ struct ValidationEntry /** * Which network type does our address belong to? */ - enum GNUNET_ATS_Network_Type network; + enum GNUNET_NetworkType network; }; @@ -654,7 +654,7 @@ transmit_ping_if_allowed (void *cls, ve->address->transport_name); ve->network = papi->get_network (papi->cls, session); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != ve->network); GST_neighbours_notify_data_sent (ve->address, session, tsize); @@ -905,7 +905,7 @@ add_valid_address (void *cls, ve = find_validation_entry (address); ve->network = papi->get_network_for_address (papi->cls, address); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != ve->network); ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); if (NULL == ve->revalidation_task) @@ -1589,7 +1589,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, struct GNUNET_ATS_Properties prop; memset (&prop, 0, sizeof (prop)); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); + GNUNET_break (GNUNET_NT_UNSPECIFIED != ve->network); prop.scope = ve->network; prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); GNUNET_assert (GNUNET_NO == diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 0afb54943..e88e2c69f 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -266,7 +266,7 @@ struct GNUNET_ATS_Session /** * ATS network type. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; }; @@ -1920,7 +1920,7 @@ client_connect (struct GNUNET_ATS_Session *s) * @param session the session * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType http_client_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -1935,7 +1935,7 @@ http_client_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType http_client_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { @@ -1997,7 +1997,7 @@ http_client_plugin_get_session (void *cls, struct HTTP_Client_Plugin *plugin = cls; struct GNUNET_ATS_Session *s; struct sockaddr *sa; - enum GNUNET_ATS_Network_Type net_type; + enum GNUNET_NetworkType net_type; size_t salen = 0; int res; @@ -2020,7 +2020,7 @@ http_client_plugin_get_session (void *cls, } /* Determine network location */ - net_type = GNUNET_ATS_NET_UNSPECIFIED; + net_type = GNUNET_NT_UNSPECIFIED; sa = http_common_socket_from_address (address->address, address->address_length, &res); @@ -2043,9 +2043,9 @@ http_client_plugin_get_session (void *cls, else if (GNUNET_NO == res) { /* Cannot convert to sockaddr -> is external hostname */ - net_type = GNUNET_ATS_NET_WAN; + net_type = GNUNET_NT_WAN; } - if (GNUNET_ATS_NET_UNSPECIFIED == net_type) + if (GNUNET_NT_UNSPECIFIED == net_type) { GNUNET_break (0); return NULL; diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index e9576d72b..3f0452d0b 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c @@ -896,17 +896,17 @@ http_common_cmp_addresses (const void *addr1, * @param address the address * @return the network type */ -enum GNUNET_ATS_Network_Type +enum GNUNET_NetworkType http_common_get_network_for_address (struct GNUNET_TRANSPORT_PluginEnvironment *env, const struct GNUNET_HELLO_Address *address) { struct sockaddr *sa; - enum GNUNET_ATS_Network_Type net_type; + enum GNUNET_NetworkType net_type; size_t salen = 0; int res; - net_type = GNUNET_ATS_NET_UNSPECIFIED; + net_type = GNUNET_NT_UNSPECIFIED; sa = http_common_socket_from_address (address->address, address->address_length, &res); diff --git a/src/transport/plugin_transport_http_common.h b/src/transport/plugin_transport_http_common.h index ac62f6ee4..f758015e1 100644 --- a/src/transport/plugin_transport_http_common.h +++ b/src/transport/plugin_transport_http_common.h @@ -253,7 +253,7 @@ http_common_cmp_addresses (const void *addr1, * @param address the address * @return the network type */ -enum GNUNET_ATS_Network_Type +enum GNUNET_NetworkType http_common_get_network_for_address (struct GNUNET_TRANSPORT_PluginEnvironment *env, const struct GNUNET_HELLO_Address *address); diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index abf60280a..8c657503a 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -260,7 +260,7 @@ struct GNUNET_ATS_Session /** * ATS network type. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; /** * #GNUNET_YES if this session is known to the service. @@ -1382,7 +1382,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, uint32_t options; int direction = GNUNET_SYSERR; unsigned int to; - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; conn_info = MHD_get_connection_info (mhd_connection, MHD_CONNECTION_INFO_CLIENT_ADDRESS); @@ -3344,7 +3344,7 @@ http_server_plugin_address_to_string (void *cls, * @param session the session * @return the network type in HBO or #GNUNET_SYSERR */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType http_server_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -3359,7 +3359,7 @@ http_server_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType http_server_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 75a885535..c056946b6 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -859,7 +859,7 @@ struct GNUNET_ATS_Session /** * Network type of the address. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; /** * Are we still expecting the welcome message? (#GNUNET_YES/#GNUNET_NO) @@ -1890,7 +1890,7 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *s) static struct GNUNET_ATS_Session * create_session (struct Plugin *plugin, const struct GNUNET_HELLO_Address *address, - enum GNUNET_ATS_Network_Type scope, + enum GNUNET_NetworkType scope, struct GNUNET_SERVER_Client *client, int is_nat) { @@ -2436,7 +2436,7 @@ tcp_plugin_get_session (void *cls, const struct IPv4TcpAddress *t4; const struct IPv6TcpAddress *t6; unsigned int options; - enum GNUNET_ATS_Network_Type net_type; + enum GNUNET_NetworkType net_type; unsigned int is_natd = GNUNET_NO; size_t addrlen; #ifdef TCP_STEALTH @@ -2539,7 +2539,7 @@ tcp_plugin_get_session (void *cls, net_type = plugin->env->get_address_type (plugin->env->cls, sb, sbs); - GNUNET_break (net_type != GNUNET_ATS_NET_UNSPECIFIED); + GNUNET_break (net_type != GNUNET_NT_UNSPECIFIED); if ( (is_natd == GNUNET_YES) && (addrlen == sizeof(struct IPv6TcpAddress)) ) @@ -3263,7 +3263,7 @@ handle_tcp_welcome (void *cls, alen), client, GNUNET_NO); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != session->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != session->scope); GNUNET_HELLO_address_free (address); LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s' client %p\n", @@ -3623,7 +3623,7 @@ try_connection_reversal (void *cls, * @param session the session * @return the network type in HBO or #GNUNET_SYSERR */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType tcp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -3638,7 +3638,7 @@ tcp_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType tcp_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { @@ -3683,7 +3683,7 @@ tcp_plugin_get_network_for_address (void *cls, else { GNUNET_break (0); - return GNUNET_ATS_NET_UNSPECIFIED; + return GNUNET_NT_UNSPECIFIED; } return plugin->env->get_address_type (plugin->env->cls, sb, diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index 679d83daa..be2dfb1c8 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c @@ -284,12 +284,12 @@ template_plugin_query_keepalive_factor (void *cls) * @param session the session * @return the network type in HBO or #GNUNET_SYSERR */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType template_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { GNUNET_assert (NULL != session); - return GNUNET_ATS_NET_UNSPECIFIED; /* Change to correct network type */ + return GNUNET_NT_UNSPECIFIED; /* Change to correct network type */ } @@ -300,11 +300,11 @@ template_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType template_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { - return GNUNET_ATS_NET_WAN; /* FOR NOW */ + return GNUNET_NT_WAN; /* FOR NOW */ } diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index abbcca2ae..9fed9b429 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -234,7 +234,7 @@ struct GNUNET_ATS_Session /** * Network type of the address. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; /** * Is this session about to be destroyed (sometimes we cannot @@ -290,7 +290,7 @@ struct DefragContext /** * Network type the address belongs to. */ - enum GNUNET_ATS_Network_Type network_type; + enum GNUNET_NetworkType network_type; /** * Has the @e sender field been initialized yet? @@ -660,7 +660,7 @@ udp_query_keepalive_factor (void *cls) * @param session the session * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType udp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -675,7 +675,7 @@ udp_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType udp_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { @@ -720,7 +720,7 @@ udp_plugin_get_network_for_address (void *cls, else { GNUNET_break (0); - return GNUNET_ATS_NET_UNSPECIFIED; + return GNUNET_NT_UNSPECIFIED; } return plugin->env->get_address_type (plugin->env->cls, sb, @@ -2627,7 +2627,7 @@ session_timeout (void *cls) static struct GNUNET_ATS_Session * udp_plugin_create_session (void *cls, const struct GNUNET_HELLO_Address *address, - enum GNUNET_ATS_Network_Type network_type) + enum GNUNET_NetworkType network_type) { struct Plugin *plugin = cls; struct GNUNET_ATS_Session *s; @@ -2687,7 +2687,7 @@ udp_plugin_get_session (void *cls, { struct Plugin *plugin = cls; struct GNUNET_ATS_Session *s; - enum GNUNET_ATS_Network_Type network_type = GNUNET_ATS_NET_UNSPECIFIED; + enum GNUNET_NetworkType network_type = GNUNET_NT_UNSPECIFIED; const struct IPv4UdpAddress *udp_v4; const struct IPv6UdpAddress *udp_v6; @@ -2739,7 +2739,7 @@ udp_plugin_get_session (void *cls, (const struct sockaddr *) &v6, sizeof (v6)); } - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); return udp_plugin_create_session (cls, address, network_type); @@ -2760,12 +2760,12 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, const union UdpAddress *udp_addr, size_t udp_addr_len, - enum GNUNET_ATS_Network_Type network_type) + enum GNUNET_NetworkType network_type) { struct GNUNET_ATS_Session *s; struct GNUNET_HELLO_Address *address; - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); if (0 != ntohl (msg->reserved)) { GNUNET_break_op(0); @@ -2992,7 +2992,7 @@ read_process_fragment (struct Plugin *plugin, const struct GNUNET_MessageHeader *msg, const union UdpAddress *udp_addr, size_t udp_addr_len, - enum GNUNET_ATS_Network_Type network_type) + enum GNUNET_NetworkType network_type) { struct DefragContext *d_ctx; struct GNUNET_TIME_Absolute now; @@ -3092,7 +3092,7 @@ udp_select_read (struct Plugin *plugin, const struct sockaddr_in6 *sa6; const union UdpAddress *int_addr; size_t int_addr_len; - enum GNUNET_ATS_Network_Type network_type; + enum GNUNET_NetworkType network_type; fromlen = sizeof (addr); memset (&addr, @@ -3345,13 +3345,13 @@ analyze_send_error (struct Plugin *plugin, socklen_t slen, int error) { - enum GNUNET_ATS_Network_Type type; + enum GNUNET_NetworkType type; type = plugin->env->get_address_type (plugin->env->cls, sa, slen); - if ( ( (GNUNET_ATS_NET_LAN == type) || - (GNUNET_ATS_NET_WAN == type) ) && + if ( ( (GNUNET_NT_LAN == type) || + (GNUNET_NT_WAN == type) ) && ( (ENETUNREACH == errno) || (ENETDOWN == errno) ) ) { diff --git a/src/transport/plugin_transport_udp.h b/src/transport/plugin_transport_udp.h index 5a2fa6f05..7a6e09329 100644 --- a/src/transport/plugin_transport_udp.h +++ b/src/transport/plugin_transport_udp.h @@ -338,7 +338,7 @@ udp_broadcast_receive (struct Plugin *plugin, ssize_t size, const union UdpAddress *udp_addr, size_t udp_addr_len, - enum GNUNET_ATS_Network_Type network_type); + enum GNUNET_NetworkType network_type); void diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index bcb622a46..c802304aa 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c @@ -117,7 +117,7 @@ struct MstContext /** * ATS network type. */ - enum GNUNET_ATS_Network_Type ats_address_network_type; + enum GNUNET_NetworkType ats_address_network_type; }; @@ -186,7 +186,7 @@ udp_broadcast_receive (struct Plugin *plugin, ssize_t size, const union UdpAddress *udp_addr, size_t udp_addr_len, - enum GNUNET_ATS_Network_Type network_type) + enum GNUNET_NetworkType network_type) { struct GNUNET_MessageStreamTokenizer *broadcast_mst; struct MstContext mc; @@ -410,7 +410,7 @@ iface_proc (void *cls, { struct Plugin *plugin = cls; struct BroadcastAddress *ba; - enum GNUNET_ATS_Network_Type network; + enum GNUNET_NetworkType network; if (NULL == addr) return GNUNET_OK; @@ -426,7 +426,7 @@ iface_proc (void *cls, GNUNET_a2s (netmask, addrlen), name, netmask); network = plugin->env->get_address_type (plugin->env->cls, broadcast_addr, addrlen); - if (GNUNET_ATS_NET_LOOPBACK == network) + if (GNUNET_NT_LOOPBACK == network) { /* Broadcasting on loopback does not make sense */ return GNUNET_YES; diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 3d177e703..19961d792 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -791,12 +791,12 @@ resend: * @param session the session * @return the network type in HBO or #GNUNET_SYSERR */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType unix_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { GNUNET_assert (NULL != session); - return GNUNET_ATS_NET_LOOPBACK; + return GNUNET_NT_LOOPBACK; } @@ -807,12 +807,12 @@ unix_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType unix_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { - return GNUNET_ATS_NET_LOOPBACK; + return GNUNET_NT_LOOPBACK; } @@ -982,7 +982,7 @@ unix_demultiplexer (struct Plugin *plugin, plugin->env->session_start (NULL, session->address, session, - GNUNET_ATS_NET_LOOPBACK); + GNUNET_NT_LOOPBACK); } else { diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 13d2ca466..e34143c59 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -126,9 +126,9 @@ typedef int * Which network scope do we belong to? */ #if BUILD_WLAN -static const enum GNUNET_ATS_Network_Type scope = GNUNET_ATS_NET_WLAN; +static const enum GNUNET_NetworkType scope = GNUNET_NT_WLAN; #else -static const enum GNUNET_ATS_Network_Type scope = GNUNET_ATS_NET_BT; +static const enum GNUNET_NetworkType scope = GNUNET_NT_BT; #endif @@ -1297,14 +1297,14 @@ create_macendpoint (struct Plugin *plugin, * @param session the session * @return the network type in HBO or #GNUNET_SYSERR */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType wlan_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { #if BUILD_WLAN - return GNUNET_ATS_NET_WLAN; + return GNUNET_NT_WLAN; #else - return GNUNET_ATS_NET_BT; + return GNUNET_NT_BT; #endif } @@ -1316,14 +1316,14 @@ wlan_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType wlan_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { #if BUILD_WLAN - return GNUNET_ATS_NET_WLAN; + return GNUNET_NT_WLAN; #else - return GNUNET_ATS_NET_BT; + return GNUNET_NT_BT; #endif } diff --git a/src/transport/plugin_transport_xt.c b/src/transport/plugin_transport_xt.c index 0f517dd0c..08f59bd70 100644 --- a/src/transport/plugin_transport_xt.c +++ b/src/transport/plugin_transport_xt.c @@ -859,7 +859,7 @@ struct GNUNET_ATS_Session /** * Network type of the address. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; /** * Are we still expecting the welcome message? (#GNUNET_YES/#GNUNET_NO) @@ -1896,7 +1896,7 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *s) static struct GNUNET_ATS_Session * create_session (struct Plugin *plugin, const struct GNUNET_HELLO_Address *address, - enum GNUNET_ATS_Network_Type scope, + enum GNUNET_NetworkType scope, struct GNUNET_SERVER_Client *client, int is_nat) { @@ -2442,7 +2442,7 @@ tcp_plugin_get_session (void *cls, const struct IPv4TcpAddress *t4; const struct IPv6TcpAddress *t6; unsigned int options; - enum GNUNET_ATS_Network_Type net_type; + enum GNUNET_NetworkType net_type; unsigned int is_natd = GNUNET_NO; size_t addrlen; #ifdef TCP_STEALTH @@ -2545,7 +2545,7 @@ tcp_plugin_get_session (void *cls, net_type = plugin->env->get_address_type (plugin->env->cls, sb, sbs); - GNUNET_break (net_type != GNUNET_ATS_NET_UNSPECIFIED); + GNUNET_break (net_type != GNUNET_NT_UNSPECIFIED); if ( (is_natd == GNUNET_YES) && (addrlen == sizeof(struct IPv6TcpAddress)) ) @@ -3269,7 +3269,7 @@ handle_tcp_welcome (void *cls, alen), client, GNUNET_NO); - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != session->scope); + GNUNET_break (GNUNET_NT_UNSPECIFIED != session->scope); GNUNET_HELLO_address_free (address); LOG (GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s' client %p\n", @@ -3629,7 +3629,7 @@ try_connection_reversal (void *cls, * @param session the session * @return the network type in HBO or #GNUNET_SYSERR */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType tcp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -3644,7 +3644,7 @@ tcp_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType tcp_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { @@ -3689,7 +3689,7 @@ tcp_plugin_get_network_for_address (void *cls, else { GNUNET_break (0); - return GNUNET_ATS_NET_UNSPECIFIED; + return GNUNET_NT_UNSPECIFIED; } return plugin->env->get_address_type (plugin->env->cls, sb, diff --git a/src/transport/plugin_transport_xu.c b/src/transport/plugin_transport_xu.c index 59e00f80e..639b38671 100644 --- a/src/transport/plugin_transport_xu.c +++ b/src/transport/plugin_transport_xu.c @@ -203,7 +203,7 @@ struct GNUNET_ATS_Session /** * Network type of the address. */ - enum GNUNET_ATS_Network_Type scope; + enum GNUNET_NetworkType scope; /** * Is this session about to be destroyed (sometimes we cannot @@ -362,7 +362,7 @@ xu_query_keepalive_factor (void *cls) * @param session the session * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType xu_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) { @@ -378,7 +378,7 @@ xu_plugin_get_network (void *cls, * @param address the address * @return the network type */ -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType xu_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address) { @@ -423,7 +423,7 @@ xu_plugin_get_network_for_address (void *cls, else { GNUNET_break (0); - return GNUNET_ATS_NET_UNSPECIFIED; + return GNUNET_NT_UNSPECIFIED; } return plugin->env->get_address_type (plugin->env->cls, sb, @@ -1215,13 +1215,13 @@ analyze_send_error (struct Plugin *plugin, socklen_t slen, int error) { - enum GNUNET_ATS_Network_Type type; + enum GNUNET_NetworkType type; type = plugin->env->get_address_type (plugin->env->cls, sa, slen); - if ( ( (GNUNET_ATS_NET_LAN == type) || - (GNUNET_ATS_NET_WAN == type) ) && + if ( ( (GNUNET_NT_LAN == type) || + (GNUNET_NT_WAN == type) ) && ( (ENETUNREACH == errno) || (ENETDOWN == errno) ) ) { @@ -1619,7 +1619,7 @@ session_timeout (void *cls) static struct GNUNET_ATS_Session * xu_plugin_create_session (void *cls, const struct GNUNET_HELLO_Address *address, - enum GNUNET_ATS_Network_Type network_type) + enum GNUNET_NetworkType network_type) { struct Plugin *plugin = cls; struct GNUNET_ATS_Session *s; @@ -1679,7 +1679,7 @@ xu_plugin_get_session (void *cls, { struct Plugin *plugin = cls; struct GNUNET_ATS_Session *s; - enum GNUNET_ATS_Network_Type network_type = GNUNET_ATS_NET_UNSPECIFIED; + enum GNUNET_NetworkType network_type = GNUNET_NT_UNSPECIFIED; const struct IPv4XuAddress *xu_v4; const struct IPv6XuAddress *xu_v6; @@ -1731,7 +1731,7 @@ xu_plugin_get_session (void *cls, (const struct sockaddr *) &v6, sizeof (v6)); } - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); return xu_plugin_create_session (cls, address, network_type); @@ -1752,12 +1752,12 @@ process_xu_message (struct Plugin *plugin, const struct XUMessage *msg, const union XuAddress *xu_addr, size_t xu_addr_len, - enum GNUNET_ATS_Network_Type network_type) + enum GNUNET_NetworkType network_type) { struct GNUNET_ATS_Session *s; struct GNUNET_HELLO_Address *address; - GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type); + GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); if (0 != ntohl (msg->reserved)) { GNUNET_break_op(0); @@ -1827,7 +1827,7 @@ xu_select_read (struct Plugin *plugin, const struct sockaddr_in6 *sa6; const union XuAddress *int_addr; size_t int_addr_len; - enum GNUNET_ATS_Network_Type network_type; + enum GNUNET_NetworkType network_type; fromlen = sizeof (addr); memset (&addr, diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index 85ab9659d..47ba7aed4 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -499,12 +499,12 @@ env_notify_address (void *cls, } -static enum GNUNET_ATS_Network_Type +static enum GNUNET_NetworkType env_get_address_type (void *cls, const struct sockaddr *addr, size_t addrlen) { - return GNUNET_ATS_NET_LOOPBACK; + return GNUNET_NT_LOOPBACK; } diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index cd93ff855..6309c3278 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -209,14 +209,14 @@ generate_config (const char *cfg_file, "PATHS", "DEFAULTCONFIG", fname); - for (int c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) + for (int c = 0; c < GNUNET_NT_COUNT; c++) { GNUNET_asprintf (&in_name, "%s_QUOTA_IN", - GNUNET_ATS_print_network_type (c)); + GNUNET_NT_to_string (c)); GNUNET_asprintf (&out_name, "%s_QUOTA_OUT", - GNUNET_ATS_print_network_type (c)); + GNUNET_NT_to_string (c)); GNUNET_CONFIGURATION_set_value_number (cfg, "ats", in_name, diff --git a/src/transport/transport.h b/src/transport/transport.h index 515c178f4..df1321d1a 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -692,7 +692,7 @@ struct GNUNET_TRANSPORT_AddAddressMessage struct GNUNET_TIME_RelativeNBO expiration; /** - * An `enum GNUNET_ATS_Network_Type` in NBO. + * An `enum GNUNET_NetworkType` in NBO. */ uint32_t nt; @@ -801,7 +801,7 @@ struct GNUNET_TRANSPORT_AddQueueMessage struct GNUNET_PeerIdentity receiver; /** - * An `enum GNUNET_ATS_Network_Type` in NBO. + * An `enum GNUNET_NetworkType` in NBO. */ uint32_t nt; @@ -988,7 +988,7 @@ struct GNUNET_TRANSPORT_MonitorData struct GNUNET_MessageHeader header; /** - * Network type (an `enum GNUNET_ATS_Network_Type` in NBO). + * Network type (an `enum GNUNET_NetworkType` in NBO). */ uint32_t nt GNUNET_PACKED; diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index a89802ddd..ffd7f208e 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c @@ -251,7 +251,7 @@ struct GNUNET_TRANSPORT_QueueHandle /** * Network type of the communciation queue. */ - enum GNUNET_ATS_Network_Type nt; + enum GNUNET_NetworkType nt; /** * Communication status of the queue. @@ -318,7 +318,7 @@ struct GNUNET_TRANSPORT_AddressIdentifier /** * Network type for the address. */ - enum GNUNET_ATS_Network_Type nt; + enum GNUNET_NetworkType nt; }; @@ -944,7 +944,7 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle const struct GNUNET_PeerIdentity *peer, const char *address, uint32_t mtu, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, uint32_t distance, enum GNUNET_TRANSPORT_ConnectionStatus cs, struct GNUNET_MQ_Handle *mq) @@ -1002,7 +1002,7 @@ GNUNET_TRANSPORT_communicator_mq_del (struct GNUNET_TRANSPORT_QueueHandle *qh) struct GNUNET_TRANSPORT_AddressIdentifier * GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const char *address, - enum GNUNET_ATS_Network_Type nt, + enum GNUNET_NetworkType nt, struct GNUNET_TIME_Relative expiration) { struct GNUNET_TRANSPORT_AddressIdentifier *ai; diff --git a/src/transport/transport_api2_monitor.c b/src/transport/transport_api2_monitor.c index 3798296c1..ca9832e45 100644 --- a/src/transport/transport_api2_monitor.c +++ b/src/transport/transport_api2_monitor.c @@ -174,7 +174,7 @@ handle_monitor_data (void *cls, struct GNUNET_TRANSPORT_MonitorInformation mi; mi.address = (const char *) &md[1]; - mi.nt = (enum GNUNET_ATS_Network_Type) ntohl (md->nt); + mi.nt = (enum GNUNET_NetworkType) ntohl (md->nt); mi.cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (md->cs); mi.num_msg_pending = ntohl (md->num_msg_pending); mi.num_bytes_pending = ntohl (md->num_bytes_pending); -- cgit v1.2.3