features_config.h File Reference

#include "asterisk/stringfields.h"

Include dependency graph for 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...

Defines

#define AST_FEATURE_MAX_LEN   11

Functions

int ast_features_config_init (void)
int ast_features_config_reload (void)
void ast_features_config_shutdown (void)
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.
struct
ast_features_general_config
ast_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.
int ast_get_feature (struct ast_channel *chan, const char *feature, char *buf, size_t len)
 Get the DTMF code for a call feature.


Define Documentation

#define AST_FEATURE_MAX_LEN   11


Function Documentation

int ast_features_config_init ( void   ) 

Definition at line 1966 of file features_config.c.

References __ast_custom_function_register(), ARRAY_LEN, ast_cli_register_multiple(), ast_features_config_shutdown(), load_config(), and NULL.

Referenced by ast_features_init().

01967 {
01968    int res;
01969 
01970    res = load_config();
01971    res |= __ast_custom_function_register(&feature_function, NULL);
01972    res |= __ast_custom_function_register(&featuremap_function, NULL);
01973    res |= ast_cli_register_multiple(cli_features_config, ARRAY_LEN(cli_features_config));
01974 
01975    if (res) {
01976       ast_features_config_shutdown();
01977    }
01978 
01979    return res;
01980 }

int ast_features_config_reload ( void   ) 

Definition at line 1955 of file features_config.c.

References aco_process_config(), ACO_PROCESS_ERROR, and parking_warning.

01956 {
01957    /* Rearm the parking config options have moved warning. */
01958    parking_warning = 0;
01959 
01960    if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) {
01961       return -1;
01962    }
01963    return 0;
01964 }

void ast_features_config_shutdown ( void   ) 

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:
chan The channel to get the option from
feature The short name of the feature (as it appears in features.conf)
[out] buf The buffer to write the DTMF value into
size The size of the buffer in bytes
Return values:
0 Success
non-zero Unrecognized builtin feature name

Definition at line 1201 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(), builtin_feature_get_exten(), detect_disconnect(), and internal_featuremap_read().

01202 {
01203    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01204 
01205    if (chan) {
01206       cfg = get_feature_ds(chan);
01207    } else {
01208       cfg = ao2_global_obj_ref(globals);
01209    }
01210 
01211    if (!cfg) {
01212       return -1;
01213    }
01214 
01215    return featuremap_get(cfg->featuremap, feature, buf, len);
01216 }

struct ao2_container* ast_get_chan_applicationmap ( struct ast_channel chan  )  [read]

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:
chan The channel for which applicationmap is being retrieved.
Return values:
NULL An error occurred or the channel has no dynamic features.
non-NULL A container of applicationmap_items pertaining to the channel.

Definition at line 1293 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().

01294 {
01295    RAII_VAR(struct features_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
01296    struct ao2_container *applicationmap;
01297    char *group_names;
01298    char *name;
01299 
01300    if (!cfg) {
01301       return NULL;
01302    }
01303 
01304    if (!chan) {
01305       if (!cfg->applicationmap || ao2_container_count(cfg->applicationmap) == 0) {
01306          return NULL;
01307       }
01308       ao2_ref(cfg->applicationmap, +1);
01309       return cfg->applicationmap;
01310    }
01311 
01312    group_names = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"), ""));
01313    if (ast_strlen_zero(group_names)) {
01314       return NULL;
01315    }
01316 
01317    applicationmap = applicationmap_alloc(0);
01318    if (!applicationmap) {
01319       return NULL;
01320    }
01321 
01322    /* global config must be initialized */
01323    ast_assert(cfg->featuregroups != NULL);
01324    ast_assert(cfg->applicationmap != NULL);
01325    while ((name = strsep(&group_names, "#"))) {
01326       RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup);
01327 
01328       if (!group) {
01329          RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup);
01330 
01331          if (item) {
01332             ao2_link(applicationmap, item);
01333          } else {
01334             ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n",
01335                name, ast_channel_name(chan));
01336          }
01337       } else {
01338          ao2_callback(group->items, 0, add_item, applicationmap);
01339       }
01340    }
01341 
01342    if (ao2_container_count(applicationmap) == 0) {
01343       ao2_cleanup(applicationmap);
01344       return NULL;
01345    }
01346 
01347    return applicationmap;
01348 }

struct ast_featuremap_config* ast_get_chan_featuremap_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The pickup features configuration

Definition at line 1181 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().

01182 {
01183    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01184 
01185    if (chan) {
01186       cfg = get_feature_ds(chan);
01187    } else {
01188       cfg = ao2_global_obj_ref(globals);
01189    }
01190 
01191    if (!cfg) {
01192       return NULL;
01193    }
01194 
01195    ast_assert(cfg->featuremap != NULL);
01196 
01197    ao2_ref(cfg->featuremap, +1);
01198    return cfg->featuremap;
01199 }

struct ast_features_general_config* ast_get_chan_features_general_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The general features configuration

Definition at line 1121 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().

01122 {
01123    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01124 
01125    if (chan) {
01126       cfg = get_feature_ds(chan);
01127    } else {
01128       cfg = ao2_global_obj_ref(globals);
01129    }
01130 
01131    if (!cfg) {
01132       return NULL;
01133    }
01134 
01135    ast_assert(cfg->global && cfg->global->general);
01136 
01137    ao2_ref(cfg->global->general, +1);
01138    return cfg->global->general;
01139 }

struct ast_features_pickup_config* ast_get_chan_features_pickup_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The pickup features configuration

Definition at line 1161 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().

01162 {
01163    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01164 
01165    if (chan) {
01166       cfg = get_feature_ds(chan);
01167    } else {
01168       cfg = ao2_global_obj_ref(globals);
01169    }
01170 
01171    if (!cfg) {
01172       return NULL;
01173    }
01174 
01175    ast_assert(cfg->global && cfg->global->pickup);
01176 
01177    ao2_ref(cfg->global->pickup, +1);
01178    return cfg->global->pickup;
01179 }

struct ast_features_xfer_config* ast_get_chan_features_xfer_config ( struct ast_channel chan  )  [read]

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:
chan The channel to get configuration options for
Return values:
NULL Failed to get configuration
non-NULL The transfer features configuration

Definition at line 1141 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(), attended_transfer_properties_alloc(), bridge_exec(), grab_transfer(), and testsuite_notify_feature_success().

01142 {
01143    RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
01144 
01145    if (chan) {
01146       cfg = get_feature_ds(chan);
01147    } else {
01148       cfg = ao2_global_obj_ref(globals);
01149    }
01150 
01151    if (!cfg) {
01152       return NULL;
01153    }
01154 
01155    ast_assert(cfg->global && cfg->global->xfer);
01156 
01157    ao2_ref(cfg->global->xfer, +1);
01158    return cfg->global->xfer;
01159 }

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:
chan The channel to get the option from
feature The short name of the feature
[out] buf The buffer to write the DTMF value into
size The size of the buffer in bytes
Return values:
0 Success
non-zero Unrecognized feature name

Definition at line 1218 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().

01219 {
01220    RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
01221    RAII_VAR(struct ast_applicationmap_item *, item, NULL, ao2_cleanup);
01222 
01223    if (!ast_get_builtin_feature(chan, feature, buf, len)) {
01224       return 0;
01225    }
01226 
01227    /* Dang, must be in the application map */
01228    applicationmap = ast_get_chan_applicationmap(chan);
01229    if (!applicationmap) {
01230       return -1;
01231    }
01232 
01233    item = ao2_find(applicationmap, feature, OBJ_KEY);
01234    if (!item) {
01235       return -1;
01236    }
01237 
01238    ast_copy_string(buf, item->dtmf, len);
01239    return 0;
01240 }


Generated on Thu Apr 16 06:30:59 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6