I want to evaluate character string of Cookie by a hex digit.

Hello all.

I’m Japanese.I am weak in English.

But I do my best.

I want to evaluate character string of Cookie by a hex digit.

This cookie is “EX=…” by random of hex string.

A character is “0” to “f”

I wrote following iRule.

when HTTP_REQUEST {

if { [HTTP::header exist “cookie”] }{

switch [findstr [HTTP::cookie “cookie”] “EX” 3 1] {

“0” {

use pool A_pool

}

“1” {

use pool B_pool

}

“2” {

use pool C_pool

}

.

.

.

“f” {

use pool Q_pool

}

}

}

}

This Rule is a description to check 1 character.

But,I would like to check 2 character.

The case of “00” to “0f”,use pool A_pool.

The case of “10” to “1f”,use pool B_pool.

The case of “20” to “2f”,use pool C_pool.

.

.

.

The case of “f0” to “ff”,use poll Q_pool.

In this case, It is very troublesome that I write each.

Therefore I want to make the value that I acquired a number.

Can you achieve this problem?

Thanx and regards.

What you need there is the ‘scan’ command, http://tmml.sourceforge.net/doc/tcl/scan.html , and I believe you’d want something like this:

when HTTP_REQUEST {
  if { [HTTP::header exist "cookie"] }{
    scan [HTTP::cookie "cookie"] "EX%2x" cookieval
    if { $cookieval <= 15 } {
      use pool_1
    } elseif { $cookieval > 15 ....

Hope that helps,

Aaron

Aaron-san

Thank you for your reply.

But,As for this solution, management is difficult.

I want to make string “00” equals hex number “00”.

An ideal condition is as follows.

switch [extra-rule] {

“00”-“0f”{

use pool A_pool

}

“10”-“1f” {

use pool B_pool

}

“20”-"2f {

use pool C_pool

}

.

.

.

“f0”-“ff” {

use pool Q_pool

}

}

}

Is it difficult about this?

Am I selfish?

Thank you.

Thank you.

Is there the person who can solve my trouble elsewhere?

If all 00 - 0f is going to the same pool, why do you need to evaluate the second character?