diff options
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 43 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_scheduling.c | 29 |
2 files changed, 51 insertions, 21 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 5ed3c471b..70bb8517f 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -82,16 +82,22 @@ compare_address_it (void *cls, | |||
82 | (aa->session_id != cac->search->session_id)) | 82 | (aa->session_id != cac->search->session_id)) |
83 | return GNUNET_YES; | 83 | return GNUNET_YES; |
84 | 84 | ||
85 | if (aa->addr_len != cac->search->addr_len) | ||
86 | { | ||
87 | return GNUNET_YES; | ||
88 | } | ||
89 | |||
85 | if (0 == strcmp(aa->plugin, cac->search->plugin)) | 90 | if (0 == strcmp(aa->plugin, cac->search->plugin)) |
86 | { | 91 | { |
87 | if (aa->addr_len != cac->search->addr_len) | 92 | return GNUNET_YES; |
88 | return GNUNET_YES; | 93 | } |
89 | if (aa->addr_len == 0) | 94 | |
90 | return GNUNET_YES; | 95 | if (0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) |
91 | if (0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) | 96 | { |
92 | cac->result = aa; | 97 | cac->result = aa; |
93 | return GNUNET_NO; | 98 | return GNUNET_NO; |
94 | } | 99 | } |
100 | |||
95 | return GNUNET_YES; | 101 | return GNUNET_YES; |
96 | } | 102 | } |
97 | 103 | ||
@@ -212,16 +218,17 @@ GAS_address_destroyed (const struct GNUNET_PeerIdentity *peer, | |||
212 | aa->session_client = session_client; | 218 | aa->session_client = session_client; |
213 | aa->session_id = session_id; | 219 | aa->session_id = session_id; |
214 | 220 | ||
215 | res = find_address (peer, aa); | ||
216 | GNUNET_assert (res != 0); | ||
217 | |||
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
219 | "Deleting address for peer `%s'\n", | 222 | "Deleting address for peer `%s': `%s'\n", |
220 | GNUNET_i2s (peer)); | 223 | GNUNET_i2s (peer), plugin_name); |
221 | 224 | ||
222 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(addresses, &peer->hashPubKey, res)); | 225 | res = find_address (peer, aa); |
223 | destroy_address (aa); | 226 | if (res != NULL) |
224 | destroy_address (res); | 227 | { |
228 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(addresses, &peer->hashPubKey, res)); | ||
229 | destroy_address (aa); | ||
230 | destroy_address (res); | ||
231 | } | ||
225 | } | 232 | } |
226 | 233 | ||
227 | 234 | ||
@@ -231,7 +238,15 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | |||
231 | struct ATS_Address * aa = NULL; | 238 | struct ATS_Address * aa = NULL; |
232 | aa = GNUNET_CONTAINER_multihashmap_get (addresses, &peer->hashPubKey); | 239 | aa = GNUNET_CONTAINER_multihashmap_get (addresses, &peer->hashPubKey); |
233 | if (aa != NULL) | 240 | if (aa != NULL) |
241 | { | ||
242 | aa->bw_in.value__ = htonl (100000); | ||
243 | aa->bw_out.value__ = htonl (100000); | ||
234 | GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr, aa->addr_len, aa->session_client, aa->session_id, aa->ats, aa->ats_count, aa->bw_out, aa->bw_in); | 244 | GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr, aa->addr_len, aa->session_client, aa->session_id, aa->ats, aa->ats_count, aa->bw_out, aa->bw_in); |
245 | } | ||
246 | else | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
248 | "Cannot provide address for peer `%s'\n", | ||
249 | GNUNET_i2s (peer)); | ||
235 | } | 250 | } |
236 | 251 | ||
237 | 252 | ||
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c index 2491529db..9eebe2c3e 100644 --- a/src/ats/gnunet-service-ats_scheduling.c +++ b/src/ats/gnunet-service-ats_scheduling.c | |||
@@ -258,7 +258,10 @@ GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client, | |||
258 | plugin_name_length = ntohs (m->plugin_name_length); | 258 | plugin_name_length = ntohs (m->plugin_name_length); |
259 | atsi = (const struct GNUNET_TRANSPORT_ATS_Information*) &m[1]; | 259 | atsi = (const struct GNUNET_TRANSPORT_ATS_Information*) &m[1]; |
260 | address = (const char*) &atsi[ats_count]; | 260 | address = (const char*) &atsi[ats_count]; |
261 | plugin_name = &address[address_length]; | 261 | if (plugin_name_length != 0) |
262 | plugin_name = &address[address_length]; | ||
263 | else | ||
264 | plugin_name = ""; | ||
262 | if ( (address_length + | 265 | if ( (address_length + |
263 | plugin_name_length + | 266 | plugin_name_length + |
264 | ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) + | 267 | ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information) + |
@@ -302,10 +305,10 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client, | |||
302 | uint16_t size; | 305 | uint16_t size; |
303 | 306 | ||
304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
305 | "Received `%s' message\n", | 308 | "Received `%s' message of size %u %u\n", |
306 | "ADDRESS_DESTROYED"); | 309 | "ADDRESS_DESTROYED", ntohs (message->size), sizeof (struct AddressDestroyedMessage)); |
307 | size = ntohs (message->size); | 310 | size = ntohs (message->size); |
308 | if (size <= sizeof (struct AddressDestroyedMessage)) | 311 | if (size < sizeof (struct AddressDestroyedMessage)) |
309 | { | 312 | { |
310 | GNUNET_break (0); | 313 | GNUNET_break (0); |
311 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 314 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -316,16 +319,28 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client, | |||
316 | address_length = ntohs (m->address_length); | 319 | address_length = ntohs (m->address_length); |
317 | plugin_name_length = ntohs (m->plugin_name_length); | 320 | plugin_name_length = ntohs (m->plugin_name_length); |
318 | address = (const char*) &m[1]; | 321 | address = (const char*) &m[1]; |
319 | plugin_name = &address[address_length]; | 322 | if (plugin_name_length != 0) |
323 | plugin_name = &address[address_length]; | ||
324 | else | ||
325 | plugin_name = ""; | ||
326 | |||
320 | if ( (address_length + | 327 | if ( (address_length + |
321 | plugin_name_length + | 328 | plugin_name_length + |
322 | sizeof (struct AddressDestroyedMessage) != ntohs (message->size)) || | 329 | sizeof (struct AddressDestroyedMessage) != ntohs (message->size))) |
323 | (plugin_name[plugin_name_length - 1] != '\0') ) | ||
324 | { | 330 | { |
325 | GNUNET_break (0); | 331 | GNUNET_break (0); |
326 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 332 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
327 | return; | 333 | return; |
328 | } | 334 | } |
335 | |||
336 | if (plugin_name_length != 0) | ||
337 | if (plugin_name[plugin_name_length - 1] != '\0') | ||
338 | { | ||
339 | GNUNET_break (0); | ||
340 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
341 | return; | ||
342 | } | ||
343 | |||
329 | GAS_address_destroyed (&m->peer, | 344 | GAS_address_destroyed (&m->peer, |
330 | plugin_name, | 345 | plugin_name, |
331 | address, | 346 | address, |