GNUnet  0.10.x
Typedefs | Functions
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 61 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 370 of file vpn_api.c.

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 GNS_resolver_lookup_cancel().

371 {
372  struct GNUNET_VPN_Handle *vh;
373 
374  vh = rr->vh;
376  vh->rr_tail,
377  rr);
378  GNUNET_free(rr);
379 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Opaque VPN handle.
Definition: vpn_api.c:34
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
Definition: vpn_api.c:53
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:48
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:89
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)

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 405 of file vpn_api.c.

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, 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 handle_gns_resolution_result(), and run().

413 {
415 
417  rr->vh = vh;
418  rr->cb = cb;
419  rr->cb_cls = cb_cls;
420  rr->peer = *peer;
421  rr->serv = *serv;
423  rr->result_af = result_af;
424  rr->protocol = protocol;
426  vh->rr_tail,
427  rr);
428  send_request(rr);
429  return rr;
430 }
int result_af
Desired address family for the result.
Definition: vpn_api.c:130
struct GNUNET_PeerIdentity peer
For service redirection, identity of the peer offering the service.
Definition: vpn_api.c:110
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute expiration_time
At what time should the created service mapping expire?
Definition: vpn_api.c:120
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:100
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
Definition: vpn_api.c:53
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Opaque redirection request handle.
Definition: vpn_api.c:75
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint8_t protocol
For service redirection, IPPROT_UDP or IPPROTO_TCP.
Definition: vpn_api.c:140
void * cb_cls
Closure for cb.
Definition: vpn_api.c:105
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:48
struct GNUNET_HashCode serv
For service redirection, service descriptor.
Definition: vpn_api.c:115
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
Definition: vpn_api.c:236
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:89
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 456 of file vpn_api.c.

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().

463 {
465  size_t alen;
466 
467  switch (addr_af)
468  {
469  case AF_INET:
470  alen = sizeof(struct in_addr);
471  break;
472 
473  case AF_INET6:
474  alen = sizeof(struct in6_addr);
475  break;
476 
477  default:
478  GNUNET_break(0);
479  return NULL;
480  }
481  rr = GNUNET_malloc(sizeof(struct GNUNET_VPN_RedirectionRequest) + alen);
482  rr->vh = vh;
483  rr->addr = &rr[1];
484  rr->cb = cb;
485  rr->cb_cls = cb_cls;
486  rr->expiration_time = expiration_time;
487  rr->result_af = result_af;
488  rr->addr_af = addr_af;
489  GNUNET_memcpy(&rr[1],
490  addr,
491  alen);
493  vh->rr_tail,
494  rr);
495  send_request(rr);
496  return rr;
497 }
int result_af
Desired address family for the result.
Definition: vpn_api.c:130
#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...
struct GNUNET_TIME_Absolute expiration_time
At what time should the created service mapping expire?
Definition: vpn_api.c:120
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:100
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
Definition: vpn_api.c:53
Opaque redirection request handle.
Definition: vpn_api.c:75
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void * cb_cls
Closure for cb.
Definition: vpn_api.c:105
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:48
int addr_af
Address family of addr.
Definition: vpn_api.c:135
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
Definition: vpn_api.c:236
#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:95
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:89
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 507 of file vpn_api.c.

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

Referenced by GNS_resolver_init(), and run().

508 {
509  struct GNUNET_VPN_Handle *vh
510  = GNUNET_new(struct GNUNET_VPN_Handle);
511 
512  vh->cfg = cfg;
513  connect_task(vh);
514  if (NULL == vh->mq)
515  {
516  GNUNET_free(vh);
517  return NULL;
518  }
519  return vh;
520 }
static void connect_task(void *cls)
Connect to the VPN service and start again to transmit our requests.
Definition: vpn_api.c:315
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:43
Opaque VPN handle.
Definition: vpn_api.c:34
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
Definition: vpn_api.c:38
#define GNUNET_free(ptr)
Wrapper around free.
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 529 of file vpn_api.c.

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(), and GNS_resolver_done().

530 {
531  GNUNET_assert(NULL == vh->rr_head);
532  if (NULL != vh->mq)
533  {
534  GNUNET_MQ_destroy(vh->mq);
535  vh->mq = NULL;
536  }
537  if (NULL != vh->rt)
538  {
540  vh->rt = NULL;
541  }
542  GNUNET_free(vh);
543 }
struct GNUNET_SCHEDULER_Task * rt
Identifier of a reconnect task.
Definition: vpn_api.c:58
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:43
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:48
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function: