提交 f0172523 authored 作者: Brian West's avatar Brian West

fix via for outbound sub and reg contacts are correct

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13596 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 603256e3
...@@ -134,11 +134,14 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -134,11 +134,14 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) { for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) {
int ss_state = nua_callstate_authenticating; int ss_state = nua_callstate_authenticating;
sub_state_t ostate = gw_sub_ptr->state; sub_state_t ostate = gw_sub_ptr->state;
char *user_via = NULL;
if (!now) { if (!now) {
gw_sub_ptr->state = ostate = SUB_STATE_UNSUBED; gw_sub_ptr->state = ostate = SUB_STATE_UNSUBED;
gw_sub_ptr->expires_str = "0"; gw_sub_ptr->expires_str = "0";
} }
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
switch (ostate) { switch (ostate) {
case SUB_STATE_NOSUB: case SUB_STATE_NOSUB:
...@@ -152,18 +155,20 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -152,18 +155,20 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
/* not tested .. */ /* not tested .. */
nua_unsubscribe(gateway_ptr->nh, nua_unsubscribe(gateway_ptr->nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gateway_ptr->register_url),
SIPTAG_EVENT_STR(gw_sub_ptr->event), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), SIPTAG_EVENT_STR(gw_sub_ptr->event),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type),
SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_FROM_STR(gateway_ptr->register_from),
TAG_NULL()); SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
TAG_NULL());
break; break;
case SUB_STATE_UNSUBED: case SUB_STATE_UNSUBED:
gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL, gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL,
NUTAG_URL(gateway_ptr->register_proxy), NUTAG_URL(gateway_ptr->register_proxy),
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_TO_STR(gateway_ptr->register_to), SIPTAG_TO_STR(gateway_ptr->register_to),
NUTAG_CALLSTATE_REF(ss_state), NUTAG_CALLSTATE_REF(ss_state),
SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
...@@ -179,25 +184,27 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -179,25 +184,27 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
if (now) { if (now) {
nua_subscribe(gateway_ptr->sub_nh, nua_subscribe(gateway_ptr->sub_nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gateway_ptr->register_url),
SIPTAG_EVENT_STR(gw_sub_ptr->event), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), SIPTAG_EVENT_STR(gw_sub_ptr->event),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type),
SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), // sofia stack bases its auto-refresh stuff on this SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
TAG_NULL()); SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), // sofia stack bases its auto-refresh stuff on this
TAG_NULL());
gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds; gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds;
} else { } else {
nua_unsubscribe(gateway_ptr->sub_nh, nua_unsubscribe(gateway_ptr->sub_nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gateway_ptr->register_url),
SIPTAG_EVENT_STR(gw_sub_ptr->event), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), SIPTAG_EVENT_STR(gw_sub_ptr->event),
SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
TAG_NULL()); SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str),
TAG_NULL());
} }
gw_sub_ptr->state = SUB_STATE_TRYING; gw_sub_ptr->state = SUB_STATE_TRYING;
break; break;
...@@ -215,6 +222,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -215,6 +222,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
} }
break; break;
} }
switch_safe_free(user_via);
} }
} }
} }
...@@ -248,6 +256,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -248,6 +256,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) { for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
reg_state_t ostate = gateway_ptr->state; reg_state_t ostate = gateway_ptr->state;
char *user_via = NULL;
if (!now) { if (!now) {
gateway_ptr->state = ostate = REG_STATE_UNREGED; gateway_ptr->state = ostate = REG_STATE_UNREGED;
...@@ -301,16 +310,19 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -301,16 +310,19 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
gateway_ptr->status = SOFIA_GATEWAY_DOWN; gateway_ptr->status = SOFIA_GATEWAY_DOWN;
sofia_reg_new_handle(gateway_ptr, now ? 1 : 0); sofia_reg_new_handle(gateway_ptr, now ? 1 : 0);
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name);
if (now) { if (now) {
nua_register(gateway_ptr->nh, nua_register(gateway_ptr->nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gateway_ptr->register_url),
TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)), TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)),
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_EXPIRES_STR(gateway_ptr->expires_str), SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
NUTAG_REGISTRAR(gateway_ptr->register_proxy), NUTAG_REGISTRAR(gateway_ptr->register_proxy),
NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL()); NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
...@@ -318,6 +330,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -318,6 +330,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
} else { } else {
nua_unregister(gateway_ptr->nh, nua_unregister(gateway_ptr->nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gateway_ptr->register_url),
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
...@@ -328,6 +341,8 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) ...@@ -328,6 +341,8 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
gateway_ptr->retry = now + gateway_ptr->retry_seconds; gateway_ptr->retry = now + gateway_ptr->retry_seconds;
gateway_ptr->state = REG_STATE_TRYING; gateway_ptr->state = REG_STATE_TRYING;
switch_safe_free(user_via);
break; break;
case REG_STATE_FAILED: case REG_STATE_FAILED:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论