diff options
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r-- | src/identity/identity_api.c | 605 |
1 files changed, 301 insertions, 304 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index c463da641..530ee2d13 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -16,7 +16,7 @@ | |||
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 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file identity/identity_api.c | 22 | * @file identity/identity_api.c |
@@ -30,15 +30,13 @@ | |||
30 | #include "gnunet_identity_service.h" | 30 | #include "gnunet_identity_service.h" |
31 | #include "identity.h" | 31 | #include "identity.h" |
32 | 32 | ||
33 | #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) | 33 | #define LOG(kind, ...) GNUNET_log_from(kind, "identity-api", __VA_ARGS__) |
34 | 34 | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Handle for an operation with the identity service. | 37 | * Handle for an operation with the identity service. |
38 | */ | 38 | */ |
39 | struct GNUNET_IDENTITY_Operation | 39 | struct GNUNET_IDENTITY_Operation { |
40 | { | ||
41 | |||
42 | /** | 40 | /** |
43 | * Main identity handle. | 41 | * Main identity handle. |
44 | */ | 42 | */ |
@@ -93,8 +91,7 @@ struct GNUNET_IDENTITY_Operation | |||
93 | /** | 91 | /** |
94 | * Handle for the service. | 92 | * Handle for the service. |
95 | */ | 93 | */ |
96 | struct GNUNET_IDENTITY_Handle | 94 | struct GNUNET_IDENTITY_Handle { |
97 | { | ||
98 | /** | 95 | /** |
99 | * Configuration to use. | 96 | * Configuration to use. |
100 | */ | 97 | */ |
@@ -154,7 +151,7 @@ struct GNUNET_IDENTITY_Handle | |||
154 | * @return handle for the anonymous user, must not be freed | 151 | * @return handle for the anonymous user, must not be freed |
155 | */ | 152 | */ |
156 | const struct GNUNET_IDENTITY_Ego * | 153 | const struct GNUNET_IDENTITY_Ego * |
157 | GNUNET_IDENTITY_ego_get_anonymous () | 154 | GNUNET_IDENTITY_ego_get_anonymous() |
158 | { | 155 | { |
159 | static struct GNUNET_IDENTITY_Ego anon; | 156 | static struct GNUNET_IDENTITY_Ego anon; |
160 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 157 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
@@ -162,9 +159,9 @@ GNUNET_IDENTITY_ego_get_anonymous () | |||
162 | if (NULL != anon.pk) | 159 | if (NULL != anon.pk) |
163 | return &anon; | 160 | return &anon; |
164 | anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) | 161 | anon.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) |
165 | GNUNET_CRYPTO_ecdsa_key_get_anonymous (); | 162 | GNUNET_CRYPTO_ecdsa_key_get_anonymous(); |
166 | GNUNET_CRYPTO_ecdsa_key_get_public (anon.pk, &pub); | 163 | GNUNET_CRYPTO_ecdsa_key_get_public(anon.pk, &pub); |
167 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &anon.id); | 164 | GNUNET_CRYPTO_hash(&pub, sizeof(pub), &anon.id); |
168 | return &anon; | 165 | return &anon; |
169 | } | 166 | } |
170 | 167 | ||
@@ -175,7 +172,7 @@ GNUNET_IDENTITY_ego_get_anonymous () | |||
175 | * @param cls handle to the identity service. | 172 | * @param cls handle to the identity service. |
176 | */ | 173 | */ |
177 | static void | 174 | static void |
178 | reconnect (void *cls); | 175 | reconnect(void *cls); |
179 | 176 | ||
180 | 177 | ||
181 | /** | 178 | /** |
@@ -187,18 +184,18 @@ reconnect (void *cls); | |||
187 | * @return #GNUNET_OK (continue to iterate) | 184 | * @return #GNUNET_OK (continue to iterate) |
188 | */ | 185 | */ |
189 | static int | 186 | static int |
190 | free_ego (void *cls, const struct GNUNET_HashCode *key, void *value) | 187 | free_ego(void *cls, const struct GNUNET_HashCode *key, void *value) |
191 | { | 188 | { |
192 | struct GNUNET_IDENTITY_Handle *h = cls; | 189 | struct GNUNET_IDENTITY_Handle *h = cls; |
193 | struct GNUNET_IDENTITY_Ego *ego = value; | 190 | struct GNUNET_IDENTITY_Ego *ego = value; |
194 | 191 | ||
195 | if (NULL != h->cb) | 192 | if (NULL != h->cb) |
196 | h->cb (h->cb_cls, ego, &ego->ctx, NULL); | 193 | h->cb(h->cb_cls, ego, &ego->ctx, NULL); |
197 | GNUNET_free (ego->pk); | 194 | GNUNET_free(ego->pk); |
198 | GNUNET_free (ego->name); | 195 | GNUNET_free(ego->name); |
199 | GNUNET_assert (GNUNET_YES == | 196 | GNUNET_assert(GNUNET_YES == |
200 | GNUNET_CONTAINER_multihashmap_remove (h->egos, key, value)); | 197 | GNUNET_CONTAINER_multihashmap_remove(h->egos, key, value)); |
201 | GNUNET_free (ego); | 198 | GNUNET_free(ego); |
202 | return GNUNET_OK; | 199 | return GNUNET_OK; |
203 | } | 200 | } |
204 | 201 | ||
@@ -209,38 +206,38 @@ free_ego (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
209 | * @param h transport service to reconnect | 206 | * @param h transport service to reconnect |
210 | */ | 207 | */ |
211 | static void | 208 | static void |
212 | reschedule_connect (struct GNUNET_IDENTITY_Handle *h) | 209 | reschedule_connect(struct GNUNET_IDENTITY_Handle *h) |
213 | { | 210 | { |
214 | struct GNUNET_IDENTITY_Operation *op; | 211 | struct GNUNET_IDENTITY_Operation *op; |
215 | 212 | ||
216 | GNUNET_assert (NULL == h->reconnect_task); | 213 | GNUNET_assert(NULL == h->reconnect_task); |
217 | 214 | ||
218 | if (NULL != h->mq) | 215 | if (NULL != h->mq) |
219 | { | 216 | { |
220 | GNUNET_MQ_destroy (h->mq); | 217 | GNUNET_MQ_destroy(h->mq); |
221 | h->mq = NULL; | 218 | h->mq = NULL; |
222 | } | 219 | } |
223 | while (NULL != (op = h->op_head)) | 220 | while (NULL != (op = h->op_head)) |
224 | { | 221 | { |
225 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 222 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
226 | if (NULL != op->cont) | 223 | if (NULL != op->cont) |
227 | op->cont (op->cls, "Error in communication with the identity service"); | 224 | op->cont(op->cls, "Error in communication with the identity service"); |
228 | else if (NULL != op->cb) | 225 | else if (NULL != op->cb) |
229 | op->cb (op->cls, NULL, NULL, NULL); | 226 | op->cb(op->cls, NULL, NULL, NULL); |
230 | else if (NULL != op->create_cont) | 227 | else if (NULL != op->create_cont) |
231 | op->create_cont (op->cls, | 228 | op->create_cont(op->cls, |
232 | NULL, | 229 | NULL, |
233 | "Failed to communicate with the identity service"); | 230 | "Failed to communicate with the identity service"); |
234 | GNUNET_free_non_null (op->pk); | 231 | GNUNET_free_non_null(op->pk); |
235 | GNUNET_free (op); | 232 | GNUNET_free(op); |
236 | } | 233 | } |
237 | GNUNET_CONTAINER_multihashmap_iterate (h->egos, &free_ego, h); | 234 | GNUNET_CONTAINER_multihashmap_iterate(h->egos, &free_ego, h); |
238 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 235 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
239 | "Scheduling task to reconnect to identity service in %s.\n", | 236 | "Scheduling task to reconnect to identity service in %s.\n", |
240 | GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES)); | 237 | GNUNET_STRINGS_relative_time_to_string(h->reconnect_delay, GNUNET_YES)); |
241 | h->reconnect_task = | 238 | h->reconnect_task = |
242 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); | 239 | GNUNET_SCHEDULER_add_delayed(h->reconnect_delay, &reconnect, h); |
243 | h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); | 240 | h->reconnect_delay = GNUNET_TIME_STD_BACKOFF(h->reconnect_delay); |
244 | } | 241 | } |
245 | 242 | ||
246 | 243 | ||
@@ -253,11 +250,11 @@ reschedule_connect (struct GNUNET_IDENTITY_Handle *h) | |||
253 | * @param error error code | 250 | * @param error error code |
254 | */ | 251 | */ |
255 | static void | 252 | static void |
256 | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | 253 | mq_error_handler(void *cls, enum GNUNET_MQ_Error error) |
257 | { | 254 | { |
258 | struct GNUNET_IDENTITY_Handle *h = cls; | 255 | struct GNUNET_IDENTITY_Handle *h = cls; |
259 | 256 | ||
260 | reschedule_connect (h); | 257 | reschedule_connect(h); |
261 | } | 258 | } |
262 | 259 | ||
263 | 260 | ||
@@ -270,10 +267,10 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error) | |||
270 | * @return #GNUNET_OK if the message is well-formed | 267 | * @return #GNUNET_OK if the message is well-formed |
271 | */ | 268 | */ |
272 | static int | 269 | static int |
273 | check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) | 270 | check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) |
274 | { | 271 | { |
275 | if (sizeof (*rcm) != htons (rcm->header.size)) | 272 | if (sizeof(*rcm) != htons(rcm->header.size)) |
276 | GNUNET_MQ_check_zero_termination (rcm); | 273 | GNUNET_MQ_check_zero_termination(rcm); |
277 | return GNUNET_OK; | 274 | return GNUNET_OK; |
278 | } | 275 | } |
279 | 276 | ||
@@ -285,29 +282,29 @@ check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) | |||
285 | * @param rcm result message received | 282 | * @param rcm result message received |
286 | */ | 283 | */ |
287 | static void | 284 | static void |
288 | handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) | 285 | handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) |
289 | { | 286 | { |
290 | struct GNUNET_IDENTITY_Handle *h = cls; | 287 | struct GNUNET_IDENTITY_Handle *h = cls; |
291 | struct GNUNET_IDENTITY_Operation *op; | 288 | struct GNUNET_IDENTITY_Operation *op; |
292 | uint16_t size = ntohs (rcm->header.size) - sizeof (*rcm); | 289 | uint16_t size = ntohs(rcm->header.size) - sizeof(*rcm); |
293 | const char *str = (0 == size) ? NULL : (const char *) &rcm[1]; | 290 | const char *str = (0 == size) ? NULL : (const char *)&rcm[1]; |
294 | 291 | ||
295 | op = h->op_head; | 292 | op = h->op_head; |
296 | if (NULL == op) | 293 | if (NULL == op) |
297 | { | 294 | { |
298 | GNUNET_break (0); | 295 | GNUNET_break(0); |
299 | reschedule_connect (h); | 296 | reschedule_connect(h); |
300 | return; | 297 | return; |
301 | } | 298 | } |
302 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 299 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
303 | if (NULL != op->cont) | 300 | if (NULL != op->cont) |
304 | op->cont (op->cls, str); | 301 | op->cont(op->cls, str); |
305 | else if (NULL != op->cb) | 302 | else if (NULL != op->cb) |
306 | op->cb (op->cls, NULL, NULL, NULL); | 303 | op->cb(op->cls, NULL, NULL, NULL); |
307 | else if (NULL != op->create_cont) | 304 | else if (NULL != op->create_cont) |
308 | op->create_cont (op->cls, (NULL == str) ? op->pk : NULL, str); | 305 | op->create_cont(op->cls, (NULL == str) ? op->pk : NULL, str); |
309 | GNUNET_free_non_null (op->pk); | 306 | GNUNET_free_non_null(op->pk); |
310 | GNUNET_free (op); | 307 | GNUNET_free(op); |
311 | } | 308 | } |
312 | 309 | ||
313 | 310 | ||
@@ -319,18 +316,18 @@ handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) | |||
319 | * @return #GNUNET_OK if the message is well-formed | 316 | * @return #GNUNET_OK if the message is well-formed |
320 | */ | 317 | */ |
321 | static int | 318 | static int |
322 | check_identity_update (void *cls, const struct UpdateMessage *um) | 319 | check_identity_update(void *cls, const struct UpdateMessage *um) |
323 | { | 320 | { |
324 | uint16_t size = ntohs (um->header.size); | 321 | uint16_t size = ntohs(um->header.size); |
325 | uint16_t name_len = ntohs (um->name_len); | 322 | uint16_t name_len = ntohs(um->name_len); |
326 | const char *str = (const char *) &um[1]; | 323 | const char *str = (const char *)&um[1]; |
327 | 324 | ||
328 | if ((size != name_len + sizeof (struct UpdateMessage)) || | 325 | if ((size != name_len + sizeof(struct UpdateMessage)) || |
329 | ((0 != name_len) && ('\0' != str[name_len - 1]))) | 326 | ((0 != name_len) && ('\0' != str[name_len - 1]))) |
330 | { | 327 | { |
331 | GNUNET_break (0); | 328 | GNUNET_break(0); |
332 | return GNUNET_SYSERR; | 329 | return GNUNET_SYSERR; |
333 | } | 330 | } |
334 | return GNUNET_OK; | 331 | return GNUNET_OK; |
335 | } | 332 | } |
336 | 333 | ||
@@ -342,70 +339,70 @@ check_identity_update (void *cls, const struct UpdateMessage *um) | |||
342 | * @param um message received | 339 | * @param um message received |
343 | */ | 340 | */ |
344 | static void | 341 | static void |
345 | handle_identity_update (void *cls, const struct UpdateMessage *um) | 342 | handle_identity_update(void *cls, const struct UpdateMessage *um) |
346 | { | 343 | { |
347 | struct GNUNET_IDENTITY_Handle *h = cls; | 344 | struct GNUNET_IDENTITY_Handle *h = cls; |
348 | uint16_t name_len = ntohs (um->name_len); | 345 | uint16_t name_len = ntohs(um->name_len); |
349 | const char *str = (0 == name_len) ? NULL : (const char *) &um[1]; | 346 | const char *str = (0 == name_len) ? NULL : (const char *)&um[1]; |
350 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 347 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
351 | struct GNUNET_HashCode id; | 348 | struct GNUNET_HashCode id; |
352 | struct GNUNET_IDENTITY_Ego *ego; | 349 | struct GNUNET_IDENTITY_Ego *ego; |
353 | 350 | ||
354 | if (GNUNET_YES == ntohs (um->end_of_list)) | 351 | if (GNUNET_YES == ntohs(um->end_of_list)) |
355 | { | ||
356 | /* end of initial list of data */ | ||
357 | if (NULL != h->cb) | ||
358 | h->cb (h->cb_cls, NULL, NULL, NULL); | ||
359 | return; | ||
360 | } | ||
361 | GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub); | ||
362 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); | ||
363 | ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id); | ||
364 | if (NULL == ego) | ||
365 | { | ||
366 | /* ego was created */ | ||
367 | if (NULL == str) | ||
368 | { | 352 | { |
369 | /* deletion of unknown ego? not allowed */ | 353 | /* end of initial list of data */ |
370 | GNUNET_break (0); | 354 | if (NULL != h->cb) |
371 | reschedule_connect (h); | 355 | h->cb(h->cb_cls, NULL, NULL, NULL); |
372 | return; | 356 | return; |
373 | } | 357 | } |
374 | ego = GNUNET_new (struct GNUNET_IDENTITY_Ego); | 358 | GNUNET_CRYPTO_ecdsa_key_get_public(&um->private_key, &pub); |
375 | ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); | 359 | GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); |
376 | *ego->pk = um->private_key; | 360 | ego = GNUNET_CONTAINER_multihashmap_get(h->egos, &id); |
377 | ego->name = GNUNET_strdup (str); | 361 | if (NULL == ego) |
378 | ego->id = id; | 362 | { |
379 | GNUNET_assert (GNUNET_YES == | 363 | /* ego was created */ |
380 | GNUNET_CONTAINER_multihashmap_put ( | 364 | if (NULL == str) |
381 | h->egos, | 365 | { |
382 | &ego->id, | 366 | /* deletion of unknown ego? not allowed */ |
383 | ego, | 367 | GNUNET_break(0); |
384 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 368 | reschedule_connect(h); |
385 | } | 369 | return; |
370 | } | ||
371 | ego = GNUNET_new(struct GNUNET_IDENTITY_Ego); | ||
372 | ego->pk = GNUNET_new(struct GNUNET_CRYPTO_EcdsaPrivateKey); | ||
373 | *ego->pk = um->private_key; | ||
374 | ego->name = GNUNET_strdup(str); | ||
375 | ego->id = id; | ||
376 | GNUNET_assert(GNUNET_YES == | ||
377 | GNUNET_CONTAINER_multihashmap_put( | ||
378 | h->egos, | ||
379 | &ego->id, | ||
380 | ego, | ||
381 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
382 | } | ||
386 | if (NULL == str) | 383 | if (NULL == str) |
387 | { | 384 | { |
388 | /* ego was deleted */ | 385 | /* ego was deleted */ |
389 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (h->egos, | 386 | GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(h->egos, |
390 | &ego->id, | 387 | &ego->id, |
391 | ego)); | 388 | ego)); |
392 | } | 389 | } |
393 | else | 390 | else |
394 | { | 391 | { |
395 | /* ego changed name */ | 392 | /* ego changed name */ |
396 | GNUNET_free (ego->name); | 393 | GNUNET_free(ego->name); |
397 | ego->name = GNUNET_strdup (str); | 394 | ego->name = GNUNET_strdup(str); |
398 | } | 395 | } |
399 | /* inform application about change */ | 396 | /* inform application about change */ |
400 | if (NULL != h->cb) | 397 | if (NULL != h->cb) |
401 | h->cb (h->cb_cls, ego, &ego->ctx, str); | 398 | h->cb(h->cb_cls, ego, &ego->ctx, str); |
402 | /* complete deletion */ | 399 | /* complete deletion */ |
403 | if (NULL == str) | 400 | if (NULL == str) |
404 | { | 401 | { |
405 | GNUNET_free (ego->pk); | 402 | GNUNET_free(ego->pk); |
406 | GNUNET_free (ego->name); | 403 | GNUNET_free(ego->name); |
407 | GNUNET_free (ego); | 404 | GNUNET_free(ego); |
408 | } | 405 | } |
409 | } | 406 | } |
410 | 407 | ||
411 | 408 | ||
@@ -418,18 +415,18 @@ handle_identity_update (void *cls, const struct UpdateMessage *um) | |||
418 | * @return #GNUNET_OK if the message is well-formed | 415 | * @return #GNUNET_OK if the message is well-formed |
419 | */ | 416 | */ |
420 | static int | 417 | static int |
421 | check_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) | 418 | check_identity_set_default(void *cls, const struct SetDefaultMessage *sdm) |
422 | { | 419 | { |
423 | uint16_t size = ntohs (sdm->header.size) - sizeof (*sdm); | 420 | uint16_t size = ntohs(sdm->header.size) - sizeof(*sdm); |
424 | uint16_t name_len = ntohs (sdm->name_len); | 421 | uint16_t name_len = ntohs(sdm->name_len); |
425 | const char *str = (const char *) &sdm[1]; | 422 | const char *str = (const char *)&sdm[1]; |
426 | 423 | ||
427 | if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1]))) | 424 | if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1]))) |
428 | { | 425 | { |
429 | GNUNET_break (0); | 426 | GNUNET_break(0); |
430 | return GNUNET_SYSERR; | 427 | return GNUNET_SYSERR; |
431 | } | 428 | } |
432 | GNUNET_break (0 == ntohs (sdm->reserved)); | 429 | GNUNET_break(0 == ntohs(sdm->reserved)); |
433 | return GNUNET_OK; | 430 | return GNUNET_OK; |
434 | } | 431 | } |
435 | 432 | ||
@@ -442,7 +439,7 @@ check_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) | |||
442 | * @param sdm message received | 439 | * @param sdm message received |
443 | */ | 440 | */ |
444 | static void | 441 | static void |
445 | handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) | 442 | handle_identity_set_default(void *cls, const struct SetDefaultMessage *sdm) |
446 | { | 443 | { |
447 | struct GNUNET_IDENTITY_Handle *h = cls; | 444 | struct GNUNET_IDENTITY_Handle *h = cls; |
448 | struct GNUNET_IDENTITY_Operation *op; | 445 | struct GNUNET_IDENTITY_Operation *op; |
@@ -450,28 +447,28 @@ handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) | |||
450 | struct GNUNET_HashCode id; | 447 | struct GNUNET_HashCode id; |
451 | struct GNUNET_IDENTITY_Ego *ego; | 448 | struct GNUNET_IDENTITY_Ego *ego; |
452 | 449 | ||
453 | GNUNET_CRYPTO_ecdsa_key_get_public (&sdm->private_key, &pub); | 450 | GNUNET_CRYPTO_ecdsa_key_get_public(&sdm->private_key, &pub); |
454 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); | 451 | GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); |
455 | ego = GNUNET_CONTAINER_multihashmap_get (h->egos, &id); | 452 | ego = GNUNET_CONTAINER_multihashmap_get(h->egos, &id); |
456 | if (NULL == ego) | 453 | if (NULL == ego) |
457 | { | 454 | { |
458 | GNUNET_break (0); | 455 | GNUNET_break(0); |
459 | reschedule_connect (h); | 456 | reschedule_connect(h); |
460 | return; | 457 | return; |
461 | } | 458 | } |
462 | op = h->op_head; | 459 | op = h->op_head; |
463 | if (NULL == op) | 460 | if (NULL == op) |
464 | { | 461 | { |
465 | GNUNET_break (0); | 462 | GNUNET_break(0); |
466 | reschedule_connect (h); | 463 | reschedule_connect(h); |
467 | return; | 464 | return; |
468 | } | 465 | } |
469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 466 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
470 | "Received SET_DEFAULT message from identity service\n"); | 467 | "Received SET_DEFAULT message from identity service\n"); |
471 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 468 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
472 | if (NULL != op->cb) | 469 | if (NULL != op->cb) |
473 | op->cb (op->cls, ego, &ego->ctx, ego->name); | 470 | op->cb(op->cls, ego, &ego->ctx, ego->name); |
474 | GNUNET_free (op); | 471 | GNUNET_free(op); |
475 | } | 472 | } |
476 | 473 | ||
477 | 474 | ||
@@ -481,38 +478,38 @@ handle_identity_set_default (void *cls, const struct SetDefaultMessage *sdm) | |||
481 | * @param cls handle to the identity service. | 478 | * @param cls handle to the identity service. |
482 | */ | 479 | */ |
483 | static void | 480 | static void |
484 | reconnect (void *cls) | 481 | reconnect(void *cls) |
485 | { | 482 | { |
486 | struct GNUNET_IDENTITY_Handle *h = cls; | 483 | struct GNUNET_IDENTITY_Handle *h = cls; |
487 | struct GNUNET_MQ_MessageHandler handlers[] = | 484 | struct GNUNET_MQ_MessageHandler handlers[] = |
488 | {GNUNET_MQ_hd_var_size (identity_result_code, | 485 | { GNUNET_MQ_hd_var_size(identity_result_code, |
489 | GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, | 486 | GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, |
490 | struct ResultCodeMessage, | 487 | struct ResultCodeMessage, |
491 | h), | 488 | h), |
492 | GNUNET_MQ_hd_var_size (identity_update, | 489 | GNUNET_MQ_hd_var_size(identity_update, |
493 | GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, | 490 | GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, |
494 | struct UpdateMessage, | 491 | struct UpdateMessage, |
495 | h), | 492 | h), |
496 | GNUNET_MQ_hd_var_size (identity_set_default, | 493 | GNUNET_MQ_hd_var_size(identity_set_default, |
497 | GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, | 494 | GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, |
498 | struct SetDefaultMessage, | 495 | struct SetDefaultMessage, |
499 | h), | 496 | h), |
500 | GNUNET_MQ_handler_end ()}; | 497 | GNUNET_MQ_handler_end() }; |
501 | struct GNUNET_MQ_Envelope *env; | 498 | struct GNUNET_MQ_Envelope *env; |
502 | struct GNUNET_MessageHeader *msg; | 499 | struct GNUNET_MessageHeader *msg; |
503 | 500 | ||
504 | h->reconnect_task = NULL; | 501 | h->reconnect_task = NULL; |
505 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n"); | 502 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to identity service.\n"); |
506 | GNUNET_assert (NULL == h->mq); | 503 | GNUNET_assert(NULL == h->mq); |
507 | h->mq = | 504 | h->mq = |
508 | GNUNET_CLIENT_connect (h->cfg, "identity", handlers, &mq_error_handler, h); | 505 | GNUNET_CLIENT_connect(h->cfg, "identity", handlers, &mq_error_handler, h); |
509 | if (NULL == h->mq) | 506 | if (NULL == h->mq) |
510 | return; | 507 | return; |
511 | if (NULL != h->cb) | 508 | if (NULL != h->cb) |
512 | { | 509 | { |
513 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_IDENTITY_START); | 510 | env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_IDENTITY_START); |
514 | GNUNET_MQ_send (h->mq, env); | 511 | GNUNET_MQ_send(h->mq, env); |
515 | } | 512 | } |
516 | } | 513 | } |
517 | 514 | ||
518 | 515 | ||
@@ -525,23 +522,23 @@ reconnect (void *cls) | |||
525 | * @return handle to use | 522 | * @return handle to use |
526 | */ | 523 | */ |
527 | struct GNUNET_IDENTITY_Handle * | 524 | struct GNUNET_IDENTITY_Handle * |
528 | GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 525 | GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, |
529 | GNUNET_IDENTITY_Callback cb, | 526 | GNUNET_IDENTITY_Callback cb, |
530 | void *cb_cls) | 527 | void *cb_cls) |
531 | { | 528 | { |
532 | struct GNUNET_IDENTITY_Handle *h; | 529 | struct GNUNET_IDENTITY_Handle *h; |
533 | 530 | ||
534 | h = GNUNET_new (struct GNUNET_IDENTITY_Handle); | 531 | h = GNUNET_new(struct GNUNET_IDENTITY_Handle); |
535 | h->cfg = cfg; | 532 | h->cfg = cfg; |
536 | h->cb = cb; | 533 | h->cb = cb; |
537 | h->cb_cls = cb_cls; | 534 | h->cb_cls = cb_cls; |
538 | h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES); | 535 | h->egos = GNUNET_CONTAINER_multihashmap_create(16, GNUNET_YES); |
539 | reconnect (h); | 536 | reconnect(h); |
540 | if (NULL == h->mq) | 537 | if (NULL == h->mq) |
541 | { | 538 | { |
542 | GNUNET_free (h); | 539 | GNUNET_free(h); |
543 | return NULL; | 540 | return NULL; |
544 | } | 541 | } |
545 | return h; | 542 | return h; |
546 | } | 543 | } |
547 | 544 | ||
@@ -553,7 +550,7 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
553 | * @return associated ECC key, valid as long as the ego is valid | 550 | * @return associated ECC key, valid as long as the ego is valid |
554 | */ | 551 | */ |
555 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * | 552 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * |
556 | GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego) | 553 | GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego) |
557 | { | 554 | { |
558 | return ego->pk; | 555 | return ego->pk; |
559 | } | 556 | } |
@@ -566,10 +563,10 @@ GNUNET_IDENTITY_ego_get_private_key (const struct GNUNET_IDENTITY_Ego *ego) | |||
566 | * @param pk set to ego's public key | 563 | * @param pk set to ego's public key |
567 | */ | 564 | */ |
568 | void | 565 | void |
569 | GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego, | 566 | GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, |
570 | struct GNUNET_CRYPTO_EcdsaPublicKey *pk) | 567 | struct GNUNET_CRYPTO_EcdsaPublicKey *pk) |
571 | { | 568 | { |
572 | GNUNET_CRYPTO_ecdsa_key_get_public (ego->pk, pk); | 569 | GNUNET_CRYPTO_ecdsa_key_get_public(ego->pk, pk); |
573 | } | 570 | } |
574 | 571 | ||
575 | 572 | ||
@@ -584,10 +581,10 @@ GNUNET_IDENTITY_ego_get_public_key (const struct GNUNET_IDENTITY_Ego *ego, | |||
584 | * @return handle to abort the operation | 581 | * @return handle to abort the operation |
585 | */ | 582 | */ |
586 | struct GNUNET_IDENTITY_Operation * | 583 | struct GNUNET_IDENTITY_Operation * |
587 | GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, | 584 | GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, |
588 | const char *service_name, | 585 | const char *service_name, |
589 | GNUNET_IDENTITY_Callback cb, | 586 | GNUNET_IDENTITY_Callback cb, |
590 | void *cb_cls) | 587 | void *cb_cls) |
591 | { | 588 | { |
592 | struct GNUNET_IDENTITY_Operation *op; | 589 | struct GNUNET_IDENTITY_Operation *op; |
593 | struct GNUNET_MQ_Envelope *env; | 590 | struct GNUNET_MQ_Envelope *env; |
@@ -596,24 +593,24 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, | |||
596 | 593 | ||
597 | if (NULL == h->mq) | 594 | if (NULL == h->mq) |
598 | return NULL; | 595 | return NULL; |
599 | GNUNET_assert (NULL != h->cb); | 596 | GNUNET_assert(NULL != h->cb); |
600 | slen = strlen (service_name) + 1; | 597 | slen = strlen(service_name) + 1; |
601 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) | 598 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage)) |
602 | { | 599 | { |
603 | GNUNET_break (0); | 600 | GNUNET_break(0); |
604 | return NULL; | 601 | return NULL; |
605 | } | 602 | } |
606 | op = GNUNET_new (struct GNUNET_IDENTITY_Operation); | 603 | op = GNUNET_new(struct GNUNET_IDENTITY_Operation); |
607 | op->h = h; | 604 | op->h = h; |
608 | op->cb = cb; | 605 | op->cb = cb; |
609 | op->cls = cb_cls; | 606 | op->cls = cb_cls; |
610 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 607 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
611 | env = | 608 | env = |
612 | GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT); | 609 | GNUNET_MQ_msg_extra(gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT); |
613 | gdm->name_len = htons (slen); | 610 | gdm->name_len = htons(slen); |
614 | gdm->reserved = htons (0); | 611 | gdm->reserved = htons(0); |
615 | GNUNET_memcpy (&gdm[1], service_name, slen); | 612 | GNUNET_memcpy(&gdm[1], service_name, slen); |
616 | GNUNET_MQ_send (h->mq, env); | 613 | GNUNET_MQ_send(h->mq, env); |
617 | return op; | 614 | return op; |
618 | } | 615 | } |
619 | 616 | ||
@@ -629,11 +626,11 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, | |||
629 | * @return handle to abort the operation | 626 | * @return handle to abort the operation |
630 | */ | 627 | */ |
631 | struct GNUNET_IDENTITY_Operation * | 628 | struct GNUNET_IDENTITY_Operation * |
632 | GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | 629 | GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h, |
633 | const char *service_name, | 630 | const char *service_name, |
634 | struct GNUNET_IDENTITY_Ego *ego, | 631 | struct GNUNET_IDENTITY_Ego *ego, |
635 | GNUNET_IDENTITY_Continuation cont, | 632 | GNUNET_IDENTITY_Continuation cont, |
636 | void *cont_cls) | 633 | void *cont_cls) |
637 | { | 634 | { |
638 | struct GNUNET_IDENTITY_Operation *op; | 635 | struct GNUNET_IDENTITY_Operation *op; |
639 | struct GNUNET_MQ_Envelope *env; | 636 | struct GNUNET_MQ_Envelope *env; |
@@ -642,25 +639,25 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
642 | 639 | ||
643 | if (NULL == h->mq) | 640 | if (NULL == h->mq) |
644 | return NULL; | 641 | return NULL; |
645 | GNUNET_assert (NULL != h->cb); | 642 | GNUNET_assert(NULL != h->cb); |
646 | slen = strlen (service_name) + 1; | 643 | slen = strlen(service_name) + 1; |
647 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) | 644 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage)) |
648 | { | 645 | { |
649 | GNUNET_break (0); | 646 | GNUNET_break(0); |
650 | return NULL; | 647 | return NULL; |
651 | } | 648 | } |
652 | op = GNUNET_new (struct GNUNET_IDENTITY_Operation); | 649 | op = GNUNET_new(struct GNUNET_IDENTITY_Operation); |
653 | op->h = h; | 650 | op->h = h; |
654 | op->cont = cont; | 651 | op->cont = cont; |
655 | op->cls = cont_cls; | 652 | op->cls = cont_cls; |
656 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 653 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
657 | env = | 654 | env = |
658 | GNUNET_MQ_msg_extra (sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); | 655 | GNUNET_MQ_msg_extra(sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); |
659 | sdm->name_len = htons (slen); | 656 | sdm->name_len = htons(slen); |
660 | sdm->reserved = htons (0); | 657 | sdm->reserved = htons(0); |
661 | sdm->private_key = *ego->pk; | 658 | sdm->private_key = *ego->pk; |
662 | GNUNET_memcpy (&sdm[1], service_name, slen); | 659 | GNUNET_memcpy(&sdm[1], service_name, slen); |
663 | GNUNET_MQ_send (h->mq, env); | 660 | GNUNET_MQ_send(h->mq, env); |
664 | return op; | 661 | return op; |
665 | } | 662 | } |
666 | 663 | ||
@@ -675,10 +672,10 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
675 | * @return handle to abort the operation | 672 | * @return handle to abort the operation |
676 | */ | 673 | */ |
677 | struct GNUNET_IDENTITY_Operation * | 674 | struct GNUNET_IDENTITY_Operation * |
678 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | 675 | GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, |
679 | const char *name, | 676 | const char *name, |
680 | GNUNET_IDENTITY_CreateContinuation cont, | 677 | GNUNET_IDENTITY_CreateContinuation cont, |
681 | void *cont_cls) | 678 | void *cont_cls) |
682 | { | 679 | { |
683 | struct GNUNET_IDENTITY_Operation *op; | 680 | struct GNUNET_IDENTITY_Operation *op; |
684 | struct GNUNET_MQ_Envelope *env; | 681 | struct GNUNET_MQ_Envelope *env; |
@@ -688,25 +685,25 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | |||
688 | 685 | ||
689 | if (NULL == h->mq) | 686 | if (NULL == h->mq) |
690 | return NULL; | 687 | return NULL; |
691 | slen = strlen (name) + 1; | 688 | slen = strlen(name) + 1; |
692 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct CreateRequestMessage)) | 689 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct CreateRequestMessage)) |
693 | { | 690 | { |
694 | GNUNET_break (0); | 691 | GNUNET_break(0); |
695 | return NULL; | 692 | return NULL; |
696 | } | 693 | } |
697 | op = GNUNET_new (struct GNUNET_IDENTITY_Operation); | 694 | op = GNUNET_new(struct GNUNET_IDENTITY_Operation); |
698 | op->h = h; | 695 | op->h = h; |
699 | op->create_cont = cont; | 696 | op->create_cont = cont; |
700 | op->cls = cont_cls; | 697 | op->cls = cont_cls; |
701 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 698 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
702 | env = GNUNET_MQ_msg_extra (crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); | 699 | env = GNUNET_MQ_msg_extra(crm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); |
703 | crm->name_len = htons (slen); | 700 | crm->name_len = htons(slen); |
704 | crm->reserved = htons (0); | 701 | crm->reserved = htons(0); |
705 | pk = GNUNET_CRYPTO_ecdsa_key_create (); | 702 | pk = GNUNET_CRYPTO_ecdsa_key_create(); |
706 | crm->private_key = *pk; | 703 | crm->private_key = *pk; |
707 | op->pk = pk; | 704 | op->pk = pk; |
708 | GNUNET_memcpy (&crm[1], name, slen); | 705 | GNUNET_memcpy(&crm[1], name, slen); |
709 | GNUNET_MQ_send (h->mq, env); | 706 | GNUNET_MQ_send(h->mq, env); |
710 | return op; | 707 | return op; |
711 | } | 708 | } |
712 | 709 | ||
@@ -722,11 +719,11 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h, | |||
722 | * @return handle to abort the operation | 719 | * @return handle to abort the operation |
723 | */ | 720 | */ |
724 | struct GNUNET_IDENTITY_Operation * | 721 | struct GNUNET_IDENTITY_Operation * |
725 | GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, | 722 | GNUNET_IDENTITY_rename(struct GNUNET_IDENTITY_Handle *h, |
726 | const char *old_name, | 723 | const char *old_name, |
727 | const char *new_name, | 724 | const char *new_name, |
728 | GNUNET_IDENTITY_Continuation cb, | 725 | GNUNET_IDENTITY_Continuation cb, |
729 | void *cb_cls) | 726 | void *cb_cls) |
730 | { | 727 | { |
731 | struct GNUNET_IDENTITY_Operation *op; | 728 | struct GNUNET_IDENTITY_Operation *op; |
732 | struct GNUNET_MQ_Envelope *env; | 729 | struct GNUNET_MQ_Envelope *env; |
@@ -737,30 +734,30 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, | |||
737 | 734 | ||
738 | if (NULL == h->mq) | 735 | if (NULL == h->mq) |
739 | return NULL; | 736 | return NULL; |
740 | slen_old = strlen (old_name) + 1; | 737 | slen_old = strlen(old_name) + 1; |
741 | slen_new = strlen (new_name) + 1; | 738 | slen_new = strlen(new_name) + 1; |
742 | if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) || | 739 | if ((slen_old >= GNUNET_MAX_MESSAGE_SIZE) || |
743 | (slen_new >= GNUNET_MAX_MESSAGE_SIZE) || | 740 | (slen_new >= GNUNET_MAX_MESSAGE_SIZE) || |
744 | (slen_old + slen_new >= | 741 | (slen_old + slen_new >= |
745 | GNUNET_MAX_MESSAGE_SIZE - sizeof (struct RenameMessage))) | 742 | GNUNET_MAX_MESSAGE_SIZE - sizeof(struct RenameMessage))) |
746 | { | 743 | { |
747 | GNUNET_break (0); | 744 | GNUNET_break(0); |
748 | return NULL; | 745 | return NULL; |
749 | } | 746 | } |
750 | op = GNUNET_new (struct GNUNET_IDENTITY_Operation); | 747 | op = GNUNET_new(struct GNUNET_IDENTITY_Operation); |
751 | op->h = h; | 748 | op->h = h; |
752 | op->cont = cb; | 749 | op->cont = cb; |
753 | op->cls = cb_cls; | 750 | op->cls = cb_cls; |
754 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 751 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
755 | env = GNUNET_MQ_msg_extra (grm, | 752 | env = GNUNET_MQ_msg_extra(grm, |
756 | slen_old + slen_new, | 753 | slen_old + slen_new, |
757 | GNUNET_MESSAGE_TYPE_IDENTITY_RENAME); | 754 | GNUNET_MESSAGE_TYPE_IDENTITY_RENAME); |
758 | grm->old_name_len = htons (slen_old); | 755 | grm->old_name_len = htons(slen_old); |
759 | grm->new_name_len = htons (slen_new); | 756 | grm->new_name_len = htons(slen_new); |
760 | dst = (char *) &grm[1]; | 757 | dst = (char *)&grm[1]; |
761 | GNUNET_memcpy (dst, old_name, slen_old); | 758 | GNUNET_memcpy(dst, old_name, slen_old); |
762 | GNUNET_memcpy (&dst[slen_old], new_name, slen_new); | 759 | GNUNET_memcpy(&dst[slen_old], new_name, slen_new); |
763 | GNUNET_MQ_send (h->mq, env); | 760 | GNUNET_MQ_send(h->mq, env); |
764 | return op; | 761 | return op; |
765 | } | 762 | } |
766 | 763 | ||
@@ -775,10 +772,10 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *h, | |||
775 | * @return handle to abort the operation | 772 | * @return handle to abort the operation |
776 | */ | 773 | */ |
777 | struct GNUNET_IDENTITY_Operation * | 774 | struct GNUNET_IDENTITY_Operation * |
778 | GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, | 775 | GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, |
779 | const char *name, | 776 | const char *name, |
780 | GNUNET_IDENTITY_Continuation cb, | 777 | GNUNET_IDENTITY_Continuation cb, |
781 | void *cb_cls) | 778 | void *cb_cls) |
782 | { | 779 | { |
783 | struct GNUNET_IDENTITY_Operation *op; | 780 | struct GNUNET_IDENTITY_Operation *op; |
784 | struct GNUNET_MQ_Envelope *env; | 781 | struct GNUNET_MQ_Envelope *env; |
@@ -787,22 +784,22 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, | |||
787 | 784 | ||
788 | if (NULL == h->mq) | 785 | if (NULL == h->mq) |
789 | return NULL; | 786 | return NULL; |
790 | slen = strlen (name) + 1; | 787 | slen = strlen(name) + 1; |
791 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct DeleteMessage)) | 788 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct DeleteMessage)) |
792 | { | 789 | { |
793 | GNUNET_break (0); | 790 | GNUNET_break(0); |
794 | return NULL; | 791 | return NULL; |
795 | } | 792 | } |
796 | op = GNUNET_new (struct GNUNET_IDENTITY_Operation); | 793 | op = GNUNET_new(struct GNUNET_IDENTITY_Operation); |
797 | op->h = h; | 794 | op->h = h; |
798 | op->cont = cb; | 795 | op->cont = cb; |
799 | op->cls = cb_cls; | 796 | op->cls = cb_cls; |
800 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); | 797 | GNUNET_CONTAINER_DLL_insert_tail(h->op_head, h->op_tail, op); |
801 | env = GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE); | 798 | env = GNUNET_MQ_msg_extra(gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE); |
802 | gdm->name_len = htons (slen); | 799 | gdm->name_len = htons(slen); |
803 | gdm->reserved = htons (0); | 800 | gdm->reserved = htons(0); |
804 | GNUNET_memcpy (&gdm[1], name, slen); | 801 | GNUNET_memcpy(&gdm[1], name, slen); |
805 | GNUNET_MQ_send (h->mq, env); | 802 | GNUNET_MQ_send(h->mq, env); |
806 | return op; | 803 | return op; |
807 | } | 804 | } |
808 | 805 | ||
@@ -816,16 +813,16 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *h, | |||
816 | * @param op operation to cancel | 813 | * @param op operation to cancel |
817 | */ | 814 | */ |
818 | void | 815 | void |
819 | GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) | 816 | GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op) |
820 | { | 817 | { |
821 | op->cont = NULL; | 818 | op->cont = NULL; |
822 | op->cb = NULL; | 819 | op->cb = NULL; |
823 | op->create_cont = NULL; | 820 | op->create_cont = NULL; |
824 | if (NULL != op->pk) | 821 | if (NULL != op->pk) |
825 | { | 822 | { |
826 | GNUNET_free (op->pk); | 823 | GNUNET_free(op->pk); |
827 | op->pk = NULL; | 824 | op->pk = NULL; |
828 | } | 825 | } |
829 | } | 826 | } |
830 | 827 | ||
831 | 828 | ||
@@ -835,35 +832,35 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) | |||
835 | * @param h handle to destroy | 832 | * @param h handle to destroy |
836 | */ | 833 | */ |
837 | void | 834 | void |
838 | GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) | 835 | GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h) |
839 | { | 836 | { |
840 | struct GNUNET_IDENTITY_Operation *op; | 837 | struct GNUNET_IDENTITY_Operation *op; |
841 | 838 | ||
842 | GNUNET_assert (NULL != h); | 839 | GNUNET_assert(NULL != h); |
843 | if (h->reconnect_task != NULL) | 840 | if (h->reconnect_task != NULL) |
844 | { | 841 | { |
845 | GNUNET_SCHEDULER_cancel (h->reconnect_task); | 842 | GNUNET_SCHEDULER_cancel(h->reconnect_task); |
846 | h->reconnect_task = NULL; | 843 | h->reconnect_task = NULL; |
847 | } | 844 | } |
848 | if (NULL != h->egos) | 845 | if (NULL != h->egos) |
849 | { | 846 | { |
850 | GNUNET_CONTAINER_multihashmap_iterate (h->egos, &free_ego, h); | 847 | GNUNET_CONTAINER_multihashmap_iterate(h->egos, &free_ego, h); |
851 | GNUNET_CONTAINER_multihashmap_destroy (h->egos); | 848 | GNUNET_CONTAINER_multihashmap_destroy(h->egos); |
852 | h->egos = NULL; | 849 | h->egos = NULL; |
853 | } | 850 | } |
854 | while (NULL != (op = h->op_head)) | 851 | while (NULL != (op = h->op_head)) |
855 | { | 852 | { |
856 | GNUNET_break (NULL == op->cont); | 853 | GNUNET_break(NULL == op->cont); |
857 | GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op); | 854 | GNUNET_CONTAINER_DLL_remove(h->op_head, h->op_tail, op); |
858 | GNUNET_free_non_null (op->pk); | 855 | GNUNET_free_non_null(op->pk); |
859 | GNUNET_free (op); | 856 | GNUNET_free(op); |
860 | } | 857 | } |
861 | if (NULL != h->mq) | 858 | if (NULL != h->mq) |
862 | { | 859 | { |
863 | GNUNET_MQ_destroy (h->mq); | 860 | GNUNET_MQ_destroy(h->mq); |
864 | h->mq = NULL; | 861 | h->mq = NULL; |
865 | } | 862 | } |
866 | GNUNET_free (h); | 863 | GNUNET_free(h); |
867 | } | 864 | } |
868 | 865 | ||
869 | /* end of identity_api.c */ | 866 | /* end of identity_api.c */ |