GNUnet 0.21.1
nat_auto_api.c File Reference
#include "platform.h"
#include "gnunet_nat_service.h"
#include "gnunet_nat_auto_service.h"
#include "nat-auto.h"
Include dependency graph for nat_auto_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_NAT_AUTO_AutoHandle
 Handle to auto-configuration in progress. More...
 

Functions

const char * GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err)
 Converts enum GNUNET_NAT_StatusCode to string. More...
 
static int check_auto_result (void *cls, const struct GNUNET_NAT_AUTO_AutoconfigResultMessage *res)
 Check result from autoconfiguration attempt. More...
 
static void handle_auto_result (void *cls, const struct GNUNET_NAT_AUTO_AutoconfigResultMessage *res)
 Handle result from autoconfiguration attempt. More...
 
static void ah_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Handle queue errors by reporting autoconfiguration failure. More...
 
struct GNUNET_NAT_AUTO_AutoHandleGNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NAT_AUTO_AutoResultCallback cb, void *cb_cls)
 Start auto-configuration routine. More...
 
void GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah)
 Abort autoconfiguration. More...
 

Detailed Description

Author
Christian Grothoff
Milan Bouchet-Valat

Routines for NAT auto configuration.

Definition in file nat_auto_api.c.

Function Documentation

◆ check_auto_result()

static int check_auto_result ( void *  cls,
const struct GNUNET_NAT_AUTO_AutoconfigResultMessage res 
)
static

Check result from autoconfiguration attempt.

Parameters
clsthe struct GNUNET_NAT_AUTO_AutoHandle
resthe result
Returns
GNUNET_OK if res is well-formed (always for now)

Definition at line 144 of file nat_auto_api.c.

146{
147 return GNUNET_OK;
148}
@ GNUNET_OK

References GNUNET_OK.

◆ handle_auto_result()

static void handle_auto_result ( void *  cls,
const struct GNUNET_NAT_AUTO_AutoconfigResultMessage res 
)
static

Handle result from autoconfiguration attempt.

Parameters
clsthe struct GNUNET_NAT_AUTO_AutoHandle
resthe result

Definition at line 158 of file nat_auto_api.c.

160{
161 struct GNUNET_NAT_AUTO_AutoHandle *ah = cls;
162 size_t left;
165 = (enum GNUNET_NAT_Type) ntohl (res->type);
167 = (enum GNUNET_NAT_StatusCode) ntohl (res->status_code);
168
169 left = ntohs (res->header.size) - sizeof(*res);
171 if (GNUNET_OK !=
173 (const char *) &res[1],
174 left,
175 NULL))
176 {
177 GNUNET_break (0);
178 ah->arc (ah->arc_cls,
179 NULL,
181 type);
182 }
183 else
184 {
185 ah->arc (ah->arc_cls,
186 cfg,
187 status,
188 type);
189 }
192}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static char * res
Currently read line or NULL on EOF.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:38
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
De-serializes configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
GNUNET_NAT_StatusCode
Error Types for the NAT subsystem (which can then later be converted/resolved to a string)
GNUNET_NAT_Type
What the situation of the NAT connectivity.
void GNUNET_NAT_AUTO_autoconfig_cancel(struct GNUNET_NAT_AUTO_AutoHandle *ah)
Abort autoconfiguration.
Definition: nat_auto_api.c:285
@ GNUNET_NAT_ERROR_IPC_FAILURE
IPC Failure.
Handle to auto-configuration in progress.
Definition: nat_auto_api.c:38
void * arc_cls
Closure for arc.
Definition: nat_auto_api.c:57
GNUNET_NAT_AUTO_AutoResultCallback arc
Function called with the result from the autoconfiguration.
Definition: nat_auto_api.c:52

References ah, GNUNET_NAT_AUTO_AutoHandle::arc, GNUNET_NAT_AUTO_AutoHandle::arc_cls, cfg, GNUNET_break, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_destroy(), GNUNET_NAT_AUTO_autoconfig_cancel(), GNUNET_NAT_ERROR_IPC_FAILURE, GNUNET_OK, res, status, and type.

Here is the call graph for this function:

◆ ah_error_handler()

static void ah_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Handle queue errors by reporting autoconfiguration failure.

Parameters
clsthe struct GNUNET_NAT_AUTO_AutoHandle *
errordetails about the error

Definition at line 202 of file nat_auto_api.c.

204{
205 struct GNUNET_NAT_AUTO_AutoHandle *ah = cls;
206
207 ah->arc (ah->arc_cls,
208 NULL,
212}
@ GNUNET_NAT_TYPE_UNKNOWN
We know nothing about the NAT.

References ah, GNUNET_NAT_AUTO_AutoHandle::arc, GNUNET_NAT_AUTO_AutoHandle::arc_cls, GNUNET_NAT_AUTO_autoconfig_cancel(), GNUNET_NAT_ERROR_IPC_FAILURE, and GNUNET_NAT_TYPE_UNKNOWN.

Referenced by GNUNET_NAT_AUTO_autoconfig_start().

Here is the call graph for this function:
Here is the caller graph for this function: