Asterisk - The Open Source Telephony Project GIT-master-f36a736
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 858 of file app_dial.c.

◆ CAN_EARLY_BRIDGE

#define CAN_EARLY_BRIDGE (   flags,
  chan,
  peer 
)

Definition at line 787 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 702 of file app_dial.c.

◆ DIAL_NOFORWARDHTML

#define DIAL_NOFORWARDHTML   (1LLU << 32)

Definition at line 701 of file app_dial.c.

◆ DIAL_STILLGOING

#define DIAL_STILLGOING   (1LLU << 31)

Definition at line 700 of file app_dial.c.

◆ OPT_CALLEE_GO_ON

#define OPT_CALLEE_GO_ON   (1LLU << 36)

Definition at line 705 of file app_dial.c.

◆ OPT_CALLER_ANSWER

#define OPT_CALLER_ANSWER   (1LLU << 40)

Definition at line 709 of file app_dial.c.

◆ OPT_CANCEL_ELSEWHERE

#define OPT_CANCEL_ELSEWHERE   (1LLU << 34)

Definition at line 703 of file app_dial.c.

◆ OPT_CANCEL_TIMEOUT

#define OPT_CANCEL_TIMEOUT   (1LLU << 37)

Definition at line 706 of file app_dial.c.

◆ OPT_FORCE_CID_PRES

#define OPT_FORCE_CID_PRES   (1LLU << 39)

Definition at line 708 of file app_dial.c.

◆ OPT_FORCE_CID_TAG

#define OPT_FORCE_CID_TAG   (1LLU << 38)

Definition at line 707 of file app_dial.c.

◆ OPT_HANGUPCAUSE

#define OPT_HANGUPCAUSE   (1LLU << 44)

Definition at line 713 of file app_dial.c.

◆ OPT_HEARPULSING

#define OPT_HEARPULSING   (1LLU << 45)

Definition at line 714 of file app_dial.c.

◆ OPT_PEER_H

#define OPT_PEER_H   (1LLU << 35)

Definition at line 704 of file app_dial.c.

◆ OPT_PREDIAL_CALLEE

#define OPT_PREDIAL_CALLEE   (1LLU << 41)

Definition at line 710 of file app_dial.c.

◆ OPT_PREDIAL_CALLER

#define OPT_PREDIAL_CALLER   (1LLU << 42)

Definition at line 711 of file app_dial.c.

◆ OPT_RING_WITH_EARLY_MEDIA

#define OPT_RING_WITH_EARLY_MEDIA   (1LLU << 43)

Definition at line 712 of file app_dial.c.

◆ OPT_TOPOLOGY_PRESERVE

#define OPT_TOPOLOGY_PRESERVE   (1LLU << 46)

Definition at line 715 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 666 of file app_dial.c.

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

◆ 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 717 of file app_dial.c.

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

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 3601 of file app_dial.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 3601 of file app_dial.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 3601 of file app_dial.c.

◆ chanlist_free()

static void chanlist_free ( struct chanlist outgoing)
static

Definition at line 832 of file app_dial.c.

833{
835 ast_aoc_destroy_decoded(outgoing->aoc_s_rate_list);
836 ast_free(outgoing->orig_chan_name);
838}
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
Definition: aoc.c:307
#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:2091

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 1945 of file app_dial.c.

1946{
1947 char disconnect_code[AST_FEATURE_MAX_LEN];
1948 int res;
1949
1950 ast_str_append(featurecode, 1, "%c", code);
1951
1952 res = ast_get_builtin_feature(chan, "disconnect", disconnect_code, sizeof(disconnect_code));
1953 if (res) {
1954 ast_str_reset(*featurecode);
1955 return 0;
1956 }
1957
1958 if (strlen(disconnect_code) > ast_str_strlen(*featurecode)) {
1959 /* Could be a partial match, anyway */
1960 if (strncmp(disconnect_code, ast_str_buffer(*featurecode), ast_str_strlen(*featurecode))) {
1961 ast_str_reset(*featurecode);
1962 }
1963 return 0;
1964 }
1965
1966 if (strcmp(disconnect_code, ast_str_buffer(*featurecode))) {
1967 ast_str_reset(*featurecode);
1968 return 0;
1969 }
1970
1971 return 1;
1972}
#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 3459 of file app_dial.c.

3460{
3461 struct ast_flags64 peerflags;
3462
3463 memset(&peerflags, 0, sizeof(peerflags));
3464
3465 return dial_exec_full(chan, data, &peerflags, NULL);
3466}
static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast_flags64 *peerflags, int *continue_exec)
Definition: app_dial.c:2299
#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 2299 of file app_dial.c.

2300{
2301 int res = -1; /* default: error */
2302 char *rest, *cur; /* scan the list of destinations */
2303 struct dial_head out_chans = AST_LIST_HEAD_NOLOCK_INIT_VALUE; /* list of destinations */
2304 struct chanlist *outgoing;
2305 struct chanlist *tmp;
2306 struct ast_channel *peer = NULL;
2307 int to_answer, to_progress; /* timeouts */
2308 struct cause_args num = { chan, 0, 0, 0 };
2309 int cause, hanguptreecause = -1;
2310
2311 struct ast_bridge_config config = { { 0, } };
2312 struct timeval calldurationlimit = { 0, };
2313 char *dtmfcalled = NULL, *dtmfcalling = NULL, *dtmf_progress = NULL;
2314 char *mf_progress = NULL, *mf_wink = NULL;
2315 char *sf_progress = NULL, *sf_wink = NULL;
2316 struct privacy_args pa = {
2317 .sentringing = 0,
2318 .privdb_val = 0,
2319 .status = "INVALIDARGS",
2320 .canceled = 0,
2321 };
2322 int sentringing = 0, moh = 0;
2323 const char *outbound_group = NULL;
2324 int result = 0;
2325 char *parse;
2326 int opermode = 0;
2327 int delprivintro = 0;
2330 AST_APP_ARG(timeout);
2333 );
2334 struct ast_flags64 opts = { 0, };
2335 char *opt_args[OPT_ARG_ARRAY_SIZE];
2336 int fulldial = 0, num_dialed = 0;
2337 int ignore_cc = 0;
2338 char device_name[AST_CHANNEL_NAME];
2339 char forced_clid_name[AST_MAX_EXTENSION];
2340 char stored_clid_name[AST_MAX_EXTENSION];
2341 int force_forwards_only; /*!< TRUE if force CallerID on call forward only. Legacy behaviour.*/
2342 /*!
2343 * \brief Forced CallerID party information to send.
2344 * \note This will not have any malloced strings so do not free it.
2345 */
2346 struct ast_party_id forced_clid;
2347 /*!
2348 * \brief Stored CallerID information if needed.
2349 *
2350 * \note If OPT_ORIGINAL_CLID set then this is the o option
2351 * CallerID. Otherwise it is the dialplan extension and hint
2352 * name.
2353 *
2354 * \note This will not have any malloced strings so do not free it.
2355 */
2356 struct ast_party_id stored_clid;
2357 /*!
2358 * \brief CallerID party information to store.
2359 * \note This will not have any malloced strings so do not free it.
2360 */
2361 struct ast_party_caller caller;
2362 int max_forwards;
2363 struct ast_datastore *topology_ds = NULL;
2364 SCOPE_ENTER(1, "%s: Data: %s\n", ast_channel_name(chan), data);
2365
2366 /* Reset all DIAL variables back to blank, to prevent confusion (in case we don't reset all of them). */
2367 ast_channel_lock(chan);
2369 pbx_builtin_setvar_helper(chan, "DIALSTATUS", "");
2370 pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", "");
2371 pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", "");
2372 pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", "");
2373 pbx_builtin_setvar_helper(chan, "ANSWEREDTIME_MS", "");
2374 pbx_builtin_setvar_helper(chan, "DIALEDTIME", "");
2375 pbx_builtin_setvar_helper(chan, "DIALEDTIME_MS", "");
2376 pbx_builtin_setvar_helper(chan, "RINGTIME", "");
2377 pbx_builtin_setvar_helper(chan, "RINGTIME_MS", "");
2378 pbx_builtin_setvar_helper(chan, "PROGRESSTIME", "");
2379 pbx_builtin_setvar_helper(chan, "PROGRESSTIME_MS", "");
2382 ast_channel_unlock(chan);
2383
2384 if (max_forwards <= 0) {
2385 ast_log(LOG_WARNING, "Cannot place outbound call from channel '%s'. Max forwards exceeded\n",
2386 ast_channel_name(chan));
2387 pbx_builtin_setvar_helper(chan, "DIALSTATUS", "BUSY");
2388 SCOPE_EXIT_RTN_VALUE(-1, "%s: Max forwards exceeded\n", ast_channel_name(chan));
2389 }
2390
2391 if (ast_check_hangup_locked(chan)) {
2392 /*
2393 * Caller hung up before we could dial. If dial is executed
2394 * within an AGI then the AGI has likely eaten all queued
2395 * frames before executing the dial in DeadAGI mode. With
2396 * the caller hung up and no pending frames from the caller's
2397 * read queue, dial would not know that the call has hung up
2398 * until a called channel answers. It is rather annoying to
2399 * whoever just answered the non-existent call.
2400 *
2401 * Dial should not continue execution in DeadAGI mode, hangup
2402 * handlers, or the h exten.
2403 */
2404 ast_verb(3, "Caller hung up before dial.\n");
2405 pbx_builtin_setvar_helper(chan, "DIALSTATUS", "CANCEL");
2406 SCOPE_EXIT_RTN_VALUE(-1, "%s: Caller hung up before dial\n", ast_channel_name(chan));
2407 }
2408
2409 parse = ast_strdupa(data ?: "");
2410
2412
2413 if (!ast_strlen_zero(args.options) &&
2414 ast_app_parse_options64(dial_exec_options, &opts, opt_args, args.options)) {
2415 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
2416 goto done;
2417 }
2418
2419 if (ast_cc_call_init(chan, &ignore_cc)) {
2420 goto done;
2421 }
2422
2424 delprivintro = atoi(opt_args[OPT_ARG_SCREEN_NOINTRO]);
2425
2426 if (delprivintro < 0 || delprivintro > 1) {
2427 ast_log(LOG_WARNING, "Unknown argument %d specified to n option, ignoring\n", delprivintro);
2428 delprivintro = 0;
2429 }
2430 }
2431
2432 if (!ast_test_flag64(&opts, OPT_RINGBACK)) {
2433 opt_args[OPT_ARG_RINGBACK] = NULL;
2434 }
2435
2436 if (ast_test_flag64(&opts, OPT_OPERMODE)) {
2437 opermode = ast_strlen_zero(opt_args[OPT_ARG_OPERMODE]) ? 1 : atoi(opt_args[OPT_ARG_OPERMODE]);
2438 ast_verb(3, "Setting operator services mode to %d.\n", opermode);
2439 }
2440
2442 calldurationlimit.tv_sec = atoi(opt_args[OPT_ARG_DURATION_STOP]);
2443 if (!calldurationlimit.tv_sec) {
2444 ast_log(LOG_WARNING, "Dial does not accept S(%s)\n", opt_args[OPT_ARG_DURATION_STOP]);
2445 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
2446 goto done;
2447 }
2448 ast_verb(3, "Setting call duration limit to %.3lf seconds.\n", calldurationlimit.tv_sec + calldurationlimit.tv_usec / 1000000.0);
2449 }
2450
2451 if (ast_test_flag64(&opts, OPT_SENDDTMF) && !ast_strlen_zero(opt_args[OPT_ARG_SENDDTMF])) {
2452 sf_wink = opt_args[OPT_ARG_SENDDTMF];
2453 dtmfcalled = strsep(&sf_wink, ":");
2454 dtmfcalling = strsep(&sf_wink, ":");
2455 dtmf_progress = strsep(&sf_wink, ":");
2456 mf_progress = strsep(&sf_wink, ":");
2457 mf_wink = strsep(&sf_wink, ":");
2458 sf_progress = strsep(&sf_wink, ":");
2459 }
2460
2462 if (ast_bridge_timelimit(chan, &config, opt_args[OPT_ARG_DURATION_LIMIT], &calldurationlimit))
2463 goto done;
2464 }
2465
2466 /* Setup the forced CallerID information to send if used. */
2467 ast_party_id_init(&forced_clid);
2468 force_forwards_only = 0;
2469 if (ast_test_flag64(&opts, OPT_FORCECLID)) {
2470 if (ast_strlen_zero(opt_args[OPT_ARG_FORCECLID])) {
2471 ast_channel_lock(chan);
2472 forced_clid.number.str = ast_strdupa(ast_channel_exten(chan));
2473 ast_channel_unlock(chan);
2474 forced_clid_name[0] = '\0';
2475 forced_clid.name.str = (char *) get_cid_name(forced_clid_name,
2476 sizeof(forced_clid_name), chan);
2477 force_forwards_only = 1;
2478 } else {
2479 /* Note: The opt_args[OPT_ARG_FORCECLID] string value is altered here. */
2480 ast_callerid_parse(opt_args[OPT_ARG_FORCECLID], &forced_clid.name.str,
2481 &forced_clid.number.str);
2482 }
2483 if (!ast_strlen_zero(forced_clid.name.str)) {
2484 forced_clid.name.valid = 1;
2485 }
2486 if (!ast_strlen_zero(forced_clid.number.str)) {
2487 forced_clid.number.valid = 1;
2488 }
2489 }
2491 && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_TAG])) {
2492 forced_clid.tag = opt_args[OPT_ARG_FORCE_CID_TAG];
2493 }
2494 forced_clid.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN;
2496 && !ast_strlen_zero(opt_args[OPT_ARG_FORCE_CID_PRES])) {
2497 int pres;
2498
2500 if (0 <= pres) {
2501 forced_clid.number.presentation = pres;
2502 }
2503 }
2504
2505 /* Setup the stored CallerID information if needed. */
2506 ast_party_id_init(&stored_clid);
2507 if (ast_test_flag64(&opts, OPT_ORIGINAL_CLID)) {
2508 if (ast_strlen_zero(opt_args[OPT_ARG_ORIGINAL_CLID])) {
2509 ast_channel_lock(chan);
2510 ast_party_id_set_init(&stored_clid, &ast_channel_caller(chan)->id);
2511 if (!ast_strlen_zero(ast_channel_caller(chan)->id.name.str)) {
2512 stored_clid.name.str = ast_strdupa(ast_channel_caller(chan)->id.name.str);
2513 }
2514 if (!ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) {
2515 stored_clid.number.str = ast_strdupa(ast_channel_caller(chan)->id.number.str);
2516 }
2517 if (!ast_strlen_zero(ast_channel_caller(chan)->id.subaddress.str)) {
2518 stored_clid.subaddress.str = ast_strdupa(ast_channel_caller(chan)->id.subaddress.str);
2519 }
2520 if (!ast_strlen_zero(ast_channel_caller(chan)->id.tag)) {
2521 stored_clid.tag = ast_strdupa(ast_channel_caller(chan)->id.tag);
2522 }
2523 ast_channel_unlock(chan);
2524 } else {
2525 /* Note: The opt_args[OPT_ARG_ORIGINAL_CLID] string value is altered here. */
2526 ast_callerid_parse(opt_args[OPT_ARG_ORIGINAL_CLID], &stored_clid.name.str,
2527 &stored_clid.number.str);
2528 if (!ast_strlen_zero(stored_clid.name.str)) {
2529 stored_clid.name.valid = 1;
2530 }
2531 if (!ast_strlen_zero(stored_clid.number.str)) {
2532 stored_clid.number.valid = 1;
2533 }
2534 }
2535 } else {
2536 /*
2537 * In case the new channel has no preset CallerID number by the
2538 * channel driver, setup the dialplan extension and hint name.
2539 */
2540 stored_clid_name[0] = '\0';
2541 stored_clid.name.str = (char *) get_cid_name(stored_clid_name,
2542 sizeof(stored_clid_name), chan);
2543 if (ast_strlen_zero(stored_clid.name.str)) {
2544 stored_clid.name.str = NULL;
2545 } else {
2546 stored_clid.name.valid = 1;
2547 }
2548 ast_channel_lock(chan);
2549 stored_clid.number.str = ast_strdupa(ast_channel_exten(chan));
2550 stored_clid.number.valid = 1;
2551 ast_channel_unlock(chan);
2552 }
2553
2554 if (ast_test_flag64(&opts, OPT_RESETCDR)) {
2556 }
2559
2561 res = setup_privacy_args(&pa, &opts, opt_args, chan);
2562 if (res <= 0)
2563 goto out;
2564 res = -1; /* reset default */
2565 }
2566
2567 if (continue_exec)
2568 *continue_exec = 0;
2569
2570 /* If a channel group has been specified, get it for use when we create peer channels */
2571
2572 ast_channel_lock(chan);
2573 if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP_ONCE"))) {
2574 outbound_group = ast_strdupa(outbound_group);
2575 pbx_builtin_setvar_helper(chan, "OUTBOUND_GROUP_ONCE", NULL);
2576 } else if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP"))) {
2577 outbound_group = ast_strdupa(outbound_group);
2578 }
2579 ast_channel_unlock(chan);
2580
2581 /* Set per dial instance flags. These flags are also passed back to RetryDial. */
2585
2586 /* PREDIAL: Run gosub on the caller's channel */
2588 && !ast_strlen_zero(opt_args[OPT_ARG_PREDIAL_CALLER])) {
2590 ast_app_exec_sub(NULL, chan, opt_args[OPT_ARG_PREDIAL_CALLER], 0);
2591 }
2592
2593 /* loop through the list of dial destinations */
2594 rest = args.peers;
2595 while ((cur = strsep(&rest, "&"))) {
2596 struct ast_channel *tc; /* channel for this destination */
2597 char *number;
2598 char *tech;
2599 int i;
2600 size_t tech_len;
2601 size_t number_len;
2602 struct ast_stream_topology *topology;
2603 struct ast_stream *stream;
2604
2605 cur = ast_strip(cur);
2606 if (ast_strlen_zero(cur)) {
2607 /* No tech/resource in this position. */
2608 continue;
2609 }
2610
2611 /* Get a technology/resource pair */
2612 number = cur;
2613 tech = strsep(&number, "/");
2614
2615 num_dialed++;
2616 if (ast_strlen_zero(number)) {
2617 ast_log(LOG_WARNING, "Dial argument takes format (technology/resource)\n");
2618 goto out;
2619 }
2620
2621 tech_len = strlen(tech) + 1;
2622 number_len = strlen(number) + 1;
2623 tmp = ast_calloc(1, sizeof(*tmp) + (2 * tech_len) + number_len);
2624 if (!tmp) {
2625 goto out;
2626 }
2627
2628 /* Save tech, number, and interface. */
2629 cur = tmp->stuff;
2630 strcpy(cur, tech);
2631 tmp->tech = cur;
2632 cur += tech_len;
2633 strcpy(cur, tech);
2634 cur[tech_len - 1] = '/';
2635 tmp->interface = cur;
2636 cur += tech_len;
2637 strcpy(cur, number);
2638 tmp->number = cur;
2639
2640 if (opts.flags) {
2641 /* Set per outgoing call leg options. */
2642 ast_copy_flags64(tmp, &opts,
2652 }
2653
2654 /* Request the peer */
2655
2656 ast_channel_lock(chan);
2657 /*
2658 * Seed the chanlist's connected line information with previously
2659 * acquired connected line info from the incoming channel. The
2660 * previously acquired connected line info could have been set
2661 * through the CONNECTED_LINE dialplan function.
2662 */
2664
2666 topology_ds = ast_channel_datastore_find(chan, &topology_ds_info, NULL);
2667
2668 if (!topology_ds && (topology_ds = ast_datastore_alloc(&topology_ds_info, NULL))) {
2670 ast_channel_datastore_add(chan, topology_ds);
2671 }
2672 }
2673
2674 if (topology_ds) {
2675 ao2_ref(topology_ds->data, +1);
2676 topology = topology_ds->data;
2677 } else {
2679 }
2680
2681 ast_channel_unlock(chan);
2682
2683 for (i = 0; i < ast_stream_topology_get_count(topology); ++i) {
2684 stream = ast_stream_topology_get_stream(topology, i);
2685 /* For both recvonly and sendonly the stream state reflects our state, that is we
2686 * are receiving only and we are sending only. Since we are requesting a
2687 * channel for the peer, we need to swap this to reflect what we will be doing.
2688 * That is, if we are receiving from Alice then we want to be sending to Bob,
2689 * so swap recvonly to sendonly and vice versa.
2690 */
2693 } else if (ast_stream_get_state(stream) == AST_STREAM_STATE_SENDONLY) {
2695 }
2696 }
2697
2698 tc = ast_request_with_stream_topology(tmp->tech, topology, NULL, chan, tmp->number, &cause);
2699
2700 ast_stream_topology_free(topology);
2701
2702 if (!tc) {
2703 /* If we can't, just go on to the next call */
2704 /* Failure doesn't necessarily mean user error. DAHDI channels could be busy. */
2705 ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n",
2706 tmp->tech, cause, ast_cause2str(cause));
2707 handle_cause(cause, &num);
2708 if (!rest) {
2709 /* we are on the last destination */
2710 ast_channel_hangupcause_set(chan, cause);
2711 }
2712 if (!ignore_cc && (cause == AST_CAUSE_BUSY || cause == AST_CAUSE_CONGESTION)) {
2713 if (!ast_cc_callback(chan, tmp->tech, tmp->number, ast_cc_busy_interface)) {
2714 ast_cc_extension_monitor_add_dialstring(chan, tmp->interface, "");
2715 }
2716 }
2718 continue;
2719 }
2720
2721 ast_channel_get_device_name(tc, device_name, sizeof(device_name));
2722 if (!ignore_cc) {
2723 ast_cc_extension_monitor_add_dialstring(chan, tmp->interface, device_name);
2724 }
2725
2726 ast_channel_lock_both(tc, chan);
2728
2729 pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", tmp->number);
2730
2731 /* Setup outgoing SDP to match incoming one */
2732 if (!AST_LIST_FIRST(&out_chans) && !rest && CAN_EARLY_BRIDGE(peerflags, chan, tc)) {
2733 /* We are on the only destination. */
2735 }
2736
2737 /* Inherit specially named variables from parent channel */
2741
2742 ast_channel_appl_set(tc, "AppDial");
2743 ast_channel_data_set(tc, "(Outgoing Line)");
2744
2745 memset(ast_channel_whentohangup(tc), 0, sizeof(*ast_channel_whentohangup(tc)));
2746
2747 /* Determine CallerID to store in outgoing channel. */
2749 if (ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
2750 caller.id = stored_clid;
2751 ast_channel_set_caller_event(tc, &caller, NULL);
2753 } else if (ast_strlen_zero(S_COR(ast_channel_caller(tc)->id.number.valid,
2754 ast_channel_caller(tc)->id.number.str, NULL))) {
2755 /*
2756 * The new channel has no preset CallerID number by the channel
2757 * driver. Use the dialplan extension and hint name.
2758 */
2759 caller.id = stored_clid;
2760 if (!caller.id.name.valid
2761 && !ast_strlen_zero(S_COR(ast_channel_connected(chan)->id.name.valid,
2762 ast_channel_connected(chan)->id.name.str, NULL))) {
2763 /*
2764 * No hint name available. We have a connected name supplied by
2765 * the dialplan we can use instead.
2766 */
2767 caller.id.name.valid = 1;
2768 caller.id.name = ast_channel_connected(chan)->id.name;
2769 }
2770 ast_channel_set_caller_event(tc, &caller, NULL);
2772 } else if (ast_strlen_zero(S_COR(ast_channel_caller(tc)->id.name.valid, ast_channel_caller(tc)->id.name.str,
2773 NULL))) {
2774 /* The new channel has no preset CallerID name by the channel driver. */
2775 if (!ast_strlen_zero(S_COR(ast_channel_connected(chan)->id.name.valid,
2776 ast_channel_connected(chan)->id.name.str, NULL))) {
2777 /*
2778 * We have a connected name supplied by the dialplan we can
2779 * use instead.
2780 */
2781 caller.id.name.valid = 1;
2782 caller.id.name = ast_channel_connected(chan)->id.name;
2783 ast_channel_set_caller_event(tc, &caller, NULL);
2784 }
2785 }
2786
2787 /* Determine CallerID for outgoing channel to send. */
2788 if (ast_test_flag64(peerflags, OPT_FORCECLID) && !force_forwards_only) {
2790
2792 connected.id = forced_clid;
2794 } else {
2796 }
2797
2799
2801
2804 ast_channel_musicclass_set(tc, ast_channel_musicclass(chan));
2805 }
2806
2807 /* Pass ADSI CPE and transfer capability */
2810
2811 /* If we have an outbound group, set this peer channel to it */
2812 if (outbound_group)
2813 ast_app_group_set_channel(tc, outbound_group);
2814 /* If the calling channel has the ANSWERED_ELSEWHERE flag set, inherit it. This is to support local channels */
2817
2818 /* Check if we're forced by configuration */
2821
2822
2823 /* Inherit context and extension */
2824 ast_channel_dialcontext_set(tc, ast_channel_context(chan));
2826
2828
2829 /* Save the original channel name to detect call pickup masquerading in. */
2830 tmp->orig_chan_name = ast_strdup(ast_channel_name(tc));
2831
2833 ast_channel_unlock(chan);
2834
2835 /* Put channel in the list of outgoing thingies. */
2836 tmp->chan = tc;
2837 AST_LIST_INSERT_TAIL(&out_chans, tmp, node);
2838 }
2839
2840 /* As long as we attempted to dial valid peers, don't throw a warning. */
2841 /* If a DAHDI peer is busy, out_chans will be empty so checking list size is misleading. */
2842 if (!num_dialed) {
2843 ast_verb(3, "No devices or endpoints to dial (technology/resource)\n");
2844 if (continue_exec) {
2845 /* There is no point in having RetryDial try again */
2846 *continue_exec = 1;
2847 }
2848 strcpy(pa.status, "CHANUNAVAIL");
2849 res = 0;
2850 goto out;
2851 }
2852
2853 /*
2854 * PREDIAL: Run gosub on all of the callee channels
2855 *
2856 * We run the callee predial before ast_call() in case the user
2857 * wishes to do something on the newly created channels before
2858 * the channel does anything important.
2859 *
2860 * Inside the target gosub we will be able to do something with
2861 * the newly created channel name ie: now the calling channel
2862 * can know what channel will be used to call the destination
2863 * ex: now we will know that SIP/abc-123 is calling SIP/def-124
2864 */
2867 && !AST_LIST_EMPTY(&out_chans)) {
2868 const char *predial_callee;
2869
2871 predial_callee = ast_app_expand_sub_args(chan, opt_args[OPT_ARG_PREDIAL_CALLEE]);
2872 if (predial_callee) {
2874 AST_LIST_TRAVERSE(&out_chans, tmp, node) {
2875 ast_pre_call(tmp->chan, predial_callee);
2876 }
2878 ast_free((char *) predial_callee);
2879 }
2880 }
2881
2882 /* Start all outgoing calls */
2883 AST_LIST_TRAVERSE_SAFE_BEGIN(&out_chans, tmp, node) {
2884 res = ast_call(tmp->chan, tmp->number, 0); /* Place the call, but don't wait on the answer */
2885 ast_channel_lock(chan);
2886
2887 /* check the results of ast_call */
2888 if (res) {
2889 /* Again, keep going even if there's an error */
2890 ast_debug(1, "ast call on peer returned %d\n", res);
2891 ast_verb(3, "Couldn't call %s\n", tmp->interface);
2892 if (ast_channel_hangupcause(tmp->chan)) {
2894 }
2895 ast_channel_unlock(chan);
2896 ast_cc_call_failed(chan, tmp->chan, tmp->interface);
2897 ast_hangup(tmp->chan);
2898 tmp->chan = NULL;
2901 continue;
2902 }
2903
2904 ast_channel_publish_dial(chan, tmp->chan, tmp->number, NULL);
2905 ast_channel_unlock(chan);
2906
2907 ast_verb(3, "Called %s\n", tmp->interface);
2909
2910 /* If this line is up, don't try anybody else */
2911 if (ast_channel_state(tmp->chan) == AST_STATE_UP) {
2912 break;
2913 }
2914 }
2916
2917 if (ast_strlen_zero(args.timeout)) {
2918 to_answer = -1;
2919 to_progress = -1;
2920 } else {
2921 char *anstimeout = strsep(&args.timeout, "^");
2922 if (!ast_strlen_zero(anstimeout)) {
2923 to_answer = atoi(anstimeout);
2924 if (to_answer > 0) {
2925 to_answer *= 1000;
2926 } else {
2927 ast_log(LOG_WARNING, "Invalid answer timeout specified: '%s'. Setting timeout to infinite\n", args.timeout);
2928 to_answer = -1;
2929 }
2930 } else {
2931 to_answer = -1;
2932 }
2933 if (!ast_strlen_zero(args.timeout)) {
2934 to_progress = atoi(args.timeout);
2935 if (to_progress > 0) {
2936 to_progress *= 1000;
2937 } else {
2938 ast_log(LOG_WARNING, "Invalid progress timeout specified: '%s'. Setting timeout to infinite\n", args.timeout);
2939 to_progress = -1;
2940 }
2941 } else {
2942 to_progress = -1;
2943 }
2944 }
2945
2946 outgoing = AST_LIST_FIRST(&out_chans);
2947 if (!outgoing) {
2948 strcpy(pa.status, "CHANUNAVAIL");
2949 if (fulldial == num_dialed) {
2950 res = -1;
2951 goto out;
2952 }
2953 } else {
2954 /* Our status will at least be NOANSWER */
2955 strcpy(pa.status, "NOANSWER");
2957 moh = 1;
2958 if (!ast_strlen_zero(opt_args[OPT_ARG_MUSICBACK])) {
2959 char *original_moh = ast_strdupa(ast_channel_musicclass(chan));
2960 ast_channel_musicclass_set(chan, opt_args[OPT_ARG_MUSICBACK]);
2961 ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL);
2962 ast_channel_musicclass_set(chan, original_moh);
2963 } else {
2964 ast_moh_start(chan, NULL, NULL);
2965 }
2968 if (!ast_strlen_zero(opt_args[OPT_ARG_RINGBACK])) {
2969 if (dial_handle_playtones(chan, opt_args[OPT_ARG_RINGBACK])){
2971 sentringing++;
2972 } else {
2974 }
2975 } else {
2977 sentringing++;
2978 }
2979 }
2980 }
2981
2982 peer = wait_for_answer(chan, &out_chans, &to_answer, &to_progress, peerflags, opt_args, &pa, &num, &result,
2983 dtmf_progress, mf_progress, mf_wink, sf_progress, sf_wink,
2984 (ast_test_flag64(&opts, OPT_HEARPULSING) ? 1 : 0),
2985 ignore_cc, &forced_clid, &stored_clid, &config);
2986
2987 if (!peer) {
2988 if (result) {
2989 res = result;
2990 } else if (to_answer) { /* Musta gotten hung up */
2991 res = -1;
2992 } else { /* Nobody answered, next please? */
2993 res = 0;
2994 }
2995 } else {
2996 const char *number;
2997 const char *name;
2998 int dial_end_raised = 0;
2999 int cause = -1;
3000
3001 if (ast_test_flag64(&opts, OPT_CALLER_ANSWER)) {
3002 ast_answer(chan);
3003 }
3004
3005 /* Ah ha! Someone answered within the desired timeframe. Of course after this
3006 we will always return with -1 so that it is hung up properly after the
3007 conversation. */
3008
3010 && !ast_strlen_zero(opt_args[OPT_ARG_HANGUPCAUSE])) {
3011 cause = ast_str2cause(opt_args[OPT_ARG_HANGUPCAUSE]);
3012 if (cause <= 0) {
3013 if (!strcasecmp(opt_args[OPT_ARG_HANGUPCAUSE], "NONE")) {
3014 cause = 0;
3015 } else if (sscanf(opt_args[OPT_ARG_HANGUPCAUSE], "%30d", &cause) != 1
3016 || cause < 0) {
3017 ast_log(LOG_WARNING, "Invalid cause given to Dial(...Q(<cause>)): \"%s\"\n",
3018 opt_args[OPT_ARG_HANGUPCAUSE]);
3019 cause = -1;
3020 }
3021 }
3022 }
3023 hanguptree(&out_chans, peer, cause >= 0 ? cause : AST_CAUSE_ANSWERED_ELSEWHERE);
3024
3025 /* If appropriate, log that we have a destination channel and set the answer time */
3026
3027 ast_channel_lock(peer);
3029
3030 number = pbx_builtin_getvar_helper(peer, "DIALEDPEERNUMBER");
3031 if (ast_strlen_zero(number)) {
3032 number = NULL;
3033 } else {
3035 }
3036 ast_channel_unlock(peer);
3037
3038 ast_channel_lock(chan);
3040
3041 strcpy(pa.status, "ANSWER");
3042 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
3043
3044 pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", name);
3045 pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number);
3046
3048 ast_channel_unlock(chan);
3049
3050 if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) {
3051 ast_debug(1, "app_dial: sendurl=%s.\n", args.url);
3052 ast_channel_sendurl( peer, args.url );
3053 }
3055 if (do_privacy(chan, peer, &opts, opt_args, &pa)) {
3056 ast_channel_publish_dial(chan, peer, NULL, pa.status);
3057 /* hang up on the callee -- he didn't want to talk anyway! */
3059 res = 0;
3060 goto out;
3061 }
3062 }
3063 if (!ast_test_flag64(&opts, OPT_ANNOUNCE) || ast_strlen_zero(opt_args[OPT_ARG_ANNOUNCE])) {
3064 res = 0;
3065 } else {
3066 int digit = 0;
3067 struct ast_channel *chans[2];
3068 struct ast_channel *active_chan;
3069 char *calledfile = NULL, *callerfile = NULL;
3070 int calledstream = 0, callerstream = 0;
3071
3072 chans[0] = chan;
3073 chans[1] = peer;
3074
3075 /* we need to stream the announcement(s) when the OPT_ARG_ANNOUNCE (-A) is set */
3076 callerfile = opt_args[OPT_ARG_ANNOUNCE];
3077 calledfile = strsep(&callerfile, ":");
3078
3079 /* stream the file(s) */
3080 if (!ast_strlen_zero(calledfile)) {
3081 res = ast_streamfile(peer, calledfile, ast_channel_language(peer));
3082 if (res) {
3083 res = 0;
3084 ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", calledfile);
3085 } else {
3086 calledstream = 1;
3087 }
3088 }
3089 if (!ast_strlen_zero(callerfile)) {
3090 res = ast_streamfile(chan, callerfile, ast_channel_language(chan));
3091 if (res) {
3092 res = 0;
3093 ast_log(LOG_ERROR, "error streaming file '%s' to caller\n", callerfile);
3094 } else {
3095 callerstream = 1;
3096 }
3097 }
3098
3099 /* can't use ast_waitstream, because we're streaming two files at once, and can't block
3100 We'll need to handle both channels at once. */
3101
3103 while (ast_channel_stream(peer) || ast_channel_stream(chan)) {
3104 int mspeer, mschan;
3105
3106 mspeer = ast_sched_wait(ast_channel_sched(peer));
3107 mschan = ast_sched_wait(ast_channel_sched(chan));
3108
3109 if (calledstream) {
3110 if (mspeer < 0 && !ast_channel_timingfunc(peer)) {
3111 ast_stopstream(peer);
3112 calledstream = 0;
3113 }
3114 }
3115 if (callerstream) {
3116 if (mschan < 0 && !ast_channel_timingfunc(chan)) {
3117 ast_stopstream(chan);
3118 callerstream = 0;
3119 }
3120 }
3121
3122 if (!calledstream && !callerstream) {
3123 break;
3124 }
3125
3126 if (mspeer < 0)
3127 mspeer = 1000;
3128
3129 if (mschan < 0)
3130 mschan = 1000;
3131
3132 /* wait for the lowest maximum of the two */
3133 active_chan = ast_waitfor_n(chans, 2, (mspeer > mschan ? &mschan : &mspeer));
3134 if (active_chan) {
3135 struct ast_channel *other_chan;
3136 struct ast_frame *fr = ast_read(active_chan);
3137
3138 if (!fr) {
3140 res = -1;
3141 goto done;
3142 }
3143 switch (fr->frametype) {
3144 case AST_FRAME_DTMF_END:
3145 digit = fr->subclass.integer;
3146 if (active_chan == peer && strchr(AST_DIGIT_ANY, res)) {
3147 ast_stopstream(peer);
3148 res = ast_senddigit(chan, digit, 0);
3149 }
3150 break;
3151 case AST_FRAME_CONTROL:
3152 switch (fr->subclass.integer) {
3153 case AST_CONTROL_HANGUP:
3154 ast_frfree(fr);
3156 res = -1;
3157 goto done;
3159 /* Pass COLP update to the other channel. */
3160 if (active_chan == chan) {
3161 other_chan = peer;
3162 } else {
3163 other_chan = chan;
3164 }
3165 if (ast_channel_connected_line_sub(active_chan, other_chan, fr, 1)) {
3166 ast_indicate_data(other_chan, fr->subclass.integer,
3167 fr->data.ptr, fr->datalen);
3168 }
3169 break;
3170 default:
3171 break;
3172 }
3173 break;
3174 default:
3175 /* Ignore all others */
3176 break;
3177 }
3178 ast_frfree(fr);
3179 }
3182 }
3184 }
3185
3186 if (chan && peer && ast_test_flag64(&opts, OPT_GOTO) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO])) {
3187 /* chan and peer are going into the PBX; as such neither are considered
3188 * outgoing channels any longer */
3190
3192 ast_parseable_goto(chan, opt_args[OPT_ARG_GOTO]);
3193 /* peer goes to the same context and extension as chan, so just copy info from chan*/
3194 ast_channel_lock(peer);
3201 ast_channel_unlock(peer);
3202 if (ast_pbx_start(peer)) {
3204 }
3205 if (continue_exec)
3206 *continue_exec = 1;
3207 res = 0;
3208 ast_channel_publish_dial(chan, peer, NULL, "ANSWER");
3209 goto done;
3210 }
3211
3213 const char *gosub_result_peer;
3214 char *gosub_argstart;
3215 char *gosub_args = NULL;
3216 int gosub_res = -1;
3217
3219 gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
3220 if (gosub_argstart) {
3221 const char *what_is_s = "s";
3222 *gosub_argstart = 0;
3223 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)) &&
3224 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))) {
3225 what_is_s = "~~s~~";
3226 }
3227 if (ast_asprintf(&gosub_args, "%s,%s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s, gosub_argstart + 1) < 0) {
3228 gosub_args = NULL;
3229 }
3230 *gosub_argstart = ',';
3231 } else {
3232 const char *what_is_s = "s";
3233 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)) &&
3234 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))) {
3235 what_is_s = "~~s~~";
3236 }
3237 if (ast_asprintf(&gosub_args, "%s,%s,1", opt_args[OPT_ARG_CALLEE_GOSUB], what_is_s) < 0) {
3238 gosub_args = NULL;
3239 }
3240 }
3241 if (gosub_args) {
3242 gosub_res = ast_app_exec_sub(chan, peer, gosub_args, 0);
3243 ast_free(gosub_args);
3244 } else {
3245 ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
3246 }
3247
3248 ast_channel_lock_both(chan, peer);
3249
3250 if (!gosub_res && (gosub_result_peer = pbx_builtin_getvar_helper(peer, "GOSUB_RESULT"))) {
3251 char *gosub_transfer_dest;
3252 char *gosub_result = ast_strdupa(gosub_result_peer);
3253 const char *gosub_retval = pbx_builtin_getvar_helper(peer, "GOSUB_RETVAL");
3254
3255 /* Inherit return value from the peer, so it can be used in the master */
3256 if (gosub_retval) {
3257 pbx_builtin_setvar_helper(chan, "GOSUB_RETVAL", gosub_retval);
3258 }
3259
3260 ast_channel_unlock(peer);
3261 ast_channel_unlock(chan);
3262
3263 if (!strcasecmp(gosub_result, "BUSY")) {
3264 ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
3265 ast_set_flag64(peerflags, OPT_GO_ON);
3266 gosub_res = -1;
3267 } else if (!strcasecmp(gosub_result, "CONGESTION") || !strcasecmp(gosub_result, "CHANUNAVAIL")) {
3268 ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
3269 ast_set_flag64(peerflags, OPT_GO_ON);
3270 gosub_res = -1;
3271 } else if (!strcasecmp(gosub_result, "CONTINUE")) {
3272 /* Hangup peer and continue with the next extension priority. */
3273 ast_set_flag64(peerflags, OPT_GO_ON);
3274 gosub_res = -1;
3275 } else if (!strcasecmp(gosub_result, "ABORT")) {
3276 /* Hangup both ends unless the caller has the g flag */
3277 gosub_res = -1;
3278 } else if (!strncasecmp(gosub_result, "GOTO:", 5)) {
3279 gosub_transfer_dest = gosub_result + 5;
3280 gosub_res = -1;
3281 /* perform a transfer to a new extension */
3282 if (strchr(gosub_transfer_dest, '^')) { /* context^exten^priority*/
3283 ast_replace_subargument_delimiter(gosub_transfer_dest);
3284 }
3285 if (!ast_parseable_goto(chan, gosub_transfer_dest)) {
3286 ast_set_flag64(peerflags, OPT_GO_ON);
3287 }
3288 }
3289 if (gosub_res) {
3290 res = gosub_res;
3291 if (!dial_end_raised) {
3292 ast_channel_publish_dial(chan, peer, NULL, gosub_result);
3293 dial_end_raised = 1;
3294 }
3295 }
3296 } else {
3297 ast_channel_unlock(peer);
3298 ast_channel_unlock(chan);
3299 }
3300 }
3301
3302 if (!res) {
3303
3304 /* None of the Dial options changed our status; inform
3305 * everyone that this channel answered
3306 */
3307 if (!dial_end_raised) {
3308 ast_channel_publish_dial(chan, peer, NULL, "ANSWER");
3309 dial_end_raised = 1;
3310 }
3311
3312 if (!ast_tvzero(calldurationlimit)) {
3313 struct timeval whentohangup = ast_tvadd(ast_tvnow(), calldurationlimit);
3314 ast_channel_lock(peer);
3315 ast_channel_whentohangup_set(peer, &whentohangup);
3316 ast_channel_unlock(peer);
3317 }
3318 if (!ast_strlen_zero(dtmfcalled)) {
3319 ast_verb(3, "Sending DTMF '%s' to the called party.\n", dtmfcalled);
3320 res = ast_dtmf_stream(peer, chan, dtmfcalled, 250, 0);
3321 }
3322 if (!ast_strlen_zero(dtmfcalling)) {
3323 ast_verb(3, "Sending DTMF '%s' to the calling party.\n", dtmfcalling);
3324 res = ast_dtmf_stream(chan, peer, dtmfcalling, 250, 0);
3325 }
3326 }
3327
3328 if (res) { /* some error */
3329 if (!ast_check_hangup(chan) && ast_check_hangup(peer)) {
3331 }
3332 setup_peer_after_bridge_goto(chan, peer, &opts, opt_args);
3334 || ast_pbx_start(peer)) {
3336 }
3337 res = -1;
3338 } else {
3339 if (ast_test_flag64(peerflags, OPT_CALLEE_TRANSFER))
3340 ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
3341 if (ast_test_flag64(peerflags, OPT_CALLER_TRANSFER))
3342 ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
3343 if (ast_test_flag64(peerflags, OPT_CALLEE_HANGUP))
3344 ast_set_flag(&(config.features_callee), AST_FEATURE_DISCONNECT);
3345 if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP))
3346 ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT);
3347 if (ast_test_flag64(peerflags, OPT_CALLEE_MONITOR))
3348 ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
3349 if (ast_test_flag64(peerflags, OPT_CALLER_MONITOR))
3350 ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
3351 if (ast_test_flag64(peerflags, OPT_CALLEE_PARK))
3352 ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL);
3353 if (ast_test_flag64(peerflags, OPT_CALLER_PARK))
3354 ast_set_flag(&(config.features_caller), AST_FEATURE_PARKCALL);
3355 if (ast_test_flag64(peerflags, OPT_CALLEE_MIXMONITOR))
3356 ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMIXMON);
3357 if (ast_test_flag64(peerflags, OPT_CALLER_MIXMONITOR))
3358 ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMIXMON);
3359
3360 config.end_bridge_callback = end_bridge_callback;
3361 config.end_bridge_callback_data = chan;
3362 config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
3363
3364 if (moh) {
3365 moh = 0;
3366 ast_moh_stop(chan);
3367 } else if (sentringing) {
3368 sentringing = 0;
3369 ast_indicate(chan, -1);
3370 }
3371 /* Be sure no generators are left on it and reset the visible indication */
3374 /* Make sure channels are compatible */
3375 res = ast_channel_make_compatible(chan, peer);
3376 if (res < 0) {
3377 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));
3379 res = -1;
3380 goto done;
3381 }
3382 if (opermode) {
3383 struct oprmode oprmode;
3384
3385 oprmode.peer = peer;
3386 oprmode.mode = opermode;
3387
3389 }
3390 setup_peer_after_bridge_goto(chan, peer, &opts, opt_args);
3391
3392 res = ast_bridge_call(chan, peer, &config);
3393 }
3394 }
3395out:
3396 if (moh) {
3397 moh = 0;
3398 ast_moh_stop(chan);
3399 } else if (sentringing) {
3400 sentringing = 0;
3401 ast_indicate(chan, -1);
3402 }
3403
3404 if (delprivintro && ast_fileexists(pa.privintro, NULL, NULL) > 0) {
3406 if (ast_fileexists(pa.privintro, NULL, NULL) > 0) {
3407 ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa.privintro);
3408 } else {
3409 ast_verb(3, "Successfully deleted %s intro file\n", pa.privintro);
3410 }
3411 }
3412
3414 /* forward 'answered elsewhere' if we received it */
3416 hanguptreecause = AST_CAUSE_ANSWERED_ELSEWHERE;
3417 } else if (pa.canceled) { /* Caller canceled */
3418 if (ast_channel_hangupcause(chan))
3419 hanguptreecause = ast_channel_hangupcause(chan);
3420 else
3421 hanguptreecause = AST_CAUSE_NORMAL_CLEARING;
3422 }
3423 hanguptree(&out_chans, NULL, hanguptreecause);
3424 pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
3425 ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
3426
3427 if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_INCOMPLETE)) {
3428 if (!ast_tvzero(calldurationlimit))
3429 memset(ast_channel_whentohangup(chan), 0, sizeof(*ast_channel_whentohangup(chan)));
3430 res = 0;
3431 }
3432
3433done:
3434 if (config.answer_topology) {
3435 ast_trace(2, "%s Cleaning up topology: %p %s\n",
3436 peer ? ast_channel_name(peer) : "<no channel>", &config.answer_topology,
3437 ast_str_tmp(256, ast_stream_topology_to_str(config.answer_topology, &STR_TMP)));
3438
3439 /*
3440 * At this point, the channel driver that answered should have bumped the
3441 * topology refcount for itself. Here we're cleaning up the reference we added
3442 * in wait_for_answer().
3443 */
3444 ast_stream_topology_free(config.answer_topology);
3445 }
3446 if (config.warning_sound) {
3447 ast_free((char *)config.warning_sound);
3448 }
3449 if (config.end_sound) {
3450 ast_free((char *)config.end_sound);
3451 }
3452 if (config.start_sound) {
3453 ast_free((char *)config.start_sound);
3454 }
3455 ast_ignore_cc(chan);
3456 SCOPE_EXIT_RTN_VALUE(res, "%s: Done\n", ast_channel_name(chan));
3457}
char digit
#define DIAL_STILLGOING
Definition: app_dial.c:700
#define OPT_PREDIAL_CALLER
Definition: app_dial.c:711
#define OPT_CANCEL_ELSEWHERE
Definition: app_dial.c:703
static const char * get_cid_name(char *name, int namelen, struct ast_channel *chan)
Definition: app_dial.c:907
static const struct ast_app_option dial_exec_options[128]
Definition: app_dial.c:785
#define OPT_PREDIAL_CALLEE
Definition: app_dial.c:710
#define DIAL_CALLERID_ABSENT
Definition: app_dial.c:702
#define OPT_FORCE_CID_PRES
Definition: app_dial.c:708
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:2277
#define CAN_EARLY_BRIDGE(flags, chan, peer)
Definition: app_dial.c:787
#define OPT_TOPOLOGY_PRESERVE
Definition: app_dial.c:715
#define OPT_RING_WITH_EARLY_MEDIA
Definition: app_dial.c:712
#define OPT_FORCE_CID_TAG
Definition: app_dial.c:707
#define OPT_HEARPULSING
Definition: app_dial.c:714
#define DIAL_NOFORWARDHTML
Definition: app_dial.c:701
#define OPT_CANCEL_TIMEOUT
Definition: app_dial.c:706
static void chanlist_free(struct chanlist *outgoing)
Definition: app_dial.c:832
static void handle_cause(int cause, struct cause_args *num)
Definition: app_dial.c:870
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:2122
#define OPT_HANGUPCAUSE
Definition: app_dial.c:713
static void hanguptree(struct dial_head *out_chans, struct ast_channel *exception, int hangupcause)
Definition: app_dial.c:840
static const struct ast_datastore_info topology_ds_info
Definition: app_dial.c:825
static int dial_handle_playtones(struct ast_channel *chan, const char *data)
Definition: app_dial.c:2237
static void end_bridge_callback(void *data)
Definition: app_dial.c:2221
#define OPT_CALLER_ANSWER
Definition: app_dial.c:709
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:1202
static void end_bridge_callback_data_fixup(struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator)
Definition: app_dial.c:2233
#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
static int tmp()
Definition: bt_open.c:389
#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:4164
void ast_ignore_cc(struct ast_channel *chan)
Mark the channel to ignore further CC activity.
Definition: ccss.c:3685
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:4197
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:1983
int ast_cc_call_init(struct ast_channel *chan, int *ignore_cc)
Start the CC process on a call.
Definition: ccss.c:2386
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:4209
int ast_cdr_reset(const char *channel_name, int keep_variables)
Reset the detail record.
Definition: cdr.c:3677
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:625
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
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:10518
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6480
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition: channel.c:11056
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2404
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1776
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:10360
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2560
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
Definition: channel.h:1523
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:8330
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:7394
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:3176
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
Definition: channel.c:4993
#define ast_channel_lock(chan)
Definition: channel.h:2968
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
Make the frame formats of two channels compatible.
Definition: channel.c:6739
void ast_channel_data_set(struct ast_channel *chan, const char *value)
@ 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
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:2050
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:2975
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:2387
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:6453
const char * ast_channel_context(const struct ast_channel *chan)
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2912
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:459
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:4276
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:2018
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:1799
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:6790
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:6378
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:6642
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
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:4672
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
Definition: channel.c:11049
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)
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:6654
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:612
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:8315
@ AST_FLAG_OUTGOING
Definition: channel.h:1019
@ AST_FLAG_END_DTMF_ONLY
Definition: channel.h:1027
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:6463
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:7444
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:2064
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:2824
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:7434
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4296
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2969
#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:2154
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:2418
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:685
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:857
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:1293
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
Definition: file.c:1129
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
Definition: file.c:1141
#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
char * strsep(char **str, const char *delims)
#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:7788
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:7798
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:4175
#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:4708
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
Definition: pbx.c:8866
#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:2427
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.
struct ast_frame_subclass subclass
union ast_frame::@226 data
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:864
List of channel drivers.
Definition: app_dial.c:797
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:154
struct ast_channel * peer
char status[256]
Definition: app_dial.c:1145
int privdb_val
Definition: app_dial.c:1142
int sentringing
Definition: app_dial.c:1141
char privintro[1024]
Definition: app_dial.c:1144
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, cause_args::chan, chanlist_free(), config, 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, LOG_ERROR, LOG_NOTICE, LOG_WARNING, oprmode::mode, name, ast_party_id::name, NULL, 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, 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(), ast_party_id::subaddress, ast_frame::subclass, ast_party_id::tag, ast_channel::tech, tmp(), 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 2237 of file app_dial.c.

2238{
2239 struct ast_tone_zone_sound *ts = NULL;
2240 int res;
2241 const char *str = data;
2242
2243 if (ast_strlen_zero(str)) {
2244 ast_debug(1,"Nothing to play\n");
2245 return -1;
2246 }
2247
2249
2250 if (ts && ts->data[0]) {
2251 res = ast_playtones_start(chan, 0, ts->data, 0);
2252 } else {
2253 res = -1;
2254 }
2255
2256 if (ts) {
2258 }
2259
2260 if (res) {
2261 ast_log(LOG_WARNING, "Unable to start playtone \'%s\'\n", str);
2262 }
2263
2264 return res;
2265}
const char * str
Definition: app_jack.c:147
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 937 of file app_dial.c.

940{
941 char tmpchan[256];
942 char forwarder[AST_CHANNEL_NAME];
943 struct ast_channel *original = o->chan;
944 struct ast_channel *c = o->chan; /* the winner */
945 struct ast_channel *in = num->chan; /* the input channel */
946 char *stuff;
947 char *tech;
948 int cause;
949 struct ast_party_caller caller;
950
951 ast_copy_string(forwarder, ast_channel_name(c), sizeof(forwarder));
952 ast_copy_string(tmpchan, ast_channel_call_forward(c), sizeof(tmpchan));
953 if ((stuff = strchr(tmpchan, '/'))) {
954 *stuff++ = '\0';
955 tech = tmpchan;
956 } else {
957 const char *forward_context;
959 forward_context = pbx_builtin_getvar_helper(c, "FORWARD_CONTEXT");
960 if (ast_strlen_zero(forward_context)) {
961 forward_context = NULL;
962 }
963 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", ast_channel_call_forward(c), forward_context ? forward_context : ast_channel_context(c));
965 stuff = tmpchan;
966 tech = "Local";
967 }
968 if (!strcasecmp(tech, "Local")) {
969 /*
970 * Drop the connected line update block for local channels since
971 * this is going to run dialplan and the user can change his
972 * mind about what connected line information he wants to send.
973 */
975 }
976
977 /* Before processing channel, go ahead and check for forwarding */
978 ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", ast_channel_name(in), tech, stuff, ast_channel_name(c));
979 /* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
980 if (ast_test_flag64(peerflags, OPT_IGNORE_FORWARDING)) {
981 ast_verb(3, "Forwarding %s to '%s/%s' prevented.\n", ast_channel_name(in), tech, stuff);
982 ast_channel_publish_dial_forward(in, original, NULL, NULL, "CANCEL",
983 ast_channel_call_forward(original));
984 c = o->chan = NULL;
985 cause = AST_CAUSE_BUSY;
986 } else {
987 struct ast_stream_topology *topology;
988
992
993 /* Setup parameters */
994 c = o->chan = ast_request_with_stream_topology(tech, topology, NULL, in, stuff, &cause);
995
996 ast_stream_topology_free(topology);
997
998 if (c) {
999 if (single && !caller_entertained) {
1001 }
1005 pbx_builtin_setvar_helper(o->chan, "FORWARDERNAME", forwarder);
1009 /* When a call is forwarded, we don't want to track new interfaces
1010 * dialed for CC purposes. Setting the done flag will ensure that
1011 * any Dial operations that happen later won't record CC interfaces.
1012 */
1013 ast_ignore_cc(o->chan);
1014 ast_verb(3, "Not accepting call completion offers from call-forward recipient %s\n",
1016 } else
1018 "Forwarding failed to create channel to dial '%s/%s' (cause = %d)\n",
1019 tech, stuff, cause);
1020 }
1021 if (!c) {
1022 ast_channel_publish_dial(in, original, stuff, "BUSY");
1024 handle_cause(cause, num);
1025 ast_hangup(original);
1026 } else {
1027 ast_channel_lock_both(c, original);
1029 ast_channel_redirecting(original));
1031 ast_channel_unlock(original);
1032
1034
1035 if (single && !caller_entertained && CAN_EARLY_BRIDGE(peerflags, c, in)) {
1037 }
1038
1039 if (!ast_channel_redirecting(c)->from.number.valid
1040 || ast_strlen_zero(ast_channel_redirecting(c)->from.number.str)) {
1041 /*
1042 * The call was not previously redirected so it is
1043 * now redirected from this number.
1044 */
1050 }
1051
1053
1054 /* Determine CallerID to store in outgoing channel. */
1056 if (ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
1057 caller.id = *stored_clid;
1060 } else if (ast_strlen_zero(S_COR(ast_channel_caller(c)->id.number.valid,
1061 ast_channel_caller(c)->id.number.str, NULL))) {
1062 /*
1063 * The new channel has no preset CallerID number by the channel
1064 * driver. Use the dialplan extension and hint name.
1065 */
1066 caller.id = *stored_clid;
1069 } else {
1071 }
1072
1073 /* Determine CallerID for outgoing channel to send. */
1076
1078 connected.id = *forced_clid;
1080 } else {
1082 }
1083
1085
1086 ast_channel_appl_set(c, "AppDial");
1087 ast_channel_data_set(c, "(Outgoing Line)");
1089
1091 if (single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
1092 struct ast_party_redirecting redirecting;
1093
1094 /*
1095 * Redirecting updates to the caller make sense only on single
1096 * calls.
1097 *
1098 * Need to re-evalute if unlocking is still required here as macro is gone
1099 */
1100 ast_party_redirecting_init(&redirecting);
1103 if (ast_channel_redirecting_sub(c, in, &redirecting, 0)) {
1104 ast_channel_update_redirecting(in, &redirecting, NULL);
1105 }
1106 ast_party_redirecting_free(&redirecting);
1107 } else {
1109 }
1110
1111 if (ast_test_flag64(peerflags, OPT_CANCEL_TIMEOUT)) {
1112 *to = -1;
1113 }
1114
1115 if (ast_call(c, stuff, 0)) {
1116 ast_log(LOG_NOTICE, "Forwarding failed to dial '%s/%s'\n",
1117 tech, stuff);
1118 ast_channel_publish_dial(in, original, stuff, "CONGESTION");
1120 ast_hangup(original);
1121 ast_hangup(c);
1122 c = o->chan = NULL;
1123 num->nochan++;
1124 } else {
1125 ast_channel_publish_dial_forward(in, original, c, NULL, "CANCEL",
1126 ast_channel_call_forward(original));
1127
1129
1130 /* Hangup the original channel now, in case we needed it */
1131 ast_hangup(original);
1132 }
1133 if (single && !caller_entertained) {
1134 ast_indicate(in, -1);
1135 }
1136 }
1137}
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2141
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
Definition: channel.c:1663
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:10405
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:10306
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
Definition: channel.c:1710
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2041
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2198
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:867
struct ast_channel * chan
Definition: app_dial.c:799
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 2221 of file app_dial.c.

2222{
2223 struct ast_channel *chan = data;
2224
2225 ast_channel_lock(chan);
2227 set_duration_var(chan, "ANSWEREDTIME", ast_channel_get_up_time_ms(chan));
2228 set_duration_var(chan, "DIALEDTIME", ast_channel_get_duration_ms(chan));
2230 ast_channel_unlock(chan);
2231}
static void set_duration_var(struct ast_channel *chan, const char *var_base, int64_t duration)
Definition: app_dial.c:1189
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:2854
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:2839
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 2233 of file app_dial.c.

2233 {
2234 bconfig->end_bridge_callback_data = originator;
2235}
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 907 of file app_dial.c.

908{
909 const char *context;
910 const char *exten;
911
912 ast_channel_lock(chan);
914 exten = ast_strdupa(ast_channel_exten(chan));
915 ast_channel_unlock(chan);
916
917 return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
918}
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:4137

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 870 of file app_dial.c.

871{
872 switch(cause) {
873 case AST_CAUSE_BUSY:
874 num->busy++;
875 break;
877 num->congestion++;
878 break;
881 num->nochan++;
882 break;
885 break;
886 default:
887 num->nochan++;
888 break;
889 }
890}
#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:866
int busy
Definition: app_dial.c:865

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 840 of file app_dial.c.

841{
842 /* Hang up a tree of stuff */
843 struct chanlist *outgoing;
844
845 while ((outgoing = AST_LIST_REMOVE_HEAD(out_chans, node))) {
846 /* Hangup any existing lines we have open */
847 if (outgoing->chan && (outgoing->chan != exception)) {
848 if (hangupcause >= 0) {
849 /* This is for the channel drivers */
850 ast_channel_hangupcause_set(outgoing->chan, hangupcause);
851 }
852 ast_hangup(outgoing->chan);
853 }
855 }
856}
#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 3586 of file app_dial.c.

3587{
3588 int res;
3589
3592
3593 return res;
3594}
static const char app[]
Definition: app_dial.c:663
static int dial_exec(struct ast_channel *chan, const char *data)
Definition: app_dial.c:3459
static const char rapp[]
Definition: app_dial.c:664
static int retrydial_exec(struct ast_channel *chan, const char *data)
Definition: app_dial.c:3468
#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 892 of file app_dial.c.

893{
894 char rexten[2] = { exten, '\0' };
895
896 if (context) {
897 if (!ast_goto_if_exists(chan, context, rexten, pri))
898 return 1;
899 } else {
900 if (!ast_goto_if_exists(chan, ast_channel_context(chan), rexten, pri))
901 return 1;
902 }
903 return 0;
904}
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
Definition: pbx.c:8781

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 1149 of file app_dial.c.

1150{
1151 struct chanlist *outgoing;
1152 AST_LIST_TRAVERSE(out_chans, outgoing, node) {
1153 if (!outgoing->chan || outgoing->chan == exception) {
1154 continue;
1155 }
1157 }
1158}
jack_status_t status
Definition: app_jack.c:146

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 3468 of file app_dial.c.

3469{
3470 char *parse;
3471 const char *context = NULL;
3472 int sleepms = 0, loops = 0, res = -1;
3473 struct ast_flags64 peerflags = { 0, };
3475 AST_APP_ARG(announce);
3476 AST_APP_ARG(sleep);
3477 AST_APP_ARG(retries);
3478 AST_APP_ARG(dialdata);
3479 );
3480
3481 if (ast_strlen_zero(data)) {
3482 ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
3483 return -1;
3484 }
3485
3486 parse = ast_strdupa(data);
3488
3489 if (!ast_strlen_zero(args.sleep) && (sleepms = atoi(args.sleep)))
3490 sleepms *= 1000;
3491
3492 if (!ast_strlen_zero(args.retries)) {
3493 loops = atoi(args.retries);
3494 }
3495
3496 if (!args.dialdata) {
3497 ast_log(LOG_ERROR, "%s requires a 4th argument (dialdata)\n", rapp);
3498 goto done;
3499 }
3500
3501 if (sleepms < 1000)
3502 sleepms = 10000;
3503
3504 if (!loops)
3505 loops = -1; /* run forever */
3506
3507 ast_channel_lock(chan);
3508 context = pbx_builtin_getvar_helper(chan, "EXITCONTEXT");
3510 ast_channel_unlock(chan);
3511
3512 res = 0;
3513 while (loops) {
3514 int continue_exec;
3515
3516 ast_channel_data_set(chan, "Retrying");
3518 ast_moh_stop(chan);
3519
3520 res = dial_exec_full(chan, args.dialdata, &peerflags, &continue_exec);
3521 if (continue_exec)
3522 break;
3523
3524 if (res == 0) {
3525 if (ast_test_flag64(&peerflags, OPT_DTMF_EXIT)) {
3526 if (!ast_strlen_zero(args.announce)) {
3527 if (ast_fileexists(args.announce, NULL, ast_channel_language(chan)) > 0) {
3528 if (!(res = ast_streamfile(chan, args.announce, ast_channel_language(chan))))
3530 } else
3531 ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
3532 }
3533 if (!res && sleepms) {
3535 ast_moh_start(chan, NULL, NULL);
3536 res = ast_waitfordigit(chan, sleepms);
3537 }
3538 } else {
3539 if (!ast_strlen_zero(args.announce)) {
3540 if (ast_fileexists(args.announce, NULL, ast_channel_language(chan)) > 0) {
3541 if (!(res = ast_streamfile(chan, args.announce, ast_channel_language(chan))))
3542 res = ast_waitstream(chan, "");
3543 } else
3544 ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
3545 }
3546 if (sleepms) {
3548 ast_moh_start(chan, NULL, NULL);
3549 if (!res)
3550 res = ast_waitfordigit(chan, sleepms);
3551 }
3552 }
3553 }
3554
3555 if (res < 0 || res == AST_PBX_INCOMPLETE) {
3556 break;
3557 } else if (res > 0) { /* Trying to send the call elsewhere (1 digit ext) */
3558 if (onedigit_goto(chan, context, (char) res, 1)) {
3559 res = 0;
3560 break;
3561 }
3562 }
3563 loops--;
3564 }
3565 if (loops == 0)
3566 res = 0;
3567 else if (res == 1)
3568 res = 0;
3569
3571 ast_moh_stop(chan);
3572 done:
3573 return res;
3574}
static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
Definition: app_dial.c:892
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3194
@ 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:1840
#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 1189 of file app_dial.c.

1190{
1191 char buf[32];
1192 char full_var_name[128];
1193
1194 snprintf(buf, sizeof(buf), "%" PRId64, duration / 1000);
1195 pbx_builtin_setvar_helper(chan, var_base, buf);
1196
1197 snprintf(full_var_name, sizeof(full_var_name), "%s_MS", var_base);
1198 snprintf(buf, sizeof(buf), "%" PRId64, duration);
1199 pbx_builtin_setvar_helper(chan, full_var_name, buf);
1200}
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 2277 of file app_dial.c.

2278{
2279 const char *context;
2280 const char *extension;
2281 int priority;
2282
2283 if (ast_test_flag64(opts, OPT_PEER_H)) {
2284 ast_channel_lock(chan);
2286 ast_channel_unlock(chan);
2288 } else if (ast_test_flag64(opts, OPT_CALLEE_GO_ON)) {
2289 ast_channel_lock(chan);
2293 ast_channel_unlock(chan);
2295 opt_args[OPT_ARG_CALLEE_GO_ON]);
2296 }
2297}
#define OPT_PEER_H
Definition: app_dial.c:704
#define OPT_CALLEE_GO_ON
Definition: app_dial.c:705
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 2122 of file app_dial.c.

2124{
2125 char callerid[60];
2126 int res;
2127 char *l;
2128
2129 if (ast_channel_caller(chan)->id.number.valid
2130 && !ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) {
2131 l = ast_strdupa(ast_channel_caller(chan)->id.number.str);
2133 if (ast_test_flag64(opts, OPT_PRIVACY) ) {
2134 ast_verb(3, "Privacy DB is '%s', clid is '%s'\n", opt_args[OPT_ARG_PRIVACY], l);
2135 pa->privdb_val = ast_privacy_check(opt_args[OPT_ARG_PRIVACY], l);
2136 } else {
2137 ast_verb(3, "Privacy Screening, clid is '%s'\n", l);
2139 }
2140 } else {
2141 char *tnam, *tn2;
2142
2143 tnam = ast_strdupa(ast_channel_name(chan));
2144 /* clean the channel name so slashes don't try to end up in disk file name */
2145 for (tn2 = tnam; *tn2; tn2++) {
2146 if (*tn2 == '/') /* any other chars to be afraid of? */
2147 *tn2 = '=';
2148 }
2149 ast_verb(3, "Privacy-- callerid is empty\n");
2150
2151 snprintf(callerid, sizeof(callerid), "NOCALLERID_%s%s", ast_channel_exten(chan), tnam);
2152 l = callerid;
2154 }
2155
2156 ast_copy_string(pa->privcid, l, sizeof(pa->privcid));
2157
2158 if (strncmp(pa->privcid, "NOCALLERID", 10) != 0 && ast_test_flag64(opts, OPT_SCREEN_NOCALLERID)) {
2159 /* if callerid is set and OPT_SCREEN_NOCALLERID is set also */
2160 ast_verb(3, "CallerID set (%s); N option set; Screening should be off\n", pa->privcid);
2162 } else if (ast_test_flag64(opts, OPT_SCREEN_NOCALLERID) && strncmp(pa->privcid, "NOCALLERID", 10) == 0) {
2163 ast_verb(3, "CallerID blank; N option set; Screening should happen; dbval is %d\n", pa->privdb_val);
2164 }
2165
2166 if (pa->privdb_val == AST_PRIVACY_DENY) {
2167 ast_verb(3, "Privacy DB reports PRIVACY_DENY for this callerid. Dial reports unavailable\n");
2168 ast_copy_string(pa->status, "NOANSWER", sizeof(pa->status));
2169 return 0;
2170 } else if (pa->privdb_val == AST_PRIVACY_KILL) {
2171 ast_copy_string(pa->status, "DONTCALL", sizeof(pa->status));
2172 return 0; /* Is this right? */
2173 } else if (pa->privdb_val == AST_PRIVACY_TORTURE) {
2174 ast_copy_string(pa->status, "TORTURE", sizeof(pa->status));
2175 return 0; /* is this right??? */
2176 } else if (pa->privdb_val == AST_PRIVACY_UNKNOWN) {
2177 /* Get the user's intro, store it in priv-callerintros/$CID,
2178 unless it is already there-- this should be done before the
2179 call is actually dialed */
2180
2181 /* make sure the priv-callerintros dir actually exists */
2182 snprintf(pa->privintro, sizeof(pa->privintro), "%s/sounds/priv-callerintros", ast_config_AST_DATA_DIR);
2183 if ((res = ast_mkdir(pa->privintro, 0755))) {
2184 ast_log(LOG_WARNING, "privacy: can't create directory priv-callerintros: %s\n", strerror(res));
2185 return -1;
2186 }
2187
2188 snprintf(pa->privintro, sizeof(pa->privintro), "priv-callerintros/%s", pa->privcid);
2189 if (ast_fileexists(pa->privintro, NULL, NULL ) > 0 && strncmp(pa->privcid, "NOCALLERID", 10) != 0) {
2190 /* the DELUX version of this code would allow this caller the
2191 option to hear and retape their previously recorded intro.
2192 */
2193 } else {
2194 int duration; /* for feedback from play_and_wait */
2195 /* the file doesn't exist yet. Let the caller submit his
2196 vocal intro for posterity */
2197 /* priv-recordintro script:
2198 "At the tone, please say your name:"
2199 */
2201 ast_answer(chan);
2202 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 */
2203 /* don't think we'll need a lock removed, we took care of
2204 conflicts by naming the pa.privintro file */
2205 if (res == -1) {
2206 /* Delete the file regardless since they hung up during recording */
2208 if (ast_fileexists(pa->privintro, NULL, NULL) > 0)
2209 ast_log(LOG_NOTICE, "privacy: ast_filedelete didn't do its job on %s\n", pa->privintro);
2210 else
2211 ast_verb(3, "Successfully deleted %s intro file\n", pa->privintro);
2212 return -1;
2213 }
2214 if (!ast_streamfile(chan, "vm-dialout", ast_channel_language(chan)) )
2215 ast_waitstream(chan, "");
2216 }
2217 }
2218 return 1; /* success */
2219}
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:158
#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:1143
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 820 of file app_dial.c.

820 {
821 struct ast_stream_topology *top = data;
823}

References ast_stream_topology_free().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 3576 of file app_dial.c.

3577{
3578 int res;
3579
3582
3583 return res;
3584}
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 1169 of file app_dial.c.

1170{
1171 struct ast_party_connected_line connected_caller;
1172
1173 ast_party_connected_line_init(&connected_caller);
1174
1175 ast_channel_lock(peer);
1177 ast_channel_unlock(peer);
1178 connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
1179 if (ast_channel_connected_line_sub(peer, chan, &connected_caller, 0)) {
1180 ast_channel_update_connected_line(chan, &connected_caller, NULL);
1181 }
1182 ast_party_connected_line_free(&connected_caller);
1183}
@ 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:9115

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 1975 of file app_dial.c.

1976{
1977 if (res < '1')
1978 return 0;
1979 if (ast_test_flag64(opts, OPT_PRIVACY) && res <= '5')
1980 return 1;
1981 if (ast_test_flag64(opts, OPT_SCREENING) && res <= '4')
1982 return 1;
1983 return 0;
1984}

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 1202 of file app_dial.c.

1213{
1214 struct cause_args num = *num_in;
1215 int prestart = num.busy + num.congestion + num.nochan;
1216 int orig_answer_to = *to_answer;
1217 int orig_progress_to = *to_progress;
1218 struct ast_channel *peer = NULL;
1219 struct chanlist *outgoing = AST_LIST_FIRST(out_chans);
1220 /* single is set if only one destination is enabled */
1221 int single = outgoing && !AST_LIST_NEXT(outgoing, node);
1222 int caller_entertained = outgoing
1224 struct ast_str *featurecode = ast_str_alloca(AST_FEATURE_MAX_LEN + 1);
1225 int cc_recall_core_id;
1226 int is_cc_recall;
1227 int cc_frame_received = 0;
1228 int num_ringing = 0;
1229 int sent_ring = 0;
1230 int sent_progress = 0, sent_wink = 0;
1231 struct timeval start = ast_tvnow();
1232 SCOPE_ENTER(3, "%s\n", ast_channel_name(in));
1233
1234 if (single) {
1235 /* Turn off hold music, etc */
1236 if (!caller_entertained) {
1238 /* If we are calling a single channel, and not providing ringback or music, */
1239 /* then, make them compatible for in-band tone purpose */
1240 if (ast_channel_make_compatible(in, outgoing->chan) < 0) {
1241 /* If these channels can not be made compatible,
1242 * there is no point in continuing. The bridge
1243 * will just fail if it gets that far.
1244 */
1245 *to_answer = -1;
1246 strcpy(pa->status, "CONGESTION");
1248 SCOPE_EXIT_RTN_VALUE(NULL, "%s: can't be made compat with %s\n",
1250 }
1251 }
1252
1256 }
1257 }
1258
1259 is_cc_recall = ast_cc_is_recall(in, &cc_recall_core_id, NULL);
1260
1261 while ((*to_answer = ast_remaining_ms(start, orig_answer_to)) && (*to_progress = ast_remaining_ms(start, orig_progress_to)) && !peer) {
1262 struct chanlist *o;
1263 int pos = 0; /* how many channels do we handle */
1264 int numlines = prestart;
1265 struct ast_channel *winner;
1266 struct ast_channel *watchers[AST_MAX_WATCHERS];
1267
1268 watchers[pos++] = in;
1269 AST_LIST_TRAVERSE(out_chans, o, node) {
1270 /* Keep track of important channels */
1271 if (ast_test_flag64(o, DIAL_STILLGOING) && o->chan)
1272 watchers[pos++] = o->chan;
1273 numlines++;
1274 }
1275 if (pos == 1) { /* only the input channel is available */
1276 if (numlines == (num.busy + num.congestion + num.nochan)) {
1277 ast_verb(2, "Everyone is busy/congested at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
1278 if (num.busy)
1279 strcpy(pa->status, "BUSY");
1280 else if (num.congestion)
1281 strcpy(pa->status, "CONGESTION");
1282 else if (num.nochan)
1283 strcpy(pa->status, "CHANUNAVAIL");
1284 } else {
1285 ast_verb(3, "No one is available to answer at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
1286 }
1287 *to_answer = 0;
1288 if (is_cc_recall) {
1289 ast_cc_failed(cc_recall_core_id, "Everyone is busy/congested for the recall. How sad");
1290 }
1291 SCOPE_EXIT_RTN_VALUE(NULL, "%s: No outgoing channels available\n", ast_channel_name(in));
1292 }
1293
1294 /* If progress timeout is active, use that if it's the shorter of the 2 timeouts. */
1295 winner = ast_waitfor_n(watchers, pos, *to_progress > 0 && (*to_answer < 0 || *to_progress < *to_answer) ? to_progress : to_answer);
1296
1297 AST_LIST_TRAVERSE(out_chans, o, node) {
1298 int res = 0;
1299 struct ast_frame *f;
1300 struct ast_channel *c = o->chan;
1301
1302 if (c == NULL)
1303 continue;
1305 if (!peer) {
1306 ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
1307 if (o->orig_chan_name
1308 && strcmp(o->orig_chan_name, ast_channel_name(c))) {
1309 /*
1310 * The channel name changed so we must generate COLP update.
1311 * Likely because a call pickup channel masqueraded in.
1312 */
1314 } else if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
1315 if (o->pending_connected_update) {
1318 }
1319 } else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
1321 }
1322 }
1323 if (o->aoc_s_rate_list) {
1324 size_t encoded_size;
1325 struct ast_aoc_encoded *encoded;
1326 if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) {
1327 ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size);
1328 ast_aoc_destroy_encoded(encoded);
1329 }
1330 }
1331 peer = c;
1332 publish_dial_end_event(in, out_chans, peer, "CANCEL");
1333 ast_copy_flags64(peerflags, o,
1340 ast_channel_dialcontext_set(c, "");
1342 }
1343 continue;
1344 }
1345 if (c != winner)
1346 continue;
1347 /* here, o->chan == c == winner */
1349 pa->sentringing = 0;
1350 if (!ignore_cc && (f = ast_read(c))) {
1352 /* This channel is forwarding the call, and is capable of CC, so
1353 * be sure to add the new device interface to the list
1354 */
1356 }
1357 ast_frfree(f);
1358 }
1359
1360 if (o->pending_connected_update) {
1361 /*
1362 * Re-seed the chanlist's connected line information with
1363 * previously acquired connected line info from the incoming
1364 * channel. The previously acquired connected line info could
1365 * have been set through the CONNECTED_LINE dialplan function.
1366 */
1371 }
1372
1373 do_forward(o, &num, peerflags, single, caller_entertained, &orig_answer_to,
1374 forced_clid, stored_clid);
1375
1376 if (o->chan) {
1379 if (single
1383 }
1384 }
1385 continue;
1386 }
1387 f = ast_read(winner);
1388 if (!f) {
1391 ast_hangup(c);
1392 c = o->chan = NULL;
1395 continue;
1396 }
1397 switch (f->frametype) {
1398 case AST_FRAME_CONTROL:
1399 switch (f->subclass.integer) {
1400 case AST_CONTROL_ANSWER:
1401 /* This is our guy if someone answered. */
1402 if (!peer) {
1403 ast_trace(-1, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
1404 ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
1405 if (o->orig_chan_name
1406 && strcmp(o->orig_chan_name, ast_channel_name(c))) {
1407 /*
1408 * The channel name changed so we must generate COLP update.
1409 * Likely because a call pickup channel masqueraded in.
1410 */
1412 } else if (!single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
1413 if (o->pending_connected_update) {
1416 }
1417 } else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
1419 }
1420 }
1421 if (o->aoc_s_rate_list) {
1422 size_t encoded_size;
1423 struct ast_aoc_encoded *encoded;
1424 if ((encoded = ast_aoc_encode(o->aoc_s_rate_list, &encoded_size, o->chan))) {
1425 ast_indicate_data(in, AST_CONTROL_AOC, encoded, encoded_size);
1426 ast_aoc_destroy_encoded(encoded);
1427 }
1428 }
1429 peer = c;
1430 /* Answer can optionally include a topology */
1431 if (f->subclass.topology) {
1432 /*
1433 * We need to bump the refcount on the topology to prevent it
1434 * from being cleaned up when the frame is cleaned up.
1435 */
1436 config->answer_topology = ao2_bump(f->subclass.topology);
1437 ast_trace(-1, "%s Found topology in frame: %p %p %s\n",
1438 ast_channel_name(peer), f, config->answer_topology,
1439 ast_str_tmp(256, ast_stream_topology_to_str(config->answer_topology, &STR_TMP)));
1440 }
1441
1442 /* Inform everyone else that they've been canceled.
1443 * The dial end event for the peer will be sent out after
1444 * other Dial options have been handled.
1445 */
1446 publish_dial_end_event(in, out_chans, peer, "CANCEL");
1447 ast_copy_flags64(peerflags, o,
1454 ast_channel_dialcontext_set(c, "");
1456 if (CAN_EARLY_BRIDGE(peerflags, in, peer)) {
1457 /* Setup early bridge if appropriate */
1459 }
1460 }
1461 /* If call has been answered, then the eventual hangup is likely to be normal hangup */
1464 break;
1465 case AST_CONTROL_BUSY:
1466 ast_verb(3, "%s is busy\n", ast_channel_name(c));
1468 ast_channel_publish_dial(in, c, NULL, "BUSY");
1469 ast_hangup(c);
1470 c = o->chan = NULL;
1473 break;
1475 ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c));
1477 ast_channel_publish_dial(in, c, NULL, "CONGESTION");
1478 ast_hangup(c);
1479 c = o->chan = NULL;
1482 break;
1484 /* This is a tricky area to get right when using a native
1485 * CC agent. The reason is that we do the best we can to send only a
1486 * single ringing notification to the caller.
1487 *
1488 * Call completion complicates the logic used here. CCNR is typically
1489 * offered during a ringing message. Let's say that party A calls
1490 * parties B, C, and D. B and C do not support CC requests, but D
1491 * does. If we were to receive a ringing notification from B before
1492 * the others, then we would end up sending a ringing message to
1493 * A with no CCNR offer present.
1494 *
1495 * The approach that we have taken is that if we receive a ringing
1496 * response from a party and no CCNR offer is present, we need to
1497 * wait. Specifically, we need to wait until either a) a called party
1498 * offers CCNR in its ringing response or b) all called parties have
1499 * responded in some way to our call and none offers CCNR.
1500 *
1501 * The drawback to this is that if one of the parties has a delayed
1502 * response or, god forbid, one just plain doesn't respond to our
1503 * outgoing call, then this will result in a significant delay between
1504 * when the caller places the call and hears ringback.
1505 *
1506 * Note also that if CC is disabled for this call, then it is perfectly
1507 * fine for ringing frames to get sent through.
1508 */
1509 ++num_ringing;
1510 *to_progress = -1;
1511 orig_progress_to = -1;
1512 if (ignore_cc || cc_frame_received || num_ringing == numlines) {
1513 ast_verb(3, "%s is ringing\n", ast_channel_name(c));
1514 /* Setup early media if appropriate */
1515 if (single && !caller_entertained
1516 && CAN_EARLY_BRIDGE(peerflags, in, c)) {
1518 }
1521 pa->sentringing++;
1522 }
1523 if (!sent_ring) {
1524 struct timeval now, then;
1525 int64_t diff;
1526
1527 now = ast_tvnow();
1528
1531
1533 diff = ast_tvzero(then) ? 0 : ast_tvdiff_ms(now, then);
1534 set_duration_var(in, "RINGTIME", diff);
1535
1538 sent_ring = 1;
1539 }
1540 }
1541 ast_channel_publish_dial(in, c, NULL, "RINGING");
1542 break;
1544 ast_verb(3, "%s is making progress passing it to %s\n", ast_channel_name(c), ast_channel_name(in));
1545 /* Setup early media if appropriate */
1546 if (single && !caller_entertained
1547 && CAN_EARLY_BRIDGE(peerflags, in, c)) {
1549 }
1551 if (single || (!single && !pa->sentringing)) {
1553 }
1554 }
1555 *to_progress = -1;
1556 orig_progress_to = -1;
1557 if (!sent_progress) {
1558 struct timeval now, then;
1559 int64_t diff;
1560
1561 now = ast_tvnow();
1562
1565
1567 diff = ast_tvzero(then) ? 0 : ast_tvdiff_ms(now, then);
1568 set_duration_var(in, "PROGRESSTIME", diff);
1569
1572 sent_progress = 1;
1573
1574 if (!ast_strlen_zero(mf_progress)) {
1575 ast_verb(3,
1576 "Sending MF '%s' to %s as result of "
1577 "receiving a PROGRESS message.\n",
1578 mf_progress, hearpulsing ? "parties" : "called party");
1579 res |= ast_mf_stream(c, (hearpulsing ? NULL : in),
1580 (hearpulsing ? in : NULL), mf_progress, 50, 55, 120, 65, 0);
1581 }
1582 if (!ast_strlen_zero(sf_progress)) {
1583 ast_verb(3,
1584 "Sending SF '%s' to %s as result of "
1585 "receiving a PROGRESS message.\n",
1586 sf_progress, (hearpulsing ? "parties" : "called party"));
1587 res |= ast_sf_stream(c, (hearpulsing ? NULL : in),
1588 (hearpulsing ? in : NULL), sf_progress, 0, 0);
1589 }
1590 if (!ast_strlen_zero(dtmf_progress)) {
1591 ast_verb(3,
1592 "Sending DTMF '%s' to the called party as result of "
1593 "receiving a PROGRESS message.\n",
1594 dtmf_progress);
1595 res |= ast_dtmf_stream(c, in, dtmf_progress, 250, 0);
1596 }
1597 if (res) {
1598 ast_log(LOG_WARNING, "Called channel %s hung up post-progress before all digits could be sent\n", ast_channel_name(c));
1599 goto wait_over;
1600 }
1601 }
1602 ast_channel_publish_dial(in, c, NULL, "PROGRESS");
1603 break;
1604 case AST_CONTROL_WINK:
1605 ast_verb(3, "%s winked, passing it to %s\n", ast_channel_name(c), ast_channel_name(in));
1606 if (!sent_wink) {
1607 sent_wink = 1;
1608 if (!ast_strlen_zero(mf_wink)) {
1609 ast_verb(3,
1610 "Sending MF '%s' to %s as result of "
1611 "receiving a WINK message.\n",
1612 mf_wink, (hearpulsing ? "parties" : "called party"));
1613 res |= ast_mf_stream(c, (hearpulsing ? NULL : in),
1614 (hearpulsing ? in : NULL), mf_wink, 50, 55, 120, 65, 0);
1615 }
1616 if (!ast_strlen_zero(sf_wink)) {
1617 ast_verb(3,
1618 "Sending SF '%s' to %s as result of "
1619 "receiving a WINK message.\n",
1620 sf_wink, (hearpulsing ? "parties" : "called party"));
1621 res |= ast_sf_stream(c, (hearpulsing ? NULL : in),
1622 (hearpulsing ? in : NULL), sf_wink, 0, 0);
1623 }
1624 if (res) {
1625 ast_log(LOG_WARNING, "Called channel %s hung up post-wink before all digits could be sent\n", ast_channel_name(c));
1626 goto wait_over;
1627 }
1628 }
1630 break;
1634 if (!single || caller_entertained) {
1635 break;
1636 }
1637 ast_verb(3, "%s requested media update control %d, passing it to %s\n",
1640 break;
1643 ast_verb(3, "Connected line update to %s prevented.\n", ast_channel_name(in));
1644 break;
1645 }
1646 if (!single) {
1648
1649 ast_verb(3, "%s connected line has changed. Saving it until answer for %s\n",
1656 break;
1657 }
1658 if (ast_channel_connected_line_sub(c, in, f, 1)) {
1660 }
1661 break;
1662 case AST_CONTROL_AOC:
1663 {
1664 struct ast_aoc_decoded *decoded = ast_aoc_decode(f->data.ptr, f->datalen, o->chan);
1665 if (decoded && (ast_aoc_get_msg_type(decoded) == AST_AOC_S)) {
1667 o->aoc_s_rate_list = decoded;
1668 } else {
1669 ast_aoc_destroy_decoded(decoded);
1670 }
1671 }
1672 break;
1674 if (!single) {
1675 /*
1676 * Redirecting updates to the caller make sense only on single
1677 * calls.
1678 */
1679 break;
1680 }
1682 ast_verb(3, "Redirecting update to %s prevented.\n", ast_channel_name(in));
1683 break;
1684 }
1685 ast_verb(3, "%s redirecting info has changed, passing it to %s\n",
1687 if (ast_channel_redirecting_sub(c, in, f, 1)) {
1689 }
1690 pa->sentringing = 0;
1691 break;
1693 ast_verb(3, "%s is proceeding passing it to %s\n", ast_channel_name(c), ast_channel_name(in));
1694 if (single && !caller_entertained
1695 && CAN_EARLY_BRIDGE(peerflags, in, c)) {
1697 }
1700 ast_channel_publish_dial(in, c, NULL, "PROCEEDING");
1701 break;
1702 case AST_CONTROL_HOLD:
1703 /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */
1704 ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(c));
1706 break;
1707 case AST_CONTROL_UNHOLD:
1708 /* XXX this should be saved like AST_CONTROL_CONNECTED_LINE for !single || caller_entertained */
1709 ast_verb(3, "Call on %s left from hold\n", ast_channel_name(c));
1711 break;
1713 case AST_CONTROL_FLASH:
1714 /* Ignore going off hook and flash */
1715 break;
1716 case AST_CONTROL_CC:
1717 if (!ignore_cc) {
1719 cc_frame_received = 1;
1720 }
1721 break;
1724 break;
1725 case -1:
1726 if (single && !caller_entertained) {
1727 ast_verb(3, "%s stopped sounds\n", ast_channel_name(c));
1728 ast_indicate(in, -1);
1729 pa->sentringing = 0;
1730 }
1731 break;
1732 default:
1733 ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer);
1734 break;
1735 }
1736 break;
1737 case AST_FRAME_VIDEO:
1738 case AST_FRAME_VOICE:
1739 case AST_FRAME_IMAGE:
1741 case AST_FRAME_DTMF_END:
1742 if (caller_entertained) {
1743 break;
1744 }
1745 *to_progress = -1;
1746 orig_progress_to = -1;
1747 /* Fall through */
1748 case AST_FRAME_TEXT:
1749 if (single && ast_write(in, f)) {
1750 ast_log(LOG_WARNING, "Unable to write frametype: %u\n",
1751 f->frametype);
1752 }
1753 break;
1754 case AST_FRAME_HTML:
1756 && ast_channel_sendhtml(in, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
1757 ast_log(LOG_WARNING, "Unable to send URL\n");
1758 }
1759 break;
1760 default:
1761 break;
1762 }
1763 ast_frfree(f);
1764 } /* end for */
1765 if (winner == in) {
1766 struct ast_frame *f = ast_read(in);
1767#if 0
1768 if (f && (f->frametype != AST_FRAME_VOICE))
1769 printf("Frame type: %d, %d\n", f->frametype, f->subclass);
1770 else if (!f || (f->frametype != AST_FRAME_VOICE))
1771 printf("Hangup received on %s\n", in->name);
1772#endif
1773 if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
1774 /* Got hung up */
1775 *to_answer = -1;
1776 strcpy(pa->status, "CANCEL");
1777 pa->canceled = 1;
1778 publish_dial_end_event(in, out_chans, NULL, pa->status);
1779 if (f) {
1780 if (f->data.uint32) {
1782 }
1783 ast_frfree(f);
1784 }
1785 if (is_cc_recall) {
1786 ast_cc_completed(in, "CC completed, although the caller hung up (cancelled)");
1787 }
1788 SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller hung up\n", ast_channel_name(in));
1789 }
1790
1791 /* now f is guaranteed non-NULL */
1792 if (f->frametype == AST_FRAME_DTMF) {
1793 if (ast_test_flag64(peerflags, OPT_DTMF_EXIT)) {
1794 const char *context;
1796 context = pbx_builtin_getvar_helper(in, "EXITCONTEXT");
1797 if (onedigit_goto(in, context, (char) f->subclass.integer, 1)) {
1798 ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
1799 *to_answer = 0;
1800 *result = f->subclass.integer;
1801 strcpy(pa->status, "CANCEL");
1802 pa->canceled = 1;
1803 publish_dial_end_event(in, out_chans, NULL, pa->status);
1804 ast_frfree(f);
1806 if (is_cc_recall) {
1807 ast_cc_completed(in, "CC completed, but the caller used DTMF to exit");
1808 }
1809 SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller pressed %c to end call\n",
1811 }
1813 }
1814
1815 if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
1816 detect_disconnect(in, f->subclass.integer, &featurecode)) {
1817 ast_verb(3, "User requested call disconnect.\n");
1818 *to_answer = 0;
1819 strcpy(pa->status, "CANCEL");
1820 pa->canceled = 1;
1821 publish_dial_end_event(in, out_chans, NULL, pa->status);
1822 ast_frfree(f);
1823 if (is_cc_recall) {
1824 ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
1825 }
1826 SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller requested disconnect\n",
1828 }
1829 }
1830
1831 /* Send the frame from the in channel to all outgoing channels. */
1832 AST_LIST_TRAVERSE(out_chans, o, node) {
1833 if (!o->chan || !ast_test_flag64(o, DIAL_STILLGOING)) {
1834 /* This outgoing channel has died so don't send the frame to it. */
1835 continue;
1836 }
1837 switch (f->frametype) {
1838 case AST_FRAME_HTML:
1839 /* Forward HTML stuff */
1841 && ast_channel_sendhtml(o->chan, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
1842 ast_log(LOG_WARNING, "Unable to send URL\n");
1843 }
1844 break;
1845 case AST_FRAME_VIDEO:
1846 case AST_FRAME_VOICE:
1847 case AST_FRAME_IMAGE:
1848 if (!single || caller_entertained) {
1849 /*
1850 * We are calling multiple parties or caller is being
1851 * entertained and has thus not been made compatible.
1852 * No need to check any other called parties.
1853 */
1854 goto skip_frame;
1855 }
1856 /* Fall through */
1857 case AST_FRAME_TEXT:
1859 case AST_FRAME_DTMF_END:
1860 if (ast_write(o->chan, f)) {
1861 ast_log(LOG_WARNING, "Unable to forward frametype: %u\n",
1862 f->frametype);
1863 }
1864 break;
1865 case AST_FRAME_CONTROL:
1866 switch (f->subclass.integer) {
1867 case AST_CONTROL_HOLD:
1868 ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(o->chan));
1870 break;
1871 case AST_CONTROL_UNHOLD:
1872 ast_verb(3, "Call on %s left from hold\n", ast_channel_name(o->chan));
1874 break;
1875 case AST_CONTROL_FLASH:
1876 ast_verb(3, "Hook flash on %s\n", ast_channel_name(o->chan));
1878 break;
1882 if (!single || caller_entertained) {
1883 /*
1884 * We are calling multiple parties or caller is being
1885 * entertained and has thus not been made compatible.
1886 * No need to check any other called parties.
1887 */
1888 goto skip_frame;
1889 }
1890 ast_verb(3, "%s requested media update control %d, passing it to %s\n",
1893 break;
1896 ast_verb(3, "Connected line update to %s prevented.\n", ast_channel_name(o->chan));
1897 break;
1898 }
1899 if (ast_channel_connected_line_sub(in, o->chan, f, 1)) {
1901 }
1902 break;
1905 ast_verb(3, "Redirecting update to %s prevented.\n", ast_channel_name(o->chan));
1906 break;
1907 }
1908 if (ast_channel_redirecting_sub(in, o->chan, f, 1)) {
1910 }
1911 break;
1912 default:
1913 /* We are not going to do anything with this frame. */
1914 goto skip_frame;
1915 }
1916 break;
1917 default:
1918 /* We are not going to do anything with this frame. */
1919 goto skip_frame;
1920 }
1921 }
1922skip_frame:;
1923 ast_frfree(f);
1924 }
1925 }
1926
1927wait_over:
1928 if (!*to_answer || ast_check_hangup(in)) {
1929 ast_verb(3, "Nobody picked up in %d ms\n", orig_answer_to);
1930 publish_dial_end_event(in, out_chans, NULL, "NOANSWER");
1931 } else if (!*to_progress) {
1932 ast_verb(3, "No early media received in %d ms\n", orig_progress_to);
1933 publish_dial_end_event(in, out_chans, NULL, "CHANUNAVAIL");
1934 strcpy(pa->status, "CHANUNAVAIL");
1935 *to_answer = 0; /* Reset to prevent hangup */
1936 }
1937
1938 if (is_cc_recall) {
1939 ast_cc_completed(in, "Recall completed!");
1940 }
1941 SCOPE_EXIT_RTN_VALUE(peer, "%s: %s%s\n", ast_channel_name(in),
1942 peer ? "Answered by " : "No answer", peer ? ast_channel_name(peer) : "");
1943}
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
Definition: aoc.c:313
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:892
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:449
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:650
@ 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:937
#define AST_MAX_WATCHERS
Definition: app_dial.c:858
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:1149
static void update_connected_line_from_peer(struct ast_channel *chan, struct ast_channel *peer, int is_caller)
Definition: app_dial.c:1169
static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode)
Definition: app_dial.c:1945
#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:3405
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:2293
int ast_cc_completed(struct ast_channel *chan, const char *const debug,...)
Indicate recall has been acknowledged.
Definition: ccss.c:3807
int ast_cc_failed(int core_id, const char *const debug,...)
Indicate failure has occurred.
Definition: ccss.c:3844
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:6647
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:2073
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:5163
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:8807
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_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:813
struct ast_party_connected_line connected
Definition: app_dial.c:810
char * orig_chan_name
Definition: app_dial.c:807
unsigned int pending_connected_update
Definition: app_dial.c:812
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_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_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_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 3601 of file app_dial.c.

◆ app

const char app[] = "Dial"
static

Definition at line 663 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 3601 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 785 of file app_dial.c.

Referenced by dial_exec_full().

◆ rapp

const char rapp[] = "RetryDial"
static

Definition at line 664 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:820

Definition at line 825 of file app_dial.c.

Referenced by dial_exec_full().