The first FreeSWITCH patch that calls SIP “Gateways” as Trunks

Ever wondered why in FreeSWITCH, registration and authentication to remote SIP endpoints are called gateways, not trunks? Well, it’s more of the fact that SIP never really defined what trunking is. For the people who don’t know what trunking is, it’s essentially a link to another remote Central Office for telephone switches in a Central Office or from a PABX to the Central Office via a T1 or TDM link.

I’ve created a patch that essentially renames the term “gateway/gateways” into “trunk/trunks” for FreeSWITCH. This patch should make the transition from Asterisk, proprietary softswitches or even worse, people who’s finally moving to VoIP with a heavy old world PSTN/TDM background. Please do note, the old CLI and XML configuration conventions still work with this patch; backwards compatibility is retained for obvious reasons so we don’t break code here.

This patch is meant to be applied to the source tree of FreeSWITCH via the git command. To apply this patch, you’d normally type in:

git apply trunk_naming.patch

. I’ve tested this patch out on Windows and RHEL 6 like builds and so far works sufficiently okay. You can download this patch here on my site.

This patch now allows you to define your trunks by XML using the following code:

<trunk name="callitwhaterveryouwant>
    <param name="username" value="1234" />
    <param name="from-user" value="4321" />
    <param name="realm" value="" />
    <param name="proxy" value="" />
    <param name="password" value="4321" />
    <param name="sip_cid_type" value="rpd" />
    <param name="register" value="true" />

Notice the change from gateways/gateway to the trunks/trunk naming convention. In order for this new naming convention to work, you must include the <trunk> child tag in the <trunks> parent tag. The same also goes for the old gateways/gateway naming convention. The reason being is the patched code only looks for <trunk> tags in the <trunks> parent tag and vice versa for the gateways version of the same naming convention.

This means if you want to use this new naming convention in the default dialplan, you should change this line in the external.xml file:

    <X-PRE-PROCESS cmd="include" data="external/*.xml"/>


    <X-PRE-PROCESS cmd="include" data="external/*.xml"/>

And you should also change any of the <gateway&rt; tags to use the <trunk&rt; tags too.

Channel variable wise, this patch provides both ${sip_trunk} and ${sip_trunk_name} if you wish to use them. The old channel variable names have been retained for backwards compatibly reasons so things don’t get broken when this patch gets applied. Please do remember the author has taken due diligence to prevent things getting broken here, however, there’s no guarantees as if it will actually NOT break anything. Aka, use this at your own leisure and risk 😉

Leave a Reply

Your email address will not be published. Required fields are marked *