RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
rtr.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * RTRlib is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * RTRlib is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with RTRlib; see the file COPYING.LESSER.
16  *
17  * INET group, Hamburg University of Applied Sciences,
18  * CST group, Freie Universitaet Berlin
19  * Website: http://rpki.realmv6.org/
20  */
21 
22 
30 #ifndef RTR_H
31 #define RTR_H
32 #include <time.h>
33 #include <stdbool.h>
34 #include <stdint.h>
35 #include <pthread.h>
36 #include "rtrlib/pfx/pfx.h"
37 #include "rtrlib/transport/transport.h"
38 
39 #define RTR_DBG(fmt, ...) dbg("RTR Socket: " fmt, ## __VA_ARGS__)
40 #define RTR_DBG1(a) dbg("RTR Socket: " a)
41 
42 static const uint8_t RTR_PROTOCOL_VERSION_0 = 0;
43 static const uint8_t RTR_PROTOCOL_VERSION_1 = 1;
44 
45 static const uint8_t RTR_PROTOCOL_MIN_SUPPORTED_VERSION = 0;
46 static const uint8_t RTR_PROTOCOL_MAX_SUPPORTED_VERSION = 1;
47 
48 enum rtr_rtvals {
49  RTR_SUCCESS = 0,
50  RTR_ERROR = -1
51 };
52 
59 
62 
65 
68 
71 
74 
77 
80 
83 
86 };
87 
88 struct rtr_socket;
89 
93 typedef void (*rtr_connection_state_fp)(const struct rtr_socket *rtr_socket, const enum rtr_socket_state state, void *connection_state_fp_param);
94 
113 struct rtr_socket {
114  struct tr_socket *tr_socket;
115  unsigned int refresh_interval;
116  time_t last_update;
117  unsigned int expire_interval;
118  unsigned int retry_interval;
119  enum rtr_socket_state state;
120  uint32_t session_id;
121  bool request_session_id;
122  uint32_t serial_number;
123  struct pfx_table *pfx_table;
124  pthread_t thread_id;
125  rtr_connection_state_fp connection_state_fp;
126  void *connection_state_fp_param;
127  unsigned int version;
128  struct spki_table *spki_table;
129 };
130 
144 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);
145 
153 int rtr_start(struct rtr_socket *rtr_socket);
154 
159 void rtr_stop(struct rtr_socket *rtr_socket);
160 
167 const char *rtr_state_to_str(enum rtr_socket_state state);
168 
169 #endif
170 /* @} */
A transport socket datastructure.
Definition: transport.h:107
Definition: rtr.h:61
Definition: rtr.h:82
Definition: rtr.h:79
Definition: rtr.h:85
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:93
pfx_table.
Definition: lpfst-pfx.h:51
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:89
Definition: rtr.h:67
Definition: rtr.h:73
Definition: rtr.h:58
rtr_socket_state
States of the RTR socket.
Definition: rtr.h:56
A RTR socket.
Definition: rtr.h:113
Definition: rtr.h:64
void rtr_stop(struct rtr_socket *rtr_socket)
Stops the RTR connection and terminate the transport connection.
Definition: rtr.c:215
Definition: rtr.h:70
Definition: rtr.h:76
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:66
const char * rtr_state_to_str(enum rtr_socket_state state)
Converts a rtr_socket_state to a String.
Definition: rtr.c:225