RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
rtr.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * This file is subject to the terms and conditions of the MIT license.
5  * See the file LICENSE in the top level directory for more details.
6  *
7  * Website: http://rtrlib.realmv6.org/
8 */
9 
10 
18 #ifndef RTR_H
19 #define RTR_H
20 #include <time.h>
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <pthread.h>
24 #include "rtrlib/pfx/pfx.h"
25 #include "rtrlib/transport/transport.h"
26 
27 #define RTR_DBG(fmt, ...) dbg("RTR Socket: " fmt, ## __VA_ARGS__)
28 #define RTR_DBG1(a) dbg("RTR Socket: " a)
29 
30 static const uint8_t RTR_PROTOCOL_VERSION_0 = 0;
31 static const uint8_t RTR_PROTOCOL_VERSION_1 = 1;
32 
33 static const uint8_t RTR_PROTOCOL_MIN_SUPPORTED_VERSION = 0;
34 static const uint8_t RTR_PROTOCOL_MAX_SUPPORTED_VERSION = 1;
35 
36 enum rtr_rtvals {
37  RTR_SUCCESS = 0,
38  RTR_ERROR = -1
39 };
40 
47 
50 
53 
56 
59 
62 
65 
68 
71 
74 };
75 
76 struct rtr_socket;
77 
81 typedef void (*rtr_connection_state_fp)(const struct rtr_socket *rtr_socket, const enum rtr_socket_state state, void *connection_state_fp_param);
82 
101 struct rtr_socket {
102  struct tr_socket *tr_socket;
103  unsigned int refresh_interval;
104  time_t last_update;
105  unsigned int expire_interval;
106  unsigned int retry_interval;
107  enum rtr_socket_state state;
108  uint32_t session_id;
109  bool request_session_id;
110  uint32_t serial_number;
111  struct pfx_table *pfx_table;
112  pthread_t thread_id;
113  rtr_connection_state_fp connection_state_fp;
114  void *connection_state_fp_param;
115  unsigned int version;
116  struct spki_table *spki_table;
117 };
118 
132 void 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, rtr_connection_state_fp fp, void *fp_data);
133 
141 int rtr_start(struct rtr_socket *rtr_socket);
142 
147 void rtr_stop(struct rtr_socket *rtr_socket);
148 
155 const char *rtr_state_to_str(enum rtr_socket_state state);
156 
157 #endif
158 /* @} */
A transport socket datastructure.
Definition: transport.h:95
Definition: rtr.h:49
Definition: rtr.h:70
Definition: rtr.h:67
Definition: rtr.h:73
void(* rtr_connection_state_fp)(const struct rtr_socket *rtr_socket, const enum rtr_socket_state state, void *connection_state_fp_param)
A function pointer that is called if the state of the rtr socket has changed.
Definition: rtr.h:81
pfx_table.
Definition: lpfst-pfx.h:39
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 ...
Definition: rtr.c:77
Definition: rtr.h:55
Definition: rtr.h:61
Definition: rtr.h:46
rtr_socket_state
States of the RTR socket.
Definition: rtr.h:44
A RTR socket.
Definition: rtr.h:101
Definition: rtr.h:52
void rtr_stop(struct rtr_socket *rtr_socket)
Stops the RTR connection and terminate the transport connection.
Definition: rtr.c:203
Definition: rtr.h:58
Definition: rtr.h:64
void 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, rtr_connection_state_fp fp, void *fp_data)
Initializes a rtr_socket.
Definition: rtr.c:54
const char * rtr_state_to_str(enum rtr_socket_state state)
Converts a rtr_socket_state to a String.
Definition: rtr.c:213