From b91ab12102b59d2b029c2dd890b7dbb8d216bf3c Mon Sep 17 00:00:00 2001 From: winckel Date: Wed, 4 Dec 2013 18:05:46 +0000 Subject: [PATCH] Changed the way some fields are located (children rather than next). git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4598 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- .../utils/itti_analyzer/libparser/xml_parse.c | 8 ++--- .../itti_analyzer/libresolver/locate_root.c | 34 ++++++++++++++++++- .../itti_analyzer/libresolver/locate_root.h | 2 ++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/common/utils/itti_analyzer/libparser/xml_parse.c b/common/utils/itti_analyzer/libparser/xml_parse.c index fcea5210e7..5862fce68f 100644 --- a/common/utils/itti_analyzer/libparser/xml_parse.c +++ b/common/utils/itti_analyzer/libparser/xml_parse.c @@ -825,13 +825,13 @@ static int xml_parse_doc(xmlDocPtr doc) { CHECK_FCT(locate_type("ittiMsg", xml_head, &message_type)); /* Locate the origin task id field */ - CHECK_FCT(locate_type("originTaskId", message_header_type, &origin_task_id_type)); + CHECK_FCT(locate_type_children("originTaskId", message_header_type->child->child, &origin_task_id_type)); /* Locate the destination task id field */ - CHECK_FCT(locate_type("destinationTaskId", message_header_type, &destination_task_id_type)); + CHECK_FCT(locate_type_children("destinationTaskId", message_header_type->child->child, &destination_task_id_type)); /* Locate the instance field */ - CHECK_FCT(locate_type("instance", message_header_type, &instance_type)); + CHECK_FCT(locate_type_children("instance", message_header_type->child->child, &instance_type)); /* Locate the message size field */ - CHECK_FCT(locate_type("ittiMsgSize", message_header_type, &message_size_type)); + CHECK_FCT(locate_type_children("ittiMsgSize", message_header_type->child->child, &message_size_type)); // root->type_hr_display(root, 0); diff --git a/common/utils/itti_analyzer/libresolver/locate_root.c b/common/utils/itti_analyzer/libresolver/locate_root.c index 7bec706f61..61c0b45de5 100644 --- a/common/utils/itti_analyzer/libresolver/locate_root.c +++ b/common/utils/itti_analyzer/libresolver/locate_root.c @@ -84,13 +84,45 @@ int locate_type(const char *type_name, types_t *head, types_t **type) { } next_counter ++; } - g_info("locate_type: %s %d", type_name, next_counter); + g_info("locate_type: %s %d %p", type_name, next_counter, next_type); if (type) *type = next_type; return (next_type == NULL) ? RC_FAIL : RC_OK; } +int locate_type_children(const char *type_name, types_t *head, types_t **type) { + types_t *found_type = NULL; + int i; + + /* The root element is for example : MessageDef. + * This element is the entry for other sub-types. + */ + if (!type_name) { + g_warning("FATAL: no element name provided"); + return RC_BAD_PARAM; + } + if (!head) { + g_warning("Empty list detected"); + return RC_BAD_PARAM; + } + + for (i = 0; i < head->nb_members; i++) { + if (head->members_child[i]->name == NULL) + continue; + if (strcmp (type_name, head->members_child[i]->name) == 0) { + /* Matching reference */ + found_type = head->members_child[i]; + break; + } + } + g_info("locate_type: %s %d %p", type_name, i, found_type); + + if (type) + *type = found_type; + return (found_type == NULL) ? RC_FAIL : RC_OK; +} + uint32_t get_message_header_type_size(void) { /* Typedef */ diff --git a/common/utils/itti_analyzer/libresolver/locate_root.h b/common/utils/itti_analyzer/libresolver/locate_root.h index a5f81d5319..9d8c4ed8b1 100644 --- a/common/utils/itti_analyzer/libresolver/locate_root.h +++ b/common/utils/itti_analyzer/libresolver/locate_root.h @@ -16,6 +16,8 @@ int locate_root(const char *root_name, types_t *head, types_t **root); int locate_type(const char *type_name, types_t *head, types_t **type); +int locate_type_children(const char *type_name, types_t *head, types_t **type); + uint32_t get_message_header_type_size(void); uint32_t get_message_size(buffer_t *buffer);