help cure connectile-dysfunction

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5207 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-05-21 19:11:37 +00:00
parent d6a9ef7e6c
commit 3f9ae7d060
1 changed files with 17 additions and 6 deletions

View File

@ -263,11 +263,13 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
const char *rpid = "unknown";
const char *display = "\"user\"";
char network_ip[80];
int network_port;
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
expires = sip->sip_expires;
authorization = sip->sip_authorization;
@ -333,6 +335,14 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
}
if (v_event && *v_event && (v_contact_str = switch_event_get_header(*v_event, "force-contact"))) {
if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction")) {
if (contact->m_url->url_params) {
snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>",
display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params);
} else {
snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>", display, contact->m_url->url_user, network_ip, network_port);
}
} else {
char *p;
switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
for(p = contact_str; p && *p; p++) {
@ -341,6 +351,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
}
}
}
}
if (auth_res != AUTH_OK && !stale) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n", forbidden ? "forbidden" : "challange", from_user, from_host);