Update route table when a TRP update is received. Not tested.
[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   struct timespec *expiry;
19 } TRP_RENTRY;
20
21 typedef GHashTable TRP_RTABLE;
22
23 TRP_RTABLE *trp_rtable_new(void);
24 void trp_rtable_free(TRP_RTABLE *rtbl);
25 void trp_rtable_add(TRP_RTABLE *rtbl, TRP_RENTRY *entry); /* adds or updates */
26 void trp_rtable_remove(TRP_RTABLE *rtbl, TRP_RENTRY *entry);
27 size_t trp_rtable_size(TRP_RTABLE *rtbl);
28 size_t trp_rtable_apc_size(TRP_RTABLE *rtbl, TR_NAME *apc);
29 size_t trp_rtable_realm_size(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm);
30 TRP_RENTRY **trp_rtable_get_entries(TRP_RTABLE *rtbl, size_t *n_out);
31 TR_NAME **trp_rtable_get_apcs(TRP_RTABLE *rtbl, size_t *n_out);
32 TRP_RENTRY **trp_rtable_get_apc_entries(TRP_RTABLE *rtbl, TR_NAME *apc, size_t *n_out);
33 TR_NAME **trp_rtable_get_apc_realms(TRP_RTABLE *rtbl, TR_NAME *apc, size_t *n_out);
34 TRP_RENTRY **trp_rtable_get_realm_entries(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, size_t *n_out);
35 TR_NAME **trp_rtable_get_apc_realm_peers(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, size_t *n_out);
36 TRP_RENTRY *trp_rtable_get_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, TR_NAME *peer);
37 char *trp_rtable_to_str(TALLOC_CTX *mem_ctx, TRP_RTABLE *rtbl, const char *sep, const char *lineterm);
38
39 TRP_RENTRY *trp_rentry_new(TALLOC_CTX *mem_ctx);
40 void trp_rentry_free(TRP_RENTRY *entry);
41 void trp_rentry_set_apc(TRP_RENTRY *entry, TR_NAME *apc);
42 TR_NAME *trp_rentry_get_apc(TRP_RENTRY *entry);
43 void trp_rentry_set_realm(TRP_RENTRY *entry, TR_NAME *realm);
44 TR_NAME *trp_rentry_get_realm(TRP_RENTRY *entry);
45 void trp_rentry_set_trust_router(TRP_RENTRY *entry, TR_NAME *tr);
46 TR_NAME *trp_rentry_get_trust_router(TRP_RENTRY *entry);
47 void trp_rentry_set_peer(TRP_RENTRY *entry, TR_NAME *peer);
48 TR_NAME *trp_rentry_get_peer(TRP_RENTRY *entry);
49 void trp_rentry_set_metric(TRP_RENTRY *entry, unsigned int metric);
50 unsigned int trp_rentry_get_metric(TRP_RENTRY *entry);
51 void trp_rentry_set_next_hop(TRP_RENTRY *entry, TR_NAME *next_hop);
52 TR_NAME *trp_rentry_get_next_hop(TRP_RENTRY *entry);
53 void trp_rentry_set_selected(TRP_RENTRY *entry, int sel);
54 int trp_rentry_get_selected(TRP_RENTRY *entry);
55 void trp_rentry_set_expiry(TRP_RENTRY *entry, struct timespec *exp);
56 TRP_RENTRY *trp_rtable_get_selected_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm);
57 struct timespec *trp_rentry_get_expiry(TRP_RENTRY *entry);
58 char *trp_rentry_to_str(TALLOC_CTX *mem_ctx, TRP_RENTRY *entry, const char *sep);
59
60 #endif /* _TRP_RTABLE_H_ */