45#include <radcli/radcli.h>
54static unsigned int radcli_legacy_debug = 0;
56int rc_add_config(rc_handle *rh,
char const *option_name,
char const *option_val,
57 char const *source,
int line)
59 return radcli2_priv_add_config(rh, option_name, option_val, source, line);
62rc_handle *rc_config_init(rc_handle *rh)
64 return radcli2_priv_config_init(rh);
124rc_handle *rc_read_config(
char const *filename)
126 rc_handle *rh = radcli2_priv_read_config(filename, 0);
128 if (rh != NULL && radcli_legacy_debug)
129 rh->debug = radcli_legacy_debug;
134char *rc_conf_str(rc_handle
const *rh,
char const *optname)
136 return radcli2_priv_conf_str(rh, optname);
139int rc_conf_int(rc_handle
const *rh,
char const *optname)
141 return radcli2_priv_conf_int(rh, optname);
144SERVER *rc_conf_srv(rc_handle
const *rh,
char const *optname)
146 return radcli2_priv_conf_srv(rh, optname);
149int rc_test_config(rc_handle *rh,
char const *filename)
151 return radcli2_priv_test_config(rh, filename);
154int rc_apply_config(rc_handle *rh)
156 return radcli2_priv_apply_config(rh);
159int rc_find_server_addr(rc_handle
const *rh,
char const *server_name,
160 struct addrinfo **info,
char *secret,
rc_type type)
162 return radcli2_priv_find_server_addr(rh, server_name, info, secret, type);
165void rc_config_free(rc_handle *rh)
167 radcli2_priv_config_free(rh);
170rc_handle *rc_new(
void)
172 rc_handle *rh = radcli2_priv_new();
174 if (rh != NULL && radcli_legacy_debug)
175 rh->debug = radcli_legacy_debug;
180void rc_destroy(rc_handle *rh)
182 radcli2_priv_destroy(rh);
190int rc_read_dictionary(rc_handle *rh,
char const *filename)
192 return radcli2_priv_read_dictionary(rh, filename);
195int rc_read_dictionary_from_buffer(rc_handle *rh,
char const *buf,
size_t size)
197 return radcli2_priv_read_dictionary_from_buffer(rh, buf, size);
200void rc_dict_free(rc_handle *rh)
202 radcli2_priv_dict_free(rh);
205int rc_tls_fd(rc_handle *rh)
207 return radcli2_priv_tls_fd(rh);
210int rc_check_tls(rc_handle *rh)
212 return radcli2_priv_check_tls(rh);
227unsigned short rc_getport(
int type)
231 if ((svp = getservbyname((type ==
AUTH) ?
"radius" :
"radacct",
"udp")) == NULL) {
232 return (type ==
AUTH) ? PW_AUTH_UDP_PORT : PW_ACCT_UDP_PORT;
234 return ntohs((
unsigned short)svp->s_port);
238int rc_own_hostname(
char *hostname,
int len)
244#if defined(HAVE_UNAME)
245 if (uname(&uts) < 0) {
246 rc_log(LOG_ERR,
"rc_own_hostname: couldn't get own hostname");
249 strlcpy(hostname, uts.nodename, len);
250#elif defined(HAVE_GETHOSTNAME)
251 if (gethostname(hostname, len) < 0) {
252 rc_log(LOG_ERR,
"rc_own_hostname: couldn't get own hostname");
255#elif defined(HAVE_SYSINFO)
256 if (sysinfo(SI_HOSTNAME, hostname, len) < 0) {
257 rc_log(LOG_ERR,
"rc_own_hostname: couldn't get own hostname");
267int rc_get_srcaddr(
struct sockaddr *lia,
const struct sockaddr *ria)
269 return radcli2_priv_get_srcaddr(lia, ria);
272void rc_setdebug(
int debug)
274 radcli_legacy_debug = debug;
277void rc_openlog(
char const *ident)
280 openlog(ident, LOG_PID, RC_LOG_FACILITY);
296 static unsigned short int cnt = 0;
298 snprintf(buf,
sizeof(buf),
"%08lX%04X%02hX",
299 (
unsigned long int)time(NULL),
300 (
unsigned int)getpid(),
@ AUTH
Request for authentication server.