diff --git a/RISE-V2G-Shared/src/main/java/org/v2gclarity/risev2g/shared/utils/MiscUtils.java b/RISE-V2G-Shared/src/main/java/org/v2gclarity/risev2g/shared/utils/MiscUtils.java index d1d9cf5..32b9de3 100644 --- a/RISE-V2G-Shared/src/main/java/org/v2gclarity/risev2g/shared/utils/MiscUtils.java +++ b/RISE-V2G-Shared/src/main/java/org/v2gclarity/risev2g/shared/utils/MiscUtils.java @@ -65,7 +65,11 @@ public final class MiscUtils { NetworkInterface nif = null; try { - nif = NetworkInterface.getByName(networkInterfaceConfig); + if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { + nif = NetworkInterface.getByIndex(Integer.parseInt(networkInterfaceConfig)); + } else { + nif = NetworkInterface.getByName(networkInterfaceConfig); + } Enumeration inetAddresses = nif.getInetAddresses(); while (inetAddresses.hasMoreElements()) { @@ -96,7 +100,11 @@ public final class MiscUtils { byte[] macAddress = null; try { - nif = NetworkInterface.getByName(networkInterfaceConfig); + if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { + nif = NetworkInterface.getByIndex(Integer.parseInt(networkInterfaceConfig)); + } else { + nif = NetworkInterface.getByName(networkInterfaceConfig); + } macAddress = nif.getHardwareAddress(); } catch (SocketException e) { getLogger().error("Failed to retrieve local mac address (SocketException)", e);