* Address class of the address.
*/
enum GNUNET_NAT_AddressClass ac;
-
+
/**
* Number of bytes that follow.
*/
* Configuration we use.
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
-
+
/**
* Message queue for communicating with the NAT service.
*/
* Our registration message.
*/
struct GNUNET_MessageHeader *reg;
-
+
/**
* Head of address DLL.
*/
* Function to call when our addresses change.
*/
GNUNET_NAT_AddressCallback address_callback;
-
+
/**
* Function to call when another peer requests connection reversal.
*/
GNUNET_NAT_ReversalCallback reversal_callback;
-
+
/**
* Closure for the various callbacks.
*/
reconnect (struct GNUNET_NAT_Handle *nh)
{
struct AddrEntry *ae;
-
+
if (NULL != nh->mq)
{
GNUNET_MQ_destroy (nh->mq);
return GNUNET_OK;
}
-
+
/**
* Handle connection reversal request.
*
return GNUNET_OK;
}
-
+
/**
* Handle connection reversal request.
*
enum GNUNET_NAT_AddressClass ac;
struct AddrEntry *ae;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received address change notification\n");
ac = (enum GNUNET_NAT_AddressClass) ntohl (acn->addr_class);
if (GNUNET_YES == ntohl (acn->add_remove))
{
struct GNUNET_MQ_Envelope *env;
nh->reconnect_task = NULL;
- nh->mq = GNUNET_CLIENT_connecT (nh->cfg,
+ nh->mq = GNUNET_CLIENT_connect (nh->cfg,
"nat",
handlers,
&mq_error_handler,
size_t len;
size_t str_len;
char *off;
-
+
len = 0;
for (unsigned int i=0;i<num_addrs;i++)
len += addrlens[i];
str_len = strlen (config_section) + 1;
len += str_len;
- if ( (len > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*rm)) ||
+ if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof (*rm)) ||
(num_addrs > UINT16_MAX) )
{
GNUNET_break (0);
if (sizeof (struct sockaddr_in) != addrlens[i])
{
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
break;
if (sizeof (struct sockaddr_in6) != addrlens[i])
{
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
break;
if (sizeof (struct sockaddr_un) != addrlens[i])
{
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
break;
#endif
default:
GNUNET_break (0);
+ GNUNET_free (rm);
return NULL;
}
GNUNET_memcpy (off,
*
* The function does some basic sanity checks on packet size and
* content, try to extract a bit of information.
- *
+ *
* At the moment this only processes BIND requests, and returns the
* externally visible address of the request to the rest of the
* NAT logic.
* @param nh handle (used for configuration)
* @param local_sa our local address of the peer (IPv4-only)
* @param remote_sa the remote address of the peer (IPv4-only)
- * @return #GNUNET_SYSERR on error,
+ * @return #GNUNET_SYSERR on error,
* #GNUNET_NO if connection reversal is unavailable,
* #GNUNET_OK otherwise (presumably in progress)
*/
void
GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh)
{
- GNUNET_MQ_destroy (nh->mq);
+ if (NULL != nh->mq)
+ {
+ GNUNET_MQ_destroy (nh->mq);
+ nh->mq = NULL;
+ }
+ if (NULL != nh->reconnect_task)
+ {
+ GNUNET_SCHEDULER_cancel (nh->reconnect_task);
+ nh->reconnect_task = NULL;
+ }
GNUNET_free (nh->reg);
GNUNET_free (nh);
}