can't win with sip

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8885 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-07-03 15:01:46 +00:00
parent a1cf7067b6
commit 60e352cb6e

View File

@ -318,7 +318,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
if (now) { if (now) {
switch_snprintf(sql, sizeof(sql), "select * from sip_registrations where status like '%%AUTO-NAT%%'"); switch_snprintf(sql, sizeof(sql), "select * from sip_registrations where status like '%%AUTO-NAT%%' or status like '%%UDP-NAT%%'");
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_nat_callback, profile); sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_nat_callback, profile);
} }
@ -440,18 +440,43 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
char *path_encoded = NULL; char *path_encoded = NULL;
int path_encoded_len = 0; int path_encoded_len = 0;
const char *proto = "sip"; const char *proto = "sip";
int is_tls = 0, is_tcp = 0;
if (switch_stristr("transport=tls", sip->sip_contact->m_url->url_params)) {
is_tls += 1;
}
if (sip->sip_contact->m_url->url_type == url_sips) { if (sip->sip_contact->m_url->url_type == url_sips) {
proto = "sips"; proto = "sips";
is_tls += 2;
}
if (switch_stristr("transport=tcp", sip->sip_contact->m_url->url_params)) {
is_tcp = 1;
} }
display = contact->m_display; display = contact->m_display;
if (is_nat) { if (is_nat) {
reg_desc = "Registered(AUTO-NAT)"; if (is_tls) {
reg_desc = "Registered(TLS-NAT)";
} else if (is_tcp) {
reg_desc = "Registered(TCP-NAT)";
} else {
reg_desc = "Registered(UDP-NAT)";
}
contact_host = network_ip; contact_host = network_ip;
switch_snprintf(new_port, sizeof(new_port), ":%d", network_port); switch_snprintf(new_port, sizeof(new_port), ":%d", network_port);
port = NULL; port = NULL;
} else {
if (is_tls) {
reg_desc = "Registered(TLS)";
} else if (is_tcp) {
reg_desc = "Registered(TCP)";
} else {
reg_desc = "Registered(UDP)";
}
} }
if (switch_strlen_zero(display)) { if (switch_strlen_zero(display)) {
@ -735,7 +760,7 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h
sofia_regtype_t type = REG_REGISTER; sofia_regtype_t type = REG_REGISTER;
int network_port = 0; int network_port = 0;
char *is_nat = NULL; char *is_nat = NULL;
int is_tls = 0, is_tcp = 0;
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr); get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port); network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
@ -752,19 +777,6 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h
goto end; goto end;
} }
if (switch_stristr("transport=tls", sip->sip_contact->m_url->url_params)) {
is_tls += 1;
}
if (sip->sip_contact->m_url->url_type == url_sips) {
is_tls += 2;
}
if (switch_stristr("transport=tcp", sip->sip_contact->m_url->url_params)) {
is_tcp = 1;
}
if (!is_tls && !is_tcp) {
if ((profile->pflags & PFLAG_AGGRESSIVE_NAT_DETECTION)) { if ((profile->pflags & PFLAG_AGGRESSIVE_NAT_DETECTION)) {
if (sip && sip->sip_via) { if (sip && sip->sip_via) {
const char *port = sip->sip_via->v_port; const char *port = sip->sip_via->v_port;
@ -803,7 +815,6 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h
} }
} }
} }
}
if (profile->reg_acl_count) { if (profile->reg_acl_count) {
uint32_t x = 0; uint32_t x = 0;