Forum Discussion

LillyM_9417's avatar
LillyM_9417
Icon for Altostratus rankAltostratus
Dec 14, 2011

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

 

}

 

}

 

}

 

 

}

 

}

 

 

=============================

 

  • Hello Hoolio,

     

     

    Although this is not the exact equivalent what I want to do, I tried to modified my ırule like this. It is also is not working. I gave the following error:"01070151:3: Rule [IRule error: line 22: [invalid list: list element in quotes followed by "{" instead of space] []"

     

     

     

    line 22 => switch -glob $trx1 {

     

     

     

    thank you for your help.

     

  • Hello,

     

     

    I read many things in the forums and now I am more confused:)

     

    I want to make my question clear, and waiting for your help as soon as possible. I need to give my irule cpu comparison report today..

     

     

    Million thanks for your help in advance

     

     

    ---Firstly, I am doing all the following items with IF claues in prod enviroment without any problem but we want to make cpu utilization & and if it is possible we want to use switch clause.

     

     

    * I have 4- 5 Ip ranges, and I need to decide which external group files will be chose.

     

    * I have many external data group files. They all have many string values inside.

     

    * I need to check $trx1 value, with these string values those inside the external datagroup files

     

    * I could do this with IF statement but it comsumes so much CPU

     

    * Thats why I am trying to using SWITCH clause instead of IF clause

     

     

     

    Example:

     

     

    If ip is in the x.x.x.x/24 ip range

     

    If $trx1 in the A external datagroup file - do something

     

    If $trx1 in the B external datagroup file- do something

     

    If $trx1 in the C external datagroup file- do something

     

    else- do something else

     

     

    If ip is in the y.y.y.y/24 ip range

     

    If $trx1 in the D external datagroup file - do something

     

    If $trx1 in the E external datagroup file - do something

     

    If $trx1 in the F external datagroup file - do something

     

    else - do something else

     

     

    else

     

    do something - go to default pool
  • Hamish replied here:

     

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/2159026/showtab/groupforums/Default.aspx

     

     

    Aaron