Module: kamailio
Branch: 5.4
Commit: 23bdd1f6f2581d745f20c66ca9a93e4dad55ffec
URL:
https://github.com/kamailio/kamailio/commit/23bdd1f6f2581d745f20c66ca9a93e4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-10-12T10:03:38+02:00
msrp: proper parsing ipv6 host part in uri
- enclose ipv6 address in square brackets for msrp pv
- related to #2472
(cherry picked from commit 1cda029885dd89e2ec46fe28a0d6f656aad19e7a)
---
Modified: src/modules/msrp/msrp_parser.c
Modified: src/modules/msrp/msrp_vars.c
---
Diff:
https://github.com/kamailio/kamailio/commit/23bdd1f6f2581d745f20c66ca9a93e4…
Patch:
https://github.com/kamailio/kamailio/commit/23bdd1f6f2581d745f20c66ca9a93e4…
---
diff --git a/src/modules/msrp/msrp_parser.c b/src/modules/msrp/msrp_parser.c
index a6310cea93..4e5e67e130 100644
--- a/src/modules/msrp/msrp_parser.c
+++ b/src/modules/msrp/msrp_parser.c
@@ -491,10 +491,25 @@ int msrp_parse_uri(char *start, int len, msrp_uri_t *uri)
}
hook = &uri->host;
hook->s = s;
+ if(*s == '[')
+ {
+ /* IPv6 */
+ p = q_memchr(s, ']', e - s);
+ if(p == NULL)
+ {
+ goto error;
+ }
+ s = p + 1;
+ hook->len = s - hook->s;
+ }
p = q_memchr(s, ':', e - s);
if(p!=NULL)
{
- hook->len = p - hook->s;
+ if(hook->len == 0)
+ {
+ /* host len was not set yet */
+ hook->len = p - hook->s;
+ }
hook = &uri->port;
s = p+1;
if(s>=e) goto error;
diff --git a/src/modules/msrp/msrp_vars.c b/src/modules/msrp/msrp_vars.c
index fddabde189..8384ff0910 100644
--- a/src/modules/msrp/msrp_vars.c
+++ b/src/modules/msrp/msrp_vars.c
@@ -283,7 +283,7 @@ int pv_get_msrp(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
memcpy(p, "msrp://", 7);
p+=7;
}
- strcpy(p, ip_addr2a(&mf->tcpinfo->rcv->src_ip));
+ strcpy(p, ip_addr2strz(&mf->tcpinfo->rcv->src_ip));
strcat(p, ":");
strcat(p, int2str(mf->tcpinfo->rcv->src_port, NULL));
s.len = strlen(s.s);