aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-13 20:48:27 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-13 20:48:27 +0000
commit8a8968521fba2e248c37c7b817fa970c5c5097e2 (patch)
tree9120747780c742eb6b4f8d853f88962ef541c351
parent2a726953f6afa9208188ddd39a922f4ad48bb1e4 (diff)
downloadgnunet-8a8968521fba2e248c37c7b817fa970c5c5097e2.tar.gz
gnunet-8a8968521fba2e248c37c7b817fa970c5c5097e2.zip
merging
-rw-r--r--src/ats/Makefile.am4
-rw-r--r--src/ats/gnunet-service-ats.c236
-rw-r--r--src/ats/gnunet-service-ats_performance.c90
-rw-r--r--src/ats/gnunet-service-ats_performance.h50
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c154
-rw-r--r--src/ats/gnunet-service-ats_scheduling.h55
6 files changed, 412 insertions, 177 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index b5ef6cb0b..31d9ef4e6 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -22,7 +22,9 @@ bin_PROGRAMS = \
22 gnunet-service-ats 22 gnunet-service-ats
23 23
24gnunet_service_ats_SOURCES = \ 24gnunet_service_ats_SOURCES = \
25 gnunet-service-ats.c 25 gnunet-service-ats.c \
26 gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
27 gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h
26gnunet_service_ats_LDADD = \ 28gnunet_service_ats_LDADD = \
27 $(top_builddir)/src/util/libgnunetutil.la \ 29 $(top_builddir)/src/util/libgnunetutil.la \
28 $(GN_LIBINTL) 30 $(GN_LIBINTL)
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c
index db175964c..aca877d7b 100644
--- a/src/ats/gnunet-service-ats.c
+++ b/src/ats/gnunet-service-ats.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2011 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
@@ -24,23 +24,13 @@
24 * @author Matthias Wachs 24 * @author Matthias Wachs
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_service_lib.h"
29#include "gnunet_container_lib.h"
30#include "gnunet_ats_service.h" 28#include "gnunet_ats_service.h"
29#include "gnunet-service-ats_performance.h"
30#include "gnunet-service-ats_scheduling.h"
31// #include "gnunet-service-ats_performance.h"
31#include "ats.h" 32#include "ats.h"
32 33
33struct ATS_Clients
34{
35 struct ATS_Clients * next;
36
37 struct ATS_Clients * prev;
38
39 struct GNUNET_SERVER_Client *client;
40
41 uint32_t flags;
42};
43
44struct ATS_Address 34struct ATS_Address
45{ 35{
46 struct GNUNET_PeerIdentity peer; 36 struct GNUNET_PeerIdentity peer;
@@ -58,27 +48,38 @@ struct ATS_Address
58 struct GNUNET_TRANSPORT_ATS_Information * ats; 48 struct GNUNET_TRANSPORT_ATS_Information * ats;
59}; 49};
60 50
61/** 51static struct GNUNET_CONTAINER_MultiHashMap * addresses;
62 * Head of linked list of all clients to this service.
63 */
64static struct ATS_Clients *ac_head;
65 52
66/**
67 * Tail of linked list of all clients to this service.
68 */
69static struct ATS_Clients *ac_tail;
70 53
71static struct GNUNET_CONTAINER_MultiHashMap * addresses;
72 54
73int free_address_it (void *cls, 55static void
74 const GNUNET_HashCode * key, 56handle_ats_start (void *cls, struct GNUNET_SERVER_Client *client,
75 void *value) 57 const struct GNUNET_MessageHeader *message)
76{ 58{
77 struct ATS_Address * aa = cls; 59 const struct ClientStartMessage * msg = (const struct ClientStartMessage *) message;
78 GNUNET_free (aa); 60
79 return GNUNET_OK; 61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
62 "Received `%s' message\n",
63 "ATS_START");
64 switch (ntohl (msg->start_flag))
65 {
66 case START_FLAG_SCHEDULING:
67 GAS_add_scheduling_client (client);
68 break;
69 case START_FLAG_PERFORMANCE_WITH_PIC:
70 GAS_add_performance_client (client);
71 break;
72 case START_FLAG_PERFORMANCE_NO_PIC:
73 break;
74 default:
75 GNUNET_break (0);
76 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
77 return;
78 }
79 GNUNET_SERVER_receive_done (client, GNUNET_OK);
80} 80}
81 81
82
82struct CompareAddressContext 83struct CompareAddressContext
83{ 84{
84 struct ATS_Address * search; 85 struct ATS_Address * search;
@@ -101,155 +102,34 @@ int compare_address_it (void *cls,
101 return GNUNET_YES; 102 return GNUNET_YES;
102} 103}
103 104
104/**
105 * Task run during shutdown.
106 *
107 * @param cls unused
108 * @param tc unused
109 */
110static void
111cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
112{
113 struct ATS_Clients * t;
114
115 while (ac_head != NULL)
116 {
117 t = ac_head;
118 GNUNET_CONTAINER_DLL_remove(ac_head,ac_tail, t);
119 GNUNET_free (t);
120 }
121
122 GNUNET_CONTAINER_multihashmap_iterate (addresses, free_address_it, NULL);
123 105
124 GNUNET_CONTAINER_multihashmap_destroy (addresses); 106static int
125} 107free_address_it (void *cls,
126 108 const GNUNET_HashCode * key,
127static struct ATS_Clients * find_client (struct GNUNET_SERVER_Client *client) 109 void *value)
128{ 110{
129 struct ATS_Clients * ac = ac_head; 111 struct ATS_Address * aa = cls;
130 while (ac != NULL) 112 GNUNET_free (aa);
131 { 113 return GNUNET_OK;
132 if (ac->client == client)
133 break;
134 ac = ac->next;
135 }
136 return ac;
137}
138
139static void
140handle_ats_start (void *cls, struct GNUNET_SERVER_Client *client,
141 const struct GNUNET_MessageHeader *message)
142
143{
144 struct ClientStartMessage * msg = (struct ClientStartMessage *) message;
145 struct ATS_Clients * ac = NULL;
146
147
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ATS_START");
149
150 GNUNET_assert (find_client(client) == NULL);
151
152 ac = GNUNET_malloc (sizeof (struct ATS_Clients));
153 ac->client = client;
154 ac->flags = ntohl (msg->start_flag);
155
156 GNUNET_CONTAINER_DLL_insert(ac_head, ac_tail, ac);
157}
158
159static void
160handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
161 const struct GNUNET_MessageHeader *message)
162
163{
164 // struct RequestAddressMessage * msg = (struct RequestAddressMessage *) message;
165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "REQUEST_ADDRESS");
166
167} 114}
168 115
169static void
170handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
171 const struct GNUNET_MessageHeader *message)
172 116
173{
174 struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message;
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ADDRESS_UPDATE");
176
177 struct GNUNET_TRANSPORT_ATS_Information *am;
178 char *pm;
179
180 size_t size = ntohs (msg->header.size);
181 if ((size <= sizeof (struct AddressUpdateMessage)) || (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
182 {
183 GNUNET_break (0);
184 return;
185 }
186
187 size_t ats_count = ntohs (msg->ats_count);
188 size_t addr_len = ntohs (msg->address_length);
189 size_t plugin_len = ntohs (msg->plugin_name_length) + 1 ;
190
191 if (
192 (plugin_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
193 (addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
194 (addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_TRANSPORT_ATS_Information)) )
195 {
196 GNUNET_break (0);
197 return;
198 }
199 117
200 struct ATS_Address * aa = GNUNET_malloc (sizeof (struct ATS_Address) +
201 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) +
202 addr_len +
203 plugin_len);
204 118
205 119
206 120/**
207 memcpy (&aa->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity)); 121 * Task run during shutdown.
208 aa->addr_len = addr_len; 122 *
209 aa->ats_count = ats_count; 123 * @param cls unused
210 aa->ats = (struct GNUNET_TRANSPORT_ATS_Information *) &aa[1]; 124 * @param tc unused
211 125 */
212 am = (struct GNUNET_TRANSPORT_ATS_Information*) &msg[1];
213 memcpy (&aa->ats, am, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
214 pm = (char *) &am[ats_count];
215 memcpy (aa->addr, pm, addr_len);
216 memcpy (aa->plugin, &pm[plugin_len], plugin_len);
217 aa->session_id = ntohl(msg->session_id);
218
219 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(addresses, &aa->peer.hashPubKey, aa, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
220}
221
222static void
223handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
224 const struct GNUNET_MessageHeader *message)
225
226{
227 // struct AddressDestroyedMessage * msg = (struct AddressDestroyedMessage *) message;
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ADDRESS_DESTROYED");
229/*
230 struct GNUNET_PeerIdentity *peer = &msg->peer;
231 struct ATS_Address * aa = find_address_by_addr (peer);
232 GNUNET_CONTAINER_multihashmap_remove(addresses, peer, aa);
233 GNUNET_free (aa);*/
234}
235
236static void 126static void
237handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, 127cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
238 const struct GNUNET_MessageHeader *message)
239
240{ 128{
241 // struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message; 129 GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL);
242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "RESERVATION_REQUEST"); 130 GNUNET_CONTAINER_multihashmap_destroy (addresses);
243} 131}
244 132
245static void
246handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
247 const struct GNUNET_MessageHeader *message)
248
249{
250 // struct ChangePreferenceMessage * msg = (struct ChangePreferenceMessage *) message;
251 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE");
252}
253 133
254/** 134/**
255 * Process template requests. 135 * Process template requests.
@@ -263,17 +143,21 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
263 const struct GNUNET_CONFIGURATION_Handle *cfg) 143 const struct GNUNET_CONFIGURATION_Handle *cfg)
264{ 144{
265 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 145 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
266 {&handle_ats_start, NULL, GNUNET_MESSAGE_TYPE_ATS_START, sizeof (struct ClientStartMessage)}, 146 { &handle_ats_start, NULL,
267 {&handle_request_address, NULL, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS, sizeof (struct RequestAddressMessage)}, 147 GNUNET_MESSAGE_TYPE_ATS_START, sizeof (struct ClientStartMessage)},
268 {&handle_address_update, NULL, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0}, 148 { &GAS_handle_request_address, NULL,
269 {&handle_address_destroyed, NULL, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0}, 149 GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS, sizeof (struct RequestAddressMessage)},
270 {&handle_reservation_request, NULL, GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, sizeof (struct ReservationRequestMessage)}, 150 { &GAS_handle_address_update, NULL,
271 {&handle_preference_change, NULL, GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0}, 151 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0},
152 { &GAS_handle_address_destroyed, NULL,
153 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0},
154 { &GAS_handle_reservation_request, NULL,
155 GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, sizeof (struct ReservationRequestMessage)},
156 { &GAS_handle_preference_change, NULL,
157 GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0},
272 {NULL, NULL, 0, 0} 158 {NULL, NULL, 0, 0}
273 }; 159 };
274 160 addresses = GNUNET_CONTAINER_multihashmap_create(128);
275 addresses = GNUNET_CONTAINER_multihashmap_create(100);
276
277 GNUNET_SERVER_add_handlers (server, handlers); 161 GNUNET_SERVER_add_handlers (server, handlers);
278 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, 162 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
279 NULL); 163 NULL);
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
new file mode 100644
index 000000000..fa60e4973
--- /dev/null
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -0,0 +1,90 @@
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
31struct 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 */
45static struct PerformanceClient *pc_head;
46
47/**
48 * Tail of linked list of all clients to this service.
49 */
50static struct PerformanceClient *pc_tail;
51
52
53void
54GAS_add_performance_client (struct GNUNET_SERVER_Client *client)
55{
56 struct PerformanceClient * pc;
57
58 pc = GNUNET_malloc (sizeof (struct PerformanceClient));
59 pc->client = client;
60 GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc);
61}
62
63
64void
65GAS_remove_performance_client (struct GNUNET_SERVER_Client *client)
66{
67}
68
69
70void
71GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
72 const struct GNUNET_MessageHeader *message)
73
74{
75 // struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message;
76 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "RESERVATION_REQUEST");
77}
78
79
80void
81GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
82 const struct GNUNET_MessageHeader *message)
83
84{
85 // struct ChangePreferenceMessage * msg = (struct ChangePreferenceMessage *) message;
86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE");
87}
88
89
90/* end of gnunet-service-ats_performance.c */
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
new file mode 100644
index 000000000..45bc39c35
--- /dev/null
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -0,0 +1,50 @@
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.h
23 * @brief ats service, interaction with 'performance' API
24 * @author Matthias Wachs
25 */
26#ifndef GNUNET_SERVICE_ATS_PERFORMANCE_H
27#define GNUNET_SERVICE_ATS_PERFORMANCE_H
28
29#include "gnunet_util_lib.h"
30
31void
32GAS_add_performance_client (struct GNUNET_SERVER_Client *client);
33
34
35void
36GAS_remove_performance_client (struct GNUNET_SERVER_Client *client);
37
38
39void
40GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
41 const struct GNUNET_MessageHeader *message);
42
43
44void
45GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
46 const struct GNUNET_MessageHeader *message);
47
48
49#endif
50/* end of gnunet-service-ats_performance.h */
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
new file mode 100644
index 000000000..9400e12ff
--- /dev/null
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -0,0 +1,154 @@
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_scheduling.c
23 * @brief ats service, interaction with 'scheduling' API
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet-service-ats_scheduling.h"
28#include "ats.h"
29
30
31struct SchedulingClient
32{
33 struct SchedulingClient * next;
34
35 struct SchedulingClient * 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 */
45static struct SchedulingClient *ac_head;
46
47/**
48 * Tail of linked list of all clients to this service.
49 */
50static struct SchedulingClient *ac_tail;
51
52
53void
54GAS_add_scheduling_client (struct GNUNET_SERVER_Client *client)
55{
56 struct SchedulingClient *ac;
57
58 ac = GNUNET_malloc (sizeof (struct SchedulingClient));
59 ac->client = client;
60 GNUNET_SERVER_client_keep (client);
61 GNUNET_CONTAINER_DLL_insert(ac_head, ac_tail, ac);
62}
63
64
65void
66GAS_remove_scheduling_client (struct GNUNET_SERVER_Client *client)
67{
68}
69
70
71void
72GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
73 const struct GNUNET_MessageHeader *message)
74
75{
76 // struct RequestAddressMessage * msg = (struct RequestAddressMessage *) message;
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "REQUEST_ADDRESS");
78
79}
80
81
82void
83GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
84 const struct GNUNET_MessageHeader *message)
85
86{
87#if 0
88 struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message;
89 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ADDRESS_UPDATE");
90
91 struct GNUNET_TRANSPORT_ATS_Information *am;
92 char *pm;
93
94 size_t size = ntohs (msg->header.size);
95 if ((size <= sizeof (struct AddressUpdateMessage)) || (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
96 {
97 GNUNET_break (0);
98 return;
99 }
100
101 size_t ats_count = ntohs (msg->ats_count);
102 size_t addr_len = ntohs (msg->address_length);
103 size_t plugin_len = ntohs (msg->plugin_name_length) + 1 ;
104
105 if (
106 (plugin_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
107 (addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
108 (addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_TRANSPORT_ATS_Information)) )
109 {
110 GNUNET_break (0);
111 return;
112 }
113
114 struct ATS_Address * aa = GNUNET_malloc (sizeof (struct ATS_Address) +
115 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) +
116 addr_len +
117 plugin_len);
118
119
120
121 memcpy (&aa->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity));
122 aa->addr_len = addr_len;
123 aa->ats_count = ats_count;
124 aa->ats = (struct GNUNET_TRANSPORT_ATS_Information *) &aa[1];
125
126 am = (struct GNUNET_TRANSPORT_ATS_Information*) &msg[1];
127 memcpy (&aa->ats, am, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
128 pm = (char *) &am[ats_count];
129 memcpy (aa->addr, pm, addr_len);
130 memcpy (aa->plugin, &pm[plugin_len], plugin_len);
131 aa->session_id = ntohl(msg->session_id);
132
133 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(addresses, &aa->peer.hashPubKey, aa, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
134#endif
135}
136
137
138void
139GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
140 const struct GNUNET_MessageHeader *message)
141
142{
143#if 0
144 // struct AddressDestroyedMessage * msg = (struct AddressDestroyedMessage *) message;
145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ADDRESS_DESTROYED");
146/*
147 struct GNUNET_PeerIdentity *peer = &msg->peer;
148 struct ATS_Address * aa = find_address_by_addr (peer);
149 GNUNET_CONTAINER_multihashmap_remove(addresses, peer, aa);
150 GNUNET_free (aa);*/
151#endif
152}
153
154/* end of gnunet-service-ats_scheduling.c */
diff --git a/src/ats/gnunet-service-ats_scheduling.h b/src/ats/gnunet-service-ats_scheduling.h
new file mode 100644
index 000000000..5c8f77ed8
--- /dev/null
+++ b/src/ats/gnunet-service-ats_scheduling.h
@@ -0,0 +1,55 @@
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_scheduling.h
23 * @brief ats service, interaction with 'scheduling' API
24 * @author Matthias Wachs
25 */
26#ifndef GNUNET_SERVICE_ATS_SCHEDULING_H
27#define GNUNET_SERVICE_ATS_SCHEDULING_H
28
29#include "gnunet_util_lib.h"
30
31void
32GAS_add_scheduling_client (struct GNUNET_SERVER_Client *client);
33
34
35void
36GAS_remove_scheduling_client (struct GNUNET_SERVER_Client *client);
37
38
39void
40GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
41 const struct GNUNET_MessageHeader *message);
42
43
44void
45GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
46 const struct GNUNET_MessageHeader *message);
47
48
49void
50GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
51 const struct GNUNET_MessageHeader *message);
52
53
54#endif
55/* end of gnunet-service-ats_scheduling.h */