aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ats/ats_api_performance.c70
-rw-r--r--src/include/gnunet_ats_service.h49
2 files changed, 111 insertions, 8 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index 25b492614..fc2d6647e 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -129,7 +129,7 @@ struct GNUNET_ATS_AddressListHandle
129 /** 129 /**
130 * Callback 130 * Callback
131 */ 131 */
132 GNUNET_ATS_PeerInformationCallback cb; 132 GNUNET_ATS_AddressInformationCallback cb;
133 133
134 /** 134 /**
135 * Callback closure 135 * Callback closure
@@ -171,7 +171,7 @@ struct GNUNET_ATS_PerformanceHandle
171 /** 171 /**
172 * Callback to invoke on performance changes. 172 * Callback to invoke on performance changes.
173 */ 173 */
174 GNUNET_ATS_PeerInformationCallback infocb; 174 GNUNET_ATS_AddressInformationCallback infocb;
175 175
176 /** 176 /**
177 * Closure for 'infocb'. 177 * Closure for 'infocb'.
@@ -214,6 +214,16 @@ struct GNUNET_ATS_PerformanceHandle
214 struct GNUNET_ATS_AddressListHandle *addresslist_tail; 214 struct GNUNET_ATS_AddressListHandle *addresslist_tail;
215 215
216 /** 216 /**
217 * Head of linked list of pending performance monitors.
218 */
219 struct GNUNET_ATS_PerformanceMonitorHandle *monitor_head;
220
221 /**
222 * Tail of linked list of pending performance monitors.
223 */
224 struct GNUNET_ATS_PerformanceMonitorHandle *monitor_tail;
225
226 /**
217 * Current request for transmission to ATS. 227 * Current request for transmission to ATS.
218 */ 228 */
219 struct GNUNET_CLIENT_TransmitHandle *th; 229 struct GNUNET_CLIENT_TransmitHandle *th;
@@ -629,7 +639,7 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
629 */ 639 */
630struct GNUNET_ATS_PerformanceHandle * 640struct GNUNET_ATS_PerformanceHandle *
631GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 641GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
632 GNUNET_ATS_PeerInformationCallback infocb, 642 GNUNET_ATS_AddressInformationCallback infocb,
633 void *infocb_cls) 643 void *infocb_cls)
634{ 644{
635 struct GNUNET_ATS_PerformanceHandle *ph; 645 struct GNUNET_ATS_PerformanceHandle *ph;
@@ -643,6 +653,58 @@ GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
643 return ph; 653 return ph;
644} 654}
645 655
656struct GNUNET_ATS_PerformanceMonitorHandle
657{
658 struct GNUNET_ATS_PerformanceMonitorHandle *next;
659 struct GNUNET_ATS_PerformanceMonitorHandle *prev;
660
661 struct GNUNET_ATS_PerformanceHandle * ph;
662
663 GNUNET_ATS_PerformanceMonitorCb moncb;
664 void *moncb_cls;
665};
666
667/**
668 * Start monitoring performance information
669 *
670 * @param ph performance handle to use
671 * @param monitor_cb function to call on performance changes
672 * @param monitor_cb_cls closure for infocb
673 * @return a performance monitor handle
674 */
675struct GNUNET_ATS_PerformanceMonitorHandle *
676GNUNET_ATS_performance_monitor_start (struct GNUNET_ATS_PerformanceHandle * ph,
677 GNUNET_ATS_PerformanceMonitorCb monitor_cb,
678 void * monitor_cb_cls)
679{
680 GNUNET_assert (NULL != ph);
681
682 struct GNUNET_ATS_PerformanceMonitorHandle *phm =
683 GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceMonitorHandle));
684
685 phm->ph = ph;
686 phm->moncb = monitor_cb;
687 phm->moncb_cls = monitor_cb_cls;
688 GNUNET_CONTAINER_DLL_insert (ph->monitor_head, ph->monitor_tail, phm);
689
690 return phm;
691}
692
693
694/**
695 * Stop monitoring performance information
696 *
697 * @param ph performance handle to use
698 * @param monitor_cb function to call on performance changes
699 * @param monitor_cb_cls closure for infocb
700 * @return a performance monitor handle
701 */
702void
703GNUNET_ATS_performance_monitor_stop (struct GNUNET_ATS_PerformanceMonitorHandle * phm)
704{
705 GNUNET_CONTAINER_DLL_remove (phm->ph->monitor_head, phm->ph->monitor_tail, phm);
706 GNUNET_free (phm);
707}
646 708
647/** 709/**
648 * Client is done using the ATS performance subsystem, release resources. 710 * Client is done using the ATS performance subsystem, release resources.
@@ -764,7 +826,7 @@ struct GNUNET_ATS_AddressListHandle*
764GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, 826GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
765 const struct GNUNET_PeerIdentity *peer, 827 const struct GNUNET_PeerIdentity *peer,
766 int all, 828 int all,
767 GNUNET_ATS_PeerInformationCallback infocb, 829 GNUNET_ATS_AddressInformationCallback infocb,
768 void *infocb_cls) 830 void *infocb_cls)
769{ 831{
770 struct GNUNET_ATS_AddressListHandle *alh; 832 struct GNUNET_ATS_AddressListHandle *alh;
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index a6da5c897..7ac9f7f4a 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -697,9 +697,23 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
697 */ 697 */
698struct GNUNET_ATS_PerformanceHandle; 698struct GNUNET_ATS_PerformanceHandle;
699 699
700/**
701 * Signature of a function that is called with QoS information about an peer.
702 *
703 * @param cls closure
704 * @param peer the peer
705 * @param ats data for the peer
706 * @param ats_count number of performance records in 'ats'
707 */
708typedef void
709(*GNUNET_ATS_PerformanceMonitorCb) (void *cls,
710 struct GNUNET_PeerIdentity *peer,
711 struct GNUNET_ATS_Information *ats,
712 uint32_t ats_count);
713
700 714
701/** 715/**
702 * Signature of a function that is called with QoS information about a peer. 716 * Signature of a function that is called with QoS information about an address.
703 * 717 *
704 * @param cls closure 718 * @param cls closure
705 * @param address the address 719 * @param address the address
@@ -708,7 +722,7 @@ struct GNUNET_ATS_PerformanceHandle;
708 * @param ats performance data for the address (as far as known) 722 * @param ats performance data for the address (as far as known)
709 * @param ats_count number of performance records in 'ats' 723 * @param ats_count number of performance records in 'ats'
710 */ 724 */
711typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls, 725typedef void (*GNUNET_ATS_AddressInformationCallback) (void *cls,
712 const struct 726 const struct
713 GNUNET_HELLO_Address * 727 GNUNET_HELLO_Address *
714 address, 728 address,
@@ -738,11 +752,38 @@ struct GNUNET_ATS_AddressListHandle;
738 */ 752 */
739struct GNUNET_ATS_PerformanceHandle * 753struct GNUNET_ATS_PerformanceHandle *
740GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 754GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
741 GNUNET_ATS_PeerInformationCallback infocb, 755 GNUNET_ATS_AddressInformationCallback infocb,
742 void *infocb_cls); 756 void *infocb_cls);
743 757
744 758
745/** 759/**
760 * Start monitoring performance information
761 *
762 * @param ph performance handle to use
763 * @param monitor_cb function to call on performance changes
764 * @param monitor_cb_cls closure for infocb
765 * @return a performance monitor handle
766 */
767struct GNUNET_ATS_PerformanceMonitorHandle *
768GNUNET_ATS_performance_monitor_start (struct GNUNET_ATS_PerformanceHandle * ph,
769 GNUNET_ATS_PerformanceMonitorCb monitor_cb,
770 void * monitor_cb_cls);
771
772
773/**
774 * Stop monitoring performance information
775 *
776 * @param ph performance handle to use
777 * @param monitor_cb function to call on performance changes
778 * @param monitor_cb_cls closure for infocb
779 * @return a performance monitor handle
780 */
781void
782GNUNET_ATS_performance_monitor_stop (struct GNUNET_ATS_PerformanceMonitorHandle * phm);
783
784
785
786/**
746 * Get information about addresses known to the ATS subsystem. 787 * Get information about addresses known to the ATS subsystem.
747 * 788 *
748 * @param handle the performance handle to use 789 * @param handle the performance handle to use
@@ -758,7 +799,7 @@ struct GNUNET_ATS_AddressListHandle *
758GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, 799GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle,
759 const struct GNUNET_PeerIdentity *peer, 800 const struct GNUNET_PeerIdentity *peer,
760 int all, 801 int all,
761 GNUNET_ATS_PeerInformationCallback infocb, 802 GNUNET_ATS_AddressInformationCallback infocb,
762 void *infocb_cls); 803 void *infocb_cls);
763 804
764 805