Hi
@Mark: I agree, but some people only really need ser, or should I say if your route to much to asterisk its pointless having ser, I keep my Ip__IP traffic in ser, in fact my billing there also, asterisk as you mentioned for features, and when my upstream gateway wont support REFER to do transfers, and cool things like call pickup.
@Aisling: if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; };
what this will do is to see if the username you have in RURI is in your grp table and has an entry of voicemail next to it, if so it will set a flag 31
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; }; }; };
what this does is basically to see if your are calling yourself, i.e if the from and the RURI is the same, first it stores the from setting, and the compares that to your ruri.Now if they are the same, it will see if flag 31 is set, i.e if you have voicemail attached to the RURI in grp table. If both are true then goto route8, at which point it seems as if your are relaying to another server.
You seem to be getting busy, which means that flag 31 is not being set, check your ngrep dump see what your RURI has, and see what entries your grp table has.
The problem with matching like this (or at least the problem(s) I had) was that there are alot of different call scenarios which all need to be taken into account.
EG my usernames are not e164 numbers, they are part of that number, which means my ruri, and from can be different to the e164 format. Now when a caller calls from 040600, to 0845040602, it should see if 0845xxx is busy, send to voicemail, but in grp ther is no 0845xxx, hence I need to make sure that the check/match is done after the alias lookup. I had to move lookup(aliases) near the to to make sure all my lookups had been done at the start, and then I can start matching.
Your best friend will be ngrep, if you start doing the diff call scenarios, and seeing what needs to be matched, you can set 1 run settings, once it all works work out a tidier logic.
If you throw asterisk into the loop, you add another headache (depending on what you do), cause asterisk was really designed for ip devices to register with it, but if you register in ser, you could lose some of that info (although latest beta, has some nice SIP header parsing, to pull info from).
The other problem you may hit with voicemail, depends on how you set your username, initially my subscriber table had names for username...eg Iqbal, and the alias would be 040600, or whatever, problem with this was that voicemail in asterisk is better with number, especially when you have to dial the mailbox number from your phone :-), so I switched the subscriber table to hold the number, cause I think unless you will be using software dialers, no one will type in names.
"voicemail=1:500;calltype=i:700;fwd_no_answer_type=1:701;fwd_busy_type
=1:702")
All this does is to define aliases, you can use it, or not
iqbal
Mark Aiken wrote:
I see a lot of people trying to use SER and Asterisk together but mixing the roles in strange and complex ways.
Asterisk is an excellent SIP "feature server" and "b2bua" where SER is an excellent SIP proxy, registrar, and far-end NAT solution.
If you design your network based on those strengths you can create a solution that rivals 7 figure commercial solutions. People that do otherwise seem to just fall over themselves.
Mark
On 9/21/05, *Aisling* <ashling.odriscoll@cit.ie mailto:ashling.odriscoll@cit.ie> wrote:
Many thanks Iqbal- That was the problem. I think the issue is that I don't even really understand what that line does or how the code that I took from Paul's config affected my config file.....SER now displays no errors but is still not working as expected. For example I expect that if a phone (e.g. 2092) dials its own extension, it should be caught by if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; }; This then should be caught by the URI Compare code below and routed to route[8].... However that's not happening and a 486 Busy is being returned to the phone. I find this hard to troubleshoot because I think the code should be correct...given my current understanding anyhow... If Iqbal (or anyone else) has a clearer understanding of this and can shed some light on it, that would be great. Kindest Regards, Aisling. -----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk <mailto:iqbal@gigo.co.uk>] Sent: 21 September 2005 15:20 To: Aisling O'Driscoll Cc: serusers@lists.iptel.org <mailto:serusers@lists.iptel.org> Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script "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@onsip.org <mailto:greger@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@lists.iptel.org <mailto:serusers@lists.iptel.org> >http://lists.iptel.org/mailman/listinfo/serusers > >. > > > -------------------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. -------------------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@lists.iptel.org <mailto:serusers@lists.iptel.org> http://lists.iptel.org/mailman/listinfo/serusers <http://lists.iptel.org/mailman/listinfo/serusers>
Hi Iqbal,
Thanks for the detailed reply....I have an outline plan for how my asterisk/ser setup will work (using the onsip callforward script with rtp proxy)....If the logic is messed up please let me know because I'm trying to minimize the chance of making stupid changes to the config which will affect other things....Then hopefully if this makes sense it might help other people....
#########################Leaving voicemail################################
1) In the usr_preferences table in the ser database have an entry for user 2092.
Insert into usr_preferences (username, attribute, value) values ("2092", "voicemail", "y");
2) In Route[3] (used for call invite handling)
if(avp_db_load("$ruri/username","s:voicemail")){ if(avp_check("s:voicemail", "eq/y/I")){ setflag(5); }; };
This will check if the user wants to use voicemail according to the preference that is set for them in the usr_preferences table. I they don't want to use voicemail set value to "n"
3) In failure route[1]
if(isflagset(5) && t_check_status("408")){ avp_delete("s:voicemail"); resetflag(5); append_branch(); route(x); break; };
4) route[x]
{ acc_db_request("missed called", "missed_calls"); revert_uri(); rewritehostport("x.x.x.x:5064"); append_branch(); t_relay_to_udp(x.x.x.x", "5064"); break(); }
###################################Playing Voicemail#######################
1) as above
2) as above
3) If the user dials their own username they will be diverted to asterisk
if (method=="INVITE"){ if(avp_check("i:34", "eq/$ruri/i")){ if(isflagset(5)){ route(x); break; } else{ sl_send_reply("486", "Busy"); break; }; }; };
4) route[x] as before
Aisling.
-----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk] Sent: 23 September 2005 10:24 To: Mark Aiken Cc: Aisling; serusers@lists.iptel.org Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
Hi
@Mark: I agree, but some people only really need ser, or should I say if
your route to much to asterisk its pointless having ser, I keep my Ip__IP traffic in ser, in fact my billing there also, asterisk as you mentioned for features, and when my upstream gateway wont support REFER to do transfers, and cool things like call pickup.
@Aisling: if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; };
what this will do is to see if the username you have in RURI is in your grp table and has an entry of voicemail next to it, if so it will set a flag 31
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; }; }; };
what this does is basically to see if your are calling yourself, i.e if the from and the RURI is the same, first it stores the from setting, and
the compares that to your ruri.Now if they are the same, it will see if flag 31 is set, i.e if you have voicemail attached to the RURI in grp table. If both are true then goto route8, at which point it seems as if your are relaying to another server.
You seem to be getting busy, which means that flag 31 is not being set, check your ngrep dump see what your RURI has, and see what entries your grp table has.
The problem with matching like this (or at least the problem(s) I had) was that there are alot of different call scenarios which all need to be
taken into account.
EG my usernames are not e164 numbers, they are part of that number, which means my ruri, and from can be different to the e164 format. Now when a caller calls from 040600, to 0845040602, it should see if 0845xxx is busy, send to voicemail, but in grp ther is no 0845xxx, hence
I need to make sure that the check/match is done after the alias lookup.
I had to move lookup(aliases) near the to to make sure all my lookups had been done at the start, and then I can start matching.
Your best friend will be ngrep, if you start doing the diff call scenarios, and seeing what needs to be matched, you can set 1 run settings, once it all works work out a tidier logic.
If you throw asterisk into the loop, you add another headache (depending
on what you do), cause asterisk was really designed for ip devices to register with it, but if you register in ser, you could lose some of that info (although latest beta, has some nice SIP header parsing, to pull info from).
The other problem you may hit with voicemail, depends on how you set your username, initially my subscriber table had names for username...eg
Iqbal, and the alias would be 040600, or whatever, problem with this was
that voicemail in asterisk is better with number, especially when you have to dial the mailbox number from your phone :-), so I switched the subscriber table to hold the number, cause I think unless you will be using software dialers, no one will type in names.
"voicemail=1:500;calltype=i:700;fwd_no_answer_type=1:701;fwd_busy_type
=1:702")
All this does is to define aliases, you can use it, or not
iqbal
Mark Aiken wrote:
I see a lot of people trying to use SER and Asterisk together but mixing the roles in strange and complex ways.
Asterisk is an excellent SIP "feature server" and "b2bua" where SER is
an excellent SIP proxy, registrar, and far-end NAT solution.
If you design your network based on those strengths you can create a solution that rivals 7 figure commercial solutions. People that do otherwise seem to just fall over themselves.
Mark
On 9/21/05, *Aisling* <ashling.odriscoll@cit.ie mailto:ashling.odriscoll@cit.ie> wrote:
Many thanks Iqbal- That was the problem. I think the issue is that I don't even really understand what that line does or how the code that I took from Paul's config affected my
config
file.....SER now displays no errors but is still not working as expected. For example I expect that if a phone (e.g. 2092) dials its own extension, it should be caught by if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; }; This then should be caught by the URI Compare code below and
routed to
route[8].... However that's not happening and a 486 Busy is being returned to
the
phone. I find this hard to troubleshoot because I think the code should be correct...given my current understanding anyhow... If Iqbal (or anyone else) has a clearer understanding of this and
can
shed some light on it, that would be great. Kindest Regards, Aisling. -----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk <mailto:iqbal@gigo.co.uk>] Sent: 21 September 2005 15:20 To: Aisling O'Driscoll Cc: serusers@lists.iptel.org <mailto:serusers@lists.iptel.org> Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
"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@onsip.org <mailto:greger@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.
seems fine I have done it in grp table, and use is_user_in, "voicemail" check instead and set a flag, I am not sure whats best practive, and sure usr_preferences is the way to go, but I decided to use that for features like callfwd, donotdisturb, as opposed to voicemail which I figured fell into a diff category. Either way it should be fine.
Once the check is done, flags set the rest is fine.
Now for playing voicemail, what i do is near the top of my INVITE handler i see what number has been dialied, so if the user dials 699 (my voicemail number for all users), it sends straight to asterik, where they get prompted for username/pass combo to listen to voicemail, and then to use externally what I did was to bind 123456789 to my ser, and again if that gets dialed send to asterisk to pickup users voicemail also.
Iqbal
Aisling wrote:
Hi Iqbal,
Thanks for the detailed reply....I have an outline plan for how my asterisk/ser setup will work (using the onsip callforward script with rtp proxy)....If the logic is messed up please let me know because I'm trying to minimize the chance of making stupid changes to the config which will affect other things....Then hopefully if this makes sense it might help other people....
#########################Leaving voicemail################################
- In the usr_preferences table in the ser database have an entry for
user 2092.
Insert into usr_preferences (username, attribute, value) values ("2092", "voicemail", "y");
- In Route[3] (used for call invite handling)
if(avp_db_load("$ruri/username","s:voicemail")){ if(avp_check("s:voicemail", "eq/y/I")){ setflag(5); }; };
This will check if the user wants to use voicemail according to the preference that is set for them in the usr_preferences table. I they don't want to use voicemail set value to "n"
- In failure route[1]
if(isflagset(5) && t_check_status("408")){ avp_delete("s:voicemail"); resetflag(5); append_branch(); route(x); break; };
- route[x]
{ acc_db_request("missed called", "missed_calls"); revert_uri(); rewritehostport("x.x.x.x:5064"); append_branch(); t_relay_to_udp(x.x.x.x", "5064"); break(); }
###################################Playing Voicemail#######################
as above
as above
If the user dials their own username they will be diverted to
asterisk
if (method=="INVITE"){ if(avp_check("i:34", "eq/$ruri/i")){ if(isflagset(5)){ route(x); break; } else{ sl_send_reply("486", "Busy"); break; }; }; };
- route[x] as before
Aisling.
-----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk] Sent: 23 September 2005 10:24 To: Mark Aiken Cc: Aisling; serusers@lists.iptel.org Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
Hi
@Mark: I agree, but some people only really need ser, or should I say if
your route to much to asterisk its pointless having ser, I keep my Ip__IP traffic in ser, in fact my billing there also, asterisk as you mentioned for features, and when my upstream gateway wont support REFER to do transfers, and cool things like call pickup.
@Aisling: if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; };
what this will do is to see if the username you have in RURI is in your grp table and has an entry of voicemail next to it, if so it will set a flag 31
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; }; }; };
what this does is basically to see if your are calling yourself, i.e if the from and the RURI is the same, first it stores the from setting, and
the compares that to your ruri.Now if they are the same, it will see if flag 31 is set, i.e if you have voicemail attached to the RURI in grp table. If both are true then goto route8, at which point it seems as if your are relaying to another server.
You seem to be getting busy, which means that flag 31 is not being set, check your ngrep dump see what your RURI has, and see what entries your grp table has.
The problem with matching like this (or at least the problem(s) I had) was that there are alot of different call scenarios which all need to be
taken into account.
EG my usernames are not e164 numbers, they are part of that number, which means my ruri, and from can be different to the e164 format. Now when a caller calls from 040600, to 0845040602, it should see if 0845xxx is busy, send to voicemail, but in grp ther is no 0845xxx, hence
I need to make sure that the check/match is done after the alias lookup.
I had to move lookup(aliases) near the to to make sure all my lookups had been done at the start, and then I can start matching.
Your best friend will be ngrep, if you start doing the diff call scenarios, and seeing what needs to be matched, you can set 1 run settings, once it all works work out a tidier logic.
If you throw asterisk into the loop, you add another headache (depending
on what you do), cause asterisk was really designed for ip devices to register with it, but if you register in ser, you could lose some of that info (although latest beta, has some nice SIP header parsing, to pull info from).
The other problem you may hit with voicemail, depends on how you set your username, initially my subscriber table had names for username...eg
Iqbal, and the alias would be 040600, or whatever, problem with this was
that voicemail in asterisk is better with number, especially when you have to dial the mailbox number from your phone :-), so I switched the subscriber table to hold the number, cause I think unless you will be using software dialers, no one will type in names.
"voicemail=1:500;calltype=i:700;fwd_no_answer_type=1:701;fwd_busy_type
=1:702")
All this does is to define aliases, you can use it, or not
iqbal
Mark Aiken wrote:
I see a lot of people trying to use SER and Asterisk together but mixing the roles in strange and complex ways.
Asterisk is an excellent SIP "feature server" and "b2bua" where SER is
an excellent SIP proxy, registrar, and far-end NAT solution.
If you design your network based on those strengths you can create a solution that rivals 7 figure commercial solutions. People that do otherwise seem to just fall over themselves.
Mark
On 9/21/05, *Aisling* <ashling.odriscoll@cit.ie mailto:ashling.odriscoll@cit.ie> wrote:
Many thanks Iqbal- That was the problem.
I think the issue is that I don't even really understand what that line does or how the code that I took from Paul's config affected my
config
file.....SER now displays no errors but is still not working as expected. For example I expect that if a phone (e.g. 2092) dials its own extension, it should be caught by
if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; };
This then should be caught by the URI Compare code below and
routed to
route[8]....
However that's not happening and a 486 Busy is being returned to
the
phone. I find this hard to troubleshoot because I think the code should be correct...given my current understanding anyhow...
If Iqbal (or anyone else) has a clearer understanding of this and
can
shed some light on it, that would be great.
Kindest Regards, Aisling.
-----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk mailto:iqbal@gigo.co.uk] Sent: 21 September 2005 15:20 To: Aisling O'Driscoll Cc: serusers@lists.iptel.org mailto:serusers@lists.iptel.org Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
"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@onsip.org mailto:greger@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.
.
Hello,
Following on from what I said below, I changed my ser.cfg (bearing in mind that my ser.cfg is the onsip call feature on with rtpproxy support)to support asterisk voicemail according to my plan.....At first I am only dealing with leaving the voicemail.
In route[3] (The INVITE handler route), I added:
if(avp_db_load("$ruri/username", "s:voicemail")){ if(avp_check("s:voicemail", "eq/y/I")){ setflag(5); }; };
Then in failure route I changed the end to:
if(isflagset(27) && t_check_status("408")){ if(avp_pushto("$ruri", "s:fwdnoanswer")){ avp_delete("s:fwdnoanswer"); resetflag(27); route(6); break; }; } else{ if(isflagset(5) && t_check_status("408")){ resetflag(5); log(1, "in failure route - flag 5 is set, should be routing to route 7"); break; }; }; unforce_rtp_proxy(); }
route[7]{ log(1, "In route 7!! - before revert uri"); revert_uri(); log(1, "In route 7!! - before rewritehostport"); rewritehostport("x.x.x.x:5064"); log(1, "In route 7!! - before append branch"); append_branch(); log(1, "In route 7!! - before t relay to udp"); t_relay_to_udp("x.x.x.x", "5064"); log(1, "In route 7!! - before break"); break; }
Now what's strange is that all the log messages are printed meaning the flag is being set (because voicemail is set to 'y' in the usr_preferences table), the failure route is being entered and its going to route 7, but strangely enough a 404 Not Found message is being sent to the phone....Does anyone have any ideas???
Many thanks as always for help.
-----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk] Sent: 23 September 2005 15:41 To: Aisling Cc: 'Mark Aiken'; serusers@lists.iptel.org Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
seems fine I have done it in grp table, and use is_user_in, "voicemail" check instead and set a flag, I am not sure whats best practive, and sure usr_preferences is the way to go, but I decided to use that for features like callfwd, donotdisturb, as opposed to voicemail which I figured fell into a diff category. Either way it should be fine.
Once the check is done, flags set the rest is fine.
Now for playing voicemail, what i do is near the top of my INVITE handler i see what number has been dialied, so if the user dials 699 (my
voicemail number for all users), it sends straight to asterik, where they get prompted for username/pass combo to listen to voicemail, and then to use externally what I did was to bind 123456789 to my ser, and again if that gets dialed send to asterisk to pickup users voicemail also.
Iqbal
Aisling wrote:
Hi Iqbal,
Thanks for the detailed reply....I have an outline plan for how my asterisk/ser setup will work (using the onsip callforward script with rtp proxy)....If the logic is messed up please let me know because I'm trying to minimize the chance of making stupid changes to the config which will affect other things....Then hopefully if this makes sense it might help other people....
#########################Leaving voicemail################################
- In the usr_preferences table in the ser database have an entry for
user 2092.
Insert into usr_preferences (username, attribute, value) values
("2092",
"voicemail", "y");
- In Route[3] (used for call invite handling)
if(avp_db_load("$ruri/username","s:voicemail")){ if(avp_check("s:voicemail", "eq/y/I")){ setflag(5); }; };
This will check if the user wants to use voicemail according to the preference that is set for them in the usr_preferences table. I they don't want to use voicemail set value to "n"
- In failure route[1]
if(isflagset(5) && t_check_status("408")){ avp_delete("s:voicemail"); resetflag(5); append_branch(); route(x); break; };
- route[x]
{ acc_db_request("missed called", "missed_calls"); revert_uri(); rewritehostport("x.x.x.x:5064"); append_branch(); t_relay_to_udp(x.x.x.x", "5064"); break(); }
###################################Playing Voicemail#######################
as above
as above
If the user dials their own username they will be diverted to
asterisk
if (method=="INVITE"){ if(avp_check("i:34", "eq/$ruri/i")){ if(isflagset(5)){ route(x); break; } else{ sl_send_reply("486", "Busy"); break; }; }; };
- route[x] as before
Aisling.
-----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk] Sent: 23 September 2005 10:24 To: Mark Aiken Cc: Aisling; serusers@lists.iptel.org Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
Hi
@Mark: I agree, but some people only really need ser, or should I say
if
your route to much to asterisk its pointless having ser, I keep my Ip__IP traffic in ser, in fact my billing there also, asterisk as you mentioned for features, and when my upstream gateway wont support REFER
to do transfers, and cool things like call pickup.
@Aisling: if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; };
what this will do is to see if the username you have in RURI is in your
grp table and has an entry of voicemail next to it, if so it will set a
flag 31
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; }; }; };
what this does is basically to see if your are calling yourself, i.e if
the from and the RURI is the same, first it stores the from setting,
and
the compares that to your ruri.Now if they are the same, it will see if
flag 31 is set, i.e if you have voicemail attached to the RURI in grp table. If both are true then goto route8, at which point it seems as if
your are relaying to another server.
You seem to be getting busy, which means that flag 31 is not being set,
check your ngrep dump see what your RURI has, and see what entries your
grp table has.
The problem with matching like this (or at least the problem(s) I had) was that there are alot of different call scenarios which all need to
be
taken into account.
EG my usernames are not e164 numbers, they are part of that number, which means my ruri, and from can be different to the e164 format. Now when a caller calls from 040600, to 0845040602, it should see if 0845xxx is busy, send to voicemail, but in grp ther is no 0845xxx,
hence
I need to make sure that the check/match is done after the alias
lookup.
I had to move lookup(aliases) near the to to make sure all my lookups had been done at the start, and then I can start matching.
Your best friend will be ngrep, if you start doing the diff call scenarios, and seeing what needs to be matched, you can set 1 run settings, once it all works work out a tidier logic.
If you throw asterisk into the loop, you add another headache
(depending
on what you do), cause asterisk was really designed for ip devices to register with it, but if you register in ser, you could lose some of that info (although latest beta, has some nice SIP header parsing, to pull info from).
The other problem you may hit with voicemail, depends on how you set your username, initially my subscriber table had names for
username...eg
Iqbal, and the alias would be 040600, or whatever, problem with this
was
that voicemail in asterisk is better with number, especially when you have to dial the mailbox number from your phone :-), so I switched the subscriber table to hold the number, cause I think unless you will be using software dialers, no one will type in names.
"voicemail=1:500;calltype=i:700;fwd_no_answer_type=1:701;fwd_busy_type
=1:702")
All this does is to define aliases, you can use it, or not
iqbal
Mark Aiken wrote:
I see a lot of people trying to use SER and Asterisk together but mixing the roles in strange and complex ways.
Asterisk is an excellent SIP "feature server" and "b2bua" where SER is
an excellent SIP proxy, registrar, and far-end NAT solution.
If you design your network based on those strengths you can create a solution that rivals 7 figure commercial solutions. People that do otherwise seem to just fall over themselves.
Mark
On 9/21/05, *Aisling* <ashling.odriscoll@cit.ie mailto:ashling.odriscoll@cit.ie> wrote:
Many thanks Iqbal- That was the problem.
I think the issue is that I don't even really understand what that line does or how the code that I took from Paul's config affected my
config
file.....SER now displays no errors but is still not working as expected. For example I expect that if a phone (e.g. 2092) dials its own extension, it should be caught by
if (method=="INVITE"){ if(is_user_in("Request-URI", "voicemail")){ setflag(31); }; };
This then should be caught by the URI Compare code below and
routed to
route[8]....
However that's not happening and a 486 Busy is being returned to
the
phone. I find this hard to troubleshoot because I think the code should be correct...given my current understanding anyhow...
If Iqbal (or anyone else) has a clearer understanding of this and
can
shed some light on it, that would be great.
Kindest Regards, Aisling.
-----Original Message----- From: Iqbal [mailto:iqbal@gigo.co.uk mailto:iqbal@gigo.co.uk] Sent: 21 September 2005 15:20 To: Aisling O'Driscoll Cc: serusers@lists.iptel.org mailto:serusers@lists.iptel.org Subject: Re: [Serusers] ONSIP Script + Java Rockx ser 0.9.0 script
"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@onsip.org mailto:greger@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.
.
-------------------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.
-------------------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.