[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10871 - in gnunet: . src/hello src/include src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10871 - in gnunet: . src/hello src/include src/peerinfo |
Date: |
Sat, 10 Apr 2010 23:05:27 +0200 |
Author: grothoff
Date: 2010-04-10 23:05:27 +0200 (Sat, 10 Apr 2010)
New Revision: 10871
Modified:
gnunet/AUTHORS
gnunet/TODO
gnunet/src/hello/hello.c
gnunet/src/include/gnunet_hello_lib.h
gnunet/src/peerinfo/gnunet-service-peerinfo.c
Log:
work on HELLO
Modified: gnunet/AUTHORS
===================================================================
--- gnunet/AUTHORS 2010-04-10 11:21:07 UTC (rev 10870)
+++ gnunet/AUTHORS 2010-04-10 21:05:27 UTC (rev 10871)
@@ -1,9 +1,10 @@
Primary developers (0.9.x series):
Christian Grothoff <address@hidden>
Heikki Lindholm <address@hidden>
-Nils Durner <address@hidden>
+Matthias Wachs <address@hidden>
Milan Bouchet-Valat <address@hidden>
Nathan Evans <address@hidden>
+Nils Durner <address@hidden>
Code contributions also came from:
Adam Warrington [ UPnP ]
@@ -76,8 +77,7 @@
Maintainers:
FreeBSD : Kirill Ponomarew <address@hidden>
-Debian GNU/Linux: Daniel Baumann <address@hidden> and
- Arnaud Kyheng <address@hidden>
+Debian GNU/Linux: Daniel Baumann <address@hidden>
OS X : Jussi Eloranta <address@hidden>
Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-04-10 11:21:07 UTC (rev 10870)
+++ gnunet/TODO 2010-04-10 21:05:27 UTC (rev 10871)
@@ -1,5 +1,12 @@
0.9.0pre0 [April]:
* HOSTLIST: seems to have NO 'tcp' in it, so cannot have any addresses!? [CG]
+* FS-acceptance testing [CG]
+* Release checks:
+ - portability
+ - coverity
+ - clang
+ - cppcheck
+* ChangeLog update
* WWW:
- Get IPv6 hooked up [AK, after April 12th]
- change DNS [CG, need DNS]
@@ -15,8 +22,6 @@
- only connect() sockets that are ready (select()) [Nils]
[On W32, we need to select after calling socket before
doing connect etc.]
-* HELLO: [CG]
- - need function to test "equivalency" of HELLOs (or integrate with
"merge"?); use in PEERINFO
* SETUP:
- design & implement new setup tool
* TBENCH: [MW]
Modified: gnunet/src/hello/hello.c
===================================================================
--- gnunet/src/hello/hello.c 2010-04-10 11:21:07 UTC (rev 10870)
+++ gnunet/src/hello/hello.c 2010-04-10 21:05:27 UTC (rev 10871)
@@ -510,6 +510,7 @@
return GNUNET_OK;
}
+
/**
* Get the header from a HELLO message, used so other code
* can correctly send HELLO messages.
@@ -529,4 +530,125 @@
return &hello->header;
}
+
+struct EqualsContext
+{
+ struct GNUNET_TIME_Absolute expiration_limit;
+
+ struct GNUNET_TIME_Absolute result;
+
+ const struct GNUNET_HELLO_Message *h2;
+
+ const char *tname;
+
+ const void *addr;
+
+ struct GNUNET_TIME_Absolute expiration;
+
+ size_t addrlen;
+
+ int found;
+};
+
+
+static int
+find_other_matching (void *cls,
+ const char *tname,
+ struct GNUNET_TIME_Absolute expiration,
+ const void *addr, size_t addrlen)
+{
+ struct EqualsContext *ec = cls;
+
+ if (expiration.value < ec->expiration_limit.value)
+ return GNUNET_YES;
+ if ( (addrlen == ec->addrlen) &&
+ (0 == strcmp (tname,
+ ec->tname)) &&
+ (0 == memcmp (addr,
+ ec->addr,
+ addrlen)) )
+ {
+ ec->found = GNUNET_YES;
+ if (expiration.value < ec->expiration.value)
+ {
+ ec->result = GNUNET_TIME_absolute_min (expiration,
+ ec->result);
+ }
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_YES;
+}
+
+
+static int
+find_matching (void *cls,
+ const char *tname,
+ struct GNUNET_TIME_Absolute expiration,
+ const void *addr, size_t addrlen)
+{
+ struct EqualsContext *ec = cls;
+
+ if (expiration.value < ec->expiration_limit.value)
+ return GNUNET_YES;
+ ec->tname = tname;
+ ec->expiration = expiration;
+ ec->addr = addr;
+ ec->addrlen = addrlen;
+ ec->found = GNUNET_NO;
+ GNUNET_HELLO_iterate_addresses (ec->h2,
+ GNUNET_NO,
+ &find_other_matching,
+ ec);
+ if (ec->found == GNUNET_NO)
+ {
+ ec->result = GNUNET_TIME_UNIT_ZERO_ABS;
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+/**
+ * Test if two HELLO messages contain the same addresses.
+ * If they only differ in expiration time, the lowest
+ * expiration time larger than 'now' where they differ
+ * is returned.
+ *
+ * @param h1 first HELLO message
+ * @param h2 the second HELLO message
+ * @param now time to use for deciding which addresses have
+ * expired and should not be considered at all
+ * @return absolute time zero if the two HELLOs are
+ * totally identical; smallest timestamp >= now if
+ * they only differ in timestamps;
+ * forever if the some addresses with expirations >= now
+ * do not match at all
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_HELLO_equals (const struct
+ GNUNET_HELLO_Message *h1,
+ const struct
+ GNUNET_HELLO_Message *h2,
+ struct GNUNET_TIME_Absolute now)
+{
+ struct EqualsContext ec;
+
+ ec.expiration_limit = now;
+ ec.result = GNUNET_TIME_UNIT_FOREVER_ABS;
+ ec.h2 = h2;
+ GNUNET_HELLO_iterate_addresses (h1,
+ GNUNET_NO,
+ &find_matching,
+ &ec);
+ if (ec.result.value ==
+ GNUNET_TIME_UNIT_ZERO.value)
+ return ec.result;
+ ec.h2 = h1;
+ GNUNET_HELLO_iterate_addresses (h2,
+ GNUNET_NO,
+ &find_matching,
+ &ec);
+ return ec.result;
+}
+
+
/* end of hello.c */
Modified: gnunet/src/include/gnunet_hello_lib.h
===================================================================
--- gnunet/src/include/gnunet_hello_lib.h 2010-04-10 11:21:07 UTC (rev
10870)
+++ gnunet/src/include/gnunet_hello_lib.h 2010-04-10 21:05:27 UTC (rev
10871)
@@ -120,7 +120,30 @@
GNUNET_HELLO_Message *h2);
+/**
+ * Test if two HELLO messages contain the same addresses.
+ * If they only differ in expiration time, the lowest
+ * expiration time larger than 'now' where they differ
+ * is returned.
+ *
+ * @param h1 first HELLO message
+ * @param h2 the second HELLO message
+ * @param now time to use for deciding which addresses have
+ * expired and should not be considered at all
+ * @return absolute time forever if the two HELLOs are
+ * totally identical; smallest timestamp >= now if
+ * they only differ in timestamps;
+ * zero if the some addresses with expirations >= now
+ * do not match at all
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_HELLO_equals (const struct
+ GNUNET_HELLO_Message *h1,
+ const struct
+ GNUNET_HELLO_Message *h2,
+ struct GNUNET_TIME_Absolute now);
+
/**
* Iterator callback to go over all addresses.
*
Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c 2010-04-10 11:21:07 UTC
(rev 10870)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c 2010-04-10 21:05:27 UTC
(rev 10871)
@@ -441,6 +441,7 @@
char *fn;
struct HostEntry *host;
struct GNUNET_HELLO_Message *mrg;
+ struct GNUNET_TIME_Absolute delta;
add_host_to_known_hosts (peer);
host = lookup_host_entry (peer);
@@ -453,8 +454,14 @@
else
{
mrg = GNUNET_HELLO_merge (host->hello, hello);
- /* FIXME: check if old and merged hello are equal,
- and if so, bail out early... */
+ delta = GNUNET_HELLO_equals (mrg,
+ host->hello,
+ GNUNET_TIME_absolute_get ());
+ if (delta.value == GNUNET_TIME_UNIT_FOREVER_ABS.value)
+ {
+ GNUNET_free (mrg);
+ return;
+ }
GNUNET_free (host->hello);
host->hello = mrg;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10871 - in gnunet: . src/hello src/include src/peerinfo,
gnunet <=