Usage example of the RTR connection manager.
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include "rtrlib/rtrlib.h"
int main(){
char ssh_host[] = "123.231.123.221";
char ssh_user[] = "rpki_user";
char ssh_hostkey[] = "/etc/rpki-rtr/hostkey";
char ssh_privkey[] = "/etc/rpki-rtr/client.priv";
ssh_host,
22,
NULL,
ssh_user,
ssh_hostkey,
ssh_privkey,
};
char tcp_host[] = "rpki-validator.realmv6.org";
char tcp_port[] = "8282";
tcp_host,
tcp_port,
NULL
};
rtr_ssh.
tr_socket = &tr_ssh;
rtr_tcp.tr_socket = &tr_tcp;
groups[0].
sockets = malloc(
sizeof(
struct rtr_socket*));
groups[0].
sockets_len = 1;
groups[0].sockets[0] = &rtr_tcp;
groups[0].
preference = 1;
groups[1].sockets = malloc(1 *
sizeof(
struct rtr_socket*));
groups[1].sockets_len = 1;
groups[1].sockets[0] = &rtr_ssh;
groups[1].preference = 2;
struct rtr_mgr_config *conf;
int ret =
rtr_mgr_init(&conf, groups, 2, 30, 600, 600, NULL, NULL, NULL, NULL);
sleep(1);
}
const uint8_t mask = 24;
char buffer[INET_ADDRSTRLEN];
printf("RESULT: The prefix %s/%i ", buffer, mask);
switch(result) {
printf("is valid.\n");
break;
printf("is invalid.\n");
break;
printf("was not found.\n");
break;
default:
break;
}
free(groups[0].sockets);
free(groups[1].sockets);
}