diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index bc58ee9ec0..8967a7bad8 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -174,6 +174,9 @@ typedef enum { PFLAG_CALLID_AS_UUID, PFLAG_UUID_AS_CALLID, PFLAG_SCROOGE, + PFLAG_MANAGE_SHARED_APPEARANCE, + PFLAG_DISABLE_SRV, + PFLAG_DISABLE_NAPTR, /* No new flags below this line */ PFLAG_MAX @@ -451,9 +454,6 @@ struct sofia_profile { sofia_media_options_t media_options; uint32_t force_subscription_expires; switch_rtp_bug_flag_t auto_rtp_bugs; - char manage_shared_appearance; /* pflags was all full up - MTK */ - char disable_srv; - char disable_naptr; }; struct private_object { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 209780b13d..ca7230c267 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -101,7 +101,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, * *and* for Linksys, I believe they use "sa" as their magic appearance agent name for those blind notifies, so * we'll probably have to change to match */ - if (profile->manage_shared_appearance) { + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) { int sub_state; @@ -728,8 +728,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_CERTIFICATE_DIR(profile->tls_cert_dir)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERSION(profile->tls_version)), TAG_IF(!strchr(profile->sipip, ':'), NTATAG_UDP_MTU(65535)), - TAG_IF(profile->disable_srv, NTATAG_USE_SRV(0)), - TAG_IF(profile->disable_naptr, NTATAG_USE_NAPTR(0)), + TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV), NTATAG_USE_SRV(0)), + TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_NAPTR), NTATAG_USE_NAPTR(0)), NTATAG_DEFAULT_PROXY(profile->outbound_proxy), NTATAG_SERVER_RPORT(profile->rport_level), TAG_IF(tportlog, TPTAG_LOG(1)), @@ -762,9 +762,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TAG_IF(profile->pres_type, NUTAG_ALLOW("SUBSCRIBE")), TAG_IF(profile->pres_type, NUTAG_ENABLEMESSAGE(1)), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence")), - TAG_IF((profile->pres_type || profile->manage_shared_appearance), NUTAG_ALLOW_EVENTS("dialog")), + TAG_IF((profile->pres_type || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)), NUTAG_ALLOW_EVENTS("dialog")), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("call-info")), - TAG_IF((profile->pres_type || profile->manage_shared_appearance), NUTAG_ALLOW_EVENTS("sla")), + TAG_IF((profile->pres_type || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)), NUTAG_ALLOW_EVENTS("sla")), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("include-session-description")), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence.winfo")), TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("message-summary")), @@ -1807,9 +1807,6 @@ switch_status_t config_sofia(int reload, char *profile_name) sofia_set_pflag(profile, PFLAG_STUN_ENABLED); sofia_set_pflag(profile, PFLAG_DISABLE_100REL); profile->auto_restart = 1; - profile->manage_shared_appearance = 0; /* Initialize default */ - profile->disable_srv = 0; - profile->disable_naptr = 0; for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); @@ -2027,16 +2024,16 @@ switch_status_t config_sofia(int reload, char *profile_name) } } else if (!strcasecmp(var, "manage-shared-appearance")) { if (switch_true(val)) { - profile->manage_shared_appearance = 1; + sofia_set_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE); profile->sla_contact = switch_core_sprintf(profile->pool, "sip:sla-agent@%s", profile->sipip); } } else if (!strcasecmp(var, "disable-srv")) { if (switch_true(val)) { - profile->disable_srv = 1; + sofia_set_pflag(profile, PFLAG_DISABLE_SRV); } } else if (!strcasecmp(var, "disable-naptr")) { if (switch_true(val)) { - profile->disable_naptr = 1; + sofia_set_pflag(profile, PFLAG_DISABLE_NAPTR); } } else if (!strcasecmp(var, "unregister-on-options-fail")) { if (switch_true(val)) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 1dc25250c2..410f497903 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3127,7 +3127,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile) } free(test_sql); - if (profile->manage_shared_appearance) { + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname); if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) { switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL); @@ -3167,7 +3167,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile) switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_authentication", auth_sql); free(test_sql); - if(profile->manage_shared_appearance) { + if(sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname); switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql); free(test_sql); diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index dcb751ccf5..927a1fc40e 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1516,7 +1516,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, /* the following could be refactored back to the calling event handler in sofia.c XXX MTK */ - if (profile->manage_shared_appearance) { + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) { /* only fire this on <200 to try to avoid resubscribes. probably better ways to do this? */ if (status < 200) { @@ -1784,7 +1784,7 @@ void sofia_presence_handle_sip_r_subscribe(int status, } /* the following could possibly be refactored back towards the calling event handler in sofia.c XXX MTK */ - if (profile->manage_shared_appearance) { + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (!strcasecmp(o->o_type, "dialog") && msg_params_find(o->o_params, "sla")) { sofia_sla_handle_sip_r_subscribe(nua, profile, nh, sip, tags); return; @@ -1835,7 +1835,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n char *event_type; /* the following could instead be refactored back to the calling event handler in sofia.c XXX MTK */ - if (profile->manage_shared_appearance) { + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { /* also it probably is unsafe to dereference so many things in a row without testing XXX MTK */ if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) { sofia_sla_handle_sip_i_publish(nua, profile, nh, sip, tags); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index b87b0885cb..8334ea90dc 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1102,7 +1102,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand switch_event_fire(&s_event); } - if (profile->manage_shared_appearance) { + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { sofia_sla_handle_register(nua, profile, sip); }