Cidr Class |
Namespace: VirtualRadar.Interface
The Cidr type exposes the following members.
Name | Description | |
---|---|---|
Address |
Gets the IP address.
| |
BitmaskBits |
Gets the number of bits used to construct the bitmask.
| |
FirstMatchingAddress |
Gets the first matching address.
| |
IPv4Bitmask |
Gets the bitmask to use when Address is IPv4.
| |
LastMatchingAddress |
Gets the last matching address.
| |
MaskedAddress |
Gets the Address with the bitmask applied.
|
Name | Description | |
---|---|---|
Equals |
Returns true if the other object is a CIDR with the same properties as this object.
(Overrides ObjectEquals(Object).) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode |
Returns a hashcode for the CIDR. Guaranteed to return the same hashcode for two CIDRs that
are equal.
(Overrides ObjectGetHashCode.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Matches |
Returns true if the address passed across matches the CIDR.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Parse |
Parses an address. Throws exceptions if the parse fails.
| |
ToString |
See base docs.
(Overrides ObjectToString.) | |
TryParse |
Parses an address. Returns false and sets the cidr to null if the parse fails.
|
A CIDR is an IP address and a mask, expressed as a number of bits. The bits indicate the number of 1 bits measured from the high bit down to the low bit - a bitmask of /1 is the high bit (bit 32) set, 2 would be bits 31 & 32 set and so on. If the number of bits isn't specified then 32 is assumed.
The address is masked off to produce a set of high bits from the address. When we want to compare another address we apply the bitmask to the other address as well. If all of the bits match - i.e. an xor of both addresses after masking is 0 - then we have a match. Otherwise the addresses don't match.
It follows that if the number of bits is zero then every address will match the CIDR whereas if the bits are 32 then only one address can match.