[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26437 - in gnunet/src: dv include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26437 - in gnunet/src: dv include |
Date: |
Fri, 15 Mar 2013 09:49:10 +0100 |
Author: grothoff
Date: 2013-03-15 09:49:10 +0100 (Fri, 15 Mar 2013)
New Revision: 26437
Modified:
gnunet/src/dv/dv.h
gnunet/src/dv/dv_api.c
gnunet/src/dv/gnunet-service-dv.c
gnunet/src/include/gnunet_protocols.h
Log:
-nack support
Modified: gnunet/src/dv/dv.h
===================================================================
--- gnunet/src/dv/dv.h 2013-03-15 08:42:19 UTC (rev 26436)
+++ gnunet/src/dv/dv.h 2013-03-15 08:49:10 UTC (rev 26437)
@@ -135,12 +135,13 @@
/**
* Message from service to DV plugin, saying that a
- * SEND request was handled.
+ * SEND request was handled.
*/
struct GNUNET_DV_AckMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK
+ * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK or
+ * GNUNET_MESSAGE_TYPE_DV_SEND_NACK.
*/
struct GNUNET_MessageHeader header;
@@ -155,6 +156,32 @@
struct GNUNET_PeerIdentity target;
};
+
+
+/**
+ * Message from service to DV plugin, saying that our
+ * distance to another peer changed.
+ */
+struct GNUNET_DV_DistanceUpdateMessage
+{
+ /**
+ * Type: GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED.
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * What is the new distance?
+ */
+ uint32_t distance GNUNET_PACKED;
+
+ /**
+ * The peer for which the distance changed.
+ */
+ struct GNUNET_PeerIdentity peer;
+
+};
+
+
GNUNET_NETWORK_STRUCT_END
#endif
Modified: gnunet/src/dv/dv_api.c
===================================================================
--- gnunet/src/dv/dv_api.c 2013-03-15 08:42:19 UTC (rev 26436)
+++ gnunet/src/dv/dv_api.c 2013-03-15 08:49:10 UTC (rev 26437)
@@ -266,9 +266,10 @@
GNUNET_CONTAINER_multihashmap_remove (ctx->sh->send_callbacks,
key,
th));
- /* FIXME: should distinguish between success and failure here... */
th->cb (th->cb_cls,
- GNUNET_OK);
+ (ntohs (ctx->ack->header.type) == GNUNET_MESSAGE_TYPE_DV_SEND_ACK)
+ ? GNUNET_OK
+ : GNUNET_SYSERR);
GNUNET_free (th);
return GNUNET_NO;
}
@@ -345,6 +346,7 @@
payload);
break;
case GNUNET_MESSAGE_TYPE_DV_SEND_ACK:
+ case GNUNET_MESSAGE_TYPE_DV_SEND_NACK:
if (ntohs (msg->size) != sizeof (struct GNUNET_DV_AckMessage))
{
GNUNET_break (0);
@@ -358,7 +360,10 @@
&ack->target.hashPubKey,
&process_ack,
&ctx);
- return;
+ break;
+ case GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED:
+ GNUNET_break (0);
+ break;
default:
reconnect (sh);
break;
Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c 2013-03-15 08:42:19 UTC (rev 26436)
+++ gnunet/src/dv/gnunet-service-dv.c 2013-03-15 08:49:10 UTC (rev 26437)
@@ -30,8 +30,6 @@
* TODO:
* - distance updates are not properly communicate to US by core,
* and conversely we don't give distance updates properly to the plugin yet
- * - we send 'ACK' even if a message was dropped due to no route (may
- * be harmless, but should at least be documented -- or support NACK)
*/
#include "platform.h"
#include "gnunet_util_lib.h"
@@ -503,14 +501,16 @@
/**
- * Give an ACK message to the plugin, we transmitted a message for it.
+ * Give an (N)ACK message to the plugin, we transmitted a message for it.
*
* @param target peer that received the message
* @param uid plugin-chosen UID for the message
+ * @param nack GNUNET_NO to send ACK, GNUNET_YES to send NACK
*/
static void
send_ack_to_plugin (const struct GNUNET_PeerIdentity *target,
- uint32_t uid)
+ uint32_t uid,
+ int nack)
{
struct GNUNET_DV_AckMessage ack_msg;
@@ -518,7 +518,9 @@
"Delivering ACK for message to peer `%s'\n",
GNUNET_i2s (target));
ack_msg.header.size = htons (sizeof (ack_msg));
- ack_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_SEND_ACK);
+ ack_msg.header.type = htons ((GNUNET_YES == nack)
+ ? GNUNET_MESSAGE_TYPE_DV_SEND_NACK
+ : GNUNET_MESSAGE_TYPE_DV_SEND_ACK);
ack_msg.uid = htonl (uid);
ack_msg.target = *target;
send_control_to_plugin (&ack_msg.header);
@@ -610,7 +612,8 @@
memcpy (&cbuf[off], pending->msg, msize);
if (0 != pending->uid)
send_ack_to_plugin (&pending->ultimate_target,
- pending->uid);
+ pending->uid,
+ GNUNET_NO);
GNUNET_free (pending);
off += msize;
}
@@ -1321,12 +1324,11 @@
&msg->target.hashPubKey);
if (NULL == route)
{
- /* got disconnected, send ACK anyway?
- FIXME: What we really want is an 'NACK' here... */
+ /* got disconnected */
GNUNET_STATISTICS_update (stats,
"# local messages discarded (no route)",
1, GNUNET_NO);
- send_ack_to_plugin (&msg->target, ntohl (msg->uid));
+ send_ack_to_plugin (&msg->target, ntohl (msg->uid), GNUNET_YES);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h 2013-03-15 08:42:19 UTC (rev
26436)
+++ gnunet/src/include/gnunet_protocols.h 2013-03-15 08:49:10 UTC (rev
26437)
@@ -202,7 +202,17 @@
*/
#define GNUNET_MESSAGE_TYPE_DV_DISCONNECT 50
+/**
+ * P2P DV message telling plugin that a message transmission failed (negative
ACK)
+ */
+#define GNUNET_MESSAGE_TYPE_DV_SEND_NACK 51
+/**
+ * P2P DV message telling plugin that our distance to a peer changed
+ */
+#define GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED 52
+
+
/*******************************************************************************
* Transport-UDP message types
******************************************************************************/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26437 - in gnunet/src: dv include,
gnunet <=