From b2d1f8034053e29ac531103c63ee9e666b05d3dc Mon Sep 17 00:00:00 2001 From: Dustin Deyoung Date: Tue, 26 Nov 2024 14:29:59 -0500 Subject: [PATCH] IPv6 address to cidr. --- .../com/morpheusdata/core/util/NetworkUtility.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/morpheus-plugin-api/src/main/java/com/morpheusdata/core/util/NetworkUtility.java b/morpheus-plugin-api/src/main/java/com/morpheusdata/core/util/NetworkUtility.java index 01d35102..1bb1ae03 100644 --- a/morpheus-plugin-api/src/main/java/com/morpheusdata/core/util/NetworkUtility.java +++ b/morpheus-plugin-api/src/main/java/com/morpheusdata/core/util/NetworkUtility.java @@ -266,6 +266,17 @@ static public String addressToCidr(String address) { return rtn; } + // get the cidr from an IPV6 address + static public String addressToCidrIPv6(String address) { + String rtn = null; + if(address != null && address.indexOf('/') > -1) { + inet.ipaddr.IPAddress subnetIpAddress = new inet.ipaddr.IPAddressString(address).getAddress(); + rtn = subnetIpAddress.toPrefixBlock().toString(); + } + + return rtn; + } + static public String addressToSubnet(String address) { String rtn = null; if (address != null && address.indexOf('/') > -1) {