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;
/* 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;
}
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)
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 "));
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 ==
{
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);
{
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;
}
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 \
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 \
#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.
*
}
-/**
- * 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 */
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);
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) ||
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)
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
{
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);
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))
{
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;
{
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);
{
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;
}
{
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;
{
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);
{
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;
}
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);
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,
"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;
* 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
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);
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,
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,
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;
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;
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;
*/
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;
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,
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;
}
{
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,
"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]);
}
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);
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,
/* 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;
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);
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;
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);
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]);
}
/* 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;
/* 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
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;
}
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];
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);
}
{
struct GAS_MLP_Handle *mlp = solver;
- if (GNUNET_ATS_NetworkTypeCount <= network)
+ if (GNUNET_NT_COUNT <= network)
{
GNUNET_break (0);
return;
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];
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 */
{
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);
{
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);
{
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 ;
{
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 ;
/**
* ATS network type
*/
- enum GNUNET_ATS_Network_Type type;
+ enum GNUNET_NetworkType type;
/**
* Number of active addresses for this network
{
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,
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);
/**
* ATS network type
*/
- enum GNUNET_ATS_Network_Type type;
+ enum GNUNET_NetworkType type;
/**
* Total available inbound bandwidth
* @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;
* @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;
* @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;
* @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;
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);
}
.addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
.session = 0,
.properties = {
- .scope = GNUNET_ATS_NET_LAN
+ .scope = GNUNET_NT_LAN
}
}
},
.addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
.session = 0,
.properties = {
- .scope = GNUNET_ATS_NET_LAN
+ .scope = GNUNET_NT_LAN
},
.expect_fail = 1
}
.addr_num = 0,
.session = 0,
.properties = {
- .scope = GNUNET_ATS_NET_LAN
+ .scope = GNUNET_NT_LAN
}
}
},
.addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
.session = 0,
.properties = {
- .scope = GNUNET_ATS_NET_LAN
+ .scope = GNUNET_NT_LAN
}
}
},
.session = 0,
.properties = {
/* use network with 65k quota! */
- .scope = GNUNET_ATS_NET_WAN
+ .scope = GNUNET_NT_WAN
}
}
},
sh->connect_cb (sh->cls,
&cm->peer,
ntohl (cm->distance),
- (enum GNUNET_ATS_Network_Type) ntohl (cm->network));
+ (enum GNUNET_NetworkType) ntohl (cm->network));
}
sh->distance_cb (sh->cls,
&dum->peer,
ntohl (dum->distance),
- (enum GNUNET_ATS_Network_Type) ntohl (dum->network));
+ (enum GNUNET_NetworkType) ntohl (dum->network));
}
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),
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),
/**
* The network this peer is in
*/
- enum GNUNET_ATS_Network_Type network;
+ enum GNUNET_NetworkType network;
/**
* Is this neighbor connected at the core level?
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));
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;
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,
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;
}
{
struct DirectNeighbor *neighbor;
uint32_t distance;
- enum GNUNET_ATS_Network_Type network;
+ enum GNUNET_NetworkType network;
if (NULL == address)
{
}
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);
/**
* 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
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
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);
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",
* @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)
{
* @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 */
}
*/
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,
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;
}
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);
}
* 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
#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
* Which network scope does the respective address belong to?
* This property does not change.
*/
- enum GNUNET_ATS_Network_Type scope;
+ enum GNUNET_NetworkType scope;
};
-/**
- * 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 ***************************** */
/**
(*GNUNET_DV_ConnectCallback)(void *cls,
const struct GNUNET_PeerIdentity *peer,
uint32_t distance,
- enum GNUNET_ATS_Network_Type network);
+ enum GNUNET_NetworkType network);
/**
(*GNUNET_DV_DistanceChangedCallback)(void *cls,
const struct GNUNET_PeerIdentity *peer,
uint32_t distance,
- enum GNUNET_ATS_Network_Type network);
+ enum GNUNET_NetworkType network);
/**
/* 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"
/**
*/
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,
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 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);
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);
(*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);
/**
* Network type of the address.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_NetworkType nt;
/**
* Connection status.
(*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);
/**
* @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);
* @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);
* @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);
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)
* @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;
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 \
&queue->target,
foreign_addr,
UNIX_MTU,
- GNUNET_ATS_NET_LOOPBACK,
+ GNUNET_NT_LOOPBACK,
0 /* distance */,
cs,
queue->mq);
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);
}
/**
* Network type offered by this queue.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_NetworkType nt;
/**
* Connection status for this queue.
/**
* Network type offered by this address.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_NetworkType nt;
};
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;
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;
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);
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],
/**
* Interface scanner determines our LAN address range(s).
*/
-struct GNUNET_ATS_InterfaceScanner *GST_is;
+struct GNUNET_NT_InterfaceScanner *GST_is;
/**
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;
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,
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))
{
/* 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,
/**
* Interface scanner determines our LAN address range(s).
*/
-extern struct GNUNET_ATS_InterfaceScanner *GST_is;
+extern struct GNUNET_NT_InterfaceScanner *GST_is;
/**
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));
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,
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,
* @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)
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);
}
/**
* Which network type does our address belong to?
*/
- enum GNUNET_ATS_Network_Type network;
+ enum GNUNET_NetworkType network;
};
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);
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)
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 ==
/**
* ATS network type.
*/
- enum GNUNET_ATS_Network_Type scope;
+ enum GNUNET_NetworkType scope;
};
* @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)
{
* @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)
{
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;
}
/* 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);
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;
* @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);
* @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);
/**
* ATS network type.
*/
- enum GNUNET_ATS_Network_Type scope;
+ enum GNUNET_NetworkType scope;
/**
* #GNUNET_YES if this session is known to the service.
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);
* @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)
{
* @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)
{
/**
* 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)
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)
{
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
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)) )
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",
* @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)
{
* @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)
{
else
{
GNUNET_break (0);
- return GNUNET_ATS_NET_UNSPECIFIED;
+ return GNUNET_NT_UNSPECIFIED;
}
return plugin->env->get_address_type (plugin->env->cls,
sb,
* @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 */
}
* @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 */
}
/**
* 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
/**
* 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?
* @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)
{
* @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)
{
else
{
GNUNET_break (0);
- return GNUNET_ATS_NET_UNSPECIFIED;
+ return GNUNET_NT_UNSPECIFIED;
}
return plugin->env->get_address_type (plugin->env->cls,
sb,
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;
{
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;
(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);
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);
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;
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,
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) ) )
{
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
/**
* ATS network type.
*/
- enum GNUNET_ATS_Network_Type ats_address_network_type;
+ enum GNUNET_NetworkType ats_address_network_type;
};
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;
{
struct Plugin *plugin = cls;
struct BroadcastAddress *ba;
- enum GNUNET_ATS_Network_Type network;
+ enum GNUNET_NetworkType network;
if (NULL == addr)
return GNUNET_OK;
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;
* @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;
}
* @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;
}
plugin->env->session_start (NULL,
session->address,
session,
- GNUNET_ATS_NET_LOOPBACK);
+ GNUNET_NT_LOOPBACK);
}
else
{
* 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
* @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
}
* @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
}
/**
* 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)
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)
{
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
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)) )
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",
* @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)
{
* @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)
{
else
{
GNUNET_break (0);
- return GNUNET_ATS_NET_UNSPECIFIED;
+ return GNUNET_NT_UNSPECIFIED;
}
return plugin->env->get_address_type (plugin->env->cls,
sb,
/**
* 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
* @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)
{
* @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)
{
else
{
GNUNET_break (0);
- return GNUNET_ATS_NET_UNSPECIFIED;
+ return GNUNET_NT_UNSPECIFIED;
}
return plugin->env->get_address_type (plugin->env->cls,
sb,
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) ) )
{
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;
{
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;
(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);
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);
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,
}
-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;
}
"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,
struct GNUNET_TIME_RelativeNBO expiration;
/**
- * An `enum GNUNET_ATS_Network_Type` in NBO.
+ * An `enum GNUNET_NetworkType` in NBO.
*/
uint32_t nt;
struct GNUNET_PeerIdentity receiver;
/**
- * An `enum GNUNET_ATS_Network_Type` in NBO.
+ * An `enum GNUNET_NetworkType` in NBO.
*/
uint32_t nt;
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;
/**
* Network type of the communciation queue.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_NetworkType nt;
/**
* Communication status of the queue.
/**
* Network type for the address.
*/
- enum GNUNET_ATS_Network_Type nt;
+ enum GNUNET_NetworkType nt;
};
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)
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;
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);