add path support to sofia

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8851 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-06-26 20:19:09 +00:00
parent c441ffb848
commit 0f16046103
2 changed files with 58 additions and 11 deletions
+21 -6
View File
@@ -409,7 +409,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
const char *call_id = NULL;
char *force_user;
char received_data[128] = "";
char *path_val = 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);
@@ -436,6 +437,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
const char *port = contact->m_url->url_port;
char new_port[25] = "";
const char *contact_host = contact->m_url->url_host;
char *path_encoded = NULL;
int path_encoded_len = 0;
display = contact->m_display;
if (is_nat) {
@@ -454,6 +458,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
}
if (sip->sip_path) {
path_val = sip_header_as_string(nh->nh_home, (void *) sip->sip_path);
path_encoded_len = (strlen(path_val) * 3) + 1;
switch_zmalloc(path_encoded, path_encoded_len);
switch_copy_string(path_encoded, ";path=", 7);
switch_url_encode(path_val, path_encoded + 6, path_encoded_len - 6);
}
if (port) {
switch_snprintf(new_port, sizeof(new_port), ":%s", port);
}
@@ -463,12 +475,15 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
if (contact->m_url->url_params) {
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, received_data, is_nat ? ";nat=yes" : "");
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s;%s%s%s%s>",
display, contact->m_url->url_user, contact_host, new_port,
contact->m_url->url_params, received_data, is_nat ? ";nat=yes" : "", path_encoded ? path_encoded : "");
} else {
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=yes" : "");
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,
received_data, is_nat ? ";nat=yes" : "", path_encoded ? path_encoded : "");
}
switch_safe_free(path_encoded);
}
if (expires) {
@@ -691,7 +706,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
}
nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact), NUTAG_WITH_THIS(nua), TAG_END());
nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact), TAG_IF(path_val, SIPTAG_PATH_STR(path_val)), NUTAG_WITH_THIS(nua), TAG_END());
if (s_event) {
switch_event_fire(&s_event);