]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Multiple identity headers are partially implemented and duplicating the... identity
authorAndrey Volk <andywolk@gmail.com>
Fri, 28 Jul 2023 15:08:30 +0000 (18:08 +0300)
committerAndrey Volk <andywolk@gmail.com>
Tue, 19 Sep 2023 21:28:16 +0000 (00:28 +0300)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
tests/unit/conf_sip/freeswitch.xml
tests/unit/conf_test/freeswitch.xml
tests/unit/switch_ivr_originate.c

index f58bb40ac06f7191828a79e5bc34fee785660b9e..245ee13367731e4da5be07c35f4fd4f3fd3dc84d 100644 (file)
@@ -6350,7 +6350,8 @@ SWITCH_STANDARD_APP(sofia_stir_shaken_vs_function)
        stir_shaken_cert_t *cert = NULL;
        stir_shaken_error_t stir_error = { 0 };
        switch_status_t claim_status = SWITCH_STATUS_FALSE;
-       const char *identity_header = switch_channel_get_variable(channel, "sip_h_identity");
+       /* sip_identity channel variable is an ARRAY, we support only first identity for now */
+       const char *identity_header = switch_channel_get_variable_dup(channel, "sip_identity", SWITCH_TRUE, 0);
        const char *attestation = NULL;
        int orig_is_tn = 0;
        switch_bool_t hangup_on_fail = switch_true(switch_channel_get_variable(channel, "sip_stir_shaken_vs_hangup_on_fail"));
index c5b5bcc1901505d3392e0e8a9e3384652d4e1517..ddde795ef5921d6b7f04a831e23b62cced10e529 100644 (file)
@@ -11500,9 +11500,6 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                        }
                }
 
-               if (sip->sip_identity && sip->sip_identity->id_value) {
-                       switch_channel_set_variable(channel, "sip_h_identity", sip->sip_identity->id_value);
-               }
                if (sip->sip_date && sip->sip_date->d_time > 0) {
                        // This INVITE has a SIP Date header.
                        // sofia-sip stores the Date header value in sip_date->d_time as seconds since January 1, 1900 0:00:00.
index eceae218f8d55be2058e785529ed1fc7b7d3b55f..86027da1c0c7c6e44619a6c39aeff52d8fb3aca8 100644 (file)
@@ -1144,7 +1144,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                identity = identity_to_free = sofia_stir_shaken_as_create_identity_header(tech_pvt->session, stir_shaken_attest, cid_num, dest);
        }
        if (!identity) {
-               identity = switch_channel_get_variable(channel, "sip_h_identity");
+               /* sip_identity channel variable is an ARRAY, we support only first identity for now */
+               identity = switch_channel_get_variable_dup(channel, "sip_identity", SWITCH_TRUE, 0);
        }
        if (!date) {
                date = switch_channel_get_variable(channel, "sip_h_date");
index 9a992a817b358f44e05fc4f2f365beb0bb2f1104..6cb5a8f9e6cbc52c2797a38036cd0dc27b3ff709 100644 (file)
     <context name="default">
                <extension name="two">
                        <condition field="destination_number" expression="^\+15553332901$">
-                               <action application="log" data="${sip_h_identity}"/>
-                               <action application="hash" data="insert/realm/identity_check/${sip_h_identity}"/>
+                               <action application="log" data="${sip_identity}"/>
+                               <action application="hash" data="insert/realm/identity_check/${sip_identity}"/>
                                <action application="answer"/>
                                <action application="park"/>
                        </condition>
index 9097246041aa54b903986b06dfd13888951a02d6..f94df9bb3e59649c34f486274138087724cb88d9 100644 (file)
     <context name="default">
                <extension name="two">
                        <condition field="destination_number" expression="^\+15553332901$">
-                               <action application="log" data="${sip_h_identity}"/>
-                               <action application="hash" data="insert/realm/identity_check/${sip_h_identity}"/>
+                               <action application="log" data="${sip_identity}"/>
+                               <action application="hash" data="insert/realm/identity_check/${sip_identity}"/>
                                <action application="answer"/>
                                <action application="park"/>
                        </condition>
index 5603e18f0ecfe0f049ba640f0d3b4a39c2fe73ad..8c257450b6f967e5c86addc606b2815205c5ec6e 100644 (file)
@@ -113,6 +113,20 @@ FST_CORE_BEGIN("./conf")
                }
                FST_TEARDOWN_END()
 
+               FST_SESSION_BEGIN(test_var_array)
+               {
+                       const char *identity;
+
+                       switch_channel_add_variable_var_check(fst_channel, "sip_identity", "test", SWITCH_FALSE, SWITCH_STACK_PUSH);
+                       identity = switch_channel_get_variable_dup(fst_channel, "sip_identity", SWITCH_TRUE, 0);
+                       fst_check_string_equals(identity, "test");
+
+                       switch_channel_add_variable_var_check(fst_channel, "sip_identity", "test2", SWITCH_FALSE, SWITCH_STACK_PUSH);
+                       identity = switch_channel_get_variable_dup(fst_channel, "sip_identity", SWITCH_TRUE, 0);
+                       fst_check_string_equals(identity, "test");
+               }
+               FST_SESSION_END()
+
                FST_TEST_BEGIN(originate_test_external_id)
                {
                        switch_core_session_t *session = NULL;