Forum Discussion
LillyM_9417
Dec 14, 2011Altostratus
switch & swith -globe question
Hello,
I could not manage to work this irule. Please help me to make it run.
Thanks
Lilly
=============================
**************
**************
**************
when CLIENT_DATA {
set pay1 [TCP::payload 8]
binary scan $pay1 IA4 len1 trx1
switch [IP::addr [IP::client_addr]]{
"x.x.x.x/24"{
switch -glob [class match $trx1 ] {
"A"{
do smthng}
}
"B" {
do something
}
"C" {
do something
}
default {
do something
}
}
}
"y.y.y.y/24"{
switch -glob [class match $trx1 ] {
"D"{
do something
}
"E" {
do something
}
"F" {
do something
}
default {
do something
}
}
}
}
}
=============================
- Michael_YatesNimbostratusHi LillyM,
when CLIENT_DATA { set pay1 [TCP::payload 8] binary scan $pay1 IA4 len1 trx1 if { [IP::addr [IP::client_addr] equals "x.x.x.x/24" ] } { switch -glob [ $trx1 ] { "A" { do something } "B" { do something } "C" { do something } default { do something else } } } elseif { [IP::addr [IP::client_addr] equals "y.y.y.y/24" ] } { switch -glob [ $trx1 ] { "D" { do something } "E" { do something } "F" { do something } default { do something else } } } }
- LillyM_9417AltostratusHi Micheal,
- LillyM_9417AltostratusHi again Micheal,
- Michael_YatesNimbostratusYou should investigate your binary scan command and possibly log the value to your LTM Log to see what you are getting.
- LillyM_9417Altostratus4 character ascii command and no problem in it. It seems to me that it is related with switch -globe command and the error also says like this.
- Michael_YatesNimbostratusCan you post the error that it is logging?
- LillyM_9417AltostratusI cannot even load and save this IRULE, I got the following error:
- hooleylistCirrostratusYou should just need to remove the square braces from the switch string:
when CLIENT_DATA { set pay1 [TCP::payload 8] binary scan $pay1 IA4 len1 trx1 if { [IP::addr [IP::client_addr] equals "x.x.x.x/24" ] } { switch -glob $trx1 { "A" { do something } "B" { do something } "C" { do something } default { do something else } } } elseif { [IP::addr [IP::client_addr] equals "y.y.y.y/24" ] } { switch -glob $trx1 { "D" { do something } "E" { do something } "F" { do something } default { do something else } } } }
- Michael_YatesNimbostratus
I would have thought that the square brackets could have caused that problem.
Learn something new all the time.
Can you let us know if Hoolio's suggestion works?
- LillyM_9417AltostratusHello All,
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