aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_performance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-08-29 15:34:53 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-08-29 15:34:53 +0000
commitf5136eb1b1a24c5b307ce8123dfc4cc0c85facaf (patch)
tree357763a82d29edd1bf8f533cd294818ff3ce5a9d /src/ats/ats_api_performance.c
parent81eaa5a9d5ebe1e61790069a2777178abd1b6a2c (diff)
downloadgnunet-f5136eb1b1a24c5b307ce8123dfc4cc0c85facaf.tar.gz
gnunet-f5136eb1b1a24c5b307ce8123dfc4cc0c85facaf.zip
implemented feedback API, but not yet calling solver
Diffstat (limited to 'src/ats/ats_api_performance.c')
-rw-r--r--src/ats/ats_api_performance.c83
1 files changed, 82 insertions, 1 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index 8acce225f..b7c24aa53 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -866,7 +866,7 @@ GNUNET_ATS_print_preference_type (uint32_t type)
866 * @param ... 0-terminated specification of the desired changes 866 * @param ... 0-terminated specification of the desired changes
867 */ 867 */
868void 868void
869GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph, 869GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
870 const struct GNUNET_PeerIdentity *peer, ...) 870 const struct GNUNET_PeerIdentity *peer, ...)
871{ 871{
872 struct PendingMessage *p; 872 struct PendingMessage *p;
@@ -938,4 +938,85 @@ GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
938 do_transmit (ph); 938 do_transmit (ph);
939} 939}
940 940
941/**
942 * Send feedback to ATS on how good a the requirements for a peer and a
943 * preference is satisfied by ATS
944 *
945 * @param ph performance handle
946 * @param peer identifies the peer
947 * @param ... 0-terminated specification of the desired changes
948 */
949void
950GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
951 const struct GNUNET_PeerIdentity *peer, ...)
952{
953 struct PendingMessage *p;
954 struct FeedbackPreferenceMessage *m;
955 size_t msize;
956 uint32_t count;
957 struct PreferenceInformation *pi;
958 va_list ap;
959 enum GNUNET_ATS_PreferenceKind kind;
960
961 count = 0;
962 va_start (ap, peer);
963 while (GNUNET_ATS_PREFERENCE_END !=
964 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
965 {
966 switch (kind)
967 {
968 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
969 count++;
970 (void) va_arg (ap, double);
971
972 break;
973 case GNUNET_ATS_PREFERENCE_LATENCY:
974 count++;
975 (void) va_arg (ap, double);
976
977 break;
978 default:
979 GNUNET_assert (0);
980 }
981 }
982 va_end (ap);
983 msize =
984 count * sizeof (struct PreferenceInformation) +
985 sizeof (struct FeedbackPreferenceMessage);
986 p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
987 p->size = msize;
988 p->is_init = GNUNET_NO;
989 m = (struct FeedbackPreferenceMessage *) &p[1];
990 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
991 m->header.size = htons (msize);
992 m->num_preferences = htonl (count);
993 m->peer = *peer;
994 pi = (struct PreferenceInformation *) &m[1];
995 count = 0;
996 va_start (ap, peer);
997 while (GNUNET_ATS_PREFERENCE_END !=
998 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
999 {
1000 pi[count].preference_kind = htonl (kind);
1001 switch (kind)
1002 {
1003 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
1004 pi[count].preference_value = (float) va_arg (ap, double);
1005
1006 count++;
1007 break;
1008 case GNUNET_ATS_PREFERENCE_LATENCY:
1009 pi[count].preference_value = (float) va_arg (ap, double);
1010
1011 count++;
1012 break;
1013 default:
1014 GNUNET_assert (0);
1015 }
1016 }
1017 va_end (ap);
1018 GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
1019 do_transmit (ph);
1020}
1021
941/* end of ats_api_performance.c */ 1022/* end of ats_api_performance.c */