entry->peer=NULL;
entry->next_hop=NULL;
entry->selected=0;
+ entry->interval=0;
entry->expiry=talloc(entry, struct timespec);
if (entry->expiry==NULL) {
talloc_free(entry);
return entry->apc;
}
+TR_NAME *trp_rentry_dup_apc(TRP_RENTRY *entry)
+{
+ return tr_dup_name(trp_rentry_get_apc(entry));
+}
+
void trp_rentry_set_realm(TRP_RENTRY *entry, TR_NAME *realm)
{
entry->realm=realm;
return entry->realm;
}
+TR_NAME *trp_rentry_dup_realm(TRP_RENTRY *entry)
+{
+ return tr_dup_name(trp_rentry_get_realm(entry));
+}
+
void trp_rentry_set_trust_router(TRP_RENTRY *entry, TR_NAME *tr)
{
entry->trust_router=tr;
return entry->trust_router;
}
+TR_NAME *trp_rentry_dup_trust_router(TRP_RENTRY *entry)
+{
+ return tr_dup_name(trp_rentry_get_trust_router(entry));
+}
+
void trp_rentry_set_peer(TRP_RENTRY *entry, TR_NAME *peer)
{
entry->peer=peer;
return entry->peer;
}
+TR_NAME *trp_rentry_dup_peer(TRP_RENTRY *entry)
+{
+ return tr_dup_name(trp_rentry_get_peer(entry));
+}
+
void trp_rentry_set_metric(TRP_RENTRY *entry, unsigned int metric)
{
entry->metric=metric;
return entry->next_hop;
}
+TR_NAME *trp_rentry_dup_next_hop(TRP_RENTRY *entry)
+{
+ return tr_dup_name(trp_rentry_get_next_hop(entry));
+}
+
void trp_rentry_set_selected(TRP_RENTRY *entry, int sel)
{
entry->selected=sel;
return entry->selected;
}
+void trp_rentry_set_interval(TRP_RENTRY *entry, int interval)
+{
+ entry->interval=interval;
+}
+
+int trp_rentry_get_interval(TRP_RENTRY *entry)
+{
+ return entry->interval;
+}
+
/* copies incoming value, does not assume responsibility for freeing */
void trp_rentry_set_expiry(TRP_RENTRY *entry, struct timespec *exp)
{
/* Gets a single entry. Do not free it. */
TRP_RENTRY *trp_rtable_get_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm, TR_NAME *peer)
{
- GHashTable *apc_tbl=NULL;
GHashTable *realm_tbl=NULL;
- apc_tbl=g_hash_table_lookup(rtbl, apc);
- if (apc_tbl==NULL)
- return NULL;
- realm_tbl=g_hash_table_lookup(apc_tbl, realm);
+ realm_tbl=trp_rtable_get_realm_table(rtbl, apc, realm);
if (realm_tbl==NULL)
return NULL;
return g_hash_table_lookup(realm_tbl, peer); /* does not copy or increment ref count */
return s;
}
+TRP_RENTRY *trp_rtable_get_selected_entry(TRP_RTABLE *rtbl, TR_NAME *apc, TR_NAME *realm)
+{
+ size_t n=0;
+ TRP_RENTRY **entry=trp_rtable_get_realm_entries(rtbl, apc, realm, &n);
+ TRP_RENTRY *selected=NULL;
+
+ if (n==0)
+ return NULL;
+
+ while(n-- && !trp_rentry_get_selected(entry[n])) { }
+ selected=entry[n];
+ talloc_free(entry);
+ return selected;
+}
+
/* Pretty print a route table entry to a newly allocated string. If sep is NULL,
* returns comma+space separated string. */
char *trp_rentry_to_str(TALLOC_CTX *mem_ctx, TRP_RENTRY *entry, const char *sep)