test_class.file: bundles/org.openhab.core/src/test/java/org/openhab/core/net/NetUtilTest.java
test_class.identifier: NetUtilTest
test_case.body: @Test
      public void testBroadcastAddress() {
          String broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.0.1", (short) 24);
          assertThat(broadcast, is("192.168.0.255"));
  
          broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.23.5", (short) 24);
          assertThat(broadcast, is("192.168.23.255"));
  
          broadcast = NetUtil.getIpv4NetBroadcastAddress("172.16.42.23", (short) 16);
          assertThat(broadcast, is("172.16.255.255"));
  
          broadcast = NetUtil.getIpv4NetBroadcastAddress("10.8.13.5", (short) 8);
          assertThat(broadcast, is("10.255.255.255"));
  
          broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.5.8", (short) 23);
          assertThat(broadcast, is("192.168.5.255"));
  
          broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.5.8", (short) 27);
          assertThat(broadcast, is("192.168.5.31"));
  
          broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.5.8", (short) 29);
          assertThat(broadcast, is("192.168.5.15"));
  
          try {
              broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.5.8", (short) 33);
          } catch (IllegalArgumentException iae) {
              assertThat(iae.getMessage(), is("Prefix '33' is out of bounds (1-32)"));
          }
          try {
              broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.58", (short) 24);
          } catch (IllegalArgumentException iae) {
              assertThat(iae.getMessage(), is("IP '192.168.58' is not a valid IPv4 address"));
          }
          try {
              broadcast = NetUtil.getIpv4NetBroadcastAddress("192.168.58", (short) 24);
          } catch (IllegalArgumentException iae) {
              assertThat(iae.getMessage(), is("IP '192.168.58' is not a valid IPv4 address"));
          }
          try {
              broadcast = NetUtil.getIpv4NetBroadcastAddress("SOME_TEXT", (short) 42);
          } catch (IllegalArgumentException iae) {
              assertThat(iae.getMessage(), is("IP 'SOME_TEXT' is not a valid IPv4 address"));
          }
      }
test_case.class_method_signature: NetUtilTest.testBroadcastAddress()
test_case.full_signature: @Test public void testBroadcastAddress()
test_case.identifier: testBroadcastAddress
test_case.invocations: getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat is getIpv4NetBroadcastAddress assertThat getMessage is getIpv4NetBroadcastAddress assertThat getMessage is getIpv4NetBroadcastAddress assertThat getMessage is getIpv4NetBroadcastAddress assertThat getMessage is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testBroadcastAddress()
focal_class.declarator: PRIMARY_ADDRESS = "primaryAddress"
focal_class.modifier: private static final
focal_class.original_string: private static final String PRIMARY_ADDRESS = "primaryAddress";
focal_class.type: String
focal_class.var_name: PRIMARY_ADDRESS
focal_class.declarator: BROADCAST_ADDRESS = "broadcastAddress"
focal_class.modifier: private static final
focal_class.original_string: private static final String BROADCAST_ADDRESS = "broadcastAddress";
focal_class.type: String
focal_class.var_name: BROADCAST_ADDRESS
focal_class.declarator: POLL_INTERVAL = "pollInterval"
focal_class.modifier: private static final
focal_class.original_string: private static final String POLL_INTERVAL = "pollInterval";
focal_class.type: String
focal_class.var_name: POLL_INTERVAL
focal_class.declarator: USE_ONLY_ONE_ADDRESS = "useOnlyOneAddress"
focal_class.modifier: private static final
focal_class.original_string: private static final String USE_ONLY_ONE_ADDRESS = "useOnlyOneAddress";
focal_class.type: String
focal_class.var_name: USE_ONLY_ONE_ADDRESS
focal_class.declarator: USE_IPV6 = "useIPv6"
focal_class.modifier: private static final
focal_class.original_string: private static final String USE_IPV6 = "useIPv6";
focal_class.type: String
focal_class.var_name: USE_IPV6
focal_class.declarator: LOGGER = LoggerFactory.getLogger(NetUtil.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(NetUtil.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: POLL_INTERVAL_SECONDS = 60
focal_class.modifier: public static final
focal_class.original_string: public static final int POLL_INTERVAL_SECONDS = 60;
focal_class.type: int
focal_class.var_name: POLL_INTERVAL_SECONDS
focal_class.declarator: IPV4_PATTERN = Pattern
              .compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern IPV4_PATTERN = Pattern
              .compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
focal_class.type: Pattern
focal_class.var_name: IPV4_PATTERN
focal_class.declarator: primaryAddress
focal_class.modifier: private @Nullable
focal_class.original_string: private @Nullable String primaryAddress;
focal_class.type: String
focal_class.var_name: primaryAddress
focal_class.declarator: configuredBroadcastAddress
focal_class.modifier: private @Nullable
focal_class.original_string: private @Nullable String configuredBroadcastAddress;
focal_class.type: String
focal_class.var_name: configuredBroadcastAddress
focal_class.declarator: useOnlyOneAddress
focal_class.modifier: private
focal_class.original_string: private boolean useOnlyOneAddress;
focal_class.type: boolean
focal_class.var_name: useOnlyOneAddress
focal_class.declarator: useIPv6
focal_class.modifier: private
focal_class.original_string: private boolean useIPv6;
focal_class.type: boolean
focal_class.var_name: useIPv6
focal_class.declarator: networkAddressChangeListeners = ConcurrentHashMap.newKeySet()
focal_class.modifier: private
focal_class.original_string: private Set<NetworkAddressChangeListener> networkAddressChangeListeners = ConcurrentHashMap.newKeySet();
focal_class.type: Set<NetworkAddressChangeListener>
focal_class.var_name: networkAddressChangeListeners
focal_class.declarator: lastKnownInterfaceAddresses = Collections.emptyList()
focal_class.modifier: private
focal_class.original_string: private Collection<CidrAddress> lastKnownInterfaceAddresses = Collections.emptyList();
focal_class.type: Collection<CidrAddress>
focal_class.var_name: lastKnownInterfaceAddresses
focal_class.declarator: scheduledExecutorService = ThreadPoolManager
              .getScheduledPool(ThreadPoolManager.THREAD_POOL_NAME_COMMON)
focal_class.modifier: private final
focal_class.original_string: private final ScheduledExecutorService scheduledExecutorService = ThreadPoolManager
              .getScheduledPool(ThreadPoolManager.THREAD_POOL_NAME_COMMON);
focal_class.type: ScheduledExecutorService
focal_class.var_name: scheduledExecutorService
focal_class.declarator: networkInterfacePollFuture = null
focal_class.modifier: private @Nullable
focal_class.original_string: private @Nullable ScheduledFuture<?> networkInterfacePollFuture = null;
focal_class.type: ScheduledFuture<?>
focal_class.var_name: networkInterfacePollFuture
focal_class.declarator: safeCaller
focal_class.modifier: private final
focal_class.original_string: private final SafeCaller safeCaller;
focal_class.type: SafeCaller
focal_class.var_name: safeCaller
focal_class.file: bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java
focal_class.identifier: NetUtil
focal_class.interfaces: implements NetworkAddressService
focal_class.class_method_signature: NetUtil.NetUtil(final @Reference SafeCaller safeCaller)
focal_class.full_signature: @Activate public  NetUtil(final @Reference SafeCaller safeCaller)
focal_class.identifier: NetUtil
focal_class.modifiers: @Activate public
focal_class.parameters: (final @Reference SafeCaller safeCaller)
focal_class.signature:  NetUtil(final @Reference SafeCaller safeCaller)
focal_class.class_method_signature: NetUtil.activate(Map<String, Object> props)
focal_class.full_signature: @Activate protected void activate(Map<String, Object> props)
focal_class.identifier: activate
focal_class.modifiers: @Activate protected
focal_class.parameters: (Map<String, Object> props)
focal_class.return: void
focal_class.signature: void activate(Map<String, Object> props)
focal_class.class_method_signature: NetUtil.deactivate()
focal_class.full_signature: @Deactivate protected void deactivate()
focal_class.identifier: deactivate
focal_class.modifiers: @Deactivate protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void deactivate()
focal_class.class_method_signature: NetUtil.modified(Map<String, Object> config)
focal_class.full_signature: @Modified public synchronized void modified(Map<String, Object> config)
focal_class.identifier: modified
focal_class.modifiers: @Modified public synchronized
focal_class.parameters: (Map<String, Object> config)
focal_class.return: void
focal_class.signature: void modified(Map<String, Object> config)
focal_class.class_method_signature: NetUtil.getPrimaryIpv4HostAddress()
focal_class.full_signature: @Override public @Nullable String getPrimaryIpv4HostAddress()
focal_class.identifier: getPrimaryIpv4HostAddress
focal_class.modifiers: @Override public @Nullable
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getPrimaryIpv4HostAddress()
focal_class.class_method_signature: NetUtil.isUseOnlyOneAddress()
focal_class.full_signature: @Override public boolean isUseOnlyOneAddress()
focal_class.identifier: isUseOnlyOneAddress
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isUseOnlyOneAddress()
focal_class.class_method_signature: NetUtil.isUseIPv6()
focal_class.full_signature: @Override public boolean isUseIPv6()
focal_class.identifier: isUseIPv6
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isUseIPv6()
focal_class.class_method_signature: NetUtil.addNetworkAddressChangeListener(NetworkAddressChangeListener listener)
focal_class.full_signature: @Override public void addNetworkAddressChangeListener(NetworkAddressChangeListener listener)
focal_class.identifier: addNetworkAddressChangeListener
focal_class.modifiers: @Override public
focal_class.parameters: (NetworkAddressChangeListener listener)
focal_class.return: void
focal_class.signature: void addNetworkAddressChangeListener(NetworkAddressChangeListener listener)
focal_class.class_method_signature: NetUtil.removeNetworkAddressChangeListener(NetworkAddressChangeListener listener)
focal_class.full_signature: @Override public void removeNetworkAddressChangeListener(NetworkAddressChangeListener listener)
focal_class.identifier: removeNetworkAddressChangeListener
focal_class.modifiers: @Override public
focal_class.parameters: (NetworkAddressChangeListener listener)
focal_class.return: void
focal_class.signature: void removeNetworkAddressChangeListener(NetworkAddressChangeListener listener)
focal_class.class_method_signature: NetUtil.getFirstLocalIPv4Address()
focal_class.full_signature: private @Nullable String getFirstLocalIPv4Address()
focal_class.identifier: getFirstLocalIPv4Address
focal_class.modifiers: private @Nullable
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getFirstLocalIPv4Address()
focal_class.class_method_signature: NetUtil.getAllBroadcastAddresses()
focal_class.full_signature: public static List<String> getAllBroadcastAddresses()
focal_class.identifier: getAllBroadcastAddresses
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: List<String>
focal_class.signature: List<String> getAllBroadcastAddresses()
focal_class.class_method_signature: NetUtil.getConfiguredBroadcastAddress()
focal_class.full_signature: @Override public @Nullable String getConfiguredBroadcastAddress()
focal_class.identifier: getConfiguredBroadcastAddress
focal_class.modifiers: @Override public @Nullable
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getConfiguredBroadcastAddress()
focal_class.class_method_signature: NetUtil.getPrimaryBroadcastAddress()
focal_class.full_signature: private @Nullable String getPrimaryBroadcastAddress()
focal_class.identifier: getPrimaryBroadcastAddress
focal_class.modifiers: private @Nullable
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getPrimaryBroadcastAddress()
focal_class.class_method_signature: NetUtil.getFirstIpv4BroadcastAddress()
focal_class.full_signature: private static @Nullable String getFirstIpv4BroadcastAddress()
focal_class.identifier: getFirstIpv4BroadcastAddress
focal_class.modifiers: private static @Nullable
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getFirstIpv4BroadcastAddress()
focal_class.class_method_signature: NetUtil.getAllInterfaceAddresses()
focal_class.full_signature: public static Collection<CidrAddress> getAllInterfaceAddresses()
focal_class.identifier: getAllInterfaceAddresses
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: Collection<CidrAddress>
focal_class.signature: Collection<CidrAddress> getAllInterfaceAddresses()
focal_class.class_method_signature: NetUtil.networkPrefixLengthToNetmask(int prefixLength)
focal_class.full_signature: public static String networkPrefixLengthToNetmask(int prefixLength)
focal_class.identifier: networkPrefixLengthToNetmask
focal_class.modifiers: public static
focal_class.parameters: (int prefixLength)
focal_class.return: String
focal_class.signature: String networkPrefixLengthToNetmask(int prefixLength)
focal_class.class_method_signature: NetUtil.getIpv4NetAddress(String ipAddressString, short netMask)
focal_class.full_signature: public static String getIpv4NetAddress(String ipAddressString, short netMask)
focal_class.identifier: getIpv4NetAddress
focal_class.modifiers: public static
focal_class.parameters: (String ipAddressString, short netMask)
focal_class.return: String
focal_class.signature: String getIpv4NetAddress(String ipAddressString, short netMask)
focal_class.class_method_signature: NetUtil.getIpv4NetBroadcastAddress(String ipAddressString, short prefix)
focal_class.full_signature: public static String getIpv4NetBroadcastAddress(String ipAddressString, short prefix)
focal_class.identifier: getIpv4NetBroadcastAddress
focal_class.modifiers: public static
focal_class.parameters: (String ipAddressString, short prefix)
focal_class.return: String
focal_class.signature: String getIpv4NetBroadcastAddress(String ipAddressString, short prefix)
focal_class.class_method_signature: NetUtil.getIPv4inSubnet(String ipAddress, String subnetMask)
focal_class.full_signature: private @Nullable String getIPv4inSubnet(String ipAddress, String subnetMask)
focal_class.identifier: getIPv4inSubnet
focal_class.modifiers: private @Nullable
focal_class.parameters: (String ipAddress, String subnetMask)
focal_class.return: String
focal_class.signature: String getIPv4inSubnet(String ipAddress, String subnetMask)
focal_class.class_method_signature: NetUtil.isValidIPConfig(String ipAddress)
focal_class.full_signature: public static boolean isValidIPConfig(String ipAddress)
focal_class.identifier: isValidIPConfig
focal_class.modifiers: public static
focal_class.parameters: (String ipAddress)
focal_class.return: boolean
focal_class.signature: boolean isValidIPConfig(String ipAddress)
focal_class.class_method_signature: NetUtil.scheduleToPollNetworkInterface(int intervalInSeconds)
focal_class.full_signature: private void scheduleToPollNetworkInterface(int intervalInSeconds)
focal_class.identifier: scheduleToPollNetworkInterface
focal_class.modifiers: private
focal_class.parameters: (int intervalInSeconds)
focal_class.return: void
focal_class.signature: void scheduleToPollNetworkInterface(int intervalInSeconds)
focal_class.class_method_signature: NetUtil.pollAndNotifyNetworkInterfaceAddress()
focal_class.full_signature: private void pollAndNotifyNetworkInterfaceAddress()
focal_class.identifier: pollAndNotifyNetworkInterfaceAddress
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void pollAndNotifyNetworkInterfaceAddress()
focal_class.class_method_signature: NetUtil.notifyListeners(List<CidrAddress> added, List<CidrAddress> removed)
focal_class.full_signature: private void notifyListeners(List<CidrAddress> added, List<CidrAddress> removed)
focal_class.identifier: notifyListeners
focal_class.modifiers: private
focal_class.parameters: (List<CidrAddress> added, List<CidrAddress> removed)
focal_class.return: void
focal_class.signature: void notifyListeners(List<CidrAddress> added, List<CidrAddress> removed)
focal_class.class_method_signature: NetUtil.notifyPrimaryAddressChange(@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress)
focal_class.full_signature: private void notifyPrimaryAddressChange(@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress)
focal_class.identifier: notifyPrimaryAddressChange
focal_class.modifiers: private
focal_class.parameters: (@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress)
focal_class.return: void
focal_class.signature: void notifyPrimaryAddressChange(@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress)
focal_class.class_method_signature: NetUtil.getConfigParameter(Map<String, Object> parameters, String parameter, boolean defaultValue)
focal_class.full_signature: private boolean getConfigParameter(Map<String, Object> parameters, String parameter, boolean defaultValue)
focal_class.identifier: getConfigParameter
focal_class.modifiers: private
focal_class.parameters: (Map<String, Object> parameters, String parameter, boolean defaultValue)
focal_class.return: boolean
focal_class.signature: boolean getConfigParameter(Map<String, Object> parameters, String parameter, boolean defaultValue)
focal_method.body: public static String getIpv4NetBroadcastAddress(String ipAddressString, short prefix) {
          String errorString = "IP '" + ipAddressString + "' is not a valid IPv4 address";
          if (!isValidIPConfig(ipAddressString)) {
              throw new IllegalArgumentException(errorString);
          }
          if (prefix < 1 || prefix > 32) {
              throw new IllegalArgumentException("Prefix '" + prefix + "' is out of bounds (1-32)");
          }
  
          try {
              byte[] addr = InetAddress.getByName(ipAddressString).getAddress();
              byte[] netmask = InetAddress.getByName(networkPrefixLengthToNetmask(prefix)).getAddress();
              byte[] broadcast = new byte[] { (byte) (~netmask[0] | addr[0]), (byte) (~netmask[1] | addr[1]),
                      (byte) (~netmask[2] | addr[2]), (byte) (~netmask[3] | addr[3]) };
              return InetAddress.getByAddress(broadcast).getHostAddress();
          } catch (UnknownHostException ex) {
              throw new IllegalArgumentException(errorString);
          }
      }
focal_method.class_method_signature: NetUtil.getIpv4NetBroadcastAddress(String ipAddressString, short prefix)
focal_method.full_signature: public static String getIpv4NetBroadcastAddress(String ipAddressString, short prefix)
focal_method.identifier: getIpv4NetBroadcastAddress
focal_method.invocations: isValidIPConfig getAddress getByName getAddress getByName networkPrefixLengthToNetmask getHostAddress getByAddress
focal_method.modifiers: public static
focal_method.parameters: (String ipAddressString, short prefix)
focal_method.return: String
focal_method.signature: String getIpv4NetBroadcastAddress(String ipAddressString, short prefix)