3.1.1.1.4.2.5 CalculateParentForIPBlock

This procedure can be used to calculate the parent IP Block for a given address block. The address block for which the parent has to be calculated is specified using the following input parameters.

Param_StartIPAddress: This is of type IPAddress specifying the StartIPAddress of the address block for which the parent block is to be determined.

Param_EndIPAddress: This is of type IPAddress specifying the EndIPAddress of the address block for which the parent block is to be determined.

Param_PrefixLength: This is an integer specifying the PrefixLength of the address block for which the parent block is to be determined.

Param_RecordIdToExclude: This specifies the RecordId of the block for which the parent block is being calculated so that it is filtered from the resulting set.

Param_AddressCategory: This specifies the AddressCategory of the block for which the parent block is being calculated.

The result of the procedure is the RecordId of the parent block determined. If there is no applicable parent block, a value of 0 is returned. This is returned as result variable.

The following are the steps involved. If the address family of the Param_StartIPAddress and Param_EndIPAddress is Internet, the remainder of the processing has to be done against the IPv4-specific table. Otherwise the remainder of the processing has to be done against the IPv6-specific table.

  1. Initialize result to 0.

  2. Enumerate the rows from the ADM_IPBlocksTable which meet the following condition:

    • Param_StartIPAddress greater than or equal to StartIPAddress of the row

    • Param_EndIPAddress lesser than or equal to the EndIPAddress of the row

    • Param_PrefixLength is greater than or equal to the PrefixLength of the row

    • RecordId of the row is not equal to Param_RecordIdToExclude.

  3. Order the enumerated set of rows in the descending order of StartIPAddress, EndIPAddress, and PrefixLength. The first row of the ordered set will be the appropriate parent.

  4. If the AddressCategory of the first row of the ordered set is the same as Param_AddressCategory, assign RecordId of the row as result.

  5. Return result as the output of the procedure.