-doxygen
[oweals/gnunet.git] / src / transport / test_plugin_transport.c
index 60cc3c94133dc12be7ffe059e6395069c3bd0d9b..98806fbb83362a184f7330cb4fa438dd3fbbc802 100644 (file)
  */
 
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_constants.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet_peerinfo_service.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_protocols.h"
-#include "gnunet_signatures.h"
 #include "gnunet_transport_plugin.h"
-
 #include "transport.h"
 
 /**
 /**
  * Our public key.
  */
-static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
-
-/**
- * Our identity.
- */
 static struct GNUNET_PeerIdentity my_identity;
 
 /**
  * Our private key.
  */
-static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
+static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
 
 /**
  * Our configuration.
@@ -342,6 +333,7 @@ env_notify_address (void *cls,
                     const char *plugin)
 {
   struct AddressWrapper *w;
+  struct AddressWrapper *wtmp;
   void *s2a;
   size_t s2a_len;
 
@@ -351,6 +343,16 @@ env_notify_address (void *cls,
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Adding address of length %u\n", addrlen);
 
+      for (wtmp = head; NULL != wtmp; wtmp = wtmp->next)
+      {
+       if ((addrlen == wtmp->addrlen) && (0 == memcmp (addr, wtmp->addr, addrlen)))
+       {
+               GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Duplicate address notification .... \n");
+                       return;
+       }
+      }
+
       w = GNUNET_new (struct AddressWrapper);
       w->addr = GNUNET_malloc (addrlen);
       w->addrlen = addrlen;
@@ -496,7 +498,7 @@ env_get_our_hello ()
 }
 
 
-static void 
+static void
 env_session_end (void *cls,
                 const struct GNUNET_PeerIdentity *peer,
                 struct Session * session)
@@ -578,6 +580,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                "Could not create statistics.  Exiting.\n");
+    GNUNET_free (keyfile);
     end_badly_now ();
     return;
   }
@@ -614,7 +617,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
 
   max_connect_per_transport = (uint32_t) tneigh;
-  my_private_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
+  my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile);
   GNUNET_free (keyfile);
   if (NULL == my_private_key)
   {
@@ -623,12 +626,9 @@ run (void *cls, char *const *args, const char *cfgfile,
     end_badly_now ();
     return;
   }
-  GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key);
-  GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
-                      &my_identity.hashPubKey);
-
+  GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_identity.public_key);
 
-  hello = GNUNET_HELLO_create(&my_public_key, NULL, NULL, GNUNET_NO);
+  hello = GNUNET_HELLO_create (&my_identity.public_key, NULL, NULL, GNUNET_NO);
 
   /* load plugins... */
   setup_plugin_environment ();