forked from diffusiondata/wireshark-dissector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpt.utilities.lua
80 lines (69 loc) · 1.83 KB
/
dpt.utilities.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- Utilities package
-- This package provides common utilities and constants.
-- Package header
local master = diffusion or {}
if master.utilities ~= nil then
return master.utilities
end
local field_ip_dsthost = Field.new("ip.dst_host")
local field_ip_srchost = Field.new("ip.src_host")
local field_ipv6_dsthost = Field.new("ipv6.dst_host")
local field_ipv6_srchost = Field.new("ipv6.src_host")
local field_tcp_srcport = Field.new("tcp.srcport")
local field_tcp_stream = Field.new("tcp.stream")
local field_time_epoch = Field.new("frame.time_epoch")
-- Get the src host either from IPv4 or IPv6
local function f_src_host()
local ipv4SrcHost = field_ip_srchost()
if ipv4SrcHost == nil then
return field_ipv6_srchost().value
else
return ipv4SrcHost.value
end
end
-- Get the dst host either from IPv4 or IPv6
local function f_dst_host()
local ipv4DstHost = field_ip_dsthost()
if ipv4DstHost == nil then
return field_ipv6_dsthost().value
else
return ipv4DstHost.value
end
end
-- Get the src port value
local function f_src_port()
return field_tcp_srcport().value
end
-- Get the tcp stream value
local function f_tcp_stream()
return field_tcp_stream().value
end
-- Get the frame time stamp value
local function f_time_epoch()
return field_time_epoch().value
end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
-- Package footer
master.utilities = {
f_src_host = f_src_host,
f_dst_host = f_dst_host,
f_src_port = f_src_port,
dump = dump,
f_tcp_stream = f_tcp_stream,
f_time_epoch = f_time_epoch,
RD = 1,
FD = 2
}
diffusion = master
return master.utilities