]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Cleanup usage of sofia-sip headers. 767/head
authorAndrey Volk <andywolk@gmail.com>
Fri, 31 Jul 2020 22:52:19 +0000 (02:52 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 3 Aug 2020 18:15:19 +0000 (22:15 +0400)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sip-dig.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 84da642aff60a99dd7a0a79e9d81c6cb8dfc6a12..e236b09a38627848808f583faac5210eb27fe2e8 100644 (file)
@@ -2456,7 +2456,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                /* Set sip_to_tag to local tag for inbound channels. */
                                if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
                                        const char* to_tag = "";
-                                       to_tag = switch_str_nil(nta_leg_get_tag(tech_pvt->nh->nh_ds->ds_leg));
+                                       to_tag = switch_str_nil(nta_leg_get_tag(nua_get_dialog_state_leg(tech_pvt->nh)));
                                        if(to_tag) {
                                                switch_channel_set_variable(channel, "sip_to_tag", to_tag);
                                        }
@@ -5251,7 +5251,7 @@ static int notify_csta_callback(void *pArg, int argc, char **argv, char **column
 
        //nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
        nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(full_to), SIPTAG_TO_STR(full_from), SIPTAG_CONTACT_STR(profile->url), TAG_END());
-       cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY);
+       cseq = sip_cseq_create(nua_handle_get_home(nh), callsequence, SIP_METHOD_NOTIFY);
 
        nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
 
index 05e50c952f206da4e4c7cc079df4e65497bae07f..324953373053f0afa29f21adec8b4cc8a9dc3a4f 100644 (file)
@@ -142,7 +142,6 @@ typedef struct private_object private_object_t;
 #include <sofia-sip/msg_addr.h>
 #include <sofia-sip/tport_tag.h>
 #include <sofia-sip/sip_extra.h>
-#include "nua_stack.h"
 #include "sofia-sip/msg_parser.h"
 #include "sofia-sip/sip_parser.h"
 #include "sofia-sip/tport_tag.h"
index 2c87f231d3b29b3789bbaae7cdd9c311070313ac..2d74eb66f686b2e9daa738095cf74ed06ed46479 100644 (file)
 
 
 #include "switch.h"
-#ifndef WIN32
-#include "../../config.h"
-#endif
 
 #include "sofia-sip/su.h"
 
index a3344fc323d12c0691d5b113f12190e84f73f141..bceec9d9060fe658a312df1daad8557370cc5a10 100644 (file)
@@ -237,9 +237,9 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
                                SWITCH_STANDARD_STREAM(stream);
 
                                for (rp = sip->sip_route; rp; rp = rp->r_next) {
-                                       char *route = sip_header_as_string(nh->nh_home, (void *) rp);
+                                       char *route = sip_header_as_string(nua_handle_get_home(nh), (void *) rp);
                                        stream.write_function(&stream, x == 0 ? "%s" : ",%s", route);
-                                       su_free(nh->nh_home, route);
+                                       su_free(nua_handle_get_home(nh), route);
                                        x++;
                                }
                                switch_channel_set_variable(channel, "sip_full_route", stream.data);
@@ -249,9 +249,9 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
 
                if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
                        if (sip->sip_contact) {
-                               char *c = sip_header_as_string(nh->nh_home, (void *) sip->sip_contact);
+                               char *c = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_contact);
                                switch_channel_set_variable(channel, "sip_recover_contact", c);
-                               su_free(nh->nh_home, c);
+                               su_free(nua_handle_get_home(nh), c);
                        }
                }
 
@@ -267,7 +267,7 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
                        SWITCH_STANDARD_STREAM(reverse_stream);
 
                        for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) {
-                               char *rr = sip_header_as_string(nh->nh_home, (void *) rrp);
+                               char *rr = sip_header_as_string(nua_handle_get_home(nh), (void *) rrp);
                                forward_stream.write_function(&forward_stream, x == 0 ? "%s" : ",%s", rr);
                                tmp[y++] = rr;
                                if (y == 127) break;
@@ -280,7 +280,7 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
 
                        while(y >= 0) {
                                reverse_stream.write_function(&reverse_stream, x == 0 ? "%s" : ",%s", tmp[y]);
-                               su_free(nh->nh_home, tmp[y]);
+                               su_free(nua_handle_get_home(nh), tmp[y]);
                                y--;
                                x++;
                        }
@@ -305,10 +305,10 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
                        SWITCH_STANDARD_STREAM(stream);
 
                        for(vp = sip->sip_via; vp; vp = vp->v_next) {
-                               char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                               char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
 
                                stream.write_function(&stream, x == 0 ? "%s" : ",%s", v);
-                               su_free(nh->nh_home, v);
+                               su_free(nua_handle_get_home(nh), v);
 
                                x++;
                        }
@@ -330,9 +330,9 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
                                switch_channel_set_variable(channel, "sip_from_display", p);
                        }
                        if (p != sip->sip_from->a_display) free(p);
-                       if ((full = sip_header_as_string(nh->nh_home, (void *) sip->sip_from))) {
+                       if ((full = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_from))) {
                                switch_channel_set_variable(channel, "sip_full_from", full);
-                               su_free(nh->nh_home, full);
+                               su_free(nua_handle_get_home(nh), full);
                        }
                }
 
@@ -345,9 +345,9 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
 
                        if (p != sip->sip_to->a_display) free(p);
 
-                       if ((full = sip_header_as_string(nh->nh_home, (void *) sip->sip_to))) {
+                       if ((full = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_to))) {
                                switch_channel_set_variable(channel, "sip_full_to", full);
-                               su_free(nh->nh_home, full);
+                               su_free(nua_handle_get_home(nh), full);
                        }
                }
 
@@ -398,9 +398,9 @@ static void sofia_add_invite_header_to_chanvars(switch_channel_t *channel, nua_h
 
        if (sip_header) {
                char *full;
-               if ((full = sip_header_as_string(nh->nh_home, sip_header))) {
+               if ((full = sip_header_as_string(nua_handle_get_home(nh), sip_header))) {
                        switch_channel_set_variable(channel, var, full);
-                       su_free(nh->nh_home, full);
+                       su_free(nua_handle_get_home(nh), full);
                }
        }
 }
@@ -464,99 +464,99 @@ static void sofia_parse_all_invite_headers(sip_t const *sip, switch_core_session
        if (sip->sip_via) {
                sip_via_t *vp;
                for (vp = sip->sip_via; vp; vp = vp->v_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_via", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if (sip->sip_record_route) {
                sip_record_route_t *rrp;
                for (rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) {
-                       char *rr = sip_header_as_string(nh->nh_home, (void *) rrp);
+                       char *rr = sip_header_as_string(nua_handle_get_home(nh), (void *) rrp);
                        switch_channel_add_variable_var_check(channel, "sip_i_record_route", rr, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, rr);
+                       su_free(nua_handle_get_home(nh), rr);
                }
        }
 
        if (sip->sip_proxy_authorization) {
                sip_proxy_authorization_t *vp;
                for (vp = sip->sip_proxy_authorization; vp; vp = vp->au_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_proxy_authorization", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if (sip->sip_call_info) {
                sip_call_info_t *vp;
                for (vp = sip->sip_call_info; vp; vp = vp->ci_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_call_info", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if (sip->sip_accept) {
                sip_accept_t *vp;
                for (vp = sip->sip_accept; vp; vp = vp->ac_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_accept", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if (sip->sip_authorization) {
                sip_authorization_t *vp;
                for (vp = sip->sip_authorization; vp; vp = vp->au_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_authorization", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if ((alert_info = sip_alert_info(sip))) {
                sip_alert_info_t *vp;
                for (vp = alert_info; vp; vp = vp->ai_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_alert_info", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if ((passerted = sip_p_asserted_identity(sip))) {
                sip_p_asserted_identity_t *vp;
                for (vp = passerted; vp; vp = vp->paid_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_p_asserted_identity", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if ((ppreferred = sip_p_preferred_identity(sip))) {
                sip_p_preferred_identity_t *vp;
                for (vp = ppreferred; vp; vp = vp->ppid_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_p_preferred_identity", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if ((rpid = sip_remote_party_id(sip))) {
                sip_remote_party_id_t *vp;
                for (vp = rpid; vp; vp = vp->rpid_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_remote_party_id", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
        if ((reply_to = sip_reply_to(sip))) {
                sip_reply_to_t *vp;
                for (vp = reply_to; vp; vp = vp->rplyto_next) {
-                       char *v = sip_header_as_string(nh->nh_home, (void *) vp);
+                       char *v = sip_header_as_string(nua_handle_get_home(nh), (void *) vp);
                        switch_channel_add_variable_var_check(channel, "sip_i_reply_to", v, SWITCH_FALSE, SWITCH_STACK_PUSH);
-                       su_free(nh->nh_home, v);
+                       su_free(nua_handle_get_home(nh), v);
                }
        }
 
@@ -1031,7 +1031,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
        call_info = switch_channel_get_variable(channel, "presence_call_info_full");
 
        if (sip->sip_reason) {
-               char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
+               char *reason_header = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_reason);
 
                if (!zstr(reason_header)) {
                        switch_channel_set_variable(channel, "sip_reason", reason_header);
@@ -1641,7 +1641,7 @@ static void our_sofia_event_callback(nua_event_t event,
 
        if (sip && sip->sip_payload && sip->sip_payload->pl_data) {
                if (sip->sip_payload->pl_len != strlen(sip->sip_payload->pl_data)) {
-                       sip->sip_payload->pl_data = su_strndup(nh->nh_home, sip->sip_payload->pl_data, sip->sip_payload->pl_len);
+                       sip->sip_payload->pl_data = su_strndup(nua_handle_get_home(nh), sip->sip_payload->pl_data, sip->sip_payload->pl_len);
                }
        }
 
@@ -1669,7 +1669,7 @@ static void our_sofia_event_callback(nua_event_t event,
                        switch_channel_set_variable(channel, "sip_invite_failure_phrase", "CANCEL");
 
                        if (sip->sip_reason) {
-                               char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
+                               char *reason_header = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_reason);
 
                                if (!zstr(reason_header)) {
                                        switch_channel_set_variable(channel, "sip_reason", reason_header);
@@ -1997,11 +1997,11 @@ static void our_sofia_event_callback(nua_event_t event,
                                contact_str = sofia_glue_gen_contact_str(profile, sip, nh, de, &np);
 
                                call_id = sip->sip_call_id ? sip->sip_call_id->i_id : "";
-                               full_from = sip_header_as_string(nh->nh_home, (void *) sip->sip_from);
-                               full_to = sip_header_as_string(nh->nh_home, (void *) sip->sip_to);
-                               full_via = sip_header_as_string(nh->nh_home, (void *) sip->sip_via);
+                               full_from = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_from);
+                               full_to = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_to);
+                               full_via = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_via);
 
-                               full_agent = sip_header_as_string(nh->nh_home, (void *) sip->sip_user_agent);
+                               full_agent = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_user_agent);
 
                                switch_stun_random_string(to_tag, 12, NULL);
 
@@ -2048,7 +2048,7 @@ static void our_sofia_event_callback(nua_event_t event,
 
                                sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
 
-                               sip_to_tag(nh->nh_home, sip->sip_to, to_tag);
+                               sip_to_tag(nua_handle_get_home(nh), sip->sip_to, to_tag);
                        }
 
                        nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_TO(sip->sip_to), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
@@ -2271,14 +2271,14 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
                                                         de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
 
        nua_destroy_event(de->event);
-       su_free(nh->nh_home, de);
+       su_free(nua_handle_get_home(nh), de);
 
        switch_mutex_lock(profile->flag_mutex);
        profile->queued_events--;
        switch_mutex_unlock(profile->flag_mutex);
 
        nua_handle_unref(nh);
-       nua_stack_unref(nua);
+       nua_unref(nua);
 }
 
 
@@ -2503,20 +2503,20 @@ void sofia_event_callback(nua_event_t event,
        profile->queued_events++;
        switch_mutex_unlock(profile->flag_mutex);
 
-       de = su_alloc(nh->nh_home, sizeof(*de));
+       de = su_alloc(nua_handle_get_home(nh), sizeof(*de));
        memset(de, 0, sizeof(*de));
        nua_save_event(nua, de->event);
        de->nh = nua_handle_ref(nh);
        de->data = nua_event_data(de->event);
        de->sip = sip_object(de->data->e_msg);
        de->profile = profile;
-       de->nua = nua_stack_ref(nua);
+       de->nua = (nua_t *)su_home_ref(nua_get_home(nua));
 
        if (event == nua_i_invite && !sofia_private) {
                switch_core_session_t *session;
                private_object_t *tech_pvt = NULL;
 
-               if (!(sofia_private = su_alloc(nh->nh_home, sizeof(*sofia_private)))) {
+               if (!(sofia_private = su_alloc(nua_handle_get_home(nh), sizeof(*sofia_private)))) {
                        abort();
                }
 
@@ -2563,14 +2563,14 @@ void sofia_event_callback(nua_event_t event,
                if (!sip || !sip->sip_call_id || zstr(sip->sip_call_id->i_id)) {
                        nua_respond(nh, 503, "INVALID INVITE", TAG_END());
                        nua_destroy_event(de->event);
-                       su_free(nh->nh_home, de);
+                       su_free(nua_handle_get_home(nh), de);
 
                        switch_mutex_lock(profile->flag_mutex);
                        profile->queued_events--;
                        switch_mutex_unlock(profile->flag_mutex);
 
                        nua_handle_unref(nh);
-                       nua_stack_unref(nua);
+                       nua_unref(nua);
 
                        goto end;
                }
@@ -2601,14 +2601,14 @@ void sofia_event_callback(nua_event_t event,
                } else {
                        nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
                        nua_destroy_event(de->event);
-                       su_free(nh->nh_home, de);
+                       su_free(nua_handle_get_home(nh), de);
 
                        switch_mutex_lock(profile->flag_mutex);
                        profile->queued_events--;
                        switch_mutex_unlock(profile->flag_mutex);
 
                        nua_handle_unref(nh);
-                       nua_stack_unref(nua);
+                       nua_unref(nua);
 
                        goto end;
                }
@@ -3326,7 +3326,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name);
 
        if (sofia_test_pflag(profile, PFLAG_AUTO_ASSIGN_PORT) || sofia_test_pflag(profile, PFLAG_AUTO_ASSIGN_TLS_PORT)) {
-               sip_via_t *vias = nta_agent_via(profile->nua->nua_nta);
+               sip_via_t *vias = nta_agent_via(nua_get_agent(profile->nua));
                sip_via_t *via = NULL;
 
                for (via = vias; via; via = via->v_next) {
@@ -9620,9 +9620,9 @@ switch_status_t sofia_proxy_sip_i_message(nua_t *nua, sofia_profile_t *profile,
                        }
 
                        nua_message(other_tech_pvt->nh,
-                                               TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(su_strdup(other_tech_pvt->nh->nh_home, ct))),
+                                               TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(su_strdup(nua_handle_get_home(other_tech_pvt->nh), ct))),
                                                TAG_IF(!zstr(other_tech_pvt->user_via), SIPTAG_VIA_STR(other_tech_pvt->user_via)),
-                                               TAG_IF(pl, SIPTAG_PAYLOAD_STR(su_strdup(other_tech_pvt->nh->nh_home, pl))),
+                                               TAG_IF(pl, SIPTAG_PAYLOAD_STR(su_strdup(nua_handle_get_home(other_tech_pvt->nh), pl))),
                                                TAG_IF(!zstr(session_id_header), SIPTAG_HEADER_STR(session_id_header)),
                                                TAG_END());
                }
@@ -9670,9 +9670,9 @@ switch_status_t sofia_proxy_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua
                        }
 
                        nua_info(other_tech_pvt->nh,
-                                        TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(su_strdup(other_tech_pvt->nh->nh_home, ct))),
+                                        TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(su_strdup(nua_handle_get_home(other_tech_pvt->nh), ct))),
                                         TAG_IF(!zstr(other_tech_pvt->user_via), SIPTAG_VIA_STR(other_tech_pvt->user_via)),
-                                        TAG_IF(pl, SIPTAG_PAYLOAD_STR(su_strdup(other_tech_pvt->nh->nh_home, pl))),
+                                        TAG_IF(pl, SIPTAG_PAYLOAD_STR(su_strdup(nua_handle_get_home(other_tech_pvt->nh), pl))),
                                         TAG_IF(!zstr(session_id_header), SIPTAG_HEADER_STR(session_id_header)),
                                         TAG_END());
                }
@@ -10696,7 +10696,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
 
        if ((rpid = sip_remote_party_id(sip))) {
                if (rpid->rpid_url->url_user) {
-                       char *full_rpid_header = sip_header_as_string(nh->nh_home, (void *) rpid);
+                       char *full_rpid_header = sip_header_as_string(nua_handle_get_home(nh), (void *) rpid);
                        from_user = rpid->rpid_url->url_user;
                        if (!zstr(full_rpid_header)) {
                                switch_channel_set_variable(channel, "sip_Remote-Party-ID", full_rpid_header);
@@ -10712,7 +10712,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
 
        if ((passerted = sip_p_asserted_identity(sip))) {
                if (passerted->paid_url->url_user) {
-                       char *full_paid_header = sip_header_as_string(nh->nh_home, (void *) passerted);
+                       char *full_paid_header = sip_header_as_string(nua_handle_get_home(nh), (void *) passerted);
                        //char *full_paid_header = (char *)(passerted->paid_common->h_data);
                        from_user = passerted->paid_url->url_user;
                        if (!zstr(full_paid_header)) {
@@ -10735,7 +10735,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
 
        if ((ppreferred = sip_p_preferred_identity(sip))) {
                if (ppreferred->ppid_url->url_user) {
-                       char *full_ppid_header = sip_header_as_string(nh->nh_home, (void *) ppreferred);
+                       char *full_ppid_header = sip_header_as_string(nua_handle_get_home(nh), (void *) ppreferred);
                        from_user = ppreferred->ppid_url->url_user;
                        if (!zstr(full_ppid_header)) {
                                switch_channel_set_variable(channel, "sip_P-Preferred-Identity", full_ppid_header);
@@ -11024,13 +11024,13 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
        }
 
        if ((alert_info = sip_alert_info(sip))) {
-               char *tmp = sip_header_as_string(nh->nh_home, (void *) alert_info);
+               char *tmp = sip_header_as_string(nua_handle_get_home(nh), (void *) alert_info);
                switch_channel_set_variable(channel, "alert_info", tmp);
-               su_free(nh->nh_home, tmp);
+               su_free(nua_handle_get_home(nh), tmp);
        }
 
        if ((call_info = sip_call_info(sip))) {
-               call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
+               call_info_str = sip_header_as_string(nua_handle_get_home(nh), (void *) call_info);
 
                if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE) && switch_stristr("appearance", call_info_str)) {
                        char *p;
@@ -11051,7 +11051,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                call_info = call_info->ci_next;
 
                while (call_info) {
-                       call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
+                       call_info_str = sip_header_as_string(nua_handle_get_home(nh), (void *) call_info);
                        switch_channel_add_variable_var_check(channel, "sip_call_info", call_info_str, SWITCH_FALSE, SWITCH_STACK_PUSH);
                        call_info = call_info->ci_next;
                }
@@ -11304,7 +11304,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                }
 
                if ((privacy = sip_privacy(sip))) {
-                       char *full_priv_header = sip_header_as_string(nh->nh_home, (void *) privacy);
+                       char *full_priv_header = sip_header_as_string(nua_handle_get_home(nh), (void *) privacy);
                        if (!zstr(full_priv_header)) {
                                switch_channel_set_variable(channel, "sip_Privacy", full_priv_header);
                        }
index a412f25cd3670b3abc954d8109c65891b15c5ff2..27171890ddec1b8a43d656753873771e7c4d7d05 100644 (file)
@@ -475,7 +475,7 @@ void sofia_glue_store_session_id(switch_core_session_t *session, sofia_profile_t
                struct private_object *tech_pvt = switch_core_session_get_private(session);
                switch_channel_set_variable(channel, SWITCH_RFC7989_SESSION_ID_VARIABLE, a_id);
                if (tech_pvt && tech_pvt->sofia_private && !tech_pvt->sofia_private->rfc7989_uuid) {
-                       tech_pvt->sofia_private->rfc7989_uuid = su_strdup(tech_pvt->nh->nh_home, a_id);
+                       tech_pvt->sofia_private->rfc7989_uuid = su_strdup(nua_handle_get_home(tech_pvt->nh), a_id);
                }
        }
 
@@ -532,7 +532,7 @@ char *sofia_glue_session_id_header(switch_core_session_t *session, sofia_profile
                                struct private_object *tech_pvt = switch_core_session_get_private(session);
                                switch_channel_set_variable(channel, SWITCH_RFC7989_APP_SESSION_ID_VARIABLE, a_id);
                                if (tech_pvt && tech_pvt->sofia_private && !tech_pvt->sofia_private->rfc7989_uuid) {
-                                       tech_pvt->sofia_private->rfc7989_uuid = su_strdup(tech_pvt->nh->nh_home, a_id);
+                                       tech_pvt->sofia_private->rfc7989_uuid = su_strdup(nua_handle_get_home(tech_pvt->nh), a_id);
                                }
                        }
                }
@@ -559,7 +559,7 @@ char *sofia_glue_session_id_header(switch_core_session_t *session, sofia_profile
                        struct private_object *tech_pvt = switch_core_session_get_private(session);
                        switch_channel_set_variable(channel, SWITCH_RFC7989_APP_SESSION_ID_VARIABLE, a_id);
                        if (tech_pvt && tech_pvt->sofia_private && !tech_pvt->sofia_private->rfc7989_uuid) {
-                               tech_pvt->sofia_private->rfc7989_uuid = su_strdup(tech_pvt->nh->nh_home, a_id);
+                               tech_pvt->sofia_private->rfc7989_uuid = su_strdup(nua_handle_get_home(tech_pvt->nh), a_id);
                        }
                }
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, 
@@ -601,7 +601,7 @@ char *sofia_glue_session_id_header(switch_core_session_t *session, sofia_profile
                        struct private_object *tech_pvt = switch_core_session_get_private(session);
                        switch_channel_set_variable(channel, SWITCH_RFC7989_APP_SESSION_ID_VARIABLE, a_id);
                        if (tech_pvt && tech_pvt->sofia_private) {
-                               tech_pvt->sofia_private->rfc7989_uuid = su_strdup(tech_pvt->nh->nh_home, a_id);
+                               tech_pvt->sofia_private->rfc7989_uuid = su_strdup(nua_handle_get_home(tech_pvt->nh), a_id);
                        }
                }
                b_id = switch_channel_get_variable(channel, SWITCH_RFC7989_SESSION_ID_VARIABLE);
@@ -1500,7 +1500,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 
                switch_safe_free(d_url);
 
-               if (!(sofia_private = su_alloc(tech_pvt->nh->nh_home, sizeof(*sofia_private)))) {
+               if (!(sofia_private = su_alloc(nua_handle_get_home(tech_pvt->nh), sizeof(*sofia_private)))) {
                        abort();
                }
 
@@ -1592,14 +1592,14 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 
        if ((val = switch_channel_get_variable(tech_pvt->channel, "sip_invite_cseq"))) {
                uint32_t callsequence = (uint32_t) strtoul(val, NULL, 10);
-               cseq = sip_cseq_create(tech_pvt->nh->nh_home, callsequence, SIP_METHOD_INVITE);
+               cseq = sip_cseq_create(nua_handle_get_home(tech_pvt->nh), callsequence, SIP_METHOD_INVITE);
        }
 
 
        switch_channel_clear_flag(channel, CF_MEDIA_ACK);
 
        if (handle_full_from) {
-               tech_pvt->nh->nh_has_invite = 1;
+               nua_handle_set_has_invite(tech_pvt->nh, 1);
        }
 
        if ((mp = sofia_media_get_multipart(session, "sip_multipart", tech_pvt->mparams.local_sdp_str, &mp_type))) {
@@ -3333,8 +3333,8 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua
        }
 
        if (sip->sip_record_route) {
-               char *full_contact = sip_header_as_string(nh->nh_home, (void *) contact);
-               char *route = sofia_glue_strip_uri(sip_header_as_string(nh->nh_home, (void *) sip->sip_record_route));
+               char *full_contact = sip_header_as_string(nua_handle_get_home(nh), (void *) contact);
+               char *route = sofia_glue_strip_uri(sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_record_route));
                char *full_contact_dup;
                char *route_encoded;
                int route_encoded_len;
@@ -3348,7 +3348,7 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua
                free(route_encoded);
        }
        else if (np->is_nat && np->fs_path) {
-               char *full_contact = sip_header_as_string(nh->nh_home, (void *) contact);
+               char *full_contact = sip_header_as_string(nua_handle_get_home(nh), (void *) contact);
                char *full_contact_dup;
                char *path_encoded;
                int path_encoded_len;
index be27121cd1153ef826de3e417ec43135435cedcb..e1c31c99c879b4401ae8744c6626a5e736bcfafc 100644 (file)
@@ -368,7 +368,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
                if (is_blocking) {
                        sanity = 200;
 
-                       while(!mstatus && --sanity && !msg_nh->nh_destroyed) {
+                       while(!mstatus && --sanity && !nua_handle_is_destroyed(msg_nh)) {
                                switch_yield(100000);
                        }
 
@@ -2334,7 +2334,7 @@ static void _send_presence_notify(sofia_profile_t *profile,
        }
 
        nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_CONTACT_STR(contact_str), TAG_END());
-       cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY);
+       cseq = sip_cseq_create(nua_handle_get_home(nh), callsequence, SIP_METHOD_NOTIFY);
        nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
 
 
@@ -3712,7 +3712,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                contact_user = sip->sip_contact->m_url->url_user;
        }
 
-       full_agent = sip_header_as_string(nh->nh_home, (void *) sip->sip_user_agent);
+       full_agent = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_user_agent);
 
        //tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END());
 
@@ -3726,7 +3726,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                }
        }
 
-       event = sip_header_as_string(nh->nh_home, (void *) sip->sip_event);
+       event = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_event);
 
        if (to) {
                to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host);
@@ -3864,9 +3864,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
        }
 
        call_id = sip->sip_call_id->i_id;
-       full_from = sip_header_as_string(nh->nh_home, (void *) sip->sip_from);
-       full_to = sip_header_as_string(nh->nh_home, (void *) sip->sip_to);
-       full_via = sip_header_as_string(nh->nh_home, (void *) sip->sip_via);
+       full_from = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_from);
+       full_to = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_to);
+       full_via = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_via);
 
 
        if (sip->sip_expires && sip->sip_expires->ex_delta > 31536000) {
@@ -4062,9 +4062,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                }
 
 
-               if (nh && nh->nh_ds->ds_usage) {
+               if (nh) {
                        /* nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta + SUB_OVERLAP, exp_delta + SUB_OVERLAP); */
-                       nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta, exp_delta);
+                       nua_handle_dialog_usage_set_refresh_range(nh, exp_delta, exp_delta);
                }
 
                if (contactstr && (p = strchr(contactstr, '@'))) {
@@ -4076,7 +4076,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                }
 
                if (nh) {
-                       sip_to_tag(nh->nh_home, sip->sip_to, use_to_tag);
+                       sip_to_tag(nua_handle_get_home(nh), sip->sip_to, use_to_tag);
                }
 
                if (mod_sofia_globals.debug_presence > 0) {
@@ -4107,7 +4107,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                        if (zstr(full_agent) || (*full_agent != 'z' && *full_agent != 'Z')) {
                                /* supress endless loop bug with zoiper */
                                callsequence = sofia_presence_get_cseq(profile);
-                               cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY);
+                               cseq = sip_cseq_create(nua_handle_get_home(nh), callsequence, SIP_METHOD_NOTIFY);
                                nua_notify(nh,
                                                   SIPTAG_EXPIRES_STR("0"),
                                                   SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
@@ -4124,7 +4124,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                char *p = NULL;
 
                if (sip->sip_call_info) {
-                       full_call_info = sip_header_as_string(nh->nh_home, (void *) sip->sip_call_info);
+                       full_call_info = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_call_info);
                        if ((p = strchr(full_call_info, ';'))) {
                                p++;
                        }
@@ -4154,7 +4154,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                                sync_sla(profile, to_user, to_host, SWITCH_FALSE, SWITCH_FALSE, NULL);
                        }
 
-                       su_free(nh->nh_home, full_call_info);
+                       su_free(nua_handle_get_home(nh), full_call_info);
 
                }
 
@@ -4165,12 +4165,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                        switch_time_t now;
 
                        if (sip->sip_call_info) {
-                               full_call_info = sip_header_as_string(nh->nh_home, (void *) sip->sip_call_info);
+                               full_call_info = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_call_info);
                                if ((p = strchr(full_call_info, ';'))) {
                                        p++;
                                }
                                callsequence = sofia_presence_get_cseq(profile);
-                               cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY);
+                               cseq = sip_cseq_create(nua_handle_get_home(nh), callsequence, SIP_METHOD_NOTIFY);
                                nua_notify(nh,
                                                   SIPTAG_FROM(sip->sip_to),
                                                   SIPTAG_TO(sip->sip_from),
@@ -4205,7 +4205,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                                sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
                                sync_sla(profile, to_user, to_host, SWITCH_FALSE, SWITCH_FALSE, NULL);
 
-                               su_free(nh->nh_home, full_call_info);
+                               su_free(nua_handle_get_home(nh), full_call_info);
                        }
                } else if (!strcasecmp(event, "call-info")) {
                        sync_sla(profile, to_user, to_host, SWITCH_FALSE, SWITCH_FALSE, call_id);
@@ -4401,21 +4401,21 @@ void sofia_presence_handle_sip_i_subscribe(int status,
        }
 
        if (event) {
-               su_free(nh->nh_home, event);
+               su_free(nua_handle_get_home(nh), event);
        }
 
        if (full_from) {
-               su_free(nh->nh_home, full_from);
+               su_free(nua_handle_get_home(nh), full_from);
        }
        if (full_to) {
-               su_free(nh->nh_home, full_to);
+               su_free(nua_handle_get_home(nh), full_to);
        }
 
        if (full_via) {
-               su_free(nh->nh_home, full_via);
+               su_free(nua_handle_get_home(nh), full_via);
        }
        if (full_agent) {
-               su_free(nh->nh_home, full_agent);
+               su_free(nua_handle_get_home(nh), full_agent);
        }
 
        switch_safe_free(d_user);
@@ -4608,7 +4608,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
                        char *open_closed = "", *note_txt = "";
 
                        if (sip->sip_user_agent) {
-                               full_agent = sip_header_as_string(nh->nh_home, (void *) sip->sip_user_agent);
+                               full_agent = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_user_agent);
                        }
 
                        if ((tuple = switch_xml_child(xml, "tuple")) && (status = switch_xml_child(tuple, "status"))
@@ -4652,7 +4652,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
                                }
                        }
 
-                       event_type = sip_header_as_string(nh->nh_home, (void *) sip->sip_event);
+                       event_type = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_event);
 
                        if (count) {
                                if ((sql = switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' "
@@ -4702,11 +4702,11 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
                        }
 
                        if (event_type) {
-                               su_free(nh->nh_home, event_type);
+                               su_free(nua_handle_get_home(nh), event_type);
                        }
 
                        if (full_agent) {
-                               su_free(nh->nh_home, full_agent);
+                               su_free(nua_handle_get_home(nh), full_agent);
                        }
 
                        switch_xml_free(xml);
@@ -4859,7 +4859,7 @@ void sofia_presence_handle_sip_i_message(int status,
                        sip_unknown_t *un;
                        int first_history_info = 1;
 
-                       full_from = sip_header_as_string(nh->nh_home, (void *) sip->sip_from);
+                       full_from = sip_header_as_string(nua_handle_get_home(nh), (void *) sip->sip_from);
 
                        if ((p = strchr(to_user, '+')) && p != to_user) {
                                switch_copy_string(proto, to_user, sizeof(proto));
@@ -5013,7 +5013,7 @@ void sofia_presence_handle_sip_i_message(int status,
                        switch_safe_free(from_addr);
 
                        if (full_from) {
-                               su_free(nh->nh_home, full_from);
+                               su_free(nua_handle_get_home(nh), full_from);
                        }
                }
        }
index 0ffa2358758dbd6ccad712b2f95f5a1e6be37dfa..81d2ffdabd084797ffa3d9039f5812cf1141c3ef 100644 (file)
@@ -1935,17 +1935,17 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu
                        switch_mutex_unlock(profile->flag_mutex);
 
                        if (!hnh) {
-                               if (!(sofia_private = su_alloc(nh->nh_home, sizeof(*sofia_private)))) {
+                               if (!(sofia_private = su_alloc(nua_handle_get_home(nh), sizeof(*sofia_private)))) {
                                        abort();
                                }
 
                                memset(sofia_private, 0, sizeof(*sofia_private));
-                               sofia_private->call_id = su_strdup(nh->nh_home, call_id);
-                               sofia_private->network_ip = su_strdup(nh->nh_home, network_ip);
-                               sofia_private->network_port = su_strdup(nh->nh_home, network_port_c);
-                               sofia_private->key = su_strdup(nh->nh_home, key);
-                               sofia_private->user = su_strdup(nh->nh_home, to_user);
-                               sofia_private->realm = su_strdup(nh->nh_home, reg_host);
+                               sofia_private->call_id = su_strdup(nua_handle_get_home(nh), call_id);
+                               sofia_private->network_ip = su_strdup(nua_handle_get_home(nh), network_ip);
+                               sofia_private->network_port = su_strdup(nua_handle_get_home(nh), network_port_c);
+                               sofia_private->key = su_strdup(nua_handle_get_home(nh), key);
+                               sofia_private->user = su_strdup(nua_handle_get_home(nh), to_user);
+                               sofia_private->realm = su_strdup(nua_handle_get_home(nh), reg_host);
 
                                sofia_private->is_static++;
                                *sofia_private_p = sofia_private;
@@ -2426,12 +2426,12 @@ void sofia_reg_handle_sip_r_register(int status,
                                        char *full;
 
                                        for (; contact; contact = contact->m_next) {
-                                               if ((full = sip_header_as_string(nh->nh_home, (void *) contact))) {
+                                               if ((full = sip_header_as_string(nua_handle_get_home(nh), (void *) contact))) {
                                                        if (switch_stristr(gateway->register_contact, full)) {
                                                                break;
                                                        }
 
-                                                       su_free(nh->nh_home, full);
+                                                       su_free(nua_handle_get_home(nh), full);
                                                }
                                        }
                                }