Redirecting calls on CLID help

Version 1
    This document was generated from CDN thread

    Created by: BRUCE GIBSON on 21-04-2009 09:32:04 PM
    There is an old script written by Niels Brunsgaard that works well in pre-12.3(14)T with the 'call application voice' command and using that command to specify parameters for the script to match and a number to redirect a call to based on calling line ID.
     
    I've got a customer using that scenario that needs to implement 12.4 IOS on a 3845.  The 'call application voice' command is replaced by the 'application' command.  It appears that I need to adapt the tcl script to this new IOS command structure, but I'm a network guy not a scripter. 
     
    Can someone lend a hand in helping adapt this script to the new IOS structure.  It's probably trivial for someone with scripting skills.  A directed email response is appreciated.
     
    Thanks,
     
    Bruce Gibson
    SE - Upstate NY SLED
    brugibso@cisco.com

    Subject: RE: Redirecting calls on CLID help
    Replied by: VijayPrasad Neelamegam on 22-04-2009 04:08:47 AM
    Hi Bruce,
     
       In 12.4 IOS the script loading and parameter configurations are different,
     
    conf t
    3845(config)#application
    3845(config-app)#service demo tftp://10.20.13.45/thescript.tcl
    3845(config-app-param)#param param-name value
     
    This is just an example,
    The demo is userdefined name to call the script.
    The param-name is the parameter which you want to add under this script.
     
    Hope this helps.
     
    Thanks
    Vijay

    Subject: RE: Redirecting calls on CLID help
    Replied by: VijayPrasad Neelamegam on 22-04-2009 05:21:38 AM
     
     
    Hi Bruce,

    Here is the exact configuration

    This configuration is done in 12.3 IOS

    call application voice ani_filter tftp://tftp/ani_filter.tcl
    call application voice ani_filter clid1 <clid1>
    call application voice ani_filter clid2 <clid2>
    call application voice ani_filter clid3 <clid3>
    .
    .
    call application voice ani_filter clid1000 <clid1000>
    call application voice ani_filter new_dest <new_dest>

    In 12.4 IOS it has been replaced as:

    3845#conf t
    3845(config)#application
    3845(config-appl)#service ani_filter tftp://tftp/ani_filter.tcl
    3845(config-app-param)#param clid1 <clid1>
    3845(config-app-param)#param clid2 <clid2>
    3845(config-app-param)#param clid3 <clid3>
                           .
                           .
                           .
    3845(config-app-param)#param clid1000 <clid1000>
    3845(config-app-param)#param new_dest <new_dest>


    Thanks
    Vijay

    Subject: RE: Redirecting calls on CLID help
    Replied by: BRUCE GIBSON on 22-04-2009 06:02:59 PM
    Vijay,
     
    So it's only the IOS loading and parameter configuration that has to change?  No script modification required?  Fantastic.
    Thank you for such a prompt and thorough response!!  I greatly appreciate your help.
     
    Best Regards,
     
    Bruce

    Subject: RE: Redirecting calls on CLID help
    Replied by: YAW-MING CHEN on 05-05-2009 11:46:01 PM
    Hi Bruce,
     
    Can you send me the script that I can take a look ? If it won't take too much time I can help. If it is time consuming usually it's a fee based service proivided by Cisco developer support.
     
    Thanks,
     
    Yawming

    Subject: RE: Redirecting calls on CLID help
    Replied by: TRUNG NGUYEN on 21-07-2009 01:54:22 PM
    Hi Yawming,
     
    I am the customer Bruce was trying to help.  The script will only work on IOS 12.4 if I use the following parameters.
     
    application
     service ani_filter flash:ani_filter.tcl
      param clid1
      param new_dest 5930
     
    It will not work when I use 'param clid1 " "'.  However, the 'param clid1' command (without " ") doesn't get save every time we reboot the voice gateway, I am guessing it needs the " " value.  Attached is the TCL script.  Please let me know what needs to be changed to allow it to recognize the " " value.
     
    Thanks.  Trung Nguyen.

    Subject: RE: Redirecting calls on CLID help
    Replied by: JASMINE KALAISELVAN on 21-07-2009 02:14:09 PM
    Please have  param clid1 " " . I mean a space between two "

    Subject: RE: Redirecting calls on CLID help
    Replied by: JASMINE KALAISELVAN on 22-07-2009 05:31:11 AM
    Please ignore my previous response. Yes, configuring clid1 with "", works only until reload. If you reload the router even after saving the configuration will not restore the CLI. I would advise you to change the script so that it can check for value NULL instead of "". Then you can configure the application clid as "param clid1 NULL" and inside the script too it checks for the same value of NULL. Hope this helps.

    Subject: RE: Redirecting calls on CLID help
    Replied by: TRUNG NGUYEN on 22-07-2009 02:35:59 PM
    Done one more change apart from your change. Change is in red color in the new script. 
     
    OLD SCRIPT
     
    # ani_filter.tcl
    # Script Version 1.0(1)
    #------------------------------------------------------------------

    # October 2002, Niels Brunsgaard
    #
    # Copyright (c) 1998-2002 by cisco Systems, Inc.
    # All rights reserved.
    #------------------------------------------------------------------

    #
    # This tcl script filters calls based on ANI. If there is
    a match # against a pe-configured list of numbers it changes the DNIS # to a
    configurable value #
    #
     
    proc init { } {
        global param
    }
     
    proc act_Setup { } {
       
        leg setupack leg_incoming
     
        set dnis [infotag get leg_dnis]
        set new_dnis [infotag get cfg_avpair new_dest]
        set ani [infotag get leg_ani]
        set ani_deny ""
        set ani_pi [infotag get leg_ani_pi]
        puts "dnis $dnis new_dnis $new_dnis ani $ani ani_pi $ani_pi"
        if { $ani_pi != "presentation_allowed" } {
          set ani ""
        }
     
        set x 1
        while {1} {
          if {[infotag get cfg_avpair_exists clid$x]} {
            set ani_deny [infotag get cfg_avpair clid$x]
            puts "clid$x = $ani_deny"
            if { $ani == $ani_deny} {
              set dnis $new_dnis
              puts "match clid $ani_deny x=$x"
              break
            }
          } else {
            puts "No more clid at $x"
            break
          }
          incr x
          if { $x > 1000 } { puts "Too many clids" }
        }
        puts "Final dnis $dnis"
        leg proceeding leg_incoming
        leg setup $dnis callInfo leg_incoming
    }
     
    proc act_CallSetupDone { } {
        global beep
     
        set status [infotag get evt_status]
     
        puts "Entering act_CallSetupDone"
        if { $status != "ls_000"} {
            puts "Call [infotag get con_all] got event $status while placing an outgoing
    call"
            call close
        }
    }
     
    proc act_Cleanup { } {
        puts "Entering act_Cleanup"
        call close
    }
     
    proc act_Abort { } {
        puts "Unexpected event - entering act_Abort"
        call close
    }
     
    init
     
    #----------------------------------
    #   State Machine
    #----------------------------------
      set TopFSM(any_state,ev_disconnected) "act_Abort,same_state"
      set TopFSM(CALL_INIT,ev_setup_indication) "act_Setup,PLACECALL"
      set TopFSM(PLACECALL,ev_setup_done) "act_CallSetupDone,CALLACTIVE"
      set TopFSM(CALLACTIVE,ev_disconnected) "act_Cleanup,CALLDISCONNECTED"
      set TopFSM(CALLDISCONNECTED,ev_disconnect_done) "act_Cleanup,same_state"
     
      fsm define
    TopFSM  CALL_INIT
     
     
    NEW SCRIPT
    # ani_filter.tcl
    # Script Version 1.0(1)
    #------------------------------------------------------------------

    # October 2002, Niels Brunsgaard
    #
    # Copyright (c) 1998-2002 by cisco Systems, Inc.
    # All rights reserved.
    #------------------------------------------------------------------

    #
    # This tcl script filters calls based on ANI. If there is
    a match # against a pe-configured list of numbers it changes the DNIS # to a
    configurable value #
    #
     
    proc init { } {
        global param
    }
     
    proc act_Setup { } {
       
        leg setupack leg_incoming
     
        set dnis [infotag get leg_dnis]
        set new_dnis [infotag get cfg_avpair new_dest]
        set ani [infotag get leg_ani]
        set ani_deny NULL
        set ani_pi [infotag get leg_ani_pi]
        puts "dnis $dnis new_dnis $new_dnis ani $ani ani_pi $ani_pi"
        if { $ani_pi != "presentation_allowed" } {
          set ani NULL
        }
     
        set x 1
        while {1} {
          if {[infotag get cfg_avpair_exists clid$x]} {
            set ani_deny [infotag get cfg_avpair clid$x]
            puts "clid$x = $ani_deny"
            if { $ani == $ani_deny} {
              set dnis $new_dnis
              puts "match clid $ani_deny x=$x"
              break
            }
          } else {
            puts "No more clid at $x"
            break
          }
          incr x
          if { $x > 1000 } { puts "Too many clids" }
        }
        puts "Final dnis $dnis"
        leg proceeding leg_incoming
        leg setup $dnis callInfo leg_incoming
    }
     
    proc act_CallSetupDone { } {
        global beep
     
        set status [infotag get evt_status]
     
        puts "Entering act_CallSetupDone"
        if { $status != "ls_000"} {
            puts "Call [infotag get con_all] got event $status while placing an outgoing
    call"
            call close
        }
    }
     
    proc act_Cleanup { } {
        puts "Entering act_Cleanup"
        call close
    }
     
    proc act_Abort { } {
        puts "Unexpected event - entering act_Abort"
        call close
    }
     
    init
     
    #----------------------------------
    #   State Machine
    #----------------------------------
      set TopFSM(any_state,ev_disconnected) "act_Abort,same_state"
      set TopFSM(CALL_INIT,ev_setup_indication) "act_Setup,PLACECALL"
      set TopFSM(PLACECALL,ev_setup_done) "act_CallSetupDone,CALLACTIVE"
      set TopFSM(CALLACTIVE,ev_disconnected) "act_Cleanup,CALLDISCONNECTED"
      set TopFSM(CALLDISCONNECTED,ev_disconnect_done) "act_Cleanup,same_state"
     
      fsm define
    TopFSM  CALL_INIT