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 | Enumerations | Functions | Variables
app_dial.c File Reference

dial() & retrydial() - Trivial application to dial a channel and send an URL on answer More...

#include "asterisk.h"
#include <sys/time.h>
#include <signal.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include "asterisk/paths.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/say.h"
#include "asterisk/config.h"
#include "asterisk/features.h"
#include "asterisk/musiconhold.h"
#include "asterisk/callerid.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/causes.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/manager.h"
#include "asterisk/privacy.h"
#include "asterisk/stringfields.h"
#include "asterisk/dsp.h"
#include "asterisk/aoc.h"
#include "asterisk/ccss.h"
#include "asterisk/indications.h"
#include "asterisk/framehook.h"
#include "asterisk/dial.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/bridge_after.h"
#include "asterisk/features_config.h"
#include "asterisk/max_forwards.h"
#include "asterisk/stream.h"
Include dependency graph for app_dial.c:

Go to the source code of this file.

Data Structures

struct  cause_args
 
struct  chanlist
 List of channel drivers. More...
 
struct  dial_head
 
struct  privacy_args
 

Macros

#define AST_MAX_WATCHERS   256
 
#define CAN_EARLY_BRIDGE(flags, chan, peer)
 
#define DIAL_CALLERID_ABSENT   (1LLU << 33) /* TRUE if caller id is not available for connected line. */
 
#define DIAL_NOFORWARDHTML   (1LLU << 32)
 
#define DIAL_STILLGOING   (1LLU << 31)
 
#define OPT_CALLEE_GO_ON   (1LLU << 36)
 
#define OPT_CALLER_ANSWER   (1LLU << 40)
 
#define OPT_CANCEL_ELSEWHERE   (1LLU << 34)
 
#define OPT_CANCEL_TIMEOUT   (1LLU << 37)
 
#define OPT_FORCE_CID_PRES   (1LLU << 39)
 
#define OPT_FORCE_CID_TAG   (1LLU << 38)
 
#define OPT_HANGUPCAUSE   (1LLU << 44)
 
#define OPT_HEARPULSING   (1LLU << 45)
 
#define OPT_PEER_H   (1LLU << 35)
 
#define OPT_PREDIAL_CALLEE   (1LLU << 41)
 
#define OPT_PREDIAL_CALLER   (1LLU << 42)
 
#define OPT_RING_WITH_EARLY_MEDIA   (1LLU << 43)
 
#define OPT_TOPOLOGY_PRESERVE   (1LLU << 46)
 

Enumerations

enum  {
  OPT_ANNOUNCE = (1 << 0) , OPT_RESETCDR = (1 << 1) , OPT_DTMF_EXIT = (1 << 2) , OPT_SENDDTMF = (1 << 3) ,
  OPT_FORCECLID = (1 << 4) , OPT_GO_ON = (1 << 5) , OPT_CALLEE_HANGUP = (1 << 6) , OPT_CALLER_HANGUP = (1 << 7) ,
  OPT_ORIGINAL_CLID = (1 << 8) , OPT_DURATION_LIMIT = (1 << 9) , OPT_MUSICBACK = (1 << 10) , OPT_SCREEN_NOINTRO = (1 << 12) ,
  OPT_SCREEN_NOCALLERID = (1 << 13) , OPT_IGNORE_CONNECTEDLINE = (1 << 14) , OPT_SCREENING = (1 << 15) , OPT_PRIVACY = (1 << 16) ,
  OPT_RINGBACK = (1 << 17) , OPT_DURATION_STOP = (1 << 18) , OPT_CALLEE_TRANSFER = (1 << 19) , OPT_CALLER_TRANSFER = (1 << 20) ,
  OPT_CALLEE_MONITOR = (1 << 21) , OPT_CALLER_MONITOR = (1 << 22) , OPT_GOTO = (1 << 23) , OPT_OPERMODE = (1 << 24) ,
  OPT_CALLEE_PARK = (1 << 25) , OPT_CALLER_PARK = (1 << 26) , OPT_IGNORE_FORWARDING = (1 << 27) , OPT_CALLEE_GOSUB = (1 << 28) ,
  OPT_CALLEE_MIXMONITOR = (1 << 29) , OPT_CALLER_MIXMONITOR = (1 << 30)
}
 
enum  {
  OPT_ARG_ANNOUNCE = 0 , OPT_ARG_SENDDTMF , OPT_ARG_GOTO , OPT_ARG_DURATION_LIMIT ,
  OPT_ARG_MUSICBACK , OPT_ARG_RINGBACK , OPT_ARG_CALLEE_GOSUB , OPT_ARG_CALLEE_GO_ON ,
  OPT_ARG_PRIVACY , OPT_ARG_DURATION_STOP , OPT_ARG_OPERMODE , OPT_ARG_SCREEN_NOINTRO ,
  OPT_ARG_ORIGINAL_CLID , OPT_ARG_FORCECLID , OPT_ARG_FORCE_CID_TAG , OPT_ARG_FORCE_CID_PRES ,
  OPT_ARG_PREDIAL_CALLEE , OPT_ARG_PREDIAL_CALLER , OPT_ARG_HANGUPCAUSE , OPT_ARG_ARRAY_SIZE
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static void chanlist_free (struct chanlist *outgoing)
 
static int detect_disconnect (struct ast_channel *chan, char code, struct ast_str **featurecode)
 
static int dial_exec (struct ast_channel *chan, const char *data)
 
static int dial_exec_full (struct ast_channel *chan, const char *data, struct ast_flags64 *peerflags, int *continue_exec)
 
static int dial_handle_playtones (struct ast_channel *chan, const char *data)
 
static void do_forward (struct chanlist *o, struct cause_args *num, struct ast_flags64 *peerflags, int single, int caller_entertained, int *to, struct ast_party_id *forced_clid, struct ast_party_id *stored_clid)
 
static void end_bridge_callback (void *data)
 
static void end_bridge_callback_data_fixup (struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator)
 
static const char * get_cid_name (char *name, int namelen, struct ast_channel *chan)
 
static void handle_cause (int cause, struct cause_args *num)
 
static void hanguptree (struct dial_head *out_chans, struct ast_channel *exception, int hangupcause)
 
static int load_module (void)
 
static int onedigit_goto (struct ast_channel *chan, const char *context, char exten, int pri)
 
static void publish_dial_end_event (struct ast_channel *in, struct dial_head *out_chans, struct ast_channel *exception, const char *status)
 
static int retrydial_exec (struct ast_channel *chan, const char *data)
 
static void set_duration_var (struct ast_channel *chan, const char *var_base, int64_t duration)
 
static void setup_peer_after_bridge_goto (struct ast_channel *chan, struct ast_channel *peer, struct ast_flags64 *opts, char *opt_args[])
 
static int setup_privacy_args (struct privacy_args *pa, struct ast_flags64 *opts, char *opt_args[], struct ast_channel *chan)
 returns 1 if successful, 0 or <0 if the caller should 'goto out' More...
 
static void topology_ds_destroy (void *data)
 
static int unload_module (void)
 
static void update_connected_line_from_peer (struct ast_channel *chan, struct ast_channel *peer, int is_caller)
 
static int valid_priv_reply (struct ast_flags64 *opts, int res)
 
static struct ast_channelwait_for_answer (struct ast_channel *in, struct dial_head *out_chans, int *to_answer, int *to_progress, struct ast_flags64 *peerflags, char *opt_args[], struct privacy_args *pa, const struct cause_args *num_in, int *result, char *dtmf_progress, char *mf_progress, char *mf_wink, char *sf_progress, char *sf_wink, const int hearpulsing, const int ignore_cc, struct ast_party_id *forced_clid, struct ast_party_id *stored_clid, struct ast_bridge_config *config)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Dialing Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "ccss", }
 
static const char app [] = "Dial"
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const struct ast_app_option dial_exec_options [128] = { [ 'A' ] = { .flag = OPT_ANNOUNCE , .arg_index = OPT_ARG_ANNOUNCE + 1 }, [ 'a' ] = { .flag = (1LLU << 40) }, [ 'b' ] = { .flag = (1LLU << 41) , .arg_index = OPT_ARG_PREDIAL_CALLEE + 1 }, [ 'B' ] = { .flag = (1LLU << 42) , .arg_index = OPT_ARG_PREDIAL_CALLER + 1 }, [ 'C' ] = { .flag = OPT_RESETCDR }, [ 'c' ] = { .flag = (1LLU << 34) }, [ 'd' ] = { .flag = OPT_DTMF_EXIT }, [ 'D' ] = { .flag = OPT_SENDDTMF , .arg_index = OPT_ARG_SENDDTMF + 1 }, [ 'E' ] = { .flag = (1LLU << 45) }, [ 'e' ] = { .flag = (1LLU << 35) }, [ 'f' ] = { .flag = OPT_FORCECLID , .arg_index = OPT_ARG_FORCECLID + 1 }, [ 'F' ] = { .flag = (1LLU << 36) , .arg_index = OPT_ARG_CALLEE_GO_ON + 1 }, [ 'g' ] = { .flag = OPT_GO_ON }, [ 'G' ] = { .flag = OPT_GOTO , .arg_index = OPT_ARG_GOTO + 1 }, [ 'h' ] = { .flag = OPT_CALLEE_HANGUP }, [ 'H' ] = { .flag = OPT_CALLER_HANGUP }, [ 'i' ] = { .flag = OPT_IGNORE_FORWARDING }, [ 'I' ] = { .flag = OPT_IGNORE_CONNECTEDLINE }, [ 'j' ] = { .flag = (1LLU << 46) }, [ 'k' ] = { .flag = OPT_CALLEE_PARK }, [ 'K' ] = { .flag = OPT_CALLER_PARK }, [ 'L' ] = { .flag = OPT_DURATION_LIMIT , .arg_index = OPT_ARG_DURATION_LIMIT + 1 }, [ 'm' ] = { .flag = OPT_MUSICBACK , .arg_index = OPT_ARG_MUSICBACK + 1 }, [ 'n' ] = { .flag = OPT_SCREEN_NOINTRO , .arg_index = OPT_ARG_SCREEN_NOINTRO + 1 }, [ 'N' ] = { .flag = OPT_SCREEN_NOCALLERID }, [ 'o' ] = { .flag = OPT_ORIGINAL_CLID , .arg_index = OPT_ARG_ORIGINAL_CLID + 1 }, [ 'O' ] = { .flag = OPT_OPERMODE , .arg_index = OPT_ARG_OPERMODE + 1 }, [ 'p' ] = { .flag = OPT_SCREENING }, [ 'P' ] = { .flag = OPT_PRIVACY , .arg_index = OPT_ARG_PRIVACY + 1 }, [ 'Q' ] = { .flag = (1LLU << 44) , .arg_index = OPT_ARG_HANGUPCAUSE + 1 }, [ 'r' ] = { .flag = OPT_RINGBACK , .arg_index = OPT_ARG_RINGBACK + 1 }, [ 'R' ] = { .flag = (1LLU << 43) }, [ 'S' ] = { .flag = OPT_DURATION_STOP , .arg_index = OPT_ARG_DURATION_STOP + 1 }, [ 's' ] = { .flag = (1LLU << 38) , .arg_index = OPT_ARG_FORCE_CID_TAG + 1 }, [ 't' ] = { .flag = OPT_CALLEE_TRANSFER }, [ 'T' ] = { .flag = OPT_CALLER_TRANSFER }, [ 'u' ] = { .flag = (1LLU << 39) , .arg_index = OPT_ARG_FORCE_CID_PRES + 1 }, [ 'U' ] = { .flag = OPT_CALLEE_GOSUB , .arg_index = OPT_ARG_CALLEE_GOSUB + 1 }, [ 'w' ] = { .flag = OPT_CALLEE_MONITOR }, [ 'W' ] = { .flag = OPT_CALLER_MONITOR }, [ 'x' ] = { .flag = OPT_CALLEE_MIXMONITOR }, [ 'X' ] = { .flag = OPT_CALLER_MIXMONITOR }, [ 'z' ] = { .flag = (1LLU << 37) }, }
 
static const char rapp [] = "RetryDial"
 
static const struct ast_datastore_info topology_ds_info
 

Detailed Description

dial() & retrydial() - Trivial application to dial a channel and send an URL on answer

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file app_dial.c.

Macro Definition Documentation

◆ AST_MAX_WATCHERS

#define AST_MAX_WATCHERS   256

Definition at line 864 of file app_dial.c.

◆ CAN_EARLY_BRIDGE

#define CAN_EARLY_BRIDGE (   flags,
  chan,
  peer 
)

Definition at line 793 of file app_dial.c.

◆ DIAL_CALLERID_ABSENT

#define DIAL_CALLERID_ABSENT   (1LLU << 33) /* TRUE if caller id is not available for connected line. */

Definition at line 708 of file app_dial.c.

◆ DIAL_NOFORWARDHTML

#define DIAL_NOFORWARDHTML   (1LLU << 32)

Definition at line 707 of file app_dial.c.

◆ DIAL_STILLGOING

#define DIAL_STILLGOING   (1LLU << 31)

Definition at line 706 of file app_dial.c.

◆ OPT_CALLEE_GO_ON

#define OPT_CALLEE_GO_ON   (1LLU << 36)

Definition at line 711 of file app_dial.c.

◆ OPT_CALLER_ANSWER

#define OPT_CALLER_ANSWER   (1LLU << 40)

Definition at line 715 of file app_dial.c.

◆ OPT_CANCEL_ELSEWHERE

#define OPT_CANCEL_ELSEWHERE   (1LLU << 34)

Definition at line 709 of file app_dial.c.

◆ OPT_CANCEL_TIMEOUT

#define OPT_CANCEL_TIMEOUT   (1LLU << 37)

Definition at line 712 of file app_dial.c.

◆ OPT_FORCE_CID_PRES

#define OPT_FORCE_CID_PRES   (1LLU << 39)

Definition at line 714 of file app_dial.c.

◆ OPT_FORCE_CID_TAG

#define OPT_FORCE_CID_TAG   (1LLU << 38)

Definition at line 713 of file app_dial.c.

◆ OPT_HANGUPCAUSE

#define OPT_HANGUPCAUSE   (1LLU << 44)

Definition at line 719 of file app_dial.c.

◆ OPT_HEARPULSING

#define OPT_HEARPULSING   (1LLU << 45)

Definition at line 720 of file app_dial.c.

◆ OPT_PEER_H

#define OPT_PEER_H   (1LLU << 35)

Definition at line 710 of file app_dial.c.

◆ OPT_PREDIAL_CALLEE

#define OPT_PREDIAL_CALLEE   (1LLU << 41)

Definition at line 716 of file app_dial.c.

◆ OPT_PREDIAL_CALLER

#define OPT_PREDIAL_CALLER   (1LLU << 42)

Definition at line 717 of file app_dial.c.

◆ OPT_RING_WITH_EARLY_MEDIA

#define OPT_RING_WITH_EARLY_MEDIA   (1LLU << 43)

Definition at line 718 of file app_dial.c.

◆ OPT_TOPOLOGY_PRESERVE

#define OPT_TOPOLOGY_PRESERVE   (1LLU << 46)

Definition at line 721 of file app_dial.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OPT_ANNOUNCE 
OPT_RESETCDR 
OPT_DTMF_EXIT 
OPT_SENDDTMF 
OPT_FORCECLID 
OPT_GO_ON 
OPT_CALLEE_HANGUP 
OPT_CALLER_HANGUP 
OPT_ORIGINAL_CLID 
OPT_DURATION_LIMIT 
OPT_MUSICBACK 
OPT_SCREEN_NOINTRO 
OPT_SCREEN_NOCALLERID 
OPT_IGNORE_CONNECTEDLINE 
OPT_SCREENING 
OPT_PRIVACY 
OPT_RINGBACK 
OPT_DURATION_STOP 
OPT_CALLEE_TRANSFER 
OPT_CALLER_TRANSFER 
OPT_CALLEE_MONITOR 
OPT_CALLER_MONITOR 
OPT_GOTO 
OPT_OPERMODE 
OPT_CALLEE_PARK 
OPT_CALLER_PARK 
OPT_IGNORE_FORWARDING 
OPT_CALLEE_GOSUB 
OPT_CALLEE_MIXMONITOR 
OPT_CALLER_MIXMONITOR 

Definition at line 672 of file app_dial.c.

672 {
673 OPT_ANNOUNCE = (1 << 0),
674 OPT_RESETCDR = (1 << 1),
675 OPT_DTMF_EXIT = (1 << 2),
676 OPT_SENDDTMF = (1 << 3),
677 OPT_FORCECLID = (1 << 4),
678 OPT_GO_ON = (1 << 5),
679 OPT_CALLEE_HANGUP = (1 << 6),
680 OPT_CALLER_HANGUP = (1 << 7),
681 OPT_ORIGINAL_CLID = (1 << 8),
682 OPT_DURATION_LIMIT = (1 << 9),
683 OPT_MUSICBACK = (1 << 10),
684 OPT_SCREEN_NOINTRO = (1 << 12),
685 OPT_SCREEN_NOCALLERID = (1 << 13),
686 OPT_IGNORE_CONNECTEDLINE = (1 << 14),
687 OPT_SCREENING = (1 << 15),
688 OPT_PRIVACY = (1 << 16),
689 OPT_RINGBACK = (1 << 17),
690 OPT_DURATION_STOP = (1 << 18),
691 OPT_CALLEE_TRANSFER = (1 << 19),
692 OPT_CALLER_TRANSFER = (1 << 20),
693 OPT_CALLEE_MONITOR = (1 << 21),
694 OPT_CALLER_MONITOR = (1 << 22),
695 OPT_GOTO = (1 << 23),
696 OPT_OPERMODE = (1 << 24),
697 OPT_CALLEE_PARK = (1 << 25),
698 OPT_CALLER_PARK = (1 << 26),
699 OPT_IGNORE_FORWARDING = (1 << 27),
700 OPT_CALLEE_GOSUB = (1 << 28),
701 OPT_CALLEE_MIXMONITOR = (1 << 29),
702 OPT_CALLER_MIXMONITOR = (1 << 30),
703};
@ OPT_RESETCDR
Definition: app_dial.c:674
@ OPT_SCREEN_NOINTRO
Definition: app_dial.c:684
@ OPT_DTMF_EXIT
Definition: app_dial.c:675
@ OPT_ANNOUNCE
Definition: app_dial.c:673
@ OPT_CALLEE_PARK
Definition: app_dial.c:697
@ OPT_DURATION_LIMIT
Definition: app_dial.c:682
@ OPT_SCREEN_NOCALLERID
Definition: app_dial.c:685
@ OPT_IGNORE_FORWARDING
Definition: app_dial.c:699
@ OPT_OPERMODE
Definition: app_dial.c:696
@ OPT_DURATION_STOP
Definition: app_dial.c:690
@ OPT_GO_ON
Definition: app_dial.c:678
@ OPT_RINGBACK
Definition: app_dial.c:689
@ OPT_GOTO
Definition: app_dial.c:695
@ OPT_IGNORE_CONNECTEDLINE
Definition: app_dial.c:686
@ OPT_CALLEE_TRANSFER
Definition: app_dial.c:691
@ OPT_SENDDTMF
Definition: app_dial.c:676
@ OPT_CALLER_MIXMONITOR
Definition: app_dial.c:702
@ OPT_CALLER_PARK
Definition: app_dial.c:698
@ OPT_CALLER_MONITOR
Definition: app_dial.c:694
@ OPT_CALLEE_MONITOR
Definition: app_dial.c:693
@ OPT_CALLEE_GOSUB
Definition: app_dial.c:700
@ OPT_CALLER_HANGUP
Definition: app_dial.c:680
@ OPT_FORCECLID
Definition: app_dial.c:677
@ OPT_CALLEE_HANGUP
Definition: app_dial.c:679
@ OPT_SCREENING
Definition: app_dial.c:687
@ OPT_MUSICBACK
Definition: app_dial.c:683
@ OPT_CALLER_TRANSFER
Definition: app_dial.c:692
@ OPT_CALLEE_MIXMONITOR
Definition: app_dial.c:701
@ OPT_ORIGINAL_CLID
Definition: app_dial.c:681
@ OPT_PRIVACY
Definition: app_dial.c:688

◆ anonymous enum

anonymous enum
Enumerator
OPT_ARG_ANNOUNCE 
OPT_ARG_SENDDTMF 
OPT_ARG_GOTO 
OPT_ARG_DURATION_LIMIT 
OPT_ARG_MUSICBACK 
OPT_ARG_RINGBACK 
OPT_ARG_CALLEE_GOSUB 
OPT_ARG_CALLEE_GO_ON 
OPT_ARG_PRIVACY 
OPT_ARG_DURATION_STOP 
OPT_ARG_OPERMODE 
OPT_ARG_SCREEN_NOINTRO 
OPT_ARG_ORIGINAL_CLID 
OPT_ARG_FORCECLID 
OPT_ARG_FORCE_CID_TAG 
OPT_ARG_FORCE_CID_PRES 
OPT_ARG_PREDIAL_CALLEE 
OPT_ARG_PREDIAL_CALLER 
OPT_ARG_HANGUPCAUSE 
OPT_ARG_ARRAY_SIZE 

Definition at line 723 of file app_dial.c.

723 {
743 /* note: this entry _MUST_ be the last one in the enum */
745};
@ OPT_ARG_CALLEE_GO_ON
Definition: app_dial.c:731
@ OPT_ARG_SENDDTMF
Definition: app_dial.c:725
@ OPT_ARG_DURATION_STOP
Definition: app_dial.c:733
@ OPT_ARG_PREDIAL_CALLEE
Definition: app_dial.c:740
@ OPT_ARG_RINGBACK
Definition: app_dial.c:729
@ OPT_ARG_MUSICBACK
Definition: app_dial.c:728
@ OPT_ARG_CALLEE_GOSUB
Definition: app_dial.c:730
@ OPT_ARG_HANGUPCAUSE
Definition: app_dial.c:742
@ OPT_ARG_FORCE_CID_PRES
Definition: app_dial.c:739
@ OPT_ARG_ANNOUNCE
Definition: app_dial.c:724
@ OPT_ARG_GOTO
Definition: app_dial.c:726
@ OPT_ARG_DURATION_LIMIT
Definition: app_dial.c:727
@ OPT_ARG_ORIGINAL_CLID
Definition: app_dial.c:736
@ OPT_ARG_OPERMODE
Definition: app_dial.c:734
@ OPT_ARG_FORCECLID
Definition: app_dial.c:737
@ OPT_ARG_PREDIAL_CALLER
Definition: app_dial.c:741
@ OPT_ARG_ARRAY_SIZE
Definition: app_dial.c:744
@ OPT_ARG_PRIVACY
Definition: app_dial.c:732
@ OPT_ARG_SCREEN_NOINTRO
Definition: app_dial.c:735
@ OPT_ARG_FORCE_CID_TAG
Definition: app_dial.c:738

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 3616 of file app_dial.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 3616 of file app_dial.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 3616 of file app_dial.c.

◆ chanlist_free()

static void chanlist_free ( struct chanlist outgoing)
static

Definition at line 838 of file app_dial.c.

839{
841 ast_aoc_destroy_decoded(outgoing->aoc_s_rate_list);
842 ast_free(outgoing->orig_chan_name);
844}
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
Definition: aoc.c:316
#define ast_free(a)
Definition: astmm.h:180
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2039

References ast_aoc_destroy_decoded(), ast_free, and ast_party_connected_line_free().

Referenced by dial_exec_full(), and hanguptree().

◆ detect_disconnect()

static int detect_disconnect ( struct ast_channel chan,
char  code,
struct ast_str **  featurecode 
)
static

Definition at line 1960 of file app_dial.c.

1961{
1962 char disconnect_code[AST_FEATURE_MAX_LEN];
1963 int res;
1964
1965 ast_str_append(featurecode, 1, "%c", code);
1966
1967 res = ast_get_builtin_feature(chan, "disconnect", disconnect_code, sizeof(disconnect_code));
1968 if (res) {
1969 ast_str_reset(*featurecode);
1970 return 0;
1971 }
1972
1973 if (strlen(disconnect_code) > ast_str_strlen(*featurecode)) {
1974 /* Could be a partial match, anyway */
1975 if (strncmp(disconnect_code, ast_str_buffer(*featurecode), ast_str_strlen(*featurecode))) {
1976 ast_str_reset(*featurecode);
1977 }
1978 return 0;
1979 }
1980
1981 if (strcmp(disconnect_code, ast_str_buffer(*featurecode))) {
1982 ast_str_reset(*featurecode);
1983 return 0;
1984 }
1985
1986 return 1;
1987}
#define AST_FEATURE_MAX_LEN
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.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:693
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730

References AST_FEATURE_MAX_LEN, ast_get_builtin_feature(), ast_str_append(), ast_str_buffer(), ast_str_reset(), and ast_str_strlen().

Referenced by wait_for_answer().

◆ dial_exec()

static int dial_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 3474 of file app_dial.c.

3475{
3476 struct ast_flags64 peerflags;
3477
3478 memset(&peerflags, 0, sizeof(peerflags));
3479
3480 return dial_exec_full(chan, data, &peerflags, NULL);
3481}
static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast_flags64 *peerflags, int *continue_exec)
Definition: app_dial.c:2314
#define NULL
Definition: resample.c:96
Structure used to handle a large number of boolean flags == used only in app_dial?
Definition: utils.h:204

References dial_exec_full(), and NULL.

Referenced by load_module().

◆ dial_exec_full()

static int dial_exec_full ( struct ast_channel chan,
const char *  data,
struct ast_flags64 peerflags,
int *  continue_exec 
)
static

< TRUE if force CallerID on call forward only. Legacy behaviour.

Forced CallerID party information to send.

Note
This will not have any malloced strings so do not free it.

Stored CallerID information if needed.

Note
If OPT_ORIGINAL_CLID set then this is the o option CallerID. Otherwise it is the dialplan extension and hint name.
This will not have any malloced strings so do not free it.

CallerID party information to store.

Note
This will not have any malloced strings so do not free it.

Definition at line 2314 of file app_dial.c.

2315{
2316 int res = -1; /* default: error */
2317 char *rest, *cur; /* scan the list of destinations */
2318 struct dial_head out_chans = AST_LIST_HEAD_NOLOCK_INIT_VALUE; /* list of destinations */
2319 struct chanlist *outgoing;
2320 struct chanlist *tmp;
2321 struct ast_channel *peer = NULL;
2322 int to_answer, to_progress; /* timeouts */
2323 struct cause_args num = { chan, 0, 0, 0 };
2324 int cause, hanguptreecause = -1;
2325
2326 struct ast_bridge_config config = { { 0, } };
2327 struct timeval calldurationlimit = { 0, };
2328 char *dtmfcalled = NULL, *dtmfcalling = NULL, *dtmf_progress = NULL;
2329 char *mf_progress = NULL, *mf_wink = NULL;
2330 char *sf_progress = NULL, *sf_wink = NULL;
2331 struct privacy_args pa = {
2332 .sentringing = 0,
2333 .privdb_val = 0,
2334 .status = "INVALIDARGS",
2335 .canceled = 0,
2336 };
2337 int sentringing = 0, moh = 0;
2338 const char *outbound_group = NULL;
2339 int result = 0;
2340 char *parse;
2341 int opermode = 0;
2342 int delprivintro = 0;
2345 AST_APP_ARG(timeout);
2348 );
2349 struct ast_flags64 opts = { 0, };
2350 char *opt_args[OPT_ARG_ARRAY_SIZE];
2351 int fulldial = 0, num_dialed = 0;
2352 int ignore_cc = 0;
2353 char device_name[AST_CHANNEL_NAME];
2354 char forced_clid_name[AST_MAX_EXTENSION];
2355 char stored_clid_name[AST_MAX_EXTENSION];
2356 int force_forwards_only; /*!< TRUE if force CallerID on call forward only. Legacy behaviour.*/
2357 /*!
2358 * \brief Forced CallerID party information to send.
2359 * \note This will not have any malloced strings so do not free it.
2360 */
2361 struct ast_party_id forced_clid;
2362 /*!
2363 * \brief Stored CallerID information if needed.
2364 *
2365 * \note If OPT_ORIGINAL_CLID set then this is the o option
2366 * CallerID. Otherwise it is the dialplan extension and hint
2367 * name.
2368 *
2369 * \note This will not have any malloced strings so do not free it.
2370 */
2371 struct ast_party_id stored_clid;
2372 /*!
2373 * \brief CallerID party information to store.
2374 * \note This will not have any malloced strings so do not free it.
2375 */
2376 struct ast_party_caller caller;
2377 int max_forwards;
2378 struct ast_datastore *topology_ds = NULL;
2379 SCOPE_ENTER(1, "%s: Data: %s\n", ast_channel_name(chan), data);
2380
2381 /* Reset all DIAL variables back to blank, to prevent confusion (in case we don't reset all of them). */
2382 ast_channel_lock(chan);
2384 pbx_builtin_setvar_helper(chan, "DIALSTATUS", "");
2385 pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", "");
2386 pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", "");
2387 pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", "");
2388 pbx_builtin_setvar_helper(chan, "ANSWEREDTIME_MS", "");
2389 pbx_builtin_setvar_helper(chan, "DIALEDTIME", "");
2390 pbx_builtin_setvar_helper(chan, "DIALEDTIME_MS", "");
2391 pbx_builtin_setvar_helper(chan, "RINGTIME", "");
2392 pbx_builtin_setvar_helper(chan, "RINGTIME_MS", "");
2393 pbx_builtin_setvar_helper(chan, "PROGRESSTIME", "");
2394 pbx_builtin_setvar_helper(chan, "PROGRESSTIME_MS", "");
2397 ast_channel_unlock(chan);
2398
2399 if (max_forwards <= 0) {
2400 ast_log(LOG_WARNING, "Cannot place outbound call from channel '%s'. Max forwards exceeded\n",
2401 ast_channel_name(chan));
2402 pbx_builtin_setvar_helper(chan, "DIALSTATUS", "BUSY");
2403 SCOPE_EXIT_RTN_VALUE(-1, "%s: Max forwards exceeded\n", ast_channel_name(chan));
2404 }
2405
2406 if (ast_check_hangup_locked(chan)) {
2407 /*
2408 * Caller hung up before we could dial. If dial is executed
2409 * within an AGI then the AGI has likely eaten all queued
2410 * frames before executing the dial in DeadAGI mode. With
2411 * the caller hung up and no pending frames from the caller's
2412 * read queue, dial would not know that the call has hung up
2413 * until a called channel answers. It is rather annoying to
2414 * whoever just answered the non-existent call.
2415 *
2416 * Dial should not continue execution in DeadAGI mode, hangup
2417 * handlers, or the h exten.
2418 */
2419 ast_verb(3, "Caller hung up before dial.\n");
2420 pbx_builtin_setvar_helper(chan, "DIALSTATUS", "CANCEL");
2421 SCOPE_EXIT_RTN_VALUE(-1, "%s: Caller hung up before dial\n", ast_channel_name(chan));
2422 }
2423
2424 parse = ast_strdupa(data ?: "");
2425
2427
2428 if (!ast_strlen_zero(args.options) &&
2429 ast_app_parse_options64(dial_exec_options, &opts, opt_args, args.options)) {
2430 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
2431 goto done;
2432 }
2433
2434 if (ast_cc_call_init(chan, &ignore_cc)) {
2435 goto done;
2436 }
2437
2439 delprivintro = atoi(opt_args[OPT_ARG_SCREEN_NOINTRO]);
2440
2441 if (delprivintro < 0 || delprivintro > 1) {
2442 ast_log(LOG_WARNING, "Unknown argument %d specified to n option, ignoring\n", delprivintro);
2443 delprivintro = 0;
2444 }
2445 }
2446
2447 if (!ast_test_flag64(&opts, OPT_RINGBACK)) {
2448 opt_args[OPT_ARG_RINGBACK] = NULL;
2449 }
2450
2451 if (ast_test_flag64(&opts, OPT_OPERMODE)) {
2452 opermode = ast_strlen_zero(opt_args[OPT_ARG_OPERMODE]) ? 1 : atoi(opt_args[OPT_ARG_OPERMODE]);
2453 ast_verb(3, "Setting operator services mode to %d.\n", opermode);
2454 }
2455
2457 calldurationlimit.tv_sec = atoi(opt_args[OPT_ARG_DURATION_STOP]);
2458 if (!calldurationlimit.tv_sec) {
2459 ast_log(LOG_WARNING, "Dial does not accept S(%s)\n", opt_args[OPT_ARG_DURATION_STOP]);
2460 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
2461 goto done;
2462 }
2463 ast_verb(3, "Setting call duration limit to %.3lf seconds.\n", calldurationlimit.tv_sec + calldurationlimit.tv_usec / 1000000.0);
2464 }
2465
2466 if (ast_test_flag64(&opts, OPT_SENDDTMF) && !ast_strlen_zero(opt_args[OPT_ARG_SENDDTMF])) {
2467 sf_wink = opt_args[OPT_ARG_SENDDTMF];
2468 dtmfcalled = strsep(&sf_wink, ":");
2469 dtmfcalling = strsep(&sf_wink, ":");
2470 dtmf_progress = strsep(&sf_wink, ":");
2471 mf_progress = strsep(&sf_wink, ":");
2472 mf_wink = strsep(&sf_wink, ":");
2473 sf_progress = strsep(&sf_wink, ":");
2474 }
2475
2477 if (ast_bridge_timelimit(chan, &config, opt_args[OPT_ARG_DURATION_LIMIT], &calldurationlimit))
2478 goto done;
2479 }
2480
2481 /* Setup the forced CallerID information to send if used. */
2482 ast_party_id_init(&forced_clid);
2483 force_forwards_only = 0;
2484 if (ast_test_flag64(&opts, OPT_FORCECLID)) {
2485 if (ast_strlen_zero(opt_args[OPT_ARG_FORCECLID])) {
2486 ast_channel_lock(chan);
2487 forced_clid.number.str = ast_strdupa(ast_channel_exten(chan));
2488 ast_channel_unlock(chan);
2489 forced_clid_name[0] = '\0';
2490 forced_clid.name.str = (char *) get_cid_name(forced_clid_name,
2491 sizeof(forced_clid_name), chan);
2492 force_forwards_only = 1;
2493 } else {
2494 /* Note: The opt_args[OPT_ARG_FORCECLID] string value is altered here. */
2495 ast_callerid_parse(opt_args[OPT_ARG_FORCECLID], &forced_clid.name.str,
2496 &forced_clid.number.str);
2497 }
2498 if (!ast_strlen_zero(forced_clid.name.str)) {
2499 forced_clid.name.valid = 1;
2500 }
2501 if (!ast_strlen_zero(forced_clid.number.str)) {
2502 forced_clid.number.valid = 1;
2503 }
2504 }
2506 && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_TAG])) {
2507 forced_clid.tag = opt_args[OPT_ARG_FORCE_CID_TAG];
2508 }
2509 forced_clid.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
2511 && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_PRES])) {
2512 int pres;
2513
2515 if (0 <= pres) {
2516 forced_clid.number.presentation = pres;
2517 }
2518 }
2519
2520 /* Setup the stored CallerID information if needed. */
2521 ast_party_id_init(&stored_clid);
2522 if (ast_test_flag64(&opts, OPT_ORIGINAL_CLID)) {
2523 if (ast_strlen_zero(opt_args[OPT_ARG_ORIGINAL_CLID])) {
2524 ast_channel_lock(chan);
2525 ast_party_id_set_init(&stored_clid, &ast_channel_caller(chan)->id);
2526 if (!ast_strlen_zero(ast_channel_caller(chan)->id.name.str)) {
2527 stored_clid.name.str = ast_strdupa(ast_channel_caller(chan)->id.name.str);
2528 }
2529 if (!ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) {
2530 stored_clid.number.str = ast_strdupa(ast_channel_caller(chan)->id.number.str);
2531 }
2532 if (!ast_strlen_zero(ast_channel_caller(chan)->id.subaddress.str)) {
2533 stored_clid.subaddress.str = ast_strdupa(ast_channel_caller(chan)->id.subaddress.str);
2534 }
2535 if (!ast_strlen_zero(ast_channel_caller(chan)->id.tag)) {
2536 stored_clid.tag = ast_strdupa(ast_channel_caller(chan)->id.tag);
2537 }
2538 ast_channel_unlock(chan);
2539 } else {
2540 /* Note: The opt_args[OPT_ARG_ORIGINAL_CLID] string value is altered here. */
2541 ast_callerid_parse(opt_args[OPT_ARG_ORIGINAL_CLID], &stored_clid.name.str,
2542 &stored_clid.number.str);
2543 if (!ast_strlen_zero(stored_clid.name.str)) {
2544 stored_clid.name.valid = 1;
2545 }
2546 if (!ast_strlen_zero(stored_clid.number.str)) {
2547 stored_clid.number.valid = 1;
2548 }
2549 }
2550 } else {
2551 /*
2552 * In case the new channel has no preset CallerID number by the
2553 * channel driver, setup the dialplan extension and hint name.
2554 */
2555 stored_clid_name[0] = '\0';
2556 stored_clid.name.str = (char *) get_cid_name(stored_clid_name,
2557 sizeof(stored_clid_name), chan);
2558 if (ast_strlen_zero(stored_clid.name.str)) {
2559 stored_clid.name.str = NULL;
2560 } else {
2561 stored_clid.name.valid = 1;
2562 }
2563 ast_channel_lock(chan);
2564 stored_clid.number.str = ast_strdupa(ast_channel_exten(chan));
2565 stored_clid.number.valid = 1;
2566 ast_channel_unlock(chan);
2567 }
2568
2569 if (ast_test_flag64(&opts, OPT_RESETCDR)) {
2571 }
2574
2576 res = setup_privacy_args(&pa, &opts, opt_args, chan);
2577 if (res <= 0)
2578 goto out;
2579 res = -1; /* reset default */
2580 }
2581
2582 if (continue_exec)
2583 *continue_exec = 0;
2584
2585 /* If a channel group has been specified, get it for use when we create peer channels */
2586
2587 ast_channel_lock(chan);
2588 if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP_ONCE"))) {
2589 outbound_group = ast_strdupa(outbound_group);
2590 pbx_builtin_setvar_helper(chan, "OUTBOUND_GROUP_ONCE", NULL);
2591 } else if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP"))) {
2592 outbound_group = ast_strdupa(outbound_group);
2593 }
2594 ast_channel_unlock(chan);
2595
2596 /* Set per dial instance flags. These flags are also passed back to RetryDial. */
2600
2601 /* PREDIAL: Run gosub on the caller's channel */
2603 && !ast_strlen_zero(opt_args[OPT_ARG_PREDIAL_CALLER])) {
2605 ast_app_exec_sub(NULL, chan, opt_args[OPT_ARG_PREDIAL_CALLER], 0);
2606 }
2607
2608 /* loop through the list of dial destinations */
2609 rest = args.peers;
2610 while ((cur = strsep(&rest, "&"))) {
2611 struct ast_channel *tc; /* channel for this destination */
2612 char *number;
2613 char *tech;
2614 int i;
2615 size_t tech_len;
2616 size_t number_len;
2617 struct ast_stream_topology *topology;
2618 struct ast_stream *stream;
2619
2620 cur = ast_strip(cur);
2621 if (ast_strlen_zero(cur)) {
2622 /* No tech/resource in this position. */
2623 continue;
2624 }
2625
2626 /* Get a technology/resource pair */
2627 number = cur;
2628 tech = strsep(&number, "/");
2629
2630 num_dialed++;
2631 if (ast_strlen_zero(number)) {
2632 ast_log(LOG_WARNING, "Dial argument takes format (technology/resource)\n");
2633 goto out;
2634 }
2635
2636 tech_len = strlen(tech) + 1;
2637 number_len = strlen(number) + 1;
2638 tmp = ast_calloc(1, sizeof(*tmp) + (2 * tech_len) + number_len);
2639 if (!tmp) {
2640 goto out;
2641 }
2642
2643 /* Save tech, number, and interface. */
2644 cur = tmp->stuff;
2645 strcpy(cur, tech);
2646 tmp->tech = cur;
2647 cur += tech_len;
2648 strcpy(cur, tech);
2649 cur[tech_len - 1] = '/';
2650 tmp->interface = cur;
2651 cur += tech_len;
2652 strcpy(cur, number);
2653 tmp->number = cur;
2654
2655 if (opts.flags) {
2656 /* Set per outgoing call leg options. */
2657 ast_copy_flags64(tmp, &opts,
2667 }
2668
2669 /* Request the peer */
2670
2671 ast_channel_lock(chan);
2672 /*
2673 * Seed the chanlist's connected line information with previously
2674 * acquired connected line info from the incoming channel. The
2675 * previously acquired connected line info could have been set
2676 * through the CONNECTED_LINE dialplan function.
2677 */
2679
2681 topology_ds = ast_channel_datastore_find(chan, &topology_ds_info, NULL);
2682
2683 if (!topology_ds && (topology_ds = ast_datastore_alloc(&topology_ds_info, NULL))) {
2685 ast_channel_datastore_add(chan, topology_ds);
2686 }
2687 }
2688
2689 if (topology_ds) {
2690 ao2_ref(topology_ds->data, +1);
2691 topology = topology_ds->data;
2692 } else {
2694 }
2695
2696 ast_channel_unlock(chan);
2697
2698 for (i = 0; i < ast_stream_topology_get_count(topology); ++i) {
2699 stream = ast_stream_topology_get_stream(topology, i);
2700 /* For both recvonly and sendonly the stream state reflects our state, that is we
2701 * are receiving only and we are sending only. Since we are requesting a
2702 * channel for the peer, we need to swap this to reflect what we will be doing.
2703 * That is, if we are receiving from Alice then we want to be sending to Bob,
2704 * so swap recvonly to sendonly and vice versa.
2705 */
2708 } else if (ast_stream_get_state(stream) == AST_STREAM_STATE_SENDONLY) {
2710 }
2711 }
2712
2713 tc = ast_request_with_stream_topology(tmp->tech, topology, NULL, chan, tmp->number, &cause);
2714
2715 ast_stream_topology_free(topology);
2716
2717 if (!tc) {
2718 /* If we can't, just go on to the next call */
2719 /* Failure doesn't necessarily mean user error. DAHDI channels could be busy. */
2720 ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n",
2721 tmp->tech, cause, ast_cause2str(cause));
2722 handle_cause(cause, &num);
2723 if (!rest) {
2724 /* we are on the last destination */
2725 ast_channel_hangupcause_set(chan, cause);
2726 }
2727 if (!ignore_cc && (cause == AST_CAUSE_BUSY || cause == AST_CAUSE_CONGESTION)) {
2728 if (!ast_cc_callback(chan, tmp->tech, tmp->number, ast_cc_busy_interface)) {
2730 }
2731 }
2732 chanlist_free(tmp);
2733 continue;
2734 }
2735
2736 ast_channel_get_device_name(tc, device_name, sizeof(device_name));
2737 if (!ignore_cc) {
2738 ast_cc_extension_monitor_add_dialstring(chan, tmp->interface, device_name);
2739 }
2740
2741 ast_channel_lock_both(tc, chan);
2743
2744 pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", tmp->number);
2745
2746 /* Setup outgoing SDP to match incoming one */
2747 if (!AST_LIST_FIRST(&out_chans) && !rest && CAN_EARLY_BRIDGE(peerflags, chan, tc)) {
2748 /* We are on the only destination. */
2750 }
2751
2752 /* Inherit specially named variables from parent channel */
2756
2757 ast_channel_appl_set(tc, "AppDial");
2758 ast_channel_data_set(tc, "(Outgoing Line)");
2759
2760 memset(ast_channel_whentohangup(tc), 0, sizeof(*ast_channel_whentohangup(tc)));
2761
2762 /* Determine CallerID to store in outgoing channel. */
2764 if (ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
2765 caller.id = stored_clid;
2766 ast_channel_set_caller_event(tc, &caller, NULL);
2768 } else if (ast_strlen_zero(S_COR(ast_channel_caller(tc)->id.number.valid,
2769 ast_channel_caller(tc)->id.number.str, NULL))) {
2770 /*
2771 * The new channel has no preset CallerID number by the channel
2772 * driver. Use the dialplan extension and hint name.
2773 */
2774 caller.id = stored_clid;
2775 if (!caller.id.name.valid
2776 && !ast_strlen_zero(S_COR(ast_channel_connected(chan)->id.name.valid,
2777 ast_channel_connected(chan)->id.name.str, NULL))) {
2778 /*
2779 * No hint name available. We have a connected name supplied by
2780 * the dialplan we can use instead.
2781 */
2782 caller.id.name.valid = 1;
2783 caller.id.name = ast_channel_connected(chan)->id.name;
2784 }
2785 ast_channel_set_caller_event(tc, &caller, NULL);
2787 } else if (ast_strlen_zero(S_COR(ast_channel_caller(tc)->id.name.valid, ast_channel_caller(tc)->id.name.str,
2788 NULL))) {
2789 /* The new channel has no preset CallerID name by the channel driver. */
2790 if (!ast_strlen_zero(S_COR(ast_channel_connected(chan)->id.name.valid,
2791 ast_channel_connected(chan)->id.name.str, NULL))) {
2792 /*
2793 * We have a connected name supplied by the dialplan we can
2794 * use instead.
2795 */
2796 caller.id.name.valid = 1;
2797 caller.id.name = ast_channel_connected(chan)->id.name;
2798 ast_channel_set_caller_event(tc, &caller, NULL);
2799 }
2800 }
2801
2802 /* Determine CallerID for outgoing channel to send. */
2803 if (ast_test_flag64(peerflags, OPT_FORCECLID) && !force_forwards_only) {
2805
2807 connected.id = forced_clid;
2809 } else {
2811 }
2812
2814
2816
2819 ast_channel_musicclass_set(tc, ast_channel_musicclass(chan));
2820 }
2821
2822 /* Pass ADSI CPE and transfer capability */
2825
2826 /* If we have an outbound group, set this peer channel to it */
2827 if (outbound_group)
2828 ast_app_group_set_channel(tc, outbound_group);
2829 /* If the calling channel has the ANSWERED_ELSEWHERE flag set, inherit it. This is to support local channels */
2832
2833 /* Check if we're forced by configuration */
2836
2837
2838 /* Inherit context and extension */
2839 ast_channel_dialcontext_set(tc, ast_channel_context(chan));
2841
2843
2844 /* Save the original channel name to detect call pickup masquerading in. */
2846
2848 ast_channel_unlock(chan);
2849
2850 /* Put channel in the list of outgoing thingies. */
2851 tmp->chan = tc;
2852 AST_LIST_INSERT_TAIL(&out_chans, tmp, node);
2853 }
2854
2855 /* As long as we attempted to dial valid peers, don't throw a warning. */
2856 /* If a DAHDI peer is busy, out_chans will be empty so checking list size is misleading. */
2857 if (!num_dialed) {
2858 ast_verb(3, "No devices or endpoints to dial (technology/resource)\n");
2859 if (continue_exec) {
2860 /* There is no point in having RetryDial try again */
2861 *continue_exec = 1;
2862 }
2863 strcpy(pa.status, "CHANUNAVAIL");
2864 res = 0;
2865 goto out;
2866 }
2867
2868 /*
2869 * PREDIAL: Run gosub on all of the callee channels
2870 *
2871 * We run the callee predial before ast_call() in case the user
2872 * wishes to do something on the newly created channels before
2873 * the channel does anything important.
2874 *
2875 * Inside the target gosub we will be able to do something with
2876 * the newly created channel name ie: now the calling channel
2877 * can know what channel will be used to call the destination
2878 * ex: now we will know that SIP/abc-123 is calling SIP/def-124
2879 */
2882 && !AST_LIST_EMPTY(&out_chans)) {
2883 const char *predial_callee;
2884
2886 predial_callee = ast_app_expand_sub_args(chan, opt_args[OPT_ARG_PREDIAL_CALLEE]);
2887 if (predial_callee) {
2889 AST_LIST_TRAVERSE(&out_chans, tmp, node) {
2890 ast_pre_call(tmp->chan, predial_callee);
2891 }
2893 ast_free((char *) predial_callee);
2894 }
2895 }
2896
2897 /* Start all outgoing calls */
2898 AST_LIST_TRAVERSE_SAFE_BEGIN(&out_chans, tmp, node) {
2899 res = ast_call(tmp->chan, tmp->number, 0); /* Place the call, but don't wait on the answer */
2900 ast_channel_lock(chan);
2901
2902 /* check the results of ast_call */
2903 if (res) {
2904 /* Again, keep going even if there's an error */
2905 ast_debug(1, "ast call on peer returned %d\n", res);
2906 ast_verb(3, "Couldn't call %s\n", tmp->interface);
2907 if (ast_channel_hangupcause(tmp->chan)) {
2909 }
2910 ast_channel_unlock(chan);
2911 ast_cc_call_failed(chan, tmp->chan, tmp->interface);
2912 ast_hangup(tmp->chan);
2913 tmp->chan = NULL;
2915 chanlist_free(tmp);
2916 continue;
2917 }
2918
2919 ast_channel_publish_dial(chan, tmp->chan, tmp->number, NULL);
2920 ast_channel_unlock(chan);
2921
2922 ast_verb(3, "Called %s\n", tmp->interface);
2924
2925 /* If this line is up, don't try anybody else */
2926 if (ast_channel_state(tmp->chan) == AST_STATE_UP) {
2927 break;
2928 }
2929 }
2931
2932 if (ast_strlen_zero(args.timeout)) {
2933 to_answer = -1;
2934 to_progress = -1;
2935 } else {
2936 char *anstimeout = strsep(&args.timeout, "^");
2937 if (!ast_strlen_zero(anstimeout)) {
2938 to_answer = atoi(anstimeout);
2939 if (to_answer > 0) {
2940 to_answer *= 1000;
2941 } else {
2942 ast_log(LOG_WARNING, "Invalid answer timeout specified: '%s'. Setting timeout to infinite\n", args.timeout);
2943 to_answer = -1;
2944 }
2945 } else {
2946 to_answer = -1;
2947 }
2948 if (!ast_strlen_zero(args.timeout)) {
2949 to_progress = atoi(args.timeout);
2950 if (to_progress > 0) {
2951 to_progress *= 1000;
2952 } else {
2953 ast_log(LOG_WARNING, "Invalid progress timeout specified: '%s'. Setting timeout to infinite\n", args.timeout);
2954 to_progress = -1;
2955 }
2956 } else {
2957 to_progress = -1;
2958 }
2959 }
2960
2961 outgoing = AST_LIST_FIRST(&out_chans);
2962 if (!outgoing) {
2963 strcpy(pa.status, "CHANUNAVAIL");
2964 if (fulldial == num_dialed) {
2965 res = -1;
2966 goto out;
2967 }
2968 } else {
2969 /* Our status will at least be NOANSWER */
2970 strcpy(pa.status, "NOANSWER");
2972 moh = 1;
2973 if (!ast_strlen_zero(opt_args[OPT_ARG_MUSICBACK])) {
2974 char *original_moh = ast_strdupa(ast_channel_musicclass(chan));
2975 ast_channel_musicclass_set(chan, opt_args[OPT_ARG_MUSICBACK]);
2976 ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL);
2977 ast_channel_musicclass_set(chan, original_moh);
2978 } else {
2979 ast_moh_start(chan, NULL, NULL);
2980 }
2983 if (!ast_strlen_zero(opt_args[OPT_ARG_RINGBACK])) {
2984 if (dial_handle_playtones(chan, opt_args[OPT_ARG_RINGBACK])){
2986 sentringing++;
2987 } else {
2989 }
2990 } else {
2992 sentringing++;
2993 }
2994 }
2995 }
2996
2997 peer = wait_for_answer(chan, &out_chans, &to_answer, &to_progress, peerflags, opt_args, &pa, &num, &result,
2998 dtmf_progress, mf_progress, mf_wink, sf_progress, sf_wink,
2999 (ast_test_flag64(&opts, OPT_HEARPULSING) ? 1 : 0),
3000 ignore_cc, &forced_clid, &stored_clid, &config);
3001
3002 if (!peer) {
3003 if (result) {
3004 res = result;
3005 } else if (to_answer) { /* Musta gotten hung up */
3006 res = -1;
3007 } else { /* Nobody answered, next please? */
3008 res = 0;
3009 }
3010 } else {
3011 const char *number;
3012 const char *name;
3013 int dial_end_raised = 0;
3014 int cause = -1;
3015
3016 if (ast_test_flag64(&opts, OPT_CALLER_ANSWER)) {
3017 ast_answer(chan);
3018 }
3019
3020 /* Ah ha! Someone answered within the desired timeframe. Of course after this
3021 we will always return with -1 so that it is hung up properly after the
3022 conversation. */
3023
3025 && !ast_strlen_zero(opt_args[OPT_ARG_HANGUPCAUSE])) {
3026 cause = ast_str2cause(opt_args[OPT_ARG_HANGUPCAUSE]);
3027 if (cause <= 0) {
3028 if (!strcasecmp(opt_args[OPT_ARG_HANGUPCAUSE], "NONE")) {
3029 cause = 0;
3030 } else if (sscanf(opt_args[OPT_ARG_HANGUPCAUSE], "%30d", &cause) != 1
3031 || cause < 0) {
3032 ast_log(LOG_WARNING, "Invalid cause given to Dial(...Q(<cause>)): \"%s\"\n",
3033 opt_args[OPT_ARG_HANGUPCAUSE]);
3034 cause = -1;
3035 }
3036 }
3037 }
3038 hanguptree(&out_chans, peer, cause >= 0 ? cause : AST_CAUSE_ANSWERED_ELSEWHERE);
3039
3040 /* If appropriate, log that we have a destination channel and set the answer time */
3041
3042 ast_channel_lock(peer);
3044
3045 number = pbx_builtin_getvar_helper(peer, "DIALEDPEERNUMBER");
3046 if (ast_strlen_zero(number)) {
3047 number = NULL;
3048 } else {
3050 }
3051 ast_channel_unlock(peer);
3052
3053 ast_channel_lock(chan);
3055
3056 strcpy(pa.status, "ANSWER");
3057 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
3058
3059 pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", name);
3060 pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number);
3061
3063 ast_channel_unlock(chan);
3064
3065 if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) {
3066 ast_debug(1, "app_dial: sendurl=%s.\n", args.url);
3067 ast_channel_sendurl( peer, args.url );
3068 }
3070 if (do_privacy(chan, peer, &opts, opt_args, &pa)) {
3071 ast_channel_publish_dial(chan, peer, NULL, pa.status);
3072 /* hang up on the callee -- he didn't want to talk anyway! */
3074 res = 0;
3075 goto out;
3076 }
3077 }
3078 if (!ast_test_flag64(&opts, OPT_ANNOUNCE) || ast_strlen_zero(opt_args[OPT_ARG_ANNOUNCE])) {
3079 res = 0;
3080 } else {
3081 int digit = 0;
3082 struct ast_channel *chans[2];
3083 struct ast_channel *active_chan;
3084 char *calledfile = NULL, *callerfile = NULL;
3085 int calledstream = 0, callerstream = 0;
3086
3087 chans[0] = chan;
3088 chans[1] = peer;
3089
3090 /* we need to stream the announcement(s) when the OPT_ARG_ANNOUNCE (-A) is set */
3091 callerfile = opt_args[OPT_ARG_ANNOUNCE];
3092 calledfile = strsep(&callerfile, ":");
3093
3094 /* stream the file(s) */
3095 if (!ast_strlen_zero(calledfile)) {
3096 res = ast_streamfile(peer, calledfile, ast_channel_language(peer));
3097 if (res) {
3098 res = 0;
3099 ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", calledfile);
3100 } else {
3101 calledstream = 1;
3102 }
3103 }
3104 if (!ast_strlen_zero(callerfile)) {
3105 res = ast_streamfile(chan, callerfile, ast_channel_language(chan));
3106 if (res) {
3107 res = 0;
3108 ast_log(LOG_ERROR, "error streaming file '%s' to caller\n", callerfile);
3109 } else {
3110 callerstream = 1;
3111 }
3112 }
3113
3114 /* can't use ast_waitstream, because we're streaming two files at once, and can't block
3115 We'll need to handle both channels at once. */
3116
3118 while (ast_channel_stream(peer) || ast_channel_stream(chan)) {
3119 int mspeer, mschan;
3120
3121 mspeer = ast_sched_wait(ast_channel_sched(peer));
3122 mschan = ast_sched_wait(ast_channel_sched(chan));
3123
3124 if (calledstream) {
3125 if (mspeer < 0 && !ast_channel_timingfunc(peer)) {
3126 ast_stopstream(peer);
3127 calledstream = 0;
3128 }
3129 }
3130 if (callerstream) {
3131 if (mschan < 0 && !ast_channel_timingfunc(chan)) {
3132 ast_stopstream(chan);
3133 callerstream = 0;
3134 }
3135 }
3136
3137 if (!calledstream && !callerstream) {
3138 break;
3139 }
3140
3141 if (mspeer < 0)
3142 mspeer = 1000;
3143
3144 if (mschan < 0)
3145 mschan = 1000;
3146
3147 /* wait for the lowest maximum of the two */
3148 active_chan = ast_waitfor_n(chans, 2, (mspeer > mschan ? &mschan : &mspeer));
3149 if (active_chan) {
3150 struct ast_channel *other_chan;
3151 struct ast_frame *fr = ast_read(active_chan);
3152
3153 if (!fr) {
3155 res = -1;
3156 goto done;
3157 }
3158 switch (fr->frametype) {
3159 case AST_FRAME_DTMF_END:
3160 digit = fr->subclass.integer;
3161 if (active_chan == peer && strchr(AST_DIGIT_ANY, res)) {
3162 ast_stopstream(peer);
3163 res = ast_senddigit(chan, digit, 0);
3164 }
3165 break;
3166 case AST_FRAME_CONTROL:
3167 switch (fr->subclass.integer) {
3168 case AST_CONTROL_HANGUP:
3169 ast_frfree(fr);
3171 res = -1;
3172 goto done;
3174 /* Pass COLP update to the other channel. */
3175 if (active_chan == chan) {
3176 other_chan = peer;
3177 } else {
3178 other_chan = chan;
3179 }
3180 if (ast_channel_connected_line_sub(active_chan, other_chan, fr, 1)) {
3181 ast_indicate_data(other_chan, fr->subclass.integer,
3182 fr->data.ptr, fr->datalen);
3183 }
3184 break;
3185 default:
3186 break;
3187 }
3188 break;
3189 default:
3190 /* Ignore all others */
3191 break;
3192 }
3193 ast_frfree(fr);
3194 }
3197 }
3199 }
3200
3201 if (chan && peer && ast_test_flag64(&opts, OPT_GOTO) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO])) {
3202 /* chan and peer are going into the PBX; as such neither are considered
3203 * outgoing channels any longer */
3205
3207 ast_parseable_goto(chan, opt_args[OPT_ARG_GOTO]);
3208 /* peer goes to the same context and extension as chan, so just copy info from chan*/
3209 ast_channel_lock(peer);
3216 ast_channel_unlock(peer);
3217 if (ast_pbx_start(peer)) {
3219 }
3220 if (continue_exec)
3221 *continue_exec = 1;
3222 res = 0;
3223 ast_channel_publish_dial(chan, peer, NULL, "ANSWER");
3224 goto done;
3225 }
3226
3228 const char *gosub_result_peer;
3229 char *gosub_argstart;
3230 char *gosub_args = NULL;
3231 int gosub_res = -1;
3232
3234 gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
3235 if (gosub_argstart) {
3236 const char *what_is_s = "s";
3237 *gosub_argstart = 0;
3238 if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
3239 ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
3240 what_is_s = "~~s~~";
3241 }
3242 if (ast_asprintf(&gosub_args, "%s,%s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s, gosub_argstart + 1) < 0) {
3243 gosub_args = NULL;
3244 }
3245 *gosub_argstart = ',';
3246 } else {
3247 const char *what_is_s = "s";
3248 if (!ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "s", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL)) &&
3249 ast_exists_extension(peer, opt_args[OPT_ARG_CALLEE_GOSUB], "~~s~~", 1, S_COR(ast_channel_caller(peer)->id.number.valid, ast_channel_caller(peer)->id.number.str, NULL))) {
3250 what_is_s = "~~s~~";
3251 }
3252 if (ast_asprintf(&gosub_args, "%s,%s,1", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s) < 0) {
3253 gosub_args = NULL;
3254 }
3255 }
3256 if (gosub_args) {
3257 gosub_res = ast_app_exec_sub(chan, peer, gosub_args, 0);
3258 ast_free(gosub_args);
3259 } else {
3260 ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
3261 }
3262
3263 ast_channel_lock_both(chan, peer);
3264
3265 if (!gosub_res && (gosub_result_peer = pbx_builtin_getvar_helper(peer, "GOSUB_RESULT"))) {
3266 char *gosub_transfer_dest;
3267 char *gosub_result = ast_strdupa(gosub_result_peer);
3268 const char *gosub_retval = pbx_builtin_getvar_helper(peer, "GOSUB_RETVAL");
3269
3270 /* Inherit return value from the peer, so it can be used in the master */
3271 if (gosub_retval) {
3272 pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", gosub_retval);
3273 }
3274
3275 ast_channel_unlock(peer);
3276 ast_channel_unlock(chan);
3277
3278 if (!strcasecmp(gosub_result, "BUSY")) {
3279 ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
3280 ast_set_flag64(peerflags, OPT_GO_ON);
3281 gosub_res = -1;
3282 } else if (!strcasecmp(gosub_result, "CONGESTION") || !strcasecmp(gosub_result, "CHANUNAVAIL")) {
3283 ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
3284 ast_set_flag64(peerflags, OPT_GO_ON);
3285 gosub_res = -1;
3286 } else if (!strcasecmp(gosub_result, "CONTINUE")) {
3287 /* Hangup peer and continue with the next extension priority. */
3288 ast_set_flag64(peerflags, OPT_GO_ON);
3289 gosub_res = -1;
3290 } else if (!strcasecmp(gosub_result, "ABORT")) {
3291 /* Hangup both ends unless the caller has the g flag */
3292 gosub_res = -1;
3293 } else if (!strncasecmp(gosub_result, "GOTO:", 5)) {
3294 gosub_transfer_dest = gosub_result + 5;
3295 gosub_res = -1;
3296 /* perform a transfer to a new extension */
3297 if (strchr(gosub_transfer_dest, '^')) { /* context^exten^priority*/
3298 ast_replace_subargument_delimiter(gosub_transfer_dest);
3299 }
3300 if (!ast_parseable_goto(chan, gosub_transfer_dest)) {
3301 ast_set_flag64(peerflags, OPT_GO_ON);
3302 }
3303 }
3304 if (gosub_res) {
3305 res = gosub_res;
3306 if (!dial_end_raised) {
3307 ast_channel_publish_dial(chan, peer, NULL, gosub_result);
3308 dial_end_raised = 1;
3309 }
3310 }
3311 } else {
3312 ast_channel_unlock(peer);
3313 ast_channel_unlock(chan);
3314 }
3315 }
3316
3317 if (!res) {
3318
3319 /* None of the Dial options changed our status; inform
3320 * everyone that this channel answered
3321 */
3322 if (!dial_end_raised) {
3323 ast_channel_publish_dial(chan, peer, NULL, "ANSWER");
3324 dial_end_raised = 1;
3325 }
3326
3327 if (!ast_tvzero(calldurationlimit)) {
3328 struct timeval whentohangup = ast_tvadd(ast_tvnow(), calldurationlimit);
3329 ast_channel_lock(peer);
3330 ast_channel_whentohangup_set(peer, &whentohangup);
3331 ast_channel_unlock(peer);
3332 }
3333 if (!ast_strlen_zero(dtmfcalled)) {
3334 ast_verb(3, "Sending DTMF '%s' to the called party.\n", dtmfcalled);
3335 res = ast_dtmf_stream(peer, chan, dtmfcalled, 250, 0);
3336 }
3337 if (!ast_strlen_zero(dtmfcalling)) {
3338 ast_verb(3, "Sending DTMF '%s' to the calling party.\n", dtmfcalling);
3339 res = ast_dtmf_stream(chan, peer, dtmfcalling, 250, 0);
3340 }
3341 }
3342
3343 if (res) { /* some error */
3344 if (!ast_check_hangup(chan) && ast_check_hangup(peer)) {
3346 }
3347 setup_peer_after_bridge_goto(chan, peer, &opts, opt_args);
3349 || ast_pbx_start(peer)) {
3351 }
3352 res = -1;
3353 } else {
3354 if (ast_test_flag64(peerflags, OPT_CALLEE_TRANSFER))
3355 ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
3356 if (ast_test_flag64(peerflags, OPT_CALLER_TRANSFER))
3357 ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
3358 if (ast_test_flag64(peerflags, OPT_CALLEE_HANGUP))
3359 ast_set_flag(&(config.features_callee), AST_FEATURE_DISCONNECT);
3360 if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP))
3361 ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT);
3362 if (ast_test_flag64(peerflags, OPT_CALLEE_MONITOR))
3363 ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
3364 if (ast_test_flag64(peerflags, OPT_CALLER_MONITOR))
3365 ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
3366 if (ast_test_flag64(peerflags, OPT_CALLEE_PARK))
3367 ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL);
3368 if (ast_test_flag64(peerflags, OPT_CALLER_PARK))
3369 ast_set_flag(&(config.features_caller), AST_FEATURE_PARKCALL);
3370 if (ast_test_flag64(peerflags, OPT_CALLEE_MIXMONITOR))
3371 ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMIXMON);
3372 if (ast_test_flag64(peerflags, OPT_CALLER_MIXMONITOR))
3373 ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMIXMON);
3374
3375 config.end_bridge_callback = end_bridge_callback;
3376 config.end_bridge_callback_data = chan;
3377 config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
3378
3379 if (moh) {
3380 moh = 0;
3381 ast_moh_stop(chan);
3382 } else if (sentringing) {
3383 sentringing = 0;
3384 ast_indicate(chan, -1);
3385 }
3386 /* Be sure no generators are left on it and reset the visible indication */
3389 /* Make sure channels are compatible */
3390 res = ast_channel_make_compatible(chan, peer);
3391 if (res < 0) {
3392 ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(chan), ast_channel_name(peer));
3394 res = -1;
3395 goto done;
3396 }
3397 if (opermode) {
3398 struct oprmode oprmode;
3399
3400 oprmode.peer = peer;
3401 oprmode.mode = opermode;
3402
3404 }
3405 setup_peer_after_bridge_goto(chan, peer, &opts, opt_args);
3406
3407 res = ast_bridge_call(chan, peer, &config);
3408 }
3409 }
3410out:
3411 if (moh) {
3412 moh = 0;
3413 ast_moh_stop(chan);
3414 } else if (sentringing) {
3415 sentringing = 0;
3416 ast_indicate(chan, -1);
3417 }
3418
3419 if (delprivintro && ast_fileexists(pa.privintro, NULL, NULL) > 0) {
3421 if (ast_fileexists(pa.privintro, NULL, NULL) > 0) {
3422 ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa.privintro);
3423 } else {
3424 ast_verb(3, "Successfully deleted %s intro file\n", pa.privintro);
3425 }
3426 }
3427
3429 /* forward 'answered elsewhere' if we received it */
3431 hanguptreecause = AST_CAUSE_ANSWERED_ELSEWHERE;
3432 } else if (pa.canceled) { /* Caller canceled */
3433 if (ast_channel_hangupcause(chan))
3434 hanguptreecause = ast_channel_hangupcause(chan);
3435 else
3436 hanguptreecause = AST_CAUSE_NORMAL_CLEARING;
3437 }
3438 hanguptree(&out_chans, NULL, hanguptreecause);
3439 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
3440 ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
3441
3442 if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_INCOMPLETE)) {
3443 if (!ast_tvzero(calldurationlimit))
3444 memset(ast_channel_whentohangup(chan), 0, sizeof(*ast_channel_whentohangup(chan)));
3445 res = 0;
3446 }
3447
3448done:
3449 if (config.answer_topology) {
3450 ast_trace(2, "%s Cleaning up topology: %p %s\n",
3451 peer ? ast_channel_name(peer) : "<no channel>", &config.answer_topology,
3452 ast_str_tmp(256, ast_stream_topology_to_str(config.answer_topology, &STR_TMP)));
3453
3454 /*
3455 * At this point, the channel driver that answered should have bumped the
3456 * topology refcount for itself. Here we're cleaning up the reference we added
3457 * in wait_for_answer().
3458 */
3459 ast_stream_topology_free(config.answer_topology);
3460 }
3461 if (config.warning_sound) {
3462 ast_free((char *)config.warning_sound);
3463 }
3464 if (config.end_sound) {
3465 ast_free((char *)config.end_sound);
3466 }
3467 if (config.start_sound) {
3468 ast_free((char *)config.start_sound);
3469 }
3470 ast_ignore_cc(chan);
3471 SCOPE_EXIT_RTN_VALUE(res, "%s: Done\n", ast_channel_name(chan));
3472}
char digit
#define DIAL_STILLGOING
Definition: app_dial.c:706
#define OPT_PREDIAL_CALLER
Definition: app_dial.c:717
#define OPT_CANCEL_ELSEWHERE
Definition: app_dial.c:709
static const char * get_cid_name(char *name, int namelen, struct ast_channel *chan)
Definition: app_dial.c:913
static const struct ast_app_option dial_exec_options[128]
Definition: app_dial.c:791
#define OPT_PREDIAL_CALLEE
Definition: app_dial.c:716
#define DIAL_CALLERID_ABSENT
Definition: app_dial.c:708
#define OPT_FORCE_CID_PRES
Definition: app_dial.c:714
static void setup_peer_after_bridge_goto(struct ast_channel *chan, struct ast_channel *peer, struct ast_flags64 *opts, char *opt_args[])
Definition: app_dial.c:2292
#define CAN_EARLY_BRIDGE(flags, chan, peer)
Definition: app_dial.c:793
#define OPT_TOPOLOGY_PRESERVE
Definition: app_dial.c:721
#define OPT_RING_WITH_EARLY_MEDIA
Definition: app_dial.c:718
#define OPT_FORCE_CID_TAG
Definition: app_dial.c:713
#define OPT_HEARPULSING
Definition: app_dial.c:720
#define DIAL_NOFORWARDHTML
Definition: app_dial.c:707
#define OPT_CANCEL_TIMEOUT
Definition: app_dial.c:712
static void chanlist_free(struct chanlist *outgoing)
Definition: app_dial.c:838
static void handle_cause(int cause, struct cause_args *num)
Definition: app_dial.c:876
static int setup_privacy_args(struct privacy_args *pa, struct ast_flags64 *opts, char *opt_args[], struct ast_channel *chan)
returns 1 if successful, 0 or <0 if the caller should 'goto out'
Definition: app_dial.c:2137
#define OPT_HANGUPCAUSE
Definition: app_dial.c:719
static void hanguptree(struct dial_head *out_chans, struct ast_channel *exception, int hangupcause)
Definition: app_dial.c:846
static const struct ast_datastore_info topology_ds_info
Definition: app_dial.c:831
static int dial_handle_playtones(struct ast_channel *chan, const char *data)
Definition: app_dial.c:2252
static void end_bridge_callback(void *data)
Definition: app_dial.c:2236
#define OPT_CALLER_ANSWER
Definition: app_dial.c:715
static struct ast_channel * wait_for_answer(struct ast_channel *in, struct dial_head *out_chans, int *to_answer, int *to_progress, struct ast_flags64 *peerflags, char *opt_args[], struct privacy_args *pa, const struct cause_args *num_in, int *result, char *dtmf_progress, char *mf_progress, char *mf_wink, char *sf_progress, char *sf_wink, const int hearpulsing, const int ignore_cc, struct ast_party_id *forced_clid, struct ast_party_id *stored_clid, struct ast_bridge_config *config)
Definition: app_dial.c:1208
static void end_bridge_callback_data_fixup(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator)
Definition: app_dial.c:2248
char * strsep(char **str, const char *delims)
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
int ast_bridge_setup_after_goto(struct ast_channel *chan)
Setup any after bridge goto location to begin execution.
Definition: bridge_after.c:435
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN
Definition: callerid.h:440
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1343
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Definition: callerid.c:1162
#define AST_CAUSE_CONGESTION
Definition: causes.h:153
#define AST_CAUSE_ANSWERED_ELSEWHERE
Definition: causes.h:114
#define AST_CAUSE_BUSY
Definition: causes.h:149
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:106
void ast_cc_call_failed(struct ast_channel *incoming, struct ast_channel *outgoing, const char *const dialstring)
Make CCBS available in the case that ast_call fails.
Definition: ccss.c:4170
void ast_ignore_cc(struct ast_channel *chan)
Mark the channel to ignore further CC activity.
Definition: ccss.c:3691
void ast_cc_busy_interface(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, void *private_data)
Callback made from ast_cc_callback for certain channel types.
Definition: ccss.c:4203
void ast_cc_extension_monitor_add_dialstring(struct ast_channel *incoming, const char *const dialstring, const char *const device_name)
Add a child dialstring to an extension monitor.
Definition: ccss.c:1989
int ast_cc_call_init(struct ast_channel *chan, int *ignore_cc)
Start the CC process on a call.
Definition: ccss.c:2392
int ast_cc_callback(struct ast_channel *inbound, const char *const tech, const char *const dest, ast_cc_callback_fn callback)
Run a callback for potential matching destinations.
Definition: ccss.c:4215
int ast_cdr_reset(const char *channel_name, int keep_variables)
Reset the detail record.
Definition: cdr.c:3731
static PGresult * result
Definition: cel_pgsql.c:84
static const char config[]
Definition: chan_ooh323.c:111
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
Definition: channel.c:624
const char * ast_channel_name(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
Definition: autoservice.c:266
@ AST_FEATURE_AUTOMIXMON
Definition: channel.h:1089
@ AST_FEATURE_REDIRECT
Definition: channel.h:1084
@ AST_FEATURE_PARKCALL
Definition: channel.h:1088
@ AST_FEATURE_AUTOMON
Definition: channel.h:1087
@ AST_FEATURE_DISCONNECT
Definition: channel.h:1085
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
Definition: channel.c:10501
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6420
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition: channel.c:11039
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2354
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1724
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame)
Run a connected line interception subroutine and update a channel's connected line information.
Definition: channel.c:10343
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2510
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
Definition: channel.h:1525
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
Definition: channel.c:8313
const char * ast_channel_musicclass(const struct ast_channel *chan)
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name...
Definition: channel.c:7345
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
Definition: channel.c:3125
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4933
#define ast_channel_lock(chan)
Definition: channel.h:2972
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
Make the frame formats of two channels compatible.
Definition: channel.c:6679
void ast_channel_data_set(struct ast_channel *chan, const char *value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
Definition: channel.c:1998
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_channel_priority(const struct ast_channel *chan)
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2979
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2337
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition: channel.c:6393
const char * ast_channel_context(const struct ast_channel *chan)
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2861
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:458
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Definition: autoservice.c:200
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4214
ast_channel_adsicpe
Definition: channel.h:888
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide)
Initialize the given caller structure using the given guide for a set update operation.
Definition: channel.c:1966
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
Initialize the given party id structure using the given guide for a set update operation.
Definition: channel.c:1747
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
Definition: channel.c:6735
struct ast_channel * ast_request_with_stream_topology(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel (specifying stream topology)
Definition: channel.c:6318
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:6582
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:444
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
int ast_channel_hangupcause(const struct ast_channel *chan)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4612
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11032
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
#define AST_CHANNEL_NAME
Definition: channel.h:173
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
@ AST_FLAG_OUTGOING
Definition: channel.h:1019
@ AST_FLAG_END_DTMF_ONLY
Definition: channel.h:1027
int ast_channel_sendurl(struct ast_channel *channel, const char *url)
Sends a URL on a given link Send URL on link.
Definition: channel.c:6594
const char * ast_channel_language(const struct ast_channel *chan)
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:611
void ast_channel_context_set(struct ast_channel *chan, const char *value)
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
Definition: channel.c:8298
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
int ast_pre_call(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel before a call is placed.
Definition: channel.c:6403
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7395
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation.
Definition: channel.c:2012
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
void ast_channel_priority_set(struct ast_channel *chan, int value)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_autoservice_chan_hangup_peer(struct ast_channel *chan, struct ast_channel *peer)
Put chan into autoservice while hanging up peer.
Definition: autoservice.c:349
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2774
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels together (early)
Definition: channel.c:7385
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4234
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2973
#define AST_MAX_EXTENSION
Definition: channel.h:134
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition: channel.c:2102
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.
Definition: channel.c:2368
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:85
char connected
Definition: eagi_proxy.c:82
int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config)
Bridge a call, optionally allowing redirection.
Definition: features.c:691
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,...
Definition: features.c:863
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:222
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Definition: file.c:1301
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
Definition: file.c:1137
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
Definition: file.c:1149
#define AST_DIGIT_ANY
Definition: file.h:48
static const char name[]
Definition: format_mp3.c:68
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_ENTER(level,...)
#define ast_trace(level,...)
void ast_channel_publish_dial(struct ast_channel *caller, struct ast_channel *peer, const char *dialstring, const char *dialstatus)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
const char * ast_app_expand_sub_args(struct ast_channel *chan, const char *args)
Add missing context/exten to subroutine argument string.
Definition: main/app.c:278
#define AST_APP_ARG(name)
Define an application argument.
int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
Set the group for a channel, splitting the provided data into group and category, if specified.
Definition: main/app.c:2193
#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.
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:297
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
Definition: main/app.c:1127
int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:3071
#define AST_OPTION_OPRMODE
#define ast_frfree(fr)
@ AST_FRAME_DTMF_END
@ AST_FRAME_CONTROL
@ AST_CONTROL_PROGRESS
@ AST_CONTROL_RINGING
@ AST_CONTROL_HANGUP
@ AST_CONTROL_CONNECTED_LINE
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_ERROR
#define ast_verb(level,...)
#define LOG_NOTICE
#define LOG_WARNING
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:450
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
Definition: linkedlists.h:252
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
Definition: max_forwards.c:135
int ast_max_forwards_get(struct ast_channel *chan)
Get the current max forwards for a particular channel.
Definition: max_forwards.c:121
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:7739
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:7749
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 ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4190
#define AST_PBX_INCOMPLETE
Definition: pbx.h:51
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.
Definition: pbx.c:4723
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
Definition: pbx.c:8881
#define AST_PRIVACY_UNKNOWN
Definition: privacy.h:34
static char url[512]
void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src)
Make two channels compatible for early bridging.
Definition: rtp_engine.c:2433
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
Definition: sched.c:786
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
Definition: sched.c:433
@ AST_STREAM_STATE_RECVONLY
Set when the stream is receiving media only.
Definition: stream.h:90
@ AST_STREAM_STATE_SENDONLY
Set when the stream is sending media only.
Definition: stream.h:86
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
Definition: stream.c:380
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
Definition: stream.c:939
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
Definition: stream.c:791
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
Definition: stream.c:768
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
Definition: stream.c:373
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
Definition: stream.c:746
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
Definition: stream.c:670
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1189
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223
bridge configuration
Definition: channel.h:1096
Main Channel structure associated with a channel.
const struct ast_channel_tech * tech
Structure for a data store object.
Definition: datastore.h:64
void * data
Definition: datastore.h:66
uint64_t flags
Definition: utils.h:205
Data structure associated with a single frame of data.
union ast_frame::@228 data
struct ast_frame_subclass subclass
enum ast_frame_type frametype
Caller Party information.
Definition: channel.h:420
Connected Line/Party information.
Definition: channel.h:458
struct ast_party_id id
Connected party ID.
Definition: channel.h:460
int transit_network_select
Transit Network Select.
Definition: channel.h:399
Information needed to identify an endpoint in a call.
Definition: channel.h:340
struct ast_party_name name
Subscriber name.
Definition: channel.h:342
struct ast_channel * chan
Definition: app_dial.c:870
List of channel drivers.
Definition: app_dial.c:803
const char * number
Definition: app_dial.c:811
const char * interface
Definition: app_dial.c:807
struct ast_party_connected_line connected
Definition: app_dial.c:816
char * orig_chan_name
Definition: app_dial.c:813
char stuff[0]
Definition: app_dial.c:821
struct ast_channel * chan
Definition: app_dial.c:805
const char * tech
Definition: app_dial.c:809
Definition: astman.c:88
Channel datastore data for max forwards.
Definition: max_forwards.c:29
Definition: test_heap.c:38
Number structure.
Definition: app_followme.c:157
struct ast_channel * peer
char status[256]
Definition: app_dial.c:1151
int privdb_val
Definition: app_dial.c:1148
int sentringing
Definition: app_dial.c:1147
char privintro[1024]
Definition: app_dial.c:1150
int done
Definition: test_amihooks.c:48
const char * args
static struct test_options options
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2282
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
FILE * out
Definition: utils/frame.c:33
#define ast_set2_flag64(p, value, flag)
Definition: utils.h:151
#define ast_test_flag64(p, flag)
Definition: utils.h:120
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_copy_flags64(dest, src, flagz)
Definition: utils.h:141
#define ast_set_flag64(p, flag)
Definition: utils.h:127
#define ast_set_flag(p, flag)
Definition: utils.h:70
void ast_replace_subargument_delimiter(char *s)
Replace '^' in a string with ','.
Definition: utils.c:2343

References ao2_ref, args, ast_answer(), AST_APP_ARG, ast_app_exec_sub(), ast_app_expand_sub_args(), ast_app_group_set_channel(), ast_app_parse_options64(), ast_asprintf, ast_autoservice_chan_hangup_peer(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_call(), ast_bridge_setup_after_goto(), ast_bridge_timelimit(), ast_call(), ast_callerid_parse(), ast_calloc, ast_cause2str(), AST_CAUSE_ANSWERED_ELSEWHERE, AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CAUSE_NORMAL_CLEARING, ast_cc_busy_interface(), ast_cc_call_failed(), ast_cc_call_init(), ast_cc_callback(), ast_cc_extension_monitor_add_dialstring(), ast_cdr_reset(), ast_channel_adsicpe_set(), ast_channel_appl_set(), ast_channel_caller(), ast_channel_clear_flag(), ast_channel_connected(), ast_channel_connected_line_sub(), ast_channel_context(), ast_channel_context_set(), ast_channel_data_set(), ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_datastore_inherit(), ast_channel_dialed(), ast_channel_early_bridge(), ast_channel_exten(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_get_device_name(), ast_channel_get_stream_topology(), ast_channel_hangupcause(), ast_channel_hangupcause_set(), ast_channel_inherit_variables(), ast_channel_language(), ast_channel_lock, ast_channel_lock_both, ast_channel_make_compatible(), ast_channel_musicclass(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_priority(), ast_channel_priority_set(), ast_channel_publish_dial(), ast_channel_redirecting(), ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, ast_channel_sched(), ast_channel_sendurl(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_flag(), ast_channel_setoption(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_stream(), ast_channel_supports_html(), ast_channel_timingfunc(), ast_channel_transfercapability(), ast_channel_transfercapability_set(), ast_channel_unlock, ast_channel_visible_indication_set(), ast_channel_whentohangup(), ast_channel_whentohangup_set(), ast_check_hangup(), ast_check_hangup_locked(), ast_clear_flag, ast_connected_line_copy_from_caller(), AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, ast_copy_flags64, ast_copy_string(), ast_datastore_alloc, ast_deactivate_generator(), ast_debug, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, ast_dtmf_stream(), ast_exists_extension(), AST_FEATURE_AUTOMIXMON, AST_FEATURE_AUTOMON, AST_FEATURE_DISCONNECT, AST_FEATURE_PARKCALL, AST_FEATURE_REDIRECT, ast_filedelete(), ast_fileexists(), AST_FLAG_END_DTMF_ONLY, AST_FLAG_OUTGOING, AST_FRAME_CONTROL, AST_FRAME_DTMF_END, ast_free, ast_frfree, ast_hangup(), ast_ignore_cc(), ast_indicate(), ast_indicate_data(), AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_HEAD_NOLOCK_INIT_VALUE, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MAX_EXTENSION, ast_max_forwards_decrement(), ast_max_forwards_get(), ast_moh_start(), ast_moh_stop(), AST_OPTION_OPRMODE, ast_parse_caller_presentation(), ast_parseable_goto(), ast_party_caller_set_init(), ast_party_connected_line_copy(), ast_party_connected_line_set_init(), ast_party_id_init(), ast_party_id_set_init(), ast_party_redirecting_copy(), AST_PBX_INCOMPLETE, ast_pbx_start(), ast_pre_call(), AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, AST_PRIVACY_UNKNOWN, ast_read(), ast_replace_subargument_delimiter(), ast_request_with_stream_topology(), ast_rtp_instance_early_bridge_make_compatible(), ast_sched_runq(), ast_sched_wait(), ast_senddigit(), ast_set2_flag64, ast_set_flag, ast_set_flag64, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_str2cause(), ast_str_tmp, ast_strdup, ast_strdupa, ast_stream_get_state(), ast_stream_set_state(), AST_STREAM_STATE_RECVONLY, AST_STREAM_STATE_SENDONLY, ast_stream_topology_clone(), ast_stream_topology_free(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_stream_topology_to_str(), ast_streamfile(), ast_strip(), ast_strlen_zero(), ast_test_flag64, ast_trace, ast_tvadd(), ast_tvnow(), ast_tvzero(), ast_verb, ast_waitfor_n(), CAN_EARLY_BRIDGE, privacy_args::canceled, chanlist::chan, cause_args::chan, chanlist_free(), config, chanlist::connected, connected, ast_datastore::data, ast_frame::data, ast_frame::datalen, DIAL_CALLERID_ABSENT, dial_exec_options, dial_handle_playtones(), DIAL_NOFORWARDHTML, DIAL_STILLGOING, digit, done, end_bridge_callback(), end_bridge_callback_data_fixup(), ast_flags64::flags, ast_frame::frametype, get_cid_name(), handle_cause(), hanguptree(), ast_party_caller::id, ast_party_connected_line::id, ast_frame_subclass::integer, chanlist::interface, LOG_ERROR, LOG_NOTICE, LOG_WARNING, oprmode::mode, name, ast_party_id::name, NULL, chanlist::number, ast_party_id::number, OPT_ANNOUNCE, OPT_ARG_ANNOUNCE, OPT_ARG_ARRAY_SIZE, OPT_ARG_CALLEE_GOSUB, OPT_ARG_DURATION_LIMIT, OPT_ARG_DURATION_STOP, OPT_ARG_FORCE_CID_PRES, OPT_ARG_FORCE_CID_TAG, OPT_ARG_FORCECLID, OPT_ARG_GOTO, OPT_ARG_HANGUPCAUSE, OPT_ARG_MUSICBACK, OPT_ARG_OPERMODE, OPT_ARG_ORIGINAL_CLID, OPT_ARG_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLER, OPT_ARG_PRIVACY, OPT_ARG_RINGBACK, OPT_ARG_SCREEN_NOINTRO, OPT_ARG_SENDDTMF, OPT_CALLEE_GOSUB, OPT_CALLEE_HANGUP, OPT_CALLEE_MIXMONITOR, OPT_CALLEE_MONITOR, OPT_CALLEE_PARK, OPT_CALLEE_TRANSFER, OPT_CALLER_ANSWER, OPT_CALLER_HANGUP, OPT_CALLER_MIXMONITOR, OPT_CALLER_MONITOR, OPT_CALLER_PARK, OPT_CALLER_TRANSFER, OPT_CANCEL_ELSEWHERE, OPT_CANCEL_TIMEOUT, OPT_DTMF_EXIT, OPT_DURATION_LIMIT, OPT_DURATION_STOP, OPT_FORCE_CID_PRES, OPT_FORCE_CID_TAG, OPT_FORCECLID, OPT_GO_ON, OPT_GOTO, OPT_HANGUPCAUSE, OPT_HEARPULSING, OPT_IGNORE_CONNECTEDLINE, OPT_IGNORE_FORWARDING, OPT_MUSICBACK, OPT_OPERMODE, OPT_ORIGINAL_CLID, OPT_PREDIAL_CALLEE, OPT_PREDIAL_CALLER, OPT_PRIVACY, OPT_RESETCDR, OPT_RING_WITH_EARLY_MEDIA, OPT_RINGBACK, OPT_SCREEN_NOINTRO, OPT_SCREENING, OPT_SENDDTMF, OPT_TOPOLOGY_PRESERVE, options, chanlist::orig_chan_name, out, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), oprmode::peer, ast_party_number::presentation, privacy_args::privdb_val, privacy_args::privintro, ast_frame::ptr, result, S_COR, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, privacy_args::sentringing, setup_peer_after_bridge_goto(), setup_privacy_args(), privacy_args::status, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, strsep(), chanlist::stuff, ast_party_id::subaddress, ast_frame::subclass, ast_party_id::tag, chanlist::tech, ast_channel::tech, topology_ds_info, ast_party_dialed::transit_network_select, url, ast_party_name::valid, ast_party_number::valid, and wait_for_answer().

Referenced by dial_exec(), and retrydial_exec().

◆ dial_handle_playtones()

static int dial_handle_playtones ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 2252 of file app_dial.c.

2253{
2254 struct ast_tone_zone_sound *ts = NULL;
2255 int res;
2256 const char *str = data;
2257
2258 if (ast_strlen_zero(str)) {
2259 ast_debug(1,"Nothing to play\n");
2260 return -1;
2261 }
2262
2264
2265 if (ts && ts->data[0]) {
2266 res = ast_playtones_start(chan, 0, ts->data, 0);
2267 } else {
2268 res = -1;
2269 }
2270
2271 if (ts) {
2273 }
2274
2275 if (res) {
2276 ast_log(LOG_WARNING, "Unable to start playtone \'%s\'\n", str);
2277 }
2278
2279 return res;
2280}
const char * str
Definition: app_jack.c:150
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:227
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:461
Description of a tone.
Definition: indications.h:35
const char * data
Description of a tone.
Definition: indications.h:52

References ast_channel_zone(), ast_debug, ast_get_indication_tone(), ast_log, ast_playtones_start(), ast_strlen_zero(), ast_tone_zone_sound_unref(), ast_tone_zone_sound::data, LOG_WARNING, NULL, and str.

Referenced by dial_exec_full().

◆ do_forward()

static void do_forward ( struct chanlist o,
struct cause_args num,
struct ast_flags64 peerflags,
int  single,
int  caller_entertained,
int *  to,
struct ast_party_id forced_clid,
struct ast_party_id stored_clid 
)
static

helper function for wait_for_answer()

Parameters
oOutgoing call channel list.
numIncoming call channel cause accumulation
peerflagsDial option flags
singleTRUE if there is only one outgoing call.
caller_entertainedTRUE if the caller is being entertained by MOH or ringback.
toRemaining call timeout time.
forced_clidOPT_FORCECLID caller id to send
stored_clidCaller id representing the called party if needed

XXX this code is highly suspicious, as it essentially overwrites the outgoing channel without properly deleting it.

Todo:
eventually this function should be integrated into and replaced by ast_call_forward()

Definition at line 943 of file app_dial.c.

946{
947 char tmpchan[256];
948 char forwarder[AST_CHANNEL_NAME];
949 struct ast_channel *original = o->chan;
950 struct ast_channel *c = o->chan; /* the winner */
951 struct ast_channel *in = num->chan; /* the input channel */
952 char *stuff;
953 char *tech;
954 int cause;
955 struct ast_party_caller caller;
956
957 ast_copy_string(forwarder, ast_channel_name(c), sizeof(forwarder));
958 ast_copy_string(tmpchan, ast_channel_call_forward(c), sizeof(tmpchan));
959 if ((stuff = strchr(tmpchan, '/'))) {
960 *stuff++ = '\0';
961 tech = tmpchan;
962 } else {
963 const char *forward_context;
965 forward_context = pbx_builtin_getvar_helper(c, "FORWARD_CONTEXT");
966 if (ast_strlen_zero(forward_context)) {
967 forward_context = NULL;
968 }
969 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(c), forward_context ? forward_context : ast_channel_context(c));
971 stuff = tmpchan;
972 tech = "Local";
973 }
974 if (!strcasecmp(tech, "Local")) {
975 /*
976 * Drop the connected line update block for local channels since
977 * this is going to run dialplan and the user can change his
978 * mind about what connected line information he wants to send.
979 */
981 }
982
983 /* Before processing channel, go ahead and check for forwarding */
984 ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", ast_channel_name(in), tech, stuff, ast_channel_name(c));
985 /* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
986 if (ast_test_flag64(peerflags, OPT_IGNORE_FORWARDING)) {
987 ast_verb(3, "Forwarding %s to '%s/%s' prevented.\n", ast_channel_name(in), tech, stuff);
988 ast_channel_publish_dial_forward(in, original, NULL, NULL, "CANCEL",
989 ast_channel_call_forward(original));
990 c = o->chan = NULL;
991 cause = AST_CAUSE_BUSY;
992 } else {
993 struct ast_stream_topology *topology;
994
998
999 /* Setup parameters */
1000 c = o->chan = ast_request_with_stream_topology(tech, topology, NULL, in, stuff, &cause);
1001
1002 ast_stream_topology_free(topology);
1003
1004 if (c) {
1005 if (single && !caller_entertained) {
1007 }
1011 pbx_builtin_setvar_helper(o->chan, "FORWARDERNAME", forwarder);
1015 /* When a call is forwarded, we don't want to track new interfaces
1016 * dialed for CC purposes. Setting the done flag will ensure that
1017 * any Dial operations that happen later won't record CC interfaces.
1018 */
1019 ast_ignore_cc(o->chan);
1020 ast_verb(3, "Not accepting call completion offers from call-forward recipient %s\n",
1022 } else
1024 "Forwarding failed to create channel to dial '%s/%s' (cause = %d)\n",
1025 tech, stuff, cause);
1026 }
1027 if (!c) {
1028 ast_channel_publish_dial(in, original, stuff, "BUSY");
1030 handle_cause(cause, num);
1031 ast_hangup(original);
1032 } else {
1033 ast_channel_lock_both(c, original);
1035 ast_channel_redirecting(original));
1037 ast_channel_unlock(original);
1038
1040
1041 if (single && !caller_entertained && CAN_EARLY_BRIDGE(peerflags, c, in)) {
1043 }
1044
1045 if (!ast_channel_redirecting(c)->from.number.valid
1046 || ast_strlen_zero(ast_channel_redirecting(c)->from.number.str)) {
1047 /*
1048 * The call was not previously redirected so it is
1049 * now redirected from this number.
1050 */
1056 }
1057
1059
1060 /* Determine CallerID to store in outgoing channel. */
1062 if (ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
1063 caller.id = *stored_clid;
1066 } else if (ast_strlen_zero(S_COR(ast_channel_caller(c)->id.number.valid,
1067 ast_channel_caller(c)->id.number.str, NULL))) {
1068 /*
1069 * The new channel has no preset CallerID number by the channel
1070 * driver. Use the dialplan extension and hint name.
1071 */
1072 caller.id = *stored_clid;
1075 } else {
1077 }
1078
1079 /* Determine CallerID for outgoing channel to send. */
1082
1084 connected.id = *forced_clid;
1086 } else {
1088 }
1089
1091
1092 ast_channel_appl_set(c, "AppDial");
1093 ast_channel_data_set(c, "(Outgoing Line)");
1095
1097 if (single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
1098 struct ast_party_redirecting redirecting;
1099
1100 /*
1101 * Redirecting updates to the caller make sense only on single
1102 * calls.
1103 *
1104 * Need to re-evalute if unlocking is still required here as macro is gone
1105 */
1106 ast_party_redirecting_init(&redirecting);
1109 if (ast_channel_redirecting_sub(c, in, &redirecting, 0)) {
1110 ast_channel_update_redirecting(in, &redirecting, NULL);
1111 }
1112 ast_party_redirecting_free(&redirecting);
1113 } else {
1115 }
1116
1117 if (ast_test_flag64(peerflags, OPT_CANCEL_TIMEOUT)) {
1118 *to = -1;
1119 }
1120
1121 if (ast_call(c, stuff, 0)) {
1122 ast_log(LOG_NOTICE, "Forwarding failed to dial '%s/%s'\n",
1123 tech, stuff);
1124 ast_channel_publish_dial(in, original, stuff, "CONGESTION");
1126 ast_hangup(original);
1127 ast_hangup(c);
1128 c = o->chan = NULL;
1129 num->nochan++;
1130 } else {
1131 ast_channel_publish_dial_forward(in, original, c, NULL, "CANCEL",
1132 ast_channel_call_forward(original));
1133
1135
1136 /* Hangup the original channel now, in case we needed it */
1137 ast_hangup(original);
1138 }
1139 if (single && !caller_entertained) {
1140 ast_indicate(in, -1);
1141 }
1142 }
1143}
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2089
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition: channel.c:1611
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
Definition: channel.c:10388
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
Definition: channel.c:10289
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:1658
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:1989
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2146
const char * ast_channel_call_forward(const struct ast_channel *chan)
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_channel_publish_dial_forward(struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:524
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:529
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:532
int nochan
Definition: app_dial.c:873
static struct test_val c
FILE * in
Definition: utils/frame.c:33
#define ast_clear_flag64(p, flag)
Definition: utils.h:134

References ast_call(), AST_CAUSE_BUSY, ast_channel_appl_set(), ast_channel_call_forward(), ast_channel_caller(), ast_channel_connected(), ast_channel_context(), ast_channel_data_set(), ast_channel_datastore_inherit(), ast_channel_dialed(), ast_channel_exten(), ast_channel_get_stream_topology(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_make_compatible(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_publish_dial(), ast_channel_publish_dial_forward(), ast_channel_publish_snapshot(), ast_channel_redirecting(), ast_channel_redirecting_sub(), ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, ast_channel_set_caller_event(), ast_channel_unlock, ast_channel_update_redirecting(), ast_clear_flag64, ast_connected_line_copy_from_caller(), ast_copy_string(), ast_hangup(), ast_ignore_cc(), ast_indicate(), ast_log, ast_max_forwards_decrement(), ast_party_caller_set_init(), ast_party_connected_line_copy(), ast_party_connected_line_init(), ast_party_number_free(), ast_party_number_init(), ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_request_with_stream_topology(), ast_rtp_instance_early_bridge_make_compatible(), ast_set_flag64, ast_strdup, ast_stream_topology_clone(), ast_stream_topology_free(), ast_strlen_zero(), ast_test_flag64, ast_verb, c, CAN_EARLY_BRIDGE, chanlist::chan, cause_args::chan, connected, DIAL_CALLERID_ABSENT, DIAL_STILLGOING, ast_party_redirecting::from, handle_cause(), ast_party_caller::id, in, LOG_NOTICE, cause_args::nochan, NULL, ast_party_id::number, OPT_CANCEL_TIMEOUT, OPT_FORCECLID, OPT_IGNORE_CONNECTEDLINE, OPT_IGNORE_FORWARDING, OPT_ORIGINAL_CLID, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), S_COR, ast_party_number::str, ast_channel::tech, ast_party_redirecting::to, ast_party_dialed::transit_network_select, and ast_party_number::valid.

Referenced by wait_for_answer().

◆ end_bridge_callback()

static void end_bridge_callback ( void *  data)
static

Definition at line 2236 of file app_dial.c.

2237{
2238 struct ast_channel *chan = data;
2239
2240 ast_channel_lock(chan);
2242 set_duration_var(chan, "ANSWEREDTIME", ast_channel_get_up_time_ms(chan));
2243 set_duration_var(chan, "DIALEDTIME", ast_channel_get_duration_ms(chan));
2245 ast_channel_unlock(chan);
2246}
static void set_duration_var(struct ast_channel *chan, const char *var_base, int64_t duration)
Definition: app_dial.c:1195
int64_t ast_channel_get_up_time_ms(struct ast_channel *chan)
Obtain how long it has been since the channel was answered in ms.
Definition: channel.c:2804
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it's been, in milliseconds, since the channel was created.
Definition: channel.c:2789
const char * data

References ast_channel_get_duration_ms(), ast_channel_get_up_time_ms(), ast_channel_lock, ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_unlock, ast_channel::data, and set_duration_var().

Referenced by dial_exec_full().

◆ end_bridge_callback_data_fixup()

static void end_bridge_callback_data_fixup ( struct ast_bridge_config bconfig,
struct ast_channel originator,
struct ast_channel terminator 
)
static

Definition at line 2248 of file app_dial.c.

2248 {
2249 bconfig->end_bridge_callback_data = originator;
2250}
void * end_bridge_callback_data
Definition: channel.h:1111

References ast_bridge_config::end_bridge_callback_data.

Referenced by dial_exec_full().

◆ get_cid_name()

static const char * get_cid_name ( char *  name,
int  namelen,
struct ast_channel chan 
)
static

Definition at line 913 of file app_dial.c.

914{
915 const char *context;
916 const char *exten;
917
918 ast_channel_lock(chan);
920 exten = ast_strdupa(ast_channel_exten(chan));
921 ast_channel_unlock(chan);
922
923 return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
924}
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
Definition: pbx.c:4152

References ast_channel_context(), ast_channel_exten(), ast_channel_lock, ast_channel_unlock, ast_get_hint(), ast_strdupa, voicemailpwcheck::context, ast_channel::exten, name, and NULL.

Referenced by dial_exec_full().

◆ handle_cause()

static void handle_cause ( int  cause,
struct cause_args num 
)
static

Definition at line 876 of file app_dial.c.

877{
878 switch(cause) {
879 case AST_CAUSE_BUSY:
880 num->busy++;
881 break;
883 num->congestion++;
884 break;
887 num->nochan++;
888 break;
891 break;
892 default:
893 num->nochan++;
894 break;
895 }
896}
#define AST_CAUSE_NO_ROUTE_DESTINATION
Definition: causes.h:100
#define AST_CAUSE_UNREGISTERED
Definition: causes.h:154
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:109
int congestion
Definition: app_dial.c:872
int busy
Definition: app_dial.c:871

References AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CAUSE_NO_ANSWER, AST_CAUSE_NO_ROUTE_DESTINATION, AST_CAUSE_NORMAL_CLEARING, AST_CAUSE_UNREGISTERED, cause_args::busy, cause_args::congestion, and cause_args::nochan.

Referenced by dial_exec_full(), do_forward(), and wait_for_answer().

◆ hanguptree()

static void hanguptree ( struct dial_head out_chans,
struct ast_channel exception,
int  hangupcause 
)
static

Definition at line 846 of file app_dial.c.

847{
848 /* Hang up a tree of stuff */
849 struct chanlist *outgoing;
850
851 while ((outgoing = AST_LIST_REMOVE_HEAD(out_chans, node))) {
852 /* Hangup any existing lines we have open */
853 if (outgoing->chan && (outgoing->chan != exception)) {
854 if (hangupcause >= 0) {
855 /* This is for the channel drivers */
856 ast_channel_hangupcause_set(outgoing->chan, hangupcause);
857 }
858 ast_hangup(outgoing->chan);
859 }
861 }
862}
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833

References ast_channel_hangupcause_set(), ast_hangup(), AST_LIST_REMOVE_HEAD, and chanlist_free().

Referenced by dial_exec_full().

◆ load_module()

static int load_module ( void  )
static

Definition at line 3601 of file app_dial.c.

3602{
3603 int res;
3604
3607
3608 return res;
3609}
static const char app[]
Definition: app_dial.c:669
static int dial_exec(struct ast_channel *chan, const char *data)
Definition: app_dial.c:3474
static const char rapp[]
Definition: app_dial.c:670
static int retrydial_exec(struct ast_channel *chan, const char *data)
Definition: app_dial.c:3483
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

References app, ast_register_application_xml, dial_exec(), rapp, and retrydial_exec().

◆ onedigit_goto()

static int onedigit_goto ( struct ast_channel chan,
const char *  context,
char  exten,
int  pri 
)
static

Definition at line 898 of file app_dial.c.

899{
900 char rexten[2] = { exten, '\0' };
901
902 if (context) {
903 if (!ast_goto_if_exists(chan, context, rexten, pri))
904 return 1;
905 } else {
906 if (!ast_goto_if_exists(chan, ast_channel_context(chan), rexten, pri))
907 return 1;
908 }
909 return 0;
910}
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
Definition: pbx.c:8796

References ast_channel_context(), ast_goto_if_exists(), voicemailpwcheck::context, and ast_channel::exten.

Referenced by retrydial_exec(), and wait_for_answer().

◆ publish_dial_end_event()

static void publish_dial_end_event ( struct ast_channel in,
struct dial_head out_chans,
struct ast_channel exception,
const char *  status 
)
static

Definition at line 1155 of file app_dial.c.

1156{
1157 struct chanlist *outgoing;
1158 AST_LIST_TRAVERSE(out_chans, outgoing, node) {
1159 if (!outgoing->chan || outgoing->chan == exception) {
1160 continue;
1161 }
1163 }
1164}
jack_status_t status
Definition: app_jack.c:149

References ast_channel_publish_dial(), AST_LIST_TRAVERSE, in, NULL, and status.

Referenced by wait_for_answer().

◆ retrydial_exec()

static int retrydial_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 3483 of file app_dial.c.

3484{
3485 char *parse;
3486 const char *context = NULL;
3487 int sleepms = 0, loops = 0, res = -1;
3488 struct ast_flags64 peerflags = { 0, };
3490 AST_APP_ARG(announce);
3491 AST_APP_ARG(sleep);
3492 AST_APP_ARG(retries);
3493 AST_APP_ARG(dialdata);
3494 );
3495
3496 if (ast_strlen_zero(data)) {
3497 ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
3498 return -1;
3499 }
3500
3501 parse = ast_strdupa(data);
3503
3504 if (!ast_strlen_zero(args.sleep) && (sleepms = atoi(args.sleep)))
3505 sleepms *= 1000;
3506
3507 if (!ast_strlen_zero(args.retries)) {
3508 loops = atoi(args.retries);
3509 }
3510
3511 if (!args.dialdata) {
3512 ast_log(LOG_ERROR, "%s requires a 4th argument (dialdata)\n", rapp);
3513 goto done;
3514 }
3515
3516 if (sleepms < 1000)
3517 sleepms = 10000;
3518
3519 if (!loops)
3520 loops = -1; /* run forever */
3521
3522 ast_channel_lock(chan);
3523 context = pbx_builtin_getvar_helper(chan, "EXITCONTEXT");
3525 ast_channel_unlock(chan);
3526
3527 res = 0;
3528 while (loops) {
3529 int continue_exec;
3530
3531 ast_channel_data_set(chan, "Retrying");
3533 ast_moh_stop(chan);
3534
3535 res = dial_exec_full(chan, args.dialdata, &peerflags, &continue_exec);
3536 if (continue_exec)
3537 break;
3538
3539 if (res == 0) {
3540 if (ast_test_flag64(&peerflags, OPT_DTMF_EXIT)) {
3541 if (!ast_strlen_zero(args.announce)) {
3542 if (ast_fileexists(args.announce, NULL, ast_channel_language(chan)) > 0) {
3543 if (!(res = ast_streamfile(chan, args.announce, ast_channel_language(chan))))
3545 } else
3546 ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
3547 }
3548 if (!res && sleepms) {
3550 ast_moh_start(chan, NULL, NULL);
3551 res = ast_waitfordigit(chan, sleepms);
3552 }
3553 } else {
3554 if (!ast_strlen_zero(args.announce)) {
3555 if (ast_fileexists(args.announce, NULL, ast_channel_language(chan)) > 0) {
3556 if (!(res = ast_streamfile(chan, args.announce, ast_channel_language(chan))))
3557 res = ast_waitstream(chan, "");
3558 } else
3559 ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
3560 }
3561 if (sleepms) {
3563 ast_moh_start(chan, NULL, NULL);
3564 if (!res)
3565 res = ast_waitfordigit(chan, sleepms);
3566 }
3567 }
3568 }
3569
3570 if (res < 0 || res == AST_PBX_INCOMPLETE) {
3571 break;
3572 } else if (res > 0) { /* Trying to send the call elsewhere (1 digit ext) */
3573 if (onedigit_goto(chan, context, (char) res, 1)) {
3574 res = 0;
3575 break;
3576 }
3577 }
3578 loops--;
3579 }
3580 if (loops == 0)
3581 res = 0;
3582 else if (res == 1)
3583 res = 0;
3584
3586 ast_moh_stop(chan);
3587 done:
3588 return res;
3589}
static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
Definition: app_dial.c:898
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3143
@ AST_FLAG_MOH
Definition: channel.h:1011
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
Definition: file.c:1848
#define ast_test_flag(p, flag)
Definition: utils.h:63

References args, AST_APP_ARG, ast_channel_data_set(), ast_channel_flags(), ast_channel_language(), ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, ast_fileexists(), AST_FLAG_MOH, ast_log, ast_moh_start(), ast_moh_stop(), AST_PBX_INCOMPLETE, AST_STANDARD_APP_ARGS, ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_test_flag64, ast_waitfordigit(), ast_waitstream(), voicemailpwcheck::context, dial_exec_full(), done, LOG_ERROR, LOG_WARNING, NULL, onedigit_goto(), OPT_DTMF_EXIT, pbx_builtin_getvar_helper(), and rapp.

Referenced by load_module().

◆ set_duration_var()

static void set_duration_var ( struct ast_channel chan,
const char *  var_base,
int64_t  duration 
)
static

Definition at line 1195 of file app_dial.c.

1196{
1197 char buf[32];
1198 char full_var_name[128];
1199
1200 snprintf(buf, sizeof(buf), "%" PRId64, duration / 1000);
1201 pbx_builtin_setvar_helper(chan, var_base, buf);
1202
1203 snprintf(full_var_name, sizeof(full_var_name), "%s_MS", var_base);
1204 snprintf(buf, sizeof(buf), "%" PRId64, duration);
1205 pbx_builtin_setvar_helper(chan, full_var_name, buf);
1206}
char buf[BUFSIZE]
Definition: eagi_proxy.c:66

References buf, and pbx_builtin_setvar_helper().

Referenced by end_bridge_callback(), and wait_for_answer().

◆ setup_peer_after_bridge_goto()

static void setup_peer_after_bridge_goto ( struct ast_channel chan,
struct ast_channel peer,
struct ast_flags64 opts,
char *  opt_args[] 
)
static

Definition at line 2292 of file app_dial.c.

2293{
2294 const char *context;
2295 const char *extension;
2296 int priority;
2297
2298 if (ast_test_flag64(opts, OPT_PEER_H)) {
2299 ast_channel_lock(chan);
2301 ast_channel_unlock(chan);
2303 } else if (ast_test_flag64(opts, OPT_CALLEE_GO_ON)) {
2304 ast_channel_lock(chan);
2308 ast_channel_unlock(chan);
2310 opt_args[OPT_ARG_CALLEE_GO_ON]);
2311 }
2312}
#define OPT_PEER_H
Definition: app_dial.c:710
#define OPT_CALLEE_GO_ON
Definition: app_dial.c:711
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.
Definition: bridge_after.c:622
void ast_bridge_set_after_h(struct ast_channel *chan, const char *context)
Set channel to run the h exten after the bridge.
Definition: bridge_after.c:617
static int priority
structure to hold extensions

References ast_bridge_set_after_go_on(), ast_bridge_set_after_h(), ast_channel_context(), ast_channel_exten(), ast_channel_lock, ast_channel_priority(), ast_channel_unlock, ast_strdupa, ast_test_flag64, voicemailpwcheck::context, OPT_ARG_CALLEE_GO_ON, OPT_CALLEE_GO_ON, OPT_PEER_H, and priority.

Referenced by dial_exec_full().

◆ setup_privacy_args()

static int setup_privacy_args ( struct privacy_args pa,
struct ast_flags64 opts,
char *  opt_args[],
struct ast_channel chan 
)
static

returns 1 if successful, 0 or <0 if the caller should 'goto out'

Definition at line 2137 of file app_dial.c.

2139{
2140 char callerid[60];
2141 int res;
2142 char *l;
2143
2144 if (ast_channel_caller(chan)->id.number.valid
2145 && !ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) {
2146 l = ast_strdupa(ast_channel_caller(chan)->id.number.str);
2148 if (ast_test_flag64(opts, OPT_PRIVACY) ) {
2149 ast_verb(3, "Privacy DB is '%s', clid is '%s'\n", opt_args[OPT_ARG_PRIVACY], l);
2150 pa->privdb_val = ast_privacy_check(opt_args[OPT_ARG_PRIVACY], l);
2151 } else {
2152 ast_verb(3, "Privacy Screening, clid is '%s'\n", l);
2154 }
2155 } else {
2156 char *tnam, *tn2;
2157
2158 tnam = ast_strdupa(ast_channel_name(chan));
2159 /* clean the channel name so slashes don't try to end up in disk file name */
2160 for (tn2 = tnam; *tn2; tn2++) {
2161 if (*tn2 == '/') /* any other chars to be afraid of? */
2162 *tn2 = '=';
2163 }
2164 ast_verb(3, "Privacy-- callerid is empty\n");
2165
2166 snprintf(callerid, sizeof(callerid), "NOCALLERID_%s%s", ast_channel_exten(chan), tnam);
2167 l = callerid;
2169 }
2170
2171 ast_copy_string(pa->privcid, l, sizeof(pa->privcid));
2172
2173 if (strncmp(pa->privcid, "NOCALLERID", 10) != 0 && ast_test_flag64(opts, OPT_SCREEN_NOCALLERID)) {
2174 /* if callerid is set and OPT_SCREEN_NOCALLERID is set also */
2175 ast_verb(3, "CallerID set (%s); N option set; Screening should be off\n", pa->privcid);
2177 } else if (ast_test_flag64(opts, OPT_SCREEN_NOCALLERID) && strncmp(pa->privcid, "NOCALLERID", 10) == 0) {
2178 ast_verb(3, "CallerID blank; N option set; Screening should happen; dbval is %d\n", pa->privdb_val);
2179 }
2180
2181 if (pa->privdb_val == AST_PRIVACY_DENY) {
2182 ast_verb(3, "Privacy DB reports PRIVACY_DENY for this callerid. Dial reports unavailable\n");
2183 ast_copy_string(pa->status, "NOANSWER", sizeof(pa->status));
2184 return 0;
2185 } else if (pa->privdb_val == AST_PRIVACY_KILL) {
2186 ast_copy_string(pa->status, "DONTCALL", sizeof(pa->status));
2187 return 0; /* Is this right? */
2188 } else if (pa->privdb_val == AST_PRIVACY_TORTURE) {
2189 ast_copy_string(pa->status, "TORTURE", sizeof(pa->status));
2190 return 0; /* is this right??? */
2191 } else if (pa->privdb_val == AST_PRIVACY_UNKNOWN) {
2192 /* Get the user's intro, store it in priv-callerintros/$CID,
2193 unless it is already there-- this should be done before the
2194 call is actually dialed */
2195
2196 /* make sure the priv-callerintros dir actually exists */
2197 snprintf(pa->privintro, sizeof(pa->privintro), "%s/sounds/priv-callerintros", ast_config_AST_DATA_DIR);
2198 if ((res = ast_mkdir(pa->privintro, 0755))) {
2199 ast_log(LOG_WARNING, "privacy: can't create directory priv-callerintros: %s\n", strerror(res));
2200 return -1;
2201 }
2202
2203 snprintf(pa->privintro, sizeof(pa->privintro), "priv-callerintros/%s", pa->privcid);
2204 if (ast_fileexists(pa->privintro, NULL, NULL ) > 0 && strncmp(pa->privcid, "NOCALLERID", 10) != 0) {
2205 /* the DELUX version of this code would allow this caller the
2206 option to hear and retape their previously recorded intro.
2207 */
2208 } else {
2209 int duration; /* for feedback from play_and_wait */
2210 /* the file doesn't exist yet. Let the caller submit his
2211 vocal intro for posterity */
2212 /* priv-recordintro script:
2213 "At the tone, please say your name:"
2214 */
2216 ast_answer(chan);
2217 res = ast_play_and_record(chan, "priv-recordintro", pa->privintro, 4, "sln", &duration, NULL, silencethreshold, 2000, 0); /* NOTE: I've reduced the total time to 4 sec */
2218 /* don't think we'll need a lock removed, we took care of
2219 conflicts by naming the pa.privintro file */
2220 if (res == -1) {
2221 /* Delete the file regardless since they hung up during recording */
2223 if (ast_fileexists(pa->privintro, NULL, NULL) > 0)
2224 ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa->privintro);
2225 else
2226 ast_verb(3, "Successfully deleted %s intro file\n", pa->privintro);
2227 return -1;
2228 }
2229 if (!ast_streamfile(chan, "vm-dialout", ast_channel_language(chan)) )
2230 ast_waitstream(chan, "");
2231 }
2232 }
2233 return 1; /* success */
2234}
static int silencethreshold
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
Definition: callerid.c:1101
@ THRESHOLD_SILENCE
Definition: dsp.h:73
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Definition: dsp.c:2009
int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path)
Record a file based on input from a channel. Use default accept and cancel DTMF. This function will p...
Definition: main/app.c:2154
const char * ast_config_AST_DATA_DIR
Definition: options.c:159
#define AST_PRIVACY_KILL
Definition: privacy.h:32
#define AST_PRIVACY_ALLOW
Definition: privacy.h:31
#define AST_PRIVACY_DENY
Definition: privacy.h:30
int ast_privacy_check(char *dest, char *cid)
Definition: privacy.c:46
#define AST_PRIVACY_TORTURE
Definition: privacy.h:33
char privcid[256]
Definition: app_dial.c:1149
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: utils.c:2479

References ast_answer(), ast_channel_caller(), ast_channel_exten(), ast_channel_language(), ast_channel_name(), ast_config_AST_DATA_DIR, ast_copy_string(), ast_dsp_get_threshold_from_settings(), ast_filedelete(), ast_fileexists(), ast_log, ast_mkdir(), ast_play_and_record(), AST_PRIVACY_ALLOW, ast_privacy_check(), AST_PRIVACY_DENY, AST_PRIVACY_KILL, AST_PRIVACY_TORTURE, AST_PRIVACY_UNKNOWN, ast_shrink_phone_number(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag64, ast_verb, ast_waitstream(), LOG_NOTICE, LOG_WARNING, NULL, OPT_ARG_PRIVACY, OPT_PRIVACY, OPT_SCREEN_NOCALLERID, privacy_args::privcid, privacy_args::privdb_val, privacy_args::privintro, silencethreshold, privacy_args::status, and THRESHOLD_SILENCE.

Referenced by dial_exec_full().

◆ topology_ds_destroy()

static void topology_ds_destroy ( void *  data)
static

Definition at line 826 of file app_dial.c.

826 {
827 struct ast_stream_topology *top = data;
829}

References ast_stream_topology_free().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 3591 of file app_dial.c.

3592{
3593 int res;
3594
3597
3598 return res;
3599}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, ast_unregister_application(), and rapp.

◆ update_connected_line_from_peer()

static void update_connected_line_from_peer ( struct ast_channel chan,
struct ast_channel peer,
int  is_caller 
)
static

Definition at line 1175 of file app_dial.c.

1176{
1177 struct ast_party_connected_line connected_caller;
1178
1179 ast_party_connected_line_init(&connected_caller);
1180
1181 ast_channel_lock(peer);
1183 ast_channel_unlock(peer);
1184 connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
1185 if (ast_channel_connected_line_sub(peer, chan, &connected_caller, 0)) {
1186 ast_channel_update_connected_line(chan, &connected_caller, NULL);
1187 }
1188 ast_party_connected_line_free(&connected_caller);
1189}
@ AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER
Definition: callerid.h:554
void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Indicate that the connected line information has changed.
Definition: channel.c:9098

References ast_channel_caller(), ast_channel_connected_line_sub(), ast_channel_lock, ast_channel_unlock, ast_channel_update_connected_line(), ast_connected_line_copy_from_caller(), AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, ast_party_connected_line_free(), ast_party_connected_line_init(), NULL, and ast_party_connected_line::source.

Referenced by wait_for_answer().

◆ valid_priv_reply()

static int valid_priv_reply ( struct ast_flags64 opts,
int  res 
)
static

Definition at line 1990 of file app_dial.c.

1991{
1992 if (res < '1')
1993 return 0;
1994 if (ast_test_flag64(opts, OPT_PRIVACY) && res <= '5')
1995 return 1;
1996 if (ast_test_flag64(opts, OPT_SCREENING) && res <= '4')
1997 return 1;
1998 return 0;
1999}

References ast_test_flag64, OPT_PRIVACY, and OPT_SCREENING.

◆ wait_for_answer()

static struct ast_channel * wait_for_answer ( struct ast_channel in,
struct dial_head out_chans,
int *  to_answer,
int *  to_progress,
struct ast_flags64 peerflags,
char *  opt_args[],
struct privacy_args pa,
const struct cause_args num_in,
int *  result,
char *  dtmf_progress,
char *  mf_progress,
char *  mf_wink,
char *  sf_progress,
char *  sf_wink,
const int  hearpulsing,
const int  ignore_cc,
struct ast_party_id forced_clid,
struct ast_party_id stored_clid,
struct ast_bridge_config config 
)
static

Definition at line 1208 of file app_dial.c.

1219{
1220 struct cause_args num = *num_in;
1221 int prestart = num.busy + num.congestion + num.nochan;
1222 int orig_answer_to = *to_answer;
1223 int orig_progress_to = *to_progress;
1224 struct ast_channel *peer = NULL;
1225 struct chanlist *outgoing = AST_LIST_FIRST(out_chans);
1226 /* single is set if only one destination is enabled */
1227 int single = outgoing && !AST_LIST_NEXT(outgoing, node);
1228 int caller_entertained = outgoing
1230 struct ast_str *featurecode = ast_str_alloca(AST_FEATURE_MAX_LEN + 1);
1231 int cc_recall_core_id;
1232 int is_cc_recall;
1233 int cc_frame_received = 0;
1234 int num_ringing = 0;
1235 int sent_ring = 0;
1236 int sent_progress = 0, sent_wink = 0;
1237 struct timeval start = ast_tvnow();
1238 SCOPE_ENTER(3, "%s\n", ast_channel_name(in));
1239
1240 if (single) {
1241 /* Turn off hold music, etc */
1242 if (!caller_entertained) {
1244 /* If we are calling a single channel, and not providing ringback or music, */
1245 /* then, make them compatible for in-band tone purpose */
1246 if (ast_channel_make_compatible(in, outgoing->chan) < 0) {
1247 /* If these channels can not be made compatible,
1248 * there is no point in continuing. The bridge
1249 * will just fail if it gets that far.
1250 */
1251 *to_answer = -1;
1252 strcpy(pa->status, "CONGESTION");
1254 SCOPE_EXIT_RTN_VALUE(NULL, "%s: can't be made compat with %s\n",
1256 }
1257 }
1258
1262 }
1263 }
1264
1265 is_cc_recall = ast_cc_is_recall(in, &cc_recall_core_id, NULL);
1266
1267 while ((*to_answer = ast_remaining_ms(start, orig_answer_to)) && (*to_progress = ast_remaining_ms(start, orig_progress_to)) && !peer) {
1268 struct chanlist *o;
1269 int pos = 0; /* how many channels do we handle */
1270 int numlines = prestart;
1271 struct ast_channel *winner;
1272 struct ast_channel *watchers[AST_MAX_WATCHERS];
1273
1274 watchers[pos++] = in;
1275 AST_LIST_TRAVERSE(out_chans, o, node) {
1276 /* Keep track of important channels */
1277 if (ast_test_flag64(o, DIAL_STILLGOING) && o->chan)
1278 watchers[pos++] = o->chan;
1279 numlines++;
1280 }
1281 if (pos == 1) { /* only the input channel is available */
1282 if (numlines == (num.busy + num.congestion + num.nochan)) {
1283 ast_verb(2, "Everyone is busy/congested at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
1284 if (num.busy)
1285 strcpy(pa->status, "BUSY");
1286 else if (num.congestion)
1287 strcpy(pa->status, "CONGESTION");
1288 else if (num.nochan)
1289 strcpy(pa->status, "CHANUNAVAIL");
1290 } else {
1291 ast_verb(3, "No one is available to answer at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
1292 }
1293 *to_answer = 0;
1294 if (is_cc_recall) {
1295 ast_cc_failed(cc_recall_core_id, "Everyone is busy/congested for the recall. How sad");
1296 }
1297 SCOPE_EXIT_RTN_VALUE(NULL, "%s: No outgoing channels available\n", ast_channel_name(in));
1298 }
1299
1300 /* If progress timeout is active, use that if it's the shorter of the 2 timeouts. */
1301 winner = ast_waitfor_n(watchers, pos, *to_progress > 0 && (*to_answer < 0 || *to_progress < *to_answer) ? to_progress : to_answer);
1302
1303 AST_LIST_TRAVERSE(out_chans, o, node) {
1304 int res = 0;
1305 struct ast_frame *f;
1306 struct ast_channel *c = o->chan;
1307
1308 if (c == NULL)
1309 continue;
1311 if (!peer) {
1312 ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
1313 if (o->orig_chan_name
1314 && strcmp(o->orig_chan_name, ast_channel_name(c))) {
1315 /*
1316 * The channel name changed so we must generate COLP update.
1317 * Likely because a call pickup channel masqueraded in.
1318 */
1320 } else if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
1321 if (o->pending_connected_update) {
1324 }
1325 } else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
1327 }
1328 }
1329 if (o->aoc_s_rate_list) {
1330 size_t encoded_size;
1331 struct ast_aoc_encoded *encoded;
1332 if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) {
1333 ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size);
1334 ast_aoc_destroy_encoded(encoded);
1335 }
1336 }
1337 peer = c;
1338 publish_dial_end_event(in, out_chans, peer, "CANCEL");
1339 ast_copy_flags64(peerflags, o,
1346 ast_channel_dialcontext_set(c, "");
1348 }
1349 continue;
1350 }
1351 if (c != winner)
1352 continue;
1353 /* here, o->chan == c == winner */
1355 pa->sentringing = 0;
1356 if (!ignore_cc && (f = ast_read(c))) {
1358 /* This channel is forwarding the call, and is capable of CC, so
1359 * be sure to add the new device interface to the list
1360 */
1362 }
1363 ast_frfree(f);
1364 }
1365
1366 if (o->pending_connected_update) {
1367 /*
1368 * Re-seed the chanlist's connected line information with
1369 * previously acquired connected line info from the incoming
1370 * channel. The previously acquired connected line info could
1371 * have been set through the CONNECTED_LINE dialplan function.
1372 */
1377 }
1378
1379 do_forward(o, &num, peerflags, single, caller_entertained, &orig_answer_to,
1380 forced_clid, stored_clid);
1381
1382 if (o->chan) {
1385 if (single
1389 }
1390 }
1391 continue;
1392 }
1393 f = ast_read(winner);
1394 if (!f) {
1397 ast_hangup(c);
1398 c = o->chan = NULL;
1401 continue;
1402 }
1403 switch (f->frametype) {
1404 case AST_FRAME_CONTROL:
1405 switch (f->subclass.integer) {
1406 case AST_CONTROL_ANSWER:
1407 /* This is our guy if someone answered. */
1408 if (!peer) {
1409 ast_trace(-1, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
1410 ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
1411 if (o->orig_chan_name
1412 && strcmp(o->orig_chan_name, ast_channel_name(c))) {
1413 /*
1414 * The channel name changed so we must generate COLP update.
1415 * Likely because a call pickup channel masqueraded in.
1416 */
1418 } else if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
1419 if (o->pending_connected_update) {
1422 }
1423 } else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
1425 }
1426 }
1427 if (o->aoc_s_rate_list) {
1428 size_t encoded_size;
1429 struct ast_aoc_encoded *encoded;
1430 if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) {
1431 ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size);
1432 ast_aoc_destroy_encoded(encoded);
1433 }
1434 }
1435 peer = c;
1436 /* Answer can optionally include a topology */
1437 if (f->subclass.topology) {
1438 /*
1439 * We need to bump the refcount on the topology to prevent it
1440 * from being cleaned up when the frame is cleaned up.
1441 */
1442 config->answer_topology = ao2_bump(f->subclass.topology);
1443 ast_trace(-1, "%s Found topology in frame: %p %p %s\n",
1444 ast_channel_name(peer), f, config->answer_topology,
1445 ast_str_tmp(256, ast_stream_topology_to_str(config->answer_topology, &STR_TMP)));
1446 }
1447
1448 /* Inform everyone else that they've been canceled.
1449 * The dial end event for the peer will be sent out after
1450 * other Dial options have been handled.
1451 */
1452 publish_dial_end_event(in, out_chans, peer, "CANCEL");
1453 ast_copy_flags64(peerflags, o,
1460 ast_channel_dialcontext_set(c, "");
1462 if (CAN_EARLY_BRIDGE(peerflags, in, peer)) {
1463 /* Setup early bridge if appropriate */
1465 }
1466 }
1467 /* If call has been answered, then the eventual hangup is likely to be normal hangup */
1470 break;
1471 case AST_CONTROL_BUSY:
1472 ast_verb(3, "%s is busy\n", ast_channel_name(c));
1474 ast_channel_publish_dial(in, c, NULL, "BUSY");
1475 ast_hangup(c);
1476 c = o->chan = NULL;
1479 break;
1481 ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c));
1483 ast_channel_publish_dial(in, c, NULL, "CONGESTION");
1484 ast_hangup(c);
1485 c = o->chan = NULL;
1488 break;
1490 /* This is a tricky area to get right when using a native
1491 * CC agent. The reason is that we do the best we can to send only a
1492 * single ringing notification to the caller.
1493 *
1494 * Call completion complicates the logic used here. CCNR is typically
1495 * offered during a ringing message. Let's say that party A calls
1496 * parties B, C, and D. B and C do not support CC requests, but D
1497 * does. If we were to receive a ringing notification from B before
1498 * the others, then we would end up sending a ringing message to
1499 * A with no CCNR offer present.
1500 *
1501 * The approach that we have taken is that if we receive a ringing
1502 * response from a party and no CCNR offer is present, we need to
1503 * wait. Specifically, we need to wait until either a) a called party
1504 * offers CCNR in its ringing response or b) all called parties have
1505 * responded in some way to our call and none offers CCNR.
1506 *
1507 * The drawback to this is that if one of the parties has a delayed
1508 * response or, god forbid, one just plain doesn't respond to our
1509 * outgoing call, then this will result in a significant delay between
1510 * when the caller places the call and hears ringback.
1511 *
1512 * Note also that if CC is disabled for this call, then it is perfectly
1513 * fine for ringing frames to get sent through.
1514 */
1515 ++num_ringing;
1516 *to_progress = -1;
1517 orig_progress_to = -1;
1518 if (ignore_cc || cc_frame_received || num_ringing == numlines) {
1519 ast_verb(3, "%s is ringing\n", ast_channel_name(c));
1520 /* Setup early media if appropriate */
1521 if (single && !caller_entertained
1522 && CAN_EARLY_BRIDGE(peerflags, in, c)) {
1524 }
1527 pa->sentringing++;
1528 }
1529 if (!sent_ring) {
1530 struct timeval now, then;
1531 int64_t diff;
1532
1533 now = ast_tvnow();
1534
1537
1539 diff = ast_tvzero(then) ? 0 : ast_tvdiff_ms(now, then);
1540 set_duration_var(in, "RINGTIME", diff);
1541
1544 sent_ring = 1;
1545 }
1546 }
1547 ast_channel_publish_dial(in, c, NULL, "RINGING");
1548 break;
1550 ast_verb(3, "%s is making progress passing it to %s\n", ast_channel_name(c), ast_channel_name(in));
1551 /* Setup early media if appropriate */
1552 if (single && !caller_entertained
1553 && CAN_EARLY_BRIDGE(peerflags, in, c)) {
1555 }
1557 if (single || (!single && !pa->sentringing)) {
1559 }
1560 }
1561 *to_progress = -1;
1562 orig_progress_to = -1;
1563 if (!sent_progress) {
1564 struct timeval now, then;
1565 int64_t diff;
1566
1567 now = ast_tvnow();
1568
1571
1573 diff = ast_tvzero(then) ? 0 : ast_tvdiff_ms(now, then);
1574 set_duration_var(in, "PROGRESSTIME", diff);
1575
1578 sent_progress = 1;
1579
1580 if (!ast_strlen_zero(mf_progress)) {
1581 ast_verb(3,
1582 "Sending MF '%s' to %s as result of "
1583 "receiving a PROGRESS message.\n",
1584 mf_progress, hearpulsing ? "parties" : "called party");
1585 res |= ast_mf_stream(c, (hearpulsing ? NULL : in),
1586 (hearpulsing ? in : NULL), mf_progress, 50, 55, 120, 65, 0);
1587 }
1588 if (!ast_strlen_zero(sf_progress)) {
1589 ast_verb(3,
1590 "Sending SF '%s' to %s as result of "
1591 "receiving a PROGRESS message.\n",
1592 sf_progress, (hearpulsing ? "parties" : "called party"));
1593 res |= ast_sf_stream(c, (hearpulsing ? NULL : in),
1594 (hearpulsing ? in : NULL), sf_progress, 0, 0);
1595 }
1596 if (!ast_strlen_zero(dtmf_progress)) {
1597 ast_verb(3,
1598 "Sending DTMF '%s' to the called party as result of "
1599 "receiving a PROGRESS message.\n",
1600 dtmf_progress);
1601 res |= ast_dtmf_stream(c, in, dtmf_progress, 250, 0);
1602 }
1603 if (res) {
1604 ast_log(LOG_WARNING, "Called channel %s hung up post-progress before all digits could be sent\n", ast_channel_name(c));
1605 goto wait_over;
1606 }
1607 }
1608 ast_channel_publish_dial(in, c, NULL, "PROGRESS");
1609 break;
1610 case AST_CONTROL_WINK:
1611 ast_verb(3, "%s winked, passing it to %s\n", ast_channel_name(c), ast_channel_name(in));
1612 if (!sent_wink) {
1613 sent_wink = 1;
1614 if (!ast_strlen_zero(mf_wink)) {
1615 ast_verb(3,
1616 "Sending MF '%s' to %s as result of "
1617 "receiving a WINK message.\n",
1618 mf_wink, (hearpulsing ? "parties" : "called party"));
1619 res |= ast_mf_stream(c, (hearpulsing ? NULL : in),
1620 (hearpulsing ? in : NULL), mf_wink, 50, 55, 120, 65, 0);
1621 }
1622 if (!ast_strlen_zero(sf_wink)) {
1623 ast_verb(3,
1624 "Sending SF '%s' to %s as result of "
1625 "receiving a WINK message.\n",
1626 sf_wink, (hearpulsing ? "parties" : "called party"));
1627 res |= ast_sf_stream(c, (hearpulsing ? NULL : in),
1628 (hearpulsing ? in : NULL), sf_wink, 0, 0);
1629 }
1630 if (res) {
1631 ast_log(LOG_WARNING, "Called channel %s hung up post-wink before all digits could be sent\n", ast_channel_name(c));
1632 goto wait_over;
1633 }
1634 }
1636 break;
1640 if (!single || caller_entertained) {
1641 break;
1642 }
1643 ast_verb(3, "%s requested media update control %d, passing it to %s\n",
1646 break;
1649 ast_verb(3, "Connected line update to %s prevented.\n", ast_channel_name(in));
1650 break;
1651 }
1652 if (!single) {
1654
1655 ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n",
1662 break;
1663 }
1664 if (ast_channel_connected_line_sub(c, in, f, 1)) {
1666 }
1667 break;
1668 case AST_CONTROL_AOC:
1669 {
1670 struct ast_aoc_decoded *decoded = ast_aoc_decode(f->data.ptr, f->datalen, o->chan);
1671 if (decoded && (ast_aoc_get_msg_type(decoded) == AST_AOC_S)) {
1673 o->aoc_s_rate_list = decoded;
1674 } else {
1675 ast_aoc_destroy_decoded(decoded);
1676 }
1677 }
1678 break;
1680 if (!single) {
1681 /*
1682 * Redirecting updates to the caller make sense only on single
1683 * calls.
1684 */
1685 break;
1686 }
1688 ast_verb(3, "Redirecting update to %s prevented.\n", ast_channel_name(in));
1689 break;
1690 }
1691 ast_verb(3, "%s redirecting info has changed, passing it to %s\n",
1693 if (ast_channel_redirecting_sub(c, in, f, 1)) {
1695 }
1696 pa->sentringing = 0;
1697 break;
1699 ast_verb(3, "%s is proceeding passing it to %s\n", ast_channel_name(c), ast_channel_name(in));
1700 if (single && !caller_entertained
1701 && CAN_EARLY_BRIDGE(peerflags, in, c)) {
1703 }
1706 ast_channel_publish_dial(in, c, NULL, "PROCEEDING");
1707 break;
1708 case AST_CONTROL_HOLD:
1709 /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */
1710 ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(c));
1712 break;
1713 case AST_CONTROL_UNHOLD:
1714 /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */
1715 ast_verb(3, "Call on %s left from hold\n", ast_channel_name(c));
1717 break;
1719 case AST_CONTROL_FLASH:
1720 /* Ignore going off hook and flash */
1721 break;
1722 case AST_CONTROL_CC:
1723 if (!ignore_cc) {
1725 cc_frame_received = 1;
1726 }
1727 break;
1730 break;
1732 if (!f->data.ptr) {
1733 ast_log(LOG_WARNING, "Got playback begin directive without filename on %s\n", ast_channel_name(c));
1734 } else {
1735 const char *filename = f->data.ptr;
1736 ast_verb(3, "Playing audio file %s on %s\n", filename, ast_channel_name(in));
1738 }
1739 break;
1740 case -1:
1741 if (single && !caller_entertained) {
1742 ast_verb(3, "%s stopped sounds\n", ast_channel_name(c));
1743 ast_indicate(in, -1);
1744 pa->sentringing = 0;
1745 }
1746 break;
1747 default:
1748 ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer);
1749 break;
1750 }
1751 break;
1752 case AST_FRAME_VIDEO:
1753 case AST_FRAME_VOICE:
1754 case AST_FRAME_IMAGE:
1756 case AST_FRAME_DTMF_END:
1757 if (caller_entertained) {
1758 break;
1759 }
1760 *to_progress = -1;
1761 orig_progress_to = -1;
1762 /* Fall through */
1763 case AST_FRAME_TEXT:
1764 if (single && ast_write(in, f)) {
1765 ast_log(LOG_WARNING, "Unable to write frametype: %u\n",
1766 f->frametype);
1767 }
1768 break;
1769 case AST_FRAME_HTML:
1771 && ast_channel_sendhtml(in, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
1772 ast_log(LOG_WARNING, "Unable to send URL\n");
1773 }
1774 break;
1775 default:
1776 break;
1777 }
1778 ast_frfree(f);
1779 } /* end for */
1780 if (winner == in) {
1781 struct ast_frame *f = ast_read(in);
1782#if 0
1783 if (f && (f->frametype != AST_FRAME_VOICE))
1784 printf("Frame type: %d, %d\n", f->frametype, f->subclass);
1785 else if (!f || (f->frametype != AST_FRAME_VOICE))
1786 printf("Hangup received on %s\n", in->name);
1787#endif
1788 if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
1789 /* Got hung up */
1790 *to_answer = -1;
1791 strcpy(pa->status, "CANCEL");
1792 pa->canceled = 1;
1793 publish_dial_end_event(in, out_chans, NULL, pa->status);
1794 if (f) {
1795 if (f->data.uint32) {
1797 }
1798 ast_frfree(f);
1799 }
1800 if (is_cc_recall) {
1801 ast_cc_completed(in, "CC completed, although the caller hung up (cancelled)");
1802 }
1803 SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller hung up\n", ast_channel_name(in));
1804 }
1805
1806 /* now f is guaranteed non-NULL */
1807 if (f->frametype == AST_FRAME_DTMF) {
1808 if (ast_test_flag64(peerflags, OPT_DTMF_EXIT)) {
1809 const char *context;
1811 context = pbx_builtin_getvar_helper(in, "EXITCONTEXT");
1812 if (onedigit_goto(in, context, (char) f->subclass.integer, 1)) {
1813 ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
1814 *to_answer = 0;
1815 *result = f->subclass.integer;
1816 strcpy(pa->status, "CANCEL");
1817 pa->canceled = 1;
1818 publish_dial_end_event(in, out_chans, NULL, pa->status);
1819 ast_frfree(f);
1821 if (is_cc_recall) {
1822 ast_cc_completed(in, "CC completed, but the caller used DTMF to exit");
1823 }
1824 SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller pressed %c to end call\n",
1826 }
1828 }
1829
1830 if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
1831 detect_disconnect(in, f->subclass.integer, &featurecode)) {
1832 ast_verb(3, "User requested call disconnect.\n");
1833 *to_answer = 0;
1834 strcpy(pa->status, "CANCEL");
1835 pa->canceled = 1;
1836 publish_dial_end_event(in, out_chans, NULL, pa->status);
1837 ast_frfree(f);
1838 if (is_cc_recall) {
1839 ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
1840 }
1841 SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller requested disconnect\n",
1843 }
1844 }
1845
1846 /* Send the frame from the in channel to all outgoing channels. */
1847 AST_LIST_TRAVERSE(out_chans, o, node) {
1848 if (!o->chan || !ast_test_flag64(o, DIAL_STILLGOING)) {
1849 /* This outgoing channel has died so don't send the frame to it. */
1850 continue;
1851 }
1852 switch (f->frametype) {
1853 case AST_FRAME_HTML:
1854 /* Forward HTML stuff */
1856 && ast_channel_sendhtml(o->chan, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
1857 ast_log(LOG_WARNING, "Unable to send URL\n");
1858 }
1859 break;
1860 case AST_FRAME_VIDEO:
1861 case AST_FRAME_VOICE:
1862 case AST_FRAME_IMAGE:
1863 if (!single || caller_entertained) {
1864 /*
1865 * We are calling multiple parties or caller is being
1866 * entertained and has thus not been made compatible.
1867 * No need to check any other called parties.
1868 */
1869 goto skip_frame;
1870 }
1871 /* Fall through */
1872 case AST_FRAME_TEXT:
1874 case AST_FRAME_DTMF_END:
1875 if (ast_write(o->chan, f)) {
1876 ast_log(LOG_WARNING, "Unable to forward frametype: %u\n",
1877 f->frametype);
1878 }
1879 break;
1880 case AST_FRAME_CONTROL:
1881 switch (f->subclass.integer) {
1882 case AST_CONTROL_HOLD:
1883 ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(o->chan));
1885 break;
1886 case AST_CONTROL_UNHOLD:
1887 ast_verb(3, "Call on %s left from hold\n", ast_channel_name(o->chan));
1889 break;
1890 case AST_CONTROL_FLASH:
1891 ast_verb(3, "Hook flash on %s\n", ast_channel_name(o->chan));
1893 break;
1897 if (!single || caller_entertained) {
1898 /*
1899 * We are calling multiple parties or caller is being
1900 * entertained and has thus not been made compatible.
1901 * No need to check any other called parties.
1902 */
1903 goto skip_frame;
1904 }
1905 ast_verb(3, "%s requested media update control %d, passing it to %s\n",
1908 break;
1911 ast_verb(3, "Connected line update to %s prevented.\n", ast_channel_name(o->chan));
1912 break;
1913 }
1914 if (ast_channel_connected_line_sub(in, o->chan, f, 1)) {
1916 }
1917 break;
1920 ast_verb(3, "Redirecting update to %s prevented.\n", ast_channel_name(o->chan));
1921 break;
1922 }
1923 if (ast_channel_redirecting_sub(in, o->chan, f, 1)) {
1925 }
1926 break;
1927 default:
1928 /* We are not going to do anything with this frame. */
1929 goto skip_frame;
1930 }
1931 break;
1932 default:
1933 /* We are not going to do anything with this frame. */
1934 goto skip_frame;
1935 }
1936 }
1937skip_frame:;
1938 ast_frfree(f);
1939 }
1940 }
1941
1942wait_over:
1943 if (!*to_answer || ast_check_hangup(in)) {
1944 ast_verb(3, "Nobody picked up in %d ms\n", orig_answer_to);
1945 publish_dial_end_event(in, out_chans, NULL, "NOANSWER");
1946 } else if (!*to_progress) {
1947 ast_verb(3, "No early media received in %d ms\n", orig_progress_to);
1948 publish_dial_end_event(in, out_chans, NULL, "CHANUNAVAIL");
1949 strcpy(pa->status, "CHANUNAVAIL");
1950 *to_answer = 0; /* Reset to prevent hangup */
1951 }
1952
1953 if (is_cc_recall) {
1954 ast_cc_completed(in, "Recall completed!");
1955 }
1956 SCOPE_EXIT_RTN_VALUE(peer, "%s: %s%s\n", ast_channel_name(in),
1957 peer ? "Answered by " : "No answer", peer ? ast_channel_name(peer) : "");
1958}
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
Definition: aoc.c:322
enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded)
get the message type, AOC-D, AOC-E, or AOC Request
Definition: aoc.c:901
struct ast_aoc_decoded * ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan)
decodes an encoded aoc payload.
Definition: aoc.c:458
struct ast_aoc_encoded * ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan)
encodes a decoded aoc structure so it can be passed on the wire
Definition: aoc.c:659
@ AST_AOC_S
Definition: aoc.h:64
static void do_forward(struct chanlist *o, struct cause_args *num, struct ast_flags64 *peerflags, int single, int caller_entertained, int *to, struct ast_party_id *forced_clid, struct ast_party_id *stored_clid)
Definition: app_dial.c:943
#define AST_MAX_WATCHERS
Definition: app_dial.c:864
static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out_chans, struct ast_channel *exception, const char *status)
Definition: app_dial.c:1155
static void update_connected_line_from_peer(struct ast_channel *chan, struct ast_channel *peer, int is_caller)
Definition: app_dial.c:1175
static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode)
Definition: app_dial.c:1960
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
int ast_cc_is_recall(struct ast_channel *chan, int *core_id, const char *const monitor_type)
Decide if a call to a particular channel is a CC recall.
Definition: ccss.c:3411
void ast_handle_cc_control_frame(struct ast_channel *inbound, struct ast_channel *outbound, void *frame_data)
Properly react to a CC control frame.
Definition: ccss.c:2299
int ast_cc_completed(struct ast_channel *chan, const char *const debug,...)
Indicate recall has been acknowledged.
Definition: ccss.c:3813
int ast_cc_failed(int core_id, const char *const debug,...)
Indicate failure has occurred.
Definition: ccss.c:3850
int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
Definition: channel.c:6587
void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
Set the connected line information based on another connected line source.
Definition: channel.c:2021
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:5103
struct timeval ast_channel_creationtime(struct ast_channel *chan)
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
Definition: channel.c:8790
const char * ast_hangup_cause_to_dial_status(int hangup_cause)
Convert a hangup cause to a publishable dial status.
Definition: dial.c:749
int ast_sf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int frequency, int is_external)
Send a string of SF digits to a channel.
Definition: main/app.c:1097
int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send a string of MF digits to a channel.
Definition: main/app.c:1113
#define AST_FRAME_DTMF
@ AST_FRAME_VIDEO
@ AST_FRAME_HTML
@ AST_FRAME_IMAGE
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_VOICE
@ AST_FRAME_TEXT
@ AST_CONTROL_SRCUPDATE
@ AST_CONTROL_WINK
@ AST_CONTROL_OFFHOOK
@ AST_CONTROL_BUSY
@ AST_CONTROL_UNHOLD
@ AST_CONTROL_VIDUPDATE
@ AST_CONTROL_PROCEEDING
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_PLAYBACK_BEGIN
@ AST_CONTROL_CC
@ AST_CONTROL_ANSWER
@ AST_CONTROL_HOLD
@ AST_CONTROL_FLASH
@ AST_CONTROL_AOC
@ AST_CONTROL_SRCCHANGE
@ AST_CONTROL_PVT_CAUSE_CODE
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:439
#define ast_str_alloca(init_len)
Definition: strings.h:848
struct ast_stream_topology * topology
Support for dynamic strings.
Definition: strings.h:623
struct ast_aoc_decoded * aoc_s_rate_list
Definition: app_dial.c:819
unsigned int pending_connected_update
Definition: app_dial.c:818
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107

References ao2_bump, chanlist::aoc_s_rate_list, ast_aoc_decode(), ast_aoc_destroy_decoded(), ast_aoc_destroy_encoded(), ast_aoc_encode(), ast_aoc_get_msg_type(), AST_AOC_S, AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CAUSE_NORMAL_CLEARING, ast_cc_completed(), ast_cc_failed(), ast_cc_is_recall(), ast_channel_call_forward(), ast_channel_connected(), ast_channel_connected_line_sub(), ast_channel_creationtime(), ast_channel_early_bridge(), ast_channel_exten_set(), ast_channel_hangupcause(), ast_channel_hangupcause_set(), ast_channel_language(), ast_channel_lock, ast_channel_make_compatible(), ast_channel_name(), ast_channel_publish_dial(), ast_channel_redirecting_sub(), ast_channel_sendhtml(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_unlock, ast_channel_update_connected_line(), ast_check_hangup(), ast_clear_flag64, ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_PLAYBACK_BEGIN, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_copy_flags64, ast_deactivate_generator(), ast_debug, ast_dtmf_stream(), AST_FEATURE_MAX_LEN, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IMAGE, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_free, ast_frfree, ast_handle_cc_control_frame(), ast_hangup(), ast_hangup_cause_to_dial_status(), ast_indicate(), ast_indicate_data(), AST_LIST_FIRST, AST_LIST_NEXT, AST_LIST_TRAVERSE, ast_log, AST_MAX_WATCHERS, ast_mf_stream(), ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_set(), ast_party_connected_line_set_init(), ast_read(), ast_remaining_ms(), ast_sf_stream(), AST_STATE_UP, ast_str_alloca, ast_str_tmp, ast_strdup, ast_stream_topology_to_str(), ast_streamfile(), ast_strlen_zero(), ast_test_flag64, ast_trace, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_verb, ast_waitfor_n(), ast_write(), cause_args::busy, c, CAN_EARLY_BRIDGE, privacy_args::canceled, chanlist::chan, config, cause_args::congestion, chanlist::connected, connected, voicemailpwcheck::context, ast_frame::data, ast_frame::datalen, detect_disconnect(), DIAL_CALLERID_ABSENT, DIAL_NOFORWARDHTML, DIAL_STILLGOING, do_forward(), ast_frame::frametype, handle_cause(), in, ast_frame_subclass::integer, LOG_WARNING, cause_args::nochan, NULL, onedigit_goto(), OPT_ARG_RINGBACK, OPT_CALLEE_HANGUP, OPT_CALLEE_MIXMONITOR, OPT_CALLEE_MONITOR, OPT_CALLEE_PARK, OPT_CALLEE_TRANSFER, OPT_CALLER_HANGUP, OPT_CALLER_MIXMONITOR, OPT_CALLER_MONITOR, OPT_CALLER_PARK, OPT_CALLER_TRANSFER, OPT_DTMF_EXIT, OPT_IGNORE_CONNECTEDLINE, OPT_MUSICBACK, OPT_RINGBACK, chanlist::orig_chan_name, pbx_builtin_getvar_helper(), chanlist::pending_connected_update, ast_frame::ptr, publish_dial_end_event(), result, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, privacy_args::sentringing, set_duration_var(), privacy_args::status, ast_frame::subclass, ast_frame_subclass::topology, ast_frame::uint32, and update_connected_line_from_peer().

Referenced by dial_exec_full().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Dialing Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "ccss", }
static

Definition at line 3616 of file app_dial.c.

◆ app

const char app[] = "Dial"
static

Definition at line 669 of file app_dial.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 3616 of file app_dial.c.

◆ dial_exec_options

const struct ast_app_option dial_exec_options[128] = { [ 'A' ] = { .flag = OPT_ANNOUNCE , .arg_index = OPT_ARG_ANNOUNCE + 1 }, [ 'a' ] = { .flag = (1LLU << 40) }, [ 'b' ] = { .flag = (1LLU << 41) , .arg_index = OPT_ARG_PREDIAL_CALLEE + 1 }, [ 'B' ] = { .flag = (1LLU << 42) , .arg_index = OPT_ARG_PREDIAL_CALLER + 1 }, [ 'C' ] = { .flag = OPT_RESETCDR }, [ 'c' ] = { .flag = (1LLU << 34) }, [ 'd' ] = { .flag = OPT_DTMF_EXIT }, [ 'D' ] = { .flag = OPT_SENDDTMF , .arg_index = OPT_ARG_SENDDTMF + 1 }, [ 'E' ] = { .flag = (1LLU << 45) }, [ 'e' ] = { .flag = (1LLU << 35) }, [ 'f' ] = { .flag = OPT_FORCECLID , .arg_index = OPT_ARG_FORCECLID + 1 }, [ 'F' ] = { .flag = (1LLU << 36) , .arg_index = OPT_ARG_CALLEE_GO_ON + 1 }, [ 'g' ] = { .flag = OPT_GO_ON }, [ 'G' ] = { .flag = OPT_GOTO , .arg_index = OPT_ARG_GOTO + 1 }, [ 'h' ] = { .flag = OPT_CALLEE_HANGUP }, [ 'H' ] = { .flag = OPT_CALLER_HANGUP }, [ 'i' ] = { .flag = OPT_IGNORE_FORWARDING }, [ 'I' ] = { .flag = OPT_IGNORE_CONNECTEDLINE }, [ 'j' ] = { .flag = (1LLU << 46) }, [ 'k' ] = { .flag = OPT_CALLEE_PARK }, [ 'K' ] = { .flag = OPT_CALLER_PARK }, [ 'L' ] = { .flag = OPT_DURATION_LIMIT , .arg_index = OPT_ARG_DURATION_LIMIT + 1 }, [ 'm' ] = { .flag = OPT_MUSICBACK , .arg_index = OPT_ARG_MUSICBACK + 1 }, [ 'n' ] = { .flag = OPT_SCREEN_NOINTRO , .arg_index = OPT_ARG_SCREEN_NOINTRO + 1 }, [ 'N' ] = { .flag = OPT_SCREEN_NOCALLERID }, [ 'o' ] = { .flag = OPT_ORIGINAL_CLID , .arg_index = OPT_ARG_ORIGINAL_CLID + 1 }, [ 'O' ] = { .flag = OPT_OPERMODE , .arg_index = OPT_ARG_OPERMODE + 1 }, [ 'p' ] = { .flag = OPT_SCREENING }, [ 'P' ] = { .flag = OPT_PRIVACY , .arg_index = OPT_ARG_PRIVACY + 1 }, [ 'Q' ] = { .flag = (1LLU << 44) , .arg_index = OPT_ARG_HANGUPCAUSE + 1 }, [ 'r' ] = { .flag = OPT_RINGBACK , .arg_index = OPT_ARG_RINGBACK + 1 }, [ 'R' ] = { .flag = (1LLU << 43) }, [ 'S' ] = { .flag = OPT_DURATION_STOP , .arg_index = OPT_ARG_DURATION_STOP + 1 }, [ 's' ] = { .flag = (1LLU << 38) , .arg_index = OPT_ARG_FORCE_CID_TAG + 1 }, [ 't' ] = { .flag = OPT_CALLEE_TRANSFER }, [ 'T' ] = { .flag = OPT_CALLER_TRANSFER }, [ 'u' ] = { .flag = (1LLU << 39) , .arg_index = OPT_ARG_FORCE_CID_PRES + 1 }, [ 'U' ] = { .flag = OPT_CALLEE_GOSUB , .arg_index = OPT_ARG_CALLEE_GOSUB + 1 }, [ 'w' ] = { .flag = OPT_CALLEE_MONITOR }, [ 'W' ] = { .flag = OPT_CALLER_MONITOR }, [ 'x' ] = { .flag = OPT_CALLEE_MIXMONITOR }, [ 'X' ] = { .flag = OPT_CALLER_MIXMONITOR }, [ 'z' ] = { .flag = (1LLU << 37) }, }
static

Definition at line 791 of file app_dial.c.

Referenced by dial_exec_full().

◆ rapp

const char rapp[] = "RetryDial"
static

Definition at line 670 of file app_dial.c.

Referenced by load_module(), retrydial_exec(), and unload_module().

◆ topology_ds_info

const struct ast_datastore_info topology_ds_info
static
Initial value:
= {
.type = "app_dial_topology_preserve",
.destroy = topology_ds_destroy,
}
static void topology_ds_destroy(void *data)
Definition: app_dial.c:826

Definition at line 831 of file app_dial.c.

Referenced by dial_exec_full().