2 * Copyright (c) 2016-2018, JANET(UK)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of JANET(UK) nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef TRUST_ROUTER_TRP_ROUTE_H
37 #define TRUST_ROUTER_TRP_ROUTE_H
39 typedef struct trp_route {
44 TR_NAME *trust_router; /* hostname */
45 int trust_router_port;
49 unsigned int interval; /* interval from route update */
50 struct timespec *expiry;
51 int local; /* is this a local route? */
56 TRP_ROUTE *trp_route_new(TALLOC_CTX *mem_ctx);
57 void trp_route_free(TRP_ROUTE *entry);
58 void trp_route_set_comm(TRP_ROUTE *entry, TR_NAME *comm);
59 TR_NAME *trp_route_get_comm(TRP_ROUTE *entry);
60 TR_NAME *trp_route_dup_comm(TRP_ROUTE *entry);
61 void trp_route_set_realm(TRP_ROUTE *entry, TR_NAME *realm);
62 TR_NAME *trp_route_get_realm(TRP_ROUTE *entry);
63 TR_NAME *trp_route_dup_realm(TRP_ROUTE *entry);
64 void trp_route_set_trust_router(TRP_ROUTE *entry, TR_NAME *tr);
65 TR_NAME *trp_route_get_trust_router(TRP_ROUTE *entry);
66 TR_NAME *trp_route_dup_trust_router(TRP_ROUTE *entry);
67 void trp_route_set_trust_router_port(TRP_ROUTE *entry, int port);
68 int trp_route_get_trust_router_port(TRP_ROUTE *entry);
69 void trp_route_set_peer(TRP_ROUTE *entry, TR_NAME *peer);
70 TR_NAME *trp_route_get_peer(TRP_ROUTE *entry);
71 TR_NAME *trp_route_dup_peer(TRP_ROUTE *entry);
72 void trp_route_set_metric(TRP_ROUTE *entry, unsigned int metric);
73 unsigned int trp_route_get_metric(TRP_ROUTE *entry);
74 void trp_route_set_next_hop(TRP_ROUTE *entry, TR_NAME *next_hop);
75 TR_NAME *trp_route_get_next_hop(TRP_ROUTE *entry);
76 TR_NAME *trp_route_dup_next_hop(TRP_ROUTE *entry);
77 void trp_route_set_next_hop_port(TRP_ROUTE *entry, int port);
78 int trp_route_get_next_hop_port(TRP_ROUTE *entry);
79 void trp_route_set_selected(TRP_ROUTE *entry, int sel);
80 int trp_route_is_selected(TRP_ROUTE *entry);
81 void trp_route_set_interval(TRP_ROUTE *entry, int interval);
82 int trp_route_get_interval(TRP_ROUTE *entry);
83 void trp_route_set_expiry(TRP_ROUTE *entry, struct timespec *exp);
84 struct timespec *trp_route_get_expiry(TRP_ROUTE *entry);
85 struct timespec *trp_route_get_expiry_realtime(TRP_ROUTE *comm, struct timespec *result);
86 void trp_route_set_local(TRP_ROUTE *entry, int local);
87 int trp_route_is_local(TRP_ROUTE *entry);
88 void trp_route_set_triggered(TRP_ROUTE *entry, int trig);
89 int trp_route_is_triggered(TRP_ROUTE *entry);
91 /* trp_route_encoders.c */
92 char *trp_route_to_str(TALLOC_CTX *mem_ctx, TRP_ROUTE *entry, const char *sep);
93 json_t *trp_route_to_json(TRP_ROUTE *route);
95 #endif //TRUST_ROUTER_TRP_ROUTE_H