27 #include <freeradius-devel/server/protocol.h>
28 #include <freeradius-devel/io/application.h>
29 #include <freeradius-devel/io/listen.h>
30 #include <freeradius-devel/io/schedule.h>
31 #include <freeradius-devel/io/load.h>
105 if (thread->
done)
return -1;
132 address = *address_p;
134 memset(address, 0,
sizeof(*address));
135 address->
socket.inet.src_ipaddr.
af = AF_INET;
136 address->
socket.inet.dst_ipaddr.
af = AF_INET;
141 if (buffer_len < 1) {
142 DEBUG2(
"proto_load_step read buffer is too small for input packet");
151 DEBUG2(
"proto_load_step - reading packet for %s",
204 li->
fd = open(
inst->filename, O_RDONLY);
206 memset(&ipaddr, 0,
sizeof(ipaddr));
213 thread->
parent = talloc_parent(li);
247 if (write(thread->
fd,
buffer, len) < 0) {
267 request->dict =
inst->dict;
272 if (
inst->code) request->packet->code =
inst->code;
273 request->packet->id =
fr_rand() & 0xff;
274 request->reply->id = request->packet->id;
276 request->packet->data = talloc_zero_array(request->packet,
uint8_t, 1);
277 request->packet->data_len = 1;
286 request->packet->socket = address->
socket;
313 if (!thread->
l)
return;
317 if (!
inst->csv)
return;
319 thread->
fd = open(
inst->csv, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);
320 if (thread->
fd < 0) {
328 if (write(thread->
fd,
buffer, len) < 0) {
350 cf_log_err(
conf,
"Please define 'namespace' in this virtual server");
356 if (!
inst->client)
return 0;
362 client->
secret = talloc_strdup(client,
"testing123");
363 client->
nas_type = talloc_strdup(client,
"load");
366 if (
inst->filename) {
370 fp = fopen(
inst->filename,
"r");
430 .default_message_size = 4096,
431 .track_duplicates =
false,
static int const char char buffer[256]
module_t common
Common fields to all loadable modules.
Public structure describing an I/O path for a protocol.
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define CONF_PARSER_TERMINATOR
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
@ CONF_FLAG_FILE_INPUT
File matching value must exist, and must be readable.
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Defines a CONF_PAIR to C data type mapping.
A section grouping multiple CONF_PAIR.
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
#define cf_log_err(_cf, _fmt,...)
#define cf_log_perr(_cf, _fmt,...)
fr_dcursor_eval_t void const * uctx
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
#define fr_event_filter_update(...)
#define FR_EVENT_SUSPEND(_s, _f)
Temporarily remove the filter for a func from kevent.
#define fr_event_timer_in(...)
Callbacks for the FR_EVENT_FILTER_IO filter.
Structure describing a modification to a filter's state.
fr_socket_t socket
src/dst ip and port.
fr_client_t const * radclient
old-style client definition
fr_socket_t * app_io_addr
for tracking duplicate sockets
void const * app_io_instance
I/O path configuration context.
void * thread_instance
thread / socket context
int fd
file descriptor for this socket - set by open
void fr_network_listen_read(fr_network_t *nr, fr_listen_t *li)
Signal the network to read from a listener.
fr_ipaddr_t ipaddr
IPv4/IPv6 address of the host.
char const * secret
Secret PSK.
fr_ipaddr_t src_ipaddr
IPv4/IPv6 address to send responses from (family must match ipaddr).
char const * nas_type
Type of client (arbitrary).
char const * longname
Client identifier.
char const * shortname
Client nickname.
bool use_connected
do we use connected sockets for this client
Describes a host allowed to send packets to the server.
Stores all information relating to an event list.
fr_load_t * fr_load_generator_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_load_config_t *config, fr_load_callback_t callback, void *uctx)
int fr_load_generator_start(fr_load_t *l)
Start the load generator.
int fr_load_generator_stop(fr_load_t *l)
Stop the load generation through the simple expedient of deleting the timer associated with it.
size_t fr_load_generator_stats_sprint(fr_load_t *l, fr_time_t now, char *buffer, size_t buflen)
Print load generator statistics in CVS format.
fr_load_reply_t fr_load_generator_have_reply(fr_load_t *l, fr_time_t request_time)
Tell the load generator that we have a reply to a packet we sent.
fr_load_reply_t
Whether or not the application should continue.
@ FR_LOAD_DONE
the load generator is done
Load generation configuration.
fr_io_address_t const * address
of this packet.. shared between multiple packets
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
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_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
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.
Load master protocol handler.
fr_app_io_t proto_load_step
fr_listen_t * parent
master IO handler
fr_client_t * client
static client
fr_pair_list_t pair_list
for input packet
fr_load_config_t load
load configuration
static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
static const conf_parser_t load_listen_config[]
CONF_SECTION * cs
our configuration
proto_load_step_t const * inst
static int mod_decode(void const *instance, request_t *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
Decode the packet.
fr_load_config_t load
load configuration
char const * filename
where to read input packet from
static void write_stats(fr_event_list_t *el, fr_time_t now, void *uctx)
uint32_t max_attributes
Limit maximum decodable attributes.
struct proto_load_step_s proto_load_step_t
char const * csv
, do we repeat the load generation
static ssize_t mod_write(fr_listen_t *li, UNUSED void *packet_ctx, fr_time_t request_time, UNUSED uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
fr_stats_t stats
statistics for this socket
static void mod_event_list_set(fr_listen_t *li, fr_event_list_t *el, void *nr)
Set the event list for a new socket.
static int mod_open(fr_listen_t *li)
Open a load listener.
fr_time_t recv_time
recv time of the last packet
fr_load_t * l
load generation handler
static char const * mod_name(fr_listen_t *li)
fr_event_timer_t const * ev
for writing statistics
fr_dict_t const * dict
Our namespace.
fr_network_t * nr
network handler
static int mod_generate(fr_time_t now, void *uctx)
Generate traffic.
fr_event_list_t * el
event list
static fr_client_t * mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
static int mod_instantiate(module_inst_ctx_t const *mctx)
char const * name
socket name
#define RADIUS_MAX_ATTRIBUTES
uint32_t fr_rand(void)
Return a 32-bit random number.
#define REQUEST_VERIFY(_x)
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
module_instance_t const * parent
Parent module's instance (if any).
fr_uint_t total_responses
eap_aka_sim_process_conf_t * inst
#define fr_time()
Allow us to arbitrarily manipulate time.
Stores an attribute, a value and various bits of other data.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...)
Call talloc vasprintf, setting the type on the new chunk correctly.
#define talloc_get_type_abort_const
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
static fr_event_list_t * el
static fr_socket_t * fr_socket_addr_alloc_inet_src(TALLOC_CTX *ctx, int proto, int ifindex, fr_ipaddr_t const *ipaddr, int port)
A variant of fr_socket_addr_init_inet_src will also allocates a fr_socket_t.
int af
AF_INET, AF_INET6, or AF_UNIX.
static void fr_socket_addr_swap(fr_socket_t *dst, fr_socket_t const *src)
Swap src/dst information of a fr_socket_t.
fr_dict_t const * virtual_server_dict_by_child_ci(CONF_ITEM const *ci)
Return the namespace for a given virtual server specified by a CONF_ITEM within the virtual server.