diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2014-04-13 18:53:29 +0200 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2014-04-13 20:02:52 +0000 |
commit | cfe11b1097a53d5d62f1b7b9de3b816378527dae (patch) | |
tree | 77da630251ba4947d28290828b86da383c452b64 /epan/proto.c | |
parent | 63ed4745a2c3abef00ec69fa1b6832674fa17605 (diff) |
Add ENC_ASCII_7BITS encoding
Change-Id: I01ec87ff4181afb5b2de487fd5f5200f8d62f17d
Reviewed-on: https://code.wireshark.org/review/1088
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/epan/proto.c b/epan/proto.c index fb7ae9fa4f..1db242d03b 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -7836,6 +7836,36 @@ proto_tree_add_ts_23_038_7bits_item(proto_tree *tree, const int hfindex, tvbuff_ return pi; } +proto_item * +proto_tree_add_ascii_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb, + const guint bit_offset, const gint no_of_chars) +{ + proto_item *pi; + header_field_info *hfinfo; + gint byte_length; + gint byte_offset; + gchar *string; + + TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hfinfo); + + DISSECTOR_ASSERT(hfinfo->type == FT_STRING); + + byte_length = (((no_of_chars + 1) * 7) + (bit_offset & 0x07)) >> 3; + byte_offset = bit_offset >> 3; + + string = tvb_get_ascii_7bits_string(wmem_packet_scope(), tvb, bit_offset, no_of_chars); + + if (hfinfo->display == STR_UNICODE) { + DISSECTOR_ASSERT(g_utf8_validate(string, -1, NULL)); + } + + pi = proto_tree_add_pi(tree, hfinfo, tvb, byte_offset, &byte_length); + DISSECTOR_ASSERT(byte_length >= 0); + proto_tree_set_string(PNODE_FINFO(pi), string); + + return pi; +} + guchar proto_check_field_name(const gchar *field_name) { |