zoukankan      html  css  js  c++  java
  • freeswitch与外部网关链接

    注册到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/目录下可以添加网关。
    
    比如添加注册到asterisk得网关,/usr/local/freeswitch/conf/sip_profiles/external/reg_to_asterisk.xml
    
    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@openser-dev>
    
    查看注册状态
    
    freeswitch@internal> sofiastatus
    
                         Name          Type                                      Data      State
    
    =================================================================================================
    
                internal-ipv6       profile                  sip:mod_sofia@[::1]:5060     RUNNING (0)
    
                     internal         profile                   sip:mod_sofia@192.168.16.111:5060      RUNNING (0)
    
                     external         profile         sip:mod_sofia@192.168.16.111:5080     RUNNING (0)
    
        external::example.com       gateway                   sip:joeuser@example.com      NOREG
    
           external::asterisk       gateway          sip:freeswitch@demo.asterisk.org     TRYING (retry: NEVER)
    
               192.168.16.111         alias                                  internal      ALIASED
    
    =================================================================================================
    
    3 profiles 1 alias
    
    a.通过网关呼出去
    
    需要修改dialplan,在conf/dialplan/default/目录下添加 route_to_asterisk.xml
    
     
    
    <include>
    
    <extension name="Dial Out asteriskGateway">
    
    <condition field="destination_number"expression="^9(11)$">
    
    <actionapplication="bridge"data="sofia/gateway/asterisk/$1"/>
    
    </condition>
    
    </extension>
    
    </include>
    
     
    
    Fs_cli 执行 reloadxml,客户端呼叫 911,呼叫会路由到asterisk网关上。
    
     
    
    b.接收网关送过来的呼叫
    
    通常,对于那些未经认证的呼叫,freeswitch认为是不安全的,包括网关送过来的呼叫,freeswitch会把这类呼叫路由到publicdialplan context中。
    
    /usr/local/freeswitch/conf/dialplan/public.xml为此类呼叫的dialplan,可以在
    
    /usr/local/freeswitch/conf/dialplan/public/目录添加对应网关送过来的dialplan
    
    如:
    
    Vim /usr/local/freeswitch/conf/dialplan/public/asterisk.xml
    
     
    
    <include>
    
    <extensionname="asterisk-inbound">
    
    <condition field="destination_number"
    
    expression="^(freeswitch)$">
    
    <actionapplication="set" data="domain_name=$${domain}"/>
    
    <actionapplication="transfer" data="1000 XML default"/>
    
    </condition>
    
    </extension>
    
    </include>
    
    当asterisk送过来的被叫号码为freeswitch注册到asterisk上的用户号时,freeswitch转移到其用户1000。
    
    (3)不需要手动配置网关,但与外部链接
    
    如果外部网关需要diguest认证,则需要在freeswitch上配置网关,如果外部网关并不需要digesut认证,则不需要再freeswitch上手动配置(2)中的过程,有一些网关通过ip验证,这种方式相对更简单,但不如(2)中的安全。
    
    比如default.xmldialplan中的
    
    <actionapplication="bridge"data="sofia/${use_profile}/$1@conference.freeswitch.org"/>
    
    即通过 internalsip profile送到freeswitch.org的网关上。


  • 相关阅读:
    迭代器和生成器
    小练习函数
    python学习(函数)
    python学习(文件的操作)
    【Python基础】数据结构
    【Python基础】break 和 continue 语句, 以及循环中的 else 子句
    【Python算法】汉诺塔
    【Python基础】序列(字符串、列表、元组)
    【Python基础】正则表达式
    【Python练习】分类数据
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13318357.html
Copyright © 2011-2022 走看看