git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8537 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-05-23 12:23:06 +00:00
parent 7a36d978a1
commit ba11f68428
1 changed files with 25 additions and 16 deletions

View File

@ -439,6 +439,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
const char *reg_desc = "Registered"; const char *reg_desc = "Registered";
const char *call_id = NULL; const char *call_id = NULL;
char *force_user; char *force_user;
char received_data[128] = "";
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */ /* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL); switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
@ -488,11 +489,19 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
switch_snprintf(new_port, sizeof(new_port), ":%s", port); switch_snprintf(new_port, sizeof(new_port), ":%s", port);
} }
if (is_nat && (profile->pflags & PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
switch_snprintf(received_data, sizeof(received_data), ";received=\"%s:%d\"", network_ip, network_port);
}
if (contact->m_url->url_params) { if (contact->m_url->url_params) {
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s;%s>%s", switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s;%s>%s%s",
display, contact->m_url->url_user, contact_host, new_port, contact->m_url->url_params, is_nat ? ";nat" : ""); display, contact->m_url->url_user, contact_host, new_port, contact->m_url->url_params,
received_data,
is_nat ? ";nat" : "");
} else { } else {
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s>%s", display, contact->m_url->url_user, contact_host, new_port, is_nat ? ";nat" : ""); switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s>%s%s", display, contact->m_url->url_user, contact_host, new_port,
received_data,
is_nat ? ";nat" : "");
} }
} }
@ -534,13 +543,18 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
} }
if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact"))) { if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact"))) {
if (switch_strlen_zero(received_data) && (profile->pflags & PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
switch_snprintf(received_data, sizeof(received_data), ";received=\"%s:%d\"", network_ip, network_port);
}
if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") || if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") ||
!strcasecmp(v_contact_str, "NDLB-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-tls-connectile-dysfunction")) { !strcasecmp(v_contact_str, "NDLB-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-tls-connectile-dysfunction")) {
if (contact->m_url->url_params) { if (contact->m_url->url_params) {
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>;nat", switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>%s;nat",
display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params); display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params, received_data);
} else { } else {
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>;nat", display, contact->m_url->url_user, network_ip, network_port); switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>%s;nat", display, contact->m_url->url_user, network_ip, network_port, received_data);
} }
if (strstr(v_contact_str, "tls")) { if (strstr(v_contact_str, "tls")) {
reg_desc = "Registered(TLSHACK)"; reg_desc = "Registered(TLSHACK)";
@ -705,7 +719,6 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
if (regtype == REG_REGISTER) { if (regtype == REG_REGISTER) {
char *new_contact = NULL; char *new_contact = NULL;
char new_port[30] = ""; char new_port[30] = "";
char received_data[128] = "";
char exp_param[128] = ""; char exp_param[128] = "";
if (exptime) { if (exptime) {
@ -717,18 +730,14 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
switch_snprintf(new_port, sizeof(new_port), ":%s", contact->m_url->url_port); switch_snprintf(new_port, sizeof(new_port), ":%s", contact->m_url->url_port);
} }
if ((is_nat || nat_hack) && (profile->pflags & PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
switch_snprintf(received_data, sizeof(received_data), ";received=\"%s:%d\"", network_ip, network_port);
}
if (contact->m_url->url_params) { if (contact->m_url->url_params) {
new_contact = switch_mprintf("%s <sip:%s@%s%s;%s>%s%s", new_contact = switch_mprintf("%s <sip:%s@%s%s;%s>%s",
display, contact->m_url->url_user, contact->m_url->url_host, new_port, contact->m_url->url_params, display, contact->m_url->url_user, contact->m_url->url_host, new_port, contact->m_url->url_params,
exp_param, received_data); exp_param);
} else { } else {
new_contact = switch_mprintf("%s <sip:%s@%s%s>%s%s", new_contact = switch_mprintf("%s <sip:%s@%s%s>%s",
display, contact->m_url->url_user, contact->m_url->url_host, new_port, display, contact->m_url->url_user, contact->m_url->url_host, new_port,
exp_param, received_data); exp_param);
} }
nua_respond(nh, nua_respond(nh,