diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-13 12:48:34 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-13 12:48:34 +0000 |
commit | fdead2414ccf29e4542d17df5eb18b8bb1d9a878 (patch) | |
tree | 108da53bbe006b4c5a308fbff42d425cf7b79db6 /src/dv | |
parent | f67fd220c5280b352c6cc9f689d5b4fb528092cd (diff) | |
download | gnunet-fdead2414ccf29e4542d17df5eb18b8bb1d9a878.tar.gz gnunet-fdead2414ccf29e4542d17df5eb18b8bb1d9a878.zip |
allow distance change to communicate changes in network of next hop as well, related to #3191, but not sure if it fixes it
Diffstat (limited to 'src/dv')
-rw-r--r-- | src/dv/dv.h | 27 | ||||
-rw-r--r-- | src/dv/dv_api.c | 3 | ||||
-rw-r--r-- | src/dv/gnunet-dv.c | 4 | ||||
-rw-r--r-- | src/dv/gnunet-service-dv.c | 16 | ||||
-rw-r--r-- | src/dv/plugin_transport_dv.c | 17 |
5 files changed, 43 insertions, 24 deletions
diff --git a/src/dv/dv.h b/src/dv/dv.h index b20e0b8ff..e791ed15c 100644 --- a/src/dv/dv.h +++ b/src/dv/dv.h | |||
@@ -37,7 +37,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
37 | struct GNUNET_DV_ConnectMessage | 37 | struct GNUNET_DV_ConnectMessage |
38 | { | 38 | { |
39 | /** | 39 | /** |
40 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_CONNECT | 40 | * Type: #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_CONNECT |
41 | */ | 41 | */ |
42 | struct GNUNET_MessageHeader header; | 42 | struct GNUNET_MessageHeader header; |
43 | 43 | ||
@@ -47,14 +47,14 @@ struct GNUNET_DV_ConnectMessage | |||
47 | uint32_t distance GNUNET_PACKED; | 47 | uint32_t distance GNUNET_PACKED; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * The network the peer is in | 50 | * The other peer (at the given distance). |
51 | */ | 51 | */ |
52 | uint32_t network GNUNET_PACKED; | 52 | struct GNUNET_PeerIdentity peer; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * The other peer (at the given distance). | 55 | * The network the peer is in |
56 | */ | 56 | */ |
57 | struct GNUNET_PeerIdentity peer; | 57 | uint32_t network GNUNET_PACKED; |
58 | 58 | ||
59 | }; | 59 | }; |
60 | 60 | ||
@@ -69,7 +69,7 @@ struct GNUNET_DV_ConnectMessage | |||
69 | struct GNUNET_DV_DisconnectMessage | 69 | struct GNUNET_DV_DisconnectMessage |
70 | { | 70 | { |
71 | /** | 71 | /** |
72 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_DISCONNECT | 72 | * Type: #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_DISCONNECT |
73 | */ | 73 | */ |
74 | struct GNUNET_MessageHeader header; | 74 | struct GNUNET_MessageHeader header; |
75 | 75 | ||
@@ -96,7 +96,7 @@ struct GNUNET_DV_DisconnectMessage | |||
96 | struct GNUNET_DV_ReceivedMessage | 96 | struct GNUNET_DV_ReceivedMessage |
97 | { | 97 | { |
98 | /** | 98 | /** |
99 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECV | 99 | * Type: #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECV |
100 | */ | 100 | */ |
101 | struct GNUNET_MessageHeader header; | 101 | struct GNUNET_MessageHeader header; |
102 | 102 | ||
@@ -121,7 +121,7 @@ struct GNUNET_DV_ReceivedMessage | |||
121 | struct GNUNET_DV_SendMessage | 121 | struct GNUNET_DV_SendMessage |
122 | { | 122 | { |
123 | /** | 123 | /** |
124 | * Type: GNUNET_MESSAGE_TYPE_DV_SEND | 124 | * Type: #GNUNET_MESSAGE_TYPE_DV_SEND |
125 | */ | 125 | */ |
126 | struct GNUNET_MessageHeader header; | 126 | struct GNUNET_MessageHeader header; |
127 | 127 | ||
@@ -145,8 +145,8 @@ struct GNUNET_DV_SendMessage | |||
145 | struct GNUNET_DV_AckMessage | 145 | struct GNUNET_DV_AckMessage |
146 | { | 146 | { |
147 | /** | 147 | /** |
148 | * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK or | 148 | * Type: #GNUNET_MESSAGE_TYPE_DV_SEND_ACK or |
149 | * GNUNET_MESSAGE_TYPE_DV_SEND_NACK. | 149 | * #GNUNET_MESSAGE_TYPE_DV_SEND_NACK. |
150 | */ | 150 | */ |
151 | struct GNUNET_MessageHeader header; | 151 | struct GNUNET_MessageHeader header; |
152 | 152 | ||
@@ -170,7 +170,7 @@ struct GNUNET_DV_AckMessage | |||
170 | struct GNUNET_DV_DistanceUpdateMessage | 170 | struct GNUNET_DV_DistanceUpdateMessage |
171 | { | 171 | { |
172 | /** | 172 | /** |
173 | * Type: GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED. | 173 | * Type: #GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED. |
174 | */ | 174 | */ |
175 | struct GNUNET_MessageHeader header; | 175 | struct GNUNET_MessageHeader header; |
176 | 176 | ||
@@ -184,6 +184,11 @@ struct GNUNET_DV_DistanceUpdateMessage | |||
184 | */ | 184 | */ |
185 | struct GNUNET_PeerIdentity peer; | 185 | struct GNUNET_PeerIdentity peer; |
186 | 186 | ||
187 | /** | ||
188 | * The network the peer is in | ||
189 | */ | ||
190 | uint32_t network GNUNET_PACKED; | ||
191 | |||
187 | }; | 192 | }; |
188 | 193 | ||
189 | 194 | ||
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 229148ae4..13bd39afc 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -371,7 +371,8 @@ handle_message_receipt (void *cls, | |||
371 | dum = (const struct GNUNET_DV_DistanceUpdateMessage *) msg; | 371 | dum = (const struct GNUNET_DV_DistanceUpdateMessage *) msg; |
372 | sh->distance_cb (sh->cls, | 372 | sh->distance_cb (sh->cls, |
373 | &dum->peer, | 373 | &dum->peer, |
374 | ntohl (dum->distance)); | 374 | ntohl (dum->distance), |
375 | ntohl (dum->network)); | ||
375 | break; | 376 | break; |
376 | case GNUNET_MESSAGE_TYPE_DV_DISCONNECT: | 377 | case GNUNET_MESSAGE_TYPE_DV_DISCONNECT: |
377 | if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DisconnectMessage)) | 378 | if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DisconnectMessage)) |
diff --git a/src/dv/gnunet-dv.c b/src/dv/gnunet-dv.c index 7be154792..dc17e1a64 100644 --- a/src/dv/gnunet-dv.c +++ b/src/dv/gnunet-dv.c | |||
@@ -62,11 +62,13 @@ connect_cb (void *cls, | |||
62 | * @param cls closure | 62 | * @param cls closure |
63 | * @param peer connected peer | 63 | * @param peer connected peer |
64 | * @param distance new distance to the peer | 64 | * @param distance new distance to the peer |
65 | * @param network network used on first hop to peer | ||
65 | */ | 66 | */ |
66 | static void | 67 | static void |
67 | change_cb (void *cls, | 68 | change_cb (void *cls, |
68 | const struct GNUNET_PeerIdentity *peer, | 69 | const struct GNUNET_PeerIdentity *peer, |
69 | uint32_t distance) | 70 | uint32_t distance, |
71 | uint32_t network) | ||
70 | { | 72 | { |
71 | fprintf (stderr, "Change: %s at %u\n", | 73 | fprintf (stderr, "Change: %s at %u\n", |
72 | GNUNET_i2s (peer), | 74 | GNUNET_i2s (peer), |
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index d5eca28c7..8445ab1f5 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -512,10 +512,12 @@ send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, | |||
512 | * | 512 | * |
513 | * @param peer peer with a changed distance | 513 | * @param peer peer with a changed distance |
514 | * @param distance new distance to the peer | 514 | * @param distance new distance to the peer |
515 | * @param network network used by the neighbor | ||
515 | */ | 516 | */ |
516 | static void | 517 | static void |
517 | send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, | 518 | send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, |
518 | uint32_t distance) | 519 | uint32_t distance, |
520 | uint32_t network) | ||
519 | { | 521 | { |
520 | struct GNUNET_DV_DistanceUpdateMessage du_msg; | 522 | struct GNUNET_DV_DistanceUpdateMessage du_msg; |
521 | 523 | ||
@@ -526,6 +528,7 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, | |||
526 | du_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED); | 528 | du_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED); |
527 | du_msg.distance = htonl (distance); | 529 | du_msg.distance = htonl (distance); |
528 | du_msg.peer = *peer; | 530 | du_msg.peer = *peer; |
531 | du_msg.network = htonl (network); | ||
529 | send_control_to_plugin (&du_msg.header); | 532 | send_control_to_plugin (&du_msg.header); |
530 | } | 533 | } |
531 | 534 | ||
@@ -1045,7 +1048,8 @@ check_possible_route (void *cls, | |||
1045 | move_route (route, ntohl (target->distance) + 1); | 1048 | move_route (route, ntohl (target->distance) + 1); |
1046 | route->next_hop = neighbor; | 1049 | route->next_hop = neighbor; |
1047 | send_distance_change_to_plugin (&target->peer, | 1050 | send_distance_change_to_plugin (&target->peer, |
1048 | ntohl (target->distance) + 1); | 1051 | ntohl (target->distance) + 1, |
1052 | neighbor->network); | ||
1049 | } | 1053 | } |
1050 | return GNUNET_YES; /* got a route to this target already */ | 1054 | return GNUNET_YES; /* got a route to this target already */ |
1051 | } | 1055 | } |
@@ -1443,7 +1447,9 @@ check_target_added (void *cls, | |||
1443 | /* distance decreased, update route */ | 1447 | /* distance decreased, update route */ |
1444 | move_route (current_route, | 1448 | move_route (current_route, |
1445 | ntohl (target->distance) + 1); | 1449 | ntohl (target->distance) + 1); |
1446 | send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1); | 1450 | send_distance_change_to_plugin (&target->peer, |
1451 | ntohl (target->distance) + 1, | ||
1452 | neighbor->network); | ||
1447 | } | 1453 | } |
1448 | } | 1454 | } |
1449 | return GNUNET_OK; | 1455 | return GNUNET_OK; |
@@ -1461,7 +1467,9 @@ check_target_added (void *cls, | |||
1461 | 1467 | ||
1462 | move_route (current_route, ntohl (target->distance) + 1); | 1468 | move_route (current_route, ntohl (target->distance) + 1); |
1463 | current_route->next_hop = neighbor; | 1469 | current_route->next_hop = neighbor; |
1464 | send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1); | 1470 | send_distance_change_to_plugin (&target->peer, |
1471 | ntohl (target->distance) + 1, | ||
1472 | neighbor->network); | ||
1465 | return GNUNET_OK; | 1473 | return GNUNET_OK; |
1466 | } | 1474 | } |
1467 | /* new route */ | 1475 | /* new route */ |
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 93792e0d9..f80c2aa33 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -296,6 +296,7 @@ handle_dv_connect (void *cls, | |||
296 | struct Session *session; | 296 | struct Session *session; |
297 | struct GNUNET_ATS_Information ats[2]; | 297 | struct GNUNET_ATS_Information ats[2]; |
298 | 298 | ||
299 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); | ||
299 | /** | 300 | /** |
300 | * This requires transport plugin to be linked to libgnunetats. | 301 | * This requires transport plugin to be linked to libgnunetats. |
301 | * If you remove it, also remove libgnunetats linkage from Makefile.am | 302 | * If you remove it, also remove libgnunetats linkage from Makefile.am |
@@ -350,26 +351,28 @@ handle_dv_connect (void *cls, | |||
350 | * @param cls closure with `struct Plugin *` | 351 | * @param cls closure with `struct Plugin *` |
351 | * @param peer connected peer | 352 | * @param peer connected peer |
352 | * @param distance new distance to the peer | 353 | * @param distance new distance to the peer |
354 | * @param network network type used for the connection | ||
353 | */ | 355 | */ |
354 | static void | 356 | static void |
355 | handle_dv_distance_changed (void *cls, | 357 | handle_dv_distance_changed (void *cls, |
356 | const struct GNUNET_PeerIdentity *peer, | 358 | const struct GNUNET_PeerIdentity *peer, |
357 | uint32_t distance) | 359 | uint32_t distance, |
360 | uint32_t network) | ||
358 | { | 361 | { |
359 | struct Plugin *plugin = cls; | 362 | struct Plugin *plugin = cls; |
360 | struct Session *session; | 363 | struct Session *session; |
361 | 364 | ||
362 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for peer `%s': new distance %u\n", | 365 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
363 | "DV_DISTANCE_CHANGED", | 366 | "Received `%s' message for peer `%s': new distance %u\n", |
364 | GNUNET_i2s (peer), distance); | 367 | "DV_DISTANCE_CHANGED", |
365 | 368 | GNUNET_i2s (peer), | |
369 | distance); | ||
366 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, | 370 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
367 | peer); | 371 | peer); |
368 | if (NULL == session) | 372 | if (NULL == session) |
369 | { | 373 | { |
370 | GNUNET_break (0); | 374 | GNUNET_break (0); |
371 | /* FIXME */ | 375 | handle_dv_connect (plugin, peer, distance, network); |
372 | handle_dv_connect (plugin, peer, distance, 0); | ||
373 | return; | 376 | return; |
374 | } | 377 | } |
375 | session->distance = distance; | 378 | session->distance = distance; |