From 5e900316b0b70bb65f573d0ad110f3d93551b11b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 13 Dec 2013 13:00:14 +0000 Subject: [PATCH] use enum GNUNET_ATS_Network_Type instead of uint32_t where appropriate --- src/dv/dv_api.c | 5 +++-- src/dv/gnunet-dv.c | 5 +++-- src/dv/gnunet-service-dv.c | 17 +++++++++-------- src/dv/plugin_transport_dv.c | 9 +++++---- src/include/gnunet_dv_service.h | 6 +++--- src/transport/gnunet-service-transport.c | 5 +++-- src/transport/plugin_transport_tcp.c | 2 +- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 13bd39afc..e726d9d90 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c @@ -359,7 +359,8 @@ handle_message_receipt (void *cls, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); sh->connect_cb (sh->cls, &cm->peer, - ntohl (cm->distance), ntohl (cm->network)); + ntohl (cm->distance), + (enum GNUNET_ATS_Network_Type) ntohl (cm->network)); break; case GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED: if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DistanceUpdateMessage)) @@ -372,7 +373,7 @@ handle_message_receipt (void *cls, sh->distance_cb (sh->cls, &dum->peer, ntohl (dum->distance), - ntohl (dum->network)); + (enum GNUNET_ATS_Network_Type) ntohl (dum->network)); break; case GNUNET_MESSAGE_TYPE_DV_DISCONNECT: if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DisconnectMessage)) diff --git a/src/dv/gnunet-dv.c b/src/dv/gnunet-dv.c index dc17e1a64..7e2d5b571 100644 --- a/src/dv/gnunet-dv.c +++ b/src/dv/gnunet-dv.c @@ -48,7 +48,8 @@ static int verbose; static void connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, - uint32_t distance, uint32_t network) + uint32_t distance, + enum GNUNET_ATS_Network_Type network) { fprintf (stderr, "Connect: %s at %u\n", GNUNET_i2s (peer), @@ -68,7 +69,7 @@ static void change_cb (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - uint32_t network) + enum GNUNET_ATS_Network_Type 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 39671edcb..50d21feef 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -272,7 +272,7 @@ struct DirectNeighbor /** * The network this peer is in */ - uint32_t network; + enum GNUNET_ATS_Network_Type network; /** * Is this neighbor connected at the core level? @@ -517,7 +517,7 @@ send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, static void send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, uint32_t distance, - uint32_t network) + enum GNUNET_ATS_Network_Type network) { struct GNUNET_DV_DistanceUpdateMessage du_msg; @@ -529,7 +529,7 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, du_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED); du_msg.distance = htonl (distance); du_msg.peer = *peer; - du_msg.network = htonl (network); + du_msg.network = htonl ((uint32_t) network); send_control_to_plugin (&du_msg.header); } @@ -543,7 +543,8 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, */ static void send_connect_to_plugin (const struct GNUNET_PeerIdentity *target, - uint32_t distance, uint32_t network) + uint32_t distance, + enum GNUNET_ATS_Network_Type network) { struct GNUNET_DV_ConnectMessage cm; @@ -553,7 +554,7 @@ send_connect_to_plugin (const struct GNUNET_PeerIdentity *target, cm.header.size = htons (sizeof (cm)); cm.header.type = htons (GNUNET_MESSAGE_TYPE_DV_CONNECT); cm.distance = htonl (distance); - cm.network = htonl (network); + cm.network = htonl ((uint32_t) network); cm.peer = *target; send_control_to_plugin (&cm.header); } @@ -1158,7 +1159,7 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi, * @param atsi_count number of entries in atsi * @return connected transport network */ -static uint32_t +static enum GNUNET_ATS_Network_Type get_atsi_network (const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count) { @@ -1166,7 +1167,7 @@ get_atsi_network (const struct GNUNET_ATS_Information *atsi, for (i = 0; i < atsi_count; i++) if (ntohl (atsi[i].type) == GNUNET_ATS_NETWORK_TYPE) - return ntohl (atsi[i].value); + return (enum GNUNET_ATS_Network_Type) ntohl (atsi[i].value); return GNUNET_ATS_NET_UNSPECIFIED; } @@ -1291,7 +1292,7 @@ handle_ats_update (void *cls, { struct DirectNeighbor *neighbor; uint32_t distance; - uint32_t network = GNUNET_ATS_NET_UNSPECIFIED; + enum GNUNET_ATS_Network_Type network = GNUNET_ATS_NET_UNSPECIFIED; if (GNUNET_NO == active) return; diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index eca888731..8e9ec9d53 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c @@ -126,7 +126,7 @@ struct Session /** * Current network the next hop peer is located in */ - uint32_t network; + enum GNUNET_ATS_Network_Type network; /** * Does the transport service know about this session (and we thus @@ -290,7 +290,8 @@ handle_dv_message_received (void *cls, static void handle_dv_connect (void *cls, const struct GNUNET_PeerIdentity *peer, - uint32_t distance, uint32_t network) + uint32_t distance, + enum GNUNET_ATS_Network_Type network) { struct Plugin *plugin = cls; struct Session *session; @@ -336,7 +337,7 @@ handle_dv_connect (void *cls, ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); ats[0].value = htonl (distance); ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); - ats[1].value = htonl (network); + ats[1].value = htonl ((uint32_t) network); session->active = GNUNET_YES; plugin->env->session_start (plugin->env->cls, peer, PLUGIN_NAME, @@ -357,7 +358,7 @@ static void handle_dv_distance_changed (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - uint32_t network) + enum GNUNET_ATS_Network_Type network) { struct Plugin *plugin = cls; struct Session *session; diff --git a/src/include/gnunet_dv_service.h b/src/include/gnunet_dv_service.h index 8ea9b1027..98648f84c 100644 --- a/src/include/gnunet_dv_service.h +++ b/src/include/gnunet_dv_service.h @@ -27,7 +27,7 @@ #define GNUNET_SERVICE_DV_H #include "gnunet_util_lib.h" - +#include "gnunet_ats_service.h" /** * Signature of a function to be called if DV @@ -41,7 +41,7 @@ typedef void (*GNUNET_DV_ConnectCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - uint32_t network); + enum GNUNET_ATS_Network_Type network); /** @@ -56,7 +56,7 @@ typedef void (*GNUNET_DV_ConnectCallback)(void *cls, typedef void (*GNUNET_DV_DistanceChangedCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance, - uint32_t network); + enum GNUNET_ATS_Network_Type network); /** diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 5ab1e59f1..33ea4a3be 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -476,9 +476,10 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, if (GNUNET_ATS_NET_UNSPECIFIED != net) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Could not obtain a valid network for `%s' %s\n"), + _("Could not obtain a valid network for `%s' %s (%s)\n"), GNUNET_i2s (&address->peer), - GST_plugins_a2s (address)); + GST_plugins_a2s (address), + address->transport_name); GNUNET_break (0); } ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index a6e46ccae..ce918d191 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2528,7 +2528,7 @@ stop_session_timeout (struct Session *s) * * @param cls closure ('struct Plugin*') * @param session the session - * @return the network type in HBO or GNUNET_SYSERR + * @return the network type in HBO or #GNUNET_SYSERR */ static enum GNUNET_ATS_Network_Type tcp_get_network (void *cls, -- 2.25.1