aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_performance.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-05 12:52:20 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-05 12:52:20 +0000
commitc55971f17dc99f9833af48e078c8f681be771cb7 (patch)
tree544fd671b67903506419c98d463d086a696e25a1 /src/ats/gnunet-service-ats_performance.c
parent15dd8e6cc1199d611d804853e134882bf13b234a (diff)
downloadgnunet-c55971f17dc99f9833af48e078c8f681be771cb7.tar.gz
gnunet-c55971f17dc99f9833af48e078c8f681be771cb7.zip
big ATS refactoring, no serious semantic changes should stem from this
Diffstat (limited to 'src/ats/gnunet-service-ats_performance.c')
-rw-r--r--src/ats/gnunet-service-ats_performance.c108
1 files changed, 2 insertions, 106 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index e0a5cbdae..c49821227 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2011-2014 Christian Grothoff (and other contributing authors) 3 (C) 2011-2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -69,6 +69,7 @@ static struct PerformanceClient *pc_head;
69 */ 69 */
70static struct PerformanceClient *pc_tail; 70static struct PerformanceClient *pc_tail;
71 71
72
72/** 73/**
73 * Context for sending messages to performance clients. 74 * Context for sending messages to performance clients.
74 */ 75 */
@@ -92,7 +93,6 @@ find_client (struct GNUNET_SERVER_Client *client)
92 return NULL; 93 return NULL;
93} 94}
94 95
95
96/** 96/**
97 * Unregister a client (which may have been a performance client, 97 * Unregister a client (which may have been a performance client,
98 * but this is not assured). 98 * but this is not assured).
@@ -108,7 +108,6 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
108 if (NULL == pc) 108 if (NULL == pc)
109 return; 109 return;
110 GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); 110 GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
111 GAS_addresses_preference_client_disconnect (client);
112 GNUNET_free (pc); 111 GNUNET_free (pc);
113} 112}
114 113
@@ -593,109 +592,6 @@ GAS_handle_reservation_request (void *cls,
593} 592}
594 593
595 594
596/**
597 * Handle 'preference change' messages from clients.
598 *
599 * @param cls unused, NULL
600 * @param client client that sent the request
601 * @param message the request message
602 */
603void
604GAS_handle_preference_change (void *cls,
605 struct GNUNET_SERVER_Client *client,
606 const struct GNUNET_MessageHeader *message)
607{
608 const struct ChangePreferenceMessage *msg;
609 const struct PreferenceInformation *pi;
610 uint16_t msize;
611 uint32_t nump;
612 uint32_t i;
613
614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
615 "Received `%s' message\n",
616 "PREFERENCE_CHANGE");
617 msize = ntohs (message->size);
618 if (msize < sizeof (struct ChangePreferenceMessage))
619 {
620 GNUNET_break (0);
621 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
622 return;
623 }
624 msg = (const struct ChangePreferenceMessage *) message;
625 nump = ntohl (msg->num_preferences);
626 if (msize !=
627 sizeof (struct ChangePreferenceMessage) +
628 nump * sizeof (struct PreferenceInformation))
629 {
630 GNUNET_break (0);
631 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
632 return;
633 }
634 GNUNET_STATISTICS_update (GSA_stats,
635 "# preference change requests processed",
636 1, GNUNET_NO);
637 pi = (const struct PreferenceInformation *) &msg[1];
638 for (i = 0; i < nump; i++)
639 GAS_addresses_preference_change (client,
640 &msg->peer,
641 (enum GNUNET_ATS_PreferenceKind)
642 ntohl (pi[i].preference_kind),
643 pi[i].preference_value);
644 GNUNET_SERVER_receive_done (client, GNUNET_OK);
645}
646
647
648/**
649 * Handle 'preference feedback' messages from clients.
650 *
651 * @param cls unused, NULL
652 * @param client client that sent the request
653 * @param message the request message
654 */
655void
656GAS_handle_preference_feedback (void *cls,
657 struct GNUNET_SERVER_Client *client,
658 const struct GNUNET_MessageHeader *message)
659{
660 const struct FeedbackPreferenceMessage *msg;
661 const struct PreferenceInformation *pi;
662 uint16_t msize;
663 uint32_t nump;
664 uint32_t i;
665
666 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
667 "Received `%s' message\n",
668 "PREFERENCE_FEEDBACK");
669 msize = ntohs (message->size);
670 if (msize < sizeof (struct FeedbackPreferenceMessage))
671 {
672 GNUNET_break (0);
673 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
674 return;
675 }
676 msg = (const struct FeedbackPreferenceMessage *) message;
677 nump = ntohl (msg->num_feedback);
678 if (msize !=
679 sizeof (struct FeedbackPreferenceMessage) +
680 nump * sizeof (struct PreferenceInformation))
681 {
682 GNUNET_break (0);
683 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
684 return;
685 }
686 GNUNET_STATISTICS_update (GSA_stats,
687 "# preference feedbacks requests processed",
688 1, GNUNET_NO);
689 pi = (const struct PreferenceInformation *) &msg[1];
690 for (i = 0; i < nump; i++)
691 GAS_addresses_preference_feedback (client,
692 &msg->peer,
693 GNUNET_TIME_relative_ntoh(msg->scope),
694 (enum GNUNET_ATS_PreferenceKind)
695 ntohl (pi[i].preference_kind),
696 pi[i].preference_value);
697 GNUNET_SERVER_receive_done (client, GNUNET_OK);
698}
699 595
700 596
701/** 597/**