diff options
Diffstat (limited to 'src/dv/plugin_transport_dv.c')
-rw-r--r-- | src/dv/plugin_transport_dv.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 382e57596..f84c4a1b6 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -234,14 +234,12 @@ static void | |||
234 | notify_distance_change (struct Session *session) | 234 | notify_distance_change (struct Session *session) |
235 | { | 235 | { |
236 | struct Plugin *plugin = session->plugin; | 236 | struct Plugin *plugin = session->plugin; |
237 | struct GNUNET_ATS_Information ats; | ||
238 | 237 | ||
239 | if (GNUNET_YES != session->active) | 238 | if (GNUNET_YES != session->active) |
240 | return; | 239 | return; |
241 | ats.type = htonl ((uint32_t) GNUNET_ATS_QUALITY_NET_DISTANCE); | 240 | plugin->env->update_address_distance (plugin->env->cls, |
242 | ats.value = htonl (session->distance); | 241 | session->address, |
243 | plugin->env->update_address_metrics (plugin->env->cls, | 242 | session->distance); |
244 | session->address, session, &ats, 1); | ||
245 | } | 243 | } |
246 | 244 | ||
247 | 245 | ||
@@ -260,21 +258,20 @@ unbox_cb (void *cls, | |||
260 | { | 258 | { |
261 | struct Plugin *plugin = cls; | 259 | struct Plugin *plugin = cls; |
262 | struct Session *session = client; | 260 | struct Session *session = client; |
263 | struct GNUNET_ATS_Information ats; | ||
264 | 261 | ||
265 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
266 | ats.value = htonl (session->distance); | ||
267 | session->active = GNUNET_YES; | 262 | session->active = GNUNET_YES; |
268 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 263 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
269 | "Delivering message of type %u with %u bytes from peer `%s'\n", | 264 | "Delivering message of type %u with %u bytes from peer `%s'\n", |
270 | ntohs (message->type), | 265 | ntohs (message->type), |
271 | ntohs (message->size), | 266 | ntohs (message->size), |
272 | GNUNET_i2s (&session->sender)); | 267 | GNUNET_i2s (&session->sender)); |
273 | 268 | plugin->env->receive (plugin->env->cls, | |
274 | plugin->env->receive (plugin->env->cls, session->address, session, | 269 | session->address, |
270 | session, | ||
275 | message); | 271 | message); |
276 | plugin->env->update_address_metrics (plugin->env->cls, | 272 | plugin->env->update_address_distance (plugin->env->cls, |
277 | session->address, session, &ats, 1); | 273 | session->address, |
274 | session->distance); | ||
278 | return GNUNET_OK; | 275 | return GNUNET_OK; |
279 | } | 276 | } |
280 | 277 | ||
@@ -294,12 +291,12 @@ handle_dv_message_received (void *cls, | |||
294 | const struct GNUNET_MessageHeader *msg) | 291 | const struct GNUNET_MessageHeader *msg) |
295 | { | 292 | { |
296 | struct Plugin *plugin = cls; | 293 | struct Plugin *plugin = cls; |
297 | struct GNUNET_ATS_Information ats; | ||
298 | struct Session *session; | 294 | struct Session *session; |
299 | 295 | ||
300 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 296 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
301 | "Received DV_MESSAGE_RECEIVED message for peer `%s': new distance %u\n", | 297 | "Received DV_MESSAGE_RECEIVED message for peer `%s': new distance %u\n", |
302 | GNUNET_i2s (sender), distance); | 298 | GNUNET_i2s (sender), |
299 | distance); | ||
303 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, | 300 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
304 | sender); | 301 | sender); |
305 | if (NULL == session) | 302 | if (NULL == session) |
@@ -320,17 +317,19 @@ handle_dv_message_received (void *cls, | |||
320 | GNUNET_NO); | 317 | GNUNET_NO); |
321 | return; | 318 | return; |
322 | } | 319 | } |
323 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
324 | ats.value = htonl (distance); | ||
325 | session->active = GNUNET_YES; | 320 | session->active = GNUNET_YES; |
326 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 321 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
327 | "Delivering message of type %u with %u bytes from peer `%s'\n", | 322 | "Delivering message of type %u with %u bytes from peer `%s'\n", |
328 | ntohs (msg->type), | 323 | ntohs (msg->type), |
329 | ntohs (msg->size), | 324 | ntohs (msg->size), |
330 | GNUNET_i2s (sender)); | 325 | GNUNET_i2s (sender)); |
331 | plugin->env->receive (plugin->env->cls, session->address, session, msg); | 326 | plugin->env->receive (plugin->env->cls, |
332 | plugin->env->update_address_metrics (plugin->env->cls, | 327 | session->address, |
333 | session->address, session, &ats, 1); | 328 | session, |
329 | msg); | ||
330 | plugin->env->update_address_distance (plugin->env->cls, | ||
331 | session->address, | ||
332 | session->distance); | ||
334 | } | 333 | } |
335 | 334 | ||
336 | 335 | ||
@@ -350,7 +349,6 @@ handle_dv_connect (void *cls, | |||
350 | { | 349 | { |
351 | struct Plugin *plugin = cls; | 350 | struct Plugin *plugin = cls; |
352 | struct Session *session; | 351 | struct Session *session; |
353 | struct GNUNET_ATS_Information ats[2]; | ||
354 | 352 | ||
355 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); | 353 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); |
356 | /** | 354 | /** |
@@ -358,8 +356,7 @@ handle_dv_connect (void *cls, | |||
358 | * If you remove it, also remove libgnunetats linkage from Makefile.am | 356 | * If you remove it, also remove libgnunetats linkage from Makefile.am |
359 | */ | 357 | */ |
360 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 358 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
361 | "Received `%s' message for peer `%s' with next hop in network %s\n", | 359 | "Received DV_CONNECT message for peer `%s' with next hop in network %s\n", |
362 | "DV_CONNECT", | ||
363 | GNUNET_i2s (peer), | 360 | GNUNET_i2s (peer), |
364 | GNUNET_ATS_print_network_type (network)); | 361 | GNUNET_ATS_print_network_type (network)); |
365 | 362 | ||
@@ -375,7 +372,8 @@ handle_dv_connect (void *cls, | |||
375 | 372 | ||
376 | session = GNUNET_new (struct Session); | 373 | session = GNUNET_new (struct Session); |
377 | session->address = GNUNET_HELLO_address_allocate (peer, "dv", | 374 | session->address = GNUNET_HELLO_address_allocate (peer, "dv", |
378 | NULL, 0, GNUNET_HELLO_ADDRESS_INFO_NONE); | 375 | NULL, 0, |
376 | GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
379 | session->sender = *peer; | 377 | session->sender = *peer; |
380 | session->plugin = plugin; | 378 | session->plugin = plugin; |
381 | session->distance = distance; | 379 | session->distance = distance; |
@@ -391,14 +389,15 @@ handle_dv_connect (void *cls, | |||
391 | GNUNET_i2s (peer), | 389 | GNUNET_i2s (peer), |
392 | distance); | 390 | distance); |
393 | 391 | ||
394 | /* Notify transport and ats about new connection */ | ||
395 | ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
396 | ats[0].value = htonl (distance); | ||
397 | ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
398 | ats[1].value = htonl ((uint32_t) network); | ||
399 | session->active = GNUNET_YES; | 392 | session->active = GNUNET_YES; |
400 | plugin->env->session_start (plugin->env->cls, session->address, | 393 | plugin->env->session_start (plugin->env->cls, |
401 | session, ats, 2); | 394 | session->address, |
395 | session, | ||
396 | network); | ||
397 | plugin->env->update_address_distance (plugin->env->cls, | ||
398 | session->address, | ||
399 | session->distance); | ||
400 | |||
402 | notify_session_monitor (session->plugin, | 401 | notify_session_monitor (session->plugin, |
403 | session, | 402 | session, |
404 | GNUNET_TRANSPORT_SS_UP); | 403 | GNUNET_TRANSPORT_SS_UP); |