[asterisk-commits] mmichelson: branch mmichelson/trunk-digiumphones r362866 - /team/mmichelson/t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 20 10:50:16 CDT 2012


Author: mmichelson
Date: Fri Apr 20 10:50:14 2012
New Revision: 362866

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=362866
Log:
Add test dialplan application to send custom SIP INFO requests.


Modified:
    team/mmichelson/trunk-digiumphones/channels/chan_sip.c

Modified: team/mmichelson/trunk-digiumphones/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/channels/chan_sip.c?view=diff&rev=362866&r1=362865&r2=362866
==============================================================================
--- team/mmichelson/trunk-digiumphones/channels/chan_sip.c (original)
+++ team/mmichelson/trunk-digiumphones/channels/chan_sip.c Fri Apr 20 10:50:14 2012
@@ -338,6 +338,20 @@
 			<para>SIPRemoveHeader(P-Asserted-Identity:);</para>
 			<para></para>
 			<para>Always returns <literal>0</literal>.</para>
+		</description>
+	</application>
+	<application name="SIPSendCustomINFO" language="en_US">
+		<synopsis>
+			Send a custom INFO frame on specified channels.
+		</synopsis>
+		<syntax>
+			<parameter name="Data" required="true" />
+			<parameter name="UserAgent" required="false" />
+		</syntax>
+		<description>
+			<para>SIPSendCustomINFO() allows you to send a custom INFO message on all
+			active SIP channels or on channels with the specified User Agent. This
+			application is only available if TEST_FRAMEWORK is defined.</para>
 		</description>
 	</application>
 	<function name="SIP_HEADER" language="en_US">
@@ -30625,6 +30639,9 @@
 static char *app_dtmfmode = "SIPDtmfMode";
 static char *app_sipaddheader = "SIPAddHeader";
 static char *app_sipremoveheader = "SIPRemoveHeader";
+#ifdef TEST_FRAMEWORK
+static char *app_sipsendcustominfo = "SIPSendCustomINFO";
+#endif
 
 /*! \brief Set the DTMFmode for an outbound SIP call (application) */
 static int sip_dtmfmode(struct ast_channel *chan, const char *data)
@@ -30752,6 +30769,32 @@
 	ast_channel_unlock(chan);
 	return 0;
 }
+
+#ifdef TEST_FRAMEWORK
+/*! \brief Send a custom INFO message via AST_CONTROL_CUSTOM indication */
+static int sip_sendcustominfo(struct ast_channel *chan, const char *data)
+{
+	char *info_data, *useragent;
+	struct ast_custom_payload *pl = NULL;
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, "You must provide data to be sent\n");
+		return 0;
+	}
+
+	useragent = ast_strdupa(data);
+	info_data = strsep(&useragent, ",");
+
+	if (!(pl = ast_custom_payload_sipinfo_encode(NULL, "text/plain", info_data, useragent))) {
+		ast_log(LOG_WARNING, "Failed to create payload for custom SIP INFO\n");
+		return 0;
+	}
+
+	ast_indicate_data(chan, AST_CONTROL_CUSTOM, pl, ast_custom_payload_len(pl));
+	ast_free(pl);
+	return 0;
+}
+#endif
 
 /*! \brief Transfer call before connect with a 302 redirect
 \note	Called by the transfer() dialplan application through the sip_transfer()
@@ -31712,6 +31755,9 @@
 	ast_register_application_xml(app_dtmfmode, sip_dtmfmode);
 	ast_register_application_xml(app_sipaddheader, sip_addheader);
 	ast_register_application_xml(app_sipremoveheader, sip_removeheader);
+#ifdef TEST_FRAMEWORK
+	ast_register_application_xml(app_sipsendcustominfo, sip_sendcustominfo);
+#endif
 
 	/* Register dialplan functions */
 	ast_custom_function_register(&sip_header_function);
@@ -31804,8 +31850,9 @@
 	ast_unregister_application(app_dtmfmode);
 	ast_unregister_application(app_sipaddheader);
 	ast_unregister_application(app_sipremoveheader);
-
 #ifdef TEST_FRAMEWORK
+	ast_unregister_application(app_sipsendcustominfo);
+
 	AST_TEST_UNREGISTER(test_sip_peers_get);
 	AST_TEST_UNREGISTER(test_sip_mwi_subscribe_parse);
 #endif




More information about the asterisk-commits mailing list