/*
This file is part of GNUnet
- Copyright (C) 2010-2015 GNUnet e.V.
+ Copyright (C) 2010-2017 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
#include "gnunet_hello_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_fragmentation_lib.h"
-#include "gnunet_nat_lib.h"
+#include "gnunet_nat_service.h"
#include "gnunet_protocols.h"
#include "gnunet_resolver_service.h"
#include "gnunet_signatures.h"
* @param cls closure, the `struct Plugin`
* @param add_remove #GNUNET_YES to mean the new public IP address,
* #GNUNET_NO to mean the previous (now invalid) one
+ * @param ac address class the address belongs to
* @param addr either the previous or the new public IP address
* @param addrlen actual length of the @a addr
*/
static void
udp_nat_port_map_callback (void *cls,
int add_remove,
+ enum GNUNET_NAT_AddressClass ac,
const struct sockaddr *addr,
socklen_t addrlen)
{
return;
}
/* modify our published address list */
+ /* TODO: use 'ac' here in the future... */
address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
PLUGIN_NAME,
arg,
sizeof(addr));
size = GNUNET_NETWORK_socket_recvfrom (rsock,
buf,
- sizeof(buf),
+ sizeof (buf),
(struct sockaddr *) &addr,
&fromlen);
sa = (const struct sockaddr *) &addr;
}
/* Check if this is a STUN packet */
- if (GNUNET_NAT_is_valid_stun_packet (plugin->nat,
- (uint8_t *)buf,
- size))
+ if (GNUNET_NO !=
+ GNUNET_NAT_stun_handle_packet (plugin->nat,
+ (const struct sockaddr *) &addr,
+ fromlen,
+ buf,
+ size))
return; /* was STUN, do not process further */
if (size < sizeof(struct GNUNET_MessageHeader))
* @param bind_v4 IPv4 address to bind to (can be NULL, for 'any')
* @return number of sockets that were successfully bound
*/
-static int
+static unsigned int
setup_sockets (struct Plugin *plugin,
const struct sockaddr_in6 *bind_v6,
const struct sockaddr_in *bind_v4)
{
int tries;
- int sockets_created = 0;
+ unsigned int sockets_created = 0;
struct sockaddr_in6 server_addrv6;
struct sockaddr_in server_addrv4;
const struct sockaddr *server_addr;
schedule_select_v4 (plugin);
schedule_select_v6 (plugin);
plugin->nat = GNUNET_NAT_register (plugin->env->cfg,
- GNUNET_NO,
- plugin->port,
+ "transport-udp",
+ IPPROTO_UDP,
sockets_created,
addrs,
addrlens,
&udp_nat_port_map_callback,
NULL,
- plugin,
- plugin->sockv4);
+ plugin);
return sockets_created;
}
struct GNUNET_TIME_Relative interval;
struct sockaddr_in server_addrv4;
struct sockaddr_in6 server_addrv6;
- int res;
+ unsigned int res;
int have_bind4;
int have_bind6;