25 #include <freeradius-devel/io/application.h>
26 #include <freeradius-devel/io/listen.h>
27 #include <freeradius-devel/io/schedule.h>
28 #include <freeradius-devel/radius/radius.h>
83 cf_log_err(ci,
"Please define 'namespace' in this virtual server");
88 if (!
inst->attr_packet_type) {
89 cf_log_err(ci,
"Failed to find 'Packet-Type' attribute");
104 inst->code = type_enum->
value->vb_uint32;
157 request->dict =
inst->dict;
158 request->packet->code =
inst->code;
163 request->packet->socket.fd = -1;
164 request->packet->socket.inet.src_ipaddr.af = AF_INET;
165 request->packet->socket.inet.src_ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
166 request->packet->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
168 request->reply->socket.inet.src_ipaddr = request->packet->socket.inet.src_ipaddr;
169 request->reply->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
174 return inst->io.app_io->decode(
inst->io.app_io_instance, request,
data, data_len);
182 if (buffer_len < 2)
return -1;
184 buffer[0] = request->reply->code;
212 inst->io.app_instance = instance;
218 inst->max_packet_size,
inst->num_messages);
240 if (!
inst->max_packet_size &&
inst->io.app_io)
inst->max_packet_size =
inst->io.app_io->default_message_size;
242 if (!
inst->num_messages)
inst->num_messages = 256;
277 if (!
inst->io.submodule) {
278 cf_log_err(
conf,
"The load generator MUST have a 'transport = ...' set");
static int const char char buffer[256]
module_t common
Common fields to all loadable modules.
module_t common
Common fields provided by all modules.
Describes a new application (protocol)
#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
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Defines a CONF_PAIR to C data type mapping.
Common header for all CONF_* types.
Configuration AVP similar to a fr_pair_t.
A section grouping multiple CONF_PAIR.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
#define cf_log_err(_cf, _fmt,...)
#define cf_data_find(_cf, _type, _name)
#define cf_section_alloc(_ctx, _parent, _name1, _name2)
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 * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_value_box_t const * value
Enum value (what name maps to).
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Value of an enumerated attribute.
int dl_module_instance(TALLOC_CTX *ctx, dl_module_inst_t **out, dl_module_inst_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name)
Load a module and parse its CONF_SECTION in one operation.
char const * dl_module_inst_name_from_conf(CONF_SECTION *conf)
Avoid boilerplate when setting the module instance name.
dl_module_inst_t const * dl_module_instance_by_data(void const *data)
Lookup a dl_module_inst_t via instance data.
int dl_module_conf_parse(dl_module_inst_t *dl_inst, CONF_SECTION *conf)
@ DL_MODULE_TYPE_SUBMODULE
Driver (or method in the case of EAP)
void *_CONST data
Module instance's parsed configuration.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
CONF_SECTION *_CONST conf
Module's instance configuration.
fr_app_io_t fr_master_app_io
int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *sc, size_t default_message_size, size_t num_messages)
#define MODULE_INST_CTX(_dl_inst)
Wrapper to create a module_inst_ctx_t as a compound literal.
dl_module_inst_t const * inst
Dynamic loader API handle for the module.
Temporary structure to hold arguments for instantiation calls.
static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
Decode the packet, and set the request->process function.
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Bootstrap the application.
static conf_parser_t const proto_load_config[]
How to parse a Load listen section.
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Load master protocol handler.
static int instantiate(module_inst_ctx_t const *mctx)
module_instantiate_t instantiate
module_instantiate_t bootstrap
static const uchar sc[16]
eap_aka_sim_process_conf_t * inst
fr_aka_sim_id_type_t type
#define talloc_get_type_abort_const
static size_t char ** out
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.