@@ -63,6 +63,11 @@ Public Class Component
6363
6464 Private _FromBI As New BigInteger( 281470681743360 )
6565 Private _ToBI As New BigInteger( 281474976710655 )
66+ Private _FromBI2 As BigInteger = BigInteger.Parse( "42545680458834377588178886921629466624" )
67+ Private _ToBI2 As BigInteger = BigInteger.Parse( "42550872755692912415807417417958686719" )
68+ Private _FromBI3 As BigInteger = BigInteger.Parse( "42540488161975842760550356425300246528" )
69+ Private _ToBI3 As BigInteger = BigInteger.Parse( "42540488241204005274814694018844196863" )
70+ Private _DivBI As BigInteger = New BigInteger( 4294967295 )
6671
6772 Private Const MAX_IPV4_RANGE As Long = 4294967295
6873 Private MAX_IPV6_RANGE As BigInteger = BigInteger.Pow( 2 , 128 ) - 1
@@ -867,6 +872,18 @@ Public Class Component
867872 Tmp = String .Join( "" , Enumerable.Repeat( "0000:" , 5 ).ToList)
868873 FinalIP = FinalIP.Replace( "::" , Tmp)
869874 End If
875+ ElseIf IPNum >= _FromBI2 AndAlso IPNum <= _ToBI2 Then
876+ '6to4 so need to remap to ipv4
877+ StrIPType = 4
878+
879+ IPNum = IPNum >> 80
880+ IPNum = IPNum And _DivBI ' get last 32 bits
881+ ElseIf IPNum >= _FromBI3 AndAlso IPNum <= _ToBI3 Then
882+ 'Teredo so need to remap to ipv4
883+ StrIPType = 4
884+
885+ IPNum = Not IPNum
886+ IPNum = IPNum And _DivBI ' get last 32 bits
870887 ElseIf IPNum <= MAX_IPV4_RANGE Then
871888 'ipv4-compatible ipv6 (DEPRECATED BUT STILL SUPPORTED BY .NET)
872889 StrIPType = 4
0 commit comments