3.1.1.1.4.2.3 GetIPBlockParentAndChildDepth
The GetIPBlockParentAndChildDepth procedure can be used to calculate the length of the address block hierarchy given the StartIPAddress and EndIPAddress of the address block. The following are the input parameters:
Param_StartIPAddress: This is of type IPAddress specifying the StartIPAddress of the block for which the length of the parent and child hierarchy length is to be calculated.
Param_EndIPAddress: This is of type IPAddress specifying the EndIPAddress of the block for which the length of the parent and child hierarchy length is to be calculated.
Param_AddressSpaceRecordId: The Address Space RecordId of the address block for which the block depth is to be computed. If this parameter is not specified while calling this procedure, the default value that is considered is 1, which maps to Default Provider Address Space.
Param_RecordIdToExclude: This specifies the RecordId of the address block that has to be excluded while calculating the length of the parent-child hierarchy.
The output parameter is the length of the parent-child hierarchy of the block whose start address and end address are given. This will be returned in variable result.
The following are the steps involved:
Note: If the address family of Param_StartIPAddress and Param_EndIPAddress is InterNetwork, the remainder of the processing is done against the IPv4-specific table. Otherwise, the remainder of the processing is done against the IPv6-specific table.
Enumerate the rows in ADM_IPBlocksTable that have either of the conditions TRUE, or have Param_AddressSpaceRecordId equal to the AddressSpaceRecordId of the block entry in the table:
StartIPAddress is less than or equal to Param_StartIPAddress and EndIPAddress is greater than or equal to Param_EndIPAddress
StartIPAddress is greater than or equal to Param_StartIPAddress and EndIPAddress is less than or equal to Param_EndIPAddress
If Param_RecordIdToExclude is specified, exclude the row from the enumerated rows.
Set result to 0.
Set RecordIdToSearch to 0.
In the enumerated rows, look up the row that has RecordId to be RecordIdToSearch.
If the row is found, perform the following:
Increment result by 1.
Set RecordIdToSearch to the ParentIPBlockRecordId of the row.
Go to step 5.
If the row is not found, the chain has been found.
Return result as the length of the hierarchy.