diff options
Diffstat (limited to 'src/credential/credential_api.c')
-rw-r--r-- | src/credential/credential_api.c | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c index 7c3b35464..dd66c8c72 100644 --- a/src/credential/credential_api.c +++ b/src/credential/credential_api.c | |||
@@ -69,6 +69,16 @@ struct GNUNET_CREDENTIAL_Request | |||
69 | void *proc_cls; | 69 | void *proc_cls; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * processor to call on intermediate result | ||
73 | */ | ||
74 | GNUNET_CREDENTIAL_IntermediateResultProcessor int_proc; | ||
75 | |||
76 | /** | ||
77 | * @e verify_proc2 closure | ||
78 | */ | ||
79 | void *proc2_cls; | ||
80 | |||
81 | /** | ||
72 | * Envelope with the message for this queue entry. | 82 | * Envelope with the message for this queue entry. |
73 | */ | 83 | */ |
74 | struct GNUNET_MQ_Envelope *env; | 84 | struct GNUNET_MQ_Envelope *env; |
@@ -247,6 +257,48 @@ handle_result (void *cls, const struct DelegationChainResultMessage *vr_msg) | |||
247 | } | 257 | } |
248 | } | 258 | } |
249 | 259 | ||
260 | static int | ||
261 | check_intermediate (void *cls, const struct DelegationChainIntermediateMessage *vr_msg) | ||
262 | { | ||
263 | //TODO | ||
264 | return GNUNET_OK; | ||
265 | } | ||
266 | |||
267 | static void | ||
268 | handle_intermediate (void *cls, const struct DelegationChainIntermediateMessage *vr_msg) | ||
269 | { | ||
270 | struct GNUNET_CREDENTIAL_Handle *handle = cls; | ||
271 | uint32_t r_id = ntohl (vr_msg->id); | ||
272 | uint32_t size = ntohl (vr_msg->size); | ||
273 | struct GNUNET_CREDENTIAL_Request *vr; | ||
274 | GNUNET_CREDENTIAL_IntermediateResultProcessor proc; | ||
275 | void *proc_cls; | ||
276 | struct GNUNET_CREDENTIAL_Delegation *dd; | ||
277 | |||
278 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received intermediate reply from CREDENTIAL service\n"); | ||
279 | for (vr = handle->request_head; NULL != vr; vr = vr->next) | ||
280 | if (vr->r_id == r_id) | ||
281 | break; | ||
282 | if (NULL == vr) | ||
283 | return; | ||
284 | |||
285 | proc = vr->int_proc; | ||
286 | proc_cls = vr->proc2_cls; | ||
287 | |||
288 | dd = GNUNET_new (struct GNUNET_CREDENTIAL_Delegation); | ||
289 | GNUNET_assert ( | ||
290 | GNUNET_OK == | ||
291 | GNUNET_CREDENTIAL_delegation_chain_deserialize (size, | ||
292 | (const char *) &vr_msg[1], | ||
293 | 1, | ||
294 | dd, | ||
295 | 0, | ||
296 | NULL)); | ||
297 | |||
298 | proc (proc_cls, dd); | ||
299 | } | ||
300 | |||
301 | |||
250 | 302 | ||
251 | /** | 303 | /** |
252 | * Reconnect to CREDENTIAL service. | 304 | * Reconnect to CREDENTIAL service. |
@@ -265,6 +317,10 @@ reconnect (struct GNUNET_CREDENTIAL_Handle *handle) | |||
265 | GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT_RESULT, | 317 | GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT_RESULT, |
266 | struct DelegationChainResultMessage, | 318 | struct DelegationChainResultMessage, |
267 | handle), | 319 | handle), |
320 | GNUNET_MQ_hd_var_size (intermediate, | ||
321 | GNUNET_MESSAGE_TYPE_CREDENTIAL_INTERMEDIATE_RESULT, | ||
322 | struct DelegationChainIntermediateMessage, | ||
323 | handle), | ||
268 | GNUNET_MQ_handler_end ()}; | 324 | GNUNET_MQ_handler_end ()}; |
269 | struct GNUNET_CREDENTIAL_Request *vr; | 325 | struct GNUNET_CREDENTIAL_Request *vr; |
270 | 326 | ||
@@ -365,7 +421,9 @@ GNUNET_CREDENTIAL_collect ( | |||
365 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key, | 421 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key, |
366 | enum GNUNET_CREDENTIAL_AlgoDirectionFlags direction, | 422 | enum GNUNET_CREDENTIAL_AlgoDirectionFlags direction, |
367 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, | 423 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, |
368 | void *proc_cls) | 424 | void *proc_cls, |
425 | GNUNET_CREDENTIAL_IntermediateResultProcessor proc2, | ||
426 | void *proc2_cls) | ||
369 | { | 427 | { |
370 | /* IPC to shorten credential names, return shorten_handle */ | 428 | /* IPC to shorten credential names, return shorten_handle */ |
371 | struct CollectMessage *c_msg; | 429 | struct CollectMessage *c_msg; |
@@ -392,6 +450,8 @@ GNUNET_CREDENTIAL_collect ( | |||
392 | vr->credential_handle = handle; | 450 | vr->credential_handle = handle; |
393 | vr->verify_proc = proc; | 451 | vr->verify_proc = proc; |
394 | vr->proc_cls = proc_cls; | 452 | vr->proc_cls = proc_cls; |
453 | vr->int_proc = proc2; | ||
454 | vr->proc2_cls = proc2_cls; | ||
395 | vr->r_id = handle->r_id_gen++; | 455 | vr->r_id = handle->r_id_gen++; |
396 | vr->env = | 456 | vr->env = |
397 | GNUNET_MQ_msg_extra (c_msg, nlen, GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT); | 457 | GNUNET_MQ_msg_extra (c_msg, nlen, GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT); |
@@ -435,7 +495,9 @@ GNUNET_CREDENTIAL_verify ( | |||
435 | const struct GNUNET_CREDENTIAL_Delegate *delegates, | 495 | const struct GNUNET_CREDENTIAL_Delegate *delegates, |
436 | enum GNUNET_CREDENTIAL_AlgoDirectionFlags direction, | 496 | enum GNUNET_CREDENTIAL_AlgoDirectionFlags direction, |
437 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, | 497 | GNUNET_CREDENTIAL_CredentialResultProcessor proc, |
438 | void *proc_cls) | 498 | void *proc_cls, |
499 | GNUNET_CREDENTIAL_IntermediateResultProcessor proc2, | ||
500 | void *proc2_cls) | ||
439 | { | 501 | { |
440 | /* IPC to shorten credential names, return shorten_handle */ | 502 | /* IPC to shorten credential names, return shorten_handle */ |
441 | struct VerifyMessage *v_msg; | 503 | struct VerifyMessage *v_msg; |
@@ -465,6 +527,8 @@ GNUNET_CREDENTIAL_verify ( | |||
465 | vr->credential_handle = handle; | 527 | vr->credential_handle = handle; |
466 | vr->verify_proc = proc; | 528 | vr->verify_proc = proc; |
467 | vr->proc_cls = proc_cls; | 529 | vr->proc_cls = proc_cls; |
530 | vr->int_proc = proc2; | ||
531 | vr->proc2_cls = proc2_cls; | ||
468 | vr->r_id = handle->r_id_gen++; | 532 | vr->r_id = handle->r_id_gen++; |
469 | vr->env = | 533 | vr->env = |
470 | GNUNET_MQ_msg_extra (v_msg, nlen, GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); | 534 | GNUNET_MQ_msg_extra (v_msg, nlen, GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY); |