28 RCSID(
"$Id: 0c8f2cf2fc5e8e5912727bebdf5a15d34b17759c $")
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/server/packet.h>
36 #include <freeradius-devel/radius/list.h>
37 #include <freeradius-devel/radius/radius.h>
38 #include <freeradius-devel/util/chap.h>
39 #ifdef HAVE_OPENSSL_SSL_H
40 #include <openssl/ssl.h>
57 #define pair_update_request(_attr, _da) do { \
58 _attr = fr_pair_find_by_da(&request->request_pairs, NULL, _da); \
60 _attr = fr_pair_afrom_da(request, _da); \
61 assert(_attr != NULL); \
62 fr_pair_append(&request->request_pairs, _attr); \
156 fprintf(stderr,
"Usage: radclient [options] server[:port] <command> [<secret>]\n");
158 fprintf(stderr,
" <command> One of auth, acct, status, coa, disconnect or auto.\n");
159 fprintf(stderr,
" -4 Use IPv4 address of server\n");
160 fprintf(stderr,
" -6 Use IPv6 address of server.\n");
161 fprintf(stderr,
" -A <attribute> Use named 'attribute' to match CoA requests to packets. Default is User-Name\n");
162 fprintf(stderr,
" -C [<client_ip>:]<client_port> Client source port and source IP address. Port values may be 1..65535\n");
163 fprintf(stderr,
" -c <count> Send each packet 'count' times.\n");
164 fprintf(stderr,
" -d <raddb> Set user dictionary directory (defaults to " RADDBDIR
").\n");
165 fprintf(stderr,
" -D <dictdir> Set main dictionary directory (defaults to " DICTDIR
").\n");
166 fprintf(stderr,
" -f <request>[:<expected>][:<coa_reply>][:<coa_expected>] Read packets from file, not stdin.\n");
167 fprintf(stderr,
" If a second file is provided, it will be used to verify responses\n");
168 fprintf(stderr,
" -F Print the file name, packet number and reply code.\n");
169 fprintf(stderr,
" -h Print usage help information.\n");
170 fprintf(stderr,
" -i <id> Set request id to 'id'. Values may be 0..255\n");
171 fprintf(stderr,
" -n <num> Send N requests/s\n");
172 fprintf(stderr,
" -o <port> Set CoA listening port (defaults to 3799)\n");
173 fprintf(stderr,
" -p <num> Send 'num' packets from a file in parallel.\n");
174 fprintf(stderr,
" -P <proto> Use proto (tcp or udp) for transport.\n");
175 fprintf(stderr,
" -r <retries> If timeout, retry sending the packet 'retries' times.\n");
176 fprintf(stderr,
" -s Print out summary information of auth results.\n");
177 fprintf(stderr,
" -S <file> read secret from file, not command line.\n");
178 fprintf(stderr,
" -t <timeout> Wait 'timeout' seconds before retrying (may be a floating point number).\n");
179 fprintf(stderr,
" -v Show program version information.\n");
180 fprintf(stderr,
" -x Debugging mode.\n");
198 #ifdef HAVE_OPENSSL_SSL_H
199 #include <openssl/provider.h>
201 static OSSL_PROVIDER *openssl_default_provider = NULL;
202 static OSSL_PROVIDER *openssl_legacy_provider = NULL;
209 openssl_default_provider = OSSL_PROVIDER_load(NULL,
"default");
210 if (!openssl_default_provider) {
211 ERROR(
"(TLS) Failed loading default provider");
220 openssl_legacy_provider = OSSL_PROVIDER_load(NULL,
"legacy");
221 if (!openssl_legacy_provider) {
222 ERROR(
"(TLS) Failed loading legacy provider");
231 if (openssl_default_provider && !OSSL_PROVIDER_unload(openssl_default_provider)) {
232 ERROR(
"Failed unloading default provider");
234 openssl_default_provider = NULL;
236 if (openssl_legacy_provider && !OSSL_PROVIDER_unload(openssl_legacy_provider)) {
237 ERROR(
"Failed unloading legacy provider");
239 openssl_legacy_provider = NULL;
242 #define openssl3_init()
243 #define openssl3_free()
247 char const *password)
264 for (i = 0; i < challenge->vp_length; i++) {
286 svp = getservbyname(
name,
"udp");
289 return ntohs(svp->s_port);
302 if (*port == 0) *port =
getport(
"radius");
307 if (*port == 0) *port =
getport(
"radacct");
320 if (*port == 0) *port = 0;
362 for (i = 0; i <
vp->vp_length; i++) {
363 if (
vp->vp_octets[i] < 32) {
374 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)
396 &request->
reply_pairs, coa_reply, coa_reply_done) < 0) {
397 REDEBUG(
"Error parsing \"%s\"", reply_filename);
414 &request->
filter, coa_filter, coa_filter_done) < 0) {
415 REDEBUG(
"Error parsing \"%s\"", filter_filename);
419 if (*coa_filter_done && !*coa_reply_done) {
420 REDEBUG(
"Differing number of replies/filters in %s:%s "
421 "(too many replies))", reply_filename, filter_filename);
425 if (!*coa_filter_done && *coa_reply_done) {
426 REDEBUG(
"Differing number of replies/filters in %s:%s "
427 "(too many filters))", reply_filename, filter_filename);
454 ERROR(
"Failed inserting packet from %s into CoA tree", request->
name);
467 FILE *packets, *filters = NULL;
471 bool packets_done =
false;
474 FILE *coa_reply = NULL;
475 FILE *coa_filter = NULL;
476 bool coa_reply_done =
false;
477 bool coa_filter_done =
false;
479 assert(files->
packets != NULL);
484 if (strcmp(files->
packets,
"-") != 0) {
485 packets = fopen(files->
packets,
"r");
495 filters = fopen(files->
filters,
"r");
503 coa_reply = fopen(files->
coa_reply,
"r");
525 char const *coa_reply_filename = NULL;
526 char const *coa_filter_filename = NULL;
541 request->
files = files;
543 request->
num = num++;
562 REDEBUG(
"Error parsing \"%s\"", input);
570 WARN(
"Skipping \"%s\": No Attributes", files->
packets);
582 &request->
filter, filters, &filters_done) < 0) {
587 if (filters_done && !packets_done) {
588 REDEBUG(
"Differing number of packets/filters in %s:%s "
593 if (!filters_done && packets_done) {
594 REDEBUG(
"Differing number of packets/filters in %s:%s "
652 request->
name =
vp->vp_strvalue;
655 coa_reply_filename =
vp->vp_strvalue;
658 coa_filter_filename =
vp->vp_strvalue;
717 REDEBUG(
"Packet-Type must be defined,"
718 "or a well known RADIUS port");
722 REDEBUG(
"Can't determine expected &reply.Packet-Type for Packet-Type %i",
752 REDEBUG(
"Can't determine expected Packet-Type for &reply.Packet-Type %i",
764 REDEBUG(
"Can't determine destination port");
772 if (coa_reply_filename) {
774 RDEBUG(
"Cannot specify CoA file on both the command line and via Radclient-CoA-Filename");
778 coa_reply = fopen(coa_reply_filename,
"r");
784 if (coa_filter_filename) {
785 coa_filter = fopen(coa_filter_filename,
"r");
794 if (
coa_init(request, coa_reply, coa_reply_filename, &coa_reply_done,
795 coa_filter, coa_filter_filename, &coa_filter_done) < 0) {
807 }
else if (coa_reply) {
808 if (
coa_init(request, coa_reply, coa_reply_filename, &coa_reply_done,
809 coa_filter, coa_filter_filename, &coa_filter_done) < 0) {
813 if (coa_reply_done != packets_done) {
814 REDEBUG(
"Differing number of packets in input file and coa_reply in %s:%s ",
833 }
while (!packets_done);
835 if (packets != stdin) fclose(packets);
836 if (filters) fclose(filters);
837 if (coa_reply) fclose(coa_reply);
838 if (coa_filter) fclose(coa_filter);
848 if (packets != stdin) fclose(packets);
849 if (filters) fclose(filters);
850 if (coa_reply) fclose(coa_reply);
851 if (coa_filter) fclose(coa_filter);
867 ERROR(
"No server was given, and request %" PRIu64
" in file %s did not contain "
875 ERROR(
"Request was \"auto\", and request %" PRIu64
" in file %s did not contain Packet-Type",
907 if (!request || !request->
packet ||
931 assert(request->
done ==
false);
933 #ifdef STATIC_ANALYZER
951 assert(request->
reply == NULL);
990 ERROR(
"Can't add new socket");
1020 vector = challenge->vp_octets;
1035 DEBUG(
"WARNING: No password in the request");
1081 REDEBUG(
"No reply from server for ID %d socket %d",
1090 request->
done =
true;
1109 request->
done =
true;
1129 #ifdef STATIC_ANALYZER
1135 FD_SET(
coafd, &set);
1149 DEBUG(
"Failed reading CoA packet");
1157 DEBUG(
"CoA verification failed");
1169 DEBUG(
"Failed decoding CoA packet");
1178 my.name =
"receive CoA request";
1183 DEBUG(
"No matching request packet for CoA packet %u %u", packet->
data[0], packet->
data[1]);
1190 request->
packet = talloc_steal(request, packet);
1220 RDEBUG(
"%s: CoA request passed filter", request->
name);
1224 REDEBUG(
"%s: CoA Request for failed filter", request->
name);
1249 RDEBUG(
"Failed getting reply packet type");
1260 REDEBUG(
"Failed sending CoA reply");
1269 TALLOC_FREE(
parent->coa);
1283 volatile int max_fd;
1285 #ifdef STATIC_ANALYZER
1298 FD_SET(
coafd, &set);
1311 if (FD_ISSET(
coafd, &set)) {
1313 FD_CLR(
coafd, &set);
1323 ERROR(
"Received bad packet");
1359 ERROR(
"Received reply to request we did not send. (id=%d socket %d)",
1364 request = packet->
uctx;
1371 REDEBUG(
"Reply verification failed");
1381 request->
reply = reply;
1390 REDEBUG(
"Reply decode failed");
1440 RDEBUG(
"%s: Response passed filter", request->
name);
1444 REDEBUG(
"%s: Response for failed filter", request->
name);
1450 request->
done =
true;
1466 int ret = EXIT_SUCCESS;
1468 char const *raddb_dir = RADDBDIR;
1469 char const *dict_dir = DICTDIR;
1470 char filesecret[256];
1472 int do_summary =
false;
1475 int force_af = AF_UNSPEC;
1504 talloc_set_log_stderr();
1517 while ((c = getopt(argc, argv,
"46c:A:C:d:D:f:Fhi:n:o:p:P:r:sS:t:vx")) != -1)
switch (c) {
1523 force_af = AF_INET6;
1542 if (strchr(optarg,
':')) {
1544 optarg, -1, AF_UNSPEC,
true,
false) < 0) {
1545 fr_perror(
"Failed parsing source address");
1552 if (tmp < 1 || tmp > 65535)
usage();
1581 p = strchr(optarg, c);
1584 p = strchr(optarg, c);
1592 MEM(files->
packets = talloc_strndup(files, optarg, p - optarg));
1598 q = strchr(files->
filters, c);
1621 if (!isdigit((
uint8_t) *optarg))
1630 persec = atoi(optarg);
1631 if (persec <= 0)
usage();
1651 if (!strcmp(optarg,
"tcp")) {
1653 }
else if (!strcmp(optarg,
"udp")) {
1673 fp = fopen(optarg,
"r");
1678 if (fgets(filesecret,
sizeof(filesecret), fp) == NULL) {
1685 p = filesecret + strlen(filesecret) - 1;
1686 while ((p >= filesecret) &&
1692 if (strlen(filesecret) < 2) {
1693 ERROR(
"Secret in %s is too short", optarg);
1696 secret = talloc_strdup(NULL, filesecret);
1702 fr_perror(
"Failed parsing timeout value");
1721 argc -= (optind - 1);
1722 argv += (optind - 1);
1724 if ((argc < 3) || ((
secret == NULL) && (argc < 4))) {
1725 ERROR(
"Insufficient arguments");
1758 "Failed to initialize the dictionaries");
1765 ERROR(
"Unknown or invalid CoA filter attribute %s", optarg);
1783 if (!isdigit((
uint8_t) argv[2][0])) {
1786 ERROR(
"Unrecognised request type \"%s\"", argv[2]);
1796 if (strcmp(argv[1],
"-") != 0) {
1812 if (argv[3])
secret = talloc_strdup(NULL, argv[3]);
1830 ERROR(
"Failed parsing input files");
1839 ERROR(
"Nothing to send");
1865 ERROR(
"Failed opening socket");
1898 ERROR(
"Failed adding socket");
1926 char const *filename = NULL;
1957 if (this->coa)
continue;
1973 if (this->files->packets != filename) {
1974 filename = this->files->packets;
2026 for (i = 0; i < 4; i++) {
2031 assert(this->done ==
false);
2032 assert(this->reply == NULL);
2079 "\tAccepted : %" PRIu64
"\n"
2080 "\tRejected : %" PRIu64
"\n"
2081 "\tLost : %" PRIu64
"\n"
2082 "\tPassed filter : %" PRIu64
"\n"
2083 "\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.
#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_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
#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 ** 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.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
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.
fr_dict_t * fr_dict_unconst(fr_dict_t const *dict)
Coerce to non-const.
#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.
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.
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.
#define fr_dlist_foreach(_list_head, _type, _iter)
Iterate over the contents of a list.
static void * fr_dlist_next(fr_dlist_head_t const *list_head, void const *ptr)
Get the next item in a list.
static void fr_dlist_talloc_free(fr_dlist_head_t *head)
Free all items in a doubly linked list (with talloc)
static unsigned int fr_dlist_num_elements(fr_dlist_head_t const *head)
Return the number of elements in the dlist.
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.
static int fr_dlist_insert_tail(fr_dlist_head_t *list_head, void *ptr)
Insert an item into the tail of a list.
static void * fr_dlist_remove(fr_dlist_head_t *list_head, void *ptr)
Remove an item from the list.
#define fr_dlist_talloc_init(_head, _type, _field)
Initialise the head structure of a doubly linked list.
Head of a doubly linked list.
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)
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.
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.
@ L_DST_STDOUT
Log to stdout.
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_packet_t * fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set, uint32_t max_attributes, bool require_message_authenticator)
void fr_packet_list_free(fr_packet_list_t *pl)
fr_packet_list_t * fr_packet_list_create(int alloc_id)
fr_packet_t * fr_packet_list_find_byreply(fr_packet_list_t *pl, fr_packet_t *reply)
bool fr_packet_list_id_alloc(fr_packet_list_t *pl, int proto, fr_packet_t *request, void **pctx)
bool fr_packet_list_yank(fr_packet_list_t *pl, fr_packet_t *request)
bool fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd, int proto, fr_ipaddr_t *dst_ipaddr, uint16_t dst_port, void *ctx)
uint32_t fr_packet_list_num_elements(fr_packet_list_t *pl)
int fr_packet_list_fd_set(fr_packet_list_t *pl, fd_set *set)
bool fr_packet_list_id_free(fr_packet_list_t *pl, fr_packet_t *request, bool yank)
@ 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
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.
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.
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.
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
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.
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.
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.
void fr_pair_list_steal(TALLOC_CTX *ctx, fr_pair_list_t *list)
Steal a list of pairs to a new context.
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)
ssize_t fr_radius_decode_simple(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t *packet, size_t packet_len, uint8_t const *vector, char const *secret)
Simple wrapper for callers who just need a shared secret.
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_packet_verify(fr_packet_t *packet, fr_packet_t *original, char const *secret)
Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet.
fr_packet_t * fr_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_message_authenticator)
Receive UDP client requests, and fill in the basics of a fr_packet_t structure.
int fr_packet_send(fr_packet_t *packet, fr_pair_list_t *list, fr_packet_t const *original, char const *secret)
Reply to the request.
void fr_radius_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *list, bool received)
static TALLOC_CTX * autofree
static fr_rb_tree_t * coa_tree
static fr_ipaddr_t client_ipaddr
static fr_dict_attr_t const * attr_packet_type
static fr_dict_attr_t const * attr_request_authenticator
static fr_dict_attr_t const * attr_user_password
static int send_one_packet(rc_request_t *request)
static int getport(char const *name)
static char const * radclient_version
static int _rc_request_free(rc_request_t *request)
static uint16_t client_port
static int radclient_sane(rc_request_t *request)
static int recv_one_packet(fr_time_delta_t wait_time)
static fr_time_delta_t sleep_time
int main(int argc, char **argv)
static fr_dict_t const * dict_freeradius
static fr_dict_attr_t const * attr_chap_password
static fr_packet_list_t * packet_list
static fr_dict_attr_t const * attr_ms_chap_response
static fr_dict_t const * dict_radius
static fr_dict_attr_t const * attr_ms_chap_challenge
static uint16_t server_port
fr_dict_attr_autoload_t radclient_dict_attr[]
static fr_dict_attr_t const * attr_chap_challenge
static int recv_coa_packet(fr_time_delta_t wait_time)
static fr_ipaddr_t server_ipaddr
static fr_dict_attr_t const * attr_cleartext_password
static void deallocate_id(rc_request_t *request)
static bool print_filename
static fr_dict_attr_t const * attr_radclient_test_name
static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files)
static fr_dict_attr_t const * attr_radclient_coa_filename
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
fr_dict_autoload_t radclient_dict[]
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_time_delta_t timeout
static fr_dict_attr_t const * attr_radclient_coa_filter
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.
bool fr_rb_delete_by_inline_node(fr_rb_tree_t *tree, fr_rb_node_t *node)
Remove node and free data (if a free function was specified)
uint32_t fr_rb_num_elements(fr_rb_tree_t *tree)
#define fr_rb_inline_talloc_alloc(_ctx, _type, _field, _data_cmp, _data_free)
Allocs a red black that verifies elements are of a specific talloc type.
void * fr_rb_remove(fr_rb_tree_t *tree, void const *data)
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
void * fr_rb_find(fr_rb_tree_t const *tree, void const *data)
The main red black tree structure.
fr_packet_t * packet
Incoming request.
fr_packet_t * reply
Outgoing response.
void smbdes_mschap(uint8_t const win_password[16], uint8_t const *challenge, uint8_t *response)
int fr_socket_server_udp(fr_ipaddr_t const *src_ipaddr, uint16_t *src_port, char const *port_name, bool async)
Open an IPv4/IPv6 unconnected UDP socket.
int fr_socket_client_tcp(char const *ifname, fr_ipaddr_t *src_ipaddr, fr_ipaddr_t const *dst_ipaddr, uint16_t dst_port, bool async)
Establish a connected TCP socket.
int fr_socket_bind(int sockfd, char const *ifname, fr_ipaddr_t *src_ipaddr, uint16_t *src_port)
Bind a UDP/TCP v4/v6 socket to a given ipaddr src port, and interface.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
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.
#define fr_time_delta_lt(_a, _b)
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
#define fr_time_delta_wrap(_time)
#define fr_time_delta_ispos(_a)
#define fr_time_delta_to_timeval(_delta)
Convert a delta to a timeval.
#define fr_time_delta_eq(_a, _b)
#define fr_time_sub(_a, _b)
Subtract one time from another.
#define fr_time_delta_gt(_a, _b)
A time delta, a difference in time measured in nanoseconds.
#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).
size_t data_len
Length of packet data.
uint8_t vector[RADIUS_AUTH_VECTOR_LENGTH]
RADIUS authentication vector.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
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.
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.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define PAIR_LIST_VERIFY(_x)
int af
AF_INET, AF_INET6, or AF_UNIX.
int fd
File descriptor if this is a live socket.
int type
SOCK_STREAM, SOCK_DGRAM, etc.
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.