@@ -927,7 +927,7 @@ class IPSubnetCalc: NSObject {
927927 /**
928928 Convert an IPv6 address in hexadecimal format to its digital format
929929
930- - Parameter ipAddress: an IPv6 address in hexadecimal format
930+ - Parameter ipAddress: an IPv6 address in hexadecimal format. Must be in full format.
931931
932932 - Returns:
933933 UInt16 array of each digitized IPv6 address hexa segments
@@ -937,7 +937,7 @@ class IPSubnetCalc: NSObject {
937937 var ipAddressNum : [ UInt16 ] = Array ( repeating: 0 , count: 8 )
938938 var ip4Hex = [ String] ( )
939939
940- ip4Hex = ipAddress. components ( separatedBy: " : " )
940+ ip4Hex = IPSubnetCalc . fullAddressIPv6 ( ipAddress: ipAddress ) . components ( separatedBy: " : " )
941941 for index in 0 ... ( ip4Hex. count - 1 ) {
942942 if ( ip4Hex [ index] == " " ) {
943943 ip4Hex [ index] = " 0 "
@@ -1044,7 +1044,7 @@ class IPSubnetCalc: NSObject {
10441044
10451045 */
10461046 func hexaIDIPv6( ) -> String {
1047- var hexID : String = fullAddressIPv6 ( ipAddress: self . ipv6Address)
1047+ var hexID : String = IPSubnetCalc . fullAddressIPv6 ( ipAddress: self . ipv6Address)
10481048 let delimiter : Set < Character > = [ " : " ]
10491049 hexID. removeAll ( where: { delimiter. contains ( $0) } )
10501050 return ( " 0x \( hexID) " )
@@ -1070,7 +1070,7 @@ class IPSubnetCalc: NSObject {
10701070 the long notation (non compact) of the given IPv6 address
10711071
10721072 */
1073- func fullAddressIPv6( ipAddress: String ) -> String {
1073+ static func fullAddressIPv6( ipAddress: String ) -> String {
10741074 var fullAddr = String ( )
10751075 var ip4Hex = [ String] ( )
10761076 var prevIsZero = false
@@ -1109,7 +1109,7 @@ class IPSubnetCalc: NSObject {
11091109 the compact notation of the given IPv6 address
11101110
11111111 */
1112- func compactAddressIPv6( ipAddress: String ) -> String {
1112+ static func compactAddressIPv6( ipAddress: String ) -> String {
11131113 var shortAddr = String ( )
11141114 var ip4Hex = [ String] ( )
11151115 var prevIsZero = false
@@ -1118,7 +1118,7 @@ class IPSubnetCalc: NSObject {
11181118 var prevNonZero = false
11191119
11201120 //print("IP Address: \(ipAddress)")
1121- ip4Hex = self . fullAddressIPv6 ( ipAddress: ipAddress) . components ( separatedBy: " : " )
1121+ ip4Hex = IPSubnetCalc . fullAddressIPv6 ( ipAddress: ipAddress) . components ( separatedBy: " : " )
11221122 for index in 0 ... ( ip4Hex. count - 1 ) {
11231123 if ( UInt16 ( ip4Hex [ index] , radix: 16 ) ! == 0 ) {
11241124 if ( !prevIsZero || prevCompactZero) {
@@ -1176,7 +1176,7 @@ class IPSubnetCalc: NSObject {
11761176 func networkIPv6( ) -> String {
11771177 var netID = [ UInt16] ( )
11781178 let numMask = IPSubnetCalc . digitizeMaskIPv6 ( maskbits: self . ipv6MaskBits)
1179- let numIP = IPSubnetCalc . digitizeIPv6 ( ipAddress: fullAddressIPv6 ( ipAddress : self . ipv6Address) )
1179+ let numIP = IPSubnetCalc . digitizeIPv6 ( ipAddress: self . ipv6Address)
11801180
11811181 for index in 0 ... 7 {
11821182 //print("Index: \(index) IP: \(numIP[index]) Mask : \(numMask[index]) Result : \(numIP[index] & (numMask[index])) ")
@@ -1196,7 +1196,7 @@ class IPSubnetCalc: NSObject {
11961196 var netID = [ UInt16] ( )
11971197 var netID2 = [ UInt16] ( )
11981198 let numMask = IPSubnetCalc . digitizeMaskIPv6 ( maskbits: self . ipv6MaskBits)
1199- let numIP = IPSubnetCalc . digitizeIPv6 ( ipAddress: fullAddressIPv6 ( ipAddress : self . ipv6Address) )
1199+ let numIP = IPSubnetCalc . digitizeIPv6 ( ipAddress: self . ipv6Address)
12001200
12011201 for index in 0 ... 7 {
12021202 //print("Index: \(index) IP: \(numIP[index]) Mask : \(numMask[index]) Result : \(numIP[index] & (numMask[index])) ")
@@ -1236,7 +1236,7 @@ class IPSubnetCalc: NSObject {
12361236 func dottedDecimalIPv6( ) -> String {
12371237 var ipv4str = String ( )
12381238
1239- let ip4Hex = fullAddressIPv6 ( ipAddress: self . ipv6Address) . components ( separatedBy: " : " )
1239+ let ip4Hex = IPSubnetCalc . fullAddressIPv6 ( ipAddress: self . ipv6Address) . components ( separatedBy: " : " )
12401240 for index in ( 0 ... ( ip4Hex. count - 1 ) ) {
12411241 if ( index != 0 ) {
12421242 ipv4str. append ( " . " )
@@ -1261,7 +1261,7 @@ class IPSubnetCalc: NSObject {
12611261
12621262 */
12631263 func ip6ARPA ( ) -> String {
1264- var ipARPA = fullAddressIPv6 ( ipAddress: self . ipv6Address)
1264+ var ipARPA = IPSubnetCalc . fullAddressIPv6 ( ipAddress: self . ipv6Address)
12651265 let delimiter : Set < Character > = [ " : " ]
12661266
12671267 ipARPA. removeAll ( where: { delimiter. contains ( $0) } )
@@ -1286,9 +1286,9 @@ class IPSubnetCalc: NSObject {
12861286 func resBlockIPv6( ) -> String ? {
12871287 var netID = networkIPv6 ( )
12881288
1289- netID = fullAddressIPv6 ( ipAddress: netID)
1289+ netID = IPSubnetCalc . fullAddressIPv6 ( ipAddress: netID)
12901290 //print("NetID BEFORE compact : \(netID)")
1291- netID = compactAddressIPv6 ( ipAddress: netID)
1291+ netID = IPSubnetCalc . compactAddressIPv6 ( ipAddress: netID)
12921292 //print("NetID AFTER compact : \(netID)")
12931293 netID. append ( " / \( self . ipv6MaskBits) " )
12941294
0 commit comments