Add some other files that weren't migrated with the project

This commit is contained in:
Cameron Gutman
2014-10-29 21:17:03 -07:00
parent d84b4bcf9a
commit 18f7bfab7f
5 changed files with 317 additions and 0 deletions

62
LuaScripts/NALParser.lua Normal file
View File

@@ -0,0 +1,62 @@
-- H264 NAL Parser
-- Version: 1.0
-- Cameron Gutman
-- NAL header
local nal_start = ProtoField.bytes("nal.start", "H264 NAL Start Sequence") -- 4 Byte Start
local nal_type = ProtoField.uint8("nal.type", "H264 NAL Type") -- 1 byte NAL type
local nal_data = ProtoField.bytes("nal.data", "H264 NAL Data") -- variable byte NAL data
p_h264raw = Proto("h264raw", "H264 Raw NAL Parser")
p_h264raw.fields = {
nal_start,
nal_type,
nal_data
}
function p_h264raw.dissector(buf, pkt, root)
pkt.cols.protocol = p_h264raw.name
subtree = root:add(p_h264raw, buf(0))
local i = 0
local data_start = -1
while i < buf:len do
-- Make sure we have a potential start sequence and type
if buf:len() - i < 5 then
-- We need more data
pkt.desegment_len = DESEGMENT_ONE_MORE_SEGMENT
pkt.desegment_offset = 0
return
end
-- Check for start sequence
start = buf(i, 4):uint()
if start == 1 then
if data_start ~= -1 then
-- End the last NAL
subtree:add(nal_data, buf(data_start, i-data_start))
end
-- This is the start of a NAL
subtree:add(nal_start, buf(i, 4))
i = i + 4
-- Next byte is NAL type
subtree:add(nal_type, buf(i, 1), buf(i, 1):uint8())
i = i + 1
-- Data begins here
data_start = i
else
-- This must be a data byte
i = i + 1
end
end
end
function p_h264raw.init()
end
local udp_dissector_table = DissectorTable.get("rtp.pt")
udp_dissector_table:add(96, p_h264raw)

View File

@@ -0,0 +1,89 @@
-- Nvidia Streaming Video Packet Dissector
-- Version: 1.0
-- Diego Waxemberg
-- video header
local nvHeader_frame = ProtoField.uint32("nv.frame", "Frame", base.HEX) -- 4 bytes
local nvHeader_pindex = ProtoField.uint16("nv.pindex", "Packet Index", base.HEX) -- 2 bytes
local nvHeader_empty = ProtoField.uint16("nv.empty", "Empty?", base.HEX) -- 2 bytes
local nvHeader_pframe = ProtoField.uint16("nv.pframe", "Packets in Frame", base.HEX) -- 2 bytes
local nvHeader_garbage = ProtoField.bytes("nv.garbage", "Garbage") -- 6 bytes
local nvHeader_length = ProtoField.uint16("nv.length", "Length", base.HEX) -- 2 bytes
local nvHeader_moregarbage = ProtoField.bytes("nv.moregarbage", "More Garbage") --23 bytes
local nvHeader_start = ProtoField.uint32("nv.start", "Start", base.HEX) -- 4 bytes
-- video data
local nvVideo_data = ProtoField.bytes("nv.data", "Data") -- rest
p_nv = Proto("nv", "Nvidia Video Stream Protocol")
p_nv.fields = {
nvHeader_frame,
nvHeader_pindex,
nvHeader_empty,
nvHeader_pframe,
nvHeader_garbage,
nvHeader_length,
nvHeader_moregarbage,
nvHeader_start,
nvVideo_data
}
function p_nv.dissector(buf, pkt, root)
pkt.cols.protocol = p_nv.name
subtree = root:add(p_nv, buf(0))
i = 0
-- frame
frame = buf(i, 4):le_uint()
subtree:add(nvHeader_frame, buf(i, 4), frame)
i = i + 4
--pindex
pindex = buf(i, 2):le_uint()
subtree:add(nvHeader_pindex, buf(i, 2), pindex)
i = i + 2
--empty
empty = buf(i, 2):le_uint()
subtree:add(nvHeader_empty, buf(i, 2), empty)
i = i + 2
--pframe
pframe = buf(i, 2):le_uint()
subtree:add(nvHeader_pframe, buf(i, 2), pframe)
i = i + 2
-- garbage
garbage = buf(i, 6):bytes()
subtree:add(nvHeader_garbage, buf(i, 6))
i = i + 6
-- length
length = buf(i, 2):le_uint()
subtree:add(nvHeader_length, buf(i, 2), length)
i = i + 2
-- moregarbage
moregarbage = buf(i, 23):bytes()
subtree:add(nvHeader_moregarbage, buf(i, 23))
i = i + 23
-- start
start = buf(i, 4):uint()
subtree:add(nvHeader_start, buf(i, 4), start)
i = i + 4
-- data
data = buf(i, buf:len()-i):bytes()
subtree:add(nvVideo_data, buf(i, buf:len()-i))
end
function p_nv.init()
end
local udp_dissector_table = DissectorTable.get("rtp.pt")
udp_dissector_table:add(96, p_nv)

86
LuaScripts/gridctl.lua Normal file
View File

@@ -0,0 +1,86 @@
local pf_type = ProtoField.uint16("gridctl.type", "Packet Type", base.HEX)
local pf_paylen = ProtoField.uint32("gridctl.paylen", "Payload Length", base.DEC)
local pf_payload = ProtoField.bytes("gridctl.payload", "Payload bytes")
local pf_payload32 = ProtoField.uint32("gridctl.payload32", "Payload as 32-bit LE integer", base.DEC)
local pf_payload16 = ProtoField.uint16("gridctl.payload16", "Payload as 16-bit LE integer", base.HEX)
local pf_response = ProtoField.uint16("gridctl.response", "Response code", base.HEX)
local pf_origtype = ProtoField.uint16("gridctl.origtype", "Original request type", base.HEX)
p_gridctl = Proto ("GridCtl", "Nvidia GRID Control Protocol")
p_gridctl.fields = {
pf_type,
pf_paylen,
pf_payload,
pf_payload16,
pf_payload32,
pf_response,
pf_origtype
}
function p_gridctl.dissector(buf, pkt, root)
pkt.cols.protocol = p_gridctl.name
subtree = root:add(p_gridctl, buf(0))
-- We can have multiple GRID control packets in one TCP datagram
i = 0
while i < buf:len() do
-- Make sure we have a full header
if buf:len() - i < 4 then
-- We need more data
pkt.desegment_len = DESEGMENT_ONE_MORE_SEGMENT
pkt.desegment_offset = 0
end
-- Read the packet type field
ptype = buf(i, 2):le_uint()
subtree:add(pf_type, buf(i, 2), ptype)
i = i + 2
-- Read the payload length field
paylen = buf(i, 2):le_uint()
subtree:add(pf_paylen, buf(i, 2), paylen)
i = i + 2
-- Make sure we have the full payload
if buf:len() - i < paylen then
-- We need more data
pkt.desegment_len = DESEGMENT_ONE_MORE_SEGMENT
pkt.desegment_offset = 0
end
-- Decode responses differently
if ptype == 0x0204 then
origtype = buf(i, 2):le_uint()
subtree:add(pf_origtype, buf(i, 2), origtype)
i = i + 2
response = buf(i, 2):le_uint()
subtree:add(pf_response, buf(i, 2), response)
i = i + 2
else
if paylen == 4 then
-- Display the payload as a uint32 (LE)
payload32 = buf(i, 4):le_uint()
subtree:add(pf_payload32, buf(i, 4), payload32)
elseif paylen == 2 then
-- Display the payload as a uint16 (LE)
payload16 = buf(i, 2):le_uint()
subtree:add(pf_payload16, buf(i, 2), payload16)
elseif paylen ~= 0 then
subtree:add(pf_payload, buf(i, paylen))
end
i = i + paylen
end
if i ~= buf:len() then
subtree:add("")
end
end
end
function p_gridctl.init()
end
local tcp_dissector_table = DissectorTable.get("tcp.port")
tcp_dissector_table:add(47995, p_gridctl)