|
Asterisk - The Open Source Telephony Project GIT-master-80b953f
|
Common logic for the CDR and CEL Custom Backends. More...

Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| struct ast_module * | AST_MODULE_SELF_SYM (void) |
| const char * | cdrel_basename (const char *path) |
| enum cdrel_data_type | cdrel_data_type_from_str (const char *str) |
| const char * | cdrel_get_field_flags (struct ast_flags *flags, struct ast_str **str) |
| static enum ast_module_load_result | load_module (void) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Combined logic for CDR/CEL Custom modules" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CDR_DRIVER, } |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| cdrel_backend_writer | cdrel_backend_writers [cdrel_format_type_end] |
| const char * | cdrel_data_type_map [] |
| cdrel_dummy_channel_alloc | cdrel_dummy_channel_allocators [cdrel_format_type_end] |
| static const char * | cdrel_field_flags_map [] |
| cdrel_field_formatter | cdrel_field_formatters [cdrel_data_type_end] |
| cdrel_field_getter | cdrel_field_getters [cdrel_record_type_end][cdrel_data_type_end] |
| const char * | cdrel_module_type_map [] |
| const char * | cdrel_record_type_map [] |
Common logic for the CDR and CEL Custom Backends.
All source files are in the res/cdrel_custom directory.
"config.c": Contains common configuration file parsing the ultimate goal of which is to create a vector of cdrel_config structures for each of the cdr_custom, cdr_sqlite3_custom, cel_custom and cel_sqlite3_custom modules. Each cdrel_config object represents an output file defined in their respective config files. Each one contains a vector of cdrel_field objects, one for each field in the output record, plus settings like the output file name, backend type (text file or database), config type ((legacy or advanced), the field separator and quote character to use.
Each cdrel_field object contains an abstract field id that points to a ast_cdr structure member or CEL event field id along with an input type and an output type. The registry of cdrel_fields is located in registry.c.
"loggers.c": Contains the common "cdrel_logger" entrypoint that the individual modules call to log a record. It takes the module's cdrel_configs vector and the record to log it got from the core cel.c and cdr.c. It then looks up and runs the logger implementation based on the backend type (text file or database) and config type (legacy or advanced).
"getters_cdr.c", "getters_cel.c": Contain the getters that retrieve values from the ast_cdr or ast_event structures based on the field id and input type defined for that field and create a cdrel_value wrapper object for it.
"writers.c": Contains common backend writers for the text file and database backends.
The load-time flow...
Each of the individual cdr/cel custom modules call the common cdrel_load_module function with their backend_type, record_type (cdr or cel), config file name, and the logging callback that should be registered with the core cdr or cel facility.
cdrel_load_module calls the config load function appropriate for the backend type, each of which parses the config file and, if successful, registers the calling module with the cdr or cel core and creates a vector of cdrel_config objects that is passed back to the calling module. That vector contains the context for all future operations.
The run-time flow...
The core cdr and cel modules use their registries of backends and call the callback function registered by the 4 cdr and cel custom modules. No changes there.
Each of those modules call the common cdrel_logger function with their cdrel_configs vector and the actual ast_cdr or ast_event structure to log. The cdrel_logger function iterates over the cdrel_configs vector and for each invokes the logger implementation specific to the backend type (text file or database) and config type (legacy or advanced).
For legacy config types, the logger implementation simply calls ast_str_substitute_variables() on the whole opaque format and writes the result to the text file or database.
For advanced configs, the logger implementation iterates over each field in the cdrel_config's fields vector and for each, calls the appropriate getter based on the record type (cdr or cel) and field id. Each getter call returns a cdrel_value object which is then passed to a field formatter looked up based on the field's data type (string, int32, etc). The formatter is also passed the cdrel_config object and the desired output type and returns the final value in another cdrel_value object formatted with any quoting, etc. needed. The logger accumulates the output cdrel_values (which are all now strings) in another vector and after all fields have been processed, hands the vector over to one of the backend writers.
The backend writer concatenates the cdrel_values into an output record using the config's separator setting and writes it to the text file or database. For the JSON output format, it creates a simple name/value pair output record.
The identification of field data types, field ids, record types and backend types is all done at config load time and saved in the cdrel_config and cdrel_field objects. The callbacks for getters, formatters and writers are also loaded when the res_cdrel_custom module loads and stored in arrays indexed by their enum values. The result is that at run time, simple array indexing is all that's needed to get the proper getter, formatter and writer for any logging request.
Definition in file res_cdrel_custom.c.
|
static |
Definition at line 258 of file res_cdrel_custom.c.
|
static |
Definition at line 258 of file res_cdrel_custom.c.
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 258 of file res_cdrel_custom.c.
| const char * cdrel_basename | ( | const char * | path | ) |
Definition at line 219 of file res_cdrel_custom.c.
References ast_strlen_zero().
Referenced by config_alloc(), field_alloc(), format_string(), load_database_columns(), load_database_config(), load_fields(), load_text_file_advanced_config(), load_text_file_legacy_config(), load_text_file_legacy_mappings(), open_database(), and parse_legacy_template().
| enum cdrel_data_type cdrel_data_type_from_str | ( | const char * | str | ) |
Definition at line 179 of file res_cdrel_custom.c.
References cdrel_data_type_end, cdrel_data_type_map, and str.
Referenced by field_alloc().
Definition at line 201 of file res_cdrel_custom.c.
References ast_str_append(), ast_str_buffer(), ast_test_flag, CDREL_FIELD_FLAG_LAST, cdrel_field_flags_map, and str.
Referenced by field_alloc(), and format_string().
|
static |
Definition at line 243 of file res_cdrel_custom.c.
References AST_MODULE_LOAD_SUCCESS, load_cdr(), load_cel(), load_formatters(), and load_writers().
|
static |
Definition at line 238 of file res_cdrel_custom.c.
|
static |
Definition at line 258 of file res_cdrel_custom.c.
|
static |
Definition at line 258 of file res_cdrel_custom.c.
| cdrel_backend_writer cdrel_backend_writers[cdrel_format_type_end] |
Definition at line 137 of file res_cdrel_custom.c.
Referenced by load_writers(), and log_advanced_record().
| const char* cdrel_data_type_map[] |
Definition at line 160 of file res_cdrel_custom.c.
Referenced by cdrel_data_type_from_str().
| cdrel_dummy_channel_alloc cdrel_dummy_channel_allocators[cdrel_format_type_end] |
Definition at line 142 of file res_cdrel_custom.c.
Referenced by config_alloc(), load_cdr(), and load_cel().
|
static |
Definition at line 191 of file res_cdrel_custom.c.
Referenced by cdrel_get_field_flags().
| cdrel_field_formatter cdrel_field_formatters[cdrel_data_type_end] |
Definition at line 132 of file res_cdrel_custom.c.
Referenced by load_formatters(), and log_advanced_record().
| cdrel_field_getter cdrel_field_getters[cdrel_record_type_end][cdrel_data_type_end] |
Definition at line 127 of file res_cdrel_custom.c.
Referenced by load_cdr(), load_cel(), and log_advanced_record().
| const char* cdrel_module_type_map[] |
Definition at line 154 of file res_cdrel_custom.c.
| const char* cdrel_record_type_map[] |
Definition at line 148 of file res_cdrel_custom.c.