48#define MAX_MESSAGE_QUEUE_SIZE 4
417 const void *source_ip,
418 uint16_t source_port,
419 const void *destination_ip,
420 uint16_t destination_port,
430 off +=
sizeof(uint16_t);
432 off +=
sizeof(uint16_t);
437 off +=
sizeof(
struct in_addr);
439 off +=
sizeof(
struct in_addr);
444 off +=
sizeof(
struct in6_addr);
445 GNUNET_memcpy (off, destination_ip,
sizeof(
struct in6_addr));
446 off +=
sizeof(
struct in6_addr);
479 rlen =
sizeof(
struct in_addr);
483 rlen =
sizeof(
struct in6_addr);
495 res->result_af = htonl (result_af);
496 res->request_id = request_id;
515 if (NULL != (channel = ts->
channel))
525 while (NULL != (tnq = ts->
tmq_head))
581 "# Messages dropped in cadet queue (overflow)"),
598 static char dest[256];
635 "CADET notified us about death of channel to `%s'\n",
662 udp->len = htons (0);
663 udp->crc = htons (0);
688 udp->len = htons (0);
689 udp->crc = htons (0);
711 if (AF_UNSPEC == ts->
af)
740 char sbuf[INET6_ADDRSTRLEN];
741 char dbuf[INET6_ADDRSTRLEN];
745 "Received ICMP packet from cadet, sending %u bytes from %s -> %s via TUN\n",
748 inet_ntop (ts->
af, &ts->
source_ip, dbuf,
sizeof(dbuf)));
769 tun->
flags = htons (0);
782 switch (ntohl (i2v->
af))
815 gettext_noop (
"# ICMPv4 packets dropped (type not allowed)"),
871 gettext_noop (
"# ICMPv6 packets dropped (impossible PT to v4)"),
888 gettext_noop (
"# ICMPv6 packets dropped (type not allowed)"),
922 tun->
flags = htons (0);
936 switch (ntohl (i2v->
af))
993 gettext_noop (
"# ICMPv4 packets dropped (impossible PT to v6)"),
1002 gettext_noop (
"# ICMPv4 packets dropped (type not allowed)"),
1041 gettext_noop (
"# ICMPv6 packets dropped (type not allowed)"),
1087 if (AF_UNSPEC == ts->
af)
1116 char sbuf[INET6_ADDRSTRLEN];
1117 char dbuf[INET6_ADDRSTRLEN];
1121 "Received UDP reply from cadet, sending %u bytes from [%s]:%u -> [%s]:%u via TUN\n",
1122 (
unsigned int) mlen,
1125 inet_ntop (ts->
af, &ts->
source_ip, dbuf,
sizeof(dbuf)),
1146 tun->
flags = htons (0);
1186 tun->
flags = htons (0);
1265 char sbuf[INET6_ADDRSTRLEN];
1266 char dbuf[INET6_ADDRSTRLEN];
1270 "Received TCP reply from cadet, sending %u bytes from [%s]:%u -> [%s]:%u via TUN\n",
1271 (
unsigned int) mlen,
1274 inet_ntop (ts->
af, &ts->
source_ip, dbuf,
sizeof(dbuf)),
1295 tun->
flags = htons (0);
1329 tun->
flags = htons (0);
1405 unsigned int get_path_length,
1407 unsigned int put_path_length)
1413 "Exit %s found for destination %s!\n",
1439 "Creating tunnel to %s for destination %s!\n",
1488 "Creating channel to peer %s offering service %s on port %u\n",
1537 "Requesting connect by string: %s\n",
1561 "Tearing down expired channel to %s\n",
1585 size_t payload_length)
1596 uint16_t source_port;
1616 source_port = ntohs (
udp->source_port);
1643 source_port = ntohs (
tcp->source_port);
1656 case IPPROTO_ICMPV6: {
1657 if ((AF_INET == af) ^ (protocol == IPPROTO_ICMP))
1685 _ (
"Protocol %u not supported, dropping\n"),
1686 (
unsigned int) protocol);
1695 alen =
sizeof(
struct in_addr);
1699 alen =
sizeof(
struct in6_addr);
1707 char sbuf[INET6_ADDRSTRLEN];
1708 char dbuf[INET6_ADDRSTRLEN];
1709 char xbuf[INET6_ADDRSTRLEN];
1713 "Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n",
1714 (protocol == IPPROTO_TCP) ?
"TCP" :
"UDP",
1715 inet_ntop (af, source_ip, sbuf,
sizeof(sbuf)),
1717 inet_ntop (af, destination_ip, dbuf,
sizeof(dbuf)),
1725 for (dt = destination->
dt_head; NULL != dt; dt = dt->
next)
1732 char sbuf[INET6_ADDRSTRLEN];
1733 char dbuf[INET6_ADDRSTRLEN];
1737 "Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n",
1738 (protocol == IPPROTO_TCP) ?
"TCP" :
"UDP",
1739 inet_ntop (af, source_ip, sbuf,
sizeof(sbuf)),
1741 inet_ntop (af, destination_ip, dbuf,
sizeof(dbuf)),
1747 for (dt = destination->
dt_head; NULL != dt; dt = dt->
next)
1766 "Creating new channel for key %s\n",
1778 ts->
source_ip.
v4 = *(
const struct in_addr *) source_ip;
1783 ts->
source_ip.
v6 = *(
const struct in6_addr *) source_ip;
1815 "Packet dropped, channel to %s not yet ready (%s)\n",
1817 (NULL == ts->
search) ?
"EXIT search failed"
1818 :
"EXIT search active");
1821 "# Packets dropped (channel not yet online)"),
1849 (ntohs (
udp->source_port) < 32000) ?
udp->source_port : 0;
1858 struct in_addr *ip4dst;
1859 struct in6_addr *ip6dst;
1870 payload_length + alen
1875 (ntohs (
udp->source_port) < 32000) ?
udp->source_port : 0;
1880 ip4dst = (
struct in_addr *) &uim[1];
1882 payload_tmp = &ip4dst[1];
1886 ip6dst = (
struct in6_addr *) &uim[1];
1888 payload_tmp = &ip6dst[1];
1928 struct in_addr *ip4dst;
1929 struct in6_addr *ip6dst;
1941 payload_length + alen
1949 ip4dst = (
struct in_addr *) &tim[1];
1951 payload_tmp = &ip4dst[1];
1955 ip6dst = (
struct in6_addr *) &tim[1];
1957 payload_tmp = &ip6dst[1];
1992 case IPPROTO_ICMPV6:
2019 "# ICMPv4 packets dropped (not allowed)"),
2045 "# ICMPv6 packets dropped (not allowed)"),
2071 ism->
af = htonl (
af);
2080 struct in_addr *ip4dst;
2081 struct in6_addr *ip6dst;
2085 new_type = icmp->
type;
2122 gettext_noop (
"# ICMPv4 packets dropped (impossible PT to v6)"),
2134 gettext_noop (
"# ICMPv4 packets dropped (type not allowed)"),
2164 gettext_noop (
"# ICMPv6 packets dropped (impossible PT to v4)"),
2178 gettext_noop (
"# ICMPv6 packets dropped (impossible PT to v4)"),
2200 gettext_noop (
"# ICMPv6 packets dropped (type not allowed)"),
2221 alen + payload_length
2230 ip4dst = (
struct in_addr *) &iim[1];
2232 payload_tmp = &ip4dst[1];
2236 ip6dst = (
struct in6_addr *) &iim[1];
2238 payload_tmp = &ip6dst[1];
2282 "# Packets received from TUN interface"),
2285 mlen = ntohs (message->
size);
2296 switch (ntohs (tun->
proto))
2312 char buf[INET6_ADDRSTRLEN];
2316 _ (
"Packet received for unmapped destination `%s' (dropping it)\n"),
2344 char buf[INET_ADDRSTRLEN];
2348 _ (
"Packet received for unmapped destination `%s' (dropping it)\n"),
2355 _ (
"Received IPv4 packet with options (dropping it)\n"));
2371 _ (
"Received packet of unknown protocol %d from TUN (dropping it)\n"),
2372 (
unsigned int) ntohs (tun->
proto));
2390 const char *ipv4addr =
vpn_argv[4];
2391 const char *ipv4mask =
vpn_argv[5];
2392 struct in_addr addr;
2393 struct in_addr mask;
2402 mask.s_addr = addr.s_addr | ~mask.s_addr;
2411 "Failed to find unallocated IPv4 address in VPN's range\n"))
2418 v4->s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr;
2423 (v4->s_addr == addr.s_addr) || (v4->s_addr == mask.s_addr));
2439 const char *ipv6addr =
vpn_argv[2];
2440 struct in6_addr addr;
2441 struct in6_addr mask;
2442 struct in6_addr rnd;
2453 mask.s6_addr[i / 8] |= (1 << (i % 8));
2464 "Failed to find unallocated IPv6 address in VPN's range\n"))
2468 for (i = 0; i < 16; i++)
2473 v6->s6_addr[i] = (addr.s6_addr[i] | rnd.s6_addr[i]) & mask.s6_addr[i];
2496 "Cleaning up destination entry `%s'\n",
2502 while (NULL != (dt = de->
dt_head))
2555 struct in6_addr *
v6)
2562 *result_af = AF_UNSPEC;
2569 *result_af = AF_UNSPEC;
2578 *result_af = AF_INET;
2583 *result_af = AF_INET6;
2616 if (alen !=
sizeof(
struct in_addr))
2624 if (alen !=
sizeof(
struct in6_addr))
2680 char sbuf[INET6_ADDRSTRLEN];
2681 char dbuf[INET6_ADDRSTRLEN];
2684 "Allocated address %s for redirection via exit to %s\n",
2685 inet_ntop (
result_af, addr, sbuf,
sizeof(sbuf)),
2686 inet_ntop (
addr_af, &
msg[1], dbuf,
sizeof(dbuf)));
2704 msg->expiration_time)
2740 result_af = (
int) htonl (
msg->result_af);
2748 if (result_af == AF_UNSPEC)
2752 _ (
"Failed to allocate IP address for new destination\n"));
2758 char sbuf[INET6_ADDRSTRLEN];
2761 "Allocated address %s for redirection to service %s on peer %s\n",
2762 inet_ntop (result_af, addr, sbuf,
sizeof(sbuf)),
2782 msg->expiration_time)
2828 "Tearing down channel to `%s' during cleanup\n",
2886 for (i = 0; i < 5; i++)
2948 "gnunet-helper-vpn");
2954 "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0"))
2957 "`%s' is not SUID or the path is invalid, refusing to run.\n",
3007 (1 != inet_pton (AF_INET6, ipv6addr, &v6))))
3012 _ (
"Must specify valid IPv6 address"));
3019 ipv6prefix_s = NULL;
3044 _ (
"Must specify valid IPv6 mask"));
3054 "IPv6 support disabled as this system does not support IPv6\n"));
3066 (1 != inet_pton (AF_INET, ipv4addr, &v4))))
3071 _ (
"Must specify valid IPv4 address"));
3084 (1 != inet_pton (AF_INET, ipv4mask, &v4))))
3089 _ (
"Must specify valid IPv4 mask"));
3101 "IPv4 support disabled as this system does not support IPv4\n"));
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
format for cadet messages exchanged between VPN service and exit daemon
#define gettext_noop(String)
static uint16_t port
Port number.
static char * address
GNS address for this phone.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static unsigned long long payload
How much data are we currently storing in the database?
static struct GNUNET_CADET_Port * cadet_port
Listen port for incoming requests.
static int check_icmp_back(void *cls, const struct GNUNET_EXIT_IcmpToVPNMessage *i2v)
We got an ICMP packet back from the CADET channel.
static void send_to_channel(struct ChannelState *ts, struct GNUNET_MQ_Envelope *env)
Add the given message to the given channel and trigger the transmission process.
static void get_channel_key_from_ips(int af, uint8_t protocol, const void *source_ip, uint16_t source_port, const void *destination_ip, uint16_t destination_port, struct GNUNET_HashCode *key)
Compute the key under which we would store an entry in the channel_map for the given socket address p...
static struct GNUNET_CONTAINER_MultiHashMap * channel_map
Map from source and destination address (IP+port) to connection information (mostly with the respecti...
static int allocate_response_ip(int *result_af, void **addr, struct in_addr *v4, struct in6_addr *v6)
Allocate an IP address for the response.
static struct GNUNET_CONTAINER_MultiHashMap * destination_map
Map from IP address to destination information (possibly with a CADET channel handle for fast setup).
static void handle_icmp_back(void *cls, const struct GNUNET_EXIT_IcmpToVPNMessage *i2v)
We got an ICMP packet back from the CADET channel.
static void route_packet(struct DestinationEntry *destination, int af, uint8_t protocol, const void *source_ip, const void *destination_ip, const void *payload, size_t payload_length)
Route a packet via cadet to the given destination.
static struct GNUNET_CADET_Channel * create_channel(struct ChannelState *ts, const struct GNUNET_PeerIdentity *target, const struct GNUNET_HashCode *port)
Create a channel for ts to target at port.
static int cleanup_destination(void *cls, const struct GNUNET_HashCode *key, void *value)
Free memory occupied by an entry in the destination map.
GNUNET_SERVICE_MAIN(GNUNET_OS_project_data_gnunet(), "vpn", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(client_redirect_to_ip, GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP, struct RedirectToIpRequestMessage, NULL), GNUNET_MQ_hd_fixed_size(client_redirect_to_service, GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE, struct RedirectToServiceRequestMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static unsigned long long ipv6prefix
Length of the prefix of the VPN's IPv6 network.
static int check_tcp_back(void *cls, const struct GNUNET_EXIT_TcpDataMessage *data)
We got a TCP packet back from the CADET channel.
static int global_ret
Return value from main().
static struct GNUNET_STATISTICS_Handle * stats
Statistics.
#define MAX_MESSAGE_QUEUE_SIZE
Maximum number of messages we allow in the queue for cadet.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static void get_destination_key_from_ip(int af, const void *address, struct GNUNET_HashCode *key)
Compute the key under which we would store an entry in the destination_map for the given IP address.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static void send_client_reply(struct GNUNET_SERVICE_Client *client, uint64_t request_id, int result_af, const void *addr)
Notify the client about the result of its request.
static void handle_udp_back(void *cls, const struct GNUNET_EXIT_UdpReplyMessage *reply)
We got a UDP packet back from the CADET channel.
static int check_udp_back(void *cls, const struct GNUNET_EXIT_UdpReplyMessage *reply)
We got a UDP packet back from the CADET channel.
static void handle_regex_result(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length)
Regex has found a potential exit peer for us; consider using it.
static char * vpn_argv[7]
Arguments to the vpn helper.
static void free_destination_entry(struct DestinationEntry *de)
Free resources occupied by a destination entry.
static struct GNUNET_CONTAINER_Heap * channel_heap
Min-Heap sorted by activity time to expire old mappings; values are of type 'struct ChannelState'.
static struct ChannelState * create_channel_to_destination(struct DestinationChannel *dt, int client_af)
Initialize the given destination entry's cadet channel.
static unsigned long long max_destination_mappings
If there are more than this number of address-mappings, old ones will be removed.
static int allocate_v6_address(struct in6_addr *v6)
Allocate an IPv6 address from the range of the channel for a new redirection.
static int cleanup_channel(void *cls, const struct GNUNET_HashCode *key, void *value)
Free memory occupied by an entry in the channel map.
static struct GNUNET_CONTAINER_Heap * destination_heap
Min-Heap sorted by activity time to expire old mappings.
static void handle_client_redirect_to_service(void *cls, const struct RedirectToServiceRequestMessage *msg)
A client asks us to setup a redirection to a particular peer offering a service.
static struct GNUNET_CADET_Handle * cadet_handle
Handle to the cadet service.
static void handle_tcp_back(void *cls, const struct GNUNET_EXIT_TcpDataMessage *data)
We got a TCP packet back from the CADET channel.
static int message_token(void *cls, const struct GNUNET_MessageHeader *message)
Receive packets from the helper-process (someone send to the local virtual channel interface).
static unsigned long long max_channel_mappings
If there are more than this number of open channels, old ones will be removed.
static void handle_client_redirect_to_ip(void *cls, const struct RedirectToIpRequestMessage *msg)
A client asks us to setup a redirection via some exit node to a particular IP.
static void expire_destination(struct DestinationEntry *except)
We have too many active destinations.
static void channel_cleaner(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever a channel is destroyed.
static void expire_channel(struct ChannelState *except)
We have too many active channels.
static const char * print_channel_destination(const struct DestinationEntry *de)
Output destination of a channel for diagnostics.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
Callback called when a client connects to the service.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
Callback called when a client disconnected from the service.
static void make_up_icmpv6_payload(struct ChannelState *ts, struct GNUNET_TUN_IPv6Header *ipp, struct GNUNET_TUN_UdpHeader *udp)
Synthesize a plausible ICMP payload for an ICMP error response on the given channel.
static void free_channel_state(struct ChannelState *ts)
Free resources associated with a channel state.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg_, struct GNUNET_SERVICE_Handle *service)
Main function that will be run by the scheduler.
static void make_up_icmpv4_payload(struct ChannelState *ts, struct GNUNET_TUN_IPv4Header *ipp, struct GNUNET_TUN_UdpHeader *udp)
Synthesize a plausible ICMP payload for an ICMP error response on the given channel.
static struct GNUNET_HELPER_Handle * helper_handle
The handle to the VPN helper process "gnunet-helper-vpn".
static int allocate_v4_address(struct in_addr *v4)
Allocate an IPv4 address from the range of the channel for a new redirection.
static int check_client_redirect_to_ip(void *cls, const struct RedirectToIpRequestMessage *msg)
A client asks us to setup a redirection via some exit node to a particular IP.
static int ipv4
Option -4: IPv4 requested.
static int udp
Option -u: UDP requested.
static int ipv6
Option -6: IPv6 requested.
static int tcp
Option -t: TCP requested.
Constants for network applications operating on top of the CADET service.
CADET service; establish channels to distant peers.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Constants for network protocols.
API to access regex service to advertise capabilities via regex and discover respective peers using m...
API to create, modify and access statistics.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX
Internet exit regex prefix.
#define GNUNET_APPLICATION_PORT_IPV4_GATEWAY
Internet IPv4 gateway (any TCP/UDP/ICMP).
#define GNUNET_APPLICATION_PORT_IPV6_GATEWAY
Internet IPv6 gateway (any TCP/UDP/ICMP).
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected channel.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote 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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, bool can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
enum GNUNET_GenericReturnValue GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(const struct GNUNET_OS_ProjectData *pd, int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
enum GNUNET_GenericReturnValue GNUNET_HELPER_kill(struct GNUNET_HELPER_Handle *h, int soft_kill)
Sends termination signal to the helper process.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_env_set_options(struct GNUNET_MQ_Envelope *env, enum GNUNET_MQ_PriorityPreferences pp)
Set application-specific options for this envelope.
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
struct GNUNET_MQ_Envelope * GNUNET_MQ_unsent_head(struct GNUNET_MQ_Handle *mq)
Remove the first envelope that has not yet been sent from the message queue and return it.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
@ GNUNET_MQ_PREF_OUT_OF_ORDER
Flag to indicate that out-of-order delivery is OK.
@ GNUNET_MQ_PRIO_BEST_EFFORT
Best-effort traffic (e.g.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_OS_check_helper_binary(const char *binary, bool check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
char * GNUNET_OS_get_suid_binary_path(const struct GNUNET_OS_ProjectData *pd, const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname)
Given the name of a helper, service or daemon binary construct the full path to the binary using the ...
#define GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY
Type of messages containing an UDP packet from a remote host.
#define GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP
VPN service responds to client with an IP to use for the requested redirection.
#define GNUNET_MESSAGE_TYPE_VPN_HELPER
Type of messages between the gnunet-vpn-helper and the daemon.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT
Type of messages containing an TCP packet of an established connection.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
Type of messages containing an ICMP packet for a service.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START
Type of messages containing an TCP packet for the Internet.
#define GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_IP
Client asks VPN service to setup an IP to redirect traffic via an exit node to some global IP address...
#define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START
Type of messages containing an TCP packet for a service.
#define GNUNET_MESSAGE_TYPE_VPN_CLIENT_REDIRECT_TO_SERVICE
Client asks VPN service to setup an IP to redirect traffic to some peer offering a service.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE
Type of messages containing an UDP packet for a service.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
Type of messages containing an ICMP packet for the Internet.
#define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_VPN
Type of messages containing an TCP packet of an established connection.
#define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET
Type of messages containing an UDP packet for the Internet.
#define GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN
Type of messages containing an ICMP packet for the VPN.
struct GNUNET_REGEX_Search * GNUNET_REGEX_search(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *string, GNUNET_REGEX_Found callback, void *callback_cls)
Search for a peer offering a regex matching certain string in the DHT.
void GNUNET_REGEX_search_cancel(struct GNUNET_REGEX_Search *s)
Stop search and free all data used by a GNUNET_REGEX_search call.
void GNUNET_REGEX_ipv4toregexsearch(const struct in_addr *ip, uint16_t port, char *rxstr)
Create a regex in rxstr from the given ip and port.
void GNUNET_REGEX_ipv6toregexsearch(const struct in6_addr *ipv6, uint16_t port, char *rxstr)
Create a regex in rxstr from the given ipv6 and port.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
void GNUNET_TUN_initialize_ipv6_header(struct GNUNET_TUN_IPv6Header *ip, uint8_t protocol, uint16_t payload_length, const struct in6_addr *src, const struct in6_addr *dst)
Initialize an IPv6 header.
void GNUNET_TUN_calculate_udp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, struct GNUNET_TUN_UdpHeader *udp, const void *payload, uint16_t payload_length)
Calculate IPv4 UDP checksum.
#define GNUNET_TUN_IPV4_REGEXLEN
Maximum regex string length for use with GNUNET_REGEX_ipv4toregexsearch.
GNUNET_NETWORK_STRUCT_END void GNUNET_TUN_initialize_ipv4_header(struct GNUNET_TUN_IPv4Header *ip, uint8_t protocol, uint16_t payload_length, const struct in_addr *src, const struct in_addr *dst)
Initialize an IPv4 header.
#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM
void GNUNET_TUN_calculate_icmp_checksum(struct GNUNET_TUN_IcmpHeader *icmp, const void *payload, uint16_t payload_length)
Calculate ICMP checksum.
#define GNUNET_TUN_IPV6_REGEXLEN
Maximum regex string length for use with GNUNET_REGEX_ipv6toregexsearch.
#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST
#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED
#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY
#define ETH_P_IPV6
Number for IPv6.
void GNUNET_TUN_compute_service_cadet_port(const struct GNUNET_HashCode *desc, uint16_t ip_port, struct GNUNET_HashCode *cadet_port)
Compute the CADET port given a service descriptor (returned from GNUNET_TUN_service_name_to_hash) and...
#define ETH_P_IPV4
Number for IPv4.
#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED
void GNUNET_TUN_calculate_tcp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, struct GNUNET_TUN_TcpHeader *tcp, const void *payload, uint16_t payload_length)
Calculate IPv6 TCP checksum.
#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE
#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH
void GNUNET_TUN_calculate_tcp4_checksum(const struct GNUNET_TUN_IPv4Header *ip, struct GNUNET_TUN_TcpHeader *tcp, const void *payload, uint16_t payload_length)
Calculate IPv4 TCP checksum.
#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE
#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST
#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG
#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY
void GNUNET_TUN_calculate_udp6_checksum(const struct GNUNET_TUN_IPv6Header *ip, struct GNUNET_TUN_UdpHeader *udp, const void *payload, uint16_t payload_length)
Calculate IPv6 UDP checksum.
static unsigned int size
Size of the "table".
A messages we have in queue for a particular channel.
const void * msg
Message to transmit, allocated at the end of this struct.
struct ChannelMessageQueueEntry * prev
This is a doubly-linked list.
size_t len
Number of bytes in msg.
struct ChannelMessageQueueEntry * next
This is a doubly-linked list.
This struct is saved into connections_map to allow finding the right channel given an IP packet from ...
unsigned int tmq_length
Length of the doubly linked 'tmq_head/tmq_tail' list.
struct DestinationEntry destination
Destination to which this channel leads.
struct GNUNET_REGEX_Search * search
Active query with REGEX to locate exit.
struct ChannelMessageQueueEntry * tmq_head
Head of list of messages scheduled for transmission.
struct ChannelMessageQueueEntry * tmq_tail
Tail of list of messages scheduled for transmission.
union ChannelState::@71 destination_ip
Destination IP address used by the source on our end (this is the IP that we pick freely within the V...
int af
Address family used for this channel on the local TUN interface.
union ChannelState::@70 source_ip
IP address of the source on our end, initially uninitialized.
uint16_t source_port
Source port used by the sender on our end; 0 for uninitialized.
struct GNUNET_CADET_Channel * channel
Cadet channel that is used for this connection.
int is_established
Is this channel new (GNUNET_NO), or did we exchange messages with the other side already (GNUNET_YES)...
struct GNUNET_CONTAINER_HeapNode * heap_node
Heap node for this state in the connections_heap.
uint8_t protocol
IPPROTO_TCP or IPPROTO_UDP once bound.
uint16_t destination_port
Destination port used by the sender on our end; 0 for uninitialized.
struct in_addr v4
Address if af is AF_INET.
struct in6_addr v6
Address if af is AF_INET6.
List of channels we keep for each destination port for a given destination entry.
struct DestinationChannel * prev
Kept in a DLL.
uint16_t destination_port
Destination port this channel state is used for.
struct DestinationEntry * destination
Destination entry list this struct DestinationChannel belongs with.
struct DestinationChannel * next
Kept in a DLL.
Information we track for each IP address to determine which channel to send the traffic over to the d...
struct DestinationChannel * dt_head
Head of DLL of channels associated with this destination.
int af
Address family used (AF_INET or AF_INET6).
struct GNUNET_PeerIdentity target
Peer offering the service.
struct GNUNET_CONTAINER_HeapNode * heap_node
Entry for this entry in the destination_heap.
struct GNUNET_HashCode key
Key under which this entry is in the 'destination_map' (only valid if 'heap_node !...
union DestinationEntry::@66::@68::@69 ip
IP address of the ultimate destination (only used for exit channels).
struct DestinationEntry::@66::@68 exit_destination
union DestinationEntry::@66 details
Details about the connection (depending on is_service).
struct GNUNET_HashCode service_descriptor
The description of the service (only used for service channels).
struct DestinationEntry::@66::@67 service_destination
int is_service
GNUNET_NO if this is a channel to an Internet-exit, GNUNET_YES if this channel is to a service.
struct in_addr v4
Address if af is AF_INET.
struct DestinationChannel * dt_tail
Tail of DLL of channels associated with this destination.
struct in6_addr v6
Address if af is AF_INET6.
Opaque handle to a channel.
Opaque handle to the service.
Handle to a node in a heap.
Internal representation of the hash map.
Message send via cadet to an exit daemon to forward ICMP data to the Internet.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
Message send via cadet to an exit daemon to send ICMP data to a local service.
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
Message send via cadet to the vpn service to send ICMP data to the VPN's TUN interface.
struct GNUNET_TUN_IcmpHeader icmp_header
ICMP header to use.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN.
Message send via cadet between VPN and entry and an exit daemon to transmit TCP data between the VPN ...
uint32_t reserved
Always 0.
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
Message send via cadet to an exit daemon to initiate forwarding of TCP data to the Internet.
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
Message send via cadet to an exit daemon to initiate forwarding of TCP data to a local service.
uint32_t reserved
Always 0.
struct GNUNET_TUN_TcpHeader tcp_header
Skeleton of the TCP header to send.
Message send via cadet to an exit daemon to forward UDP data to the Internet.
uint16_t source_port
Source port to use for the UDP request (0 to use a random port).
uint16_t destination_port
Destination port to use for the UDP request.
int32_t af
Address family, AF_INET or AF_INET6, in network byte order.
Message send from exit daemon back to the UDP entry point (used for both Internet and Service exit re...
uint16_t source_port
Source port to use for the UDP reply (0 to use the same port as for the original request).
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY.
uint16_t destination_port
Destination port to use for the UDP reply (0 to use the same port as for the original request).
Message send via cadet to an exit daemon to send UDP data to a local service.
uint16_t destination_port
Destination port to use for the UDP request.
uint16_t source_port
Source port to use for the UDP request (0 to use a random port).
The handle to a helper process.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Handle to store data about a regex search.
Handle to a client that is connected to a service.
uint64_t abs_value_us
The actual value.
Message send by the VPN client to the VPN service requesting the setup of a redirection from some IP ...
int32_t addr_af
Address family used for the destination address (AF_INET or AF_INET6, in nbo)
int32_t result_af
Address family desired for the result (AF_INET or AF_INET6 or AF_UNSPEC, in nbo)
Response from the VPN service to a VPN client informing about the IP that was assigned for the reques...
int32_t result_af
Address family of the allocated address that follows; will match "result_af" from the request,...
Message send by the VPN client to the VPN service requesting the setup of a redirection from some IP ...
IPC messages between VPN library and VPN service.