[Serusers] Re: SER + Cisco + ASTERISK

Jason Kline jkline at IDSTELCOM.com
Tue Jan 4 23:23:53 CET 2005


Hello Serusers,


This list has been very helpful.  However I am still a newbie and I am
on a project that can use some of the list users expertise.  I have SER
running with STUNd from VOCAL and ASTERISK as a voice mail sending the
subscribed users that are unregistered to ASTERISK on another UDP port
(see config below).  I also have a CISCO 5400 that I am sending outbound
calls to the PSTN.  I am having loads of problems with softphones and
NAT.  STUN seems to work best with ATA's and Sipuras since that is the
only ones I am able to test with.  I have tested a few X-Ten and SJ.  I
get disconnected from them every 5 minutes or 1 hour if the client does
not make a call.  I am sure this is a NAT issue and think that the
"nathelper" can aid me with its ability to ping the connected clients
that are subscribed to my system.  I am playing with "nathelper" and
"rtpproxy" but having issues integrating it with this configuration.  If
some list experts can overlook this and help give me input on how and
where to put the "nathelper" statements I would greatly appreciate it.

If any other configs are needed please let me know and I can post.  

Thank you

Jason


SER Config 

#
# $Id: ser.cfg,v 1.21.4.1 2003/11/10 15:35:15 andrei Exp $
#
# simple quick-start config script
#

# ----------- global configuration parameters ------------------------

debug=9         # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=no # (cmd line: -E)


listen=XXX.XXX.XXX.XXX

check_via=no    # (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
sip_warning=yes
server_signature=yes
alias=XXX.XXX.XXX.XXX
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/nathelper.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/acc.so"
#loadmodule "/usr/local/lib/ser/modules/exec.so"
#loadmodule "/usr/local/lib/ser/modules/group.so"
loadmodule "/usr/local/lib/ser/modules/textops.so"
loadmodule "/usr/local/lib/ser/modules/uri.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"

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

# -- usrloc params --

modparam("usrloc", "db_mode",   1)

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

modparam("auth_db", "use_rpid", 1)

# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)
modparam("tm", "fr_timer", 12)
modparam("tm", "fr_inv_timer", 120)
modparam("acc", "log_missed_flag", 3)
modparam("acc", "log_fmt", "ftFTUpmsc")
modparam("acc", "log_level", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "db_flag", 1)

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

# main routing logic

route{

        # initial sanity checks -- messages with
        # max_forwards==0, or excessively long requests
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                break;
        };
        if ( msg:len > max_len ) {
                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
        # loose-route processing
        if(method=="BYE") {
                setflag(1);
                };
        if (loose_route()) {
                t_relay();
                break;
        };

        if (method=="PUBLISH") {
                #t_reply("405", "Method not Supported");
                sl_send_reply("405", "Method not Supoorted");
                log(1, "PUBLISH refusal");
                break;
                }
        if (method=="SUBSCRIBE") {
                #t_reply("405", "Method not Supported");
                sl_send_reply("405", "Method not Supoorted");
                log(1, "SUBSCRIBE refusal");
                break;
                }
        if (method=="NOTIFY") {
                if (lookup("location")) {
                        t_relay();
                        log(1, "NOTIFY process");
                        break;
                        }
                #sl_send_reply("405", "Method not Supoorted");
                log(1, "NOTIFY for sub not online, ignore");
                break;
                }
    
        # if the request is for other domain use UsrLoc
        # (in case, it does not work, use the following command
        # with proper names and addresses in it)

        if (uri==myself) {
                if (method=="REGISTER") {
#Uncomment this if you want to use digest authentication
                        if (!www_authorize("XXX.XXX.XXX.XXX",
"subscriber")) {
                                www_challenge("XXX.XXX.XXX.XXX", "0");
                                break;
                        };

                        if(!save("location")) {
                                sl_reply_error();
                                }
#               t_replicate("XXX.XXX.XXX.XXX", "5060");
                break;
                };

# native SIP destinations are handled using our USRLOC DB
        if (method=="INVITE") {
                setflag(1);
                record_route();
                if (!lookup("location")) {
                        if (!does_uri_exist()) {
                                if (uri=~"sip:[0-9]{10}@.*") {
                                        log(1, "LOG: do route 3
NATIONAL\n");
                                        prefix("1");
                                        route(3);
                                        break;
                                        };
                                if (uri=~"sip:[0-9]{11,20}@.*") {
                                        log(1, "LOG: do route 3
INTL\n");
                                        route(3);
                                        break;
                                        };
                                #  add invalid pstn number here
                                log(1, "LOG: bad pstn number\n");
                                if (!sl_send_reply("404", "Not Found"))
{
                                        sl_reply_error();
                                        };
                                break;
                                };
                        log(1, "LOG: do route 4 - subscriber exists but
not REG, VM\n");
                        route(4);
                        break;
                        };
                };
        };
        # forward to current uri now; use stateful forwarding; that
        # works reliably even if we forward from TCP to UDP
        if(method=="BYE") {
                setflag(1);
                };
        t_on_failure("4");
        t_set_fr_inv_timer("24");
        if (!t_relay()) {
                sl_reply_error();
        };

}


route[3] {
    log(1, "LOG: goto cisco switch\n");
        rewritehostport("CISCO5400:5060");
        setflag(1);
    if(!proxy_authorize("XXX.XXX.XXX.XXX", "subscriber")) {
                proxy_challenge("XXX.XXX.XXX.XXX", "0");
                break;
                }
        append_rpid_hf();
        t_set_fr_inv_timer("120");
        if(!t_relay()) {
                sl_reply_error();
                break;
                };
}

route[4] {

        log(1, "LOG: inside route 4\n");
        #if (!t_newtran()) {
        #       sl_reply_error();
        #       };
#
#       if (!t_reply("404", "Not Found")) {
#               sl_reply_error();
#               };
        append_urihf("CC-Diversion: ", "\r\n");
        append_hf("P-hint: OFFLINE-VOICEMAIL\r\n");
        rewritehostport("XXX.XXX.XXX.XXX:5065"); 
        append_branch();
        t_relay_to_udp("XXX.XXX.XXX.XXX", "5065");
}

# ------------- CC-Diversion to voicemail

failure_route[4] {

        log(1, "LOG: failure_route\n");
        append_urihf("CC-Diversion: ", "\r\n");
        append_hf("P-hint: OFFLINE-VOICEMAIL\r\n");
        rewritehostport("XXX.XXX.XXX.XXX:5065"); 
        prefix("u");
        append_branch();
        t_relay_to_udp("XXX.XXX.XXX.XXX", "5065");
}





More information about the sr-users mailing list