[sr-dev] git:4.2:6a988737: path: received parameter enclosed in square brackets if ipv6

Daniel-Constantin Mierla miconda at gmail.com
Wed Jan 28 13:46:40 CET 2015


Module: kamailio
Branch: 4.2
Commit: 6a9887370e1de87afc7f0da79b09eb62b350469f
URL: https://github.com/kamailio/kamailio/commit/6a9887370e1de87afc7f0da79b09eb62b350469f

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-01-28T13:40:08+01:00

path: received parameter enclosed in square brackets if ipv6

- received should be useless for ipv4, but still can be enforced from
  config, so has to be well formatted because it is followed by a port
- reported by Sebastian Damm

(cherry picked from commit 077b26385854feb701950d020e382c254b803e75)

---

Modified: modules/path/path.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6a9887370e1de87afc7f0da79b09eb62b350469f.diff
Patch: https://github.com/kamailio/kamailio/commit/6a9887370e1de87afc7f0da79b09eb62b350469f.patch

---

diff --git a/modules/path/path.c b/modules/path/path.c
index 3ec28c4..6c350ae 100644
--- a/modules/path/path.c
+++ b/modules/path/path.c
@@ -67,7 +67,7 @@ static int prepend_path(struct sip_msg* _m, str *user, path_param_t param, str *
 
 	/* maximum possible length of suffix */
 	suffix_len = strlen(";lr;received=sip::12345%3Btransport%3Dsctp;ob;>\r\n")
-			+ IP_ADDR_MAX_STR_SIZE + (add_params ? add_params->len : 0) + 1;
+			+ IP_ADDR_MAX_STR_SIZE + 2 + (add_params ? add_params->len : 0) + 1;
 
 	cp = suffix = pkg_malloc(suffix_len);
 	if (!suffix) {
@@ -86,8 +86,13 @@ static int prepend_path(struct sip_msg* _m, str *user, path_param_t param, str *
 		else
 			proto_str = NULL;
 
-		cp += sprintf(cp, ";received=sip:%s:%hu%s", ip_addr2a(&_m->rcv.src_ip),
-				_m->rcv.src_port, proto_str ? : "");
+		if(_m->rcv.src_ip.af==AF_INET6) {
+			cp += sprintf(cp, ";received=sip:[%s]:%hu%s", ip_addr2a(&_m->rcv.src_ip),
+					_m->rcv.src_port, proto_str ? : "");
+		} else {
+			cp += sprintf(cp, ";received=sip:%s:%hu%s", ip_addr2a(&_m->rcv.src_ip),
+					_m->rcv.src_port, proto_str ? : "");
+		}
 		break;
 	case PATH_PARAM_OB:
 		cp += sprintf(cp, ";ob");




More information about the sr-dev mailing list