Annotation of embedaddon/bird2/proto/rpki/transport.h, revision 1.1.1.1
1.1 misho 1: /*
2: * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol
3: *
4: * (c) 2015 CZ.NIC
5: * (c) 2015 Pavel Tvrdik <pawel.tvrdik@gmail.com>
6: *
7: * This file was a part of RTRlib: http://rpki.realmv6.org/
8: *
9: * Can be freely distributed and used under the terms of the GNU GPL.
10: */
11:
12: /*
13: * The RPKI transport sockets implement the communication channel
14: * (e.g., SSH, TCP, TCP-AO) between an RPKI server and client.
15: *
16: * Before using the transport socket, a tr_socket must be
17: * initialized based on a protocol-dependent init function (e.g.,
18: * rpki_tr_tcp_init()).
19: *
20: * The rpki_tr_* functions call the corresponding function pointers, which are
21: * passed in the rpki_tr_sock structure, and forward the remaining arguments.
22: */
23:
24: #ifndef _BIRD_RPKI_TRANSPORT_H_
25: #define _BIRD_RPKI_TRANSPORT_H_
26:
27: #include <time.h>
28:
29: /* The return values for rpki_tr_ functions */
30: enum rpki_tr_rtvals {
31: RPKI_TR_SUCCESS = 0, /* Operation was successful */
32: RPKI_TR_ERROR = -1, /* Error occurred */
33: RPKI_TR_WOULDBLOCK = -2, /* No data is available on the socket */
34: RPKI_TR_INTR = -3, /* Call was interrupted from a signal */
35: RPKI_TR_CLOSED = -4 /* Connection closed */
36: };
37:
38: /* A transport socket structure */
39: struct rpki_tr_sock {
40: sock *sk; /* Standard BIRD socket */
41: struct rpki_cache *cache; /* Cache server */
42: int (*open_fp)(struct rpki_tr_sock *); /* Function that establishes the socket connection */
43: const char *(*ident_fp)(struct rpki_tr_sock *); /* Function that returns an identifier for the socket endpoint */
44: const char *ident; /* Internal. Use ident_fp() hook instead of this pointer */
45: };
46:
47: int rpki_tr_open(struct rpki_tr_sock *tr);
48: void rpki_tr_close(struct rpki_tr_sock *tr);
49: const char *rpki_tr_ident(struct rpki_tr_sock *tr);
50:
51: /* Types of supported transports */
52: enum rpki_tr_type {
53: RPKI_TR_TCP, /* Unprotected transport over TCP */
54: RPKI_TR_SSH, /* Protected transport by SSHv2 connection */
55: };
56:
57: /* Common configure structure for transports */
58: struct rpki_tr_config {
59: enum rpki_tr_type type; /* RPKI_TR_TCP or RPKI_TR_SSH */
60: const void *spec; /* Specific transport configuration, i.e. rpki_tr_tcp_config or rpki_tr_ssh_config */
61: };
62:
63: struct rpki_tr_tcp_config {
64: /* No internal configuration data */
65: };
66:
67: struct rpki_tr_ssh_config {
68: const char *bird_private_key; /* Filepath to the BIRD server private key */
69: const char *cache_public_key; /* Filepath to the public key of cache server, can be file known_hosts */
70: const char *user; /* Username for SSH connection */
71: };
72:
73: /* ssh_transport.c */
74: void rpki_tr_ssh_init(struct rpki_tr_sock *tr);
75:
76: /* tcp_transport.c */
77: void rpki_tr_tcp_init(struct rpki_tr_sock *tr);
78:
79: #endif /* _BIRD_RPKI_TRANSPORT_H_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>