I've recently been doing a lot of enums that have multiple illegal values, and 
the illegal value shouldn't be displayed as "Unknown" as it's hard coded in 
proto.c (in 3.6.x).


Any chance you could go for an attribute to signal that -1 can be used as the 
name of the fall-through text if defined?


Looks like it would be mostly proto that gets updated.


#define BASE_DEFAULT_VALS         0x00040000  /**< field will use -1 value 
instead of "Unknown" if value_string match is not found */

static const value_string Port_Test_Control_enum_vals[] =
{
  { -1, "Disable Manual Port Test Control" },
  { 0x5A, "Enable Manual Port Test Control" },
  { 0, NULL }
};


Here's a hf definition


    {
      &hf_Port_Test_Control_Enable,
      {
        "Port Test Control Enable",
        "mil_1553.Port_Test_Control_Enable",
        FT_UINT16,
        BASE_HEX | BASE_DEFAULT_VALS,
        VALS(Port_Test_Control_Enable_enum_vals),
        0x00FF,
        "This byte is always set to 0x00 when not in debug mode.  Only special 
debug functions may set this byte to 0x5A.",
        HFILL
      }
    },

Most of the time, my enum fields don't use -1 as a valid value, so UINT32(-1) 
should be pretty feasible.


There are _idx functions in value_string, so may be able to rig something 
there.  I have made my own version of it but I'm sure someone more experienced 
can do it the "right" way in the code base.


Just an idea.  I'm still on 3.6 so I haven't checked if a similar feature is in 
4.0.


Thanks,

John D.

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Reply via email to