Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
res_cdrel_custom.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2026, Sangoma Technologies Corporation
5 *
6 * George Joseph <gjoseph@sangoma.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*!
20 * \file
21 * \author George Joseph <gjoseph@sangoma.com>
22 *
23 * \brief Protected header for the CDR and CEL Custom Backends
24 *
25 * \warning This file should be included only by CDR and CEL backends.
26 *
27 */
28
29#ifndef _RES_CDREL_CUSTOM_H
30#define _RES_CDREL_CUSTOM_H
31
32/*! \enum Backend Types */
34 cdrel_backend_text = 0, /*!< Text file: DSV or JSON */
35 cdrel_backend_db, /*!< Database (currently only sqlite3) */
36 cdrel_backend_type_end, /*!< Sentinel */
37};
38
39/*! \enum Record Types */
41 cdrel_record_cdr = 0, /*!< Call Detail Records */
42 cdrel_record_cel, /*!< Channel Event Log records */
43 cdrel_record_type_end, /*!< Sentinel */
44};
45
46/*! \struct Forward declaration of a configuration */
47struct cdrel_config;
48
49/*! \struct Vector to hold all configurations in a config file */
50AST_VECTOR(cdrel_configs, struct cdrel_config *);
51
52/*!
53 * \brief Perform initial module load.
54 *
55 * Needs to be called by each "custom" module
56 *
57 * \param backend_type One of \ref cdrel_backend_type.
58 * \param record_type One of \ref cdrel_record_type.
59 * \param config_filename The config file name.
60 * \param backend_name The name to register the backend as.
61 * \param logging_cb The logging callback to register with CDR or CEL.
62 * \returns A pointer to a VECTOR or config objects read from the config file.
63 */
64struct cdrel_configs *cdrel_load_module(enum cdrel_backend_type backend_type,
65 enum cdrel_record_type record_type, const char *config_filename,
66 const char *backend_name, void *logging_cb);
67
68/*!
69 * \brief Perform module reload.
70 *
71 * Needs to be called by each "custom" module
72 *
73 * \warning This function MUST be called with the module's config_lock held
74 * for writing to prevent reloads from happening while we're logging.
75 *
76 * \param backend_type One of \ref cdrel_backend_type.
77 * \param record_type One of \ref cdrel_record_type.
78 * \param configs A pointer to the VECTOR of config objects returned by \ref cdrel_load_module.
79 * \param config_filename The config file name.
80 * \retval AST_MODULE_LOAD_SUCCESS
81 * \retval AST_MODULE_LOAD_DECLINE
82 */
83int cdrel_reload_module(enum cdrel_backend_type backend_type, enum cdrel_record_type record_type,
84 struct cdrel_configs **configs, const char *config_filename);
85
86/*!
87 * \brief Perform module unload.
88 *
89 * Needs to be called by each "custom" module
90 *
91 * \warning This function MUST be called with the module's config_lock held
92 * for writing to prevent the module from being unloaded while we're logging.
93 *
94 * \param backend_type One of \ref cdrel_backend_type.
95 * \param record_type One of \ref cdrel_record_type.
96 * \param configs A pointer to the VECTOR of config objects returned by \ref cdrel_load_module.
97 * \param backend_name The backend name to unregister.
98 * \retval 0 Success.
99 * \retval -1 Failure.
100 */
101int cdrel_unload_module(enum cdrel_backend_type backend_type, enum cdrel_record_type record_type,
102 struct cdrel_configs *configs, const char *backend_name);
103
104/*!
105 * \brief Log a record. The module's \ref logging_cb must call this.
106 *
107 * \warning This function MUST be called with the module's config_lock held
108 * for reading to prevent reloads from happening while we're logging.
109 *
110 * \param configs A pointer to the VECTOR of config objects returned by \ref cdrel_load_module.
111 * \param data A pointer to an ast_cdr or ast_event object to log.
112 * \retval 0 Success.
113 * \retval -1 Failure.
114 */
115int cdrel_logger(struct cdrel_configs *configs, void *data);
116
117#endif /* _RES_CDREL_CUSTOM_H */
static char * config_filename
Definition extconf.c:2118
int cdrel_logger(struct cdrel_configs *configs, void *data)
Log a record. The module's logging_cb must call this.
Definition loggers.c:270
int cdrel_reload_module(enum cdrel_backend_type backend_type, enum cdrel_record_type record_type, struct cdrel_configs **configs, const char *config_filename)
Perform module reload.
int cdrel_unload_module(enum cdrel_backend_type backend_type, enum cdrel_record_type record_type, struct cdrel_configs *configs, const char *backend_name)
Perform module unload.
struct cdrel_configs * cdrel_load_module(enum cdrel_backend_type backend_type, enum cdrel_record_type record_type, const char *config_filename, const char *backend_name, void *logging_cb)
Perform initial module load.
cdrel_backend_type
@ cdrel_backend_db
@ cdrel_backend_text
@ cdrel_backend_type_end
cdrel_record_type
@ cdrel_record_cel
@ cdrel_record_cdr
@ cdrel_record_type_end
#define AST_VECTOR(name, type)
Define a vector structure.
Definition vector.h:44