Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c (revision 168600)
+++ channels/chan_sip.c (working copy)
@@ -301,6 +301,32 @@
Always returns 0.
+
+
+ Remove SIP headers previously added with SIPAddHeader
+
+
+
+
+
+ SIPRemoveHeader() allows you to remove headers which were previously
+ added with SIPAddHeader(). If no parameter is supplied, all previously added
+ headers will be removed. If a parameter is supplied, only the matching headers
+ will be removed.
+ For example you have added these 2 headers:
+ SIPAddHeader(P-Asserted-Identity: sip:foo@bar);
+ SIPAddHeader(P-Preferred-Identity: sip:bar@foo);
+
+ // remove all headers
+ SIPRemoveHeader();
+ // remove all P- headers
+ SIPRemoveHeader(P-);
+ // remove only the PAI header (note the : at the end)
+ SIPRemoveHeader(P-Asserted-Identity:);
+
+ Always returns 0.
+
+
Gets the specified SIP header.
@@ -23713,6 +23739,7 @@
static char *app_dtmfmode = "SIPDtmfMode";
static char *app_sipaddheader = "SIPAddHeader";
+static char *app_sipremoveheader = "SIPRemoveHeader";
/*! \brief Set the DTMFmode for an outbound SIP call (application) */
static int sip_dtmfmode(struct ast_channel *chan, void *data)
@@ -23811,6 +23838,38 @@
return 0;
}
+/*! \brief Remove SIP headers added previously with SipAddHeader application */
+static int sip_removeheader(struct ast_channel *chan, void *data)
+{
+ struct ast_var_t *newvariable;
+ struct varshead *headp;
+ int removeall = 0;
+ char *inbuf = (char *) data;
+
+ if (ast_strlen_zero(inbuf)) {
+ removeall = 1;
+ }
+ ast_channel_lock(chan);
+
+ headp=&chan->varshead;
+ AST_LIST_TRAVERSE_SAFE_BEGIN (headp, newvariable, entries) {
+ if (strncasecmp(ast_var_name(newvariable), "SIPADDHEADER", strlen("SIPADDHEADER")) == 0) {
+ if (removeall || (!strncasecmp(ast_var_value(newvariable),inbuf,strlen(inbuf)))) {
+ if (sipdebug)
+ ast_log(LOG_DEBUG,"removing SIP Header \"%s\" as %s\n",
+ ast_var_value(newvariable),
+ ast_var_name(newvariable));
+ AST_LIST_REMOVE_CURRENT(entries);
+ ast_var_delete(newvariable);
+ }
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+
+ ast_channel_unlock(chan);
+ return 0;
+}
+
/*! \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
@@ -24092,6 +24151,7 @@
/* Register dialplan applications */
ast_register_application_xml(app_dtmfmode, sip_dtmfmode);
ast_register_application_xml(app_sipaddheader, sip_addheader);
+ ast_register_application_xml(app_sipremoveheader, sip_removeheader);
/* Register dialplan functions */
ast_custom_function_register(&sip_header_function);
@@ -24153,6 +24213,7 @@
/* Unregister dial plan applications */
ast_unregister_application(app_dtmfmode);
ast_unregister_application(app_sipaddheader);
+ ast_unregister_application(app_sipremoveheader);
/* Unregister CLI commands */
ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));