summaryrefslogtreecommitdiff
path: root/res/res_pjsip/location.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-04-18 17:02:24 +0000
committerMark Michelson <mmichelson@digium.com>2014-04-18 17:02:24 +0000
commitf5b8ab445f7d3638557afc98eb08a8e0445a58d3 (patch)
tree9708c03653c34d953d604f4423c43c1bead9be43 /res/res_pjsip/location.c
parent51b6c49681c17d260aebc67e618f996b9a7f1176 (diff)
Allow for multiple contacts to be configured in a single contact= line.
This is useful for configuring multiple permanent contacts for an AOR when using realtime AORs. Review: https://reviewboard.asterisk.org/r/3462 ........ Merged revisions 412582 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412584 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip/location.c')
-rw-r--r--res/res_pjsip/location.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 0c7338a98..146a02d59 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -290,31 +290,37 @@ static int permanent_uri_handler(const struct aco_option *opt, struct ast_variab
{
struct ast_sip_aor *aor = obj;
const char *aor_id = ast_sorcery_object_get_id(aor);
- struct ast_sip_contact *contact;
- char contact_id[strlen(aor_id) + strlen(var->value) + 2 + 1];
+ char *contacts = ast_strdupa(var->value);
+ char *contact_uri;
- if (ast_sip_push_task_synchronous(NULL, permanent_contact_validate, (char *) var->value)) {
- ast_log(LOG_ERROR, "Permanent URI on aor '%s' with contact '%s' failed to parse\n",
- aor_id, var->value);
- return -1;
- }
+ while ((contact_uri = strsep(&contacts, ","))) {
+ struct ast_sip_contact *contact;
+ char contact_id[strlen(aor_id) + strlen(contact_uri) + 2 + 1];
+
+ if (ast_sip_push_task_synchronous(NULL, permanent_contact_validate, contact_uri)) {
+ ast_log(LOG_ERROR, "Permanent URI on aor '%s' with contact '%s' failed to parse\n",
+ ast_sorcery_object_get_id(aor), contact_uri);
+ return -1;
+ }
- if (!aor->permanent_contacts) {
- aor->permanent_contacts = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK,
- AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, permanent_uri_sort_fn, NULL);
if (!aor->permanent_contacts) {
+ aor->permanent_contacts = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK,
+ AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, permanent_uri_sort_fn, NULL);
+ if (!aor->permanent_contacts) {
+ return -1;
+ }
+ }
+
+ snprintf(contact_id, sizeof(contact_id), "%s@@%s", aor_id, contact_uri);
+ contact = ast_sorcery_alloc(ast_sip_get_sorcery(), "contact", contact_id);
+ if (!contact) {
return -1;
}
- }
- snprintf(contact_id, sizeof(contact_id), "%s@@%s", aor_id, var->value);
- contact = ast_sorcery_alloc(ast_sip_get_sorcery(), "contact", contact_id);
- if (!contact) {
- return -1;
+ ast_string_field_set(contact, uri, contact_uri);
+ ao2_link(aor->permanent_contacts, contact);
+ ao2_ref(contact, -1);
}
- ast_string_field_set(contact, uri, var->value);
- ao2_link(aor->permanent_contacts, contact);
- ao2_ref(contact, -1);
return 0;
}