Skip to content

Commit

Permalink
usrloc: fix sending keepalive messages for IPv6, it was missing the b…
Browse files Browse the repository at this point in the history
…rackets

(cherry picked from commit bd40f0d)
  • Loading branch information
henningw committed Aug 2, 2022
1 parent 6d55d9f commit 1d03d9e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/modules/usrloc/ul_keepalive.c
Expand Up @@ -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" \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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: ":"",
Expand Down

0 comments on commit 1d03d9e

Please sign in to comment.