The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
rlm_detail.c File Reference

Write plaintext versions of packets to flatfiles. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/exfile.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/perm.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
+ Include dependency graph for rlm_detail.c:

Go to the source code of this file.

Data Structures

struct  rlm_detail_env_t
 
struct  rlm_detail_t
 Instance configuration for rlm_detail. More...
 

Macros

#define WRITE(fmt, ...)
 

Functions

static int call_env_filename_parse (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
 
static int call_env_suppress_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
 
static int8_t detail_cmp (void const *a, void const *b)
 
static unlang_action_t detail_do (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request, fr_packet_t *packet, fr_pair_list_t *list)
 
static void detail_fr_pair_fprint (TALLOC_CTX *ctx, FILE *out, fr_pair_t const *stacked)
 
static uint32_t detail_hash (void const *data)
 
static int detail_recurse (FILE *out, fr_hash_table_t *ht, fr_pair_list_t *list)
 
static int detail_write (FILE *out, rlm_detail_t const *inst, request_t *request, fr_value_box_t *header, fr_packet_t *packet, fr_pair_list_t *list, fr_hash_table_t *ht)
 Write a single detail entry to file pointer.
 
static int fr_pair_fprint (FILE *fp, fr_pair_t const *vp)
 Print one attribute and value to FP.
 
static unlang_action_t mod_accounting (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static unlang_action_t mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static unlang_action_t mod_post_auth (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 

Variables

static fr_dict_attr_t const * attr_net
 
static fr_dict_attr_t const * attr_net_dst_address
 
static fr_dict_attr_t const * attr_net_dst_port
 
static fr_dict_attr_t const * attr_net_src_address
 
static fr_dict_attr_t const * attr_net_src_port
 
static fr_dict_t const * dict_freeradius
 
static fr_dict_t const * dict_radius
 
static const call_env_method_t method_env
 
static const conf_parser_t module_config []
 
module_rlm_t rlm_detail
 
fr_dict_autoload_t rlm_detail_dict []
 
fr_dict_attr_autoload_t rlm_detail_dict_attr []
 

Detailed Description

Write plaintext versions of packets to flatfiles.

Id
d3b2c0e86c4cdab26bb342e24bb2d7c954faa9f7

Definition in file rlm_detail.c.


Data Structure Documentation

◆ rlm_detail_env_t

struct rlm_detail_env_t

Definition at line 63 of file rlm_detail.c.

+ Collaboration diagram for rlm_detail_env_t:
Data Fields
fr_value_box_t filename File / path to write to.
tmpl_t * filename_tmpl tmpl used to expand filename (for debug output)
fr_value_box_t header Header format.
fr_hash_table_t * ht Holds suppressed attributes.

◆ rlm_detail_t

struct rlm_detail_t

Instance configuration for rlm_detail.

Holds the configuration and preparsed data for a instance of rlm_detail.

Definition at line 49 of file rlm_detail.c.

+ Collaboration diagram for rlm_detail_t:
Data Fields
exfile_t * ef Log file handler.
bool escape do filename escaping, yes / no
gid_t group Resolved group.
bool group_is_set Whether group was set.
bool locking Whether the file should be locked.
bool log_srcdst Add IP src/dst attributes to entries.
mode_t perm Permissions to use for new files.

Macro Definition Documentation

◆ WRITE

#define WRITE (   fmt,
  ... 
)
Value:
do { \
if (fprintf(out, fmt, ## __VA_ARGS__) < 0) goto fail; \
} while(0)
while(1)
Definition acutest.h:856
static int const char * fmt
Definition acutest.h:573
static size_t char ** out
Definition value.h:1012

Function Documentation

◆ call_env_filename_parse()

static int call_env_filename_parse ( TALLOC_CTX *  ctx,
void *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
call_env_ctx_t const *  cec,
UNUSED call_env_parser_t const *  rule 
)
static

Definition at line 384 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ call_env_suppress_parse()

static int call_env_suppress_parse ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
UNUSED call_env_ctx_t const *  cec,
UNUSED call_env_parser_t const *  rule 
)
static

Definition at line 412 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ detail_cmp()

static int8_t detail_cmp ( void const *  a,
void const *  b 
)
static

Definition at line 147 of file rlm_detail.c.

+ Here is the caller graph for this function:

◆ detail_do()

static unlang_action_t detail_do ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request,
fr_packet_t packet,
fr_pair_list_t list 
)
static

Definition at line 303 of file rlm_detail.c.

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

◆ detail_fr_pair_fprint()

static void detail_fr_pair_fprint ( TALLOC_CTX *  ctx,
FILE *  out,
fr_pair_t const *  stacked 
)
static

Definition at line 172 of file rlm_detail.c.

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

◆ detail_hash()

static uint32_t detail_hash ( void const *  data)
static

Definition at line 141 of file rlm_detail.c.

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

◆ detail_recurse()

static int detail_recurse ( FILE *  out,
fr_hash_table_t ht,
fr_pair_list_t list 
)
static

Definition at line 185 of file rlm_detail.c.

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

◆ detail_write()

static int detail_write ( FILE *  out,
rlm_detail_t const *  inst,
request_t request,
fr_value_box_t header,
fr_packet_t packet,
fr_pair_list_t list,
fr_hash_table_t ht 
)
static

Write a single detail entry to file pointer.

Parameters
[in]outWhere to write entry.
[in]instInstance of rlm_detail.
[in]requestThe current request.
[in]headerTo print above packet
[in]packetassociated with the request (request, reply...).
[in]listof pairs to write.
[in]htHash table containing attributes to be suppressed in the output.

Definition at line 211 of file rlm_detail.c.

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

◆ fr_pair_fprint()

static int fr_pair_fprint ( FILE *  fp,
fr_pair_t const *  vp 
)
static

Print one attribute and value to FP.

Complete string with '\t' and '\n' is written to buffer before printing to avoid issues when running with multiple threads.

Todo:
  • This function should print flattened lists.
Parameters
fpto output to.
vpto print.
Returns
  • >=0 on success
  • <0 on error

Definition at line 123 of file rlm_detail.c.

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

◆ mod_accounting()

static unlang_action_t mod_accounting ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 363 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ mod_authorize()

static unlang_action_t mod_authorize ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 371 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 155 of file rlm_detail.c.

+ Here is the call graph for this function:

◆ mod_post_auth()

static unlang_action_t mod_post_auth ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 379 of file rlm_detail.c.

+ Here is the call graph for this function:

Variable Documentation

◆ attr_net

fr_dict_attr_t const* attr_net
static

Definition at line 93 of file rlm_detail.c.

◆ attr_net_dst_address

fr_dict_attr_t const* attr_net_dst_address
static

Definition at line 95 of file rlm_detail.c.

◆ attr_net_dst_port

fr_dict_attr_t const* attr_net_dst_port
static

Definition at line 97 of file rlm_detail.c.

◆ attr_net_src_address

fr_dict_attr_t const* attr_net_src_address
static

Definition at line 94 of file rlm_detail.c.

◆ attr_net_src_port

fr_dict_attr_t const* attr_net_src_port
static

Definition at line 96 of file rlm_detail.c.

◆ dict_freeradius

fr_dict_t const* dict_freeradius
static

Definition at line 83 of file rlm_detail.c.

◆ dict_radius

fr_dict_t const* dict_radius
static

Definition at line 84 of file rlm_detail.c.

◆ method_env

const call_env_method_t method_env
static
Initial value:
= {
.env = (call_env_parser_t[]){
.pair.func = call_env_filename_parse },
.pair.dflt = "%t", .pair.dflt_quote = T_DOUBLE_QUOTED_STRING },
}
}
#define CALL_ENV_TERMINATOR
Definition call_env.h:236
#define FR_CALL_ENV_PARSE_OFFSET(_name, _cast_type, _flags, _struct, _field, _parse_field)
Specify a call_env_parser_t which writes out runtime results and the result of the parsing phase to t...
Definition call_env.h:365
#define FR_CALL_ENV_METHOD_OUT(_inst)
Helper macro for populating the size/type fields of a call_env_method_t from the output structure typ...
Definition call_env.h:240
@ CALL_ENV_FLAG_CONCAT
If the tmpl produced multiple boxes they should be concatenated.
Definition call_env.h:76
@ CALL_ENV_FLAG_NONE
Definition call_env.h:74
@ CALL_ENV_FLAG_REQUIRED
Associated conf pair or section is required.
Definition call_env.h:75
#define FR_CALL_ENV_SUBSECTION_FUNC(_name, _name2, _flags, _func)
Specify a call_env_parser_t which parses a subsection using a callback function.
Definition call_env.h:412
#define FR_CALL_ENV_OFFSET(_name, _cast_type, _flags, _struct, _field)
Specify a call_env_parser_t which writes out runtime results to the specified field.
Definition call_env.h:340
Per method call config.
Definition call_env.h:180
@ FR_TYPE_STRING
String of printable characters.
static int call_env_filename_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
Definition rlm_detail.c:384
static int call_env_suppress_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule)
Definition rlm_detail.c:412
@ T_DOUBLE_QUOTED_STRING
Definition token.h:121

Definition at line 472 of file rlm_detail.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("permissions", rlm_detail_t, perm), .dflt = "0600", .func = cf_parse_permissions },
{ FR_CONF_OFFSET_IS_SET("group", FR_TYPE_VOID, 0, rlm_detail_t, group), .func = cf_parse_gid },
{ FR_CONF_OFFSET("locking", rlm_detail_t, locking), .dflt = "no" },
{ FR_CONF_OFFSET("escape_filenames", rlm_detail_t, escape), .dflt = "no" },
{ FR_CONF_OFFSET("log_packet_header", rlm_detail_t, log_srcdst), .dflt = "no" },
}
int cf_parse_gid(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Generic function for resolving GID strings to uid_t values.
Definition cf_parse.c:1659
int cf_parse_permissions(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Generic function for resolving permissions to a mode-t.
Definition cf_parse.c:1674
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:658
#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
Definition cf_parse.h:284
#define FR_CONF_OFFSET_IS_SET(_name, _type, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct,...
Definition cf_parse.h:298
@ FR_TYPE_VOID
User data.
Instance configuration for rlm_detail.
Definition rlm_detail.c:49

Definition at line 74 of file rlm_detail.c.

◆ rlm_detail

module_rlm_t rlm_detail
Initial value:
= {
.common = {
.name = "detail",
.inst_size = sizeof(rlm_detail_t),
},
.method_group = {
.bindings = (module_method_binding_t[]){
{ .section = SECTION_NAME("accounting", CF_IDENT_ANY), .method = mod_accounting, .method_env = &method_env },
{ .section = SECTION_NAME("recv", "accounting-request"), .method = mod_accounting, .method_env = &method_env },
{ .section = SECTION_NAME("send", "accounting-response"), .method = mod_accounting, .method_env = &method_env },
{ .section = SECTION_NAME("recv", CF_IDENT_ANY), .method = mod_authorize, .method_env = &method_env },
{ .section = SECTION_NAME("send", CF_IDENT_ANY), .method = mod_post_auth, .method_env = &method_env },
}
}
}
#define CF_IDENT_ANY
Definition cf_util.h:78
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
static const conf_parser_t config[]
Definition base.c:183
static const call_env_method_t method_env
Definition rlm_detail.c:472
static unlang_action_t mod_accounting(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition rlm_detail.c:363
static unlang_action_t mod_authorize(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition rlm_detail.c:371
static const conf_parser_t module_config[]
Definition rlm_detail.c:74
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition rlm_detail.c:155
static unlang_action_t mod_post_auth(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition rlm_detail.c:379
static int instantiate(module_inst_ctx_t const *mctx)
Definition rlm_rest.c:1313
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition section.h:40
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition module.h:151
Named methods exported by a module.
Definition module.h:173

Definition at line 486 of file rlm_detail.c.

◆ rlm_detail_dict

fr_dict_autoload_t rlm_detail_dict
Initial value:
= {
{ .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_radius, .proto = "radius" },
{ NULL }
}
static fr_dict_t const * dict_freeradius
Definition rlm_detail.c:83
static fr_dict_t const * dict_radius
Definition rlm_detail.c:84

Definition at line 87 of file rlm_detail.c.

◆ rlm_detail_dict_attr

fr_dict_attr_autoload_t rlm_detail_dict_attr
Initial value:
= {
{ .out = &attr_net, .name = "Net", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
{ .out = &attr_net_dst_address, .name = "Net.Dst.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
{ .out = &attr_net_dst_port, .name = "Net.Dst.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
{ .out = &attr_net_src_address, .name = "Net.Src.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius },
{ .out = &attr_net_src_port, .name = "Net.Src.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
{ NULL }
}
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
static fr_dict_attr_t const * attr_net_dst_port
Definition rlm_detail.c:97
static fr_dict_attr_t const * attr_net
Definition rlm_detail.c:93
static fr_dict_attr_t const * attr_net_src_address
Definition rlm_detail.c:94
static fr_dict_attr_t const * attr_net_dst_address
Definition rlm_detail.c:95
static fr_dict_attr_t const * attr_net_src_port
Definition rlm_detail.c:96

Definition at line 100 of file rlm_detail.c.