GNUnet  0.10.x
Data Structures | Functions
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 143 of file nat_auto_api.c.

References GNUNET_OK.

145 {
146  return GNUNET_OK;
147 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ 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 157 of file nat_auto_api.c.

References ah, GNUNET_NAT_AUTO_AutoHandle::arc, GNUNET_NAT_AUTO_AutoHandle::arc_cls, GNUNET_NAT_AUTO_AutoHandle::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_NAT_AUTO_AutoconfigResultMessage::header, GNUNET_MessageHeader::size, status, GNUNET_NAT_AUTO_AutoconfigResultMessage::status_code, GNUNET_NAT_AUTO_AutoconfigResultMessage::type, and type.

159 {
160  struct GNUNET_NAT_AUTO_AutoHandle *ah = cls;
161  size_t left;
163  enum GNUNET_NAT_Type type
164  = (enum GNUNET_NAT_Type)ntohl(res->type);
166  = (enum GNUNET_NAT_StatusCode)ntohl(res->status_code);
167 
168  left = ntohs(res->header.size) - sizeof(*res);
170  if (GNUNET_OK !=
172  (const char *)&res[1],
173  left,
174  NULL))
175  {
176  GNUNET_break(0);
177  ah->arc(ah->arc_cls,
178  NULL,
180  type);
181  }
182  else
183  {
184  ah->arc(ah->arc_cls,
185  cfg,
186  status,
187  type);
188  }
191 }
void GNUNET_NAT_AUTO_autoconfig_cancel(struct GNUNET_NAT_AUTO_AutoHandle *ah)
Abort autoconfiguration.
Definition: nat_auto_api.c:283
GNUNET_NAT_AUTO_AutoResultCallback arc
Function called with the result from the autoconfiguration.
Definition: nat_auto_api.c:52
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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...
int32_t status_code
An enum GNUNET_NAT_StatusCode in NBO.
Definition: nat-auto.h:92
int32_t type
An enum GNUNET_NAT_Type in NBO.
Definition: nat-auto.h:97
GNUNET_NAT_StatusCode
Error Types for the NAT subsystem (which can then later be converted/resolved to a string) ...
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
uint16_t status
See PRISM_STATUS_*-constants.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Handle to auto-configuration in progress.
Definition: nat_auto_api.c:38
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
configuration data
Definition: configuration.c:83
struct GNUNET_MessageHeader header
Header with type GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT.
Definition: nat-auto.h:87
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
GNUNET_NAT_Type
What the situation of the NAT connectivity.
int GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
De-serializes configuration.
void * arc_cls
Closure for arc.
Definition: nat_auto_api.c:57
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 201 of file nat_auto_api.c.

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

203 {
204  struct GNUNET_NAT_AUTO_AutoHandle *ah = cls;
205 
206  ah->arc(ah->arc_cls,
207  NULL,
211 }
void GNUNET_NAT_AUTO_autoconfig_cancel(struct GNUNET_NAT_AUTO_AutoHandle *ah)
Abort autoconfiguration.
Definition: nat_auto_api.c:283
GNUNET_NAT_AUTO_AutoResultCallback arc
Function called with the result from the autoconfiguration.
Definition: nat_auto_api.c:52
We know nothing about the NAT.
Handle to auto-configuration in progress.
Definition: nat_auto_api.c:38
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
void * arc_cls
Closure for arc.
Definition: nat_auto_api.c:57
Here is the call graph for this function:
Here is the caller graph for this function: