Asterisk - The Open Source Telephony Project GIT-master-80b953f
Loading...
Searching...
No Matches
registry.c
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 CDR/CEL field registry
24 *
25 */
26
27#include "cdrel.h"
28
29#include "asterisk/json.h"
30#include "asterisk/cdr.h"
31#include "asterisk/cel.h"
32
33/*!
34 * \internal
35 * \brief Helper macro that populates the static array of cdrel_fields.
36 *
37 * \param _record_type The type of record: CDR or CEL.
38 * \param _field_id For CEL, it's the event field. For CDR it's one of cdr_field_id.
39 * \param _name The field name.
40 * \param _input_type The input data type. Drives the getters.
41 * \param output_types An array of types, one each for dsv, json and sql. Drives the formatters.
42 * \param _mallocd Not used.
43 */
44#define REGISTER_FIELD(_record_type, _field_id, _name, _input_type, _output_type) \
45 { _record_type, _field_id, _name, _input_type, _output_type, { 0 } }
46
47static const struct cdrel_field cdrel_field_registry[] = {
75
102};
103
104/*
105* \internal
106* \brief Get a cdrel_field structure by record type and field name.
107*
108* \param record_type The cdrel_record_type to search.
109* \param name The field name to search for.
110* \returns A pointer to a constant cdrel_field structure or NULL if not found.
111* This pointer must never be freed.
112*/
114{
115 int ix = 0;
116
117 for (ix = 0; ix < ARRAY_LEN(cdrel_field_registry); ix++) {
118 if (cdrel_field_registry[ix].record_type == type && strcasecmp(cdrel_field_registry[ix].name, name) == 0) {
119 return &cdrel_field_registry[ix];
120 }
121 }
122 return NULL;
123}
Call Detail Record API.
Private header for res_cdrel_custom.
@ cdr_field_peeraccount
Definition cdrel.h:155
@ cdr_field_amaflags
Definition cdrel.h:153
@ cdr_field_dcontext
Definition cdrel.h:142
@ cdr_field_flags
Definition cdrel.h:156
@ cdr_field_end
Definition cdrel.h:149
@ cdr_field_duration
Definition cdrel.h:150
@ cdr_field_billsec
Definition cdrel.h:151
@ cdr_field_dstchannel
Definition cdrel.h:144
@ cdr_field_literal
Definition cdrel.h:138
@ cdr_field_sequence
Definition cdrel.h:162
@ cdr_field_lastdata
Definition cdrel.h:146
@ cdr_field_uniqueid
Definition cdrel.h:157
@ cdr_field_answer
Definition cdrel.h:148
@ cdr_field_tenantid
Definition cdrel.h:159
@ cdr_field_linkedid
Definition cdrel.h:158
@ cdr_field_channel
Definition cdrel.h:143
@ cdr_field_peertenantid
Definition cdrel.h:160
@ cdr_field_clid
Definition cdrel.h:139
@ cdr_field_dst
Definition cdrel.h:141
@ cdr_field_varshead
Definition cdrel.h:163
@ cdr_field_start
Definition cdrel.h:147
@ cdr_field_disposition
Definition cdrel.h:152
@ cdr_field_lastapp
Definition cdrel.h:145
@ cdr_field_userfield
Definition cdrel.h:161
@ cdr_field_accountcode
Definition cdrel.h:154
@ cdr_field_src
Definition cdrel.h:140
#define AST_EVENT_IE_CEL_EVENT_ENUM
Definition cdrel.h:119
#define AST_EVENT_IE_CEL_LITERAL
Definition cdrel.h:118
@ cdrel_type_event_type
Definition cdrel.h:79
@ cdrel_type_cel_timefmt
Definition cdrel.h:81
@ cdrel_type_amaflags
Definition cdrel.h:76
@ cdrel_type_event_enum
Definition cdrel.h:80
@ cdrel_type_disposition
Definition cdrel.h:77
@ cdrel_type_uservar
Definition cdrel.h:78
@ cdrel_type_int64
Definition cdrel.h:85
@ cdrel_type_literal
Definition cdrel.h:75
@ cdrel_type_int32
Definition cdrel.h:83
@ cdrel_type_string
Definition cdrel.h:73
@ cdrel_type_timeval
Definition cdrel.h:74
@ cdrel_type_uint32
Definition cdrel.h:84
Call Event Logging API.
static const char type[]
@ AST_EVENT_IE_CEL_ACCTCODE
Channel Event AccountCode Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:205
@ AST_EVENT_IE_CEL_EXTRA
Channel Event extra data Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:259
@ AST_EVENT_IE_CEL_CONTEXT
Channel Event context name Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:175
@ AST_EVENT_IE_CEL_PEERACCT
Channel Event peeraccount Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:253
@ AST_EVENT_IE_CEL_CIDRDNIS
Channel Event CID RDNIS field Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:229
@ AST_EVENT_IE_CEL_EVENT_TIME
Channel Event Time (seconds) Used by: AST_EVENT_CEL Payload type: UINT.
Definition event_defs.h:139
@ AST_EVENT_IE_CEL_CHANNAME
Channel Event channel name Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:181
@ AST_EVENT_IE_CEL_CIDANI
Channel Event CID ANI field Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:223
@ AST_EVENT_IE_CEL_CIDDNID
Channel Event CID dnid Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:235
@ AST_EVENT_IE_CEL_EXTEN
Channel Event extension name Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:169
@ AST_EVENT_IE_CEL_CIDNAME
Channel Event CID name Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:157
@ AST_EVENT_IE_CEL_AMAFLAGS
Channel Event AMA flags Used by: AST_EVENT_CEL Payload type: UINT.
Definition event_defs.h:199
@ AST_EVENT_IE_CEL_USEREVENT_NAME
Channel Event User Event Name Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:151
@ AST_EVENT_IE_CEL_TENANTID
Channel Event TenantID Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:320
@ AST_EVENT_IE_CEL_LINKEDID
Channel Event LinkedID Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:247
@ AST_EVENT_IE_CEL_EVENT_TIME_USEC
Channel Event Time (micro-seconds) Used by: AST_EVENT_CEL Payload type: UINT.
Definition event_defs.h:145
@ AST_EVENT_IE_CEL_EVENT_TYPE
Channel Event Type Used by: AST_EVENT_CEL Payload type: UINT.
Definition event_defs.h:133
@ AST_EVENT_IE_CEL_UNIQUEID
Channel Event UniqueID Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:211
@ AST_EVENT_IE_CEL_APPNAME
Channel Event app name Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:187
@ AST_EVENT_IE_CEL_APPDATA
Channel Event app args/data Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:193
@ AST_EVENT_IE_CEL_PEER
Channel Event Peer – for Things involving multiple channels, like BRIDGE Used by: AST_EVENT_CEL Paylo...
Definition event_defs.h:241
@ AST_EVENT_IE_CEL_CIDNUM
Channel Event CID num Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:163
@ AST_EVENT_IE_CEL_USERFIELD
Channel Event Userfield Used by: AST_EVENT_CEL Payload type: STR.
Definition event_defs.h:217
static const char name[]
Definition format_mp3.c:68
Asterisk JSON abstraction layer.
#define REGISTER_FIELD(_record_type, _field_id, _name, _input_type, _output_type)
Definition registry.c:44
static const struct cdrel_field cdrel_field_registry[]
Definition registry.c:47
const struct cdrel_field * get_registered_field_by_name(enum cdrel_record_type type, const char *name)
Definition registry.c:113
cdrel_record_type
@ cdrel_record_cel
@ cdrel_record_cdr
#define NULL
Definition resample.c:96
enum cdrel_record_type record_type
Definition cdrel.h:271
#define ARRAY_LEN(a)
Definition utils.h:706