Cálculo de segmentación de direcciones IP
<scriptLanguage = "jscript" runat = "servidor">
FunctionIpDecode (EIP) {
Varip1, IP2, IP3, IP4;
IP1 = MoveByter (EIP y 0xff00000000,3);
IP2 = MoveByter (EIP y 0x00ff0000,2);
IP3 = MoveByter (EIP y 0x0000ff00,1);
IP4 = EIP y 0x000000ff;
returnIP1+"."+ip2+"."+ip3+"."+ip4;
}
functionMoveByTel (num, bytenum) {
returnnum << = (bytenum*8)
}
functionMoveByter (num, bytenum) {
returnnum >>> = (bytenum*8)
}
</script>
No hay operación de bit en VBS, por lo que no es bueno usar JS y VBS en una página. También está bien si usa VBS, pero es un poco detallado. Y una cosa es un poco notable. Si se divide ("202.102.29.6", ".") En VBS, obtendrá tres números 202, 102 y 29, y no obtendrá los últimos 6, por lo que debe cambiar IP para dividir ("202.102.29.6" & ".". ")
Lo hice con VBS, y como no hay operación de bit, es más problemático
<%
FunctionIP2Int (IPSTR)
dimiptemp, max
iptemp = Split (iPstr & ".", ".")
max = ubund (iptemp)
ifmax <> 4then
extinción
endif
dima, b, yo
a = "& h"
fori = 0to3
b = hex (ipptemp (i))
iflen (b) = 1
B = "0" y B
endif
A = A y B
próximo
IP2Int = CLNG (a)
Función final
functionInT2IP (IP)
dimiptemp, a, iPstr, i, longitud
ipptemp = hex (IP)
Longitud = 8-Len (Iptemp)
Fori = 1Tolgentil
ipptemp = "0" e iptemp
próximo
a = izquierda (iptemp, 2)
a = "& h" & a
i = cint (a)
a = cstr (i)
iPstr = a & "."
A = Mid (Iptemp, 3,2)
a = "& h" & a
i = cint (a)
a = cstr (i)
IPSTR = IPSTR & A & "."
A = Mid (Iptemp, 5,2)
a = "& h" & a
i = cint (a)
a = cstr (i)
IPSTR = IPSTR & A & "."
a = correcto (iptemp, 2)
a = "& h" & a
i = cint (a)
a = cstr (i)
IPSTR = IPSTR & A
int2IP = iPSTR
Función final
dimTestip, testint
testip = "202.102.29.6"
testInt = IP2Int (testip)
Respuesta.WriteTestip & "WillbeEncodedto <FontColor = Red>" & testInt & "</font> <br>"
Respuesta.WriteTestip & "WillbedEncodedto <fontColor = Red>" & int2ip (testInt) & "</font> <br>"