From 55028fbb51ffb5d2190ecb87cf48ea079b724387 Mon Sep 17 00:00:00 2001 From: winckel <winckel@eurecom.fr> Date: Tue, 12 Nov 2013 09:35:33 +0000 Subject: [PATCH] Added handling of 64 bits fundamental types. git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4358 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- .../utils/itti_analyzer/libbuffers/buffers.c | 10 ++++ .../utils/itti_analyzer/libbuffers/buffers.h | 2 + .../libparser/fundamental_type.c | 54 ++++++++++++------- .../libparser/fundamental_type.h | 2 +- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/common/utils/itti_analyzer/libbuffers/buffers.c b/common/utils/itti_analyzer/libbuffers/buffers.c index 3e017216c8..5a165ab7cb 100644 --- a/common/utils/itti_analyzer/libbuffers/buffers.c +++ b/common/utils/itti_analyzer/libbuffers/buffers.c @@ -43,6 +43,16 @@ uint32_t buffer_get_uint32_t(buffer_t *buffer, uint32_t offset) return value; } +/* Try to fetch 64 bits unsigned from the buffer */ +uint64_t buffer_get_uint64_t(buffer_t *buffer, uint32_t offset) +{ + uint64_t value; + + buffer_fetch(buffer, offset, 8, &value); + + return value; +} + static int buffer_fetch(buffer_t *buffer, uint32_t offset, int size, void *value) { diff --git a/common/utils/itti_analyzer/libbuffers/buffers.h b/common/utils/itti_analyzer/libbuffers/buffers.h index 39b836dc00..51799a5e21 100644 --- a/common/utils/itti_analyzer/libbuffers/buffers.h +++ b/common/utils/itti_analyzer/libbuffers/buffers.h @@ -25,6 +25,8 @@ uint16_t buffer_get_uint16_t(buffer_t *buffer, uint32_t offset); uint32_t buffer_get_uint32_t(buffer_t *buffer, uint32_t offset); +uint64_t buffer_get_uint64_t(buffer_t *buffer, uint32_t offset); + int buffer_fetch_bits(buffer_t *buffer, uint32_t offset, int nbits, uint32_t *value); int buffer_fetch_nbytes(buffer_t *buffer, uint32_t offset, int n_bytes, uint8_t *value); diff --git a/common/utils/itti_analyzer/libparser/fundamental_type.c b/common/utils/itti_analyzer/libparser/fundamental_type.c index 3a4388ccdc..b3291adc6d 100644 --- a/common/utils/itti_analyzer/libparser/fundamental_type.c +++ b/common/utils/itti_analyzer/libparser/fundamental_type.c @@ -2,26 +2,31 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <inttypes.h> #include "fundamental_type.h" #include "ui_interface.h" -uint32_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset) { - uint32_t value; +uint64_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset) { + uint64_t value; switch (type->size) { - case 8: { + case 8: value = buffer_get_uint8_t (buffer, offset + parent_offset); - } break; - case 16: { + + case 16: value = buffer_get_uint16_t (buffer, offset + parent_offset); - } break; - case 32: { + + case 32: value = buffer_get_uint32_t (buffer, offset + parent_offset); - } break; + + case 64: + value = buffer_get_uint64_t (buffer, offset + parent_offset); + break; + default: /* ??? */ value = 0; @@ -37,7 +42,10 @@ int fundamental_dissect_from_buffer( int length = 0; char cbuf[200]; int type_unsigned; - uint32_t value; + uint8_t value8; + uint16_t value16; + uint32_t value32; + uint64_t value64; DISPLAY_PARSE_INFO("fundamental", type->name, offset, parent_offset); @@ -45,28 +53,36 @@ int fundamental_dissect_from_buffer( type_unsigned = strstr (type->name, "unsigned") == NULL ? 0 : 1; - value = fundamental_read_from_buffer(type, buffer, offset, parent_offset); + value64 = fundamental_read_from_buffer(type, buffer, offset, parent_offset); if (indent > 0) { DISPLAY_TYPE("Fun"); } switch (type->size) { - case 8: { + case 8: + value8 = (uint8_t) value64; INDENTED_STRING(cbuf, indent, - sprintf(cbuf, type_unsigned ? "(0x%02x) %3u '%c';\n" : "(0x%02x) %4d '%c';\n", value, value, isprint(value) ? value : '.')); - } + sprintf(cbuf, type_unsigned ? "(0x%02" PRIx8 ") %3" PRIu8 " '%c';\n" : "(0x%02" PRIx8 ") %4" PRId8 " '%c';\n", value8, value8, isprint(value8) ? value8 : '.')); break; - case 16: { + + case 16: + value16 = (uint16_t) value64; INDENTED_STRING(cbuf, indent, - sprintf(cbuf, type_unsigned ? "(0x%04x) %5u;\n" : "(0x%04x) %6d;\n", value, value)); - } + sprintf(cbuf, type_unsigned ? "(0x%04" PRIx16 ") %5" PRIu16 ";\n" : "(0x%04" PRIx16 ") %6" PRId16 ";\n", value16, value16)); break; - case 32: { + + case 32: + value32 = (uint32_t) value64; INDENTED_STRING(cbuf, indent, - sprintf(cbuf, type_unsigned ? "(0x%08x) %9u;\n" : "(0x%08x) %10d;\n", value, value)); - } + sprintf(cbuf, type_unsigned ? "(0x%08" PRIx32 ") %9" PRIu32 ";\n" : "(0x%08" PRIx32 ") %10" PRId32 ";\n", value32, value32)); break; + + case 64: + INDENTED_STRING(cbuf, indent, + sprintf(cbuf, type_unsigned ? "(0x%016" PRIx64 ") %20" PRIu64 ";\n" : "(0x%016" PRIx64 ") %20" PRId64 ";\n", value64, value64)); + break; + default: /* ??? */ break; diff --git a/common/utils/itti_analyzer/libparser/fundamental_type.h b/common/utils/itti_analyzer/libparser/fundamental_type.h index 956788a8d2..0b58a426fe 100644 --- a/common/utils/itti_analyzer/libparser/fundamental_type.h +++ b/common/utils/itti_analyzer/libparser/fundamental_type.h @@ -3,7 +3,7 @@ #ifndef FUNDAMENTAL_TYPE_H_ #define FUNDAMENTAL_TYPE_H_ -uint32_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset); +uint64_t fundamental_read_from_buffer(struct types_s *type, buffer_t *buffer, uint32_t offset, uint32_t parent_offset); int fundamental_dissect_from_buffer( struct types_s *type, ui_set_signal_text_cb_t ui_set_signal_text_cb, gpointer user_data, -- GitLab