17#include <radcli/radcli2.h>
24print_reply(radcli_ctx *ctx,
const radcli_avp_list *recvd)
26 uint32_t timeout, service_type;
27 struct in6_addr framed_ipv6;
28 char buf[INET6_ADDRSTRLEN];
31 fprintf(stderr,
"Session-Timeout: %u seconds\n", (
unsigned)timeout);
34 inet_ntop(AF_INET6, &framed_ipv6, buf,
sizeof(buf)) != NULL)
35 fprintf(stderr,
"Framed-IPv6-Address: %s\n", buf);
38 fprintf(stderr,
"Service-Type: %u\n", (
unsigned)service_type);
42main (
int argc,
char **argv)
46 radcli_avp_list *send = NULL;
50 openlog(
"my-prog-name", LOG_PID, LOG_DAEMON);
72 fprintf(stderr,
"error constructing the Access-Request\n");
87 fprintf(stderr,
"\"my-username\" RADIUS Authentication OK\n");
91 fprintf(stderr,
"\"my-username\" RADIUS Authentication failure\n");
int radcli_avp_list_error(const radcli_avp_list *list)
Check whether any radcli_avp_add_*()/_by_num() call on list has ever failed.
void radcli_avp_list_free(radcli_avp_list *list)
Free a list and every attribute it holds.
int radcli_avp_add_uint32_by_num(radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, uint32_t value)
Look up an integer/IPv4-address/date-typed attribute by legacy numeric ID and append it.
int radcli_avp_add_str_by_num(radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, const char *value)
Look up a string-typed attribute by legacy numeric ID and append it.
int radcli_avp_get_uint32_by_num(const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, uint32_t *out)
Look up an integer/IPv4-address/date-typed attribute by legacy numeric ID and read its first occurren...
radcli_avp_list * radcli_avp_list_new(void)
Create an empty attribute-value pair list.
int radcli_avp_get_ip6_by_num(const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, struct in6_addr *out, unsigned *prefix)
Look up an IPv6-address or IPv6-prefix-typed attribute by legacy numeric ID and read its first occurr...
radcli_ctx * radcli_ctx_read_config(const char *filename, unsigned flags)
Create a context by parsing a config file – the main, recommended way to configure radcli.
void radcli_ctx_free(radcli_ctx *ctx)
Release a context.
int radcli_request_perform(radcli_request *r, unsigned flags)
Send a request, optionally waiting for the reply.
const radcli_avp_list * radcli_request_attrs(const radcli_request *r)
Return the reply's decoded attributes.
radcli_request * radcli_request_new(radcli_ctx *ctx, radcli_code code, const radcli_avp_list *send)
Create a request to send.
void radcli_request_free(radcli_request *r)
Release a request.
radcli_code radcli_request_code(const radcli_request *r)
Return the reply's RADIUS code.
@ RADCLI_OK
A validated reply was received; see radcli_request_code() for which one.