add configurable outgoing cid types
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12427 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
fcf61f24a8
commit
df13840625
|
@ -2579,6 +2579,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
switch_ivr_transfer_variable(session, nsession, "sip_video_fmtp");
|
||||
switch_ivr_transfer_variable(session, nsession, "sip-force-contact");
|
||||
switch_ivr_transfer_variable(session, nsession, "sip_sticky_contact");
|
||||
switch_ivr_transfer_variable(session, nsession, "sip_cid_type");
|
||||
|
||||
if (switch_core_session_compare(session, nsession)) {
|
||||
/* It's another sofia channel! so lets cache what they use as a pt for telephone event so
|
||||
|
|
|
@ -105,6 +105,7 @@ typedef struct private_object private_object_t;
|
|||
#include <sofia-sip/nea.h>
|
||||
#include <sofia-sip/msg_addr.h>
|
||||
#include <sofia-sip/tport_tag.h>
|
||||
#include <sofia-sip/sip_extra.h>
|
||||
#include "nua_stack.h"
|
||||
|
||||
typedef enum {
|
||||
|
@ -371,6 +372,12 @@ typedef enum {
|
|||
MEDIA_OPT_BYPASS_AFTER_ATT_XFER = (1 << 1)
|
||||
} sofia_media_options_t;
|
||||
|
||||
typedef enum {
|
||||
CID_TYPE_RPID,
|
||||
CID_TYPE_PID,
|
||||
CID_TYPE_NONE
|
||||
} sofia_cid_type_t;
|
||||
|
||||
struct sofia_profile {
|
||||
int debug;
|
||||
char *name;
|
||||
|
@ -403,6 +410,7 @@ struct sofia_profile {
|
|||
char *record_template;
|
||||
char *presence_hosts;
|
||||
char *challenge_realm;
|
||||
sofia_cid_type_t cid_type;
|
||||
sofia_dtmf_t dtmf_type;
|
||||
int auto_restart;
|
||||
int sip_port;
|
||||
|
@ -493,6 +501,9 @@ struct private_object {
|
|||
char *contact_url;
|
||||
char *from_str;
|
||||
char *rpid;
|
||||
char *asserted_id;
|
||||
char *preferred_id;
|
||||
char *privacy;
|
||||
char *gateway_from_str;
|
||||
char *rm_encoding;
|
||||
char *iananame;
|
||||
|
@ -825,3 +836,4 @@ switch_status_t sofia_set_loglevel(const char *name, int level);
|
|||
* \return the component's loglevel, or -1 if the component isn't valid
|
||||
*/
|
||||
int sofia_get_loglevel(const char *name);
|
||||
sofia_cid_type_t sofia_cid_name2type(const char *name);
|
||||
|
|
|
@ -1453,6 +1453,8 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
|||
if (switch_true(val)) {
|
||||
profile->rport_level = 2;
|
||||
}
|
||||
} else if (!strcasecmp(var, "caller-id-type")) {
|
||||
profile->cid_type = sofia_cid_name2type(val);
|
||||
} else if (!strcasecmp(var, "record-template")) {
|
||||
profile->record_template = switch_core_strdup(profile->pool, val);;
|
||||
} else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media"))) {
|
||||
|
@ -1920,6 +1922,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||
profile->dbname = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "presence-hosts")) {
|
||||
profile->presence_hosts = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "caller-id-type")) {
|
||||
profile->cid_type = sofia_cid_name2type(val);
|
||||
} else if (!strcasecmp(var, "record-template")) {
|
||||
profile->record_template = switch_core_strdup(profile->pool, val);
|
||||
} else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media")) && switch_true(val)) {
|
||||
|
@ -4195,6 +4199,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
if (!switch_strlen_zero(rpid->rpid_display)) {
|
||||
displayname = rpid->rpid_display;
|
||||
}
|
||||
switch_channel_set_variable(channel, "sip_cid_type", "rpid");
|
||||
}
|
||||
|
||||
if ((passerted = sip_p_asserted_identity(sip))) {
|
||||
|
@ -4204,6 +4209,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
if (!switch_strlen_zero(passerted->paid_display)) {
|
||||
displayname = passerted->paid_display;
|
||||
}
|
||||
switch_channel_set_variable(channel, "sip_cid_type", "pid");
|
||||
}
|
||||
|
||||
if ((ppreferred = sip_p_preferred_identity(sip))) {
|
||||
|
@ -4213,6 +4219,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
if (!switch_strlen_zero(ppreferred->ppid_display)) {
|
||||
displayname = ppreferred->ppid_display;
|
||||
}
|
||||
switch_channel_set_variable(channel, "sip_cid_type", "pid");
|
||||
}
|
||||
|
||||
if (from_user) {
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "mod_sofia.h"
|
||||
#include <switch_stun.h>
|
||||
|
||||
|
||||
void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options)
|
||||
{
|
||||
char buf[2048];
|
||||
|
@ -1112,6 +1113,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
char *route = NULL;
|
||||
char *route_uri = NULL;
|
||||
char *sendto = NULL;
|
||||
sofia_cid_type_t cid_type = tech_pvt->profile->cid_type;
|
||||
|
||||
rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
|
||||
|
||||
|
@ -1300,23 +1302,54 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
switch_channel_set_variable(channel, "sip_nat_detected", "true");
|
||||
}
|
||||
|
||||
/* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
|
||||
priv = "name";
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
|
||||
priv = "full";
|
||||
if ((val = switch_channel_get_variable(channel, "sip_cid_type"))) {
|
||||
cid_type = sofia_cid_name2type(val);
|
||||
}
|
||||
switch (cid_type) {
|
||||
case CID_TYPE_PID:
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
|
||||
tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>",
|
||||
tech_pvt->caller_profile->caller_id_name,
|
||||
tech_pvt->caller_profile->caller_id_number,
|
||||
rpid_domain);
|
||||
} else {
|
||||
tech_pvt->preferred_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>",
|
||||
tech_pvt->caller_profile->caller_id_name,
|
||||
tech_pvt->caller_profile->caller_id_number,
|
||||
rpid_domain);
|
||||
}
|
||||
} else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
|
||||
priv = "full";
|
||||
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
|
||||
tech_pvt->privacy = "id";
|
||||
} else {
|
||||
tech_pvt->privacy = "none";
|
||||
}
|
||||
|
||||
break;
|
||||
case CID_TYPE_RPID:
|
||||
{
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
|
||||
priv = "name";
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
|
||||
priv = "full";
|
||||
}
|
||||
} else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
|
||||
priv = "full";
|
||||
}
|
||||
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
|
||||
screen = "yes";
|
||||
}
|
||||
|
||||
tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>;party=calling;screen=%s;privacy=%s",
|
||||
tech_pvt->caller_profile->caller_id_name,
|
||||
tech_pvt->caller_profile->caller_id_number, rpid_domain, screen, priv);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
|
||||
screen = "yes";
|
||||
}
|
||||
|
||||
tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "Remote-Party-ID: \"%s\"<sip:%s@%s>;party=calling;screen=%s;privacy=%s",
|
||||
tech_pvt->caller_profile->caller_id_name,
|
||||
tech_pvt->caller_profile->caller_id_number, rpid_domain, screen, priv);
|
||||
|
||||
switch_safe_free(d_url);
|
||||
|
||||
|
@ -1438,7 +1471,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
NUTAG_AUTOANSWER(0),
|
||||
NUTAG_SESSION_TIMER(session_timeout),
|
||||
TAG_IF(!switch_strlen_zero(sendto), NTATAG_DEFAULT_PROXY(sendto)),
|
||||
TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_HEADER_STR(tech_pvt->rpid)),
|
||||
TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)),
|
||||
TAG_IF(!switch_strlen_zero(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)),
|
||||
TAG_IF(!switch_strlen_zero(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)),
|
||||
TAG_IF(!switch_strlen_zero(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->preferred_id)),
|
||||
TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
|
||||
TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
|
||||
TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
|
||||
|
@ -3557,6 +3593,20 @@ const char *sofia_glue_strip_proto(const char *uri)
|
|||
return uri;
|
||||
}
|
||||
|
||||
sofia_cid_type_t sofia_cid_name2type(const char *name)
|
||||
{
|
||||
if (!strcasecmp(name, "rpid")) {
|
||||
return CID_TYPE_RPID;
|
||||
}
|
||||
|
||||
if (!strcasecmp(name, "pid")) {
|
||||
return CID_TYPE_PID;
|
||||
}
|
||||
|
||||
return CID_TYPE_NONE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
|
Loading…
Reference in New Issue