This is an example of how to use the radcli API.
#include <config.h>
#include <stdio.h>
#include <syslog.h>
#include <radcli/radcli.h>
int
main (int argc, char **argv)
{
int result;
char username[128];
char passwd[AUTH_PASS_LEN + 1];
VALUE_PAIR *send = NULL, *received = NULL;
uint32_t service;
rc_handle *rh;
openlog("my-prog-name", LOG_PID, LOG_DAEMON);
return ERROR_RC;
snprintf(username, sizeof(username), "my-username");
snprintf(passwd, sizeof(passwd), "my-password");
return ERROR_RC;
}
return ERROR_RC;
}
service = PW_AUTHENTICATE_ONLY;
return ERROR_RC;
}
result =
rc_auth(rh, 0, send, &received, NULL);
if (result == OK_RC) {
VALUE_PAIR *vp = received;
char name[128];
char value[128];
fprintf(stderr, "\"%s\" RADIUS Authentication OK\n", username);
while(vp != NULL) {
if (
rc_avpair_tostr(rh, vp, name,
sizeof(name), value,
sizeof(value)) == 0) {
fprintf(stderr, "%s:\t%s\n", name, value);
}
}
} else {
fprintf(stderr, "\"%s\" RADIUS Authentication failure (RC=%i)\n", username, result);
}
return 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.