49#include <netinet/in.h>
278 if (!(df_copy =
ast_calloc(1,
sizeof(*df)))) {
282 memcpy(df_copy, df,
sizeof(*df));
288 .
type =
"dial-features",
322 dialfeatures =
ast_calloc(1,
sizeof(*dialfeatures));
331 datastore->
data = dialfeatures;
364 if (!applicationmap) {
378 ast_log(
LOG_NOTICE,
"CHAN: name: %s; appl: %s; data: %s; contxt: %s; exten: %s; pri: %d;\n",
402 for (feature = features; *feature; feature++) {
405 if (isupper(*feature)) {
406 party = &
config->features_caller;
408 party = &
config->features_callee;
411 switch (tolower(*feature)) {
454 if (
config->warning_sound) {
458 if (
config->start_sound) {
564 int abandon_call = 0;
567 ast_log(
LOG_ERROR,
"Could not construct caller duration limits. Bridge canceled.\n");
573 ast_log(
LOG_ERROR,
"Could not construct callee duration limits. Bridge canceled.\n");
593 ast_log(
LOG_ERROR,
"Could not set duration limits on one or more sides of the call. Bridge canceled.\n");
614 if (res || !peer_features) {
672 if (res &&
config->end_bridge_callback) {
673 config->end_bridge_callback(
config->end_bridge_callback_data);
707 }
if (!strcasecmp(playtone_val,
"channel1")) {
709 }
else if (!strcasecmp(playtone_val,
"channel2") ||
ast_true(playtone_val)) {
711 }
else if (!strcasecmp(playtone_val,
"both")) {
739 const char *chana_exten;
740 const char *chana_context;
742 const char *chanb_exten;
743 const char *chanb_context;
756 ast_debug(1,
"Performing Bridge action on %s and %s\n", channela, channelb);
761 snprintf(
buf,
sizeof(
buf),
"Channel1 does not exist: %s", channela);
777 snprintf(
buf,
sizeof(
buf),
"Channel2 does not exist: %s", channelb);
864 char *parse,
struct timeval *calldurationlimit)
867 char *limit_str, *warning_str, *warnfreq_str;
869 int play_to_caller = 0, play_to_callee = 0;
872 limit_str =
strsep(&stringp,
":");
873 warning_str =
strsep(&stringp,
":");
874 warnfreq_str =
strsep(&stringp,
":");
876 config->timelimit = atol(limit_str);
878 config->play_warning = atol(warning_str);
880 config->warning_freq = atol(warnfreq_str);
887 }
else if ( (delta =
config->play_warning -
config->timelimit) > 0) {
888 int w =
config->warning_freq;
907 config->play_warning -= w * ( 1 + (delta-1)/w );
908 if (
config->play_warning < 1)
921 if (!play_to_caller && !play_to_callee)
942 calldurationlimit->tv_sec = 0;
943 calldurationlimit->tv_usec = 0;
947 calldurationlimit->tv_sec =
config->timelimit / 1000;
948 calldurationlimit->tv_usec = (
config->timelimit % 1000) * 1000;
949 ast_verb(3,
"Setting call duration limit to %.3lf seconds.\n",
950 calldurationlimit->tv_sec + calldurationlimit->tv_usec / 1000000.0);
957 ast_verb(4,
"Limit Data for this call:\n");
959 ast_verb(4,
"play_warning = %ld ms (%.3lf s)\n",
config->play_warning,
config->play_warning / 1000.0);
960 ast_verb(4,
"play_to_caller = %s\n", play_to_caller ?
"yes" :
"no");
961 ast_verb(4,
"play_to_callee = %s\n", play_to_callee ?
"yes" :
"no");
962 ast_verb(4,
"warning_freq = %ld ms (%.3lf s)\n",
config->warning_freq,
config->warning_freq / 1000.0);
987 char *tmp_data =
NULL;
991 struct timeval calldurationlimit = { 0, };
995 int bridge_add_failed;
1017 strlen(
args.dest_chan));
1019 if (!current_dest_chan) {
1020 ast_verb(4,
"Bridge failed because channel '%s' does not exist\n",
1021 args.dest_chan ?:
"");
1027 if (chan == current_dest_chan) {
1082 if (!peer_features) {
1107 if (bridge_add_failed) {
1164 .
requires =
"extconfig",
Prototypes for public functions only of internal interest,.
static int playtone(struct ast_channel *chan, int tone, int len)
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args, enum ast_bridge_join_flags flags)
Join a channel to a bridge (blocking)
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
@ AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP
@ AST_BRIDGE_IMPART_CHAN_INDEPENDENT
@ AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP
@ AST_BRIDGE_JOIN_PASS_REFERENCE
After Bridge Execution API.
int ast_bridge_setup_after_goto(struct ast_channel *chan)
Setup any after bridge goto location to begin execution.
void ast_bridge_set_after_go_on(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *parseable_goto)
Set channel to go on in the dialplan after the bridge.
void ast_bridge_set_after_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set channel to goto specific location after the bridge.
Basic bridge subclass API.
void ast_bridge_basic_set_flags(struct ast_bridge *bridge, unsigned int flags)
Set feature flags on a basic bridge.
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
int ast_bridge_features_ds_append(struct ast_channel *chan, struct ast_flags *flags)
Append basic bridge DTMF feature flags on the channel.
int ast_bridge_features_set_limits(struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)
Limit the amount of time a channel may stay in the bridge and optionally play warning messages as tim...
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
int ast_bridge_features_limits_construct(struct ast_bridge_features_limits *limits)
Constructor function for ast_bridge_features_limits.
struct ast_bridge_features * ast_bridge_features_new(void)
Allocate a new bridge features struct.
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
void ast_bridge_features_destroy(struct ast_bridge_features *features)
Destroy an allocated bridge features struct.
void ast_bridge_features_limits_destroy(struct ast_bridge_features_limits *limits)
Destructor function for ast_bridge_features_limits.
Internal Asterisk hangup causes.
static const char config[]
General Asterisk PBX channel definitions.
const char * ast_channel_linkedid(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
@ AST_FEATURE_PLAY_WARNING
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
const char * ast_channel_data(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define AST_BRIDGE_DTMF_CHANNEL_0
Report DTMF on channel 0.
int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer a channel passing in a stream topology.
#define DATASTORE_INHERIT_FOREVER
#define ast_channel_lock(chan)
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_accountcode(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
#define AST_BRIDGE_DTMF_CHANNEL_1
Report DTMF on channel 1.
const char * ast_channel_appl(const struct ast_channel *chan)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
const char * ast_channel_dialcontext(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
#define AST_FEATURE_DTMF_MASK
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
int ast_channel_visible_indication(const struct ast_channel *chan)
void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer)
Put chan into autoservice while hanging up peer.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
@ AST_SOFTHANGUP_ASYNCGOTO
ast_channel_state
ast_channel states
Standard Command Line Interface.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static void bridge_config_set_limits_warning_values(struct ast_bridge_config *config, struct ast_bridge_features_limits *limits)
static const struct ast_app_option bridge_exec_options[128]
void ast_channel_log(char *title, struct ast_channel *chan)
static int pre_bridge_setup(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, struct ast_bridge_features *chan_features, struct ast_bridge_features *peer_features, int noanswer)
static void add_features_datastores(struct ast_channel *caller, struct ast_channel *callee, struct ast_bridge_config *config)
int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config)
bridge the call and set CDR
static void bridge_config_set_limits(struct ast_bridge_config *config, struct ast_bridge_features_limits *caller_limits, struct ast_bridge_features_limits *callee_limits)
static int action_bridge(struct mansession *s, const struct message *m)
Bridge channels together.
static int bridge_exec(struct ast_channel *chan, const char *data)
Bridge channels.
int ast_bridge_call_with_flags(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, unsigned int flags)
Bridge a call, and add additional flags to the bridge.
int ast_bridge_timelimit(struct ast_channel *chan, struct ast_bridge_config *config, char *parse, struct timeval *calldurationlimit)
parse L option and read associated channel variables to set warning, warning frequency,...
static void set_config_flags(struct ast_channel *chan, struct ast_bridge_config *config)
static void bridge_failed_peer_goto(struct ast_channel *chan, struct ast_channel *peer)
static int load_module(void)
static enum play_tone_action parse_playtone(const char *playtone_val)
static void * dial_features_duplicate(void *data)
static int unload_module(void)
static const struct ast_datastore_info dial_features_info
@ FEATURE_INTERPRET_CHECK
@ FEATURE_INTERPRET_DETECT
static void set_bridge_features_on_config(struct ast_bridge_config *config, const char *features)
static int add_features_datastore(struct ast_channel *chan, const struct ast_flags *my_features, const struct ast_flags *peer_features)
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features, int play_tone, const char *xfersound)
Add an arbitrary channel to a bridge.
void unload_features_config(void)
int load_features_config(void)
int reload_features_config(void)
Generic File Format Support. Should be included by clients of the file handling routines....
globally accessible channel datastores
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
#define SCOPE_TRACE(__level,...)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Configuration File Parser.
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.
struct ao2_container * ast_get_chan_applicationmap(struct ast_channel *chan)
Get the applicationmap for a given channel.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
Asterisk locking-related definitions:
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
int ast_max_forwards_reset(struct ast_channel *chan)
Reset the max forwards on a channel to its starting value.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Say numbers and dates (maybe words one day too)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
const char * warning_sound
struct ast_flags features_callee
struct ast_flags features_caller
Structure that contains configuration information for the limits feature.
Structure that contains features information.
struct ast_channel * peer
struct ast_bridge_config bconfig
struct ast_channel * chan
unsigned int return_to_pbx
Structure that contains information about a bridge.
Main Channel structure associated with a channel.
Structure for a data store type.
Structure for a data store object.
struct ast_flags peer_features
struct ast_flags my_features
Feature configuration relating to transfers.
const ast_string_field xfersound
Structure used to handle boolean flags.
structure to hold extensions
In case you didn't read that giant block of text above the mansession_session struct,...
Support for translation of data formats. translate.c.
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_clear_flag(p, flag)
#define ast_set_flag(p, flag)
#define ast_copy_flags(dest, src, flagz)