/**
- * Queue of messages to a tunnel.
+ * Queue of messages to a channel.
*/
-struct TunnelMessageQueue
+struct ChannelMessageQueue
{
/**
* This is a doubly-linked list.
*/
- struct TunnelMessageQueue *next;
+ struct ChannelMessageQueue *next;
/**
* This is a doubly-linked list.
*/
- struct TunnelMessageQueue *prev;
+ struct ChannelMessageQueue *prev;
/**
- * Payload to send via the tunnel.
+ * Payload to send via the channel.
*/
const void *payload;
/**
* This struct is saved into connections_map to allow finding the
- * right tunnel given an IP packet from TUN. It is also associated
- * with the tunnel's closure so we can find it again for the next
- * message from the tunnel.
+ * right channel given an IP packet from TUN. It is also associated
+ * with the channel's closure so we can find it again for the next
+ * message from the channel.
*/
-struct TunnelState
+struct ChannelState
{
/**
- * Mesh tunnel that is used for this connection.
+ * Mesh channel that is used for this connection.
*/
- struct GNUNET_MESH_Tunnel *tunnel;
+ struct GNUNET_MESH_Channel *channel;
/**
- * Who is the other end of this tunnel.
+ * Who is the other end of this channel.
* FIXME is this needed? Only used for debugging messages
*/
struct GNUNET_PeerIdentity peer;
/**
- * Active tunnel transmission request (or NULL).
+ * Active channel transmission request (or NULL).
*/
struct GNUNET_MESH_TransmitHandle *th;
/**
- * #GNUNET_NO if this is a tunnel for TCP/UDP,
- * #GNUNET_YES if this is a tunnel for DNS,
- * #GNUNET_SYSERR if the tunnel is not yet initialized.
+ * #GNUNET_NO if this is a channel for TCP/UDP,
+ * #GNUNET_YES if this is a channel for DNS,
+ * #GNUNET_SYSERR if the channel is not yet initialized.
*/
int is_dns;
struct LocalService *serv;
/**
- * Head of DLL of messages for this tunnel.
+ * Head of DLL of messages for this channel.
*/
- struct TunnelMessageQueue *head;
+ struct ChannelMessageQueue *head;
/**
- * Tail of DLL of messages for this tunnel.
+ * Tail of DLL of messages for this channel.
*/
- struct TunnelMessageQueue *tail;
+ struct ChannelMessageQueue *tail;
/**
* Primary redirection information for this connection.
/**
* This hashmaps contains the mapping from peer, service-descriptor,
- * source-port and destination-port to a struct TunnelState
+ * source-port and destination-port to a struct ChannelState
*/
static struct GNUNET_CONTAINER_MultiHashMap *connections_map;
static struct GNUNET_CONTAINER_MultiHashMap *tcp_services;
/**
- * Array of all open DNS requests from tunnels.
+ * Array of all open DNS requests from channels.
*/
-static struct TunnelState *tunnels[UINT16_MAX + 1];
+static struct ChannelState *channels[UINT16_MAX + 1];
/**
* Handle to the DNS Stub resolver.
/**
* Private key for this peer.
*/
-static struct GNUNET_CRYPTO_EccPrivateKey *peer_key;
+static struct GNUNET_CRYPTO_EddsaPrivateKey *peer_key;
/**
* Are we an IPv4-exit?
/**
- * We got a reply from DNS for a request of a MESH tunnel. Send it
- * via the tunnel (after changing the request ID back).
+ * We got a reply from DNS for a request of a MESH channel. Send it
+ * via the channel (after changing the request ID back).
*
- * @param cls the 'struct TunnelState'
+ * @param cls the 'struct ChannelState'
* @param size number of bytes available in buf
* @param buf where to copy the reply
* @return number of bytes written to buf
size_t size,
void *buf)
{
- struct TunnelState *ts = cls;
+ struct ChannelState *ts = cls;
size_t off;
size_t ret;
char *cbuf = buf;
const struct GNUNET_TUN_DnsHeader *dns,
size_t r)
{
- struct TunnelState *ts;
+ struct ChannelState *ts;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing DNS result from stub resolver\n");
GNUNET_assert (NULL == cls);
- /* Handle case that this is a reply to a request from a MESH DNS tunnel */
- ts = tunnels[dns->id];
+ /* Handle case that this is a reply to a request from a MESH DNS channel */
+ ts = channels[dns->id];
if ( (NULL == ts) ||
(ts->specifics.dns.rs != rs) )
return;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got a response from the stub resolver for DNS request received via MESH!\n");
- tunnels[dns->id] = NULL;
+ channels[dns->id] = NULL;
GNUNET_free_non_null (ts->specifics.dns.reply);
ts->specifics.dns.reply = GNUNET_malloc (r);
ts->specifics.dns.reply_length = r;
memcpy (ts->specifics.dns.reply, dns, r);
if (NULL != ts->th)
GNUNET_MESH_notify_transmit_ready_cancel (ts->th);
- ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel,
+ ts->th = GNUNET_MESH_notify_transmit_ready (ts->channel,
GNUNET_NO,
GNUNET_TIME_UNIT_FOREVER_REL,
sizeof (struct GNUNET_MessageHeader) + r,
* Process a request via mesh to perform a DNS query.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our `struct TunnelState *`
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our `struct ChannelState *`
* @param message the actual message
*
* @return #GNUNET_OK to keep the connection open,
* #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
+receive_dns_request (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
+ void **channel_ctx,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *ts = *tunnel_ctx;
+ struct ChannelState *ts = *channel_ctx;
const struct GNUNET_TUN_DnsHeader *dns;
size_t mlen = ntohs (message->size);
size_t dlen = mlen - sizeof (struct GNUNET_MessageHeader);
}
if (GNUNET_SYSERR == ts->is_dns)
{
- /* tunnel is DNS from now on */
+ /* channel is DNS from now on */
ts->is_dns = GNUNET_YES;
}
if (dlen < sizeof (struct GNUNET_TUN_DnsHeader))
}
dns = (const struct GNUNET_TUN_DnsHeader *) &message[1];
ts->specifics.dns.original_id = dns->id;
- if (tunnels[ts->specifics.dns.my_id] == ts)
- tunnels[ts->specifics.dns.my_id] = NULL;
+ if (channels[ts->specifics.dns.my_id] == ts)
+ channels[ts->specifics.dns.my_id] = NULL;
ts->specifics.dns.my_id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT16_MAX + 1);
- tunnels[ts->specifics.dns.my_id] = ts;
+ channels[ts->specifics.dns.my_id] = ts;
memcpy (buf, dns, dlen);
dout = (struct GNUNET_TUN_DnsHeader *) buf;
dout->id = ts->specifics.dns.my_id;
* @param state_key set to hash's state if non-NULL
* @return NULL if we have no tracking information for this tuple
*/
-static struct TunnelState *
+static struct ChannelState *
get_redirect_state (int af,
- int protocol,
+ int protocol,
const void *destination_ip,
uint16_t destination_port,
const void *local_ip,
{
struct RedirectInformation ri;
struct GNUNET_HashCode key;
- struct TunnelState *state;
+ struct ChannelState *state;
if ( ( (af == AF_INET) && (protocol == IPPROTO_ICMP) ) ||
( (af == AF_INET6) && (protocol == IPPROTO_ICMPV6) ) )
char key[sizeof (struct GNUNET_HashCode) + sizeof (uint16_t)];
struct GNUNET_HashCode desc;
- GNUNET_CRYPTO_hash (name, strlen (name) + 1, &desc);
+ GNUNET_TUN_service_name_to_hash (name, &desc);
service->name = GNUNET_strdup (name);
memcpy (&key[0], &destination_port, sizeof (uint16_t));
memcpy (&key[sizeof(uint16_t)], &desc, sizeof (struct GNUNET_HashCode));
/**
- * MESH is ready to receive a message for the tunnel. Transmit it.
+ * MESH is ready to receive a message for the channel. Transmit it.
*
- * @param cls the 'struct TunnelState'.
+ * @param cls the 'struct ChannelState'.
* @param size number of bytes available in buf
* @param buf where to copy the message
* @return number of bytes copied to buf
static size_t
send_to_peer_notify_callback (void *cls, size_t size, void *buf)
{
- struct TunnelState *s = cls;
- struct GNUNET_MESH_Tunnel *tunnel = s->tunnel;
- struct TunnelMessageQueue *tnq;
+ struct ChannelState *s = cls;
+ struct GNUNET_MESH_Channel *channel = s->channel;
+ struct ChannelMessageQueue *tnq;
s->th = NULL;
tnq = s->specifics.tcp_udp.head;
return 0;
if (0 == size)
{
- s->th = GNUNET_MESH_notify_transmit_ready (tunnel,
+ s->th = GNUNET_MESH_notify_transmit_ready (channel,
GNUNET_NO /* corking */,
GNUNET_TIME_UNIT_FOREVER_REL,
tnq->len,
tnq);
GNUNET_free (tnq);
if (NULL != (tnq = s->specifics.tcp_udp.head))
- s->th = GNUNET_MESH_notify_transmit_ready (tunnel,
+ s->th = GNUNET_MESH_notify_transmit_ready (channel,
GNUNET_NO /* corking */,
GNUNET_TIME_UNIT_FOREVER_REL,
tnq->len,
&send_to_peer_notify_callback,
s);
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# Bytes transmitted via mesh tunnels"),
+ gettext_noop ("# Bytes transmitted via mesh channels"),
size, GNUNET_NO);
return size;
}
/**
- * Send the given packet via the mesh tunnel.
+ * Send the given packet via the mesh channel.
*
- * @param s tunnel destination
+ * @param s channel destination
* @param tnq message to queue
*/
static void
-send_packet_to_mesh_tunnel (struct TunnelState *s,
- struct TunnelMessageQueue *tnq)
+send_packet_to_mesh_channel (struct ChannelState *s,
+ struct ChannelMessageQueue *tnq)
{
- struct GNUNET_MESH_Tunnel *mesh_tunnel;
+ struct GNUNET_MESH_Channel *mesh_channel;
- mesh_tunnel = s->tunnel;
+ mesh_channel = s->channel;
GNUNET_assert (NULL != s);
GNUNET_CONTAINER_DLL_insert_tail (s->specifics.tcp_udp.head, s->specifics.tcp_udp.tail, tnq);
if (NULL == s->th)
- s->th = GNUNET_MESH_notify_transmit_ready (mesh_tunnel,
+ s->th = GNUNET_MESH_notify_transmit_ready (mesh_channel,
GNUNET_NO /* cork */,
GNUNET_TIME_UNIT_FOREVER_REL,
tnq->len,
const void *destination_ip,
const void *source_ip)
{
- struct TunnelState *state;
- struct TunnelMessageQueue *tnq;
+ struct ChannelState *state;
+ struct ChannelMessageQueue *tnq;
struct GNUNET_EXIT_IcmpToVPNMessage *i2v;
const struct GNUNET_TUN_IPv4Header *ipv4;
const struct GNUNET_TUN_IPv6Header *ipv6;
return;
}
mlen = sizeof (struct GNUNET_EXIT_IcmpToVPNMessage) + pktlen - sizeof (struct GNUNET_TUN_IcmpHeader);
- tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen);
+ tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
tnq->payload = &tnq[1];
tnq->len = mlen;
i2v = (struct GNUNET_EXIT_IcmpToVPNMessage *) &tnq[1];
memcpy (&i2v->icmp_header,
icmp,
pktlen);
- send_packet_to_mesh_tunnel (state, tnq);
+ send_packet_to_mesh_channel (state, tnq);
}
const void *destination_ip,
const void *source_ip)
{
- struct TunnelState *state;
- struct TunnelMessageQueue *tnq;
+ struct ChannelState *state;
+ struct ChannelMessageQueue *tnq;
struct GNUNET_EXIT_UdpReplyMessage *urm;
size_t mlen;
return;
}
mlen = sizeof (struct GNUNET_EXIT_UdpReplyMessage) + pktlen - sizeof (struct GNUNET_TUN_UdpHeader);
- tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen);
+ tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
tnq->payload = &tnq[1];
tnq->len = mlen;
urm = (struct GNUNET_EXIT_UdpReplyMessage *) &tnq[1];
memcpy (&urm[1],
&udp[1],
pktlen - sizeof (struct GNUNET_TUN_UdpHeader));
- send_packet_to_mesh_tunnel (state, tnq);
+ send_packet_to_mesh_channel (state, tnq);
}
const void *destination_ip,
const void *source_ip)
{
- struct TunnelState *state;
+ struct ChannelState *state;
char buf[pktlen] GNUNET_ALIGN;
struct GNUNET_TUN_TcpHeader *mtcp;
struct GNUNET_EXIT_TcpDataMessage *tdm;
- struct TunnelMessageQueue *tnq;
+ struct ChannelMessageQueue *tnq;
size_t mlen;
{
return;
}
- tnq = GNUNET_malloc (sizeof (struct TunnelMessageQueue) + mlen);
+ tnq = GNUNET_malloc (sizeof (struct ChannelMessageQueue) + mlen);
tnq->payload = &tnq[1];
tnq->len = mlen;
tdm = (struct GNUNET_EXIT_TcpDataMessage *) &tnq[1];
memcpy (&tdm->tcp_header,
buf,
pktlen);
- send_packet_to_mesh_tunnel (state, tnq);
+ send_packet_to_mesh_channel (state, tnq);
}
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) ||
* We are starting a fresh connection (TCP or UDP) and need
* to pick a source port and IP address (within the correct
* range and address family) to associate replies with the
- * connection / correct mesh tunnel. This function generates
+ * connection / correct mesh channel. This function generates
* a "fresh" source IP and source port number for a connection
* After picking a good source address, this function sets up
* the state in the 'connections_map' and 'connections_heap'
* @param state skeleton state to setup a record for; should
* 'state->specifics.tcp_udp.ri.remote_address' filled in so that
* this code can determine which AF/protocol is
- * going to be used (the 'tunnel' should also
+ * going to be used (the 'channel' should also
* already be set); after calling this function,
* heap_node and the local_address will be
* also initialized (heap_node != NULL can be
* used to test if a state has been fully setup).
*/
static void
-setup_state_record (struct TunnelState *state)
+setup_state_record (struct ChannelState *state)
{
struct GNUNET_HashCode key;
- struct TunnelState *s;
+ struct ChannelState *s;
/* generate fresh, unique address */
do
s = GNUNET_CONTAINER_heap_remove_root (connections_heap);
GNUNET_assert (state != s);
s->specifics.tcp_udp.heap_node = NULL;
- GNUNET_MESH_tunnel_destroy (s->tunnel);
+ GNUNET_MESH_channel_destroy (s->channel);
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_remove (connections_map,
&s->specifics.tcp_udp.state_key,
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;
* offered by this system.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our `struct ChannelState *`
* @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_Channel *channel,
+ void **channel_ctx,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
const struct GNUNET_EXIT_TcpServiceStartMessage *start;
uint16_t pkt_len = ntohs (message->size);
}
if (GNUNET_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
GNUNET_STATISTICS_update (stats,
GNUNET_i2s (&state->peer),
GNUNET_h2s (&start->service_descriptor),
(unsigned int) ntohs (start->tcp_header.destination_port));
- if (NULL == (state->specifics.tcp_udp.serv = find_service (tcp_services, &start->service_descriptor,
- ntohs (start->tcp_header.destination_port))))
+ if (NULL == (state->specifics.tcp_udp.serv =
+ find_service (tcp_services,
+ &start->service_descriptor,
+ ntohs (start->tcp_header.destination_port))))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("No service found for %s on port %d!\n"),
+ _("No service %s found for %s on port %d!\n"),
+ GNUNET_h2s (&start->service_descriptor),
"TCP",
ntohs (start->tcp_header.destination_port));
GNUNET_STATISTICS_update (stats,
* Process a request to forward TCP data to the Internet via this peer.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
* @param message the actual message
*
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
-receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx GNUNET_UNUSED,
+receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
+ void **channel_ctx GNUNET_UNUSED,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
const struct GNUNET_EXIT_TcpInternetStartMessage *start;
uint16_t pkt_len = ntohs (message->size);
const struct in_addr *v4;
}
if (GNUNET_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
GNUNET_STATISTICS_update (stats,
* connection via this peer.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
* @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,
- void **tunnel_ctx GNUNET_UNUSED,
+receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Channel *channel,
+ void **channel_ctx GNUNET_UNUSED,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
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)
+ {
+ /* channel 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;
/**
* Synthesize a plausible ICMP payload for an ICMPv4 error
- * response on the given tunnel.
+ * response on the given channel.
*
- * @param state tunnel information
+ * @param state channel information
* @param ipp IPv6 header to fill in (ICMP payload)
* @param udp "UDP" header to fill in (ICMP payload); might actually
* also be the first 8 bytes of the TCP header
*/
static void
-make_up_icmpv4_payload (struct TunnelState *state,
+make_up_icmpv4_payload (struct ChannelState *state,
struct GNUNET_TUN_IPv4Header *ipp,
struct GNUNET_TUN_UdpHeader *udp)
{
/**
* Synthesize a plausible ICMP payload for an ICMPv6 error
- * response on the given tunnel.
+ * response on the given channel.
*
- * @param state tunnel information
+ * @param state channel information
* @param ipp IPv6 header to fill in (ICMP payload)
* @param udp "UDP" header to fill in (ICMP payload); might actually
* also be the first 8 bytes of the TCP header
*/
static void
-make_up_icmpv6_payload (struct TunnelState *state,
+make_up_icmpv6_payload (struct ChannelState *state,
struct GNUNET_TUN_IPv6Header *ipp,
struct GNUNET_TUN_UdpHeader *udp)
{
* Process a request to forward ICMP data to the Internet via this peer.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
* @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_Channel *channel,
+ void **channel_ctx,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
const struct GNUNET_EXIT_IcmpInternetMessage *msg;
uint16_t pkt_len = ntohs (message->size);
const struct in_addr *v4;
}
if (GNUNET_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
GNUNET_STATISTICS_update (stats,
if ( (NULL != state->specifics.tcp_udp.heap_node) &&
(af != state->specifics.tcp_udp.ri.remote_address.af) )
{
- /* other peer switched AF on this tunnel; not allowed */
+ /* other peer switched AF on this channel; not allowed */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
* @return number of bytes of payload we created in buf
*/
static uint16_t
-make_up_icmp_service_payload (struct TunnelState *state,
+make_up_icmp_service_payload (struct ChannelState *state,
char *buf)
{
switch (state->specifics.tcp_udp.serv->address.af)
* offered by this system.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
* @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,
- void **tunnel_ctx,
+receive_icmp_service (void *cls,
+ struct GNUNET_MESH_Channel *channel,
+ void **channel_ctx,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
const struct GNUNET_EXIT_IcmpServiceMessage *msg;
uint16_t pkt_len = ntohs (message->size);
struct GNUNET_TUN_IcmpHeader icmp;
}
if (GNUNET_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
GNUNET_STATISTICS_update (stats,
* @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;
* Process a request to forward UDP data to the Internet via this peer.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
* @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_Channel *channel,
+ void **channel_ctx,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
const struct GNUNET_EXIT_UdpInternetMessage *msg;
uint16_t pkt_len = ntohs (message->size);
const struct in_addr *v4;
}
if (GNUNET_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
GNUNET_STATISTICS_update (stats,
* offered by this system.
*
* @param cls closure, NULL
- * @param tunnel connection to the other end
- * @param tunnel_ctx pointer to our 'struct TunnelState *'
+ * @param channel connection to the other end
+ * @param channel_ctx pointer to our 'struct ChannelState *'
* @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,
- void **tunnel_ctx,
+receive_udp_service (void *cls,
+ struct GNUNET_MESH_Channel *channel,
+ void **channel_ctx,
const struct GNUNET_MessageHeader *message)
{
- struct TunnelState *state = *tunnel_ctx;
+ struct ChannelState *state = *channel_ctx;
const struct GNUNET_EXIT_UdpServiceMessage *msg;
uint16_t pkt_len = ntohs (message->size);
}
if (GNUNET_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
GNUNET_STATISTICS_update (stats,
GNUNET_i2s (&state->peer),
GNUNET_h2s (&msg->service_descriptor),
(unsigned int) ntohs (msg->destination_port));
- if (NULL == (state->specifics.tcp_udp.serv = find_service (udp_services, &msg->service_descriptor,
- ntohs (msg->destination_port))))
+ if (NULL == (state->specifics.tcp_udp.serv =
+ find_service (udp_services,
+ &msg->service_descriptor,
+ ntohs (msg->destination_port))))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("No service found for %s on port %d!\n"),
+ _("No service %s found for %s on port %d!\n"),
+ GNUNET_h2s (&msg->service_descriptor),
"UDP",
ntohs (msg->destination_port));
GNUNET_STATISTICS_update (stats,
/**
- * Callback from GNUNET_MESH for new tunnels.
+ * Callback from GNUNET_MESH for new channels.
*
* @param cls closure
- * @param tunnel new handle to the tunnel
- * @param initiator peer that started the tunnel
+ * @param channel new handle to the channel
+ * @param initiator peer that started the channel
* @param port destination port
- * @return initial tunnel context for the tunnel
+ * @param options channel options flags
+ * @return initial channel context for the channel
*/
static void *
-new_tunnel (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
- const struct GNUNET_PeerIdentity *initiator, uint32_t port)
+new_channel (void *cls,
+ struct GNUNET_MESH_Channel *channel,
+ const struct GNUNET_PeerIdentity *initiator,
+ uint32_t port, enum GNUNET_MESH_ChannelOption options)
{
- struct TunnelState *s = GNUNET_new (struct TunnelState);
+ struct ChannelState *s = GNUNET_new (struct ChannelState);
s->is_dns = GNUNET_SYSERR;
s->peer = *initiator;
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# Inbound MESH tunnels created"),
+ gettext_noop ("# Inbound MESH channels created"),
1, GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received inbound tunnel from `%s'\n",
+ "Received inbound channel from `%s'\n",
GNUNET_i2s (initiator));
- s->tunnel = tunnel;
+ s->channel = channel;
return s;
}
/**
- * Function called by mesh whenever an inbound tunnel is destroyed.
+ * Function called by mesh whenever an inbound channel is destroyed.
* Should clean up any associated state.
*
- * @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
+ * @param cls closure (set from #GNUNET_MESH_connect)
+ * @param channel connection to the other end (henceforth invalid)
+ * @param channel_ctx place where local state associated
+ * with the channel is stored
*/
static void
-clean_tunnel (void *cls GNUNET_UNUSED, const struct GNUNET_MESH_Tunnel *tunnel,
- void *tunnel_ctx)
+clean_channel (void *cls,
+ const struct GNUNET_MESH_Channel *channel,
+ void *channel_ctx)
{
- struct TunnelState *s = tunnel_ctx;
- struct TunnelMessageQueue *tnq;
+ struct ChannelState *s = channel_ctx;
+ struct ChannelMessageQueue *tnq;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Tunnel destroyed\n");
+ "Channel destroyed\n");
if (GNUNET_SYSERR == s->is_dns)
{
GNUNET_free (s);
}
if (GNUNET_YES == s->is_dns)
{
- if (tunnels[s->specifics.dns.my_id] == s)
- tunnels[s->specifics.dns.my_id] = NULL;
+ if (channels[s->specifics.dns.my_id] == s)
+ channels[s->specifics.dns.my_id] = NULL;
GNUNET_free_non_null (s->specifics.dns.reply);
}
else
* @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;
char *hostname;
char *hostport;
struct LocalService *serv;
+ char *n;
+ size_t slen;
+
+ slen = strlen (name);
+ GNUNET_assert (slen >= 8);
+ n = GNUNET_strndup (name, slen - 8 /* remove .gnunet. */);
for (redirect = strtok (cpy, " "); redirect != NULL;
redirect = strtok (NULL, " "))
if (NULL == (hostname = strstr (redirect, ":")))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "option `%s' for domain `%s' is not formatted correctly!\n",
+ _("Option `%s' for domain `%s' is not formatted correctly!\n"),
redirect,
name);
continue;
if (NULL == (hostport = strstr (hostname, ":")))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "option `%s' for domain `%s' is not formatted correctly!\n",
- redirect,
- name);
+ _("Option `%s' for domain `%s' is not formatted correctly!\n"),
+ redirect,
+ name);
continue;
}
hostport[0] = '\0';
if (!((local_port > 0) && (local_port < 65536)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "`%s' is not a valid port number (for domain `%s')!", redirect,
- name);
+ _("`%s' is not a valid port number (for domain `%s')!"),
+ redirect,
+ name);
continue;
}
if (!((remote_port > 0) && (remote_port < 65536)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "`%s' is not a valid port number (for domain `%s')!", hostport,
+ _("`%s' is not a valid port number (for domain `%s')!"),
+ hostport,
name);
continue;
}
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("No addresses found for hostname `%s' of service `%s'!\n"),
hostname,
- name);
+ n);
GNUNET_free (serv);
continue;
}
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
- name);
+ n);
freeaddrinfo (res);
GNUNET_free (serv);
continue;
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
- name);
+ n);
freeaddrinfo (res);
GNUNET_free (serv);
continue;
- }
+ }
serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("No IP addresses found for hostname `%s' of service `%s'!\n"),
hostname,
- name);
+ n);
GNUNET_free (serv);
continue;
}
freeaddrinfo (res);
}
store_service ((IPPROTO_UDP == proto) ? udp_services : tcp_services,
- name,
+ n,
local_port,
serv);
}
+ GNUNET_free (n);
}
* @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;
expiration = GNUNET_TIME_relative_to_absolute (DNS_ADVERTISEMENT_TIMEOUT);
dns_advertisement.expiration_time = GNUNET_TIME_absolute_hton (expiration);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_ecc_sign (peer_key,
+ GNUNET_CRYPTO_eddsa_sign (peer_key,
&dns_advertisement.purpose,
&dns_advertisement.signature));
}
* @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[] = {
dns_exit = NULL;
if ( (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "ENABLE_DNS")) &&
+ GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "EXIT_DNS")) &&
( (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, "exit",
"DNS_RESOLVER",
GNUNET_free_non_null (dns_exit);
dns_exit = NULL;
}
- if (NULL != dns_exit)
- dnsstub = GNUNET_DNSSTUB_start (dns_exit);
-
-
app_idx = 0;
if (GNUNET_YES == ipv4_exit)
{
- // FIXME use regex to put info
apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
app_idx++;
}
if (GNUNET_YES == ipv6_exit)
{
- // FIXME use regex to put info
apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
app_idx++;
}
if (NULL != dns_exit)
{
dht = GNUNET_DHT_connect (cfg, 1);
- peer_key = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg);
- GNUNET_CRYPTO_ecc_key_get_public_for_signature (peer_key,
+ peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
+ GNUNET_CRYPTO_eddsa_key_get_public (peer_key,
&dns_advertisement.peer.public_key);
dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
- sizeof (struct GNUNET_CRYPTO_EccSignature));
+ sizeof (struct GNUNET_CRYPTO_EddsaSignature));
dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
GNUNET_CRYPTO_hash ("dns",
strlen ("dns"),
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 !=
return;
}
exit_argv[5] = ipv4addr;
+ ipv4mask = NULL;
if ( (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK",
&ipv4mask) ||
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4MASK");
GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free_non_null (ipv4mask);
return;
}
exit_argv[6] = ipv4mask;
connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ if (0 == app_idx)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No useful service enabled. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
mesh_handle
= GNUNET_MESH_connect (cfg, NULL,
- &new_tunnel,
- &clean_tunnel, handlers,
- apptypes); // FIXME use ports
+ &new_channel,
+ &clean_channel, handlers,
+ apptypes);
if (NULL == mesh_handle)
{
GNUNET_SCHEDULER_shutdown ();
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exit",
- "EXIT_RANGE_IPV4_REGEX",
+ "EXIT_RANGE_IPV4_POLICY",
&policy))
regex = NULL;
else
(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);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exit",
- "EXIT_RANGE_IPV6_REGEX",
+ "EXIT_RANGE_IPV6_POLICY",
&policy))
regex = NULL;
else