entry->comm=NULL;
entry->realm=NULL;
entry->trust_router=NULL;
- entry->trp_port=TRP_PORT;
- entry->tid_port=TID_PORT;
+ entry->trust_router_port=TRP_PORT;
+ entry->next_hop_port=TID_PORT;
entry->peer=NULL;
entry->next_hop=NULL;
entry->selected=0;
return entry->metric;
}
-/* TODO: set the hostname and port for the next hop. Currently assume default TID port. --jlr */
void trp_route_set_next_hop(TRP_ROUTE *entry, TR_NAME *next_hop)
{
if (entry->next_hop!=NULL)
return entry->expiry;
}
+/**
+ * Get the expiration according to the realtime clock
+ *
+ * @param entry
+ * @param result space to store the result
+ * @return pointer to the result, or null on error
+ */
+struct timespec *trp_route_get_expiry_realtime(TRP_ROUTE *entry, struct timespec *result)
+{
+ return tr_clock_convert(TRP_CLOCK, entry->expiry, CLOCK_REALTIME, result);
+}
+
void trp_route_set_local(TRP_ROUTE *entry, int local)
{
entry->local=local;
return entry->triggered;
}
-/* Pretty print a route table entry to a newly allocated string. If sep is NULL,
- * returns comma+space separated string. */
-char *trp_route_to_str(TALLOC_CTX *mem_ctx, TRP_ROUTE *entry, const char *sep)
-{
- char *comm=tr_name_strdup(entry->comm);
- char *realm=tr_name_strdup(entry->realm);
- char *peer=tr_name_strdup(entry->peer);
- char *trust_router=tr_name_strdup(entry->trust_router);
- char *next_hop=tr_name_strdup(entry->next_hop);
- char *expiry=timespec_to_str(entry->expiry);
- char *result=NULL;
-
- if (sep==NULL)
- sep=", ";
-
- result=talloc_asprintf(mem_ctx,
- "%s%s%s%s%s%s%u%s%s%s%s%s%u%s%u%s%s%s%u",
- comm, sep,
- realm, sep,
- peer, sep,
- entry->metric, sep,
- trust_router, sep,
- next_hop, sep,
- entry->selected, sep,
- entry->local, sep,
- expiry, sep,
- entry->triggered);
- free(comm);
- free(realm);
- free(peer);
- free(trust_router);
- free(next_hop);
- free(expiry);
- return result;
+void trp_route_set_trust_router_port(TRP_ROUTE *entry, int port)
+{
+ if (entry)
+ entry->trust_router_port = port;
+}
+
+/**
+ * Get the port to use for TRP connections to the trust router
+ *
+ * @param entry
+ * @return port, or -1 if entry is null
+ */
+int trp_route_get_trust_router_port(TRP_ROUTE *entry)
+{
+ if (entry)
+ return entry->trust_router_port;
+
+ return -1;
+}
+
+void trp_route_set_next_hop_port(TRP_ROUTE *entry, int port)
+{
+ if (entry)
+ entry->next_hop_port = port;
+}
+
+/**
+ * Get the port to use for TID connections to the next hop
+ *
+ * @param entry
+ * @return port, or -1 if entry is null
+ */
+int trp_route_get_next_hop_port(TRP_ROUTE *entry)
+{
+ if (entry)
+ return entry->next_hop_port;
+
+ return -1;
}