*
* @author Milan Bouchet-Valat
*/
+#include "platform.h"
+#include "gnunet_common.h"
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
-#include "platform.h"
-#include "gnunet_common.h"
#include "gnunet_nat_lib.h"
#include "nat.h"
#include "upnp-discover.h"
struct GNUNET_NAT_UPNP_Handle
{
- struct GNUNET_SCHEDULER_Handle *sched;
int hasDiscovered;
char *control_url;
char *service_type;
struct GNUNET_NAT_UPNP_Handle *
-GNUNET_NAT_UPNP_init (struct GNUNET_SCHEDULER_Handle *sched,
- const struct sockaddr *addr,
+GNUNET_NAT_UPNP_init (const struct sockaddr *addr,
socklen_t addrlen,
u_short port,
GNUNET_NAT_UPNP_pulse_cb pulse_cb, void *pulse_cls)
struct GNUNET_NAT_UPNP_Handle *handle;
handle = GNUNET_malloc (sizeof (struct GNUNET_NAT_UPNP_Handle));
- handle->sched = sched;
handle->processing = GNUNET_NO;
handle->state = UPNP_DISCOVER;
handle->addr = addr;
}
/* Try IPv4 and IPv6 as we don't know what's the format */
+#ifndef MINGW
if (inet_aton (ext_addr, &addr) != 0)
+#else
+ addr.S_un.S_addr = inet_addr(ext_addr);
+ if (addr.S_un.S_addr == INADDR_NONE)
+#endif
{
handle->ext_addr = GNUNET_malloc (sizeof (struct sockaddr_in));
handle->ext_addr->sa_family = AF_INET;
*
* @param handle the handle for UPnP object
* @param is_enabled whether enable port redirection
- * @param doPortCheck FIXME
- * @param ext_addr pointer for returning external IP address.
- * Will be set to NULL if address could not be found. Don't free the sockaddr.
+ * @param doPortCheck do port check
*/
void
GNUNET_NAT_UPNP_pulse (struct GNUNET_NAT_UPNP_Handle *handle,
if (is_enabled && (handle->state == UPNP_DISCOVER))
{
handle->processing = GNUNET_YES;
- UPNP_discover_ (handle->sched, handle->iface, handle->addr, discover_cb,
+ UPNP_discover_ (handle->iface, handle->addr, discover_cb,
handle);
}
GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port);
handle->processing = GNUNET_YES;
- UPNP_get_specific_port_mapping_entry_ (handle->sched,
- handle->control_url,
+ UPNP_get_specific_port_mapping_entry_ (handle->control_url,
handle->service_type, portStr,
"TCP", check_port_mapping_cb,
handle);
GNUNET_snprintf (portStr, sizeof (portStr), "%d", handle->port);
handle->processing = GNUNET_YES;
- UPNP_delete_port_mapping_ (handle->sched, handle->control_url,
+ UPNP_delete_port_mapping_ (handle->control_url,
handle->service_type, portStr, "TCP", NULL,
delete_port_mapping_cb, handle);
}
GNUNET_snprintf (desc, sizeof (desc), "GNUnet at %d", handle->port);
handle->processing = GNUNET_YES;
- UPNP_add_port_mapping_ (handle->sched, handle->control_url,
+ UPNP_add_port_mapping_ (handle->control_url,
handle->service_type,
portStr, portStr, GNUNET_a2s (handle->addr,
handle->addrlen),
if (handle->state != UPNP_DISCOVER)
{
handle->processing = GNUNET_YES;
- UPNP_get_external_ip_address_ (handle->sched, handle->control_url,
+ UPNP_get_external_ip_address_ (handle->control_url,
handle->service_type,
get_ip_address_cb, handle);
}