set chanvars on both directions in sip and introduce sip_to_tag and sip_from_tag vars
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16395 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
80196ad1f7
commit
110f634cda
|
@ -85,6 +85,69 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void _set_chanvars(switch_core_session_t *session, url_t *url, const char *user_var,
|
||||
const char *host_var, const char *port_var, const char *uri_var, const char *params_var)
|
||||
{
|
||||
const char *user = NULL, *host = NULL, *port = NULL;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char new_port[25] = "";
|
||||
|
||||
if (url) {
|
||||
user = url->url_user;
|
||||
host = url->url_host;
|
||||
port = url->url_port;
|
||||
if (!zstr(url->url_params)) {
|
||||
switch_channel_set_variable(channel, params_var, url->url_params);
|
||||
}
|
||||
}
|
||||
|
||||
if (zstr(user)) {
|
||||
user = "nobody";
|
||||
}
|
||||
|
||||
if (zstr(host)) {
|
||||
host = "nowhere";
|
||||
}
|
||||
|
||||
check_decode(user, session);
|
||||
|
||||
if (user) {
|
||||
switch_channel_set_variable(channel, user_var, user);
|
||||
}
|
||||
|
||||
|
||||
if (port) {
|
||||
switch_snprintf(new_port, sizeof(new_port), ":%s", port);
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, port_var, port);
|
||||
|
||||
}
|
||||
#define set_chanvars(session, url, varprefix) _set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri", #varprefix "_params")
|
||||
|
||||
|
||||
static void extract_vars(sip_t const *sip, switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (sip) {
|
||||
if (sip->sip_from && sip->sip_from->a_url) set_chanvars(session, sip->sip_from->a_url, sip_from);
|
||||
if (sip->sip_request && sip->sip_request->rq_url) set_chanvars(session, sip->sip_request->rq_url, sip_req);
|
||||
if (sip->sip_to && sip->sip_to->a_url) set_chanvars(session, sip->sip_to->a_url, sip_to);
|
||||
if (sip->sip_contact && sip->sip_contact->m_url) set_chanvars(session, sip->sip_contact->m_url, sip_contact);
|
||||
if (sip->sip_referred_by && sip->sip_referred_by->b_url) set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
|
||||
if (sip->sip_to && sip->sip_to->a_tag) {
|
||||
switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
|
||||
}
|
||||
if (sip->sip_from && sip->sip_from->a_tag) {
|
||||
switch_channel_set_variable(channel, "sip_from_tag", sip->sip_from->a_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
|
@ -644,6 +707,17 @@ void sofia_event_callback(nua_event_t event,
|
|||
case nua_r_prack:
|
||||
break;
|
||||
case nua_i_ack:
|
||||
{
|
||||
if (channel && sip) {
|
||||
if (sip->sip_to && sip->sip_to->a_tag) {
|
||||
switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
|
||||
}
|
||||
|
||||
if (sip->sip_from && sip->sip_from->a_tag) {
|
||||
switch_channel_set_variable(channel, "sip_from_tag", sip->sip_from->a_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
case nua_r_ack:
|
||||
if (channel) switch_channel_set_flag(channel, CF_MEDIA_ACK);
|
||||
break;
|
||||
|
@ -3474,6 +3548,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
|||
|
||||
switch_channel_set_flag(channel, CF_MEDIA_ACK);
|
||||
|
||||
extract_vars(sip, session);
|
||||
|
||||
if ((x_freeswitch_support = sofia_glue_get_unknown_header(sip, "X-FS-Support"))) {
|
||||
tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, x_freeswitch_support);
|
||||
}
|
||||
|
@ -5269,7 +5345,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
|
||||
#define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri", #varprefix "_params")
|
||||
|
||||
const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const char *user_var,
|
||||
static const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const char *user_var,
|
||||
const char *host_var, const char *port_var, const char *uri_var, const char *params_var)
|
||||
{
|
||||
const char *user = NULL, *host = NULL, *port = NULL;
|
||||
|
@ -5319,6 +5395,7 @@ const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const
|
|||
return uri;
|
||||
}
|
||||
|
||||
|
||||
void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue