IPAddressExtensions
Useful IPAddressExtensions from: http://blogs.msdn.com/knom/archive/2008/12/31/ip-address-calculations-with-c-subnetmasks-networks.aspx
Assembly: ServiceStack.Common.dll
View Source
Declaration
public static class IPAddressExtensions
Methods
GetBroadcastAddress(IPAddress, IPAddress)
View Source
Declaration
public static IPAddress GetBroadcastAddress(this IPAddress address, IPAddress subnetMask)
Returns
System.Net.IPAddress
Parameters
Type | Name |
---|---|
System.Net.IPAddress | address |
System.Net.IPAddress | subnetMask |
GetNetworkAddress(IPAddress, IPAddress)
View Source
Declaration
public static IPAddress GetNetworkAddress(this IPAddress address, IPAddress subnetMask)
Returns
System.Net.IPAddress
Parameters
Type | Name |
---|---|
System.Net.IPAddress | address |
System.Net.IPAddress | subnetMask |
GetNetworkAddressBytes(Byte[], Byte[])
View Source
Declaration
public static byte[] GetNetworkAddressBytes(byte[] ipAdressBytes, byte[] subnetMaskBytes)
Returns
System.Byte[]
Parameters
Type | Name |
---|---|
System.Byte[] | ipAdressBytes |
System.Byte[] | subnetMaskBytes |
IsInSameIpv6Subnet(IPAddress, IPAddress)
View Source
Declaration
public static bool IsInSameIpv6Subnet(this IPAddress address2, IPAddress address)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Net.IPAddress | address2 |
System.Net.IPAddress | address |
IsInSameIpv6Subnet(Byte[], Byte[])
View Source
Declaration
public static bool IsInSameIpv6Subnet(this byte[] address1Bytes, byte[] address2Bytes)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Byte[] | address1Bytes |
System.Byte[] | address2Bytes |
IsInSameIpv4Subnet(IPAddress, IPAddress, IPAddress)
View Source
Declaration
public static bool IsInSameIpv4Subnet(this IPAddress address2, IPAddress address, IPAddress subnetMask)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Net.IPAddress | address2 |
System.Net.IPAddress | address |
System.Net.IPAddress | subnetMask |
IsInSameIpv4Subnet(Byte[], Byte[], Byte[])
View Source
Declaration
public static bool IsInSameIpv4Subnet(this byte[] address1Bytes, byte[] address2Bytes, byte[] subnetMaskBytes)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Byte[] | address1Bytes |
System.Byte[] | address2Bytes |
System.Byte[] | subnetMaskBytes |
GetAllNetworkInterfaceIpv4Addresses()
Gets the ipv4 addresses from all Network Interfaces that have Subnet masks.
View Source
Declaration
public static Dictionary<IPAddress, IPAddress> GetAllNetworkInterfaceIpv4Addresses()
Returns
System.Collections.Generic.Dictionary<System.Net.IPAddress,System.Net.IPAddress>
GetAllNetworkInterfaceIpv6Addresses()
Gets the ipv6 addresses from all Network Interfaces.
View Source
Declaration
public static List<IPAddress> GetAllNetworkInterfaceIpv6Addresses()
Returns
System.Collections.Generic.List<System.Net.IPAddress>