Module: kamailio
Branch: 5.8
Commit: 3c89405ed74152fd59365ad7dacb144092f5516a
URL: 
https://github.com/kamailio/kamailio/commit/3c89405ed74152fd59365ad7dacb144092f5516a

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2024-09-04T18:58:00+02:00

nathelper: check if alias ipv6 has already square brackets

- GH #3968

(cherry picked from commit 6e01172a138d395fa3f7c3f25238647934137dba)

---

Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3c89405ed74152fd59365ad7dacb144092f5516a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3c89405ed74152fd59365ad7dacb144092f5516a.patch

---

diff --git a/src/modules/nathelper/nathelper.c 
b/src/modules/nathelper/nathelper.c
index 9c0bebad3a7..9ee73e62a21 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -1140,6 +1140,7 @@ static int ki_handle_ruri_alias_mode(struct sip_msg *msg, 
int mode)
                        *trans, *start;
        unsigned int len, rest_len, val_len, alias_len, proto_type, cur_uri_len,
                        ip_len, ip_port_len, port_len, i;
+       int is_ipv6 = 0;
 
        if(parse_sip_msg_uri(msg) < 0) {
                LM_ERR("while parsing Request-URI\n");
@@ -1188,7 +1189,6 @@ static int ki_handle_ruri_alias_mode(struct sip_msg *msg, 
int mode)
        // IPv6 needs some [] added when composing a SIP URI, which further
        // complicates this code.
        ip_len = port - val;
-       int is_ipv6 = 0;
        for(i = 0; i < ip_len; i++) {
                if(val[i] == ':') {
                        is_ipv6 = 1;
@@ -1206,7 +1206,7 @@ static int ki_handle_ruri_alias_mode(struct sip_msg *msg, 
int mode)
        append_str(at, "sip:", 4);
        ip_port_len = trans - val;
        alias_len = _ksr_contact_salias.len + ip_port_len + 2 /* ~n */;
-       if(is_ipv6) {
+       if(is_ipv6 && val[0] != '[') {
                // IPv6 - add '[' ']' around IP
                // then append ':' and copy the port
                append_chr(at, '[');

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to