Connect to hard-coded peer and exchange route info. Buggy and incomplete.
[trust_router.git] / include / trp_ptable.h
1 #ifndef _TRP_PTABLE_H_
2 #define _TRP_PTABLE_H_
3
4 #include <time.h>
5 #include <talloc.h>
6
7 #include <trust_router/tr_name.h>
8 #include <trp_internal.h>
9
10 typedef struct trp_peer TRP_PEER;
11 struct trp_peer {
12   TRP_PEER *next; /* for making a linked list */
13   char *server;
14   unsigned int port;
15   unsigned int linkcost;
16   struct timespec last_conn_attempt;
17 };
18
19 typedef struct trp_ptable {
20   TRP_PEER *head; /* head of a peer table list */
21 } TRP_PTABLE;
22
23 /* iterator for the peer table */
24 typedef TRP_PEER *TRP_PTABLE_ITER;
25
26 TRP_PTABLE *trp_ptable_new(TALLOC_CTX *memctx);
27 void trp_ptable_free(TRP_PTABLE *ptbl);
28 TRP_RC trp_ptable_add(TRP_PTABLE *ptbl, TRP_PEER *newpeer);
29 TRP_RC trp_ptable_remove(TRP_PTABLE *ptbl, TRP_PEER *peer);
30 TRP_PEER *trp_ptable_find(TRP_PTABLE *ptbl, TR_NAME *gssname);
31 char *trp_ptable_to_str(TALLOC_CTX *memctx, TRP_PTABLE *ptbl, const char *sep, const char *lineterm);
32
33 TRP_PTABLE_ITER *trp_ptable_iter_new(TALLOC_CTX *mem_ctx);
34 TRP_PEER *trp_ptable_iter_first(TRP_PTABLE_ITER *iter, TRP_PTABLE *ptbl);
35 TRP_PEER *trp_ptable_iter_next(TRP_PTABLE_ITER *iter);
36 void trp_ptable_iter_free(TRP_PTABLE_ITER *iter);
37
38 TRP_PEER *trp_peer_new(TALLOC_CTX *memctx);
39 void trp_peer_free(TRP_PEER *peer);
40 char *trp_peer_get_server(TRP_PEER *peer);
41 void trp_peer_set_server(TRP_PEER *peer, char *server);
42 TR_NAME *trp_peer_get_gssname(TRP_PEER *peer);
43 unsigned int trp_peer_get_port(TRP_PEER *peer);
44 void trp_peer_set_port(TRP_PEER *peer, unsigned int port);
45 unsigned int trp_peer_get_linkcost(TRP_PEER *peer);
46 struct timespec *trp_peer_get_last_conn_attempt(TRP_PEER *peer);
47 void trp_peer_set_last_conn_attempt(TRP_PEER *peer, struct timespec *time);
48 void trp_peer_set_linkcost(TRP_PEER *peer, unsigned int linkcost);
49 char *trp_peer_to_str(TALLOC_CTX *memctx, TRP_PEER *peer, const char *sep);
50
51 #endif /* _TRP_PTABLE_H_ */