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>
This commit is contained in:
parent
0156f22c62
commit
0837dd23ec
|
@ -226,6 +226,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:
|
||||
#
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ local testfield =
|
|||
OID = ProtoField.oid ("test.basic.oid", "Basic OID"),
|
||||
REL_OID = ProtoField.rel_oid("test.basic.rel_oid", "Basic Relative OID"),
|
||||
ABSOLUTE_LOCAL = ProtoField.absolute_time("test.basic.absolute.local","Basic absolute local"),
|
||||
ABSOLUTE_UTC = ProtoField.absolute_time("test.basic.absolute.utc", "Basic absolute utc", 1001),
|
||||
ABSOLUTE_UTC = ProtoField.absolute_time("test.basic.absolute.utc", "Basic absolute utc", base.UTC),
|
||||
IPv4 = ProtoField.ipv4 ("test.basic.ipv4", "Basic ipv4 address"),
|
||||
IPv6 = ProtoField.ipv6 ("test.basic.ipv6", "Basic ipv6 address"),
|
||||
-- GUID = ProtoField.guid ("test.basic.guid", "Basic GUID"),
|
||||
|
@ -164,7 +164,7 @@ local testfield =
|
|||
time =
|
||||
{
|
||||
ABSOLUTE_LOCAL = ProtoField.absolute_time("test.time.absolute.local","Time absolute local"),
|
||||
ABSOLUTE_UTC = ProtoField.absolute_time("test.time.absolute.utc", "Time absolute utc", 1001),
|
||||
ABSOLUTE_UTC = ProtoField.absolute_time("test.time.absolute.utc", "Time absolute utc", base.UTC),
|
||||
},
|
||||
|
||||
bytes =
|
||||
|
|
Loading…
Reference in New Issue