diff options
Diffstat (limited to 'src/dv/plugin_transport_dv.c')
-rw-r--r-- | src/dv/plugin_transport_dv.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 30d33c2d7..ba625d257 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-dv",__VA_ARGS__) | 39 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-dv",__VA_ARGS__) |
40 | 40 | ||
41 | #define PLUGIN_NAME "dv" | ||
41 | 42 | ||
42 | /** | 43 | /** |
43 | * Encapsulation of all of the state of the plugin. | 44 | * Encapsulation of all of the state of the plugin. |
@@ -123,6 +124,11 @@ struct Session | |||
123 | uint32_t distance; | 124 | uint32_t distance; |
124 | 125 | ||
125 | /** | 126 | /** |
127 | * Current network the next hop peer is located in | ||
128 | */ | ||
129 | uint32_t network; | ||
130 | |||
131 | /** | ||
126 | * Does the transport service know about this session (and we thus | 132 | * Does the transport service know about this session (and we thus |
127 | * need to call 'session_end' when it is released?) | 133 | * need to call 'session_end' when it is released?) |
128 | */ | 134 | */ |
@@ -180,7 +186,7 @@ notify_distance_change (struct Session *session) | |||
180 | ats.value = htonl (session->distance); | 186 | ats.value = htonl (session->distance); |
181 | plugin->env->update_address_metrics (plugin->env->cls, | 187 | plugin->env->update_address_metrics (plugin->env->cls, |
182 | &session->sender, | 188 | &session->sender, |
183 | "", 0, | 189 | NULL, 0, |
184 | session, | 190 | session, |
185 | &ats, 1); | 191 | &ats, 1); |
186 | } | 192 | } |
@@ -211,7 +217,7 @@ unbox_cb (void *cls, | |||
211 | message, | 217 | message, |
212 | session, "", 0); | 218 | session, "", 0); |
213 | plugin->env->update_address_metrics (plugin->env->cls, | 219 | plugin->env->update_address_metrics (plugin->env->cls, |
214 | &session->sender, "", 0, session, &ats, 1); | 220 | &session->sender, NULL, 0, session, &ats, 1); |
215 | return GNUNET_OK; | 221 | return GNUNET_OK; |
216 | } | 222 | } |
217 | 223 | ||
@@ -278,14 +284,17 @@ handle_dv_message_received (void *cls, | |||
278 | static void | 284 | static void |
279 | handle_dv_connect (void *cls, | 285 | handle_dv_connect (void *cls, |
280 | const struct GNUNET_PeerIdentity *peer, | 286 | const struct GNUNET_PeerIdentity *peer, |
281 | uint32_t distance) | 287 | uint32_t distance, uint32_t network) |
282 | { | 288 | { |
283 | struct Plugin *plugin = cls; | 289 | struct Plugin *plugin = cls; |
284 | struct Session *session; | 290 | struct Session *session; |
291 | struct GNUNET_ATS_Information ats[2]; | ||
285 | 292 | ||
286 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for peer `%s'\n", | 293 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
294 | "Received `%s' message for peer `%s' with next hop in network %s \n", | ||
287 | "DV_CONNECT", | 295 | "DV_CONNECT", |
288 | GNUNET_i2s (peer)); | 296 | GNUNET_i2s (peer), |
297 | GNUNET_ATS_print_network_type (network)); | ||
289 | 298 | ||
290 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, | 299 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
291 | peer); | 300 | peer); |
@@ -300,11 +309,20 @@ handle_dv_connect (void *cls, | |||
300 | session = GNUNET_new (struct Session); | 309 | session = GNUNET_new (struct Session); |
301 | session->sender = *peer; | 310 | session->sender = *peer; |
302 | session->distance = distance; | 311 | session->distance = distance; |
312 | session->network = network; | ||
303 | GNUNET_assert (GNUNET_YES == | 313 | GNUNET_assert (GNUNET_YES == |
304 | GNUNET_CONTAINER_multipeermap_put (plugin->sessions, | 314 | GNUNET_CONTAINER_multipeermap_put (plugin->sessions, |
305 | &session->sender, | 315 | &session->sender, |
306 | session, | 316 | session, |
307 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 317 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
318 | |||
319 | /* Notify transport and ats about new connection */ | ||
320 | ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
321 | ats[0].value = htonl (distance); | ||
322 | ats[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
323 | ats[0].value = htonl (network); | ||
324 | plugin->env->session_start (plugin->env->cls, peer, PLUGIN_NAME, NULL, 0, | ||
325 | session, ats, 2); | ||
308 | } | 326 | } |
309 | 327 | ||
310 | 328 | ||
@@ -332,7 +350,8 @@ handle_dv_distance_changed (void *cls, | |||
332 | if (NULL == session) | 350 | if (NULL == session) |
333 | { | 351 | { |
334 | GNUNET_break (0); | 352 | GNUNET_break (0); |
335 | handle_dv_connect (plugin, peer, distance); | 353 | /* FIXME */ |
354 | handle_dv_connect (plugin, peer, distance, 0); | ||
336 | return; | 355 | return; |
337 | } | 356 | } |
338 | session->distance = distance; | 357 | session->distance = distance; |
@@ -398,6 +417,7 @@ handle_dv_disconnect (void *cls, | |||
398 | peer); | 417 | peer); |
399 | if (NULL == session) | 418 | if (NULL == session) |
400 | return; /* nothing to do */ | 419 | return; /* nothing to do */ |
420 | |||
401 | free_session (session); | 421 | free_session (session); |
402 | } | 422 | } |
403 | 423 | ||
@@ -668,7 +688,7 @@ dv_get_network (void *cls, | |||
668 | struct Session *session) | 688 | struct Session *session) |
669 | { | 689 | { |
670 | GNUNET_assert (NULL != session); | 690 | GNUNET_assert (NULL != session); |
671 | return GNUNET_ATS_NET_UNSPECIFIED; | 691 | return session->network; |
672 | } | 692 | } |
673 | 693 | ||
674 | 694 | ||