+/* convert an IDP realm into routing table entries. Outputs number in *n_routes */
+static TRP_RENTRY **tr_make_local_routes(TALLOC_CTX *mem_ctx,
+ TR_IDP_REALM *realm,
+ char *trust_router,
+ size_t *n_routes)
+{
+ TALLOC_CTX *tmp_ctx=talloc_new(NULL);
+ TR_APC *apc=NULL;
+ TRP_RENTRY *new_entry=NULL;
+ TRP_RENTRY **entries=NULL;
+ size_t n_apcs=0, ii=0;
+
+ *n_routes=0;
+
+ if (realm==NULL)
+ goto cleanup;
+
+ /* count apcs */
+ for (apc=realm->apcs, n_apcs=0; apc!=NULL; apc=apc->next,n_apcs++) {}
+
+ entries=talloc_array(tmp_ctx, TRP_RENTRY *, n_apcs);
+ for (apc=realm->apcs,ii=0; apc!=NULL; apc=apc->next, ii++) {
+ new_entry=trp_rentry_new(entries);
+ if (new_entry==NULL) {
+ tr_crit("tr_make_local_routes: unable to allocate entry.");
+ talloc_free(entries);
+ goto cleanup;
+ }
+ trp_rentry_set_apc(new_entry, tr_dup_name(apc->id));
+ trp_rentry_set_realm(new_entry, tr_dup_name(realm->realm_id));
+ trp_rentry_set_peer(new_entry, tr_new_name("")); /* no peer, it's us */
+ trp_rentry_set_metric(new_entry, 0);
+ trp_rentry_set_trust_router(new_entry, tr_new_name(trust_router));
+ trp_rentry_set_next_hop(new_entry, tr_new_name(""));
+ /* we do not set selected (tbd later) or expiry/interval (not needed for
+ * local routes) */
+ entries[ii]=new_entry;
+ }
+
+ talloc_steal(mem_ctx, entries);
+ *n_routes=n_apcs;
+ cleanup:
+ talloc_free(tmp_ctx);
+ return entries;
+}
+
+struct tr_trpc_status_change_cookie {
+ TRPS_INSTANCE *trps;
+ TRPC_INSTANCE *trpc;
+ TRP_PEER *peer;
+};
+static void tr_trpc_status_change(TRP_CONNECTION *conn, void *cookie)
+{
+ struct tr_trpc_status_change_cookie *cook=talloc_get_type_abort(cookie, struct tr_trpc_status_change_cookie);
+ /*TRPS_INSTANCE *trps=cook->trps;*/
+ /* TRPC_INSTANCE *trpc=cook->trpc;*/
+ TRP_PEER *peer=cook->peer;
+ TR_NAME *gssname=trp_peer_get_gssname(peer);
+
+ if (trp_connection_get_status(conn)==TRP_CONNECTION_UP)
+ tr_debug("tr_trpc_status_change: connection now up.");
+ else
+ tr_debug("tr_trpc_status_change: connection now down.");
+ tr_free_name(gssname);
+}
+