Discussion:
[asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field and FQDN
KoltogyanU2 SergeyU2
2018-10-30 04:38:13 UTC
Permalink
PJSIP . How to force use FQDN in the "Contact" field ( INVITE) ?

In the INVITE the "Contact" field looks like this:
Contact: <sip:***@11.22.33.44:5061;transport=TLS>

How to reconfigure Asterisk, or where in the source code to make a change, so that the "Contact" always use FQDN =ast.firma.org and looked like this:
Contact: <sip:***@ast.firma.org:5061;transport=TLS>

?

Description of the problem:
Asterisk 16 (use PJSIP. asterisk build with:
./configure --with-pjproject-bundled -sysconfdir=/etc --libdir=/usr/lib64
)

Asterisk sends a INVITE to the sip.pstnhub.microsoft.com in this form:
<--- Transmitting SIP request (806 bytes) to TLS:52.114.75.24:5061 --->
INVITE sip:+***@sip.pstnhub.microsoft.com:5061 SIP/2.0
Via: SIP/2.0/TLS 11.22.33.44:5061;rport;branch=z9hG4bKPjd2417f6c-8788-4d40-b666-3244b903d886;alias
From: <sip:***@ast.firma.org>;tag=9912223a-ff74-4ba6-8a0f-c3225e70eaba
To: <sip:+***@sip.pstnhub.microsoft.com>
Contact: <sip:***@11.22.33.44:5061;transport=TLS>
Call-ID: ee581ee7-e624-41cb-a486-b06cf233c63c
CSeq: 19204 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 16.0.0
Content-Type: application/sdp
Content-Length: 92

v=0
o=- 233177990 233177990 IN IP4 11.22.33.44
s=Asterisk
c=IN IP4 40.127.205.7
t=0 0


Where 11.22.33.44 - Asterisk public IP Address ( Asterisk over NAT ):
Asterisk(172.18.1.16)--->NAT(11.22.33.44)---->ISP

In the INVITE the "Contact" field looks like this:
Contact: <sip:***@11.22.33.44:5061;transport=TLS>

How to reconfigure Asterisk, or where in the source code to make a change,
so that the "Contact" always use FQDN =ast.firma.org and looked like this:
Contact: <sip:***@ast.firma.org:5061;transport=TLS>

Serg
?
Mani Kanta Gadde
2018-10-30 06:03:03 UTC
Permalink
Use the external_media_address and external_signalling_address in PJSIP in
general section.

These variables will explicitly put the required IP in SIP messages, so
that other SIP phone/VoIP server know where to reply.


Thanks & Regards
Manikanta


On Tue, Oct 30, 2018 at 10:08 AM KoltogyanU2 SergeyU2 <***@amintegrator.com>
wrote:

>
> PJSIP . How to force use FQDN in the "Contact" field ( INVITE) ?
>
> In the INVITE the "Contact" field looks like this:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> How to reconfigure Asterisk, or where in the source code to make a change,
> so that the "Contact" always use FQDN =ast.firma.org and looked like
> this:
> Contact: <sip:***@ast.firma.org:5061;transport=TLS>
>
> ?
>
> Description of the problem:
> Asterisk 16 (use PJSIP. asterisk build with:
> ./configure --with-pjproject-bundled -sysconfdir=/etc --libdir=/usr/lib64
> )
>
> Asterisk sends a INVITE to the sip.pstnhub.microsoft.com in this form:
> <--- Transmitting SIP request (806 bytes) to TLS:52.114.75.24:5061 --->
> INVITE sip:+***@sip.pstnhub.microsoft.com:5061 SIP/2.0
> Via: SIP/2.0/TLS 11.22.33.44:5061
> ;rport;branch=z9hG4bKPjd2417f6c-8788-4d40-b666-3244b903d886;alias
> From: <sip:***@ast.firma.org>;tag=9912223a-ff74-4ba6-8a0f-c3225e70eaba
> To: <sip:+***@sip.pstnhub.microsoft.com>
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
> Call-ID: ee581ee7-e624-41cb-a486-b06cf233c63c
> CSeq: 19204 INVITE
> Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE,
> CANCEL, UPDATE, PRACK, MESSAGE, REFER
> Supported: 100rel, timer, replaces, norefersub
> Session-Expires: 1800
> Min-SE: 90
> Max-Forwards: 70
> User-Agent: Asterisk PBX 16.0.0
> Content-Type: application/sdp
> Content-Length: 92
>
> v=0
> o=- 233177990 233177990 IN IP4 11.22.33.44
> s=Asterisk
> c=IN IP4 40.127.205.7
> t=0 0
>
>
> Where 11.22.33.44 - Asterisk public IP Address ( Asterisk over NAT ):
> Asterisk(172.18.1.16)--->NAT(11.22.33.44)---->ISP
>
> In the INVITE the "Contact" field looks like this:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> How to reconfigure Asterisk, or where in the source code to make a change,
> so that the "Contact" always use FQDN =ast.firma.org and looked like
> this:
> Contact: <sip:***@ast.firma.org:5061;transport=TLS>
>
> Serg
> ?
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> Astricon is coming up October 9-11! Signup is available at:
> https://www.asterisk.org/community/astricon-user-conference
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
KoltogyanU2 SergeyU2
2018-10-30 08:05:39 UTC
Permalink
Thank. it has been configured:
$ cat /etc/asterisk/pjsip.conf | grep -i "external"
external_media_address=11.22.33.44
external_signaling_address=11.22.33.44

As a result - in the "Contact" field of the request "INVITE" is indicated IP ddress and not FQDN:
Contact: <sip:***@11.22.33.44:5061;transport=TLS>

It is necessary for me that instead of IP Address there was a FQDN, example:
Contact: <sip:***@ast.firma.org:5061;transport=TLS>

How i can do this ?
Where in the source code to make a change?

Serg


________________________________
From: asterisk-dev <asterisk-dev-***@lists.digium.com> on behalf of Mani Kanta Gadde <***@zemosolabs.com>
Sent: Tuesday, October 30, 2018 8:03
To: asterisk-***@lists.digium.com
Subject: Re: [asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field and FQDN

Use the external_media_address and external_signalling_address in PJSIP in general section.

These variables will explicitly put the required IP in SIP messages, so that other SIP phone/VoIP server know where to reply.


Thanks & Regards
Manikanta


On Tue, Oct 30, 2018 at 10:08 AM KoltogyanU2 SergeyU2 <***@amintegrator.com<mailto:***@amintegrator.com>> wrote:

PJSIP . How to force use FQDN in the "Contact" field ( INVITE) ?

In the INVITE the "Contact" field looks like this:
Contact: <sip:***@11.22.33.44:5061;transport=TLS>

How to reconfigure Asterisk, or where in the source code to make a change, so that the "Contact" always use FQDN =ast.firma.org<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fast.firma.org&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=SXju69fIhpTARkNrterbLYhzdN5KeIC8lFMhILQhOFM%3D&reserved=0> and looked like this:
Contact: <sip:***@ast.firma.org:5061;transport=TLS>

?

Description of the problem:
Asterisk 16 (use PJSIP. asterisk build with:
./configure --with-pjproject-bundled -sysconfdir=/etc --libdir=/usr/lib64
)

Asterisk sends a INVITE to the sip.pstnhub.microsoft.com<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsip.pstnhub.microsoft.com&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=T0%2FsRAuJEOFdq6tTqbOIWYTLCIXyDTF8sP9LwRj85KQ%3D&reserved=0> in this form:
<--- Transmitting SIP request (806 bytes) to TLS:52.114.75.24:5061<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2F52.114.75.24%3A5061&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=k5BOHpk7%2B9a%2Fo%2BE6%2ByRQ%2FPKz3sJ6p1xPJACDiLAni4c%3D&reserved=0> --->
INVITE sip:+***@sip.pstnhub.microsoft.com:5061<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsip%3A%2B380770081%40sip.pstnhub.microsoft.com%3A5061&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=kiay5u7zJuMB2rYSG5ytHwCeJZZd8g3IEARPBCrOa5E%3D&reserved=0> SIP/2.0
Via: SIP/2.0/TLS 11.22.33.44:5061;rport;branch=z9hG4bKPjd2417f6c-8788-4d40-b666-3244b903d886;alias
From: <sip:***@ast.firma.org<mailto:sip%***@ast.firma.org>>;tag=9912223a-ff74-4ba6-8a0f-c3225e70eaba
To: <sip:+***@sip.pstnhub.microsoft.com<mailto:sip%3A%***@sip.pstnhub.microsoft.com>>
Contact: <sip:***@11.22.33.44:5061;transport=TLS>
Call-ID: ee581ee7-e624-41cb-a486-b06cf233c63c
CSeq: 19204 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 16.0.0
Content-Type: application/sdp
Content-Length: 92

v=0
o=- 233177990 233177990 IN IP4 11.22.33.44
s=Asterisk
c=IN IP4 40.127.205.7
t=0 0


Where 11.22.33.44 - Asterisk public IP Address ( Asterisk over NAT ):
Asterisk(172.18.1.16)--->NAT(11.22.33.44)---->ISP

In the INVITE the "Contact" field looks like this:
Contact: <sip:***@11.22.33.44:5061;transport=TLS>

How to reconfigure Asterisk, or where in the source code to make a change,
so that the "Contact" always use FQDN =ast.firma.org<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fast.firma.org&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=SXju69fIhpTARkNrterbLYhzdN5KeIC8lFMhILQhOFM%3D&reserved=0> and looked like this:
Contact: <sip:***@ast.firma.org:5061;transport=TLS>

Serg
?


--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.api-digital.com&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=3UhVy2X8BMu8BtWkMoBvGqZlcNOgXlj5ppDHildrx3s%3D&reserved=0> --

Astricon is coming up October 9-11! Signup is available at: https://www.asterisk.org/community/astricon-user-conference<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asterisk.org%2Fcommunity%2Fastricon-user-conference&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=zn6WU%2BiP1InpwuR1h9VMiQ84xUn%2F8ViIzgtOa1RHQw0%3D&reserved=0>

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.digium.com%2Fmailman%2Flistinfo%2Fasterisk-dev&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=vCXE1WzASgA%2BmQZnNdAVM7J%2FQpI5Z5zYgHde2c%2FEK%2Bk%3D&reserved=0>
Mani Kanta Gadde
2018-10-30 12:12:32 UTC
Permalink
I think you can also set the DNS instead of IP itself. Try it
Thanks & Regards
Manikanta


On Tue, Oct 30, 2018 at 1:35 PM KoltogyanU2 SergeyU2 <***@amintegrator.com>
wrote:

> Thank. it has been configured:
> $ cat /etc/asterisk/pjsip.conf | grep -i "external"
> external_media_address=11.22.33.44
> external_signaling_address=11.22.33.44
>
> As a result - in the "Contact" field of the request "INVITE" is indicated
> IP ddress and not FQDN:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> It is necessary for me that instead of IP Address there was a FQDN,
> example:
> Contact: <sip:***@ast.firma.org:5061;transport=TLS>
>
> How i can do this ?
> Where in the source code to make a change?
>
> Serg
>
>
> ------------------------------
> *From:* asterisk-dev <asterisk-dev-***@lists.digium.com> on behalf of
> Mani Kanta Gadde <***@zemosolabs.com>
> *Sent:* Tuesday, October 30, 2018 8:03
> *To:* asterisk-***@lists.digium.com
> *Subject:* Re: [asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field
> and FQDN
>
> Use the external_media_address and external_signalling_address in PJSIP in
> general section.
>
> These variables will explicitly put the required IP in SIP messages, so
> that other SIP phone/VoIP server know where to reply.
>
>
> Thanks & Regards
> Manikanta
>
>
> On Tue, Oct 30, 2018 at 10:08 AM KoltogyanU2 SergeyU2 <***@amintegrator.com>
> wrote:
>
>
> PJSIP . How to force use FQDN in the "Contact" field ( INVITE) ?
>
> In the INVITE the "Contact" field looks like this:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> How to reconfigure Asterisk, or where in the source code to make a change,
> so that the "Contact" always use FQDN =ast.firma.org
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fast.firma.org&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=SXju69fIhpTARkNrterbLYhzdN5KeIC8lFMhILQhOFM%3D&reserved=0>
> and looked like this:
> Contact: <sip:***@ast.firma.org:5061;transport=TLS>
>
> ?
>
> Description of the problem:
> Asterisk 16 (use PJSIP. asterisk build with:
> ./configure --with-pjproject-bundled -sysconfdir=/etc --libdir=/usr/lib64
> )
>
> Asterisk sends a INVITE to the sip.pstnhub.microsoft.com
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsip.pstnhub.microsoft.com&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=T0%2FsRAuJEOFdq6tTqbOIWYTLCIXyDTF8sP9LwRj85KQ%3D&reserved=0>
> in this form:
> <--- Transmitting SIP request (806 bytes) to TLS:52.114.75.24:5061
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2F52.114.75.24%3A5061&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=k5BOHpk7%2B9a%2Fo%2BE6%2ByRQ%2FPKz3sJ6p1xPJACDiLAni4c%3D&reserved=0>
> --->
> INVITE sip:+***@sip.pstnhub.microsoft.com:5061
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsip%3A%2B380770081%40sip.pstnhub.microsoft.com%3A5061&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=kiay5u7zJuMB2rYSG5ytHwCeJZZd8g3IEARPBCrOa5E%3D&reserved=0>
> SIP/2.0
> Via: SIP/2.0/TLS 11.22.33.44:5061
> ;rport;branch=z9hG4bKPjd2417f6c-8788-4d40-b666-3244b903d886;alias
> From: <sip:***@ast.firma.org>;tag=9912223a-ff74-4ba6-8a0f-c3225e70eaba
> To: <sip:+***@sip.pstnhub.microsoft.com>
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
> Call-ID: ee581ee7-e624-41cb-a486-b06cf233c63c
> CSeq: 19204 INVITE
> Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE,
> CANCEL, UPDATE, PRACK, MESSAGE, REFER
> Supported: 100rel, timer, replaces, norefersub
> Session-Expires: 1800
> Min-SE: 90
> Max-Forwards: 70
> User-Agent: Asterisk PBX 16.0.0
> Content-Type: application/sdp
> Content-Length: 92
>
> v=0
> o=- 233177990 233177990 IN IP4 11.22.33.44
> s=Asterisk
> c=IN IP4 40.127.205.7
> t=0 0
>
>
> Where 11.22.33.44 - Asterisk public IP Address ( Asterisk over NAT ):
> Asterisk(172.18.1.16)--->NAT(11.22.33.44)---->ISP
>
> In the INVITE the "Contact" field looks like this:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> How to reconfigure Asterisk, or where in the source code to make a change,
> so that the "Contact" always use FQDN =ast.firma.org
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fast.firma.org&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=SXju69fIhpTARkNrterbLYhzdN5KeIC8lFMhILQhOFM%3D&reserved=0>
> and looked like this:
> Contact: <sip:***@ast.firma.org:5061;transport=TLS>
>
> Serg
> ?
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.api-digital.com&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=3UhVy2X8BMu8BtWkMoBvGqZlcNOgXlj5ppDHildrx3s%3D&reserved=0>
> --
>
> Astricon is coming up October 9-11! Signup is available at:
> https://www.asterisk.org/community/astricon-user-conference
> <https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asterisk.org%2Fcommunity%2Fastricon-user-conference&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=zn6WU%2BiP1InpwuR1h9VMiQ84xUn%2F8ViIzgtOa1RHQw0%3D&reserved=0>
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.digium.com%2Fmailman%2Flistinfo%2Fasterisk-dev&data=02%7C01%7Cu2%40amintegrator.com%7C560fe46fc314491f9bc508d63e2d6727%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764762056891576&sdata=vCXE1WzASgA%2BmQZnNdAVM7J%2FQpI5Z5zYgHde2c%2FEK%2Bk%3D&reserved=0>
>
>
Joshua C. Colp
2018-10-30 12:19:42 UTC
Permalink
On Tue, Oct 30, 2018, at 9:12 AM, Mani Kanta Gadde wrote:
> I think you can also set the DNS instead of IP itself. Try it
> Thanks & Regards
> Manikanta

A hostname is not supported with the external_* options, for placement into the messages. It gets resolved down to the IP address. Placing a hostname into the Contact header URI host is not currently supported out of the box. The Contact stuff is handled within res_pjsip.c, the easiest option being to look for use of "contact_user" as that already modifies the user portion and using that as a base for any modification.

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Astricon is coming up October 9-11! Signup is available at: https://www.asterisk.org/community/astricon-user-conference

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk
KoltogyanU2 SergeyU2
2018-10-30 13:16:49 UTC
Permalink
I found a place in res_pjsip.c, where a new "contact_user" is added.
This is file ./res/res_pjsip.c string 3514
pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);

I Tried this:
pj_strdup2(dlg->pool, &sip_uri->user, "XXYYZZ");
So it works - it changes the ContactUserName ( on the left of @ ).

But I do not find a place where I can enter FQDN, instead of the IP address.
Someone can tell - in which place of the source text to make a change, what was right of @ was not an IP Address, but a FQDN?



________________________________
From: asterisk-dev <asterisk-dev-***@lists.digium.com> on behalf of Joshua C. Colp <***@digium.com>
Sent: Tuesday, October 30, 2018 14:19
To: asterisk-***@lists.digium.com
Subject: Re: [asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field and FQDN

On Tue, Oct 30, 2018, at 9:12 AM, Mani Kanta Gadde wrote:
> I think you can also set the DNS instead of IP itself. Try it
> Thanks & Regards
> Manikanta

A hostname is not supported with the external_* options, for placement into the messages. It gets resolved down to the IP address. Placing a hostname into the Contact header URI host is not currently supported out of the box. The Contact stuff is handled within res_pjsip.c, the easiest option being to look for use of "contact_user" as that already modifies the user portion and using that as a base for any modification.

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: https://emea01.safelinks.protection.outlook.com/?url=www.digium.com&amp;data=02%7C01%7Cu2%40amintegrator.com%7C8fef6e3cc0784547d3cb08d63e61fe51%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764987937407942&amp;sdata=RlqsUvtKA0wb%2F3dWWqEEB5MxhvSIYvtwe5O%2FmS2WE%2FQ%3D&amp;reserved=0 & https://emea01.safelinks.protection.outlook.com/?url=www.asterisk.org&amp;data=02%7C01%7Cu2%40amintegrator.com%7C8fef6e3cc0784547d3cb08d63e61fe51%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764987937407942&amp;sdata=3cFldB%2Bbb3VHyPd87t1tvSPevM3vvzfyNygN5poCp1k%3D&amp;reserved=0

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.api-digital.com&amp;data=02%7C01%7Cu2%40amintegrator.com%7C8fef6e3cc0784547d3cb08d63e61fe51%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764987937407942&amp;sdata=Z4gx8OTFhl%2FqWOj4mT2tYZJJzrwzIA5fql8PSV55mpQ%3D&amp;reserved=0 --

Astricon is coming up October 9-11! Signup is available at: https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asterisk.org%2Fcommunity%2Fastricon-user-conference&amp;data=02%7C01%7Cu2%40amintegrator.com%7C8fef6e3cc0784547d3cb08d63e61fe51%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764987937407942&amp;sdata=B1vCN2ini%2BXiEY18UfO%2BUF8MkW%2FF%2FgkEMJryV1wfgHU%3D&amp;reserved=0

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.digium.com%2Fmailman%2Flistinfo%2Fasterisk-dev&amp;data=02%7C01%7Cu2%40amintegrator.com%7C8fef6e3cc0784547d3cb08d63e61fe51%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636764987937407942&amp;sdata=zxjbVaWbmeSQPb2c56NaZi2NchNuDLmlpPSBhBcqPWw%3D&amp;reserved=0
Joshua C. Colp
2018-10-30 13:19:12 UTC
Permalink
On Tue, Oct 30, 2018, at 10:16 AM, KoltogyanU2 SergeyU2 wrote:
> I found a place in res_pjsip.c, where a new "contact_user" is added.
> This is file ./res/res_pjsip.c string 3514
> pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);
>
> I Tried this:
> pj_strdup2(dlg->pool, &sip_uri->user, "XXYYZZ");
> So it works - it changes the ContactUserName ( on the left of @ ).
>
> But I do not find a place where I can enter FQDN, instead of the IP
> address.
> Someone can tell - in which place of the source text to make a change,
> what was right of @ was not an IP Address, but a FQDN?

The structure of a PJSIP SIP URI is documented in their doxygen[1], this includes the part you are looking for (the hostname portion).

[1] https://www.pjsip.org/pjsip/docs/html/structpjsip__sip__uri.htm

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Astricon is coming up October 9-11! Signup is available at: https://www.asterisk.org/community/astricon-user-conference

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asteri
KoltogyanU2 SergeyU2
2018-10-30 14:31:37 UTC
Permalink
I tried it(./res/res_pjsip.c :
if (!ast_strlen_zero(endpoint->contact_user)) {
pjsip_sip_uri *sip_uri;
sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
file004r = fopen("/tmp/0/res_pjsip.log","ab");
fwrite("\n456=456\n",strlen("\n456=456\n"),1,file004r);
fwrite("\n===SIP_URI_USER_BEFORE=\n",strlen("\n===SIP_URI_USER_BEFORE=\n"),1,file004r);
fwrite(sip_uri->user.ptr,sip_uri->user.slen,1,file004r);
fwrite("\n===SIP_URI_HOST_BEFORE=\n",strlen("\n===SIP_URI_HOST_BEFORE=\n"),1,file004r);
fwrite(sip_uri->host.ptr,sip_uri->host.slen,1,file004r);

pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);

fwrite("\n===SIP_URI_USER_AFTER=\n",strlen("\n===SIP_URI_USER_AFTER=\n"),1,file004r);
fwrite(sip_uri->user.ptr,sip_uri->user.slen,1,file004r);
fwrite("\n===SIP_URI_HOST_AFTER=\n",strlen("\n===SIP_URI_HOST_AFTER=\n"),1,file004r);
fwrite(sip_uri->host.ptr,sip_uri->host.slen,1,file004r);
fclose(file004r);

}

added at /etc/asterisk/pjsip.conf
contact_user = asterisk654

make && make install
systemctl restart asterisk

made a test call
and results:
cat /tmp/0/res_pjsip.log
456=456

===SIP_URI_USER_BEFORE=
asterisk
===SIP_URI_HOST_BEFORE=
ast.firma.org
===SIP_URI_USER_AFTER=
asterisk654
===SIP_URI_HOST_AFTER=
ast.firma.org

Apparently sip_uri->host has already had the value "ast.firma.org",
but in the INVITE in the "Contact" field - ip address = 11.22.33.44:
Contact: <sip:***@11.22.33.44:5061;transport=TLS>

Such INVITE sent asterisk:
<--- Transmitting SIP request (813 bytes) to TLS:52.114.76.76:5061 --->
INVITE sip:+***@sip.pstnhub.microsoft.com:5061 SIP/2.0
Via: SIP/2.0/TLS 11.22.33.44:5061;rport;branch=z9hG4bKPj70d53a0c-a0f3-479a-8917-00082632d069;alias
From: <sip:***@ast.firma.org>;tag=afd3b600-886a-45fb-a120-5faac8220cec
To: <sip:+***@sip.pstnhub.microsoft.com>
Contact: <sip:***@11.22.33.44:5061;transport=TLS>
Call-ID: b0323db6-6e7f-4dc4-bfa9-309683031962
CSeq: 20795 INVITE


Serg

________________________________
From: Joshua C. Colp <***@digium.com>
Sent: Tuesday, October 30, 2018 15:19
To: ëÏÌÔÏÇÑÎ óÅÒÇÅÊ òÕÂÅÎÏ×ÉÞ U2; Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field and FQDN

On Tue, Oct 30, 2018, at 10:16 AM, KoltogyanU2 SergeyU2 wrote:
> I found a place in res_pjsip.c, where a new "contact_user" is added.
> This is file ./res/res_pjsip.c string 3514
> pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);
>
> I Tried this:
> pj_strdup2(dlg->pool, &sip_uri->user, "XXYYZZ");
> So it works - it changes the ContactUserName ( on the left of @ ).
>
> But I do not find a place where I can enter FQDN, instead of the IP
> address.
> Someone can tell - in which place of the source text to make a change,
> what was right of @ was not an IP Address, but a FQDN?

The structure of a PJSIP SIP URI is documented in their doxygen[1], this includes the part you are looking for (the hostname portion).

[1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.pjsip.org%2Fpjsip%2Fdocs%2Fhtml%2Fstructpjsip__sip__uri.htm&amp;data=02%7C01%7Cu2%40amintegrator.com%7C0016dac0a75c4036998908d63e6a4b76%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765023596895828&amp;sdata=oMRG%2FzRlBEeTvbQudg2l7Y3UjNfp8iBgRls1OAxPSzo%3D&amp;reserved=0

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: https://emea01.safelinks.protection.outlook.com/?url=www.digium.com&amp;data=02%7C01%7Cu2%40amintegrator.com%7C0016dac0a75c4036998908d63e6a4b76%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765023596895828&amp;sdata=rJ%2BfZ0c0nEeD%2FesxKp9u8897STKvKdH56s2B6fRBfto%3D&amp;reserved=0 & https://emea01.safelinks.protection.outlook.com/?url=www.asterisk.org&amp;data=02%7C01%7Cu2%40amintegrator.com%7C0016dac0a75c4036998908d63e6a4b76%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765023596895828&amp;sdata=wRhVtosDsSsfYHrGe8YCKTRMia7EUQxTtRxBTaJpU%2Fg%3D&amp;reserved=0
Joshua C. Colp
2018-10-30 14:33:46 UTC
Permalink
On Tue, Oct 30, 2018, at 11:31 AM, KoltogyanU2 SergeyU2 wrote:

<snip>

> Apparently sip_uri->host has already had the value "ast.firma.org",
> but in the INVITE in the "Contact" field - ip address = 11.22.33.44:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> Such INVITE sent asterisk:
> <--- Transmitting SIP request (813 bytes) to TLS:52.114.76.76:5061 --->
> INVITE sip:+***@sip.pstnhub.microsoft.com:5061 SIP/2.0
> Via: SIP/2.0/TLS 11.22.33.44:5061;rport;branch=z9hG4bKPj70d53a0c-a0f3-
> 479a-8917-00082632d069;alias
> From: <sip:***@ast.firma.org>;tag=afd3b600-886a-45fb-a120-5faac8220cec
> To: <sip:+***@sip.pstnhub.microsoft.com>
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
> Call-ID: b0323db6-6e7f-4dc4-bfa9-309683031962
> CSeq: 20795 INVITE

You would need to track down why that is, then. It may be that the NAT code or multihomed code is changing it.

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Astricon is coming up October 9-11! Signup is available at: https://www.asterisk.org/community/astricon-user-conference

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
KoltogyanU2 SergeyU2
2018-10-30 16:58:42 UTC
Permalink
"NAT code" - it`s ./res/res_pjsip_nat.c ?
"multihomed code" - What is this ?



________________________________
From: Joshua C. Colp <***@digium.com>
Sent: Tuesday, October 30, 2018 16:33
To: ëÏÌÔÏÇÑÎ óÅÒÇÅÊ òÕÂÅÎÏ×ÉÞ U2; Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field and FQDN

On Tue, Oct 30, 2018, at 11:31 AM, KoltogyanU2 SergeyU2 wrote:

<snip>

> Apparently sip_uri->host has already had the value "ast.firma.org",
> but in the INVITE in the "Contact" field - ip address = 11.22.33.44:
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
>
> Such INVITE sent asterisk:
> <--- Transmitting SIP request (813 bytes) to TLS:52.114.76.76:5061 --->
> INVITE sip:+***@sip.pstnhub.microsoft.com:5061 SIP/2.0
> Via: SIP/2.0/TLS 11.22.33.44:5061;rport;branch=z9hG4bKPj70d53a0c-a0f3-
> 479a-8917-00082632d069;alias
> From: <sip:***@ast.firma.org>;tag=afd3b600-886a-45fb-a120-5faac8220cec
> To: <sip:+***@sip.pstnhub.microsoft.com>
> Contact: <sip:***@11.22.33.44:5061;transport=TLS>
> Call-ID: b0323db6-6e7f-4dc4-bfa9-309683031962
> CSeq: 20795 INVITE

You would need to track down why that is, then. It may be that the NAT code or multihomed code is changing it.

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: https://emea01.safelinks.protection.outlook.com/?url=www.digium.com&amp;data=02%7C01%7Cu2%40amintegrator.com%7Cdebac7a77e244af4176608d63e74b5c6%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765068326808022&amp;sdata=TGYAaYvOZ14iQlGdS%2BvWLvPEkxKBVsm4pjPq1CX41tY%3D&amp;reserved=0 & https://emea01.safelinks.protection.outlook.com/?url=www.asterisk.org&amp;data=02%7C01%7Cu2%40amintegrator.com%7Cdebac7a77e244af4176608d63e74b5c6%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765068326808022&amp;sdata=X5u24UsJTIinAyFOBpz87aUuBbQ7o7k0NsNTEmOiC50%3D&amp;reserved=0
Joshua C. Colp
2018-10-30 17:52:17 UTC
Permalink
On Tue, Oct 30, 2018, at 1:58 PM, KoltogyanU2 SergeyU2 wrote:
> "NAT code" - it`s ./res/res_pjsip_nat.c ?

Yes.

> "multihomed code" - What is this ?

That code is contained in res/res_pjsip/pjsip_message_filter.c

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Astricon is coming up October 9-11! Signup is available at: https://www.asterisk.org/community/astricon-user-conference

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://l
KoltogyanU2 SergeyU2
2018-10-30 18:57:43 UTC
Permalink
Thanks for the help. I found what I was looking for.
/res/res_pjsip_nat.c

cat /datadrive/src/asterisk-16.0.0/res/res_pjsip_nat.c | grep -ni ast.firma.org
pj_strdup2(tdata->pool, &uri->host, "ast.firma.org");
pj_strdup2(tdata->pool, &via->sent_by.host, "ast.firma.org");

this is in the function:
static pj_status_t nat_on_tx_message(pjsip_tx_data *tdata)
{
RAII_VAR(struct ao2_container *, transport_states, NULL, ao2_cleanup);
RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
RAII_VAR(struct ast_sip_transport_state *, transport_state, NULL, ao2_cleanup);
struct request_transport_details details = { 0, };
.......


Serg


________________________________
From: Joshua C. Colp <***@digium.com>
Sent: Tuesday, October 30, 2018 19:52
To: ëÏÌÔÏÇÑÎ óÅÒÇÅÊ òÕÂÅÎÏ×ÉÞ U2; Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] Asterisk 16. PJSIP. INVITE. "Contact" field and FQDN

On Tue, Oct 30, 2018, at 1:58 PM, KoltogyanU2 SergeyU2 wrote:
> "NAT code" - it`s ./res/res_pjsip_nat.c ?

Yes.

> "multihomed code" - What is this ?

That code is contained in res/res_pjsip/pjsip_message_filter.c

--
Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: https://emea01.safelinks.protection.outlook.com/?url=www.digium.com&amp;data=02%7C01%7Cu2%40amintegrator.com%7C7b9ed3cce854492f73e708d63e907169%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765187443945780&amp;sdata=mL%2F3EVTrDtbKZYpJbKX8zWzT5jjS2VpjuTE0hPrKbOI%3D&amp;reserved=0 & https://emea01.safelinks.protection.outlook.com/?url=www.asterisk.org&amp;data=02%7C01%7Cu2%40amintegrator.com%7C7b9ed3cce854492f73e708d63e907169%7C806bcdf8cdfb4595995e80fbcae20097%7C0%7C0%7C636765187443945780&amp;sdata=DWioncHIdkZzeLv99qlUEp0sl9X%2F%2BrMkOtOA%2F7mqyHk%3D&amp;reserved=0
Loading...