Telephone system:FreeSWITCH tricks

From Hackerspace ACKspace
Revision as of 17:02, 26 January 2022 by Xopr (talk | contribs) (updated samples (100/ackspace became a group))
Jump to: navigation, search

This page provides a couple of tricks to ease working and debugging with FreeSWITCH

config snippets

dial by incoming domain

Typically, FreeSWITCH only looks at the destination number, so 1200@ackspace.nl is treated the same as 1200@illegaleshow.nl in the public dialplan.

This snippet routes all calls destined to either the illegaleshow.nl domain or the illegaleshow extension to 1200 in its own dialplan.

Note that there aren't many sip_to_host examples on the net (or the less predictable alternative sip_req_host for that matter, also see this stackoverflow thread):

  • req or Request Uri is where the INVITE goes (he next hop address, a proxy if you will)
  • To Uri is the actual destination to call
  <extension name="Illegale show">
    <condition regex="any">
      <!-- sip_req_host -->
      <regex field="${sip_to_host}" expression="illegaleshow.nl"/>
      <regex field="destination_number" expression="^illegaleshow$"/>

      <action application="set" data="domain_name=illegaleshow.nl"/>
      <action application="transfer" data="1200 XML illegaleshow"/>
    </condition>
  </extension>

You only need to set some DNS SRV records and you're off to go:

_sip._tcp.illegaleshow.nl. 384 IN SRV 10 20 5060 sip.ackspace.nl.
_sip._udp.illegaleshow.nl. 384 IN SRV 10 20 5060 sip.ackspace.nl.

Verify that they're active with: dig -t srv _sip._tcp.illegaleshow.nl

dial-string for Skinny and SIP

TODO: SCCP..

command line examples

You can run command line commands either as fs_cli -x "COMMAND" or by running the command line interface fs_cli and typing the COMMAND there

user_exists and user_data

Note that directory users have an id and optionally, a number-alias. Both can be used to register and check if it exists in the directory.

Typical for desk phones:

user_exists id 101 ackspace.nl
true

Typical for soft-phones (SIP client):

user_exists id slackspace ackspace.nl
true

Number from name or number

user_data 101@ackspace.nl attr number-alias and user_data slackspace@ackspace.nl attr number-alias
101

Name from name or number

user_data 101@ackspace.nl attr id and user_data slackspace@ackspace.nl attr id
slackspace

Group call information:

group_call 100@ackspace.nl
[sip_invite_domain=ackspace.nl,presence_id=slackspace@ackspace.nl]error/user_not_registered,[sip_invite_domain=ackspace.nl,presence_id=hackspace@ackspace.nl]sofia/external/sip:gw+hackspace_at_ackspace@666.666.666.666:5080;transport=udp;gw=hackspace_at_ackspace;fs_nat=yes

Note that for both number and name group calling, you need two identical groups.

dial-string and sofia_contact

There is a user/ endpoint that uses the user's (or more regularly, the directory domain's) dial-string value to lookup the dial string address of the dialed user. This string usually contains the sofia_contact command:

sofia_contact ackspace@ackspace.nl
sofia/external/sip:ackspace@123.456.789.0:9876;transport=udp;user=phone;fs_nat=yes

Note: the contact URI only works on the registered user (use a number instead of a name if the user registered numerically; it happens, see Fritz!Box)

You can call a user by using: originate user/xopr@ackspace.nl 002 xml ackspace or originate user/196@ackspace.nl 002 xml ackspace.