/*
This file is part of GNUnet.
- (C) 2010-2015 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2015 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file ats/ats_api_scanner.c
/**
- * Convert a ATS property to a string
+ * Convert ATS properties from host to network byte order.
*
- * @param type the property type
- * @return a string or NULL if invalid
+ * @param nbo[OUT] value written
+ * @param hbo value read
*/
-const char *
-GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type)
+void
+GNUNET_ATS_properties_hton (struct GNUNET_ATS_PropertiesNBO *nbo,
+ const struct GNUNET_ATS_Properties *hbo)
{
- switch (type)
- {
- case GNUNET_ATS_ARRAY_TERMINATOR:
- return "TERMINATOR";
- case GNUNET_ATS_UTILIZATION_OUT:
- return "UTILIZATION_UP";
- case GNUNET_ATS_UTILIZATION_IN:
- return "UTILIZATION_DOWN";
- case GNUNET_ATS_UTILIZATION_PAYLOAD_OUT:
- return "UTILIZATION_PAYLOAD_UP";
- case GNUNET_ATS_UTILIZATION_PAYLOAD_IN:
- return "UTILIZATION_PAYLOAD_DOWN";
- case GNUNET_ATS_NETWORK_TYPE:
- return "NETWORK_TYPE";
- case GNUNET_ATS_QUALITY_NET_DELAY:
- return "DELAY";
- case GNUNET_ATS_QUALITY_NET_DISTANCE:
- return "DISTANCE";
- case GNUNET_ATS_COST_WAN:
- return "COST_WAN";
- case GNUNET_ATS_COST_LAN:
- return "COST_LAN";
- case GNUNET_ATS_COST_WLAN:
- return "COST_WLAN";
- default:
- return NULL;
- }
+ nbo->utilization_out = htonl (hbo->utilization_out);
+ nbo->utilization_in = htonl (hbo->utilization_in);
+ nbo->scope = htonl ((uint32_t) hbo->scope);
+ nbo->distance = htonl (hbo->distance);
+ nbo->delay = GNUNET_TIME_relative_hton (hbo->delay);
+}
+
+
+/**
+ * Convert ATS properties from network to host byte order.
+ *
+ * @param hbo[OUT] value written
+ * @param nbo value read
+ */
+void
+GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo,
+ const struct GNUNET_ATS_PropertiesNBO *nbo)
+{
+ hbo->utilization_out = ntohl (nbo->utilization_out);
+ hbo->utilization_in = ntohl (nbo->utilization_in);
+ hbo->scope = ntohl ((uint32_t) nbo->scope);
+ hbo->distance = ntohl (nbo->distance);
+ hbo->delay = GNUNET_TIME_relative_ntoh (nbo->delay);
}
/* Store in list */
#if VERBOSE_ATS
char * netmask = GNUNET_strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding network `%s', netmask `%s'\n",
- GNUNET_a2s ((struct sockaddr *) net->network,
- addrlen),
- netmask);
+ 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,
* Periodically get list of network addresses from our interfaces.
*
* @param cls closure
- * @param tc Task context
*/
static void
-get_addresses (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+get_addresses (void *cls)
{
struct GNUNET_ATS_InterfaceScanner *is = cls;
if (type == GNUNET_ATS_NET_UNSPECIFIED)
type = GNUNET_ATS_NET_WAN;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "ats-scheduling-api",
+ "ats-scanner-api",
"`%s' is in network `%s'\n",
GNUNET_a2s (addr,
addrlen),