* incoming connection.
*
* @param cls
- * @param tc scheduler context
*/
static void
-do_udp_read (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_udp_read (void *cls)
{
struct GNUNET_NAT_AutoHandle *ah = cls;
unsigned char reply_buf[1024];
ssize_t rlen;
struct sockaddr_in answer;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
-
+ tc = GNUNET_SCHEDULER_get_task_context ();
if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
(GNUNET_NETWORK_fdset_isset (tc->read_ready,
lsock4)))
{
- rlen = GNUNET_NETWORK_socket_recv (lsock4, reply_buf, sizeof (reply_buf));
+ rlen = GNUNET_NETWORK_socket_recv (lsock4,
+ reply_buf,
+ sizeof (reply_buf));
//Lets handle the packet
memset(&answer, 0, sizeof(struct sockaddr_in));
}
else
{
- if (GNUNET_OK == GNUNET_NAT_stun_handle_packet (reply_buf, rlen, &answer))
+ if (GNUNET_OK ==
+ GNUNET_NAT_stun_handle_packet (reply_buf, rlen, &answer))
{
//Process the answer
process_stun_reply (&answer, ah);
next_phase (ah);
}
-
-
-
}
}
-
-
-static void request_callback (void *cls,
- enum GNUNET_NAT_StatusCode result)
+static void
+request_callback (void *cls,
+ enum GNUNET_NAT_StatusCode result)
{
// struct GNUNET_NAT_AutoHandle *ah = cls;
stop_stun ();
// next_phase (ah); FIXME this always will be NULL, as called in test_stun()
-};
-
-
-
+}
/**
* Main function for the connection reversal test.
*
* @param cls the `struct GNUNET_NAT_AutoHandle`
- * @param tc scheduler context
*/
static void
-reversal_test (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+reversal_test (void *cls)
{
struct GNUNET_NAT_AutoHandle *ah = cls;
{
//Lets call our function now when it accepts
ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT,
- lsock4, &do_udp_read, ah);
-
+ lsock4,
+ &do_udp_read,
+ ah);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"STUN service listens on port %u\n",
- port);
- if (GNUNET_NO == GNUNET_NAT_stun_make_request (stun_server, stun_port,
- lsock4, &request_callback,
- NULL))
+ (unsigned int) port);
+ if (GNUNET_NO ==
+ GNUNET_NAT_stun_make_request (stun_server, stun_port,
+ lsock4,
+ &request_callback,
+ NULL))
{
/*An error happened*/
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STUN error, stopping\n");
}
-
/**
* Process list of local IP addresses. Find and set the
* one of the default interface.
* @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned)
* @param netmask the network mask (can be NULL for unknown or unassigned))
* @param addrlen length of the @a addr and @a broadcast_addr
- * @return GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
+ * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
*/
static int
process_if (void *cls,
- const char *name,
- int isDefault,
- const struct sockaddr *addr,
- const struct sockaddr *broadcast_addr,
- const struct sockaddr *netmask,
- socklen_t addrlen)
+ const char *name,
+ int isDefault,
+ const struct sockaddr *addr,
+ const struct sockaddr *broadcast_addr,
+ const struct sockaddr *netmask,
+ socklen_t addrlen)
{
struct GNUNET_NAT_AutoHandle *ah = cls;
const struct sockaddr_in *in;
static void
test_nat_punched (struct GNUNET_NAT_AutoHandle *ah)
{
-
struct GNUNET_CLIENT_Connection *client;
struct GNUNET_NAT_TestMessage msg;
-
if (ah->stun_ip)
{
LOG (GNUNET_ERROR_TYPE_INFO,
{
GNUNET_SCHEDULER_cancel (ltask4);
ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT,
- lsock4, &do_udp_read, ah);
+ lsock4,
+ &do_udp_read,
+ ah);
}
-
}
else
{
"We don't have a STUN IP");
next_phase(ah);
}
-
-
}
-
-
/**
* Test if UPnPC works.
*
ah->task = GNUNET_SCHEDULER_add_now (&reversal_test, ah);
else
next_phase (ah);
-
}
static void
test_icmp_client (struct GNUNET_NAT_AutoHandle *ah)
{
-
-
char *tmp;
char *helper;
if (GNUNET_YES !=
GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("test_icmp_server not possible, as we are not behind NAT\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("test_icmp_server not possible, as we are not behind NAT\n"));
}
else
goto err;
if (GNUNET_YES ==
GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){
// none of these parameters are actually used in privilege testing mode
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("No working gnunet-helper-nat-server found\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("No working gnunet-helper-nat-server found\n"));
}
err:
GNUNET_free_non_null (tmp);
GNUNET_free (helper);
next_phase (ah);
-
}
GNUNET_CONFIGURATION_destroy (diff);
GNUNET_NAT_autoconfig_cancel (ah);
return;
-
}
-
-
-
}