[Serusers] ONSIP Script + Java Rockx ser 0.9.0 script

Iqbal iqbal at gigo.co.uk
Wed Sep 21 16:19:42 CEST 2005


"voicemail=1:500;calltype=i:700;fwd_no_answer_type=1:701;fwd_busy_type
=1:702")

try a voicemail=i:500 not 1:500

Iqbal



Aisling O'Driscoll wrote:

>Hello everyone,
>
>I am trying to modify the Onsip call forward script to forward to
>asterisk voicemail given a users preference. I am using the script
>that Java RockX (Paul) posted in January...
>http://lists.iptel.org/pipermail/serusers/2005-January/014968.html
>
>I think I am getting very confused though with the logic...I want
>users to be able to load their preference using the avpops module of
>whether they want call forward on no answer or voicemail. They get
>directed to voicemail if they dial their own extension number....I
>have posted the modified script which is a combination of the Pauls
>script and the Onsip script...When I start SER I currently have these
>errors but I'd say these are a consequence of my messed up logic
>;)....
>
>0(20031) ERROR:parse_avp_name: unsupported type [1]
> 0(20031) ERROR:add_avp_galias_str: <500> not a valid AVP name
> 0(20031) parse error (70,20-21): Can't set module parameter
>
>The config is below....
>If anyone can offer some insight, Id be very grateful.
>Many thanks,
>Aisling.
>
># $Id: nat-rtpproxy.cfg 9 2005-08-19 15:30:55Z /CN=Greger V.
>Teigre/emailAddress=greger at onsip.org $
>#debug=3
>#fork=yes
>#log_stderror=no
>
>#listen=x.x.x.x           # INSERT YOUR IP ADDRESS HERE
>#port=5060
>#children=4
>
>check_via=no
>dns=no
>rev_dns=no
>fifo="/tmp/ser_fifo"
>fifo_db_url="mysql://root:password@localhost/ser"
>
>alias="x.x.x.x:5060"
>
>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/auth.so"
>loadmodule "/usr/local/lib/ser/modules/auth_db.so"
>loadmodule "/usr/local/lib/ser/modules/uri.so"
>loadmodule "/usr/local/lib/ser/modules/uri_db.so"
>loadmodule "/usr/local/lib/ser/modules/nathelper.so"
>loadmodule "/usr/local/lib/ser/modules/textops.so"
>loadmodule "/usr/local/lib/ser/modules/cpl-c.so"
>loadmodule "/usr/local/lib/ser/modules/avpops.so"
>loadmodule "/usr/local/lib/ser/modules/permissions.so"
>loadmodule "/usr/local/lib/ser/modules/speeddial.so"
>loadmodule "/usr/local/lib/ser/modules/group.so"
>
>modparam("auth_db|permissions|uri_db|usrloc", "db_url",
>"mysql://root:password@localhost/ser")
>modparam("auth_db", "calculate_ha1", 1)
>modparam("auth_db", "password_column", "password")
>
>modparam("nathelper", "natping_interval", 30) #ping every 30 seconds
>modparam("nathelper", "ping_nated_only", 1)   
>modparam("nathelper", "rtpproxy_sock", "/var/run/rtpproxy.sock")
>
>modparam("cpl-c", "cpl_db", "mysql://root:password@localhost/ser")
>modparam("cpl-c", "cpl_table", "cpl")
>modparam("cpl-c", "cpl_dtd_file",
>"/tmp/ser-0.9.3/modules/cpl-c/cpl-06.dtd")
>modparam("cpl-c", "lookup_domain", "location")
>
>modparam("tm", "fr_inv_timer", 27)
>modparam("tm", "fr_inv_timer_avp", "inv_timeout")
>
>modparam("permissions", "db_mode", 1)
>modparam("permissions", "trusted_table", "trusted")
>
>modparam("usrloc", "db_mode", 2)
>
>modparam("registrar", "nat_flag", 6)
>
>modparam("rr", "enable_full_lr", 1)
>
>modparam("speeddial", "db_url", "mysql://root:password@localhost/ser")
>modparam("speeddial", "user_column", "userid")
>modparam("speeddial", "sd_user_column", "short_user")
>modparam("speeddial", "sd_domain_column", "short_domain")
>modparam("speeddial", "new_uri_column", "real_uri")
>
>modparam("avpops", "avp_url", "mysql://root:password@localhost/ser")
>modparam("avpops", "avp_table", "usr_preferences")
>modparam("avpops", "avp_aliases",
>"voicemail=1:500;calltype=i:700;fwd_no_answer_type=1:701;fwd_busy_type
>=1:702")
>
>route {
>
>	# -----------------------------------------------------------------
>	# Sanity Check Section
>	# -----------------------------------------------------------------
>	if (!mf_process_maxfwd_header("10")) {
>		sl_send_reply("483", "Too Many Hops");
>		break;
>	};
>
>	if (msg:len > max_len) {
>		sl_send_reply("513", "Message Overflow");
>		break;
>	};
>
>	#------------------------------------------------------------------
>	# NOTIFY Keep Alive Section
>	#------------------------------------------------------------------
>	if ((method=="NOTIFY") && search("^Event: keep-alive")){
>		sl_send_reply("200", "OK");
>		break;
>	};
>
>	#------------------------------------------------------------------
>	# Speed Dialing Section
>	#------------------------------------------------------------------
>	if ((method=="INVITE") && (uri=~"^sip:[0-9]{2}@.*")) {
>                sd_lookup("speed_dial");
>        };
>
>	#------------------------------------------------------------------
>	# Do not Disturb Section
>	#------------------------------------------------------------------
>	#if(avp_db_load("$ruri/username", "s:donotdisturb")){
>	#	if(avp_check("s:donotdisturb", "eq/y/i")){
>	#		route(x)   #whereever asterisk voicemail is
>	#		break;
>	#	};
>	#};
>
>	# -----------------------------------------------------------------
>	# Record Route Section
>	# -----------------------------------------------------------------
>	if (method!="REGISTER") {
>		record_route();
>	};
>
>	if (method=="BYE" || method=="CANCEL") {
>		unforce_rtp_proxy();
>	};
>
>	if (method=="INVITE"){
>		if(is_user_in("Request-URI", "voicemail")){
>			setflag(31);
>		};
>	};
>
>	#
>----------------------------------------------------------------------
>--
>        # URI Compare Section
>        #
>        # Here we compare the "from" and "to" to see if the caller is
>dialing
>        # their own extension. If so then we route to voicemail if
>needed
>        #
>----------------------------------------------------------------------
>--
>        if (method=="INVITE") {
>                avp_write("$from", "i:34");
>                if (avp_check("i:34", "eq/$ruri/i")) {
>
>                        if (isflagset(31)) {
>                                route(8);
>                                break;
>                        } else {
>                                sl_send_reply("486", "Busy");
>                                break;
>                        };
>                };
>        };
>
>	# -----------------------------------------------------------------
>	# Loose Route Section
>	# -----------------------------------------------------------------
>	if (loose_route()) {
>
>		if (has_totag() && (method=="INVITE" || method=="ACK")) {
>			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=="CANCEL") {
>		route(1);
>		break;
>	} else if (method=="INVITE") {
>		if(!cpl_run_script("incoming", "is_stateless"))
>		{
>			# script execution failed
>			t_reply("500", "CPL script execution failed");
>		};
>		route(3);
>		break;
>	} else  if (method=="REGISTER") {
>		#handle REGISTER messages with CPL script
>		cpl_process_register();
>		route(2);
>		break;
>	};
>
>	lookup("aliases");
>	if (uri!=myself) {
>		route(4);
>		route(1);
>		break;
>	};
>
>	if (!lookup("location")) {
>
>		if(isflagset(31)){
>			setflag(19);
>		};
>
>		#sl_send_reply("404", "User Not Found");
>		#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;
>	};
>
>	#Blind Call Forwarding
>	if (avp_db_load("$ruri/username", "s:callfwd")){
>		setflag(22);
>		avp_pushto("$ruri", "s:callfwd");
>		route(6);
>		break;
>	};
>
>	if (!lookup("location")) {
>		sl_send_reply("404", "User Not Found");
>		break;
>	};
>
>	if (avp_db_load("$ruri/username", "s:fwdbusy")){
>		if(!avp_check("s:fwdbusy", "eq/$ruri/i")){
>			setflag(26);
>		};
>	};
>
>	if (avp_db_load("$ruri/username", "s:fwdnoanswer")){
>		if(!avp_check("s:fwdnoanswer", "eq/$ruri/i")){
>			setflag(27);
>		};
>	};
>
>	t_on_failure("1");
>
>	route(4);
>	route(1);
>}
>
>route[4] {
>
>	# -----------------------------------------------------------------
>	# NAT Traversal Section
>	# -----------------------------------------------------------------
>
>	if (isflagset(6)) {
>		force_rport();
>		fix_nated_contact();
>		force_rtp_proxy();
>	};
>}
>
>route[5]{
>
>	#-----------------------------------------------------------------
>	# PSTN Handler
>	#-----------------------------------------------------------------
>
>	revert_uri();
>        rewritehostport("x.x.x.x:5064");
>        append_branch();
>        t_relay_to_udp("x.x.x.x", "5064");
>	break();
>
>	t_on_failure("1");
>
>	route(4);
>	route(1);
>}
>
>route[6]{
>
>	#------------------------------------------------------------------
>	# Call Forwarding Handler
>	#
>	# This must be done as a route block because sl_send_reply() cannot
>	# be called from the failure_route block
>	#-------------------------------------------------------------------
>
>	if(uri=~"^sip:1[0-9][10]@"){
>		strip(1);
>	};
>
>	lookup ("aliases");
>
>	if(uri!=myself){
>		if(!isflagset(22)){
>			append_branch();
>		};
>
>		route(4);
>		route(1);
>		break;
>	};
>
>	if(uri=~"^sip:011[0-9]*@"){
>		route(4);
>		route(5);
>		break;
>	};
>
>	if(!lookup("location")){
>		if (uri=~"^sip:[0-9][10]@"){
>			route(4);
>			route(1);
>			break;
>		};
>		sl_send_reply("404", "User Not Found");
>	};
>
>	route(4);
>	route(1);
>}
>
>route[8] {
>
>        # voicemail route #2
>        #
>        # this path this executed during these conditions:
>        #
>        #       cond 1) the called number is not in the location table
>        #       cond 2) the from_uri == to_uri (ie, caller==callee)
>
>	if (method == "INVITE" || method == "ACK"){
>		force_rtp_proxy();
>	};
>
>	rewritehostport("x.x.x.x:5064");
>
>        t_on_reply("1");
>
>        if (!t_relay()) {
>
>		if(method == "INVITE" || method == "ACK"){
>			unforce_rtp_proxy();
>		};
>
>                sl_reply_error();
>        };
>}
>
>route[9]{
>
>	#voicemail route 1
>	#
>	#this path is executed during these conditions:
>	#
>	# cond 1) the called number is in the location table
>	#         but the callee did not answer the phone (i.e. failover to
>voicemail)
>
>	rewritehostport("x.x.x.x:5064");
>	append_branch();
>
>	t_on_reply("1");
>
>	if (!t_relay()){
>		if(method == "INVITE" || method=="ACK"){
>			unforce_rtp_proxy();
>		};
>		sl_reply_error();
>	};
>}
>
>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();
>	};
>}
>
>failure_route[1]{
>
>	if(t_check_status("487")){
>		break;
>	};
>
>	if(isflagset(26) && t_check_status("486")){
>		if(avp_pushto("$ruri", "s:fwdbusy")){
>			avp_delete("s:fwdbusy");
>			resetflag(26);
>			append_branch();
>			route(6);
>			break;
>		};
>	};
>
>	#Here we can have either voicemail OR forward no answer
>	#forward on no answer is flag 27
>	#voicemail is flag 31
>
>	if(isflagset(27) && t_check_status("408")){
>		if(avp_pushto("$ruri", "s:fwdnoanswer")){
>			avp_delete("s:fwdnoanswer");
>			resetflag(27);
>			append_branch;
>			route(6);
>			break;
>		};
>	}
>	else if(isflagset(31) && avp_pushto("$ruri", "$voicemail")){
>		avp_delete("$voicemail");
>		route(9);
>		break;
>	};
>}
>
>
>
>-------------------Legal  Disclaimer---------------------------------------
>
>The above electronic mail transmission is confidential and intended only for the person to whom it is addressed. Its contents may be protected by legal and/or professional privilege. Should it be received by you in error please contact the sender at the above quoted email address. Any unauthorised form of reproduction of this message is strictly prohibited. The Institute does not guarantee the security of any information electronically transmitted and is not liable if the information contained in this communication is not a proper and complete record of the message as transmitted by the sender nor for any delay in its receipt.
>
>_______________________________________________
>Serusers mailing list
>serusers at lists.iptel.org
>http://lists.iptel.org/mailman/listinfo/serusers
>
>.
>
>  
>




More information about the sr-users mailing list