Merge team/russell/sla_rewrite

This is a completely new implementation of the SLA functionality introduced in
Asterisk 1.4.  It is now functional and ready for testing.  However, I will be
adding some additional features over the next week, as well.

For information on how to set this up, see configs/sla.conf.sample 
and doc/sla.txt.

In addition to the changes in app_meetme.c for the SLA implementation itself,
this merge brings in various other changes:

chan_sip:
 - Add the ability to indicate HOLD state in NOTIFY messages.
 - Queue HOLD and UNHOLD control frames even if the channel is not bridged to
   another channel.

linkedlists.h:
 - Add support for rwlock based linked lists.

dial.c:
 - Add the ability to run ast_dial_start() without a reference channel to
   inherit information from.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@53810 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 19 years ago
parent 2f5eabb51e
commit 7ee02f585d

File diff suppressed because it is too large Load Diff

@ -4705,7 +4705,6 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
int iterator;
int sendonly = 0;
int numberofports;
struct ast_channel *bridgepeer = NULL;
struct ast_rtp *newaudiortp, *newvideortp; /* Buffers for codec handling */
int newjointcapability; /* Negotiated capability */
int newpeercapability;
@ -5196,22 +5195,21 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
ast_set_write_format(p->owner, p->owner->writeformat);
}
/* Turn on/off music on hold if we are holding/unholding */
if ((bridgepeer = ast_bridged_channel(p->owner))) {
if (sin.sin_addr.s_addr && !sendonly) {
ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
/* Activate a re-invite */
ast_queue_frame(p->owner, &ast_null_frame);
} else if (!sin.sin_addr.s_addr || sendonly) {
ast_queue_control_data(p->owner, AST_CONTROL_HOLD,
S_OR(p->mohsuggest, NULL),
!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
if (sendonly)
ast_rtp_stop(p->rtp);
/* RTCP needs to go ahead, even if we're on hold!!! */
/* Activate a re-invite */
ast_queue_frame(p->owner, &ast_null_frame);
}
if (sin.sin_addr.s_addr && !sendonly) {
ast_log(LOG_DEBUG, "Queueing UNHOLD!\n");
ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
/* Activate a re-invite */
ast_queue_frame(p->owner, &ast_null_frame);
} else if (!sin.sin_addr.s_addr || sendonly) {
ast_log(LOG_DEBUG, "Going on HOLD!\n");
ast_queue_control_data(p->owner, AST_CONTROL_HOLD,
S_OR(p->mohsuggest, NULL),
!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
if (sendonly)
ast_rtp_stop(p->rtp);
/* RTCP needs to go ahead, even if we're on hold!!! */
/* Activate a re-invite */
ast_queue_frame(p->owner, &ast_null_frame);
}
/* Manager Hold and Unhold events must be generated, if necessary */
@ -6868,6 +6866,10 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int tim
pidfnote = "Unavailable";
break;
case AST_EXTENSION_ONHOLD:
statestring = "confirmed";
local_state = NOTIFY_INUSE;
pidfstate = "busy";
pidfnote = "On the phone";
break;
case AST_EXTENSION_NOT_INUSE:
default:
@ -6963,6 +6965,11 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int tim
else
ast_build_string(&t, &maxbytes, "<dialog id=\"%s\">\n", p->exten);
ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
if (state == AST_EXTENSION_ONHOLD) {
ast_build_string(&t, &maxbytes, "<local>\n<target uri=\"%s\">\n"
"<param pname=\"+sip.rendering\" pvalue=\"no\">\n"
"</target>\n</local>\n", mto);
}
ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
break;
case NONE:

@ -1,26 +1,82 @@
; Configuration file for SLAs (Shared Line Appearances).
; Defining a SLA uses the following syntax:
;
; type => Technology/TechData
;
; type => trunk or station
; Technology => the channel driver (see show channeltypes)
; TechData => the data specific to the channel driver
;
; The Technology/TechData information is the same as that provided to the
; Dial application.
; Configuration for Shared Line Appearances (SLA).
;
; define a SLA called junky
[junky]
trunk => SIP/10
station => SIP/15
station => SIP/16
; ---- General Options ----------------
[general]
; There are none!
; -------------------------------------
; ---- Trunk Declarations -------------
; Provide a name for this trunk.
[line1]
; This line is what marks this entry as a trunk.
type=trunk
; Map this trunk declaration to a specific device.
; NOTE: At this point, this *must* be a zap channel!
device=Zap/3
; This supports automatic generation of the dialplan entries if the autocontext
; option is used. Each trunk should have a unique context name. Then, in
; zapata.conf, this device should be configured to have incoming calls go to
; this context.
autocontext=line1
[line2]
type=trunk
device=Zap/4
autocontext=line2
[line3]
type=trunk
device=Zap/3
autocontext=line3
[line4]
type=trunk
device=Zap/4
autocontext=line4
; --------------------------------------
; ---- Station Declarations ------------
; In this example, all stations have the same trunks, so this configuration
; template is used to simplify the declaration of each station.
[station](!)
; This line indicates that this entry is a station.
type=station
; This supports automatic generation of the dialplan entries if the autocontext
; option is used. All stations can use the same context without conflict. The
; device for this station should have its context configured to the same one
; listed here.
autocontext=sla_stations
; Individually list all of the trunks that will appear on this station. This
; order is significant. It should be the same order as they appear on the
; phone. The order here defines the order of preference that the trunks will
; be used.
trunk=line1
trunk=line2
trunk=line3
trunk=line4
; Define a station that uses the configuration from the template "station".
[station1](station)
; Each station must be mapped to a device.
device=SIP/station1
[station2](station)
device=SIP/station2
[station3](station)
device=SIP/station3
[station4](station)
device=SIP/station4
;define a SLA called markster
[markster]
trunk => Zap/1
station => SIP/20
[station5](station)
device=SIP/station5
; --------------------------------------
; Also you can see SLA infos via the CLI, by typing "sla show"

@ -0,0 +1,93 @@
-------------------------------------------------------------
--- Shared Line Appearances ---------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
INTRODUCTION
The "SLA" functionality in Asterisk is intended to allow a setup that emulates
a simple key system. It uses the various abstraction layers already built into
Asterisk to emulate key system functionality across various devices, including
IP channels.
-------------------------------------------------------------
-------------------------------------------------------------
DIALPLAN CONFIGURATION
The SLA implementation can automatically generate the dialplan necessary for
basic operation if the "autocontext" option is set for trunks and stations in
sla.conf. However, for reference, here is an automatically generated dialplan
to help with custom building of the dialplan to include other features, such as
voicemail:
[line1]
exten => s,1,SLATrunk(line1)
[line2]
exten => s,2,SLATRUNK(line2)
[sla_stations]
exten => station1,1,SLAStation(station1)
exten => station1_line1,hint,SLA:station1_line1
exten => station1_line1,1,SLAStation(station1_line1)
exten => station1_line2,hint,SLA:station1_line2
exten => station1_line2,1,SLAStation(station1_line2)
exten => station2,1,SLAStation(station2)
exten => station2_line1,hint,SLA:station2_line1
exten => station2_line1,1,SLAStation(station2_line1)
exten => station2_line2,hint,SLA:station2_line2
exten => station2_line2,1,SLAStation(station2_line2)
exten => station3,1,SLAStation(station3)
exten => station3_line1,hint,SLA:station3_line1
exten => station3_line1,1,SLAStation(station3_line1)
exten => station3_line2,hint,SLA:station3_line2
exten => station3_line2,1,SLAStation(station3_line2)
-------------------------------------------------------------
-------------------------------------------------------------
TRUNKS
For the trunk side of SLA, the only channels that are currently supported are
Zap channels. Support for IP trunks is planned, but not yet implemented.
Be sure to configure the trunk's context to be the same one that is set for the
"autocontext" option in sla.conf if automatic dialplan configuration is used.
If the dialplan is being built manually, ensure that calls coming in on a trunk
execute the SLATrunk() application with an argument of the trunk name.
-------------------------------------------------------------
-------------------------------------------------------------
STATIONS
Currently, the only channel driver that has all of the features necessary to
support an SLA environment is chan_sip. Here are some hints on configuring
a SIP phone for use with SLA:
1) Add the SIP channel as a [station] in sla.conf.
2) Configure the phone in sip.conf. If automatic dialplan configuration was
used by enabling the "autocontext" option in sla.conf, then this entry in
sip.conf should have the same context setting.
3) On the phone itself, there are various things that must be configured to
make everything work correctly:
Let's say this phone is called "station1" in sla.conf, and it uses trunks
named "line1" and line2".
a) Two line buttons must be configured to subscribe to the state of the
following extensions:
- station1_line1
- station1_line2
b) The line appearance buttons should be configured to dial the extensions
that they are subscribed to when they are pressed.
c) If you would like the phone to automatically connect to a trunk when it
is taken off hook, then the phone should be automatically configured to
dial "station1" when it is taken off hook.
-------------------------------------------------------------

@ -306,6 +306,9 @@ struct ast_app_option {
unsigned int arg_index;
};
#define BEGIN_OPTIONS {
#define END_OPTIONS }
/*!
\brief Declares an array of options for an application.
\param holder The name of the array to be created

@ -42,7 +42,7 @@ enum ast_dial_option {
/*! \brief List of return codes for dial run API calls */
enum ast_dial_result {
AST_DIAL_RESULT_INVALID = 0, /*!< Invalid options were passed to run function */
AST_DIAL_RESULT_INVALID, /*!< Invalid options were passed to run function */
AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */
AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */
AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */

@ -37,6 +37,28 @@
*/
#define AST_LIST_LOCK(head) \
ast_mutex_lock(&(head)->lock)
/*!
\brief Write locks a list.
\param head This is a pointer to the list head structure
This macro attempts to place an exclusive write lock in the
list head structure pointed to by head.
Returns non-zero on success, 0 on failure
*/
#define AST_RWLIST_WRLOCK(head) \
ast_rwlock_wrlock(&(head)->lock)
/*!
\brief Read locks a list.
\param head This is a pointer to the list head structure
This macro attempts to place a read lock in the
list head structure pointed to by head.
Returns non-zero on success, 0 on failure
*/
#define AST_RWLIST_RDLOCK(head) \
ast_rwlock_rdlock(&(head)->lock)
/*!
\brief Locks a list, without blocking if the list is locked.
@ -48,6 +70,28 @@
*/
#define AST_LIST_TRYLOCK(head) \
ast_mutex_trylock(&(head)->lock)
/*!
\brief Write locks a list, without blocking if the list is locked.
\param head This is a pointer to the list head structure
This macro attempts to place an exclusive write lock in the
list head structure pointed to by head.
Returns non-zero on success, 0 on failure
*/
#define AST_RWLIST_TRYWRLOCK(head) \
ast_rwlock_trywrlock(&(head)->lock)
/*!
\brief Read locks a list, without blocking if the list is locked.
\param head This is a pointer to the list head structure
This macro attempts to place a read lock in the
list head structure pointed to by head.
Returns non-zero on success, 0 on failure
*/
#define AST_RWLIST_TRYRDLOCK(head) \
ast_rwlock_tryrdlock(&(head)->lock)
/*!
\brief Attempts to unlock a list.
@ -60,6 +104,17 @@
#define AST_LIST_UNLOCK(head) \
ast_mutex_unlock(&(head)->lock)
/*!
\brief Attempts to unlock a read/write based list.
\param head This is a pointer to the list head structure
This macro attempts to remove a read or write lock from the
list head structure pointed to by head. If the list
was not locked by this thread, this macro has no effect.
*/
#define AST_RWLIST_UNLOCK(head) \
ast_rwlock_unlock(&(head)->lock)
/*!
\brief Defines a structure to be used to hold a list of specified type.
\param name This will be the name of the defined structure.
@ -86,6 +141,32 @@ struct name { \
ast_mutex_t lock; \
}
/*!
\brief Defines a structure to be used to hold a read/write list of specified type.
\param name This will be the name of the defined structure.
\param type This is the type of each list entry.
This macro creates a structure definition that can be used
to hold a list of the entries of type \a type. It does not actually
declare (allocate) a structure; to do that, either follow this
macro with the desired name of the instance you wish to declare,
or use the specified \a name to declare instances elsewhere.
Example usage:
\code
static AST_RWLIST_HEAD(entry_list, entry) entries;
\endcode
This would define \c struct \c entry_list, and declare an instance of it named
\a entries, all intended to hold a list of type \c struct \c entry.
*/
#define AST_RWLIST_HEAD(name, type) \
struct name { \
struct type *first; \
struct type *last; \
ast_rwlock_t lock; \
}
/*!
\brief Defines a structure to be used to hold a list of specified type (with no lock).
\param name This will be the name of the defined structure.
@ -120,6 +201,15 @@ struct name { \
.lock = AST_MUTEX_INIT_VALUE, \
}
/*!
\brief Defines initial values for a declaration of AST_RWLIST_HEAD
*/
#define AST_RWLIST_HEAD_INIT_VALUE { \
.first = NULL, \
.last = NULL, \
.lock = AST_RWLOCK_INIT_VALUE, \
}
/*!
\brief Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK
*/
@ -170,6 +260,48 @@ struct name { \
} name = AST_LIST_HEAD_INIT_VALUE
#endif
/*!
\brief Defines a structure to be used to hold a read/write list of specified type, statically initialized.
\param name This will be the name of the defined structure.
\param type This is the type of each list entry.
This macro creates a structure definition that can be used
to hold a list of the entries of type \a type, and allocates an instance
of it, initialized to be empty.
Example usage:
\code
static AST_RWLIST_HEAD_STATIC(entry_list, entry);
\endcode
This would define \c struct \c entry_list, intended to hold a list of
type \c struct \c entry.
*/
#ifndef AST_RWLOCK_INIT_VALUE
#define AST_RWLIST_HEAD_STATIC(name, type) \
struct name { \
struct type *first; \
struct type *last; \
ast_rwlock_t lock; \
} name; \
static void __attribute__ ((constructor)) init_##name(void) \
{ \
AST_RWLIST_HEAD_INIT(&name); \
} \
static void __attribute__ ((destructor)) fini_##name(void) \
{ \
AST_RWLIST_HEAD_DESTROY(&name); \
} \
struct __dummy_##name
#else
#define AST_RWLIST_HEAD_STATIC(name, type) \
struct name { \
struct type *first; \
struct type *last; \
ast_rwlock_t lock; \
} name = AST_RWLIST_HEAD_INIT_VALUE
#endif
/*!
\brief Defines a structure to be used to hold a list of specified type, statically initialized.
@ -195,6 +327,20 @@ struct name { \
ast_mutex_init(&(head)->lock); \
} while (0)
/*!
\brief Initializes an rwlist head structure with a specified first entry.
\param head This is a pointer to the list head structure
\param entry pointer to the list entry that will become the head of the list
This macro initializes a list head structure by setting the head
entry to the supplied value and recreating the embedded lock.
*/
#define AST_RWLIST_HEAD_SET(head, entry) do { \
(head)->first = (entry); \
(head)->last = (entry); \
ast_rwlock_init(&(head)->lock); \
} while (0)
/*!
\brief Initializes a list head structure with a specified first entry.
\param head This is a pointer to the list head structure
@ -229,6 +375,8 @@ struct name { \
struct { \
struct type *next; \
}
#define AST_RWLIST_ENTRY AST_LIST_ENTRY
/*!
\brief Returns the first entry contained in a list.
@ -236,12 +384,16 @@ struct { \
*/
#define AST_LIST_FIRST(head) ((head)->first)
#define AST_RWLIST_FIRST AST_LIST_FIRST
/*!
\brief Returns the last entry contained in a list.
\param head This is a pointer to the list head structure
*/
#define AST_LIST_LAST(head) ((head)->last)
#define AST_RWLIST_LAST AST_LIST_LAST
/*!
\brief Returns the next entry in the list after the given entry.
\param elm This is a pointer to the current entry.
@ -250,6 +402,8 @@ struct { \
*/
#define AST_LIST_NEXT(elm, field) ((elm)->field.next)
#define AST_RWLIST_NEXT AST_LIST_NEXT
/*!
\brief Checks whether the specified list contains any entries.
\param head This is a pointer to the list head structure
@ -258,6 +412,8 @@ struct { \
*/
#define AST_LIST_EMPTY(head) (AST_LIST_FIRST(head) == NULL)
#define AST_RWLIST_EMPTY AST_LIST_EMPTY
/*!
\brief Loops over (traverses) the entries in a list.
\param head This is a pointer to the list head structure
@ -297,6 +453,8 @@ struct { \
#define AST_LIST_TRAVERSE(head,var,field) \
for((var) = (head)->first; (var); (var) = (var)->field.next)
#define AST_RWLIST_TRAVERSE AST_LIST_TRAVERSE
/*!
\brief Loops safely over (traverses) the entries in a list.
\param head This is a pointer to the list head structure
@ -342,6 +500,8 @@ struct { \
__list_next = (var) ? (var)->field.next : NULL \
)
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN AST_LIST_TRAVERSE_SAFE_BEGIN
/*!
\brief Removes the \a current entry from a list during a traversal.
\param head This is a pointer to the list head structure
@ -363,6 +523,8 @@ struct { \
if (!__list_next) \
(head)->last = __list_prev;
#define AST_RWLIST_REMOVE_CURRENT AST_LIST_REMOVE_CURRENT
/*!
\brief Inserts a list entry before the current entry during a traversal.
\param head This is a pointer to the list head structure
@ -384,11 +546,15 @@ struct { \
__new_prev = (elm); \
} while (0)
#define AST_RWLIST_INSERT_BEFORE_CURRENT AST_LIST_INSERT_BEFORE_CURRENT
/*!
\brief Closes a safe loop traversal block.
*/
#define AST_LIST_TRAVERSE_SAFE_END }
#define AST_RWLIST_TRAVERSE_SAFE_END AST_LIST_TRAVERSE_SAFE_END
/*!
\brief Initializes a list head structure.
\param head This is a pointer to the list head structure
@ -402,6 +568,19 @@ struct { \
ast_mutex_init(&(head)->lock); \
}
/*!
\brief Initializes an rwlist head structure.
\param head This is a pointer to the list head structure
This macro initializes a list head structure by setting the head
entry to \a NULL (empty list) and recreating the embedded lock.
*/
#define AST_RWLIST_HEAD_INIT(head) { \
(head)->first = NULL; \
(head)->last = NULL; \
ast_rwlock_init(&(head)->lock); \
}
/*!
\brief Destroys a list head structure.
\param head This is a pointer to the list head structure
@ -416,6 +595,20 @@ struct { \
ast_mutex_destroy(&(head)->lock); \
}
/*!
\brief Destroys an rwlist head structure.
\param head This is a pointer to the list head structure
This macro destroys a list head structure by setting the head
entry to \a NULL (empty list) and destroying the embedded lock.
It does not free the structure from memory.
*/
#define AST_RWLIST_HEAD_DESTROY(head) { \
(head)->first = NULL; \
(head)->last = NULL; \
ast_rwlock_destroy(&(head)->lock); \
}
/*!
\brief Initializes a list head structure.
\param head This is a pointer to the list head structure
@ -445,6 +638,8 @@ struct { \
(head)->last = (elm); \
} while (0)
#define AST_RWLIST_INSERT_AFTER AST_LIST_INSERT_AFTER
/*!
\brief Inserts a list entry at the head of a list.
\param head This is a pointer to the list head structure
@ -459,6 +654,8 @@ struct { \
(head)->last = (elm); \
} while (0)
#define AST_RWLIST_INSERT_HEAD AST_LIST_INSERT_HEAD
/*!
\brief Appends a list entry to the tail of a list.
\param head This is a pointer to the list head structure
@ -480,6 +677,8 @@ struct { \
} \
} while (0)
#define AST_RWLIST_INSERT_TAIL AST_LIST_INSERT_TAIL
/*!
\brief Appends a whole list to the tail of a list.
\param head This is a pointer to the list head structure
@ -497,6 +696,8 @@ struct { \
} \
} while (0)
#define AST_RWLIST_APPEND_LIST AST_LIST_APPEND_LIST
/*!
\brief Removes and returns the head entry from a list.
\param head This is a pointer to the list head structure
@ -517,6 +718,8 @@ struct { \
cur; \
})
#define AST_RWLIST_REMOVE_HEAD AST_LIST_REMOVE_HEAD
/*!
\brief Removes a specific entry from a list.
\param head This is a pointer to the list head structure
@ -543,4 +746,6 @@ struct { \
(elm)->field.next = NULL; \
} while (0)
#define AST_RWLIST_REMOVE AST_LIST_REMOVE
#endif /* _ASTERISK_LINKEDLISTS_H */

@ -553,4 +553,6 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c
*/
void ast_enable_packet_fragmentation(int sock);
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
#endif /* _ASTERISK_UTILS_H */

@ -228,33 +228,37 @@ static int begin_dial(struct ast_dial *dial, struct ast_channel *chan)
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
/* Request that the channel be created */
if (!(channel->owner = ast_request(channel->tech, chan->nativeformats, numsubst, &channel->cause)))
if (!(channel->owner = ast_request(channel->tech,
chan ? chan->nativeformats : AST_FORMAT_AUDIO_MASK, numsubst, &channel->cause))) {
continue;
}
channel->owner->appl = "AppDial2";
channel->owner->data = "(Outgoing Line)";
channel->owner->whentohangup = 0;
/* Inherit everything from he who spawned this Dial */
ast_channel_inherit_variables(chan, channel->owner);
/* Copy over callerid information */
S_REPLACE(channel->owner->cid.cid_num, ast_strdup(chan->cid.cid_num));
S_REPLACE(channel->owner->cid.cid_name, ast_strdup(chan->cid.cid_name));
S_REPLACE(channel->owner->cid.cid_ani, ast_strdup(chan->cid.cid_ani));
S_REPLACE(channel->owner->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
ast_string_field_set(channel->owner, language, chan->language);
ast_string_field_set(channel->owner, accountcode, chan->accountcode);
channel->owner->cdrflags = chan->cdrflags;
if (ast_strlen_zero(channel->owner->musicclass))
ast_string_field_set(channel->owner, musicclass, chan->musicclass);
channel->owner->cid.cid_pres = chan->cid.cid_pres;
channel->owner->cid.cid_ton = chan->cid.cid_ton;
channel->owner->cid.cid_tns = chan->cid.cid_tns;
channel->owner->adsicpe = chan->adsicpe;
channel->owner->transfercapability = chan->transfercapability;
if (chan) {
ast_channel_inherit_variables(chan, channel->owner);
/* Copy over callerid information */
S_REPLACE(channel->owner->cid.cid_num, ast_strdup(chan->cid.cid_num));
S_REPLACE(channel->owner->cid.cid_name, ast_strdup(chan->cid.cid_name));
S_REPLACE(channel->owner->cid.cid_ani, ast_strdup(chan->cid.cid_ani));
S_REPLACE(channel->owner->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
ast_string_field_set(channel->owner, language, chan->language);
ast_string_field_set(channel->owner, accountcode, chan->accountcode);
channel->owner->cdrflags = chan->cdrflags;
if (ast_strlen_zero(channel->owner->musicclass))
ast_string_field_set(channel->owner, musicclass, chan->musicclass);
channel->owner->cid.cid_pres = chan->cid.cid_pres;
channel->owner->cid.cid_ton = chan->cid.cid_ton;
channel->owner->cid.cid_tns = chan->cid.cid_tns;
channel->owner->adsicpe = chan->adsicpe;
channel->owner->transfercapability = chan->transfercapability;
}
/* Actually call the device */
if ((res = ast_call(channel->owner, numsubst, 0))) {
@ -530,12 +534,16 @@ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *cha
enum ast_dial_result res = AST_DIAL_RESULT_TRYING;
/* Ensure required arguments are passed */
if (!dial || !chan)
if (!dial || (!chan && !async)) {
ast_log(LOG_DEBUG, "invalid #1\n");
return AST_DIAL_RESULT_INVALID;
}
/* If there are no channels to dial we can't very well try to dial them */
if (AST_LIST_EMPTY(&dial->channels))
if (AST_LIST_EMPTY(&dial->channels)) {
ast_log(LOG_DEBUG, "invalid #2\n");
return AST_DIAL_RESULT_INVALID;
}
/* Dial each requested channel */
if (!begin_dial(dial, chan))
@ -543,6 +551,7 @@ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *cha
/* If we are running async spawn a thread and send it away... otherwise block here */
if (async) {
dial->status = AST_DIAL_RESULT_TRYING;
/* Try to create a thread */
if (ast_pthread_create(&dial->thread, NULL, async_dial, dial)) {
/* Failed to create the thread - hangup all dialed channels and return failed */

Loading…
Cancel
Save