--create nsdp protocol and its fields p_nsdp = Proto ("nsdp","Netgear Switch Description Protocol") -- local f_source = ProtoField.uint16("nsdp.src", "Source", base.HEX) local f_type = ProtoField.uint16("nsdp.type", "Type", base.HEX,{ [0x101]="Query Data", [0x102]="Data Response", [0x103]="Change Request", [0x104]="Change Response" }) local f_source = ProtoField.ether("nsdp.src", "Source", base.HEX) local f_destination = ProtoField.ether("nsdp.dst", "Destination", base.HEX) p_nsdp.fields = {f_type,f_source} -- nsdp dissector function function p_nsdp.dissector (buf, pkt, root) -- validate packet length is adequate, otherwise quit if buf:len() == 0 then return end pkt.cols.protocol = p_nsdp.name -- create subtree for nsdp subtree = root:add(p_nsdp, buf(0)) local offset = 0 local ptype = buf(offset,2):uint() if ptype == 0x0104 then if buf:len() == offset then subtree:append_text(", password changed") else subtree:append_text(", logged in") end end subtree:add(f_type, buf(offset,2)) offset = offset + 8 subtree:add(f_source, buf(offset,6)) end function p_nsdp.init() -- init end local tcp_dissector_table = DissectorTable.get("udp.port") dissector = tcp_dissector_table:get_dissector(63321) tcp_dissector_table:add(63321, p_nsdp) local tcp_dissector_table = DissectorTable.get("udp.port") dissector = tcp_dissector_table:get_dissector(63322) tcp_dissector_table:add(63322, p_nsdp)