The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Typedefs | Functions | Variables
proto_cron_crontab.c File Reference

Generate crontab events. More...

#include <netdb.h>
#include <fcntl.h>
#include <freeradius-devel/server/protocol.h>
#include <freeradius-devel/io/application.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/schedule.h>
#include "lib/server/cf_util.h"
#include "proto_cron.h"
+ Include dependency graph for proto_cron_crontab.c:

Go to the source code of this file.

Data Structures

struct  cron_tab_t
 
struct  proto_cron_crontab_thread_t
 
struct  proto_cron_tab_s
 

Typedefs

typedef struct proto_cron_tab_s proto_cron_crontab_t
 

Functions

static void do_cron (fr_event_list_t *el, fr_time_t now, void *uctx)
 
static bool get_next (struct tm *tm, cron_tab_t const *tab)
 
static fr_client_tmod_client_find (fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
 
static int mod_decode (void const *instance, request_t *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
 Decode the packet. More...
 
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. 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 crontab listener. More...
 
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 ssize_t mod_write (UNUSED fr_listen_t *li, UNUSED void *packet_ctx, UNUSED fr_time_t request_time, UNUSED uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
 
static int parse_field (CONF_ITEM *ci, char const **start, char const *name, cron_tab_t *tab, unsigned int min, unsigned int max, size_t offset)
 
static int time_parse (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int time_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Checks the syntax of a cron job. More...
 

Variables

static const conf_parser_t crontab_listen_config []
 
fr_app_io_t proto_cron_crontab
 
static fr_table_ptr_sorted_t time_names []
 
static size_t time_names_len = NUM_ELEMENTS(time_names)
 

Detailed Description

Generate crontab events.

Id
575f50afcdffbc705d7edef3bebb566776ddcc4e

Definition in file proto_cron_crontab.c.


Data Structure Documentation

◆ cron_tab_t

struct cron_tab_t

Definition at line 3 of file cron.h.

Data Fields
uint64_t fields
unsigned int max
unsigned int min
size_t offset
bool wildcard

◆ proto_cron_crontab_thread_t

struct proto_cron_crontab_thread_t

Definition at line 38 of file proto_cron_crontab.c.

+ Collaboration diagram for proto_cron_crontab_thread_t:
Data Fields
bool bootstrap get it started
fr_event_list_t * el event list
fr_event_timer_t const * ev for writing statistics
proto_cron_crontab_t const * inst
char const * name socket name
fr_network_t * nr network handler
fr_listen_t * parent master IO handler
fr_time_t recv_time when the timer hit.
bool suspended we suspend reading from the FD.

◆ proto_cron_tab_s

struct proto_cron_tab_s

Definition at line 66 of file proto_cron_crontab.c.

+ Collaboration diagram for proto_cron_tab_s:
Data Fields
fr_client_t * client static client
int code
CONF_SECTION * cs our configuration
fr_dict_t const * dict our namespace.
char const * filename where to read input packet from
fr_pair_list_t pair_list for input packet
proto_cron_t * parent
char const * spec crontab spec
cron_tab_t tab[5]

Typedef Documentation

◆ proto_cron_crontab_t

Definition at line 34 of file proto_cron_crontab.c.

Function Documentation

◆ do_cron()

static void do_cron ( fr_event_list_t el,
fr_time_t  now,
void *  uctx 
)
static

Definition at line 522 of file proto_cron_crontab.c.

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

◆ get_next()

static bool get_next ( struct tm *  tm,
cron_tab_t const *  tab 
)
static

Definition at line 478 of file proto_cron_crontab.c.

+ Here is the caller graph for this function:

◆ mod_client_find()

static fr_client_t* mod_client_find ( fr_listen_t li,
UNUSED fr_ipaddr_t const *  ipaddr,
UNUSED int  ipproto 
)
static

Definition at line 682 of file proto_cron_crontab.c.

◆ mod_decode()

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

Decode the packet.

Definition at line 431 of file proto_cron_crontab.c.

+ Here is the call graph for this function:

◆ mod_event_list_set()

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

Set the event list for a new socket.

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

Definition at line 662 of file proto_cron_crontab.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 689 of file proto_cron_crontab.c.

+ Here is the call graph for this function:

◆ mod_name()

static char const* mod_name ( fr_listen_t li)
static

Definition at line 675 of file proto_cron_crontab.c.

◆ mod_open()

static int mod_open ( fr_listen_t li)
static

Open a crontab listener.

Definition at line 401 of file proto_cron_crontab.c.

+ Here is the call graph for this function:

◆ mod_read()

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

Definition at line 331 of file proto_cron_crontab.c.

+ Here is the call graph for this function:

◆ mod_write()

static ssize_t mod_write ( UNUSED fr_listen_t li,
UNUSED void *  packet_ctx,
UNUSED fr_time_t  request_time,
UNUSED uint8_t buffer,
size_t  buffer_len,
UNUSED size_t  written 
)
static

Definition at line 391 of file proto_cron_crontab.c.

◆ parse_field()

static int parse_field ( CONF_ITEM ci,
char const **  start,
char const *  name,
cron_tab_t tab,
unsigned int  min,
unsigned int  max,
size_t  offset 
)
static

Definition at line 99 of file proto_cron_crontab.c.

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

◆ time_parse() [1/2]

static int time_parse ( TALLOC_CTX *  ctx,
void *  out,
UNUSED void *  parent,
CONF_ITEM ci,
conf_parser_t const *  rule 
)
static

◆ time_parse() [2/2]

static int time_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM ci,
UNUSED conf_parser_t const *  rule 
)
static

Checks the syntax of a cron job.

Parameters
[in]ctxto allocate data in (instance of proto_cron).
[out]outWhere to write a module_instance_t containing the module handle and instance.
[in]parentBase structure address.
[in]ciCONF_PAIR specifying the name of the type module.
[in]ruleunused.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 286 of file proto_cron_crontab.c.

+ Here is the call graph for this function:

Variable Documentation

◆ crontab_listen_config

const conf_parser_t crontab_listen_config[]
static
Initial value:
= {
.func = time_parse },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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
@ CONF_FLAG_FILE_INPUT
File matching value must exist, and must be readable.
Definition: cf_parse.h:411
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition: cf_parse.h:420
static int time_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)

Definition at line 87 of file proto_cron_crontab.c.

◆ proto_cron_crontab

fr_app_io_t proto_cron_crontab
Initial value:
= {
.common = {
.name = "cron_crontab",
.inst_size = sizeof(proto_cron_crontab_t),
.thread_inst_size = sizeof(proto_cron_crontab_thread_t),
.instantiate = mod_instantiate
},
.default_message_size = 4096,
.track_duplicates = false,
.open = mod_open,
.read = mod_read,
.write = mod_write,
.event_list_set = mod_event_list_set,
.client_find = mod_client_find,
.get_name = mod_name,
.decode = mod_decode,
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t crontab_listen_config[]
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 int mod_decode(void const *instance, request_t *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
Decode the packet.
struct proto_cron_tab_s proto_cron_crontab_t
static ssize_t mod_write(UNUSED fr_listen_t *li, UNUSED void *packet_ctx, UNUSED fr_time_t request_time, UNUSED uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
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 crontab listener.
static char const * mod_name(fr_listen_t *li)
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)

Definition at line 739 of file proto_cron_crontab.c.

◆ time_names

fr_table_ptr_sorted_t time_names[]
static
Initial value:
= {
{ L("annually"), "0 0 1 1 *" },
{ L("daily"), "0 0 * * *" },
{ L("hourly"), "0 * * * *" },
{ L("midnight"), "0 0 * * *" },
{ L("monthly"), "0 0 1 * *" },
{ L("weekly"), "0 0 * * 0" },
{ L("yearly"), "0 0 1 1 *" },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

Definition at line 263 of file proto_cron_crontab.c.

◆ time_names_len

size_t time_names_len = NUM_ELEMENTS(time_names)
static

Definition at line 273 of file proto_cron_crontab.c.