summaryrefslogtreecommitdiff
path: root/main/dial.c
diff options
context:
space:
mode:
authorScott Griepentrog <sgriepentrog@digium.com>2014-03-07 15:47:55 +0000
committerScott Griepentrog <sgriepentrog@digium.com>2014-03-07 15:47:55 +0000
commit80ef9a21b9d91ff0bafc304923bc29effa230b00 (patch)
treea67db39a4c17a4b01a87201ef37ffdc43189c119 /main/dial.c
parentd3ac8b8a0e70049af7b5552c4dfd8adc2cc5df11 (diff)
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and much change was necessary to accomplish it. Channel uniqueids and linkedids are split into separate string and creation time components without breaking linkedid propgation. This allowed the uniqueid to be specified by the user interface - and those values are now carried through to channel creation, adding the assignedids value to every function in the chain including the channel drivers. For local channels, the second channel can be specified or left to default to a ;2 suffix of first. In ARI, bridge, playback, and snoop objects can also be created with a specified uniqueid. Along the way, the args order to allocating channels was fixed in chan_mgcp and chan_gtalk, and linkedid is no longer lost as masquerade occurs. (closes issue ASTERISK-23120) Review: https://reviewboard.asterisk.org/r/3191/ ........ Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/dial.c')
-rw-r--r--main/dial.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/main/dial.c b/main/dial.c
index 6ff0e7f7d..246d4f406 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -69,6 +69,8 @@ struct ast_dial_channel {
void *options[AST_DIAL_OPTION_MAX]; /*!< Channel specific options */
int cause; /*!< Cause code in case of failure */
unsigned int is_running_app:1; /*!< Is this running an application? */
+ char *assignedid1; /*!< UniqueID to assign channel */
+ char *assignedid2; /*!< UniqueID to assign 2nd channel */
struct ast_channel *owner; /*!< Asterisk channel */
AST_LIST_ENTRY(ast_dial_channel) list; /*!< Linked list information */
};
@@ -247,7 +249,7 @@ struct ast_dial *ast_dial_create(void)
* \note Appends a channel to a dialing structure
* \return Returns channel reference number on success, -1 on failure
*/
-int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device)
+int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
{
struct ast_dial_channel *channel = NULL;
@@ -263,6 +265,16 @@ int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device)
channel->tech = ast_strdup(tech);
channel->device = ast_strdup(device);
+ /* Store the assigned id */
+ if (assignedids && !ast_strlen_zero(assignedids->uniqueid))
+ {
+ channel->assignedid1 = ast_strdup(assignedids->uniqueid);
+
+ if (!ast_strlen_zero(assignedids->uniqueid2)) {
+ channel->assignedid2 = ast_strdup(assignedids->uniqueid2);
+ }
+ }
+
/* Grab reference number from dial structure */
channel->num = ast_atomic_fetchadd_int(&dial->num, +1);
@@ -281,6 +293,7 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
char numsubst[AST_MAX_EXTENSION];
struct ast_format_cap *cap_all_audio = NULL;
struct ast_format_cap *cap_request;
+ struct ast_assigned_ids assignedids = {channel->assignedid1, channel->assignedid2};
/* Copy device string over */
ast_copy_string(numsubst, channel->device, sizeof(numsubst));
@@ -296,7 +309,7 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
}
/* If we fail to create our owner channel bail out */
- if (!(channel->owner = ast_request(channel->tech, cap_request, chan, numsubst, &channel->cause))) {
+ if (!(channel->owner = ast_request(channel->tech, cap_request, &assignedids, chan, numsubst, &channel->cause))) {
cap_all_audio = ast_format_cap_destroy(cap_all_audio);
return -1;
}
@@ -461,6 +474,14 @@ static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *c
/* Drop old destination information */
ast_free(channel->tech);
ast_free(channel->device);
+ if (channel->assignedid1) {
+ ast_free(channel->assignedid1);
+ channel->assignedid1 = NULL;
+ }
+ if (channel->assignedid2) {
+ ast_free(channel->assignedid2);
+ channel->assignedid2 = NULL;
+ }
/* Update the dial channel with the new destination information */
channel->tech = ast_strdup(tech);
@@ -1045,6 +1066,13 @@ int ast_dial_destroy(struct ast_dial *dial)
/* Free structure */
ast_free(channel->tech);
ast_free(channel->device);
+ if (channel->assignedid1) {
+ ast_free(channel->assignedid1);
+ }
+ if (channel->assignedid2) {
+ ast_free(channel->assignedid2);
+ }
+
AST_LIST_REMOVE_CURRENT(list);
ast_free(channel);
}