Index: epan/proto.h =================================================================== --- epan/proto.h (revision 39201) +++ epan/proto.h (working copy) @@ -205,13 +205,26 @@ * Currently, proto_tree_add_item() treats its last argument as a * Boolean - if it's zero, the field is big-endian, and if it's non-zero, * the field is little-endian - and other code in epan/proto.c does - * the same. We therefore define ENC_BIG_ENDIAN as 0x00000000 and - * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit - * so that we could put a field type and/or a value such as a character - * encoding in the lower bits. + * the same. We therefore define the encoding argument as follows: + * + * 32 31 - 2 1 + * +---+--------//--------+---+ + * |EA | CHAR ENCODING | E | + * +---+--------//--------+---+ + * + * EA = Endian Applicability bit + * 1 = Endian bit is NOT applicable + * 0 = Endian bit IS applicable + * CHAR ENCODING = Character encoding as follows: + * 0x00000000 = UTF-8 or ASCII + * 0x0EBCD1C0 = EBCDIC + * E = Endian bit: + * 0 = Big Endian + * 1 = Little Endian */ -#define ENC_BIG_ENDIAN 0x00000000 -#define ENC_LITTLE_ENDIAN 0x80000000 +#define ENC_ENDIAN_APPLICABILITY_MASK 0x80000000 +#define ENC_ENDIAN_APPLICABLE 0x00000000 +#define ENC_ENDIAN_NOT_APPLICABLE 0x80000000 /* * Historically FT_TIMEs were only timespecs; the only question was whether @@ -255,6 +268,12 @@ #define ENC_ASCII 0x00000000 #define ENC_EBCDIC 0x0EBCD1C0 +/* The 'E' bit: */ +#define ENC_ENDIAN_MASK 0x00000001 +#define ENC_LITTLE_ENDIAN TRUE +#define ENC_BIG_ENDIAN FALSE + + /* * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE), * opaque byte-array fields (FT_BYTES), and other fields where there @@ -262,7 +281,7 @@ * of bytes" or because the encoding is completely fixed), we * have ENC_NA (for "Not Applicable"). */ -#define ENC_NA 0x00000000 +#define ENC_NA (ENC_ENDIAN_NOT_APPLICABLE|ENC_UTF_8|ENC_BIG_ENDIAN) /* Values for header_field_info.display */ Index: epan/proto.c =================================================================== --- epan/proto.c (revision 39201) +++ epan/proto.c (working copy) @@ -1260,6 +1260,12 @@ break; case FT_BYTES: + if ((encoding_arg & ENC_ENDIAN_APPLICABILITY_MASK) == ENC_ENDIAN_APPLICABLE) { + /* TODO: Issue some sort of warning, expert_info(), ...? + * g_warning("Endian not applicable for type %d.\n", + * new_fi->hfinfo->type); */ + } + encoding = encoding_arg & ENC_ENDIAN_MASK; proto_tree_set_bytes_tvb(new_fi, tvb, start, length); break; @@ -1294,12 +1300,12 @@ case FT_UINT16: case FT_UINT24: case FT_UINT32: - /* - * Map all non-zero values to little-endian for - * backwards compatibility. - */ - if (encoding) - encoding = ENC_LITTLE_ENDIAN; + if ((encoding_arg & ENC_ENDIAN_APPLICABILITY_MASK) == ENC_ENDIAN_NOT_APPLICABLE) { + /* TODO: Issue some sort of warning, expert_info(), ...? + * g_warning("Endian marked as not applicable for type %d.\n", + * new_fi->hfinfo->type); */; + } + encoding = encoding_arg & ENC_ENDIAN_MASK; proto_tree_set_uint(new_fi, get_uint_value(tvb, start, length, encoding)); break; @@ -1695,7 +1701,7 @@ DISSECTOR_ASSERT_NOT_REACHED(); break; } - FI_SET_FLAG(new_fi, (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN); + FI_SET_FLAG(new_fi, (encoding & ENC_ENDIAN_MASK) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN); /* Don't add new node to proto_tree until now so that any exceptions * raised by a tvbuff access method doesn't leave junk in the proto_tree. */