diff options
-rw-r--r-- | src/ats/ats_api_performance.c | 95 | ||||
-rw-r--r-- | src/include/gnunet_ats_service.h | 34 |
2 files changed, 129 insertions, 0 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 14815ea36..66cfda88e 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c | |||
@@ -106,6 +106,38 @@ struct GNUNET_ATS_ReservationContext | |||
106 | 106 | ||
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Linked list of pending reservations. | ||
110 | */ | ||
111 | struct GNUNET_ATS_AddressListHandle | ||
112 | { | ||
113 | |||
114 | /** | ||
115 | * Kept in a DLL. | ||
116 | */ | ||
117 | struct GNUNET_ATS_AddressListHandle *next; | ||
118 | |||
119 | /** | ||
120 | * Kept in a DLL. | ||
121 | */ | ||
122 | struct GNUNET_ATS_AddressListHandle *prev; | ||
123 | |||
124 | /** | ||
125 | * Target peer. | ||
126 | */ | ||
127 | struct GNUNET_PeerIdentity peer; | ||
128 | |||
129 | /** | ||
130 | * Return all or specific peer only | ||
131 | */ | ||
132 | int all_peers; | ||
133 | |||
134 | /** | ||
135 | * Return all or used address only | ||
136 | */ | ||
137 | int all_addresses; | ||
138 | }; | ||
139 | |||
140 | /** | ||
109 | * ATS Handle to obtain and/or modify performance information. | 141 | * ATS Handle to obtain and/or modify performance information. |
110 | */ | 142 | */ |
111 | struct GNUNET_ATS_PerformanceHandle | 143 | struct GNUNET_ATS_PerformanceHandle |
@@ -152,6 +184,16 @@ struct GNUNET_ATS_PerformanceHandle | |||
152 | struct GNUNET_ATS_ReservationContext *reservation_tail; | 184 | struct GNUNET_ATS_ReservationContext *reservation_tail; |
153 | 185 | ||
154 | /** | 186 | /** |
187 | * Head of linked list of pending address list requests. | ||
188 | */ | ||
189 | struct GNUNET_ATS_AddressListHandle *addresslist_head; | ||
190 | |||
191 | /** | ||
192 | * Tail of linked list of pending address list requests. | ||
193 | */ | ||
194 | struct GNUNET_ATS_AddressListHandle *addresslist_tail; | ||
195 | |||
196 | /** | ||
155 | * Current request for transmission to ATS. | 197 | * Current request for transmission to ATS. |
156 | */ | 198 | */ |
157 | struct GNUNET_CLIENT_TransmitHandle *th; | 199 | struct GNUNET_CLIENT_TransmitHandle *th; |
@@ -564,6 +606,59 @@ GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc) | |||
564 | rc->rcb = NULL; | 606 | rc->rcb = NULL; |
565 | } | 607 | } |
566 | 608 | ||
609 | /** | ||
610 | * Get information about addresses known to the ATS subsystem. | ||
611 | * | ||
612 | * @param cfg configuration to use | ||
613 | * @param peer peer idm can be NULL for all peers | ||
614 | * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to | ||
615 | * get only address currently used | ||
616 | * @param infocb callback to call with the addresses, | ||
617 | * will callback with address == NULL when done | ||
618 | * @param infocb_cls closure for infocb | ||
619 | * @return ats performance context | ||
620 | */ | ||
621 | struct GNUNET_ATS_AddressListHandle* | ||
622 | GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, | ||
623 | const struct GNUNET_PeerIdentity *peer, | ||
624 | int all, | ||
625 | GNUNET_ATS_PeerInformationCallback infocb, | ||
626 | void *infocb_cls) | ||
627 | { | ||
628 | struct GNUNET_ATS_AddressListHandle *alh; | ||
629 | |||
630 | GNUNET_assert (NULL != handle); | ||
631 | |||
632 | alh = GNUNET_malloc (sizeof (struct GNUNET_ATS_AddressListHandle)); | ||
633 | alh->all_addresses = all; | ||
634 | if (NULL == peer) | ||
635 | alh->all_peers = GNUNET_YES; | ||
636 | else | ||
637 | { | ||
638 | alh->all_peers = GNUNET_NO; | ||
639 | alh->peer = (*peer); | ||
640 | } | ||
641 | |||
642 | GNUNET_CONTAINER_DLL_insert (handle->addresslist_head, handle->addresslist_tail, alh); | ||
643 | |||
644 | /* TODO */ | ||
645 | |||
646 | return alh; | ||
647 | } | ||
648 | |||
649 | |||
650 | /** | ||
651 | * Cancel a pending address listing operation | ||
652 | * | ||
653 | * @param handle the GNUNET_ATS_AddressListHandle handle to cancel | ||
654 | */ | ||
655 | void | ||
656 | GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle) | ||
657 | { | ||
658 | |||
659 | |||
660 | } | ||
661 | |||
567 | 662 | ||
568 | /** | 663 | /** |
569 | * Change preferences for the given peer. Preference changes are forgotten if peers | 664 | * Change preferences for the given peer. Preference changes are forgotten if peers |
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 11d718158..a8f742cba 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h | |||
@@ -690,6 +690,11 @@ typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls, | |||
690 | GNUNET_ATS_Information * | 690 | GNUNET_ATS_Information * |
691 | ats, uint32_t ats_count); | 691 | ats, uint32_t ats_count); |
692 | 692 | ||
693 | /** | ||
694 | * Handle for an address listing operation | ||
695 | */ | ||
696 | struct GNUNET_ATS_AddressListHandle; | ||
697 | |||
693 | 698 | ||
694 | /** | 699 | /** |
695 | * Get handle to access performance API of the ATS subsystem. | 700 | * Get handle to access performance API of the ATS subsystem. |
@@ -706,6 +711,35 @@ GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
706 | 711 | ||
707 | 712 | ||
708 | /** | 713 | /** |
714 | * Get information about addresses known to the ATS subsystem. | ||
715 | * | ||
716 | * @param cfg configuration to use | ||
717 | * @param peer peer idm can be NULL for all peers | ||
718 | * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to | ||
719 | * get only address currently used | ||
720 | * @param infocb callback to call with the addresses, | ||
721 | * will callback with address == NULL when done | ||
722 | * @param infocb_cls closure for infocb | ||
723 | * @return ats performance context | ||
724 | */ | ||
725 | struct GNUNET_ATS_AddressListHandle * | ||
726 | GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, | ||
727 | const struct GNUNET_PeerIdentity *peer, | ||
728 | int all, | ||
729 | GNUNET_ATS_PeerInformationCallback infocb, | ||
730 | void *infocb_cls); | ||
731 | |||
732 | |||
733 | /** | ||
734 | * Cancel a pending address listing operation | ||
735 | * | ||
736 | * @param handle the GNUNET_ATS_AddressListHandle handle to cancel | ||
737 | */ | ||
738 | void | ||
739 | GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle); | ||
740 | |||
741 | |||
742 | /** | ||
709 | * Client is done using the ATS performance subsystem, release resources. | 743 | * Client is done using the ATS performance subsystem, release resources. |
710 | * | 744 | * |
711 | * @param ph handle | 745 | * @param ph handle |