WIP on libradsec: 94e3f46 Example client crafting simple packet using freeradius...
[libradsec.git] / lib / radsec.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <libgen.h>
5
6 #include <freeradius/libradius.h>
7 #include "libradsec.h"
8 #include "libradsec-impl.h"
9
10 int
11 rs_context_create(struct rs_handle **ctx, const char *dict)
12 {
13   struct rs_handle *h;
14
15   *ctx = NULL;
16   h = (struct rs_handle *) malloc (sizeof (struct rs_handle));
17   if (h)
18     {
19       char *buf;
20       char *dir, *fn;
21
22       buf = malloc (strlen (dict) + 1);
23       if (!buf)
24         {
25           free (h);
26           return RSE_NOMEM;
27         }
28       strcpy (buf, dict);
29       dir = dirname (buf);
30       free (buf);
31       strcpy (buf, dict);
32       fn = basename (buf);
33       free (buf);
34       if (dict_init (dir, fn) < 0)
35         {
36           free (h);
37           return RSE_SOME_ERROR;
38         }
39 #if defined (DEBUG)
40       fr_log_fp = stderr;
41       fr_debug_flag = 1;
42 #endif
43       fr_randinit (&h->fr_randctx, 0);
44       fr_rand_seed (NULL, 0);
45
46       *ctx = h;
47     }
48   return (h ? RSE_OK : RSE_NOMEM);
49 }
50
51 void rs_context_destroy(struct rs_handle *ctx)
52 {
53   free (ctx);
54 }
55
56 int rs_context_set_alloc_scheme(struct rs_handle *ctx, struct rs_alloc_scheme *scheme)
57 {
58   return RSE_NOSYS;
59 }
60
61 int rs_context_config_read(struct rs_handle *ctx, const char *config_file)
62 {
63   return RSE_NOSYS;
64 }
65
66 int rs_conn_create(const struct rs_handle *ctx, struct rs_connection **conn)
67 {
68   return RSE_NOSYS;
69 }
70
71 int rs_conn_add_server(struct rs_connection  *conn, rs_conn_type_t type, const char *host, int port, int timeout, int tries, const char *secret)
72 {
73   return RSE_NOSYS;
74 }
75
76 int rs_conn_add_listener(struct rs_connection  *conn, rs_conn_type_t type, const char *host, int port, const char *secret)
77 {
78   return RSE_NOSYS;
79 }
80
81 int rs_conn_destroy(struct rs_connection  *conn)
82 {
83   return RSE_NOSYS;
84 }
85
86 int rs_conn_set_eventbase(struct rs_connection *conn, struct event_base *eb)
87 {
88   return RSE_NOSYS;
89 }
90
91 int rs_conn_set_callbacks(struct rs_connection *conn, struct rs_conn_callbacks *cb)
92 {
93   return RSE_NOSYS;
94 }
95
96 int rs_conn_set_server(struct rs_connection *conn, const char *name)
97 {
98   return RSE_NOSYS;
99 }
100
101 int rs_conn_get_server(const struct rs_connection *conn, const char *name, size_t buflen)
102 {
103   return RSE_NOSYS;
104 }