Asterisk - The Open Source Telephony Project GIT-master-70eff7f
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
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.
 
struct ao2_containerast_get_chan_applicationmap (struct ast_channel *chan)
 Get the applicationmap for a given channel.
 
struct ast_featuremap_configast_get_chan_featuremap_config (struct ast_channel *chan)
 Get the featuremap configuration options for a channel.
 
char * ast_get_chan_features_atxferabort (struct ast_channel *chan)
 Get the transfer configuration option atxferabort.
 
struct ast_features_general_configast_get_chan_features_general_config (struct ast_channel *chan)
 Get the general configuration options for a channel.
 
struct ast_features_pickup_configast_get_chan_features_pickup_config (struct ast_channel *chan)
 Get the pickup configuration options for a channel.
 
struct ast_features_xfer_configast_get_chan_features_xfer_config (struct ast_channel *chan)
 Get the transfer configuration options for a channel.
 
char * ast_get_chan_features_xferfailsound (struct ast_channel *chan)
 Get the transfer configuration option xferfailsound.
 
int ast_get_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a call feature.
 

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

1310{
1311 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1312
1313 if (chan) {
1314 cfg = get_feature_ds(chan);
1315 } else {
1317 }
1318
1319 if (!cfg) {
1320 return -1;
1321 }
1322
1323 return featuremap_get(cfg->featuremap, feature, buf, len);
1324}
#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:981

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

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

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

1290{
1291 RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1292
1293 if (chan) {
1294 cfg = get_feature_ds(chan);
1295 } else {
1297 }
1298
1299 if (!cfg) {
1300 return NULL;
1301 }
1302
1303 ast_assert(cfg->featuremap != NULL);
1304
1305 ao2_ref(cfg->featuremap, +1);
1306 return cfg->featuremap;
1307}

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

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

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

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

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

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

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

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

1240{
1241 char *res;
1243
1244 if (!cfg) {
1245 return NULL;
1246 }
1247
1248 res = ast_strdup(cfg->xferfailsound);
1249 ao2_ref(cfg, -1);
1250
1251 return res;
1252}

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

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