Module: kamailio
Branch: master
Commit: aa9129b71bb009176571a8cb5bde7221b2f92b75
URL:
https://github.com/kamailio/kamailio/commit/aa9129b71bb009176571a8cb5bde722…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-06-27T16:14:52+02:00
core: parser - get_rcv_socket_uri() with option to use advertised address
---
Modified: src/core/parser/msg_parser.c
Modified: src/core/parser/msg_parser.h
---
Diff:
https://github.com/kamailio/kamailio/commit/aa9129b71bb009176571a8cb5bde722…
Patch:
https://github.com/kamailio/kamailio/commit/aa9129b71bb009176571a8cb5bde722…
---
diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c
index 84a7ba6ff5..be137652de 100644
--- a/src/core/parser/msg_parser.c
+++ b/src/core/parser/msg_parser.c
@@ -1105,8 +1105,9 @@ int get_src_uri(sip_msg_t *m, int tmode, str *uri)
/**
* get received-on-socket ip, port and protocol in SIP URI format
* - tmode - 0: short format (transport=udp is not added, being default)
+ * - atype - 0: listen address; 1: advertised address
*/
-int get_rcv_socket_uri(sip_msg_t *m, int tmode, str *uri)
+int get_rcv_socket_uri(sip_msg_t *m, int tmode, str *uri, int atype)
{
static char buf[MAX_URI_SIZE];
char* p;
@@ -1139,11 +1140,21 @@ int get_rcv_socket_uri(sip_msg_t *m, int tmode, str *uri)
}
}
- ip.s = m->rcv.bind_address->address_str.s;
- ip.len = m->rcv.bind_address->address_str.len;
+ if(atype==0 || m->rcv.bind_address->useinfo.address_str.len<=0) {
+ ip.s = m->rcv.bind_address->address_str.s;
+ ip.len = m->rcv.bind_address->address_str.len;
+ } else {
+ ip.s = m->rcv.bind_address->useinfo.address_str.s;
+ ip.len = m->rcv.bind_address->useinfo.address_str.len;
+ }
- port.s = m->rcv.bind_address->port_no_str.s;
- port.len = m->rcv.bind_address->port_no_str.len;
+ if(atype==0|| m->rcv.bind_address->useinfo.port_no_str.len <= 0) {
+ port.s = m->rcv.bind_address->port_no_str.s;
+ port.len = m->rcv.bind_address->port_no_str.len;
+ } else {
+ port.s = m->rcv.bind_address->useinfo.port_no_str.s;
+ port.len = m->rcv.bind_address->useinfo.port_no_str.len;
+ }
len = 4 + ip.len + 2*(m->rcv.src_ip.af==AF_INET6)+ 1 + port.len;
if (proto.s) {
diff --git a/src/core/parser/msg_parser.h b/src/core/parser/msg_parser.h
index dd5f498a12..41e6deeb33 100644
--- a/src/core/parser/msg_parser.h
+++ b/src/core/parser/msg_parser.h
@@ -501,6 +501,6 @@ int get_src_uri(sip_msg_t *m, int tmode, str *uri);
/**
* get received-on-socket ip, port and protocol in SIP URI format
*/
-int get_rcv_socket_uri(sip_msg_t *m, int tmode, str *uri);
+int get_rcv_socket_uri(sip_msg_t *m, int tmode, str *uri, int atype);
#endif