/**
* If there are at least this many connections, old ones will be removed
*/
-static long long unsigned int max_connections;
+static unsigned long long max_connections;
/**
* This hashmaps saves interesting things about the configured UDP services
GNUNET_HashCode key;
struct TunnelState *state;
- if (protocol == IPPROTO_ICMP)
+ if ( ( (af == AF_INET) && (protocol == IPPROTO_ICMP) ) ||
+ ( (af == AF_INET6) && (protocol == IPPROTO_ICMPV6) ) )
{
/* ignore ports */
destination_port = 0;
existing session from the IP data in the ICMP payload */
source_port = 0;
destination_port = 0;
- protocol = IPPROTO_ICMP;
switch (af)
{
case AF_INET:
+ protocol = IPPROTO_ICMP;
switch (icmp->type)
{
case GNUNET_TUN_ICMPTYPE_ECHO_REPLY:
/* could be TCP or UDP, but both have the ports in the right
place, so that doesn't matter here */
udp = (const struct GNUNET_TUN_UdpHeader *) &ipv4[1];
- source_port = ntohs (udp->source_port);
- destination_port = ntohs (udp->destination_port);
+ /* swap ports, as they are from the original message */
+ destination_port = ntohs (udp->source_port);
+ source_port = ntohs (udp->destination_port);
/* throw away ICMP payload, won't be useful for the other side anyway */
pktlen = sizeof (struct GNUNET_TUN_IcmpHeader);
break;
}
break;
case AF_INET6:
+ protocol = IPPROTO_ICMPV6;
switch (icmp->type)
{
case GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE:
/* could be TCP or UDP, but both have the ports in the right
place, so that doesn't matter here */
udp = (const struct GNUNET_TUN_UdpHeader *) &ipv6[1];
- source_port = ntohs (udp->source_port);
- destination_port = ntohs (udp->destination_port);
+ /* swap ports, as they are from the original message */
+ destination_port = ntohs (udp->source_port);
+ source_port = ntohs (udp->destination_port);
/* throw away ICMP payload, won't be useful for the other side anyway */
pktlen = sizeof (struct GNUNET_TUN_IcmpHeader);
break;
destination_ip, 0,
NULL);
break;
+ case IPPROTO_ICMPV6:
+ state = get_redirect_state (af, IPPROTO_ICMPV6,
+ source_ip, 0,
+ destination_ip, 0,
+ NULL);
+ break;
case IPPROTO_UDP:
state = get_redirect_state (af, IPPROTO_UDP,
source_ip,
const void *source_ip)
{
struct TunnelState *state;
- char buf[pktlen];
+ char buf[pktlen] GNUNET_ALIGN;
struct GNUNET_TUN_TcpHeader *mtcp;
struct GNUNET_EXIT_TcpDataMessage *tdm;
struct TunnelMessageQueue *tnq;
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("IPv4 packet with unsupported next header received. Ignored.\n"));
+ _("IPv4 packet with unsupported next header %u received. Ignored.\n"),
+ (int) pkt4->protocol);
return;
}
}
&pkt6->destination_address,
&pkt6->source_address);
break;
- case IPPROTO_ICMP:
+ case IPPROTO_ICMPV6:
icmp_from_helper ((const struct GNUNET_TUN_IcmpHeader *) &pkt6[1], size,
AF_INET6,
&pkt6->destination_address,
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("IPv6 packet with unsupported next header received. Ignored.\n"));
+ _("IPv6 packet with unsupported next header %d received. Ignored.\n"),
+ pkt6->next_header);
return;
}
}
local_address->proto = (uint8_t) proto;
/* default "local" port range is often 32768--61000,
so we pick a random value in that range */
- if (proto == IPPROTO_ICMP)
+ if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
+ ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
local_address->port = 0;
else
local_address->port
* @param tcp_header skeleton of the TCP header, NULL for UDP
* @param src_address source address to use (IP and port)
* @param dst_address destination address to use (IP and port)
- * @param pkt6 where to write the assembled packet; must
+ * @param pkt4 where to write the assembled packet; must
* contain enough space for the IP header, UDP/TCP header
* AND the payload
*/
* TCP header, depending on protocol)
* @param payload_length number of bytes in 'payload'
* @param protocol IPPROTO_UDP or IPPROTO_TCP
+ * @param tcp_header skeleton TCP header data to send, NULL for UDP
* @param src_address source address to use (IP and port)
* @param dst_address destination address to use (IP and port)
* @param pkt6 where to write the assembled packet; must
return;
}
{
- char buf[len];
+ char buf[len] GNUNET_ALIGN;
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TUN_Layer2PacketHeader *tun;
return;
}
{
- char buf[len];
+ char buf[len] GNUNET_ALIGN;
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TUN_Layer2PacketHeader *tun;
tun->proto = htons (ETH_P_IPV6);
GNUNET_TUN_initialize_ipv6_header (ipv6,
- IPPROTO_ICMP,
+ IPPROTO_ICMPV6,
sizeof (struct GNUNET_TUN_IcmpHeader) + payload_length,
&source_address->address.ipv6,
&destination_address->address.ipv6);
const struct in_addr *v4;
const struct in6_addr *v6;
const void *payload;
- char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8];
+ char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN;
int af;
GNUNET_STATISTICS_update (stats,
if (NULL == state->heap_node)
{
state->ri.remote_address.af = af;
- state->ri.remote_address.proto = IPPROTO_ICMP;
+ state->ri.remote_address.proto = IPPROTO_ICMPV6;
setup_state_record (state);
}
/* check that ICMP type is something we want to support
const struct GNUNET_EXIT_IcmpServiceMessage *msg;
uint16_t pkt_len = ntohs (message->size);
struct GNUNET_TUN_IcmpHeader icmp;
- char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8];
+ char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN;
const void *payload;
GNUNET_STATISTICS_update (stats,
return;
}
{
- char buf[len];
+ char buf[len] GNUNET_ALIGN;
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TUN_Layer2PacketHeader *tun;
static void *
new_tunnel (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
const struct GNUNET_PeerIdentity *initiator GNUNET_UNUSED,
- const struct GNUNET_ATS_Information *ats GNUNET_UNUSED)
+ const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED)
{
struct TunnelState *s = GNUNET_malloc (sizeof (struct TunnelState));
if (GNUNET_YES !=
GNUNET_OS_check_helper_binary ("gnunet-helper-exit"))
{
- fprintf (stderr,
- "`%s' is not SUID, refusing to run.\n",
- "gnunet-helper-exit");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("`%s' must be installed SUID, refusing to run\n"),
+ "gnunet-helper-exit");
global_ret = 1;
return;
}