pdr: Rework pldm_pdr_find_container_id_range_exclude() API

The API was returning the child container id, so renamed the API as
pldm_pdr_find_child_container_id_index_range_exclude(). The API returns
the child container id based on the index passed as an argument.

This commit addresses the comment in
https://gerrit.openbmc.org/c/openbmc/libpldm/+/63615/comment/439b3560_78f6dbbc/

Fixes: 5dc025719dc3 (“pdr: Add pldm_pdr_find_container_id_range_exclude() API”)
Change-Id: I811105d9ccc64e6f5ab28133e75ff63fdcc2c6bc
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/src/pdr.c b/src/pdr.c
index 3b86f88..55350a8 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -374,10 +374,10 @@
 }
 
 LIBPLDM_ABI_TESTING
-int pldm_pdr_find_container_id_range_exclude(
+int pldm_pdr_find_child_container_id_index_range_exclude(
 	const pldm_pdr *repo, uint16_t entity_type, uint16_t entity_instance,
-	uint32_t range_exclude_start_handle, uint32_t range_exclude_end_handle,
-	uint16_t *container_id)
+	uint8_t child_index, uint32_t range_exclude_start_handle,
+	uint32_t range_exclude_end_handle, uint16_t *container_id)
 {
 	pldm_pdr_record *record;
 	if (!repo) {
@@ -408,10 +408,11 @@
 		// this cast is valid with respect to alignment because
 		// struct pldm_pdr_hdr is declared with __attribute__((packed))
 		pdr = (void *)(record->data + sizeof(struct pldm_pdr_hdr));
-		if (pdr->num_children == 0) {
+		if (child_index >= pdr->num_children) {
 			continue;
 		}
-		child = (&pdr->children[0]);
+
+		child = (&pdr->children[child_index]);
 		is_container_entity_type = pdr->container.entity_type ==
 					   entity_type;
 		is_container_entity_instance_number =