Ejemplo n.º 1
0
 private IpAddressV6(byte[] address)
     : this(BitUtilities.Reverse(BitConverter.ToUInt64(address, 0)), BitUtilities.Reverse(BitConverter.ToUInt64(address, 8)))
 {
     if (address.Length != 16)
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 2
0
#pragma warning disable CS0618
    public IpAddressV4(IPAddress address) : this(BitUtilities.Reverse((uint)address.Address))
#pragma warning restore CS0618
    {
        if (address.AddressFamily != AddressFamily.InterNetwork)
        {
            throw new ArgumentException();
        }
    }
Ejemplo n.º 3
0
    public void CurrentUint()
    {
        uint expected = 0x21436587;
        uint val      = 0x87654321;
        uint res      = BitUtilities.Reverse(val);

        if (res != expected)
        {
            throw new ArgumentException();
        }
    }
Ejemplo n.º 4
0
    public void CurrentUlong()
    {
        ulong expected = 0x8765432155648934;
        ulong val      = 0x3489645521436587;
        ulong res      = BitUtilities.Reverse(val);

        if (res != expected)
        {
            throw new ArgumentException();
        }
    }
    public IpAddressNetworkV6(IPAddress address, byte mask)
    {
        if (address.AddressFamily != AddressFamily.InterNetworkV6)
        {
            throw new ArgumentException();
        }

        byte[] bytes = address.GetAddressBytes();
        ulong  high  = BitUtilities.Reverse(BitConverter.ToUInt64(bytes, 0));
        ulong  low   = BitUtilities.Reverse(BitConverter.ToUInt64(bytes, 8));

        _networkAddress = new IpAddressV6(high, low);
        _mask           = mask;

        TruncateNetworkAddress(ref _networkAddress);
    }
Ejemplo n.º 6
0
 public static IPAddress ToIp(uint value)
 {
     return(new IPAddress(BitUtilities.Reverse(value)));
 }
Ejemplo n.º 7
0
    /// <summary>
    /// Creates an instance of <see cref="IpAddressNetworkV4"/> from a network and broadcast address.
    /// </summary>
    /// <param name="networkAddress">The network address. Note that it must be a network start address such as 10.0.0.0</param>
    /// <param name="broadcastAddress">The broadcast address. Note that it must be a broadcast address such as 10.255.255.255</param>
#pragma warning disable CS0618
    public IpAddressNetworkV4(IPAddress networkAddress, IPAddress broadcastAddress) : this(BitUtilities.Reverse((uint)networkAddress.Address), BitUtilities.Reverse((uint)broadcastAddress.Address))
#pragma warning restore CS0618
    {
    }