From fcaf99a705789c0a92fb8771a4461f31f576094b Mon Sep 17 00:00:00 2001 From: Leo Siepel Date: Mon, 7 Oct 2024 21:08:29 +0200 Subject: [PATCH] First part of review Signed-off-by: Leo Siepel --- .../java/org/openhab/core/net/NetUtil.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java index d7e73ee2fe3..f1bbd7ceed1 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java @@ -388,7 +388,7 @@ public static String networkPrefixLengthToNetmask(int prefixLength) { /** * Get the network address a specific ip address is in * - * @param ipAddressString ipv4 address of the device (i.e. 192.168.5.1) + * @param ipAddressString IPv4 address of the device (i.e. 192.168.5.1) * @param netMask netmask in bits (i.e. 24) * @return network a device is in (i.e. 192.168.5.0) * @throws IllegalArgumentException if parameters are wrong @@ -424,7 +424,7 @@ public static String getIpv4NetAddress(String ipAddressString, short netMask) { /** * Get the network broadcast address of the subnet a specific ip address is in * - * @param ipAddressString ipv4 address of the device (i.e. 192.168.5.1) + * @param ipAddressString IPv4 address of the device (i.e. 192.168.5.1) * @param prefix network prefix in bits (i.e. 24) * @return network broadcast address of the network the device is in (i.e. 192.168.5.255) * @throws IllegalArgumentException if parameters are wrong @@ -599,7 +599,7 @@ private boolean getConfigParameter(Map parameters, String parame } /** - * For all network interfaces (except loopback) all Ipv4 addresses are returned. + * For all network interfaces (except loopback) all IPv4 addresses are returned. * This list can for example, be used to scan the network for available devices. * * @return A full list of IP {@link InetAddress} (except network and broadcast) @@ -616,15 +616,17 @@ public static List getFullRangeOfAddressesToScan() { } /** - * For the given {@link CidrAddress} all Ipv4 addresses are returned. - * This list can for example, be used to scan the network for available devices. + * For the given {@link CidrAddress} all IPv4 addresses are returned. + * This list can, for example, be used to scan the network for available devices. * * @param iFaceAddress The {@link CidrAddress} of the network interface - * @param maxPrefixLength Control the prefix length of the network (e.g. 24 for class C) + * @param maxAllowedPrefixLength Control the maximum allowed prefix length of the network (e.g. 24 for class C). + * iFaceAddress's with a larger prefix are ignored and return an empty result. * @return A full list of IP {@link InetAddress} (except network and broadcast) */ - public static List getAddressesRangeByCidrAddress(CidrAddress iFaceAddress, int maxPrefixLength) { - if (!(iFaceAddress.getAddress() instanceof Inet4Address) || iFaceAddress.getPrefix() < maxPrefixLength) { + public static List getAddressesRangeByCidrAddress(CidrAddress iFaceAddress, + int maxAllowedPrefixLength) { + if (!(iFaceAddress.getAddress() instanceof Inet4Address) || iFaceAddress.getPrefix() < maxAllowedPrefixLength) { return List.of(); }