56#define REGEX_MAX_PATH_LEN_IPV4 4
62#define REGEX_MAX_PATH_LEN_IPV6 8
67#define REGEX_REFRESH_FREQUENCY GNUNET_TIME_relative_multiply ( \
68 GNUNET_TIME_UNIT_MINUTES, 30)
73#define DHT_PUT_FREQUENCY GNUNET_TIME_relative_multiply ( \
74 GNUNET_TIME_UNIT_MINUTES, 15)
79#define DNS_ADVERTISEMENT_TIMEOUT GNUNET_TIME_relative_multiply ( \
80 GNUNET_TIME_UNIT_HOURS, 3)
86#define LOG(kind, ...) \
87 GNUNET_log_from (kind, "exit", __VA_ARGS__);
471 "Processing DNS result from stub resolver\n");
480 "Got a response from the stub resolver for DNS request received via CADET!\n");
533 size_t mlen = ntohs (
msg->header.
size);
589 switch (
ri->remote_address.af)
593 &
ri->remote_address.address.ipv4,
594 sizeof(
struct in_addr));
595 off +=
sizeof(
struct in_addr);
600 &
ri->remote_address.address.ipv6,
601 sizeof(
struct in6_addr));
602 off +=
sizeof(
struct in_addr);
609 &
ri->remote_address.port,
611 off +=
sizeof(uint16_t);
612 switch (
ri->local_address.af)
616 &
ri->local_address.address.ipv4,
617 sizeof(
struct in_addr));
618 off +=
sizeof(
struct in_addr);
623 &
ri->local_address.address.ipv6,
624 sizeof(
struct in6_addr));
625 off +=
sizeof(
struct in_addr);
632 &
ri->local_address.port,
634 off +=
sizeof(uint16_t);
636 &
ri->remote_address.proto,
660 const void *local_ip,
668 if (((
af == AF_INET) && (
protocol == IPPROTO_ICMP)) ||
669 ((
af == AF_INET6) && (
protocol == IPPROTO_ICMPV6)))
675 ri.remote_address.
af =
af;
677 ri.remote_address.address.ipv4 = *((
struct in_addr*) destination_ip);
679 ri.remote_address.address.ipv6 = *((
struct in6_addr*) destination_ip);
680 ri.remote_address.port = destination_port;
681 ri.remote_address.proto = protocol;
682 ri.local_address.af = af;
684 ri.local_address.address.ipv4 = *((
struct in_addr*) local_ip);
686 ri.local_address.address.ipv6 = *((
struct in6_addr*) local_ip);
687 ri.local_address.port = local_port;
688 ri.local_address.proto = protocol;
691 if (NULL != state_key)
698 if (NULL == state_key)
731 if (NULL ==
state->specifics.tcp_udp.serv)
736 if (NULL !=
state->specifics.tcp_udp.heap_node)
770 size_t payload_length,
779 len = payload_length;
815 pkt4_udp->
len = htons ((uint16_t) payload_length);
833 "Sending TCP packet from port %u to port %u\n",
874 size_t payload_length,
883 len = payload_length;
919 pkt6_udp->
len = htons ((uint16_t) payload_length);
970 size_t payload_length)
979 "Sending packet with %u bytes TCP payload via TUN\n",
980 (
unsigned int) payload_length);
983 switch (source_address->
af)
998 len += payload_length;
1011 hdr->
size = htons (len);
1013 tun->
flags = htons (0);
1014 switch (source_address->
af)
1084 "Sending packet with %u bytes ICMP payload via TUN\n",
1085 (
unsigned int) payload_length);
1088 switch (destination_address->
af)
1103 len += payload_length;
1116 hdr->
size = htons (len);
1118 tun->
flags = htons (0);
1119 switch (source_address->
af)
1159 *icmp = *icmp_header;
1188 local_address->
af = af;
1192 if (((af == AF_INET) && (
proto == IPPROTO_ICMP)) ||
1193 ((af == AF_INET6) && (
proto == IPPROTO_ICMPV6)))
1194 local_address->
port = 0;
1203 struct in_addr addr;
1204 struct in_addr mask;
1209 if (0 == ~mask.s_addr)
1217 mask.s_addr = addr.s_addr | ~mask.s_addr;
1223 local_address->
address.
ipv4.s_addr = (addr.s_addr | rnd.s_addr)
1226 while ((local_address->
address.
ipv4.s_addr == addr.s_addr) ||
1227 (local_address->
address.
ipv4.s_addr == mask.s_addr));
1233 struct in6_addr addr;
1234 struct in6_addr mask;
1235 struct in6_addr rnd;
1250 mask.s6_addr[i / 8] |= (1 << (i % 8));
1255 for (i = 0; i < 16; i++)
1261 = (addr.s6_addr[i] | rnd.s6_addr[i]) & mask.s6_addr[i];
1307 if (NULL ==
state->specifics.tcp_udp.serv)
1309 state->specifics.tcp_udp.ri.remote_address.proto,
1310 &
state->specifics.tcp_udp.ri.local_address);
1313 state->specifics.tcp_udp.serv->address.proto,
1314 &
state->specifics.tcp_udp.ri.local_address);
1318 state->specifics.tcp_udp.ri.remote_address.proto,
1319 &
state->specifics.tcp_udp.ri.remote_address.address
1321 state->specifics.tcp_udp.ri.remote_address.port,
1322 &
state->specifics.tcp_udp.ri.local_address.address,
1323 state->specifics.tcp_udp.ri.local_address.port,
1326 char buf[INET6_ADDRSTRLEN];
1328 "Picked local address %s:%u for new connection\n",
1329 inet_ntop (
state->specifics.tcp_udp.ri.local_address.af,
1330 &
state->specifics.tcp_udp.ri.local_address.address,
1333 (
unsigned int)
state->specifics.tcp_udp.ri.local_address.port);
1335 state->specifics.tcp_udp.state_key =
key;
1340 state->specifics.tcp_udp.heap_node
1371 const void *
payload,
size_t payload_length)
1379 "Sending packet with %u bytes UDP payload via TUN\n",
1380 (
unsigned int) payload_length);
1383 switch (source_address->
af)
1398 len += payload_length;
1411 hdr->
size = htons (len);
1413 tun->
flags = htons (0);
1414 switch (source_address->
af)
1495 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
1497 const struct in_addr *v4;
1498 const struct in6_addr *v6;
1512 "# UDP IP-exit requests received via cadet"),
1514 af = (int) ntohl (
msg->af);
1515 state->specifics.tcp_udp.ri.remote_address.af = af;
1519 if (pkt_len <
sizeof(
struct in_addr))
1529 v4 = (
const struct in_addr*) &
msg[1];
1531 pkt_len -=
sizeof(
struct in_addr);
1532 state->specifics.tcp_udp.ri.remote_address.address.ipv4 = *v4;
1536 if (pkt_len <
sizeof(
struct in6_addr))
1546 v6 = (
const struct in6_addr*) &
msg[1];
1548 pkt_len -=
sizeof(
struct in6_addr);
1549 state->specifics.tcp_udp.ri.remote_address.address.ipv6 = *v6;
1557 char buf[INET6_ADDRSTRLEN];
1559 "Received data from %s for forwarding to UDP %s:%u\n",
1562 &
state->specifics.tcp_udp.ri.remote_address.address,
1564 (
unsigned int) ntohs (
msg->destination_port));
1566 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_UDP;
1567 state->specifics.tcp_udp.ri.remote_address.port =
msg->destination_port;
1568 if (NULL ==
state->specifics.tcp_udp.heap_node)
1570 if (0 != ntohs (
msg->source_port))
1571 state->specifics.tcp_udp.ri.local_address.port =
msg->source_port;
1573 &
state->specifics.tcp_udp.ri.local_address,
1595 if (NULL ==
state->specifics.tcp_udp.serv)
1616 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
1624 "# UDP service requests received via cadet"),
1627 "Received data from %s for forwarding to UDP service %s on port %u\n",
1630 (
unsigned int) ntohs (
msg->destination_port));
1632 if (0 != ntohs (
msg->source_port))
1633 state->specifics.tcp_udp.ri.local_address.port =
msg->source_port;
1635 &
state->specifics.tcp_udp.ri.local_address,
1656 uint16_t pkt_len = ntohs (
start->header.size) -
sizeof(
struct
1666 "# TCP service creation requests received via cadet"),
1676 "Received data from %s for forwarding to TCP service %s on port %u\n",
1679 (
unsigned int) ntohs (
start->tcp_header.destination_port));
1682 &
state->specifics.tcp_udp.ri.local_address,
1714 if ((NULL !=
state->specifics.tcp_udp.serv) ||
1715 (NULL !=
state->specifics.tcp_udp.heap_node))
1740 uint16_t pkt_len = ntohs (
start->header.size) -
sizeof(
struct
1742 const struct in_addr *v4;
1743 const struct in6_addr *v6;
1757 "# TCP IP-exit creation requests received via cadet"),
1759 af = (int) ntohl (
start->af);
1760 state->specifics.tcp_udp.ri.remote_address.af = af;
1764 if (pkt_len <
sizeof(
struct in_addr))
1774 v4 = (
const struct in_addr*) &
start[1];
1776 pkt_len -=
sizeof(
struct in_addr);
1777 state->specifics.tcp_udp.ri.remote_address.address.ipv4 = *v4;
1781 if (pkt_len <
sizeof(
struct in6_addr))
1791 v6 = (
const struct in6_addr*) &
start[1];
1793 pkt_len -=
sizeof(
struct in6_addr);
1794 state->specifics.tcp_udp.ri.remote_address.address.ipv6 = *v6;
1802 char buf[INET6_ADDRSTRLEN];
1804 "Received payload from %s for existing TCP stream to %s:%u\n",
1807 &
state->specifics.tcp_udp.ri.remote_address.address,
1809 (
unsigned int) ntohs (
start->tcp_header.destination_port));
1811 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_TCP;
1812 state->specifics.tcp_udp.ri.remote_address.port = ntohs (
1813 start->tcp_header.destination_port);
1816 &
state->specifics.tcp_udp.ri.local_address,
1839 if ((NULL ==
state) ||
1840 (NULL ==
state->specifics.tcp_udp.heap_node))
1845 "# TCP DATA requests dropped (no session)"),
1876 uint16_t pkt_len = ntohs (
data->header.size) -
sizeof(
struct
1884 "# TCP data requests received via cadet"),
1894 char buf[INET6_ADDRSTRLEN];
1896 "Received additional %u bytes of data from %s for TCP stream to %s:%u\n",
1899 inet_ntop (
state->specifics.tcp_udp.ri.remote_address.af,
1900 &
state->specifics.tcp_udp.ri.remote_address.address,
1902 (
unsigned int)
state->specifics.tcp_udp.ri.remote_address.port);
1906 &
state->specifics.tcp_udp.ri.local_address,
1928 state->specifics.tcp_udp.ri.remote_address.
1931 &
state->specifics.tcp_udp.ri.remote_address
1933 &
state->specifics.tcp_udp.ri.local_address.
1935 udp->source_port = htons (
state->specifics.tcp_udp.ri.remote_address.port);
1936 udp->destination_port = htons (
1937 state->specifics.tcp_udp.ri.local_address.port);
1938 udp->len = htons (0);
1939 udp->crc = htons (0);
1958 state->specifics.tcp_udp.ri.remote_address.
1961 &
state->specifics.tcp_udp.ri.remote_address
1963 &
state->specifics.tcp_udp.ri.local_address.
1965 udp->source_port = htons (
state->specifics.tcp_udp.ri.remote_address.port);
1966 udp->destination_port = htons (
1967 state->specifics.tcp_udp.ri.local_address.port);
1968 udp->len = htons (0);
1969 udp->crc = htons (0);
2007 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
2009 const struct in_addr *v4;
2010 const struct in6_addr *v6;
2025 "# ICMP IP-exit requests received via cadet"),
2028 af = (int) ntohl (
msg->af);
2029 if ((NULL !=
state->specifics.tcp_udp.heap_node) &&
2030 (af !=
state->specifics.tcp_udp.ri.remote_address.af))
2040 if (pkt_len <
sizeof(
struct in_addr))
2050 v4 = (
const struct in_addr*) &
msg[1];
2052 pkt_len -=
sizeof(
struct in_addr);
2053 state->specifics.tcp_udp.ri.remote_address.address.ipv4 = *v4;
2054 if (NULL ==
state->specifics.tcp_udp.heap_node)
2056 state->specifics.tcp_udp.ri.remote_address.af = af;
2057 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMP;
2062 switch (
msg->icmp_header.
type)
2096 "# ICMPv4 packets dropped (type not allowed)")
2105 if (pkt_len <
sizeof(
struct in6_addr))
2115 v6 = (
const struct in6_addr*) &
msg[1];
2117 pkt_len -=
sizeof(
struct in6_addr);
2118 state->specifics.tcp_udp.ri.remote_address.address.ipv6 = *v6;
2119 if (NULL ==
state->specifics.tcp_udp.heap_node)
2121 state->specifics.tcp_udp.ri.remote_address.af = af;
2122 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMPV6;
2127 switch (
msg->icmp_header.
type)
2162 "# ICMPv6 packets dropped (type not allowed)")
2177 char buf_tmp[INET6_ADDRSTRLEN];
2179 "Received ICMP data from %s for forwarding to %s\n",
2182 &
state->specifics.tcp_udp.ri.remote_address.address,
2183 buf_tmp,
sizeof(buf_tmp)));
2186 &
state->specifics.tcp_udp.ri.local_address,
2206 switch (
state->specifics.tcp_udp.serv->address.af)
2265 if (NULL ==
state->specifics.tcp_udp.serv)
2286 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
2297 "# ICMP service requests received via cadet"),
2301 "Received data from %s for forwarding to ICMP service %s\n",
2304 icmp =
msg->icmp_header;
2306 state->specifics.tcp_udp.ri.remote_address
2307 =
state->specifics.tcp_udp.serv->address;
2315 switch (
msg->icmp_header.
type)
2318 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2323 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2328 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2340 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2352 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2356 "# ICMPv4 packets dropped (impossible PT to v6)"),
2373 "# ICMPv4 packets dropped (type not allowed)")
2382 switch (
msg->icmp_header.
type)
2385 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2390 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2395 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2407 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2420 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2424 "# ICMPv6 packets dropped (impossible PT to v4)"),
2441 "# ICMPv6 packets dropped (type not allowed)")
2455 &
state->specifics.tcp_udp.ri.local_address,
2505 s->
peer = *initiator;
2511 "Received inbound channel from `%s'\n",
2534 "Channel destroyed\n");
2606 "Opening CADET port %s for SERVICE exit %s on port %u\n",
2609 (
unsigned int) destination_port);
2628 _ (
"Got duplicate service records for `%s:%u'\n"),
2630 (
unsigned int) destination_port);
2648 "# Messages transmitted via cadet channels"),
2671 const void *destination_ip,
2672 const void *source_ip)
2685 char sbuf[INET6_ADDRSTRLEN];
2686 char dbuf[INET6_ADDRSTRLEN];
2688 "Received ICMP packet going from %s to %s\n",
2691 sbuf,
sizeof(sbuf)),
2694 dbuf,
sizeof(dbuf)));
2712 protocol = IPPROTO_ICMP;
2745 "# ICMPv4 packets dropped (type not allowed)")
2753 protocol = IPPROTO_ICMPV6;
2769 protocol =
ipv6->next_header;
2787 "# ICMPv6 packets dropped (type not allowed)")
2809 case IPPROTO_ICMPV6:
2842 "# ICMP packets dropped (not allowed)"),
2851 "ICMP Packet dropped, have no matching connection information\n"));
2857 i2v->
af = htonl (af);
2881 const void *destination_ip,
2882 const void *source_ip)
2889 char sbuf[INET6_ADDRSTRLEN];
2890 char dbuf[INET6_ADDRSTRLEN];
2893 "Received UDP packet going from %s:%u to %s:%u\n",
2896 sbuf,
sizeof(sbuf)),
2897 (
unsigned int) ntohs (
udp->source_port),
2900 dbuf,
sizeof(dbuf)),
2901 (
unsigned int) ntohs (
udp->destination_port));
2910 if (pktlen != ntohs (
udp->len))
2919 ntohs (
udp->source_port),
2921 ntohs (
udp->destination_port),
2927 "UDP Packet dropped, have no matching connection information\n"));
2958 const void *destination_ip,
2959 const void *source_ip)
2969 char sbuf[INET6_ADDRSTRLEN];
2970 char dbuf[INET6_ADDRSTRLEN];
2972 "Received TCP packet with %u bytes going from %s:%u to %s:%u\n",
2976 sbuf,
sizeof(sbuf)),
2977 (
unsigned int) ntohs (
tcp->source_port),
2980 dbuf,
sizeof(dbuf)),
2981 (
unsigned int) ntohs (
tcp->destination_port));
2993 ntohs (
tcp->source_port),
2995 ntohs (
tcp->destination_port),
3001 "TCP Packet dropped, have no matching connection information\n"));
3010 mtcp->destination_port = 0;
3046 "Got %u-byte message of type %u from gnunet-helper-exit\n",
3047 ntohs (message->
size),
3048 ntohs (message->
type));
3070 switch (ntohs (pkt_tun->
proto))
3092 _ (
"IPv4 packet options received. Ignored.\n"));
3102 &pkt4->destination_address,
3103 &pkt4->source_address);
3109 &pkt4->destination_address,
3110 &pkt4->source_address);
3116 &pkt4->destination_address,
3117 &pkt4->source_address);
3123 "IPv4 packet with unsupported next header %u received. Ignored.\n"),
3124 (
int) pkt4->protocol);
3154 &pkt6->destination_address,
3155 &pkt6->source_address);
3161 &pkt6->destination_address,
3162 &pkt6->source_address);
3165 case IPPROTO_ICMPV6:
3168 &pkt6->destination_address,
3169 &pkt6->source_address);
3175 "IPv6 packet with unsupported next header %d received. Ignored.\n"),
3184 _ (
"Packet from unknown protocol %u received. Ignored.\n"),
3185 ntohs (pkt_tun->
proto));
3208 s->
peer = *initiator;
3214 "Received inbound channel from `%s'\n",
3264 "Exit service is shutting down now\n");
3357 for (i = 0; i < 8; i++)
3383 slen = strlen (
name);
3387 for (redirect = strtok (cpy,
" ;"); redirect != NULL;
3388 redirect = strtok (NULL,
" ;"))
3390 if (NULL == (hostname = strstr (redirect,
":")))
3394 "Option `%s' for domain `%s' is not formatted correctly!\n")
3402 if (NULL == (hostport = strstr (hostname,
":")))
3406 "Option `%s' for domain `%s' is not formatted correctly!\n")
3415 local_port = atoi (redirect);
3418 if (! ((local_port > 0) && (local_port < 65536)))
3421 _ (
"`%s' is not a valid port number (for domain `%s')!"),
3429 _ (
"`%s' is not a valid port number (for domain `%s')!"),
3438 if (0 == strcmp (
"localhost4",
3448 else if (0 == strcmp (
"localhost6",
3460 struct addrinfo *
res;
3463 ret = getaddrinfo (hostname,
3467 if ((0 !=
ret) || (NULL ==
res))
3471 "No addresses found for hostname `%s' of service `%s'!\n")
3480 switch (
res->ai_family)
3487 "Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
3494 = ((
struct sockaddr_in *)
res->ai_addr)->sin_addr;
3502 "Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
3509 = ((
struct sockaddr_in6 *)
res->ai_addr)->sin6_addr;
3516 "No IP addresses found for hostname `%s' of service `%s'!\n"),
3541 const char *section)
3545 if ((strlen (section) < 8) ||
3546 (0 != strcmp (
".gnunet.", section + (strlen (section) - 8))))
3718 "This system does not support IPv4, will disable IPv4 functions despite them being enabled in the configuration\n"));
3727 "This system does not support IPv6, will disable IPv6 functions despite them being enabled in the configuration\n"));
3735 "Cannot enable IPv4 exit but disable IPv4 on TUN interface, will use ENABLE_IPv4=YES\n"));
3742 "Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n"));
3785 _ (
"need a valid IPv4 or IPv6 address\n"));
3794 "Opening CADET port %s for DNS exit service\n",
3868 (1 != inet_pton (AF_INET6,
3901 _ (
"Must be a number"));
3919 (1 != inet_pton (AF_INET,
3936 (1 != inet_pton (AF_INET,
3970 const char *cfgfile,
3996 char *prefixed_regex;
4008 "gnunet-helper-exit");
4014 "gnunet-vpn - - - 169.1.3.7 255.255.255.0"))
4020 "`%s' is not SUID or the path is invalid, EXIT will not work\n"),
4021 "gnunet-helper-exit");
4032 _ (
"No useful service enabled. Exiting.\n"));
4076 "Opening CADET port %s for IPv4 gateway service\n",
4089 "EXIT_RANGE_IPV4_POLICY",
4116 "Opening CADET port %s for IPv6 gateway service\n",
4129 "EXIT_RANGE_IPV6_POLICY",
4179 "gnunet-daemon-exit",
4181 "Daemon to run to provide an IP exit node for the VPN"),
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
int main()
Program to simulate results from GCP_get_desirability_of_path() for various plausible inputs.
format for cadet messages exchanged between VPN service and exit daemon
#define gettext_noop(String)
static int start
Set if we are to start default services (including ARM).
static int ret
Final status code.
static uint16_t port
Port number.
static char * address
GNS address for this phone.
static int check_udp_remote(void *cls, const struct GNUNET_EXIT_UdpInternetMessage *msg)
Check a request to forward UDP data to the Internet via this peer.
static int check_dns_request(void *cls, const struct DnsResponseMessage *msg)
Check a request via cadet to perform a DNS query.
static void udp_from_helper(const struct GNUNET_TUN_UdpHeader *udp, size_t pktlen, int af, const void *destination_ip, const void *source_ip)
Handles an UDP packet received from the helper.
static void do_initial_dht_put(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
static struct GNUNET_DHT_Handle * dht
Handle to the DHT.
static void send_udp_packet_via_tun(const struct SocketAddress *destination_address, const struct SocketAddress *source_address, const void *payload, size_t payload_length)
Send a UDP packet via the TUN interface.
static int ipv6_enabled
Do we support IPv6 at all on the TUN interface?
static int check_udp_service(void *cls, const struct GNUNET_EXIT_UdpServiceMessage *msg)
Check a request via cadet to send a request to a UDP service offered by this system.
static void make_up_icmpv4_payload(struct ChannelState *state, struct GNUNET_TUN_IPv4Header *ipp, struct GNUNET_TUN_UdpHeader *udp)
Synthesize a plausible ICMP payload for an ICMPv4 error response on the given channel.
static void clean_channel(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called by cadet whenever an inbound channel is destroyed.
static struct GNUNET_REGEX_Announcement * regex4
Handle to our regex announcement for IPv4.
static void send_packet_to_cadet_channel(struct ChannelState *s, struct GNUNET_MQ_Envelope *env)
Send the given packet via the cadet channel.
static int ipv4_enabled
Do we support IPv4 at all on the TUN interface?
static int check_tcp_service(void *cls, const struct GNUNET_EXIT_TcpServiceStartMessage *start)
Check a request via cadet to send a request to a TCP service offered by this system.
static void send_tcp_packet_via_tun(const struct SocketAddress *destination_address, const struct SocketAddress *source_address, const struct GNUNET_TUN_TcpHeader *tcp_header, const void *payload, size_t payload_length)
Send a TCP packet via the TUN interface.
static struct GNUNET_CONTAINER_MultiHashMap * services
This hashmaps saves interesting things about the configured services.
#define REGEX_MAX_PATH_LEN_IPV4
Maximum path compression length for cadet regex announcing for IPv4 address based regex.
#define DNS_ADVERTISEMENT_TIMEOUT
How long do we typically sign the DNS exit advertisement for?
static struct ChannelState * channels[UINT16_MAX+1]
Array of all open DNS requests from channels.
static unsigned long long ipv6prefix
IPv6 prefix (0..127) from configuration file.
#define REGEX_REFRESH_FREQUENCY
How frequently do we re-announce the regex for the exit?
static struct in6_addr exit_ipv6addr
IPv6 address of our TUN interface.
static struct ChannelState * get_redirect_state(int af, int protocol, const void *destination_ip, uint16_t destination_port, const void *local_ip, uint16_t local_port, struct GNUNET_HashCode *state_key)
Get our connection tracking state.
static void handle_icmp_service(void *cls, const struct GNUNET_EXIT_IcmpServiceMessage *msg)
Process a request via cadet to send ICMP data to a service offered by this system.
static void setup_fresh_address(int af, uint8_t proto, struct SocketAddress *local_address)
We need to create a (unique) fresh local address (IP+port).
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
static int global_ret
Return value from 'main'.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_)
Main function that will be run by the scheduler.
static struct GNUNET_STATISTICS_Handle * stats
Statistics.
static int setup_exit_helper_args()
Initialize exit_argv.
static const struct GNUNET_CONFIGURATION_Handle * cfg
The handle to the configuration used throughout the process.
static struct GNUNET_DNS_Advertisement dns_advertisement
Advertisement message we put into the DHT to advertise us as a DNS exit.
static void * new_service_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Callback from CADET for new channels.
static void prepare_ipv6_packet(const void *payload, size_t payload_length, int protocol, const struct GNUNET_TUN_TcpHeader *tcp_header, const struct SocketAddress *src_address, const struct SocketAddress *dst_address, struct GNUNET_TUN_IPv6Header *pkt6)
Prepare an IPv6 packet for transmission via the TUN interface.
static struct GNUNET_DNSSTUB_Context * dnsstub
Handle to the DNS Stub resolver.
static void send_icmp_packet_via_tun(const struct SocketAddress *destination_address, const struct SocketAddress *source_address, const struct GNUNET_TUN_IcmpHeader *icmp_header, const void *payload, size_t payload_length)
Send an ICMP packet via the TUN interface.
static void dht_put_cont(void *cls)
Function called when the DHT PUT operation is complete.
static int check_icmp_service(void *cls, const struct GNUNET_EXIT_IcmpServiceMessage *msg)
Check a request via cadet to send ICMP data to a service offered by this system.
static void store_service(int proto, const char *name, uint16_t destination_port, struct LocalService *service)
Given a service descriptor and a destination port, find the respective service entry.
static struct GNUNET_CONTAINER_MultiHashMap * connections_map
This hashmaps contains the mapping from peer, service-descriptor, source-port and destination-port to...
static int ipv6_exit
Are we an IPv6-exit?
static void icmp_from_helper(const struct GNUNET_TUN_IcmpHeader *icmp, size_t pktlen, int af, const void *destination_ip, const void *source_ip)
Handles an ICMP packet received from the helper.
static void add_services(int proto, char *cpy, const char *name)
Add services to the service map.
static struct GNUNET_CONTAINER_Heap * connections_heap
Heap so we can quickly find "old" connections.
static void tcp_from_helper(const struct GNUNET_TUN_TcpHeader *tcp, size_t pktlen, int af, const void *destination_ip, const void *source_ip)
Handles a TCP packet received from the helper.
static void prepare_ipv4_packet(const void *payload, size_t payload_length, int protocol, const struct GNUNET_TUN_TcpHeader *tcp_header, const struct SocketAddress *src_address, const struct SocketAddress *dst_address, struct GNUNET_TUN_IPv4Header *pkt4)
Prepare an IPv4 packet for transmission via the TUN interface.
static struct GNUNET_DHT_PutHandle * dht_put
Handle for ongoing DHT PUT operations to advertise exit service.
#define REGEX_MAX_PATH_LEN_IPV6
Maximum path compression length for cadet regex announcing for IPv6 address based regex.
static void hash_redirect_info(struct GNUNET_HashCode *hash, const struct RedirectInformation *ri)
Given IP information about a connection, calculate the respective hash we would use for the connectio...
static void handle_tcp_service(void *cls, const struct GNUNET_EXIT_TcpServiceStartMessage *start)
Process a request via cadet to send a request to a TCP service offered by this system.
static uint16_t make_up_icmp_service_payload(struct ChannelState *state, char *buf)
Setup ICMP payload for ICMP error messages.
static struct GNUNET_REGEX_Announcement * regex6
Handle to our regex announcement for IPv4.
static void handle_tcp_remote(void *cls, const struct GNUNET_EXIT_TcpInternetStartMessage *start)
Process a request to forward TCP data to the Internet via this peer.
static struct GNUNET_CADET_Handle * cadet_handle
The handle to cadet.
static void dummy_task(void *cls)
Function scheduled as very last function if the service disabled itself because the helper is not ins...
static void do_dht_put(void *cls)
We are running a DNS exit service, advertise it in the DHT.
static int message_token(void *cls, const struct GNUNET_MessageHeader *message)
Receive packets from the helper-process.
static void handle_icmp_remote(void *cls, const struct GNUNET_EXIT_IcmpInternetMessage *msg)
Process a request to forward ICMP data to the Internet via this peer.
static void handle_udp_service(void *cls, const struct GNUNET_EXIT_UdpServiceMessage *msg)
Process a request via cadet to send a request to a UDP service offered by this system.
static void handle_tcp_data(void *cls, const struct GNUNET_EXIT_TcpDataMessage *data)
Process a request to forward TCP data on an established connection via this peer.
static char * exit_argv[8]
Arguments to the exit helper.
static void read_service_conf(void *cls, const char *section)
Reads the configuration and populates #udp_services and #tcp_services.
static struct GNUNET_CADET_Port * cadet_port4
Port for IPv4 exit.
static GNUNET_NETWORK_STRUCT_END void process_dns_result(void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t r)
Callback called from DNSSTUB resolver when a resolution succeeded.
static struct in_addr exit_ipv4mask
IPv4 netmask of our TUN interface.
static void parse_ip_options()
Figure out which IP versions we should support (and which are supported by the OS) according to our c...
static struct in_addr exit_ipv4addr
IPv4 address of our TUN interface.
static int free_service_record(void *cls, const struct GNUNET_HashCode *key, void *value)
Free memory associated with a service record.
static struct GNUNET_HashCode dht_put_key
Key we store the DNS advertismenet under.
static void * new_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Callback from CADET for new channels.
#define LOG(kind,...)
Generic logging shorthand.
static int check_tcp_data(void *cls, const struct GNUNET_EXIT_TcpDataMessage *data)
Check a request to forward TCP data on an established connection via this peer.
static void sign_dns_advertisement(void *cls, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig)
#define DHT_PUT_FREQUENCY
How frequently do we re-announce the DNS exit in the DHT?
static int check_icmp_remote(void *cls, const struct GNUNET_EXIT_IcmpInternetMessage *msg)
Check a request to forward ICMP data to the Internet via this peer.
static struct GNUNET_PILS_Operation * sign_op
Operation for signing the dns advertisement.
static void handle_udp_remote(void *cls, const struct GNUNET_EXIT_UdpInternetMessage *msg)
Process a request to forward UDP data to the Internet via this peer.
static void setup_state_record(struct ChannelState *state)
We are starting a fresh connection (TCP or UDP) and need to pick a source port and IP address (within...
static struct GNUNET_CADET_Port * dns_port
Port for DNS exit.
static struct GNUNET_HELPER_Handle * helper_handle
The handle to the helper.
static int ipv4_exit
Are we an IPv4-exit?
static int free_iterate(void *cls, const struct GNUNET_HashCode *hash, void *value)
Function that frees everything from a hashmap.
static void advertise_dns_exit()
Helper function to open the CADET port for DNS exits and to advertise the DNS exit (if applicable).
static struct GNUNET_CADET_Port * cadet_port6
Port for IPv6 exit.
static struct GNUNET_SCHEDULER_Task * dht_task
Task for doing DHT PUTs to advertise exit service.
static int check_tcp_remote(void *cls, const struct GNUNET_EXIT_TcpInternetStartMessage *start)
Check a request to forward TCP data to the Internet via this peer.
static struct GNUNET_PILS_Handle * pils
The pils service handle.
static void make_up_icmpv6_payload(struct ChannelState *state, struct GNUNET_TUN_IPv6Header *ipp, struct GNUNET_TUN_UdpHeader *udp)
Synthesize a plausible ICMP payload for an ICMPv6 error response on the given channel.
static void handle_dns_request(void *cls, const struct DnsResponseMessage *msg)
Process a request via cadet to perform a DNS query.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static char * name
Name (label) of the records to list.
static int state
The current state of the parser.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static uint8_t proto
Protocol to use.
static struct GNUNET_NETWORK_Handle * ls
Listen socket for STUN processing.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
static unsigned long long payload
How much data are we currently storing in the database?
static struct GNUNET_CADET_Port * cadet_port
Listen port for incoming requests.
static void cleanup()
Cleanup task.
static unsigned long long remote_port
Remote host's port.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static int ipv4
Option -4: IPv4 requested.
static int udp
Option -u: UDP requested.
static int ipv6
Option -6: IPv6 requested.
static int tcp
Option -t: TCP requested.
Constants for network applications operating on top of the CADET service.
CADET service; establish channels to distant peers.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
@ GNUNET_BLOCK_TYPE_DNS
Block for storing DNS exit service advertisements.
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
struct GNUNET_PILS_Operation * GNUNET_PILS_sign_by_peer_identity(struct GNUNET_PILS_Handle *handle, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, GNUNET_PILS_SignResultCallback cb, void *cb_cls)
Sign data with the peer id.
const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity(const struct GNUNET_PILS_Handle *handle)
Return the current peer identity of a given handle.
Constants for network protocols.
API to access regex service to advertise capabilities via regex and discover respective peers using m...
#define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD
Signature on a GNUNET_DNS_Advertisement.
API to create, modify and access statistics.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX
Internet exit regex prefix.
#define GNUNET_APPLICATION_PORT_INTERNET_RESOLVER
Internet DNS resolution (external DNS gateway).
#define GNUNET_APPLICATION_PORT_IPV4_GATEWAY
Internet IPv4 gateway (any TCP/UDP/ICMP).
#define GNUNET_APPLICATION_PORT_IPV6_GATEWAY
Internet IPv6 gateway (any TCP/UDP/ICMP).
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected channel.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
@ GNUNET_DHT_RO_NONE
Default.
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start(unsigned int num_sockets)
Start a DNS stub resolver.
int GNUNET_DNSSTUB_add_dns_ip(struct GNUNET_DNSSTUB_Context *ctx, const char *dns_ip)
Add nameserver for use by the DNSSTUB.
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
struct GNUNET_DNSSTUB_RequestSocket * GNUNET_DNSSTUB_resolve(struct GNUNET_DNSSTUB_Context *ctx, const void *request, size_t request_len, GNUNET_DNSSTUB_ResultCallback rc, void *rc_cls)
Perform DNS resolution using our default IP from init.
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, bool can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(const struct GNUNET_OS_ProjectData *pd, int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
void GNUNET_HELPER_stop(struct GNUNET_HELPER_Handle *h, int soft_kill)
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_UNUSED
gcc-ism to document unused arguments
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
enum GNUNET_GenericReturnValue GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_OS_check_helper_binary(const char *binary, bool check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
char * GNUNET_OS_get_suid_binary_path(const struct GNUNET_OS_ProjectData *pd, const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname)
Given the name of a helper, service or daemon binary construct the full path to the binary using the ...
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
#define GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY
Type of messages containing an UDP packet from a remote host.
#define GNUNET_MESSAGE_TYPE_VPN_HELPER
Type of messages between the gnunet-vpn-helper and the daemon.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT
Type of messages containing an TCP packet of an established connection.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
Type of messages containing an ICMP packet for a service.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START
Type of messages containing an TCP packet for the Internet.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START
Type of messages containing an TCP packet for a service.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE
Type of messages containing an UDP packet for a service.
#define GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET
Type of messages containing an DNS request for a DNS exit service.
#define GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET
Type of messages containing an DNS reply from a DNS exit service.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
Type of messages containing an ICMP packet for the Internet.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN
Type of messages containing an TCP packet of an established connection.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET
Type of messages containing an UDP packet for the Internet.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN
Type of messages containing an ICMP packet for the VPN.
char * GNUNET_REGEX_ipv6policy2regex(const char *policy)
Convert an exit policy to a regular expression.
void GNUNET_REGEX_announce_cancel(struct GNUNET_REGEX_Announcement *a)
Stop announcing the regex specified by the given handle.
struct GNUNET_REGEX_Announcement * GNUNET_REGEX_announce(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *regex, struct GNUNET_TIME_Relative refresh_delay, uint16_t compression)
Announce this peer under the given regular expression.
char * GNUNET_REGEX_ipv4policy2regex(const char *policy)
Convert an exit policy to a regular expression.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
void GNUNET_TUN_initialize_ipv6_header(struct GNUNET_TUN_IPv6Header *ip, uint8_t protocol, uint16_t payload_length, const struct in6_addr *src, const struct in6_addr *dst)
Initialize an IPv6 header.
void GNUNET_TUN_calculate_udp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, struct GNUNET_TUN_UdpHeader *udp, const void *payload, uint16_t payload_length)
Calculate IPv4 UDP checksum.
GNUNET_NETWORK_STRUCT_END void GNUNET_TUN_initialize_ipv4_header(struct GNUNET_TUN_IPv4Header *ip, uint8_t protocol, uint16_t payload_length, const struct in_addr *src, const struct in_addr *dst)
Initialize an IPv4 header.
#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM
void GNUNET_TUN_calculate_icmp_checksum(struct GNUNET_TUN_IcmpHeader *icmp, const void *payload, uint16_t payload_length)
Calculate ICMP checksum.
#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST
#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED
#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY
#define ETH_P_IPV6
Number for IPv6.
void GNUNET_TUN_compute_service_cadet_port(const struct GNUNET_HashCode *desc, uint16_t ip_port, struct GNUNET_HashCode *cadet_port)
Compute the CADET port given a service descriptor (returned from GNUNET_TUN_service_name_to_hash) and...
#define ETH_P_IPV4
Number for IPv4.
#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED
void GNUNET_TUN_calculate_tcp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, struct GNUNET_TUN_TcpHeader *tcp, const void *payload, uint16_t payload_length)
Calculate IPv6 TCP checksum.
void GNUNET_TUN_service_name_to_hash(const char *service_name, struct GNUNET_HashCode *hc)
Hash the service name of a hosted service to the hash code that is used to identify the service on th...
#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE
#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH
void GNUNET_TUN_calculate_tcp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, struct GNUNET_TUN_TcpHeader *tcp, const void *payload, uint16_t payload_length)
Calculate IPv4 TCP checksum.
#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE
#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST
#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG
#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY
void GNUNET_TUN_calculate_udp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, struct GNUNET_TUN_UdpHeader *udp, const void *payload, uint16_t payload_length)
Calculate IPv6 UDP checksum.
static unsigned int size
Size of the "table".
This struct is saved into connections_map to allow finding the right channel given an IP packet from ...
struct LocalService * serv
Associated service record, or NULL for no service.
uint16_t my_id
DNS request ID that we used for forwarding.
struct GNUNET_HashCode state_key
Key this state has in the connections_map.
union ChannelState::@79 destination_ip
Destination IP address used by the source on our end (this is the IP that we pick freely within the V...
struct ChannelState::@54::@55 tcp_udp
struct GNUNET_DNSSTUB_RequestSocket * rs
Socket we are using to transmit this request (must match if we receive a response).
struct ChannelState::@54::@56 dns
int af
Address family used for this channel on the local TUN interface.
struct GNUNET_CADET_Channel * channel
Cadet channel that is used for this connection.
union ChannelState::@54 specifics
struct GNUNET_PeerIdentity peer
Who is the other end of this channel.
int is_dns
GNUNET_NO if this is a channel for TCP/UDP, GNUNET_YES if this is a channel for DNS,...
struct GNUNET_CONTAINER_HeapNode * heap_node
Heap node for this state in the connections_heap.
uint8_t protocol
IPPROTO_TCP or IPPROTO_UDP once bound.
uint16_t destination_port
Destination port used by the sender on our end; 0 for uninitialized.
uint16_t original_id
Original DNS request ID as used by the client.
struct RedirectInformation ri
Primary redirection information for this connection.
Message with a DNS response.
struct GNUNET_MessageHeader header
GNUnet header, of type GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET.
struct GNUNET_TUN_DnsHeader dns
DNS header.
Opaque handle to a channel.
Opaque handle to the service.
Handle to a node in a heap.
Internal representation of the hash map.
an ECC signature using EdDSA.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
Connection to the DHT service.
Handle to the stub resolver.
UDP socket we are using for sending DNS requests to the Internet.
This is the structure describing an DNS exit service.
struct GNUNET_PeerIdentity peer
The peer providing this service.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does this signature expire?
struct GNUNET_CRYPTO_SignaturePurpose purpose
Beginning of signed portion of the record, signs everything until the end of the struct.
struct GNUNET_CRYPTO_EddsaSignature signature
Signature of the peer affirming that it is offering the service.
Message send via cadet to an exit daemon to forward ICMP data to the Internet.
Message send via cadet to an exit daemon to send ICMP data to a local service.
Message send via cadet to the vpn service to send ICMP data to the VPN's TUN interface.
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
Message send via cadet between VPN and entry and an exit daemon to transmit TCP data between the VPN ...
uint32_t reserved
Always 0.
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
Message send via cadet to an exit daemon to initiate forwarding of TCP data to the Internet.
Message send via cadet to an exit daemon to initiate forwarding of TCP data to a local service.
Message send via cadet to an exit daemon to forward UDP data to the Internet.
Message send from exit daemon back to the UDP entry point (used for both Internet and Service exit re...
uint16_t source_port
Source port to use for the UDP reply (0 to use the same port as for the original request).
uint16_t destination_port
Destination port to use for the UDP reply (0 to use the same port as for the original request).
Message send via cadet to an exit daemon to send UDP data to a local service.
Definition of a command line option.
Context for parsing HELLOs.
The handle to a helper process.
Message handler for a specific message type.
A handle for the PILS service.
The identity of the host (wraps the signing key of the peer).
Handle to store cached data about a regex announce.
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
This struct is saved into the services-hashmap to represent a service this peer is specifically offer...
int16_t is_udp
GNUNET_YES if this is a UDP service, otherwise TCP.
struct GNUNET_CADET_Port * port
Open port with CADET.
struct SocketAddress address
Remote address to use for the service.
struct GNUNET_HashCode descriptor
Descriptor for the service (CADET port).
char * name
DNS name of the service.
Information about an address.
int af
AF_INET or AF_INET6.
union SocketAddress::@53 address
Remote address information.
uint8_t proto
IPPROTO_TCP or IPPROTO_UDP;.
struct in_addr ipv4
Address, if af is AF_INET.
uint16_t port
Remote port, in host byte order!
struct in6_addr ipv6
Address, if af is AF_INET6.
enum GNUNET_TIME_RounderInterval ri