3.1.1.1.1.2.6 MapUnmappedRangesToBlock
This procedure is used to map the appropriate ranges that are not mapped to any address block to the specified block by calculating the overlapping ranges and having only one range out of the overlapping ranges to be mapped. The block to which the ranges have to be mapped are specified by using the following input parameters.
Param_BlockRecordId: The RecordId of the block for which the children ranges are to be calculated.
Param_StartIPAddress: The StartIPAddress of the block for which the children ranges are to be calculated.
Param_EndIPAddress: The EndIPAddress of the block for which the children ranges are to be calculated.
Param_PrefixLength: The PrefixLength of the block for which the children ranges are to be calculated.
Param_AddressCategory: The AddressCategory of the block for which the children ranges are to be calculated.
There is no output value for this procedure. It updates the eligible child ranges for the specified block and updates their ParentIPBlockRecordId to the specified Param_BlockRecordId value.
The following are the steps involved. If the address family of the Param_StartIPAddress and Param_EndIPAddress is Internet, the rest of the processing has to be done against the IPv4-specific table. Otherwise the rest of the processing has to be done against the IPv6-specific table.
For all the address ranges that do not have overlapping range and that are not mapped to a block, set the ParentIPBlockRecordId to Param_BlockRecordId. The rows that meet this requirement are calculated as those that meet the following criteria:
StartIPAddress of the row >= Param_StartIPAddress.
EndIPAddress of the row >= Param_EndIPAddress.
PrefixLength of the row >= Param_PrefixLength.
AddressCategory of the row >= Param_AddressCategory.
Assuming the row being evaluated is CurrentRow, Count of the rows that meet the following condition is 0 (indicating they have no overlapping ranges)
CurrentRow.EndIPAddress >= StartIPAddress and CurrentRow.StartIPAddress < EndIPAddress
CurrentRow.RecordId != RecordId
The following are the processing steps involved in determining the address range to be mapped to the block when there are overlapping ranges.
Enumerate the rows in ADM_IPRangeTable that meet the following criteria and store them in a collection PotentialOverlapRanges. This gives the list of rows that can potentially map to the address block but are having overlap.
StartIPAddress of the row >= Param_StartIPAddress.
EndIPAddress of the row >= Param_EndIPAddress.
PrefixLength of the row >= Param_PrefixLength.
AddressCategory of the row >= Param_AddressCategory.
Assuming the row being evaluated is CurrentRow, Count of the rows that meet the following condition is not 0 (indicating they have no overlapping ranges)
CurrentRow.EndIPAddress >= StartIPAddress and CurrentRow.StartIPAddress < EndIPAddress
CurrentRow.RecordId != RecordId
Enumerate the rows in ADM_IPRangeTable which meet the following criteria and store them in a collection BlockOverlapRanges. This gives the list of rows which overlap with the given address block itself.
EndIPAddress >= Param_StartIPAddress and Param_EndIPAddress >= StartIPAddress
For each row in the PotentialOverlapRanges and BlockOverlapRanges, if the ScopeRecordId is set, get the ExclusionRanges from ADM_DHCPScopesTable and associate with the corresponding range entry in the PotentialOverlapRanges list.
For each PotentialOverlapRow in PotentialOverlapRanges
For each BlockOverlapRow in BlockOverlapRanges
If BlockOverlapRow.RecordId != PotentialOverlapRow.RecordId, perform the following checks
Check if the following conditions are being met to see if the PotentialOverlapRow and BlockOverlapRow form potential overlap.
PotentialOverlapRow.EndIPAddress < BlockOverlapRow.StartIPAddress or BlockOverlapRow.EndIPAddress < PotentialOverlapRow.StartIPAddress
If the BlockOverlapRow and PotentialOverlapRow have the exclusion ranges associated, remove the exclusion ranges from the address ranges and recompute if the ranges overlap. If they do not overlap, the two ranges do not form an overlap. If they do overlap or if one of them doesn’t have exclusion ranges associated with them, they do form a valid overlap.
If the ranges form a valid overlap as computed above, if BlockOverlapRow. IPBlockId is set, that means another range is already mapped and PotentialOverlapRow cannot be mapped to the block. Otherwise update the IPBlockId of the PotentialOverlapRow to the Param_BlockRecordId.