Radcli library 1.5.3
A simple radius library
Loading...
Searching...
No Matches
radcli.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1995,1996,1997,1998 Lars Fenneberg
3 *
4 * Copyright 1992 Livingston Enterprises, Inc.
5 *
6 * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
7 * and Merit Network, Inc. All Rights Reserved
8 *
9 * See the file COPYRIGHT for the respective terms and conditions.
10 * If the file is missing contact me at lf@elemental.net
11 * and I'll send you a copy.
12 *
13 */
14
18
19#ifndef RADCLI_H
20#define RADCLI_H
21
22#include <sys/types.h>
23/*
24 * Include for C99 uintX_t defines is stdint.h on most systems. Solaris uses
25 * inttypes.h instead. Comment out the stdint include if you get an error,
26 * and uncomment the inttypes.h include.
27 */
28#include <stdint.h>
29/* #include <inttypes.h> */
30#include <stdio.h>
31#include <time.h>
32
33/* for struct in6_addr */
34#include <netinet/in.h>
35
36/* for struct addrinfo and sockaddr_storage */
37#include <sys/socket.h>
38#include <netdb.h>
39
40/* *INDENT-OFF* */
41#ifdef __cplusplus
42extern "C" {
43#endif
44/* *INDENT-ON* */
45
52
53#define AUTH_PASS_LEN (8 * 16) /* multiple of 16 */
54#define AUTH_ID_LEN 64
55
56#define RC_BUFFER_LEN 8192
57#define RC_MAX_PACKET_LEN 4096 /* RFC 2865: maximum RADIUS packet size */
58
59#define RC_NAME_LENGTH 64
60
61#define MAX_SECRET_LENGTH (16 * 16) /* MUST be multiple of 16 */
62
63#define RADCLI_VENDOR_MASK 0xffffffff
64#define VENDOR_BIT_SIZE 32
65#define RADCLI_VENDOR_ATTR_SET(attr, vendor) ((attr)|((uint64_t)((vendor)&RADCLI_VENDOR_MASK)) << VENDOR_BIT_SIZE)
66
67#define VENDOR(x) (((x) >> VENDOR_BIT_SIZE) & 0xffffffff)
68#define ATTRID(x) ((x) & 0xffffffff)
69
70#define PW_MAX_MSG_SIZE 4096
71
74typedef enum rc_type {
75 AUTH = 0,
76 ACCT = 1
77} rc_type;
78
79/* defines for config.c */
80
81#define RC_SERVER_MAX 8
82
83#define AUTH_LOCAL_FST (1<<0)
84#define AUTH_RADIUS_FST (1<<1)
85#define AUTH_LOCAL_SND (1<<2)
86#define AUTH_RADIUS_SND (1<<3)
87
88struct rc_conf;
89typedef struct rc_conf rc_handle;
90
95typedef struct server {
96 int max;
97 char *name[RC_SERVER_MAX];
98 uint16_t port[RC_SERVER_MAX];
99 char *secret[RC_SERVER_MAX];
100 double deadtime_ends[RC_SERVER_MAX];
101} SERVER;
102
111
112#define AUTH_HDR_LEN 20
113#define CHAP_VALUE_LENGTH 16
114
115#define PW_AUTH_UDP_PORT 1812
116#define PW_ACCT_UDP_PORT 1813
117
129
132typedef enum rc_standard_codes {
133 PW_ACCESS_REQUEST=1,
134 PW_ACCESS_ACCEPT=2,
135 PW_ACCESS_REJECT=3,
136 PW_ACCOUNTING_REQUEST=4,
137 PW_ACCOUNTING_RESPONSE=5,
138 PW_ACCOUNTING_STATUS=6,
139 PW_PASSWORD_REQUEST=7,
140 PW_PASSWORD_ACK=8,
141 PW_PASSWORD_REJECT=9,
142 PW_ACCOUNTING_MESSAGE=10,
143 PW_ACCESS_CHALLENGE=11,
144 PW_STATUS_SERVER=12,
145 PW_STATUS_CLIENT=13
147
150typedef enum rc_attr_id {
253
257
259
272
276} rc_attr_id;
277
278/* Integer Translations */
279
282typedef enum rc_service_type {
283 PW_LOGIN=1,
284 PW_FRAMED=2,
285 PW_CALLBACK_LOGIN=3,
286 PW_CALLBACK_FRAMED=4,
287 PW_OUTBOUND=5,
288 PW_ADMINISTRATIVE=6,
289 PW_NAS_PROMPT=7,
290 PW_AUTHENTICATE_ONLY=8,
291 PW_CALLBACK_NAS_PROMPT=9
293
296typedef enum rc_framed_protocol {
297 PW_PPP=1,
298 PW_SLIP=2,
299 PW_ARA= 3,
300 PW_GANDALF=4,
301 PW_XYLOGICS=5
303
307 PW_NONE=0,
308 PW_BROADCAST=1,
309 PW_LISTEN=2,
310 PW_BROADCAST_LISTEN=3
312
314
317typedef enum rc_framed_comp {
318 PW_COMP_NONE=0,
319 PW_VAN_JACOBSON_TCP_IP=1,
320 PW_IPX_HEADER_COMPRESSION=2,
321 PW_COMP_LZS=3
323
327 PW_TELNET=0,
328 PW_RLOGIN=1,
329 PW_TCP_CLEAR=2,
330 PW_PORTMASTER=3,
331 PW_LAT=4,
332 PW_X25_PAD=5,
333 PW_X25_T3POS=6
335
339 PW_DEFAULT=0,
340 PW_RADIUS_REQUEST=1
342
343
347 PW_STATUS_START=1,
348 PW_STATUS_STOP=2,
349 PW_STATUS_ALIVE=3,
350 PW_STATUS_MODEM_START=4,
351 PW_STATUS_MODEM_STOP=5,
352 PW_STATUS_CANCEL=6,
353 PW_ACCOUNTING_ON=7,
354 PW_ACCOUNTING_OFF=8
356
360 PW_USER_REQUEST=1,
361 PW_LOST_CARRIER=2,
362 PW_LOST_SERVICE=3,
363 PW_ACCT_IDLE_TIMEOUT=4,
364 PW_ACCT_SESSION_TIMEOUT=5,
365 PW_ADMIN_RESET=6,
366 PW_ADMIN_REBOOT=7,
367 PW_PORT_ERROR=8,
368 PW_NAS_ERROR=9,
369 PW_NAS_REQUEST=10,
370 PW_NAS_REBOOT=11,
371 PW_PORT_UNNEEDED=12,
372 PW_PORT_PREEMPTED=13,
373 PW_PORT_SUSPENDED=14,
374 PW_SERVICE_UNAVAILABLE=15,
375 PW_CALLBACK=16,
376 PW_USER_ERROR=17,
377 PW_HOST_REQUEST=18
379
382typedef enum rc_nas_port_type {
383 PW_ASYNC=0,
384 PW_SYNC=1,
385 PW_ISDN_SYNC=2,
386 PW_ISDN_SYNC_V120=3,
387 PW_ISDN_SYNC_V110=4,
388 PW_VIRTUAL=5
390
393typedef enum rc_acct_auth_type {
394 PW_RADIUS=1,
395 PW_LOCAL=2,
396 PW_REMOTE=3
398
401typedef enum rc_vendor_pec {
402 VENDOR_NONE=0,
403 VENDOR_MICROSOFT = 311,
404 VENDOR_ROARING_PENGUIN = 10055
405} rc_vendor_type;
406
407/* Vendor RADIUS attribute-value pairs for MICROSOFT */
408enum rc_vendor_attr_microsoft {
409 PW_MS_CHAP_CHALLENGE = 11, /* string */
410 PW_MS_CHAP_RESPONSE = 1, /* string */
411 PW_MS_CHAP2_RESPONSE = 25, /* string */
412 PW_MS_CHAP2_SUCCESS = 26, /* string */
413 PW_MS_MPPE_ENCRYPTION_POLICY= 7, /* string */
414 PW_MS_MPPE_ENCRYPTION_TYPE= 8, /* string */
415 PW_MS_MPPE_ENCRYPTION_TYPES=PW_MS_MPPE_ENCRYPTION_TYPE,
416 PW_MS_CHAP_MPPE_KEYS = 12, /* string */
417 PW_MS_MPPE_SEND_KEY = 16, /* string */
418 PW_MS_MPPE_RECV_KEY = 17, /* string */
419 PW_MS_PRIMARY_DNS_SERVER= 28, /* ipaddr */
420 PW_MS_SECONDARY_DNS_SERVER= 29, /* ipaddr */
421 PW_MS_PRIMARY_NBNS_SERVER= 30, /* ipaddr */
422 PW_MS_SECONDARY_NBNS_SERVER= 31, /* ipaddr */
423};
424
425/* Vendor RADIUS attribute-value pairs for Roaring Penguin: Bandwidth bit rate limits */
426enum rc_vendor_attr_roaringpenguin {
427 PW_RP_UPSTREAM_LIMIT =1, /* integer */
428 PW_RP_DOWNSTREAM_LIMIT =2, /* integer */
429};
430
431/* PROHIBIT PROTOCOL */
432#define PW_DUMB 0
433#define PW_AUTH_ONLY 3
434#define PW_ALL 255
435
436/* Server data structures */
437
441typedef struct dict_attr
442{
443 char name[RC_NAME_LENGTH + 1];
444 uint64_t value;
446 struct dict_attr *next;
447} DICT_ATTR;
448
452typedef struct dict_value
453{
454 char attrname[RC_NAME_LENGTH +1];
455 char name[RC_NAME_LENGTH + 1];
456 uint32_t value;
457 struct dict_value *next;
458} DICT_VALUE;
459
463typedef struct dict_vendor
464{
465 char vendorname[RC_NAME_LENGTH +1];
466 uint32_t vendorpec;
467 struct dict_vendor *next;
468} DICT_VENDOR;
469
470/* don't change this, as it has to be the same as in the Merit radiusd code */
471#define MGMT_POLL_SECRET "Hardlyasecret"
472
475typedef enum rc_send_status {
476 NETUNREACH_RC=-4,
477 BADRESPID_RC=-3,
478 BADRESP_RC=-2,
479 ERROR_RC=-1,
480 OK_RC=0,
481 TIMEOUT_RC=1,
482 REJECT_RC=2,
483 CHALLENGE_RC=3
485
486
487# define AUTH_STRING_LEN 253 /* maximum of 253 */
488
496typedef struct rc_value_pair
497{
498 char name[RC_NAME_LENGTH + 1];
499 uint64_t attribute;
501 uint32_t lvalue;
502 char strvalue[AUTH_STRING_LEN + 1];
503 struct rc_value_pair *next;
504 char pad[32];
505} VALUE_PAIR;
506
512typedef struct send_data
513{
514 uint8_t code;
515 uint8_t seq_nbr;
516 char *server;
518 char *secret;
520 int retries;
521 VALUE_PAIR *send_pairs;
522 VALUE_PAIR *receive_pairs;
523} SEND_DATA;
524
525#define AUTH_VECTOR_LEN 16
526
527struct rc_aaa_ctx_st;
537typedef struct rc_aaa_ctx_st RC_AAA_CTX;
538
539#ifndef RC_MIN
540#define RC_MIN(a, b) ((a) < (b) ? (a) : (b))
541#endif
542#ifndef RC_MAX
543#define RC_MAX(a, b) ((a) > (b) ? (a) : (b))
544#endif
545
546#ifndef PATH_MAX
547#define PATH_MAX 1024
548#endif
549
550#define ENV_SIZE 128
551
553
613
617
621
625
629
633
634/* avpair.c */
635
636VALUE_PAIR *rc_avpair_add (rc_handle const *rh, VALUE_PAIR **list, uint32_t attrid, void const *pval, int len, uint32_t vendorspec);
637int rc_avpair_assign (VALUE_PAIR *vp, void const *pval, int len);
638VALUE_PAIR *rc_avpair_new (rc_handle const *rh, uint32_t attrid, void const *pval, int len, uint32_t vendorspec);
639VALUE_PAIR *rc_avpair_gen(rc_handle const *rh, VALUE_PAIR *pair, unsigned char const *ptr,
640 int length, uint32_t vendorspec);
641void rc_avpair_remove (VALUE_PAIR **list, uint32_t attrid, uint32_t vendorspec);
642VALUE_PAIR *rc_avpair_get (VALUE_PAIR *vp, uint32_t attrid, uint32_t vendorspec);
643VALUE_PAIR *rc_avpair_copy(VALUE_PAIR *p);
644void rc_avpair_insert(VALUE_PAIR **a, VALUE_PAIR *p, VALUE_PAIR *b);
645void rc_avpair_free (VALUE_PAIR *pair);
646int rc_avpair_parse (rc_handle const *rh, char const *buffer, VALUE_PAIR **first_pair);
647int rc_avpair_tostr (rc_handle const *rh, VALUE_PAIR *pair, char *name, int ln, char *value, int lv);
648char *rc_avpair_log(rc_handle const *rh, VALUE_PAIR *pair, char *buf, size_t buf_len);
649VALUE_PAIR *rc_avpair_next(VALUE_PAIR *t);
650
651int rc_avpair_get_uint32 (VALUE_PAIR *vp, uint32_t *res);
652int rc_avpair_get_in6 (VALUE_PAIR *vp, struct in6_addr *res, unsigned *prefix);
653int rc_avpair_get_raw (VALUE_PAIR *vp, char **res, unsigned *res_size);
654void rc_avpair_get_attr (VALUE_PAIR *vp, unsigned *type, unsigned *id);
655
656/* buildreq.c */
657
658void rc_buildreq(rc_handle const *rh, SEND_DATA *data, int code, char *server, unsigned short port,
659 char *secret, int timeout, int retries);
660int rc_auth(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send,
661 VALUE_PAIR **received, char *msg);
662int rc_auth_proxy(rc_handle *rh, VALUE_PAIR *send, VALUE_PAIR **received, char *msg);
663int rc_acct(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send);
664int rc_acct_proxy(rc_handle *rh, VALUE_PAIR *send);
665
684int rc_acct_async(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send);
685
686int rc_check(rc_handle *rh, char *host, char *secret, unsigned short port, char *msg);
687
688int rc_aaa(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received,
689 char *msg, int add_nas_port, rc_standard_codes request_type);
690int rc_aaa_ctx(rc_handle *rh, RC_AAA_CTX **ctx, uint32_t client_port, VALUE_PAIR *send,
691 VALUE_PAIR **received,
692 char *msg, int add_nas_port, rc_standard_codes request_type);
693int rc_aaa_ctx_server(rc_handle *rh, RC_AAA_CTX **ctx, SERVER *aaaserver,
694 rc_type type, uint32_t client_port,
695 VALUE_PAIR *send, VALUE_PAIR **received,
696 char *msg, int add_nas_port, rc_standard_codes request_type);
697
698/* config.c */
699
700int rc_add_config(rc_handle *rh, char const *option_name, char const *option_val, char const *source, int line);
701rc_handle *rc_config_init(rc_handle *rh);
702rc_handle *rc_read_config(char const *filename);
703char *rc_conf_str(rc_handle const *rh, char const *optname);
704int rc_conf_int(rc_handle const *rh, char const *optname);
705SERVER *rc_conf_srv(rc_handle const *rh, char const *optname);
706int rc_test_config(rc_handle *rh, char const *filename);
707int rc_apply_config(rc_handle *rh);
708int rc_find_server_addr (rc_handle const *rh, char const *server_name,
709 struct addrinfo** info, char *secret, rc_type type);
710void rc_config_free(rc_handle *rh);
711rc_handle *rc_new(void);
712void rc_destroy(rc_handle *rh);
713rc_socket_type rc_get_socket_type(rc_handle * rh);
714
715#define test_config rc_test_config
716
717/* dict.c */
718
719int rc_read_dictionary (rc_handle *rh, char const *filename);
720int rc_read_dictionary_from_buffer (rc_handle *rh, char const *buf, size_t size);
721
722DICT_ATTR *rc_dict_addattr(rc_handle *rh, char const * namestr, uint32_t value, int type, uint32_t vendorspec);
723DICT_VALUE *rc_dict_addval(rc_handle *rh, char const * attrstr, char const * namestr, uint32_t value);
724DICT_VENDOR *rc_dict_addvend(rc_handle *rh, char const * vendorname, uint32_t value);
725
726DICT_ATTR *rc_dict_getattr(rc_handle const *rh, uint64_t attribute);
727DICT_ATTR *rc_dict_findattr(rc_handle const *rh, char const *attrname);
728DICT_VALUE *rc_dict_findval(rc_handle const *rh, char const *valname);
729DICT_VENDOR *rc_dict_findvend(rc_handle const *rh, char const *vendorname);
730DICT_VENDOR *rc_dict_getvend (rc_handle const *rh, uint32_t vendorspec);
731DICT_VALUE *rc_dict_getval(rc_handle const *rh, uint32_t value, char const *attrname);
732void rc_dict_free(rc_handle *rh);
733
734/* tls.c */
735
736int rc_tls_fd(rc_handle * rh);
737int rc_check_tls(rc_handle * rh);
738
739/* ip_util.c */
740
741unsigned short rc_getport(int type);
742int rc_own_hostname(char *hostname, int len);
743struct sockaddr;
744int rc_get_srcaddr(struct sockaddr *lia, const struct sockaddr *ria);
745
746/* log.c */
747
748void rc_setdebug(int debug);
749void rc_openlog(char const *ident);
750/* to provide compatibility with any old applications that may have
751 * been using rc_log() */
752#define rc_log syslog
753
754/* sendserver.c */
755
756int rc_send_server (rc_handle *rh, SEND_DATA *data, char *msg,
757 rc_type type);
758
759/* aaa_ctx.c */
760void rc_aaa_ctx_free(RC_AAA_CTX *ctx);
761const char *rc_aaa_ctx_get_secret(RC_AAA_CTX *ctx);
762const void *rc_aaa_ctx_get_vector(RC_AAA_CTX *ctx);
763
764/* obsolete functions */
765#define _RADCLI_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
766#if !defined RADCLI_INTERNAL_BUILD
767# if _RADCLI_GCC_VERSION >= 30100
768# define _RADCLI_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
769# endif
770#endif
771char *rc_mksid(void) _RADCLI_GCC_ATTR_DEPRECATED;
772
773
774/* *INDENT-OFF* */
775#ifdef __cplusplus
776}
777#endif
778/* *INDENT-ON* */
779
780#endif /* RADCLI_H */
unsigned short rc_getport(int type)
Get the port number for the supplied request type.
Definition ip_util.c:64
void rc_setdebug(int debug)
Set debug logging level.
Definition log.c:39
int rc_get_srcaddr(struct sockaddr *lia, const struct sockaddr *ria)
Find outbound interface address for a given destination.
Definition ip_util.c:125
void rc_openlog(char const *ident)
Open the system log for radcli messages.
Definition log.c:54
int rc_own_hostname(char *hostname, int len)
Get the hostname of this machine.
Definition ip_util.c:82
void rc_avpair_remove(VALUE_PAIR **list, uint32_t attrid, uint32_t vendorspec)
Removes an attribute-value pair from the given list.
Definition avpair.c:69
rc_acct_status_type
Definition radcli.h:346
DICT_VALUE * rc_dict_getval(rc_handle const *rh, uint32_t value, char const *attrname)
Get DICT_VALUE based on attribute name and integer value number.
Definition dict.c:704
rc_acct_terminate_cause
Definition radcli.h:359
int rc_avpair_get_raw(VALUE_PAIR *vp, char **res, unsigned *res_size)
Get the raw value of the given attribute value-pair.
Definition avpair.c:1089
char * rc_avpair_log(rc_handle const *rh, VALUE_PAIR *pair, char *buf, size_t buf_len)
Format a sequence of attribute value pairs into a printable string.
Definition avpair.c:1004
rc_socket_type rc_get_socket_type(rc_handle *rh)
Returns the type of the socket used.
Definition config.c:1273
VALUE_PAIR * rc_avpair_next(VALUE_PAIR *t)
Iterates through the attribute-value pairs.
Definition avpair.c:112
rc_handle * rc_new(void)
Initialises new Radius Client handle.
Definition config.c:1218
rc_nas_port_type
Definition radcli.h:382
const void * rc_aaa_ctx_get_vector(RC_AAA_CTX *ctx)
Returns a pointer request vector used in the request. It is of AUTH_VECTOR_LEN size.
Definition aaa_ctx.c:52
int rc_acct(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send)
Builds an accounting request for port id nas_port with the value_pairs at send.
Definition buildreq.c:342
rc_type
Definition radcli.h:74
int rc_auth_proxy(rc_handle *rh, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
Builds an authentication request for proxying.
Definition buildreq.c:325
rc_framed_comp
Definition radcli.h:317
int rc_auth(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
Builds an authentication request for port id nas_port with the value_pairs send and submits it to a s...
Definition buildreq.c:303
struct rc_aaa_ctx_st RC_AAA_CTX
Definition radcli.h:537
int rc_avpair_get_uint32(VALUE_PAIR *vp, uint32_t *res)
Get the integer value of the given attribute value-pair.
Definition avpair.c:1036
rc_termination_action
Definition radcli.h:338
void rc_buildreq(rc_handle const *rh, SEND_DATA *data, int code, char *server, unsigned short port, char *secret, int timeout, int retries)
Build a skeleton RADIUS request using information from the config file.
Definition buildreq.c:47
DICT_ATTR * rc_dict_addattr(rc_handle *rh, char const *namestr, uint32_t value, int type, uint32_t vendorspec)
Add attribute to dictionary.
Definition dict.c:38
int rc_avpair_get_in6(VALUE_PAIR *vp, struct in6_addr *res, unsigned *prefix)
Get the IPv6 address and prefix value of the given attribute value-pair.
Definition avpair.c:1057
void rc_avpair_get_attr(VALUE_PAIR *vp, unsigned *type, unsigned *id)
Get the attribute ID and type of the given attribute value-pair.
Definition avpair.c:1109
rc_vendor_pec
Definition radcli.h:401
VALUE_PAIR * rc_avpair_gen(rc_handle const *rh, VALUE_PAIR *pair, unsigned char const *ptr, int length, uint32_t vendorspec)
Decode a raw RADIUS attribute buffer into a VALUE_PAIR list.
Definition avpair.c:459
void rc_destroy(rc_handle *rh)
Destroys Radius Client handle reclaiming all memory.
Definition config.c:1249
DICT_VENDOR * rc_dict_findvend(rc_handle const *rh, char const *vendorname)
Lookup a DICT_VENDOR by its name.
Definition dict.c:671
rc_acct_auth_type
Definition radcli.h:393
int rc_acct_proxy(rc_handle *rh, VALUE_PAIR *send)
Builds an accounting request with the value_pairs at send.
Definition buildreq.c:355
const char * rc_aaa_ctx_get_secret(RC_AAA_CTX *ctx)
Returns the secret available in this context. It is the secret value used in the request.
Definition aaa_ctx.c:41
void rc_avpair_free(VALUE_PAIR *pair)
Frees all value_pairs in the list.
Definition avpair.c:584
int rc_read_dictionary_from_buffer(rc_handle *rh, char const *buf, size_t size)
Initialize the dictionary from Buffer.
Definition dict.c:579
int rc_aaa_ctx(rc_handle *rh, RC_AAA_CTX **ctx, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
Builds an authentication/accounting request and submits it to a server, optionally returning context.
Definition buildreq.c:166
VALUE_PAIR * rc_avpair_copy(VALUE_PAIR *p)
Return a copy of the existing list "p" ala strdup().
Definition avpair.c:497
int rc_avpair_tostr(rc_handle const *rh, VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
Translate an av_pair into printable strings.
Definition avpair.c:883
int rc_aaa(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
Builds an authentication/accounting request for port id nas_port with the value_pairs send and submit...
Definition buildreq.c:283
rc_send_status
Definition radcli.h:475
int rc_avpair_assign(VALUE_PAIR *vp, void const *pval, int len)
Assigns the given value to an attribute-value pair.
Definition avpair.c:135
DICT_VALUE * rc_dict_findval(rc_handle const *rh, char const *valname)
Lookup a DICT_VALUE by its name.
Definition dict.c:650
int rc_send_server(rc_handle *rh, SEND_DATA *data, char *msg, rc_type type)
Sends a request to a RADIUS server and waits for the reply.
Definition sendserver.c:231
int rc_acct_async(rc_handle *rh, uint32_t client_port, VALUE_PAIR *send)
Sends an accounting request to every configured accounting server without waiting for a reply.
Definition buildreq.c:443
int rc_avpair_parse(rc_handle const *rh, char const *buffer, VALUE_PAIR **first_pair)
Parses the buffer to extract the attribute-value pairs.
Definition avpair.c:650
rc_handle * rc_read_config(char const *filename)
Read the global config file.
Definition config.c:676
int rc_read_dictionary(rc_handle *rh, char const *filename)
Initialize the dictionary.
Definition dict.c:544
int rc_aaa_ctx_server(rc_handle *rh, RC_AAA_CTX **ctx, SERVER *aaaserver, rc_type type, uint32_t client_port, VALUE_PAIR *send, VALUE_PAIR **received, char *msg, int add_nas_port, rc_standard_codes request_type)
Builds an authentication/accounting request and submits it to a specific server.
Definition buildreq.c:205
int rc_conf_int(rc_handle const *rh, char const *optname)
Get the value of a config option as an integer.
Definition config.c:864
int rc_check(rc_handle *rh, char *host, char *secret, unsigned short port, char *msg)
Asks the server hostname on the specified port for a status message.
Definition buildreq.c:464
DICT_VENDOR * rc_dict_getvend(rc_handle const *rh, uint32_t vendorspec)
Lookup a DICT_VENDOR by its IANA number.
Definition dict.c:687
char * rc_conf_str(rc_handle const *rh, char const *optname)
Get the value of a config option.
Definition config.c:817
rc_standard_codes
Definition radcli.h:132
int rc_test_config(rc_handle *rh, char const *filename)
Tests the configuration the user supplied.
Definition config.c:895
DICT_ATTR * rc_dict_getattr(rc_handle const *rh, uint64_t attribute)
Lookup a DICT_ATTR by attribute number.
Definition dict.c:604
void rc_dict_free(rc_handle *rh)
Frees the allocated dictionary.
Definition dict.c:725
rc_service_type
Definition radcli.h:282
rc_framed_protocol
Definition radcli.h:296
rc_handle * rc_config_init(rc_handle *rh)
Initialise a configuration structure for programmatic configuration.
Definition config.c:404
void rc_config_free(rc_handle *rh)
Frees allocated config values.
Definition config.c:1187
rc_login_service_type
Definition radcli.h:326
DICT_VALUE * rc_dict_addval(rc_handle *rh, char const *attrstr, char const *namestr, uint32_t value)
Add value to dictionary.
Definition dict.c:81
int rc_find_server_addr(rc_handle const *rh, char const *server_name, struct addrinfo **info, char *secret, rc_type type)
Locate a server in the rh config or if not found, check for a servers file.
Definition config.c:1037
DICT_VENDOR * rc_dict_addvend(rc_handle *rh, char const *vendorname, uint32_t value)
Add vendor to dictionary.
Definition dict.c:122
SERVER * rc_conf_srv(rc_handle const *rh, char const *optname)
Get the value of a config option.
Definition config.c:875
VALUE_PAIR * rc_avpair_add(rc_handle const *rh, VALUE_PAIR **list, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
Adds an attribute-value pair to the given list.
Definition avpair.c:46
rc_framed_routing_type
Definition radcli.h:306
void rc_aaa_ctx_free(RC_AAA_CTX *ctx)
Deinitializes an RC_AAA_CTX structure.
Definition aaa_ctx.c:62
void rc_avpair_insert(VALUE_PAIR **a, VALUE_PAIR *p, VALUE_PAIR *b)
Insert a VALUE_PAIR into a list.
Definition avpair.c:532
rc_attr_id
Definition radcli.h:150
VALUE_PAIR * rc_avpair_get(VALUE_PAIR *vp, uint32_t attrid, uint32_t vendorspec)
Find the first attribute value-pair (which matches the given attribute) from the specified value-pair...
Definition avpair.c:480
rc_attr_type
Definition radcli.h:120
DICT_ATTR * rc_dict_findattr(rc_handle const *rh, char const *attrname)
Lookup a DICT_ATTR by its name.
Definition dict.c:627
int rc_add_config(rc_handle *rh, char const *option_name, char const *option_val, char const *source, int line)
Allow a config option to be added to rc_handle from inside a program.
Definition config.c:337
VALUE_PAIR * rc_avpair_new(rc_handle const *rh, uint32_t attrid, void const *pval, int len, uint32_t vendorspec)
Make a new attribute-value pair with given parameters.
Definition avpair.c:196
rc_socket_type
Definition radcli.h:105
int rc_apply_config(rc_handle *rh)
Apply configuration and initialise the transport.
Definition config.c:575
@ ACCT
Request for accounting server.
Definition radcli.h:76
@ AUTH
Request for authentication server.
Definition radcli.h:75
@ PW_NAS_PORT_ID_STRING
Its type is string.
Definition radcli.h:236
@ PW_ACCT_LINK_COUNT
Its type is integer.
Definition radcli.h:201
@ PW_ACCT_INPUT_GIGAWORDS
Its type is integer.
Definition radcli.h:202
@ PW_ORIGINATING_LINE_INFO
Its type is string.
Definition radcli.h:243
@ PW_USER_REALM
Its type is string.
Definition radcli.h:275
@ PW_TUNNEL_CLIENT_ENDPOINT
Its type is string.
Definition radcli.h:215
@ PW_FILTER_ID
Its type is string.
Definition radcli.h:161
@ PW_DIGEST_NONCE
Its type is string.
Definition radcli.h:263
@ PW_FRAMED_POOL
Its type is string.
Definition radcli.h:237
@ PW_NAS_IDENTIFIER
Its type is string.
Definition radcli.h:182
@ PW_ACCT_SESSION_TIME
Its type is integer.
Definition radcli.h:196
@ PW_NAS_PORT_TYPE
Its type is integer.
Definition radcli.h:210
@ PW_ARAP_FEATURES
Its type is string.
Definition radcli.h:220
@ PW_ACCT_INPUT_OCTETS
Its type is integer.
Definition radcli.h:192
@ PW_ACCT_TUNNEL_PACKETS_LOST
Its type is integer.
Definition radcli.h:235
@ PW_DIGEST_REALM
Its type is string.
Definition radcli.h:262
@ PW_TUNNEL_TYPE
Its type is string.
Definition radcli.h:213
@ PW_ACCT_STATUS_TYPE
Its type is integer.
Definition radcli.h:190
@ PW_USER_ID
Its type is string.
Definition radcli.h:274
@ PW_FRAMED_INTERFACE_ID
Its type is string.
Definition radcli.h:245
@ PW_TERMINATION_ACTION
Its type is integer.
Definition radcli.h:179
@ PW_ACCT_TUNNEL_CONNECTION
Its type is string.
Definition radcli.h:217
@ PW_DIGEST_USER_NAME
Its type is string.
Definition radcli.h:271
@ PW_CHAP_PASSWORD
Its type is string.
Definition radcli.h:153
@ PW_OLD_PASSWORD
Its type is string - deprecated.
Definition radcli.h:167
@ PW_FRAMED_APPLETALK_NETWORK
Its type is integer.
Definition radcli.h:188
@ PW_ACCT_INPUT_PACKETS
Its type is integer.
Definition radcli.h:197
@ PW_NAS_IP_ADDRESS
Its type is ipaddr.
Definition radcli.h:154
@ PW_FRAMED_ROUTING
Its type is integer.
Definition radcli.h:160
@ PW_ACCT_SESSION_ID
Its type is string.
Definition radcli.h:194
@ PW_FRAMED_IP_ADDRESS
Its type is ipaddr.
Definition radcli.h:158
@ PW_CONNECT_INFO
Its type is string.
Definition radcli.h:226
@ PW_PASSWORD_RETRY
Its type is integer.
Definition radcli.h:224
@ PW_PROXY_STATE
Its type is string.
Definition radcli.h:183
@ PW_TUNNEL_SERVER_ENDPOINT
Its type is string.
Definition radcli.h:216
@ PW_LOGIN_LAT_NODE
Its type is string.
Definition radcli.h:185
@ PW_ACCT_OUTPUT_PACKETS
Its type is integer.
Definition radcli.h:198
@ PW_EVENT_TIMESTAMP
Its type is integer.
Definition radcli.h:204
@ PW_TUNNEL_ASSIGNMENT_ID
Its type is string.
Definition radcli.h:231
@ PW_DIGEST_URI
Its type is string.
Definition radcli.h:265
@ PW_SESSION_TIMEOUT
Its type is integer.
Definition radcli.h:177
@ PW_DIGEST_QOP
Its type is string.
Definition radcli.h:266
@ PW_FRAMED_IPV6_ROUTE
Its type is string.
Definition radcli.h:248
@ PW_NAS_PORT
Its type is integer.
Definition radcli.h:155
@ PW_DIGEST_BODY_DIGEST
Its type is string.
Definition radcli.h:268
@ PW_ACCT_OUTPUT_GIGAWORDS
Its type is integer.
Definition radcli.h:203
@ PW_DNS_SERVER_IPV6_ADDRESS
Its type is ipaddr6.
Definition radcli.h:255
@ PW_FRAMED_COMPRESSION
Its type is integer.
Definition radcli.h:163
@ PW_EGRESS_VLANID
Its type is string.
Definition radcli.h:205
@ PW_FRAMED_IPV6_ADDRESS
Its type is ipaddr6.
Definition radcli.h:254
@ PW_SERVICE_TYPE
Its type is integer.
Definition radcli.h:156
@ PW_TUNNEL_PREFERENCE
Its type is string.
Definition radcli.h:232
@ PW_PORT_LIMIT
Its type is integer.
Definition radcli.h:211
@ PW_CUI
Its type is string.
Definition radcli.h:239
@ PW_LOGIN_LAT_SERVICE
Its type is string.
Definition radcli.h:184
@ PW_FRAMED_IPV6_POOL
Its type is string.
Definition radcli.h:249
@ PW_TUNNEL_CLIENT_AUTH_ID
Its type is string.
Definition radcli.h:240
@ PW_NAS_IPV6_ADDRESS
Its type is string.
Definition radcli.h:244
@ PW_CALLED_STATION_ID
Its type is string.
Definition radcli.h:180
@ PW_DIGEST_ATTRIBUTES
Its type is string.
Definition radcli.h:261
@ PW_FRAMED_APPLETALK_LINK
Its type is integer.
Definition radcli.h:187
@ PW_CALLING_STATION_ID
Its type is string.
Definition radcli.h:181
@ PW_LOGIN_CALLBACK_NUMBER
Its type is string.
Definition radcli.h:169
@ PW_EXPIRATION
Its type is date - deprecated.
Definition radcli.h:171
@ PW_ARAP_SECURITY
Its type is integer.
Definition radcli.h:222
@ PW_USER_PRIORITY_TABLE
Its type is string.
Definition radcli.h:208
@ PW_PROMPT
Its type is integer.
Definition radcli.h:225
@ PW_FRAMED_IPV6_PREFIX
Its type is string.
Definition radcli.h:246
@ PW_TUNNEL_MEDIUM_TYPE
Its type is integer.
Definition radcli.h:214
@ PW_DIGEST_NONCE_COUNT
Its type is string.
Definition radcli.h:270
@ PW_EAP_MESSAGE
Its type is string.
Definition radcli.h:228
@ PW_FRAMED_IP_NETMASK
Its type is ipaddr.
Definition radcli.h:159
@ PW_LOGIN_PORT
Its type is integer.
Definition radcli.h:166
@ PW_FRAMED_IPX_NETWORK
Its type is integer.
Definition radcli.h:173
@ PW_DIGEST_ALGORITHM
Its type is string.
Definition radcli.h:267
@ PW_ACCT_TERMINATE_CAUSE
Its type is integer.
Definition radcli.h:199
@ PW_LOGIN_LAT_GROUP
Its type is string.
Definition radcli.h:186
@ PW_TUNNEL_PASSWORD
Its type is string.
Definition radcli.h:218
@ PW_LOGIN_IPV6_HOST
Its type is string.
Definition radcli.h:247
@ PW_ROUTE_IPV6_INFORMATION
Its type is ipv6prefix.
Definition radcli.h:256
@ PW_EAP_KEY_NAME
Its type is string.
Definition radcli.h:251
@ PW_DIGEST_RESPONSE
Its type is string.
Definition radcli.h:260
@ PW_FRAMED_MTU
Its type is integer.
Definition radcli.h:162
@ PW_LOGIN_LAT_PORT
Its type is string.
Definition radcli.h:212
@ PW_ACCT_MULTI_SESSION_ID
Its type is string.
Definition radcli.h:200
@ PW_ACCT_OUTPUT_OCTETS
Its type is integer.
Definition radcli.h:193
@ PW_FRAMED_APPLETALK_ZONE
Its type is string.
Definition radcli.h:189
@ PW_DIGEST_CNONCE
Its type is string.
Definition radcli.h:269
@ PW_TUNNEL_SERVER_AUTH_ID
Its type is string.
Definition radcli.h:241
@ PW_ARAP_SECURITY_DATA
Its type is string.
Definition radcli.h:223
@ PW_LOGIN_SERVICE
Its type is integer.
Definition radcli.h:165
@ PW_DIGEST_METHOD
Its type is string.
Definition radcli.h:264
@ PW_TUNNEL_PRIVATE_GROUP_ID
Its type is string.
Definition radcli.h:230
@ PW_LOGIN_IP_HOST
Its type is ipaddr.
Definition radcli.h:164
@ PW_ACCT_DELAY_TIME
Its type is integer.
Definition radcli.h:191
@ PW_STATE
Its type is string.
Definition radcli.h:174
@ PW_EGRESS_VLAN_NAME
Its type is string.
Definition radcli.h:207
@ PW_ERROR_CAUSE
Its type is integer.
Definition radcli.h:250
@ PW_USER_NAME
Its type is string.
Definition radcli.h:151
@ PW_MESSAGE_AUTHENTICATOR
Its type is string.
Definition radcli.h:229
@ PW_DELEGATED_IPV6_PREFIX
Its type is ipv6prefix.
Definition radcli.h:252
@ PW_REPLY_MESSAGE
Its type is string.
Definition radcli.h:168
@ PW_VENDOR_SPECIFIC
Its type is string.
Definition radcli.h:176
@ PW_CHAP_CHALLENGE
Its type is string.
Definition radcli.h:209
@ PW_ACCT_AUTHENTIC
Its type is integer.
Definition radcli.h:195
@ PW_USER_PASSWORD
Its type is string.
Definition radcli.h:152
@ PW_INGRESS_FILTERS
Its type is integer.
Definition radcli.h:206
@ PW_CHARGEABLE_USER_IDENTITY
Its type is string.
Definition radcli.h:238
@ PW_FRAMED_PROTOCOL
Its type is integer.
Definition radcli.h:157
@ PW_ARAP_ZONE_ACCESS
Its type is integer.
Definition radcli.h:221
@ PW_FRAMED_CALLBACK_ID
Its type is string.
Definition radcli.h:170
@ PW_ARAP_CHALLENGE_RESPONSE
Its type is string.
Definition radcli.h:233
@ PW_NAS_FILTER_RULE
Its type is string.
Definition radcli.h:242
@ PW_IDLE_TIMEOUT
Its type is integer.
Definition radcli.h:178
@ PW_ARAP_PASSWORD
Its type is string.
Definition radcli.h:219
@ PW_FRAMED_ROUTE
Its type is string.
Definition radcli.h:172
@ PW_ACCT_INTERIM_INTERVAL
Its type is integer.
Definition radcli.h:234
@ PW_CONFIGURATION_TOKEN
Its type is string.
Definition radcli.h:227
@ PW_CLASS
Its type is string.
Definition radcli.h:175
@ PW_TYPE_IPADDR
The attribute is an IPv4 address in host-byte order.
Definition radcli.h:123
@ PW_TYPE_IPV6ADDR
The attribute is an 128-bit IPv6 address.
Definition radcli.h:125
@ PW_TYPE_MAX
Maximum number of types (last+1)
Definition radcli.h:127
@ PW_TYPE_IPV6PREFIX
The attribute is an IPv6 prefix; the lvalue will indicate its size.
Definition radcli.h:126
@ PW_TYPE_INTEGER
The attribute is a 32-bit integer.
Definition radcli.h:122
@ PW_TYPE_DATE
The attribute contains a 32-bit number indicating the seconds since epoch.
Definition radcli.h:124
@ PW_TYPE_STRING
The attribute is a printable string.
Definition radcli.h:121
@ RC_SOCKET_UDP
Plain UDP socket.
Definition radcli.h:106
@ RC_SOCKET_TCP
Plain TCP socket.
Definition radcli.h:109
@ RC_SOCKET_DTLS
DTLS socket.
Definition radcli.h:108
@ RC_SOCKET_TLS
TLS socket.
Definition radcli.h:107
int rc_tls_fd(rc_handle *rh)
Returns the file descriptor of the TLS/DTLS session.
Definition tls.c:564
int rc_check_tls(rc_handle *rh)
Check established TLS/DTLS channels for operation and reconnect if needed.
Definition tls.c:597
char * rc_mksid(void) _RADCLI_GCC_ATTR_DEPRECATED
Generate a "unique" session-ID string.
Definition util.c:107
rc_attr_type type
string, int, etc..
Definition radcli.h:445
uint64_t value
attribute index and vendor number; use VENDOR() and ATTRID() to separate.
Definition radcli.h:444
char name[RC_NAME_LENGTH+1]
attribute name.
Definition radcli.h:443
rc_attr_type type
attribute type.
Definition radcli.h:500
char pad[32]
unused pad
Definition radcli.h:504
uint64_t attribute
attribute numeric value of type rc_attr_id including vendor; use VENDOR() and ATTRID() to separate.
Definition radcli.h:499
uint32_t lvalue
attribute value if type is PW_TYPE_INTEGER, PW_TYPE_DATE or PW_TYPE_IPADDR.
Definition radcli.h:501
char strvalue[AUTH_STRING_LEN+1]
contains attribute value in other cases.
Definition radcli.h:502
char name[RC_NAME_LENGTH+1]
attribute name if known.
Definition radcli.h:498
int timeout
Session timeout in seconds.
Definition radcli.h:519
char * secret
Shared secret of RADIUS server.
Definition radcli.h:518
uint8_t seq_nbr
Packet sequence number.
Definition radcli.h:515
int svc_port
RADIUS protocol destination port.
Definition radcli.h:517
char * server
Name/address of RADIUS server.
Definition radcli.h:516
VALUE_PAIR * send_pairs
More a/v pairs to send.
Definition radcli.h:521
VALUE_PAIR * receive_pairs
Where to place received a/v pairs.
Definition radcli.h:522
uint8_t code
RADIUS packet code.
Definition radcli.h:514
double deadtime_ends[RC_SERVER_MAX]
unused
Definition radcli.h:100