aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/experimentation/gnunet-daemon-experimentation.h8
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_experiments.c56
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_nodes.c27
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_storage.c1
4 files changed, 55 insertions, 37 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h
index cfcedcd13a..9886f5d5d5 100644
--- a/src/experimentation/gnunet-daemon-experimentation.h
+++ b/src/experimentation/gnunet-daemon-experimentation.h
@@ -174,6 +174,14 @@ struct Node
struct NodeComCtx *e_req_head;
struct NodeComCtx *e_req_tail;
+
+ /**
+ * Array of issuers accepted by this neighbor.
+ */
+ struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id;
+
+ unsigned int issuer_count;
+
};
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c
index 3c00b72ab5..b4db5188b1 100644
--- a/src/experimentation/gnunet-daemon-experimentation_experiments.c
+++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c
@@ -105,11 +105,11 @@ free_issuer (void *cls,
* @return #GNUNET_YES or #GNUNET_NO
*/
int
-GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_id)
+GED_experiments_issuer_accepted (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id)
{
struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (issuer_id, sizeof (struct GNUNET_PeerIdentity), &hash);
+ GNUNET_CRYPTO_hash (issuer_id, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), &hash);
if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &hash))
return GNUNET_YES;
return GNUNET_NO;
@@ -121,14 +121,14 @@ GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_id)
* experiment map.
*/
static void
-get_experment_key (const struct GNUNET_PeerIdentity *issuer,
- const char *name,
- const struct GNUNET_TIME_Absolute version,
- struct GNUNET_HashCode *key)
+get_experiment_key (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
+ const char *name,
+ const struct GNUNET_TIME_Absolute version,
+ struct GNUNET_HashCode *key)
{
GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_kdf (key, sizeof (struct GNUNET_HashCode),
- issuer, sizeof (struct GNUNET_PeerIdentity),
+ issuer, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
name, strlen (name),
&version, sizeof (version),
NULL, 0));
@@ -144,11 +144,11 @@ get_experment_key (const struct GNUNET_PeerIdentity *issuer,
* @return the experiment or NULL if not found
*/
struct Experiment *
-GED_experiments_find (const struct GNUNET_PeerIdentity *issuer,
+GED_experiments_find (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
const char *name,
const struct GNUNET_TIME_Absolute version)
{
- struct GNUENT_HashCode hc;
+ struct GNUNET_HashCode hc;
get_experiment_key (issuer,
name,
@@ -177,10 +177,10 @@ get_it (void *cls,
struct GetCtx *get_ctx = cls;
struct Experiment *e = value;
- if (0 == memcmp (e->issuer,
+ if (0 == memcmp (&e->issuer,
get_ctx->issuer,
- sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))
- get_ctx->get_cb (get_ctx->n, e);
+ sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)))
+ get_ctx->get_cb (get_ctx->n, e);
return GNUNET_OK;
}
@@ -210,7 +210,7 @@ GED_experiments_get (struct Node *n,
int
GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
const char *name,
- const struct GNUNET_CRYPTO_EccPublicKey *issuer_id,
+ const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id,
struct GNUNET_TIME_Absolute version,
char *description,
uint32_t required_capabilities,
@@ -220,10 +220,11 @@ GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
struct GNUNET_TIME_Absolute stop)
{
struct Experiment *e;
+ struct GNUNET_HashCode hc;
e = GNUNET_new (struct Experiment);
e->name = GNUNET_strdup (name);
- e->issuer = issuer_id;
+ e->issuer = *issuer_id;
e->version = version;
if (NULL != description)
e->description = GNUNET_strdup (description);
@@ -252,8 +253,12 @@ GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
GNUNET_STRINGS_absolute_time_to_string (stop),
(long long unsigned int) frequency.rel_value_us / 1000000LL,
(long long unsigned int) duration.rel_value_us / 1000000LL);
+ get_experiment_key (&e->issuer,
+ name,
+ version,
+ &hc);
GNUNET_CONTAINER_multihashmap_put (experiments,
- &e->issuer.hashPubKey,
+ &hc,
e,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_STATISTICS_set (GED_stats,
@@ -279,7 +284,7 @@ exp_file_iterator (void *cls,
char *val;
unsigned long long number;
/* Experiment values */
- struct GNUNET_PeerIdentity issuer;
+ struct GNUNET_CRYPTO_EccPublicSignKey issuer;
struct GNUNET_TIME_Absolute version;
char *description;
uint32_t required_capabilities;
@@ -287,6 +292,7 @@ exp_file_iterator (void *cls,
struct GNUNET_TIME_Absolute stop;
struct GNUNET_TIME_Relative frequency;
struct GNUNET_TIME_Relative duration;
+ struct GNUNET_HashCode phash;
/* Mandatory fields */
@@ -297,14 +303,18 @@ exp_file_iterator (void *cls,
_("Experiment `%s': Issuer missing\n"), name);
return;
}
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (val, &issuer.hashPubKey))
+ if (GNUNET_SYSERR ==
+ GNUNET_CRYPTO_ecc_public_sign_key_from_string (val,
+ strlen (val),
+ &issuer))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Experiment `%s': Issuer invalid\n"), name);
GNUNET_free (val);
return;
}
- if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &issuer.hashPubKey)))
+ GNUNET_CRYPTO_hash (&issuer, sizeof (issuer), &phash);
+ if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &phash)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Experiment `%s': Issuer not accepted!\n"), name);
@@ -353,7 +363,7 @@ exp_file_iterator (void *cls,
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value_us))
stop = GNUNET_TIME_UNIT_FOREVER_ABS;
- GNUNET_EXPERIMENTATION_experiments_add (i, name, issuer, version,
+ GNUNET_EXPERIMENTATION_experiments_add (i, name, &issuer, version,
description, required_capabilities,
start, frequency, duration, stop);
GNUNET_free_non_null (description);
@@ -395,10 +405,8 @@ GED_experiments_start ()
struct Issuer *i;
char *issuers;
char *file;
- char *pubkey;
char *pos;
- struct GNUNET_PeerIdentity issuer_ID;
- struct GNUNET_CRYPTO_EccPublicSignKey pub;
+ struct GNUNET_CRYPTO_EccPublicSignKey issuer_ID;
struct GNUNET_HashCode hash;
/* Load valid issuer */
@@ -417,13 +425,13 @@ GED_experiments_start ()
valid_issuers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " "))
{
- if (GNUNET_SYSERR == GNUNET_CRYPTO_ecc_public_sign_key_from_string (pos,
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_ecc_public_sign_key_from_string (pos,
strlen (pos),
&issuer_ID))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"EXPERIMENTATION",
- "ISSUERS"
+ "ISSUERS",
_("Invalid value for public key\n"));
GED_experiments_stop ();
return GNUNET_SYSERR;
diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c
index 2c8a0418e4..5e29f5f73d 100644
--- a/src/experimentation/gnunet-daemon-experimentation_nodes.c
+++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c
@@ -471,7 +471,8 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
struct Node *n;
struct NodeComCtx *e_ctx;
const struct Experimentation_Request *rm = (const struct Experimentation_Request *) message;
- const struct Experimentation_Issuer *rmi = (const struct Experimentation_Issuer *) &rm[1];
+ const struct GNUNET_CRYPTO_EccPublicSignKey *rmi = (const struct GNUNET_CRYPTO_EccPublicSignKey *) &rm[1];
+ unsigned int my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers);
int c1;
int c2;
uint32_t ic;
@@ -484,7 +485,8 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
return;
}
ic = ntohl (rm->issuer_count);
- if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Issuer))
+ if (ntohs (message->size) !=
+ sizeof (struct Experimentation_Request) + ic * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))
{
GNUNET_break (0);
return;
@@ -528,20 +530,20 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
ic_accepted = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1]))
ic_accepted ++;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Request from peer `%s' with %u issuers, we accepted %u issuer \n",
GNUNET_i2s (peer), ic, ic_accepted);
GNUNET_free_non_null (n->issuer_id);
- n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity));
+ n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey));
c2 = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GED_experiments_issuer_accepted (&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted (&rmi[c1]))
{
- n->issuer_id[c2] = rmi[c1].issuer_id;
+ n->issuer_id[c2] = rmi[c1];
c2 ++;
}
}
@@ -554,7 +556,8 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
e_ctx = GNUNET_new (struct NodeComCtx);
e_ctx->n = n;
e_ctx->e = NULL;
- e_ctx->size = sizeof (struct Experimentation_Response) + GSE_my_issuer_count * sizeof (struct Experimentation_Issuer);
+ e_ctx->size = sizeof (struct Experimentation_Response) +
+ my_issuer_count * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey);
e_ctx->notify = &send_response_cb;
e_ctx->notify_cls = n;
@@ -574,7 +577,7 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
{
struct Node *n;
const struct Experimentation_Response *rm = (const struct Experimentation_Response *) message;
- const struct Experimentation_Issuer *rmi = (const struct Experimentation_Issuer *) &rm[1];
+ const struct GNUNET_CRYPTO_EccPublicSignKey *rmi = (const struct GNUNET_CRYPTO_EccPublicSignKey *) &rm[1];
uint32_t ic;
uint32_t ic_accepted;
int make_active;
@@ -587,7 +590,7 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
return;
}
ic = ntohl (rm->issuer_count);
- if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct Experimentation_Issuer))
+ if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))
{
GNUNET_break (0);
return;
@@ -636,7 +639,7 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
ic_accepted = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1]))
ic_accepted ++;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -647,9 +650,9 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
c2 = 0;
for (c1 = 0; c1 < ic; c1++)
{
- if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id))
+ if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1]))
{
- n->issuer_id[c2] = rmi[c1].issuer_id;
+ n->issuer_id[c2] = rmi[c1];
c2 ++;
}
}
diff --git a/src/experimentation/gnunet-daemon-experimentation_storage.c b/src/experimentation/gnunet-daemon-experimentation_storage.c
index 641915e660..8c6214c7b1 100644
--- a/src/experimentation/gnunet-daemon-experimentation_storage.c
+++ b/src/experimentation/gnunet-daemon-experimentation_storage.c
@@ -25,7 +25,6 @@
* @author Matthias Wachs
*/
#include "platform.h"
-#include "gnunet_getopt_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_core_service.h"
#include "gnunet_statistics_service.h"