/** Set the last block number of the block range list. It removes all the blocks after the Last. MTFTP initialize the block range to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the last block number, it calls this function to set the last block number. @param[in] Head The block range list. @param[in] Last The last block number. **/ VOID Mtftp6SetLastBlockNum ( IN LIST_ENTRY *Head, IN UINT16 Last ) { MTFTP6_BLOCK_RANGE *Range; // // Iterate from the tail to head to remove the block number // after the last. // while (!IsListEmpty (Head)) { Range = NET_LIST_TAIL (Head, MTFTP6_BLOCK_RANGE, Link); if (Range->Start > Last) { RemoveEntryList (&Range->Link); FreePool (Range); continue; } if (Range->End > Last) { Range->End = Last; } return ; } }
VOID Mtftp4SetLastBlockNum ( IN NET_LIST_ENTRY *Head, IN UINT16 Last ) /*++ Routine Description: Set the last block number of the block range list. It will remove all the blocks after the Last. MTFTP initialize the block range to the maximum possible range, such as [0, 0xffff] for WRQ. When it gets the last block number, it will call this function to set the last block number. Arguments: Head - The block range list Last - The last block number Returns: None --*/ { MTFTP4_BLOCK_RANGE *Range; // // Iterate from the tail to head to remove the block number // after the last. // while (!NetListIsEmpty (Head)) { Range = NET_LIST_TAIL (Head, MTFTP4_BLOCK_RANGE, Link); if (Range->Start > Last) { NetListRemoveEntry (&Range->Link); NetFreePool (Range); continue; } if (Range->End > Last) { Range->End = Last; } return ; } }