using System.Net; using System.Net.Sockets; using Microsoft.AspNetCore.HttpOverrides; namespace MediaBrowser.Common.Net { /// /// Base network object class. /// public class IPData { /// /// Initializes a new instance of the class. /// /// The . /// The . /// The interface name. public IPData(IPAddress address, IPNetwork? subnet, string name) { Address = address; Subnet = subnet ?? (address.AddressFamily == AddressFamily.InterNetwork ? new IPNetwork(address, 32) : new IPNetwork(address, 128)); Name = name; } /// /// Initializes a new instance of the class. /// /// The . /// The . public IPData(IPAddress address, IPNetwork? subnet) : this(address, subnet, string.Empty) { } /// /// Gets or sets the object's IP address. /// public IPAddress Address { get; set; } /// /// Gets or sets the object's IP address. /// public IPNetwork Subnet { get; set; } /// /// Gets or sets the interface index. /// public int Index { get; set; } /// /// Gets or sets the interface name. /// public string Name { get; set; } /// /// Gets the AddressFamily of the object. /// public AddressFamily AddressFamily { get { return Address.Equals(IPAddress.None) ? (Subnet.Prefix.AddressFamily.Equals(IPAddress.None) ? AddressFamily.Unspecified : Subnet.Prefix.AddressFamily) : Address.AddressFamily; } } } }