diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-05-02 11:27:09 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-05-02 11:27:09 +0200 |
commit | 70824dc0035428da3ec00ef7e6aca48eb1302527 (patch) | |
tree | e3f59870cdfa2c5491da625ee5c6938c64281e52 | |
parent | 8dde46a0133e95c9fa2ba0b525b5d1ebbc75ccec (diff) | |
download | gnunet-70824dc0035428da3ec00ef7e6aca48eb1302527.tar.gz gnunet-70824dc0035428da3ec00ef7e6aca48eb1302527.zip |
RECLAIM: cleanup, comments
-rw-r--r-- | src/include/gnunet_reclaim_attribute_lib.h | 103 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_attribute_plugin.h | 47 | ||||
-rw-r--r-- | src/include/gnunet_reclaim_service.h | 26 | ||||
-rw-r--r-- | src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c | 60 | ||||
-rw-r--r-- | src/reclaim-attribute/reclaim_attribute.c | 208 | ||||
-rw-r--r-- | src/reclaim-attribute/reclaim_attribute.h | 3 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 328 | ||||
-rw-r--r-- | 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 @@ | |||
24 | * @file | 24 | * @file |
25 | * Identity attribute definitions | 25 | * Identity attribute definitions |
26 | * | 26 | * |
27 | * @defgroup identity-provider Identity Provider service | 27 | * @defgroup reclaim-attribute reclaim attributes |
28 | * @{ | 28 | * @{ |
29 | */ | 29 | */ |
30 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H | 30 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
31 | #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H | 31 | #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
32 | 32 | ||
33 | #ifdef __cplusplus | 33 | #ifdef __cplusplus |
34 | extern "C" | 34 | extern "C" { |
35 | { | 35 | #if 0 /* keep Emacsens' auto-indent happy */ |
36 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
37 | } | 36 | } |
38 | #endif | 37 | #endif |
39 | #endif | 38 | #endif |
@@ -52,7 +51,6 @@ extern "C" | |||
52 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 | 51 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 |
53 | 52 | ||
54 | 53 | ||
55 | |||
56 | /** | 54 | /** |
57 | * An attribute. | 55 | * An attribute. |
58 | */ | 56 | */ |
@@ -76,7 +74,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
76 | * The name of the attribute. Note "name" must never be individually | 74 | * The name of the attribute. Note "name" must never be individually |
77 | * free'd | 75 | * free'd |
78 | */ | 76 | */ |
79 | const char* name; | 77 | const char *name; |
80 | 78 | ||
81 | /** | 79 | /** |
82 | * Number of bytes in @e data. | 80 | * Number of bytes in @e data. |
@@ -89,9 +87,12 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
89 | * existing data area. | 87 | * existing data area. |
90 | */ | 88 | */ |
91 | const void *data; | 89 | const void *data; |
92 | |||
93 | }; | 90 | }; |
94 | 91 | ||
92 | |||
93 | /** | ||
94 | * A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures. | ||
95 | */ | ||
95 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList | 96 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList |
96 | { | 97 | { |
97 | /** | 98 | /** |
@@ -105,6 +106,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList | |||
105 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail; | 106 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail; |
106 | }; | 107 | }; |
107 | 108 | ||
109 | |||
108 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | 110 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry |
109 | { | 111 | { |
110 | /** | 112 | /** |
@@ -123,6 +125,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | |||
123 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 125 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
124 | }; | 126 | }; |
125 | 127 | ||
128 | |||
126 | /** | 129 | /** |
127 | * Create a new attribute claim. | 130 | * Create a new attribute claim. |
128 | * | 131 | * |
@@ -133,9 +136,9 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | |||
133 | * @return the new attribute | 136 | * @return the new attribute |
134 | */ | 137 | */ |
135 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 138 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
136 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, | 139 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, |
137 | uint32_t type, | 140 | uint32_t type, |
138 | const void* data, | 141 | const void *data, |
139 | size_t data_size); | 142 | size_t data_size); |
140 | 143 | ||
141 | 144 | ||
@@ -143,57 +146,73 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, | |||
143 | * Get required size for serialization buffer | 146 | * Get required size for serialization buffer |
144 | * | 147 | * |
145 | * @param attrs the attribute list to serialize | 148 | * @param attrs the attribute list to serialize |
146 | * | ||
147 | * @return the required buffer size | 149 | * @return the required buffer size |
148 | */ | 150 | */ |
149 | size_t | 151 | size_t |
150 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 152 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( |
153 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
154 | |||
151 | 155 | ||
156 | /** | ||
157 | * Destroy claim list | ||
158 | * | ||
159 | * @param attrs list to destroy | ||
160 | */ | ||
152 | void | 161 | void |
153 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 162 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( |
163 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
164 | |||
154 | 165 | ||
166 | /** | ||
167 | * Add a new attribute to a claim list | ||
168 | * | ||
169 | * @param attr_name the name of the new attribute claim | ||
170 | * @param type the type of the claim | ||
171 | * @param data claim payload | ||
172 | * @param data_size claim payload size | ||
173 | */ | ||
155 | void | 174 | void |
156 | GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 175 | GNUNET_RECLAIM_ATTRIBUTE_list_add ( |
157 | const char* attr_name, | 176 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
158 | uint32_t type, | 177 | const char *attr_name, |
159 | const void* data, | 178 | uint32_t type, |
160 | size_t data_size); | 179 | const void *data, |
180 | size_t data_size); | ||
181 | |||
161 | 182 | ||
162 | /** | 183 | /** |
163 | * Serialize an attribute list | 184 | * Serialize an attribute list |
164 | * | 185 | * |
165 | * @param attrs the attribute list to serialize | 186 | * @param attrs the attribute list to serialize |
166 | * @param result the serialized attribute | 187 | * @param result the serialized attribute |
167 | * | ||
168 | * @return length of serialized data | 188 | * @return length of serialized data |
169 | */ | 189 | */ |
170 | size_t | 190 | size_t |
171 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 191 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( |
172 | char *result); | 192 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
193 | char *result); | ||
194 | |||
173 | 195 | ||
174 | /** | 196 | /** |
175 | * Deserialize an attribute list | 197 | * Deserialize an attribute list |
176 | * | 198 | * |
177 | * @param data the serialized attribute list | 199 | * @param data the serialized attribute list |
178 | * @param data_size the length of the serialized data | 200 | * @param data_size the length of the serialized data |
179 | * | ||
180 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | 201 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller |
181 | */ | 202 | */ |
182 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | 203 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * |
183 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char* data, | 204 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size); |
184 | size_t data_size); | ||
185 | 205 | ||
186 | 206 | ||
187 | /** | 207 | /** |
188 | * Get required size for serialization buffer | 208 | * Get required size for serialization buffer |
189 | * | 209 | * |
190 | * @param attr the attribute to serialize | 210 | * @param attr the attribute to serialize |
191 | * | ||
192 | * @return the required buffer size | 211 | * @return the required buffer size |
193 | */ | 212 | */ |
194 | size_t | 213 | size_t |
195 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); | 214 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( |
196 | 215 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); | |
197 | 216 | ||
198 | 217 | ||
199 | /** | 218 | /** |
@@ -201,12 +220,13 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBU | |||
201 | * | 220 | * |
202 | * @param attr the attribute to serialize | 221 | * @param attr the attribute to serialize |
203 | * @param result the serialized attribute | 222 | * @param result the serialized attribute |
204 | * | ||
205 | * @return length of serialized data | 223 | * @return length of serialized data |
206 | */ | 224 | */ |
207 | size_t | 225 | size_t |
208 | GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 226 | GNUNET_RECLAIM_ATTRIBUTE_serialize ( |
209 | char *result); | 227 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
228 | char *result); | ||
229 | |||
210 | 230 | ||
211 | /** | 231 | /** |
212 | * Deserialize an attribute | 232 | * Deserialize an attribute |
@@ -217,11 +237,18 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
217 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 237 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
218 | */ | 238 | */ |
219 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 239 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
220 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char* data, | 240 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size); |
221 | size_t data_size); | 241 | |
242 | |||
243 | /** | ||
244 | * Make a (deep) copy of a claim list | ||
245 | * @param attrs claim list to copy | ||
246 | * @return copied claim list | ||
247 | */ | ||
248 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | ||
249 | GNUNET_RECLAIM_ATTRIBUTE_list_dup ( | ||
250 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
222 | 251 | ||
223 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList* | ||
224 | GNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
225 | 252 | ||
226 | /** | 253 | /** |
227 | * Convert a type name to the corresponding number | 254 | * Convert a type name to the corresponding number |
@@ -248,6 +275,7 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, | |||
248 | void **data, | 275 | void **data, |
249 | size_t *data_size); | 276 | size_t *data_size); |
250 | 277 | ||
278 | |||
251 | /** | 279 | /** |
252 | * Convert the 'claim' of an attribute to a string | 280 | * Convert the 'claim' of an attribute to a string |
253 | * | 281 | * |
@@ -258,20 +286,21 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, | |||
258 | */ | 286 | */ |
259 | char * | 287 | char * |
260 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, | 288 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, |
261 | const void* data, | 289 | const void *data, |
262 | size_t data_size); | 290 | size_t data_size); |
263 | 291 | ||
292 | |||
264 | /** | 293 | /** |
265 | * Convert a type number to the corresponding type string | 294 | * Convert a type number to the corresponding type string |
266 | * | 295 | * |
267 | * @param type number of a type | 296 | * @param type number of a type |
268 | * @return corresponding typestring, NULL on error | 297 | * @return corresponding typestring, NULL on error |
269 | */ | 298 | */ |
270 | const char* | 299 | const char * |
271 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); | 300 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); |
272 | 301 | ||
273 | 302 | ||
274 | #if 0 /* keep Emacsens' auto-indent happy */ | 303 | #if 0 /* keep Emacsens' auto-indent happy */ |
275 | { | 304 | { |
276 | #endif | 305 | #endif |
277 | #ifdef __cplusplus | 306 | #ifdef __cplusplus |
@@ -282,6 +311,6 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); | |||
282 | /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */ | 311 | /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */ |
283 | #endif | 312 | #endif |
284 | 313 | ||
285 | /** @} */ /* end of group identity */ | 314 | /** @} */ /* end of group reclaim-attribute */ |
286 | 315 | ||
287 | /* end of gnunet_reclaim_attribute_lib.h */ | 316 | /* 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 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -22,10 +22,9 @@ | |||
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
23 | * | 23 | * |
24 | * @file | 24 | * @file |
25 | * Plugin API for the idp database backend | 25 | * Plugin API for reclaim attribute types |
26 | * | 26 | * |
27 | * @defgroup identity-provider-plugin IdP service plugin API | 27 | * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims |
28 | * Plugin API for the idp database backend | ||
29 | * @{ | 28 | * @{ |
30 | */ | 29 | */ |
31 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H | 30 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H |
@@ -35,9 +34,8 @@ | |||
35 | #include "gnunet_reclaim_attribute_lib.h" | 34 | #include "gnunet_reclaim_attribute_lib.h" |
36 | 35 | ||
37 | #ifdef __cplusplus | 36 | #ifdef __cplusplus |
38 | extern "C" | 37 | extern "C" { |
39 | { | 38 | #if 0 /* keep Emacsens' auto-indent happy */ |
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | 39 | } |
42 | #endif | 40 | #endif |
43 | #endif | 41 | #endif |
@@ -53,10 +51,11 @@ extern "C" | |||
53 | * @param data_size number of bytes in @a data | 51 | * @param data_size number of bytes in @a data |
54 | * @return NULL on error, otherwise human-readable representation of the value | 52 | * @return NULL on error, otherwise human-readable representation of the value |
55 | */ | 53 | */ |
56 | typedef char * (*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (void *cls, | 54 | typedef char *(*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) ( |
57 | uint32_t type, | 55 | void *cls, |
58 | const void *data, | 56 | uint32_t type, |
59 | size_t data_size); | 57 | const void *data, |
58 | size_t data_size); | ||
60 | 59 | ||
61 | 60 | ||
62 | /** | 61 | /** |
@@ -71,11 +70,12 @@ typedef char * (*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (void *cls, | |||
71 | * @param data_size set to number of bytes in @a data | 70 | * @param data_size set to number of bytes in @a data |
72 | * @return #GNUNET_OK on success | 71 | * @return #GNUNET_OK on success |
73 | */ | 72 | */ |
74 | typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (void *cls, | 73 | typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) ( |
75 | uint32_t type, | 74 | void *cls, |
76 | const char *s, | 75 | uint32_t type, |
77 | void **data, | 76 | const char *s, |
78 | size_t *data_size); | 77 | void **data, |
78 | size_t *data_size); | ||
79 | 79 | ||
80 | 80 | ||
81 | /** | 81 | /** |
@@ -86,8 +86,9 @@ typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (void *cls, | |||
86 | * @param typename name to convert | 86 | * @param typename name to convert |
87 | * @return corresponding number, UINT32_MAX on error | 87 | * @return corresponding number, UINT32_MAX on error |
88 | */ | 88 | */ |
89 | typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (void *cls, | 89 | typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) ( |
90 | const char *typename); | 90 | void *cls, |
91 | const char *typename); | ||
91 | 92 | ||
92 | 93 | ||
93 | /** | 94 | /** |
@@ -98,8 +99,9 @@ typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (void *cls | |||
98 | * @param type number of a type to convert | 99 | * @param type number of a type to convert |
99 | * @return corresponding typestring, NULL on error | 100 | * @return corresponding typestring, NULL on error |
100 | */ | 101 | */ |
101 | typedef const char * (*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) (void *cls, | 102 | typedef const char *(*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) ( |
102 | uint32_t type); | 103 | void *cls, |
104 | uint32_t type); | ||
103 | 105 | ||
104 | 106 | ||
105 | /** | 107 | /** |
@@ -133,11 +135,10 @@ struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions | |||
133 | * Number to typename. | 135 | * Number to typename. |
134 | */ | 136 | */ |
135 | GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename; | 137 | GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename; |
136 | |||
137 | }; | 138 | }; |
138 | 139 | ||
139 | 140 | ||
140 | #if 0 /* keep Emacsens' auto-indent happy */ | 141 | #if 0 /* keep Emacsens' auto-indent happy */ |
141 | { | 142 | { |
142 | #endif | 143 | #endif |
143 | #ifdef __cplusplus | 144 | #ifdef __cplusplus |
@@ -146,4 +147,4 @@ struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions | |||
146 | 147 | ||
147 | #endif | 148 | #endif |
148 | 149 | ||
149 | /** @} */ /* end of group */ | 150 | /** @} */ /* 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 @@ | |||
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
23 | * | 23 | * |
24 | * @file | 24 | * @file |
25 | * Identity provider service; implements identity provider for GNUnet | 25 | * reclaim service; implements identity and personal data sharing |
26 | * for GNUnet | ||
26 | * | 27 | * |
27 | * @defgroup reclaim Identity Provider service | 28 | * @defgroup reclaim service |
28 | * @{ | 29 | * @{ |
29 | */ | 30 | */ |
30 | #ifndef GNUNET_RECLAIM_SERVICE_H | 31 | #ifndef GNUNET_RECLAIM_SERVICE_H |
@@ -43,7 +44,7 @@ extern "C" { | |||
43 | /** | 44 | /** |
44 | * Version number of the re:claimID API. | 45 | * Version number of the re:claimID API. |
45 | */ | 46 | */ |
46 | #define GNUNET_RECLAIM_VERSION 0x00000000 | 47 | #define GNUNET_RECLAIM_VERSION 0x00000001 |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * Opaque handle to access the service. | 50 | * Opaque handle to access the service. |
@@ -58,10 +59,10 @@ struct GNUNET_RECLAIM_Operation; | |||
58 | 59 | ||
59 | 60 | ||
60 | /** | 61 | /** |
61 | * The an authorization ticket. This ticket is meant to be transferred | 62 | * The authorization ticket. This ticket is meant to be transferred |
62 | * out of band the a relying party. | 63 | * out of band to a relying party. |
63 | * The contents of a ticket must be protected and should be treated as a | 64 | * The contents of a ticket must be protected and should be treated as a |
64 | * SHARED SECRET between user and relying party. | 65 | * shared secret between user and relying party. |
65 | */ | 66 | */ |
66 | struct GNUNET_RECLAIM_Ticket | 67 | struct GNUNET_RECLAIM_Ticket |
67 | { | 68 | { |
@@ -84,8 +85,8 @@ struct GNUNET_RECLAIM_Ticket | |||
84 | 85 | ||
85 | /** | 86 | /** |
86 | * Method called when a token has been issued. | 87 | * Method called when a token has been issued. |
87 | * On success returns a ticket that can be given to the relying party to retrive | 88 | * On success returns a ticket that can be given to a relying party |
88 | * the token | 89 | * in order for it retrive identity attributes |
89 | * | 90 | * |
90 | * @param cls closure | 91 | * @param cls closure |
91 | * @param ticket the ticket | 92 | * @param ticket the ticket |
@@ -133,7 +134,7 @@ GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
133 | * Store an attribute. If the attribute is already present, | 134 | * Store an attribute. If the attribute is already present, |
134 | * it is replaced with the new attribute. | 135 | * it is replaced with the new attribute. |
135 | * | 136 | * |
136 | * @param h handle to the re:claimID service | 137 | * @param h handle to the reclaim service |
137 | * @param pkey Private key of the identity to add an attribute to | 138 | * @param pkey Private key of the identity to add an attribute to |
138 | * @param attr The attribute | 139 | * @param attr The attribute |
139 | * @param exp_interval The relative expiration interval for the attribute | 140 | * @param exp_interval The relative expiration interval for the attribute |
@@ -246,6 +247,7 @@ GNUNET_RECLAIM_ticket_issue ( | |||
246 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 247 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
247 | GNUNET_RECLAIM_TicketCallback cb, void *cb_cls); | 248 | GNUNET_RECLAIM_TicketCallback cb, void *cb_cls); |
248 | 249 | ||
250 | |||
249 | /** | 251 | /** |
250 | * Revoked an issued ticket. The relying party will be unable to retrieve | 252 | * Revoked an issued ticket. The relying party will be unable to retrieve |
251 | * attributes. Other issued tickets remain unaffected. | 253 | * attributes. Other issued tickets remain unaffected. |
@@ -286,6 +288,7 @@ GNUNET_RECLAIM_ticket_consume ( | |||
286 | const struct GNUNET_RECLAIM_Ticket *ticket, | 288 | const struct GNUNET_RECLAIM_Ticket *ticket, |
287 | GNUNET_RECLAIM_AttributeResult cb, void *cb_cls); | 289 | GNUNET_RECLAIM_AttributeResult cb, void *cb_cls); |
288 | 290 | ||
291 | |||
289 | /** | 292 | /** |
290 | * Lists all tickets that have been issued to remote | 293 | * Lists all tickets that have been issued to remote |
291 | * identites (relying parties) | 294 | * identites (relying parties) |
@@ -321,6 +324,7 @@ GNUNET_RECLAIM_ticket_iteration_start ( | |||
321 | void | 324 | void |
322 | GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it); | 325 | GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it); |
323 | 326 | ||
327 | |||
324 | /** | 328 | /** |
325 | * Stops iteration and releases the handle for further calls. Must | 329 | * Stops iteration and releases the handle for further calls. Must |
326 | * be called on any iteration that has not yet completed prior to calling | 330 | * 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); | |||
331 | void | 335 | void |
332 | GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it); | 336 | GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it); |
333 | 337 | ||
338 | |||
334 | /** | 339 | /** |
335 | * Disconnect from identity provider service. | 340 | * Disconnect from identity provider service. |
336 | * | 341 | * |
@@ -351,6 +356,7 @@ GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h); | |||
351 | void | 356 | void |
352 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); | 357 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); |
353 | 358 | ||
359 | |||
354 | #if 0 /* keep Emacsens' auto-indent happy */ | 360 | #if 0 /* keep Emacsens' auto-indent happy */ |
355 | { | 361 | { |
356 | #endif | 362 | #endif |
@@ -362,6 +368,6 @@ GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); | |||
362 | /* ifndef GNUNET_RECLAIM_SERVICE_H */ | 368 | /* ifndef GNUNET_RECLAIM_SERVICE_H */ |
363 | #endif | 369 | #endif |
364 | 370 | ||
365 | /** @} */ /* end of group identity */ | 371 | /** @} */ /* end of group reclaim */ |
366 | 372 | ||
367 | /* end of gnunet_reclaim_service.h */ | 373 | /* 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 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -20,8 +20,9 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c | 22 | * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c |
23 | * @brief identity attribute plugin to provide the API for fundamental | 23 | * @brief reclaim-attribute-plugin-gnuid attribute plugin to provide the API for |
24 | * attribute types. | 24 | * fundamental |
25 | * attribute types. | ||
25 | * | 26 | * |
26 | * @author Martin Schanzenbach | 27 | * @author Martin Schanzenbach |
27 | */ | 28 | */ |
@@ -42,9 +43,9 @@ | |||
42 | */ | 43 | */ |
43 | static char * | 44 | static char * |
44 | gnuid_value_to_string (void *cls, | 45 | gnuid_value_to_string (void *cls, |
45 | uint32_t type, | 46 | uint32_t type, |
46 | const void *data, | 47 | const void *data, |
47 | size_t data_size) | 48 | size_t data_size) |
48 | { | 49 | { |
49 | 50 | ||
50 | switch (type) | 51 | switch (type) |
@@ -70,22 +71,22 @@ gnuid_value_to_string (void *cls, | |||
70 | */ | 71 | */ |
71 | static int | 72 | static int |
72 | gnuid_string_to_value (void *cls, | 73 | gnuid_string_to_value (void *cls, |
73 | uint32_t type, | 74 | uint32_t type, |
74 | const char *s, | 75 | const char *s, |
75 | void **data, | 76 | void **data, |
76 | size_t *data_size) | 77 | size_t *data_size) |
77 | { | 78 | { |
78 | if (NULL == s) | 79 | if (NULL == s) |
79 | return GNUNET_SYSERR; | 80 | return GNUNET_SYSERR; |
80 | switch (type) | 81 | switch (type) |
81 | { | 82 | { |
82 | 83 | ||
83 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: | 84 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: |
84 | *data = GNUNET_strdup (s); | 85 | *data = GNUNET_strdup (s); |
85 | *data_size = strlen (s); | 86 | *data_size = strlen (s); |
86 | return GNUNET_OK; | 87 | return GNUNET_OK; |
87 | default: | 88 | default: |
88 | return GNUNET_SYSERR; | 89 | return GNUNET_SYSERR; |
89 | } | 90 | } |
90 | } | 91 | } |
91 | 92 | ||
@@ -94,13 +95,12 @@ gnuid_string_to_value (void *cls, | |||
94 | * Mapping of attribute type numbers to human-readable | 95 | * Mapping of attribute type numbers to human-readable |
95 | * attribute type names. | 96 | * attribute type names. |
96 | */ | 97 | */ |
97 | static struct { | 98 | static struct |
99 | { | ||
98 | const char *name; | 100 | const char *name; |
99 | uint32_t number; | 101 | uint32_t number; |
100 | } gnuid_name_map[] = { | 102 | } gnuid_name_map[] = {{"STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING}, |
101 | { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING }, | 103 | {NULL, UINT32_MAX}}; |
102 | { NULL, UINT32_MAX } | ||
103 | }; | ||
104 | 104 | ||
105 | 105 | ||
106 | /** | 106 | /** |
@@ -111,15 +111,13 @@ static struct { | |||
111 | * @return corresponding number, UINT32_MAX on error | 111 | * @return corresponding number, UINT32_MAX on error |
112 | */ | 112 | */ |
113 | static uint32_t | 113 | static uint32_t |
114 | gnuid_typename_to_number (void *cls, | 114 | gnuid_typename_to_number (void *cls, const char *gnuid_typename) |
115 | const char *gnuid_typename) | ||
116 | { | 115 | { |
117 | unsigned int i; | 116 | unsigned int i; |
118 | 117 | ||
119 | i=0; | 118 | i = 0; |
120 | while ( (NULL != gnuid_name_map[i].name) && | 119 | while ((NULL != gnuid_name_map[i].name) && |
121 | (0 != strcasecmp (gnuid_typename, | 120 | (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name))) |
122 | gnuid_name_map[i].name)) ) | ||
123 | i++; | 121 | i++; |
124 | return gnuid_name_map[i].number; | 122 | return gnuid_name_map[i].number; |
125 | } | 123 | } |
@@ -133,14 +131,12 @@ gnuid_typename_to_number (void *cls, | |||
133 | * @return corresponding typestring, NULL on error | 131 | * @return corresponding typestring, NULL on error |
134 | */ | 132 | */ |
135 | static const char * | 133 | static const char * |
136 | gnuid_number_to_typename (void *cls, | 134 | gnuid_number_to_typename (void *cls, uint32_t type) |
137 | uint32_t type) | ||
138 | { | 135 | { |
139 | unsigned int i; | 136 | unsigned int i; |
140 | 137 | ||
141 | i=0; | 138 | i = 0; |
142 | while ( (NULL != gnuid_name_map[i].name) && | 139 | while ((NULL != gnuid_name_map[i].name) && (type != gnuid_name_map[i].number)) |
143 | (type != gnuid_name_map[i].number) ) | ||
144 | i++; | 140 | i++; |
145 | return gnuid_name_map[i].name; | 141 | return gnuid_name_map[i].name; |
146 | } | 142 | } |
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 @@ | |||
24 | * @author Martin Schanzenbach | 24 | * @author Martin Schanzenbach |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | |||
28 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
29 | |||
30 | #include "gnunet_reclaim_attribute_plugin.h" | 28 | #include "gnunet_reclaim_attribute_plugin.h" |
31 | #include "reclaim_attribute.h" | 29 | #include "reclaim_attribute.h" |
30 | |||
31 | |||
32 | /** | 32 | /** |
33 | * Handle for a plugin | 33 | * Handle for a plugin |
34 | */ | 34 | */ |
@@ -45,23 +45,31 @@ struct Plugin | |||
45 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; | 45 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | |||
48 | /** | 49 | /** |
49 | * Plugins | 50 | * Plugins |
50 | */ | 51 | */ |
51 | static struct Plugin **attr_plugins; | 52 | static struct Plugin **attr_plugins; |
52 | 53 | ||
54 | |||
53 | /** | 55 | /** |
54 | * Number of plugins | 56 | * Number of plugins |
55 | */ | 57 | */ |
56 | static unsigned int num_plugins; | 58 | static unsigned int num_plugins; |
57 | 59 | ||
60 | |||
58 | /** | 61 | /** |
59 | * Init canary | 62 | * Init canary |
60 | */ | 63 | */ |
61 | static int initialized; | 64 | static int initialized; |
62 | 65 | ||
66 | |||
63 | /** | 67 | /** |
64 | * Add a plugin | 68 | * Add a plugin |
69 | * | ||
70 | * @param cls closure | ||
71 | * @param library_name name of the API library | ||
72 | * @param lib_ret the plugin API pointer | ||
65 | */ | 73 | */ |
66 | static void | 74 | static void |
67 | add_plugin (void *cls, const char *library_name, void *lib_ret) | 75 | 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) | |||
69 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret; | 77 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret; |
70 | struct Plugin *plugin; | 78 | struct Plugin *plugin; |
71 | 79 | ||
72 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading attribute plugin `%s'\n", | 80 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
81 | "Loading attribute plugin `%s'\n", | ||
73 | library_name); | 82 | library_name); |
74 | plugin = GNUNET_new (struct Plugin); | 83 | plugin = GNUNET_new (struct Plugin); |
75 | plugin->api = api; | 84 | plugin->api = api; |
@@ -77,6 +86,7 @@ add_plugin (void *cls, const char *library_name, void *lib_ret) | |||
77 | GNUNET_array_append (attr_plugins, num_plugins, plugin); | 86 | GNUNET_array_append (attr_plugins, num_plugins, plugin); |
78 | } | 87 | } |
79 | 88 | ||
89 | |||
80 | /** | 90 | /** |
81 | * Load plugins | 91 | * Load plugins |
82 | */ | 92 | */ |
@@ -86,10 +96,13 @@ init () | |||
86 | if (GNUNET_YES == initialized) | 96 | if (GNUNET_YES == initialized) |
87 | return; | 97 | return; |
88 | initialized = GNUNET_YES; | 98 | initialized = GNUNET_YES; |
89 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attribute_", NULL, | 99 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attribute_", |
90 | &add_plugin, NULL); | 100 | NULL, |
101 | &add_plugin, | ||
102 | NULL); | ||
91 | } | 103 | } |
92 | 104 | ||
105 | |||
93 | /** | 106 | /** |
94 | * Convert a type name to the corresponding number | 107 | * Convert a type name to the corresponding number |
95 | * | 108 | * |
@@ -104,7 +117,8 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename) | |||
104 | uint32_t ret; | 117 | uint32_t ret; |
105 | 118 | ||
106 | init (); | 119 | init (); |
107 | for (i = 0; i < num_plugins; i++) { | 120 | for (i = 0; i < num_plugins; i++) |
121 | { | ||
108 | plugin = attr_plugins[i]; | 122 | plugin = attr_plugins[i]; |
109 | if (UINT32_MAX != | 123 | if (UINT32_MAX != |
110 | (ret = plugin->api->typename_to_number (plugin->api->cls, typename))) | 124 | (ret = plugin->api->typename_to_number (plugin->api->cls, typename))) |
@@ -113,6 +127,7 @@ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename) | |||
113 | return UINT32_MAX; | 127 | return UINT32_MAX; |
114 | } | 128 | } |
115 | 129 | ||
130 | |||
116 | /** | 131 | /** |
117 | * Convert a type number to the corresponding type string | 132 | * Convert a type number to the corresponding type string |
118 | * | 133 | * |
@@ -127,7 +142,8 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type) | |||
127 | const char *ret; | 142 | const char *ret; |
128 | 143 | ||
129 | init (); | 144 | init (); |
130 | for (i = 0; i < num_plugins; i++) { | 145 | for (i = 0; i < num_plugins; i++) |
146 | { | ||
131 | plugin = attr_plugins[i]; | 147 | plugin = attr_plugins[i]; |
132 | if (NULL != | 148 | if (NULL != |
133 | (ret = plugin->api->number_to_typename (plugin->api->cls, type))) | 149 | (ret = plugin->api->number_to_typename (plugin->api->cls, type))) |
@@ -136,6 +152,7 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type) | |||
136 | return NULL; | 152 | return NULL; |
137 | } | 153 | } |
138 | 154 | ||
155 | |||
139 | /** | 156 | /** |
140 | * Convert human-readable version of a 'claim' of an attribute to the binary | 157 | * Convert human-readable version of a 'claim' of an attribute to the binary |
141 | * representation | 158 | * representation |
@@ -147,22 +164,29 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type) | |||
147 | * @return #GNUNET_OK on success | 164 | * @return #GNUNET_OK on success |
148 | */ | 165 | */ |
149 | int | 166 | int |
150 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, const char *s, | 167 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, |
151 | void **data, size_t *data_size) | 168 | const char *s, |
169 | void **data, | ||
170 | size_t *data_size) | ||
152 | { | 171 | { |
153 | unsigned int i; | 172 | unsigned int i; |
154 | struct Plugin *plugin; | 173 | struct Plugin *plugin; |
155 | 174 | ||
156 | init (); | 175 | init (); |
157 | for (i = 0; i < num_plugins; i++) { | 176 | for (i = 0; i < num_plugins; i++) |
177 | { | ||
158 | plugin = attr_plugins[i]; | 178 | plugin = attr_plugins[i]; |
159 | if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls, type, s, | 179 | if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls, |
160 | data, data_size)) | 180 | type, |
181 | s, | ||
182 | data, | ||
183 | data_size)) | ||
161 | return GNUNET_OK; | 184 | return GNUNET_OK; |
162 | } | 185 | } |
163 | return GNUNET_SYSERR; | 186 | return GNUNET_SYSERR; |
164 | } | 187 | } |
165 | 188 | ||
189 | |||
166 | /** | 190 | /** |
167 | * Convert the 'claim' of an attribute to a string | 191 | * Convert the 'claim' of an attribute to a string |
168 | * | 192 | * |
@@ -172,7 +196,8 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, const char *s, | |||
172 | * @return NULL on error, otherwise human-readable representation of the claim | 196 | * @return NULL on error, otherwise human-readable representation of the claim |
173 | */ | 197 | */ |
174 | char * | 198 | char * |
175 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, const void *data, | 199 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, |
200 | const void *data, | ||
176 | size_t data_size) | 201 | size_t data_size) |
177 | { | 202 | { |
178 | unsigned int i; | 203 | unsigned int i; |
@@ -180,15 +205,19 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, const void *data, | |||
180 | char *ret; | 205 | char *ret; |
181 | 206 | ||
182 | init (); | 207 | init (); |
183 | for (i = 0; i < num_plugins; i++) { | 208 | for (i = 0; i < num_plugins; i++) |
209 | { | ||
184 | plugin = attr_plugins[i]; | 210 | plugin = attr_plugins[i]; |
185 | if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls, type, | 211 | if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls, |
186 | data, data_size))) | 212 | type, |
213 | data, | ||
214 | data_size))) | ||
187 | return ret; | 215 | return ret; |
188 | } | 216 | } |
189 | return NULL; | 217 | return NULL; |
190 | } | 218 | } |
191 | 219 | ||
220 | |||
192 | /** | 221 | /** |
193 | * Create a new attribute. | 222 | * Create a new attribute. |
194 | * | 223 | * |
@@ -199,8 +228,10 @@ GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, const void *data, | |||
199 | * @return the new attribute | 228 | * @return the new attribute |
200 | */ | 229 | */ |
201 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 230 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
202 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, uint32_t type, | 231 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, |
203 | const void *data, size_t data_size) | 232 | uint32_t type, |
233 | const void *data, | ||
234 | size_t data_size) | ||
204 | { | 235 | { |
205 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; | 236 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
206 | char *write_ptr; | 237 | char *write_ptr; |
@@ -213,7 +244,7 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, uint32_t type, | |||
213 | attr->type = type; | 244 | attr->type = type; |
214 | attr->data_size = data_size; | 245 | attr->data_size = data_size; |
215 | attr->version = 0; | 246 | attr->version = 0; |
216 | write_ptr = (char *)&attr[1]; | 247 | write_ptr = (char *) &attr[1]; |
217 | GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1); | 248 | GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1); |
218 | attr->name = write_ptr; | 249 | attr->name = write_ptr; |
219 | write_ptr += strlen (attr->name) + 1; | 250 | write_ptr += strlen (attr->name) + 1; |
@@ -223,32 +254,42 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, uint32_t type, | |||
223 | return attr; | 254 | return attr; |
224 | } | 255 | } |
225 | 256 | ||
257 | |||
226 | /** | 258 | /** |
227 | * Add a new claim list entry. | 259 | * Add a new attribute to a claim list |
228 | * | 260 | * |
229 | * @param claim_list the attribute name | 261 | * @param attr_name the name of the new attribute claim |
230 | * @param attr_name the attribute name | 262 | * @param type the type of the claim |
231 | * @param type the attribute type | 263 | * @param data claim payload |
232 | * @param data the attribute value | 264 | * @param data_size claim payload size |
233 | * @param data_size the attribute value size | ||
234 | * @return | ||
235 | */ | 265 | */ |
236 | void | 266 | void |
237 | GNUNET_RECLAIM_ATTRIBUTE_list_add ( | 267 | GNUNET_RECLAIM_ATTRIBUTE_list_add ( |
238 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list, | 268 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list, |
239 | const char *attr_name, uint32_t type, const void *data, size_t data_size) | 269 | const char *attr_name, |
270 | uint32_t type, | ||
271 | const void *data, | ||
272 | size_t data_size) | ||
240 | { | 273 | { |
241 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 274 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
242 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 275 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
243 | le->claim = | 276 | le->claim = |
244 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); | 277 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, type, data, data_size); |
245 | GNUNET_CONTAINER_DLL_insert (claim_list->list_head, claim_list->list_tail, | 278 | GNUNET_CONTAINER_DLL_insert (claim_list->list_head, |
279 | claim_list->list_tail, | ||
246 | le); | 280 | le); |
247 | } | 281 | } |
248 | 282 | ||
283 | |||
284 | /** | ||
285 | * Get required size for serialization buffer | ||
286 | * | ||
287 | * @param attrs the attribute list to serialize | ||
288 | * @return the required buffer size | ||
289 | */ | ||
249 | size_t | 290 | size_t |
250 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( | 291 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( |
251 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) | 292 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
252 | { | 293 | { |
253 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 294 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
254 | size_t len = 0; | 295 | size_t len = 0; |
@@ -257,9 +298,18 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( | |||
257 | return len; | 298 | return len; |
258 | } | 299 | } |
259 | 300 | ||
301 | |||
302 | /** | ||
303 | * Serialize an attribute list | ||
304 | * | ||
305 | * @param attrs the attribute list to serialize | ||
306 | * @param result the serialized attribute | ||
307 | * @return length of serialized data | ||
308 | */ | ||
260 | size_t | 309 | size_t |
261 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( | 310 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( |
262 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result) | 311 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
312 | char *result) | ||
263 | { | 313 | { |
264 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 314 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
265 | size_t len; | 315 | size_t len; |
@@ -268,7 +318,8 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( | |||
268 | 318 | ||
269 | write_ptr = result; | 319 | write_ptr = result; |
270 | total_len = 0; | 320 | total_len = 0; |
271 | for (le = attrs->list_head; NULL != le; le = le->next) { | 321 | for (le = attrs->list_head; NULL != le; le = le->next) |
322 | { | ||
272 | len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr); | 323 | len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr); |
273 | total_len += len; | 324 | total_len += len; |
274 | write_ptr += len; | 325 | write_ptr += len; |
@@ -276,6 +327,14 @@ GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( | |||
276 | return total_len; | 327 | return total_len; |
277 | } | 328 | } |
278 | 329 | ||
330 | |||
331 | /** | ||
332 | * Deserialize an attribute list | ||
333 | * | ||
334 | * @param data the serialized attribute list | ||
335 | * @param data_size the length of the serialized data | ||
336 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | ||
337 | */ | ||
279 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | 338 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * |
280 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size) | 339 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size) |
281 | { | 340 | { |
@@ -289,12 +348,15 @@ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size) | |||
289 | 348 | ||
290 | attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 349 | attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
291 | read_ptr = data; | 350 | read_ptr = data; |
292 | while (((data + data_size) - read_ptr) >= sizeof (struct Attribute)) { | 351 | while (((data + data_size) - read_ptr) >= sizeof (struct Attribute)) |
352 | { | ||
293 | 353 | ||
294 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 354 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
295 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ( | 355 | le->claim = |
296 | read_ptr, data_size - (read_ptr - data)); | 356 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (read_ptr, |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deserialized attribute %s\n", | 357 | data_size - (read_ptr - data)); |
358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
359 | "Deserialized attribute %s\n", | ||
298 | le->claim->name); | 360 | le->claim->name); |
299 | GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le); | 361 | GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le); |
300 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim); | 362 | 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) | |||
303 | return attrs; | 365 | return attrs; |
304 | } | 366 | } |
305 | 367 | ||
368 | |||
369 | /** | ||
370 | * Make a (deep) copy of a claim list | ||
371 | * @param attrs claim list to copy | ||
372 | * @return copied claim list | ||
373 | */ | ||
306 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | 374 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * |
307 | GNUNET_RECLAIM_ATTRIBUTE_list_dup ( | 375 | GNUNET_RECLAIM_ATTRIBUTE_list_dup ( |
308 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) | 376 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
309 | { | 377 | { |
310 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 378 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
311 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le; | 379 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le; |
312 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result; | 380 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result; |
313 | 381 | ||
314 | result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 382 | result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
315 | for (le = attrs->list_head; NULL != le; le = le->next) { | 383 | for (le = attrs->list_head; NULL != le; le = le->next) |
384 | { | ||
316 | result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 385 | result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
317 | result_le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new ( | 386 | result_le->claim = |
318 | le->claim->name, le->claim->type, le->claim->data, | 387 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (le->claim->name, |
319 | le->claim->data_size); | 388 | le->claim->type, |
389 | le->claim->data, | ||
390 | le->claim->data_size); | ||
320 | result_le->claim->version = le->claim->version; | 391 | result_le->claim->version = le->claim->version; |
321 | result_le->claim->id = le->claim->id; | 392 | result_le->claim->id = le->claim->id; |
322 | GNUNET_CONTAINER_DLL_insert (result->list_head, result->list_tail, | 393 | GNUNET_CONTAINER_DLL_insert (result->list_head, |
394 | result->list_tail, | ||
323 | result_le); | 395 | result_le); |
324 | } | 396 | } |
325 | return result; | 397 | return result; |
326 | } | 398 | } |
327 | 399 | ||
328 | 400 | ||
329 | void | 401 | /** |
402 | * Destroy claim list | ||
403 | * | ||
404 | * @param attrs list to destroy | ||
405 | */ | ||
330 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( | 406 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( |
331 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) | 407 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
332 | { | 408 | { |
333 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 409 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
334 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le; | 410 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le; |
335 | 411 | ||
336 | for (le = attrs->list_head; NULL != le;) { | 412 | for (le = attrs->list_head; NULL != le;) |
413 | { | ||
337 | GNUNET_free (le->claim); | 414 | GNUNET_free (le->claim); |
338 | tmp_le = le; | 415 | tmp_le = le; |
339 | le = le->next; | 416 | le = le->next; |
@@ -342,29 +419,45 @@ GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( | |||
342 | GNUNET_free (attrs); | 419 | GNUNET_free (attrs); |
343 | } | 420 | } |
344 | 421 | ||
422 | |||
423 | /** | ||
424 | * Get required size for serialization buffer | ||
425 | * | ||
426 | * @param attr the attribute to serialize | ||
427 | * @return the required buffer size | ||
428 | */ | ||
345 | size_t | 429 | size_t |
346 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( | 430 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( |
347 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 431 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
348 | { | 432 | { |
349 | return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; | 433 | return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; |
350 | } | 434 | } |
351 | 435 | ||
436 | |||
437 | /** | ||
438 | * Serialize an attribute | ||
439 | * | ||
440 | * @param attr the attribute to serialize | ||
441 | * @param result the serialized attribute | ||
442 | * @return length of serialized data | ||
443 | */ | ||
352 | size_t | 444 | size_t |
353 | GNUNET_RECLAIM_ATTRIBUTE_serialize ( | 445 | GNUNET_RECLAIM_ATTRIBUTE_serialize ( |
354 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result) | 446 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
447 | char *result) | ||
355 | { | 448 | { |
356 | size_t data_len_ser; | 449 | size_t data_len_ser; |
357 | size_t name_len; | 450 | size_t name_len; |
358 | struct Attribute *attr_ser; | 451 | struct Attribute *attr_ser; |
359 | char *write_ptr; | 452 | char *write_ptr; |
360 | 453 | ||
361 | attr_ser = (struct Attribute *)result; | 454 | attr_ser = (struct Attribute *) result; |
362 | attr_ser->attribute_type = htons (attr->type); | 455 | attr_ser->attribute_type = htons (attr->type); |
363 | attr_ser->attribute_version = htonl (attr->version); | 456 | attr_ser->attribute_version = htonl (attr->version); |
364 | attr_ser->attribute_id = GNUNET_htonll (attr->id); | 457 | attr_ser->attribute_id = GNUNET_htonll (attr->id); |
365 | name_len = strlen (attr->name); | 458 | name_len = strlen (attr->name); |
366 | attr_ser->name_len = htons (name_len); | 459 | attr_ser->name_len = htons (name_len); |
367 | write_ptr = (char *)&attr_ser[1]; | 460 | write_ptr = (char *) &attr_ser[1]; |
368 | GNUNET_memcpy (write_ptr, attr->name, name_len); | 461 | GNUNET_memcpy (write_ptr, attr->name, name_len); |
369 | write_ptr += name_len; | 462 | write_ptr += name_len; |
370 | // TODO plugin-ize | 463 | // TODO plugin-ize |
@@ -377,6 +470,15 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize ( | |||
377 | return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; | 470 | return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; |
378 | } | 471 | } |
379 | 472 | ||
473 | |||
474 | /** | ||
475 | * Deserialize an attribute | ||
476 | * | ||
477 | * @param data the serialized attribute | ||
478 | * @param data_size the length of the serialized data | ||
479 | * | ||
480 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | ||
481 | */ | ||
380 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 482 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
381 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size) | 483 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size) |
382 | { | 484 | { |
@@ -389,7 +491,7 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size) | |||
389 | if (data_size < sizeof (struct Attribute)) | 491 | if (data_size < sizeof (struct Attribute)) |
390 | return NULL; | 492 | return NULL; |
391 | 493 | ||
392 | attr_ser = (struct Attribute *)data; | 494 | attr_ser = (struct Attribute *) data; |
393 | data_len = ntohs (attr_ser->data_size); | 495 | data_len = ntohs (attr_ser->data_size); |
394 | name_len = ntohs (attr_ser->name_len); | 496 | name_len = ntohs (attr_ser->name_len); |
395 | attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + | 497 | attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + |
@@ -399,13 +501,13 @@ GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size) | |||
399 | attr->id = GNUNET_ntohll (attr_ser->attribute_id); | 501 | attr->id = GNUNET_ntohll (attr_ser->attribute_id); |
400 | attr->data_size = ntohs (attr_ser->data_size); | 502 | attr->data_size = ntohs (attr_ser->data_size); |
401 | 503 | ||
402 | write_ptr = (char *)&attr[1]; | 504 | write_ptr = (char *) &attr[1]; |
403 | GNUNET_memcpy (write_ptr, &attr_ser[1], name_len); | 505 | GNUNET_memcpy (write_ptr, &attr_ser[1], name_len); |
404 | write_ptr[name_len] = '\0'; | 506 | write_ptr[name_len] = '\0'; |
405 | attr->name = write_ptr; | 507 | attr->name = write_ptr; |
406 | 508 | ||
407 | write_ptr += name_len + 1; | 509 | write_ptr += name_len + 1; |
408 | GNUNET_memcpy (write_ptr, (char *)&attr_ser[1] + name_len, attr->data_size); | 510 | GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size); |
409 | attr->data = write_ptr; | 511 | attr->data = write_ptr; |
410 | return attr; | 512 | return attr; |
411 | } | 513 | } |
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 @@ | |||
28 | 28 | ||
29 | #include "gnunet_reclaim_service.h" | 29 | #include "gnunet_reclaim_service.h" |
30 | 30 | ||
31 | /** | ||
32 | * Serialized claim | ||
33 | */ | ||
31 | struct Attribute | 34 | struct Attribute |
32 | { | 35 | { |
33 | /** | 36 | /** |
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 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | |||
28 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
29 | |||
30 | #include "gnunet-service-reclaim_tickets.h" | 28 | #include "gnunet-service-reclaim_tickets.h" |
31 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
32 | #include "gnunet_gnsrecord_lib.h" | 30 | #include "gnunet_gnsrecord_lib.h" |
@@ -124,6 +122,7 @@ struct TicketIteration | |||
124 | struct RECLAIM_TICKETS_Iterator *iter; | 122 | struct RECLAIM_TICKETS_Iterator *iter; |
125 | }; | 123 | }; |
126 | 124 | ||
125 | |||
127 | /** | 126 | /** |
128 | * An attribute iteration operation. | 127 | * An attribute iteration operation. |
129 | */ | 128 | */ |
@@ -160,6 +159,7 @@ struct AttributeIterator | |||
160 | uint32_t request_id; | 159 | uint32_t request_id; |
161 | }; | 160 | }; |
162 | 161 | ||
162 | |||
163 | /** | 163 | /** |
164 | * An idp client | 164 | * An idp client |
165 | */ | 165 | */ |
@@ -251,6 +251,9 @@ struct IdpClient | |||
251 | }; | 251 | }; |
252 | 252 | ||
253 | 253 | ||
254 | /** | ||
255 | * Handle for attribute deletion request | ||
256 | */ | ||
254 | struct AttributeDeleteHandle | 257 | struct AttributeDeleteHandle |
255 | { | 258 | { |
256 | /** | 259 | /** |
@@ -311,6 +314,9 @@ struct AttributeDeleteHandle | |||
311 | }; | 314 | }; |
312 | 315 | ||
313 | 316 | ||
317 | /** | ||
318 | * Handle for attribute store request | ||
319 | */ | ||
314 | struct AttributeStoreHandle | 320 | struct AttributeStoreHandle |
315 | { | 321 | { |
316 | /** | 322 | /** |
@@ -359,6 +365,10 @@ struct AttributeStoreHandle | |||
359 | uint32_t r_id; | 365 | uint32_t r_id; |
360 | }; | 366 | }; |
361 | 367 | ||
368 | |||
369 | /** | ||
370 | * Handle for ticket consume request | ||
371 | */ | ||
362 | struct ConsumeTicketOperation | 372 | struct ConsumeTicketOperation |
363 | { | 373 | { |
364 | /** | 374 | /** |
@@ -387,6 +397,7 @@ struct ConsumeTicketOperation | |||
387 | struct RECLAIM_TICKETS_ConsumeHandle *ch; | 397 | struct RECLAIM_TICKETS_ConsumeHandle *ch; |
388 | }; | 398 | }; |
389 | 399 | ||
400 | |||
390 | /** | 401 | /** |
391 | * Updated attribute IDs | 402 | * Updated attribute IDs |
392 | */ | 403 | */ |
@@ -413,6 +424,7 @@ struct TicketAttributeUpdateEntry | |||
413 | uint64_t new_id; | 424 | uint64_t new_id; |
414 | }; | 425 | }; |
415 | 426 | ||
427 | |||
416 | /** | 428 | /** |
417 | * Ticket revocation request handle | 429 | * Ticket revocation request handle |
418 | */ | 430 | */ |
@@ -444,6 +456,7 @@ struct TicketRevocationOperation | |||
444 | uint32_t r_id; | 456 | uint32_t r_id; |
445 | }; | 457 | }; |
446 | 458 | ||
459 | |||
447 | /** | 460 | /** |
448 | * Ticket issue operation handle | 461 | * Ticket issue operation handle |
449 | */ | 462 | */ |
@@ -470,6 +483,7 @@ struct TicketIssueOperation | |||
470 | uint32_t r_id; | 483 | uint32_t r_id; |
471 | }; | 484 | }; |
472 | 485 | ||
486 | |||
473 | /** | 487 | /** |
474 | * DLL for ego handles to egos containing the RECLAIM_ATTRS in a | 488 | * DLL for ego handles to egos containing the RECLAIM_ATTRS in a |
475 | * map in json_t format | 489 | * map in json_t format |
@@ -498,6 +512,7 @@ struct EgoEntry | |||
498 | struct GNUNET_CONTAINER_MultiHashMap *attr_map; | 512 | struct GNUNET_CONTAINER_MultiHashMap *attr_map; |
499 | }; | 513 | }; |
500 | 514 | ||
515 | |||
501 | /** | 516 | /** |
502 | * Cleanup task | 517 | * Cleanup task |
503 | */ | 518 | */ |
@@ -517,6 +532,7 @@ cleanup () | |||
517 | GNUNET_NAMESTORE_disconnect (nsh); | 532 | GNUNET_NAMESTORE_disconnect (nsh); |
518 | } | 533 | } |
519 | 534 | ||
535 | |||
520 | /** | 536 | /** |
521 | * Shutdown task | 537 | * Shutdown task |
522 | * | 538 | * |
@@ -530,6 +546,14 @@ do_shutdown (void *cls) | |||
530 | } | 546 | } |
531 | 547 | ||
532 | 548 | ||
549 | /** | ||
550 | * Sends a ticket result message to the client | ||
551 | * | ||
552 | * @param client the client to send to | ||
553 | * @param r_id the request message ID to reply to | ||
554 | * @param ticket the ticket to include (may be NULL) | ||
555 | * @param success the success status of the request | ||
556 | */ | ||
533 | static void | 557 | static void |
534 | send_ticket_result (const struct IdpClient *client, | 558 | send_ticket_result (const struct IdpClient *client, |
535 | uint32_t r_id, | 559 | uint32_t r_id, |
@@ -555,6 +579,15 @@ send_ticket_result (const struct IdpClient *client, | |||
555 | GNUNET_MQ_send (client->mq, env); | 579 | GNUNET_MQ_send (client->mq, env); |
556 | } | 580 | } |
557 | 581 | ||
582 | |||
583 | /** | ||
584 | * Issue ticket result | ||
585 | * | ||
586 | * @param cls out ticket issue operation handle | ||
587 | * @param ticket the issued ticket | ||
588 | * @param success issue success status (GNUNET_OK if successful) | ||
589 | * @param emsg error message (NULL of success is GNUNET_OK) | ||
590 | */ | ||
558 | static void | 591 | static void |
559 | issue_ticket_result_cb (void *cls, | 592 | issue_ticket_result_cb (void *cls, |
560 | struct GNUNET_RECLAIM_Ticket *ticket, | 593 | struct GNUNET_RECLAIM_Ticket *ticket, |
@@ -578,6 +611,14 @@ issue_ticket_result_cb (void *cls, | |||
578 | GNUNET_free (tio); | 611 | GNUNET_free (tio); |
579 | } | 612 | } |
580 | 613 | ||
614 | |||
615 | /** | ||
616 | * Check issue ticket message | ||
617 | * | ||
618 | * @cls unused | ||
619 | * @im message to check | ||
620 | * @return GNUNET_OK if message is ok | ||
621 | */ | ||
581 | static int | 622 | static int |
582 | check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | 623 | check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) |
583 | { | 624 | { |
@@ -591,6 +632,13 @@ check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
591 | return GNUNET_OK; | 632 | return GNUNET_OK; |
592 | } | 633 | } |
593 | 634 | ||
635 | |||
636 | /** | ||
637 | * Handle ticket issue message | ||
638 | * | ||
639 | * @param cls our client | ||
640 | * @param im the message | ||
641 | */ | ||
594 | static void | 642 | static void |
595 | handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | 643 | handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) |
596 | { | 644 | { |
@@ -615,10 +663,18 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
615 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); | 663 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); |
616 | } | 664 | } |
617 | 665 | ||
666 | |||
667 | |||
618 | /********************************************************** | 668 | /********************************************************** |
619 | * Revocation | 669 | * Revocation |
620 | **********************************************************/ | 670 | **********************************************************/ |
621 | 671 | ||
672 | /** | ||
673 | * Handles revocation result | ||
674 | * | ||
675 | * @param cls our revocation operation handle | ||
676 | * @param success revocation result (GNUNET_OK if successful) | ||
677 | */ | ||
622 | static void | 678 | static void |
623 | revoke_result_cb (void *cls, int32_t success) | 679 | revoke_result_cb (void *cls, int32_t success) |
624 | { | 680 | { |
@@ -639,6 +695,13 @@ revoke_result_cb (void *cls, int32_t success) | |||
639 | } | 695 | } |
640 | 696 | ||
641 | 697 | ||
698 | /** | ||
699 | * Check revocation message format | ||
700 | * | ||
701 | * @param cls unused | ||
702 | * @param im the message to check | ||
703 | * @return GNUNET_OK if message is ok | ||
704 | */ | ||
642 | static int | 705 | static int |
643 | check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) | 706 | check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) |
644 | { | 707 | { |
@@ -652,6 +715,13 @@ check_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *im) | |||
652 | return GNUNET_OK; | 715 | return GNUNET_OK; |
653 | } | 716 | } |
654 | 717 | ||
718 | |||
719 | /** | ||
720 | * Handle a revocation message to a ticket. | ||
721 | * | ||
722 | * @param cls our client | ||
723 | * @param rm the message to handle | ||
724 | */ | ||
655 | static void | 725 | static void |
656 | handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | 726 | handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) |
657 | { | 727 | { |
@@ -670,19 +740,16 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | |||
670 | GNUNET_SERVICE_client_continue (idp->client); | 740 | GNUNET_SERVICE_client_continue (idp->client); |
671 | } | 741 | } |
672 | 742 | ||
673 | static int | ||
674 | check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | ||
675 | { | ||
676 | uint16_t size; | ||
677 | |||
678 | size = ntohs (cm->header.size); | ||
679 | if (size <= sizeof (struct ConsumeTicketMessage)) { | ||
680 | GNUNET_break (0); | ||
681 | return GNUNET_SYSERR; | ||
682 | } | ||
683 | return GNUNET_OK; | ||
684 | } | ||
685 | 743 | ||
744 | /** | ||
745 | * Handle a ticket consume result | ||
746 | * | ||
747 | * @param cls our consume ticket operation handle | ||
748 | * @param identity the attribute authority | ||
749 | * @param attrs the attribute/claim list | ||
750 | * @param success GNUNET_OK if successful | ||
751 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
752 | */ | ||
686 | static void | 753 | static void |
687 | consume_result_cb (void *cls, | 754 | consume_result_cb (void *cls, |
688 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 755 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
@@ -716,6 +783,33 @@ consume_result_cb (void *cls, | |||
716 | GNUNET_free (cop); | 783 | GNUNET_free (cop); |
717 | } | 784 | } |
718 | 785 | ||
786 | |||
787 | /** | ||
788 | * Check a consume ticket message | ||
789 | * | ||
790 | * @param cls unused | ||
791 | * @param cm the message to handle | ||
792 | */ | ||
793 | static int | ||
794 | check_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | ||
795 | { | ||
796 | uint16_t size; | ||
797 | |||
798 | size = ntohs (cm->header.size); | ||
799 | if (size <= sizeof (struct ConsumeTicketMessage)) { | ||
800 | GNUNET_break (0); | ||
801 | return GNUNET_SYSERR; | ||
802 | } | ||
803 | return GNUNET_OK; | ||
804 | } | ||
805 | |||
806 | |||
807 | /** | ||
808 | * Handle a consume ticket message | ||
809 | * | ||
810 | * @param cls our client handle | ||
811 | * @cm the message to handle | ||
812 | */ | ||
719 | static void | 813 | static void |
720 | handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | 814 | handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) |
721 | { | 815 | { |
@@ -753,6 +847,14 @@ cleanup_as_handle (struct AttributeStoreHandle *ash) | |||
753 | GNUNET_free (ash); | 847 | GNUNET_free (ash); |
754 | } | 848 | } |
755 | 849 | ||
850 | |||
851 | /** | ||
852 | * Attribute store result handler | ||
853 | * | ||
854 | * @param cls our attribute store handle | ||
855 | * @param success GNUNET_OK if successful | ||
856 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
857 | */ | ||
756 | static void | 858 | static void |
757 | attr_store_cont (void *cls, int32_t success, const char *emsg) | 859 | attr_store_cont (void *cls, int32_t success, const char *emsg) |
758 | { | 860 | { |
@@ -782,8 +884,9 @@ attr_store_cont (void *cls, int32_t success, const char *emsg) | |||
782 | cleanup_as_handle (ash); | 884 | cleanup_as_handle (ash); |
783 | } | 885 | } |
784 | 886 | ||
887 | |||
785 | /** | 888 | /** |
786 | * Adds a new attribute | 889 | * Add a new attribute |
787 | * | 890 | * |
788 | * @param cls the AttributeStoreHandle | 891 | * @param cls the AttributeStoreHandle |
789 | */ | 892 | */ |
@@ -823,6 +926,13 @@ attr_store_task (void *cls) | |||
823 | GNUNET_free (buf); | 926 | GNUNET_free (buf); |
824 | } | 927 | } |
825 | 928 | ||
929 | |||
930 | /** | ||
931 | * Check an attribute store message | ||
932 | * | ||
933 | * @param cls unused | ||
934 | * @param sam the message to check | ||
935 | */ | ||
826 | static int | 936 | static int |
827 | check_attribute_store_message (void *cls, | 937 | check_attribute_store_message (void *cls, |
828 | const struct AttributeStoreMessage *sam) | 938 | const struct AttributeStoreMessage *sam) |
@@ -837,6 +947,13 @@ check_attribute_store_message (void *cls, | |||
837 | return GNUNET_OK; | 947 | return GNUNET_OK; |
838 | } | 948 | } |
839 | 949 | ||
950 | |||
951 | /** | ||
952 | * Handle an attribute store message | ||
953 | * | ||
954 | * @param cls our client | ||
955 | * @param sam the message to handle | ||
956 | */ | ||
840 | static void | 957 | static void |
841 | handle_attribute_store_message (void *cls, | 958 | handle_attribute_store_message (void *cls, |
842 | const struct AttributeStoreMessage *sam) | 959 | const struct AttributeStoreMessage *sam) |
@@ -863,6 +980,11 @@ handle_attribute_store_message (void *cls, | |||
863 | } | 980 | } |
864 | 981 | ||
865 | 982 | ||
983 | /** | ||
984 | * Cleanup attribute delete handle | ||
985 | * | ||
986 | * @param adh the attribute to cleanup | ||
987 | */ | ||
866 | static void | 988 | static void |
867 | cleanup_adh (struct AttributeDeleteHandle *adh) | 989 | cleanup_adh (struct AttributeDeleteHandle *adh) |
868 | { | 990 | { |
@@ -889,6 +1011,12 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
889 | } | 1011 | } |
890 | 1012 | ||
891 | 1013 | ||
1014 | /** | ||
1015 | * Send a deletion success response | ||
1016 | * | ||
1017 | * @param adh our attribute deletion handle | ||
1018 | * @param success the success status | ||
1019 | */ | ||
892 | static void | 1020 | static void |
893 | send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) | 1021 | send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) |
894 | { | 1022 | { |
@@ -907,6 +1035,16 @@ send_delete_response (struct AttributeDeleteHandle *adh, int32_t success) | |||
907 | } | 1035 | } |
908 | 1036 | ||
909 | 1037 | ||
1038 | /** | ||
1039 | * Namestore iteration within attribute deletion. | ||
1040 | * We need to reissue tickets with the deleted attribute removed. | ||
1041 | * | ||
1042 | * @param cls our attribute deletion handle | ||
1043 | * @param zone the private key of the ticket issuer | ||
1044 | * @param label the label of the record | ||
1045 | * @param rd_count number of records | ||
1046 | * @param rd record data | ||
1047 | */ | ||
910 | static void | 1048 | static void |
911 | ticket_iter (void *cls, | 1049 | ticket_iter (void *cls, |
912 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1050 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -944,10 +1082,21 @@ ticket_iter (void *cls, | |||
944 | } | 1082 | } |
945 | 1083 | ||
946 | 1084 | ||
1085 | /** | ||
1086 | * Recursion prototype for function | ||
1087 | * @param cls our deletion handle | ||
1088 | */ | ||
947 | static void | 1089 | static void |
948 | update_tickets (void *cls); | 1090 | update_tickets (void *cls); |
949 | 1091 | ||
950 | 1092 | ||
1093 | /** | ||
1094 | * Callback called when a ticket was updated | ||
1095 | * | ||
1096 | * @param cls our attribute deletion handle | ||
1097 | * @param success GNUNET_OK if successful | ||
1098 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1099 | */ | ||
951 | static void | 1100 | static void |
952 | ticket_updated (void *cls, int32_t success, const char *emsg) | 1101 | ticket_updated (void *cls, int32_t success, const char *emsg) |
953 | { | 1102 | { |
@@ -956,6 +1105,14 @@ ticket_updated (void *cls, int32_t success, const char *emsg) | |||
956 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); | 1105 | GNUNET_SCHEDULER_add_now (&update_tickets, adh); |
957 | } | 1106 | } |
958 | 1107 | ||
1108 | |||
1109 | /** | ||
1110 | * Update tickets: Remove shared attribute which has just been deleted. | ||
1111 | * This method is called recursively until all tickets are processed. | ||
1112 | * Eventually, the updated tickets are stored using ``update_tickets''. | ||
1113 | * | ||
1114 | * @param cls our attribute deletion handle | ||
1115 | */ | ||
959 | static void | 1116 | static void |
960 | update_tickets (void *cls) | 1117 | update_tickets (void *cls) |
961 | { | 1118 | { |
@@ -1002,6 +1159,11 @@ update_tickets (void *cls) | |||
1002 | } | 1159 | } |
1003 | 1160 | ||
1004 | 1161 | ||
1162 | /** | ||
1163 | * Done collecting affected tickets, start updating. | ||
1164 | * | ||
1165 | * @param cls our attribute deletion handle | ||
1166 | */ | ||
1005 | static void | 1167 | static void |
1006 | ticket_iter_fin (void *cls) | 1168 | ticket_iter_fin (void *cls) |
1007 | { | 1169 | { |
@@ -1011,6 +1173,11 @@ ticket_iter_fin (void *cls) | |||
1011 | } | 1173 | } |
1012 | 1174 | ||
1013 | 1175 | ||
1176 | /** | ||
1177 | * Error collecting affected tickets. Abort. | ||
1178 | * | ||
1179 | * @param cls our attribute deletion handle | ||
1180 | */ | ||
1014 | static void | 1181 | static void |
1015 | ticket_iter_err (void *cls) | 1182 | ticket_iter_err (void *cls) |
1016 | { | 1183 | { |
@@ -1024,6 +1191,12 @@ ticket_iter_err (void *cls) | |||
1024 | } | 1191 | } |
1025 | 1192 | ||
1026 | 1193 | ||
1194 | /** | ||
1195 | * Start processing tickets which may still contain reference to deleted | ||
1196 | * attribute. | ||
1197 | * | ||
1198 | * @param cls attribute deletion handle | ||
1199 | */ | ||
1027 | static void | 1200 | static void |
1028 | start_ticket_update (void *cls) | 1201 | start_ticket_update (void *cls) |
1029 | { | 1202 | { |
@@ -1039,6 +1212,13 @@ start_ticket_update (void *cls) | |||
1039 | } | 1212 | } |
1040 | 1213 | ||
1041 | 1214 | ||
1215 | /** | ||
1216 | * Attribute deleted callback | ||
1217 | * | ||
1218 | * @param cls our handle | ||
1219 | * @param success success status | ||
1220 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1221 | */ | ||
1042 | static void | 1222 | static void |
1043 | attr_delete_cont (void *cls, int32_t success, const char *emsg) | 1223 | attr_delete_cont (void *cls, int32_t success, const char *emsg) |
1044 | { | 1224 | { |
@@ -1052,11 +1232,17 @@ attr_delete_cont (void *cls, int32_t success, const char *emsg) | |||
1052 | cleanup_adh (adh); | 1232 | cleanup_adh (adh); |
1053 | return; | 1233 | return; |
1054 | } | 1234 | } |
1055 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating tickets...\n"); | 1235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); |
1056 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | 1236 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); |
1057 | } | 1237 | } |
1058 | 1238 | ||
1059 | 1239 | ||
1240 | /** | ||
1241 | * Check attribute delete message format | ||
1242 | * | ||
1243 | * @cls unused | ||
1244 | * @dam message to check | ||
1245 | */ | ||
1060 | static int | 1246 | static int |
1061 | check_attribute_delete_message (void *cls, | 1247 | check_attribute_delete_message (void *cls, |
1062 | const struct AttributeDeleteMessage *dam) | 1248 | const struct AttributeDeleteMessage *dam) |
@@ -1072,6 +1258,12 @@ check_attribute_delete_message (void *cls, | |||
1072 | } | 1258 | } |
1073 | 1259 | ||
1074 | 1260 | ||
1261 | /** | ||
1262 | * Handle attribute deletion | ||
1263 | * | ||
1264 | * @param cls our client | ||
1265 | * @param dam deletion message | ||
1266 | */ | ||
1075 | static void | 1267 | static void |
1076 | handle_attribute_delete_message (void *cls, | 1268 | handle_attribute_delete_message (void *cls, |
1077 | const struct AttributeDeleteMessage *dam) | 1269 | const struct AttributeDeleteMessage *dam) |
@@ -1107,24 +1299,12 @@ handle_attribute_delete_message (void *cls, | |||
1107 | * Attrubute iteration | 1299 | * Attrubute iteration |
1108 | *************************************************/ | 1300 | *************************************************/ |
1109 | 1301 | ||
1110 | static void | ||
1111 | cleanup_attribute_iter_handle (struct AttributeIterator *ai) | ||
1112 | { | ||
1113 | GNUNET_free (ai); | ||
1114 | } | ||
1115 | |||
1116 | static void | ||
1117 | attr_iter_error (void *cls) | ||
1118 | { | ||
1119 | struct AttributeIterator *ai = cls; | ||
1120 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); | ||
1121 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, | ||
1122 | ai->client->attr_iter_tail, | ||
1123 | ai); | ||
1124 | cleanup_attribute_iter_handle (ai); | ||
1125 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1126 | } | ||
1127 | 1302 | ||
1303 | /** | ||
1304 | * Done iterating over attributes | ||
1305 | * | ||
1306 | * @param cls our iterator handle | ||
1307 | */ | ||
1128 | static void | 1308 | static void |
1129 | attr_iter_finished (void *cls) | 1309 | attr_iter_finished (void *cls) |
1130 | { | 1310 | { |
@@ -1140,9 +1320,33 @@ attr_iter_finished (void *cls) | |||
1140 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, | 1320 | GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, |
1141 | ai->client->attr_iter_tail, | 1321 | ai->client->attr_iter_tail, |
1142 | ai); | 1322 | ai); |
1143 | cleanup_attribute_iter_handle (ai); | 1323 | GNUNET_free (ai); |
1324 | } | ||
1325 | |||
1326 | /** | ||
1327 | * Error iterating over attributes. Abort. | ||
1328 | * | ||
1329 | * @param cls our attribute iteration handle | ||
1330 | */ | ||
1331 | static void | ||
1332 | attr_iter_error (void *cls) | ||
1333 | { | ||
1334 | struct AttributeIterator *ai = cls; | ||
1335 | |||
1336 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n"); | ||
1337 | attr_iter_finished (ai); | ||
1144 | } | 1338 | } |
1145 | 1339 | ||
1340 | |||
1341 | /** | ||
1342 | * Got record. Return if it is an attribute. | ||
1343 | * | ||
1344 | * @param cls our attribute iterator | ||
1345 | * @param zone zone we are iterating | ||
1346 | * @param label label of the records | ||
1347 | * @param rd_count record count | ||
1348 | * @param rd records | ||
1349 | */ | ||
1146 | static void | 1350 | static void |
1147 | attr_iter_cb (void *cls, | 1351 | attr_iter_cb (void *cls, |
1148 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1352 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -1177,6 +1381,13 @@ attr_iter_cb (void *cls, | |||
1177 | GNUNET_MQ_send (ai->client->mq, env); | 1381 | GNUNET_MQ_send (ai->client->mq, env); |
1178 | } | 1382 | } |
1179 | 1383 | ||
1384 | |||
1385 | /** | ||
1386 | * Iterate over zone to get attributes | ||
1387 | * | ||
1388 | * @param cls our client | ||
1389 | * @param ais_msg the iteration message to start | ||
1390 | */ | ||
1180 | static void | 1391 | static void |
1181 | handle_iteration_start (void *cls, | 1392 | handle_iteration_start (void *cls, |
1182 | const struct AttributeIterationStartMessage *ais_msg) | 1393 | const struct AttributeIterationStartMessage *ais_msg) |
@@ -1203,6 +1414,13 @@ handle_iteration_start (void *cls, | |||
1203 | GNUNET_SERVICE_client_continue (idp->client); | 1414 | GNUNET_SERVICE_client_continue (idp->client); |
1204 | } | 1415 | } |
1205 | 1416 | ||
1417 | |||
1418 | /** | ||
1419 | * Handle iteration stop message from client | ||
1420 | * | ||
1421 | * @param cls the client | ||
1422 | * @param ais_msg the stop message | ||
1423 | */ | ||
1206 | static void | 1424 | static void |
1207 | handle_iteration_stop (void *cls, | 1425 | handle_iteration_stop (void *cls, |
1208 | const struct AttributeIterationStopMessage *ais_msg) | 1426 | const struct AttributeIterationStopMessage *ais_msg) |
@@ -1228,6 +1446,13 @@ handle_iteration_stop (void *cls, | |||
1228 | GNUNET_SERVICE_client_continue (idp->client); | 1446 | GNUNET_SERVICE_client_continue (idp->client); |
1229 | } | 1447 | } |
1230 | 1448 | ||
1449 | |||
1450 | /** | ||
1451 | * Client requests next attribute from iterator | ||
1452 | * | ||
1453 | * @param cls the client | ||
1454 | * @param ais_msg the message | ||
1455 | */ | ||
1231 | static void | 1456 | static void |
1232 | handle_iteration_next (void *cls, | 1457 | handle_iteration_next (void *cls, |
1233 | const struct AttributeIterationNextMessage *ais_msg) | 1458 | const struct AttributeIterationNextMessage *ais_msg) |
@@ -1255,6 +1480,12 @@ handle_iteration_next (void *cls, | |||
1255 | * Ticket iteration | 1480 | * Ticket iteration |
1256 | ******************************************************/ | 1481 | ******************************************************/ |
1257 | 1482 | ||
1483 | /** | ||
1484 | * Got a ticket. Return to client | ||
1485 | * | ||
1486 | * @param cls our ticket iterator | ||
1487 | * @param ticket the ticket | ||
1488 | */ | ||
1258 | static void | 1489 | static void |
1259 | ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | 1490 | ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) |
1260 | { | 1491 | { |
@@ -1281,6 +1512,13 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
1281 | GNUNET_free (ti); | 1512 | GNUNET_free (ti); |
1282 | } | 1513 | } |
1283 | 1514 | ||
1515 | |||
1516 | /** | ||
1517 | * Client requests a ticket iteration | ||
1518 | * | ||
1519 | * @param cls the client | ||
1520 | * @param tis_msg the iteration request message | ||
1521 | */ | ||
1284 | static void | 1522 | static void |
1285 | handle_ticket_iteration_start ( | 1523 | handle_ticket_iteration_start ( |
1286 | void *cls, | 1524 | void *cls, |
@@ -1303,6 +1541,13 @@ handle_ticket_iteration_start ( | |||
1303 | GNUNET_SERVICE_client_continue (client->client); | 1541 | GNUNET_SERVICE_client_continue (client->client); |
1304 | } | 1542 | } |
1305 | 1543 | ||
1544 | |||
1545 | /** | ||
1546 | * Client has had enough tickets | ||
1547 | * | ||
1548 | * @param cls the client | ||
1549 | * @param tis_msg the stop message | ||
1550 | */ | ||
1306 | static void | 1551 | static void |
1307 | handle_ticket_iteration_stop (void *cls, | 1552 | handle_ticket_iteration_stop (void *cls, |
1308 | const struct TicketIterationStopMessage *tis_msg) | 1553 | const struct TicketIterationStopMessage *tis_msg) |
@@ -1331,6 +1576,13 @@ handle_ticket_iteration_stop (void *cls, | |||
1331 | GNUNET_SERVICE_client_continue (client->client); | 1576 | GNUNET_SERVICE_client_continue (client->client); |
1332 | } | 1577 | } |
1333 | 1578 | ||
1579 | |||
1580 | /** | ||
1581 | * Client requests next result. | ||
1582 | * | ||
1583 | * @param cls the client | ||
1584 | * @param tis_msg the message | ||
1585 | */ | ||
1334 | static void | 1586 | static void |
1335 | handle_ticket_iteration_next (void *cls, | 1587 | handle_ticket_iteration_next (void *cls, |
1336 | const struct TicketIterationNextMessage *tis_msg) | 1588 | const struct TicketIterationNextMessage *tis_msg) |
@@ -1354,6 +1606,7 @@ handle_ticket_iteration_next (void *cls, | |||
1354 | GNUNET_SERVICE_client_continue (client->client); | 1606 | GNUNET_SERVICE_client_continue (client->client); |
1355 | } | 1607 | } |
1356 | 1608 | ||
1609 | |||
1357 | /** | 1610 | /** |
1358 | * Main function that will be run | 1611 | * Main function that will be run |
1359 | * | 1612 | * |
@@ -1400,6 +1653,7 @@ run (void *cls, | |||
1400 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 1653 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
1401 | } | 1654 | } |
1402 | 1655 | ||
1656 | |||
1403 | /** | 1657 | /** |
1404 | * Called whenever a client is disconnected. | 1658 | * Called whenever a client is disconnected. |
1405 | * | 1659 | * |
@@ -1421,8 +1675,6 @@ client_disconnect_cb (void *cls, | |||
1421 | struct AttributeStoreHandle *as; | 1675 | struct AttributeStoreHandle *as; |
1422 | struct AttributeDeleteHandle *adh; | 1676 | struct AttributeDeleteHandle *adh; |
1423 | 1677 | ||
1424 | // TODO other operations | ||
1425 | |||
1426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); | 1678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); |
1427 | 1679 | ||
1428 | while (NULL != (iss = idp->issue_op_head)) { | 1680 | while (NULL != (iss = idp->issue_op_head)) { |
@@ -1448,7 +1700,7 @@ client_disconnect_cb (void *cls, | |||
1448 | 1700 | ||
1449 | while (NULL != (ai = idp->attr_iter_head)) { | 1701 | while (NULL != (ai = idp->attr_iter_head)) { |
1450 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); | 1702 | GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); |
1451 | cleanup_attribute_iter_handle (ai); | 1703 | GNUNET_free (ai); |
1452 | } | 1704 | } |
1453 | while (NULL != (rop = idp->revoke_op_head)) { | 1705 | while (NULL != (rop = idp->revoke_op_head)) { |
1454 | GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); | 1706 | GNUNET_CONTAINER_DLL_remove (idp->revoke_op_head, idp->revoke_op_tail, rop); |
@@ -1465,6 +1717,7 @@ client_disconnect_cb (void *cls, | |||
1465 | GNUNET_free (idp); | 1717 | GNUNET_free (idp); |
1466 | } | 1718 | } |
1467 | 1719 | ||
1720 | |||
1468 | /** | 1721 | /** |
1469 | * Add a client to our list of active clients. | 1722 | * Add a client to our list of active clients. |
1470 | * | 1723 | * |
@@ -1486,6 +1739,7 @@ client_connect_cb (void *cls, | |||
1486 | return idp; | 1739 | return idp; |
1487 | } | 1740 | } |
1488 | 1741 | ||
1742 | |||
1489 | /** | 1743 | /** |
1490 | * Define "main" method using service macro. | 1744 | * Define "main" method using service macro. |
1491 | */ | 1745 | */ |
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) | |||
610 | GNUNET_assert (0); | 610 | GNUNET_assert (0); |
611 | } | 611 | } |
612 | 612 | ||
613 | |||
613 | /** | 614 | /** |
614 | * Handle an incoming message of type | 615 | * Handle an incoming message of type |
615 | * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT | 616 | * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT |