Home / Function/ isValidIpV6AddressOld() — netty Function Reference

isValidIpV6AddressOld() — netty Function Reference

Architecture documentation for the isValidIpV6AddressOld() function in IsValidIpV6Benchmark.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  57b756cc_5352_fd98_feb3_98288ab9dd2c["isValidIpV6AddressOld()"]
  9b92b46f_30d7_cc3a_cdb1_382da71e0b4b["IsValidIpV6Benchmark"]
  57b756cc_5352_fd98_feb3_98288ab9dd2c -->|defined in| 9b92b46f_30d7_cc3a_cdb1_382da71e0b4b
  e844f822_84a6_3bea_aedb_3dddd7b02c83["isValidIPv4MappedChar()"]
  57b756cc_5352_fd98_feb3_98288ab9dd2c -->|calls| e844f822_84a6_3bea_aedb_3dddd7b02c83
  4284543e_d63d_4f50_7633_966dfec71ba6["isValidIp4Word()"]
  57b756cc_5352_fd98_feb3_98288ab9dd2c -->|calls| 4284543e_d63d_4f50_7633_966dfec71ba6
  5a662ff3_5643_047b_1135_3570ffd5f146["isValidHexChar()"]
  57b756cc_5352_fd98_feb3_98288ab9dd2c -->|calls| 5a662ff3_5643_047b_1135_3570ffd5f146
  style 57b756cc_5352_fd98_feb3_98288ab9dd2c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbenchmark/common/IsValidIpV6Benchmark.java lines 63–206

    public static boolean isValidIpV6AddressOld(String ipAddress) {
        boolean doubleColon = false;
        int numberOfColons = 0;
        int numberOfPeriods = 0;
        StringBuilder word = new StringBuilder();
        char c = 0;
        char prevChar;
        int startOffset = 0; // offset for [] ip addresses
        int endOffset = ipAddress.length();

        if (endOffset < 2) {
            return false;
        }

        // Strip []
        if (ipAddress.charAt(0) == '[') {
            if (ipAddress.charAt(endOffset - 1) != ']') {
                return false; // must have a close ]
            }

            startOffset = 1;
            endOffset--;
        }

        // Strip the interface name/index after the percent sign.
        int percentIdx = ipAddress.indexOf('%', startOffset);
        if (percentIdx >= 0) {
            endOffset = percentIdx;
        }

        for (int i = startOffset; i < endOffset; i++) {
            prevChar = c;
            c = ipAddress.charAt(i);
            switch (c) {
            // case for the last 32-bits represented as IPv4 x:x:x:x:x:x:d.d.d.d
            case '.':
                numberOfPeriods++;
                if (numberOfPeriods > 3) {
                    return false;
                }
                if (numberOfPeriods == 1) {
                    // Verify this address is of the correct structure to contain an IPv4 address.
                    // It must be IPv4-Mapped or IPv4-Compatible
                    // (see https://tools.ietf.org/html/rfc4291#section-2.5.5).
                    int j = i - word.length() - 2; // index of character before the previous ':'.
                    final int beginColonIndex = ipAddress.lastIndexOf(':', j);
                    if (beginColonIndex == -1) {
                        return false;
                    }
                    char tmpChar = ipAddress.charAt(j);
                    if (isValidIPv4MappedChar(tmpChar)) {
                        if (j - beginColonIndex != 4 ||
                            !isValidIPv4MappedChar(ipAddress.charAt(j - 1)) ||
                            !isValidIPv4MappedChar(ipAddress.charAt(j - 2)) ||
                            !isValidIPv4MappedChar(ipAddress.charAt(j - 3))) {
                            return false;
                        }
                        j -= 5;
                    } else if (tmpChar == '0' || tmpChar == ':') {
                        --j;
                    } else {
                        return false;
                    }

                    // a special case ::1:2:3:4:5:d.d.d.d allows 7 colons with an
                    // IPv4 ending, otherwise 7 :'s is bad
                    if ((numberOfColons != 6 && !doubleColon) || numberOfColons > 7 ||
                        (numberOfColons == 7 && (ipAddress.charAt(startOffset) != ':' ||
                                                 ipAddress.charAt(1 + startOffset) != ':'))) {
                        return false;
                    }

                    for (; j >= startOffset; --j) {
                        tmpChar = ipAddress.charAt(j);
                        if (tmpChar != '0' && tmpChar != ':') {
                            return false;
                        }
                    }
                }

                if (!isValidIp4Word(word.toString())) {

Domain

Subdomains

Frequently Asked Questions

What does isValidIpV6AddressOld() do?
isValidIpV6AddressOld() is a function in the netty codebase, defined in microbench/src/main/java/io/netty/microbenchmark/common/IsValidIpV6Benchmark.java.
Where is isValidIpV6AddressOld() defined?
isValidIpV6AddressOld() is defined in microbench/src/main/java/io/netty/microbenchmark/common/IsValidIpV6Benchmark.java at line 63.
What does isValidIpV6AddressOld() call?
isValidIpV6AddressOld() calls 3 function(s): isValidHexChar, isValidIPv4MappedChar, isValidIp4Word.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free