Lua tshark class and examples

This commit is contained in:
Luca Deri
2021-04-25 11:40:53 +02:00
parent 0ef7998348
commit b586c223dd
4 changed files with 974 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env lua
--
-- (C) 2021 - ntop.org
--
package.path = "lib/?.lua;" .. package.path
local tshark = require "tshark"
local pcap_file = "../../tests/pcap/tor.pcap"
local t = tshark:open(pcap_file, "tcp")
if(t == nil) then
io.write("Unable to read pcap file "..pcap_file.."\n")
exit()
end
local num_tcp = 0
while(true) do
local l = t:read()
if(l == nil) then break end
io.write(".")
io.flush()
num_tcp = num_tcp + 1
end
t:close()
io.write("\nFound "..num_tcp.." TCP packets on pcap "..pcap_file.."\n")