From_domain interpreted as IPV6

Hello!

We have run into a problem regarding from_domain on PJSIP endpoints when using a domain with a port. Example:

from_domain=sip.example.com:6060

When sending an INVITE with this endpoint, the from-header looks like:

From: sip:12345@[sip.example.com:6060];tag=abcde

As the brackets were added, this lead us to believe this was interpreted as IPV6.

While trying to find why this happens I found this in function sip_dialog_create_from in res_pjsip.c:

/* If the host is IPv6 turn the transport into an IPv6 version */
if (pj_strchr(&sip_uri->host, ':')) {
	type |= PJSIP_TRANSPORT_IPV6;
}

This looks for a : in the uri, and then says this must be IPV6. A bit further down in the same function, the same logic is applied again, and after that brackets are added if the PJSIP_TRANSPORT_IPV6 bit is set.

Is this the probable culprit for this behaviour?

Would a check for two : be a solution? Like

if (pj_strchr(pj_strchr(&sip_uri->host, ':')+1, ':')) {
	type |= PJSIP_TRANSPORT_IPV6;
}

Thanks in advance!

Best Regards
Torbjörn Abrahamsson

Possibly? Though from_domain was never intended to include the port, merely the domain name. I don’t know what other repercussions there could be.

And looking more at the code, it’s a parsed URI so I would think the parser would have already parsed out the port into the URI properly for the code you referenced.

OK, I see!

Is there a correct way to use from_domain, if you want to address a non standard port, like 6060? So that the domain part of the From-header would contain the correct port? We might have missed something obvious…

Thank you for the quick response!

Nothing currently.

OK, then I will keep looking at the code.

Would this be something that could be considered as a bug? Should I file an issue?

I would not consider it a bug, the documentation explicitly states domain. You can submit a feature request if you want[1].

[1] GitHub - asterisk/asterisk-feature-requests: A place to submit feature and improvement requests for the Asterisk project. Contains no code.

Sure! I’ll see what I find…

Thanks for your assistance…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.