summaryrefslogtreecommitdiff
path: root/lib/radsec.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2010-10-03 23:27:46 +0200
committerLinus Nordberg <linus@nordu.net>2010-10-03 23:27:46 +0200
commitdcfb8bca7400c5db4fafbed7aa9395e5f3277d9b (patch)
treeb27ba2c7de397236b85e5a02a6277fe786fc17ff /lib/radsec.c
parent4d99bb55ec1368b42daccb29f0440bc166297a17 (diff)
WIP
Diffstat (limited to 'lib/radsec.c')
-rw-r--r--lib/radsec.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/radsec.c b/lib/radsec.c
index 6ec2b06..adf5576 100644
--- a/lib/radsec.c
+++ b/lib/radsec.c
@@ -81,7 +81,7 @@ int rs_context_config_read(struct rs_handle *ctx, const char *config_file)
int
rs_conn_create(struct rs_handle *ctx, struct rs_connection **conn,
- rs_conn_type_t type)
+ const char *config)
{
struct rs_connection *c;
@@ -90,13 +90,27 @@ rs_conn_create(struct rs_handle *ctx, struct rs_connection **conn,
{
memset (c, 0, sizeof(struct rs_connection));
c->ctx = ctx;
- c->type = type;
+ if (config)
+ {
+ struct rs_realm *r = rs_conf_find_realm (ctx, config);
+ if (r)
+ {
+ c->type = r->type;
+ c->peers = r->peers; /* FIXME: Copy? */
+ }
+ }
}
if (conn)
*conn = c;
return c ? RSE_OK : rs_err_ctx_push (ctx, RSE_NOMEM, NULL);
}
+void
+rs_conn_set_type(struct rs_connection *conn, rs_conn_type_t type)
+{
+ conn->type = type;
+}
+
struct addrinfo *
_resolv (struct rs_connection *conn, const char *hostname, int port)
{
@@ -157,8 +171,7 @@ _peer_new (struct rs_connection *conn)
}
int
-rs_server_create (struct rs_connection *conn, struct rs_peer **server,
- const char *config)
+rs_server_create (struct rs_connection *conn, struct rs_peer **server)
{
struct rs_peer *srv;
@@ -168,7 +181,8 @@ rs_server_create (struct rs_connection *conn, struct rs_peer **server,
srv->timeout = 1;
srv->tries = 3;
}
- *server = srv;
+ if (*server)
+ *server = srv;
return srv ? RSE_OK : -1;
}