]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Apply AOR outbound proxy to static contacts.
authorJoshua C. Colp <jcolp@sangoma.com>
Fri, 26 Jun 2020 10:18:55 +0000 (07:18 -0300)
committerJoshua C. Colp <jcolp@sangoma.com>
Fri, 26 Jun 2020 10:38:06 +0000 (07:38 -0300)
The outbound proxy for an AOR was not being applied to
any statically configured Contacts. This resulted in the
OPTIONS requests being sent to the wrong target.

This change sets the outbound proxy on statically configured
contacts once the AOR configuration is done being
applied.

ASTERISK-28965

Change-Id: Ia60f3e93ea63f819c5a46bc8b54be2e588dfa9e0

res/res_pjsip/location.c

index 2a173dabd9885f871a6f6ef80262e468cc49c856..68ea83b47e79d9dd5c7af33e03108ef8b4f0a525 100644 (file)
@@ -1289,6 +1289,29 @@ static int contact_apply_handler(const struct ast_sorcery *sorcery, void *object
        return status ? 0 : -1;
 }
 
+static int aor_apply_outbound_proxy(void *obj, void *arg, int flags)
+{
+       struct ast_sip_contact *contact = obj;
+       struct ast_sip_aor *aor = arg;
+
+       ast_string_field_set(contact, outbound_proxy, aor->outbound_proxy);
+
+       return 0;
+}
+
+static int aor_apply_handler(const struct ast_sorcery *sorcery, void *object)
+{
+       struct ast_sip_aor *aor = object;
+
+       if (!aor->permanent_contacts || ast_strlen_zero(aor->outbound_proxy)) {
+               return 0;
+       }
+
+       ao2_callback(aor->permanent_contacts, OBJ_NODATA | OBJ_MULTIPLE, aor_apply_outbound_proxy, aor);
+
+       return 0;
+}
+
 /*! \brief Initialize sorcery with location support */
 int ast_sip_initialize_sorcery_location(void)
 {
@@ -1305,7 +1328,7 @@ int ast_sip_initialize_sorcery_location(void)
        ast_sorcery_apply_default(sorcery, "aor", "config", "pjsip.conf,criteria=type=aor");
 
        if (ast_sorcery_object_register(sorcery, "contact", contact_alloc, NULL, contact_apply_handler) ||
-               ast_sorcery_object_register(sorcery, "aor", aor_alloc, NULL, NULL)) {
+               ast_sorcery_object_register(sorcery, "aor", aor_alloc, NULL, aor_apply_handler)) {
                return -1;
        }