The following is a section of code which builds a list of IP addresses and their subnet masks from the local system, however the Warn function seems to get triggered regularly which should in theory be impossible - as it should not be possible to have an IPv4 address without the associated subnet mask[?].
static NetworkUtil()
{
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses)
{
if (address.Address.AddressFamily == AddressFamily.InterNetwork)
{
if (address.IPv4Mask != null)
{
m_subnets.Add(address.Address, address.IPv4Mask);
}
else
{
m_log.Warn("[NetworkUtil] Found IPv4 Address without Subnet Mask!?");
}
}
}
}
}