aboutsummaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-13 13:00:14 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-13 13:00:14 +0000
commit5e900316b0b70bb65f573d0ad110f3d93551b11b (patch)
treee78e9d55d8c5da7272acc472c2e8441458e6f84c /src/dv
parent280ca97ba6c2df197a0e6a3ca5b6cb9da0df9ec2 (diff)
downloadgnunet-5e900316b0b70bb65f573d0ad110f3d93551b11b.tar.gz
gnunet-5e900316b0b70bb65f573d0ad110f3d93551b11b.zip
use enum GNUNET_ATS_Network_Type instead of uint32_t where appropriate
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/dv_api.c5
-rw-r--r--src/dv/gnunet-dv.c5
-rw-r--r--src/dv/gnunet-service-dv.c17
-rw-r--r--src/dv/plugin_transport_dv.c9
4 files changed, 20 insertions, 16 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,
359 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 359 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
360 sh->connect_cb (sh->cls, 360 sh->connect_cb (sh->cls,
361 &cm->peer, 361 &cm->peer,
362 ntohl (cm->distance), ntohl (cm->network)); 362 ntohl (cm->distance),
363 (enum GNUNET_ATS_Network_Type) ntohl (cm->network));
363 break; 364 break;
364 case GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED: 365 case GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED:
365 if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DistanceUpdateMessage)) 366 if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DistanceUpdateMessage))
@@ -372,7 +373,7 @@ handle_message_receipt (void *cls,
372 sh->distance_cb (sh->cls, 373 sh->distance_cb (sh->cls,
373 &dum->peer, 374 &dum->peer,
374 ntohl (dum->distance), 375 ntohl (dum->distance),
375 ntohl (dum->network)); 376 (enum GNUNET_ATS_Network_Type) ntohl (dum->network));
376 break; 377 break;
377 case GNUNET_MESSAGE_TYPE_DV_DISCONNECT: 378 case GNUNET_MESSAGE_TYPE_DV_DISCONNECT:
378 if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DisconnectMessage)) 379 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;
48static void 48static void
49connect_cb (void *cls, 49connect_cb (void *cls,
50 const struct GNUNET_PeerIdentity *peer, 50 const struct GNUNET_PeerIdentity *peer,
51 uint32_t distance, uint32_t network) 51 uint32_t distance,
52 enum GNUNET_ATS_Network_Type network)
52{ 53{
53 fprintf (stderr, "Connect: %s at %u\n", 54 fprintf (stderr, "Connect: %s at %u\n",
54 GNUNET_i2s (peer), 55 GNUNET_i2s (peer),
@@ -68,7 +69,7 @@ static void
68change_cb (void *cls, 69change_cb (void *cls,
69 const struct GNUNET_PeerIdentity *peer, 70 const struct GNUNET_PeerIdentity *peer,
70 uint32_t distance, 71 uint32_t distance,
71 uint32_t network) 72 enum GNUNET_ATS_Network_Type network)
72{ 73{
73 fprintf (stderr, "Change: %s at %u\n", 74 fprintf (stderr, "Change: %s at %u\n",
74 GNUNET_i2s (peer), 75 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
272 /** 272 /**
273 * The network this peer is in 273 * The network this peer is in
274 */ 274 */
275 uint32_t network; 275 enum GNUNET_ATS_Network_Type network;
276 276
277 /** 277 /**
278 * Is this neighbor connected at the core level? 278 * Is this neighbor connected at the core level?
@@ -517,7 +517,7 @@ send_ack_to_plugin (const struct GNUNET_PeerIdentity *target,
517static void 517static void
518send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, 518send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer,
519 uint32_t distance, 519 uint32_t distance,
520 uint32_t network) 520 enum GNUNET_ATS_Network_Type network)
521{ 521{
522 struct GNUNET_DV_DistanceUpdateMessage du_msg; 522 struct GNUNET_DV_DistanceUpdateMessage du_msg;
523 523
@@ -529,7 +529,7 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer,
529 du_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED); 529 du_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED);
530 du_msg.distance = htonl (distance); 530 du_msg.distance = htonl (distance);
531 du_msg.peer = *peer; 531 du_msg.peer = *peer;
532 du_msg.network = htonl (network); 532 du_msg.network = htonl ((uint32_t) network);
533 send_control_to_plugin (&du_msg.header); 533 send_control_to_plugin (&du_msg.header);
534} 534}
535 535
@@ -543,7 +543,8 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer,
543 */ 543 */
544static void 544static void
545send_connect_to_plugin (const struct GNUNET_PeerIdentity *target, 545send_connect_to_plugin (const struct GNUNET_PeerIdentity *target,
546 uint32_t distance, uint32_t network) 546 uint32_t distance,
547 enum GNUNET_ATS_Network_Type network)
547{ 548{
548 struct GNUNET_DV_ConnectMessage cm; 549 struct GNUNET_DV_ConnectMessage cm;
549 550
@@ -553,7 +554,7 @@ send_connect_to_plugin (const struct GNUNET_PeerIdentity *target,
553 cm.header.size = htons (sizeof (cm)); 554 cm.header.size = htons (sizeof (cm));
554 cm.header.type = htons (GNUNET_MESSAGE_TYPE_DV_CONNECT); 555 cm.header.type = htons (GNUNET_MESSAGE_TYPE_DV_CONNECT);
555 cm.distance = htonl (distance); 556 cm.distance = htonl (distance);
556 cm.network = htonl (network); 557 cm.network = htonl ((uint32_t) network);
557 cm.peer = *target; 558 cm.peer = *target;
558 send_control_to_plugin (&cm.header); 559 send_control_to_plugin (&cm.header);
559} 560}
@@ -1158,7 +1159,7 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi,
1158 * @param atsi_count number of entries in atsi 1159 * @param atsi_count number of entries in atsi
1159 * @return connected transport network 1160 * @return connected transport network
1160 */ 1161 */
1161static uint32_t 1162static enum GNUNET_ATS_Network_Type
1162get_atsi_network (const struct GNUNET_ATS_Information *atsi, 1163get_atsi_network (const struct GNUNET_ATS_Information *atsi,
1163 uint32_t atsi_count) 1164 uint32_t atsi_count)
1164{ 1165{
@@ -1166,7 +1167,7 @@ get_atsi_network (const struct GNUNET_ATS_Information *atsi,
1166 1167
1167 for (i = 0; i < atsi_count; i++) 1168 for (i = 0; i < atsi_count; i++)
1168 if (ntohl (atsi[i].type) == GNUNET_ATS_NETWORK_TYPE) 1169 if (ntohl (atsi[i].type) == GNUNET_ATS_NETWORK_TYPE)
1169 return ntohl (atsi[i].value); 1170 return (enum GNUNET_ATS_Network_Type) ntohl (atsi[i].value);
1170 return GNUNET_ATS_NET_UNSPECIFIED; 1171 return GNUNET_ATS_NET_UNSPECIFIED;
1171} 1172}
1172 1173
@@ -1291,7 +1292,7 @@ handle_ats_update (void *cls,
1291{ 1292{
1292 struct DirectNeighbor *neighbor; 1293 struct DirectNeighbor *neighbor;
1293 uint32_t distance; 1294 uint32_t distance;
1294 uint32_t network = GNUNET_ATS_NET_UNSPECIFIED; 1295 enum GNUNET_ATS_Network_Type network = GNUNET_ATS_NET_UNSPECIFIED;
1295 1296
1296 if (GNUNET_NO == active) 1297 if (GNUNET_NO == active)
1297 return; 1298 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
126 /** 126 /**
127 * Current network the next hop peer is located in 127 * Current network the next hop peer is located in
128 */ 128 */
129 uint32_t network; 129 enum GNUNET_ATS_Network_Type network;
130 130
131 /** 131 /**
132 * Does the transport service know about this session (and we thus 132 * Does the transport service know about this session (and we thus
@@ -290,7 +290,8 @@ handle_dv_message_received (void *cls,
290static void 290static void
291handle_dv_connect (void *cls, 291handle_dv_connect (void *cls,
292 const struct GNUNET_PeerIdentity *peer, 292 const struct GNUNET_PeerIdentity *peer,
293 uint32_t distance, uint32_t network) 293 uint32_t distance,
294 enum GNUNET_ATS_Network_Type network)
294{ 295{
295 struct Plugin *plugin = cls; 296 struct Plugin *plugin = cls;
296 struct Session *session; 297 struct Session *session;
@@ -336,7 +337,7 @@ handle_dv_connect (void *cls,
336 ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); 337 ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
337 ats[0].value = htonl (distance); 338 ats[0].value = htonl (distance);
338 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); 339 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
339 ats[1].value = htonl (network); 340 ats[1].value = htonl ((uint32_t) network);
340 session->active = GNUNET_YES; 341 session->active = GNUNET_YES;
341 plugin->env->session_start (plugin->env->cls, peer, 342 plugin->env->session_start (plugin->env->cls, peer,
342 PLUGIN_NAME, 343 PLUGIN_NAME,
@@ -357,7 +358,7 @@ static void
357handle_dv_distance_changed (void *cls, 358handle_dv_distance_changed (void *cls,
358 const struct GNUNET_PeerIdentity *peer, 359 const struct GNUNET_PeerIdentity *peer,
359 uint32_t distance, 360 uint32_t distance,
360 uint32_t network) 361 enum GNUNET_ATS_Network_Type network)
361{ 362{
362 struct Plugin *plugin = cls; 363 struct Plugin *plugin = cls;
363 struct Session *session; 364 struct Session *session;