aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_scheduling.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/ats_api_scheduling.c')
-rw-r--r--src/ats/ats_api_scheduling.c94
1 files changed, 14 insertions, 80 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index f81dfe7eb..792215598 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -92,13 +92,6 @@ struct GNUNET_ATS_AddressRecord
92 uint32_t slot; 92 uint32_t slot;
93 93
94 /** 94 /**
95 * Is this address currently in use? In use means
96 * that the transport service will use this address
97 * for sending.
98 */
99 int in_use;
100
101 /**
102 * We're about to destroy this address record, just ATS does 95 * We're about to destroy this address record, just ATS does
103 * not know this yet. Once ATS confirms its destruction, 96 * not know this yet. Once ATS confirms its destruction,
104 * we can clean up. 97 * we can clean up.
@@ -418,6 +411,11 @@ process_ats_address_suggestion_message (void *cls,
418 if ( (0 == ntohl (m->bandwidth_out.value__)) && 411 if ( (0 == ntohl (m->bandwidth_out.value__)) &&
419 (0 == ntohl (m->bandwidth_in.value__)) ) 412 (0 == ntohl (m->bandwidth_in.value__)) )
420 { 413 {
414 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
415 "ATS suggests disconnect from peer `%s' with BW %u/%u\n",
416 GNUNET_i2s (&ar->address->peer),
417 (unsigned int) ntohl (m->bandwidth_out.value__),
418 (unsigned int) ntohl (m->bandwidth_in.value__));
421 sh->suggest_cb (sh->suggest_cb_cls, 419 sh->suggest_cb (sh->suggest_cb_cls,
422 &m->peer, 420 &m->peer,
423 NULL, 421 NULL,
@@ -434,6 +432,11 @@ process_ats_address_suggestion_message (void *cls,
434 GNUNET_break (0); 432 GNUNET_break (0);
435 return; 433 return;
436 } 434 }
435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
436 "ATS suggests address slot %u for peer `%s' using plugin %s\n",
437 ar->slot,
438 GNUNET_i2s (&ar->address->peer),
439 ar->address->transport_name);
437 sh->suggest_cb (sh->suggest_cb_cls, 440 sh->suggest_cb (sh->suggest_cb_cls,
438 &m->peer, 441 &m->peer,
439 ar->address, 442 ar->address,
@@ -498,7 +501,7 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh,
498 m->session_id = htonl (ar->slot); 501 m->session_id = htonl (ar->slot);
499 502
500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
501 "Adding address for peer `%s', plugin `%s', session %p id %u\n", 504 "Adding address for peer `%s', plugin `%s', session %p slot %u\n",
502 GNUNET_i2s (&ar->address->peer), 505 GNUNET_i2s (&ar->address->peer),
503 ar->address->transport_name, 506 ar->address->transport_name,
504 ar->session, 507 ar->session,
@@ -520,29 +523,6 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh,
520 523
521 524
522/** 525/**
523 * Generate and transmit the `struct AddressUseMessage` for the given
524 * address record.
525 *
526 * @param ar the address to inform the ATS service about
527 * @param in_use say if it is in use or not
528 */
529static void
530send_in_use_message (struct GNUNET_ATS_AddressRecord *ar,
531 int in_use)
532{
533 struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
534 struct GNUNET_MQ_Envelope *ev;
535 struct AddressUseMessage *m;
536
537 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE);
538 m->peer = ar->address->peer;
539 m->in_use = htonl ((uint32_t) in_use);
540 m->session_id = htonl (ar->slot);
541 GNUNET_MQ_send (sh->mq, ev);
542}
543
544
545/**
546 * Re-establish the connection to the ATS service. 526 * Re-establish the connection to the ATS service.
547 * 527 *
548 * @param sh handle to use to re-connect. 528 * @param sh handle to use to re-connect.
@@ -586,8 +566,6 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
586 if (NULL == ar) 566 if (NULL == ar)
587 continue; 567 continue;
588 send_add_address_message (sh, ar); 568 send_add_address_message (sh, ar);
589 if (ar->in_use)
590 send_in_use_message (ar, GNUNET_YES);
591 if (NULL == sh->mq) 569 if (NULL == sh->mq)
592 return; 570 return;
593 } 571 }
@@ -652,27 +630,6 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
652 630
653 631
654/** 632/**
655 * We would like to reset the address suggestion block time for this
656 * peer.
657 *
658 * @param sh handle
659 * @param peer identity of the peer we want to reset
660 */
661void
662GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
663 const struct GNUNET_PeerIdentity *peer)
664{
665 struct GNUNET_MQ_Envelope *ev;
666 struct ResetBackoffMessage *m;
667
668 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF);
669 m->reserved = htonl (0);
670 m->peer = *peer;
671 GNUNET_MQ_send (sh->mq, ev);
672}
673
674
675/**
676 * Test if a address and a session is known to ATS 633 * Test if a address and a session is known to ATS
677 * 634 *
678 * @param sh the scheduling handle 635 * @param sh the scheduling handle
@@ -799,7 +756,6 @@ GNUNET_ATS_address_del_session (struct GNUNET_ATS_AddressRecord *ar,
799{ 756{
800 GNUNET_break (session == ar->session); 757 GNUNET_break (session == ar->session);
801 ar->session = NULL; 758 ar->session = NULL;
802 GNUNET_break (GNUNET_NO == ar->in_use);
803 if (GNUNET_HELLO_address_check_option (ar->address, 759 if (GNUNET_HELLO_address_check_option (ar->address,
804 GNUNET_HELLO_ADDRESS_INFO_INBOUND)) 760 GNUNET_HELLO_ADDRESS_INFO_INBOUND))
805 { 761 {
@@ -834,7 +790,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar,
834 size_t msize; 790 size_t msize;
835 791
836 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 792 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
837 "Adding address for peer `%s', plugin `%s', session %p id %u\n", 793 "Updating address for peer `%s', plugin `%s', session %p slot %u\n",
838 GNUNET_i2s (&ar->address->peer), 794 GNUNET_i2s (&ar->address->peer),
839 ar->address->transport_name, 795 ar->address->transport_name,
840 ar->session, 796 ar->session,
@@ -861,29 +817,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar,
861} 817}
862 818
863 819
864/**
865 * An address is now in use or not used any more.
866 *
867 * @param ar the address
868 * @param in_use #GNUNET_YES if this address is now used, #GNUNET_NO
869 * if address is not used any more
870 */
871void
872GNUNET_ATS_address_set_in_use (struct GNUNET_ATS_AddressRecord *ar,
873 int in_use)
874{
875 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
876 "Setting address used to %s for peer `%s', plugin `%s', session %p\n",
877 (GNUNET_YES == in_use) ? "YES" : "NO",
878 GNUNET_i2s (&ar->address->peer),
879 ar->address->transport_name,
880 ar->session);
881 ar->in_use = in_use;
882 if (NULL == ar->sh->mq)
883 return;
884 send_in_use_message (ar, in_use);
885}
886
887 820
888/** 821/**
889 * An address got destroyed, stop using it as a valid address. 822 * An address got destroyed, stop using it as a valid address.
@@ -898,9 +831,10 @@ GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar)
898 struct AddressDestroyedMessage *m; 831 struct AddressDestroyedMessage *m;
899 832
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 833 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
901 "Deleting address for peer `%s', plugin `%s', session %p\n", 834 "Deleting address for peer `%s', plugin `%s', slot %u session %p\n",
902 GNUNET_i2s (&ar->address->peer), 835 GNUNET_i2s (&ar->address->peer),
903 ar->address->transport_name, 836 ar->address->transport_name,
837 ar->slot,
904 ar->session); 838 ar->session);
905 GNUNET_break (NULL == ar->session); 839 GNUNET_break (NULL == ar->session);
906 ar->session = NULL; 840 ar->session = NULL;