cont...
loop through subnet until octet3 has reached it's maximum allocated value
while {$::oct3 <= $static::oct3end} {
set ip 217.39.$::oct3.$::oct4
if { [table lookup -notouch -subtable "DynNatAddreses" $ip] eq "" } {
log local0. "Free IP: $ip found added to clientDynNat table"
reserve the Free IP
table add -subtable "DynNatAddreses" $ip [IP::client_addr] $static::timeout
allocate the Free IP as client SNAT address
table add -subtable "ClientDynNat" [IP::client_addr] $ip $static::timeout
debugging
if {$static::debug} {
log local0. "table lookup in DynNatAddress for $ip: [table lookup -notouch -subtable "DynNatAddreses" $ip]"
log local0. "table remaining ClientDynNat for [IP::client_addr]: [table timeout -subtable "ClientDynNat" -remaining [IP::client_addr]]"
log local0. "table timeout DynNatAddreses for $ip: [table timeout -subtable "DynNatAddreses" -remaining $ip]"
}
SNAT the client to the free IP
snat $ip
break the loop - found and allocated a address so no point in cycling through rest of Pool of IP's
break
}
increment the last octect of pool
incr ::oct4
if last octect has reached the end of the range increment next octet of IP and start looping through again
if {$::oct4 > $static::oct4end} {
incr ::oct3
set ::oct4 0
}
}
}
}