Wireshark-dev: Re: [Wireshark-dev] Wireshark-dev Digest, Vol 207, Issue 3
Here is a sample from my implementation.
proto.c snippets
>Message: 1
>Date: Mon, 14 Aug 2023 15:22:01 +0000
>From: John Dill <John.Dill@xxxxxxxxxxxxxxxxx>
>To: "wireshark-dev@xxxxxxxxxxxxx" <wireshark-dev@xxxxxxxxxxxxx>
>Subject: [Wireshark-dev] add a BASE_DEFAULT_VALS
>Message-ID: <7842e9e621b04ca6a8749b5286f2d91a@xxxxxxxxxxxxxxxxx>
>Content-Type: text/plain; charset="iso-8859-1"
>
>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: Tuesday, August 15, 2023 8:00:01 AM
To: wireshark-dev@xxxxxxxxxxxxx
Subject: Wireshark-dev Digest, Vol 207, Issue 3
wireshark-dev@xxxxxxxxxxxxx
To subscribe or unsubscribe via the World Wide Web, visit
https://www.wireshark.org/mailman/listinfo/wireshark-dev
or, via email, send a message with subject or body 'help' to
wireshark-dev-request@xxxxxxxxxxxxx
You can reach the person managing the list at
wireshark-dev-owner@xxxxxxxxxxxxx
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Wireshark-dev digest..."
Today's Topics:
1. add a BASE_DEFAULT_VALS (John Dill)
----------------------------------------------------------------------
Message: 1
Date: Mon, 14 Aug 2023 15:22:01 +0000
From: John Dill <John.Dill@xxxxxxxxxxxxxxxxx>
To: "wireshark-dev@xxxxxxxxxxxxx" <wireshark-dev@xxxxxxxxxxxxx>
Subject: [Wireshark-dev] add a BASE_DEFAULT_VALS
Message-ID: <7842e9e621b04ca6a8749b5286f2d91a@xxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset="iso-8859-1"
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.wireshark.org/lists/wireshark-dev/attachments/20230814/6339cb57/attachment.htm>
------------------------------
Subject: Digest Footer
_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
https://www.wireshark.org/mailman/listinfo/wireshark-dev
------------------------------
End of Wireshark-dev Digest, Vol 207, Issue 3
*********************************************
- Prev by Date: [Wireshark-dev] add a BASE_DEFAULT_VALS
- Next by Date: [Wireshark-dev] Timestamp from icmp data is incorrect in Wireshark v4.0.7-0-g0ad1823cc090
- Previous by thread: Re: [Wireshark-dev] add a BASE_DEFAULT_VALS
- Next by thread: [Wireshark-dev] Timestamp from icmp data is incorrect in Wireshark v4.0.7-0-g0ad1823cc090
- Index(es):