From ec19c1e316efdd29a7af0524fc2ff33cc4b19d09 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Jan 2022 12:22:04 +0100 Subject: DHT: modify API and protocol messages to add path signatures, except for now the actual signatures are just placeholders (signing and signature verification are missing) --- src/include/gnunet_datacache_lib.h | 23 ++++++++++++----------- src/include/gnunet_datacache_plugin.h | 2 +- src/include/gnunet_dht_service.h | 34 +++++++++++++++++++++++++++------- src/include/gnunet_strings_lib.h | 12 ------------ 4 files changed, 40 insertions(+), 31 deletions(-) (limited to 'src/include') diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h index 519c36bb4..11076e3e7 100644 --- a/src/include/gnunet_datacache_lib.h +++ b/src/include/gnunet_datacache_lib.h @@ -39,6 +39,7 @@ #include "gnunet_util_lib.h" #include "gnunet_block_lib.h" +#include "gnunet_dht_service.h" #ifdef __cplusplus extern "C" @@ -89,15 +90,15 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h); * @param path_info a path through the network * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort */ -typedef int -(*GNUNET_DATACACHE_Iterator) (void *cls, - const struct GNUNET_HashCode *key, - size_t data_size, - const char *data, - enum GNUNET_BLOCK_Type type, - struct GNUNET_TIME_Absolute exp, - unsigned int path_info_len, - const struct GNUNET_PeerIdentity *path_info); +typedef enum GNUNET_GenericReturnValue +(*GNUNET_DATACACHE_Iterator)(void *cls, + const struct GNUNET_HashCode *key, + size_t data_size, + const char *data, + enum GNUNET_BLOCK_Type type, + struct GNUNET_TIME_Absolute exp, + unsigned int path_info_len, + const struct GNUNET_DHT_PathElement *path_info); /** @@ -114,7 +115,7 @@ typedef int * @param path_info a path through the network * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate */ -int +enum GNUNET_GenericReturnValue GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, const struct GNUNET_HashCode *key, uint32_t xor_distance, @@ -123,7 +124,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, - const struct GNUNET_PeerIdentity *path_info); + const struct GNUNET_DHT_PathElement *path_info); /** diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h index 5d5cac12c..24570be72 100644 --- a/src/include/gnunet_datacache_plugin.h +++ b/src/include/gnunet_datacache_plugin.h @@ -124,7 +124,7 @@ struct GNUNET_DATACACHE_PluginFunctions enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, - const struct GNUNET_PeerIdentity *path_info); + const struct GNUNET_DHT_PathElement *path_info); /** diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index 15da9ecdd..d33ef2f0d 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h @@ -257,7 +257,9 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph); * @param get_path_length number of entries in @a get_path * @param put_path peers on the PUT path (or NULL if not recorded) * [0] = origin, [length - 1] = datastore - * @param put_path_length number of entries in @a put_path + * @param put_path_length number of entries in @a put_path, + * note that the last signature will be all zeros as + * we did not forward and thus did not sign! * @param type type of the result * @param size number of bytes in @a data * @param data pointer to the result data @@ -266,9 +268,9 @@ typedef void (*GNUNET_DHT_GetIterator) (void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, - const struct GNUNET_PeerIdentity *get_path, + const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, - const struct GNUNET_PeerIdentity *put_path, + const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, @@ -343,6 +345,8 @@ struct GNUNET_DHT_MonitorHandle; * @param hop_count Hop count so far. * @param path_length number of entries in @a path (or 0 if not recorded). * @param path peers on the GET path (or NULL if not recorded). + * note that the last signature will be all zeros as + * we did not forward and thus did not sign! * @param desired_replication_level Desired replication level. * @param key Key of the requested data. */ @@ -353,7 +357,7 @@ typedef void uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, - const struct GNUNET_PeerIdentity *path, + const struct GNUNET_DHT_PathElement *path, const struct GNUNET_HashCode *key); @@ -363,6 +367,8 @@ typedef void * @param cls Closure. * @param type The type of data in the result. * @param get_path Peers on GET path (or NULL if not recorded). + * note that the last signature will be all zeros as + * we did not forward and thus did not sign! * @param get_path_length number of entries in @a get_path. * @param put_path peers on the PUT path (or NULL if not recorded). * @param put_path_length number of entries in @a get_path. @@ -374,9 +380,9 @@ typedef void typedef void (*GNUNET_DHT_MonitorGetRespCB) (void *cls, enum GNUNET_BLOCK_Type type, - const struct GNUNET_PeerIdentity *get_path, + const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, - const struct GNUNET_PeerIdentity *put_path, + const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, @@ -393,6 +399,8 @@ typedef void * @param hop_count Hop count so far. * @param path_length number of entries in @a path (or 0 if not recorded). * @param path peers on the PUT path (or NULL if not recorded). + * note that the last signature will be all zeros as + * we did not forward and thus did not sign! * @param desired_replication_level Desired replication level. * @param exp Expiration time of the data. * @param key Key under which data is to be stored. @@ -406,7 +414,7 @@ typedef void uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, - const struct GNUNET_PeerIdentity *path, + const struct GNUNET_DHT_PathElement *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, @@ -446,6 +454,18 @@ void GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); +/** + * Convert a peer path to a human-readable string. + * + * @param path array of path elements to convert to a string + * @param num_pids length of the @a pids array + * @return string representing the array of @a pids + */ +char * +GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, + unsigned int path_len); + + #if 0 /* keep Emacsens' auto-indent happy */ { #endif diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index 2e0c720ee..ef9d5ac58 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h @@ -456,18 +456,6 @@ GNUNET_STRINGS_urldecode (const char *data, char **out); -/** - * Convert a peer path to a human-readable string. - * - * @param pids array of PIDs to convert to a string - * @param num_pids length of the @a pids array - * @return string representing the array of @a pids - */ -char * -GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids, - unsigned int num_pids); - - /** * Parse a path that might be an URI. * -- cgit v1.2.3