*/
struct GNUNET_NAT_NATPMP_Handle *natpmp;
- /**
- * Scheduler.
- */
- struct GNUNET_SCHEDULER_Handle *sched;
-
/**
* LAN address as passed by the caller
*/
static int
get_traversal_status (const struct GNUNET_NAT_Handle *h)
{
- return MAX (h->natpmp_status, h->upnp_status);
+ return GNUNET_MAX (h->natpmp_status, h->upnp_status);
}
notify_change (h, h->ext_addr_natpmp, addrlen, port_mapped);
}
- h->pulse_timer = GNUNET_SCHEDULER_add_delayed (h->sched,
- GNUNET_TIME_UNIT_SECONDS,
+ h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&nat_pulse, h);
}
struct GNUNET_NAT_Handle *h = cls;
/* Stop if we're already waiting for an action to complete */
+ h->pulse_timer = GNUNET_SCHEDULER_NO_TASK;
if (h->processing)
return;
-
- h->pulse_timer = GNUNET_SCHEDULER_NO_TASK;
h->old_status = get_traversal_status (h);
/* Only update the protocol that has been successful until now */
GNUNET_NAT_UPNP_pulse (h->upnp, h->is_enabled, GNUNET_YES);
#if 0
- GNUNET_NAT_NATPMP_pulse (h->natpmp, h->is_enabled, natpmp_pulse_cb, h);
+ GNUNET_NAT_NATPMP_pulse (h->natpmp, h->is_enabled, &natpmp_pulse_cb, h);
#endif
}
}
* of the local host's addresses should the external port be mapped. The port
* is taken from the corresponding sockaddr_in[6] field.
*
- * @param sched the sheduler used in the program
* @param addr the local address packets should be redirected to
* @param addrlen actual lenght of the address
* @param callback function to call everytime the public IP address changes
* @return NULL on error, otherwise handle that can be used to unregister
*/
struct GNUNET_NAT_Handle *
-GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle
- *sched,
- const struct sockaddr *addr,
+GNUNET_NAT_register (const struct sockaddr *addr,
socklen_t addrlen,
GNUNET_NAT_AddressCallback callback, void *callback_cls)
{
}
}
h->should_change = GNUNET_YES;
- h->sched = sched;
h->is_enabled = GNUNET_YES;
h->upnp_status = GNUNET_NAT_PORT_UNMAPPED;
h->natpmp_status = GNUNET_NAT_PORT_UNMAPPED;
h->callback = callback;
h->callback_cls = callback_cls;
h->upnp =
- GNUNET_NAT_UPNP_init (h->sched, h->local_addr, addrlen, h->public_port,
- upnp_pulse_cb, h);
+ GNUNET_NAT_UPNP_init (h->local_addr, addrlen, h->public_port,
+ &upnp_pulse_cb, h);
#if 0
h->natpmp =
- GNUNET_NAT_NATPMP_init (h->sched, h->local_addr, addrlen, h->public_port,
- natpmp_pulse_cb, h);
+ GNUNET_NAT_NATPMP_init (h->local_addr, addrlen, h->public_port,
+ &natpmp_pulse_cb, h);
#endif
- h->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_UNIT_SECONDS,
+ h->pulse_timer = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&nat_pulse, h);
return h;
}
GNUNET_NAT_NATPMP_close (h->natpmp);
#endif
- GNUNET_SCHEDULER_cancel (h->sched, h->pulse_timer);
+ if (GNUNET_SCHEDULER_NO_TASK != h->pulse_timer)
+ GNUNET_SCHEDULER_cancel (h->pulse_timer);
GNUNET_free_non_null (h->local_addr);
GNUNET_free_non_null (h->ext_addr);