58 #define REGEX_MAX_PATH_LEN_IPV4 4 64 #define REGEX_MAX_PATH_LEN_IPV6 8 69 #define REGEX_REFRESH_FREQUENCY GNUNET_TIME_relative_multiply ( \ 70 GNUNET_TIME_UNIT_MINUTES, 30) 75 #define DHT_PUT_FREQUENCY GNUNET_TIME_relative_multiply ( \ 76 GNUNET_TIME_UNIT_MINUTES, 15) 81 #define DNS_ADVERTISEMENT_TIMEOUT GNUNET_TIME_relative_multiply ( \ 82 GNUNET_TIME_UNIT_HOURS, 3) 88 #define LOG(kind, ...) \ 89 GNUNET_log_from (kind, "exit", __VA_ARGS__); 468 "Processing DNS result from stub resolver\n");
473 ts = channels[dns->
id];
477 "Got a response from the stub resolver for DNS request received via CADET!\n");
478 channels[dns->
id] = NULL;
591 sizeof(
struct in_addr));
592 off +=
sizeof(
struct in_addr);
598 sizeof(
struct in6_addr));
599 off +=
sizeof(
struct in_addr);
608 off +=
sizeof(uint16_t);
614 sizeof(
struct in_addr));
615 off +=
sizeof(
struct in_addr);
621 sizeof(
struct in6_addr));
622 off +=
sizeof(
struct in_addr);
631 off +=
sizeof(uint16_t);
657 const void *local_ip,
665 if (((af == AF_INET) && (protocol == IPPROTO_ICMP)) ||
666 ((af == AF_INET6) && (protocol == IPPROTO_ICMPV6)))
669 destination_port = 0;
688 if (NULL != state_key)
695 if (NULL == state_key)
766 size_t payload_length,
775 len = payload_length;
811 pkt4_udp->
len = htons ((uint16_t) payload_length);
827 *pkt4_tcp = *tcp_header;
829 "Sending TCP packet from port %u to port %u\n",
870 size_t payload_length,
879 len = payload_length;
894 if (len > UINT16_MAX)
915 pkt6_udp->
len = htons ((uint16_t) payload_length);
932 *pkt6_tcp = *tcp_header;
966 size_t payload_length)
975 "Sending packet with %u bytes TCP payload via TUN\n",
976 (
unsigned int) payload_length);
978 GNUNET_TUN_Layer2PacketHeader);
979 switch (source_address->
af)
994 len += payload_length;
1003 struct GNUNET_TUN_Layer2PacketHeader *tun;
1007 hdr->
size = htons (len);
1008 tun = (
struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1];
1009 tun->
flags = htons (0);
1010 switch (source_address->
af)
1023 destination_address,
1039 destination_address,
1048 if (NULL != helper_handle)
1080 "Sending packet with %u bytes ICMP payload via TUN\n",
1081 (
unsigned int) payload_length);
1083 GNUNET_TUN_Layer2PacketHeader);
1084 switch (destination_address->
af)
1099 len += payload_length;
1108 struct GNUNET_TUN_Layer2PacketHeader *tun;
1112 hdr->
size = htons (len);
1113 tun = (
struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1];
1114 tun->
flags = htons (0);
1115 switch (source_address->
af)
1155 *icmp = *icmp_header;
1162 if (NULL != helper_handle)
1184 local_address->
af =
af;
1185 local_address->
proto = (uint8_t) proto;
1188 if (((af == AF_INET) && (proto == IPPROTO_ICMP)) ||
1189 ((af == AF_INET6) && (proto == IPPROTO_ICMPV6)))
1190 local_address->
port = 0;
1199 struct in_addr addr;
1200 struct in_addr mask;
1205 if (0 == ~mask.s_addr)
1213 mask.s_addr = addr.s_addr | ~mask.s_addr;
1219 local_address->
address.
ipv4.s_addr = (addr.s_addr | rnd.s_addr)
1222 while ((local_address->
address.
ipv4.s_addr == addr.s_addr) ||
1223 (local_address->
address.
ipv4.s_addr == mask.s_addr));
1229 struct in6_addr addr;
1230 struct in6_addr mask;
1231 struct in6_addr rnd;
1246 mask.s6_addr[i / 8] |= (1 << (i % 8));
1251 for (i = 0; i < 16; i++)
1257 = (addr.s6_addr[i] | rnd.s6_addr[i]) & mask.s6_addr[i];
1321 char buf[INET6_ADDRSTRLEN];
1323 "Picked local address %s:%u for new connection\n",
1366 const void *
payload,
size_t payload_length)
1374 "Sending packet with %u bytes UDP payload via TUN\n",
1375 (
unsigned int) payload_length);
1377 GNUNET_TUN_Layer2PacketHeader);
1378 switch (source_address->
af)
1393 len += payload_length;
1402 struct GNUNET_TUN_Layer2PacketHeader *tun;
1406 hdr->
size = htons (len);
1407 tun = (
struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1];
1408 tun->
flags = htons (0);
1409 switch (source_address->
af)
1422 destination_address,
1438 destination_address,
1447 if (NULL != helper_handle)
1490 uint16_t pkt_len = ntohs (msg->
header.
size) -
sizeof(
struct 1492 const struct in_addr *v4;
1493 const struct in6_addr *v6;
1507 "# UDP IP-exit requests received via cadet"),
1509 af = (int) ntohl (msg->
af);
1514 if (pkt_len <
sizeof(
struct in_addr))
1524 v4 = (
const struct in_addr*) &msg[1];
1526 pkt_len -=
sizeof(
struct in_addr);
1531 if (pkt_len <
sizeof(
struct in6_addr))
1541 v6 = (
const struct in6_addr*) &msg[1];
1543 pkt_len -=
sizeof(
struct in6_addr);
1552 char buf[INET6_ADDRSTRLEN];
1554 "Received data from %s for forwarding to UDP %s:%u\n",
1611 uint16_t pkt_len = ntohs (msg->
header.
size) -
sizeof(
struct 1619 "# UDP service requests received via cadet"),
1622 "Received data from %s for forwarding to UDP service %s on port %u\n",
1651 uint16_t pkt_len = ntohs (start->
header.
size) -
sizeof(
struct 1661 "# TCP service creation requests received via cadet"),
1671 "Received data from %s for forwarding to TCP service %s on port %u\n",
1735 uint16_t pkt_len = ntohs (start->
header.
size) -
sizeof(
struct 1737 const struct in_addr *v4;
1738 const struct in6_addr *v6;
1752 "# TCP IP-exit creation requests received via cadet"),
1754 af = (int) ntohl (start->
af);
1759 if (pkt_len <
sizeof(
struct in_addr))
1769 v4 = (
const struct in_addr*) &start[1];
1771 pkt_len -=
sizeof(
struct in_addr);
1776 if (pkt_len <
sizeof(
struct in6_addr))
1786 v6 = (
const struct in6_addr*) &start[1];
1788 pkt_len -=
sizeof(
struct in6_addr);
1797 char buf[INET6_ADDRSTRLEN];
1799 "Received payload from %s for existing TCP stream to %s:%u\n",
1834 if ((NULL == state) ||
1840 "# TCP DATA requests dropped (no session)"),
1871 uint16_t pkt_len = ntohs (data->
header.
size) -
sizeof(
struct 1879 "# TCP data requests received via cadet"),
1889 char buf[INET6_ADDRSTRLEN];
1891 "Received additional %u bytes of data from %s for TCP stream to %s:%u\n",
1933 udp->
len = htons (0);
1934 udp->
crc = htons (0);
1963 udp->
len = htons (0);
1964 udp->
crc = htons (0);
2002 uint16_t pkt_len = ntohs (msg->
header.
size) -
sizeof(
struct 2004 const struct in_addr *v4;
2005 const struct in6_addr *v6;
2020 "# ICMP IP-exit requests received via cadet"),
2023 af = (int) ntohl (msg->
af);
2035 if (pkt_len <
sizeof(
struct in_addr))
2045 v4 = (
const struct in_addr*) &msg[1];
2047 pkt_len -=
sizeof(
struct in_addr);
2091 "# ICMPv4 packets dropped (type not allowed)"),
2099 if (pkt_len <
sizeof(
struct in6_addr))
2109 v6 = (
const struct in6_addr*) &msg[1];
2111 pkt_len -=
sizeof(
struct in6_addr);
2156 "# ICMPv6 packets dropped (type not allowed)"),
2170 char buf[INET6_ADDRSTRLEN];
2172 "Received ICMP data from %s for forwarding to %s\n",
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",
2349 "# ICMPv4 packets dropped (impossible PT to v6)"),
2366 "# ICMPv4 packets dropped (type not allowed)"),
2416 "# ICMPv6 packets dropped (impossible PT to v4)"),
2433 "# ICMPv6 packets dropped (type not allowed)"),
2496 s->
peer = *initiator;
2502 "Received inbound channel from `%s'\n",
2525 "Channel destroyed\n");
2597 "Opening CADET port %s for SERVICE exit %s on port %u\n",
2600 (
unsigned int) destination_port);
2619 _ (
"Got duplicate service records for `%s:%u'\n"),
2621 (
unsigned int) destination_port);
2639 "# Messages transmitted via cadet channels"),
2662 const void *destination_ip,
2663 const void *source_ip)
2676 char sbuf[INET6_ADDRSTRLEN];
2677 char dbuf[INET6_ADDRSTRLEN];
2679 "Received ICMP packet going from %s to %s\n",
2682 sbuf,
sizeof(sbuf)),
2685 dbuf,
sizeof(dbuf)));
2699 destination_port = 0;
2703 protocol = IPPROTO_ICMP;
2736 "# ICMPv4 packets dropped (type not allowed)"),
2743 protocol = IPPROTO_ICMPV6;
2777 "# ICMPv6 packets dropped (type not allowed)"),
2798 case IPPROTO_ICMPV6:
2831 "# ICMP packets dropped (not allowed)"),
2840 "ICMP Packet dropped, have no matching connection information\n"));
2846 i2v->
af = htonl (af);
2870 const void *destination_ip,
2871 const void *source_ip)
2878 char sbuf[INET6_ADDRSTRLEN];
2879 char dbuf[INET6_ADDRSTRLEN];
2882 "Received UDP packet going from %s:%u to %s:%u\n",
2885 sbuf,
sizeof(sbuf)),
2889 dbuf,
sizeof(dbuf)),
2899 if (pktlen != ntohs (udp->
len))
2916 "UDP Packet dropped, have no matching connection information\n"));
2947 const void *destination_ip,
2948 const void *source_ip)
2958 char sbuf[INET6_ADDRSTRLEN];
2959 char dbuf[INET6_ADDRSTRLEN];
2961 "Received TCP packet with %u bytes going from %s:%u to %s:%u\n",
2965 sbuf,
sizeof(sbuf)),
2969 dbuf,
sizeof(dbuf)),
2990 "TCP Packet dropped, have no matching connection information\n"));
3003 GNUNET_TUN_TcpHeader));
3010 pktlen -
sizeof(
struct GNUNET_TUN_TcpHeader),
3035 "Got %u-byte message of type %u from gnunet-helper-exit\n",
3036 ntohs (message->
size),
3037 ntohs (message->
type));
3046 size = ntohs (message->
size);
3058 GNUNET_MessageHeader);
3059 switch (ntohs (pkt_tun->
proto))
3081 _ (
"IPv4 packet options received. Ignored.\n"));
3091 &pkt4->destination_address,
3092 &pkt4->source_address);
3098 &pkt4->destination_address,
3099 &pkt4->source_address);
3105 &pkt4->destination_address,
3106 &pkt4->source_address);
3112 "IPv4 packet with unsupported next header %u received. Ignored.\n"),
3113 (
int) pkt4->protocol);
3143 &pkt6->destination_address,
3144 &pkt6->source_address);
3150 &pkt6->destination_address,
3151 &pkt6->source_address);
3154 case IPPROTO_ICMPV6:
3157 &pkt6->destination_address,
3158 &pkt6->source_address);
3164 "IPv6 packet with unsupported next header %d received. Ignored.\n"),
3173 _ (
"Packet from unknown protocol %u received. Ignored.\n"),
3174 ntohs (pkt_tun->
proto));
3197 s->
peer = *initiator;
3203 "Received inbound channel from `%s'\n",
3254 "Exit service is shutting down now\n");
3256 if (NULL != helper_handle)
3259 helper_handle = NULL;
3271 if (NULL != services)
3278 if (NULL != dns_port)
3283 if (NULL != cadet_port4)
3288 if (NULL != cadet_port6)
3293 if (NULL != cadet_handle)
3296 cadet_handle = NULL;
3298 if (NULL != connections_map)
3304 connections_map = NULL;
3306 if (NULL != connections_heap)
3309 connections_heap = NULL;
3311 if (NULL != dnsstub)
3316 if (NULL != peer_key)
3321 if (NULL != dht_task)
3326 if (NULL != dht_put)
3342 for (i = 0; i < 8; i++)
3366 slen = strlen (name);
3370 for (redirect = strtok (cpy,
" ;"); redirect != NULL;
3371 redirect = strtok (NULL,
" ;"))
3373 if (NULL == (hostname = strstr (redirect,
":")))
3377 "Option `%s' for domain `%s' is not formatted correctly!\n"),
3384 if (NULL == (hostport = strstr (hostname,
":")))
3388 "Option `%s' for domain `%s' is not formatted correctly!\n"),
3396 int local_port = atoi (redirect);
3399 if (! ((local_port > 0) && (local_port < 65536)))
3402 _ (
"`%s' is not a valid port number (for domain `%s')!"),
3407 if (! ((remote_port > 0) && (remote_port < 65536)))
3410 _ (
"`%s' is not a valid port number (for domain `%s')!"),
3419 if (0 == strcmp (
"localhost4",
3429 else if (0 == strcmp (
"localhost6",
3441 struct addrinfo *
res;
3444 ret = getaddrinfo (hostname,
3448 if ((0 != ret) || (NULL == res))
3452 "No addresses found for hostname `%s' of service `%s'!\n"),
3460 switch (res->ai_family)
3467 "Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
3474 = ((
struct sockaddr_in *) res->ai_addr)->sin_addr;
3482 "Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
3489 = ((
struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
3496 "No IP addresses found for hostname `%s' of service `%s'!\n"),
3525 if ((strlen (section) < 8) ||
3526 (0 != strcmp (
".gnunet.", section + (strlen (section) - 8))))
3602 if (NULL != dht_put)
3641 "This system does not support IPv4, will disable IPv4 functions despite them being enabled in the configuration\n"));
3650 "This system does not support IPv6, will disable IPv6 functions despite them being enabled in the configuration\n"));
3658 "Cannot enable IPv4 exit but disable IPv4 on TUN interface, will use ENABLE_IPv4=YES\n"));
3665 "Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n"));
3708 _ (
"need a valid IPv4 or IPv6 address\n"));
3717 "Opening CADET port %s for DNS exit service\n",
3803 (1 != inet_pton (AF_INET6,
3836 _ (
"Must be a number"));
3854 (1 != inet_pton (AF_INET,
3871 (1 != inet_pton (AF_INET,
3905 const char *cfgfile,
3931 char *prefixed_regex;
3947 "gnunet-vpn - - - 169.1.3.7 255.255.255.0"))
3952 "`%s' is not SUID or the path is invalid, EXIT will not work\n"),
3953 "gnunet-helper-exit");
3964 _ (
"No useful service enabled. Exiting.\n"));
3974 if (NULL == cadet_handle)
4008 "Opening CADET port %s for IPv4 gateway service\n",
4021 "EXIT_RANGE_IPV4_POLICY",
4048 "Opening CADET port %s for IPv6 gateway service\n",
4061 "EXIT_RANGE_IPV6_POLICY",
4116 "gnunet-daemon-exit",
4118 "Daemon to run to provide an IP exit node for the VPN"),
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 uint16_t make_up_icmp_service_payload(struct ChannelState *state, char *buf)
Setup ICMP payload for ICMP error messages.
static unsigned long long remote_port
Remote host's port.
static struct GNUNET_HELPER_Handle * helper_handle
The handle to the helper.
static struct GNUNET_CADET_Handle * cadet_handle
The handle to cadet.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
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.
static int free_service_record(void *cls, const struct GNUNET_HashCode *key, void *value)
Free memory associated with a service record.
static struct GNUNET_REGEX_Announcement * regex4
Handle to our regex announcement for IPv4.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct in_addr exit_ipv4mask
IPv4 netmask of our TUN interface.
static int udp
Option -u: UDP requested.
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.
struct in6_addr ipv6
Address, if af is AF_INET6.
char * name
DNS name of the service.
struct GNUNET_MessageHeader * msg
void GNUNET_REGEX_announce_cancel(struct GNUNET_REGEX_Announcement *a)
Stop announcing the regex specified by the given handle.
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(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, parse options).
This is the structure describing an DNS exit service.
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 void setup_fresh_address(int af, uint8_t proto, struct SocketAddress *local_address)
We need to create a (unique) fresh local address (IP+port).
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
Type of messages containing an ICMP packet for a service.
static struct in6_addr exit_ipv6addr
IPv6 address of our TUN interface.
char * GNUNET_TUN_ipv4policy2regex(const char *policy)
Convert an exit policy to a regular expression.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
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.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
Type of messages containing an ICMP packet for the Internet.
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.
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.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Opaque handle to the service.
#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED
uint8_t protocol
IPPROTO_TCP or IPPROTO_UDP once bound.
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.
#define GNUNET_UNUSED
gcc-ism to document unused arguments
The handle to a helper process.
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(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.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
static struct GNUNET_DNS_Advertisement dns_advertisement
Advertisement message we put into the DHT to advertise us as a DNS exit.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
static int start
Set if we are to start default services (including ARM).
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
#define GNUNET_SIGNATURE_PURPOSE_DNS_RECORD
Signature of an GNUNET_DNS_Advertisement.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
#define REGEX_MAX_PATH_LEN_IPV4
Maximum path compression length for cadet regex announcing for IPv4 address based regex...
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.
struct GNUNET_MessageHeader header
GNUnet header, of type GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE
Type of messages containing an UDP packet for a service.
int GNUNET_DNSSTUB_add_dns_ip(struct GNUNET_DNSSTUB_Context *ctx, const char *dns_ip)
Add nameserver for use by the DNSSTUB.
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 char * exit_argv[8]
Arguments to the exit helper.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START
Type of messages containing an TCP packet for a service.
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...
struct in_addr ipv4
Address, if af is AF_INET.
Handle to store cached data about a regex announce.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET
Type of messages containing an UDP packet for the Internet.
#define ETH_P_IPV6
Number for IPv6.
static void read_service_conf(void *cls, const char *section)
Reads the configuration and populates #udp_services and #tcp_services.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
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.
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.
This struct is saved into the services-hashmap to represent a service this peer is specifically offer...
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
Opaque handle to a channel.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
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.
struct GNUNET_CRYPTO_EddsaSignature signature
Signature of the peer affirming that it is offering the service.
int GNUNET_OS_check_helper_binary(const char *binary, int check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
int main(int argc, char *const *argv)
The main function.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
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.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
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.
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
struct GNUNET_CONTAINER_HeapNode * heap_node
Heap node for this state in the connections_heap.
#define GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET
Type of messages containing an DNS reply from a DNS exit service.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Beginning of signed portion of the record, signs everything until the end of the struct.
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.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
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_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.
#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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.
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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 int ipv6_exit
Are we an IPv6-exit?
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 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.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE.
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 LOG(kind,...)
Generic logging shorthand.
struct ChannelState::@10::@12 dns
Internal representation of the hash map.
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...
struct GNUNET_CADET_Port * port
Open port with CADET.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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 long long ipv6prefix
IPv6 prefix (0..127) from configuration file.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
union SocketAddress::@9 address
Remote address information.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
Connection to the DHT service.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
#define DHT_PUT_FREQUENCY
How frequently do we re-announce the DNS exit in the DHT?
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.
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.
static char * section
Name of the section.
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.
Block for storing DNS exit service advertisements.
#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_DNS_TO_INTERNET
Type of messages containing an DNS request for a DNS exit service.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
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 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.
Message send via cadet to an exit daemon to send ICMP data to a local service.
#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE
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.
#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
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.
#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY
static int ipv6_enabled
Do we support IPv6 at all on the TUN interface?
static int free_iterate(void *cls, const struct GNUNET_HashCode *hash, void *value)
Function that frees everything from a hashmap.
static int setup_exit_helper_args()
Initialize exit_argv.
enum State state
current state of profiling
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 incomming MQ-based channels.
static struct GNUNET_DNSSTUB_Context * dnsstub
Handle to the DNS Stub resolver.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
#define GNUNET_APPLICATION_PORT_IPV6_GATEWAY
Internet IPv6 gateway (any TCP/UDP/ICMP).
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY
Type of messages containing an UDP packet from a remote host.
static struct GNUNET_CONTAINER_MultiHashMap * services
This hashmaps saves interesting things about the configured services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start(unsigned int num_sockets)
Start a DNS stub resolver.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
int16_t is_udp
GNUNET_YES if this is a UDP service, otherwise TCP.
#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG
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.
uint16_t destination_port
Destination port to use for the UDP request.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static int global_ret
Return value from 'main'.
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.
union ChannelState::@10 specifics
static struct GNUNET_CADET_Port * dns_port
Port for DNS exit.
static struct GNUNET_DHT_PutHandle * dht_put
Handle for ongoing DHT PUT operations to advertise exit service.
uint32_t reserved
Always 0.
Message send via cadet to an exit daemon to forward ICMP data to the Internet.
#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_DATA_TO_VPN
Type of messages containing an TCP packet of an established connection.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
int 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.
char * GNUNET_OS_get_suid_binary_path(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 ...
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...
Handle to a node in a heap.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
static struct in_addr exit_ipv4addr
IPv4 address of our TUN interface.
Heap with the minimum cost at the root.
static void * new_service_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Callback from CADET for new channels.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
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.
Handle to the stub resolver.
Message send from exit daemon back to the UDP entry point (used for both Internet and Service exit re...
static int check_dns_request(void *cls, const struct DnsResponseMessage *msg)
Check a request via cadet to perform a DNS query.
Message handler for a specific message type.
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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct LocalService * serv
Associated service record, or NULL for no service.
struct GNUNET_CADET_Channel * channel
Cadet channel that is used for this connection.
static int ipv4_enabled
Do we support IPv4 at all on the TUN interface?
struct GNUNET_PeerIdentity peer
The peer providing this service.
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 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.
struct GNUNET_HashCode state_key
Key this state has in the connections_map.
static void add_services(int proto, char *cpy, const char *name)
Add services to the service map.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
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.
uint16_t source_port
Source port to use for the UDP reply (0 to use the same port as for the original request).
static const struct GNUNET_CONFIGURATION_Handle * cfg
The handle to the configuration used throughout the process.
#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX
Internet exit regex prefix.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
static void * new_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Callback from CADET for new channels.
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...
static int ipv4_exit
Are we an IPv4-exit?
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.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
format for cadet messages exchanged between VPN service and exit daemon
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
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.
static unsigned int size
Size of the "table".
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
uint8_t proto
IPPROTO_TCP or IPPROTO_UDP;.
#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE
struct SocketAddress address
Remote address to use for the service.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
static void do_dht_put(void *cls)
We are running a DNS exit service, advertise it in the DHT.
struct GNUNET_MQ_Envelope * env
void GNUNET_TUN_calculate_icmp_checksum(struct GNUNET_TUN_IcmpHeader *icmp, const void *payload, uint16_t payload_length)
Calculate ICMP checksum.
Message send via cadet to the vpn service to send ICMP data to the VPN's TUN interface.
struct GNUNET_TUN_DnsHeader dns
DNS header.
int 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.
static unsigned long long payload
How much data are we currently storing in the database?
static struct GNUNET_CONTAINER_Heap * connections_heap
Heap so we can quickly find "old" connections.
static struct GNUNET_CRYPTO_EddsaPrivateKey * peer_key
Private key for this peer.
static struct GNUNET_NETWORK_Handle * ls
Listen socket for STUN processing.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
an ECC signature using EdDSA.
static int tcp
Option -t: TCP requested.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
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.
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.
#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST
#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM
Message send via cadet to an exit daemon to send UDP data to a local service.
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.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
Private ECC key encoded for transmission.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
static struct GNUNET_REGEX_Announcement * regex6
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.
int af
AF_INET or AF_INET6.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
uint16_t my_id
DNS request ID that we used for forwarding.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET.
static char * hostname
Our hostname; we give this to all the peers we start.
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.
#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_MESSAGE_TYPE_VPN_ICMP_TO_VPN
Type of messages containing an ICMP packet for the VPN.
char * GNUNET_TUN_ipv6policy2regex(const char *policy)
Convert an exit policy to a regular expression.
static struct GNUNET_HashCode dht_put_key
Key we store the DNS advertismenet under.
static void dht_put_cont(void *cls)
Function called when the DHT PUT operation is complete.
Message with a DNS response.
struct GNUNET_HashCode descriptor
Descriptor for the service (CADET port).
static struct GNUNET_STATISTICS_Handle * stats
Statistics.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
static void handle_dns_request(void *cls, const struct DnsResponseMessage *msg)
Process a request via cadet to perform a DNS query.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START.
uint16_t destination_port
Destination port used by the sender on our end; 0 for uninitialized.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Section_Iterator iter, void *iter_cls)
Iterate over all sections in the configuration.
static struct GNUNET_CADET_Port * cadet_port6
Port for IPv6 exit.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
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.
struct ChannelState::@10::@11 tcp_udp
static void advertise_dns_exit()
Helper function to open the CADET port for DNS exits and to advertise the DNS exit (if applicable)...
uint16_t port
Remote port, in host byte order!
#define GNUNET_APPLICATION_PORT_INTERNET_RESOLVER
Internet DNS resolution (external DNS gateway).
Message send via cadet to an exit daemon to initiate forwarding of TCP data to the Internet...
uint16_t original_id
Original DNS request ID as used by the client.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
int is_dns
GNUNET_NO if this is a channel for TCP/UDP, GNUNET_YES if this is a channel for DNS, GNUNET_SYSERR if the channel is not yet initialized.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
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".
Information about an address.
#define REGEX_MAX_PATH_LEN_IPV6
Maximum path compression length for cadet regex announcing for IPv6 address based regex...
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...
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?
static int message_token(void *cls, const struct GNUNET_MessageHeader *message)
Receive packets from the helper-process.
uint16_t destination_port
Destination port to use for the UDP reply (0 to use the same port as for the original request)...
struct GNUNET_MessageHeader header
Type is #GNUNET_MESSAGE_TYPE_VPN_TCP_DATA.
This struct is saved into connections_map to allow finding the right channel given an IP packet from ...
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
Time for absolute times used by GNUnet, in microseconds.
static struct GNUNET_CADET_Port * cadet_port4
Port for IPv4 exit.
struct GNUNET_DNSSTUB_RequestSocket * rs
Socket we are using to transmit this request (must match if we receive a response).
#define REGEX_REFRESH_FREQUENCY
How frequently do we re-announce the regex for the exit?
static struct GNUNET_SCHEDULER_Task * dht_task
Task for doing DHT PUTs to advertise exit service.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define DNS_ADVERTISEMENT_TIMEOUT
How long do we typically sign the DNS exit advertisement for?
static struct GNUNET_CONTAINER_MultiHashMap * connections_map
This hashmaps contains the mapping from peer, service-descriptor, source-port and destination-port to...
static void dummy_task(void *cls)
Function scheduled as very last function if the service disabled itself because the helper is not ins...
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does this signature expire?
static struct ChannelState * channels[UINT16_MAX+1]
Array of all open DNS requests from channels.
UDP socket we are using for sending DNS requests to the Internet.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START.
uint16_t source_port
Source port to use for the UDP request (0 to use a random port).
Message send via cadet to an exit daemon to initiate forwarding of TCP data to a local service...
uint32_t data
The data value.
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY
union ChannelState::@75 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_PeerIdentity peer
Who is the other end of this channel.
#define GNUNET_APPLICATION_PORT_IPV4_GATEWAY
Internet IPv4 gateway (any TCP/UDP/ICMP).
static struct GNUNET_DHT_Handle * dht
Handle to the DHT.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Message send via cadet between VPN and entry and an exit daemon to transmit TCP data between the VPN ...
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
uint32_t reserved
Always 0.
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
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.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void clean_channel(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called by cadet whenever an inbound channel is destroyed.
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.
uint16_t source_port
Source port to use for the UDP request (0 to use a random port).
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE.
#define ETH_P_IPV4
Number for IPv4.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
int GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
Message send via cadet to an exit daemon to forward UDP data to the Internet.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
#define GNUNET_MESSAGE_TYPE_VPN_HELPER
Type of messages between the gnunet-vpn-helper and the daemon.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
#define gettext_noop(String)
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
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.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
uint16_t destination_port
Destination port to use for the UDP request.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET.