Forum Discussion
Nat_Thirasuttakorn
May 14, 2009Employee
and if you want something that easily to scale ... try this...
(if you dont plan to have more store subnet, probably dont need this...
timing on
when RULE_INIT {
set static::list_net_start "172.20.0.0 10.192.0.0"
array set static::array_net_maskbit {
"172.20.0.0" 14
"10.192.0.0" 10
}
array set static::array_net_mask {
"172.20.0.0" "0.3.255.224"
"10.192.0.0" "0.63.254.0"
}
array set static::array_net_segment_bit {
"172.20.0.0" 5
"10.192.0.0" 9
}
}
when CLIENT_ACCEPTED {
set ip 10.192.18.0
foreach net_start $static::list_net_start {
if { [IP::addr $ip/$static::array_net_maskbit($net_start) equals $net_start] }{
log local0. "net $net_start found."
scan [IP::addr $ip mask $static::array_net_mask($net_start)] "%d.%d.%d.%d" a b c d
set VKSTID [expr ( {$a} << 24 | {$b} << 16 | {$c} << 8 | {$d} ) >> {$static::array_net_segment_bit($net_start)} ]
log local0. "VKSTID = $VKSTID"
}
}
}
actually, you already use foreach with publications variable. this is same. (I just prefer to use array than list)