GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-nat-auto.c File Reference

NAT autoconfiguration service. More...

#include "platform.h"
#include <math.h>
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
#include "gnunet_nat_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet_resolver_service.h"
#include "nat-auto.h"
#include <gcrypt.h>
Include dependency graph for gnunet-service-nat-auto.c:

Go to the source code of this file.

Data Structures

struct  ClientHandle
 Struct containing information about a client, handle to connect to it, and any pending messages that need to be sent to it. More...
 
struct  AutoconfigContext
 Context for autoconfiguration operations. More...
 

Macros

#define AUTOCONFIG_TIMEOUT   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 How long do we wait until we forcefully terminate autoconfiguration? More...
 

Functions

static int check_autoconfig_request (void *cls, const struct GNUNET_NAT_AUTO_AutoconfigRequestMessage *message)
 Check validity of #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG message from client. More...
 
static void terminate_ac_activities (struct AutoconfigContext *ac)
 Stop all pending activities with respect to the ac. More...
 
static void conclude_autoconfig_request (void *cls)
 Finish handling the autoconfiguration request and send the response to the client. More...
 
static void check_autoconfig_finished (struct AutoconfigContext *ac)
 Check if all autoconfiguration operations have concluded, and if they have, send the result back to the client. More...
 
static void update_enable_upnpc_option (struct AutoconfigContext *ac)
 Update ENABLE_UPNPC configuration option. More...
 
static void handle_autoconfig_request (void *cls, const struct GNUNET_NAT_AUTO_AutoconfigRequestMessage *message)
 Handler for #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG message from client. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Setup NAT service. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
 Callback called when a client connects to the service. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
 Callback called when a client disconnected from the service. More...
 
 GNUNET_SERVICE_MAIN ("nat-auto", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(autoconfig_request, GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG, struct GNUNET_NAT_AUTO_AutoconfigRequestMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct ClientHandlech_head
 Head of client DLL. More...
 
static struct ClientHandlech_tail
 Tail of client DLL. More...
 
static struct AutoconfigContextac_head
 DLL of our autoconfiguration operations. More...
 
static struct AutoconfigContextac_tail
 DLL of our autoconfiguration operations. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Handle to our current configuration. More...
 
static struct GNUNET_STATISTICS_Handlestats
 Handle to the statistics service. More...
 

Detailed Description

NAT autoconfiguration service.

Author
Christian Grothoff

TODO:

Definition in file gnunet-service-nat-auto.c.

Macro Definition Documentation

◆ AUTOCONFIG_TIMEOUT

#define AUTOCONFIG_TIMEOUT   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)

How long do we wait until we forcefully terminate autoconfiguration?

Definition at line 48 of file gnunet-service-nat-auto.c.

Referenced by handle_autoconfig_request().

Function Documentation

◆ check_autoconfig_request()

static int check_autoconfig_request ( void *  cls,
const struct GNUNET_NAT_AUTO_AutoconfigRequestMessage message 
)
static

Check validity of #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG message from client.

Parameters
clsclient who sent the message
messagethe message received
Returns
GNUNET_OK if message is well-formed

Definition at line 173 of file gnunet-service-nat-auto.c.

References GNUNET_OK.

175 {
176  return GNUNET_OK; /* checked later */
177 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ terminate_ac_activities()

static void terminate_ac_activities ( struct AutoconfigContext ac)
static

Stop all pending activities with respect to the ac.

Parameters
acautoconfiguration to terminate activities for

Definition at line 186 of file gnunet-service-nat-auto.c.

References GNUNET_SCHEDULER_cancel(), and AutoconfigContext::timeout_task.

Referenced by conclude_autoconfig_request(), and shutdown_task().

187 {
188  if (NULL != ac->timeout_task)
189  {
191  ac->timeout_task = NULL;
192  }
193 }
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task to force termination.
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:

◆ conclude_autoconfig_request()

static void conclude_autoconfig_request ( void *  cls)
static

Finish handling the autoconfiguration request and send the response to the client.

Parameters
clsthe struct AutoconfigContext to conclude

Definition at line 203 of file gnunet-service-nat-auto.c.

References ac, buf, AutoconfigContext::c, AutoconfigContext::ch, ch, ClientHandle::client, env, GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_diff(), GNUNET_CONFIGURATION_serialize(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), ClientHandle::mq, AutoconfigContext::orig, GNUNET_NAT_AUTO_AutoconfigResultMessage::status_code, AutoconfigContext::status_code, terminate_ac_activities(), AutoconfigContext::timeout_task, GNUNET_NAT_AUTO_AutoconfigResultMessage::type, and AutoconfigContext::type.

Referenced by check_autoconfig_finished(), and handle_autoconfig_request().

204 {
205  struct AutoconfigContext *ac = cls;
206  struct ClientHandle *ch = ac->ch;
208  struct GNUNET_MQ_Envelope *env;
209  size_t c_size;
210  char *buf;
211  struct GNUNET_CONFIGURATION_Handle *diff;
212 
213  ac->timeout_task = NULL;
215 
216  /* Send back response */
218  ac->c);
219  buf = GNUNET_CONFIGURATION_serialize (diff,
220  &c_size);
222  env = GNUNET_MQ_msg_extra (arm,
223  c_size,
225  arm->status_code = htonl ((uint32_t) ac->status_code);
226  arm->type = htonl ((uint32_t) ac->type);
227  GNUNET_memcpy (&arm[1],
228  buf,
229  c_size);
230  GNUNET_free (buf);
231  GNUNET_MQ_send (ch->mq,
232  env);
233 
234  /* clean up */
238  ac_tail,
239  ac);
240  GNUNET_free (ac);
242 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT
Message from NAT service with the autoconfiguration result.
struct GNUNET_CONFIGURATION_Handle * c
Configuration we are creating.
Service responding with proposed configuration.
Definition: nat-auto.h:87
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task to force termination.
int32_t status_code
An enum GNUNET_NAT_StatusCode in NBO.
Definition: nat-auto.h:97
static struct AutoconfigContext * ac_head
DLL of our autoconfiguration operations.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
enum GNUNET_NAT_Type type
NAT type to return to the client.
#define GNUNET_memcpy(dst, src, n)
int32_t type
An enum GNUNET_NAT_Type in NBO.
Definition: nat-auto.h:102
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_get_diff(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new)
Compute configuration with only entries that have been changed.
Context for autoconfiguration operations.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static char buf[2048]
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
static void terminate_ac_activities(struct AutoconfigContext *ac)
Stop all pending activities with respect to the ac.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
The message queue to this client.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
configuration data
Definition: configuration.c:85
struct ClientHandle * ch
Which client asked the question.
struct GNUNET_CONFIGURATION_Handle * orig
Original configuration (for diffing).
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
enum GNUNET_NAT_StatusCode status_code
Status code to return to the client.
static struct AutoconfigContext * ac_tail
DLL of our autoconfiguration operations.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_autoconfig_finished()

static void check_autoconfig_finished ( struct AutoconfigContext ac)
static

Check if all autoconfiguration operations have concluded, and if they have, send the result back to the client.

Parameters
acautoconfiguation context to check

Definition at line 252 of file gnunet-service-nat-auto.c.

References conclude_autoconfig_request(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), and AutoconfigContext::timeout_task.

Referenced by handle_autoconfig_request().

253 {
255  ac->timeout_task
257  ac);
258 }
static void conclude_autoconfig_request(void *cls)
Finish handling the autoconfiguration request and send the response to the client.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task to force termination.
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
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:

◆ update_enable_upnpc_option()

static void update_enable_upnpc_option ( struct AutoconfigContext ac)
static

Update ENABLE_UPNPC configuration option.

Parameters
acautoconfiguration to update

Definition at line 267 of file gnunet-service-nat-auto.c.

References AutoconfigContext::c, AutoconfigContext::enable_upnpc, GNUNET_CONFIGURATION_set_value_string(), GNUNET_NO, GNUNET_SYSERR, and GNUNET_YES.

Referenced by handle_autoconfig_request().

268 {
269  switch (ac->enable_upnpc)
270  {
271  case GNUNET_YES:
273  "NAT",
274  "ENABLE_UPNP",
275  "YES");
276  break;
277  case GNUNET_NO:
279  "NAT",
280  "ENABLE_UPNP",
281  "NO");
282  break;
283  case GNUNET_SYSERR:
284  /* We are unsure, do not change option */
285  break;
286  }
287 }
struct GNUNET_CONFIGURATION_Handle * c
Configuration we are creating.
int enable_upnpc
GNUNET_YES if upnpc should be used, GNUNET_NO if upnpc should not be used, GNUNET_SYSERR if we should...
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_autoconfig_request()

static void handle_autoconfig_request ( void *  cls,
const struct GNUNET_NAT_AUTO_AutoconfigRequestMessage message 
)
static

Handler for #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG message from client.

Parameters
clsclient who sent the message
messagethe message received

Definition at line 298 of file gnunet-service-nat-auto.c.

References _, ac, AUTOCONFIG_TIMEOUT, AutoconfigContext::c, AutoconfigContext::ch, ch, check_autoconfig_finished(), ClientHandle::client, conclude_autoconfig_request(), AutoconfigContext::enable_upnpc, GNUNET_break, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_dup(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NAT_ERROR_SUCCESS, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_OS_check_helper_binary(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, GNUNET_NAT_AUTO_AutoconfigRequestMessage::header, AutoconfigContext::orig, GNUNET_MessageHeader::size, AutoconfigContext::status_code, AutoconfigContext::timeout_task, and update_enable_upnpc_option().

300 {
301  struct ClientHandle *ch = cls;
302  size_t left = ntohs (message->header.size) - sizeof (*message);
303  struct AutoconfigContext *ac;
304 
305  ac = GNUNET_new (struct AutoconfigContext);
307  ac->ch = ch;
309  if (GNUNET_OK !=
311  (const char *) &message[1],
312  left,
313  NULL))
314  {
315  GNUNET_break (0);
318  GNUNET_free (ac);
319  return;
320  }
322  "Received REQUEST_AUTO_CONFIG message from client\n");
323 
325  ac_tail,
326  ac);
327  ac->orig
328  = GNUNET_CONFIGURATION_dup (ac->c);
329  ac->timeout_task
332  ac);
333  ac->enable_upnpc = GNUNET_SYSERR; /* undecided */
334 
335  /* Probe for upnpc */
336  if (GNUNET_SYSERR ==
338  GNUNET_NO,
339  NULL))
340  {
342  _("UPnP client `upnpc` command not found, disabling UPnP\n"));
343  ac->enable_upnpc = GNUNET_NO;
344  }
345  else
346  {
347  /* We might at some point be behind NAT, try upnpc */
348  ac->enable_upnpc = GNUNET_YES;
349  }
351 
352  /* Finally, check if we are already done */
354 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_CONFIGURATION_Handle * c
Configuration we are creating.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void conclude_autoconfig_request(void *cls)
Finish handling the autoconfiguration request and send the response to the client.
int enable_upnpc
GNUNET_YES if upnpc should be used, GNUNET_NO if upnpc should not be used, GNUNET_SYSERR if we should...
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task to force termination.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GNUNET_OS_check_helper_binary(const char *binary, int check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static void check_autoconfig_finished(struct AutoconfigContext *ac)
Check if all autoconfiguration operations have concluded, and if they have, send the result back to t...
static struct AutoconfigContext * ac_head
DLL of our autoconfiguration operations.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
Context for autoconfiguration operations.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static void update_enable_upnpc_option(struct AutoconfigContext *ac)
Update ENABLE_UPNPC configuration option.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
struct ClientHandle * ch
Which client asked the question.
#define GNUNET_log(kind,...)
struct GNUNET_CONFIGURATION_Handle * orig
Original configuration (for diffing).
struct GNUNET_MessageHeader header
Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG.
Definition: nat-auto.h:77
#define GNUNET_YES
Definition: gnunet_common.h:80
int GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
De-serializes configuration.
enum GNUNET_NAT_StatusCode status_code
Status code to return to the client.
#define AUTOCONFIG_TIMEOUT
How long do we wait until we forcefully terminate autoconfiguration?
static struct AutoconfigContext * ac_tail
DLL of our autoconfiguration operations.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 363 of file gnunet-service-nat-auto.c.

References ac, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_destroy(), and terminate_ac_activities().

Referenced by run().

364 {
365  struct AutoconfigContext *ac;
366 
367  while (NULL != (ac = ac_head))
368  {
370  ac_tail,
371  ac);
373  GNUNET_free (ac);
374  }
375  if (NULL != stats)
376  {
378  GNUNET_NO);
379  stats = NULL;
380  }
381 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
static struct AutoconfigContext * ac_head
DLL of our autoconfiguration operations.
Context for autoconfiguration operations.
static void terminate_ac_activities(struct AutoconfigContext *ac)
Stop all pending activities with respect to the ac.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static struct AutoconfigContext * ac_tail
DLL of our autoconfiguration operations.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Setup NAT service.

Parameters
clsclosure
cconfiguration to use
servicethe initialized service

Definition at line 392 of file gnunet-service-nat-auto.c.

References AutoconfigContext::c, GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), and shutdown_task().

Referenced by client_disconnect_cb().

395 {
396  cfg = c;
398  NULL);
399  stats = GNUNET_STATISTICS_create ("nat-auto",
400  cfg);
401 }
struct GNUNET_CONFIGURATION_Handle * c
Configuration we are creating.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
static void shutdown_task(void *cls)
Task run during shutdown.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client c,
struct GNUNET_MQ_Handle mq 
)
static

Callback called when a client connects to the service.

Parameters
clsclosure for the service
cthe new client that connected to the service
mqthe message queue used to send messages to the client
Returns
a struct ClientHandle

Definition at line 413 of file gnunet-service-nat-auto.c.

References ch, ClientHandle::client, GNUNET_CONTAINER_DLL_insert, GNUNET_new, and ClientHandle::mq.

Referenced by client_disconnect_cb().

416 {
417  struct ClientHandle *ch;
418 
419  ch = GNUNET_new (struct ClientHandle);
420  ch->mq = mq;
421  ch->client = c;
423  ch_tail,
424  ch);
425  return ch;
426 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#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.
static struct ClientHandle * ch_tail
Tail of client DLL.
struct GNUNET_SERVICE_Client * client
The handle to this client.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
struct GNUNET_MQ_Handle * mq
The message queue to this client.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static struct ClientHandle * ch_head
Head of client DLL.
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client c,
void *  internal_cls 
)
static

Callback called when a client disconnected from the service.

Parameters
clsclosure for the service
cthe client that disconnected
internal_clsa struct ClientHandle *

Definition at line 437 of file gnunet-service-nat-auto.c.

References __attribute__, ch, client_connect_cb(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, and run().

440 {
441  struct ClientHandle *ch = internal_cls;
442 
444  ch_tail,
445  ch);
446  GNUNET_free (ch);
447 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct ClientHandle * ch_tail
Tail of client DLL.
Struct containing information about a client, handle to connect to it, and any pending messages that ...
static struct ClientHandle * ch_head
Head of client DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "nat-auto"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_var_size(autoconfig_request, GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG, struct GNUNET_NAT_AUTO_AutoconfigRequestMessage, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

Referenced by client_disconnect_cb().

Here is the caller graph for this function:

Variable Documentation

◆ ch_head

struct ClientHandle* ch_head
static

Head of client DLL.

Definition at line 136 of file gnunet-service-nat-auto.c.

◆ ch_tail

struct ClientHandle* ch_tail
static

Tail of client DLL.

Definition at line 141 of file gnunet-service-nat-auto.c.

◆ ac_head

struct AutoconfigContext* ac_head
static

DLL of our autoconfiguration operations.

Definition at line 146 of file gnunet-service-nat-auto.c.

◆ ac_tail

struct AutoconfigContext* ac_tail
static

DLL of our autoconfiguration operations.

Definition at line 151 of file gnunet-service-nat-auto.c.

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Handle to our current configuration.

Definition at line 156 of file gnunet-service-nat-auto.c.

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

Handle to the statistics service.

Definition at line 161 of file gnunet-service-nat-auto.c.