Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e84c00f4 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android (Google) Code Review
Browse files

Merge "Remove NetworkUtils.isIpAddress."

parents a7ccd130 1693182c
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -174,28 +174,6 @@ public class NetworkUtils {
        return Integer.reverseBytes(value);
    }

    public static boolean isIpAddress(String address) {
        //TODO: Add NetworkUtils support for IPv6 configuration and
        //remove IPv4 validation and use a generic InetAddress validation
        try {
            String[] parts = address.split("\\.");
            if (parts.length != 4) {
                return false;
            }
            int a = Integer.parseInt(parts[0]);
            if (a < 0 || a > 255) return false;
            a = Integer.parseInt(parts[1]);
            if (a < 0 || a > 255) return false;
            a = Integer.parseInt(parts[2]);
            if (a < 0 || a > 255) return false;
            a = Integer.parseInt(parts[3]);
            if (a < 0 || a > 255) return false;
        } catch (NumberFormatException ex) {
            return false;
        }
        return true;
    }

    /**
     * Add a default route through the specified gateway.
     * @param interfaceName interface on which the route should be added