afs: use a simpler way to read a time field

If a time field uses a standard enconding, we can call proto_tree_add_item()
to add it to the tree. There's no need to parse the time field ourselves.

Update two places in the afs dissector where the manual parsing can
easily be replaced with a proto_tree_add_item() call.
This commit is contained in:
Martin Kaiser 2020-09-16 11:19:18 +00:00 committed by AndersBroman
parent d02ddfb9b1
commit 11adf2d019
2 changed files with 4 additions and 19 deletions

View File

@ -513,12 +513,7 @@ static void OUT_RXArray8(ptvcursor_t *cursor, int field, int field_size, int enc
nstime_t */
static void OUT_TIMESTAMP(ptvcursor_t *cursor, int field)
{
nstime_t ts;
ts.secs = tvb_get_ntohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ts.nsecs = tvb_get_ntohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)+4)*1000;
proto_tree_add_time(ptvcursor_tree(cursor), field, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 8, &ts);
proto_tree_add_item(ptvcursor_tree(cursor), field, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 8, ENC_TIME_SECS_USECS|ENC_BIG_ENDIAN);
ptvcursor_advance(cursor, 8);
}
@ -527,11 +522,7 @@ static void OUT_TIMESTAMP(ptvcursor_t *cursor, int field)
relative time in seconds */
static void OUT_TIMESECS(ptvcursor_t *cursor, int field)
{
nstime_t ts;
ts.secs = tvb_get_ntohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ts.nsecs = 0;
proto_tree_add_time(ptvcursor_tree(cursor), field, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 4, &ts);
proto_tree_add_item(ptvcursor_tree(cursor), field, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
ptvcursor_advance(cursor, 4);
}

View File

@ -1886,8 +1886,6 @@ static void file_close(int offset, gboolean request, tvbuff_t *tvb, proto_tree*
/*a function to display file attributes*/
static int get_file_attribute(packet_info* pinfo, int offset, guint8 attribute0, tvbuff_t *tvb, proto_tree* ecmp_current_tree)
{
nstime_t ts;
switch(attribute0)
{
case 0: /*display length of file*/
@ -1917,15 +1915,11 @@ static int get_file_attribute(packet_info* pinfo, int offset, guint8 attribute0,
}
break;
case 4: /*display creation date*/
ts.secs = tvb_get_ntohl(tvb, offset);
ts.nsecs = 0;
proto_tree_add_time(ecmp_current_tree, hf_ecmp_display_creation, tvb, offset, 4, &ts);
proto_tree_add_item(ecmp_current_tree, hf_ecmp_display_creation, tvb, offset, 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
offset+= 3;
break;
case 5: /*display modification date*/
ts.secs = tvb_get_ntohl(tvb, offset);
ts.nsecs = 0;
proto_tree_add_time(ecmp_current_tree, hf_ecmp_display_modification, tvb, offset, 4, &ts);
proto_tree_add_item(ecmp_current_tree, hf_ecmp_display_modification, tvb, offset, 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
offset+= 3;
break;
default: /*display incorrect attribute type error*/