3.1.1.1.4.2.5 CalculateParentForIPBlock

The CalculateParentForIPBlock 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_AddressSpaceRecordId: The AddressSpaceRecordId of the block for which the parent block 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_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 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 has to be done against the IPv6-specific table:

  1. Initialize result to 0.

  2. Enumerate the rows from ADM_IPBlocksTable that meet the following conditions:

    • Param_StartIPAddress is greater than or equal to StartIPAddress of the row.

    • Param_EndIPAddress is less than or equal to the EndIPAddress of the row.

    • Param_AddressSpaceRecordId is equal to AddressSpaceRecordId of the block entry in the table.

    • 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.