Introduce a new field type called FT_EBCDIC. This field works the same as

FT_STRING, except that it converts the data from the packet from EBCDIC
to ASCII for display in Wireshark.


svn path=/trunk/; revision=23503
This commit is contained in:
Stephen Fisher 2007-11-19 21:27:01 +00:00
parent 53faa469bd
commit 849e628334
6 changed files with 72 additions and 2 deletions

View File

@ -997,8 +997,8 @@ FIELDABBREV The abbreviated name for the header field. (NO SPACES)
FIELDTYPE FT_NONE, FT_BOOLEAN, FT_UINT8, FT_UINT16, FT_UINT24,
FT_UINT32, FT_UINT64, FT_INT8, FT_INT16, FT_INT24, FT_INT32,
FT_INT64, FT_FLOAT, FT_DOUBLE, FT_ABSOLUTE_TIME,
FT_RELATIVE_TIME, FT_STRING, FT_STRINGZ, FT_UINT_STRING,
FT_ETHER, FT_BYTES, FT_IPv4, FT_IPv6, FT_IPXNET,
FT_RELATIVE_TIME, FT_STRING, FT_STRINGZ, FT_EBCDIC,
FT_UINT_STRING, FT_ETHER, FT_BYTES, FT_IPv4, FT_IPv6, FT_IPXNET,
FT_FRAMENUM, FT_PROTOCOL, FT_GUID, FT_OID
FIELDBASE BASE_NONE, BASE_DEC, BASE_HEX, BASE_OCT, BASE_DEC_HEX,
BASE_HEX_DEC, BASE_RANGE_STRING
@ -1542,6 +1542,10 @@ The type of value this field holds. The current field types are:
types, are to be used for text strings,
not raw binary data.
FT_STRINGZ A NUL-terminated string of characters.
FT_EBCDIC A string of characters, not necessarily
NUL-terminated, but possibly NUL-padded.
The data from the packet is converted from
EBCDIC to ASCII before displaying to the user.
FT_UINT_STRING A counted string of characters, consisting
of a count (represented as an integral
value) followed immediately by the

View File

@ -108,6 +108,7 @@ compatible_ftypes(ftenum_t a, ftenum_t b)
case FT_STRING:
case FT_STRINGZ:
case FT_EBCDIC:
case FT_UINT_STRING:
switch (b) {
case FT_STRING:
@ -165,6 +166,7 @@ mk_fvalue_from_val_string(header_field_info *hfinfo, char *s)
case FT_UINT_BYTES:
case FT_STRING:
case FT_STRINGZ:
case FT_EBCDIC:
case FT_UINT_STRING:
case FT_UINT64:
case FT_INT64:
@ -254,6 +256,7 @@ is_bytes_type(enum ftenum type)
case FT_IPXNET:
case FT_STRING:
case FT_STRINGZ:
case FT_EBCDIC:
case FT_UINT_STRING:
case FT_BOOLEAN:
case FT_FRAMENUM:

View File

@ -370,6 +370,43 @@ ftype_register_string(void)
len,
slice,
};
static ftype_t ebcdic_type = {
FT_EBCDIC, /* ftype */
"FT_EBCDIC", /* name */
"EBCDIC character string", /* pretty name */
0, /* wire_size */
string_fvalue_new, /* new_value */
string_fvalue_free, /* free_value */
val_from_unparsed, /* val_from_unparsed */
val_from_string, /* val_from_string */
string_to_repr, /* val_to_string_repr */
string_repr_len, /* len_string_repr */
string_fvalue_set, /* set_value */
NULL, /* set_value_uinteger */
NULL, /* set_value_sinteger */
NULL, /* set_value_integer64 */
NULL, /* set_value_floating */
value_get, /* get_value */
NULL, /* get_value_uinteger */
NULL, /* get_value_sinteger */
NULL, /* get_value_integer64 */
NULL, /* get_value_floating */
cmp_eq,
cmp_ne,
cmp_gt,
cmp_ge,
cmp_lt,
cmp_le,
NULL, /* cmp_bitwise_and */
cmp_contains, /* cmp_contains */
CMP_MATCHES,
len,
slice,
};
static ftype_t uint_string_type = {
FT_UINT_STRING, /* ftype */
"FT_UINT_STRING", /* name */
@ -410,5 +447,6 @@ ftype_register_string(void)
ftype_register(FT_STRING, &string_type);
ftype_register(FT_STRINGZ, &stringz_type);
ftype_register(FT_EBCDIC, &ebcdic_type);
ftype_register(FT_UINT_STRING, &uint_string_type);
}

View File

@ -50,6 +50,7 @@ enum ftenum {
FT_RELATIVE_TIME,
FT_STRING,
FT_STRINGZ, /* for use with proto_tree_add_item() */
FT_EBCDIC, /* for use with proto_tree_add_item() */
FT_UINT_STRING, /* for use with proto_tree_add_item() */
/*FT_UCS2_LE, */ /* Unicode, 2 byte, Little Endian */
FT_ETHER,

View File

@ -43,6 +43,7 @@
#include "slab.h"
#include "tvbuff.h"
#include "emem.h"
#include "charsets.h"
#define SUBTREE_ONCE_ALLOCATION_NUMBER 8
#define SUBTREE_MAX_LEVELS 256
@ -166,6 +167,8 @@ proto_tree_set_string(field_info *fi, const char* value);
static void
proto_tree_set_string_tvb(field_info *fi, tvbuff_t *tvb, gint start, gint length);
static void
proto_tree_set_ebcdic_string_tvb(field_info *fi, tvbuff_t *tvb, gint start, gint length);
static void
proto_tree_set_ether(field_info *fi, const guint8* value);
static void
proto_tree_set_ether_tvb(field_info *fi, tvbuff_t *tvb, gint start);
@ -1149,6 +1152,10 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, int hfindex,
proto_tree_set_string(new_fi, string);
break;
case FT_EBCDIC:
proto_tree_set_ebcdic_string_tvb(new_fi, tvb, start, length);
break;
case FT_UINT_STRING:
n = get_uint_value(tvb, start, length, little_endian);
proto_tree_set_string_tvb(new_fi, tvb, start + length, n);
@ -2159,6 +2166,20 @@ proto_tree_set_string_tvb(field_info *fi, tvbuff_t *tvb, gint start, gint length
proto_tree_set_string(fi, string);
}
static void
proto_tree_set_ebcdic_string_tvb(field_info *fi, tvbuff_t *tvb, gint start, gint length)
{
gchar *string;
if (length == -1) {
length = tvb_ensure_length_remaining(tvb, start);
}
string = tvb_get_ephemeral_string(tvb, start, length);
EBCDIC_to_ASCII(string, length);
proto_tree_set_string(fi, string);
}
/* Add a FT_ETHER to a proto_tree */
proto_item *
proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length,
@ -4091,6 +4112,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_STRING:
case FT_STRINGZ:
case FT_EBCDIC:
case FT_UINT_STRING:
bytes = fvalue_get(&fi->value);
if(strlen(bytes) > ITEM_LABEL_LENGTH) {

View File

@ -523,6 +523,7 @@ add_decode_as(const gchar *cl_param)
case FT_STRING:
case FT_STRINGZ:
case FT_EBCDIC:
/* The selector for this table is a string. */
break;
@ -619,6 +620,7 @@ add_decode_as(const gchar *cl_param)
case FT_STRING:
case FT_STRINGZ:
case FT_EBCDIC:
/* The selector for this table is a string. */
dissector_change_string(table_name, selector_str, dissector_matching);
break;