Possible to use wildcards in param clid under service ani_filter?

Version 1
    This document was generated from CDN thread

    Created by: Joe Bourne on 27-12-2009 10:48:24 PM
    I have the ani_filter TCL application running well on a UC520 with IOS 12.4(22)YB4.
     
    I am trying to block calls from a telemarketing group that has part of the range 770-452-9xxx. I can block them fine individually, but was wondering if there's an option to wildcard a number range in the 'param clidn', similar to
        UC520(config-app-param)#param clid38 77045296..
     
    I've read through the TCL IVR documentation, and I'm not grasping how/if I can control the clid interpretation. I'd like to be able to block  7704529564 through 7704529624, if possible.
     
    Also, is there a way to get the param clid staments to display in order? When I sho run, I get what appears to be a jumble:
     
    application
     service ani_filter flash:/TCL/ani_filter.tcl
      param clid27 8664339146
      param clid9 7037702249
      param clid10 8772132767
      param clid37 8663005574
      param clid20 3238173539
      param clid19 8883557209
      param clid2 8667849307
      param clid30 4077223516
      param clid29 2057766011
      param clid12 8005476110
      param clid22 8008040057
      param clid4 8776191828
      param clid32 4806492753
      param clid14 2025562270
      param new_dest 700
      param clid6 8662111876
      param clid24 7704529625
      param clid16 8772135152
      param clid34 2057766016
      param clid8 8664315121
      param clid26 8009934685
      param clid36 2057766017
      param clid18 8009421970
      param clid1 2026072579
      param clid11 6782982073
      param clid28 2133216218
      param clid21 3238173582
      param clid3 8883792463
      param clid31 2027477340
      param clid13 8665917737
      param clid5 2485838084
      param clid23 4806033796
      param clid15 8668391376
      param clid33 2012574086
      param clid25 7704529564
      param clid7 3238173529
      param clid17 8772135046
      param clid35 5136392399
     !
    This makes it a bit bothersome to find which 'clidn' number to use next when updatin the script.
     
    Many thanks,
    Joe

    Subject: New Message from Joe Bourne in Voice Gateway API (VGAPI) - TCL-API: Possibl
    Replied by: Anusha Kannappan on 27-12-2009 10:49:10 PM
    Hi,

    I will be on PTO till 28th December 2009 and will be back to office on 29th December 2009. I will not be able to access mails during this period, shall respond to your mails once I come back.

    Thanks,
    Anusha

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Anusha Kannappan on 29-12-2009 11:01:47 AM
    Hi Joe,
     
    It is not possible to use the wildcard in param clid under the service ani_filter. In the script The loop reads through all configured ¿blocked¿ CLIDs and compares each CLID against the ani. While performing this comparison if we use the wild card for a particular clid means the condition fails and the call can not be blocked or redirected. 
     
    I am not very sure of whether there is a way to get the param clid staments to display in order. Though we add the clids in order they get jumbled when we do a show run.
     
    Thanks,
    Anusha.

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Joe Bourne on 03-01-2010 10:34:45 PM
    Okay. Thank you for the reply.

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 04-02-2010 08:26:22 PM
    Is there a way to have multiple newdest fields?  I have a group of 100 number that are being custom redirected to a single DID.  When you view that call the Calling Number field is what I need to match on but I just want to take the CPN and make it the newdest. 
     
    So if 5551212 is the calling number and the called party number is 5551234, I just want to do a one to one matching but for all 100 numbers in my list.
     
    dial-peer voice 1 pots
     incoming called-number 5551234
     service ani_filter
     
     
    application
      service ani_filter tftp://x.x.x.x/ani_filter.tcl
      param new_dest 5551212
      param clid1 5551212
     
     
    So I would like to be able to do this:
     
    application

      service ani_filter tftp://x.x.x.x/ani_filter.tcl

      param new_dest1 5551212

      param clid1 5551212
      param new_dest2 5551213


      param clid2 5551213
      param new_dest3 5551214



      param clid3 5551214
      .
      .
      .
     
     
     
     

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yawming Chen on 04-02-2010 09:11:51 PM
    It really depends on the pattern of your mapping.
     
    If the rule is just like you decribed then it's easy. We jsut get the ANI the make DNIS +1
     
    set ani [infotag get leg_ani]
    set dnis [expr $ani + 1]
     
    If rule is not this but there is a rule that we can apply regular expression then use regular expression
     
    If ther is no rule then
    1. use the existing script
    or
    2. create a flat text file, example (personally I think this is neater. )
     
    5551212 5552001
    5551213 5552012
    5551214 5552135
    ....
     
    then read the file in when initialize the script.
     
    Thanks !
     
     

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 05-02-2010 04:30:11 PM
    So the beginning of the script would look like this?
     
     
     
    proc init { } {
        global param
    }

    proc act_Setup { } {
       
        leg setupack leg_incoming

        set dnis [expr $ani + 1]
        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 ""

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yawming Chen on 05-02-2010 04:58:58 PM
    No !
     
    If rule is DNIS = ANI + 1
    then get ANI first
     
     set ani [infotag get leg_ani]

     set dnis [expr $ani + 1]

            leg proceeding leg_incoming
            leg setup $dnis callInfo leg_incoming
     
     
    Thanks,
     
    Yawming
     
     

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yawming Chen on 05-02-2010 07:24:21 PM
    Let's backup a little bit,
     
    All you liek to do is changing destination number to be incoming number +1, right ?
     
    In this case I don't sguuest using  ani_filter.tcl.
    Yue need to modify it.
    The scirpt will be very simple, don't need any " param " configuration from IOS CLI

    something like this :


    proc act_Setup { } {
        global dest

        if { [infotag get leg_isdid] } {

        set ani [infotag get leg_ani]
      
        set dest [expr $ani + 1]

            leg proceeding leg_incoming
            leg setup $dest callInfo leg_incoming
            fsm setstate PLACECALL

        } else {
            puts "only for DID"
             call close
        }

    }


    proc act_CallSetupDone { } {
        set status [infotag get evt_status]
        puts "TCL: Status of leg setup is $status"
        if { $status == "ls_000"} {

         handoff appl leg_all default

      act_Cleanup
        } else {
            act_Cleanup
        }
    }

    proc act_Cleanup { } {
        call close
    }

    ############# Initializing global varaiables #####################

    #------------------
    #   State Machine
    #----------------------------------
      set fsm(any_state,ev_disconnected)  "act_Cleanup              same_state"
      set fsm(CALL_INIT,ev_setup_indication) "act_Setup            PLACCECALL"

      set fsm(PLACECALL,ev_setup_done)    "act_CallSetupDone    CALLACTIVE"
      set fsm(CALLACTIVE,ev_disconnected)   "act_Cleanup         CALLDISCONNECT"
      set fsm(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"
      set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"
      fsm define fsm CALL_INIT

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 05-02-2010 07:10:09 PM
    I am not sure I understand.  Here is what I have now.  I get the ANI first then added the command from the previous posts.
     
    proc init { } {
        global param
    }

    proc act_Setup { } {
       
        leg setupack leg_incoming


        set ani [infotag get leg_ani]
        set ani_deny ""
        set ani_pi [infotag get leg_ani_pi]
        set dnis [expr $ani + 1]

        set new_dnis [infotag get cfg_avpair new_dest]
        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
     
     
     
     
    Here is my router config:
     
    application
      service ani_filter tftp://10.83.25.227/ani_filter.tcl
      param clid1 5556661234
      param new_dest 5556661234
     
    THAT WORKS
     
     
    I then try:
     
    application

      service ani_filter tftp://10.83.25.227/ani_filter.tcl

      param clid1 5556661234

      param new_dest1 5556661234
      param clid2 5556661235


      param new_dest2 5556661235
     
    THAT DOES NOT WORK
     
     
    The script looks for new_dest and if I put something after that in the router it fails.  I want to capture 99 specific numbers and change them to themselves.

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 05-02-2010 07:38:21 PM
    Let's backup a little bit,
     
    All you like to do is changing destination number to be incoming number +1, right ?
     
    In this case I don't sguuest using  ani_filter.tcl.
    Yue need to modify it.
    The scirpt will be very simple, don't need any " param " configuration from IOS CLI

    something like this :


    proc act_Setup { } {
        global dest

        if { [infotag get leg_isdid] } {

        set ani [infotag get leg_ani]
      
        set dest [expr $ani + 1]

            leg proceeding leg_incoming
            leg setup $dest callInfo leg_incoming
            fsm setstate PLACECALL

        } else {
            puts "only for DID"
             call close
        }

    }


    proc act_CallSetupDone { } {
        set status [infotag get evt_status]
        puts "TCL: Status of leg setup is $status"
        if { $status == "ls_000"} {

         handoff appl leg_all default

      act_Cleanup
        } else {
            act_Cleanup
        }
    }

    proc act_Cleanup { } {
        call close
    }

    ############# Initializing global varaiables #####################

    #------------------
    #   State Machine
    #----------------------------------
      set fsm(any_state,ev_disconnected)  "act_Cleanup              same_state"
      set fsm(CALL_INIT,ev_setup_indication) "act_Setup            PLACCECALL"

      set fsm(PLACECALL,ev_setup_done)    "act_CallSetupDone    CALLACTIVE"
      set fsm(CALLACTIVE,ev_disconnected)   "act_Cleanup         CALLDISCONNECT"
      set fsm(CALLDISCONNECT,ev_disconnected)   "act_Cleanup         same_state"
      set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup         same_state"
      fsm define fsm CALL_INIT


     
     
    Thank you very much for your help and patience.  I only want to do that for 99 particular numbers.  I would assume if I apply this application to a dial-peer it would translate all calls hitting the dial-peer.  The numbers I want to match on would come in as 4000 - 4099.
     
    Thanks,
    Chris

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yawming Chen on 05-02-2010 07:53:45 PM
    If you use the example I show you it will translate any calling number to destination number and the translation rule is dest number = calling number + 1
     
    Is this what you like to confirm ?
     
    Hope I answer your question. Please let me know if there is naything not clear
     
    Thanks !
     

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 17-02-2010 01:47:20 PM
    This is not exactly what I need.  Lets says that out of all calling numbers coming into the gateway I want to only change 100 of them.  The rest of the numbers need to pass through the gateway untouched.  They need to come in as a calling number and go out to CallManager as the same calling number.  Now, the 100 numbers that need to be translated from calling number to called number will all be a one-for-one match.
     
    So if those 100 numbers that need changed begin with 5556664100 and end with 5556664199, those are the only numbers that I want to alter.
     
    So if someone called from 5556664200 it should go through as the calling number and not be translated to the called number, but if I see someone calling in from 5556664100 then it should be translated to the called number of 5556664100 and sent along to CallManager. 
     
    Sorry for the confusion and thank you for the help.
     
    Chris
     

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yawming Chen on 17-02-2010 03:49:49 PM
    It's tha same thing, use the regular express.
     
    for examplr set d as calling number

     if {[regexp {55566641[0-9][0-9]} $d]}
     
    then use calliing as called
     
    Thanks,
     
    Yawming

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yaw-Ming Chen on 17-06-2013 12:12:43 PM
    Yes you can use that concept,  or if you can find a pattern you can just use tcl string command to manipulate it.
    for example if you just need to remove every second digit then use some string commands is enough, 91281208 --> 9281208

    Thanks,

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 17-06-2013 11:54:18 AM
    Yaw-Ming Chen:
    It really depends on the pattern of your mapping.
     
    If the rule is just like you decribed then it's easy. We jsut get the ANI the make DNIS +1
     
    set ani [infotag get leg_ani]
    set dnis [expr $ani + 1]
     
    If rule is not this but there is a rule that we can apply regular expression then use regular expression
     
    If ther is no rule then
    1. use the existing script
    or
    2. create a flat text file, example (personally I think this is neater. )
     
    5551212 5552001
    5551213 5552012
    5551214 5552135
    ....
     
    then read the file in when initialize the script.
     
    Thanks !
     
     

    You mention that I can use a flat file that probably gets loaded to in flash to search and alter the number in the above reply.  I have a customer that wants to alter numbers being called from the CallManager through the gateway on certain area codes.  I have the file that show an example as 91281208 being translated to 9281208.  Can I alter the anifiltering.tcl script to look at DNIS instead and load a file int memory to search?

    Chris

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 17-06-2013 12:15:04 PM
    Yaw-Ming Chen:
    Yes you can use that concept,  or if you can find a pattern you can just use tcl string command to manipulate it.
    for example if you just need to remove every second digit then use some string commands is enough, 91281208 --> 9281208

    Thanks,

    I think they are going to have to be in a file because 91282 might have to proceed while 91281 will have to be changed to 9281.  What should my text file look like? 

    91281,9281

    or

    91281       9281

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Yaw-Ming Chen on 17-06-2013 12:27:57 PM
    use " 91281       9281" format maybe easier

    Anyway if you can find a pattern you can utilize regular expression

    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Chris Bomba on 19-06-2013 10:02:02 AM
    Does this script make sense?

      1# ani_filter.tcl
      2# Script Version 1.0(1)
      3#------------------------------------------------------------------
      4# October 2002, Niels Brunsgaard
      5#
      6# Copyright (c) 1998-2002 by cisco Systems, Inc.
      7# All rights reserved.
      8#------------------------------------------------------------------
      9#
     10# 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 #
     11#
     12
     13proc init { } {
     14    global param
     15}
     16
     17proc act_Setup { } {
     18   
     19    leg setupack leg_incoming
     20
     21    set num [infotag get leg_dnis]
     22    set new_dnis ""
     23    }
     24
     25    # fixnum num
     26# num - the phone number you want to fix
     27# takes num, decides if it's local or long distance and adds/removes a leading 1 as required
     28# returns the new phone number with or without the 1
     29proc fixnum {num} {
     30
     31# a list of all local prefixes
     32# if a match isn't found in this list it is assumed the number is long distance
     33# these must all be 6 characters long or you will need to change the code
     34set local [list \
     35281208 \
     36832922 \
     37832964 \
     38832967 \
     39832969 \
     40              ];
     41
     42
     43# if the number is < 10 digits don't change it
     44if { [ string length $num ] < 10 } {
     45    return $num;
     46}
     47
     48# get the first two digits
     49set ftd [ string range $num 0 1 ];
     50
     51#if the first two digits are 90 don't change it (meant for international 011 calls)
     52if { $ftd == 90 } {
     53    return $num;
     54}
     55
     56# if first two digits are 91 we drop the 1 regardless, we want to work the first 6 digits, starting with the area code
     57if { $ftd == 91 } {
     58    set num [ string range $num 2 [ string length $num ] ];
     59}
     60
     61# get first 6 digits, and see if they're in the list of local numbers
     62set snum [ string range $num 0 5 ];
     63set islocal [ lsearch $local $snum ];
     64
     65# if they're not local add the 91 at the start
     66if { $islocal == -1 } {
     67    set num "91$num";
     68}
     69
     70# return the number with the 1 added/removed as required
     71return $num;
     72
     73}
     74    puts "Final dnis $num"
     75    leg proceeding leg_incoming
     76    leg setup $num callInfo leg_incoming
     77}
     78
     79proc act_CallSetupDone { } {
     80    global beep
     81
     82    set status [infotag get evt_status]
     83
     84    puts "Entering act_CallSetupDone"
     85    if { $status != "ls_000"} {
     86        puts "Call [infotag get con_all] got event $status while placing an outgoing call"
     87        call close
     88    }
     89}
     90
     91proc act_Cleanup { } {
     92    puts "Entering act_Cleanup"
     93    call close
     94}
     95
     96proc act_Abort { } {
     97    puts "Unexpected event - entering act_Abort"
     98    call close
     99}
    100
    101init
    102
    103#----------------------------------
    104#   State Machine
    105#----------------------------------
    106  set TopFSM(any_state,ev_disconnected) "act_Abort,same_state"
    107  set TopFSM(CALL_INIT,ev_setup_indication) "act_Setup,PLACECALL"
    108  set TopFSM(PLACECALL,ev_setup_done)  "act_CallSetupDone,CALLACTIVE"
    109  set TopFSM(CALLACTIVE,ev_disconnected)   "act_Cleanup,CALLDISCONNECTED"
    110  set TopFSM(CALLDISCONNECTED,ev_disconnect_done) "act_Cleanup,same_state"
    111
    112  fsm define TopFSM  CALL_INIT


    Subject: RE: Possible to use wildcards in param clid under service ani_filter?
    Replied by: Lisandro Quinteros on 19-06-2013 10:11:24 AM
    I think nop.. You have 2 ways or get all that logic under proc act_Setup { } {  or call proc fixnum  procedure inside proc act_Setup {} refer to Tcl ivr guide to acomplish that..