The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Macros | Typedefs | Functions | Variables
radclient-ng.c File Reference
#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/util/event.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 <freeradius-devel/radius/client.h>
#include <ctype.h>
#include <assert.h>
#include "smbdes.h"
#include "mschap.h"
#include "radclient.h"
+ Include dependency graph for radclient-ng.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 _loop_status (UNUSED fr_time_t now, fr_time_delta_t wake, UNUSED void *ctx)
 
static int _rc_request_free (rc_request_t *request)
 
static bool already_hex (fr_pair_t *vp)
 
static void cleanup (fr_bio_packet_t *client, rc_request_t *request)
 
static void client_bio_connected (fr_bio_packet_t *client)
 
static NEVER_RETURNS void client_bio_failed (fr_bio_packet_t *bio)
 
static int client_bio_write_pause (fr_bio_packet_t *bio)
 
static int client_bio_write_resume (fr_bio_packet_t *bio)
 
static NEVER_RETURNS void client_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx)
 
static void client_packet_release (fr_bio_packet_t *client, fr_packet_t *packet)
 
static void client_packet_retry_log (UNUSED fr_bio_packet_t *client, fr_packet_t *packet)
 
static void client_read (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 
static void client_write (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 
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 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 int8_t request_cmp (void const *one, void const *two)
 
static int send_one_packet (fr_bio_packet_t *client, 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 TALLOC_CTX * autofree = NULL
 
static fr_bio_packet_tclient_bio = NULL
 
static fr_radius_client_config_t client_config
 
static fr_radius_client_bio_info_t const * client_info = NULL
 
static int coa_port = FR_COA_UDP_PORT
 
static fr_rb_tree_tcoa_tree = NULL
 
static rc_request_tcurrent = NULL
 
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 fr_bio_fd_config_t fd_config
 
static int forced_id = -1
 
static int ipproto = IPPROTO_UDP
 
static int packet_code = FR_RADIUS_CODE_UNDEFINED
 
static size_t parallel = 1
 
static fr_event_update_t const pause_write []
 
static bool paused = false
 
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 fr_event_update_t const resume_write []
 
static char * secret = NULL
 
static rc_stats_t stats
 

Macro Definition Documentation

◆ openssl3_free

#define openssl3_free ( )

Definition at line 253 of file radclient-ng.c.

◆ openssl3_init

#define openssl3_init ( )

Definition at line 252 of file radclient-ng.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); \
fr_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 60 of file radclient-ng.c.

Typedef Documentation

◆ request_t

typedef struct request_s request_t

Definition at line 53 of file radclient-ng.c.

Function Documentation

◆ _loop_status()

static int _loop_status ( UNUSED fr_time_t  now,
fr_time_delta_t  wake,
UNUSED void *  ctx 
)
static

Definition at line 256 of file radclient-ng.c.

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

◆ _rc_request_free()

static int _rc_request_free ( rc_request_t request)
static

Definition at line 192 of file radclient-ng.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 370 of file radclient-ng.c.

+ Here is the caller graph for this function:

◆ cleanup()

static void cleanup ( fr_bio_packet_t client,
rc_request_t request 
)
static

Definition at line 932 of file radclient-ng.c.

+ Here is the call graph for this function:

◆ client_bio_connected()

static void client_bio_connected ( fr_bio_packet_t client)
static

Definition at line 1290 of file radclient-ng.c.

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

◆ client_bio_failed()

static NEVER_RETURNS void client_bio_failed ( fr_bio_packet_t bio)
static

Definition at line 1101 of file radclient-ng.c.

+ Here is the caller graph for this function:

◆ client_bio_write_pause()

static int client_bio_write_pause ( fr_bio_packet_t bio)
static

Definition at line 1078 of file radclient-ng.c.

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

◆ client_bio_write_resume()

static int client_bio_write_resume ( fr_bio_packet_t bio)
static

Definition at line 1089 of file radclient-ng.c.

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

◆ client_error()

static NEVER_RETURNS void client_error ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
int  fd_errno,
void *  uctx 
)
static

Definition at line 1115 of file radclient-ng.c.

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

◆ client_packet_release()

static void client_packet_release ( fr_bio_packet_t client,
fr_packet_t packet 
)
static

Definition at line 971 of file radclient-ng.c.

+ Here is the caller graph for this function:

◆ client_packet_retry_log()

static void client_packet_retry_log ( UNUSED fr_bio_packet_t client,
fr_packet_t packet 
)
static

Definition at line 960 of file radclient-ng.c.

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

◆ client_read()

static void client_read ( fr_event_list_t el,
int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Definition at line 1131 of file radclient-ng.c.

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

◆ client_write()

static void client_write ( fr_event_list_t el,
int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Definition at line 1243 of file radclient-ng.c.

+ Here is the call graph for this function:
+ 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 395 of file radclient-ng.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 303 of file radclient-ng.c.

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1308 of file radclient-ng.c.

◆ mschapv1_encode()

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

Definition at line 267 of file radclient-ng.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 349 of file radclient-ng.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 316 of file radclient-ng.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 486 of file radclient-ng.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 884 of file radclient-ng.c.

+ 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 918 of file radclient-ng.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 ( fr_bio_packet_t client,
rc_request_t request 
)
static

Definition at line 984 of file radclient-ng.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 158 of file radclient-ng.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 126 of file radclient-ng.c.

◆ attr_chap_password

fr_dict_attr_t const* attr_chap_password
static

Definition at line 125 of file radclient-ng.c.

◆ attr_cleartext_password

fr_dict_attr_t const* attr_cleartext_password
static

Definition at line 116 of file radclient-ng.c.

◆ attr_coa_filter

fr_dict_attr_t const* attr_coa_filter = NULL
static

Definition at line 134 of file radclient-ng.c.

◆ attr_coa_filter_name

const char* attr_coa_filter_name = "User-Name"
static

Definition at line 72 of file radclient-ng.c.

◆ attr_ms_chap_challenge

fr_dict_attr_t const* attr_ms_chap_challenge
static

Definition at line 118 of file radclient-ng.c.

◆ attr_ms_chap_password

fr_dict_attr_t const* attr_ms_chap_password
static

Definition at line 119 of file radclient-ng.c.

◆ attr_ms_chap_response

fr_dict_attr_t const* attr_ms_chap_response
static

Definition at line 120 of file radclient-ng.c.

◆ attr_packet_type

fr_dict_attr_t const* attr_packet_type
static

Definition at line 127 of file radclient-ng.c.

◆ attr_radclient_coa_filename

fr_dict_attr_t const* attr_radclient_coa_filename
static

Definition at line 131 of file radclient-ng.c.

◆ attr_radclient_coa_filter

fr_dict_attr_t const* attr_radclient_coa_filter
static

Definition at line 132 of file radclient-ng.c.

◆ attr_radclient_test_name

fr_dict_attr_t const* attr_radclient_test_name
static

Definition at line 122 of file radclient-ng.c.

◆ attr_request_authenticator

fr_dict_attr_t const* attr_request_authenticator
static

Definition at line 123 of file radclient-ng.c.

◆ attr_user_name

fr_dict_attr_t const* attr_user_name
static

Definition at line 128 of file radclient-ng.c.

◆ attr_user_password

fr_dict_attr_t const* attr_user_password
static

Definition at line 129 of file radclient-ng.c.

◆ autofree

TALLOC_CTX* autofree = NULL
static

Definition at line 107 of file radclient-ng.c.

◆ client_bio

fr_bio_packet_t* client_bio = NULL
static

Definition at line 88 of file radclient-ng.c.

◆ client_config

fr_radius_client_config_t client_config
static

Definition at line 86 of file radclient-ng.c.

◆ client_info

fr_radius_client_bio_info_t const* client_info = NULL
static

Definition at line 90 of file radclient-ng.c.

◆ coa_port

int coa_port = FR_COA_UDP_PORT
static

Definition at line 96 of file radclient-ng.c.

◆ coa_tree

fr_rb_tree_t* coa_tree = NULL
static

Definition at line 97 of file radclient-ng.c.

◆ current

rc_request_t* current = NULL
static

Definition at line 100 of file radclient-ng.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 104 of file radclient-ng.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 105 of file radclient-ng.c.

◆ do_coa

bool do_coa = false
static

Definition at line 94 of file radclient-ng.c.

◆ do_output

bool do_output = true
static

Definition at line 70 of file radclient-ng.c.

◆ fd_config

fr_bio_fd_config_t fd_config
static

Definition at line 84 of file radclient-ng.c.

◆ forced_id

int forced_id = -1
static

Definition at line 80 of file radclient-ng.c.

◆ ipproto

int ipproto = IPPROTO_UDP
static

Definition at line 92 of file radclient-ng.c.

◆ packet_code

int packet_code = FR_RADIUS_CODE_UNDEFINED
static

Definition at line 76 of file radclient-ng.c.

◆ parallel

size_t parallel = 1
static

Definition at line 81 of file radclient-ng.c.

◆ pause_write

fr_event_update_t const pause_write[]
static
Initial value:
= {
{ 0 }
}
#define FR_EVENT_SUSPEND(_s, _f)
Temporarily remove the filter for a func from kevent.
Definition event.h:94
Callbacks for the FR_EVENT_FILTER_IO filter.
Definition event.h:173

Definition at line 1067 of file radclient-ng.c.

◆ paused

bool paused = false
static

Definition at line 82 of file radclient-ng.c.

◆ print_filename

bool print_filename = false
static

Definition at line 78 of file radclient-ng.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
static fr_dict_t const * dict_radius

Definition at line 110 of file radclient-ng.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.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
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 fr_dict_attr_t const * attr_chap_password
static fr_dict_attr_t const * attr_ms_chap_response
static fr_dict_attr_t const * attr_ms_chap_challenge
static fr_dict_attr_t const * attr_chap_challenge
static fr_dict_attr_t const * attr_cleartext_password
static fr_dict_attr_t const * attr_radclient_test_name
static fr_dict_attr_t const * attr_radclient_coa_filename
static fr_dict_attr_t const * attr_user_name
static fr_dict_attr_t const * attr_ms_chap_password
static fr_dict_attr_t const * attr_radclient_coa_filter

Definition at line 137 of file radclient-ng.c.

◆ radclient_version

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

Definition at line 102 of file radclient-ng.c.

◆ rc_request_list

fr_dlist_head_t rc_request_list
static

Definition at line 99 of file radclient-ng.c.

◆ resend_count

int resend_count = 1
static

Definition at line 77 of file radclient-ng.c.

◆ resume_write

fr_event_update_t const resume_write[]
static
Initial value:
= {
{ 0 }
}
#define FR_EVENT_RESUME(_s, _f)
Re-add the filter for a func from kevent.
Definition event.h:110

Definition at line 1072 of file radclient-ng.c.

◆ secret

char* secret = NULL
static

Definition at line 69 of file radclient-ng.c.

◆ stats

rc_stats_t stats
static

Definition at line 74 of file radclient-ng.c.