[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: RECLAIM: cleanup, comments
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: RECLAIM: cleanup, comments |
Date: |
Thu, 02 May 2019 11:27:26 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 70824dc00 RECLAIM: cleanup, comments
70824dc00 is described below
commit 70824dc0035428da3ec00ef7e6aca48eb1302527
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Thu May 2 11:27:09 2019 +0200
RECLAIM: cleanup, comments
---
src/include/gnunet_reclaim_attribute_lib.h | 103 ++++---
src/include/gnunet_reclaim_attribute_plugin.h | 47 +--
src/include/gnunet_reclaim_service.h | 26 +-
.../plugin_reclaim_attribute_gnuid.c | 60 ++--
src/reclaim-attribute/reclaim_attribute.c | 208 +++++++++----
src/reclaim-attribute/reclaim_attribute.h | 3 +
src/reclaim/gnunet-service-reclaim.c | 328 ++++++++++++++++++---
src/reclaim/reclaim_api.c | 1 +
8 files changed, 584 insertions(+), 192 deletions(-)
diff --git a/src/include/gnunet_reclaim_attribute_lib.h
b/src/include/gnunet_reclaim_attribute_lib.h
index db009da3f..e96937ea8 100644
--- a/src/include/gnunet_reclaim_attribute_lib.h
+++ b/src/include/gnunet_reclaim_attribute_lib.h
@@ -24,16 +24,15 @@
* @file
* Identity attribute definitions
*
- * @defgroup identity-provider Identity Provider service
+ * @defgroup reclaim-attribute reclaim attributes
* @{
*/
#ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H
#define GNUNET_RECLAIM_ATTRIBUTE_LIB_H
#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
@@ -52,7 +51,6 @@ extern "C"
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1
-
/**
* An attribute.
*/
@@ -76,7 +74,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim
* The name of the attribute. Note "name" must never be individually
* free'd
*/
- const char* name;
+ const char *name;
/**
* Number of bytes in @e data.
@@ -89,9 +87,12 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim
* existing data area.
*/
const void *data;
-
};
+
+/**
+ * A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
+ */
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList
{
/**
@@ -105,6 +106,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail;
};
+
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
{
/**
@@ -123,6 +125,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
};
+
/**
* Create a new attribute claim.
*
@@ -133,9 +136,9 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
* @return the new attribute
*/
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name,
+GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
uint32_t type,
- const void* data,
+ const void *data,
size_t data_size);
@@ -143,57 +146,73 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name,
* Get required size for serialization buffer
*
* @param attrs the attribute list to serialize
- *
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct
GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
+ const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+
+/**
+ * Destroy claim list
+ *
+ * @param attrs list to destroy
+ */
void
-GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct
GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+GNUNET_RECLAIM_ATTRIBUTE_list_destroy (
+ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
+
+/**
+ * Add a new attribute to a claim list
+ *
+ * @param attr_name the name of the new attribute claim
+ * @param type the type of the claim
+ * @param data claim payload
+ * @param data_size claim payload size
+ */
void
-GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList
*attrs,
- const char* attr_name,
- uint32_t type,
- const void* data,
- size_t data_size);
+GNUNET_RECLAIM_ATTRIBUTE_list_add (
+ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ const char *attr_name,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
+
/**
* Serialize an attribute list
*
* @param attrs the attribute list to serialize
* @param result the serialized attribute
- *
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct
GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
- char *result);
+GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
+ const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ char *result);
+
/**
* Deserialize an attribute list
*
* @param data the serialized attribute list
* @param data_size the length of the serialized data
- *
* @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
*/
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
-GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char* data,
- size_t data_size);
+GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size);
/**
* Get required size for serialization buffer
*
* @param attr the attribute to serialize
- *
* @return the required buffer size
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct
GNUNET_RECLAIM_ATTRIBUTE_Claim *attr);
-
+GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (
+ const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr);
/**
@@ -201,12 +220,13 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct
GNUNET_RECLAIM_ATTRIBU
*
* @param attr the attribute to serialize
* @param result the serialized attribute
- *
* @return length of serialized data
*/
size_t
-GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct
GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- char *result);
+GNUNET_RECLAIM_ATTRIBUTE_serialize (
+ const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
+ char *result);
+
/**
* Deserialize an attribute
@@ -217,11 +237,18 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct
GNUNET_RECLAIM_ATTRIBUTE_Claim
* @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
*/
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char* data,
- size_t data_size);
+GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size);
+
+
+/**
+ * Make a (deep) copy of a claim list
+ * @param attrs claim list to copy
+ * @return copied claim list
+ */
+struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
+GNUNET_RECLAIM_ATTRIBUTE_list_dup (
+ const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
-struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList*
-GNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct
GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
/**
* Convert a type name to the corresponding number
@@ -248,6 +275,7 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
void **data,
size_t *data_size);
+
/**
* Convert the 'claim' of an attribute to a string
*
@@ -258,20 +286,21 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
*/
char *
GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
- const void* data,
+ 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*
+const char *
GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type);
-#if 0 /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
@@ -282,6 +311,6 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type);
/* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
#endif
-/** @} */ /* end of group identity */
+/** @} */ /* end of group reclaim-attribute */
/* end of gnunet_reclaim_attribute_lib.h */
diff --git a/src/include/gnunet_reclaim_attribute_plugin.h
b/src/include/gnunet_reclaim_attribute_plugin.h
index 0dfd69b82..c05c80b07 100644
--- a/src/include/gnunet_reclaim_attribute_plugin.h
+++ b/src/include/gnunet_reclaim_attribute_plugin.h
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -22,10 +22,9 @@
* @author Martin Schanzenbach
*
* @file
- * Plugin API for the idp database backend
+ * Plugin API for reclaim attribute types
*
- * @defgroup identity-provider-plugin IdP service plugin API
- * Plugin API for the idp database backend
+ * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims
* @{
*/
#ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
@@ -35,9 +34,8 @@
#include "gnunet_reclaim_attribute_lib.h"
#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
@@ -53,10 +51,11 @@ extern "C"
* @param data_size number of bytes in @a data
* @return NULL on error, otherwise human-readable representation of the value
*/
-typedef char * (*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (void *cls,
- uint32_t type,
- const void *data,
- size_t data_size);
+typedef char *(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (
+ void *cls,
+ uint32_t type,
+ const void *data,
+ size_t data_size);
/**
@@ -71,11 +70,12 @@ typedef char *
(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (void *cls,
* @param data_size set to number of bytes in @a data
* @return #GNUNET_OK on success
*/
-typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (void *cls,
- uint32_t type,
- const char *s,
- void **data,
- size_t *data_size);
+typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (
+ void *cls,
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size);
/**
@@ -86,8 +86,9 @@ typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction)
(void *cls,
* @param typename name to convert
* @return corresponding number, UINT32_MAX on error
*/
-typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (void
*cls,
- const char
*typename);
+typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (
+ void *cls,
+ const char *typename);
/**
@@ -98,8 +99,9 @@ typedef uint32_t
(*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (void *cls
* @param type number of a type to convert
* @return corresponding typestring, NULL on error
*/
-typedef const char * (*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction)
(void *cls,
- uint32_t
type);
+typedef const char *(*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) (
+ void *cls,
+ uint32_t type);
/**
@@ -133,11 +135,10 @@ struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions
* Number to typename.
*/
GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename;
-
};
-#if 0 /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
@@ -146,4 +147,4 @@ struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions
#endif
-/** @} */ /* end of group */
+/** @} */ /* end of group */
diff --git a/src/include/gnunet_reclaim_service.h
b/src/include/gnunet_reclaim_service.h
index fc3d0f920..8d7babd7c 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -22,9 +22,10 @@
* @author Martin Schanzenbach
*
* @file
- * Identity provider service; implements identity provider for GNUnet
+ * reclaim service; implements identity and personal data sharing
+ * for GNUnet
*
- * @defgroup reclaim Identity Provider service
+ * @defgroup reclaim service
* @{
*/
#ifndef GNUNET_RECLAIM_SERVICE_H
@@ -43,7 +44,7 @@ extern "C" {
/**
* Version number of the re:claimID API.
*/
-#define GNUNET_RECLAIM_VERSION 0x00000000
+#define GNUNET_RECLAIM_VERSION 0x00000001
/**
* Opaque handle to access the service.
@@ -58,10 +59,10 @@ struct GNUNET_RECLAIM_Operation;
/**
- * The an authorization ticket. This ticket is meant to be transferred
- * out of band the a relying party.
+ * The authorization ticket. This ticket is meant to be transferred
+ * out of band to a relying party.
* The contents of a ticket must be protected and should be treated as a
- * SHARED SECRET between user and relying party.
+ * shared secret between user and relying party.
*/
struct GNUNET_RECLAIM_Ticket
{
@@ -84,8 +85,8 @@ struct GNUNET_RECLAIM_Ticket
/**
* Method called when a token has been issued.
- * On success returns a ticket that can be given to the relying party to
retrive
- * the token
+ * On success returns a ticket that can be given to a relying party
+ * in order for it retrive identity attributes
*
* @param cls closure
* @param ticket the ticket
@@ -133,7 +134,7 @@ GNUNET_RECLAIM_connect (const struct
GNUNET_CONFIGURATION_Handle *cfg);
* Store an attribute. If the attribute is already present,
* it is replaced with the new attribute.
*
- * @param h handle to the re:claimID service
+ * @param h handle to the reclaim service
* @param pkey Private key of the identity to add an attribute to
* @param attr The attribute
* @param exp_interval The relative expiration interval for the attribute
@@ -246,6 +247,7 @@ GNUNET_RECLAIM_ticket_issue (
const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
GNUNET_RECLAIM_TicketCallback cb, void *cb_cls);
+
/**
* Revoked an issued ticket. The relying party will be unable to retrieve
* attributes. Other issued tickets remain unaffected.
@@ -286,6 +288,7 @@ GNUNET_RECLAIM_ticket_consume (
const struct GNUNET_RECLAIM_Ticket *ticket,
GNUNET_RECLAIM_AttributeResult cb, void *cb_cls);
+
/**
* Lists all tickets that have been issued to remote
* identites (relying parties)
@@ -321,6 +324,7 @@ GNUNET_RECLAIM_ticket_iteration_start (
void
GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator
*it);
+
/**
* Stops iteration and releases the handle for further calls. Must
* be called on any iteration that has not yet completed prior to calling
@@ -331,6 +335,7 @@ GNUNET_RECLAIM_ticket_iteration_next (struct
GNUNET_RECLAIM_TicketIterator *it);
void
GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator
*it);
+
/**
* Disconnect from identity provider service.
*
@@ -351,6 +356,7 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h);
void
GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
@@ -362,6 +368,6 @@ GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op);
/* ifndef GNUNET_RECLAIM_SERVICE_H */
#endif
-/** @} */ /* end of group identity */
+/** @} */ /* end of group reclaim */
/* end of gnunet_reclaim_service.h */
diff --git a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
index 4d506fe67..bd0bb1741 100644
--- a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
+++ b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -20,8 +20,9 @@
/**
* @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c
- * @brief identity attribute plugin to provide the API for fundamental
- * attribute types.
+ * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API
for
+ * fundamental
+ * attribute types.
*
* @author Martin Schanzenbach
*/
@@ -42,9 +43,9 @@
*/
static char *
gnuid_value_to_string (void *cls,
- uint32_t type,
- const void *data,
- size_t data_size)
+ uint32_t type,
+ const void *data,
+ size_t data_size)
{
switch (type)
@@ -70,22 +71,22 @@ gnuid_value_to_string (void *cls,
*/
static int
gnuid_string_to_value (void *cls,
- uint32_t type,
- const char *s,
- void **data,
- size_t *data_size)
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size)
{
if (NULL == s)
return GNUNET_SYSERR;
switch (type)
{
- case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
- *data = GNUNET_strdup (s);
- *data_size = strlen (s);
- return GNUNET_OK;
- default:
- return GNUNET_SYSERR;
+ case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
+ *data = GNUNET_strdup (s);
+ *data_size = strlen (s);
+ return GNUNET_OK;
+ default:
+ return GNUNET_SYSERR;
}
}
@@ -94,13 +95,12 @@ gnuid_string_to_value (void *cls,
* Mapping of attribute type numbers to human-readable
* attribute type names.
*/
-static struct {
+static struct
+{
const char *name;
uint32_t number;
-} gnuid_name_map[] = {
- { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
- { NULL, UINT32_MAX }
-};
+} gnuid_name_map[] = {{"STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING},
+ {NULL, UINT32_MAX}};
/**
@@ -111,15 +111,13 @@ static struct {
* @return corresponding number, UINT32_MAX on error
*/
static uint32_t
-gnuid_typename_to_number (void *cls,
- const char *gnuid_typename)
+gnuid_typename_to_number (void *cls, const char *gnuid_typename)
{
unsigned int i;
- i=0;
- while ( (NULL != gnuid_name_map[i].name) &&
- (0 != strcasecmp (gnuid_typename,
- gnuid_name_map[i].name)) )
+ i = 0;
+ while ((NULL != gnuid_name_map[i].name) &&
+ (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name)))
i++;
return gnuid_name_map[i].number;
}
@@ -133,14 +131,12 @@ gnuid_typename_to_number (void *cls,
* @return corresponding typestring, NULL on error
*/
static const char *
-gnuid_number_to_typename (void *cls,
- uint32_t type)
+gnuid_number_to_typename (void *cls, uint32_t type)
{
unsigned int i;
- i=0;
- while ( (NULL != gnuid_name_map[i].name) &&
- (type != gnuid_name_map[i].number) )
+ i = 0;
+ while ((NULL != gnuid_name_map[i].name) && (type !=
gnuid_name_map[i].number))
i++;
return gnuid_name_map[i].name;
}
diff --git a/src/reclaim-attribute/reclaim_attribute.c
b/src/reclaim-attribute/reclaim_attribute.c
index b434c386e..6e5f14ddf 100644
--- a/src/reclaim-attribute/reclaim_attribute.c
+++ b/src/reclaim-attribute/reclaim_attribute.c
@@ -24,11 +24,11 @@
* @author Martin Schanzenbach
*/
#include "platform.h"
-
#include "gnunet_util_lib.h"
-
#include "gnunet_reclaim_attribute_plugin.h"
#include "reclaim_attribute.h"
+
+
/**
* Handle for a plugin
*/
@@ -45,23 +45,31 @@ struct Plugin
struct GNUNET_RECLAIM_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
+ *
+ * @param cls closure
+ * @param library_name name of the API library
+ * @param lib_ret the plugin API pointer
*/
static void
add_plugin (void *cls, const char *library_name, void *lib_ret)
@@ -69,7 +77,8 @@ add_plugin (void *cls, const char *library_name, void
*lib_ret)
struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret;
struct Plugin *plugin;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading attribute plugin `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Loading attribute plugin `%s'\n",
library_name);
plugin = GNUNET_new (struct Plugin);
plugin->api = api;
@@ -77,6 +86,7 @@ add_plugin (void *cls, const char *library_name, void
*lib_ret)
GNUNET_array_append (attr_plugins, num_plugins, plugin);
}
+
/**
* Load plugins
*/
@@ -86,10 +96,13 @@ init ()
if (GNUNET_YES == initialized)
return;
initialized = GNUNET_YES;
- GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attribute_", NULL,
- &add_plugin, NULL);
+ GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attribute_",
+ NULL,
+ &add_plugin,
+ NULL);
}
+
/**
* Convert a type name to the corresponding number
*
@@ -104,7 +117,8 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char
*typename)
uint32_t ret;
init ();
- for (i = 0; i < num_plugins; i++) {
+ for (i = 0; i < num_plugins; i++)
+ {
plugin = attr_plugins[i];
if (UINT32_MAX !=
(ret = plugin->api->typename_to_number (plugin->api->cls, typename)))
@@ -113,6 +127,7 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char
*typename)
return UINT32_MAX;
}
+
/**
* Convert a type number to the corresponding type string
*
@@ -127,7 +142,8 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type)
const char *ret;
init ();
- for (i = 0; i < num_plugins; i++) {
+ for (i = 0; i < num_plugins; i++)
+ {
plugin = attr_plugins[i];
if (NULL !=
(ret = plugin->api->number_to_typename (plugin->api->cls, type)))
@@ -136,6 +152,7 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type)
return NULL;
}
+
/**
* Convert human-readable version of a 'claim' of an attribute to the binary
* representation
@@ -147,22 +164,29 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t
type)
* @return #GNUNET_OK on success
*/
int
-GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, const char *s,
- void **data, size_t *data_size)
+GNUNET_RECLAIM_ATTRIBUTE_string_to_value (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++) {
+ 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))
+ 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
*
@@ -172,7 +196,8 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
const char *s,
* @return NULL on error, otherwise human-readable representation of the claim
*/
char *
-GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, const void *data,
+GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
+ const void *data,
size_t data_size)
{
unsigned int i;
@@ -180,15 +205,19 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
const void *data,
char *ret;
init ();
- for (i = 0; i < num_plugins; i++) {
+ 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)))
+ if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
+ type,
+ data,
+ data_size)))
return ret;
}
return NULL;
}
+
/**
* Create a new attribute.
*
@@ -199,8 +228,10 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
const void *data,
* @return the new attribute
*/
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
-GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, uint32_t type,
- const void *data, size_t data_size)
+GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
{
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
char *write_ptr;
@@ -213,7 +244,7 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name,
uint32_t type,
attr->type = type;
attr->data_size = data_size;
attr->version = 0;
- write_ptr = (char *)&attr[1];
+ write_ptr = (char *) &attr[1];
GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
attr->name = write_ptr;
write_ptr += strlen (attr->name) + 1;
@@ -223,32 +254,42 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char
*attr_name, uint32_t type,
return attr;
}
+
/**
- * Add a new claim list entry.
+ * Add a new attribute to a claim list
*
- * @param claim_list the attribute name
- * @param attr_name the attribute name
- * @param type the attribute type
- * @param data the attribute value
- * @param data_size the attribute value size
- * @return
+ * @param attr_name the name of the new attribute claim
+ * @param type the type of the claim
+ * @param data claim payload
+ * @param data_size claim payload size
*/
void
GNUNET_RECLAIM_ATTRIBUTE_list_add (
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list,
- const char *attr_name, uint32_t type, const void *data, size_t data_size)
+ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list,
+ const char *attr_name,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
{
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
le->claim =
- GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
- GNUNET_CONTAINER_DLL_insert (claim_list->list_head, claim_list->list_tail,
+ GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size);
+ GNUNET_CONTAINER_DLL_insert (claim_list->list_head,
+ claim_list->list_tail,
le);
}
+
+/**
+ * Get required size for serialization buffer
+ *
+ * @param attrs the attribute list to serialize
+ * @return the required buffer size
+ */
size_t
GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
+ const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
{
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
size_t len = 0;
@@ -257,9 +298,18 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (
return len;
}
+
+/**
+ * Serialize an attribute list
+ *
+ * @param attrs the attribute list to serialize
+ * @param result the serialized attribute
+ * @return length of serialized data
+ */
size_t
GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
+ const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
+ char *result)
{
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
size_t len;
@@ -268,7 +318,8 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
write_ptr = result;
total_len = 0;
- for (le = attrs->list_head; NULL != le; le = le->next) {
+ for (le = attrs->list_head; NULL != le; le = le->next)
+ {
len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr);
total_len += len;
write_ptr += len;
@@ -276,6 +327,14 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize (
return total_len;
}
+
+/**
+ * Deserialize an attribute list
+ *
+ * @param data the serialized attribute list
+ * @param data_size the length of the serialized data
+ * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
+ */
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size)
{
@@ -289,12 +348,15 @@ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char
*data, size_t data_size)
attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
read_ptr = data;
- while (((data + data_size) - read_ptr) >= sizeof (struct Attribute)) {
+ while (((data + data_size) - read_ptr) >= sizeof (struct Attribute))
+ {
le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (
- read_ptr, data_size - (read_ptr - data));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deserialized attribute %s\n",
+ le->claim =
+ GNUNET_RECLAIM_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_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim);
@@ -303,37 +365,52 @@ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char
*data, size_t data_size)
return attrs;
}
+
+/**
+ * Make a (deep) copy of a claim list
+ * @param attrs claim list to copy
+ * @return copied claim list
+ */
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
GNUNET_RECLAIM_ATTRIBUTE_list_dup (
- const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
+ const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
{
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le;
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result;
result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList);
- for (le = attrs->list_head; NULL != le; le = le->next) {
+ for (le = attrs->list_head; NULL != le; le = le->next)
+ {
result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
- result_le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (
- le->claim->name, le->claim->type, le->claim->data,
- le->claim->data_size);
+ result_le->claim =
+ GNUNET_RECLAIM_ATTRIBUTE_claim_new (le->claim->name,
+ le->claim->type,
+ le->claim->data,
+ le->claim->data_size);
result_le->claim->version = le->claim->version;
result_le->claim->id = le->claim->id;
- GNUNET_CONTAINER_DLL_insert (result->list_head, result->list_tail,
+ GNUNET_CONTAINER_DLL_insert (result->list_head,
+ result->list_tail,
result_le);
}
return result;
}
-void
+/**
+ * Destroy claim list
+ *
+ * @param attrs list to destroy
+ */
GNUNET_RECLAIM_ATTRIBUTE_list_destroy (
- struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
+ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
{
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le;
- for (le = attrs->list_head; NULL != le;) {
+ for (le = attrs->list_head; NULL != le;)
+ {
GNUNET_free (le->claim);
tmp_le = le;
le = le->next;
@@ -342,29 +419,45 @@ GNUNET_RECLAIM_ATTRIBUTE_list_destroy (
GNUNET_free (attrs);
}
+
+/**
+ * Get required size for serialization buffer
+ *
+ * @param attr the attribute to serialize
+ * @return the required buffer size
+ */
size_t
GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
+ const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
{
return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size;
}
+
+/**
+ * Serialize an attribute
+ *
+ * @param attr the attribute to serialize
+ * @param result the serialized attribute
+ * @return length of serialized data
+ */
size_t
GNUNET_RECLAIM_ATTRIBUTE_serialize (
- const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
+ const struct GNUNET_RECLAIM_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 = (struct Attribute *) result;
attr_ser->attribute_type = htons (attr->type);
attr_ser->attribute_version = htonl (attr->version);
attr_ser->attribute_id = GNUNET_htonll (attr->id);
name_len = strlen (attr->name);
attr_ser->name_len = htons (name_len);
- write_ptr = (char *)&attr_ser[1];
+ write_ptr = (char *) &attr_ser[1];
GNUNET_memcpy (write_ptr, attr->name, name_len);
write_ptr += name_len;
// TODO plugin-ize
@@ -377,6 +470,15 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize (
return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size;
}
+
+/**
+ * Deserialize an attribute
+ *
+ * @param data the serialized attribute
+ * @param data_size the length of the serialized data
+ *
+ * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
+ */
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size)
{
@@ -389,7 +491,7 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data,
size_t data_size)
if (data_size < sizeof (struct Attribute))
return NULL;
- attr_ser = (struct Attribute *)data;
+ 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_RECLAIM_ATTRIBUTE_Claim) +
@@ -399,13 +501,13 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data,
size_t data_size)
attr->id = GNUNET_ntohll (attr_ser->attribute_id);
attr->data_size = ntohs (attr_ser->data_size);
- write_ptr = (char *)&attr[1];
+ 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);
+ GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
attr->data = write_ptr;
return attr;
}
diff --git a/src/reclaim-attribute/reclaim_attribute.h
b/src/reclaim-attribute/reclaim_attribute.h
index 773d39c5a..f0c944bdb 100644
--- a/src/reclaim-attribute/reclaim_attribute.h
+++ b/src/reclaim-attribute/reclaim_attribute.h
@@ -28,6 +28,9 @@
#include "gnunet_reclaim_service.h"
+/**
+ * Serialized claim
+ */
struct Attribute
{
/**
diff --git a/src/reclaim/gnunet-service-reclaim.c
b/src/reclaim/gnunet-service-reclaim.c
index d5aeff8d7..6db97fe87 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -24,9 +24,7 @@
*
*/
#include "platform.h"
-
#include "gnunet_util_lib.h"
-
#include "gnunet-service-reclaim_tickets.h"
#include "gnunet_constants.h"
#include "gnunet_gnsrecord_lib.h"
@@ -124,6 +122,7 @@ struct TicketIteration
struct RECLAIM_TICKETS_Iterator *iter;
};
+
/**
* An attribute iteration operation.
*/
@@ -160,6 +159,7 @@ struct AttributeIterator
uint32_t request_id;
};
+
/**
* An idp client
*/
@@ -251,6 +251,9 @@ struct IdpClient
};
+/**
+ * Handle for attribute deletion request
+ */
struct AttributeDeleteHandle
{
/**
@@ -311,6 +314,9 @@ struct AttributeDeleteHandle
};
+/**
+ * Handle for attribute store request
+ */
struct AttributeStoreHandle
{
/**
@@ -359,6 +365,10 @@ struct AttributeStoreHandle
uint32_t r_id;
};
+
+/**
+ * Handle for ticket consume request
+ */
struct ConsumeTicketOperation
{
/**
@@ -387,6 +397,7 @@ struct ConsumeTicketOperation
struct RECLAIM_TICKETS_ConsumeHandle *ch;
};
+
/**
* Updated attribute IDs
*/
@@ -413,6 +424,7 @@ struct TicketAttributeUpdateEntry
uint64_t new_id;
};
+
/**
* Ticket revocation request handle
*/
@@ -444,6 +456,7 @@ struct TicketRevocationOperation
uint32_t r_id;
};
+
/**
* Ticket issue operation handle
*/
@@ -470,6 +483,7 @@ struct TicketIssueOperation
uint32_t r_id;
};
+
/**
* DLL for ego handles to egos containing the RECLAIM_ATTRS in a
* map in json_t format
@@ -498,6 +512,7 @@ struct EgoEntry
struct GNUNET_CONTAINER_MultiHashMap *attr_map;
};
+
/**
* Cleanup task
*/
@@ -517,6 +532,7 @@ cleanup ()
GNUNET_NAMESTORE_disconnect (nsh);
}
+
/**
* Shutdown task
*
@@ -530,6 +546,14 @@ do_shutdown (void *cls)
}
+/**
+ * Sends a ticket result message to the client
+ *
+ * @param client the client to send to
+ * @param r_id the request message ID to reply to
+ * @param ticket the ticket to include (may be NULL)
+ * @param success the success status of the request
+ */
static void
send_ticket_result (const struct IdpClient *client,
uint32_t r_id,
@@ -555,6 +579,15 @@ send_ticket_result (const struct IdpClient *client,
GNUNET_MQ_send (client->mq, env);
}
+
+/**
+ * Issue ticket result
+ *
+ * @param cls out ticket issue operation handle
+ * @param ticket the issued ticket
+ * @param success issue success status (GNUNET_OK if successful)
+ * @param emsg error message (NULL of success is GNUNET_OK)
+ */
static void
issue_ticket_result_cb (void *cls,
struct GNUNET_RECLAIM_Ticket *ticket,
@@ -578,6 +611,14 @@ issue_ticket_result_cb (void *cls,
GNUNET_free (tio);
}
+
+/**
+ * Check issue ticket message
+ *
+ * @cls unused
+ * @im message to check
+ * @return GNUNET_OK if message is ok
+ */
static int
check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
{
@@ -591,6 +632,13 @@ check_issue_ticket_message (void *cls, const struct
IssueTicketMessage *im)
return GNUNET_OK;
}
+
+/**
+ * Handle ticket issue message
+ *
+ * @param cls our client
+ * @param im the message
+ */
static void
handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
{
@@ -615,10 +663,18 @@ handle_issue_ticket_message (void *cls, const struct
IssueTicketMessage *im)
GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
}
+
+
/**********************************************************
* Revocation
**********************************************************/
+/**
+ * Handles revocation result
+ *
+ * @param cls our revocation operation handle
+ * @param success revocation result (GNUNET_OK if successful)
+ */
static void
revoke_result_cb (void *cls, int32_t success)
{
@@ -639,6 +695,13 @@ revoke_result_cb (void *cls, int32_t success)
}
+/**
+ * Check revocation message format
+ *
+ * @param cls unused
+ * @param im the message to check
+ * @return GNUNET_OK if message is ok
+ */
static int
check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im)
{
@@ -652,6 +715,13 @@ check_revoke_ticket_message (void *cls, const struct
RevokeTicketMessage *im)
return GNUNET_OK;
}
+
+/**
+ * Handle a revocation message to a ticket.
+ *
+ * @param cls our client
+ * @param rm the message to handle
+ */
static void
handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
{
@@ -670,19 +740,16 @@ handle_revoke_ticket_message (void *cls, const struct
RevokeTicketMessage *rm)
GNUNET_SERVICE_client_continue (idp->client);
}
-static int
-check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
-{
- uint16_t size;
-
- size = ntohs (cm->header.size);
- if (size <= sizeof (struct ConsumeTicketMessage)) {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
+/**
+ * Handle a ticket consume result
+ *
+ * @param cls our consume ticket operation handle
+ * @param identity the attribute authority
+ * @param attrs the attribute/claim list
+ * @param success GNUNET_OK if successful
+ * @param emsg error message (NULL if success=GNUNET_OK)
+ */
static void
consume_result_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
@@ -716,6 +783,33 @@ consume_result_cb (void *cls,
GNUNET_free (cop);
}
+
+/**
+ * Check a consume ticket message
+ *
+ * @param cls unused
+ * @param cm the message to handle
+ */
+static int
+check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
+{
+ uint16_t size;
+
+ size = ntohs (cm->header.size);
+ if (size <= sizeof (struct ConsumeTicketMessage)) {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Handle a consume ticket message
+ *
+ * @param cls our client handle
+ * @cm the message to handle
+ */
static void
handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage
*cm)
{
@@ -753,6 +847,14 @@ cleanup_as_handle (struct AttributeStoreHandle *ash)
GNUNET_free (ash);
}
+
+/**
+ * Attribute store result handler
+ *
+ * @param cls our attribute store handle
+ * @param success GNUNET_OK if successful
+ * @param emsg error message (NULL if success=GNUNET_OK)
+ */
static void
attr_store_cont (void *cls, int32_t success, const char *emsg)
{
@@ -782,8 +884,9 @@ attr_store_cont (void *cls, int32_t success, const char
*emsg)
cleanup_as_handle (ash);
}
+
/**
- * Adds a new attribute
+ * Add a new attribute
*
* @param cls the AttributeStoreHandle
*/
@@ -823,6 +926,13 @@ attr_store_task (void *cls)
GNUNET_free (buf);
}
+
+/**
+ * Check an attribute store message
+ *
+ * @param cls unused
+ * @param sam the message to check
+ */
static int
check_attribute_store_message (void *cls,
const struct AttributeStoreMessage *sam)
@@ -837,6 +947,13 @@ check_attribute_store_message (void *cls,
return GNUNET_OK;
}
+
+/**
+ * Handle an attribute store message
+ *
+ * @param cls our client
+ * @param sam the message to handle
+ */
static void
handle_attribute_store_message (void *cls,
const struct AttributeStoreMessage *sam)
@@ -863,6 +980,11 @@ handle_attribute_store_message (void *cls,
}
+/**
+ * Cleanup attribute delete handle
+ *
+ * @param adh the attribute to cleanup
+ */
static void
cleanup_adh (struct AttributeDeleteHandle *adh)
{
@@ -889,6 +1011,12 @@ cleanup_adh (struct AttributeDeleteHandle *adh)
}
+/**
+ * Send a deletion success response
+ *
+ * @param adh our attribute deletion handle
+ * @param success the success status
+ */
static void
send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
{
@@ -907,6 +1035,16 @@ send_delete_response (struct AttributeDeleteHandle *adh,
int32_t success)
}
+/**
+ * Namestore iteration within attribute deletion.
+ * We need to reissue tickets with the deleted attribute removed.
+ *
+ * @param cls our attribute deletion handle
+ * @param zone the private key of the ticket issuer
+ * @param label the label of the record
+ * @param rd_count number of records
+ * @param rd record data
+ */
static void
ticket_iter (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
@@ -944,10 +1082,21 @@ ticket_iter (void *cls,
}
+/**
+ * Recursion prototype for function
+ * @param cls our deletion handle
+ */
static void
update_tickets (void *cls);
+/**
+ * Callback called when a ticket was updated
+ *
+ * @param cls our attribute deletion handle
+ * @param success GNUNET_OK if successful
+ * @param emsg error message (NULL if success=GNUNET_OK)
+ */
static void
ticket_updated (void *cls, int32_t success, const char *emsg)
{
@@ -956,6 +1105,14 @@ ticket_updated (void *cls, int32_t success, const char
*emsg)
GNUNET_SCHEDULER_add_now (&update_tickets, adh);
}
+
+/**
+ * Update tickets: Remove shared attribute which has just been deleted.
+ * This method is called recursively until all tickets are processed.
+ * Eventually, the updated tickets are stored using ``update_tickets''.
+ *
+ * @param cls our attribute deletion handle
+ */
static void
update_tickets (void *cls)
{
@@ -1002,6 +1159,11 @@ update_tickets (void *cls)
}
+/**
+ * Done collecting affected tickets, start updating.
+ *
+ * @param cls our attribute deletion handle
+ */
static void
ticket_iter_fin (void *cls)
{
@@ -1011,6 +1173,11 @@ ticket_iter_fin (void *cls)
}
+/**
+ * Error collecting affected tickets. Abort.
+ *
+ * @param cls our attribute deletion handle
+ */
static void
ticket_iter_err (void *cls)
{
@@ -1024,6 +1191,12 @@ ticket_iter_err (void *cls)
}
+/**
+ * Start processing tickets which may still contain reference to deleted
+ * attribute.
+ *
+ * @param cls attribute deletion handle
+ */
static void
start_ticket_update (void *cls)
{
@@ -1039,6 +1212,13 @@ start_ticket_update (void *cls)
}
+/**
+ * Attribute deleted callback
+ *
+ * @param cls our handle
+ * @param success success status
+ * @param emsg error message (NULL if success=GNUNET_OK)
+ */
static void
attr_delete_cont (void *cls, int32_t success, const char *emsg)
{
@@ -1052,11 +1232,17 @@ attr_delete_cont (void *cls, int32_t success, const
char *emsg)
cleanup_adh (adh);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating tickets...\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
}
+/**
+ * Check attribute delete message format
+ *
+ * @cls unused
+ * @dam message to check
+ */
static int
check_attribute_delete_message (void *cls,
const struct AttributeDeleteMessage *dam)
@@ -1072,6 +1258,12 @@ check_attribute_delete_message (void *cls,
}
+/**
+ * Handle attribute deletion
+ *
+ * @param cls our client
+ * @param dam deletion message
+ */
static void
handle_attribute_delete_message (void *cls,
const struct AttributeDeleteMessage *dam)
@@ -1107,24 +1299,12 @@ handle_attribute_delete_message (void *cls,
* Attrubute iteration
*************************************************/
-static void
-cleanup_attribute_iter_handle (struct AttributeIterator *ai)
-{
- GNUNET_free (ai);
-}
-
-static void
-attr_iter_error (void *cls)
-{
- struct AttributeIterator *ai = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
- GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
- ai->client->attr_iter_tail,
- ai);
- cleanup_attribute_iter_handle (ai);
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
-}
+/**
+ * Done iterating over attributes
+ *
+ * @param cls our iterator handle
+ */
static void
attr_iter_finished (void *cls)
{
@@ -1140,9 +1320,33 @@ attr_iter_finished (void *cls)
GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
ai->client->attr_iter_tail,
ai);
- cleanup_attribute_iter_handle (ai);
+ GNUNET_free (ai);
+}
+
+/**
+ * Error iterating over attributes. Abort.
+ *
+ * @param cls our attribute iteration handle
+ */
+static void
+attr_iter_error (void *cls)
+{
+ struct AttributeIterator *ai = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
+ attr_iter_finished (ai);
}
+
+/**
+ * Got record. Return if it is an attribute.
+ *
+ * @param cls our attribute iterator
+ * @param zone zone we are iterating
+ * @param label label of the records
+ * @param rd_count record count
+ * @param rd records
+ */
static void
attr_iter_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
@@ -1177,6 +1381,13 @@ attr_iter_cb (void *cls,
GNUNET_MQ_send (ai->client->mq, env);
}
+
+/**
+ * Iterate over zone to get attributes
+ *
+ * @param cls our client
+ * @param ais_msg the iteration message to start
+ */
static void
handle_iteration_start (void *cls,
const struct AttributeIterationStartMessage *ais_msg)
@@ -1203,6 +1414,13 @@ handle_iteration_start (void *cls,
GNUNET_SERVICE_client_continue (idp->client);
}
+
+/**
+ * Handle iteration stop message from client
+ *
+ * @param cls the client
+ * @param ais_msg the stop message
+ */
static void
handle_iteration_stop (void *cls,
const struct AttributeIterationStopMessage *ais_msg)
@@ -1228,6 +1446,13 @@ handle_iteration_stop (void *cls,
GNUNET_SERVICE_client_continue (idp->client);
}
+
+/**
+ * Client requests next attribute from iterator
+ *
+ * @param cls the client
+ * @param ais_msg the message
+ */
static void
handle_iteration_next (void *cls,
const struct AttributeIterationNextMessage *ais_msg)
@@ -1255,6 +1480,12 @@ handle_iteration_next (void *cls,
* Ticket iteration
******************************************************/
+/**
+ * Got a ticket. Return to client
+ *
+ * @param cls our ticket iterator
+ * @param ticket the ticket
+ */
static void
ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
{
@@ -1281,6 +1512,13 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket
*ticket)
GNUNET_free (ti);
}
+
+/**
+ * Client requests a ticket iteration
+ *
+ * @param cls the client
+ * @param tis_msg the iteration request message
+ */
static void
handle_ticket_iteration_start (
void *cls,
@@ -1303,6 +1541,13 @@ handle_ticket_iteration_start (
GNUNET_SERVICE_client_continue (client->client);
}
+
+/**
+ * Client has had enough tickets
+ *
+ * @param cls the client
+ * @param tis_msg the stop message
+ */
static void
handle_ticket_iteration_stop (void *cls,
const struct TicketIterationStopMessage *tis_msg)
@@ -1331,6 +1576,13 @@ handle_ticket_iteration_stop (void *cls,
GNUNET_SERVICE_client_continue (client->client);
}
+
+/**
+ * Client requests next result.
+ *
+ * @param cls the client
+ * @param tis_msg the message
+ */
static void
handle_ticket_iteration_next (void *cls,
const struct TicketIterationNextMessage *tis_msg)
@@ -1354,6 +1606,7 @@ handle_ticket_iteration_next (void *cls,
GNUNET_SERVICE_client_continue (client->client);
}
+
/**
* Main function that will be run
*
@@ -1400,6 +1653,7 @@ run (void *cls,
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
+
/**
* Called whenever a client is disconnected.
*
@@ -1421,8 +1675,6 @@ client_disconnect_cb (void *cls,
struct AttributeStoreHandle *as;
struct AttributeDeleteHandle *adh;
- // TODO other operations
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
while (NULL != (iss = idp->issue_op_head)) {
@@ -1448,7 +1700,7 @@ client_disconnect_cb (void *cls,
while (NULL != (ai = idp->attr_iter_head)) {
GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
- cleanup_attribute_iter_handle (ai);
+ GNUNET_free (ai);
}
while (NULL != (rop = idp->revoke_op_head)) {
GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail,
rop);
@@ -1465,6 +1717,7 @@ client_disconnect_cb (void *cls,
GNUNET_free (idp);
}
+
/**
* Add a client to our list of active clients.
*
@@ -1486,6 +1739,7 @@ client_connect_cb (void *cls,
return idp;
}
+
/**
* Define "main" method using service macro.
*/
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index e0ca9adf3..2e64a27b6 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -610,6 +610,7 @@ handle_attribute_result (void *cls, const struct
AttributeResultMessage *msg)
GNUNET_assert (0);
}
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: RECLAIM: cleanup, comments,
gnunet <=