Use Network Security Services SHA1 hash to calculate hash of joining members.
This hash is printed to the user in hex.
Signed-off-by: Steven Dake <sdake(a)redhat.com>
---
src/d1htedra.c | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/d1htedra.c b/src/d1htedra.c
index 68eef63..1bd72f3 100644
--- a/src/d1htedra.c
+++ b/src/d1htedra.c
@@ -41,6 +41,7 @@
#include <sys/time.h>
#include <sys/poll.h>
#include <limits.h>
+#include <nss3/sechash.h>
#include "logsys.h"
@@ -148,6 +149,8 @@ struct d1htedra_instance {
void *d1htnet_context;
struct d1ht_config *d1ht_config;
+
+ HASHContext *hash;
};
struct message_handlers {
@@ -342,6 +345,8 @@ int d1htedra_initialize (
main_deliver_fn,
main_iface_change_fn);
+ instance->hash = HASH_Create (HASH_AlgSHA1);
+
*srp_context = instance;
return (0);
@@ -393,7 +398,10 @@ static inline void member_add (
struct d1ht_ip_address *addr)
{
uint32_t i;
-
+ unsigned char result[20];
+ uint32_t result_len;
+ char result_string[128];
+
/*
* Prevent duplicate membership additions
*/
@@ -402,9 +410,16 @@ static inline void member_add (
return;
}
}
-
- log_printf (LOGSYS_LEVEL_NOTICE, "JOINED member (%s)\n",
- d1htip_print (addr));
+ HASH_Begin (instance->hash);
+ HASH_Update (instance->hash, (const unsigned char*)addr,
+ sizeof (struct d1ht_ip_address));
+ HASH_End (instance->hash, result, &result_len, 20);
+ for (i = 0; i < 20; i++) {
+ sprintf (&result_string[i*2], "%02x", result[i]);
+ }
+
+ log_printf (LOGSYS_LEVEL_NOTICE, "JOINED member (%s) hash(%s)\n",
+ d1htip_print (addr), result_string);
memcpy (&instance->my_member_list[instance->my_member_count],
addr, sizeof (struct d1ht_ip_address));
instance->my_member_count++;
--
1.6.2.5