diff options
Diffstat (limited to 'src/dhtu/plugin_dhtu_gnunet.c')
-rw-r--r-- | src/dhtu/plugin_dhtu_gnunet.c | 63 |
1 files changed, 25 insertions, 38 deletions
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c index 2163af941..b072be2be 100644 --- a/src/dhtu/plugin_dhtu_gnunet.c +++ b/src/dhtu/plugin_dhtu_gnunet.c | |||
@@ -70,11 +70,6 @@ struct GNUNET_DHTU_Source | |||
70 | { | 70 | { |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Hash of @e pid, position of this peer in the DHT overlay. | ||
74 | */ | ||
75 | struct GNUNET_DHTU_HashKey id; | ||
76 | |||
77 | /** | ||
78 | * Application context for this source. | 73 | * Application context for this source. |
79 | */ | 74 | */ |
80 | void *app_ctx; | 75 | void *app_ctx; |
@@ -125,11 +120,6 @@ struct GNUNET_DHTU_Target | |||
125 | struct GNUNET_PeerIdentity pid; | 120 | struct GNUNET_PeerIdentity pid; |
126 | 121 | ||
127 | /** | 122 | /** |
128 | * Hash of @e pid, position of this peer in the DHT overlay. | ||
129 | */ | ||
130 | struct GNUNET_DHTU_HashKey id; | ||
131 | |||
132 | /** | ||
133 | * Preference counter, length of the @a ph_head DLL. | 123 | * Preference counter, length of the @a ph_head DLL. |
134 | */ | 124 | */ |
135 | unsigned int ph_count; | 125 | unsigned int ph_count; |
@@ -240,27 +230,26 @@ hello_offered_cb (void *cls) | |||
240 | * Request creation of a session with a peer at the given @a address. | 230 | * Request creation of a session with a peer at the given @a address. |
241 | * | 231 | * |
242 | * @param cls closure (internal context for the plugin) | 232 | * @param cls closure (internal context for the plugin) |
233 | * @param pid target identity of the peer to connect to | ||
243 | * @param address target address to connect to | 234 | * @param address target address to connect to |
244 | */ | 235 | */ |
245 | static void | 236 | static void |
246 | ip_try_connect (void *cls, | 237 | gnunet_try_connect (void *cls, |
247 | const char *address) | 238 | const struct GNUNET_PeerIdentity *pid, |
239 | const char *address) | ||
248 | { | 240 | { |
249 | struct Plugin *plugin = cls; | 241 | struct Plugin *plugin = cls; |
250 | struct GNUNET_HELLO_Message *hello = NULL; | 242 | struct GNUNET_HELLO_Message *hello = NULL; |
251 | struct HelloHandle *hh; | 243 | struct HelloHandle *hh; |
252 | struct GNUNET_CRYPTO_EddsaPublicKey pubkey; | 244 | struct GNUNET_CRYPTO_EddsaPublicKey pubkey; |
253 | 245 | ||
246 | (void) pid; /* will be needed with future address URIs */ | ||
254 | if (GNUNET_OK != | 247 | if (GNUNET_OK != |
255 | GNUNET_HELLO_parse_uri (address, | 248 | GNUNET_HELLO_parse_uri (address, |
256 | &pubkey, | 249 | &pubkey, |
257 | &hello, | 250 | &hello, |
258 | &GPI_plugins_find)) | 251 | &GPI_plugins_find)) |
259 | { | ||
260 | GNUNET_break (0); | ||
261 | return; | 252 | return; |
262 | } | ||
263 | |||
264 | hh = GNUNET_new (struct HelloHandle); | 253 | hh = GNUNET_new (struct HelloHandle); |
265 | hh->plugin = plugin; | 254 | hh->plugin = plugin; |
266 | GNUNET_CONTAINER_DLL_insert (plugin->hh_head, | 255 | GNUNET_CONTAINER_DLL_insert (plugin->hh_head, |
@@ -283,8 +272,8 @@ ip_try_connect (void *cls, | |||
283 | * @param target connection to keep alive | 272 | * @param target connection to keep alive |
284 | */ | 273 | */ |
285 | static struct GNUNET_DHTU_PreferenceHandle * | 274 | static struct GNUNET_DHTU_PreferenceHandle * |
286 | ip_hold (void *cls, | 275 | gnunet_hold (void *cls, |
287 | struct GNUNET_DHTU_Target *target) | 276 | struct GNUNET_DHTU_Target *target) |
288 | { | 277 | { |
289 | struct Plugin *plugin = cls; | 278 | struct Plugin *plugin = cls; |
290 | struct GNUNET_DHTU_PreferenceHandle *ph; | 279 | struct GNUNET_DHTU_PreferenceHandle *ph; |
@@ -312,7 +301,7 @@ ip_hold (void *cls, | |||
312 | * @param target connection to keep alive | 301 | * @param target connection to keep alive |
313 | */ | 302 | */ |
314 | static void | 303 | static void |
315 | ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) | 304 | gnunet_drop (struct GNUNET_DHTU_PreferenceHandle *ph) |
316 | { | 305 | { |
317 | struct GNUNET_DHTU_Target *target = ph->target; | 306 | struct GNUNET_DHTU_Target *target = ph->target; |
318 | struct Plugin *plugin = target->plugin; | 307 | struct Plugin *plugin = target->plugin; |
@@ -350,12 +339,12 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph) | |||
350 | * @param finished_cb_cls closure for @a finished_cb | 339 | * @param finished_cb_cls closure for @a finished_cb |
351 | */ | 340 | */ |
352 | static void | 341 | static void |
353 | ip_send (void *cls, | 342 | gnunet_send (void *cls, |
354 | struct GNUNET_DHTU_Target *target, | 343 | struct GNUNET_DHTU_Target *target, |
355 | const void *msg, | 344 | const void *msg, |
356 | size_t msg_size, | 345 | size_t msg_size, |
357 | GNUNET_SCHEDULER_TaskCallback finished_cb, | 346 | GNUNET_SCHEDULER_TaskCallback finished_cb, |
358 | void *finished_cb_cls) | 347 | void *finished_cb_cls) |
359 | { | 348 | { |
360 | struct GNUNET_MQ_Envelope *env; | 349 | struct GNUNET_MQ_Envelope *env; |
361 | struct GNUNET_MessageHeader *cmsg; | 350 | struct GNUNET_MessageHeader *cmsg; |
@@ -394,12 +383,9 @@ core_connect_cb (void *cls, | |||
394 | target->plugin = plugin; | 383 | target->plugin = plugin; |
395 | target->mq = mq; | 384 | target->mq = mq; |
396 | target->pid = *peer; | 385 | target->pid = *peer; |
397 | GNUNET_CRYPTO_hash (peer, | ||
398 | sizeof (*peer), | ||
399 | &target->id.sha512); | ||
400 | plugin->env->connect_cb (plugin->env->cls, | 386 | plugin->env->connect_cb (plugin->env->cls, |
401 | target, | 387 | target, |
402 | &target->id, | 388 | &target->pid, |
403 | &target->app_ctx); | 389 | &target->app_ctx); |
404 | return target; | 390 | return target; |
405 | } | 391 | } |
@@ -461,11 +447,7 @@ peerinfo_cb (void *cls, | |||
461 | &GPI_plugins_find); | 447 | &GPI_plugins_find); |
462 | if (NULL == addr) | 448 | if (NULL == addr) |
463 | return; | 449 | return; |
464 | GNUNET_CRYPTO_hash (peer, | ||
465 | sizeof (*peer), | ||
466 | &plugin->src.id.sha512); | ||
467 | plugin->env->address_add_cb (plugin->env->cls, | 450 | plugin->env->address_add_cb (plugin->env->cls, |
468 | &plugin->src.id, | ||
469 | addr, | 451 | addr, |
470 | &plugin->src, | 452 | &plugin->src, |
471 | &plugin->src.app_ctx); | 453 | &plugin->src.app_ctx); |
@@ -584,6 +566,10 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls) | |||
584 | } | 566 | } |
585 | if (NULL != plugin->nse) | 567 | if (NULL != plugin->nse) |
586 | GNUNET_NSE_disconnect (plugin->nse); | 568 | GNUNET_NSE_disconnect (plugin->nse); |
569 | plugin->env->network_size_cb (plugin->env->cls, | ||
570 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
571 | 0.0, | ||
572 | 0.0); | ||
587 | if (NULL != plugin->core) | 573 | if (NULL != plugin->core) |
588 | GNUNET_CORE_disconnect (plugin->core); | 574 | GNUNET_CORE_disconnect (plugin->core); |
589 | if (NULL != plugin->ats) | 575 | if (NULL != plugin->ats) |
@@ -604,7 +590,7 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls) | |||
604 | * @return the plugin's API | 590 | * @return the plugin's API |
605 | */ | 591 | */ |
606 | void * | 592 | void * |
607 | libgnunet_plugin_dhtu_ip_init (void *cls) | 593 | libgnunet_plugin_dhtu_gnunet_init (void *cls) |
608 | { | 594 | { |
609 | struct GNUNET_DHTU_PluginEnvironment *env = cls; | 595 | struct GNUNET_DHTU_PluginEnvironment *env = cls; |
610 | struct GNUNET_DHTU_PluginFunctions *api; | 596 | struct GNUNET_DHTU_PluginFunctions *api; |
@@ -621,10 +607,10 @@ libgnunet_plugin_dhtu_ip_init (void *cls) | |||
621 | plugin->env = env; | 607 | plugin->env = env; |
622 | api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); | 608 | api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); |
623 | api->cls = plugin; | 609 | api->cls = plugin; |
624 | api->try_connect = &ip_try_connect; | 610 | api->try_connect = &gnunet_try_connect; |
625 | api->hold = &ip_hold; | 611 | api->hold = &gnunet_hold; |
626 | api->drop = &ip_drop; | 612 | api->drop = &gnunet_drop; |
627 | api->send = &ip_send; | 613 | api->send = &gnunet_send; |
628 | plugin->ats = GNUNET_ATS_connectivity_init (env->cfg); | 614 | plugin->ats = GNUNET_ATS_connectivity_init (env->cfg); |
629 | plugin->core = GNUNET_CORE_connect (env->cfg, | 615 | plugin->core = GNUNET_CORE_connect (env->cfg, |
630 | plugin, | 616 | plugin, |
@@ -640,6 +626,7 @@ libgnunet_plugin_dhtu_ip_init (void *cls) | |||
640 | (NULL == plugin->nse) ) | 626 | (NULL == plugin->nse) ) |
641 | { | 627 | { |
642 | GNUNET_break (0); | 628 | GNUNET_break (0); |
629 | GNUNET_free (api); | ||
643 | libgnunet_plugin_dhtu_gnunet_done (plugin); | 630 | libgnunet_plugin_dhtu_gnunet_done (plugin); |
644 | return NULL; | 631 | return NULL; |
645 | } | 632 | } |