From a9a7ac802811e76e33b54040bf31f00ea9438cea Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Sat, 2 Dec 2017 22:32:28 +0100 Subject: -refactored --- src/identity-attribute/identity_attribute.c | 245 ++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 src/identity-attribute/identity_attribute.c (limited to 'src/identity-attribute/identity_attribute.c') diff --git a/src/identity-attribute/identity_attribute.c b/src/identity-attribute/identity_attribute.c new file mode 100644 index 0000000000..377eb3211a --- /dev/null +++ b/src/identity-attribute/identity_attribute.c @@ -0,0 +1,245 @@ +/* + This file is part of GNUnet + Copyright (C) 2010-2015 GNUnet e.V. + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +/** + * @file identity-provider/identity_attribute.c + * @brief helper library to manage identity attributes + * @author Martin Schanzenbach + */ +#include "platform.h" +#include "gnunet_util_lib.h" +#include "identity_attribute.h" + +/** + * Create a new attribute. + * + * @param name the attribute name + * @param type the attribute type + * @param data the attribute value + * @param data_size the attribute value size + * @return the new attribute + */ +struct GNUNET_IDENTITY_ATTRIBUTE_Claim * +GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name, + uint32_t attr_type, + const void* data, + size_t data_size) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr; + char *write_ptr; + + attr = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_ATTRIBUTE_Claim) + + strlen (attr_name) + 1 + + data_size); + attr->type = attr_type; + attr->data_size = data_size; + attr->version = 0; + write_ptr = (char*)&attr[1]; + GNUNET_memcpy (write_ptr, + attr_name, + strlen (attr_name) + 1); + attr->name = write_ptr; + write_ptr += strlen (attr->name) + 1; + GNUNET_memcpy (write_ptr, + data, + data_size); + attr->data = write_ptr; + return attr; +} + +size_t +GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; + size_t len = 0; + for (le = attrs->list_head; NULL != le; le = le->next) + len += GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (le->claim); + return len; +} + +size_t +GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, + char *result) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; + size_t len; + size_t total_len; + char* write_ptr; + + write_ptr = result; + total_len = 0; + for (le = attrs->list_head; NULL != le; le = le->next) + { + len = GNUNET_IDENTITY_ATTRIBUTE_serialize (le->claim, + write_ptr); + total_len += len; + write_ptr += len; + } + return total_len; +} + +struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList * +GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data, + size_t data_size) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; + size_t attr_len; + const char* read_ptr; + + if (data_size < sizeof (struct Attribute)) + return NULL; + + attrs = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); + read_ptr = data; + while (((data + data_size) - read_ptr) >= sizeof (struct Attribute)) + { + + le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); + le->claim = GNUNET_IDENTITY_ATTRIBUTE_deserialize (read_ptr, + data_size - (read_ptr - data)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Deserialized attribute %s\n", le->claim->name); + GNUNET_CONTAINER_DLL_insert (attrs->list_head, + attrs->list_tail, + le); + attr_len = GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (le->claim); + read_ptr += attr_len; + } + return attrs; +} + +struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList* +GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *result_le; + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *result; + size_t len; + + result = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); + for (le = attrs->list_head; NULL != le; le = le->next) + { + result_le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); + len = sizeof (struct GNUNET_IDENTITY_ATTRIBUTE_Claim) + le->claim->data_size; + result_le->claim = GNUNET_malloc (len); + GNUNET_memcpy (result_le->claim, + le->claim, + len); + result_le->claim->name = (const char*)&result_le->claim[1]; + GNUNET_CONTAINER_DLL_insert (result->list_head, + result->list_tail, + result_le); + } + return result; +} + + +void +GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; + struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *tmp_le; + + for (le = attrs->list_head; NULL != le;) + { + GNUNET_free (le->claim); + tmp_le = le; + le = le->next; + GNUNET_free (tmp_le); + } + GNUNET_free (attrs); + +} + +size_t +GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) +{ + return sizeof (struct Attribute) + + strlen (attr->name) + + attr->data_size; +} + +size_t +GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr, + char *result) +{ + size_t data_len_ser; + size_t name_len; + struct Attribute *attr_ser; + char* write_ptr; + + attr_ser = (struct Attribute*)result; + attr_ser->attribute_type = htons (attr->type); + attr_ser->attribute_version = htonl (attr->version); + name_len = strlen (attr->name); + attr_ser->name_len = htons (name_len); + write_ptr = (char*)&attr_ser[1]; + GNUNET_memcpy (write_ptr, attr->name, name_len); + write_ptr += name_len; + //TODO plugin-ize + //data_len_ser = plugin->serialize_attribute_value (attr, + // &attr_ser[1]); + data_len_ser = attr->data_size; + GNUNET_memcpy (write_ptr, attr->data, attr->data_size); + attr_ser->data_size = htons (data_len_ser); + + return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; +} + +struct GNUNET_IDENTITY_ATTRIBUTE_Claim * +GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data, + size_t data_size) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr; + struct Attribute *attr_ser; + size_t data_len; + size_t name_len; + char* write_ptr; + + if (data_size < sizeof (struct Attribute)) + return NULL; + + attr_ser = (struct Attribute*)data; + data_len = ntohs (attr_ser->data_size); + name_len = ntohs (attr_ser->name_len); + attr = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_ATTRIBUTE_Claim) + + data_len + name_len + 1); + attr->type = ntohs (attr_ser->attribute_type); + attr->version = ntohl (attr_ser->attribute_version); + attr->data_size = ntohs (attr_ser->data_size); + + write_ptr = (char*)&attr[1]; + GNUNET_memcpy (write_ptr, + &attr_ser[1], + name_len); + write_ptr[name_len] = '\0'; + attr->name = write_ptr; + + write_ptr += name_len + 1; + GNUNET_memcpy (write_ptr, + (char*)&attr_ser[1] + name_len, + attr->data_size); + attr->data = write_ptr; + return attr; + +} + +/* end of identity_attribute.c */ -- cgit v1.2.3-70-g09d2 From f485d0399e8ef0c388a321bbad7ae424935752bc Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Mon, 4 Dec 2017 16:37:28 +0100 Subject: -fix makefile --- po/POTFILES.in | 2 +- src/identity-attribute/Makefile.am | 2 +- src/identity-attribute/identity_attribute.c | 176 ++++++++++++++++++++++++++++ src/identity-provider/gnunet-idp.c | 12 +- src/include/gnunet_identity_attribute_lib.h | 45 +++++++ 5 files changed, 231 insertions(+), 6 deletions(-) (limited to 'src/identity-attribute/identity_attribute.c') diff --git a/po/POTFILES.in b/po/POTFILES.in index b06eb3a9f7..01c197fcd4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -197,7 +197,7 @@ src/hostlist/gnunet-daemon-hostlist.c src/hostlist/gnunet-daemon-hostlist_client.c src/hostlist/gnunet-daemon-hostlist_server.c src/identity-attribute/identity_attribute.c -src/identity-attribute/plugin_identity_attribute_type_gnuid.c +src/identity-attribute/plugin_identity_attribute_gnuid.c src/identity-provider/gnunet-idp.c src/identity-provider/gnunet-service-identity-provider.c src/identity-provider/identity_provider_api.c diff --git a/src/identity-attribute/Makefile.am b/src/identity-attribute/Makefile.am index 770bc2ead2..5835453443 100644 --- a/src/identity-attribute/Makefile.am +++ b/src/identity-attribute/Makefile.am @@ -38,7 +38,7 @@ libgnunet_plugin_identity_attribute_gnuid_la_SOURCES = \ libgnunet_plugin_identity_attribute_gnuid_la_LIBADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(LTLIBINTL) -libgnunet_plugin_gnsrecord_dns_la_LDFLAGS = \ +libgnunet_plugin_identity_attribute_gnuid_la_LDFLAGS = \ $(GN_PLUGIN_LDFLAGS) diff --git a/src/identity-attribute/identity_attribute.c b/src/identity-attribute/identity_attribute.c index 377eb3211a..05cdcdaf02 100644 --- a/src/identity-attribute/identity_attribute.c +++ b/src/identity-attribute/identity_attribute.c @@ -26,6 +26,182 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "identity_attribute.h" +#include "gnunet_identity_attribute_plugin.h" + +/** + * Handle for a plugin + */ +struct Plugin +{ + /** + * Name of the plugin + */ + char *library_name; + + /** + * Plugin API + */ + struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api; +}; + +/** + * Plugins + */ +static struct Plugin **attr_plugins; + +/** + * Number of plugins + */ +static unsigned int num_plugins; + +/** + * Init canary + */ +static int initialized; + +/** + * Add a plugin + */ +static void +add_plugin (void* cls, + const char *library_name, + void *lib_ret) +{ + struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api = lib_ret; + struct Plugin *plugin; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Loading attribute plugin `%s'\n", + library_name); + plugin = GNUNET_new (struct Plugin); + plugin->api = api; + plugin->library_name = GNUNET_strdup (library_name); + GNUNET_array_append (attr_plugins, num_plugins, plugin); +} + +/** + * Load plugins + */ +static void +init() +{ + if (GNUNET_YES == initialized) + return; + initialized = GNUNET_YES; + GNUNET_PLUGIN_load_all ("libgnunet_plugin_attribute_", NULL, + &add_plugin, NULL); +} + +/** + * Convert a type name to the corresponding number + * + * @param typename name to convert + * @return corresponding number, UINT32_MAX on error + */ +uint32_t +GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename) +{ + unsigned int i; + struct Plugin *plugin; + uint32_t ret; + + init (); + for (i = 0; i < num_plugins; i++) + { + plugin = attr_plugins[i]; + if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls, + typename))) + return ret; + } + return UINT32_MAX; +} + +/** + * Convert a type number to the corresponding type string + * + * @param type number of a type + * @return corresponding typestring, NULL on error + */ +const char* +GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type) +{ + unsigned int i; + struct Plugin *plugin; + const char *ret; + + init (); + for (i = 0; i < num_plugins; i++) + { + plugin = attr_plugins[i]; + if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls, + type))) + return ret; + } + return NULL; +} + +/** + * Convert human-readable version of a 'claim' of an attribute to the binary + * representation + * + * @param type type of the claim + * @param s human-readable string + * @param data set to value in binary encoding (will be allocated) + * @param data_size set to number of bytes in @a data + * @return #GNUNET_OK on success + */ +int +GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type, + const char *s, + void **data, + size_t *data_size) +{ + unsigned int i; + struct Plugin *plugin; + + init (); + for (i = 0; i < num_plugins; i++) + { + plugin = attr_plugins[i]; + if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls, + type, + s, + data, + data_size)) + return GNUNET_OK; + } + return GNUNET_SYSERR; +} + +/** + * Convert the 'claim' of an attribute to a string + * + * @param type the type of attribute + * @param data claim in binary encoding + * @param data_size number of bytes in @a data + * @return NULL on error, otherwise human-readable representation of the claim + */ +char * +GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type, + const void* data, + size_t data_size) +{ + unsigned int i; + struct Plugin *plugin; + char *ret; + + init(); + for (i = 0; i < num_plugins; i++) + { + plugin = attr_plugins[i]; + if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls, + type, + data, + data_size))) + return ret; + } + return NULL; +} /** * Create a new attribute. diff --git a/src/identity-provider/gnunet-idp.c b/src/identity-provider/gnunet-idp.c index 18a5676c0d..78da1cb4d1 100644 --- a/src/identity-provider/gnunet-idp.c +++ b/src/identity-provider/gnunet-idp.c @@ -168,6 +168,7 @@ process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) { + char *claim; if (NULL == identity) { GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); @@ -178,8 +179,11 @@ process_attrs (void *cls, ret = 1; return; } + claim = GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (attr->type, + attr->data, + attr->data_size); GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "%s: %s\n", attr->name, (char*)attr->data); + "%s: %s\n", attr->name, claim); } @@ -245,9 +249,9 @@ iter_finished (void *cls) return; } attr = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name, - GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, - attr_value, - strlen (attr_value) + 1); + GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, + attr_value, + strlen (attr_value) + 1); idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle, pkey, attr, diff --git a/src/include/gnunet_identity_attribute_lib.h b/src/include/gnunet_identity_attribute_lib.h index 039b50351b..4e32c2ae11 100644 --- a/src/include/gnunet_identity_attribute_lib.h +++ b/src/include/gnunet_identity_attribute_lib.h @@ -213,7 +213,52 @@ GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data, struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList* GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); +/** + * Convert a type name to the corresponding number + * + * @param typename name to convert + * @return corresponding number, UINT32_MAX on error + */ +uint32_t +GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename); + +/** + * Convert human-readable version of a 'claim' of an attribute to the binary + * representation + * + * @param type type of the claim + * @param s human-readable string + * @param data set to value in binary encoding (will be allocated) + * @param data_size set to number of bytes in @a data + * @return #GNUNET_OK on success + */ +int +GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type, + const char *s, + void **data, + size_t *data_size); +/** + * Convert the 'claim' of an attribute to a string + * + * @param type the type of attribute + * @param data claim in binary encoding + * @param data_size number of bytes in @a data + * @return NULL on error, otherwise human-readable representation of the claim + */ +char * +GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type, + const void* data, + size_t data_size); + +/** + * Convert a type number to the corresponding type string + * + * @param type number of a type + * @return corresponding typestring, NULL on error + */ +const char* +GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type); #if 0 /* keep Emacsens' auto-indent happy */ { -- cgit v1.2.3-70-g09d2 From 02861d7594513ad336f86ff20162a861489f20b1 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Mon, 4 Dec 2017 17:10:54 +0100 Subject: -fix --- src/identity-attribute/identity_attribute.c | 6 ++-- .../plugin_identity_attribute_gnuid.c | 4 +-- src/identity-provider/gnunet-idp.c | 40 +++++++++++++++++----- src/include/gnunet_identity_attribute_lib.h | 4 +-- 4 files changed, 38 insertions(+), 16 deletions(-) (limited to 'src/identity-attribute/identity_attribute.c') diff --git a/src/identity-attribute/identity_attribute.c b/src/identity-attribute/identity_attribute.c index 05cdcdaf02..a8aae6ced7 100644 --- a/src/identity-attribute/identity_attribute.c +++ b/src/identity-attribute/identity_attribute.c @@ -88,7 +88,7 @@ init() if (GNUNET_YES == initialized) return; initialized = GNUNET_YES; - GNUNET_PLUGIN_load_all ("libgnunet_plugin_attribute_", NULL, + GNUNET_PLUGIN_load_all ("libgnunet_plugin_identity_attribute_", NULL, &add_plugin, NULL); } @@ -151,7 +151,7 @@ GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type) * @return #GNUNET_OK on success */ int -GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type, +GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size) @@ -182,7 +182,7 @@ GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type, * @return NULL on error, otherwise human-readable representation of the claim */ char * -GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type, +GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type, const void* data, size_t data_size) { diff --git a/src/identity-attribute/plugin_identity_attribute_gnuid.c b/src/identity-attribute/plugin_identity_attribute_gnuid.c index ba460d0a57..0ff44d1993 100644 --- a/src/identity-attribute/plugin_identity_attribute_gnuid.c +++ b/src/identity-attribute/plugin_identity_attribute_gnuid.c @@ -153,7 +153,7 @@ gnuid_number_to_typename (void *cls, * @return the exported block API */ void * -libgnunet_plugin_attribute_type_gnuid_init (void *cls) +libgnunet_plugin_identity_attribute_gnuid_init (void *cls) { struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api; @@ -173,7 +173,7 @@ libgnunet_plugin_attribute_type_gnuid_init (void *cls) * @return NULL */ void * -libgnunet_plugin_attribute_type_gnuid_done (void *cls) +libgnunet_plugin_identity_attribute_gnuid_done (void *cls) { struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api = cls; diff --git a/src/identity-provider/gnunet-idp.c b/src/identity-provider/gnunet-idp.c index 78da1cb4d1..62f07842b9 100644 --- a/src/identity-provider/gnunet-idp.c +++ b/src/identity-provider/gnunet-idp.c @@ -66,6 +66,11 @@ static char* issue_attrs; */ static char* consume_ticket; +/** + * Attribute type + */ +static char* type_str; + /** * Ticket to revoke */ @@ -168,7 +173,7 @@ process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) { - char *claim; + char *value_str; if (NULL == identity) { GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); @@ -179,11 +184,11 @@ process_attrs (void *cls, ret = 1; return; } - claim = GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (attr->type, + value_str = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (attr->type, attr->data, attr->data_size); GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "%s: %s\n", attr->name, claim); + "%s: %s\n", attr->name, value_str); } @@ -211,7 +216,10 @@ process_rvk (void *cls, int success, const char* msg) static void iter_finished (void *cls) { - struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr; + struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim; + char *data; + size_t data_size; + int type; attr_iterator = NULL; if (list) @@ -248,13 +256,22 @@ iter_finished (void *cls) NULL); return; } - attr = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name, - GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, - attr_value, - strlen (attr_value) + 1); + if (NULL == type_str) + type = GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING; + else + type = GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (type_str); + + GNUNET_assert (GNUNET_SYSERR != GNUNET_IDENTITY_ATTRIBUTE_string_to_value (type, + attr_value, + (void**)&data, + &data_size)); + claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name, + type, + data, + data_size); idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle, pkey, - attr, + claim, &store_attr_cont, NULL); @@ -408,6 +425,11 @@ main(int argc, char *const argv[]) NULL, gettext_noop ("Revoke a ticket"), &revoke_ticket), + GNUNET_GETOPT_option_string ('t', + "type", + NULL, + gettext_noop ("Type of attribute"), + &type_str), GNUNET_GETOPT_OPTION_END }; GNUNET_PROGRAM_run (argc, argv, "ct", diff --git a/src/include/gnunet_identity_attribute_lib.h b/src/include/gnunet_identity_attribute_lib.h index 4e32c2ae11..a43b509da4 100644 --- a/src/include/gnunet_identity_attribute_lib.h +++ b/src/include/gnunet_identity_attribute_lib.h @@ -233,7 +233,7 @@ GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename); * @return #GNUNET_OK on success */ int -GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type, +GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size); @@ -247,7 +247,7 @@ GNUNET_IDENTITY_ATTRIBUTE_string_to_claim (uint32_t type, * @return NULL on error, otherwise human-readable representation of the claim */ char * -GNUNET_IDENTITY_ATTRIBUTE_claim_to_string (uint32_t type, +GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type, const void* data, size_t data_size); -- cgit v1.2.3-70-g09d2