Asterisk - The Open Source Telephony Project GIT-master-a358458
Data Structures | Macros | Functions
include/asterisk/features_config.h File Reference
#include "asterisk/stringfields.h"
Include dependency graph for include/asterisk/features_config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_applicationmap_item
 An applicationmap configuration item. More...
 
struct  ast_featuremap_config
 Configuration for the builtin features. More...
 
struct  ast_features_general_config
 General features configuration items. More...
 
struct  ast_features_pickup_config
 Configuration relating to call pickup. More...
 
struct  ast_features_xfer_config
 Feature configuration relating to transfers. More...
 

Macros

#define AST_FEATURE_MAX_LEN   11
 

Functions

int ast_get_builtin_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a builtin feature. More...
 
struct ao2_containerast_get_chan_applicationmap (struct ast_channel *chan)
 Get the applicationmap for a given channel. More...
 
struct ast_featuremap_configast_get_chan_featuremap_config (struct ast_channel *chan)
 Get the featuremap configuration options for a channel. More...
 
char * ast_get_chan_features_atxferabort (struct ast_channel *chan)
 Get the transfer configuration option atxferabort. More...
 
struct ast_features_general_configast_get_chan_features_general_config (struct ast_channel *chan)
 Get the general configuration options for a channel. More...
 
struct ast_features_pickup_configast_get_chan_features_pickup_config (struct ast_channel *chan)
 Get the pickup configuration options for a channel. More...
 
struct ast_features_xfer_configast_get_chan_features_xfer_config (struct ast_channel *chan)
 Get the transfer configuration options for a channel. More...
 
char * ast_get_chan_features_xferfailsound (struct ast_channel *chan)
 Get the transfer configuration option xferfailsound. More...
 
int ast_get_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a call feature. More...
 

Macro Definition Documentation

◆ AST_FEATURE_MAX_LEN

#define AST_FEATURE_MAX_LEN   11

Definition at line 231 of file include/asterisk/features_config.h.

Function Documentation

◆ ast_get_builtin_feature()

int ast_get_builtin_feature ( struct ast_channel chan,
const char *  feature,
char *  buf,
size_t  len 
)

Get the DTMF code for a builtin feature.

Note
The channel should be locked before calling this function

If no channel is provided, then the global setting for the option is returned.

Parameters
chanThe channel to get the option from
featureThe short name of the feature (as it appears in features.conf)
[out]bufThe buffer to write the DTMF value into
lenThe size of the buffer in bytes
Return values
0Success
non-zeroUnrecognized builtin feature name

Definition at line 1225 of file features_config.c.

1226{
1227 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1228
1229 if (chan) {
1230 cfg = get_feature_ds(chan);
1231 } else {
1233 }
1234
1235 if (!cfg) {
1236 return -1;
1237 }
1238
1239 return featuremap_get(cfg->featuremap, feature, buf, len);
1240}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
Definition: astobj2.h:918
static struct console_pvt globals
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static struct features_config * get_feature_ds(struct ast_channel *chan)
static int featuremap_get(struct ast_featuremap_config *featuremap, const char *field, char *buf, size_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References ao2_cleanup, ao2_global_obj_ref, buf, featuremap_get(), get_feature_ds(), globals, len(), NULL, and RAII_VAR.

Referenced by action_atxfer(), ast_get_feature(), attended_transfer_exec(), builtin_feature_get_exten(), detect_disconnect(), and internal_featuremap_read().

◆ ast_get_chan_applicationmap()

struct ao2_container * ast_get_chan_applicationmap ( struct ast_channel chan)

Get the applicationmap for a given channel.

Note
The channel should be locked before calling this function.

This uses the value of the DYNAMIC_FEATURES channel variable to build a custom applicationmap for this channel. The returned container has applicationmap_items inside.

Parameters
chanThe channel for which applicationmap is being retrieved.
Return values
NULLAn error occurred or the channel has no dynamic features.
non-NULLA container of applicationmap_items pertaining to the channel.

Definition at line 1317 of file features_config.c.

1318{
1320 struct ao2_container *applicationmap;
1321 char *group_names;
1322 char *name;
1323
1324 if (!cfg) {
1325 return NULL;
1326 }
1327
1328 if (!chan) {
1329 if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
1330 return NULL;
1331 }
1332 ao2_ref(cfg->applicationmap, +1);
1333 return cfg->applicationmap;
1334 }
1335
1336 group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
1337 if (ast_strlen_zero(group_names)) {
1338 return NULL;
1339 }
1340
1341 applicationmap = applicationmap_alloc(0);
1342 if (!applicationmap) {
1343 return NULL;
1344 }
1345
1346 /* global config must be initialized */
1347 ast_assert(cfg->featuregroups != NULL);
1348 ast_assert(cfg->applicationmap != NULL);
1349 while ((name = strsep(&group_names, "#"))) {
1350 RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup);
1351
1352 if (!group) {
1353 RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup);
1354
1355 if (item) {
1356 ao2_link(applicationmap, item);
1357 } else {
1358 ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n",
1359 name, ast_channel_name(chan));
1360 }
1361 } else {
1362 ao2_callback(group->items, 0, add_item, applicationmap);
1363 }
1364 }
1365
1366 if (ao2_container_count(applicationmap) == 0) {
1367 ao2_cleanup(applicationmap);
1368 return NULL;
1369 }
1370
1371 return applicationmap;
1372}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
#define OBJ_KEY
Definition: astobj2.h:1151
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
const char * ast_channel_name(const struct ast_channel *chan)
static struct ao2_container * applicationmap_alloc(int replace_duplicates)
static int add_item(void *obj, void *arg, int flags)
static const char name[]
Definition: format_mp3.c:68
char * strsep(char **str, const char *delims)
#define LOG_WARNING
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Generic container type.
An applicationmap configuration item.
Featuregroup representation.
static struct aco_type item
Definition: test_config.c:1463
#define ast_assert(a)
Definition: utils.h:739

References add_item(), ao2_callback, ao2_cleanup, ao2_container_count(), ao2_find, ao2_global_obj_ref, ao2_link, ao2_ref, applicationmap_alloc(), ast_assert, ast_channel_name(), ast_log, ast_strdupa, ast_strlen_zero(), globals, item, LOG_WARNING, name, NULL, OBJ_KEY, pbx_builtin_getvar_helper(), RAII_VAR, S_OR, and strsep().

Referenced by ast_get_feature(), set_config_flags(), and setup_bridge_features_dynamic().

◆ ast_get_chan_featuremap_config()

struct ast_featuremap_config * ast_get_chan_featuremap_config ( struct ast_channel chan)

Get the featuremap configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global featuremap configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe pickup features configuration

Definition at line 1205 of file features_config.c.

1206{
1207 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1208
1209 if (chan) {
1210 cfg = get_feature_ds(chan);
1211 } else {
1213 }
1214
1215 if (!cfg) {
1216 return NULL;
1217 }
1218
1219 ast_assert(cfg->featuremap != NULL);
1220
1221 ao2_ref(cfg->featuremap, +1);
1222 return cfg->featuremap;
1223}

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by testsuite_notify_feature_success().

◆ ast_get_chan_features_atxferabort()

char * ast_get_chan_features_atxferabort ( struct ast_channel chan)

Get the transfer configuration option atxferabort.

Note
The channel should be locked before calling this function.
The returned value has to be freed.

If no channel is provided, then option is pulled from the global transfer configuration.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe atxferabort

Definition at line 1170 of file features_config.c.

1171{
1172 char *res;
1174
1175 if (!cfg) {
1176 return NULL;
1177 }
1178
1179 res = ast_strdup(cfg->atxferabort);
1180 ao2_ref(cfg, -1);
1181
1182 return res;
1183}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.
Feature configuration relating to transfers.

References ao2_ref, ast_get_chan_features_xfer_config(), ast_strdup, ast_features_xfer_config::atxferabort, and NULL.

Referenced by action_cancel_atxfer().

◆ ast_get_chan_features_general_config()

struct ast_features_general_config * ast_get_chan_features_general_config ( struct ast_channel chan)

Get the general configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global features configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe general features configuration

Definition at line 1115 of file features_config.c.

1116{
1117 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1118
1119 if (chan) {
1120 cfg = get_feature_ds(chan);
1121 } else {
1123 }
1124
1125 if (!cfg) {
1126 return NULL;
1127 }
1128
1129 ast_assert(cfg->global && cfg->global->general);
1130
1131 ao2_ref(cfg->global->general, +1);
1132 return cfg->global->general;
1133}

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by bridge_channel_feature_digit_timeout(), and feature_automixmonitor().

◆ ast_get_chan_features_pickup_config()

struct ast_features_pickup_config * ast_get_chan_features_pickup_config ( struct ast_channel chan)

Get the pickup configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global pickup configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe pickup features configuration

Definition at line 1185 of file features_config.c.

1186{
1187 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1188
1189 if (chan) {
1190 cfg = get_feature_ds(chan);
1191 } else {
1193 }
1194
1195 if (!cfg) {
1196 return NULL;
1197 }
1198
1199 ast_assert(cfg->global && cfg->global->pickup);
1200
1201 ao2_ref(cfg->global->pickup, +1);
1202 return cfg->global->pickup;
1203}

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_pickup_call(), call_pickup_incoming_request(), get_destination(), handle_call_outgoing(), and key_main_page().

◆ ast_get_chan_features_xfer_config()

struct ast_features_xfer_config * ast_get_chan_features_xfer_config ( struct ast_channel chan)

Get the transfer configuration options for a channel.

Note
The channel should be locked before calling this function.
The returned value has its reference count incremented.

If no channel is provided, then the global transfer configuration is returned.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe transfer features configuration

Definition at line 1135 of file features_config.c.

1136{
1137 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1138
1139 if (chan) {
1140 cfg = get_feature_ds(chan);
1141 } else {
1143 }
1144
1145 if (!cfg) {
1146 return NULL;
1147 }
1148
1149 ast_assert(cfg->global && cfg->global->xfer);
1150
1151 ao2_ref(cfg->global->xfer, +1);
1152 return cfg->global->xfer;
1153}

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_assert, get_feature_ds(), globals, NULL, and RAII_VAR.

Referenced by action_bridge(), add_transferer_role(), ast_get_chan_features_atxferabort(), ast_get_chan_features_xferfailsound(), attended_transfer_properties_alloc(), bridge_exec(), grab_transfer(), and testsuite_notify_feature_success().

◆ ast_get_chan_features_xferfailsound()

char * ast_get_chan_features_xferfailsound ( struct ast_channel chan)

Get the transfer configuration option xferfailsound.

Note
The channel should be locked before calling this function.
The returned value has to be freed.

If no channel is provided, then option is pulled from the global transfer configuration.

Parameters
chanThe channel to get configuration options for
Return values
NULLFailed to get configuration
non-NULLThe xferfailsound

Definition at line 1155 of file features_config.c.

1156{
1157 char *res;
1159
1160 if (!cfg) {
1161 return NULL;
1162 }
1163
1164 res = ast_strdup(cfg->xferfailsound);
1165 ao2_ref(cfg, -1);
1166
1167 return res;
1168}

References ao2_ref, ast_get_chan_features_xfer_config(), ast_strdup, NULL, and ast_features_xfer_config::xferfailsound.

Referenced by play_failsound(), and stream_failsound().

◆ ast_get_feature()

int ast_get_feature ( struct ast_channel chan,
const char *  feature,
char *  buf,
size_t  len 
)

Get the DTMF code for a call feature.

Note
The channel should be locked before calling this function

If no channel is provided, then the global setting for the option is returned.

This function is like ast_get_builtin_feature except that it will also check the applicationmap in addition to the builtin features.

Parameters
chanThe channel to get the option from
featureThe short name of the feature
[out]bufThe buffer to write the DTMF value into
lenThe size of the buffer in bytes
Return values
0Success
non-zeroUnrecognized feature name

Definition at line 1242 of file features_config.c.

1243{
1244 RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
1246
1247 if (!ast_get_builtin_feature(chan, feature, buf, len)) {
1248 return 0;
1249 }
1250
1251 /* Dang, must be in the application map */
1252 applicationmap = ast_get_chan_applicationmap(chan);
1253 if (!applicationmap) {
1254 return -1;
1255 }
1256
1257 item = ao2_find(applicationmap, feature, OBJ_KEY);
1258 if (!item) {
1259 return -1;
1260 }
1261
1262 ast_copy_string(buf, item->dtmf, len);
1263 return 0;
1264}
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a builtin feature.
struct ao2_container * ast_get_chan_applicationmap(struct ast_channel *chan)
Get the applicationmap for a given channel.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ao2_cleanup, ao2_find, ast_copy_string(), ast_get_builtin_feature(), ast_get_chan_applicationmap(), buf, item, len(), NULL, OBJ_KEY, and RAII_VAR.

Referenced by handle_incoming_request().