12#include <radcli/radcli.h>
15main (
int argc,
char **argv)
19 char passwd[AUTH_PASS_LEN + 1];
20 VALUE_PAIR *send = NULL, *received = NULL;
25 openlog(
"my-prog-name", LOG_PID, LOG_DAEMON);
30 snprintf(username,
sizeof(username),
"my-username");
31 snprintf(passwd,
sizeof(passwd),
"my-password");
53 service = PW_AUTHENTICATE_ONLY;
60 result =
rc_auth(rh, 0, send, &received, NULL);
62 if (result == OK_RC) {
63 VALUE_PAIR *vp = received;
67 fprintf(stderr,
"\"%s\" RADIUS Authentication OK\n", username);
71 if (
rc_avpair_tostr(rh, vp, name,
sizeof(name), value,
sizeof(value)) == 0) {
72 fprintf(stderr,
"%s:\t%s\n", name, value);
77 fprintf(stderr,
"\"%s\" RADIUS Authentication failure (RC=%i)\n", username, result);
VALUE_PAIR * rc_avpair_next(VALUE_PAIR *t)
int rc_auth(rc_handle *rh, uint32_t nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
void rc_destroy(rc_handle *rh)
void rc_avpair_free(VALUE_PAIR *pair)
int rc_avpair_tostr(rc_handle const *rh, VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
rc_handle * rc_read_config(char const *filename)
VALUE_PAIR * rc_avpair_add(rc_handle const *rh, VALUE_PAIR **list, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
@ PW_SERVICE_TYPE
Its type is integer.
@ PW_USER_NAME
Its type is string.
@ PW_USER_PASSWORD
Its type is string.