GNUnet 0.22.2
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;
164 enum GNUNET_NAT_Type type = ntohl (res->type);
165 enum GNUNET_NAT_StatusCode status = ntohl (res->status_code);
166
167 left = ntohs (res->header.size) - sizeof(*res);
169 if (GNUNET_OK !=
171 (const char *) &res[1],
172 left,
173 NULL))
174 {
175 GNUNET_break (0);
176 ah->arc (ah->arc_cls,
177 NULL,
179 type);
180 }
181 else
182 {
183 ah->arc (ah->arc_cls,
184 cfg,
185 status,
186 type);
187 }
190}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
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:39
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
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.
#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:283
@ GNUNET_NAT_ERROR_IPC_FAILURE
IPC Failure.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
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, GNUNET_OS_project_data_gnunet(), 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 200 of file nat_auto_api.c.

202{
203 struct GNUNET_NAT_AUTO_AutoHandle *ah = cls;
204
205 ah->arc (ah->arc_cls,
206 NULL,
210}
@ 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: