tool to allow IP traffic exit from the GNUnet cadet to the Internet More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
#include "gnunet_dht_service.h"
#include "gnunet_cadet_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet_signatures.h"
#include "gnunet_regex_service.h"
#include "exit.h"
#include "block_dns.h"
Go to the source code of this file.
Data Structures | |
struct | SocketAddress |
Information about an address. More... | |
struct | LocalService |
This struct is saved into the services-hashmap to represent a service this peer is specifically offering an exit for (for a specific domain name). More... | |
struct | RedirectInformation |
Information we use to track a connection (the classical 6-tuple of IP-version, protocol, source-IP, destination-IP, source-port and destinatin-port. More... | |
struct | ChannelState |
This struct is saved into connections_map to allow finding the right channel given an IP packet from TUN. More... | |
struct | DnsResponseMessage |
Message with a DNS response. More... | |
Macros | |
#define | REGEX_MAX_PATH_LEN_IPV4 4 |
Maximum path compression length for cadet regex announcing for IPv4 address based regex. More... | |
#define | REGEX_MAX_PATH_LEN_IPV6 8 |
Maximum path compression length for cadet regex announcing for IPv6 address based regex. More... | |
#define | REGEX_REFRESH_FREQUENCY |
How frequently do we re-announce the regex for the exit? More... | |
#define | DHT_PUT_FREQUENCY |
How frequently do we re-announce the DNS exit in the DHT? More... | |
#define | DNS_ADVERTISEMENT_TIMEOUT |
How long do we typically sign the DNS exit advertisement for? More... | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "exit", __VA_ARGS__); |
Generic logging shorthand. More... | |
Functions | |
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. More... | |
static int | check_dns_request (void *cls, const struct DnsResponseMessage *msg) |
Check a request via cadet to perform a DNS query. More... | |
static void | handle_dns_request (void *cls, const struct DnsResponseMessage *msg) |
Process a request via cadet to perform a DNS query. More... | |
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 connections_map. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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). More... | |
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 the correct range and address family) to associate replies with the connection / correct cadet channel. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static uint16_t | make_up_icmp_service_payload (struct ChannelState *state, char *buf) |
Setup ICMP payload for ICMP error messages. More... | |
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. More... | |
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. More... | |
static int | free_service_record (void *cls, const struct GNUNET_HashCode *key, void *value) |
Free memory associated with a service record. More... | |
static void * | new_service_channel (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator) |
Callback from CADET for new channels. More... | |
static void | clean_channel (void *cls, const struct GNUNET_CADET_Channel *channel) |
Function called by cadet whenever an inbound channel is destroyed. More... | |
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. More... | |
static void | send_packet_to_cadet_channel (struct ChannelState *s, struct GNUNET_MQ_Envelope *env) |
Send the given packet via the cadet channel. More... | |
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. More... | |
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. More... | |
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. More... | |
static int | message_token (void *cls, const struct GNUNET_MessageHeader *message) |
Receive packets from the helper-process. More... | |
static void * | new_channel (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator) |
Callback from CADET for new channels. More... | |
static int | free_iterate (void *cls, const struct GNUNET_HashCode *hash, void *value) |
Function that frees everything from a hashmap. More... | |
static void | dummy_task (void *cls) |
Function scheduled as very last function if the service disabled itself because the helper is not installed properly. More... | |
static void | cleanup (void *cls) |
Function scheduled as very last function, cleans up after us. More... | |
static void | add_services (int proto, char *cpy, const char *name) |
Add services to the service map. More... | |
static void | read_service_conf (void *cls, const char *section) |
Reads the configuration and populates #udp_services and #tcp_services. More... | |
static void | do_dht_put (void *cls) |
We are running a DNS exit service, advertise it in the DHT. More... | |
static void | dht_put_cont (void *cls) |
Function called when the DHT PUT operation is complete. More... | |
static void | parse_ip_options () |
Figure out which IP versions we should support (and which are supported by the OS) according to our configuration. More... | |
static void | advertise_dns_exit () |
Helper function to open the CADET port for DNS exits and to advertise the DNS exit (if applicable). More... | |
static int | setup_exit_helper_args () |
Initialize exit_argv. More... | |
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. More... | |
int | main (int argc, char *const *argv) |
The main function. More... | |
Variables | |
static int | global_ret |
Return value from 'main'. More... | |
static struct GNUNET_REGEX_Announcement * | regex4 |
Handle to our regex announcement for IPv4. More... | |
static struct GNUNET_REGEX_Announcement * | regex6 |
Handle to our regex announcement for IPv4. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
The handle to the configuration used throughout the process. More... | |
static struct GNUNET_HELPER_Handle * | helper_handle |
The handle to the helper. More... | |
static char * | exit_argv [8] |
Arguments to the exit helper. More... | |
static struct in6_addr | exit_ipv6addr |
IPv6 address of our TUN interface. More... | |
static unsigned long long | ipv6prefix |
IPv6 prefix (0..127) from configuration file. More... | |
static struct in_addr | exit_ipv4addr |
IPv4 address of our TUN interface. More... | |
static struct in_addr | exit_ipv4mask |
IPv4 netmask of our TUN interface. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
Statistics. More... | |
static struct GNUNET_CADET_Handle * | cadet_handle |
The handle to cadet. More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | connections_map |
This hashmaps contains the mapping from peer, service-descriptor, source-port and destination-port to a struct ChannelState. More... | |
static struct GNUNET_CONTAINER_Heap * | connections_heap |
Heap so we can quickly find "old" connections. More... | |
static unsigned long long | max_connections |
If there are at least this many connections, old ones will be removed. More... | |
static struct GNUNET_CONTAINER_MultiHashMap * | services |
This hashmaps saves interesting things about the configured services. More... | |
static struct ChannelState * | channels [UINT16_MAX+1] |
Array of all open DNS requests from channels. More... | |
static struct GNUNET_DNSSTUB_Context * | dnsstub |
Handle to the DNS Stub resolver. More... | |
static struct GNUNET_DHT_PutHandle * | dht_put |
Handle for ongoing DHT PUT operations to advertise exit service. More... | |
static struct GNUNET_DHT_Handle * | dht |
Handle to the DHT. More... | |
static struct GNUNET_SCHEDULER_Task * | dht_task |
Task for doing DHT PUTs to advertise exit service. More... | |
static struct GNUNET_DNS_Advertisement | dns_advertisement |
Advertisement message we put into the DHT to advertise us as a DNS exit. More... | |
static struct GNUNET_HashCode | dht_put_key |
Key we store the DNS advertismenet under. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | peer_key |
Private key for this peer. More... | |
static struct GNUNET_CADET_Port * | dns_port |
Port for DNS exit. More... | |
static struct GNUNET_CADET_Port * | cadet_port4 |
Port for IPv4 exit. More... | |
static struct GNUNET_CADET_Port * | cadet_port6 |
Port for IPv6 exit. More... | |
static int | ipv4_exit |
Are we an IPv4-exit? More... | |
static int | ipv6_exit |
Are we an IPv6-exit? More... | |
static int | ipv4_enabled |
Do we support IPv4 at all on the TUN interface? More... | |
static int | ipv6_enabled |
Do we support IPv6 at all on the TUN interface? More... | |
tool to allow IP traffic exit from the GNUnet cadet to the Internet
TODO:
Design:
Definition in file gnunet-daemon-exit.c.
#define REGEX_MAX_PATH_LEN_IPV4 4 |
Maximum path compression length for cadet regex announcing for IPv4 address based regex.
Definition at line 54 of file gnunet-daemon-exit.c.
#define REGEX_MAX_PATH_LEN_IPV6 8 |
Maximum path compression length for cadet regex announcing for IPv6 address based regex.
Definition at line 60 of file gnunet-daemon-exit.c.
#define REGEX_REFRESH_FREQUENCY |
How frequently do we re-announce the regex for the exit?
Definition at line 65 of file gnunet-daemon-exit.c.
#define DHT_PUT_FREQUENCY |
How frequently do we re-announce the DNS exit in the DHT?
Definition at line 71 of file gnunet-daemon-exit.c.
#define DNS_ADVERTISEMENT_TIMEOUT |
How long do we typically sign the DNS exit advertisement for?
Definition at line 77 of file gnunet-daemon-exit.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "exit", __VA_ARGS__); |
Generic logging shorthand.
Definition at line 84 of file gnunet-daemon-exit.c.
|
static |
Callback called from DNSSTUB resolver when a resolution succeeded.
cls | NULL |
dns | the response itself |
r | number of bytes in dns |
Definition at line 455 of file gnunet-daemon-exit.c.
References ChannelState::channel, channels, ChannelState::dns, DnsResponseMessage::dns, env, GNUNET_assert, GNUNET_CADET_get_mq(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_VPN_DNS_FROM_INTERNET, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TUN_DnsHeader::id, LOG, ChannelState::original_id, and ChannelState::specifics.
Referenced by handle_dns_request().
|
static |
Check a request via cadet to perform a DNS query.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 496 of file gnunet-daemon-exit.c.
References dnsstub, GNUNET_break, GNUNET_break_op, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, and ChannelState::is_dns.
|
static |
Process a request via cadet to perform a DNS query.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 522 of file gnunet-daemon-exit.c.
References ChannelState::channel, channels, ChannelState::dns, dnsstub, GNUNET_ALIGN, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_DNSSTUB_resolve(), GNUNET_memcpy, GNUNET_SYSERR, GNUNET_YES, GNUNET_TUN_DnsHeader::id, ChannelState::is_dns, msg, ChannelState::my_id, ChannelState::original_id, process_dns_result(), ChannelState::rs, GNUNET_MessageHeader::size, and ChannelState::specifics.
|
static |
Given IP information about a connection, calculate the respective hash we would use for the connections_map.
hash | resulting hash |
ri | information about the connection |
Definition at line 571 of file gnunet-daemon-exit.c.
References SocketAddress::address, SocketAddress::af, GNUNET_assert, GNUNET_memcpy, SocketAddress::ipv4, SocketAddress::ipv6, RedirectInformation::local_address, SocketAddress::port, SocketAddress::proto, and RedirectInformation::remote_address.
Referenced by get_redirect_state().
|
static |
Get our connection tracking state.
Warns if it does not exists, refreshes the timestamp if it does exist.
af | address family |
protocol | IPPROTO_UDP or IPPROTO_TCP |
destination_ip | target IP |
destination_port | target port |
local_ip | local IP |
local_port | local port |
state_key | set to hash's state if non-NULL |
Definition at line 649 of file gnunet-daemon-exit.c.
References SocketAddress::address, SocketAddress::af, ChannelState::af, connections_map, ChannelState::destination_port, GNUNET_CONTAINER_heap_update_cost(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_TIME_absolute_get(), hash_redirect_info(), SocketAddress::ipv4, SocketAddress::ipv6, key, RedirectInformation::local_address, SocketAddress::port, SocketAddress::proto, ChannelState::protocol, RedirectInformation::remote_address, ChannelState::ri, and state.
Referenced by icmp_from_helper(), setup_state_record(), tcp_from_helper(), and udp_from_helper().
|
static |
Check a request via cadet to send a request to a TCP service offered by this system.
cls | our struct ChannelState * |
start | the actual message |
Definition at line 709 of file gnunet-daemon-exit.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, start, and state.
|
static |
Prepare an IPv4 packet for transmission via the TUN interface.
Initializes the IP header and calculates checksums (IP+UDP/TCP). For UDP, the UDP header will be fully created, whereas for TCP only the ports and checksum will be filled in. So for TCP, a skeleton TCP header must be part of the provided payload.
payload | payload of the packet (starting with UDP payload or TCP header, depending on protocol) |
payload_length | number of bytes in payload |
protocol | IPPROTO_UDP or IPPROTO_TCP |
tcp_header | skeleton of the TCP header, NULL for UDP |
src_address | source address to use (IP and port) |
dst_address | destination address to use (IP and port) |
pkt4 | where to write the assembled packet; must contain enough space for the IP header, UDP/TCP header AND the payload |
Definition at line 762 of file gnunet-daemon-exit.c.
References SocketAddress::address, GNUNET_TUN_TcpHeader::destination_port, GNUNET_TUN_UdpHeader::destination_port, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_TUN_calculate_tcp4_checksum(), GNUNET_TUN_calculate_udp4_checksum(), GNUNET_TUN_initialize_ipv4_header(), SocketAddress::ipv4, GNUNET_TUN_UdpHeader::len, payload, SocketAddress::port, ChannelState::protocol, GNUNET_TUN_TcpHeader::source_port, and GNUNET_TUN_UdpHeader::source_port.
Referenced by send_tcp_packet_via_tun(), and send_udp_packet_via_tun().
|
static |
Prepare an IPv6 packet for transmission via the TUN interface.
Initializes the IP header and calculates checksums (IP+UDP/TCP). For UDP, the UDP header will be fully created, whereas for TCP only the ports and checksum will be filled in. So for TCP, a skeleton TCP header must be part of the provided payload.
payload | payload of the packet (starting with UDP payload or TCP header, depending on protocol) |
payload_length | number of bytes in payload |
protocol | IPPROTO_UDP or IPPROTO_TCP |
tcp_header | skeleton TCP header data to send, NULL for UDP |
src_address | source address to use (IP and port) |
dst_address | destination address to use (IP and port) |
pkt6 | where to write the assembled packet; must contain enough space for the IP header, UDP/TCP header AND the payload |
Definition at line 866 of file gnunet-daemon-exit.c.
References SocketAddress::address, GNUNET_TUN_TcpHeader::destination_port, GNUNET_TUN_UdpHeader::destination_port, GNUNET_assert, GNUNET_break, GNUNET_memcpy, GNUNET_TUN_calculate_tcp6_checksum(), GNUNET_TUN_calculate_udp6_checksum(), GNUNET_TUN_initialize_ipv6_header(), SocketAddress::ipv6, GNUNET_TUN_UdpHeader::len, payload, SocketAddress::port, GNUNET_TUN_TcpHeader::source_port, and GNUNET_TUN_UdpHeader::source_port.
Referenced by send_tcp_packet_via_tun(), and send_udp_packet_via_tun().
|
static |
Send a TCP packet via the TUN interface.
destination_address | IP and port to use for the TCP packet's destination |
source_address | IP and port to use for the TCP packet's source |
tcp_header | header template to use |
payload | payload of the TCP packet |
payload_length | number of bytes in payload |
Definition at line 959 of file gnunet-daemon-exit.c.
References SocketAddress::af, GNUNET_TUN_IPv4Header::destination_address, GNUNET_TUN_IPv6Header::destination_address, ETH_P_IPV4, ETH_P_IPV6, GNUNET_TUN_Layer2PacketHeader::flags, gettext_noop, GNUNET_ALIGN, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_VPN_HELPER, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, helper_handle, ipv4, ipv6, payload, GNUNET_TUN_IPv6Header::payload_length, prepare_ipv4_packet(), prepare_ipv6_packet(), GNUNET_TUN_Layer2PacketHeader::proto, GNUNET_MessageHeader::size, GNUNET_TUN_IPv4Header::source_address, GNUNET_TUN_IPv6Header::source_address, stats, and GNUNET_MessageHeader::type.
Referenced by handle_tcp_data(), handle_tcp_remote(), and handle_tcp_service().
|
static |
Send an ICMP packet via the TUN interface.
destination_address | IP to use for the ICMP packet's destination |
source_address | IP to use for the ICMP packet's source |
icmp_header | ICMP header to send |
payload | payload of the ICMP packet (does NOT include ICMP header) |
payload_length | number of bytes of data in payload |
Definition at line 1065 of file gnunet-daemon-exit.c.
References SocketAddress::af, GNUNET_TUN_IPv4Header::destination_address, GNUNET_TUN_IPv6Header::destination_address, ETH_P_IPV4, ETH_P_IPV6, GNUNET_TUN_Layer2PacketHeader::flags, gettext_noop, GNUNET_ALIGN, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_VPN_HELPER, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TUN_calculate_icmp_checksum(), GNUNET_TUN_initialize_ipv4_header(), GNUNET_TUN_initialize_ipv6_header(), GNUNET_YES, helper_handle, ipv4, ipv6, payload, GNUNET_TUN_IPv6Header::payload_length, GNUNET_TUN_Layer2PacketHeader::proto, GNUNET_MessageHeader::size, GNUNET_TUN_IPv4Header::source_address, GNUNET_TUN_IPv6Header::source_address, stats, and GNUNET_MessageHeader::type.
Referenced by handle_icmp_remote(), and handle_icmp_service().
|
static |
We need to create a (unique) fresh local address (IP+port).
Fill one in.
af | desired address family |
proto | desired protocol (IPPROTO_UDP or IPPROTO_TCP) |
local_address | address to initialize |
Definition at line 1177 of file gnunet-daemon-exit.c.
References SocketAddress::address, SocketAddress::af, exit_ipv4addr, exit_ipv4mask, exit_ipv6addr, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_memcmp, SocketAddress::ipv4, SocketAddress::ipv6, ipv6prefix, SocketAddress::port, proto, and SocketAddress::proto.
Referenced by setup_state_record().
|
static |
We are starting a fresh connection (TCP or UDP) and need to pick a source port and IP address (within the correct range and address family) to associate replies with the connection / correct cadet channel.
This function generates a "fresh" source IP and source port number for a connection After picking a good source address, this function sets up the state in the 'connections_map' and 'connections_heap' to allow finding the state when needed later. The function also makes sure that we remain within memory limits by cleaning up 'old' states.
state | skeleton state to setup a record for; should 'state->specifics.tcp_udp.ri.remote_address' filled in so that this code can determine which AF/protocol is going to be used (the 'channel' should also already be set); after calling this function, heap_node and the local_address will be also initialized (heap_node != NULL can be used to test if a state has been fully setup). |
Definition at line 1292 of file gnunet-daemon-exit.c.
References ChannelState::channel, connections_heap, connections_map, get_redirect_state(), GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_TIME_absolute_get(), ChannelState::heap_node, key, max_connections, setup_fresh_address(), ChannelState::specifics, state, ChannelState::state_key, and ChannelState::tcp_udp.
Referenced by handle_icmp_remote(), handle_icmp_service(), handle_tcp_remote(), handle_tcp_service(), handle_udp_remote(), and handle_udp_service().
|
static |
Send a UDP packet via the TUN interface.
destination_address | IP and port to use for the UDP packet's destination |
source_address | IP and port to use for the UDP packet's source |
payload | payload of the UDP packet (does NOT include UDP header) |
payload_length | number of bytes of data in payload |
Definition at line 1362 of file gnunet-daemon-exit.c.
References SocketAddress::af, GNUNET_TUN_IPv4Header::destination_address, GNUNET_TUN_IPv6Header::destination_address, ETH_P_IPV4, ETH_P_IPV6, GNUNET_TUN_Layer2PacketHeader::flags, gettext_noop, GNUNET_ALIGN, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_VPN_HELPER, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, helper_handle, ipv4, ipv6, GNUNET_TUN_UdpHeader::len, payload, GNUNET_TUN_IPv6Header::payload_length, prepare_ipv4_packet(), prepare_ipv6_packet(), GNUNET_TUN_Layer2PacketHeader::proto, GNUNET_MessageHeader::size, GNUNET_TUN_IPv4Header::source_address, GNUNET_TUN_IPv6Header::source_address, stats, and GNUNET_MessageHeader::type.
Referenced by handle_udp_remote(), and handle_udp_service().
|
static |
Check a request to forward UDP data to the Internet via this peer.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 1463 of file gnunet-daemon-exit.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and state.
|
static |
Process a request to forward UDP data to the Internet via this peer.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 1484 of file gnunet-daemon-exit.c.
References gettext_noop, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, consensus-simulation::int, ipv4_exit, ipv6_exit, msg, payload, send_udp_packet_via_tun(), setup_state_record(), GNUNET_MessageHeader::size, state, and stats.
|
static |
Check a request via cadet to send a request to a UDP service offered by this system.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 1583 of file gnunet-daemon-exit.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and state.
|
static |
Process a request via cadet to send a request to a UDP service offered by this system.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 1605 of file gnunet-daemon-exit.c.
References gettext_noop, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_NO, GNUNET_STATISTICS_update(), LOG, msg, send_udp_packet_via_tun(), setup_state_record(), GNUNET_MessageHeader::size, state, and stats.
|
static |
Process a request via cadet to send a request to a TCP service offered by this system.
cls | our struct ChannelState * |
start | the actual message |
Definition at line 1645 of file gnunet-daemon-exit.c.
References gettext_noop, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, send_tcp_packet_via_tun(), setup_state_record(), start, state, and stats.
|
static |
Check a request to forward TCP data to the Internet via this peer.
cls | our struct ChannelState * |
start | the actual message |
Definition at line 1692 of file gnunet-daemon-exit.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, start, and state.
|
static |
Process a request to forward TCP data to the Internet via this peer.
cls | our struct ChannelState * |
start | the actual message |
Definition at line 1729 of file gnunet-daemon-exit.c.
References gettext_noop, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, consensus-simulation::int, ipv4_exit, ipv6_exit, payload, send_tcp_packet_via_tun(), setup_state_record(), start, state, and stats.
|
static |
Check a request to forward TCP data on an established connection via this peer.
cls | our struct ChannelState * |
data | the actual message |
Definition at line 1827 of file gnunet-daemon-exit.c.
References data, gettext_noop, GNUNET_break_op, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, state, and stats.
|
static |
Process a request to forward TCP data on an established connection via this peer.
cls | our struct ChannelState * |
data | the actual message |
Definition at line 1865 of file gnunet-daemon-exit.c.
References data, gettext_noop, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, send_tcp_packet_via_tun(), state, and stats.
|
static |
Synthesize a plausible ICMP payload for an ICMPv4 error response on the given channel.
state | channel information |
ipp | IPv6 header to fill in (ICMP payload) |
udp | "UDP" header to fill in (ICMP payload); might actually also be the first 8 bytes of the TCP header |
Definition at line 1916 of file gnunet-daemon-exit.c.
References address, GNUNET_TUN_initialize_ipv4_header(), proto, state, and udp.
Referenced by handle_icmp_remote(), and make_up_icmp_service_payload().
|
static |
Synthesize a plausible ICMP payload for an ICMPv6 error response on the given channel.
state | channel information |
ipp | IPv6 header to fill in (ICMP payload) |
udp | "UDP" header to fill in (ICMP payload); might actually also be the first 8 bytes of the TCP header |
Definition at line 1946 of file gnunet-daemon-exit.c.
References address, GNUNET_TUN_initialize_ipv6_header(), proto, state, and udp.
Referenced by handle_icmp_remote(), and make_up_icmp_service_payload().
|
static |
Check a request to forward ICMP data to the Internet via this peer.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 1975 of file gnunet-daemon-exit.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and state.
|
static |
Process a request to forward ICMP data to the Internet via this peer.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 1996 of file gnunet-daemon-exit.c.
References gettext_noop, GNUNET_ALIGN, GNUNET_assert, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE, GNUNET_TUN_ICMPTYPE6_ECHO_REPLY, GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST, GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG, GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM, GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED, GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE, GNUNET_TUN_ICMPTYPE_ECHO_REPLY, GNUNET_TUN_ICMPTYPE_ECHO_REQUEST, GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH, GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED, consensus-simulation::int, ipv4_exit, ipv6_exit, make_up_icmpv4_payload(), make_up_icmpv6_payload(), msg, payload, send_icmp_packet_via_tun(), setup_state_record(), GNUNET_MessageHeader::size, state, stats, GNUNET_MessageHeader::type, and udp.
|
static |
Setup ICMP payload for ICMP error messages.
Called for both IPv4 and IPv6 addresses.
state | context for creating the IP Packet |
buf | where to create the payload, has at least sizeof (struct GNUNET_TUN_IPv6Header) + 8 bytes |
Definition at line 2196 of file gnunet-daemon-exit.c.
References GNUNET_assert, GNUNET_break, ipv4, ipv6, make_up_icmpv4_payload(), make_up_icmpv6_payload(), state, and udp.
Referenced by handle_icmp_service().
|
static |
Check a request via cadet to send ICMP data to a service offered by this system.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 2248 of file gnunet-daemon-exit.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and state.
|
static |
Process a request via cadet to send ICMP data to a service offered by this system.
cls | our struct ChannelState * |
msg | the actual message |
Definition at line 2275 of file gnunet-daemon-exit.c.
References gettext_noop, GNUNET_ALIGN, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE, GNUNET_TUN_ICMPTYPE6_ECHO_REPLY, GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST, GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG, GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM, GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED, GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE, GNUNET_TUN_ICMPTYPE_ECHO_REPLY, GNUNET_TUN_ICMPTYPE_ECHO_REQUEST, GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH, GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED, make_up_icmp_service_payload(), msg, payload, send_icmp_packet_via_tun(), setup_state_record(), GNUNET_MessageHeader::size, state, stats, GNUNET_MessageHeader::type, and GNUNET_TUN_IcmpHeader::type.
|
static |
Free memory associated with a service record.
cls | unused |
key | service descriptor |
value | service record to free |
Definition at line 2465 of file gnunet-daemon-exit.c.
References GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_OK, GNUNET_YES, key, service, services, and value.
Referenced by cleanup().
|
static |
Callback from CADET for new channels.
cls | closure |
channel | new handle to the channel |
initiator | peer that started the channel |
Definition at line 2491 of file gnunet-daemon-exit.c.
References ChannelState::channel, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), ls, ChannelState::peer, RedirectInformation::remote_address, ChannelState::ri, ChannelState::serv, ChannelState::specifics, stats, and ChannelState::tcp_udp.
Referenced by store_service().
|
static |
Function called by cadet whenever an inbound channel is destroyed.
Should clean up any associated state.
cls | our struct ChannelState * |
channel | connection to the other end (henceforth invalid) |
Definition at line 2521 of file gnunet-daemon-exit.c.
References channels, connections_map, ChannelState::dns, GNUNET_assert, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SYSERR, GNUNET_YES, ChannelState::heap_node, ChannelState::is_dns, LOG, ChannelState::my_id, ChannelState::specifics, ChannelState::state_key, and ChannelState::tcp_udp.
Referenced by advertise_dns_exit(), run(), and store_service().
|
static |
Given a service descriptor and a destination port, find the respective service entry.
proto | IPPROTO_TCP or IPPROTO_UDP |
name | name of the service |
destination_port | destination port |
service | service information record to store (service->name will be set). |
Definition at line 2565 of file gnunet-daemon-exit.c.
References _, cadet_handle, cadet_port, clean_channel(), GNUNET_CADET_close_port(), GNUNET_CADET_open_port(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_OK, GNUNET_strdup, GNUNET_TUN_compute_service_cadet_port(), GNUNET_TUN_service_name_to_hash(), handlers, name, new_service_channel(), proto, service, and services.
Referenced by add_services().
|
static |
Send the given packet via the cadet channel.
s | channel destination |
env | message to queue |
Definition at line 2635 of file gnunet-daemon-exit.c.
References ChannelState::channel, env, gettext_noop, GNUNET_assert, GNUNET_CADET_get_mq(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), and stats.
Referenced by icmp_from_helper(), tcp_from_helper(), and udp_from_helper().
|
static |
Handles an ICMP packet received from the helper.
icmp | A pointer to the Packet |
pktlen | number of bytes in icmp |
af | address family (AFINET or AF_INET6) |
destination_ip | destination IP-address of the IP packet (should be our local address) |
source_ip | original source IP-address of the IP packet (should be the original destination address) |
Definition at line 2661 of file gnunet-daemon-exit.c.
References _, GNUNET_EXIT_IcmpToVPNMessage::af, GNUNET_TUN_UdpHeader::destination_port, env, get_redirect_state(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE, GNUNET_TUN_ICMPTYPE6_ECHO_REPLY, GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST, GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG, GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM, GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED, GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE, GNUNET_TUN_ICMPTYPE_ECHO_REPLY, GNUNET_TUN_ICMPTYPE_ECHO_REQUEST, GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH, GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED, GNUNET_EXIT_IcmpToVPNMessage::icmp_header, ipv4, ipv6, GNUNET_TUN_IPv4Header::protocol, send_packet_to_cadet_channel(), GNUNET_TUN_UdpHeader::source_port, state, stats, GNUNET_TUN_IcmpHeader::type, and udp.
Referenced by message_token().
|
static |
Handles an UDP packet received from the helper.
udp | A pointer to the Packet |
pktlen | number of bytes in 'udp' |
af | address family (AFINET or AF_INET6) |
destination_ip | destination IP-address of the IP packet (should be our local address) |
source_ip | original source IP-address of the IP packet (should be the original destination address) |
Definition at line 2871 of file gnunet-daemon-exit.c.
References _, GNUNET_EXIT_UdpReplyMessage::destination_port, env, get_redirect_state(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY, GNUNET_MQ_msg_extra, send_packet_to_cadet_channel(), GNUNET_EXIT_UdpReplyMessage::source_port, state, and udp.
Referenced by message_token().
|
static |
Handles a TCP packet received from the helper.
tcp | A pointer to the Packet |
pktlen | the length of the packet, including its TCP header |
af | address family (AFINET or AF_INET6) |
destination_ip | destination IP-address of the IP packet (should be our local address) |
source_ip | original source IP-address of the IP packet (should be the original destination address) |
Definition at line 2948 of file gnunet-daemon-exit.c.
References _, GNUNET_TUN_TcpHeader::crc, GNUNET_TUN_TcpHeader::destination_port, env, get_redirect_state(), GNUNET_ALIGN, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN, GNUNET_MQ_msg_extra, GNUNET_EXIT_TcpDataMessage::reserved, send_packet_to_cadet_channel(), GNUNET_TUN_TcpHeader::source_port, state, tcp, and GNUNET_EXIT_TcpDataMessage::tcp_header.
Referenced by message_token().
|
static |
Receive packets from the helper-process.
cls | unused |
message | message received from helper |
Definition at line 3032 of file gnunet-daemon-exit.c.
References _, ETH_P_IPV4, ETH_P_IPV6, gettext_noop, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSAGE_TYPE_VPN_HELPER, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_TUN_IPv4Header::header_length, icmp_from_helper(), GNUNET_TUN_IPv6Header::next_header, GNUNET_TUN_IPv6Header::payload_length, GNUNET_TUN_Layer2PacketHeader::proto, GNUNET_TUN_IPv4Header::protocol, GNUNET_MessageHeader::size, size, stats, tcp_from_helper(), GNUNET_TUN_IPv4Header::total_length, GNUNET_MessageHeader::type, and udp_from_helper().
Referenced by run().
|
static |
Callback from CADET for new channels.
cls | closure |
channel | new handle to the channel |
initiator | peer that started the channel |
Definition at line 3194 of file gnunet-daemon-exit.c.
References ChannelState::channel, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, ChannelState::is_dns, ChannelState::peer, and stats.
Referenced by advertise_dns_exit(), and run().
|
static |
Function that frees everything from a hashmap.
cls | unused |
hash | key |
value | value to free |
Definition at line 3222 of file gnunet-daemon-exit.c.
References GNUNET_free, GNUNET_YES, and value.
Referenced by cleanup().
|
static |
Function scheduled as very last function if the service disabled itself because the helper is not installed properly.
Does nothing, except for keeping the service process alive by virtue of being scheduled.
cls | NULL |
Definition at line 3240 of file gnunet-daemon-exit.c.
Referenced by run().
|
static |
Function scheduled as very last function, cleans up after us.
cls | NULL |
Definition at line 3252 of file gnunet-daemon-exit.c.
References cadet_handle, cadet_port4, cadet_port6, connections_heap, connections_map, dht, dht_put, dht_task, dns_port, dnsstub, exit_argv, free_iterate(), free_service_record(), GNUNET_CADET_close_port(), GNUNET_CADET_disconnect(), GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DHT_disconnect(), GNUNET_DHT_put_cancel(), GNUNET_DNSSTUB_stop(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELPER_stop(), GNUNET_log, GNUNET_NO, GNUNET_REGEX_announce_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), helper_handle, peer_key, regex4, regex6, services, and stats.
Referenced by run().
|
static |
Add services to the service map.
proto | IPPROTO_TCP or IPPROTO_UDP |
cpy | copy of the service descriptor (can be mutilated) |
name | DNS name of the service |
Definition at line 3358 of file gnunet-daemon-exit.c.
References _, SocketAddress::address, LocalService::address, SocketAddress::af, exit_argv, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_strndup, SocketAddress::ipv4, ipv4_enabled, SocketAddress::ipv6, ipv6_enabled, name, SocketAddress::port, proto, SocketAddress::proto, remote_port, res, ret, and store_service().
Referenced by read_service_conf().
|
static |
Reads the configuration and populates #udp_services and #tcp_services.
cls | unused |
section | name of section in config |
Definition at line 3528 of file gnunet-daemon-exit.c.
References add_services(), cfg, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, and GNUNET_OK.
Referenced by run().
|
static |
We are running a DNS exit service, advertise it in the DHT.
This task is run periodically to do the DHT PUT.
cls | closure |
Definition at line 3591 of file gnunet-daemon-exit.c.
References dht, dht_put, dht_put_cont(), DHT_PUT_FREQUENCY, dht_put_key, dht_task, dns_advertisement, DNS_ADVERTISEMENT_TIMEOUT, do_dht_put(), expiration, GNUNET_DNS_Advertisement::expiration_time, GNUNET_assert, GNUNET_BLOCK_TYPE_DNS, GNUNET_CRYPTO_eddsa_sign_(), GNUNET_DHT_put(), GNUNET_DHT_put_cancel(), GNUNET_DHT_RO_NONE, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_HOURS, peer_key, GNUNET_DNS_Advertisement::purpose, and GNUNET_DNS_Advertisement::signature.
Referenced by advertise_dns_exit(), and do_dht_put().
|
static |
Function called when the DHT PUT operation is complete.
Schedules the next PUT.
cls | closure, NULL |
Definition at line 3578 of file gnunet-daemon-exit.c.
References dht_put.
Referenced by do_dht_put().
|
static |
Figure out which IP versions we should support (and which are supported by the OS) according to our configuration.
Definition at line 3630 of file gnunet-daemon-exit.c.
References _, cfg, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NETWORK_test_pf(), GNUNET_NO, GNUNET_OK, GNUNET_YES, ipv4_enabled, ipv4_exit, ipv6_enabled, and ipv6_exit.
Referenced by run().
|
static |
Helper function to open the CADET port for DNS exits and to advertise the DNS exit (if applicable).
Definition at line 3684 of file gnunet-daemon-exit.c.
References _, cadet_handle, cfg, clean_channel(), dht, dht_put_key, dht_task, dns_advertisement, dns_port, dnsstub, do_dht_put(), GNUNET_APPLICATION_PORT_INTERNET_RESOLVER, GNUNET_assert, GNUNET_CADET_open_port(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_DHT_connect(), GNUNET_DNSSTUB_add_dns_ip(), GNUNET_DNSSTUB_start(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_log_config_invalid(), GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SIGNATURE_PURPOSE_DNS_RECORD, GNUNET_YES, handlers, new_channel(), GNUNET_DNS_Advertisement::peer, peer_key, port, GNUNET_PeerIdentity::public_key, GNUNET_DNS_Advertisement::purpose, GNUNET_CRYPTO_EccSignaturePurpose::purpose, and GNUNET_CRYPTO_EccSignaturePurpose::size.
Referenced by run().
|
static |
Initialize exit_argv.
Definition at line 3762 of file gnunet-daemon-exit.c.
References _, cfg, exit_argv, exit_ipv4addr, exit_ipv4mask, exit_ipv6addr, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_invalid(), GNUNET_log_config_missing(), GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_YES, ipv4_enabled, ipv6_enabled, and ipv6prefix.
Referenced by run().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
cfg_ | configuration |
Definition at line 3912 of file gnunet-daemon-exit.c.
References _, advertise_dns_exit(), cadet_handle, cadet_port4, cadet_port6, cfg, clean_channel(), cleanup(), connections_heap, connections_map, dummy_task(), exit_argv, global_ret, GNUNET_APPLICATION_PORT_IPV4_GATEWAY, GNUNET_APPLICATION_PORT_IPV6_GATEWAY, GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, GNUNET_asprintf(), GNUNET_CADET_connect(), GNUNET_CADET_open_port(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_HELPER_start(), GNUNET_log, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_OK, GNUNET_OS_check_helper_binary(), GNUNET_OS_get_suid_binary_path(), GNUNET_OS_project_data_gnunet(), GNUNET_REGEX_announce(), GNUNET_REGEX_ipv4policy2regex(), GNUNET_REGEX_ipv6policy2regex(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_YES, handlers, helper_handle, ipv4_enabled, ipv4_exit, ipv6_enabled, ipv6_exit, max_connections, message_token(), new_channel(), parse_ip_options(), port, read_service_conf(), regex4, regex6, REGEX_MAX_PATH_LEN_IPV4, REGEX_MAX_PATH_LEN_IPV6, REGEX_REFRESH_FREQUENCY, services, setup_exit_helper_args(), and stats.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 4112 of file gnunet-daemon-exit.c.
References gettext_noop, global_ret, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), options, and run().
|
static |
Return value from 'main'.
Definition at line 268 of file gnunet-daemon-exit.c.
|
static |
Handle to our regex announcement for IPv4.
Definition at line 273 of file gnunet-daemon-exit.c.
|
static |
Handle to our regex announcement for IPv4.
Definition at line 278 of file gnunet-daemon-exit.c.
|
static |
The handle to the configuration used throughout the process.
Definition at line 283 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), parse_ip_options(), read_service_conf(), run(), and setup_exit_helper_args().
|
static |
The handle to the helper.
Definition at line 288 of file gnunet-daemon-exit.c.
Referenced by cleanup(), run(), send_icmp_packet_via_tun(), send_tcp_packet_via_tun(), and send_udp_packet_via_tun().
|
static |
Arguments to the exit helper.
Definition at line 293 of file gnunet-daemon-exit.c.
Referenced by add_services(), cleanup(), run(), and setup_exit_helper_args().
|
static |
IPv6 address of our TUN interface.
Definition at line 298 of file gnunet-daemon-exit.c.
Referenced by setup_exit_helper_args(), and setup_fresh_address().
|
static |
IPv6 prefix (0..127) from configuration file.
Definition at line 303 of file gnunet-daemon-exit.c.
Referenced by run(), setup_exit_helper_args(), and setup_fresh_address().
|
static |
IPv4 address of our TUN interface.
Definition at line 308 of file gnunet-daemon-exit.c.
Referenced by setup_exit_helper_args(), and setup_fresh_address().
|
static |
IPv4 netmask of our TUN interface.
Definition at line 313 of file gnunet-daemon-exit.c.
Referenced by setup_exit_helper_args(), and setup_fresh_address().
|
static |
Statistics.
Definition at line 318 of file gnunet-daemon-exit.c.
Referenced by check_tcp_data(), cleanup(), handle_icmp_remote(), handle_icmp_service(), handle_tcp_data(), handle_tcp_remote(), handle_tcp_service(), handle_udp_remote(), handle_udp_service(), icmp_from_helper(), message_token(), new_channel(), new_service_channel(), run(), send_icmp_packet_via_tun(), send_packet_to_cadet_channel(), send_tcp_packet_via_tun(), and send_udp_packet_via_tun().
|
static |
The handle to cadet.
Definition at line 323 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), cleanup(), run(), and store_service().
|
static |
This hashmaps contains the mapping from peer, service-descriptor, source-port and destination-port to a struct ChannelState.
Definition at line 329 of file gnunet-daemon-exit.c.
Referenced by clean_channel(), cleanup(), get_redirect_state(), run(), and setup_state_record().
|
static |
Heap so we can quickly find "old" connections.
Definition at line 334 of file gnunet-daemon-exit.c.
Referenced by cleanup(), run(), and setup_state_record().
|
static |
If there are at least this many connections, old ones will be removed.
Definition at line 339 of file gnunet-daemon-exit.c.
Referenced by run(), and setup_state_record().
|
static |
This hashmaps saves interesting things about the configured services.
Definition at line 344 of file gnunet-daemon-exit.c.
Referenced by cleanup(), free_service_record(), run(), and store_service().
|
static |
Array of all open DNS requests from channels.
Definition at line 349 of file gnunet-daemon-exit.c.
Referenced by clean_channel(), handle_dns_request(), and process_dns_result().
|
static |
Handle to the DNS Stub resolver.
Definition at line 354 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), check_dns_request(), cleanup(), and handle_dns_request().
|
static |
Handle for ongoing DHT PUT operations to advertise exit service.
Definition at line 359 of file gnunet-daemon-exit.c.
Referenced by cleanup(), dht_put_cont(), and do_dht_put().
|
static |
Handle to the DHT.
Definition at line 364 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), cleanup(), do_dht_put(), GNS_resolver_init(), REGEX_INTERNAL_announce(), and REGEX_INTERNAL_search().
|
static |
Task for doing DHT PUTs to advertise exit service.
Definition at line 369 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), cleanup(), and do_dht_put().
|
static |
Advertisement message we put into the DHT to advertise us as a DNS exit.
Definition at line 375 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), and do_dht_put().
|
static |
Key we store the DNS advertismenet under.
Definition at line 380 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), and do_dht_put().
|
static |
Private key for this peer.
Definition at line 385 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), cleanup(), and do_dht_put().
|
static |
Port for DNS exit.
Definition at line 390 of file gnunet-daemon-exit.c.
Referenced by advertise_dns_exit(), and cleanup().
|
static |
Port for IPv4 exit.
Definition at line 395 of file gnunet-daemon-exit.c.
|
static |
Port for IPv6 exit.
Definition at line 400 of file gnunet-daemon-exit.c.
|
static |
Are we an IPv4-exit?
Definition at line 405 of file gnunet-daemon-exit.c.
Referenced by handle_icmp_remote(), handle_tcp_remote(), handle_udp_remote(), parse_ip_options(), and run().
|
static |
Are we an IPv6-exit?
Definition at line 410 of file gnunet-daemon-exit.c.
Referenced by handle_icmp_remote(), handle_tcp_remote(), handle_udp_remote(), parse_ip_options(), and run().
|
static |
Do we support IPv4 at all on the TUN interface?
Definition at line 415 of file gnunet-daemon-exit.c.
Referenced by add_services(), parse_ip_options(), run(), and setup_exit_helper_args().
|
static |
Do we support IPv6 at all on the TUN interface?
Definition at line 420 of file gnunet-daemon-exit.c.
Referenced by add_services(), parse_ip_options(), run(), and setup_exit_helper_args().