[Serusers] Asymmetric UA & mediaproxy

Fikri Pribadi fikri at affitel.com
Fri Oct 22 11:56:46 CEST 2004


Hi

Sorry if this is already answered, but i've search the archives and
couldn't find what I'm looking for.

Basically I would like to have the following scenario:


UA1 asym --> NAT/Firewall --> Ser/mediaproxy --> PSTN Gateway

PSTN Gateway is a Quintum box, we already have several of this, and it
can only support asymmetric rtp, that's why we are looking at mediaproxy

I develop the UA1 myself, and can support both symmetric or asymmetric
rtp.

My question, is this possible with Ser/mediaproxy? If it is, could
somebody give me pointer on how to configure Ser with mediaproxy

Currenty I have the call goes to the pstn gateway but no voice on each
side.

Another question, how do you know if the sip signalling is asymmetric or
not?

Thanks,
Fikri

here is my ser config:
# ----------- global configuration parameters ------------------------

debug=4         # 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
*/

check_via=no	# (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
port=5060
children=4
fifo="/tmp/ser_fifo"

# ------------------ 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/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"

# !! Nathelper
#loadmodule "/usr/local/lib/ser/modules/nathelper.so"

# !! Mediaproxy
loadmodule "/usr/local/lib/ser/modules/domain.so"
loadmodule "/usr/local/lib/ser/modules/mediaproxy.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", "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)

# !! Nathelper
#modparam("registrar", "nat_flag", 6)
#modparam("nathelper", "natping_interval", 30) # Ping interval 30 s
#modparam("nathelper", "ping_nated_only", 1)   # Ping only clients behind NAT

# !! Mediaproxy
modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy.sock")
modparam("mediaproxy", "sip_asymmetrics", "/usr/local/etc/ser/sip-asymmetrics-clients")
modparam("mediaproxy", "rtp_asymmetrics", "/usr/local/etc/ser/rtp-asymmetrics-clients")
modparam("mediaproxy", "natping_interval", 60)
modparam("registrar",  "nat_flag",         2)

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

# main routing logic

route{
    if (!mf_process_maxfwd_header("10")) {
        if (method!="ACK") {
            sl_send_reply("483", "Too many hops");
        };
        break;
    };

    if (msg:len >= max_len) {
        if (method!="ACK") {
            sl_send_reply("513", "Message too big");
        };
        break;
    };

    if (method=="REGISTER") {
        if (is_from_local()) {
            # Mark as NAT'ed
            if (client_nat_test("3")) {
                setflag(2);
                force_rport();
                fix_contact();
            };

#            if (!www_authorize("", "subscriber")) {
#                www_challenge("", "0");
#                break;
#            } else if (!check_to()) {
#                sl_send_reply("403", "Username!=To not allowed");
#                break;
#            };

            if (!save("location")) {
                sl_reply_error();  
            };
        } else {
            sl_send_reply("403", "This domain is not served here");
        };

        break;
    };

    if (method=="INVITE") {
        if (!(is_from_local() || is_uri_host_local())) {
            sl_send_reply("403", "Relaying is forbidden");
            break;
        };
        t_on_failure("1");
    } else if (method == "BYE" || method == "CANCEL") {
        end_media_session();
    };

    if (loose_route()) { 
        if (method=="INVITE" || method=="ACK") {
            use_media_proxy();
        };
        # end media session for BYE and CANCEL is done above
        # before entering the loose route. no need to call it here
        t_relay();
        break;
    };

    # Force subsequent messages to pass trough this proxy
    if (method == "INVITE") {
        record_route();
    };

    if (client_nat_test("3") && !search("^Record-Route:")) {
        # Mark as NAT'ed
        force_rport();
        fix_contact();
    };

    if (method=="INVITE") {
        t_on_reply("1");
    };

    if (is_uri_host_local()) {
        if (!lookup("location")) {
            if (uri=~"^sip:[0-9]*@.*") {
              log(1, "Calling gateway\n");
              rewritehostport("202.172.45.110:5060");
              forward(uri:host, uri:port);
#              break;
            } else {

                sl_send_reply("404", "User not found");
                break;
            };
        };
    };

    if (method=="INVITE" || method=="ACK") {
        use_media_proxy();
    };

    if (!t_relay()) {
        if (method=="INVITE" || method=="ACK") {
            end_media_session();
        };
        sl_reply_error();
    };
}

failure_route[1] {
    end_media_session();
}

onreply_route[1] {
    if (status=~"(183)|(2[0-9][0-9])") {
        if (client_nat_test("1")) {
            fix_contact();
        };
        use_media_proxy();
    };
}




More information about the sr-users mailing list