local p_edimax=Proto("edimax","EdiMax"); local f_xmltext=ProtoField.string("edimax.xmltext", "Text") local f_keepalive=ProtoField.string("edimax.keepalive", "Keepalive") local f_pnvdatalen=ProtoField.string("edimax.pnvdatalen", "Data Length") p_edimax.fields={f_xmltext, f_keepalive, f_pnvdatalen} local data_dis=Dissector.get("data"); function p_edimax.dissector(buf, pkt, root) local t=root:add(p_edimax, buf(0)) local firstbyte=buf(0,1):uint() if (firstbyte == 0x22) then t:add(f_keepalive, buf(0, 4)) else local codestart=0 if (buf(0, 12):string() == "PnvDataLen: ") then codestart=12; while (codestart < buf:len() and buf(codestart, 1):uint() >= 0x30 and buf(codestart, 1):uint() <= 0x39) do codestart=codestart+1 end codestart = codestart + 4 -- skip \r\n\r\n t:add(f_pnvdatalen, buf(0, codestart)) end if (codestart < buf:len()) then firstbyte=buf(codestart, 1):uint() local rotor=firstbyte-0x3c local decoded='<' for i=codestart+1, buf:len()-1 do local byte=buf(i, 1):uint() local rot=bit.lshift(bit.band(byte, 0xff),rotor) local realchar=bit.bor( bit.band(rot, 0xff), bit.rshift(bit.band(rot,0xff00), 8)) if realchar == 0x3c and decoded:len()>1 then t:add(f_xmltext, decoded) decoded="" end decoded = decoded .. string.char(realchar) if realchar == 10 then t:add(f_xmltext, decoded) decoded="" end end if decoded ~= "" then t:add(f_xmltext, decoded) end end end end local udp_encap_table=DissectorTable.get("udp.port"); local tcp_encap_table=DissectorTable.get("tcp.port"); udp_encap_table:add(8765, p_edimax) tcp_encap_table:add(8767, p_edimax)