123 |
char p[DOTTED_QUAD_LEN+1]; |
char p[DOTTED_QUAD_LEN+1]; |
124 |
SCM tail = SCM_EOL; |
SCM tail = SCM_EOL; |
125 |
|
|
126 |
for (s = srv_queue->first_server; s; s = s->next) { |
for (s = list_first(srv_queue->servers); |
127 |
|
s; |
128 |
|
s = list_next(srv_queue->servers)) { |
129 |
ip_iptostr(s->addr, p); |
ip_iptostr(s->addr, p); |
130 |
tail = scm_cons(scm_list_2(scm_makfrom0str(s->name), |
tail = scm_cons(scm_list_2(scm_makfrom0str(s->name), |
131 |
scm_makfrom0str(p)), |
scm_makfrom0str(p)), |
140 |
"Returns the ID of the currently selected server.") |
"Returns the ID of the currently selected server.") |
141 |
#define FUNC_NAME s_rad_get_server |
#define FUNC_NAME s_rad_get_server |
142 |
{ |
{ |
143 |
return scm_makfrom0str(srv_queue->first_server->name); |
RADIUS_SERVER *s = list_current(srv_queue->servers); |
144 |
|
return s ? scm_makfrom0str(s->name) : SCM_BOOL_F; |
145 |
} |
} |
146 |
#undef FUNC_NAME |
#undef FUNC_NAME |
147 |
|
|
148 |
RADIUS_SERVER * |
RADIUS_SERVER * |
149 |
scheme_to_server(LIST, func) |
scheme_to_server(SRVLIST, func) |
150 |
SCM LIST; |
SCM SRVLIST; |
151 |
const char *func; |
const char *func; |
152 |
{ |
{ |
153 |
RADIUS_SERVER serv; |
RADIUS_SERVER serv; |
154 |
SCM scm; |
SCM scm; |
155 |
|
|
156 |
SCM_ASSERT((SCM_NIMP(LIST) && SCM_CONSP(LIST)), |
SCM_ASSERT((SCM_NIMP(SRVLIST) && SCM_CONSP(SRVLIST)), |
157 |
LIST, SCM_ARG1, func); |
SRVLIST, SCM_ARG1, func); |
158 |
|
|
159 |
scm = SCM_CAR(LIST); |
scm = SCM_CAR(SRVLIST); |
160 |
SCM_ASSERT(SCM_NIMP(scm) && SCM_STRINGP(scm), |
SCM_ASSERT(SCM_NIMP(scm) && SCM_STRINGP(scm), |
161 |
scm, SCM_ARG1, func); |
scm, SCM_ARG1, func); |
162 |
serv.name = SCM_STRING_CHARS(scm); |
serv.name = SCM_STRING_CHARS(scm); |
163 |
|
|
164 |
scm = SCM_CADR(LIST); |
scm = SCM_CADR(SRVLIST); |
165 |
SCM_ASSERT(SCM_NIMP(scm) && SCM_STRINGP(scm), |
SCM_ASSERT(SCM_NIMP(scm) && SCM_STRINGP(scm), |
166 |
scm, SCM_ARG1, func); |
scm, SCM_ARG1, func); |
167 |
serv.addr = ip_gethostaddr(SCM_STRING_CHARS(scm)); |
serv.addr = ip_gethostaddr(SCM_STRING_CHARS(scm)); |
170 |
"Bad hostname or ip address ~S\n", |
"Bad hostname or ip address ~S\n", |
171 |
scm); |
scm); |
172 |
|
|
173 |
scm = SCM_CADDR(LIST); |
scm = SCM_CADDR(SRVLIST); |
174 |
SCM_ASSERT(SCM_NIMP(scm) && SCM_STRINGP(scm), |
SCM_ASSERT(SCM_NIMP(scm) && SCM_STRINGP(scm), |
175 |
scm, SCM_ARG1, func); |
scm, SCM_ARG1, func); |
176 |
serv.secret = SCM_STRING_CHARS(scm); |
serv.secret = SCM_STRING_CHARS(scm); |
177 |
|
|
178 |
scm = SCM_CADDDR(LIST); |
scm = SCM_CADDDR(SRVLIST); |
179 |
SCM_ASSERT(SCM_IMP(scm) && SCM_INUMP(scm), |
SCM_ASSERT(SCM_IMP(scm) && SCM_INUMP(scm), |
180 |
scm, SCM_ARG1, func); |
scm, SCM_ARG1, func); |
181 |
serv.port[PORT_AUTH] = SCM_INUM(scm); |
serv.port[PORT_AUTH] = SCM_INUM(scm); |
182 |
|
|
183 |
scm = SCM_CAR(SCM_CDDDDR(LIST)); |
scm = SCM_CAR(SCM_CDDDDR(SRVLIST)); |
184 |
SCM_ASSERT(SCM_IMP(scm) && SCM_INUMP(scm), |
SCM_ASSERT(SCM_IMP(scm) && SCM_INUMP(scm), |
185 |
scm, SCM_ARG1, func); |
scm, SCM_ARG1, func); |
186 |
serv.port[PORT_ACCT] = SCM_INUM(scm); |
serv.port[PORT_ACCT] = SCM_INUM(scm); |
189 |
} |
} |
190 |
|
|
191 |
SCM_DEFINE(rad_client_add_server, "rad-client-add-server", 1, 0, 0, |
SCM_DEFINE(rad_client_add_server, "rad-client-add-server", 1, 0, 0, |
192 |
(SCM LIST), |
(SCM SRVLIST), |
193 |
"Add a server to the list of configured radius servers") |
"Add a server to the list of configured radius servers") |
194 |
#define FUNC_NAME s_rad_client_add_server |
#define FUNC_NAME s_rad_client_add_server |
195 |
{ |
{ |
196 |
srv_queue->first_server = |
rad_clt_append_server(srv_queue, scheme_to_server(SRVLIST, FUNC_NAME)); |
|
rad_clt_append_server(srv_queue->first_server, |
|
|
scheme_to_server(LIST, FUNC_NAME)); |
|
197 |
return SCM_UNSPECIFIED; |
return SCM_UNSPECIFIED; |
198 |
} |
} |
199 |
#undef FUNC_NAME |
#undef FUNC_NAME |
200 |
|
|
201 |
SCM_DEFINE(rad_client_set_server, "rad-client-set-server", 1, 0, 0, |
SCM_DEFINE(rad_client_set_server, "rad-client-set-server", 1, 0, 0, |
202 |
(SCM LIST), |
(SCM SRVLIST), |
203 |
"Selects for use the server described by LIST. A LIST should be:\n" |
"Selects for use the server described by SRVLIST. A SRVLIST should be:\n" |
204 |
"\n" |
"\n" |
205 |
" (list ID-STRING HOST-STRING SECRET-STRING AUTH-NUM ACCT-NUM)\n" |
" (list ID-STRING HOST-STRING SECRET-STRING AUTH-NUM ACCT-NUM)\n" |
206 |
"Where:\n" |
"Where:\n" |
211 |
" ACCT-NUM Accounting port number\n") |
" ACCT-NUM Accounting port number\n") |
212 |
#define FUNC_NAME s_rad_client_set_server |
#define FUNC_NAME s_rad_client_set_server |
213 |
{ |
{ |
214 |
RADIUS_SERVER *s = scheme_to_server(LIST, FUNC_NAME); |
RADIUS_SERVER *s = scheme_to_server(SRVLIST, FUNC_NAME); |
215 |
|
|
216 |
rad_clt_clear_server_list(srv_queue->first_server); |
rad_clt_clear_server_list(srv_queue); |
217 |
srv_queue->first_server = rad_clt_append_server(NULL, s); |
rad_clt_append_server(srv_queue, s); |
218 |
return SCM_UNSPECIFIED; |
return SCM_UNSPECIFIED; |
219 |
} |
} |
220 |
#undef FUNC_NAME |
#undef FUNC_NAME |