Asterisk - The Open Source Telephony Project  18.5.0
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

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
sizeThe size of the buffer in bytes
Return values
0Success
non-zeroUnrecognized builtin feature name

Definition at line 1233 of file features_config.c.

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

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

1234 {
1235  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1236 
1237  if (chan) {
1238  cfg = get_feature_ds(chan);
1239  } else {
1240  cfg = ao2_global_obj_ref(globals);
1241  }
1242 
1243  if (!cfg) {
1244  return -1;
1245  }
1246 
1247  return featuremap_get(cfg->featuremap, feature, buf, len);
1248 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#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:911
static struct console_pvt globals
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int featuremap_get(struct ast_featuremap_config *featuremap, const char *field, char *buf, size_t len)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

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

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().

1326 {
1328  struct ao2_container *applicationmap;
1329  char *group_names;
1330  char *name;
1331 
1332  if (!cfg) {
1333  return NULL;
1334  }
1335 
1336  if (!chan) {
1337  if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
1338  return NULL;
1339  }
1340  ao2_ref(cfg->applicationmap, +1);
1341  return cfg->applicationmap;
1342  }
1343 
1344  group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
1345  if (ast_strlen_zero(group_names)) {
1346  return NULL;
1347  }
1348 
1349  applicationmap = applicationmap_alloc(0);
1350  if (!applicationmap) {
1351  return NULL;
1352  }
1353 
1354  /* global config must be initialized */
1355  ast_assert(cfg->featuregroups != NULL);
1356  ast_assert(cfg->applicationmap != NULL);
1357  while ((name = strsep(&group_names, "#"))) {
1358  RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup);
1359 
1360  if (!group) {
1361  RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup);
1362 
1363  if (item) {
1364  ao2_link(applicationmap, item);
1365  } else {
1366  ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n",
1367  name, ast_channel_name(chan));
1368  }
1369  } else {
1370  ao2_callback(group->items, 0, add_item, applicationmap);
1371  }
1372  }
1373 
1374  if (ao2_container_count(applicationmap) == 0) {
1375  ao2_cleanup(applicationmap);
1376  return NULL;
1377  }
1378 
1379  return applicationmap;
1380 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
Featuregroup representation.
#define OBJ_KEY
Definition: astobj2.h:1155
An applicationmap configuration item.
#define LOG_WARNING
Definition: logger.h:274
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
static struct ao2_container * applicationmap_alloc(int replace_duplicates)
static struct aco_type item
Definition: test_config.c:1463
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
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 ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int add_item(void *obj, void *arg, int flags)
static struct console_pvt globals
static const char name[]
Definition: cdr_mysql.c:74
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
char * strsep(char **str, const char *delims)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
Generic container type.
#define ao2_link(container, obj)
Definition: astobj2.h:1549

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

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().

1214 {
1215  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1216 
1217  if (chan) {
1218  cfg = get_feature_ds(chan);
1219  } else {
1220  cfg = ao2_global_obj_ref(globals);
1221  }
1222 
1223  if (!cfg) {
1224  return NULL;
1225  }
1226 
1227  ast_assert(cfg->featuremap != NULL);
1228 
1229  ao2_ref(cfg->featuremap, +1);
1230  return cfg->featuremap;
1231 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

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

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

Referenced by action_cancel_atxfer().

1179 {
1180  char *res;
1182 
1183  if (!cfg) {
1184  return NULL;
1185  }
1186 
1187  res = ast_strdup(cfg->atxferabort);
1188  ao2_ref(cfg, -1);
1189 
1190  return res;
1191 }
Feature configuration relating to transfers.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.

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

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(), feature_automixmonitor(), and feature_automonitor().

1124 {
1125  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1126 
1127  if (chan) {
1128  cfg = get_feature_ds(chan);
1129  } else {
1130  cfg = ao2_global_obj_ref(globals);
1131  }
1132 
1133  if (!cfg) {
1134  return NULL;
1135  }
1136 
1137  ast_assert(cfg->global && cfg->global->general);
1138 
1139  ao2_ref(cfg->global->general, +1);
1140  return cfg->global->general;
1141 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

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

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(), cb_events(), get_destination(), handle_call_outgoing(), handle_request_invite(), key_main_page(), and mgcp_ss().

1194 {
1195  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1196 
1197  if (chan) {
1198  cfg = get_feature_ds(chan);
1199  } else {
1200  cfg = ao2_global_obj_ref(globals);
1201  }
1202 
1203  if (!cfg) {
1204  return NULL;
1205  }
1206 
1207  ast_assert(cfg->global && cfg->global->pickup);
1208 
1209  ao2_ref(cfg->global->pickup, +1);
1210  return cfg->global->pickup;
1211 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

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

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().

1144 {
1145  RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
1146 
1147  if (chan) {
1148  cfg = get_feature_ds(chan);
1149  } else {
1150  cfg = ao2_global_obj_ref(globals);
1151  }
1152 
1153  if (!cfg) {
1154  return NULL;
1155  }
1156 
1157  ast_assert(cfg->global && cfg->global->xfer);
1158 
1159  ao2_ref(cfg->global->xfer, +1);
1160  return cfg->global->xfer;
1161 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define ast_assert(a)
Definition: utils.h:695
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct console_pvt globals
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static struct features_config * get_feature_ds(struct ast_channel *chan)

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

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().

1164 {
1165  char *res;
1167 
1168  if (!cfg) {
1169  return NULL;
1170  }
1171 
1172  res = ast_strdup(cfg->xferfailsound);
1173  ao2_ref(cfg, -1);
1174 
1175  return res;
1176 }
Feature configuration relating to transfers.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.

◆ 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
sizeThe size of the buffer in bytes
Return values
0Success
non-zeroUnrecognized feature name

Definition at line 1250 of file features_config.c.

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

Referenced by handle_incoming_request(), and handle_request_info().

1251 {
1252  RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
1254 
1255  if (!ast_get_builtin_feature(chan, feature, buf, len)) {
1256  return 0;
1257  }
1258 
1259  /* Dang, must be in the application map */
1260  applicationmap = ast_get_chan_applicationmap(chan);
1261  if (!applicationmap) {
1262  return -1;
1263  }
1264 
1265  item = ao2_find(applicationmap, feature, OBJ_KEY);
1266  if (!item) {
1267  return -1;
1268  }
1269 
1270  ast_copy_string(buf, item->dtmf, len);
1271  return 0;
1272 }
#define OBJ_KEY
Definition: astobj2.h:1155
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
An applicationmap configuration item.
struct ao2_container * ast_get_chan_applicationmap(struct ast_channel *chan)
Get the applicationmap for a given channel.
static struct aco_type item
Definition: test_config.c:1463
#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:911
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
Generic container type.
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.