- handle multiple Contact headers (e.g. in REGISTER response)
This commit is contained in:
parent
cf7c43e3fa
commit
fb744b6ba4
@ -175,6 +175,7 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
|
||||
int i, j, n, sts;
|
||||
int expires;
|
||||
time_t time_now;
|
||||
osip_contact_t *contact;
|
||||
osip_uri_t *url1_to, *url1_contact=NULL;
|
||||
osip_uri_t *url2_to;
|
||||
osip_header_t *expires_hdr;
|
||||
@ -235,20 +236,29 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
|
||||
* (gdb) p *((osip_contact_t*)(sip->contacts->node->element))
|
||||
* $5 = {displayname = 0x8af8848 "*", url = 0x0, gen_params = 0x8af8838}
|
||||
*/
|
||||
if (ticket->sipmsg->contacts && ticket->sipmsg->contacts->node &&
|
||||
/*
|
||||
if (ticket->sipmsg->contacts &&
|
||||
(ticket->sipmsg->contacts->nb_elt != 0) &&
|
||||
ticket->sipmsg->contacts->node &&
|
||||
ticket->sipmsg->contacts->node->element) {
|
||||
url1_contact=((osip_contact_t*)
|
||||
(ticket->sipmsg->contacts->node->element))->url;
|
||||
}
|
||||
|
||||
if ((url1_contact == NULL) || (url1_contact->host == NULL)) {
|
||||
*/
|
||||
osip_message_get_contact(ticket->sipmsg, 0, &contact);
|
||||
if ((contact == NULL) ||
|
||||
(contact->url == NULL) ||
|
||||
(contact->url->host == NULL)) {
|
||||
/* Don't have required Contact fields.
|
||||
This may be a Registration query. We should simply forward
|
||||
this request to its destination. */
|
||||
ERROR("empty Contact header - seems to be a registration query");
|
||||
DEBUGC(DBCLASS_REG, "empty Contact header - "
|
||||
"seems to be a registration query");
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
url1_contact=contact->url;
|
||||
|
||||
/* evaluate Expires Header field */
|
||||
osip_message_get_expires(ticket->sipmsg, 0, &expires_hdr);
|
||||
|
||||
|
||||
@ -681,6 +681,19 @@ int sip_rewrite_contact (sip_ticket_t *ticket, int direction) {
|
||||
/* found a mapping entry */
|
||||
if (i<URLMAP_SIZE) {
|
||||
char *tmp;
|
||||
|
||||
if (direction == DIR_OUTGOING) {
|
||||
DEBUGC(DBCLASS_PROXY, "rewriting Contact header %s@%s -> %s@%s",
|
||||
(contact->url->username)? contact->url->username : "*NULL*",
|
||||
(contact->url->host)? contact->url->host : "*NULL*",
|
||||
urlmap[i].masq_url->username, urlmap[i].masq_url->host);
|
||||
} else {
|
||||
DEBUGC(DBCLASS_PROXY, "rewriting Contact header %s@%s -> %s@%s",
|
||||
(contact->url->username)? contact->url->username : "*NULL*",
|
||||
(contact->url->host)? contact->url->host : "*NULL*",
|
||||
urlmap[i].true_url->username, urlmap[i].true_url->host);
|
||||
}
|
||||
|
||||
/* remove old entry */
|
||||
osip_list_remove(sip_msg->contacts,j);
|
||||
osip_contact_to_str(contact, &tmp);
|
||||
@ -694,17 +707,9 @@ int sip_rewrite_contact (sip_ticket_t *ticket, int direction) {
|
||||
if (direction == DIR_OUTGOING) {
|
||||
/* outgoing, use masqueraded url */
|
||||
osip_uri_clone(urlmap[i].masq_url, &contact->url);
|
||||
DEBUGC(DBCLASS_PROXY, "rewrote Contact header %s@%s -> %s@%s",
|
||||
(contact->url->username)? contact->url->username : "*NULL*",
|
||||
(contact->url->host)? contact->url->host : "*NULL*",
|
||||
urlmap[i].masq_url->username, urlmap[i].masq_url->host);
|
||||
} else {
|
||||
/* incoming, use true url */
|
||||
osip_uri_clone(urlmap[i].true_url, &contact->url);
|
||||
DEBUGC(DBCLASS_PROXY, "rewrote Contact header %s@%s -> %s@%s",
|
||||
(contact->url->username)? contact->url->username : "*NULL*",
|
||||
(contact->url->host)? contact->url->host : "*NULL*",
|
||||
urlmap[i].true_url->username, urlmap[i].true_url->host);
|
||||
}
|
||||
|
||||
osip_list_add(sip_msg->contacts,contact,j);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user