GNUnet  0.17.5
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.


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


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

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.

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

Definition at line 59 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.

have_natGNUNET_YES if we believe we are behind NAT

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

246 {
247  if (GNUNET_YES != enable_upnp)
248  return;
249  if ((GNUNET_YES == have_nat) &&
250  (NULL == probe_external_ip_task) &&
251  (NULL == probe_external_ip_op))
252  {
255  NULL);
256  return;
257  }
258  if (GNUNET_NO == have_nat)
259  {
260  if (NULL != probe_external_ip_task)
261  {
263  probe_external_ip_task = NULL;
264  }
265  if (NULL != probe_external_ip_op)
266  {
268  probe_external_ip_op = NULL;
269  }
270  }
271 }
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.
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).
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...
void GNUNET_NAT_mini_get_external_ipv4_cancel_(struct GNUNET_NAT_ExternalHandle *eh)
Cancel operation.
Definition: gnunet_common.h:98
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:1281
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957

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

Referenced by run_scan(), and shutdown_task().

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.

cbfunction to call on changes
cb_clsclosure for cb
handle to cancel

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

284 {
285  struct GN_ExternalIPMonitor *mon;
287  mon = GNUNET_new (struct GN_ExternalIPMonitor);
288  mon->cb = cb;
289  mon->cb_cls = cb_cls;
291  mon_tail,
292  mon);
293  if (0 != mini_external_ipv4.s_addr)
294  cb (cb_cls,
297  return mon;
298 }
static struct GN_ExternalIPMonitor * mon_tail
List of monitors, kept in DLL.
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.
#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.
GN_NotifyExternalIPv4Change cb
Function to call when we believe our external IPv4 address changed.

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

Referenced by handle_register().

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.

monmonitor to call

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

308 {
310  mon_tail,
311  mon);
312  GNUNET_free (mon);
313 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, mon_head, and mon_tail.

Referenced by client_disconnect_cb().

Here is the caller graph for this function: