Asterisk - The Open Source Telephony Project GIT-master-8f1982c
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 1305 of file features_config.c.

1306{
1307 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1308
1309 if (chan) {
1310 cfg = get_feature_ds(chan);
1311 } else {
1313 }
1314
1315 if (!cfg) {
1316 return -1;
1317 }
1318
1319 return featuremap_get(cfg->featuremap, feature, buf, len);
1320}
#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 1397 of file features_config.c.

1398{
1400 struct ao2_container *applicationmap;
1401 char *group_names;
1402 char *name;
1403
1404 if (!cfg) {
1405 return NULL;
1406 }
1407
1408 if (!chan) {
1409 if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
1410 return NULL;
1411 }
1412 ao2_ref(cfg->applicationmap, +1);
1413 return cfg->applicationmap;
1414 }
1415
1416 group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
1417 if (ast_strlen_zero(group_names)) {
1418 return NULL;
1419 }
1420
1421 applicationmap = applicationmap_alloc(0);
1422 if (!applicationmap) {
1423 return NULL;
1424 }
1425
1426 /* global config must be initialized */
1427 ast_assert(cfg->featuregroups != NULL);
1428 ast_assert(cfg->applicationmap != NULL);
1429 while ((name = strsep(&group_names, "#"))) {
1430 RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup);
1431
1432 if (!group) {
1433 RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup);
1434
1435 if (item) {
1436 ao2_link(applicationmap, item);
1437 } else {
1438 ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n",
1439 name, ast_channel_name(chan));
1440 }
1441 } else {
1442 ao2_callback(group->items, 0, add_item, applicationmap);
1443 }
1444 }
1445
1446 if (ao2_container_count(applicationmap) == 0) {
1447 ao2_cleanup(applicationmap);
1448 return NULL;
1449 }
1450
1451 return applicationmap;
1452}
char * strsep(char **str, const char *delims)
#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
#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 1285 of file features_config.c.

1286{
1287 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1288
1289 if (chan) {
1290 cfg = get_feature_ds(chan);
1291 } else {
1293 }
1294
1295 if (!cfg) {
1296 return NULL;
1297 }
1298
1299 ast_assert(cfg->featuremap != NULL);
1300
1301 ao2_ref(cfg->featuremap, +1);
1302 return cfg->featuremap;
1303}

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 1250 of file features_config.c.

1251{
1252 char *res;
1254
1255 if (!cfg) {
1256 return NULL;
1257 }
1258
1259 res = ast_strdup(cfg->atxferabort);
1260 ao2_ref(cfg, -1);
1261
1262 return res;
1263}
#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 1195 of file features_config.c.

1196{
1197 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1198
1199 if (chan) {
1200 cfg = get_feature_ds(chan);
1201 } else {
1203 }
1204
1205 if (!cfg) {
1206 return NULL;
1207 }
1208
1209 ast_assert(cfg->global && cfg->global->general);
1210
1211 ao2_ref(cfg->global->general, +1);
1212 return cfg->global->general;
1213}

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 1265 of file features_config.c.

1266{
1267 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1268
1269 if (chan) {
1270 cfg = get_feature_ds(chan);
1271 } else {
1273 }
1274
1275 if (!cfg) {
1276 return NULL;
1277 }
1278
1279 ast_assert(cfg->global && cfg->global->pickup);
1280
1281 ao2_ref(cfg->global->pickup, +1);
1282 return cfg->global->pickup;
1283}

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 1215 of file features_config.c.

1216{
1217 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1218
1219 if (chan) {
1220 cfg = get_feature_ds(chan);
1221 } else {
1223 }
1224
1225 if (!cfg) {
1226 return NULL;
1227 }
1228
1229 ast_assert(cfg->global && cfg->global->xfer);
1230
1231 ao2_ref(cfg->global->xfer, +1);
1232 return cfg->global->xfer;
1233}

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 1235 of file features_config.c.

1236{
1237 char *res;
1239
1240 if (!cfg) {
1241 return NULL;
1242 }
1243
1244 res = ast_strdup(cfg->xferfailsound);
1245 ao2_ref(cfg, -1);
1246
1247 return res;
1248}

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 1322 of file features_config.c.

1323{
1324 RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
1326
1327 if (!ast_get_builtin_feature(chan, feature, buf, len)) {
1328 return 0;
1329 }
1330
1331 /* Dang, must be in the application map */
1332 applicationmap = ast_get_chan_applicationmap(chan);
1333 if (!applicationmap) {
1334 return -1;
1335 }
1336
1337 item = ao2_find(applicationmap, feature, OBJ_KEY);
1338 if (!item) {
1339 return -1;
1340 }
1341
1342 ast_copy_string(buf, item->dtmf, len);
1343 return 0;
1344}
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().