aboutsummaryrefslogtreecommitdiffstats
path: root/epan/to_str.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2019-08-28 15:04:32 -0400
committerAnders Broman <a.broman58@gmail.com>2019-08-29 13:31:48 +0000
commit01d7793976cca50519c6609dc2a4ba391946f07b (patch)
treebbe7e8a2c863904dcac33459226b24882e7828f1 /epan/to_str.c
parent862e2acdd94ca38e9310f4ec9509a1108346f2bc (diff)
Add proto_tree_add_item_ret_time_string
A few dissectors need the functionality of adding a time field to a proto_tree while also needing the "time to string" value (typically to show on a tree above). The functionality to do "get value from tvb and convert to string" was being done in packet-ntp.c. Instead proto_tree_add_item_ret_time_string can be used with various encoding to get the necessary functionality with less code duplication. ENC_TIME_MIP6 was added as a result of the refactoring. ABSOLUTE_TIME_NTP_UTC was added as another potential "base" type for time fields. Change-Id: Ie460c33370b0af59ef60bdab893ce9d6eb23b94f Reviewed-on: https://code.wireshark.org/review/34390 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/to_str.c')
-rw-r--r--epan/to_str.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/epan/to_str.c b/epan/to_str.c
index 62841b4273..fd37f8c6bb 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -439,6 +439,7 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut
case ABSOLUTE_TIME_UTC:
case ABSOLUTE_TIME_DOY_UTC:
+ case ABSOLUTE_TIME_NTP_UTC:
tmp = gmtime(&abs_time->secs);
zonename = "UTC";
break;
@@ -475,6 +476,12 @@ abs_time_to_str(wmem_allocator_t *scope, const nstime_t *abs_time, const absolut
(long)abs_time->nsecs);
}
break;
+ case ABSOLUTE_TIME_NTP_UTC:
+ if ((abs_time->secs == 0) && (abs_time->nsecs == 0)) {
+ buf = wmem_strdup(scope, "NULL");
+ break;
+ }
+ /* FALLTHROUGH */
case ABSOLUTE_TIME_UTC:
case ABSOLUTE_TIME_LOCAL:
@@ -519,6 +526,7 @@ abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absol
case ABSOLUTE_TIME_UTC:
case ABSOLUTE_TIME_DOY_UTC:
+ case ABSOLUTE_TIME_NTP_UTC:
tmp = gmtime(&abs_time);
zonename = "UTC";
break;
@@ -554,6 +562,12 @@ abs_time_secs_to_str(wmem_allocator_t *scope, const time_t abs_time, const absol
}
break;
+ case ABSOLUTE_TIME_NTP_UTC:
+ if (abs_time == 0) {
+ buf = wmem_strdup(scope, "NULL");
+ break;
+ }
+ /* FALLTHROUGH */
case ABSOLUTE_TIME_UTC:
case ABSOLUTE_TIME_LOCAL:
if (show_zone) {