RTRlib
Loading...
Searching...
No Matches
rtr_private.h File Reference
#include "rtrlib/rtr/rtr.h"
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define RTR_DBG(fmt, ...)   lrtr_dbg("RTR Socket: " fmt, ##__VA_ARGS__)
 
#define RTR_DBG1(a)   lrtr_dbg("RTR Socket: " a)
 

Enumerations

enum  rtr_interval_range { RTR_BELOW_INTERVAL_RANGE = -1 , RTR_INSIDE_INTERVAL_RANGE = 0 , RTR_ABOVE_INTERVAL_RANGE = 1 }
 
enum  rtr_interval_type { RTR_INTERVAL_TYPE_EXPIRATION , RTR_INTERVAL_TYPE_REFRESH , RTR_INTERVAL_TYPE_RETRY }
 

Functions

int rtr_init (struct rtr_socket *rtr_socket, struct tr_socket *tr_socket, struct pfx_table *pfx_table, struct spki_table *spki_table, struct aspa_table *aspa_table, const unsigned int refresh_interval, const unsigned int expire_interval, const unsigned int retry_interval, enum rtr_interval_mode iv_mode, rtr_connection_state_fp fp, void *fp_data_config, void *fp_data_group)
 Initializes a rtr_socket.
 
int rtr_start (struct rtr_socket *rtr_socket)
 Starts the RTR protocol state machine in a pthread.
 
void rtr_stop (struct rtr_socket *rtr_socket)
 Stops the RTR connection and terminate the transport connection.
 

Variables

static const uint32_t RTR_EXPIRATION_MIN = 600
 
static const uint32_t RTR_EXPIRATION_MAX = 172800
 
static const uint32_t RTR_EXPIRATION_DEFAULT = 7200
 
static const uint32_t RTR_REFRESH_MIN = 1
 
static const uint32_t RTR_REFRESH_MAX = 86400
 
static const uint32_t RTR_REFRESH_DEFAULT = 3600
 
static const uint32_t RTR_RETRY_MIN = 1
 
static const uint32_t RTR_RETRY_MAX = 7200
 
static const uint32_t RTR_RETRY_DEFAULT = 600
 
static const uint8_t RTR_PROTOCOL_VERSION_0 = 0
 
static const uint8_t RTR_PROTOCOL_VERSION_1 = 1
 
static const uint8_t RTR_PROTOCOL_VERSION_2 = 2
 
static const uint8_t RTR_PROTOCOL_MIN_SUPPORTED_VERSION
 
static const uint8_t RTR_PROTOCOL_MAX_SUPPORTED_VERSION = 2
 

Macro Definition Documentation

◆ RTR_DBG

#define RTR_DBG (   fmt,
  ... 
)    lrtr_dbg("RTR Socket: " fmt, ##__VA_ARGS__)

◆ RTR_DBG1

#define RTR_DBG1 (   a)    lrtr_dbg("RTR Socket: " a)

Enumeration Type Documentation

◆ rtr_interval_range

Enumerator
RTR_BELOW_INTERVAL_RANGE 
RTR_INSIDE_INTERVAL_RANGE 
RTR_ABOVE_INTERVAL_RANGE 

◆ rtr_interval_type

Enumerator
RTR_INTERVAL_TYPE_EXPIRATION 
RTR_INTERVAL_TYPE_REFRESH 
RTR_INTERVAL_TYPE_RETRY 

Function Documentation

◆ rtr_init()

int rtr_init ( struct rtr_socket rtr_socket,
struct tr_socket tr_socket,
struct pfx_table pfx_table,
struct spki_table spki_table,
struct aspa_table aspa_table,
const unsigned int  refresh_interval,
const unsigned int  expire_interval,
const unsigned int  retry_interval,
enum rtr_interval_mode  iv_mode,
rtr_connection_state_fp  fp,
void *  fp_data_config,
void *  fp_data_group 
)

Initializes a rtr_socket.

Parameters
[out]rtr_socketPointer to the allocated rtr_socket that will be initialized.
[in]tr_socketPointer to a tr_socket that will be used for the transport connection. If NULL the tr_socket element of the rtr_socket won't be changed.
[in]pfx_tablepfx_table that stores the validation records obtained from the connected rtr server.
[in]spki_tablespki_table that stores the router keys obtained from the connected rtr server.
[in]refresh_intervalInterval in seconds between serial queries that are sent to the server. Must be >= 1 and <= 86400 (one day), recommended default is 3600s (one hour).
[in]expire_intervalStored validation records will be deleted if cache was unable to refresh data for this period. The value should be twice the refresh_interval. The value must be >= 600 (ten minutes) and <= 172800 (two days). The recommended default is 7200s (two hours).
[in]retry_intervalThis parameter tells the router how long to wait (in seconds) before retrying a failed Serial Query or Reset Query. The value must be >= 1s and <= 7200s (two hours). The recommended default is 600 seconds (ten minutes).
[in]iv_modeThe interval mode that controls how new interval values are applied.
[in]fpA callback function that is executed when the state of the socket changes.
[in]fp_data_configParameter that is passed to the connection_state_fp callback. Expects rtr_mgr_config.
[in]fp_data_groupParameter that is passed to the connection_state_fp callback. Expects rtr_mgr_group.
Returns
RTR_INVALID_PARAM If the refresh_interval or the expire_interval is not valid.
RTR_SUCCESS On success.

◆ rtr_start()

int rtr_start ( struct rtr_socket rtr_socket)

Starts the RTR protocol state machine in a pthread.

Connection to the rtr_server will be established and the pfx_records will be synced.

Parameters
[in]rtr_socketrtr_socket that will be used.
Returns
RTR_ERROR On error.
RTR_SUCCESS On success.

◆ rtr_stop()

void rtr_stop ( struct rtr_socket rtr_socket)

Stops the RTR connection and terminate the transport connection.

Parameters
[in]rtr_socketrtr_socket that will be used.

Variable Documentation

◆ RTR_EXPIRATION_DEFAULT

const uint32_t RTR_EXPIRATION_DEFAULT = 7200
static

◆ RTR_EXPIRATION_MAX

const uint32_t RTR_EXPIRATION_MAX = 172800
static

◆ RTR_EXPIRATION_MIN

const uint32_t RTR_EXPIRATION_MIN = 600
static

◆ RTR_PROTOCOL_MAX_SUPPORTED_VERSION

const uint8_t RTR_PROTOCOL_MAX_SUPPORTED_VERSION = 2
static

◆ RTR_PROTOCOL_MIN_SUPPORTED_VERSION

const uint8_t RTR_PROTOCOL_MIN_SUPPORTED_VERSION
static

◆ RTR_PROTOCOL_VERSION_0

const uint8_t RTR_PROTOCOL_VERSION_0 = 0
static

◆ RTR_PROTOCOL_VERSION_1

const uint8_t RTR_PROTOCOL_VERSION_1 = 1
static

◆ RTR_PROTOCOL_VERSION_2

const uint8_t RTR_PROTOCOL_VERSION_2 = 2
static

◆ RTR_REFRESH_DEFAULT

const uint32_t RTR_REFRESH_DEFAULT = 3600
static

◆ RTR_REFRESH_MAX

const uint32_t RTR_REFRESH_MAX = 86400
static

◆ RTR_REFRESH_MIN

const uint32_t RTR_REFRESH_MIN = 1
static

◆ RTR_RETRY_DEFAULT

const uint32_t RTR_RETRY_DEFAULT = 600
static

◆ RTR_RETRY_MAX

const uint32_t RTR_RETRY_MAX = 7200
static

◆ RTR_RETRY_MIN

const uint32_t RTR_RETRY_MIN = 1
static