GNUnet  0.11.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 375 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().

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.
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:91
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 410 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().

418 {
420 
422  rr->vh = vh;
423  rr->cb = cb;
424  rr->cb_cls = cb_cls;
425  rr->peer = *peer;
426  rr->serv = *serv;
428  rr->result_af = result_af;
429  rr->protocol = protocol;
431  vh->rr_tail,
432  rr);
433  send_request (rr);
434  return rr;
435 }
int result_af
Desired address family for the result.
Definition: vpn_api.c:132
struct GNUNET_PeerIdentity peer
For service redirection, identity of the peer offering the service.
Definition: vpn_api.c:112
#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:122
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:102
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:76
#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:142
void * cb_cls
Closure for cb.
Definition: vpn_api.c:107
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: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
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:91
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 461 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().

468 {
470  size_t alen;
471 
472  switch (addr_af)
473  {
474  case AF_INET:
475  alen = sizeof(struct in_addr);
476  break;
477 
478  case AF_INET6:
479  alen = sizeof(struct in6_addr);
480  break;
481 
482  default:
483  GNUNET_break (0);
484  return NULL;
485  }
486  rr = GNUNET_malloc (sizeof(struct GNUNET_VPN_RedirectionRequest) + alen);
487  rr->vh = vh;
488  rr->addr = &rr[1];
489  rr->cb = cb;
490  rr->cb_cls = cb_cls;
491  rr->expiration_time = expiration_time;
492  rr->result_af = result_af;
493  rr->addr_af = addr_af;
494  GNUNET_memcpy (&rr[1],
495  addr,
496  alen);
498  vh->rr_tail,
499  rr);
500  send_request (rr);
501  return rr;
502 }
int result_af
Desired address family for the result.
Definition: vpn_api.c:132
#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:122
GNUNET_VPN_AllocationCallback cb
Function to call with the designated IP address.
Definition: vpn_api.c:102
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:76
#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:107
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:137
static void send_request(struct GNUNET_VPN_RedirectionRequest *rr)
Add a request to our request queue and transmit it.
Definition: vpn_api.c:238
#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
struct GNUNET_VPN_Handle * vh
Pointer to the VPN struct.
Definition: vpn_api.c:91
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 512 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().

513 {
514  struct GNUNET_VPN_Handle *vh
515  = GNUNET_new (struct GNUNET_VPN_Handle);
516 
517  vh->cfg = cfg;
518  connect_task (vh);
519  if (NULL == vh->mq)
520  {
521  GNUNET_free (vh);
522  return NULL;
523  }
524  return vh;
525 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static void connect_task(void *cls)
Connect to the VPN service and start again to transmit our requests.
Definition: vpn_api.c:317
#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
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 534 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().

535 {
536  GNUNET_assert (NULL == vh->rr_head);
537  if (NULL != vh->mq)
538  {
539  GNUNET_MQ_destroy (vh->mq);
540  vh->mq = NULL;
541  }
542  if (NULL != vh->rt)
543  {
545  vh->rt = NULL;
546  }
547  GNUNET_free (vh);
548 }
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:966
Here is the call graph for this function:
Here is the caller graph for this function: