Connect to hard-coded peer and exchange route info. Buggy and incomplete.
[trust_router.git] / include / trp_rtable.h
1 #ifndef _TRP_RTABLE_H_
2 #define _TRP_RTABLE_H_
3
4 #include <glib.h>
5 #include <talloc.h>
6 #include <time.h>
7
8 #include <trp_internal.h>
9
10 typedef struct trp_rentry {
11   TR_NAME *apc;
12   TR_NAME *realm;
13   TR_NAME *peer;
14   unsigned int metric;
15   TR_NAME *trust_router;
16   TR_NAME *next_hop;
17   int selected;
18   unsigned int interval; /* interval from route update */
19   struct timespec *expiry;
20 } TRP_RENTRY;
21
22 typedef GHashTable TRP_RTABLE;
23
24 TRP_RTABLE *trp_rtable_new(void);
25 void trp_rtable_free(TRP_RTABLE *rtbl);
26 void trp_rtable_add(TRP_RTABLE *rtbl, TRP_RENTRY *entry); /* adds or updates */
27 void trp_rtable_remove(TRP_RTABLE *rtbl, TRP_RENTRY *entry);
28 size_t trp_rtable_size(TRP_RTABLE *rtbl);
29 size_t trp_rtable_apc_size(TRP_RTABLE *rtbl, TR_NAME *apc);
30 size_t trp_rtable_realm_size(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm);
31 TRP_RENTRY **trp_rtable_get_entries(TRP_RTABLE *rtbl, size_t *n_out);
32 TR_NAME **trp_rtable_get_apcs(TRP_RTABLE *rtbl, size_t *n_out);
33 TRP_RENTRY **trp_rtable_get_apc_entries(TRP_RTABLE *rtbl, TR_NAME *apc, size_t *n_out);
34 TR_NAME **trp_rtable_get_apc_realms(TRP_RTABLE *rtbl, TR_NAME *apc, size_t *n_out);
35 TRP_RENTRY **trp_rtable_get_realm_entries(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, size_t *n_out);
36 TR_NAME **trp_rtable_get_apc_realm_peers(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, size_t *n_out);
37 TRP_RENTRY *trp_rtable_get_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, TR_NAME *peer);
38 TRP_RENTRY *trp_rtable_get_selected_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm);
39 char *trp_rtable_to_str(TALLOC_CTX *mem_ctx, TRP_RTABLE *rtbl, const char *sep, const char *lineterm);
40
41 TRP_RENTRY *trp_rentry_new(TALLOC_CTX *mem_ctx);
42 void trp_rentry_free(TRP_RENTRY *entry);
43 void trp_rentry_set_apc(TRP_RENTRY *entry, TR_NAME *apc);
44 TR_NAME *trp_rentry_get_apc(TRP_RENTRY *entry);
45 TR_NAME *trp_rentry_dup_apc(TRP_RENTRY *entry);
46 void trp_rentry_set_realm(TRP_RENTRY *entry, TR_NAME *realm);
47 TR_NAME *trp_rentry_get_realm(TRP_RENTRY *entry);
48 TR_NAME *trp_rentry_dup_realm(TRP_RENTRY *entry);
49 void trp_rentry_set_trust_router(TRP_RENTRY *entry, TR_NAME *tr);
50 TR_NAME *trp_rentry_get_trust_router(TRP_RENTRY *entry);
51 TR_NAME *trp_rentry_dup_trust_router(TRP_RENTRY *entry);
52 void trp_rentry_set_peer(TRP_RENTRY *entry, TR_NAME *peer);
53 TR_NAME *trp_rentry_get_peer(TRP_RENTRY *entry);
54 TR_NAME *trp_rentry_dup_peer(TRP_RENTRY *entry);
55 void trp_rentry_set_metric(TRP_RENTRY *entry, unsigned int metric);
56 unsigned int trp_rentry_get_metric(TRP_RENTRY *entry);
57 void trp_rentry_set_next_hop(TRP_RENTRY *entry, TR_NAME *next_hop);
58 TR_NAME *trp_rentry_get_next_hop(TRP_RENTRY *entry);
59 TR_NAME *trp_rentry_dup_next_hop(TRP_RENTRY *entry);
60 void trp_rentry_set_selected(TRP_RENTRY *entry, int sel);
61 int trp_rentry_get_selected(TRP_RENTRY *entry);
62 void trp_rentry_set_interval(TRP_RENTRY *entry, int interval);
63 int trp_rentry_get_interval(TRP_RENTRY *entry);
64 void trp_rentry_set_expiry(TRP_RENTRY *entry, struct timespec *exp);
65 struct timespec *trp_rentry_get_expiry(TRP_RENTRY *entry);
66 char *trp_rentry_to_str(TALLOC_CTX *mem_ctx, TRP_RENTRY *entry, const char *sep);
67
68 #endif /* _TRP_RTABLE_H_ */