[sr-dev] git:5.4:14670263: usrloc: fix sending keepalive messages for IPv6, it was missing the brackets

Henning Westerholt hw at gilawa.com
Tue Aug 2 10:50:40 CEST 2022


Module: kamailio
Branch: 5.4
Commit: 14670263837dd158f8f4512a474ea7dee3a561b3
URL: https://github.com/kamailio/kamailio/commit/14670263837dd158f8f4512a474ea7dee3a561b3

Author: Henning Westerholt <hw at gilawa.com>
Committer: Henning Westerholt <hw at gilawa.com>
Date: 2022-08-02T08:50:30Z

usrloc: fix sending keepalive messages for IPv6, it was missing the brackets

(cherry picked from commit bd40f0d08f5d0f14b301cb492d1082c71be91c50)

---

Modified: src/modules/usrloc/ul_keepalive.c

---

Diff:  https://github.com/kamailio/kamailio/commit/14670263837dd158f8f4512a474ea7dee3a561b3.diff
Patch: https://github.com/kamailio/kamailio/commit/14670263837dd158f8f4512a474ea7dee3a561b3.patch

---

diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index a69a76d8b9..5b1572483b 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -61,7 +61,7 @@ Content-Length: 0\r\n\r\n"
 #define ULKA_CALLID_PREFIX_LEN (sizeof(ULKA_CALLID_PREFIX) - 1)
 
 #define ULKA_MSG "%.*s %.*s SIP/2.0\r\n" \
-  "Via: SIP/2.0/%.*s %.*s:%.*s;branch=z9hG4bKx.%u.%u.0\r\n" \
+  "Via: SIP/2.0/%.*s %s%.*s%s:%.*s;branch=z9hG4bKx.%u.%u.0\r\n" \
   "%s%.*s%.*s" \
   "From: <%.*s>;tag=%.*s-%x-%lx-%lx-%x.%x\r\n" \
   "To: <sip:%.*s%s%.*s>\r\n" \
@@ -101,6 +101,7 @@ int ul_ka_urecord(urecord_t *ur)
 	socket_info_t *ssock;
 	dest_info_t idst;
 	unsigned int bcnt = 0;
+	unsigned int via_ipv6 = 0;
 	int aortype = 0;
 	int i;
 	struct timeval tv;
@@ -195,8 +196,14 @@ int ul_ka_urecord(urecord_t *ur)
 		idst.send_sock = ssock;
 
 		if(ssock->useinfo.name.len > 0) {
+			if (ssock->useinfo.address.af == AF_INET6) {
+				via_ipv6 = 1;
+			}
 			vaddr = ssock->useinfo.name;
 		} else {
+			if (ssock->address.af == AF_INET6) {
+				via_ipv6 = 1;
+			}
 			vaddr = ssock->address_str;
 		}
 		if(ssock->useinfo.port_no > 0) {
@@ -212,7 +219,9 @@ int ul_ka_urecord(urecord_t *ur)
 				ul_ka_method.len, ul_ka_method.s,
 				uc->c.len, uc->c.s,
 				sproto.len, sproto.s,
+				(via_ipv6==1)?"[":"",
 				vaddr.len, vaddr.s,
+				(via_ipv6==1)?"]":"",
 				vport.len, vport.s,
 				_ul_ka_counter, bcnt,
 				(uc->path.len>0)?"Route: ":"",




More information about the sr-dev mailing list