summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-03-15 09:21:18 +0100
committerPeter Wu <peter@lekensteyn.nl>2017-03-15 18:44:44 +0000
commit0837dd23ec0df1446c2912f378eb9fefe3fe362d (patch)
tree8eebe4df2a6c221d2c04e4c1e5b82c5d4f87e2fb /epan
parent0156f22c62c1d955724ae44ca607c95e2944aa26 (diff)
downloadwireshark-0837dd23ec0df1446c2912f378eb9fefe3fe362d.tar.gz
Lua: Add absolute time base values
Add ABSOLUTE_TIME_* defines to the base table in init.lua for use in ProtoField.absolute_time. Change-Id: I5c99eafdac97655d71fd4f3374294cd587afaf0a Reviewed-on: https://code.wireshark.org/review/20543 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan')
-rwxr-xr-xepan/wslua/make-init-lua.pl20
-rw-r--r--epan/wslua/wslua_proto_field.c18
2 files changed, 33 insertions, 5 deletions
diff --git a/epan/wslua/make-init-lua.pl b/epan/wslua/make-init-lua.pl
index 45035e1f5c..eea8f331eb 100755
--- a/epan/wslua/make-init-lua.pl
+++ b/epan/wslua/make-init-lua.pl
@@ -227,6 +227,26 @@ while(<PROTO_H>) {
close PROTO_H;
#
+# Extract values from time_fmt.h:
+#
+# ABSOLUTE_TIME_XXX values for absolute time bases
+#
+
+my $absolute_time_num = 0;
+
+open TIME_FMT_H, "< $WSROOT/epan/time_fmt.h" or die "cannot open '$WSROOT/epan/time_fmt.h': $!";
+while(<TIME_FMT_H>) {
+ if (/^\s+ABSOLUTE_TIME_([A-Z_]+)[ ]*=[ ]*([0-9]+)[,\s]+(?:\/\* (.*?) \*\/)?/) {
+ $bases_table .= "\t[\"$1\"] = $2, -- $3\n";
+ $absolute_time_num = $2 + 1;
+ } elsif (/^\s+ABSOLUTE_TIME_([A-Z_]+)[,\s]+(?:\/\* (.*?) \*\/)?/) {
+ $bases_table .= "\t[\"$1\"] = $absolute_time_num, -- $2\n";
+ $absolute_time_num++;
+ }
+}
+close TIME_FTM_H;
+
+#
# Extract values from stat_groups.h:
#
# MENU_X_X values for register_stat_group_t
diff --git a/epan/wslua/wslua_proto_field.c b/epan/wslua/wslua_proto_field.c
index 44e0d354cc..f9738f35c8 100644
--- a/epan/wslua/wslua_proto_field.c
+++ b/epan/wslua/wslua_proto_field.c
@@ -98,6 +98,11 @@ struct field_display_string_t {
unsigned base;
};
+/*
+ * This table is primarily used to convert from string representation
+ * to int representation in string_to_base().
+ * Some string values are added for backward compatibility.
+ */
static const struct field_display_string_t base_displays[] = {
{"base.NONE", BASE_NONE},
{"base.DEC", BASE_DEC},
@@ -120,9 +125,12 @@ static const struct field_display_string_t base_displays[] = {
{"24",24},
{"32",32},
/* for FT_ABSOLUTE_TIME use values in absolute_time_display_e */
- {"LOCAL", ABSOLUTE_TIME_LOCAL},
- {"UTC", ABSOLUTE_TIME_UTC},
- {"DOY_UTC", ABSOLUTE_TIME_DOY_UTC},
+ {"base.LOCAL", ABSOLUTE_TIME_LOCAL},
+ {"base.UTC", ABSOLUTE_TIME_UTC},
+ {"base.DOY_UTC", ABSOLUTE_TIME_DOY_UTC},
+ {"LOCAL", ABSOLUTE_TIME_LOCAL}, /* for backward compatibility */
+ {"UTC", ABSOLUTE_TIME_UTC}, /* for backward compatibility */
+ {"DOY_UTC", ABSOLUTE_TIME_DOY_UTC}, /* for backward compatibility */
{NULL,0}
};
@@ -534,7 +542,7 @@ WSLUA_CONSTRUCTOR ProtoField_new(lua_State* L) {
if (base == BASE_NONE) {
base = ABSOLUTE_TIME_LOCAL; /* Default base for FT_ABSOLUTE_TIME */
} else if (base < ABSOLUTE_TIME_LOCAL || base > ABSOLUTE_TIME_DOY_UTC) {
- WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Base must be either LOCAL, UTC, or DOY_UTC");
+ WSLUA_OPTARG_ERROR(ProtoField_new,BASE,"Base must be either base.LOCAL, base.UTC, or base.DOY_UTC");
return 0;
}
if (mask) {
@@ -945,7 +953,7 @@ static int ProtoField_time(lua_State* L,enum ftenum type) {
if (type == FT_ABSOLUTE_TIME) {
if (base < ABSOLUTE_TIME_LOCAL || base > ABSOLUTE_TIME_DOY_UTC) {
- luaL_argerror(L, 3, "Base must be either LOCAL, UTC, or DOY_UTC");
+ luaL_argerror(L, 3, "Base must be either base.LOCAL, base.UTC, or base.DOY_UTC");
return 0;
}
}