Verify currect node is a child of current parent

This commit is to add the pldm_is_current_parent_child method and
to verify that the current node is a child of the current parent,
If so, return true, otherwise return false.

Tested: built pldm successfully and unit test passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ie2f01d948178dfdf3a5bfa1c6c0a939b6fdd96e3
diff --git a/libpldm/pdr.c b/libpldm/pdr.c
index 562c9f9..d8c0f77 100644
--- a/libpldm/pdr.c
+++ b/libpldm/pdr.c
@@ -520,6 +520,25 @@
 	return count;
 }
 
+bool pldm_is_current_parent_child(pldm_entity_node *parent, pldm_entity *node)
+{
+	assert(parent != NULL);
+	assert(node != NULL);
+
+	pldm_entity_node *curr = parent->first_child;
+	while (curr != NULL) {
+		if (node->entity_type == curr->entity.entity_type &&
+		    node->entity_instance_num ==
+			curr->entity.entity_instance_num) {
+
+			return true;
+		}
+		curr = curr->next_sibling;
+	}
+
+	return false;
+}
+
 static void _entity_association_pdr_add_entry(pldm_entity_node *curr,
 					      pldm_pdr *repo, uint16_t size,
 					      uint8_t contained_count,