Click or drag to resize
Cidr Class
Represents a Classless Inter-Domain Routing value.
Inheritance Hierarchy
SystemObject
  VirtualRadar.InterfaceCidr

Namespace: VirtualRadar.Interface
Assembly: VirtualRadar.Interface (in VirtualRadar.Interface.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class Cidr

The Cidr type exposes the following members.

Constructors
  NameDescription
Public methodCidr
Creates a new object.
Top
Properties
  NameDescription
Public propertyAddress
Gets the IP address.
Public propertyBitmaskBits
Gets the number of bits used to construct the bitmask.
Public propertyFirstMatchingAddress
Gets the first matching address.
Public propertyIPv4Bitmask
Gets the bitmask to use when Address is IPv4.
Public propertyLastMatchingAddress
Gets the last matching address.
Public propertyMaskedAddress
Gets the Address with the bitmask applied.
Top
Methods
  NameDescription
Public methodEquals
Returns true if the other object is a CIDR with the same properties as this object.
(Overrides ObjectEquals(Object).)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Returns a hashcode for the CIDR. Guaranteed to return the same hashcode for two CIDRs that are equal.
(Overrides ObjectGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodMatches
Returns true if the address passed across matches the CIDR.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberParse
Parses an address. Throws exceptions if the parse fails.
Public methodToString
See base docs.
(Overrides ObjectToString.)
Public methodStatic memberTryParse
Parses an address. Returns false and sets the cidr to null if the parse fails.
Top
Remarks

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.

See Also