2 This file is part of GNUnet.
3 Copyright (C) 2017 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Martin Schanzenbach
25 * Identity attribute definitions
27 * @defgroup identity-provider Identity Provider service
30 #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H
31 #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_util_lib.h"
47 #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE 0
52 #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1
59 struct GNUNET_RECLAIM_ATTRIBUTE_Claim
76 * The name of the attribute. Note "name" must never be individually
82 * Number of bytes in @e data.
87 * Binary value stored as attribute value. Note: "data" must never
88 * be individually 'malloc'ed, but instead always points into some
95 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList
100 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_head;
105 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail;
108 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
113 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *prev;
118 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *next;
121 * The attribute claim
123 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
127 * Create a new attribute claim.
129 * @param attr_name the attribute name
130 * @param type the attribute type
131 * @param data the attribute value
132 * @param data_size the attribute value size
133 * @return the new attribute
135 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
136 GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name,
143 * Get required size for serialization buffer
145 * @param attrs the attribute list to serialize
147 * @return the required buffer size
150 GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
153 GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
156 GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
157 const char* attr_name,
163 * Serialize an attribute list
165 * @param attrs the attribute list to serialize
166 * @param result the serialized attribute
168 * @return length of serialized data
171 GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
175 * Deserialize an attribute list
177 * @param data the serialized attribute list
178 * @param data_size the length of the serialized data
180 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
182 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *
183 GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char* data,
188 * Get required size for serialization buffer
190 * @param attr the attribute to serialize
192 * @return the required buffer size
195 GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr);
200 * Serialize an attribute
202 * @param attr the attribute to serialize
203 * @param result the serialized attribute
205 * @return length of serialized data
208 GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
212 * Deserialize an attribute
214 * @param data the serialized attribute
215 * @param data_size the length of the serialized data
217 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
219 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *
220 GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char* data,
223 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList*
224 GNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
227 * Convert a type name to the corresponding number
229 * @param typename name to convert
230 * @return corresponding number, UINT32_MAX on error
233 GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename);
236 * Convert human-readable version of a 'claim' of an attribute to the binary
239 * @param type type of the claim
240 * @param s human-readable string
241 * @param data set to value in binary encoding (will be allocated)
242 * @param data_size set to number of bytes in @a data
243 * @return #GNUNET_OK on success
246 GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type,
252 * Convert the 'claim' of an attribute to a string
254 * @param type the type of attribute
255 * @param data claim in binary encoding
256 * @param data_size number of bytes in @a data
257 * @return NULL on error, otherwise human-readable representation of the claim
260 GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type,
265 * Convert a type number to the corresponding type string
267 * @param type number of a type
268 * @return corresponding typestring, NULL on error
271 GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type);
274 #if 0 /* keep Emacsens' auto-indent happy */
282 /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */
285 /** @} */ /* end of group identity */
287 /* end of gnunet_reclaim_attribute_lib.h */