RTRlib
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
RTR socket

Data Structures

struct  rtr_socket
 

Macros

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

Typedefs

typedef void(* rtr_connection_state_fp )(const struct rtr_socket *rtr_socket, const enum rtr_socket_state state, void *connection_state_fp_param)
 

Enumerations

enum  rtr_rtvals { RTR_SUCCESS = 0, RTR_ERROR = -1, RTR_INVALID_PARAM = -2 }
 
enum  rtr_socket_state {
  RTR_CONNECTING, RTR_ESTABLISHED, RTR_RESET, RTR_SYNC,
  RTR_FAST_RECONNECT, RTR_ERROR_NO_DATA_AVAIL, RTR_ERROR_NO_INCR_UPDATE_AVAIL, RTR_ERROR_FATAL,
  RTR_ERROR_TRANSPORT, RTR_SHUTDOWN
}
 

Functions

int rtr_init (struct rtr_socket *rtr_socket, struct tr_socket *tr_socket, struct pfx_table *pfx_table, struct spki_table *spki_table, const unsigned int refresh_interval, const unsigned int expire_interval, const unsigned int retry_interval, rtr_connection_state_fp fp, void *fp_data)
 
int rtr_start (struct rtr_socket *rtr_socket)
 
const char * rtr_state_to_str (enum rtr_socket_state state)
 
void rtr_stop (struct rtr_socket *rtr_socket)
 

Detailed Description

One rtr_socket communicates with a single RPKI-RTR server.

Enumeration Type Documentation

States of the RTR socket.

Enumerator
RTR_CONNECTING 

Socket is establishing the transport connection.

RTR_ESTABLISHED 

Connection is established, socket is waiting for a Serial Notify or expiration of the refresh_interval timer

RTR_RESET 

Resetting RTR connection.

RTR_SYNC 

Receiving validation records from the RTR server.

RTR_FAST_RECONNECT 

Reconnect without any waiting period

RTR_ERROR_NO_DATA_AVAIL 

No validation records are available on the RTR server.

RTR_ERROR_NO_INCR_UPDATE_AVAIL 

Server was unable to answer the last serial or reset query.

RTR_ERROR_FATAL 

Fatal protocol error occurred.

RTR_ERROR_TRANSPORT 

Error on the transport socket occurred.

RTR_SHUTDOWN 

RTR Socket is stopped.

Function Documentation

int rtr_init ( struct rtr_socket rtr_socket,
struct tr_socket tr_socket,
struct pfx_table pfx_table,
struct spki_table *  spki_table,
const unsigned int  refresh_interval,
const unsigned int  expire_interval,
const unsigned int  retry_interval,
rtr_connection_state_fp  fp,
void *  fp_data 
)

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 recommanded 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 recommanded default is 600 seconds (ten minutes).
[in]fpA callback function that is executed when the state of the socket changes.
[in]fp_dataParameter that is passed to the connection_state_fp callback.
Returns
RTR_INVALID_PARAM If the refresh_interval or the expire_interval is not valid.
RTR_SUCCESS On success.

References RTR_SHUTDOWN.

Referenced by rtr_mgr_init().

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.
const char* rtr_state_to_str ( enum rtr_socket_state  state)

Converts a rtr_socket_state to a String.

Parameters
[in]statestate to convert to a string
Returns
NULL If state isn't a valid rtr_socket_state
!=NULL The rtr_socket_state as String.
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.

References RTR_SHUTDOWN.

Referenced by rtr_mgr_stop().