use enum GNUNET_ATS_Network_Type instead of uint32_t where appropriate
authorChristian Grothoff <christian@grothoff.org>
Fri, 13 Dec 2013 13:00:14 +0000 (13:00 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 13 Dec 2013 13:00:14 +0000 (13:00 +0000)
src/dv/dv_api.c
src/dv/gnunet-dv.c
src/dv/gnunet-service-dv.c
src/dv/plugin_transport_dv.c
src/include/gnunet_dv_service.h
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c

index 13bd39afcda022947feebb8e761e3f57b2052b2c..e726d9d9038726879cf6c0e77b01c1ad9d89d2dd 100644 (file)
@@ -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))
index dc17e1a642569ed3867d279c29af2aede80e2e4d..7e2d5b5715a592cd50eb655ef37e8d5020a3f342 100644 (file)
@@ -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),
index 39671edcb52bbf6abf7b973cfcc12929b8b5734e..50d21feef65d03f8a8ce1ec07de3e43a796e81e4 100644 (file)
@@ -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;
index eca8887317eda93d795b9553a15436d98ba2f66f..8e9ec9d53f3b2995b865b84138933fb0558ae0c8 100644 (file)
@@ -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;
index 8ea9b10277216be610e08feaf1db405b201e797f..98648f84cac1aace18c00b989984933ce3ea3a79 100644 (file)
@@ -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);
 
 
 /**
index 5ab1e59f1c8943735166a41b19fe3362e171add0..33ea4a3bee426a1ce68cc0fb0a480f451633993f 100644 (file)
@@ -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);
index a6e46ccae38804719e596b5103603c43cd8af509..ce918d1918af338b6c3686f38f8c70773c331861 100644 (file)
@@ -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,