diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2008-07-11 15:16:03 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2008-07-11 15:16:03 +0000 |
commit | 0c18cbc98f9b835778d562b56a5848de8bae0516 (patch) | |
tree | daea260dccef1ab4dee765dae88204f00ab09cef /epan/dissectors/packet-armagetronad.c | |
parent | b92594e56cb96ca0bffe1b4bf7c617c94e54864b (diff) | |
download | wireshark-0c18cbc98f9b835778d562b56a5848de8bae0516.tar.gz wireshark-0c18cbc98f9b835778d562b56a5848de8bae0516.tar.bz2 wireshark-0c18cbc98f9b835778d562b56a5848de8bae0516.zip |
(Finally) stop guint16s to access a string: just treat it as an array of chars and swap them "the hard way".
svn path=/trunk/; revision=25702
Diffstat (limited to 'epan/dissectors/packet-armagetronad.c')
-rw-r--r-- | epan/dissectors/packet-armagetronad.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/epan/dissectors/packet-armagetronad.c b/epan/dissectors/packet-armagetronad.c index 747ae61b13..f6509c244e 100644 --- a/epan/dissectors/packet-armagetronad.c +++ b/epan/dissectors/packet-armagetronad.c @@ -110,7 +110,8 @@ static value_string descriptors[] = { {0, NULL} }; -static gboolean is_armagetronad_packet(tvbuff_t * tvb) +static gboolean +is_armagetronad_packet(tvbuff_t * tvb) { gint offset = 0; @@ -144,44 +145,40 @@ static gboolean is_armagetronad_packet(tvbuff_t * tvb) static void add_message_data(tvbuff_t * tvb, gint offset, gint data_len, proto_tree * tree) { - guint16 *data = NULL; + gchar *data = NULL; + gchar tmp; + int i; - if (tree) { - gchar *bptr; + if (!tree) + return; - data = tvb_memcpy(tvb, ep_alloc(data_len + 1), offset, data_len); - bptr = (gchar *)data; - bptr[data_len] = '\0'; + data = tvb_memcpy(tvb, ep_alloc(data_len + 1), offset, data_len); + data[data_len] = '\0'; + + for (i = 0; i < data_len; i += 2) { + /* + * There must be a better way to tell + * Wireshark not to stop on null bytes + * as the length is known + */ + if (!data[i]) + data[i] = ' '; + + if (!data[i+1]) + data[i+1] = ' '; + + /* Armagetronad swaps unconditionally */ + tmp = data[i]; + data[i] = data[i+1]; + data[i+1] = tmp; } - if (data) { - guint16 *ptr, *end = &data[data_len]; - for (ptr = data; ptr != end; ptr++) { - /* - * There must be a better way to tell - * Wireshark not to stop on null bytes - * as the length is known - */ - gchar *bptr = (gchar *) ptr; - if (!bptr[0]) - bptr[0] = ' '; - - if (!bptr[1]) - bptr[1] = ' '; - - /* Armagetronad swaps unconditionally */ - *ptr = GUINT16_SWAP_LE_BE(*ptr); - } - - proto_tree_add_string(tree, hf_armagetronad_data, tvb, offset, - data_len, (gchar *) data); - } else - proto_tree_add_item(tree, hf_armagetronad_data, tvb, offset, - data_len, FALSE); + proto_tree_add_string(tree, hf_armagetronad_data, tvb, offset, + data_len, (gchar *) data); } -static gint add_message(tvbuff_t * tvb, gint offset, proto_tree * tree, - GString * info) +static gint +add_message(tvbuff_t * tvb, gint offset, proto_tree * tree, GString * info) { guint16 descriptor_id, message_id; gint data_len; |