From 6a498f713a2522e18bed96dc4d1f361008a95502 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 7 Oct 2015 11:39:37 -0700 Subject: [PATCH] presence: use advertised ip for local contact --- modules/presence/utils_func.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/presence/utils_func.h b/modules/presence/utils_func.h index 866df1be6df..6592375bbd5 100644 --- a/modules/presence/utils_func.h +++ b/modules/presence/utils_func.h @@ -124,15 +124,18 @@ static inline int ps_fill_local_contact(struct sip_msg* msg, str *contact) goto error; } - ip.s= ip_addr2a(&msg->rcv.dst_ip); - if(ip.s== NULL) - { - LM_ERR("transforming ip_addr to ascii\n"); - goto error; + if(msg->rcv.bind_address->useinfo.name.len>0) { + ip = msg->rcv.bind_address->useinfo.name; + } else { + ip = msg->rcv.bind_address->address_str; } - ip.len= strlen(ip.s); - port = msg->rcv.dst_port; + if(msg->rcv.bind_address->useinfo.port_no>0) { + port = msg->rcv.bind_address->useinfo.port_no; + } else { + port = msg->rcv.bind_address->port_no; + } + if(strncmp(ip.s, "sip:", 4)!=0) { strncpy(contact->s, "sip:", 4);