summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-12-14 17:28:21 +0000
committerJoshua Colp <jcolp@digium.com>2013-12-14 17:28:21 +0000
commitd7b84b036801d967e4f81bd55349576021679c16 (patch)
treef43c4793ce0ade65186819be0e0581ff60ba81f9 /res/res_pjsip.c
parent3a5cc054ed3efb0733a70a6945880b71506b5757 (diff)
res_pjsip: Apply outbound proxy to all SIP requests.
Objects which are involved in SIP request creation and sending now allow an outbound proxy to be specified. For cases where an endpoint is used the outbound proxy specified there will be applied. (closes issue ASTERISK-22673) Reported by: Antti Yrjola Review: https://reviewboard.asterisk.org/r/3022/ ........ Merged revisions 403811 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403812 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r--res/res_pjsip.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 08c455242..5abb1f32f 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -868,6 +868,13 @@
If <literal>0</literal> never qualify. Time in seconds.
</para></description>
</configOption>
+ <configOption name="outbound_proxy">
+ <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
+ <description><para>
+ If set the provided URI will be used as the outbound proxy when an
+ OPTIONS request is sent to a contact for qualify purposes.
+ </para></description>
+ </configOption>
</configObject>
<configObject name="aor">
<synopsis>The configuration for a location of an endpoint</synopsis>
@@ -964,6 +971,13 @@
authentication is attempted before declaring the contact available.
</para></description>
</configOption>
+ <configOption name="outbound_proxy">
+ <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
+ <description><para>
+ If set the provided URI will be used as the outbound proxy when an
+ OPTIONS request is sent to a contact for qualify purposes.
+ </para></description>
+ </configOption>
</configObject>
<configObject name="system">
<synopsis>Options that apply to the SIP stack as well as other system-wide settings</synopsis>
@@ -1637,6 +1651,15 @@ static int create_out_of_dialog_request(const pjsip_method *method, struct ast_s
return -1;
}
+ /* If an outbound proxy is specified on the endpoint apply it to this request */
+ if (endpoint && !ast_strlen_zero(endpoint->outbound_proxy) &&
+ ast_sip_set_outbound_proxy((*tdata), endpoint->outbound_proxy)) {
+ ast_log(LOG_ERROR, "Unable to apply outbound proxy on request %.*s to endpoint %s\n",
+ (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
+ pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+ return -1;
+ }
+
/* We can release this pool since request creation copied all the necessary
* data into the outbound request's pool
*/
@@ -1713,6 +1736,22 @@ int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct
}
}
+int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
+{
+ pjsip_route_hdr *route;
+ static const pj_str_t ROUTE_HNAME = { "Route", 5 };
+ pj_str_t tmp;
+
+ pj_strdup2_with_null(tdata->pool, &tmp, proxy);
+ if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
+ return -1;
+ }
+
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)route);
+
+ return 0;
+}
+
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
{
pj_str_t hdr_name;