The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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 client_connect (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 
static NEVER_RETURNS void client_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, UNUSED void *uctx)
 
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 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 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_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_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_tbio = 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 rc_request_tcurrent = NULL
 
static fr_dict_t const * dict_freeradius
 
static fr_dict_t const * dict_radius
 
static bool do_output = true
 
static fr_bio_fd_config_t fd_config
 
static fr_bio_fd_info_t const * fd_info = NULL
 
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 235 of file radclient-ng.c.

◆ openssl3_init

#define openssl3_init ( )

Definition at line 234 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:688
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:278

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

Typedef Documentation

◆ request_t

typedef struct request_s request_t

Definition at line 1 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 238 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 179 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 352 of file radclient-ng.c.

+ Here is the caller graph for this function:

◆ client_connect()

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

Definition at line 997 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,
UNUSED void *  uctx 
)
static

Definition at line 822 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 829 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 959 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 285 of file radclient-ng.c.

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1017 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 249 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 331 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 298 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 378 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 691 of file radclient-ng.c.

+ 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 728 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 147 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 123 of file radclient-ng.c.

◆ attr_chap_password

fr_dict_attr_t const* attr_chap_password
static

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

◆ attr_cleartext_password

fr_dict_attr_t const* attr_cleartext_password
static

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

◆ attr_ms_chap_challenge

fr_dict_attr_t const* attr_ms_chap_challenge
static

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

◆ attr_ms_chap_password

fr_dict_attr_t const* attr_ms_chap_password
static

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

◆ attr_ms_chap_response

fr_dict_attr_t const* attr_ms_chap_response
static

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

◆ attr_packet_type

fr_dict_attr_t const* attr_packet_type
static

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

◆ attr_radclient_test_name

fr_dict_attr_t const* attr_radclient_test_name
static

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

◆ attr_request_authenticator

fr_dict_attr_t const* attr_request_authenticator
static

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

◆ attr_user_name

fr_dict_attr_t const* attr_user_name
static

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

◆ attr_user_password

fr_dict_attr_t const* attr_user_password
static

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

◆ autofree

TALLOC_CTX* autofree = NULL
static

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

◆ bio

fr_bio_t* bio = NULL
static

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

◆ client_bio

fr_bio_packet_t* client_bio = NULL
static

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

◆ client_config

fr_radius_client_config_t client_config
static

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

◆ client_info

fr_radius_client_bio_info_t const* client_info = NULL
static

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

◆ current

rc_request_t* current = NULL
static

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

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

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

◆ dict_radius

fr_dict_t const* dict_radius
static

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

◆ fd_info

fr_bio_fd_info_t const* fd_info = NULL
static

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

◆ forced_id

int forced_id = -1
static

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

◆ ipproto

int ipproto = IPPROTO_UDP
static

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

◆ packet_code

int packet_code = FR_RADIUS_CODE_UNDEFINED
static

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

◆ parallel

size_t parallel = 1
static

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

◆ paused

bool paused = false
static

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

◆ print_filename

bool print_filename = false
static

Definition at line 76 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
Definition: radclient-ng.c:101
static fr_dict_t const * dict_radius
Definition: radclient-ng.c:102

Definition at line 107 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_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-ng.c:124
static fr_dict_attr_t const * attr_request_authenticator
Definition: radclient-ng.c:120
static fr_dict_attr_t const * attr_user_password
Definition: radclient-ng.c:126
static fr_dict_attr_t const * attr_chap_password
Definition: radclient-ng.c:122
static fr_dict_attr_t const * attr_ms_chap_response
Definition: radclient-ng.c:117
static fr_dict_attr_t const * attr_ms_chap_challenge
Definition: radclient-ng.c:115
static fr_dict_attr_t const * attr_chap_challenge
Definition: radclient-ng.c:123
static fr_dict_attr_t const * attr_cleartext_password
Definition: radclient-ng.c:113
static fr_dict_attr_t const * attr_radclient_test_name
Definition: radclient-ng.c:119
static fr_dict_attr_t const * attr_user_name
Definition: radclient-ng.c:125
static fr_dict_attr_t const * attr_ms_chap_password
Definition: radclient-ng.c:116

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

◆ radclient_version

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

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

◆ rc_request_list

fr_dlist_head_t rc_request_list
static

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

◆ resend_count

int resend_count = 1
static

Definition at line 75 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 816 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 72 of file radclient-ng.c.