Wireshark-dev: Re: [Wireshark-dev] proto add time or string for time data on different offsets

From: Chris Maynard <chris.maynard@xxxxxxxxx>
Date: Mon, 14 Feb 2011 01:11:53 +0000 (UTC)
Ivan R. Sy <ivan_jr@...> writes:

> i have this in the data part of the packet
> 
> offset7 = secs
> offset8 = mins
> offset9 = hours
> offset10 = day
> offset11 = month
> offset12 = double digit year (in this case "11" for 2011)
> 
> My question is, is there a proto add item (something the like, or a
combination) that will transform the
> above part to a single item with the format
> 
> Month DD, 20YY HH:MM:SS

There is no proto_tree_add_item() that will directly do this for you (that I'm
aware of).  However, you could:

1) Read those values, populate a "struct tm", then make use of strftime() and
add the resulting string to the tree using proto_tree_add_string_format[_value]()

2) Construct your own value strings for month, then format your own string into
a buffer and add the resulting string to the tree using
proto_tree_add_string_format[_value]()

3) Read those values, calculating secs and nsecs for an nstime_t structure, then
call proto_tree_add_time_format[_value](), or

There might be some other alternatives.
- Chris