Introduce a new field type called FT_EBCDIC. This field works the same as
authorsfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 19 Nov 2007 21:27:01 +0000 (21:27 +0000)
committersfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 19 Nov 2007 21:27:01 +0000 (21:27 +0000)
FT_STRING, except that it converts the data from the packet from EBCDIC
to ASCII for display in Wireshark.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23503 f5534014-38df-0310-8fa8-9805f1628bb7

doc/README.developer
epan/dfilter/semcheck.c
epan/ftypes/ftype-string.c
epan/ftypes/ftypes.h
epan/proto.c
tshark.c

index 58bfde8cd7546a60db2bcee166013f395ed61f80..e4f7df3cfb28ab78836f94779facc37506930d85 100644 (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
index 0046f2ef533e57da830d7169f7460a34179679e6..3acb7c560fcca3a40da4fdd9e0c9d3790fad2dcf 100644 (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:
index fed7c2b017f484996328d44d252bb75fd4c67249..e7fd24ad50ae51ecbc6c1ef9c929644f2b8ef641 100644 (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);
 }
index 78c322555df42f68c7cbe43b35a6b6d8a52beb79..2b7d6f0388dcf84fe5704dc117d4bd0264dce881 100644 (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,
index bef84ee8b8106d9a540eec6c59ee9d3c31609015..02a0555c11dc2686e4a4fbb9941ec731099b7cef 100644 (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) {
index b03372a1c9f886eaa497aa17002cd5edbf3c65e6..7a4a1700512a6d261a7912e5bdd0ea8219d204ed 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -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;