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> 
   29#include <freeradius-devel/util/pair_legacy.h> 
   31#include <freeradius-devel/server/dl_module.h> 
   32#include <freeradius-devel/server/module.h> 
   33#include <freeradius-devel/server/module_rlm.h> 
  127                cf_log_err(ci, 
"Please define 'namespace' in this virtual server");
 
  132        if (!
inst->attr_packet_type) {
 
  133                cf_log_err(ci, 
"Failed to find 'Packet-Type' attribute");
 
  148        inst->code = type_enum->
value->vb_uint32;
 
 
  163        if (strcmp(
inst->io_submodule->module->dl->name, 
"proto_detail_work") != 0) {
 
  166                char const              *inst_name;
 
  168                inst->work_submodule = NULL;
 
  176                                                      "work", NULL, 
false);
 
  178                                cf_log_err(mi->
conf, 
"Failed to create configuration for worker");
 
  194                                                             "work", inst_name, 0);
 
  195                if (
inst->work_submodule == NULL) {
 
  198                        TALLOC_FREE(
inst->work_submodule);
 
  205                inst->work_io_instance = 
inst->work_submodule->data;
 
  206                inst->work_io_conf = 
inst->work_submodule->conf;
 
 
  223        time_t                  timestamp = 0;
 
  228        request->packet->code = 
inst->code;
 
  233        request->packet->socket.fd = -1;
 
  234        request->packet->socket.inet.src_ipaddr.af = AF_INET;
 
  235        request->packet->socket.inet.src_ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
 
  236        request->packet->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
 
  238        request->reply->socket.inet.src_ipaddr = request->packet->socket.inet.src_ipaddr;
 
  239        request->reply->socket.inet.dst_ipaddr = request->packet->socket.inet.src_ipaddr;
 
  241        end = 
data + data_len;
 
  245        if (sscanf((
char const *) 
data, 
"%*s %*s %*d %*d:%*d:%*d %d", &num) != 1) {
 
  246                REDEBUG(
"Malformed header '%s'", (
char const *) 
data);
 
  253        for (p = 
data; p < end; p++) {
 
  271                if ((end - p) < 2) 
break;
 
  278                if ((*p != 
'\0') && (*p != 
'\t')) {
 
  279                        REDEBUG(
"Malformed line %d", lineno);
 
  291                if (
strncasecmp((
char const *) p, 
"Request-Authenticator", 21) == 0) 
goto next;
 
  298                if (
strncasecmp((
char const *) p, 
"Timestamp = ", 12) == 0) {
 
  301                        timestamp = atoi((
char const *) p);
 
  314                if (
strncasecmp((
char const *) p, 
"Donestamp", 9) == 0) {
 
  353                        .
ctx = request->request_ctx,
 
  365                        RWDEBUG(
"Ignoring line %d - :%s", lineno, p);
 
  373                                request->packet->socket.inet.src_ipaddr = 
vp->vp_ip;
 
  375                                request->packet->socket.inet.dst_ipaddr = 
vp->vp_ip;
 
  377                                request->packet->socket.inet.src_port = 
vp->vp_uint16;
 
  379                                request->packet->socket.inet.dst_port = 
vp->vp_uint16;
 
  385                while ((p < end) && (*p)) p++;
 
  391        return inst->app_io->decode(
inst->app_io_instance, request, 
data, data_len);
 
 
  396        if (buffer_len < 1) 
return -1;
 
  398        *
buffer = request->reply->code;
 
 
  409        return inst->priority;
 
 
  453        if (
inst->app_io->open(li) < 0) {
 
  466        if (strcmp(
inst->io_submodule->module->dl->name, 
"proto_detail_work") == 0) {
 
  494        DEBUG(
"Listening on %s bound to virtual server %s",
 
 
  527        if (!
inst->io_submodule) {
 
  528                cf_log_err(
conf, 
"Virtual server for detail files requires a 'transport' configuration");
 
  536        inst->app_io_instance = 
inst->io_submodule->data;
 
  537        inst->app_io_conf = 
inst->io_submodule->conf;
 
  543        if (!
inst->max_packet_size) 
inst->max_packet_size = 
inst->app_io->default_message_size;
 
  545        if (!
inst->num_messages) 
inst->num_messages = 2;
 
 
static int const char char buffer[256]
module_t common
Common fields to all loadable modules.
fr_io_name_t get_name
get the socket name
Public structure describing an I/O path for a protocol.
module_t common
Common fields provided by all modules.
Describes a new application (protocol)
#define CONF_PARSER_TERMINATOR
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
#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.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
CONF_SECTION * cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
Duplicate a configuration section.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
#define cf_log_err(_cf, _fmt,...)
#define cf_log_perr(_cf, _fmt,...)
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
static void * fr_dcursor_tail(fr_dcursor_t *cursor)
Wind cursor to the tail item in the list.
static void fr_dcursor_free_list(fr_dcursor_t *cursor)
Free the current item and all items after it.
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_dict_attr_t const  ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const  ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
fr_value_box_t const  * value
Enum value (what name maps to).
#define DICT_AUTOLOAD_TERMINATOR
fr_dict_enum_value_t const * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
Value of an enumerated attribute.
@ DL_MODULE_TYPE_SUBMODULE
Driver (or method in the case of EAP)
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
size_t num_messages
for the message ring buffer
bool non_socket_listener
special internal listener that does not use sockets.
char const  * name
printable name for this socket - set by open
void const  * app_instance
size_t default_message_size
copied from app_io, but may be changed
void const  * app_io_instance
I/O path configuration context.
int fr_io_listen_free(fr_listen_t *li)
CONF_SECTION * server_cs
CONF_SECTION of the server.
void * thread_instance
thread / socket context
fr_app_io_t const  * app_io
I/O path functions.
#define RHEXDUMP3(_data, _len, _fmt,...)
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
int strncasecmp(char *s1, char *s2, int n)
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
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.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t *relative, fr_sbuff_t *in)
Parse a fr_pair_list_t from a substring.
struct fr_pair_parse_s fr_pair_parse_t
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_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
Open listen sockets/connect to external event source.
static fr_dict_attr_t const  * attr_packet_src_port
static fr_dict_t const  * dict_freeradius
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 fr_dict_attr_t const  * attr_packet_original_timestamp
static int mod_priority_set(void const *instance, UNUSED uint8_t const *buffer, UNUSED size_t buflen)
fr_dict_attr_autoload_t proto_detail_dict_attr[]
fr_dict_autoload_t proto_detail_dict[]
static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static fr_dict_attr_t const  * attr_packet_dst_ip_address
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the application.
static fr_dict_attr_t const  * attr_packet_src_ip_address
static fr_dict_attr_t const  * attr_packet_dst_port
static conf_parser_t const proto_detail_config[]
How to parse a Detail listen section.
Detail master protocol handler.
#define FR_SBUFF_IN(_start, _len_or_end)
fr_network_t * fr_schedule_directory_add(fr_schedule_t *sc, fr_listen_t *li)
Add a directory NOTE_EXTEND to a scheduler.
fr_network_t * fr_schedule_listen_add(fr_schedule_t *sc, fr_listen_t *li)
Add a fr_listen_t to a scheduler.
CONF_SECTION * conf
Module's instance configuration.
void * data
Module's instance data.
module_list_t * ml
Module list this instance belongs to.
size_t thread_inst_size
Size of the module's thread-specific instance data.
conf_parser_t const  * config
How to convert a CONF_SECTION to a module instance.
static const uchar sc[16]
module_instance_t * module_instance_alloc(module_list_t *ml, module_instance_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name, module_instance_state_t init_state)
Allocate a new module and add it to a module list for later bootstrap/instantiation.
fr_slen_t module_instance_name_from_conf(char const **name, CONF_SECTION *conf)
Avoid boilerplate when setting the module instance name.
int module_instance_conf_parse(module_instance_t *mi, CONF_SECTION *conf)
Covert a CONF_SECTION into parsed module instance data.
eap_aka_sim_process_conf_t * inst
fr_aka_sim_id_type_t type
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const  *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
#define talloc_get_type_abort_const
static fr_unix_time_t fr_unix_time_from_sec(int64_t sec)
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
static size_t char ** out
module_instance_t * virtual_server_listener_by_data(void const *data)
Resolve proto data to a module instance.
int virtual_server_listen_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.
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.