diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-19 16:06:34 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-19 16:06:34 +0100 |
commit | 95ffa9b9ac9711539aac3feb15eefcfebfc14825 (patch) | |
tree | 9f4d5a853807d60f8e1a786ff3d48eb078792e68 /src/dhtu | |
parent | 901b2fcc56a618a0d3e9d3e65c8688f84e3e180c (diff) | |
download | gnunet-95ffa9b9ac9711539aac3feb15eefcfebfc14825.tar.gz gnunet-95ffa9b9ac9711539aac3feb15eefcfebfc14825.zip |
-fix htons/htonl bug introduced by message format change
Diffstat (limited to 'src/dhtu')
-rw-r--r-- | src/dhtu/plugin_dhtu_ip.c | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c index 2f6d6161e..612d2c119 100644 --- a/src/dhtu/plugin_dhtu_ip.c +++ b/src/dhtu/plugin_dhtu_ip.c | |||
@@ -567,6 +567,51 @@ create_source (struct Plugin *plugin, | |||
567 | 567 | ||
568 | 568 | ||
569 | /** | 569 | /** |
570 | * Compare two addresses excluding the ports for equality. Only compares IP | ||
571 | * address. Must only be called on AF_INET or AF_INET6 addresses. | ||
572 | * | ||
573 | * @param a1 address to compare | ||
574 | * @param a2 address to compare | ||
575 | * @param alen number of bytes in @a a1 and @a a2 | ||
576 | * @return 0 if @a a1 == @a a2. | ||
577 | */ | ||
578 | static int | ||
579 | addrcmp_np (const struct sockaddr *a1, | ||
580 | const struct sockaddr *a2, | ||
581 | size_t alen) | ||
582 | { | ||
583 | GNUNET_assert (a1->sa_family == a2->sa_family); | ||
584 | switch (a1->sa_family) | ||
585 | { | ||
586 | case AF_INET: | ||
587 | GNUNET_assert (sizeof (struct sockaddr_in) == alen); | ||
588 | { | ||
589 | const struct sockaddr_in *s1 = (const struct sockaddr_in *) a1; | ||
590 | const struct sockaddr_in *s2 = (const struct sockaddr_in *) a2; | ||
591 | |||
592 | if (s1->sin_addr.s_addr != s2->sin_addr.s_addr) | ||
593 | return 1; | ||
594 | break; | ||
595 | } | ||
596 | case AF_INET6: | ||
597 | GNUNET_assert (sizeof (struct sockaddr_in6) == alen); | ||
598 | { | ||
599 | const struct sockaddr_in6 *s1 = (const struct sockaddr_in6 *) a1; | ||
600 | const struct sockaddr_in6 *s2 = (const struct sockaddr_in6 *) a2; | ||
601 | |||
602 | if (0 != GNUNET_memcmp (&s1->sin6_addr, | ||
603 | &s2->sin6_addr)) | ||
604 | return 1; | ||
605 | break; | ||
606 | } | ||
607 | default: | ||
608 | GNUNET_assert (0); | ||
609 | } | ||
610 | return 0; | ||
611 | } | ||
612 | |||
613 | |||
614 | /** | ||
570 | * Compare two addresses for equality. Only | 615 | * Compare two addresses for equality. Only |
571 | * compares IP address and port. Must only be | 616 | * compares IP address and port. Must only be |
572 | * called on AF_INET or AF_INET6 addresses. | 617 | * called on AF_INET or AF_INET6 addresses. |
@@ -601,6 +646,7 @@ addrcmp (const struct sockaddr *a1, | |||
601 | { | 646 | { |
602 | const struct sockaddr_in6 *s1 = (const struct sockaddr_in6 *) a1; | 647 | const struct sockaddr_in6 *s1 = (const struct sockaddr_in6 *) a1; |
603 | const struct sockaddr_in6 *s2 = (const struct sockaddr_in6 *) a2; | 648 | const struct sockaddr_in6 *s2 = (const struct sockaddr_in6 *) a2; |
649 | |||
604 | if (s1->sin6_port != s2->sin6_port) | 650 | if (s1->sin6_port != s2->sin6_port) |
605 | return 1; | 651 | return 1; |
606 | if (0 != GNUNET_memcmp (&s1->sin6_addr, | 652 | if (0 != GNUNET_memcmp (&s1->sin6_addr, |
@@ -644,9 +690,9 @@ process_ifcs (void *cls, | |||
644 | src = src->next) | 690 | src = src->next) |
645 | { | 691 | { |
646 | if ( (addrlen == src->addrlen) && | 692 | if ( (addrlen == src->addrlen) && |
647 | (0 == addrcmp (addr, | 693 | (0 == addrcmp_np (addr, |
648 | (const struct sockaddr *) &src->addr, | 694 | (const struct sockaddr *) &src->addr, |
649 | addrlen)) ) | 695 | addrlen)) ) |
650 | { | 696 | { |
651 | src->scan_generation = plugin->scan_generation; | 697 | src->scan_generation = plugin->scan_generation; |
652 | return GNUNET_OK; | 698 | return GNUNET_OK; |
@@ -706,7 +752,7 @@ scan (void *cls) | |||
706 | src = next) | 752 | src = next) |
707 | { | 753 | { |
708 | next = src->next; | 754 | next = src->next; |
709 | if (src->scan_generation == plugin->scan_generation) | 755 | if (src->scan_generation >= plugin->scan_generation) |
710 | continue; | 756 | continue; |
711 | GNUNET_CONTAINER_DLL_remove (plugin->src_head, | 757 | GNUNET_CONTAINER_DLL_remove (plugin->src_head, |
712 | plugin->src_tail, | 758 | plugin->src_tail, |
@@ -831,6 +877,9 @@ read_cb (void *cls) | |||
831 | src = find_source (plugin, | 877 | src = find_source (plugin, |
832 | &sa, | 878 | &sa, |
833 | sizeof (sa)); | 879 | sizeof (sa)); |
880 | /* For sources we discovered by reading, | ||
881 | force the generation far into the future */ | ||
882 | src->scan_generation = plugin->scan_generation + 60; | ||
834 | } | 883 | } |
835 | break; | 884 | break; |
836 | } | 885 | } |
@@ -859,6 +908,9 @@ read_cb (void *cls) | |||
859 | src = find_source (plugin, | 908 | src = find_source (plugin, |
860 | &sa, | 909 | &sa, |
861 | sizeof (sa)); | 910 | sizeof (sa)); |
911 | /* For sources we discovered by reading, | ||
912 | force the generation far into the future */ | ||
913 | src->scan_generation = plugin->scan_generation + 60; | ||
862 | break; | 914 | break; |
863 | } | 915 | } |
864 | } | 916 | } |