Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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.

0
Rate this Question
Comments on this Question
Comment made 3 months ago by PS 54

Image Text

0
Comment made 3 months ago by PS 54

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.

0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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 
        }
    }
}
0
Comments on this Answer
Comment made 3 months ago by PS 54

Thanks Niels, could you elaborate a bit how this below statement works and selects the first out of the two (AMR, AMR-WB).

if { [findstr [SIP::payload] "AMR" 0 "AMR-WB"] != "" } { log local0. "AMR before AMR-WB found -> PoolB"

0
Comment made 3 months ago by Niels van Sluis 2742

The value "AMR" is the search string and the value "AMR-WB" is the terminator. So (if I'm not mistaking) this command will try to return a value starting with AMR and ending with AMR-WB. If it matches it will return a string, so you know that the string AMR was found before AMR-WB.

See: https://devcentral.f5.com/wiki/iRules.findstr.ashx

0
Comment made 3 months ago by PS 54

Thanks Niels, I am working on the final iRule using ideas from your iRule and another shared to me by a SE who worked on something similar. Will post the final iRule here once tested and cleared.

0