public static IPAddress GetBroadcastAddress(this IPAddress address, NetMask mask)
{
if (address == null)
throw new ArgumentNullException("address");
if (mask == null)
throw new ArgumentNullException("mask");
if (address.AddressFamily != Sockets.AddressFamily.InterNetwork)
throw new NotSupportedException(OnlyIPv4Supported);
// TODO: Test
var ipBytes = address.GetAddressBytes();
var notMaskBytes = mask.GetMaskBytes().Not();
var broadcastAddressBytes = notMaskBytes.Or(ipBytes);
return new IPAddress(broadcastAddressBytes);
}