* @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
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1
-
/**
* An attribute.
*/
* 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.
* existing data area.
*/
const void *data;
-
};
+
+/**
+ * A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
+ */
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList
{
/**
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail;
};
+
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
{
/**
struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
};
+
/**
* Create a new attribute claim.
*
* @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);
* 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);
/**
*
* @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
* @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
void **data,
size_t *data_size);
+
/**
* Convert the 'claim' of an attribute to a string
*
*/
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
/* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
#endif
-/** @} */ /* end of group identity */
+/** @} */ /* end of group reclaim-attribute */
/* end of gnunet_reclaim_attribute_lib.h */
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/>.
* @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
#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
* @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);
/**
* @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);
/**
* @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);
/**
* @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);
/**
* 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
#endif
-/** @} */ /* end of group */
+/** @} */ /* end of group */
* @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
/**
* Version number of the re:claimID API.
*/
-#define GNUNET_RECLAIM_VERSION 0x00000000
+#define GNUNET_RECLAIM_VERSION 0x00000001
/**
* Opaque handle to access the service.
/**
- * 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
{
/**
* 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
* 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
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.
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)
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
void
GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it);
+
/**
* Disconnect from identity provider service.
*
void
GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
/* ifndef GNUNET_RECLAIM_SERVICE_H */
#endif
-/** @} */ /* end of group identity */
+/** @} */ /* end of group reclaim */
/* end of gnunet_reclaim_service.h */
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/>.
/**
* @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
*/
*/
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)
*/
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;
}
}
* 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}};
/**
* @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;
}
* @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;
}
* @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
*/
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)
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;
GNUNET_array_append (attr_plugins, num_plugins, plugin);
}
+
/**
* Load plugins
*/
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
*
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)))
return UINT32_MAX;
}
+
/**
* Convert a type number to the corresponding type string
*
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)))
return NULL;
}
+
/**
* Convert human-readable version of a 'claim' of an attribute to the binary
* representation
* @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
*
* @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;
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.
*
* @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;
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;
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;
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;
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;
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)
{
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);
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;
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
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)
{
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) +
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;
}
#include "gnunet_reclaim_service.h"
+/**
+ * Serialized claim
+ */
struct Attribute
{
/**
*
*/
#include "platform.h"
-
#include "gnunet_util_lib.h"
-
#include "gnunet-service-reclaim_tickets.h"
#include "gnunet_constants.h"
#include "gnunet_gnsrecord_lib.h"
struct RECLAIM_TICKETS_Iterator *iter;
};
+
/**
* An attribute iteration operation.
*/
uint32_t request_id;
};
+
/**
* An idp client
*/
};
+/**
+ * Handle for attribute deletion request
+ */
struct AttributeDeleteHandle
{
/**
};
+/**
+ * Handle for attribute store request
+ */
struct AttributeStoreHandle
{
/**
uint32_t r_id;
};
+
+/**
+ * Handle for ticket consume request
+ */
struct ConsumeTicketOperation
{
/**
struct RECLAIM_TICKETS_ConsumeHandle *ch;
};
+
/**
* Updated attribute IDs
*/
uint64_t new_id;
};
+
/**
* Ticket revocation request handle
*/
uint32_t r_id;
};
+
/**
* Ticket issue operation handle
*/
uint32_t r_id;
};
+
/**
* DLL for ego handles to egos containing the RECLAIM_ATTRS in a
* map in json_t format
struct GNUNET_CONTAINER_MultiHashMap *attr_map;
};
+
/**
* Cleanup task
*/
GNUNET_NAMESTORE_disconnect (nsh);
}
+
/**
* Shutdown task
*
}
+/**
+ * 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,
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,
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)
{
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)
{
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)
{
}
+/**
+ * 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)
{
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)
{
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,
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)
{
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)
{
cleanup_as_handle (ash);
}
+
/**
- * Adds a new attribute
+ * Add a new attribute
*
* @param cls the AttributeStoreHandle
*/
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)
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)
}
+/**
+ * Cleanup attribute delete handle
+ *
+ * @param adh the attribute to cleanup
+ */
static void
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)
{
}
+/**
+ * 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,
}
+/**
+ * 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)
{
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)
{
}
+/**
+ * Done collecting affected tickets, start updating.
+ *
+ * @param cls our attribute deletion handle
+ */
static void
ticket_iter_fin (void *cls)
{
}
+/**
+ * Error collecting affected tickets. Abort.
+ *
+ * @param cls our attribute deletion handle
+ */
static void
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)
{
}
+/**
+ * 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)
{
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)
}
+/**
+ * Handle attribute deletion
+ *
+ * @param cls our client
+ * @param dam deletion message
+ */
static void
handle_attribute_delete_message (void *cls,
const struct AttributeDeleteMessage *dam)
* 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)
{
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,
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)
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)
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)
* 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)
{
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,
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)
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)
GNUNET_SERVICE_client_continue (client->client);
}
+
/**
* Main function that will be run
*
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
+
/**
* Called whenever a client is disconnected.
*
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)) {
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);
GNUNET_free (idp);
}
+
/**
* Add a client to our list of active clients.
*
return idp;
}
+
/**
* Define "main" method using service macro.
*/
GNUNET_assert (0);
}
+
/**
* Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT