public void Add(IPAddress addr, int prefix) { cachedHash = null; if (addr.IsIPv4MappedToIPv6) { // workaround for buggy MapToIPv4 implementation addr = Fixes.MapToIPv4(addr); if (prefix >= 96) { prefix -= 96; } } if (addr.AddressFamily == AddressFamily.InterNetwork) { writer.Write((byte)F2B_FWDATA_TYPE0_ENUM.F2B_FWDATA_IPv4_AND_PREFIX); } else { writer.Write((byte)F2B_FWDATA_TYPE0_ENUM.F2B_FWDATA_IPv6_AND_PREFIX); } writer.Write(addr.GetAddressBytes()); writer.Write((byte)prefix); }
public void Add(IPAddress addrLow, IPAddress addrHigh) { cachedHash = null; if (addrLow.IsIPv4MappedToIPv6) { // workaround for buggy MapToIPv4 implementation addrLow = Fixes.MapToIPv4(addrLow); } if (addrHigh.IsIPv4MappedToIPv6) { // workaround for buggy MapToIPv4 implementation addrHigh = Fixes.MapToIPv4(addrHigh); } if (addrLow.AddressFamily != addrHigh.AddressFamily) { throw new ArgumentException("Unable to add rule with mixed IPv4 and IPv6 range"); } if (addrLow.AddressFamily == AddressFamily.InterNetwork) { writer.Write((byte)F2B_FWDATA_TYPE0_ENUM.F2B_FWDATA_IPv4_RANGE); } else { writer.Write((byte)F2B_FWDATA_TYPE0_ENUM.F2B_FWDATA_IPv6_RANGE); } writer.Write(addrLow.GetAddressBytes()); writer.Write(addrHigh.GetAddressBytes()); }
public void Add(IPAddress addr) { cachedHash = null; if (addr.IsIPv4MappedToIPv6) { // workaround for buggy MapToIPv4 implementation addr = Fixes.MapToIPv4(addr); } if (addr.AddressFamily == AddressFamily.InterNetwork) { writer.Write((byte)F2B_FWDATA_TYPE0_ENUM.F2B_FWDATA_IPv4); } else { writer.Write((byte)F2B_FWDATA_TYPE0_ENUM.F2B_FWDATA_IPv6); } writer.Write(addr.GetAddressBytes()); }