The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Typedefs | Functions | Variables
radclient.c File Reference

General radius client and debug tool. More...

#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/util/time.h>
#include <freeradius-devel/server/packet.h>
#include <freeradius-devel/radius/list.h>
#include <freeradius-devel/radius/radius.h>
#include <freeradius-devel/util/chap.h>
#include <ctype.h>
#include <assert.h>
#include "smbdes.h"
#include "mschap.h"
#include "radclient.h"
+ Include dependency graph for radclient.c:

Go to the source code of this file.

Macros

#define openssl3_free()
 
#define openssl3_init()
 
#define pair_update_request(_attr, _da)
 

Typedefs

typedef struct request_s request_t
 

Functions

static int _rc_request_free (rc_request_t *request)
 
static bool already_hex (fr_pair_t *vp)
 
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)
 
static void deallocate_id (rc_request_t *request)
 
static int getport (char const *name)
 
int main (int argc, char **argv)
 
static int mschapv1_encode (fr_packet_t *packet, fr_pair_list_t *list, char const *password)
 
static fr_radius_packet_code_t radclient_get_code (uint16_t port)
 
static void radclient_get_port (fr_radius_packet_code_t type, uint16_t *port)
 
static int radclient_init (TALLOC_CTX *ctx, rc_file_pair_t *files)
 
static int radclient_sane (rc_request_t *request)
 
static int recv_coa_packet (fr_time_delta_t wait_time)
 
static int recv_one_packet (fr_time_delta_t wait_time)
 
static int8_t request_cmp (void const *one, void const *two)
 
static int send_one_packet (rc_request_t *request)
 
static NEVER_RETURNS void usage (void)
 

Variables

static fr_dict_attr_t const * attr_chap_challenge
 
static fr_dict_attr_t const * attr_chap_password
 
static fr_dict_attr_t const * attr_cleartext_password
 
static fr_dict_attr_t const * attr_coa_filter = NULL
 
static const char * attr_coa_filter_name = "User-Name"
 
static fr_dict_attr_t const * attr_ms_chap_challenge
 
static fr_dict_attr_t const * attr_ms_chap_password
 
static fr_dict_attr_t const * attr_ms_chap_response
 
static fr_dict_attr_t const * attr_packet_type
 
static fr_dict_attr_t const * attr_radclient_coa_filename
 
static fr_dict_attr_t const * attr_radclient_coa_filter
 
static fr_dict_attr_t const * attr_radclient_test_name
 
static fr_dict_attr_t const * attr_request_authenticator
 
static fr_dict_attr_t const * attr_user_name
 
static fr_dict_attr_t const * attr_user_password
 
static fr_ipaddr_t client_ipaddr
 
static uint16_t client_port = 0
 
static uint16_t coa_port = FR_COA_UDP_PORT
 
static fr_rb_tree_tcoa_tree = NULL
 
static int coafd
 
static fr_dict_t const * dict_freeradius
 
static fr_dict_t const * dict_radius
 
static bool do_coa = false
 
static bool do_output = true
 
static bool done = true
 
static int ipproto = IPPROTO_UDP
 
static int last_used_id = -1
 
static int packet_code = FR_RADIUS_CODE_UNDEFINED
 
static fr_packet_list_tpacket_list = NULL
 
static bool print_filename = false
 
fr_dict_autoload_t radclient_dict []
 
fr_dict_attr_autoload_t radclient_dict_attr []
 
static char const * radclient_version = RADIUSD_VERSION_BUILD("radclient")
 
static fr_dlist_head_t rc_request_list
 
static int resend_count = 1
 
static int retries = 3
 
static char * secret = NULL
 
static fr_ipaddr_t server_ipaddr
 
static uint16_t server_port = 0
 
static fr_time_delta_t sleep_time = fr_time_delta_wrap(-1)
 
static int sockfd
 
static rc_stats_t stats
 
static fr_time_delta_t timeout = fr_time_delta_wrap((int64_t)5 * NSEC)
 

Detailed Description

General radius client and debug tool.

Id
55dfc93959f97d5fe5a1a64a56969346cbb6b558
Id
0c8f2cf2fc5e8e5912727bebdf5a15d34b17759c

Definition in file radclient.c.

Macro Definition Documentation

◆ openssl3_free

#define openssl3_free ( )

Definition at line 243 of file radclient.c.

◆ openssl3_init

#define openssl3_init ( )

Definition at line 242 of file radclient.c.

◆ pair_update_request

#define pair_update_request (   _attr,
  _da 
)
Value:
do { \
_attr = fr_pair_find_by_da(&request->request_pairs, NULL, _da); \
if (!_attr) { \
_attr = fr_pair_afrom_da(request, _da); \
assert(_attr != NULL); \
fr_pair_append(&request->request_pairs, _attr); \
} \
} while (0)
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.
Definition: pair.c:693
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.
Definition: pair.c:283

Definition at line 57 of file radclient.c.

Typedef Documentation

◆ request_t

typedef struct request_s request_t

Definition at line 1 of file radclient.c.

Function Documentation

◆ _rc_request_free()

static int _rc_request_free ( rc_request_t request)
static

Definition at line 189 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ already_hex()

static bool already_hex ( fr_pair_t vp)
static

Definition at line 349 of file radclient.c.

+ Here is the caller graph for this function:

◆ coa_init()

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 
)
static

Definition at line 374 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deallocate_id()

static void deallocate_id ( rc_request_t request)
static

Definition at line 905 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getport()

static int getport ( char const *  name)
static

Definition at line 282 of file radclient.c.

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1464 of file radclient.c.

◆ mschapv1_encode()

static int mschapv1_encode ( fr_packet_t packet,
fr_pair_list_t list,
char const *  password 
)
static

Definition at line 246 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radclient_get_code()

static fr_radius_packet_code_t radclient_get_code ( uint16_t  port)
static

Definition at line 328 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radclient_get_port()

static void radclient_get_port ( fr_radius_packet_code_t  type,
uint16_t port 
)
static

Definition at line 295 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radclient_init()

static int radclient_init ( TALLOC_CTX *  ctx,
rc_file_pair_t files 
)
static

Definition at line 465 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radclient_sane()

static int radclient_sane ( rc_request_t request)
static

Definition at line 860 of file radclient.c.

+ Here is the caller graph for this function:

◆ recv_coa_packet()

static int recv_coa_packet ( fr_time_delta_t  wait_time)
static

Definition at line 1121 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recv_one_packet()

static int recv_one_packet ( fr_time_delta_t  wait_time)
static

Definition at line 1277 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ request_cmp()

static int8_t request_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 887 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_one_packet()

static int send_one_packet ( rc_request_t request)
static

Definition at line 929 of file radclient.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ usage()

static NEVER_RETURNS void usage ( void  )
static

Definition at line 154 of file radclient.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ attr_chap_challenge

fr_dict_attr_t const* attr_chap_challenge
static

Definition at line 122 of file radclient.c.

◆ attr_chap_password

fr_dict_attr_t const* attr_chap_password
static

Definition at line 121 of file radclient.c.

◆ attr_cleartext_password

fr_dict_attr_t const* attr_cleartext_password
static

Definition at line 112 of file radclient.c.

◆ attr_coa_filter

fr_dict_attr_t const* attr_coa_filter = NULL
static

Definition at line 130 of file radclient.c.

◆ attr_coa_filter_name

const char* attr_coa_filter_name = "User-Name"
static

Definition at line 72 of file radclient.c.

◆ attr_ms_chap_challenge

fr_dict_attr_t const* attr_ms_chap_challenge
static

Definition at line 114 of file radclient.c.

◆ attr_ms_chap_password

fr_dict_attr_t const* attr_ms_chap_password
static

Definition at line 115 of file radclient.c.

◆ attr_ms_chap_response

fr_dict_attr_t const* attr_ms_chap_response
static

Definition at line 116 of file radclient.c.

◆ attr_packet_type

fr_dict_attr_t const* attr_packet_type
static

Definition at line 123 of file radclient.c.

◆ attr_radclient_coa_filename

fr_dict_attr_t const* attr_radclient_coa_filename
static

Definition at line 127 of file radclient.c.

◆ attr_radclient_coa_filter

fr_dict_attr_t const* attr_radclient_coa_filter
static

Definition at line 128 of file radclient.c.

◆ attr_radclient_test_name

fr_dict_attr_t const* attr_radclient_test_name
static

Definition at line 118 of file radclient.c.

◆ attr_request_authenticator

fr_dict_attr_t const* attr_request_authenticator
static

Definition at line 119 of file radclient.c.

◆ attr_user_name

fr_dict_attr_t const* attr_user_name
static

Definition at line 124 of file radclient.c.

◆ attr_user_password

fr_dict_attr_t const* attr_user_password
static

Definition at line 125 of file radclient.c.

◆ client_ipaddr

fr_ipaddr_t client_ipaddr
static

Definition at line 83 of file radclient.c.

◆ client_port

uint16_t client_port = 0
static

Definition at line 84 of file radclient.c.

◆ coa_port

uint16_t coa_port = FR_COA_UDP_PORT
static

Definition at line 93 of file radclient.c.

◆ coa_tree

fr_rb_tree_t* coa_tree = NULL
static

Definition at line 94 of file radclient.c.

◆ coafd

int coafd
static

Definition at line 92 of file radclient.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 102 of file radclient.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 103 of file radclient.c.

◆ do_coa

bool do_coa = false
static

Definition at line 91 of file radclient.c.

◆ do_output

bool do_output = true
static

Definition at line 70 of file radclient.c.

◆ done

bool done = true
static

Definition at line 80 of file radclient.c.

◆ ipproto

int ipproto = IPPROTO_UDP
static

Definition at line 89 of file radclient.c.

◆ last_used_id

int last_used_id = -1
static

Definition at line 87 of file radclient.c.

◆ packet_code

int packet_code = FR_RADIUS_CODE_UNDEFINED
static

Definition at line 77 of file radclient.c.

◆ packet_list

fr_packet_list_t* packet_list = NULL
static

Definition at line 96 of file radclient.c.

◆ print_filename

bool print_filename = false
static

Definition at line 81 of file radclient.c.

◆ radclient_dict

fr_dict_autoload_t radclient_dict[]
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition: radclient.c:102
static fr_dict_t const * dict_radius
Definition: radclient.c:103

Definition at line 106 of file radclient.c.

◆ radclient_dict_attr

fr_dict_attr_autoload_t radclient_dict_attr[]
Initial value:
= {
{ .out = &attr_cleartext_password, .name = "Password.Cleartext", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_ms_chap_challenge, .name = "Vendor-Specific.Microsoft.CHAP-Challenge", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_ms_chap_password, .name = "Password.MS-CHAP", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_ms_chap_response, .name = "Vendor-Specific.Microsoft.CHAP-Response", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_radclient_test_name, .name = "Radclient-Test-Name", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_request_authenticator, .name = "Request-Authenticator", .type = FR_TYPE_OCTETS, .dict = &dict_freeradius },
{ .out = &attr_radclient_coa_filename, .name = "Radclient-CoA-Filename", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_radclient_coa_filter, .name = "Radclient-CoA-Filter", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_chap_password, .name = "CHAP-Password", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_chap_challenge, .name = "CHAP-Challenge", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
{ .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ NULL }
}
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_OCTETS
Raw octets.
Definition: merged_model.c:84
static fr_dict_attr_t const * attr_packet_type
Definition: radclient.c:123
static fr_dict_attr_t const * attr_request_authenticator
Definition: radclient.c:119
static fr_dict_attr_t const * attr_user_password
Definition: radclient.c:125
static fr_dict_attr_t const * attr_chap_password
Definition: radclient.c:121
static fr_dict_attr_t const * attr_ms_chap_response
Definition: radclient.c:116
static fr_dict_attr_t const * attr_ms_chap_challenge
Definition: radclient.c:114
static fr_dict_attr_t const * attr_chap_challenge
Definition: radclient.c:122
static fr_dict_attr_t const * attr_cleartext_password
Definition: radclient.c:112
static fr_dict_attr_t const * attr_radclient_test_name
Definition: radclient.c:118
static fr_dict_attr_t const * attr_radclient_coa_filename
Definition: radclient.c:127
static fr_dict_attr_t const * attr_user_name
Definition: radclient.c:124
static fr_dict_attr_t const * attr_ms_chap_password
Definition: radclient.c:115
static fr_dict_attr_t const * attr_radclient_coa_filter
Definition: radclient.c:128

Definition at line 133 of file radclient.c.

◆ radclient_version

char const* radclient_version = RADIUSD_VERSION_BUILD("radclient")
static

Definition at line 100 of file radclient.c.

◆ rc_request_list

fr_dlist_head_t rc_request_list
static

Definition at line 98 of file radclient.c.

◆ resend_count

int resend_count = 1
static

Definition at line 79 of file radclient.c.

◆ retries

int retries = 3
static

Definition at line 66 of file radclient.c.

◆ secret

char* secret = NULL
static

Definition at line 69 of file radclient.c.

◆ server_ipaddr

fr_ipaddr_t server_ipaddr
static

Definition at line 78 of file radclient.c.

◆ server_port

uint16_t server_port = 0
static

Definition at line 76 of file radclient.c.

◆ sleep_time

fr_time_delta_t sleep_time = fr_time_delta_wrap(-1)
static

Definition at line 68 of file radclient.c.

◆ sockfd

int sockfd
static

Definition at line 86 of file radclient.c.

◆ stats

rc_stats_t stats
static

Definition at line 74 of file radclient.c.

◆ timeout

fr_time_delta_t timeout = fr_time_delta_wrap((int64_t)5 * NSEC)
static

Definition at line 67 of file radclient.c.