Hacking on PJSIP for Asterisk ... Some Friday Fun!

Happy Friday!

Working with 18.8.0 source …

I’m developing a proof of concept for integrating with some 3rd party SBCs … one of them requires that the sip contact and via address show the fqdn instead of the ip address.

I got it working by hard coding the fqdn into res_pjsip_nat.c, static pj_status_t process_nat(pjsip_tx_data *tdata)(), which works great!

I changed:

pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
pj_strdup2(tdata->pool, &via->sent_by.host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));


pj_strdup2(tdata->pool, &uri->host, "some.domain.net");
pj_strdup2(tdata->pool, &via->sent_by.host, "some.domain.net");

My immediate goal is to make the fqdn arbitrary based on the endpoint, using two new pjsip.conf endpoint settings:


I’m confused on how to properly define a new property for pjsip.conf and then access that property in this function.

Ultimate goal is to get a patch submitted for consideration.

Any push in the right direction would be awesome!



Looks like this will have to be transport based due to TLS certificate requirements.

The transport properties are already available in this function.

Over the weekend I tried and failed to add a new transport setting for pjsip.conf, I hacked on the res_pjsip* source code but can’t seem to figure out how to properly add a new string.

Can someone point me in the right direction of properly adding a new pjsip.conf string setting to the source?

Big thanks for any help!

These are developer questions, and may relate to the PJSIP project, not the Asterisk one. For Asterisk project developer issues, there is a developer mailing list and IRC channel. I don’t know what arrangements exist for PJSIP.

Transport options are added in multiple places. The first place is where it is defined as part of the transport[1]. Secondly sorcery is told it exists[2]. Thirdly it has to be documented[3].

[1] asterisk/res_pjsip.h at master · asterisk/asterisk · GitHub
[2] asterisk/config_transport.c at master · asterisk/asterisk · GitHub
[3] asterisk/res_pjsip.c at master · asterisk/asterisk · GitHub

Thanks @jcolp I was all over those three files, diving back in :slight_smile:

Then you’ll need to be more specific in the future about what isn’t working and what happens.

It would just fail to compile not finding my test string with the compiler suggesting alternatives. Just my ignorance at work, but I’m nose down on it this week, determined.

Boom! Success, at least as far as the setting goes. I missed adding it to sorcery.

The calls progress like it was hard coded in my original example … and properly sets the fqdn in th sip header’s via and contact fields … except asterisk crashes on hangup, so on to investigating that.

Big thanks :sunglasses:

1 Like

I had good success with this as long as I didn’t try to override the VIA field in the header. Whenever I would do that, Asterisk will consistently core dump on hangup (not the Hangup() app specifically, but when the call terminated).

However, during the course of troubleshooting, it appears that the SBCs I’m targeting don’t care about the FQDN being in the VIA field after all.

I parsed and examined the dump using the included ast_coredumper script but don’t know enough about what I’m looking at to understand where to look for the actual cause.

Today we have about 30 calls up with the targeted SBCs using this modification, so far so good.