28RCSID(
"$Id: 8be4f61b752a38f44c59b428a66fe8945ed65347 $")
30#include <freeradius-devel/util/conf.h>
31#include <freeradius-devel/util/syserror.h>
32#include <freeradius-devel/util/atexit.h>
33#include <freeradius-devel/util/pair_legacy.h>
34#include <freeradius-devel/util/time.h>
35#include <freeradius-devel/util/event.h>
36#include <freeradius-devel/server/packet.h>
37#include <freeradius-devel/radius/list.h>
38#include <freeradius-devel/radius/radius.h>
39#include <freeradius-devel/util/chap.h>
40#include <freeradius-devel/radius/client.h>
42#ifdef HAVE_OPENSSL_SSL_H
43#include <openssl/ssl.h>
60#define pair_update_request(_attr, _da) do { \
61 _attr = fr_pair_find_by_da(&request->request_pairs, NULL, _da); \
63 _attr = fr_pair_afrom_da(request, _da); \
64 fr_assert(_attr != NULL); \
65 fr_pair_append(&request->request_pairs, _attr); \
160 fprintf(stderr,
"Usage: radclient [options] server[:port] <command> [<secret>]\n");
162 fprintf(stderr,
" <command> One of auth, acct, status, coa, disconnect or auto.\n");
163 fprintf(stderr,
" -4 Use IPv4 address of server\n");
164 fprintf(stderr,
" -6 Use IPv6 address of server.\n");
165 fprintf(stderr,
" -A <attribute> Use named 'attribute' to match CoA requests to packets. Default is User-Name\n");
166 fprintf(stderr,
" -C [<client_ip>:]<client_port> Client source port and source IP address. Port values may be 1..65535\n");
167 fprintf(stderr,
" -c <count> Send each packet 'count' times.\n");
168 fprintf(stderr,
" -d <raddb> Set user dictionary directory (defaults to " RADDBDIR
").\n");
169 fprintf(stderr,
" -D <dictdir> Set main dictionary directory (defaults to " DICTDIR
").\n");
170 fprintf(stderr,
" -f <file>[:<file>] Read packets from file, not stdin.\n");
171 fprintf(stderr,
" If a second file is provided, it will be used to verify responses\n");
172 fprintf(stderr,
" -F Print the file name, packet number and reply code.\n");
173 fprintf(stderr,
" -h Print usage help information.\n");
174 fprintf(stderr,
" -i <id> Set request id to 'id'. Values may be 0..255\n");
175 fprintf(stderr,
" -o <port> Set CoA listening port (defaults to 3799)\n");
176 fprintf(stderr,
" -p <num> Send 'num' packets from a file in parallel.\n");
177 fprintf(stderr,
" -P <proto> Use proto (tcp or udp) for transport.\n");
178 fprintf(stderr,
" -r <retries> If timeout, retry sending the packet 'retries' times.\n");
179 fprintf(stderr,
" -s Print out summary information of auth results.\n");
180 fprintf(stderr,
" -S <file> read secret from file, not command line.\n");
181 fprintf(stderr,
" -t <timeout> Wait 'timeout' seconds before retrying (may be a floating point number).\n");
182 fprintf(stderr,
" -v Show program version information.\n");
183 fprintf(stderr,
" -x Debugging mode.\n");
208#ifdef HAVE_OPENSSL_SSL_H
209#include <openssl/provider.h>
211static OSSL_PROVIDER *openssl_default_provider = NULL;
212static OSSL_PROVIDER *openssl_legacy_provider = NULL;
219 openssl_default_provider = OSSL_PROVIDER_load(NULL,
"default");
220 if (!openssl_default_provider) {
221 ERROR(
"(TLS) Failed loading default provider");
230 openssl_legacy_provider = OSSL_PROVIDER_load(NULL,
"legacy");
231 if (!openssl_legacy_provider) {
232 ERROR(
"(TLS) Failed loading legacy provider");
241 if (openssl_default_provider && !OSSL_PROVIDER_unload(openssl_default_provider)) {
242 ERROR(
"Failed unloading default provider");
244 openssl_default_provider = NULL;
246 if (openssl_legacy_provider && !OSSL_PROVIDER_unload(openssl_legacy_provider)) {
247 ERROR(
"Failed unloading legacy provider");
249 openssl_legacy_provider = NULL;
252#define openssl3_init()
253#define openssl3_free()
268 char const *password)
285 for (i = 0; i < challenge->vp_length; i++) {
307 svp = getservbyname(
name,
"udp");
310 return ntohs(svp->s_port);
323 if (*port == 0) *port =
getport(
"radius");
328 if (*port == 0) *port =
getport(
"radacct");
341 if (*port == 0) *port = 0;
383 for (i = 0; i <
vp->vp_length; i++) {
384 if (
vp->vp_octets[i] < 32) {
395static int coa_init(
rc_request_t *
parent, FILE *coa_reply,
char const *reply_filename,
bool *coa_reply_done, FILE *coa_filter,
char const *filter_filename,
bool *coa_filter_done)
417 &request->
reply_pairs, coa_reply, coa_reply_done) < 0) {
418 REDEBUG(
"Error parsing \"%s\"", reply_filename);
435 &request->
filter, coa_filter, coa_filter_done) < 0) {
436 REDEBUG(
"Error parsing \"%s\"", filter_filename);
440 if (*coa_filter_done && !*coa_reply_done) {
441 REDEBUG(
"Differing number of replies/filters in %s:%s "
442 "(too many replies))", reply_filename, filter_filename);
446 if (!*coa_filter_done && *coa_reply_done) {
447 REDEBUG(
"Differing number of replies/filters in %s:%s "
448 "(too many filters))", reply_filename, filter_filename);
475 ERROR(
"Failed inserting packet from %s into CoA tree", request->
name);
488 FILE *packets, *filters = NULL;
492 bool packets_done =
false;
495 FILE *coa_reply = NULL;
496 FILE *coa_filter = NULL;
497 bool coa_reply_done =
false;
498 bool coa_filter_done =
false;
505 if (strcmp(files->
packets,
"-") != 0) {
506 packets = fopen(files->
packets,
"r");
516 filters = fopen(files->
filters,
"r");
524 coa_reply = fopen(files->
coa_reply,
"r");
546 char const *coa_reply_filename = NULL;
547 char const *coa_filter_filename = NULL;
560 request->
files = files;
562 request->
num = num++;
581 REDEBUG(
"Error parsing \"%s\"", input);
589 WARN(
"Skipping \"%s\": No Attributes", files->
packets);
601 &request->
filter, filters, &filters_done) < 0) {
606 if (filters_done && !packets_done) {
607 REDEBUG(
"Differing number of packets/filters in %s:%s "
612 if (!filters_done && packets_done) {
613 REDEBUG(
"Differing number of packets/filters in %s:%s "
671 request->
name =
vp->vp_strvalue;
674 coa_reply_filename =
vp->vp_strvalue;
677 coa_filter_filename =
vp->vp_strvalue;
724 REDEBUG(
"Packet-Type must be defined,"
725 "or a well known RADIUS port");
729 REDEBUG(
"Can't determine expected &reply.Packet-Type for Packet-Type %i",
759 REDEBUG(
"Can't determine expected Packet-Type for &reply.Packet-Type %i",
770 REDEBUG(
"Can't determine destination port");
796 if (coa_reply_filename) {
798 RDEBUG(
"Cannot specify CoA file on both the command line and via Radclient-CoA-Filename");
802 coa_reply = fopen(coa_reply_filename,
"r");
808 if (coa_filter_filename) {
809 coa_filter = fopen(coa_filter_filename,
"r");
818 if (
coa_init(request, coa_reply, coa_reply_filename, &coa_reply_done,
819 coa_filter, coa_filter_filename, &coa_filter_done) < 0) {
831 }
else if (coa_reply) {
832 if (
coa_init(request, coa_reply, coa_reply_filename, &coa_reply_done,
833 coa_filter, coa_filter_filename, &coa_filter_done) < 0) {
837 if (coa_reply_done != packets_done) {
838 REDEBUG(
"Differing number of packets in input file and coa_reply in %s:%s ",
857 }
while (!packets_done);
859 if (packets != stdin) fclose(packets);
860 if (filters) fclose(filters);
861 if (coa_reply) fclose(coa_reply);
862 if (coa_filter) fclose(coa_filter);
872 if (packets != stdin) fclose(packets);
873 if (filters) fclose(filters);
874 if (coa_reply) fclose(coa_reply);
875 if (coa_filter) fclose(coa_filter);
896 ERROR(
"No server was given, and request %" PRIu64
" in file %s did not contain "
905 ERROR(
"Request was \"auto\", and request %" PRIu64
" in file %s did not contain Packet-Type",
964 DEBUG(
"Timeout - resending packet");
975 ERROR(
"No reply to packet");
991#ifdef STATIC_ANALYZER
1019 vector = challenge->vp_octets;
1034 DEBUG(
"WARNING: No password in the request");
1103 ERROR(
"Failed connecting to server");
1116 int fd_errno,
void *uctx)
1126 TALLOC_FREE(client);
1164 switch (reply->
code) {
1204 RDEBUG(
"%s: Response passed filter", request->
name);
1208 REDEBUG(
"%s: Response for failed filter", request->
name);
1228 if (!request->
done) {
1310 int ret = EXIT_SUCCESS;
1312 char const *raddb_dir = RADDBDIR;
1313 char const *dict_dir = DICTDIR;
1315 char filesecret[256];
1317 int do_summary =
false;
1346#ifdef STATIC_ANALYZER
1353 talloc_set_log_stderr();
1371 .socket_type = SOCK_DGRAM,
1397 .require_message_authenticator =
false,
1399 .max_packet_size = 4096,
1409 while ((c = getopt(argc, argv,
"46A:c:C:d:D:f:Fi:ho:p:P:r:sS:t:vx")) != -1)
switch (c) {
1434 if (strchr(optarg,
':')) {
1436 optarg, -1, AF_UNSPEC,
true,
false) < 0) {
1437 fr_perror(
"Failed parsing source address");
1444 if (tmp < 1 || tmp > 65535)
usage();
1473 p = strchr(optarg, c);
1476 p = strchr(optarg, c);
1482 MEM(files->
packets = talloc_strndup(files, optarg, p - optarg));
1494 if (!isdigit((
uint8_t) *optarg))
1515 parallel = strtoul(optarg, &end, 10);
1521 if (!strcmp(optarg,
"tcp")) {
1524 }
else if (!strcmp(optarg,
"udp")) {
1545 fp = fopen(optarg,
"r");
1550 if (fgets(filesecret,
sizeof(filesecret), fp) == NULL) {
1557 p = filesecret + strlen(filesecret) - 1;
1558 while ((p >= filesecret) &&
1564 if (strlen(filesecret) < 2) {
1565 ERROR(
"Secret in %s is too short", optarg);
1576 fr_perror(
"Failed parsing timeout value");
1595 argc -= (optind - 1);
1596 argv += (optind - 1);
1598 if ((argc < 3) || ((
secret == NULL) && (argc < 4))) {
1599 ERROR(
"Insufficient arguments");
1606 if (!isdigit((
uint8_t) argv[2][0])) {
1609 ERROR(
"Unrecognised request type \"%s\"", argv[2]);
1636 if (strcmp(argv[1],
"-") != 0) {
1691 "Failed to initialize the dictionaries");
1698 ERROR(
"Unknown or invalid CoA filter attribute %s", optarg);
1741 ERROR(
"Failed parsing input files");
1750 ERROR(
"Nothing to send");
1784#ifdef STATIC_ANALYZER
1860 "\tAccepted : %" PRIu64
"\n"
1861 "\tRejected : %" PRIu64
"\n"
1862 "\tLost : %" PRIu64
"\n"
1863 "\tPassed filter : %" PRIu64
"\n"
1864 "\tFailed filter : %" PRIu64,
static int const char char buffer[256]
int fr_atexit_global_setup(void)
Setup the atexit handler, should be called at the start of a program's execution.
int fr_atexit_global_trigger_all(void)
Cause all global free triggers to fire.
static int fr_bio_packet_read(fr_bio_packet_t *my, void **pctx_p, fr_packet_t **packet_p, TALLOC_CTX *out_ctx, fr_pair_list_t *out)
Read a packet from a packet BIO.
fr_bio_packet_callback_t connected
static int fr_bio_packet_write(fr_bio_packet_t *my, void *pctx, fr_packet_t *packet, fr_pair_list_t *list)
Write a packet to a packet BIO.
fr_event_list_t * el
event list
fr_retry_config_t retry_config
base retry config
fr_event_list_t * el
event list
#define NEVER_RETURNS
Should be placed before the function return type.
void fr_chap_encode(uint8_t out[static 1+FR_CHAP_CHALLENGE_LENGTH], uint8_t id, uint8_t const *challenge, size_t challenge_len, char const *password, size_t password_len)
Encode a CHAP password.
int fr_fault_setup(TALLOC_CTX *ctx, char const *cmd, char const *program)
Registers signal handlers to execute panic_action on fatal signal.
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
fr_radius_packet_code_t
RADIUS packet codes.
@ FR_RADIUS_CODE_ACCESS_CHALLENGE
RFC2865 - Access-Challenge.
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
@ FR_RADIUS_CODE_DISCONNECT_REQUEST
RFC3575/RFC5176 - Disconnect-Request.
@ FR_RADIUS_CODE_MAX
Maximum possible protocol code.
@ FR_RADIUS_CODE_DISCONNECT_ACK
RFC3575/RFC5176 - Disconnect-Ack (positive)
@ FR_RADIUS_CODE_STATUS_SERVER
RFC2865/RFC5997 - Status Server (request)
@ FR_RADIUS_CODE_COA_REQUEST
RFC3575/RFC5176 - CoA-Request.
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
@ FR_RADIUS_CODE_ACCOUNTING_RESPONSE
RFC2866 - Accounting-Response.
@ FR_RADIUS_CODE_COA_NAK
RFC3575/RFC5176 - CoA-Nak (not willing to perform)
@ FR_RADIUS_CODE_UNDEFINED
Packet code has not been set.
@ FR_RADIUS_CODE_COA_ACK
RFC3575/RFC5176 - CoA-Ack (positive)
@ FR_RADIUS_CODE_DISCONNECT_NAK
RFC3575/RFC5176 - Disconnect-Nak (not willing to perform)
@ FR_RADIUS_CODE_ACCOUNTING_REQUEST
RFC2866 - Accounting-Request.
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
#define FR_ACCT_UDP_PORT_ALT
#define FR_AUTH_UDP_PORT_ALT
fr_dict_gctx_t * fr_dict_global_ctx_init(TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir)
Initialise the global protocol hashes.
fr_dict_t * fr_dict_unconst(fr_dict_t const *dict)
Coerce to non-const.
#define fr_dict_autofree(_to_free)
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
Locate a fr_dict_attr_t by its name.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
Process a dict_attr_autoload element to load/verify a dictionary attribute.
#define fr_dict_autoload(_to_load)
int fr_dict_read(fr_dict_t *dict, char const *dict_dir, char const *filename)
Read supplementary attribute definitions into an existing dictionary.
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
static void * fr_dlist_head(fr_dlist_head_t const *list_head)
Return the HEAD item of a list or NULL if the list is empty.
#define fr_dlist_foreach(_list_head, _type, _iter)
Iterate over the contents of a list.
static void * fr_dlist_remove(fr_dlist_head_t *list_head, void *ptr)
Remove an item from the list.
static void fr_dlist_talloc_free(fr_dlist_head_t *head)
Free all items in a doubly linked list (with talloc)
static void * fr_dlist_prev(fr_dlist_head_t const *list_head, void const *ptr)
Get the previous item in a list.
static unsigned int fr_dlist_num_elements(fr_dlist_head_t const *head)
Return the number of elements in the dlist.
static int fr_dlist_insert_tail(fr_dlist_head_t *list_head, void *ptr)
Insert an item into the tail of a list.
#define fr_dlist_talloc_init(_head, _type, _field)
Initialise the head structure of a doubly linked list.
static void * fr_dlist_next(fr_dlist_head_t const *list_head, void const *ptr)
Get the next item in a list.
Head of a doubly linked list.
#define fr_event_fd_insert(...)
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
#define fr_event_filter_update(...)
#define FR_EVENT_RESUME(_s, _f)
Re-add the filter for a func from kevent.
#define FR_EVENT_SUSPEND(_s, _f)
Temporarily remove the filter for a func from kevent.
Callbacks for the FR_EVENT_FILTER_IO filter.
Structure describing a modification to a filter's state.
fr_socket_t socket
as connected socket
uint16_t src_port
our port
@ FR_BIO_FD_CONNECTED
connected client sockets (UDP or TCP)
fr_ipaddr_t dst_ipaddr
their IP address
fr_bio_fd_type_t type
accept, connected, unconnected, etc.
int socket_type
SOCK_STREAM or SOCK_DGRAM.
uint16_t dst_port
their port
fr_ipaddr_t src_ipaddr
our IP address
Configuration for sockets.
int fr_inet_pton_port(fr_ipaddr_t *out, uint16_t *port_out, char const *value, ssize_t inlen, int af, bool resolve, bool mask)
Parses IPv4/6 address + port, to fr_ipaddr_t and integer (port)
char const * fr_bio_strerror(ssize_t error)
int packet_global_init(void)
Initialises the Net.
void fr_packet_net_from_pairs(fr_packet_t *packet, fr_pair_list_t const *list)
Convert pairs to information in a packet.
fr_event_list_t * fr_event_list_alloc(TALLOC_CTX *ctx, fr_event_status_cb_t status, void *status_uctx)
Initialise a new event list.
void fr_event_loop_exit(fr_event_list_t *el, int code)
Signal an event loop exit with the specified code.
int fr_event_fd_delete(fr_event_list_t *el, int fd, fr_event_filter_t filter)
Remove a file descriptor from the event loop.
int fr_event_loop(fr_event_list_t *el)
Run an event loop.
Stores all information relating to an event list.
void fr_log_perror(fr_log_t const *log, fr_log_type_t type, char const *file, int line, fr_log_perror_format_t const *rules, char const *fmt,...)
Drain any outstanding messages from the fr_strerror buffers.
void fr_log(fr_log_t const *log, fr_log_type_t type, char const *file, int line, char const *fmt,...)
Send a server log message to its destination.
@ L_DST_STDOUT
Log to stdout.
@ L_DBG
Only displayed when debugging is enabled.
fr_packet_t * fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new fr_packet_t.
void fr_packet_free(fr_packet_t **packet_p)
Free a fr_packet_t.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
int mschap_nt_password_hash(uint8_t out[static NT_DIGEST_LENGTH], char const *password)
Converts Unicode password to 16-byte NT hash with MD4.
#define RADIUS_AUTH_VECTOR_LENGTH
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
void fr_pair_validate_debug(fr_pair_t const *failed[2])
Write an error to the library errorbuff detailing the mismatch.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
int fr_pair_delete_by_da(fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete matching pairs from the specified list.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
bool fr_pair_validate(fr_pair_t const *failed[2], fr_pair_list_t *filter, fr_pair_list_t *list)
Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
int fr_pair_value_bstrndup(fr_pair_t *vp, char const *src, size_t len, bool tainted)
Copy data into a "string" type value pair.
int fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list and free.
int8_t fr_pair_cmp_by_da(void const *a, void const *b)
Order attributes by their da, and tag.
int fr_pair_value_memdup_buffer_shallow(fr_pair_t *vp, uint8_t const *src, bool tainted)
Assign a talloced buffer to a "octets" type value pair.
int fr_pair_list_afrom_file(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *out, FILE *fp, bool *pfiledone)
Read valuepairs from the fp up to End-Of-File.
int fr_radius_global_init(void)
void fr_radius_global_free(void)
fr_table_num_sorted_t const fr_radius_request_name_table[]
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
int fr_radius_allow_reply(int code, bool allowed[static FR_RADIUS_CODE_MAX])
bool allowed[FR_RADIUS_CODE_MAX]
allowed outgoing packet types
fr_radius_bio_verify_t verify
fr_bio_retry_info_t const * retry_info
fr_bio_retry_config_t retry_cfg
fr_retry_config_t retry[FR_RADIUS_CODE_MAX]
default retry configuration for each packet type
fr_bio_fd_info_t const * fd_info
fr_bio_packet_cb_funcs_t packet_cb_cfg
bool outgoing[FR_RADIUS_CODE_MAX]
allowed outgoing packet types
void fr_radius_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
static fr_rb_tree_t * coa_tree
static fr_dict_attr_t const * attr_packet_type
static fr_dict_attr_t const * attr_request_authenticator
static int send_one_packet(fr_bio_packet_t *client, rc_request_t *request)
static fr_dict_attr_t const * attr_user_password
static int getport(char const *name)
static void client_packet_release(fr_bio_packet_t *client, fr_packet_t *packet)
static char const * radclient_version
static int _rc_request_free(rc_request_t *request)
fr_dict_autoload_t radclient_dict[]
static void client_read(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
static int radclient_sane(rc_request_t *request)
static TALLOC_CTX * autofree
static fr_bio_fd_config_t fd_config
static fr_bio_packet_t * client_bio
int main(int argc, char **argv)
static fr_dict_t const * dict_freeradius
static fr_dict_attr_t const * attr_chap_password
static fr_radius_client_config_t client_config
static fr_radius_client_bio_info_t const * client_info
static int client_bio_write_pause(fr_bio_packet_t *bio)
static fr_dict_attr_t const * attr_ms_chap_response
static fr_event_update_t const resume_write[]
static fr_dict_t const * dict_radius
static fr_dict_attr_t const * attr_ms_chap_challenge
static NEVER_RETURNS void client_bio_failed(fr_bio_packet_t *bio)
static fr_dict_attr_t const * attr_chap_challenge
static void client_bio_connected(fr_bio_packet_t *client)
static int _loop_status(UNUSED fr_time_t now, fr_time_delta_t wake, UNUSED void *ctx)
fr_dict_attr_autoload_t radclient_dict_attr[]
static fr_dict_attr_t const * attr_cleartext_password
static int client_bio_write_resume(fr_bio_packet_t *bio)
static bool print_filename
static fr_dict_attr_t const * attr_radclient_test_name
static rc_request_t * current
static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files)
static void client_packet_retry_log(UNUSED fr_bio_packet_t *client, fr_packet_t *packet)
static fr_dict_attr_t const * attr_radclient_coa_filename
static NEVER_RETURNS void client_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx)
static int mschapv1_encode(fr_packet_t *packet, fr_pair_list_t *list, char const *password)
static bool already_hex(fr_pair_t *vp)
static fr_dict_attr_t const * attr_user_name
static void client_write(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
static fr_dlist_head_t rc_request_list
static fr_dict_attr_t const * attr_coa_filter
static void radclient_get_port(fr_radius_packet_code_t type, uint16_t *port)
static fr_dict_attr_t const * attr_ms_chap_password
#define pair_update_request(_attr, _da)
static int8_t request_cmp(void const *one, void const *two)
static const char * attr_coa_filter_name
static fr_dict_attr_t const * attr_radclient_coa_filter
static fr_event_update_t const pause_write[]
static NEVER_RETURNS void usage(void)
static fr_radius_packet_code_t radclient_get_code(uint16_t port)
static int coa_init(rc_request_t *parent, FILE *coa_reply, char const *reply_filename, bool *coa_reply_done, FILE *coa_filter, char const *filter_filename, bool *coa_filter_done)
Structures for the radclient utility.
uint64_t num
The number (within the file) of the request were reading.
fr_pair_t * password
Password.Cleartext.
uint64_t accepted
Requests to which we received a accept.
fr_packet_t * reply
The incoming response.
fr_pair_list_t request_pairs
char const * coa_reply
file containing the CoA filter we want to match
uint64_t rejected
Requests to which we received a reject.
fr_rb_node_t node
rbtree node data for CoA
char const * packets
The file containing the request packet.
uint64_t lost
Requests to which we received no response.
bool done
Whether the request is complete.
char const * coa_filter
file containing the CoA filter we want to match
fr_pair_list_t filter
If the reply passes the filter, then the request passes.
uint64_t failed
Requests which failed a filter.
fr_pair_list_t reply_pairs
uint64_t passed
Requests which passed a filter.
fr_radius_packet_code_t filter_code
Expected code of the response packet.
char const * name
Test name (as specified in the request).
char const * filters
The file containing the definition of the packet we want to match.
fr_packet_t * packet
The outgoing request.
rc_file_pair_t * files
Request and response file names.
#define RADIUS_MAX_ATTRIBUTES
#define FR_RADIUS_PACKET_CODE_VALID(_x)
uint32_t fr_rand(void)
Return a 32-bit random number.
void fr_rand_buffer(void *start, size_t length)
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
Insert data into a tree.
bool fr_rb_delete(fr_rb_tree_t *tree, void const *data)
Remove node and free data (if a free function was specified)
#define fr_rb_talloc_alloc(_ctx, _type, _data_cmp, _data_free)
Allocs a red black that verifies elements are of a specific talloc type.
The main red black tree structure.
fr_packet_t * reply
Outgoing response.
char const *fr_packet_t * packet
< Module the request is currently being processed by.
#define reply_pairs
Convenience macro for accessing the reply list.
void smbdes_mschap(uint8_t const win_password[16], uint8_t const *challenge, uint8_t *response)
void fr_radius_client_bio_connect(NDEBUG_UNUSED fr_event_list_t *el, NDEBUG_UNUSED int fd, UNUSED int flags, void *uctx)
int fr_radius_client_fd_bio_cancel(fr_bio_packet_t *bio, fr_packet_t *packet)
Cancel one packet.
fr_bio_packet_t * fr_radius_client_bio_alloc(TALLOC_CTX *ctx, fr_radius_client_config_t *cfg, fr_bio_fd_config_t const *fd_cfg)
int fr_radius_client_bio_force_id(fr_bio_packet_t *bio, int code, int id)
size_t fr_radius_client_bio_outstanding(fr_bio_packet_t *bio)
fr_radius_client_bio_info_t const * fr_radius_client_bio_info(fr_bio_packet_t *bio)
fr_aka_sim_id_type_t type
#define fr_time()
Allow us to arbitrarily manipulate time.
fr_log_dst_t dst
Log destination.
int fd
File descriptor to write messages to.
bool print_level
sometimes we don't want log levels printed
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
fr_slen_t fr_time_delta_from_str(fr_time_delta_t *out, char const *in, size_t inlen, fr_time_res_t hint)
Create fr_time_delta_t from a string.
int fr_time_start(void)
Initialize the local time.
static int64_t fr_time_delta_unwrap(fr_time_delta_t time)
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
A time delta, a difference in time measured in nanoseconds.
static fr_event_list_t * el
#define FR_DICTIONARY_FILE
unsigned int code
Packet code (type).
fr_socket_t socket
This packet was received on.
int id
Packet ID (used to link requests/responses).
uint8_t * data
Packet data (body).
uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH]
RADIUS authentication vector.
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
void fr_pair_list_sort(fr_pair_list_t *list, fr_cmp_t cmp)
Sort a doubly linked list of fr_pair_ts using merge sort.
fr_pair_t * fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item))
Get the next item in a valuepair list after a specific entry.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
fr_time_delta_t irt
Initial transmission time.
int af
AF_INET, AF_INET6, or AF_UNIX.
int fd
File descriptor if this is a live socket.
char const * fr_strerror(void)
Get the last library error.
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
void fr_strerror_clear(void)
Clears all pending messages from the talloc pools.
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
#define RADIUSD_VERSION_BUILD(_x)
Create a version string for a utility in the suite of FreeRADIUS utilities.
#define RADIUSD_MAGIC_NUMBER
int8_t fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b)
Compare two values.
#define fr_box_time_delta(_val)