Send triggered updates (not really 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   unsigned int interval; /* interval from route update */
19   struct timespec *expiry;
20   int triggered;
21 } TRP_RENTRY;
22
23 typedef GHashTable TRP_RTABLE;
24
25 TRP_RTABLE *trp_rtable_new(void);
26 void trp_rtable_free(TRP_RTABLE *rtbl);
27 void trp_rtable_add(TRP_RTABLE *rtbl, TRP_RENTRY *entry); /* adds or updates */
28 void trp_rtable_remove(TRP_RTABLE *rtbl, TRP_RENTRY *entry);
29 void trp_rtable_clear(TRP_RTABLE *rtbl);
30 size_t trp_rtable_size(TRP_RTABLE *rtbl);
31 size_t trp_rtable_apc_size(TRP_RTABLE *rtbl, TR_NAME *apc);
32 size_t trp_rtable_realm_size(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm);
33 TRP_RENTRY **trp_rtable_get_entries(TRP_RTABLE *rtbl, size_t *n_out);
34 TR_NAME **trp_rtable_get_apcs(TRP_RTABLE *rtbl, size_t *n_out);
35 TRP_RENTRY **trp_rtable_get_apc_entries(TRP_RTABLE *rtbl, TR_NAME *apc, size_t *n_out);
36 TR_NAME **trp_rtable_get_apc_realms(TRP_RTABLE *rtbl, TR_NAME *apc, size_t *n_out);
37 TRP_RENTRY **trp_rtable_get_realm_entries(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, size_t *n_out);
38 TR_NAME **trp_rtable_get_apc_realm_peers(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, size_t *n_out);
39 TRP_RENTRY *trp_rtable_get_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, TR_NAME *peer);
40 TRP_RENTRY *trp_rtable_get_selected_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm);
41 void trp_rtable_clear_triggered(TRP_RTABLE *rtbl);
42 char *trp_rtable_to_str(TALLOC_CTX *mem_ctx, TRP_RTABLE *rtbl, const char *sep, const char *lineterm);
43
44 TRP_RENTRY *trp_rentry_new(TALLOC_CTX *mem_ctx);
45 void trp_rentry_free(TRP_RENTRY *entry);
46 void trp_rentry_set_apc(TRP_RENTRY *entry, TR_NAME *apc);
47 TR_NAME *trp_rentry_get_apc(TRP_RENTRY *entry);
48 TR_NAME *trp_rentry_dup_apc(TRP_RENTRY *entry);
49 void trp_rentry_set_realm(TRP_RENTRY *entry, TR_NAME *realm);
50 TR_NAME *trp_rentry_get_realm(TRP_RENTRY *entry);
51 TR_NAME *trp_rentry_dup_realm(TRP_RENTRY *entry);
52 void trp_rentry_set_trust_router(TRP_RENTRY *entry, TR_NAME *tr);
53 TR_NAME *trp_rentry_get_trust_router(TRP_RENTRY *entry);
54 TR_NAME *trp_rentry_dup_trust_router(TRP_RENTRY *entry);
55 void trp_rentry_set_peer(TRP_RENTRY *entry, TR_NAME *peer);
56 TR_NAME *trp_rentry_get_peer(TRP_RENTRY *entry);
57 TR_NAME *trp_rentry_dup_peer(TRP_RENTRY *entry);
58 void trp_rentry_set_metric(TRP_RENTRY *entry, unsigned int metric);
59 unsigned int trp_rentry_get_metric(TRP_RENTRY *entry);
60 void trp_rentry_set_next_hop(TRP_RENTRY *entry, TR_NAME *next_hop);
61 TR_NAME *trp_rentry_get_next_hop(TRP_RENTRY *entry);
62 TR_NAME *trp_rentry_dup_next_hop(TRP_RENTRY *entry);
63 void trp_rentry_set_selected(TRP_RENTRY *entry, int sel);
64 int trp_rentry_get_selected(TRP_RENTRY *entry);
65 void trp_rentry_set_interval(TRP_RENTRY *entry, int interval);
66 int trp_rentry_get_interval(TRP_RENTRY *entry);
67 void trp_rentry_set_expiry(TRP_RENTRY *entry, struct timespec *exp);
68 struct timespec *trp_rentry_get_expiry(TRP_RENTRY *entry);
69 void trp_rentry_set_triggered(TRP_RENTRY *entry, int trig);
70 int trp_rentry_get_triggered(TRP_RENTRY *entry);
71 char *trp_rentry_to_str(TALLOC_CTX *mem_ctx, TRP_RENTRY *entry, const char *sep);
72
73 #endif /* _TRP_RTABLE_H_ */