The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Functions | Variables
cron.c File Reference
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/unlang/base.h>
#include <freeradius-devel/util/debug.h>
#include "proto_cron.h"
+ Include dependency graph for cron.c:

Go to the source code of this file.

Functions

static int mod_instantiate (void *instance, CONF_SECTION *conf)
 Instantiate the application. More...
 
static int mod_open (void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
 Open listen sockets/connect to external event source. More...
 
static int parse_field (CONF_ITEM *ci, char const **start, char const *name, unsigned int min, unsigned int max)
 
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, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Checks the syntax of a cron job. More...
 
static int type_parse (TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 
static int type_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Translates the packet-type into a submodule name. More...
 

Variables

static fr_dict_t const * dict_cron
 
static conf_parser_t const limit_config []
 
fr_app_t proto_cron
 
static conf_parser_t const proto_cron_config []
 How to parse a CRON listen section. More...
 
fr_dict_autoload_t proto_cron_dict []
 
static fr_table_ptr_sorted_t time_names []
 
static size_t time_names_len = NUM_ELEMENTS(time_names)
 

Function Documentation

◆ mod_instantiate()

static int mod_instantiate ( void *  instance,
CONF_SECTION conf 
)
static

Instantiate the application.

Instantiate I/O and type submodules.

Parameters
[in]instanceCtx data for this application.
[in]confListen section parsed to give us instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 395 of file cron.c.

+ Here is the call graph for this function:

◆ mod_open()

static int mod_open ( void *  instance,
fr_schedule_t sc,
UNUSED CONF_SECTION conf 
)
static

Open listen sockets/connect to external event source.

Parameters
[in]instanceCtx data for this application.
[in]scto add our file descriptor to.
[in]confListen section parsed to give us instance.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 334 of file cron.c.

+ Here is the call graph for this function:

◆ parse_field()

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

Definition at line 124 of file cron.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,
UNUSED 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.

https://github.com/staticlibs/ccronexpr/blob/master/ccronexpr.c

Definition at line 279 of file cron.c.

+ Here is the call graph for this function:

◆ type_parse() [1/2]

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

◆ type_parse() [2/2]

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

Translates the packet-type into a submodule name.

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 81 of file cron.c.

+ Here is the call graph for this function:

Variable Documentation

◆ dict_cron

fr_dict_t const* dict_cron
static

Definition at line 62 of file cron.c.

◆ limit_config

conf_parser_t const limit_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("max_packet_size", proto_cron_t, max_packet_size) } ,
{ FR_CONF_OFFSET("num_messages", proto_cron_t, num_messages) } ,
}
#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

Definition at line 34 of file cron.c.

◆ proto_cron

fr_app_t proto_cron
Initial value:
= {
.magic = RLM_MODULE_INIT,
.name = "cron",
.config = proto_cron_config,
.inst_size = sizeof(proto_cron_t),
.open = mod_open,
}
static int mod_instantiate(void *instance, CONF_SECTION *conf)
Instantiate the application.
Definition: cron.c:395
static conf_parser_t const proto_cron_config[]
How to parse a CRON listen section.
Definition: cron.c:47
static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf)
Open listen sockets/connect to external event source.
Definition: cron.c:334
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1302

Definition at line 436 of file cron.c.

◆ proto_cron_config

conf_parser_t const proto_cron_config[]
static
Initial value:
= {
type), .func = type_parse },
.func = time_parse },
{ FR_CONF_OFFSET("priority", proto_cron_t, priority) },
{ FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
}
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#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
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:399
#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
Definition: cf_parse.h:241
static conf_parser_t const limit_config[]
Definition: cron.c:34
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
static int time_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
@ FR_TYPE_VOID
User data.
Definition: merged_model.c:127
fr_aka_sim_id_type_t type

How to parse a CRON listen section.

Definition at line 47 of file cron.c.

◆ proto_cron_dict

fr_dict_autoload_t proto_cron_dict
Initial value:
= {
{ .out = &dict_cron, .proto = "freeradius" },
{ NULL }
}
static fr_dict_t const * dict_cron
Definition: cron.c:62

Definition at line 65 of file cron.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("reboot"), "+" },
{ L("shutdown"), "-" },
{ L("startup"), "+" },
{ 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 252 of file cron.c.

◆ time_names_len

size_t time_names_len = NUM_ELEMENTS(time_names)
static

Definition at line 264 of file cron.c.