-improve indentation, reduce duplication of PIDs in core's neighbour map
[oweals/gnunet.git] / src / identity / gnunet-service-identity.c
index c61286bd51c163be5940089284affc9c5d262274..5d2d22a0ab6ed8e889354818284f569e83a3887d 100644 (file)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  (C) 2013 Christian Grothoff (and other contributing authors)
+  Copyright (C) 2013 Christian Grothoff (and other contributing authors)
 
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
   You should have received a copy of the GNU General Public License
   along with GNUnet; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-  Boston, MA 02111-1307, USA.
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
  */
 
 /**
@@ -58,7 +58,7 @@ struct Ego
   /**
    * Private key of the ego.
    */
-  struct GNUNET_CRYPTO_EccPrivateKey *pk;
+  struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
 
   /**
    * String identifier for the ego.
@@ -161,6 +161,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   {
     GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, e);
     GNUNET_free (e->pk);
+    GNUNET_free (e->identifier);
     GNUNET_free (e);
   }
 }
@@ -345,7 +346,8 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client,
     {
       sdm = create_set_default_message (ego,
                                        name);
-      GNUNET_SERVER_notification_context_broadcast (nc, &sdm->header, GNUNET_NO);
+      GNUNET_SERVER_notification_context_unicast (nc, client,
+                                                  &sdm->header, GNUNET_NO);
       GNUNET_free (sdm);
       GNUNET_SERVER_receive_done (client, GNUNET_OK);
       GNUNET_free (identifier);
@@ -370,10 +372,10 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client,
  * @return 0 if the keys are equal
  */
 static int
-key_cmp (const struct GNUNET_CRYPTO_EccPrivateKey *pk1,
-        const struct GNUNET_CRYPTO_EccPrivateKey *pk2)
+key_cmp (const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1,
+        const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk2)
 {
-  return memcmp (pk1, pk2, sizeof (struct GNUNET_CRYPTO_EccPrivateKey));
+  return memcmp (pk1, pk2, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey));
 }
 
 
@@ -517,7 +519,7 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
     }
   }
   ego = GNUNET_new (struct Ego);
-  ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
+  ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey);
   *ego->pk = crm->private_key;
   ego->identifier = GNUNET_strdup (str);
   GNUNET_CONTAINER_DLL_insert (ego_head,
@@ -526,10 +528,10 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
   send_result_code (client, 0, NULL);
   fn = get_ego_filename (ego);
   (void) GNUNET_DISK_directory_create_for_file (fn);
-  if (sizeof (struct GNUNET_CRYPTO_EccPrivateKey) !=
+  if (sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey) !=
       GNUNET_DISK_fn_write (fn,
                            &crm->private_key,
-                           sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
+                           sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
                            GNUNET_DISK_PERM_USER_READ |
                            GNUNET_DISK_PERM_USER_WRITE))
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
@@ -819,15 +821,15 @@ process_ego_file (void *cls,
     return GNUNET_OK;
   }
   ego = GNUNET_new (struct Ego);
-  ego->pk = GNUNET_CRYPTO_ecc_key_create_from_file (filename);
+  ego->pk = GNUNET_CRYPTO_ecdsa_key_create_from_file (filename);
   if (NULL == ego->pk)
-    {
-      GNUNET_free (ego);
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 _("Failed to parse ego information in `%s'\n"),
-                 filename);
-      return GNUNET_OK;
-    }
+  {
+    GNUNET_free (ego);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                _("Failed to parse ego information in `%s'\n"),
+                filename);
+    return GNUNET_OK;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Loaded ego `%s'\n",
              fn + 1);