----- Original Message -----From: ramTo: Glenn DalglieshSent: Monday, June 05, 2006 1:11 AMSubject: Re: [Users] Openser+Asterisk Voice mailHihere is my configiam able to dial *86, i get voice message that no voice messagesBut the call rewriting when the user not availableit should go to asterisks voice mailram[root@sert openser]# more openser.cfg
#
# $Id: openser.cfg,v 1.5 2005/10/28 19:45:33 bogdan_iancu Exp $
#
# simple quick-start config script
## ----------- global configuration parameters ------------------------
debug=3 # debug level (cmd line: -dddddddddd)
log_facility=LOG_LOCAL7
fork=yes
log_stderror=no # (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/openser_fifo"# ------------------ module loading ----------------------------------
loadmodule "/usr/local/lib/openser/modules/tm.so"
loadmodule "/usr/local/lib/openser/modules/sl.so"
loadmodule "/usr/local/lib/openser/modules/acc.so"
loadmodule "/usr/local/lib/openser/modules/rr.so"
loadmodule "/usr/local/lib/openser/modules/maxfwd.so"
loadmodule "/usr/local/lib/openser/modules/mysql.so"
loadmodule "/usr/local/lib/openser/modules/usrloc.so"
loadmodule "/usr/local/lib/openser/modules/registrar.so"
loadmodule "/usr/local/lib/openser/modules/auth.so"
loadmodule "/usr/local/lib/openser/modules/auth_db.so"
loadmodule "/usr/local/lib/openser/modules/textops.so"
loadmodule "/usr/local/lib/openser/modules/uri.so"
loadmodule "/usr/local/lib/openser/modules/uri_db.so"
loadmodule "/usr/local/lib/openser/modules/group.so"
loadmodule "/usr/local/lib/openser/modules/msilo.so"
loadmodule "/usr/local/lib/openser/modules/nathelper.so"
loadmodule "/usr/local/lib/openser/modules/enum.so"
loadmodule "/usr/local/lib/openser/modules/domain.so"
loadmodule "/usr/local/lib/openser/modules/xlog.so"
fifo_db_url="mysql://openser:openserrw@localhost/openser"
modparam("usrloc|acc|auth_db|group|msilo", "db_url", "mysql://openser:openserrw@localhost/openser")
# ----------------- setting module-specific parameters ---------------
# -- usrloc params --
/* 0 -- dont use mysql, 1 -- write_through, 2--write_back */
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "timer_interval", 10)
modparam("usrloc", "use_domain", 1)
modparam("registrar", "use_domain", 1)
# -- auth params --
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
#modparam("auth_db", "use_rpid", 1)
modparam("auth", "nonce_expire", 300)
modparam("auth", "rpid_prefix", "<sip:")
modparam("auth", "rpid_suffix", "@myip>;party=calling;id-type=subscriber;screen=yes;privacy=off")# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)# -- acc params --
# report ACKs too for sake of completeness -- as we account PSTN
# destinations which are RR, ACKs should show up
modparam("acc", "report_ack", 1)
modparam("acc", "log_level", 1)
# if BYE fails (telephone is dead, record-routing broken, etc.), generate
# a report nevertheless -- otherwise we would have no STOP event; => 1
#modparam("acc", "failed_transactions", 1)# that is the flag for which we will account -- don't forget to
# set the same one :-)
# Usage of flags is as follows:
# 1 == should account(all to gateway),
# 3 == should report on missed calls (transactions to iptel.org's users),
# 4 == destination user wishes to use voicemail
# 6 == nathelper
#
modparam("acc", "log_flag", 1)
modparam("acc", "db_flag", 1)
modparam("acc", "log_missed_flag", 3)
modparam("acc", "db_missed_flag", 3)# report to syslog: From, i-uri, status, digest id, method
modparam("acc", "log_fmt", "fisumdpr")# -- tm params --
modparam("tm", "fr_timer", 15)
modparam("tm", "fr_inv_timer", 25)
modparam("tm", "wt_timer", 30)# -- msilo params
modparam("msilo", "registrar", "sip:registrar@mydomain.com")# -- enum params --
modparam("enum", "domain_suffix", "e164.arpa.")# -- multi-domain
modparam("domain", "db_mode", 1)
# ------------------------- request routing logic -------------------# main routing logic
#Routing Script
route {
#check for old messages: could mean a problem with the DNS entries or some other loop-causer...
if (!mf_process_maxfwd_header("10"))
{
xlog("L_WARN", "WARNING: Too many hops\n");
sl_send_reply("483", "Too many hops, forward count exceeded limit\n");
return;
};#check for extremely large messages; we don't need a sip dos attack
if (msg:len >= 2048)
{
xlog("L_WARN", "WARNING: Message too large, >= 2048 bytes\n");
sl_send_reply("513", "Message too large, exceeded limit\n");
return;
};#record everything besides registers and acks
if(method!="REGISTER" && method!="ACK")
{
setflag(1);
};#do not send to voicemail if BYE or CANCEL
#is used to end call before user pickup or timeout
if(method=="CANCEL" || method=="BYE")
{
setflag(10);
};#grant route if route headers already present
if (loose_route())
{
route(1);
return;
};#Always require authentication, which could result in a PSTN, ie $$$
if (method=="REGISTER")
{
if(!www_authorize("domain.com", "subscriber"))
{
www_challenge("domain.com", "0");
return;
}
else
{
#Save into user database, used below when checking if user is available
xlog("L_INFO", "REGISTER: User Authenticated Correctly\n");
save("location");
return;
};
};if (method=="INVITE")
{
if (uri=~"sip:1[0-9]+@.*")
{
#authorize if a call is going to PSTN
if(!proxy_authorize("domain.com", "subscriber"))
{
proxy_challenge("domain.com", "0");
return;
};xlog("L_INFO", "CALL: Call to international number\n");
# rewritehostport("voip_gw.domain.net:5060");
rewritehostport("myprovider-voip:port");
}
else if(uri=~"sip:\*86@.*")
{
#authorize if a call is going to PSTN
if(!proxy_authorize("domain.com", "subscriber"))
{
proxy_challenge(" domain.com", "0");
return;
};xlog("L_INFO", "CALL: Call to check voicemail\n");
rewritehostport("asterisk-server-ip:5090");
}
else
{
if (does_uri_exist()){
#Call is to sip client, so do nothing but route
xlog("L_INFO", "CALL: Sip client\n");
if (!lookup("location"))
{
sl_send_reply("404", "Not Found");
log(1, "ERROR: User Not Found\n");
return;
};
}
else
{
#authorize if a call is going to PSTN
if(!proxy_authorize("domain.com ", "subscriber"))
{
proxy_challenge("domain", "0");
return;
};#Call destination is PSTN, so send it to the gateway (Net.com)
xlog("L_INFO", "CALL: PSTN gateway\n");
# rewritehostport("voip_gw.domain.net:5060");
rewritehostport("myprovider-voip:port");};
};#Make sure that all subsequent requests go through us;
record_route();
}
else
{
if (does_uri_exist())
{
#Call is to sip client, so do nothing but route
xlog("L_INFO", "CALL: Sip client\n");
if (!lookup("location"))
{
sl_send_reply("404", "Not Found");
log(1, "ERROR: User Not Found\n");return;
};
}
else
{
#Call destination is PSTN, so send it to the gateway (Net.com)
xlog("L_INFO", "CALL: PSTN gateway\n");
rewritehostport("voip_gw.domain.net:5060");};
record_route();
};#ALL PROCESSING IS DONE, SO ROUTE
route(1);
}
route[1]
{
#send the call outwardif(method=="INVITE" && !isflagset(10))
{
t_on_failure("2");
};if (!t_relay())
{
xlog("L_WARN", "ERROR: t_relay failed");
sl_reply_error();
};}
failure_route[2]
{
if(!t_was_cancelled())
{
revert_uri();
rewritehostport("asterisk-ip-voicemail:5090");
append_branch();
#PREVENT SOME CRAZY VOICEMAIL LOOP
xlog("L_INFO", "INFO: CALL TO VOICEMAIL");
setflag(10);
route(1);
}
}
ram