GNUnet  0.10.x
Typedefs | Functions
gnunet-service-nat_externalip.h File Reference

Code to figure out what our external IPv4 address(es) might be (external IPv4s are what is seen on the rest of the Internet). More...

#include "platform.h"
Include dependency graph for gnunet-service-nat_externalip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* GN_NotifyExternalIPv4Change) (void *cls, const struct in_addr *ip, int add_remove)
 Function we call when we believe our external IPv4 address changed. More...
 

Functions

void GN_nat_status_changed (int have_nat)
 We have changed our opinion about being NATed in the first place. More...
 
struct GN_ExternalIPMonitorGN_external_ipv4_monitor_start (GN_NotifyExternalIPv4Change cb, void *cb_cls)
 Start monitoring external IPv4 addresses. More...
 
void GN_external_ipv4_monitor_stop (struct GN_ExternalIPMonitor *mon)
 Stop calling monitor. More...
 

Detailed Description

Code to figure out what our external IPv4 address(es) might be (external IPv4s are what is seen on the rest of the Internet).

This can be implemented using different methods, and we allow the main service to be notified about changes to what we believe is our external IPv4 address.

Note that this is explicitly only about NATed systems; if one of our network interfaces has a global IP address this does not count as "external".

Functions for monitoring external IPv4 addresses

Author
Christian Grothoff

Definition in file gnunet-service-nat_externalip.h.

Typedef Documentation

◆ GN_NotifyExternalIPv4Change

typedef void(* GN_NotifyExternalIPv4Change) (void *cls, const struct in_addr *ip, int add_remove)

Function we call when we believe our external IPv4 address changed.

Parameters
clsclosure
ipaddress to add/remove
add_removeGNUNET_YES to add, GNUNET_NO to remove

Definition at line 60 of file gnunet-service-nat_externalip.h.

Function Documentation

◆ GN_nat_status_changed()

void GN_nat_status_changed ( int  have_nat)

We have changed our opinion about being NATed in the first place.

Adapt our probing.

Parameters
have_natGNUNET_YES if we believe we are behind NAT

Definition at line 242 of file gnunet-service-nat_externalip.c.

References enable_upnp, GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, and run_external_ip().

Referenced by run_scan(), and shutdown_task().

243 {
244  if (GNUNET_YES != enable_upnp)
245  return;
246  if ( (GNUNET_YES == have_nat) &&
247  (NULL == probe_external_ip_task) &&
248  (NULL == probe_external_ip_op) )
249  {
252  NULL);
253  return;
254  }
255  if (GNUNET_NO == have_nat)
256  {
257  if (NULL != probe_external_ip_task)
258  {
260  probe_external_ip_task = NULL;
261  }
262  if (NULL != probe_external_ip_op)
263  {
265  probe_external_ip_op = NULL;
266  }
267  }
268 }
static void run_external_ip(void *cls)
Task used to run external-ip to get our external IPv4 address and pass it to NATed clients if possibl...
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static struct GNUNET_SCHEDULER_Task * probe_external_ip_task
Task run to obtain our external IP (if enable_upnp is set and if we find we have a NATed IP address)...
int enable_upnp
Is UPnP enabled? GNUNET_YES if enabled, GNUNET_NO if disabled, GNUNET_SYSERR if configuration enabled...
static struct GNUNET_NAT_ExternalHandle * probe_external_ip_op
Handle to our operation to run external-ip.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_NAT_mini_get_external_ipv4_cancel_(struct GNUNET_NAT_ExternalHandle *eh)
Cancel operation.
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:

◆ GN_external_ipv4_monitor_start()

struct GN_ExternalIPMonitor* GN_external_ipv4_monitor_start ( GN_NotifyExternalIPv4Change  cb,
void *  cb_cls 
)

Start monitoring external IPv4 addresses.

Parameters
cbfunction to call on changes
cb_clsclosure for cb
Returns
handle to cancel

Definition at line 279 of file gnunet-service-nat_externalip.c.

References GN_ExternalIPMonitor::cb, GN_ExternalIPMonitor::cb_cls, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_YES, and mini_external_ipv4.

Referenced by handle_register().

281 {
282  struct GN_ExternalIPMonitor *mon;
283 
284  mon = GNUNET_new (struct GN_ExternalIPMonitor);
285  mon->cb = cb;
286  mon->cb_cls = cb_cls;
288  mon_tail,
289  mon);
290  if (0 != mini_external_ipv4.s_addr)
291  cb (cb_cls,
293  GNUNET_YES);
294  return mon;
295 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle to monitor for external IP changes.
static struct in_addr mini_external_ipv4
What is our external IP address as claimed by external-ip? 0 for unknown.
static struct GN_ExternalIPMonitor * mon_head
List of monitors, kept in DLL.
GN_NotifyExternalIPv4Change cb
Function to call when we believe our external IPv4 address changed.
#define GNUNET_YES
Definition: gnunet_common.h:80
static struct GN_ExternalIPMonitor * mon_tail
List of monitors, kept in DLL.
Here is the caller graph for this function:

◆ GN_external_ipv4_monitor_stop()

void GN_external_ipv4_monitor_stop ( struct GN_ExternalIPMonitor mon)

Stop calling monitor.

Parameters
monmonitor to call

Definition at line 304 of file gnunet-service-nat_externalip.c.

References GNUNET_CONTAINER_DLL_remove, and GNUNET_free.

Referenced by client_disconnect_cb().

305 {
307  mon_tail,
308  mon);
309  GNUNET_free (mon);
310 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GN_ExternalIPMonitor * mon_head
List of monitors, kept in DLL.
static struct GN_ExternalIPMonitor * mon_tail
List of monitors, kept in DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function: