The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Typedefs | Functions | Variables
proto_detail_file.c File Reference

Detail handler for files. More...

#include <freeradius-devel/io/application.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/schedule.h>
#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/server/protocol.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/misc.h>
#include "proto_detail.h"
#include <netdb.h>
#include <fcntl.h>
#include <sys/stat.h>
+ Include dependency graph for proto_detail_file.c:

Go to the source code of this file.

Macros

#define MPRINT   DEBUG3
 

Typedefs

typedef struct proto_detail_work_s proto_detail_file_t
 
typedef struct proto_detail_work_thread_s proto_detail_file_thread_t
 

Functions

static int8_t _detail_file_cmp (void const *one, void const *two)
 Compare two thread instances based on node pointer. More...
 
static int mod_close (fr_listen_t *li)
 
static int mod_decode (void const *instance, request_t *request, uint8_t *const data, size_t data_len)
 
static void mod_event_list_set (fr_listen_t *li, fr_event_list_t *el, UNUSED void *nr)
 Set the event list for a new IO instance. More...
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 
static char const * mod_name (fr_listen_t *li)
 
static int mod_open (fr_listen_t *li)
 Open a detail listener. More...
 
static void mod_vnode_delete (fr_event_list_t *el, int fd, UNUSED int fflags, void *ctx)
 
static void mod_vnode_extend (fr_listen_t *li, UNUSED uint32_t fflags)
 
static int work_exists (proto_detail_file_thread_t *thread, int fd)
 
static void work_init (proto_detail_file_thread_t *thread, bool triggered_by_delete)
 Start processing a new work file. More...
 
static int work_rename (proto_detail_file_thread_t *thread)
 
static void work_retry_timer (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 

Variables

static pthread_mutex_t detail_file_mutex = PTHREAD_MUTEX_INITIALIZER
 
static fr_rb_tree_tdetail_file_tree = NULL
 
static const conf_parser_t file_listen_config []
 
fr_app_io_t proto_detail_file
 Private interface for use by proto_detail_file. More...
 

Detailed Description

Detail handler for files.

Id
663ba8cb66b7a74d2df732c017d59da4a2575d7e

Definition in file proto_detail_file.c.

Macro Definition Documentation

◆ MPRINT

#define MPRINT   DEBUG3

Definition at line 57 of file proto_detail_file.c.

Typedef Documentation

◆ proto_detail_file_t

Definition at line 1 of file proto_detail_file.c.

◆ proto_detail_file_thread_t

Definition at line 1 of file proto_detail_file.c.

Function Documentation

◆ _detail_file_cmp()

static int8_t _detail_file_cmp ( void const *  one,
void const *  two 
)
static

Compare two thread instances based on node pointer.

Parameters
[in]oneFirst thread specific xlat expansion instance.
[in]twoSecond thread specific xlat expansion instance.
Returns
CMP(one, two)

Definition at line 634 of file proto_detail_file.c.

+ Here is the caller graph for this function:

◆ mod_close()

static int mod_close ( fr_listen_t li)
static

Definition at line 743 of file proto_detail_file.c.

+ Here is the call graph for this function:

◆ mod_decode()

static int mod_decode ( void const *  instance,
request_t request,
uint8_t *const  data,
size_t  data_len 
)
static

Definition at line 90 of file proto_detail_file.c.

◆ mod_event_list_set()

static void mod_event_list_set ( fr_listen_t li,
fr_event_list_t el,
UNUSED void *  nr 
)
static

Set the event list for a new IO instance.

Parameters
[in]lithe listener
[in]elthe event list
[in]nrcontext from the network side

Definition at line 591 of file proto_detail_file.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 644 of file proto_detail_file.c.

+ Here is the call graph for this function:

◆ mod_name()

static char const* mod_name ( fr_listen_t li)
static

Definition at line 617 of file proto_detail_file.c.

◆ mod_open()

static int mod_open ( fr_listen_t li)
static

Open a detail listener.

Definition at line 133 of file proto_detail_file.c.

+ Here is the call graph for this function:

◆ mod_vnode_delete()

static void mod_vnode_delete ( fr_event_list_t el,
int  fd,
UNUSED int  fflags,
void *  ctx 
)
static

Definition at line 429 of file proto_detail_file.c.

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

◆ mod_vnode_extend()

static void mod_vnode_extend ( fr_listen_t li,
UNUSED uint32_t  fflags 
)
static

Definition at line 113 of file proto_detail_file.c.

+ Here is the call graph for this function:

◆ work_exists()

static int work_exists ( proto_detail_file_thread_t thread,
int  fd 
)
static

Definition at line 244 of file proto_detail_file.c.

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

◆ work_init()

static void work_init ( proto_detail_file_thread_t thread,
bool  triggered_by_delete 
)
static

Start processing a new work file.

Parameters
[in]threadthe thread instance.
[in]triggered_by_deletetrue if this was triggered by a vnode_delete. When a new file is moved over a workfile vnode delete can serve as an indication that new data is available. It can also mean however, that the file has just been deleted, so we shouldn't treat this failure to open the new file as a fatal error.

Definition at line 478 of file proto_detail_file.c.

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

◆ work_rename()

static int work_rename ( proto_detail_file_thread_t thread)
static

Definition at line 169 of file proto_detail_file.c.

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

◆ work_retry_timer()

static void work_retry_timer ( UNUSED fr_event_list_t el,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Definition at line 234 of file proto_detail_file.c.

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

Variable Documentation

◆ detail_file_mutex

pthread_mutex_t detail_file_mutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 626 of file proto_detail_file.c.

◆ detail_file_tree

fr_rb_tree_t* detail_file_tree = NULL
static

Definition at line 625 of file proto_detail_file.c.

◆ file_listen_config

const conf_parser_t file_listen_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("filename_work", proto_detail_file_t, filename_work ) },
{ FR_CONF_OFFSET("poll_interval", proto_detail_file_t, poll_interval), .dflt = "5" },
{ FR_CONF_OFFSET("immediate", proto_detail_file_t, immediate) },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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:268
#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
Definition: cf_parse.h:256
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition: cf_parse.h:405

Definition at line 74 of file proto_detail_file.c.

◆ proto_detail_file

fr_app_io_t proto_detail_file
Initial value:
= {
.common = {
.name = "detail_file",
.config = file_listen_config,
.inst_size = sizeof(proto_detail_file_t),
.thread_inst_size = sizeof(proto_detail_file_thread_t),
.instantiate = mod_instantiate,
},
.default_message_size = 65536,
.default_reply_size = 32,
.open = mod_open,
.close = mod_close,
.vnode = mod_vnode_extend,
.decode = mod_decode,
.event_list_set = mod_event_list_set,
.get_name = mod_name,
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static void mod_vnode_extend(fr_listen_t *li, UNUSED uint32_t fflags)
static const conf_parser_t file_listen_config[]
struct proto_detail_work_s proto_detail_file_t
static int mod_decode(void const *instance, request_t *request, uint8_t *const data, size_t data_len)
static int mod_open(fr_listen_t *li)
Open a detail listener.
static char const * mod_name(fr_listen_t *li)
static void mod_event_list_set(fr_listen_t *li, fr_event_list_t *el, UNUSED void *nr)
Set the event list for a new IO instance.
static int mod_close(fr_listen_t *li)
static int mod_instantiate(module_inst_ctx_t const *mctx)

Private interface for use by proto_detail_file.

Definition at line 779 of file proto_detail_file.c.