forked from osmocom/wireshark
Fix lua file testsuite not working and weak heuristic readers not being registered
The testsuite for Lua file reader/writer uses the acme_file.lua script to generate a pcapng file from an Acme sipmsg.log file. It then compares the tshark verbose output of this new pcapng file to a sip.pcapng file in the test/captures directory that was previously made. Unfortunately, the acme_file.lua script generates a timestamp based on local system timezone, rather than UTC, so the testsuite fails if not run in the EST timezone where the sip.pcapng file was originally made. This has now been fixed. Also, trying to register new weak heuristic readers fails because the GArray is terminated with a NULL-based row without Glib knowing about that. So this commit changes it to let Glib handle the NULL-terminated row, so that appending takes it into account automatically. Change-Id: I037ce1cfbda03585b3a1e159df78ff8ebb41fc32 Reviewed-on: https://code.wireshark.org/review/741 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
parent
a68e3a410c
commit
c8a98f37ec
Binary file not shown.
|
@ -196,6 +196,10 @@ if DEBUG or DEBUG2 then
|
|||
end
|
||||
end
|
||||
|
||||
-- this should be done as a preference setting
|
||||
local ALWAYS_UDP = true
|
||||
|
||||
|
||||
local fh = FileHandler.new("Oracle Acme Packet logs", "acme", "A file reader for Oracle Acme Packet message logs such as sipmsg.log","rs")
|
||||
|
||||
|
||||
|
@ -323,6 +327,14 @@ end
|
|||
-- monthlist table for getting month number value from 3-char name (number is table index)
|
||||
local monthlist = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
|
||||
|
||||
-- Compute the difference in seconds between local time and UTC
|
||||
-- from http://lua-users.org/wiki/TimeZone
|
||||
local function get_timezone()
|
||||
local now = os.time()
|
||||
return os.difftime(now, os.time(os.date("!*t", now)))
|
||||
end
|
||||
local timezone = get_timezone()
|
||||
|
||||
local function get_timestamp(line, file_position, seeking)
|
||||
local i, line_pos, month, day, hour, min, sec, milli = line:find(header_time_pattern)
|
||||
if not month then
|
||||
|
@ -387,6 +399,8 @@ local function get_timestamp(line, file_position, seeking)
|
|||
dprint("timestamp conversion failed")
|
||||
end
|
||||
|
||||
timet = timet + timezone
|
||||
|
||||
-- make an NSTime
|
||||
statics.nstime = NSTime(timet, milli * 1000000)
|
||||
packets[file_position][TTIME] = statics.nstime
|
||||
|
@ -1192,6 +1206,11 @@ local function parse_header(file, line, file_position, seeking)
|
|||
ttype = UDP
|
||||
end
|
||||
|
||||
-- override above decisions based on configuration
|
||||
if ALWAYS_UDP then
|
||||
ttype = UDP
|
||||
end
|
||||
|
||||
direction = get_direction(direction)
|
||||
if direction == nil then
|
||||
dprint("parse_header: failed to convert direction")
|
||||
|
|
|
@ -64,7 +64,7 @@ local ENCAP_TYPE = wtap.UNKNOWN
|
|||
|
||||
----------------------------------------
|
||||
-- The read_open() is called by Wireshark once per file, to see if the file is this reader's type.
|
||||
-- Wireshark passes in a File object to this function
|
||||
-- Wireshark passes in (1) a File object and (2) CaptureInfo object to this function
|
||||
-- It expects in return either nil or false to mean it's not our file type, or true if it is
|
||||
-- In our case what this means is we figure out if the file has the magic header, and get the
|
||||
-- endianess of the file, and the encapsulation type of its frames/records
|
||||
|
@ -181,7 +181,7 @@ end
|
|||
|
||||
----------------------------------------
|
||||
-- ok, so let's create a FileHandler object
|
||||
local fh = FileHandler.new("Lua-based PCAP reader", "lua_pcap", "A Lua-based file reader for PCAP-type files","rs")
|
||||
local fh = FileHandler.new("Lua-based PCAP reader", "lua_pcap", "A Lua-based file reader for PCAP-type files","rms")
|
||||
|
||||
-- set above functions to the FileHandler
|
||||
fh.read_open = read_open
|
||||
|
|
|
@ -79,7 +79,7 @@ wslua_step_file_test() {
|
|||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
echo
|
||||
cat ./testin.txt
|
||||
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
||||
test_step_failed "subtest-1 exit status of $DUT: $RETURNVALUE"
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -90,7 +90,7 @@ wslua_step_file_test() {
|
|||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
||||
test_step_failed "subtest-2 exit status of $DUT: $RETURNVALUE"
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -101,7 +101,7 @@ wslua_step_file_test() {
|
|||
echo
|
||||
cat ./testin.txt
|
||||
cat ./testout.txt
|
||||
test_step_failed "reading the pcap file with Lua did not match internal"
|
||||
test_step_failed "subtest-3 reading the pcap file with Lua did not match internal"
|
||||
fi
|
||||
|
||||
# Now generate a new capture file using the Lua writer.
|
||||
|
@ -110,7 +110,7 @@ wslua_step_file_test() {
|
|||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
||||
test_step_failed "subtest-4 exit status of $DUT: $RETURNVALUE"
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -120,7 +120,7 @@ wslua_step_file_test() {
|
|||
else
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "writing the pcap out as Lua did not match dhcp.cap"
|
||||
test_step_failed "subtest-5 creating a new pcap file using Lua did not match dhcp.cap"
|
||||
fi
|
||||
|
||||
# Now read an acme sipmsg.log using the acme Lua reader, writing it out as pcapng.
|
||||
|
@ -129,7 +129,7 @@ wslua_step_file_test() {
|
|||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
||||
test_step_failed "subtest-6 exit status of $DUT: $RETURNVALUE"
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -139,7 +139,7 @@ wslua_step_file_test() {
|
|||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
||||
test_step_failed "subtest-7 exit status of $DUT: $RETURNVALUE"
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -149,7 +149,7 @@ wslua_step_file_test() {
|
|||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
echo
|
||||
cat ./testin.txt
|
||||
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
||||
test_step_failed "subtest-8 exit status of $DUT: $RETURNVALUE"
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -159,7 +159,8 @@ wslua_step_file_test() {
|
|||
else
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "writing the acme sipmsg.log out as pcapng did not match sip.pcapng"
|
||||
diff ./testout.txt ./testin.txt
|
||||
test_step_failed "subtest-9 writing the acme sipmsg.log out as pcapng did not match sip.pcapng"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -368,7 +368,6 @@ static struct open_info open_info_base[] = {
|
|||
/* Extremely weak heuristics - put them at the end. */
|
||||
{ "VWR", OPEN_INFO_HEURISTIC, vwr_open, "vwr", NULL },
|
||||
{ "Camins", OPEN_INFO_HEURISTIC, camins_open, "camins", NULL },
|
||||
{ NULL, 0, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* this is only used to build the dynamic array on load, do NOT use this
|
||||
|
@ -405,7 +404,7 @@ void init_open_routines(void) {
|
|||
|
||||
if (open_info_arr) return;
|
||||
|
||||
open_info_arr = g_array_new(FALSE,TRUE,sizeof(struct open_info));
|
||||
open_info_arr = g_array_new(TRUE,TRUE,sizeof(struct open_info));
|
||||
|
||||
g_array_append_vals(open_info_arr, open_info_base, N_OPEN_INFO_ROUTINES);
|
||||
|
||||
|
|
Loading…
Reference in New Issue