roa_flush(cache->p->cf->roa_table_cf->table, cache->roa_src);
}
-void
-rtr_change_socket_state(struct rtr_socket *rtr_socket, const enum rtr_socket_state new_state)
-{
- const enum rtr_socket_state old_state = rtr_socket->state;
-
- if (old_state == new_state)
- return;
-
- rtr_socket->state = new_state;
-
- struct rpki_cache *cache = rtr_socket->cache;
- CACHE_TRACE(D_EVENTS, cache, "Change state %s -> %s", rtr_state_to_str(old_state), rtr_state_to_str(new_state));
-
- switch (new_state)
- {
- case RTR_CONNECTING:
- if (cache->sk == NULL || cache->sk->fd < 0)
- {
- if (rpki_open_connection(cache) == TR_SUCCESS)
- cache->rtr_socket->state = RTR_SYNC; /* Need call a setup the bird socket in io.c loop */
- }
- else
- rtr_change_socket_state(rtr_socket, RTR_SYNC);
- break;
-
- case RTR_ESTABLISHED:
- /* Connection is established, socket is waiting for a Serial Notify or expiration of the refresh_interval timer */
- break;
-
- case RTR_RESET:
- /* Resetting RTR connection. */
- rtr_socket->request_session_id = true;
- rtr_socket->serial_number = 0;
- rtr_change_socket_state(rtr_socket, RTR_SYNC);
- break;
-
- case RTR_SYNC:
- /* Requesting for receive validation records from the RTR server. */
- if (rtr_socket->request_session_id)
- {
- //change to state RESET, if socket dont has a session_id
- if (rtr_send_reset_query(cache) != RTR_SUCCESS)
- rtr_change_socket_state(rtr_socket, RTR_ERROR_FATAL);
- }
- else
- {
- //if we already have a session_id, send a serial query and start to sync
- if (rtr_send_serial_query(cache) != RTR_SUCCESS)
- rtr_change_socket_state(rtr_socket, RTR_ERROR_FATAL);
- }
- break;
-
- case RTR_ERROR_NO_INCR_UPDATE_AVAIL:
- /* Server was unable to answer the last serial or reset query. */
- rtr_purge_records_if_outdated(cache);
- /* Fall through */
-
- case RTR_ERROR_NO_DATA_AVAIL:
- /* No validation records are available on the RTR server. */
- rtr_change_socket_state(rtr_socket, RTR_RESET);
- break;
-
- case RTR_ERROR_FATAL:
- /* Fatal protocol error occurred. */
- rtr_socket->request_session_id = true;
- rtr_socket->serial_number = 0;
- rtr_socket->last_update = 0;
- pfx_table_src_remove(cache);
- /* Fall through */
-
- case RTR_ERROR_TRANSPORT:
- /* Error on the transport socket occurred. */
- rpki_close_connection(cache);
- rtr_schedule_next_retry(cache);
- break;
-
- case RTR_FAST_RECONNECT:
- /* Reconnect without any waiting period */
- rpki_close_connection(cache);
- rtr_change_socket_state(rtr_socket, RTR_CONNECTING);
- break;
-
- case RTR_SHUTDOWN:
- /* RTR Socket is stopped. */
- rpki_close_connection(cache);
- rtr_socket->request_session_id = true;
- rtr_socket->serial_number = 0;
- rtr_socket->last_update = 0;
- pfx_table_src_remove(cache);
- break;
- };
-}
static void rtr_pdu_to_network_byte_order(void *pdu)
{
#define RPKI_RECV_TIMEOUT 60
#define RPKI_SEND_TIMEOUT 60
-void rtr_change_socket_state(struct rtr_socket *rtr_socket, const enum rtr_socket_state new_state);
int rtr_sync(struct rpki_cache *cache);
int rtr_wait_for_sync(struct rpki_cache *cache);
int rtr_send_serial_query(struct rpki_cache *cache);
rpki_remove_cache_from_group(struct rpki_cache *cache)
{
rem2_node(&cache->n);
-
}
static void
return rtr_socket_str_states[state];
}
+void
+rtr_change_socket_state(struct rtr_socket *rtr_socket, const enum rtr_socket_state new_state)
+{
+ const enum rtr_socket_state old_state = rtr_socket->state;
+
+ if (old_state == new_state)
+ return;
+
+ rtr_socket->state = new_state;
+
+ struct rpki_cache *cache = rtr_socket->cache;
+ CACHE_TRACE(D_EVENTS, cache, "Change state %s -> %s", rtr_state_to_str(old_state), rtr_state_to_str(new_state));
+
+ switch (new_state)
+ {
+ case RTR_CONNECTING:
+ if (cache->sk == NULL || cache->sk->fd < 0)
+ {
+ if (rpki_open_connection(cache) == TR_SUCCESS)
+ cache->rtr_socket->state = RTR_SYNC; /* Need call a setup the bird socket in io.c loop */
+ }
+ else
+ rtr_change_socket_state(rtr_socket, RTR_SYNC);
+ break;
+
+ case RTR_ESTABLISHED:
+ /* Connection is established, socket is waiting for a Serial Notify or expiration of the refresh_interval timer */
+ break;
+
+ case RTR_RESET:
+ /* Resetting RTR connection. */
+ rtr_socket->request_session_id = true;
+ rtr_socket->serial_number = 0;
+ rtr_change_socket_state(rtr_socket, RTR_SYNC);
+ break;
+
+ case RTR_SYNC:
+ /* Requesting for receive validation records from the RTR server. */
+ if (rtr_socket->request_session_id)
+ {
+ //change to state RESET, if socket dont has a session_id
+ if (rtr_send_reset_query(cache) != RTR_SUCCESS)
+ rtr_change_socket_state(rtr_socket, RTR_ERROR_FATAL);
+ }
+ else
+ {
+ //if we already have a session_id, send a serial query and start to sync
+ if (rtr_send_serial_query(cache) != RTR_SUCCESS)
+ rtr_change_socket_state(rtr_socket, RTR_ERROR_FATAL);
+ }
+ break;
+
+ case RTR_ERROR_NO_INCR_UPDATE_AVAIL:
+ /* Server was unable to answer the last serial or reset query. */
+ rtr_purge_records_if_outdated(cache);
+ /* Fall through */
+
+ case RTR_ERROR_NO_DATA_AVAIL:
+ /* No validation records are available on the RTR server. */
+ rtr_change_socket_state(rtr_socket, RTR_RESET);
+ break;
+
+ case RTR_ERROR_FATAL:
+ /* Fatal protocol error occurred. */
+ rtr_socket->request_session_id = true;
+ rtr_socket->serial_number = 0;
+ rtr_socket->last_update = 0;
+ pfx_table_src_remove(cache);
+ /* Fall through */
+
+ case RTR_ERROR_TRANSPORT:
+ /* Error on the transport socket occurred. */
+ rpki_close_connection(cache);
+ rtr_schedule_next_retry(cache);
+ break;
+
+ case RTR_FAST_RECONNECT:
+ /* Reconnect without any waiting period */
+ rpki_close_connection(cache);
+ rtr_change_socket_state(rtr_socket, RTR_CONNECTING);
+ break;
+
+ case RTR_SHUTDOWN:
+ /* RTR Socket is stopped. */
+ rpki_close_connection(cache);
+ rtr_socket->request_session_id = true;
+ rtr_socket->serial_number = 0;
+ rtr_socket->last_update = 0;
+ pfx_table_src_remove(cache);
+ break;
+ };
+}
+
/*
* Timers
*/
*/
const char *rtr_state_to_str(enum rtr_socket_state state);
+void rtr_purge_records_if_outdated(struct rpki_cache *cache);
+void rtr_change_socket_state(struct rtr_socket *rtr_socket, const enum rtr_socket_state new_state);
+
void rpki_retry_hook(struct timer *tm);
void rpki_expire_hook(struct timer *tm);
void rpki_refresh_hook(struct timer *tm);
-void rtr_purge_records_if_outdated(struct rpki_cache *cache);
void rtr_schedule_next_refresh(struct rpki_cache *cache);
void rtr_schedule_next_retry(struct rpki_cache *cache);