[asterisk-commits] tilghman: trunk r122802 - in /trunk: ./ channels/ funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jun 15 10:21:17 CDT 2008


Author: tilghman
Date: Sun Jun 15 10:21:16 2008
New Revision: 122802

URL: http://svn.digium.com/view/asterisk?view=rev&rev=122802
Log:
Add some more IAX2-specific information about the channel to the CHANNEL()
function and begin the transition from SIPCHANINFO() to just using CHANNEL().
(closes issue #12856)
 Reported by: mostyn
 Patches: 
       iax_and_sip_channel_info.patch uploaded by mostyn (license 398)
       (with some additional cleanup by me)

Modified:
    trunk/UPGRADE.txt
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/funcs/func_channel.c

Modified: trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/trunk/UPGRADE.txt?view=diff&rev=122802&r1=122801&r2=122802
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Sun Jun 15 10:21:16 2008
@@ -181,6 +181,9 @@
 	sip:defaultuser at defaultip
   The "username" setting still work, but is deprecated and will not work in 
   the next version of Asterisk.
+* SIP: All of the functionality in SIPCHANINFO() has been implemented in CHANNEL(),
+  and you should start using that function instead for retrieving information about
+  the channel in a technology-agnostic way.
 
 * chan_local.c: the comma delimiter inside the channel name has been changed to a
   semicolon, in order to make the Local channel driver compatible with the comma

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=122802&r1=122801&r2=122802
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sun Jun 15 10:21:16 2008
@@ -11749,10 +11749,15 @@
 		return -1;
 	}
 
-	if (!strcasecmp(args, "osptoken"))
+	if (!strcasecmp(args, "osptoken")) {
 		ast_copy_string(buf, pvt->osptoken, buflen);
-	else
+	} else if (!strcasecmp(args, "peerip")) {
+		ast_copy_string(buf, pvt->addr.sin_addr.s_addr ? ast_inet_ntoa(pvt->addr.sin_addr) : "", buflen);
+	} else if (!strcasecmp(args, "peername")) {
+		ast_copy_string(buf, pvt->username, buflen);
+	} else {
 		res = -1;
+	}
 
 	ast_mutex_unlock(&iaxsl[callno]);
 

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=122802&r1=122801&r2=122802
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sun Jun 15 10:21:16 2008
@@ -15510,6 +15510,7 @@
 static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
 	struct sip_pvt *p;
+	static int deprecated = 0;
 
 	*buf = 0;
 	
@@ -15523,6 +15524,11 @@
 		ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
 		ast_channel_unlock(chan);
 		return -1;
+	}
+
+	if (deprecated++ % 20 == 0) {
+		/* Deprecated in 1.6.1 */
+		ast_log(LOG_WARNING, "SIPCHANINFO() is deprecated.  Please transition to using CHANNEL().\n");
 	}
 
 	p = chan->tech_pvt;
@@ -18524,7 +18530,25 @@
 
 	memset(buf, 0, buflen);
 
-	if (!strcasecmp(args.param, "rtpdest")) {
+	if (!strcasecmp(args.param, "peerip")) {
+		ast_copy_string(buf, p->sa.sin_addr.s_addr ? ast_inet_ntoa(p->sa.sin_addr) : "", buflen);
+	} else if (!strcasecmp(args.param, "recvip")) {
+		ast_copy_string(buf, p->recv.sin_addr.s_addr ? ast_inet_ntoa(p->recv.sin_addr) : "", buflen);
+	} else if (!strcasecmp(args.param, "from")) {
+		ast_copy_string(buf, p->from, buflen);
+	} else if (!strcasecmp(args.param, "uri")) {
+		ast_copy_string(buf, p->uri, buflen);
+	} else if (!strcasecmp(args.param, "useragent")) {
+		ast_copy_string(buf, p->useragent, buflen);
+	} else if (!strcasecmp(args.param, "peername")) {
+		ast_copy_string(buf, p->peername, buflen);
+	} else if (!strcasecmp(args.param, "t38passthrough")) {
+		if (p->t38.state == T38_DISABLED) {
+			ast_copy_string(buf, "0", sizeof("0"));
+		} else {  /* T38 is offered or enabled in this call */
+			ast_copy_string(buf, "1", sizeof("1"));
+		}
+	} else if (!strcasecmp(args.param, "rtpdest")) {
 		struct sockaddr_in sin;
 
 		if (ast_strlen_zero(args.type))

Modified: trunk/funcs/func_channel.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_channel.c?view=diff&rev=122802&r1=122801&r2=122802
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Sun Jun 15 10:21:16 2008
@@ -190,6 +190,13 @@
 #endif
 		"\n"
 		"chan_sip provides the following additional options:\n"
+		"R/O    peerip             Get the IP address of the peer\n"
+		"R/O    recvip             Get the source IP address of the peer\n"
+		"R/O    from               Get the URI from the From: header\n"
+		"R/O    uri                Get the URI from the Contact: header\n"
+		"R/O    useragent          Get the useragent\n"
+		"R/O    peername           Get the name of the peer\n"
+		"R/O    t38passthrough     1 if T38 is offered or enabled in this channel, otherwise 0\n"
 		"R/O    rtpqos             Get QOS information about the RTP stream\n"
 		"       This option takes two additional arguments:\n"
 		"  Argument 1:\n"
@@ -227,6 +234,8 @@
 		"\n"
 		"chan_iax2 provides the following additional options:\n"
 		"R/W    osptoken           Get or set the OSP token information for a call\n"
+		"R/O    peerip             Get the peer's ip address\n"
+		"R/O    peername           Get the peer's username\n"
 		"\n"
 		"Additional items may be available from the channel driver providing\n"
 		"the channel; see its documentation for details.\n"




More information about the asterisk-commits mailing list