Hi,
First of all, thanks for help.
Second, it was my fault. I did not describe my goal precise enough. Idea is to create keys (for tables or iStats) using variable mask (depending on some iRule logic). IPs are not know in advance and right now there is no idea of using them for some if or switch operations.
Below my crude iRule that should shed some light on what I mean - at least I hope so 🙂
when CLIENT_ACCEPTED {
set addr [IP::client_addr]
log local0. "Client IP: $addr"
scan $addr {%d.%d.%d.%d} a b c d
}
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"*/24" {
set newaddr "$a.$b.$c.0"
set uri [string map -nocase {"/24" "/"} [HTTP::uri]]
HTTP::uri $uri
}
"*/16" {
set newaddr "$a.$b.0.0"
set uri [string map -nocase {"/16" "/"} [HTTP::uri]]
HTTP::uri $uri
}
"*/8" {
set newaddr "$a.0.0.0"
set uri [string map -nocase {"/8" "/"} [HTTP::uri]]
HTTP::uri $uri
}
default {
set newaddr $addr
}
}
log local0. "scan result: $newaddr"
ISTATS::incr "ltm.virtual [virtual name] c $newaddr" 1
}
Point is if I can perform subnet creation in some more elegant, faster way that the one above (scan cmd).
Piotr