Example edit
$ 6to4 132.235.201.144 132.235.201.144 -> 2610:a8:4831:0538::
Code edit
proc 6to4 {addr} {
set octets [split [string trim $addr] .]
if {[llength $octets] != 4} {
return -code error \
"\"$addr\" does not consist of 4 octets separated by dots"
}
foreach octet $octets {
if {![string is integer $octet] || $octet < 0 || $octet > 255} {
return -code error "\"$octet\" is not a valid octet"
}
}
foreach {a b} $octets {
lappend words [expr {($a<<8) | $b}]
}
eval [linsert $words 0 format "2002:%x:%x::"]
}
foreach v4addr $argv {
catch {6to4 $v4addr} v6addr
puts "$v4addr -> $v6addr"
}WHD: Not to be pedantic, but since it's converting IPV4 to IPV6, shouldn't it be called 4to6? Or am I missing something?PT: you are missing something - RFC 3056
is all about something called 6to4 as opposed to 6over4 which is something else.Note also that tcllib_ip can accept and manipulate ipv4 and ipv6 addresses and includes the ability to take 6to4 addresses of the type 2002:192.168.0.4::/48
