Forum Discussion

PS_332920's avatar
PS_332920
Icon for Nimbostratus rankNimbostratus
Nov 25, 2018

iRules - Matching multiple entries and making decision FIFO basis

Need your advise regarding an iRule modification I am looking into. The present iRule logic in place checks for "AMR-WB" in the SIP payload and directs to PoolA and all remaining requests including "AMR" go to PoolB. However some traffic being received has a combination of both and customer wants the pool decision to be made based on the very first occurrence of either AMR or AMR-WB.

 

when SIP_REQUEST { if {[active_members PoolA ] != 0 and [active_members PoolB ] != 0}{ log local0. "AMR - Primary Site" if {[SIP::method] eq "INVITE" } { log local0. "AMR SIP Payload [SIP::payload]" if { [SIP::payload] contains "AMR-WB"} { log local0. "AMR WB found in Payload" pool PoolA } else { pool PoolB }

 

} else { pool PoolB } ---> Default

 

Could you suggest a way to check both in the payload and make pool decision based on which occurs first.

 

3 Replies

  • In the snapshot attached, even though AMR occurs first, the present iRule logic based on the AMR-WB occurrence much later selects the PoolA pool while as per customer it should have gone to PoolB. Would any of you have any suggestions as to how I could match between the 2 (AMR and AMR-WB) at the same time and direct to the appropriate pool.

     

  • Maybe something like this:

    when SIP_REQUEST { 
        if {[active_members PoolA ] != 0 and [active_members PoolB ] != 0}{
            log local0. "AMR - Primary Site" 
            if {[SIP::method] eq "INVITE" } { 
                log local0. "AMR SIP Payload [SIP::payload]" 
                if { [SIP::payload] contains "AMR-WB"} {
                    log local0. "AMR WB found in Payload" 
                    if { [findstr [SIP::payload] "AMR" 0 "AMR-WB"] != "" } {
                        log local0. "AMR before AMR-WB found -> PoolB"
                        pool PoolB
                    }
                    else {
                        log local0. "Only AMR-WB found -> PoolA"
                        pool PoolA
                    }
                } else { 
                    pool PoolB 
                } 
            } else { 
               pool PoolB 
            }
        }
    }