mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-26 22:30:28 +00:00
Add a test application for sending custom SIP INFO messages.
When TEST_FRAMEWORK is enabled, SIPSendCustomInfo is available to test sending custom INFO requests. Review: https://reviewboard.asterisk.org/r/1866 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8-digiumphones@362673 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -339,6 +339,20 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
<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">
|
||||
<synopsis>
|
||||
Gets the specified SIP header from an incoming INVITE message.
|
||||
@@ -29697,6 +29711,9 @@ static struct ast_rtp_glue sip_rtp_glue = {
|
||||
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)
|
||||
@@ -29824,6 +29841,32 @@ static int sip_removeheader(struct ast_channel *chan, const char *data)
|
||||
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()
|
||||
pbx interface function if the call is in ringing state
|
||||
@@ -30757,6 +30800,9 @@ static int load_module(void)
|
||||
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);
|
||||
@@ -30849,8 +30895,9 @@ static int unload_module(void)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user