Chinaunix首页 | 论坛 | 博客
  • 博客访问: 21742
  • 博文数量: 3
  • 博客积分: 160
  • 博客等级: 入伍新兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-02 22:49
文章分类

全部博文(3)

文章存档

2014年(1)

2007年(2)

我的朋友

分类: 系统运维

2007-04-29 15:56:19

软件版本:ser 0.9.6,rtpproxy 0.3,mysql 4.1.12
安装环境:linux as 3.0
安装目的:普通SIPUA可以通过认证注册到ser上,并支持NAT下的PC2PC呼叫.

安装ser 0.9.6
1.解压
2.make && make modules (在这之前需要确定安装MYSQL)
3.make prefix=/usr/local  install
4./usr/local/sbin/ser_mysql.sh create
5.export SIP_DOMAIN=xxx.com 指定域名
6.添加几个用户
/usr/local/sbin/serctl add john 1234 john@xxx.com

ser和openser还是有所不同的,上面有详细的说明.

安装rtpproxy 0.3
1.解压
2.configure
3.make
4.make install

联调ser和rtpproxy
1.配置ser.conf   /usr/local/etc/ser/ser.conf
自己改过ser.conf如下:
debug=3         # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=yes    # (cmd line: -E)

/* Uncomment these lines to enter debugging mode
fork=no
log_stderror=yes
*/
alias="192.168.0.87:5060" 
alias="ser.xxx.com"

listen=udp:192.168.0.87

check_via=yes    # (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
#port=5060
#children=4
fifo="/tmp/ser_fifo"
fifo_db_url="mysql://ser:heslo@localhost/ser"

# ------------------ module loading ----------------------------------

# Uncomment this if you want to use SQL database
loadmodule "/usr/local/lib/ser/modules/mysql.so"

loadmodule "/usr/local/lib/ser/modules/sl.so"
loadmodule "/usr/local/lib/ser/modules/tm.so"
loadmodule "/usr/local/lib/ser/modules/rr.so"
loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
loadmodule "/usr/local/lib/ser/modules/usrloc.so"
loadmodule "/usr/local/lib/ser/modules/registrar.so"
loadmodule "/usr/local/lib/ser/modules/nathelper.so"
loadmodule "/usr/local/lib/ser/modules/textops.so"

# Uncomment this if you want digest authentication
# mysql.so must be loaded !
loadmodule "/usr/local/lib/ser/modules/auth.so"
loadmodule "/usr/local/lib/ser/modules/auth_db.so"
loadmodule "/usr/local/lib/ser/modules/uri_db.so"
loadmodule "/usr/local/lib/ser/modules/uri.so"


# ----------------- setting module-specific parameters ---------------

# -- usrloc params --

#modparam("usrloc", "db_mode",   0)

# Uncomment this if you want to use SQL database
# for persistent storage and comment the previous line
modparam("usrloc", "db_mode", 2)

# -- auth params --
# Uncomment if you are using auth module
#
modparam("auth_db|uri_db|usrloc", "db_url", "mysql://ser:heslo@localhost/ser")

modparam("auth_db", "calculate_ha1", yes)
#
# If you set "calculate_ha1" parameter to yes (which true in this config),
# uncomment also the following parameter)
#
modparam("auth_db", "password_column", "password")

# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# SQL settings

#the deafult database name is "ser" . dbhost can be "localhost"
#modparam("usrloc", "db_url","mysql://user:password@localhost/ser")
#modparam("auth_db", "db_url","mysql://user:password@localhost/ser")

#-- nathelper params --
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)  
modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")

#--registrar params --
modparam("registrar", "nat_flag", 6)




# -------------------------  request routing logic -------------------

# main routing logic

route{

    # initial sanity checks -- messages with
    # max_forwards==0, or excessively long requests
        route(5);


    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483","Too Many Hops");
        break;
    };
    if (msg:len >=  2048 ) {
        sl_send_reply("513", "Message too big");
        break;
    };
   

    # we record-route all messages -- to make sure that
    # subsequent messages will go through our proxy; that's
    # particularly good if upstream and downstream entities
    # use different transport protocol
    if (!method=="REGISTER") {
                record_route();
        };

        if (method=="BYE" || method=="CANCEL") {

        if (isflagset(6)) {
        unforce_rtp_proxy();
    };     
        };
    # -----------------------------------------------------------------
    # Loose Route Section
    # -----------------------------------------------------------------
    if (loose_route()) {

        if ((method=="INVITE" || method=="REFER") && !has_totag()) {
            sl_send_reply("403", "Forbidden");
            break;
        };

        if (method=="INVITE") {

            if (!proxy_authorize("","subscriber")) {
                proxy_challenge("","0");
                break;
            } else if (!check_from()) {
                sl_send_reply("403", "Use From=ID");
                break;
            };
            consume_credentials();

            if (nat_uac_test("19")) {
                setflag(6);
                force_rport();
                fix_nated_contact();
            };
            force_rtp_proxy("l");
        };
        route(1);
        break;
    };

    # -----------------------------------------------------------------
    # Call Type Processing Section
    # -----------------------------------------------------------------
    if (uri!=myself) {
        route(4);
        route(1);
        break;
    };

    if (method=="ACK") {
        route(1);
        break;
    } else if (method=="CANCEL") {
        route(1);
        break;
    } else if (method=="INVITE") {
        route(3);
        break;
    } else  if (method=="REGISTER") {
        route(2);
        break;
    };

    lookup("aliases");
    if (uri!=myself) {
        route(4);
        route(1);
        break;
    };

    if (!lookup("location")) {
        sl_send_reply("404", "User Not Found1");
        break;
    };

    route(1);
}

route[1] {

    # -----------------------------------------------------------------
    # Default Message Handler
    # -----------------------------------------------------------------

    t_on_reply("1");

    if (!t_relay()) {
        if (method=="INVITE" && isflagset(6)) {
            unforce_rtp_proxy();
        };
        sl_reply_error();
    };
}

route[2] {

    # -----------------------------------------------------------------
    # REGISTER Message Handler
    # ----------------------------------------------------------------

    if (!search("^Contact:[ ]*\*") && nat_uac_test("19")) {
        setflag(6);
        fix_nated_register();
        force_rport();
    };

    sl_send_reply("100", "Trying");

    if (!www_authorize("","subscriber")) {
        www_challenge("","0");
        break;
    };

    if (!check_to()) {
        sl_send_reply("401", "Unauthorized");
        break;
    };

    consume_credentials();

    if (!save("location")) {
        sl_reply_error();
    };
}

route[3] {

    # -----------------------------------------------------------------
    # INVITE Message Handler
    # -----------------------------------------------------------------



    if (!proxy_authorize("","subscriber")) {
        proxy_challenge("","0");
        break;
    } else if (!check_from()) {
        sl_send_reply("403", "Use From=ID");
        break;
    };

    consume_credentials();

    if (nat_uac_test("19")) {
        setflag(6);
    }

    lookup("aliases");
    if (uri!=myself) {
        route(4);
        route(1);
        break;
    };

    if (!lookup("location")) {
        sl_send_reply("404", "User Not Found2");
        break;
    };

    route(4);
    route(1);
}

route[4] {

    # -----------------------------------------------------------------
    # NAT Traversal Section
    # -----------------------------------------------------------------

    if (isflagset(6)) {
        force_rport();
        fix_nated_contact();
        force_rtp_proxy();
    }
}

onreply_route[1] {

    if (isflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") {
        if (!search("^Content-Length:[ ]*0")) {
            force_rtp_proxy();
        };
    };

    if (nat_uac_test("1")) {
        fix_nated_contact();
    };

}

route[5]{
        if (nat_uac_test("19")) {
                setflag(6);
        };

        if (isflagset(6)) {
                force_rport();
                fix_nated_contact();
  #              unforce_rtp_proxy();
        };

}

自己加的ROUTE5,不加的话4xx的一些错误不能发到NAT下的client端.
2.启动rtpproxy
/usr/local/rtpproxy/bin/rtpproxy

3.用户注册呼叫.完成!!!
阅读(2120) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~