Browse code

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

(cherry picked from commit bd40f0d08f5d0f14b301cb492d1082c71be91c50)

Henning Westerholt authored on 02/08/2022 08:47:17
Showing 1 changed files
... ...
@@ -61,7 +61,7 @@ Content-Length: 0\r\n\r\n"
61 61
 #define ULKA_CALLID_PREFIX_LEN (sizeof(ULKA_CALLID_PREFIX) - 1)
62 62
 
63 63
 #define ULKA_MSG "%.*s %.*s SIP/2.0\r\n" \
64
-  "Via: SIP/2.0/%.*s %.*s:%.*s;branch=z9hG4bKx.%u.%u.0\r\n" \
64
+  "Via: SIP/2.0/%.*s %s%.*s%s:%.*s;branch=z9hG4bKx.%u.%u.0\r\n" \
65 65
   "%s%.*s%.*s" \
66 66
   "From: <%.*s>;tag=%.*s-%x-%lx-%lx-%x.%x\r\n" \
67 67
   "To: <sip:%.*s%s%.*s>\r\n" \
... ...
@@ -101,6 +101,7 @@ int ul_ka_urecord(urecord_t *ur)
101 101
 	socket_info_t *ssock;
102 102
 	dest_info_t idst;
103 103
 	unsigned int bcnt = 0;
104
+	unsigned int via_ipv6 = 0;
104 105
 	int aortype = 0;
105 106
 	int i;
106 107
 	struct timeval tv;
... ...
@@ -195,8 +196,14 @@ int ul_ka_urecord(urecord_t *ur)
195 196
 		idst.send_sock = ssock;
196 197
 
197 198
 		if(ssock->useinfo.name.len > 0) {
199
+			if (ssock->useinfo.address.af == AF_INET6) {
200
+				via_ipv6 = 1;
201
+			}
198 202
 			vaddr = ssock->useinfo.name;
199 203
 		} else {
204
+			if (ssock->address.af == AF_INET6) {
205
+				via_ipv6 = 1;
206
+			}
200 207
 			vaddr = ssock->address_str;
201 208
 		}
202 209
 		if(ssock->useinfo.port_no > 0) {
... ...
@@ -212,7 +219,9 @@ int ul_ka_urecord(urecord_t *ur)
212 219
 				ul_ka_method.len, ul_ka_method.s,
213 220
 				uc->c.len, uc->c.s,
214 221
 				sproto.len, sproto.s,
222
+				(via_ipv6==1)?"[":"",
215 223
 				vaddr.len, vaddr.s,
224
+				(via_ipv6==1)?"]":"",
216 225
 				vport.len, vport.s,
217 226
 				_ul_ka_counter, bcnt,
218 227
 				(uc->path.len>0)?"Route: ":"",