Code: Select all
set ip [lindex $arg 0]
if {[string is alpha $ip] == 1} {
...
}
but if i move the a forward 192.168.a0.1 it will see the alpha
why is that 192.168.0.1q is non alpha string it contains apha chars ??
Code: Select all
set ip [lindex $arg 0]
if {[string is alpha $ip] == 1} {
...
}
Code: Select all
proc Ip2Int { ipDotAddr } {
foreach ipByte [split $ipDotAddr {.}] {
append hexAddr [format {%02x} $ipByte]
}
return [format {%u} "0x$hexAddr"]
}
proc IsPrivateIp {in} {
if {![regexp ^\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+$ $ip]} { error "Invalid IP input" }
set ip [Ip2Int $in]
if {($ip == 2130706433) || \
(($ip >= 167772160) && ($ip <= 184549375)) || \
(($ip >= 2886729728) && ($ip <= 2887778303)) || \
(($ip >= 3232235520) && ($ip <= 3232301055))} {
return 1
} else { return 0 }
}
The original function (available HERE) was designed to convert a dotted IP address (xxx.xxx.xxx.xxx) into the HEX equivilant.#######################################
# Source: iplib.tcl
# oreillynet.com
# Author: Michael Norton 04/19/2000