/**
- * 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.
/**
- * 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,
const void *destination_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);
}
* 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,
* 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)
*/
static int
receive_tcp_service (void *cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
+ 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)
*/
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_SYSERR == state->is_dns)
{
- /* tunnel is UDP/TCP from now on */
+ /* channel is UDP/TCP from now on */
state->is_dns = GNUNET_NO;
}
/**
* 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)
*/
static int
receive_icmp_remote (void *cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
+ 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)
*/
static int
receive_icmp_service (void *cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
+ 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,
* 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)
*/
static int
receive_udp_remote (void *cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
+ 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)
*/
static int
receive_udp_service (void *cls,
- struct GNUNET_MESH_Tunnel *tunnel,
- void **tunnel_ctx,
+ 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,
- struct GNUNET_MESH_Tunnel *tunnel,
+new_channel (void *cls,
+ struct GNUNET_MESH_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port)
+ 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 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,
- 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
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;
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);
}
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++;
}
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 ();