/* * Preparse the message for the info column */ static wmem_strbuf_t* get_column_info(tvbuff_t *tvb) { int byte_length; guint8 type_code; wmem_strbuf_t *result_buf; int my_offset = 0; /* We've a full PDU: 8 bytes + pdu_packetlen bytes */ result_buf = wmem_strbuf_new_label(wmem_packet_scope()); my_offset += (4 + 4 + 1); /* skip Magic, Length, Version */ type_code = tvb_get_guint8(tvb, my_offset); byte_length = get_byte_length(type_code); my_offset++; if (byte_length == 4) { const gchar *symbol; guint32 hash; hash = tvb_get_ntohl(tvb, my_offset); symbol = try_val_to_str_ext(hash, gbl_symbols_vs_ext); if (symbol != NULL) { wmem_strbuf_append_printf(result_buf, "%s()", symbol); } } return result_buf; }
/* * read a number and add it to tree */ static void read_number(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree, int asWhat, guint8 type_code) { int byteLength; read_type(offset, tvb, etch_tree); byteLength = get_byte_length(type_code); if (byteLength > 0) { proto_item *ti; const gchar *symbol = NULL; guint32 hash = 0; gbl_symbol_buffer = wmem_strbuf_new_label(wmem_packet_scope()); /* no symbol found yet */ if (byteLength == 4) { hash = tvb_get_ntohl(tvb, *offset); symbol = try_val_to_str_ext(hash, gbl_symbols_vs_ext); if(symbol != NULL) { asWhat = hf_etch_symbol; gbl_have_symbol = TRUE; wmem_strbuf_append_printf(gbl_symbol_buffer,"%s",symbol); } } ti = proto_tree_add_item(etch_tree, asWhat, tvb, *offset, byteLength, ENC_BIG_ENDIAN); *offset += byteLength; if (symbol != NULL) { proto_item_append_text(ti, " (0x%08x) %s", hash, symbol); } } }
/* * read the length of an array and add it to tree */ static guint32 read_length(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree) { guint32 length; int length_of_array_length_type; guint8 tiny; tiny = tvb_get_guint8(tvb, *offset); /* Is this the value already? */ if ( tiny <= ETCH_TC_MAX_TINY_INT || tiny >= ETCH_TC_MIN_TINY_INT) { length = tiny; length_of_array_length_type = 1; } else { guint8 type_code; type_code = read_type(offset, tvb, etch_tree); length_of_array_length_type = get_byte_length(type_code); switch (length_of_array_length_type) { case 1: length = tvb_get_guint8(tvb, *offset); break; case 2: length = tvb_get_ntohs(tvb, *offset); break; case 4: length = tvb_get_ntohl(tvb, *offset); break; default: return 0; /* error! */ } } proto_tree_add_item(etch_tree, hf_etch_length, tvb, *offset, length_of_array_length_type, ENC_BIG_ENDIAN); (*offset) += length_of_array_length_type; if (*offset + length < *offset) { /* overflow case * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8464 */ length = tvb_reported_length_remaining(tvb, *offset); } return length; }
/* * read the length of an array and add it to tree */ static guint32 read_length(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree) { guint32 length; int length_of_array_length_type; guint8 tiny; tiny = tvb_get_guint8(tvb, *offset); /* Is this the value already? */ if ( tiny <= ETCH_TC_MAX_TINY_INT || tiny >= ETCH_TC_MIN_TINY_INT) { length = tiny; length_of_array_length_type = 1; } else { guint8 type_code; type_code = read_type(offset, tvb, etch_tree); length_of_array_length_type = get_byte_length(type_code); switch (length_of_array_length_type) { case 1: length = tvb_get_guint8(tvb, *offset); break; case 2: length = tvb_get_ntohs(tvb, *offset); break; case 4: length = tvb_get_ntohl(tvb, *offset); break; default: return 0; /* error! */ } } proto_tree_add_item(etch_tree, hf_etch_length, tvb, *offset, length_of_array_length_type, ENC_BIG_ENDIAN); (*offset) += length_of_array_length_type; return length; }