aboutsummaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-03-15 08:49:10 +0000
committerChristian Grothoff <christian@grothoff.org>2013-03-15 08:49:10 +0000
commitd1c05be0514d7b0074a8df34b12a0acb6bae82d0 (patch)
tree154ea3eda6cc4f7ccd1aa7ac84bd4a29e180669d /src/dv
parent44f07a618e64d94b03e3a1be7812a1721aa63902 (diff)
downloadgnunet-d1c05be0514d7b0074a8df34b12a0acb6bae82d0.tar.gz
gnunet-d1c05be0514d7b0074a8df34b12a0acb6bae82d0.zip
-nack support
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/dv.h31
-rw-r--r--src/dv/dv_api.c11
-rw-r--r--src/dv/gnunet-service-dv.c20
3 files changed, 48 insertions, 14 deletions
diff --git a/src/dv/dv.h b/src/dv/dv.h
index bcc586a0e..c0247218e 100644
--- a/src/dv/dv.h
+++ b/src/dv/dv.h
@@ -135,12 +135,13 @@ struct GNUNET_DV_SendMessage
135 135
136/** 136/**
137 * Message from service to DV plugin, saying that a 137 * Message from service to DV plugin, saying that a
138 * SEND request was handled. 138 * SEND request was handled.
139 */ 139 */
140struct GNUNET_DV_AckMessage 140struct GNUNET_DV_AckMessage
141{ 141{
142 /** 142 /**
143 * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK 143 * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK or
144 * GNUNET_MESSAGE_TYPE_DV_SEND_NACK.
144 */ 145 */
145 struct GNUNET_MessageHeader header; 146 struct GNUNET_MessageHeader header;
146 147
@@ -155,6 +156,32 @@ struct GNUNET_DV_AckMessage
155 struct GNUNET_PeerIdentity target; 156 struct GNUNET_PeerIdentity target;
156 157
157}; 158};
159
160
161/**
162 * Message from service to DV plugin, saying that our
163 * distance to another peer changed.
164 */
165struct GNUNET_DV_DistanceUpdateMessage
166{
167 /**
168 * Type: GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED.
169 */
170 struct GNUNET_MessageHeader header;
171
172 /**
173 * What is the new distance?
174 */
175 uint32_t distance GNUNET_PACKED;
176
177 /**
178 * The peer for which the distance changed.
179 */
180 struct GNUNET_PeerIdentity peer;
181
182};
183
184
158GNUNET_NETWORK_STRUCT_END 185GNUNET_NETWORK_STRUCT_END
159 186
160#endif 187#endif
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c
index fff0896b3..dab7c7ad3 100644
--- a/src/dv/dv_api.c
+++ b/src/dv/dv_api.c
@@ -266,9 +266,10 @@ process_ack (void *cls,
266 GNUNET_CONTAINER_multihashmap_remove (ctx->sh->send_callbacks, 266 GNUNET_CONTAINER_multihashmap_remove (ctx->sh->send_callbacks,
267 key, 267 key,
268 th)); 268 th));
269 /* FIXME: should distinguish between success and failure here... */
270 th->cb (th->cb_cls, 269 th->cb (th->cb_cls,
271 GNUNET_OK); 270 (ntohs (ctx->ack->header.type) == GNUNET_MESSAGE_TYPE_DV_SEND_ACK)
271 ? GNUNET_OK
272 : GNUNET_SYSERR);
272 GNUNET_free (th); 273 GNUNET_free (th);
273 return GNUNET_NO; 274 return GNUNET_NO;
274} 275}
@@ -345,6 +346,7 @@ handle_message_receipt (void *cls,
345 payload); 346 payload);
346 break; 347 break;
347 case GNUNET_MESSAGE_TYPE_DV_SEND_ACK: 348 case GNUNET_MESSAGE_TYPE_DV_SEND_ACK:
349 case GNUNET_MESSAGE_TYPE_DV_SEND_NACK:
348 if (ntohs (msg->size) != sizeof (struct GNUNET_DV_AckMessage)) 350 if (ntohs (msg->size) != sizeof (struct GNUNET_DV_AckMessage))
349 { 351 {
350 GNUNET_break (0); 352 GNUNET_break (0);
@@ -358,7 +360,10 @@ handle_message_receipt (void *cls,
358 &ack->target.hashPubKey, 360 &ack->target.hashPubKey,
359 &process_ack, 361 &process_ack,
360 &ctx); 362 &ctx);
361 return; 363 break;
364 case GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED:
365 GNUNET_break (0);
366 break;
362 default: 367 default:
363 reconnect (sh); 368 reconnect (sh);
364 break; 369 break;
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index fafccb7f3..e6c107981 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -30,8 +30,6 @@
30 * TODO: 30 * TODO:
31 * - distance updates are not properly communicate to US by core, 31 * - distance updates are not properly communicate to US by core,
32 * and conversely we don't give distance updates properly to the plugin yet 32 * and conversely we don't give distance updates properly to the plugin yet
33 * - we send 'ACK' even if a message was dropped due to no route (may
34 * be harmless, but should at least be documented -- or support NACK)
35 */ 33 */
36#include "platform.h" 34#include "platform.h"
37#include "gnunet_util_lib.h" 35#include "gnunet_util_lib.h"
@@ -503,14 +501,16 @@ send_control_to_plugin (const struct GNUNET_MessageHeader *message)
503 501
504 502
505/** 503/**
506 * Give an ACK message to the plugin, we transmitted a message for it. 504 * Give an (N)ACK message to the plugin, we transmitted a message for it.
507 * 505 *
508 * @param target peer that received the message 506 * @param target peer that received the message
509 * @param uid plugin-chosen UID for the message 507 * @param uid plugin-chosen UID for the message
508 * @param nack GNUNET_NO to send ACK, GNUNET_YES to send NACK
510 */ 509 */
511static void 510static void
512send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, 511send_ack_to_plugin (const struct GNUNET_PeerIdentity *target,
513 uint32_t uid) 512 uint32_t uid,
513 int nack)
514{ 514{
515 struct GNUNET_DV_AckMessage ack_msg; 515 struct GNUNET_DV_AckMessage ack_msg;
516 516
@@ -518,7 +518,9 @@ send_ack_to_plugin (const struct GNUNET_PeerIdentity *target,
518 "Delivering ACK for message to peer `%s'\n", 518 "Delivering ACK for message to peer `%s'\n",
519 GNUNET_i2s (target)); 519 GNUNET_i2s (target));
520 ack_msg.header.size = htons (sizeof (ack_msg)); 520 ack_msg.header.size = htons (sizeof (ack_msg));
521 ack_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_SEND_ACK); 521 ack_msg.header.type = htons ((GNUNET_YES == nack)
522 ? GNUNET_MESSAGE_TYPE_DV_SEND_NACK
523 : GNUNET_MESSAGE_TYPE_DV_SEND_ACK);
522 ack_msg.uid = htonl (uid); 524 ack_msg.uid = htonl (uid);
523 ack_msg.target = *target; 525 ack_msg.target = *target;
524 send_control_to_plugin (&ack_msg.header); 526 send_control_to_plugin (&ack_msg.header);
@@ -610,7 +612,8 @@ core_transmit_notify (void *cls, size_t size, void *buf)
610 memcpy (&cbuf[off], pending->msg, msize); 612 memcpy (&cbuf[off], pending->msg, msize);
611 if (0 != pending->uid) 613 if (0 != pending->uid)
612 send_ack_to_plugin (&pending->ultimate_target, 614 send_ack_to_plugin (&pending->ultimate_target,
613 pending->uid); 615 pending->uid,
616 GNUNET_NO);
614 GNUNET_free (pending); 617 GNUNET_free (pending);
615 off += msize; 618 off += msize;
616 } 619 }
@@ -1321,12 +1324,11 @@ handle_dv_send_message (void *cls, struct GNUNET_SERVER_Client *client,
1321 &msg->target.hashPubKey); 1324 &msg->target.hashPubKey);
1322 if (NULL == route) 1325 if (NULL == route)
1323 { 1326 {
1324 /* got disconnected, send ACK anyway? 1327 /* got disconnected */
1325 FIXME: What we really want is an 'NACK' here... */
1326 GNUNET_STATISTICS_update (stats, 1328 GNUNET_STATISTICS_update (stats,
1327 "# local messages discarded (no route)", 1329 "# local messages discarded (no route)",
1328 1, GNUNET_NO); 1330 1, GNUNET_NO);
1329 send_ack_to_plugin (&msg->target, ntohl (msg->uid)); 1331 send_ack_to_plugin (&msg->target, ntohl (msg->uid), GNUNET_YES);
1330 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1332 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1331 return; 1333 return;
1332 } 1334 }