*/
static struct TunnelState *
get_redirect_state (int af,
- int protocol,
+ int protocol,
const void *destination_ip,
uint16_t destination_port,
const void *local_ip,
local_address->af = af;
local_address->proto = (uint8_t) proto;
/* default "local" port range is often 32768--61000,
- so we pick a random value in that range */
+ so we pick a random value in that range */
if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
local_address->port = 0;
do
{
rnd.s_addr = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX);
+ UINT32_MAX);
local_address->address.ipv4.s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr;
}
while ( (local_address->address.ipv4.s_addr == addr.s_addr) ||
GNUNET_TUN_initialize_ipv6_header (pkt6,
protocol,
- len,
+ len,
&src_address->address.ipv6,
&dst_address->address.ipv6);
* @param source_address IP and port to use for the TCP packet's source
* @param tcp_header header template to use
* @param payload payload of the TCP packet
- * @param payload_length number of bytes in 'payload'
+ * @param payload_length number of bytes in @a payload
*/
static void
send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
case AF_INET:
{
struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
-
+
tun->proto = htons (ETH_P_IPV4);
prepare_ipv4_packet (payload, payload_length,
IPPROTO_TCP,
case AF_INET6:
{
struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
-
+
tun->proto = htons (ETH_P_IPV6);
prepare_ipv6_packet (payload, payload_length,
IPPROTO_TCP,
destination_address,
ipv6);
}
- break;
+ break;
default:
GNUNET_assert (0);
break;
*
* @param cls closure, NULL
* @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param tunnel_ctx pointer to our `struct TunnelState *`
* @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_tcp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx GNUNET_UNUSED,
+receive_tcp_service (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
* @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_EXIT_TcpDataMessage *data;
uint16_t pkt_len = ntohs (message->size);
- if (GNUNET_YES == state->is_dns)
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_SYSERR == state->is_dns)
- {
- /* tunnel is UDP/TCP from now on */
- state->is_dns = GNUNET_NO;
- }
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Bytes received from MESH"),
pkt_len, GNUNET_NO);
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
+ if (GNUNET_YES == state->is_dns)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_SYSERR == state->is_dns)
+ {
+ /* tunnel is UDP/TCP from now on */
+ state->is_dns = GNUNET_NO;
+ }
GNUNET_break_op (ntohl (data->reserved) == 0);
{
* @param source_address IP to use for the ICMP packet's source
* @param icmp_header ICMP header to send
* @param payload payload of the ICMP packet (does NOT include ICMP header)
- * @param payload_length number of bytes of data in payload
+ * @param payload_length number of bytes of data in @a payload
*/
static void
send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
case AF_INET:
{
struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
-
+
tun->proto = htons (ETH_P_IPV4);
GNUNET_TUN_initialize_ipv4_header (ipv4,
IPPROTO_ICMP,
case AF_INET6:
{
struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
-
+
tun->proto = htons (ETH_P_IPV6);
GNUNET_TUN_initialize_ipv6_header (ipv6,
IPPROTO_ICMPV6,
&destination_address->address.ipv6);
icmp = (struct GNUNET_TUN_IcmpHeader*) &ipv6[1];
}
- break;
+ break;
default:
GNUNET_assert (0);
break;
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
* @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx GNUNET_UNUSED,
+receive_icmp_remote (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
* @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
+receive_icmp_service (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
const struct GNUNET_MessageHeader *message)
{
* @param destination_address IP and port to use for the UDP packet's destination
* @param source_address IP and port to use for the UDP packet's source
* @param payload payload of the UDP packet (does NOT include UDP header)
- * @param payload_length number of bytes of data in payload
+ * @param payload_length number of bytes of data in @a payload
*/
static void
send_udp_packet_via_tun (const struct SocketAddress *destination_address,
case AF_INET:
{
struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
-
+
tun->proto = htons (ETH_P_IPV4);
prepare_ipv4_packet (payload, payload_length,
IPPROTO_UDP,
case AF_INET6:
{
struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
-
+
tun->proto = htons (ETH_P_IPV6);
prepare_ipv6_packet (payload, payload_length,
IPPROTO_UDP,
destination_address,
ipv6);
}
- break;
+ break;
default:
GNUNET_assert (0);
break;
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
* @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx GNUNET_UNUSED,
+receive_udp_remote (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ void **tunnel_ctx,
const struct GNUNET_MessageHeader *message)
{
struct TunnelState *state = *tunnel_ctx;
* @param tunnel connection to the other end
* @param tunnel_ctx pointer to our 'struct TunnelState *'
* @param message the actual message
- *
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
+receive_udp_service (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
const struct GNUNET_MessageHeader *message)
{
* @return initial tunnel context for the tunnel
*/
static void *
-new_tunnel (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- const struct GNUNET_PeerIdentity *initiator, uint32_t port)
+new_tunnel (void *cls,
+ struct GNUNET_MESH_Tunnel *tunnel,
+ const struct GNUNET_PeerIdentity *initiator,
+ uint32_t port)
{
struct TunnelState *s = GNUNET_new (struct TunnelState);
* Function called by mesh whenever an inbound tunnel is destroyed.
* Should clean up any associated state.
*
- * @param cls closure (set from GNUNET_MESH_connect)
+ * @param cls closure (set from #GNUNET_MESH_connect)
* @param tunnel connection to the other end (henceforth invalid)
* @param tunnel_ctx place where local state associated
* with the tunnel is stored
*/
static void
-clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
+clean_tunnel (void *cls,
+ const struct GNUNET_MESH_Tunnel *tunnel,
void *tunnel_ctx)
{
struct TunnelState *s = tunnel_ctx;
* @param value value to free
*/
static int
-free_iterate (void *cls GNUNET_UNUSED,
- const struct GNUNET_HashCode * hash GNUNET_UNUSED, void *value)
+free_iterate (void *cls,
+ const struct GNUNET_HashCode * hash,
+ void *value)
{
GNUNET_free (value);
return GNUNET_YES;
* Function scheduled as very last function, cleans up after us
*/
static void
-cleanup (void *cls GNUNET_UNUSED,
+cleanup (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tskctx)
{
unsigned int i;
freeaddrinfo (res);
GNUNET_free (serv);
continue;
- }
+ }
serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
break;
default:
* @param section name of section in config, equal to hostname
*/
static void
-read_service_conf (void *cls GNUNET_UNUSED, const char *section)
+read_service_conf (void *cls, const char *section)
{
char *cpy;
* @param cfg_ configuration
*/
static void
-run (void *cls, char *const *args GNUNET_UNUSED,
- const char *cfgfile GNUNET_UNUSED,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg_)
{
static struct GNUNET_MESH_MessageHandler handlers[] = {
apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER;
app_idx++;
}
-
+ GNUNET_free_non_null (dns_exit);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
if (GNUNET_OK !=
(void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
"4", regex);
- regex4 = GNUNET_REGEX_announce (cfg,
+ regex4 = GNUNET_REGEX_announce (cfg,
prefixed_regex,
REGEX_REFRESH_FREQUENCY,
REGEX_MAX_PATH_LEN_IPV4);