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

242 {
243  if (GNUNET_YES != enable_upnp)
244  return;
245  if ((GNUNET_YES == have_nat) &&
246  (NULL == probe_external_ip_task) &&
247  (NULL == probe_external_ip_op))
248  {
251  NULL);
252  return;
253  }
254  if (GNUNET_NO == have_nat)
255  {
256  if (NULL != probe_external_ip_task)
257  {
259  probe_external_ip_task = NULL;
260  }
261  if (NULL != probe_external_ip_op)
262  {
264  probe_external_ip_op = NULL;
265  }
266  }
267 }
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:78
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:1264
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:77
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:956
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 278 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().

280 {
281  struct GN_ExternalIPMonitor *mon;
282 
283  mon = GNUNET_new(struct GN_ExternalIPMonitor);
284  mon->cb = cb;
285  mon->cb_cls = cb_cls;
287  mon_tail,
288  mon);
289  if (0 != mini_external_ipv4.s_addr)
290  cb(cb_cls,
292  GNUNET_YES);
293  return mon;
294 }
#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:77
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 303 of file gnunet-service-nat_externalip.c.

References GNUNET_CONTAINER_DLL_remove, and GNUNET_free.

Referenced by client_disconnect_cb().

304 {
306  mon_tail,
307  mon);
308  GNUNET_free(mon);
309 }
#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: