aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_performance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-20 09:12:46 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-20 09:12:46 +0000
commit41716910083763fdfc1bf796c96ba4cc76dd499d (patch)
tree70e57677e9dddb004027bff9f759bcf647b99622 /src/ats/ats_api_performance.c
parent1f8a38dedc78849ddd46c3b3bdf653297c63c78c (diff)
downloadgnunet-41716910083763fdfc1bf796c96ba4cc76dd499d.tar.gz
gnunet-41716910083763fdfc1bf796c96ba4cc76dd499d.zip
- changes
Diffstat (limited to 'src/ats/ats_api_performance.c')
-rw-r--r--src/ats/ats_api_performance.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index b86276363..c4254cf90 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -420,6 +420,60 @@ process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
420 420
421 421
422/** 422/**
423 * We received a reservation result message. Validate and process it.
424 *
425 * @param ph our context with the callback
426 * @param msg the message
427 * @return GNUNET_OK if the message was well-formed
428 */
429static int
430process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph,
431 const struct GNUNET_MessageHeader *msg)
432{
433 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "TO BE IMPLEMENTED\n");
434# if 0
435 TBD!
436 const struct ReservationResultMessage *rr;
437 struct GNUNET_ATS_ReservationContext *rc;
438 int32_t amount;
439
440 if (ntohs (msg->size) < sizeof (struct ReservationResultMessage))
441 {
442 GNUNET_break (0);
443 return GNUNET_SYSERR;
444 }
445 rr = (const struct ReservationResultMessage *) msg;
446 amount = ntohl (rr->amount);
447 rc = ph->reservation_head;
448 if (0 != memcmp (&rr->peer, &rc->peer, sizeof (struct GNUNET_PeerIdentity)))
449 {
450 GNUNET_break (0);
451 return GNUNET_SYSERR;
452 }
453 GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail, rc);
454 if ((amount == 0) || (rc->rcb != NULL))
455 {
456 /* tell client if not cancelled */
457 if (rc->rcb != NULL)
458 rc->rcb (rc->rcb_cls, &rr->peer, amount,
459 GNUNET_TIME_relative_ntoh (rr->res_delay));
460 GNUNET_free (rc);
461 return GNUNET_OK;
462 }
463 /* amount non-zero, but client cancelled, consider undo! */
464 if (GNUNET_YES != rc->undo)
465 {
466 GNUNET_free (rc);
467 return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
468 }
469 GNUNET_free (rc);
470 (void) GNUNET_ATS_reserve_bandwidth (ph, &rr->peer, -amount, NULL, NULL);
471#endif
472 return GNUNET_OK;
473}
474
475
476/**
423 * Type of a function to call when we receive a message 477 * Type of a function to call when we receive a message
424 * from the service. 478 * from the service.
425 * 479 *
@@ -443,6 +497,10 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
443 if (GNUNET_OK != process_rr_message (ph, msg)) 497 if (GNUNET_OK != process_rr_message (ph, msg))
444 goto reconnect; 498 goto reconnect;
445 break; 499 break;
500 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
501 if (GNUNET_OK != process_ar_message (ph, msg))
502 goto reconnect;
503 break;
446 default: 504 default:
447 GNUNET_break (0); 505 GNUNET_break (0);
448 goto reconnect; 506 goto reconnect;