#include <talloc.h>
#include <time.h>
-#include <trust_router/tr_name.h>
+#include <tr_name_internal.h>
#include <tr_idp.h>
#include <tr_config.h>
#include <tr_debug.h>
{
TR_AAA_SERVER *aaa=talloc(mem_ctx, TR_AAA_SERVER);
if (aaa!=NULL) {
+ aaa->next=NULL;
aaa->hostname=hostname;
talloc_set_destructor((void *)aaa, tr_aaa_server_destructor);
}
talloc_free(aaa);
}
-TR_AAA_SERVER *tr_idp_aaa_server_lookup(TR_IDP_REALM *idp_realms, TR_NAME *idp_realm_name, TR_NAME *comm)
+TR_AAA_SERVER_ITER *tr_aaa_server_iter_new(TALLOC_CTX *mem_ctx)
+{
+ return talloc(mem_ctx, TR_AAA_SERVER_ITER);
+}
+
+void tr_aaa_server_iter_free(TR_AAA_SERVER_ITER *iter)
+{
+ talloc_free(iter);
+}
+
+TR_AAA_SERVER *tr_aaa_server_iter_first(TR_AAA_SERVER_ITER *iter, TR_AAA_SERVER *aaa)
+{
+ iter->this=aaa;
+ return iter->this;
+}
+
+TR_AAA_SERVER *tr_aaa_server_iter_next(TR_AAA_SERVER_ITER *iter)
+{
+ if (iter->this!=NULL) {
+ iter->this=iter->this->next;
+ }
+ return iter->this;
+}
+
+
+/* fills in shared if pointer not null */
+TR_AAA_SERVER *tr_idp_aaa_server_lookup(TR_IDP_REALM *idp_realms, TR_NAME *idp_realm_name, TR_NAME *comm, int *shared_out)
{
TR_IDP_REALM *idp = NULL;
break;
}
}
- if (idp)
+ if (idp) {
+ if (shared_out!=NULL)
+ *shared_out=idp->shared_config;
return idp->aaa_servers;
- else
+ } else
return NULL;
}
idp->aaa_servers=NULL;
idp->apcs=NULL;
idp->origin=TR_REALM_LOCAL;
+ idp->refcount=0;
talloc_set_destructor((void *)idp, tr_idp_realm_destructor);
}
return idp;
}
result=talloc_asprintf(mem_ctx,
- "IDP realm: \"%.*s\"\n"
- " shared: %s\n"
- " local: %s\n"
- " AAA servers: %s\n"
- " APCs: %s\n",
+ "IDP realm: \"%.*s\""
+ " shared: %s"
+ " local: %s"
+ " AAA servers: %s"
+ " APCs: %s",
idp->realm_id->len, idp->realm_id->buf,
(idp->shared_config)?"yes":"no",
(idp->origin==TR_REALM_LOCAL)?"yes":"no",
if (head==NULL)
return NULL;
- /* will not remove the head here, that has already been done */
- for (idp=head; idp->next!=NULL; idp=idp->next) {
+ /* Will not remove the head here, that has already been done.*/
+ for (idp=head; (idp!=NULL) && (idp->next!=NULL); idp=idp->next) {
if (idp->next->refcount==0) {
old_next=idp->next;
- tr_idp_realm_remove(head, idp->next); /* changes idp->next */
+ tr_idp_realm_remove(head, idp->next); /* changes idp->next, may make it NULL */
tr_idp_realm_free(old_next);
}
}