diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/nat/nat.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/nat/nat.c')
-rw-r--r-- | src/nat/nat.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c index 74d08bd6f..eb203265c 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -54,11 +54,6 @@ struct GNUNET_NAT_Handle | |||
54 | struct GNUNET_NAT_NATPMP_Handle *natpmp; | 54 | struct GNUNET_NAT_NATPMP_Handle *natpmp; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Scheduler. | ||
58 | */ | ||
59 | struct GNUNET_SCHEDULER_Handle *sched; | ||
60 | |||
61 | /** | ||
62 | * LAN address as passed by the caller | 57 | * LAN address as passed by the caller |
63 | */ | 58 | */ |
64 | struct sockaddr *local_addr; | 59 | struct sockaddr *local_addr; |
@@ -296,8 +291,7 @@ pulse_cb (struct GNUNET_NAT_Handle *h) | |||
296 | notify_change (h, h->ext_addr_natpmp, addrlen, port_mapped); | 291 | notify_change (h, h->ext_addr_natpmp, addrlen, port_mapped); |
297 | } | 292 | } |
298 | 293 | ||
299 | h->pulse_timer = GNUNET_SCHEDULER_add_delayed (h->sched, | 294 | h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
300 | GNUNET_TIME_UNIT_SECONDS, | ||
301 | &nat_pulse, h); | 295 | &nat_pulse, h); |
302 | } | 296 | } |
303 | 297 | ||
@@ -372,7 +366,6 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
372 | * of the local host's addresses should the external port be mapped. The port | 366 | * of the local host's addresses should the external port be mapped. The port |
373 | * is taken from the corresponding sockaddr_in[6] field. | 367 | * is taken from the corresponding sockaddr_in[6] field. |
374 | * | 368 | * |
375 | * @param sched the sheduler used in the program | ||
376 | * @param addr the local address packets should be redirected to | 369 | * @param addr the local address packets should be redirected to |
377 | * @param addrlen actual lenght of the address | 370 | * @param addrlen actual lenght of the address |
378 | * @param callback function to call everytime the public IP address changes | 371 | * @param callback function to call everytime the public IP address changes |
@@ -380,9 +373,7 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
380 | * @return NULL on error, otherwise handle that can be used to unregister | 373 | * @return NULL on error, otherwise handle that can be used to unregister |
381 | */ | 374 | */ |
382 | struct GNUNET_NAT_Handle * | 375 | struct GNUNET_NAT_Handle * |
383 | GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle | 376 | GNUNET_NAT_register (const struct sockaddr *addr, |
384 | *sched, | ||
385 | const struct sockaddr *addr, | ||
386 | socklen_t addrlen, | 377 | socklen_t addrlen, |
387 | GNUNET_NAT_AddressCallback callback, void *callback_cls) | 378 | GNUNET_NAT_AddressCallback callback, void *callback_cls) |
388 | { | 379 | { |
@@ -408,22 +399,20 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle | |||
408 | } | 399 | } |
409 | } | 400 | } |
410 | h->should_change = GNUNET_YES; | 401 | h->should_change = GNUNET_YES; |
411 | h->sched = sched; | ||
412 | h->is_enabled = GNUNET_YES; | 402 | h->is_enabled = GNUNET_YES; |
413 | h->upnp_status = GNUNET_NAT_PORT_UNMAPPED; | 403 | h->upnp_status = GNUNET_NAT_PORT_UNMAPPED; |
414 | h->natpmp_status = GNUNET_NAT_PORT_UNMAPPED; | 404 | h->natpmp_status = GNUNET_NAT_PORT_UNMAPPED; |
415 | h->callback = callback; | 405 | h->callback = callback; |
416 | h->callback_cls = callback_cls; | 406 | h->callback_cls = callback_cls; |
417 | h->upnp = | 407 | h->upnp = |
418 | GNUNET_NAT_UPNP_init (h->sched, h->local_addr, addrlen, h->public_port, | 408 | GNUNET_NAT_UPNP_init (h->local_addr, addrlen, h->public_port, |
419 | &upnp_pulse_cb, h); | 409 | &upnp_pulse_cb, h); |
420 | #if 0 | 410 | #if 0 |
421 | h->natpmp = | 411 | h->natpmp = |
422 | GNUNET_NAT_NATPMP_init (h->sched, h->local_addr, addrlen, h->public_port, | 412 | GNUNET_NAT_NATPMP_init (h->local_addr, addrlen, h->public_port, |
423 | &natpmp_pulse_cb, h); | 413 | &natpmp_pulse_cb, h); |
424 | #endif | 414 | #endif |
425 | h->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched, | 415 | h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
426 | GNUNET_TIME_UNIT_SECONDS, | ||
427 | &nat_pulse, h); | 416 | &nat_pulse, h); |
428 | return h; | 417 | return h; |
429 | } | 418 | } |
@@ -447,7 +436,7 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h) | |||
447 | #endif | 436 | #endif |
448 | 437 | ||
449 | if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer) | 438 | if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer) |
450 | GNUNET_SCHEDULER_cancel (h->sched, h->pulse_timer); | 439 | GNUNET_SCHEDULER_cancel (h->pulse_timer); |
451 | 440 | ||
452 | GNUNET_free_non_null (h->local_addr); | 441 | GNUNET_free_non_null (h->local_addr); |
453 | GNUNET_free_non_null (h->ext_addr); | 442 | GNUNET_free_non_null (h->ext_addr); |