summaryrefslogtreecommitdiff
path: root/res/res_pjsip
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
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')
-rw-r--r--res/res_pjsip/location.c6
-rw-r--r--res/res_pjsip/pjsip_options.c10
2 files changed, 16 insertions, 0 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 14f58552a..ddd846123 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -193,6 +193,10 @@ int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri, struc
contact->qualify_frequency = aor->qualify_frequency;
contact->authenticate_qualify = aor->authenticate_qualify;
+ if (!ast_strlen_zero(aor->outbound_proxy)) {
+ ast_string_field_set(contact, outbound_proxy, aor->outbound_proxy);
+ }
+
return ast_sorcery_create(ast_sip_get_sorcery(), contact);
}
@@ -388,6 +392,7 @@ int ast_sip_initialize_sorcery_location(struct ast_sorcery *sorcery)
ast_sorcery_object_field_register_custom(sorcery, "contact", "expiration_time", "", expiration_str2struct, expiration_struct2str, 0, 0);
ast_sorcery_object_field_register(sorcery, "contact", "qualify_frequency", 0, OPT_UINT_T,
PARSE_IN_RANGE, FLDSET(struct ast_sip_contact, qualify_frequency), 0, 86400);
+ ast_sorcery_object_field_register(sorcery, "contact", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, outbound_proxy));
ast_sorcery_object_field_register(sorcery, "aor", "type", "", OPT_NOOP_T, 0, 0);
ast_sorcery_object_field_register(sorcery, "aor", "minimum_expiration", "60", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, minimum_expiration));
@@ -399,6 +404,7 @@ int ast_sip_initialize_sorcery_location(struct ast_sorcery *sorcery)
ast_sorcery_object_field_register(sorcery, "aor", "remove_existing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, remove_existing));
ast_sorcery_object_field_register_custom(sorcery, "aor", "contact", "", permanent_uri_handler, NULL, 0, 0);
ast_sorcery_object_field_register(sorcery, "aor", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, mailboxes));
+ ast_sorcery_object_field_register(sorcery, "aor", "outbound_proxy", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_aor, outbound_proxy));
ast_sip_register_endpoint_formatter(&endpoint_aor_formatter);
return 0;
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 8d46eb036..0409c1557 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -258,6 +258,15 @@ static int qualify_contact(struct ast_sip_contact *contact)
return -1;
}
+ /* If an outbound proxy is specified set it on this request */
+ if (!ast_strlen_zero(contact->outbound_proxy) &&
+ ast_sip_set_outbound_proxy(tdata, contact->outbound_proxy)) {
+ pjsip_tx_data_dec_ref(tdata);
+ ast_log(LOG_ERROR, "Unable to apply outbound proxy on request to qualify contact %s\n",
+ contact->uri);
+ return -1;
+ }
+
init_start_time(contact);
ao2_ref(contact, +1);
@@ -795,6 +804,7 @@ static int qualify_and_schedule_cb(void *obj, void *arg, int flags)
struct ast_sip_aor *aor = arg;
contact->qualify_frequency = aor->qualify_frequency;
+
qualify_and_schedule(contact);
return 0;