C# Class NetworkCommsDotNet.Tools.IPRange

A class that encapsulates an IPv4 or IPv6 range. Used for checking if an IPAddress is within an IPRange.
Mostrar archivo Open project: MarcFletcher/NetworkComms.Net Class Usage Examples

Private Properties

Property Type Description
IPRange System
RecursivePopulate void

Public Methods

Method Description
AllAddressesBetween ( IPAddress firstAddress, IPAddress lastAddress ) : List

Returns all IPAddresses that are between the provided addresses

AllAddressesInRange ( ) : List

Returns a list of all IPAddresses in the specified range

Contains ( IEnumerable ranges, IPAddress ipAddress ) : bool

Returns true if the provided IPAddress is within one of the provided IPRanges, otherwise false

Contains ( IPAddress ipAddress ) : bool

Returns true if this IPRange contains the provided IPAddress

Contains ( byte ipAddressBytes ) : bool

Returns true if this IPRange contains the provided IPAddress bytes

Contains ( string ipAddressStr ) : bool

Returns true if this IPRange contains the provided IPAddress

IPRange ( IPAddress address, IPAddress subnetmask ) : System

Initialise an IPRange using the provided address and subnet mask.

IPRange ( string rangeCIDR ) : System

Initialise an IPRange using the provided CIDR notation.

IsAutoAssignedAddress ( IPAddress ipAddress ) : bool

Returns true if the provided IPAddress is within one of the autoassigned ip ranges, otherwise false

ToString ( ) : string

Returns a clean ToString of the IPRange

Private Methods

Method Description
IPRange ( ) : System
RecursivePopulate ( byte firstAddressBytes, byte lastAddressBytes, byte knownBytes, List result ) : void

Recursively populates the result list by looping over all address byte levels

Method Details

AllAddressesBetween() public static method

Returns all IPAddresses that are between the provided addresses
public static AllAddressesBetween ( IPAddress firstAddress, IPAddress lastAddress ) : List
firstAddress IPAddress
lastAddress IPAddress
return List

AllAddressesInRange() public method

Returns a list of all IPAddresses in the specified range
public AllAddressesInRange ( ) : List
return List

Contains() public static method

Returns true if the provided IPAddress is within one of the provided IPRanges, otherwise false
public static Contains ( IEnumerable ranges, IPAddress ipAddress ) : bool
ranges IEnumerable The ranges to search
ipAddress IPAddress The IPAddress to find in ranges
return bool

Contains() public method

Returns true if this IPRange contains the provided IPAddress
public Contains ( IPAddress ipAddress ) : bool
ipAddress IPAddress The IPAddress to check
return bool

Contains() public method

Returns true if this IPRange contains the provided IPAddress bytes
public Contains ( byte ipAddressBytes ) : bool
ipAddressBytes byte The IPAddress bytes to check
return bool

Contains() public method

Returns true if this IPRange contains the provided IPAddress
public Contains ( string ipAddressStr ) : bool
ipAddressStr string The IPAddress to check
return bool

IPRange() public method

Initialise an IPRange using the provided address and subnet mask.
public IPRange ( IPAddress address, IPAddress subnetmask ) : System
address IPAddress The address range to create
subnetmask IPAddress The subnet mask that specifies the network-identifying portion of the address
return System

IPRange() public method

Initialise an IPRange using the provided CIDR notation.
public IPRange ( string rangeCIDR ) : System
rangeCIDR string IP range using CIDR notation, e.g. "192.168.1.0/24" contains 192.168.1.0 to 192.168.1.255
return System

IsAutoAssignedAddress() public static method

Returns true if the provided IPAddress is within one of the autoassigned ip ranges, otherwise false
public static IsAutoAssignedAddress ( IPAddress ipAddress ) : bool
ipAddress IPAddress The IPAddress to find in ranges
return bool

ToString() public method

Returns a clean ToString of the IPRange
public ToString ( ) : string
return string