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

370 {
371  struct GNUNET_VPN_Handle *vh;
372 
373  vh = rr->vh;
375  vh->rr_tail,
376  rr);
377  GNUNET_free (rr);
378 }
#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:54
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:49
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:92
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 404 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().

412 {
414 
416  rr->vh = vh;
417  rr->cb = cb;
418  rr->cb_cls = cb_cls;
419  rr->peer = *peer;
420  rr->serv = *serv;
422  rr->result_af = result_af;
423  rr->protocol = protocol;
425  vh->rr_tail,
426  rr);
427  send_request (rr);
428  return rr;
429 }
int result_af
Desired address family for the result.
Definition: vpn_api.c:133
struct GNUNET_PeerIdentity peer
For service redirection, identity of the peer offering the service.
Definition: vpn_api.c:113
#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:123
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:103
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
Definition: vpn_api.c:54
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Opaque redirection request handle.
Definition: vpn_api.c:77
#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:143
void * cb_cls
Closure for cb.
Definition: vpn_api.c:108
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:49
struct GNUNET_HashCode serv
For service redirection, service descriptor.
Definition: vpn_api.c:118
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
Definition: vpn_api.c:237
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:92
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 455 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().

462 {
464  size_t alen;
465 
466  switch (addr_af)
467  {
468  case AF_INET:
469  alen = sizeof (struct in_addr);
470  break;
471  case AF_INET6:
472  alen = sizeof (struct in6_addr);
473  break;
474  default:
475  GNUNET_break (0);
476  return NULL;
477  }
478  rr = GNUNET_malloc (sizeof (struct GNUNET_VPN_RedirectionRequest) + alen);
479  rr->vh = vh;
480  rr->addr = &rr[1];
481  rr->cb = cb;
482  rr->cb_cls = cb_cls;
483  rr->expiration_time = expiration_time;
484  rr->result_af = result_af;
485  rr->addr_af = addr_af;
486  GNUNET_memcpy (&rr[1],
487  addr,
488  alen);
490  vh->rr_tail,
491  rr);
492  send_request (rr);
493  return rr;
494 }
int result_af
Desired address family for the result.
Definition: vpn_api.c:133
#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:123
#define GNUNET_memcpy(dst, src, n)
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:103
struct GNUNET_VPN_RedirectionRequest * rr_tail
Tail of list of active redirection requests.
Definition: vpn_api.c:54
Opaque redirection request handle.
Definition: vpn_api.c:77
#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:108
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:49
int addr_af
Address family of addr.
Definition: vpn_api.c:138
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
Definition: vpn_api.c:237
#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:98
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:92
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 504 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().

505 {
506  struct GNUNET_VPN_Handle *vh
507  = GNUNET_new (struct GNUNET_VPN_Handle);
508 
509  vh->cfg = cfg;
510  connect_task (vh);
511  if (NULL == vh->mq)
512  {
513  GNUNET_free (vh);
514  return NULL;
515  }
516  return vh;
517 }
static void connect_task(void *cls)
Connect to the VPN service and start again to transmit our requests.
Definition: vpn_api.c:314
#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:44
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:39
#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 526 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().

527 {
528  GNUNET_assert (NULL == vh->rr_head);
529  if (NULL != vh->mq)
530  {
531  GNUNET_MQ_destroy (vh->mq);
532  vh->mq = NULL;
533  }
534  if (NULL != vh->rt)
535  {
537  vh->rt = NULL;
538  }
539  GNUNET_free (vh);
540 }
struct GNUNET_SCHEDULER_Task * rt
Identifier of a reconnect task.
Definition: vpn_api.c:59
#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:44
struct GNUNET_VPN_RedirectionRequest * rr_head
Head of list of active redirection requests.
Definition: vpn_api.c:49
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#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:965
Here is the call graph for this function:
Here is the caller graph for this function: