summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorOlle Johansson <oej@edvina.net>2006-01-23 16:21:51 +0000
committerOlle Johansson <oej@edvina.net>2006-01-23 16:21:51 +0000
commite0fe84d1b274cf69730c18e5ff8902e5c3ff9ae5 (patch)
treeb9eab4275868759d8785e3ebf5f1b50434f63cd2 /channels/chan_sip.c
parent50797d7c05375b28d5ae3967252bc4fdad03965c (diff)
Re-instate sip_addheader() while waiting for a dialplan function. (Issue 6317)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8481 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index aa832ba9d..1ab48e6e2 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -12788,6 +12788,18 @@ static char *synopsis_dtmfmode = "Change the dtmfmode for a SIP call";
static char *descrip_dtmfmode = "SIPDtmfMode(inband|info|rfc2833): Changes the dtmfmode for a SIP call\n";
static char *app_dtmfmode = "SIPDtmfMode";
+static char *app_sipaddheader = "SIPAddHeader";
+static char *synopsis_sipaddheader = "Add a SIP header to the outbound call";
+
+static char *descrip_sipaddheader = ""
+" SIPAddHeader(Header: Content)\n"
+"Adds a header to a SIP call placed with DIAL.\n"
+"Remember to user the X-header if you are adding non-standard SIP\n"
+"headers, like \"X-Asterisk-Accountcode:\". Use this with care.\n"
+"Adding the wrong headers may jeopardize the SIP dialog.\n"
+"Always returns 0\n";
+
+
/*! \brief sip_dtmfmode: change the DTMFmode for a SIP call (application) */
static int sip_dtmfmode(struct ast_channel *chan, void *data)
{
@@ -12838,6 +12850,39 @@ static int sip_dtmfmode(struct ast_channel *chan, void *data)
return 0;
}
+/*! \brief sip_addheader: Add a SIP header */
+static int sip_addheader(struct ast_channel *chan, void *data)
+{
+ int no = 0;
+ int ok = 0;
+ char varbuf[30];
+ char *inbuf = (char *) data;
+
+ if (ast_strlen_zero(inbuf)) {
+ ast_log(LOG_WARNING, "This application requires the argument: Header\n");
+ return 0;
+ }
+ ast_mutex_lock(&chan->lock);
+
+ /* Check for headers */
+ while (!ok && no <= 50) {
+ no++;
+ snprintf(varbuf, sizeof(varbuf), "_SIPADDHEADER%.2d", no);
+
+ if( (pbx_builtin_getvar_helper(chan, (const char *) varbuf) == (const char *) NULL) )
+ ok = 1;
+ }
+ if (ok) {
+ pbx_builtin_setvar_helper (chan, varbuf, inbuf);
+ if (sipdebug)
+ ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
+ } else {
+ ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n");
+ }
+ ast_mutex_unlock(&chan->lock);
+ return 0;
+}
+
/*! \brief sip_sipredirect: Transfer call before connect with a 302 redirect */
/* Called by the transfer() dialplan application through the sip_transfer() */
/* pbx interface function if the call is in ringing state */
@@ -13050,6 +13095,7 @@ int load_module()
/* Register dialplan applications */
ast_register_application(app_dtmfmode, sip_dtmfmode, synopsis_dtmfmode, descrip_dtmfmode);
+ ast_register_application(app_sipaddheader, sip_addheader, synopsis_sipaddheader, descrip_sipaddheader);
/* Register dialplan functions */
ast_custom_function_register(&sip_header_function);
@@ -13085,6 +13131,7 @@ int unload_module()
ast_custom_function_unregister(&checksipdomain_function);
ast_unregister_application(app_dtmfmode);
+ ast_unregister_application(app_sipaddheader);
ast_cli_unregister_multiple(my_clis, sizeof(my_clis) / sizeof(my_clis[0]));