44#include "gnunet_signatures.h"
54#define REGEX_MAX_PATH_LEN_IPV4 4
60#define REGEX_MAX_PATH_LEN_IPV6 8
65#define REGEX_REFRESH_FREQUENCY GNUNET_TIME_relative_multiply ( \
66 GNUNET_TIME_UNIT_MINUTES, 30)
71#define DHT_PUT_FREQUENCY GNUNET_TIME_relative_multiply ( \
72 GNUNET_TIME_UNIT_MINUTES, 15)
77#define DNS_ADVERTISEMENT_TIMEOUT GNUNET_TIME_relative_multiply ( \
78 GNUNET_TIME_UNIT_HOURS, 3)
84#define LOG(kind, ...) \
85 GNUNET_log_from (kind, "exit", __VA_ARGS__);
464 "Processing DNS result from stub resolver\n");
473 "Got a response from the stub resolver for DNS request received via CADET!\n");
526 size_t mlen = ntohs (
msg->header.
size);
587 sizeof(
struct in_addr));
588 off +=
sizeof(
struct in_addr);
594 sizeof(
struct in6_addr));
595 off +=
sizeof(
struct in_addr);
604 off +=
sizeof(uint16_t);
610 sizeof(
struct in_addr));
611 off +=
sizeof(
struct in_addr);
617 sizeof(
struct in6_addr));
618 off +=
sizeof(
struct in_addr);
627 off +=
sizeof(uint16_t);
653 const void *local_ip,
661 if (((
af == AF_INET) && (
protocol == IPPROTO_ICMP)) ||
662 ((
af == AF_INET6) && (
protocol == IPPROTO_ICMPV6)))
684 if (NULL != state_key)
691 if (NULL == state_key)
724 if (NULL ==
state->specifics.tcp_udp.serv)
729 if (NULL !=
state->specifics.tcp_udp.heap_node)
763 size_t payload_length,
772 len = payload_length;
808 pkt4_udp->
len = htons ((uint16_t) payload_length);
824 *pkt4_tcp = *tcp_header;
826 "Sending TCP packet from port %u to port %u\n",
867 size_t payload_length,
876 len = payload_length;
891 if (len > UINT16_MAX)
912 pkt6_udp->
len = htons ((uint16_t) payload_length);
929 *pkt6_tcp = *tcp_header;
963 size_t payload_length)
972 "Sending packet with %u bytes TCP payload via TUN\n",
973 (
unsigned int) payload_length);
976 switch (source_address->
af)
991 len += payload_length;
1004 hdr->
size = htons (len);
1006 tun->
flags = htons (0);
1007 switch (source_address->
af)
1077 "Sending packet with %u bytes ICMP payload via TUN\n",
1078 (
unsigned int) payload_length);
1081 switch (destination_address->
af)
1096 len += payload_length;
1109 hdr->
size = htons (len);
1111 tun->
flags = htons (0);
1112 switch (source_address->
af)
1152 *icmp = *icmp_header;
1181 local_address->
af = af;
1185 if (((af == AF_INET) && (
proto == IPPROTO_ICMP)) ||
1186 ((af == AF_INET6) && (
proto == IPPROTO_ICMPV6)))
1187 local_address->
port = 0;
1196 struct in_addr addr;
1197 struct in_addr mask;
1202 if (0 == ~mask.s_addr)
1210 mask.s_addr = addr.s_addr | ~mask.s_addr;
1216 local_address->
address.
ipv4.s_addr = (addr.s_addr | rnd.s_addr)
1219 while ((local_address->
address.
ipv4.s_addr == addr.s_addr) ||
1220 (local_address->
address.
ipv4.s_addr == mask.s_addr));
1226 struct in6_addr addr;
1227 struct in6_addr mask;
1228 struct in6_addr rnd;
1243 mask.s6_addr[i / 8] |= (1 << (i % 8));
1248 for (i = 0; i < 16; i++)
1254 = (addr.s6_addr[i] | rnd.s6_addr[i]) & mask.s6_addr[i];
1300 if (NULL ==
state->specifics.tcp_udp.serv)
1302 state->specifics.tcp_udp.ri.remote_address.proto,
1303 &
state->specifics.tcp_udp.ri.local_address);
1306 state->specifics.tcp_udp.serv->address.proto,
1307 &
state->specifics.tcp_udp.ri.local_address);
1311 state->specifics.tcp_udp.ri.remote_address.proto,
1312 &
state->specifics.tcp_udp.ri.remote_address.address
1314 state->specifics.tcp_udp.ri.remote_address.port,
1315 &
state->specifics.tcp_udp.ri.local_address.address,
1316 state->specifics.tcp_udp.ri.local_address.port,
1319 char buf[INET6_ADDRSTRLEN];
1321 "Picked local address %s:%u for new connection\n",
1322 inet_ntop (
state->specifics.tcp_udp.ri.local_address.af,
1323 &
state->specifics.tcp_udp.ri.local_address.address,
1326 (
unsigned int)
state->specifics.tcp_udp.ri.local_address.port);
1328 state->specifics.tcp_udp.state_key =
key;
1333 state->specifics.tcp_udp.heap_node
1364 const void *
payload,
size_t payload_length)
1372 "Sending packet with %u bytes UDP payload via TUN\n",
1373 (
unsigned int) payload_length);
1376 switch (source_address->
af)
1391 len += payload_length;
1404 hdr->
size = htons (len);
1406 tun->
flags = htons (0);
1407 switch (source_address->
af)
1488 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
1490 const struct in_addr *v4;
1491 const struct in6_addr *v6;
1505 "# UDP IP-exit requests received via cadet"),
1507 af = (
int) ntohl (
msg->af);
1508 state->specifics.tcp_udp.ri.remote_address.af = af;
1512 if (pkt_len <
sizeof(
struct in_addr))
1522 v4 = (
const struct in_addr*) &
msg[1];
1524 pkt_len -=
sizeof(
struct in_addr);
1525 state->specifics.tcp_udp.ri.remote_address.address.ipv4 = *v4;
1529 if (pkt_len <
sizeof(
struct in6_addr))
1539 v6 = (
const struct in6_addr*) &
msg[1];
1541 pkt_len -=
sizeof(
struct in6_addr);
1542 state->specifics.tcp_udp.ri.remote_address.address.ipv6 = *v6;
1550 char buf[INET6_ADDRSTRLEN];
1552 "Received data from %s for forwarding to UDP %s:%u\n",
1555 &
state->specifics.tcp_udp.ri.remote_address.address,
1557 (
unsigned int) ntohs (
msg->destination_port));
1559 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_UDP;
1560 state->specifics.tcp_udp.ri.remote_address.port =
msg->destination_port;
1561 if (NULL ==
state->specifics.tcp_udp.heap_node)
1563 if (0 != ntohs (
msg->source_port))
1564 state->specifics.tcp_udp.ri.local_address.port =
msg->source_port;
1566 &
state->specifics.tcp_udp.ri.local_address,
1588 if (NULL ==
state->specifics.tcp_udp.serv)
1609 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
1617 "# UDP service requests received via cadet"),
1620 "Received data from %s for forwarding to UDP service %s on port %u\n",
1623 (
unsigned int) ntohs (
msg->destination_port));
1625 if (0 != ntohs (
msg->source_port))
1626 state->specifics.tcp_udp.ri.local_address.port =
msg->source_port;
1628 &
state->specifics.tcp_udp.ri.local_address,
1649 uint16_t pkt_len = ntohs (
start->header.size) -
sizeof(
struct
1659 "# TCP service creation requests received via cadet"),
1669 "Received data from %s for forwarding to TCP service %s on port %u\n",
1672 (
unsigned int) ntohs (
start->tcp_header.destination_port));
1675 &
state->specifics.tcp_udp.ri.local_address,
1707 if ((NULL !=
state->specifics.tcp_udp.serv) ||
1708 (NULL !=
state->specifics.tcp_udp.heap_node))
1733 uint16_t pkt_len = ntohs (
start->header.size) -
sizeof(
struct
1735 const struct in_addr *v4;
1736 const struct in6_addr *v6;
1750 "# TCP IP-exit creation requests received via cadet"),
1753 state->specifics.tcp_udp.ri.remote_address.af = af;
1757 if (pkt_len <
sizeof(
struct in_addr))
1767 v4 = (
const struct in_addr*) &
start[1];
1769 pkt_len -=
sizeof(
struct in_addr);
1770 state->specifics.tcp_udp.ri.remote_address.address.ipv4 = *v4;
1774 if (pkt_len <
sizeof(
struct in6_addr))
1784 v6 = (
const struct in6_addr*) &
start[1];
1786 pkt_len -=
sizeof(
struct in6_addr);
1787 state->specifics.tcp_udp.ri.remote_address.address.ipv6 = *v6;
1795 char buf[INET6_ADDRSTRLEN];
1797 "Received payload from %s for existing TCP stream to %s:%u\n",
1800 &
state->specifics.tcp_udp.ri.remote_address.address,
1802 (
unsigned int) ntohs (
start->tcp_header.destination_port));
1804 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_TCP;
1805 state->specifics.tcp_udp.ri.remote_address.port = ntohs (
1806 start->tcp_header.destination_port);
1809 &
state->specifics.tcp_udp.ri.local_address,
1832 if ((NULL ==
state) ||
1833 (NULL ==
state->specifics.tcp_udp.heap_node))
1838 "# TCP DATA requests dropped (no session)"),
1869 uint16_t pkt_len = ntohs (
data->header.size) -
sizeof(
struct
1877 "# TCP data requests received via cadet"),
1887 char buf[INET6_ADDRSTRLEN];
1889 "Received additional %u bytes of data from %s for TCP stream to %s:%u\n",
1892 inet_ntop (
state->specifics.tcp_udp.ri.remote_address.af,
1893 &
state->specifics.tcp_udp.ri.remote_address.address,
1895 (
unsigned int)
state->specifics.tcp_udp.ri.remote_address.port);
1899 &
state->specifics.tcp_udp.ri.local_address,
1921 state->specifics.tcp_udp.ri.remote_address.
1924 &
state->specifics.tcp_udp.ri.remote_address
1926 &
state->specifics.tcp_udp.ri.local_address.
1928 udp->source_port = htons (
state->specifics.tcp_udp.ri.remote_address.port);
1929 udp->destination_port = htons (
1930 state->specifics.tcp_udp.ri.local_address.port);
1931 udp->len = htons (0);
1932 udp->crc = htons (0);
1951 state->specifics.tcp_udp.ri.remote_address.
1954 &
state->specifics.tcp_udp.ri.remote_address
1956 &
state->specifics.tcp_udp.ri.local_address.
1958 udp->source_port = htons (
state->specifics.tcp_udp.ri.remote_address.port);
1959 udp->destination_port = htons (
1960 state->specifics.tcp_udp.ri.local_address.port);
1961 udp->len = htons (0);
1962 udp->crc = htons (0);
2000 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
2002 const struct in_addr *v4;
2003 const struct in6_addr *v6;
2018 "# ICMP IP-exit requests received via cadet"),
2021 af = (
int) ntohl (
msg->af);
2022 if ((NULL !=
state->specifics.tcp_udp.heap_node) &&
2023 (af !=
state->specifics.tcp_udp.ri.remote_address.af))
2033 if (pkt_len <
sizeof(
struct in_addr))
2043 v4 = (
const struct in_addr*) &
msg[1];
2045 pkt_len -=
sizeof(
struct in_addr);
2046 state->specifics.tcp_udp.ri.remote_address.address.ipv4 = *v4;
2047 if (NULL ==
state->specifics.tcp_udp.heap_node)
2049 state->specifics.tcp_udp.ri.remote_address.af = af;
2050 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMP;
2055 switch (
msg->icmp_header.
type)
2089 "# ICMPv4 packets dropped (type not allowed)")
2098 if (pkt_len <
sizeof(
struct in6_addr))
2108 v6 = (
const struct in6_addr*) &
msg[1];
2110 pkt_len -=
sizeof(
struct in6_addr);
2111 state->specifics.tcp_udp.ri.remote_address.address.ipv6 = *v6;
2112 if (NULL ==
state->specifics.tcp_udp.heap_node)
2114 state->specifics.tcp_udp.ri.remote_address.af = af;
2115 state->specifics.tcp_udp.ri.remote_address.proto = IPPROTO_ICMPV6;
2120 switch (
msg->icmp_header.
type)
2155 "# ICMPv6 packets dropped (type not allowed)")
2170 char buf_tmp[INET6_ADDRSTRLEN];
2172 "Received ICMP data from %s for forwarding to %s\n",
2175 &
state->specifics.tcp_udp.ri.remote_address.address,
2176 buf_tmp,
sizeof(buf_tmp)));
2179 &
state->specifics.tcp_udp.ri.local_address,
2199 switch (
state->specifics.tcp_udp.serv->address.af)
2258 if (NULL ==
state->specifics.tcp_udp.serv)
2279 uint16_t pkt_len = ntohs (
msg->header.
size) -
sizeof(
struct
2290 "# ICMP service requests received via cadet"),
2294 "Received data from %s for forwarding to ICMP service %s\n",
2297 icmp =
msg->icmp_header;
2299 state->specifics.tcp_udp.ri.remote_address
2300 =
state->specifics.tcp_udp.serv->address;
2308 switch (
msg->icmp_header.
type)
2311 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2316 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2321 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2333 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2345 if (
state->specifics.tcp_udp.serv->address.af == AF_INET6)
2349 "# ICMPv4 packets dropped (impossible PT to v6)"),
2366 "# ICMPv4 packets dropped (type not allowed)")
2375 switch (
msg->icmp_header.
type)
2378 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2383 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2388 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2400 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2413 if (
state->specifics.tcp_udp.serv->address.af == AF_INET)
2417 "# ICMPv6 packets dropped (impossible PT to v4)"),
2434 "# ICMPv6 packets dropped (type not allowed)")
2448 &
state->specifics.tcp_udp.ri.local_address,
2498 s->
peer = *initiator;
2504 "Received inbound channel from `%s'\n",
2527 "Channel destroyed\n");
2599 "Opening CADET port %s for SERVICE exit %s on port %u\n",
2602 (
unsigned int) destination_port);
2621 _ (
"Got duplicate service records for `%s:%u'\n"),
2623 (
unsigned int) destination_port);
2641 "# Messages transmitted via cadet channels"),
2664 const void *destination_ip,
2665 const void *source_ip)
2678 char sbuf[INET6_ADDRSTRLEN];
2679 char dbuf[INET6_ADDRSTRLEN];
2681 "Received ICMP packet going from %s to %s\n",
2684 sbuf,
sizeof(sbuf)),
2687 dbuf,
sizeof(dbuf)));
2705 protocol = IPPROTO_ICMP;
2738 "# ICMPv4 packets dropped (type not allowed)")
2746 protocol = IPPROTO_ICMPV6;
2762 protocol =
ipv6->next_header;
2780 "# ICMPv6 packets dropped (type not allowed)")
2802 case IPPROTO_ICMPV6:
2835 "# ICMP packets dropped (not allowed)"),
2844 "ICMP Packet dropped, have no matching connection information\n"));
2850 i2v->
af = htonl (af);
2874 const void *destination_ip,
2875 const void *source_ip)
2882 char sbuf[INET6_ADDRSTRLEN];
2883 char dbuf[INET6_ADDRSTRLEN];
2886 "Received UDP packet going from %s:%u to %s:%u\n",
2889 sbuf,
sizeof(sbuf)),
2890 (
unsigned int) ntohs (
udp->source_port),
2893 dbuf,
sizeof(dbuf)),
2894 (
unsigned int) ntohs (
udp->destination_port));
2903 if (pktlen != ntohs (
udp->len))
2912 ntohs (
udp->source_port),
2914 ntohs (
udp->destination_port),
2920 "UDP Packet dropped, have no matching connection information\n"));
2951 const void *destination_ip,
2952 const void *source_ip)
2962 char sbuf[INET6_ADDRSTRLEN];
2963 char dbuf[INET6_ADDRSTRLEN];
2965 "Received TCP packet with %u bytes going from %s:%u to %s:%u\n",
2969 sbuf,
sizeof(sbuf)),
2970 (
unsigned int) ntohs (
tcp->source_port),
2973 dbuf,
sizeof(dbuf)),
2974 (
unsigned int) ntohs (
tcp->destination_port));
2986 ntohs (
tcp->source_port),
2988 ntohs (
tcp->destination_port),
2994 "TCP Packet dropped, have no matching connection information\n"));
3039 "Got %u-byte message of type %u from gnunet-helper-exit\n",
3040 ntohs (message->
size),
3041 ntohs (message->
type));
3063 switch (ntohs (pkt_tun->
proto))
3085 _ (
"IPv4 packet options received. Ignored.\n"));
3095 &pkt4->destination_address,
3096 &pkt4->source_address);
3102 &pkt4->destination_address,
3103 &pkt4->source_address);
3109 &pkt4->destination_address,
3110 &pkt4->source_address);
3116 "IPv4 packet with unsupported next header %u received. Ignored.\n"),
3117 (
int) pkt4->protocol);
3147 &pkt6->destination_address,
3148 &pkt6->source_address);
3154 &pkt6->destination_address,
3155 &pkt6->source_address);
3158 case IPPROTO_ICMPV6:
3161 &pkt6->destination_address,
3162 &pkt6->source_address);
3168 "IPv6 packet with unsupported next header %d received. Ignored.\n"),
3177 _ (
"Packet from unknown protocol %u received. Ignored.\n"),
3178 ntohs (pkt_tun->
proto));
3201 s->
peer = *initiator;
3207 "Received inbound channel from `%s'\n",
3257 "Exit service is shutting down now\n");
3345 for (i = 0; i < 8; i++)
3371 slen = strlen (
name);
3375 for (redirect = strtok (cpy,
" ;"); redirect != NULL;
3376 redirect = strtok (NULL,
" ;"))
3378 if (NULL == (hostname = strstr (redirect,
":")))
3382 "Option `%s' for domain `%s' is not formatted correctly!\n")
3390 if (NULL == (hostport = strstr (hostname,
":")))
3394 "Option `%s' for domain `%s' is not formatted correctly!\n")
3403 local_port = atoi (redirect);
3406 if (! ((local_port > 0) && (local_port < 65536)))
3409 _ (
"`%s' is not a valid port number (for domain `%s')!"),
3417 _ (
"`%s' is not a valid port number (for domain `%s')!"),
3426 if (0 == strcmp (
"localhost4",
3436 else if (0 == strcmp (
"localhost6",
3448 struct addrinfo *
res;
3451 ret = getaddrinfo (hostname,
3455 if ((0 !=
ret) || (NULL ==
res))
3459 "No addresses found for hostname `%s' of service `%s'!\n")
3468 switch (
res->ai_family)
3475 "Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
3482 = ((
struct sockaddr_in *)
res->ai_addr)->sin_addr;
3490 "Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
3497 = ((
struct sockaddr_in6 *)
res->ai_addr)->sin6_addr;
3504 "No IP addresses found for hostname `%s' of service `%s'!\n"),
3529 const char *section)
3533 if ((strlen (section) < 8) ||
3534 (0 != strcmp (
".gnunet.", section + (strlen (section) - 8))))
3649 "This system does not support IPv4, will disable IPv4 functions despite them being enabled in the configuration\n"));
3658 "This system does not support IPv6, will disable IPv6 functions despite them being enabled in the configuration\n"));
3666 "Cannot enable IPv4 exit but disable IPv4 on TUN interface, will use ENABLE_IPv4=YES\n"));
3673 "Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n"));
3716 _ (
"need a valid IPv4 or IPv6 address\n"));
3725 "Opening CADET port %s for DNS exit service\n",
3812 (1 != inet_pton (AF_INET6,
3845 _ (
"Must be a number"));
3863 (1 != inet_pton (AF_INET,
3880 (1 != inet_pton (AF_INET,
3914 const char *cfgfile,
3940 char *prefixed_regex;
3952 "gnunet-helper-exit");
3958 "gnunet-vpn - - - 169.1.3.7 255.255.255.0"))
3964 "`%s' is not SUID or the path is invalid, EXIT will not work\n"),
3965 "gnunet-helper-exit");
3976 _ (
"No useful service enabled. Exiting.\n"));
4020 "Opening CADET port %s for IPv4 gateway service\n",
4033 "EXIT_RANGE_IPV4_POLICY",
4060 "Opening CADET port %s for IPv6 gateway service\n",
4073 "EXIT_RANGE_IPV6_POLICY",
4123 "gnunet-daemon-exit",
4125 "Daemon to run to provide an IP exit node for the VPN"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
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 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 cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
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 struct GNUNET_CRYPTO_EddsaPrivateKey * peer_key
Private key for this peer.
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.
int main(int argc, char *const *argv)
The main function.
#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 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 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 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.
enum State state
current state of profiling
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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 unsigned long long remote_port
Remote host's port.
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.
Constants for network protocols.
API to access regex service to advertise capabilities via regex and discover respective peers using m...
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.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration.
@ 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.
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".
@ GNUNET_BLOCK_TYPE_DNS
Block for storing DNS exit service advertisements.
#define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD
Signature on a GNUNET_DNS_Advertisement.
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.
struct ChannelState::@46::@47 tcp_udp
union ChannelState::@71 destination_ip
Destination IP address used by the source on our end (this is the IP that we pick freely within the V...
struct GNUNET_DNSSTUB_RequestSocket * rs
Socket we are using to transmit this request (must match if we receive a response).
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.
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 ChannelState::@46::@48 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.
union ChannelState::@46 specifics
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.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Private ECC key encoded for transmission.
an ECC signature using EdDSA.
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_EddsaSignature signature
Signature of the peer affirming that it is offering the service.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Beginning of signed portion of the record, signs everything until the end of the struct.
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.
The handle to a helper process.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Handle to store cached data about a regex announce.
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
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::@45 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.