Forum Discussion
Eric_Werner_283
Nimbostratus
Aug 12, 2010Use of pipe in if statement
I'm trying to find out if I can configure an if statement that checks for one of a series of possible values, like this:
if { $avp_code == 304|305|309} {
do stuff
}
Is the syntax correct, or would I get horrible, unintended results?
- Chris_Miller
Altostratus
I'd give it a shot...I know you can use pipe to separate acceptable responses in HTTP monitors...Throw it in and see if you get a syntax error. - naladar_65658
Altostratus
Do you mind posting your full code for this? It may be that this could be written into switch statement which would make it more efficient/faster on your BIG-IP. - Eric_Werner_283
Nimbostratus
Thought I had an extra curly brace at the end of the rule I copied in earlier. And maybe I do, but that's not the key here. Still getting a lot of syntax errors stating I need to use curly braces to avoid double substitution. In places that before I added the pipe statement I didn't need to use before. - Wow, a lot of logic there... What are you accomplishing with the above iRule?
- Eric_Werner_283
Nimbostratus
Posted By iRuleYou on 08/24/2010 08:31 AM - Colin_Walker_12Historic F5 AccountAs far as the beast above, I noticed that you're doing a lot of setting statics and math in the CLIENT_ACCEPTED event that could be done in RULE_INIT rather than for every single connection. Is there a reason for that?
set maxloop 20 set timeout 11100 set DWA_head 010000400000011800000000 set DWA_avp 0000010c4000000c000007d1000001084000000e4249472d495000000000012840000010746573742e636f6d set DPA_head 0100004c0000011a00000000 set DPA_avp 0000010c4000000c000007d1000001084000000e4249472d495000000000012840000010746573742e636f6d0000010c4000000c000007d1 set ohostval "lb.site.com" set ohostdlen [string len $ohostval] set ohostlen {expr $ohostdlen + 8} set ohostpad {expr (4 - ( ${ohostdlen} % 4) )%4 } set ohostlen_pad {expr $ohostlen + $ohostpad } set my_ohostavp {binary format IIa${ohostdlen}H[expr 2 * ${ohostpad}] 264 [expr (0x40<<24)| ${ohostlen}] $ohostval 000000} binary scan $my_ohostavp H* ohosthex
- Eric_Werner_283
Nimbostratus
Posted By Colin Walker on 08/25/2010 03:02 PMset maxloop 20 set timeout 11100 set DWA_head 010000400000011800000000 set DWA_avp 0000010c4000000c000007d1000001084000000e4249472d495000000000012840000010746573742e636f6d set DPA_head 0100004c0000011a00000000 set DPA_avp 0000010c4000000c000007d1000001084000000e4249472d495000000000012840000010746573742e636f6d0000010c4000000c000007d1 set ohostval "lb.site.com" set ohostdlen [string len $ohostval] set ohostlen {expr $ohostdlen + 8} set ohostpad {expr (4 - ( ${ohostdlen} % 4) )%4 } set ohostlen_pad {expr $ohostlen + $ohostpad } set my_ohostavp {binary format IIa${ohostdlen}H[expr 2 * ${ohostpad}] 264 [expr (0x40<<24)| ${ohostlen}] $ohostval 000000} binary scan $my_ohostavp H* ohosthex
- Eric_Werner_283
Nimbostratus
Thanks for the "static::my_ohostavp" pointer. Would have missed that one right off. - Colin_Walker_12Historic F5 AccountThe first thing I notice is that in the RULE_INIT section you'll want to use the static::var form as well.
- Eric_Werner_283
Nimbostratus
Took a while, but finally got enough numbers to deem them useful. Here's the stats comparison between the version using switch and moving items to RULE_INIT vs. the original.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects