do
--123用于过滤。DoIP protocol用于显示tree的协议名称
local wgm1 = Proto("12345","protocol") --定义协议名称
---获取端口号关键函数1
udp_dst_f = Field.new("udp.dstport")
udp_src_f = Field.new("udp.srcport")
function wgm1.dissector(TVB,pinfo,tree)
--TVB代表每一帧所有数据,pinfo代表一个log内所有帧,tree代表每一帧所有的>^折叠和展开箭头 。但是由于咱们绑定的是UDP和TCP以下,所以TVB指的是data部分
--cols代表所有pinfo帧的某一帧,,其proctocol 指的是协议,它可以是length、或者source
local DoIP_type = TVB(2,3):uint()
---获取目的地端口号关键函数2
local huoquport = udp_dst_f()
---获取发送的端口号关键函数
local huoquportsrc = udp_src_f()
---对获取端口号做判断
if (tostring(huoquport) == "13400") then
if (DoIP_type==0x0001) then
pinfo.cols.protocol = "Tester发现车辆请求报文"
end
if(DoIP_type~=0x0001) then
pinfo.cols.protocol = "GW的UDP广播报文"
end
end
---如果原端口等于13400且资源端口不等于13400
if ((tostring(huoquportsrc) == "13400") and (tostring(huoquport) ~= "13400") ) then
pinfo.cols.protocol = "GW回应tester车辆存在"
end
end
-- pinfo.cols.protocol = "GW的UDP广播报文"
--
--- end
-- trivial postdissector example
-- declare some Fields to be read
--ip_src_f = Field.new("ip.src")
--ip_dst_f = Field.new("ip.dst")
--tcp_src_f = Field.new("tcp.srcport")
--tcp_dst_f = Field.new("tcp.dstport")
----udp_dst_f = Field.new("udp.dstport")
local udp_encap_table = DissectorTable.get("udp.port")
--因为我们的DT协议的接受端口肯定是50002,所以这里只需要添加到"udp.port"这个DissectorTable里,并且指定值为50002即可。
--udp_encap_table("udp.dstport")
udp_encap_table:add(13400, wgm1)
end
wireshark插件编写以太网DOIP-Ⅱ
最新推荐文章于 2024-02-02 13:13:20 发布