This is an example of how to use the radcli API.
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <radcli/radcli.h>
int
main (int argc, char **argv)
{
int result;
char username[128];
char passwd[AUTH_PASS_LEN + 1];
uint32_t service;
rc_handle *rh;
return ERROR_RC;
strcpy(username, "my-username");
strcpy(passwd, "my-password");
send = NULL;
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) {
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;
}
void rc_openlog(char const *ident)
int rc_auth(rc_handle *rh, uint32_t nas_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
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.