1 /* See the file COPYING for licensing information. */
3 #if defined HAVE_CONFIG_H
14 #include <freeradius/libradius.h>
15 #include <event2/event.h>
16 #include <event2/util.h>
17 #include <radsec/radsec.h>
18 #include <radsec/radsec-impl.h>
19 #if defined (RS_ENABLE_TLS)
23 #include "../radsecproxy.h"
25 #include "rsp_debug.h"
28 rs_context_create(struct rs_context **ctx, const char *dict)
32 char *buf1 = NULL, *buf2 = NULL;
39 h = (struct rs_context *) malloc (sizeof(struct rs_context));
43 /* Initialize freeradius dictionary. */
44 buf1 = malloc (strlen (dict) + 1);
45 buf2 = malloc (strlen (dict) + 1);
55 if (dict_init (dir, fn) < 0)
63 #if defined (RS_ENABLE_TLS)
70 debug_init ("libradsec"); /* radsecproxy compat, FIXME: remove */
72 memset (h, 0, sizeof(struct rs_context));
73 fr_randinit (&h->fr_randctx, 0);
74 fr_rand_seed (NULL, 0);
92 _rs_peer_create (struct rs_context *ctx, struct rs_peer **rootp)
96 p = (struct rs_peer *) rs_malloc (ctx, sizeof(*p));
99 memset (p, 0, sizeof(struct rs_peer));
102 p->next = (*rootp)->next;
112 _rs_peer_destroy (struct rs_peer *p)
116 assert (p->conn->ctx);
117 /* NOTE: The peer object doesn't own its connection (conn). */
120 evutil_freeaddrinfo (p->addr);
124 rs_free (p->conn->ctx, p->secret);
125 rs_free (p->conn->ctx, p);
128 void rs_context_destroy(struct rs_context *ctx)
130 struct rs_realm *r = NULL;
131 struct rs_peer *p = NULL;
133 for (r = ctx->realms; r; )
135 struct rs_realm *tmp = r;
136 for (p = r->peers; p; )
138 struct rs_peer *tmp = p;
140 _rs_peer_destroy (tmp);
148 int rs_context_set_alloc_scheme(struct rs_context *ctx,
149 struct rs_alloc_scheme *scheme)
151 return rs_err_ctx_push_fl (ctx, RSE_NOSYS, __FILE__, __LINE__,
152 "%s: NYI", __func__);