diff options
-rw-r--r-- | src/ats-tool/gnunet-ats.c | 44 | ||||
-rw-r--r-- | src/ats/ats.h | 9 | ||||
-rw-r--r-- | src/ats/ats_api_performance.c | 19 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats.c | 3 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 20 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.h | 11 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 12 |
7 files changed, 92 insertions, 26 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 0ca28724a..27dfd4dca 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -178,31 +178,27 @@ void ats_perf_cb (void *cls, | |||
178 | { | 178 | { |
179 | struct PendingResolutions * pr; | 179 | struct PendingResolutions * pr; |
180 | 180 | ||
181 | pr = GNUNET_malloc (sizeof (struct PendingResolutions) + | ||
182 | ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
183 | |||
184 | pr->ats_count = ats_count; | ||
185 | pr->ats = (struct GNUNET_ATS_Information *) &pr[1]; | ||
186 | if (ats_count > 0) | ||
187 | memcpy (pr->ats, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
188 | pr->address = GNUNET_HELLO_address_copy (address); | ||
189 | pr->bandwidth_in = bandwidth_in; | ||
190 | pr->bandwidth_out = bandwidth_out; | ||
191 | pr->tats_ctx = GNUNET_TRANSPORT_address_to_string(cfg, address, | ||
192 | resolve_addresses_numeric, GNUNET_TIME_UNIT_FOREVER_REL, transport_addr_to_str_cb, pr); | ||
193 | GNUNET_CONTAINER_DLL_insert (head, tail, pr); | ||
194 | results++; | ||
195 | } | ||
196 | |||
197 | void la_cb (void *cls, | ||
198 | const struct GNUNET_HELLO_Address * address, | ||
199 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
200 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
201 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | ||
202 | { | ||
203 | 181 | ||
182 | if (NULL != address) | ||
183 | { | ||
184 | pr = GNUNET_malloc (sizeof (struct PendingResolutions) + | ||
185 | ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
186 | |||
187 | pr->ats_count = ats_count; | ||
188 | pr->ats = (struct GNUNET_ATS_Information *) &pr[1]; | ||
189 | if (ats_count > 0) | ||
190 | memcpy (pr->ats, ats, ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
191 | pr->address = GNUNET_HELLO_address_copy (address); | ||
192 | pr->bandwidth_in = bandwidth_in; | ||
193 | pr->bandwidth_out = bandwidth_out; | ||
194 | pr->tats_ctx = GNUNET_TRANSPORT_address_to_string(cfg, address, | ||
195 | resolve_addresses_numeric, GNUNET_TIME_UNIT_FOREVER_REL, transport_addr_to_str_cb, pr); | ||
196 | GNUNET_CONTAINER_DLL_insert (head, tail, pr); | ||
197 | results++; | ||
198 | } | ||
204 | } | 199 | } |
205 | 200 | ||
201 | |||
206 | void end (void *cls, | 202 | void end (void *cls, |
207 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 203 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
208 | { | 204 | { |
@@ -289,7 +285,7 @@ void testservice_ats (void *cls, | |||
289 | 285 | ||
290 | alh = GNUNET_ATS_performance_list_addresses (ph, | 286 | alh = GNUNET_ATS_performance_list_addresses (ph, |
291 | (NULL == pid_str) ? NULL : &pid, | 287 | (NULL == pid_str) ? NULL : &pid, |
292 | GNUNET_YES, la_cb, NULL); | 288 | GNUNET_YES, ats_perf_cb, NULL); |
293 | if (NULL == alh) | 289 | if (NULL == alh) |
294 | { | 290 | { |
295 | fprintf (stderr, _("Cannot issue request to ATS service, exiting...\n")); | 291 | fprintf (stderr, _("Cannot issue request to ATS service, exiting...\n")); |
@@ -308,7 +304,7 @@ void testservice_ats (void *cls, | |||
308 | 304 | ||
309 | alh = GNUNET_ATS_performance_list_addresses (ph, | 305 | alh = GNUNET_ATS_performance_list_addresses (ph, |
310 | (NULL == pid_str) ? NULL : &pid, | 306 | (NULL == pid_str) ? NULL : &pid, |
311 | GNUNET_NO, la_cb, NULL); | 307 | GNUNET_NO, ats_perf_cb, NULL); |
312 | if (NULL == alh) | 308 | if (NULL == alh) |
313 | { | 309 | { |
314 | fprintf (stderr, _("Cannot issue request to ATS service, exiting...\n")); | 310 | fprintf (stderr, _("Cannot issue request to ATS service, exiting...\n")); |
diff --git a/src/ats/ats.h b/src/ats/ats.h index f4c3d9fba..61bef12fe 100644 --- a/src/ats/ats.h +++ b/src/ats/ats.h | |||
@@ -188,6 +188,15 @@ struct PeerInformationMessage | |||
188 | 188 | ||
189 | }; | 189 | }; |
190 | 190 | ||
191 | struct AddressListRequestMessage | ||
192 | { | ||
193 | struct GNUNET_MessageHeader header; | ||
194 | |||
195 | int32_t all GNUNET_PACKED; | ||
196 | |||
197 | struct GNUNET_PeerIdentity peer; | ||
198 | }; | ||
199 | |||
191 | 200 | ||
192 | struct ReservationRequestMessage | 201 | struct ReservationRequestMessage |
193 | { | 202 | { |
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 49e0df595..b86276363 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c | |||
@@ -648,6 +648,8 @@ GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *hand | |||
648 | void *infocb_cls) | 648 | void *infocb_cls) |
649 | { | 649 | { |
650 | struct GNUNET_ATS_AddressListHandle *alh; | 650 | struct GNUNET_ATS_AddressListHandle *alh; |
651 | struct PendingMessage *p; | ||
652 | struct AddressListRequestMessage *m; | ||
651 | 653 | ||
652 | GNUNET_assert (NULL != handle); | 654 | GNUNET_assert (NULL != handle); |
653 | 655 | ||
@@ -666,8 +668,21 @@ GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *hand | |||
666 | 668 | ||
667 | GNUNET_CONTAINER_DLL_insert (handle->addresslist_head, handle->addresslist_tail, alh); | 669 | GNUNET_CONTAINER_DLL_insert (handle->addresslist_head, handle->addresslist_tail, alh); |
668 | 670 | ||
669 | /* TODO */ | 671 | p = GNUNET_malloc (sizeof (struct PendingMessage) + |
670 | FPRINTF (stderr, "TBD"); | 672 | sizeof (struct AddressListRequestMessage)); |
673 | p->size = sizeof (struct AddressListRequestMessage); | ||
674 | m = (struct AddressListRequestMessage *) &p[1]; | ||
675 | m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST); | ||
676 | m->header.size = htons (sizeof (struct AddressListRequestMessage)); | ||
677 | m->all = htonl (all); | ||
678 | if (NULL != peer) | ||
679 | m->peer = *peer; | ||
680 | else | ||
681 | { | ||
682 | memset (&m->peer, '\0', sizeof (struct GNUNET_PeerIdentity)); | ||
683 | } | ||
684 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, p); | ||
685 | do_transmit (handle); | ||
671 | 686 | ||
672 | return alh; | 687 | return alh; |
673 | } | 688 | } |
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index 8f2e45d5d..e9a11a8b8 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -142,6 +142,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
142 | {&GAS_handle_request_address_cancel, NULL, | 142 | {&GAS_handle_request_address_cancel, NULL, |
143 | GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL, | 143 | GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL, |
144 | sizeof (struct RequestAddressMessage)}, | 144 | sizeof (struct RequestAddressMessage)}, |
145 | {&GAS_handle_request_address_list, NULL, | ||
146 | GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST, | ||
147 | sizeof (struct AddressListRequestMessage)}, | ||
145 | {&GAS_handle_address_add, NULL, | 148 | {&GAS_handle_address_add, NULL, |
146 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, 0}, | 149 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, 0}, |
147 | {&GAS_handle_address_update, NULL, | 150 | {&GAS_handle_address_update, NULL, |
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 508a6c45e..ccc2446d9 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -284,6 +284,26 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | |||
284 | GAS_addresses_iterate_peers (&peer_it, pc); | 284 | GAS_addresses_iterate_peers (&peer_it, pc); |
285 | } | 285 | } |
286 | 286 | ||
287 | /** | ||
288 | * Handle 'address list request' messages from clients. | ||
289 | * | ||
290 | * @param cls unused, NULL | ||
291 | * @param client client that sent the request | ||
292 | * @param message the request message | ||
293 | */ | ||
294 | void | ||
295 | GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, | ||
296 | const struct GNUNET_MessageHeader *message) | ||
297 | { | ||
298 | struct AddressListRequestMessage * alrm = cls; | ||
299 | |||
300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", | ||
301 | "ADDRESSLIST_REQUEST"); | ||
302 | |||
303 | |||
304 | |||
305 | } | ||
306 | |||
287 | 307 | ||
288 | 308 | ||
289 | /** | 309 | /** |
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h index 35b7ad3ea..c904ed3f0 100644 --- a/src/ats/gnunet-service-ats_performance.h +++ b/src/ats/gnunet-service-ats_performance.h | |||
@@ -78,6 +78,17 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
78 | 78 | ||
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Handle 'address list request' messages from clients. | ||
82 | * | ||
83 | * @param cls unused, NULL | ||
84 | * @param client client that sent the request | ||
85 | * @param message the request message | ||
86 | */ | ||
87 | void | ||
88 | GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, | ||
89 | const struct GNUNET_MessageHeader *message); | ||
90 | |||
91 | /** | ||
81 | * Handle 'reservation request' messages from clients. | 92 | * Handle 'reservation request' messages from clients. |
82 | * | 93 | * |
83 | * @param cls unused, NULL | 94 | * @param cls unused, NULL |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 7b0b46055..b9102f429 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1100,6 +1100,18 @@ extern "C" | |||
1100 | */ | 1100 | */ |
1101 | #define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD 353 | 1101 | #define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD 353 |
1102 | 1102 | ||
1103 | /** | ||
1104 | * Type of the 'struct AddressListRequestMessage' sent by client to ATS | ||
1105 | * to request information about addresses | ||
1106 | */ | ||
1107 | #define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST 354 | ||
1108 | |||
1109 | /** | ||
1110 | * Type of the 'struct AddressListResponseMessage' sent by ATS to client | ||
1111 | * with information about addresses | ||
1112 | */ | ||
1113 | #define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE 355 | ||
1114 | |||
1103 | /******************************************************************************* | 1115 | /******************************************************************************* |
1104 | * TRANSPORT message types | 1116 | * TRANSPORT message types |
1105 | ******************************************************************************/ | 1117 | ******************************************************************************/ |