Module: kamailio
Branch: master
Commit: 1cda029885dd89e2ec46fe28a0d6f656aad19e7a
URL:
https://github.com/kamailio/kamailio/commit/1cda029885dd89e2ec46fe28a0d6f65…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-09-09T13:01:36+02:00
msrp: proper parsing ipv6 host part in uri
- enclose ipv6 address in square brackets for msrp pv
- related to #2472
---
Modified: src/modules/msrp/msrp_parser.c
Modified: src/modules/msrp/msrp_vars.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1cda029885dd89e2ec46fe28a0d6f65…
Patch:
https://github.com/kamailio/kamailio/commit/1cda029885dd89e2ec46fe28a0d6f65…
---
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);