aboutsummaryrefslogtreecommitdiff
path: root/src/abd/abd_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/abd/abd_api.c')
-rw-r--r--src/abd/abd_api.c90
1 files changed, 49 insertions, 41 deletions
diff --git a/src/abd/abd_api.c b/src/abd/abd_api.c
index cdc52df91..cc25d06da 100644
--- a/src/abd/abd_api.c
+++ b/src/abd/abd_api.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
@@ -192,6 +192,7 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
192 force_reconnect (handle); 192 force_reconnect (handle);
193} 193}
194 194
195
195/** 196/**
196 * Check validity of message received from the ABD service 197 * Check validity of message received from the ABD service
197 * 198 *
@@ -201,7 +202,7 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
201static int 202static int
202check_result (void *cls, const struct DelegationChainResultMessage *vr_msg) 203check_result (void *cls, const struct DelegationChainResultMessage *vr_msg)
203{ 204{
204 //TODO 205 // TODO
205 return GNUNET_OK; 206 return GNUNET_OK;
206} 207}
207 208
@@ -241,11 +242,11 @@ handle_result (void *cls, const struct DelegationChainResultMessage *vr_msg)
241 GNUNET_assert ( 242 GNUNET_assert (
242 GNUNET_OK == 243 GNUNET_OK ==
243 GNUNET_ABD_delegation_chain_deserialize (mlen, 244 GNUNET_ABD_delegation_chain_deserialize (mlen,
244 (const char *) &vr_msg[1], 245 (const char *) &vr_msg[1],
245 d_count, 246 d_count,
246 d_chain, 247 d_chain,
247 c_count, 248 c_count,
248 dels)); 249 dels));
249 if (GNUNET_NO == ntohl (vr_msg->del_found)) 250 if (GNUNET_NO == ntohl (vr_msg->del_found))
250 { 251 {
251 proc (proc_cls, 0, NULL, 0, 252 proc (proc_cls, 0, NULL, 0,
@@ -257,51 +258,55 @@ handle_result (void *cls, const struct DelegationChainResultMessage *vr_msg)
257 } 258 }
258} 259}
259 260
261
260static int 262static int
261check_intermediate (void *cls, const struct DelegationChainIntermediateMessage *vr_msg) 263check_intermediate (void *cls, const struct
264 DelegationChainIntermediateMessage *vr_msg)
262{ 265{
263 //TODO 266 // TODO
264 return GNUNET_OK; 267 return GNUNET_OK;
265} 268}
266 269
270
267static void 271static void
268handle_intermediate (void *cls, const struct DelegationChainIntermediateMessage *vr_msg) 272handle_intermediate (void *cls, const struct
273 DelegationChainIntermediateMessage *vr_msg)
269{ 274{
270 struct GNUNET_ABD_Handle *handle = cls; 275 struct GNUNET_ABD_Handle *handle = cls;
271 uint32_t r_id = ntohl (vr_msg->id); 276 uint32_t r_id = ntohl (vr_msg->id);
272 uint32_t size = ntohl (vr_msg->size); 277 uint32_t size = ntohl (vr_msg->size);
273 bool is_bw = ntohs(vr_msg->is_bw); 278 bool is_bw = ntohs (vr_msg->is_bw);
274 struct GNUNET_ABD_Request *vr; 279 struct GNUNET_ABD_Request *vr;
275 GNUNET_ABD_IntermediateResultProcessor proc; 280 GNUNET_ABD_IntermediateResultProcessor proc;
276 void *proc_cls; 281 void *proc_cls;
277 struct GNUNET_ABD_Delegation *dd; 282 struct GNUNET_ABD_Delegation *dd;
278 283
279 284
280 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received intermediate reply from ABD service\n"); 285 LOG (GNUNET_ERROR_TYPE_DEBUG,
286 "Received intermediate reply from ABD service\n");
281 287
282 for (vr = handle->request_head; NULL != vr; vr = vr->next) 288 for (vr = handle->request_head; NULL != vr; vr = vr->next)
283 if (vr->r_id == r_id) 289 if (vr->r_id == r_id)
284 break; 290 break;
285 if (NULL == vr) 291 if (NULL == vr)
286 return; 292 return;
287 293
288 proc = vr->int_proc; 294 proc = vr->int_proc;
289 proc_cls = vr->proc2_cls; 295 proc_cls = vr->proc2_cls;
290 296
291 dd = GNUNET_new (struct GNUNET_ABD_Delegation); 297 dd = GNUNET_new (struct GNUNET_ABD_Delegation);
292 GNUNET_assert ( 298 GNUNET_assert (
293 GNUNET_OK == 299 GNUNET_OK ==
294 GNUNET_ABD_delegation_chain_deserialize (size, 300 GNUNET_ABD_delegation_chain_deserialize (size,
295 (const char *) &vr_msg[1], 301 (const char *) &vr_msg[1],
296 1, 302 1,
297 dd, 303 dd,
298 0, 304 0,
299 NULL)); 305 NULL));
300 proc (proc_cls, dd, is_bw); 306 proc (proc_cls, dd, is_bw);
301} 307}
302 308
303 309
304
305/** 310/**
306 * Reconnect to ABD service. 311 * Reconnect to ABD service.
307 * 312 *
@@ -311,19 +316,19 @@ static void
311reconnect (struct GNUNET_ABD_Handle *handle) 316reconnect (struct GNUNET_ABD_Handle *handle)
312{ 317{
313 struct GNUNET_MQ_MessageHandler handlers[] = 318 struct GNUNET_MQ_MessageHandler handlers[] =
314 {GNUNET_MQ_hd_var_size (result, 319 {GNUNET_MQ_hd_var_size (result,
315 GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT, 320 GNUNET_MESSAGE_TYPE_ABD_VERIFY_RESULT,
316 struct DelegationChainResultMessage, 321 struct DelegationChainResultMessage,
317 handle), 322 handle),
318 GNUNET_MQ_hd_var_size (result, 323 GNUNET_MQ_hd_var_size (result,
319 GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT, 324 GNUNET_MESSAGE_TYPE_ABD_COLLECT_RESULT,
320 struct DelegationChainResultMessage, 325 struct DelegationChainResultMessage,
321 handle), 326 handle),
322 GNUNET_MQ_hd_var_size (intermediate, 327 GNUNET_MQ_hd_var_size (intermediate,
323 GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT, 328 GNUNET_MESSAGE_TYPE_ABD_INTERMEDIATE_RESULT,
324 struct DelegationChainIntermediateMessage, 329 struct DelegationChainIntermediateMessage,
325 handle), 330 handle),
326 GNUNET_MQ_handler_end ()}; 331 GNUNET_MQ_handler_end ()};
327 struct GNUNET_ABD_Request *vr; 332 struct GNUNET_ABD_Request *vr;
328 333
329 GNUNET_assert (NULL == handle->mq); 334 GNUNET_assert (NULL == handle->mq);
@@ -404,7 +409,7 @@ GNUNET_ABD_request_cancel (struct GNUNET_ABD_Request *lr)
404 409
405/** 410/**
406 * Performs attribute collection. 411 * Performs attribute collection.
407 * Collects all abds of subject to fulfill the 412 * Collects all abds of subject to fulfill the
408 * attribute, if possible 413 * attribute, if possible
409 * 414 *
410 * @param handle handle to the Credential service 415 * @param handle handle to the Credential service
@@ -438,7 +443,7 @@ GNUNET_ABD_collect (
438 return NULL; 443 return NULL;
439 } 444 }
440 445
441 //DEBUG LOG 446 // DEBUG LOG
442 LOG (GNUNET_ERROR_TYPE_DEBUG, 447 LOG (GNUNET_ERROR_TYPE_DEBUG,
443 "Trying to collect `%s' in ABD\n", 448 "Trying to collect `%s' in ABD\n",
444 issuer_attribute); 449 issuer_attribute);
@@ -469,6 +474,8 @@ GNUNET_ABD_collect (
469 GNUNET_MQ_send_copy (handle->mq, vr->env); 474 GNUNET_MQ_send_copy (handle->mq, vr->env);
470 return vr; 475 return vr;
471} 476}
477
478
472/** 479/**
473 * Performs attribute verification. 480 * Performs attribute verification.
474 * Checks if there is a delegation chain from 481 * Checks if there is a delegation chain from
@@ -507,7 +514,7 @@ GNUNET_ABD_verify (
507 size_t nlen; 514 size_t nlen;
508 size_t clen; 515 size_t clen;
509 516
510 if (NULL == issuer_attribute || NULL == delegates) 517 if ((NULL == issuer_attribute) || (NULL == delegates))
511 { 518 {
512 GNUNET_break (0); 519 GNUNET_break (0);
513 return NULL; 520 return NULL;
@@ -515,7 +522,7 @@ GNUNET_ABD_verify (
515 522
516 clen = GNUNET_ABD_delegates_get_size (delegate_count, delegates); 523 clen = GNUNET_ABD_delegates_get_size (delegate_count, delegates);
517 524
518 //DEBUG LOG 525 // DEBUG LOG
519 LOG (GNUNET_ERROR_TYPE_DEBUG, 526 LOG (GNUNET_ERROR_TYPE_DEBUG,
520 "Trying to verify `%s' in ABD\n", 527 "Trying to verify `%s' in ABD\n",
521 issuer_attribute); 528 issuer_attribute);
@@ -543,14 +550,15 @@ GNUNET_ABD_verify (
543 550
544 GNUNET_memcpy (&v_msg[1], issuer_attribute, strlen (issuer_attribute)); 551 GNUNET_memcpy (&v_msg[1], issuer_attribute, strlen (issuer_attribute));
545 GNUNET_ABD_delegates_serialize (delegate_count, 552 GNUNET_ABD_delegates_serialize (delegate_count,
546 delegates, 553 delegates,
547 clen, 554 clen,
548 ((char *) &v_msg[1]) + 555 ((char *) &v_msg[1])
549 strlen (issuer_attribute) + 1); 556 + strlen (issuer_attribute) + 1);
550 GNUNET_CONTAINER_DLL_insert (handle->request_head, handle->request_tail, vr); 557 GNUNET_CONTAINER_DLL_insert (handle->request_head, handle->request_tail, vr);
551 if (NULL != handle->mq) 558 if (NULL != handle->mq)
552 GNUNET_MQ_send_copy (handle->mq, vr->env); 559 GNUNET_MQ_send_copy (handle->mq, vr->env);
553 return vr; 560 return vr;
554} 561}
555 562
563
556/* end of abd_api.c */ 564/* end of abd_api.c */