[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16512 - in gnunet/src: include transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16512 - in gnunet/src: include transport |
Date: |
Sun, 14 Aug 2011 22:47:31 +0200 |
Author: grothoff
Date: 2011-08-14 22:47:31 +0200 (Sun, 14 Aug 2011)
New Revision: 16512
Modified:
gnunet/src/include/gnunet_signatures.h
gnunet/src/transport/gnunet-service-transport-new.c
gnunet/src/transport/gnunet-service-transport_neighbours.c
gnunet/src/transport/gnunet-service-transport_neighbours.h
gnunet/src/transport/gnunet-service-transport_validation.c
gnunet/src/transport/plugin_transport_udp.c
Log:
process keepalive, simplify PONGs
Modified: gnunet/src/include/gnunet_signatures.h
===================================================================
--- gnunet/src/include/gnunet_signatures.h 2011-08-14 20:08:07 UTC (rev
16511)
+++ gnunet/src/include/gnunet_signatures.h 2011-08-14 20:47:31 UTC (rev
16512)
@@ -49,7 +49,7 @@
/**
* Signature for confirming that this peer connected to another peer
- * using a particular address.
+ * using a particular address (LEGACY)
*/
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING 2
Modified: gnunet/src/transport/gnunet-service-transport-new.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport-new.c 2011-08-14 20:08:07 UTC
(rev 16511)
+++ gnunet/src/transport/gnunet-service-transport-new.c 2011-08-14 20:47:31 UTC
(rev 16512)
@@ -226,6 +226,9 @@
a fake disconnect message... */
GST_neighbours_force_disconnect (peer);
break;
+ case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE:
+ GST_neighbours_keepalive (peer);
+ break;
default:
/* should be payload */
do_forward = GNUNET_SYSERR;
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c 2011-08-14
20:08:07 UTC (rev 16511)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c 2011-08-14
20:47:31 UTC (rev 16512)
@@ -815,10 +815,6 @@
n->quota_violation_count--;
}
}
- GNUNET_SCHEDULER_cancel (n->timeout_task);
- n->timeout_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &neighbour_timeout_task, n);
if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD)
{
GNUNET_STATISTICS_update (GST_stats,
@@ -849,6 +845,33 @@
/**
+ * Keep the connection to the given neighbour alive longer,
+ * we received a KEEPALIVE (or equivalent).
+ *
+ * @param neighbour neighbour to keep alive
+ */
+void
+GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour)
+{
+ struct NeighbourMapEntry *n;
+
+ n = lookup_neighbour (neighbour);
+ if (NULL == n)
+ {
+ GNUNET_STATISTICS_update (GST_stats,
+ gettext_noop ("# KEEPALIVE messages discarded
(not connected)"),
+ 1,
+ GNUNET_NO);
+ return;
+ }
+ GNUNET_SCHEDULER_cancel (n->timeout_task);
+ n->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &neighbour_timeout_task, n);
+}
+
+
+/**
* Change the incoming quota for the given peer.
*
* @param neighbour identity of peer to change qutoa for
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h 2011-08-14
20:08:07 UTC (rev 16511)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h 2011-08-14
20:47:31 UTC (rev 16512)
@@ -122,6 +122,16 @@
/**
+ * Keep the connection to the given neighbour alive longer,
+ * we received a KEEPALIVE (or equivalent).
+ *
+ * @param neighbour neighbour to keep alive
+ */
+void
+GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour);
+
+
+/**
* Change the incoming quota for the given peer.
*
* @param neighbour identity of peer to change qutoa for
Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c 2011-08-14
20:08:07 UTC (rev 16511)
+++ gnunet/src/transport/gnunet-service-transport_validation.c 2011-08-14
20:47:31 UTC (rev 16512)
@@ -132,11 +132,8 @@
struct GNUNET_CRYPTO_RsaSignature signature;
/**
- * What are we signing and why? Two possible reason codes can be here:
* GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN to confirm that this is a
- * plausible address for this peer (pid is set to identity of signer); or
- * GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING to confirm that this is
- * an address we used to connect to the peer with the given pid.
+ * plausible address for the signing peer.
*/
struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
@@ -146,13 +143,6 @@
struct GNUNET_TIME_AbsoluteNBO expiration;
/**
- * Either the identity of the peer Who signed this message, or the
- * identity of the peer that we're connected to using the given
- * address (depending on purpose.type).
- */
- struct GNUNET_PeerIdentity pid;
-
- /**
* Size of address appended to this message (part of what is
* being signed, hence not redundant).
*/
@@ -683,11 +673,10 @@
htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
sizeof (uint32_t) +
sizeof (struct GNUNET_TIME_AbsoluteNBO) +
- sizeof (struct GNUNET_PeerIdentity) + alen + slen);
+ alen + slen);
pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
pong->challenge = ping->challenge;
pong->addrlen = htonl(alen + slen);
- pong->pid = GST_my_identity;
memcpy (&pong[1], addr, slen);
memcpy (&((char*)&pong[1])[slen], addrend, alen);
if (GNUNET_TIME_absolute_get_remaining (*sig_cache_exp).rel_value <
PONG_SIGNATURE_LIFETIME.rel_value / 4)
@@ -993,13 +982,6 @@
1,
GNUNET_NO);
pong = (const struct TransportPongMessage *) hdr;
- if (0 != memcmp (&pong->pid,
- sender,
- sizeof (struct GNUNET_PeerIdentity)))
- {
- GNUNET_break_op (0);
- return;
- }
addr = (const char*) &pong[1];
alen = ntohs (hdr->size) - sizeof (struct TransportPongMessage);
addrend = memchr (addr, '\0', alen);
@@ -1025,6 +1007,14 @@
return;
}
/* now check that PONG is well-formed */
+ if (0 != memcmp (&ve->pid,
+ sender,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+
if (GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
(pong->expiration)).rel_value == 0)
{
GNUNET_STATISTICS_update (GST_stats,
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2011-08-14 20:08:07 UTC (rev
16511)
+++ gnunet/src/transport/plugin_transport_udp.c 2011-08-14 20:47:31 UTC (rev
16512)
@@ -129,7 +129,8 @@
/**
- * Session with another peer.
+ * Session with another peer. FIXME: why not make this into
+ * a regular 'struct Session' and pass it around!?
*/
struct PeerSession
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16512 - in gnunet/src: include transport,
gnunet <=