GNUnet 0.22.2
Collaboration diagram for VPN service:

Typedefs

typedef void(* GNUNET_VPN_AllocationCallback) (void *cls, int af, const void *address)
 Callback invoked from the VPN service once a redirection is available. More...
 

Functions

void GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr)
 Cancel redirection request with the service. More...
 
struct GNUNET_VPN_RedirectionRequestGNUNET_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. More...
 
struct GNUNET_VPN_RedirectionRequestGNUNET_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. More...
 
struct GNUNET_VPN_HandleGNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the VPN service. More...
 
void GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh)
 Disconnect from the VPN service. More...
 

Detailed Description

Typedef Documentation

◆ GNUNET_VPN_AllocationCallback

typedef void(* GNUNET_VPN_AllocationCallback) (void *cls, int af, const void *address)

Callback invoked from the VPN service once a redirection is available.

Provides the IP address that can now be used to reach the requested destination.

Parameters
clsclosure
afaddress family, AF_INET or AF_INET6; AF_UNSPEC on error; will match 'result_af' from the request
addressIP address (struct in_addr or struct in_addr6, depending on 'af') that the VPN allocated for the redirection; traffic to this IP will now be redirected to the specified target peer; NULL on error

Definition at line 65 of file gnunet_vpn_service.h.

Function Documentation

◆ GNUNET_VPN_cancel_request()

void GNUNET_VPN_cancel_request ( struct GNUNET_VPN_RedirectionRequest rr)

Cancel redirection request with the service.

Parameters
rrrequest to cancel

Definition at line 375 of file vpn_api.c.

376{
377 struct GNUNET_VPN_Handle *vh;
378
379 vh = rr->vh;
381 vh->rr_tail,
382 rr);
383 GNUNET_free (rr);
384}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Opaque VPN handle.
Definition: vpn_api.c:35
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
Definition: vpn_api.c:54
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:49
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:91

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_VPN_Handle::rr_head, GNUNET_VPN_Handle::rr_tail, and GNUNET_VPN_RedirectionRequest::vh.

Referenced by do_disconnect(), and do_timeout().

Here is the caller graph for this function:

◆ GNUNET_VPN_redirect_to_peer()

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.

The VPN is to reserve a particular IP for the redirection and return it. The VPN will begin the redirection as soon as possible and maintain it as long as it is actively used and keeping it is feasible. Given resource limitations, the longest inactive mappings will be destroyed.

Parameters
vhVPN handle
result_afdesired address family for the returned allocation can also be AF_UNSPEC
protocolprotocol, IPPROTO_UDP or IPPROTO_TCP
peertarget peer for the redirection
servservice descriptor to give to the peer
expiration_timeat what time should the redirection expire? (this should not impact connections that are active at that time)
cbfunction to call with the IP
cb_clsclosure for cb
Returns
handle to cancel the request (means the callback won't be invoked anymore; the mapping may or may not be established anyway)

Definition at line 388 of file vpn_api.c.

396{
398
400 rr->vh = vh;
401 rr->cb = cb;
402 rr->cb_cls = cb_cls;
403 rr->peer = *peer;
404 rr->serv = *serv;
406 rr->result_af = result_af;
407 rr->protocol = protocol;
409 vh->rr_tail,
410 rr);
411 send_request (rr);
412 return rr;
413}
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Opaque redirection request handle.
Definition: vpn_api.c:77
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:102
void * cb_cls
Closure for cb.
Definition: vpn_api.c:107
struct GNUNET_PeerIdentity peer
For service redirection, identity of the peer offering the service.
Definition: vpn_api.c:112
uint8_t protocol
For service redirection, IPPROT_UDP or IPPROTO_TCP.
Definition: vpn_api.c:142
struct GNUNET_TIME_Absolute expiration_time
At what time should the created service mapping expire?
Definition: vpn_api.c:122
int result_af
Desired address family for the result.
Definition: vpn_api.c:132
struct GNUNET_HashCode serv
For service redirection, service descriptor.
Definition: vpn_api.c:117
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
Definition: vpn_api.c:238

References GNUNET_VPN_RedirectionRequest::cb, GNUNET_VPN_RedirectionRequest::cb_cls, GNUNET_VPN_RedirectionRequest::expiration_time, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, GNUNET_VPN_RedirectionRequest::peer, GNUNET_VPN_RedirectionRequest::protocol, GNUNET_VPN_RedirectionRequest::result_af, GNUNET_VPN_Handle::rr_head, GNUNET_VPN_Handle::rr_tail, send_request(), GNUNET_VPN_RedirectionRequest::serv, and GNUNET_VPN_RedirectionRequest::vh.

Referenced by result_processor(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_VPN_redirect_to_ip()

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.

Note that both UDP and TCP traffic will be forwarded, but possibly to different exit nodes. The VPN is to reserve a particular IP for the redirection and return it. The VPN will begin the redirection as soon as possible and maintain it as long as it is actively used and keeping it is feasible. Given resource limitations, the longest inactive mappings will be destroyed.

Parameters
vhVPN handle
result_afdesired address family for the returned allocation, can also be AF_UNSPEC
addr_afaddress family for 'addr', AF_INET or AF_INET6
addrdestination IP address on the Internet; destination port is to be taken from the VPN packet itself
expiration_timeat what time should the redirection expire? (this should not impact connections that are active at that time)
cbfunction to call with the IP
cb_clsclosure for cb
Returns
handle to cancel the request (means the callback won't be invoked anymore; the mapping may or may not be established anyway)

Note that both UDP and TCP traffic will be forwarded, but possibly to different exit nodes. The VPN is to reserve a particular IP for the redirection and return it. The VPN will begin the redirection as soon as possible and maintain it as long as it is actively used and keeping it is feasible. Given resource limitations, the longest inactive mappings will be destroyed.

Parameters
vhVPN handle
result_afdesired address family for the returned allocation
addr_afaddress family for addr, AF_INET or AF_INET6
addrdestination IP address on the Internet; destination port is to be taken from the VPN packet itself
expiration_timeat what time should the redirection expire? (this should not impact connections that are active at that time)
cbfunction to call with the IP
cb_clsclosure for cb
Returns
handle to cancel the request (means the callback won't be invoked anymore; the mapping may or may not be established anyway)

Definition at line 439 of file vpn_api.c.

446{
448 size_t alen;
449
450 switch (addr_af)
451 {
452 case AF_INET:
453 alen = sizeof(struct in_addr);
454 break;
455
456 case AF_INET6:
457 alen = sizeof(struct in6_addr);
458 break;
459
460 default:
461 GNUNET_break (0);
462 return NULL;
463 }
464 rr = GNUNET_malloc (sizeof(struct GNUNET_VPN_RedirectionRequest) + alen);
465 rr->vh = vh;
466 rr->addr = &rr[1];
467 rr->cb = cb;
468 rr->cb_cls = cb_cls;
469 rr->expiration_time = expiration_time;
470 rr->result_af = result_af;
471 rr->addr_af = addr_af;
472 GNUNET_memcpy (&rr[1],
473 addr,
474 alen);
476 vh->rr_tail,
477 rr);
478 send_request (rr);
479 return rr;
480}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_malloc(size)
Wrapper around malloc.
const void * addr
Target IP address for the redirection, or NULL for redirection to service.
Definition: vpn_api.c:97
int addr_af
Address family of addr.
Definition: vpn_api.c:137

References GNUNET_VPN_RedirectionRequest::addr, GNUNET_VPN_RedirectionRequest::addr_af, GNUNET_VPN_RedirectionRequest::cb, GNUNET_VPN_RedirectionRequest::cb_cls, GNUNET_VPN_RedirectionRequest::expiration_time, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_malloc, GNUNET_memcpy, GNUNET_VPN_RedirectionRequest::result_af, GNUNET_VPN_Handle::rr_head, GNUNET_VPN_Handle::rr_tail, send_request(), and GNUNET_VPN_RedirectionRequest::vh.

Referenced by modify_address(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_VPN_connect()

struct GNUNET_VPN_Handle * GNUNET_VPN_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the VPN service.

Parameters
cfgconfiguration to use
Returns
VPN handle

Definition at line 490 of file vpn_api.c.

491{
492 struct GNUNET_VPN_Handle *vh
493 = GNUNET_new (struct GNUNET_VPN_Handle);
494
495 vh->cfg = cfg;
496 connect_task (vh);
497 if (NULL == vh->mq)
498 {
499 GNUNET_free (vh);
500 return NULL;
501 }
502 return vh;
503}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
Definition: vpn_api.c:39
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44
static void connect_task(void *cls)
Connect to the VPN service and start again to transmit our requests.
Definition: vpn_api.c:317

References cfg, GNUNET_VPN_Handle::cfg, connect_task(), GNUNET_free, GNUNET_new, and GNUNET_VPN_Handle::mq.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_VPN_disconnect()

void GNUNET_VPN_disconnect ( struct GNUNET_VPN_Handle vh)

Disconnect from the VPN service.

Parameters
vhVPN handle

Definition at line 512 of file vpn_api.c.

513{
514 GNUNET_assert (NULL == vh->rr_head);
515 if (NULL != vh->mq)
516 {
517 GNUNET_MQ_destroy (vh->mq);
518 vh->mq = NULL;
519 }
520 if (NULL != vh->rt)
521 {
523 vh->rt = NULL;
524 }
525 GNUNET_free (vh);
526}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
struct GNUNET_SCHEDULER_Task * rt
Identifier of a reconnect task.
Definition: vpn_api.c:59

References GNUNET_assert, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_VPN_Handle::mq, GNUNET_VPN_Handle::rr_head, and GNUNET_VPN_Handle::rt.

Referenced by cleanup(), do_disconnect(), do_shutdown(), and run().

Here is the call graph for this function:
Here is the caller graph for this function: