forked from diffusiondata/wireshark-dissector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdpt.info.lua
112 lines (94 loc) · 2.91 KB
/
dpt.info.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
-- Info package
-- This package provides information tables that are built up and maintained over the course of the dissection.
-- Package header
local master = diffusion or {}
if master.info ~= nil then
return master.info
end
-- -----------------------------------
-- The Alias Table
local AliasTable = {}
function AliasTable:new()
local result = {}
setmetatable( result, self )
self.__index = self
return result
end
function AliasTable:setAlias( tcpStream, alias, topicName )
-- Get the table for the tcpStream, or create a new one
local conversation = self[tcpStream] or {}
conversation[alias] = topicName
self[tcpStream] = conversation
end
function AliasTable:getAlias( tcpStream, alias )
local conversation = self[tcpStream]
if conversation == nil then
return nil
end
return conversation[alias]
end
local aliasTable = AliasTable:new()
local topicIdTable = AliasTable:new()
-- ------------------------------------
-- The EndpointTable Table
local EndpointTable = {}
function EndpointTable:new()
local result = {}
setmetatable( result, self )
self.__index = self
return result
end
function EndpointTable:add( host, port, server )
local machine = self[host] or {}
machine[port] = server
self[host] = machine
end
function EndpointTable:get( host, port )
return self[host][port]
end
local clientTable = EndpointTable:new()
local serverTable = EndpointTable:new()
-- -----------------------------------
-- Create and register a listener for TCP connections
local tcpConnections = {}
function tcpConnections:len()
local result = 0
local i,v
for i,v in pairs( self ) do result = result +1 end
return result
end
-- -----------------------------------
-- Stores information about specific service requests
local ServiceMessageTable = {}
function ServiceMessageTable:new()
local result = {}
setmetatable( result, self )
self.__index = self
return result
end
-- Add information about a service request
function ServiceMessageTable:addRequest( tcpStream, requestSrc, conversation, time )
local serviceConversationStream = self[tcpStream] or {}
local serviceConversation = serviceConversationStream[requestSrc] or {}
serviceConversation[conversation] = {}
serviceConversation[conversation].time = time
serviceConversationStream[requestSrc] = serviceConversation
self[tcpStream] = serviceConversationStream
end
-- Get the time of a service request
function ServiceMessageTable:getRequestTime( tcpStream, requestSrc, conversation )
local res = self[tcpStream][requestSrc][conversation]
return res.time
end
local serviceMessageTable = ServiceMessageTable:new()
-- Package footer
master.info = {
aliasTable = aliasTable,
tcpConnections = tcpConnections,
topicIdTable = topicIdTable,
clientTable = clientTable,
serverTable = serverTable,
serviceMessageTable = serviceMessageTable
}
diffusion = master
return master.info