[asterisk-commits] mmichelson: branch group/CCSS r246377 - in /team/group/CCSS/channels: ./ sip/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 11 17:58:13 CST 2010


Author: mmichelson
Date: Thu Feb 11 17:58:09 2010
New Revision: 246377

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=246377
Log:
Add a case for AST_OPTION_DEVICE_NAME to sip_queryoption.

I found that when using call completion to place a call to
two distinct sip endpoints using a connection to the a single
peer, i.e. Dial(SIP/1000 at asterisk&SIP/2000 at asterisk) where
"asterisk" is a peer in sip.conf, call completion was not
working as expected. The problem was that both channels are
named SIP/asterisk-<seqno>. Since the call completion core
will drop any CC frames received from what it perceives to
be the same device, only the first call leg over which we
queued a CC frame would be eligible for requesting call
completion.

The solution to this is to fill in the AST_OPTION_DEVICE_NAME
portion of chan_sip's sip_queryoption. This way, whenever
ast_channel_get_device_name is called on a SIP channel, a more
exact device name will be returned. In the sample above, the
two devices returned will be SIP/1000 at asterisk and SIP/2000 at asterisk.
In the case where a local SIP peer is dialed, the current scheme
can result in a somewhat odd name like SIP/1000 at 1000. However, this
causes no harmful side effects so for now anyway, there's no real
need to change this.


Modified:
    team/group/CCSS/channels/chan_sip.c
    team/group/CCSS/channels/sip/include/sip.h

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=246377&r1=246376&r2=246377
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Thu Feb 11 17:58:09 2010
@@ -2540,7 +2540,7 @@
 		 * refcount once the monitor destructor is called
 		 */
 		ast_module_ref(ast_module_info->self);
-		ast_queue_cc_frame(pvt->owner, "SIP", interface_name, offered_service, monitor_instance);
+		ast_queue_cc_frame(pvt->owner, "SIP", pvt->dialstring, offered_service, monitor_instance);
 		ao2_ref(monitor_instance, -1);
 		return;
 	}
@@ -4284,6 +4284,9 @@
 	enum ast_t38_state state = T38_STATE_UNAVAILABLE;
 	struct sip_pvt *p = (struct sip_pvt *) chan->tech_pvt;
 	char *cp;
+	char *peer_or_host;
+	char *separator;
+	char *chan_name_copy;
 
 	switch (option) {
 	case AST_OPTION_T38_STATE:
@@ -4321,6 +4324,41 @@
 		*cp = p->dsp ? 1 : 0;
 		ast_debug(1, "Reporting digit detection %sabled on %s\n", *cp ? "en" : "dis", chan->name);
 		break;
+	case AST_OPTION_DEVICE_NAME:
+		chan_name_copy = ast_strdupa(chan->name);
+		if ((peer_or_host = strchr(chan_name_copy, '/'))) {
+			*peer_or_host++ = '\0';
+		}
+		if ((separator = strrchr(peer_or_host, '-'))) {
+			*separator = '\0';
+		}
+		/* If the channel name already has '@' in it, then 
+		 * the device name is already specific enough for our needs.
+		 * ast_channel_get_device_name, will do our job for us in this
+		 * case.
+		 */
+		if (strchr(peer_or_host, '@')) {
+			break;
+		}
+
+		/* SIP channel names are not formulated all that well. Let's say
+		 * we have a second Asterisk box which is listed in our sip.conf
+		 * as a peer called "asterisk." This second Asterisk box has two
+		 * SIP phones defined in its sip.conf file called "1000" and "2000"
+		 *
+		 * From here, if we dial 1000 at asterisk, then the resulting channel
+		 * gets the name SIP/asterisk-<sequence>. The same name is what is
+		 * used for when we dial 2000 at asterisk as well.
+		 *
+		 * Since call completion requires finer granularity than this, the
+		 * channel name of a SIP channel is made distinct from the device
+		 * name by specifying p->username @ p->peername. In cases where
+		 * we are not dialing a peer, but rather some hostname, we make the
+		 * device name p->username @ host.
+		 */
+		cp = (char *) data;
+		snprintf(cp, *datalen, "SIP/%s%s%s", S_OR(p->username, ""), ast_strlen_zero(p->username) ? "" : "@", peer_or_host);
+		res = 0;
 	default:
 		break;
 	}
@@ -24476,6 +24514,7 @@
  	char *md5secret = NULL;
  	char *authname = NULL;
 	char *trans = NULL;
+	char dialstring[256];
 	enum sip_transport transport = 0;
 	format_t oldformat = format;
 
@@ -24501,6 +24540,9 @@
 	}
 
 	p->outgoing_call = TRUE;
+
+	snprintf(dialstring, sizeof(dialstring), "%s/%s", type, dest);
+	ast_string_field_set(p, dialstring, dialstring);
 
 	if (!(p->options = ast_calloc(1, sizeof(*p->options)))) {
 		dialog_unlink_all(p, TRUE, TRUE);

Modified: team/group/CCSS/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/sip/include/sip.h?view=diff&rev=246377&r1=246376&r2=246377
==============================================================================
--- team/group/CCSS/channels/sip/include/sip.h (original)
+++ team/group/CCSS/channels/sip/include/sip.h Thu Feb 11 17:58:09 2010
@@ -929,6 +929,7 @@
 		AST_STRING_FIELD(url);          /*!< URL to be sent with next message to peer */
 		AST_STRING_FIELD(parkinglot);   /*!< Parkinglot */
 		AST_STRING_FIELD(engine);       /*!< RTP engine to use */
+		AST_STRING_FIELD(dialstring);   /*!< The dialstring used to call this SIP endpoint */
 	);
 	char via[128];                          /*!< Via: header */
 	struct sip_socket socket;               /*!< The socket used for this dialog */




More information about the asterisk-commits mailing list