178 alen =
sizeof(
struct in_addr);
182 alen =
sizeof(
struct in6_addr);
189 if ((ntohs (rm->
header.
size) != alen +
sizeof(*rm)) ||
224 (af == AF_UNSPEC) ? NULL : &rm[1]);
248 if (NULL == rr->
addr)
265 alen =
sizeof(
struct in_addr);
269 alen =
sizeof(
struct in6_addr);
453 alen =
sizeof(
struct in_addr);
457 alen =
sizeof(
struct in6_addr);
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MQ_Envelope * env
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
API to access the VPN service.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void * cls
Closure for mv and cb.
#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_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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#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_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_CLIENT_REDIRECT_TO_SERVICE
Client asks VPN service to setup an IP to redirect traffic to some peer offering a service.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
#define GNUNET_TIME_UNIT_SECONDS
One second.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
struct GNUNET_VPN_Handle * GNUNET_VPN_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the VPN service.
struct GNUNET_VPN_RedirectionRequest * GNUNET_VPN_redirect_to_peer(struct GNUNET_VPN_Handle *vh, int result_af, uint8_t protocol, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HashCode *serv, struct GNUNET_TIME_Absolute expiration_time, GNUNET_VPN_AllocationCallback cb, void *cb_cls)
Tell the VPN that a forwarding to a particular peer offering a particular service is requested.
struct GNUNET_VPN_RedirectionRequest * GNUNET_VPN_redirect_to_ip(struct GNUNET_VPN_Handle *vh, int result_af, int addr_af, const void *addr, struct GNUNET_TIME_Absolute expiration_time, GNUNET_VPN_AllocationCallback cb, void *cb_cls)
Tell the VPN that forwarding to the Internet via some exit node is requested.
void GNUNET_VPN_cancel_request(struct GNUNET_VPN_RedirectionRequest *rr)
Cancel redirection request with the service.
void(* GNUNET_VPN_AllocationCallback)(void *cls, int af, const void *address)
Callback invoked from the VPN service once a redirection is available.
void GNUNET_VPN_disconnect(struct GNUNET_VPN_Handle *vh)
Disconnect from the VPN service.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_TIME_Relative backoff
How long do we wait until we try to reconnect?
uint64_t request_id_gen
ID of the last request that was submitted to the service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
struct GNUNET_SCHEDULER_Task * rt
Identifier of a reconnect task.
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Opaque redirection request handle.
const void * addr
Target IP address for the redirection, or NULL for redirection to service.
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
void * cb_cls
Closure for cb.
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
uint64_t request_id
non-zero if this request has been sent to the service.
struct GNUNET_PeerIdentity peer
For service redirection, identity of the peer offering the service.
uint8_t protocol
For service redirection, IPPROT_UDP or IPPROTO_TCP.
struct GNUNET_TIME_Absolute expiration_time
At what time should the created service mapping expire?
int addr_af
Address family of addr.
int result_af
Desired address family for the result.
struct GNUNET_HashCode serv
For service redirection, service descriptor.
struct GNUNET_VPN_RedirectionRequest * prev
Element in DLL.
struct GNUNET_VPN_RedirectionRequest * next
Element in DLL.
Message send by the VPN client to the VPN service requesting the setup of a redirection from some IP ...
uint64_t request_id
Unique ID to match a future response to this request.
uint32_t reserved
Always zero.
int32_t addr_af
Address family used for the destination address (AF_INET or AF_INET6, in nbo)
struct GNUNET_TIME_AbsoluteNBO expiration_time
How long should the redirection be maintained at most?
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,...
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP.
uint64_t request_id
Unique ID to match the response to a request.
Message send by the VPN client to the VPN service requesting the setup of a redirection from some IP ...
int32_t result_af
Address family desired for the result (AF_INET or AF_INET6 or AF_UNSPEC, in nbo)
struct GNUNET_TIME_AbsoluteNBO expiration_time
How long should the redirection be maintained at most?
struct GNUNET_PeerIdentity target
Target peer offering the service.
uint64_t request_id
Unique ID to match a future response to this request.
uint32_t reserved
Always zero.
struct GNUNET_HashCode service_descriptor
Service descriptor identifying the service.
int32_t protocol
Desired protocol (IPPROTO_UDP or IPPROTO_TCP)
IPC messages between VPN library and VPN service.
static int check_use_ip(void *cls, const struct RedirectToIpResponseMessage *rm)
Check a GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP message from the VPN service.
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static void reconnect(struct GNUNET_VPN_Handle *vh)
Disconnect from the service (communication error) and reconnect later.
static void connect_task(void *cls)
Connect to the VPN service and start again to transmit our requests.
static void handle_use_ip(void *cls, const struct RedirectToIpResponseMessage *rm)
Handle a GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP message from the VPN service.