aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS6
-rw-r--r--TODO9
-rw-r--r--src/hello/hello.c122
-rw-r--r--src/include/gnunet_hello_lib.h23
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c11
5 files changed, 164 insertions, 7 deletions
diff --git a/AUTHORS b/AUTHORS
index 6e30bb7a9..1e58d0b51 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,9 +1,10 @@
1Primary developers (0.9.x series): 1Primary developers (0.9.x series):
2Christian Grothoff <christian@grothoff.org> 2Christian Grothoff <christian@grothoff.org>
3Heikki Lindholm <holin@iki.fi> 3Heikki Lindholm <holin@iki.fi>
4Nils Durner <durner@gnunet.org> 4Matthias Wachs <wachs@net.in.tum.de>
5Milan Bouchet-Valat <nalimilan@club.fr> 5Milan Bouchet-Valat <nalimilan@club.fr>
6Nathan Evans <evans@net.in.tum.de> 6Nathan Evans <evans@net.in.tum.de>
7Nils Durner <durner@gnunet.org>
7 8
8Code contributions also came from: 9Code contributions also came from:
9Adam Warrington [ UPnP ] 10Adam Warrington [ UPnP ]
@@ -76,8 +77,7 @@ new GNU in Net: Nicklas Larsson <whybill@gmail.com>
76 77
77Maintainers: 78Maintainers:
78FreeBSD : Kirill Ponomarew <ponomarew@oberon.net> 79FreeBSD : Kirill Ponomarew <ponomarew@oberon.net>
79Debian GNU/Linux: Daniel Baumann <daniel.baumann@panthera-systems.net> and 80Debian GNU/Linux: Daniel Baumann <daniel.baumann@panthera-systems.net>
80 Arnaud Kyheng <Arnaud.Kyheng@free.fr>
81OS X : Jussi Eloranta <eloranta@cc.jyu.fi> 81OS X : Jussi Eloranta <eloranta@cc.jyu.fi>
82 82
83 83
diff --git a/TODO b/TODO
index 83f25cf3a..868cc5b62 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,12 @@
10.9.0pre0 [April]: 10.9.0pre0 [April]:
2* HOSTLIST: seems to have NO 'tcp' in it, so cannot have any addresses!? [CG] 2* HOSTLIST: seems to have NO 'tcp' in it, so cannot have any addresses!? [CG]
3* FS-acceptance testing [CG]
4* Release checks:
5 - portability
6 - coverity
7 - clang
8 - cppcheck
9* ChangeLog update
3* WWW: 10* WWW:
4 - Get IPv6 hooked up [AK, after April 12th] 11 - Get IPv6 hooked up [AK, after April 12th]
5 - change DNS [CG, need DNS] 12 - change DNS [CG, need DNS]
@@ -15,8 +22,6 @@
15 - only connect() sockets that are ready (select()) [Nils] 22 - only connect() sockets that are ready (select()) [Nils]
16 [On W32, we need to select after calling socket before 23 [On W32, we need to select after calling socket before
17 doing connect etc.] 24 doing connect etc.]
18* HELLO: [CG]
19 - need function to test "equivalency" of HELLOs (or integrate with "merge"?); use in PEERINFO
20* SETUP: 25* SETUP:
21 - design & implement new setup tool 26 - design & implement new setup tool
22* TBENCH: [MW] 27* TBENCH: [MW]
diff --git a/src/hello/hello.c b/src/hello/hello.c
index 4ddeebd03..51575ebaf 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -510,6 +510,7 @@ GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
510 return GNUNET_OK; 510 return GNUNET_OK;
511} 511}
512 512
513
513/** 514/**
514 * Get the header from a HELLO message, used so other code 515 * Get the header from a HELLO message, used so other code
515 * can correctly send HELLO messages. 516 * can correctly send HELLO messages.
@@ -529,4 +530,125 @@ GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello)
529 return &hello->header; 530 return &hello->header;
530} 531}
531 532
533
534struct EqualsContext
535{
536 struct GNUNET_TIME_Absolute expiration_limit;
537
538 struct GNUNET_TIME_Absolute result;
539
540 const struct GNUNET_HELLO_Message *h2;
541
542 const char *tname;
543
544 const void *addr;
545
546 struct GNUNET_TIME_Absolute expiration;
547
548 size_t addrlen;
549
550 int found;
551};
552
553
554static int
555find_other_matching (void *cls,
556 const char *tname,
557 struct GNUNET_TIME_Absolute expiration,
558 const void *addr, size_t addrlen)
559{
560 struct EqualsContext *ec = cls;
561
562 if (expiration.value < ec->expiration_limit.value)
563 return GNUNET_YES;
564 if ( (addrlen == ec->addrlen) &&
565 (0 == strcmp (tname,
566 ec->tname)) &&
567 (0 == memcmp (addr,
568 ec->addr,
569 addrlen)) )
570 {
571 ec->found = GNUNET_YES;
572 if (expiration.value < ec->expiration.value)
573 {
574 ec->result = GNUNET_TIME_absolute_min (expiration,
575 ec->result);
576 }
577 return GNUNET_SYSERR;
578 }
579 return GNUNET_YES;
580}
581
582
583static int
584find_matching (void *cls,
585 const char *tname,
586 struct GNUNET_TIME_Absolute expiration,
587 const void *addr, size_t addrlen)
588{
589 struct EqualsContext *ec = cls;
590
591 if (expiration.value < ec->expiration_limit.value)
592 return GNUNET_YES;
593 ec->tname = tname;
594 ec->expiration = expiration;
595 ec->addr = addr;
596 ec->addrlen = addrlen;
597 ec->found = GNUNET_NO;
598 GNUNET_HELLO_iterate_addresses (ec->h2,
599 GNUNET_NO,
600 &find_other_matching,
601 ec);
602 if (ec->found == GNUNET_NO)
603 {
604 ec->result = GNUNET_TIME_UNIT_ZERO_ABS;
605 return GNUNET_SYSERR;
606 }
607 return GNUNET_OK;
608}
609
610/**
611 * Test if two HELLO messages contain the same addresses.
612 * If they only differ in expiration time, the lowest
613 * expiration time larger than 'now' where they differ
614 * is returned.
615 *
616 * @param h1 first HELLO message
617 * @param h2 the second HELLO message
618 * @param now time to use for deciding which addresses have
619 * expired and should not be considered at all
620 * @return absolute time zero if the two HELLOs are
621 * totally identical; smallest timestamp >= now if
622 * they only differ in timestamps;
623 * forever if the some addresses with expirations >= now
624 * do not match at all
625 */
626struct GNUNET_TIME_Absolute
627GNUNET_HELLO_equals (const struct
628 GNUNET_HELLO_Message *h1,
629 const struct
630 GNUNET_HELLO_Message *h2,
631 struct GNUNET_TIME_Absolute now)
632{
633 struct EqualsContext ec;
634
635 ec.expiration_limit = now;
636 ec.result = GNUNET_TIME_UNIT_FOREVER_ABS;
637 ec.h2 = h2;
638 GNUNET_HELLO_iterate_addresses (h1,
639 GNUNET_NO,
640 &find_matching,
641 &ec);
642 if (ec.result.value ==
643 GNUNET_TIME_UNIT_ZERO.value)
644 return ec.result;
645 ec.h2 = h1;
646 GNUNET_HELLO_iterate_addresses (h2,
647 GNUNET_NO,
648 &find_matching,
649 &ec);
650 return ec.result;
651}
652
653
532/* end of hello.c */ 654/* end of hello.c */
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index 73f84bc43..ca5e29284 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -120,6 +120,29 @@ struct GNUNET_HELLO_Message *GNUNET_HELLO_merge (const struct
120 GNUNET_HELLO_Message *h2); 120 GNUNET_HELLO_Message *h2);
121 121
122 122
123/**
124 * Test if two HELLO messages contain the same addresses.
125 * If they only differ in expiration time, the lowest
126 * expiration time larger than 'now' where they differ
127 * is returned.
128 *
129 * @param h1 first HELLO message
130 * @param h2 the second HELLO message
131 * @param now time to use for deciding which addresses have
132 * expired and should not be considered at all
133 * @return absolute time forever if the two HELLOs are
134 * totally identical; smallest timestamp >= now if
135 * they only differ in timestamps;
136 * zero if the some addresses with expirations >= now
137 * do not match at all
138 */
139struct GNUNET_TIME_Absolute
140GNUNET_HELLO_equals (const struct
141 GNUNET_HELLO_Message *h1,
142 const struct
143 GNUNET_HELLO_Message *h2,
144 struct GNUNET_TIME_Absolute now);
145
123 146
124/** 147/**
125 * Iterator callback to go over all addresses. 148 * Iterator callback to go over all addresses.
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 5c3f2dfbf..aa2047c7c 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -441,6 +441,7 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
441 char *fn; 441 char *fn;
442 struct HostEntry *host; 442 struct HostEntry *host;
443 struct GNUNET_HELLO_Message *mrg; 443 struct GNUNET_HELLO_Message *mrg;
444 struct GNUNET_TIME_Absolute delta;
444 445
445 add_host_to_known_hosts (peer); 446 add_host_to_known_hosts (peer);
446 host = lookup_host_entry (peer); 447 host = lookup_host_entry (peer);
@@ -453,8 +454,14 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
453 else 454 else
454 { 455 {
455 mrg = GNUNET_HELLO_merge (host->hello, hello); 456 mrg = GNUNET_HELLO_merge (host->hello, hello);
456 /* FIXME: check if old and merged hello are equal, 457 delta = GNUNET_HELLO_equals (mrg,
457 and if so, bail out early... */ 458 host->hello,
459 GNUNET_TIME_absolute_get ());
460 if (delta.value == GNUNET_TIME_UNIT_FOREVER_ABS.value)
461 {
462 GNUNET_free (mrg);
463 return;
464 }
458 GNUNET_free (host->hello); 465 GNUNET_free (host->hello);
459 host->hello = mrg; 466 host->hello = mrg;
460 } 467 }