[Serusers] having problems using avpops module

Jack Wei cowlemon at yahoo.com
Thu Jul 7 21:44:36 CEST 2005


i'm trying to load the db and check if the username for the "to" sip uri is in
the database, but my script is displaying the following errors:

 0(0) AVPops - initializing
 0(0) ERROR:avpops:parse_check_value: unknown flag <u>
 0(0) ERROR:avpops:fixup_check_avp: failed to parse checked value 
 0(0) ERROR: fix_expr : fix_actions error
ERROR: error -1 while trying to fix configuration


Here's my ser.cfg:

less /etc/ha.d/ser.cfg
/etc/ha.d/ser.cfg: No such file or directory
[root at SER02 ser]# less /usr/local/etc/ser/ser.cfg
#
# $Id: ser.cfg,v 1.27 2005/03/10 14:16:25 andrei Exp $
#
# simple quick-start config script
#

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

fork=yes

# Uncomment these lines to enter debugging mode 
#debug=3                # debug level (cmd line: -dddddddddd)
#fork=no
log_stderror=yes        # (cmd line: -E)
#memlog=5 # memory debug log level
#log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))

alias="SER02"

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"
fifo_db_url="mysql://ser:heslo@10.1.201.107/ser"
#user=ser
#group=ser
#fifo_user=ser # owner of the ser fifo
#fifo_group=ser
#fifo_mode=0660 # fifo's permissions
#disable_core=yes #disables core dumping
#open_fd_limit=1024 # sets the open file descriptors limit
#mhomed=yes  # usefull for multihomed hosts, small performance penalty
#disable_tcp=yes 
#tcp_accept_aliases=yes # accepts the tcp alias via option (see NEWS)

#

# ------------------ 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"
loadmodule "/usr/local/lib/ser/modules/xlog.so"
loadmodule "/usr/local/lib/ser/modules/exec.so"
loadmodule "/usr/local/lib/ser/modules/avpops.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)
modparam("usrloc", "timer_interval", 10)

# -- db_url params --
modparam("acc|auth_db|domain|group|permissions|speeddial|uri_db|usrloc|xdz_tools",
"db_url","mysql://ser:heslo@10.1.201.107/ser")

# -- auth params --
modparam("auth_db", "calculate_ha1", yes)
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)

# -- tm params --
modparam("tm", "fr_inv_timer", 90)

# -- avp params --
modparam("avpops", "avp_url", "mysql://ser:heslo@10.1.201.107/ser")
modparam("avpops", "avp_table", "location")
#modparam("avpops", "use_domain", "1")
#modparam("avpops", "uuid_column", "callid")
modparam("avpops", "username_column", "username")
modparam("avpops", "domain_column", "domain")
#modparam("avpops", "attribute_column", "attribute")
modparam("avpops", "value_column", "contact")
#modparam("avpops", "type_column", "type")
#modparam("avpops", "avp_aliases",
"voicemail=i:500;calltype=i:700;fwd_no_answer_type=i:701;fwd_busy_type=i:702")
# To use more than one tables example
#modparam("avpops", "db_scheme",
"scheme1:table=location;username_col=username;domain_col=domain;value_col=contact;value_type=string
")

# -------------------------  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;
        };
        

        # 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)
        {
                xlog("L_INFO", "%rm New URI = %ru from %ct\n\n");

                if (method=="REGISTER")
                {
                        # digest authentication
                        if (!www_authorize("localhost", "subscriber")) {
                                www_challenge("localhost", "0");
                                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
        xlog("L_INFO", "pre-rr(): %rm to URI %ru\n\n");
#       record_route();
        record_route_preset( "10.1.201.189:5060" );
        xlog("L_INFO", "post-rr(): %rm to URI %ru\n\n");

        # subsequent messages withing a dialog should take the
        # path determined by record-routing
        if ( loose_route() )
        {
                # mark routing logic in request
                append_hf("P-hint: rr-enforced\r\n"); 
                xlog("L_INFO", "loose_route(): Looking up %rm URI %ru from
%ct\n\n");
                lookup("location");
                xlog("L_INFO", "loose_route(): t_relay() %rm to URI %ru\n\n");
                route(1);
                break;
        };


        if ( uri =~
"sip:[0-9]+@(10.1.101.(159|250)|192.168.10.31|64.77.239.90)" )
        {
                if ( method == "INVITE" || method == "ACK" || method ==
"CANCEL" || method == "REFER" || method == "BYE" )
                {
                        xlog("L_INFO", "\n%rm came from a VoIP phone
(%ct)\n\n");

                        # Making an outbound cal, which starts with a "9", to a
PSTN phone
                        if( uri =~ "^sip:9[0-9]+@*" )  
                        {
                                append_hf( "P-hint: OUTBOUND\r\n" );
                                route(2);
                                rewritehostport("10.1.101.152:5060");
#                               forward( localhost, 5061 );

                                xlog("L_INFO", "URI is a PSTN phone...sending
URI (%ru) to 10.1.101.152\n\n");
#                               xlog("L_INFO", "URI is a PSTN phone...sending
URI (%ru) to Asterisk\n\n");
                                route(1);
                                break;
                        }
                        # Making an outbound call to another VoIP phone
                        else
                        {
                                # Redirect call to voicemail when destination
is not registered
                                append_hf( "P-hint: USRLOC\r\n" );
                                if( !lookup("location") && !(uri =~
"^sip:11111111111@*") )
                                {
#                                       prefix("*");
                                        xlog("L_INFO", "\n\n%ru is not online
(in usrloc)\n");
#                                       route(3);
                                        route(4);
                                }
                                else
                                {
                                        setflag(5);
                                };

#                               forward( uri:host, uri:port );
#                               forward( localhost, 5061 );

                                if ( isflagset(5) )
                                {
                                        xlog("L_INFO", "URI is a VoIP
phone...forwarding URI (%ru) to destination\n\n");
#                                       xlog("L_INFO", "URI is a VoIP
phone...forwarding URI (%ru) to Asterisk\n\n");
                                        resetflag(5);
                                        route(1);
                                };
                                break;
                        };
                };

                route(1);
                break;
        };
#       route(1);
}

#---------------------------------------------------------------------

route[1] 
{
        # send it out now; use stateful forwarding as it works reliably
        # even for UDP2TCP
        xlog("L_INFO", "\n\n%ru is being t_relay()ed\n");
        if (!t_relay()) {
                xlog("L_INFO", "\n\n%ru t_relay() error\n");
                sl_reply_error();
                break;
        };
}

#---------------------------------------------------------------------

# All PSTN calls require a prefix of "0010"
route[2]
{
        if ( uri =~ "^sip:0010[0-9]+@*" )
        {
                xlog("L_INFO", "URI has 0010 prefix already\n\n");
        }
        else
        {
                xlog("L_INFO", "URI does not has 0010 prefix...attaching
prefix\n\n");
                strip(1);
                prefix("0010");
        };
}

#---------------------------------------------------------------------

# Check database for actual user address
route[4]
{
        if ( avp_db_load("$to/username","s:") &&
avp_check("s:username","eq/$to/username/g") ) 
        {
                xlog("L_INFO", "\n\n%ru is online (in db)\n");
                setflag(5);
                break;
        };

        xlog("L_INFO", "\n\n%ru is not online (in db)\n");
        sl_send_reply( "404", "User does not exist" );
}



Can someone tell me what i'm doing wrong?  Thanks.

Jack


		
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.  
http://auctions.yahoo.com/




More information about the sr-users mailing list