[Freeswitch-trunk] [commit] r12427 - freeswitch/trunk/src/mod/endpoints/mod_sofia
FreeSWITCH SVN
anthm at freeswitch.org
Wed Mar 4 15:03:25 PST 2009
Author: anthm
Date: Wed Mar 4 17:03:25 2009
New Revision: 12427
Log:
add configurable outgoing cid types
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 4 17:03:25 2009
@@ -2579,6 +2579,7 @@
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
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Wed Mar 4 17:03:25 2009
@@ -105,6 +105,7 @@
#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 @@
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 @@
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 @@
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 @@
* \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);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Mar 4 17:03:25 2009
@@ -1453,6 +1453,8 @@
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 @@
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 @@
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 @@
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 @@
if (!switch_strlen_zero(ppreferred->ppid_display)) {
displayname = ppreferred->ppid_display;
}
+ switch_channel_set_variable(channel, "sip_cid_type", "pid");
}
if (from_user) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Mar 4 17:03:25 2009
@@ -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 @@
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_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 ((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);
+ }
+
if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
- priv = "full";
+ tech_pvt->privacy = "id";
+ } else {
+ tech_pvt->privacy = "none";
}
- } else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
- priv = "full";
- }
- if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
- screen = "yes";
+ 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;
}
- 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 @@
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 @@
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:
More information about the Freeswitch-trunk
mailing list