Module: kamailio
Branch: master
Commit: 2df98c7afdc7ef574124912de01a5fd66f7aa6bb
URL:
https://github.com/kamailio/kamailio/commit/2df98c7afdc7ef574124912de01a5fd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-02-19T09:11:54+01:00
nathelper: received uri is using core function for generating source uri
- transport value is now lower case
---
Modified: modules/nathelper/nathelper.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2df98c7afdc7ef574124912de01a5fd…
Patch:
https://github.com/kamailio/kamailio/commit/2df98c7afdc7ef574124912de01a5fd…
---
diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c
index 20500d2..0c9e4fb 100644
--- a/modules/nathelper/nathelper.c
+++ b/modules/nathelper/nathelper.c
@@ -2223,94 +2223,7 @@ nh_timer(unsigned int ticks, void *timer_idx)
static int
create_rcv_uri(str* uri, struct sip_msg* m)
{
- static char buf[MAX_URI_SIZE];
- char* p;
- str ip, port;
- int len;
- str proto;
-
- if (!uri || !m) {
- LM_ERR("invalid parameter value\n");
- return -1;
- }
-
- ip.s = ip_addr2a(&m->rcv.src_ip);
- ip.len = strlen(ip.s);
-
- port.s = int2str(m->rcv.src_port, &port.len);
-
- switch(m->rcv.proto) {
- case PROTO_NONE:
- case PROTO_UDP:
- proto.s = 0; /* Do not add transport parameter, UDP is default */
- proto.len = 0;
- break;
-
- case PROTO_TCP:
- proto.s = "TCP";
- proto.len = 3;
- break;
-
- case PROTO_TLS:
- proto.s = "TLS";
- proto.len = 3;
- break;
-
- case PROTO_SCTP:
- proto.s = "SCTP";
- proto.len = 4;
- break;
-
- case PROTO_WS:
- case PROTO_WSS:
- proto.s = "WS";
- proto.len = 2;
- break;
-
- default:
- LM_ERR("unknown transport protocol\n");
- return -1;
- }
-
- len = 4 + ip.len + 2*(m->rcv.src_ip.af==AF_INET6)+ 1 + port.len;
- if (proto.s) {
- len += TRANSPORT_PARAM_LEN;
- len += proto.len;
- }
-
- if (len > MAX_URI_SIZE) {
- LM_ERR("buffer too small\n");
- return -1;
- }
-
- p = buf;
- memcpy(p, "sip:", 4);
- p += 4;
-
- if (m->rcv.src_ip.af==AF_INET6)
- *p++ = '[';
- memcpy(p, ip.s, ip.len);
- p += ip.len;
- if (m->rcv.src_ip.af==AF_INET6)
- *p++ = ']';
-
- *p++ = ':';
-
- memcpy(p, port.s, port.len);
- p += port.len;
-
- if (proto.s) {
- memcpy(p, TRANSPORT_PARAM, TRANSPORT_PARAM_LEN);
- p += TRANSPORT_PARAM_LEN;
-
- memcpy(p, proto.s, proto.len);
- p += proto.len;
- }
-
- uri->s = buf;
- uri->len = len;
-
- return 0;
+ return get_src_uri(m, 0, uri);
}