天天看點

freeswitch與外部網關連結

我建了一個 Freeswitch 核心研究 交流群, 45211986, 歡迎加入, 另外,提供基于SIP的通信伺服器及用戶端解決方案,

承接 sip/ims 視訊用戶端開發,支援接入sip軟交換,ims核心網,支援 語音,視訊,即時通信功能,視訊格式支援 h263,h264,mpeg4 軟編軟解,提供硬體編解碼接口對接,提供伺服器,有興趣請聯系我。

注冊到freeswitch的用戶端可以互相撥打,但是當用戶端想通過freeswitch呼叫那些并沒有注冊到freeswitch上的用戶端怎麼辦?這就需要freeswitch與外部網關連結,比如與另一個sip server或者pstn測的營運商網絡連結。Freeswitch引入網關概念來處理與外部連結問題。

Freeswitch中配置的網關在系統啟動時注冊到另一個sip伺服器,類似于sip用戶端注冊到freeswitch。

配置網關通常需要使用者名,密碼,以及要注冊到的sip伺服器ip位址。

網關相關配置儲存在目錄/conf/sofia_profiles/external

/usr/local/freeswitch/conf/sip_profiles/external.xml為freeswitch作為用戶端注冊到另一個網關的全局配置,

/usr/local/freeswitch/conf/sip_profiles/external/目錄下可以添加網關。

reg_to_asterisk.xml内容:

<include>

<gatewayname="asterisk">

<paramname="username" value="freeswitch"/>

<paramname="password" value="freeswitch"/>

<paramname="realm" value="demo.asterisk.org"/>

<paramname="proxy" value="demo.asterisk.org"/>

</gateway>

</include>

~          

儲存,控制台重新開機 sipprofile

freeswitch@openser-dev>sofia profile external restart

2012-08-18 20:21:47.254868[INFO] mod_enum.c:871 ENUM Reloaded

2012-08-18 20:21:47.254868[INFO] switch_time.c:1163 Timezone reloaded 530 definitions

Reload XML [Success]

restarting: external

freeswitch@openser-dev>2012-08-18 20:21:47.295211 [NOTICE] sofia.c:2500 Waiting for worker thread

2012-08-18 20:21:47.956692[NOTICE] sofia_glue.c:5707 deleted gateway example.com from profile external

2012-08-18 20:21:47.956692[NOTICE] sofia.c:5202 Started Profile external [sofia_reg_external]

2012-08-18 20:21:47.984023[NOTICE] sofia_reg.c:2944 Added gateway 'asterisk' to profile 'external'

2012-08-18 20:21:47.984023[NOTICE] sofia_reg.c:2944 Added gateway 'example.com' to profile 'external'

2012-08-18 20:21:49.975233[NOTICE] sofia_reg.c:415 Registering asterisk

freeswitch@openser-dev>

檢視注冊狀态

freeswitch@internal> sofiastatus

                     Name          Type                                      Data      State

=================================================================================================

            internal-ipv6       profile                  sip:mod_sofia@[::1]:5060     RUNNING (0)

                 internal         profile                   sip:[email protected]:5060      RUNNING (0)

                 external         profile         sip:[email protected]:5080     RUNNING (0)

    external::example.com       gateway                   sip:[email protected]      NOREG

       external::asterisk       gateway          sip:[email protected]     TRYING (retry: NEVER)

           192.168.16.111         alias                                  internal      ALIASED

3 profiles 1 alias

a.通過網關呼出去

需要修改dialplan,在conf/dialplan/default/目錄下添加 route_to_asterisk.xml

<extension name="Dial Out asteriskGateway">

<condition field="destination_number"expression="^9(11)$">

<actionapplication="bridge"data="sofia/gateway/asterisk/$1"/>

</condition>

</extension>

Fs_cli 執行 reloadxml,用戶端呼叫 911,呼叫會路由到asterisk網關上。

b.接收網關送過來的呼叫

通常,對于那些未經認證的呼叫,freeswitch認為是不安全的,包括網關送過來的呼叫,freeswitch會把這類呼叫路由到publicdialplan context中。

/usr/local/freeswitch/conf/dialplan/public.xml為此類呼叫的dialplan,可以在

如:

Vim /usr/local/freeswitch/conf/dialplan/public/asterisk.xml

<extensionname="asterisk-inbound">

<condition field="destination_number"

expression="^(freeswitch)$">

<actionapplication="set" data="domain_name=$${domain}"/>

<actionapplication="transfer" data="1000 XML default"/>

當asterisk送過來的被叫号碼為freeswitch注冊到asterisk上的使用者号時,freeswitch轉移到其使用者1000。

(3)不需要手動配置網關,但與外部連結

如果外部網關需要diguest認證,則需要在freeswitch上配置網關,如果外部網關并不需要digesut認證,則不需要再freeswitch上手動配置(2)中的過程,有一些網關通過ip驗證,這種方式相對更簡單,但不如(2)中的安全。

比如default.xmldialplan中的

<actionapplication="bridge"data="sofia/${use_profile}/[email protected]"/>

即通過 internalsip profile送到freeswitch.org的網關上。

本文轉自einyboy部落格園部落格,原文連結:http://www.cnblogs.com/einyboy/archive/2012/11/21/2780033.html,如需轉載請自行聯系原作者。