Indy 9
TIdNetworkCalculator
Hierarchy, Properties, Methods, See Also, Unit: IdNetworkCalculator
Implements an IP address calculator.
TIdNetworkCalculator = class(TIdBaseComponent)
Unit
IdNetworkCalculator
Description
TIdNetworkCalculator is a component that can be used to calculate the validity of a network address, or calculate a list of valid network addresses.

The 32-bit IP address used by TIdNetworkCalculator is based on the network address scheme described in the Internet Standards document RFC 1365 - An IP Address Extension Proposal (http://www.rfc-editor.org/rfc/rfc1365.txt)

Assign values to the properties NetworkClass, NetworkAddress, and NetworkMask to allow the component to validate the IP address desired. You can also use IsAddressInNetwork to determine if a specific network address is valid based on the NetworkMask settings. Use ListIP to view a list of IP addresses accessible over a network having the given network address and network mask.


TIdNetworkCalculator.IsAddressRoutable
TIdNetworkCalculator
Indicates if the network address is a routable public IP address.
property IsAddressRoutable: Boolean;
Return Value
Boolean - True when the network address is a public IP address.
Description
IsAddressRoutable is a read-only Boolean property that indicates if the value in NetworkAddress represents an internet address that can be passed to the public internet. IsAddressRoutable compares the Byte values in NetworkAddress to insure that the address does not reside in the IANA-assigned Private Address Space, including the following IP Address blocks:

  • 10.0.0.0 - 10.255.255.255

  • 172.16.0.0 - 172.31.255.255

  • 192.168.0.0 - 192.168.255.255

The Private Address Space allows an organization to decide the use of IP addresses without any coordination with IANA or an Internet registry. Addresses within the Private Address Space will only be unique within the enterprise, or the set of enterprises which choose to cooperate over this space so they may communicate with each other in their own private internet. As a result, these network address cannot be routed to the public internet.


TIdNetworkCalculator.ListIP
TIdNetworkCalculator
Represents the list of valid IP addresses for the network.
property ListIP: TStrings;
Description
ListIP is a read-only TStrings property that represents the list of valid IP addresses for the current network settings. IP addresses in the list are in "dotted-decimal" form, like 129.71.2.4.

ListIP is automatically populated when values are read from the property and the list does not contain any entries, or by the OnNetAddressChange and OnNetMaskChange event handlers. FillIPLIst is used to populate the strings in ListIP.

Note: ListIP will not contain IP addresses in the IDE, or when the component state is csDesigning, if the length of the list from NumIP will exceed 1024 entries. This is done to prevent a long loop where the IDE would appear to be locked.


TIdNetworkCalculator.NetworkAddress
TIdNetworkCalculator, See Also
Specifies a local address on a network.
property NetworkAddress: TIpProperty;
Description
NetworkAddress is a TIPProperty property that identifies the local address for a computer on the network. NetworkAddress allows the local address to be retrieved and assigned using a variety of representations of the 32-bit IP address, as permitted by TIPProperty.

NetworkAddress is used in conjunction with NetworkMask to determine the NetworkClass for the complete network address. The OnNetAddressChange event handler is triggered when the value in NetworkAddress is modified.


TIdNetworkCalculator.NetworkClass
TIdNetworkCalculator, See Also
Specifies the network class for the current network address.
property NetworkClass: TNetworkClass;
Description
NetworkClass is a read-only TNetworkClass property that identifies the network class for the settings in NetworkAddress and NetworkMask. NetworkClass is automatically updated in the OnNetAddressChange event handler when the value of NetworkAddress is updated.

Values for NetworkClass correspond to the enumerated values in TNetworkClass, and include the following:

  • ID_NET_CLASS_A - Class A

  • ID_NET_CLASS_B - Class B

  • ID_NET_CLASS_C - Class C

  • ID_NET_CLASS_D - Class D

  • ID_NET_CLASS_E - Class E

TIdNetworkCalculator.NetworkClassAsString
TIdNetworkCalculator
Returns the text representation of the network class.
property NetworkClassAsString: String;
Return Value
String - Text representation of the network class.
Description
NetworkClassAsString is a read-only String property that returns the character representation for the value in NetworkClass. Values in NetworkClass correspond to the enumerated values in TNetworkClass, and include the following:

  • ID_NET_CLASS_A - Class 'A'

  • ID_NET_CLASS_B - Class 'B'

  • ID_NET_CLASS_C - Class 'C'

  • ID_NET_CLASS_D - Class 'D'

  • ID_NET_CLASS_E - Class 'E'

TIdNetworkCalculator.NetworkMask
TIdNetworkCalculator, See Also
Specifies the network address mask for the current network settings.
property NetworkMask: TIpProperty;
Description
NetworkMask is a TIpProperty that identifies the network address mask for computers on the network. NetworkMask is used in determining valid IP address for local computers on the network and the network number used for routing and gateway applications.

NetworkMask is used in conjunction with NetworkAddress to determine the NetworkClass for the complete network address. NetworkMaskLength identifies the number of available network address based on NetworkMask.

The OnNetMaskChange event handler is triggered when the value in NetworkMask is modified.


TIdNetworkCalculator.NetworkMaskLength
TIdNetworkCalculator
Specifies the number of available network addresses for the current network.
property NetworkMaskLength: cardinal;
Description
NetworkMaskLength is a Cardinal property that identifies the number of available network addresses for the network based on the value of NetworkMask. The default value for NetworkMaskLength is ID_NC_MASK_LENGTH, as assigned in Create.

NetworkMaskLength is automatically recalculated in the OnNetMaskChange event handler following a change in the value of NetworkMask.


TIdNetworkCalculator.OnChange
TIdNetworkCalculator
Specifies the event handler for changes to network address properties.
property OnChange: TNotifyEvent;
Description
OnChange is a TNotifyEvent property that specifies the event handler for changes to network address properties. OnChange is triggered from both the OnNetAddressChange and OnNetMaskChange event handlers following a change to the values of either property.

Use OnChange to notify the application of changes in the TIdNetworkCalculator network address properties. Assign an OnChange event handler to respond to the event notification.


TIdNetworkCalculator.OnGenIPList
TIdNetworkCalculator
Specifies the event handler for updates to ListIP.
property OnGenIPList: TNotifyEvent;
Description
OnGenIPList is a TNotifyEvent property that specifies the event handler for changes to IP address in ListIP.
Todo
OnGenIPList is triggered when...

Use OnGenIPList to notify the application that IP addresses in ListIP have been regenerated after a change to network address settings. Assign an OnGenIPList event handler to respond to the event notification.


TIdNetworkCalculator.Create
TIdNetworkCalculator
Creates and initializes the class instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the constructor for the class instance, and is responsible for properly initializing properties and private variables.

Create relies on the inherited Create constructor, and also performs the following:


TIdNetworkCalculator.Destroy
TIdNetworkCalculator, See Also
Frees the class instance.
destructor Destroy; override;
Description
Destroy is the destructor for the class instance. Destroy will clear items stored in the ListIP property. Destroy will release resources allocated to the NetworkAddress, NetworkMask, and ListIP properties. Destroy calls the inherited Destroy method prior to exiting.

TIdNetworkCalculator.EndIP
TIdNetworkCalculator, Example
Determines the last available IP address for the network.
function EndIP: String;
Return Value
String - IP address in "dotted-decimal" format, like 129.71.2.4.
Description
EndIP is a String function used to determine the last available IP address for the network. EndIP uses the values in NetworkAddress and NetworkMask to perform calculations for available network addresses. The binary length of NetworkMask is used to determine the maximum number of IP addresses on the network in NumIP.

TIdNetworkCalculator.FillIPList
TIdNetworkCalculator
Generates a list of valid IP address for the network.
procedure FillIPList;
Description
FillIPList is a procedure used to generate a list of valid IP addresses for the network. The list of valid addresses is stored in ListIP. IP addresses are create in "dotted-decimal" form, like 129.71.2.4.

FillIPList is used when reading values from the ListIP property. FillIPList populates the address list when it does not contain any entries, or in the OnNetAddressChange and OnNetMaskChange event handlers.

FillIPList uses the values in NetworkAddress and NetworkMask to perform calculations for available network addresses. The binary length of NetworkMask is used to determine the maximum number of IP addresses on the network in NumIP.

Note: FillIPList will not create a list of IP addresses in the IDE, or when the component state is csDesigning, if the length of the list from NumIP will exceed 1024 entries. This is done to prevent a long loop where the IDE would appear to be locked.


TIdNetworkCalculator.IsAddressInNetwork
TIdNetworkCalculator, Example
Indicates if an IP address is valid for the network settings.
function IsAddressInNetwork(Address: String): Boolean;
Parameters
Address: String
IP address to be checked in "dotted-decimal" form, like 129.71.2.4.
Return Value
Boolean - True when valid.
Description
IsAddressInNetwork is a Boolean function used to determine if a specific IP address is valid, based on the current network settings. NetworkAddress and NetworkMask are used to determine the current network visibility.

TIdNetworkCalculator.NumIP
TIdNetworkCalculator
Identifies the number of IP addresses available on the network.
function NumIP: integer;
Return Value
Integer - Number of IP addresses available.
Description
NumIP is an Integer function that identifies the number of IP addresses available on the network, based on the current NetworkMask. NumIP uses NetworkMaskLength to calculate the number of IP addresses available.

NumIP is used by FillIPList to determine the number of list entries, and by EndIP to determine the last available IP address on the network.


TIdNetworkCalculator.StartIP
TIdNetworkCalculator, Example
Determines the first available IP address for the network.
function StartIP: String;
Return Value
String - IP address in "dotted-decimal" format, like 129.71.2.4.
Description
StartIP is a String function used to determine the first available IP address for the network. StartIP uses the values in NetworkAddress and NetworkMask to perform calculations for available network addresses.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.