RVS_IPAddressV6

public struct RVS_IPAddressV6 : RVS_IPAddress

This is a specialization for IPV6

  • Declaration

    Swift

    public var isPadded: Bool

    Return Value

    true, if we want the address Strings to be zero-padded (default is false).

  • Declaration

    Swift

    public var port: Int

    Return Value

    the TCP Port of the IP address.

  • Declaration

    Swift

    public var isV6: Bool

    Return Value

    true

  • Declaration

    Swift

    public var isValidAddress: Bool { get }

    Return Value

    true, if this is a valid IPV6 address.

  • Declaration

    Swift

    public var address: String { get }

    Return Value

    The IPV6 String representation. If isPadded is true, then each element will be zero-padded, and no shortcuts will be taken. If false, then we “shortcut” consecutive zeores.

  • Declaration

    Swift

    public var addressAndPort: String { get }
  • This is the array, containing the address.

    It clears the Address Array, if it is not “legal.”

    Declaration

    Swift

    public var addressArray: [Int] { get set }
  • This init extracts an IPV6 address, and, if applicable, TCP port, from a given string.

    The definition of an IPV6 address is: XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX

    Where X is 0…F (hexadecimal). There are shortcuts (discussed below), but we assume leading zeroes, and all zeores are represented.

    Each segment is a positive integer, from 0 - 65535 (FFFF in hexadecimal).

    If there is an additional TCP port, then the IP address is bracketed, and followed immediately by a colon (:), then immediately by a positive integer, like this: [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:Y

    Where Y is a positive integer

    SHORTCUTS:

    You can specify a range of 0-filled elements by using :: as a shortcut. This is only allowed once in the entire address, so:

    XXXX:0000:0000:0000:XXXX:0000:0000:XXXX can be written as XXXX::XXXX:0000:0000:XXXX or XXXX:0000:0000:0000:XXXX::XXXX

    Usually, the first shortcut will be selected, as it’s the longest range.

    You can have a maximum of four (4) hexadecimal characters in an element. Case of the hex digits is usually lowercased, as a convention, but uppercased is allowed. We use lowercase.

    You cannot have characters other than 0-9, a-f (or A-F) in an element.

    You must separate elements with colons (:). If you are specifying a port, you must wrap the address in brackets ([]). You must have BOTH brackets if you are wrapping the address.

    You can wrap an address in brackets, even if you do not specify a port.

    If you specify a port, it must appear after a colon (:), after the closing bracket (]), so you would have ]:12345, to specify TCP Port 12345.

    You can have a maximum of eight (8) elements.

    Illegal formats and syntax errors result in no address being set. This method does not guess.

    Declaration

    Swift

    public init(_ inString: String)

    Parameters

    inString

    The String to be parsed.

  • Default initializer -Allows us to forgo initial values.

    Declaration

    Swift

    public init(_ inArray: [Int] = [], port inPort: Int = 0, isPadded inIsPadded: Bool = false)

    Parameters

    inArray

    An optional Array of Int. Exactly 8 elements, with positive integer values below 65536.

    port

    An optional (Default is 0) positive Int, with the TCP Port for the address.

    isPadded

    An optional Bool. If true (default is false), then the address components are complete (no shortcuts) and 0-padded.