more client disconnect code
[oweals/gnunet.git] / src / ats / gnunet-service-ats_performance.c
1 /*
2      This file is part of GNUnet.
3      (C) 2011 Christian Grothoff (and other contributing authors)
4
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
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file ats/gnunet-service-ats_performance.c
23  * @brief ats service, interaction with 'performance' API
24  * @author Matthias Wachs
25  */
26 #include "platform.h"
27 #include "gnunet-service-ats_performance.h"
28 #include "ats.h"
29
30
31 struct PerformanceClient
32 {
33   struct PerformanceClient * next;
34
35   struct PerformanceClient * prev;
36
37   struct GNUNET_SERVER_Client *client;
38
39 };
40
41
42 /**
43  * Head of linked list of all clients to this service.
44  */
45 static struct PerformanceClient *pc_head;
46
47 /**
48  * Tail of linked list of all clients to this service.
49  */
50 static struct PerformanceClient *pc_tail;
51  
52
53 static struct PerformanceClient * 
54 find_client (struct GNUNET_SERVER_Client *client)
55 {
56   struct PerformanceClient * pc;
57
58   for (pc = pc_head; pc != NULL; pc = pc->next)
59     if (pc->client == client)
60       return pc;
61   return NULL;
62 }
63
64
65 void
66 GAS_add_performance_client (struct GNUNET_SERVER_Client *client)
67 {
68   struct PerformanceClient * pc;
69
70   GNUNET_break (NULL == find_client (client));
71   pc = GNUNET_malloc (sizeof (struct PerformanceClient));
72   pc->client = client;
73   GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc);
74 }
75
76
77 void
78 GAS_remove_performance_client (struct GNUNET_SERVER_Client *client)
79 {
80   struct PerformanceClient * pc;
81
82   pc = find_client (client);
83   if (NULL == pc)
84     return;
85   GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
86   GNUNET_SERVER_client_drop (client);
87   GNUNET_free (pc);
88 }
89
90
91 void
92 GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
93                       const struct GNUNET_MessageHeader *message)
94
95 {
96   // struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message;
97   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "RESERVATION_REQUEST");
98 }
99
100
101 void
102 GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
103                       const struct GNUNET_MessageHeader *message)
104
105 {
106   // struct ChangePreferenceMessage * msg = (struct ChangePreferenceMessage *) message;
107   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE");
108 }
109
110
111 /* end of gnunet-service-ats_performance.c */