|
| 1 | +-- Wireshark dissector for labstreamerlayer stream discovery packets |
| 2 | +-- Place this file in $WIRESHARK_CONFIG_DIR/plugins/lsl.lua |
| 3 | +-- (C) 2020 Tristan Stenner |
| 4 | +do |
| 5 | + local lsl_proto = Proto("lsldiscovery", "Labstreaminglayer Discovery") |
| 6 | + -- source fields |
| 7 | + local udp_src_f = Field.new("udp.srcport") |
| 8 | + local udp_dst_f = Field.new("udp.dstport") |
| 9 | + -- fields to be shown in the packet analysis pane |
| 10 | + local cmd_F = ProtoField.string("lsl.cmd", "Command") |
| 11 | + local dst_F = ProtoField.string("lsl.dst", "Destination") |
| 12 | + local query_F = ProtoField.string("lsl.query", "QueryID", "QueryID") |
| 13 | + local content_F = ProtoField.string("lsl.content", "Content", "Content") |
| 14 | + local streaminfo_F = ProtoField.string("lsl.streaminfo", "Streaminfo", "Streaminfo") |
| 15 | + local ansport_F = ProtoField.string('lsl.answerport', 'Answer port', 'Answer port') |
| 16 | + |
| 17 | + lsl_proto.fields = {cmd_F, dst_F, query_F, ansport_F, streaminfo_F, content_F} |
| 18 | + |
| 19 | + function lsl_proto.dissector(buffer, pinfo, tree) |
| 20 | + if udp_dst_f().value == 16571 then |
| 21 | + if buffer(0, 4):string()~='LSL:' then |
| 22 | + return |
| 23 | + end |
| 24 | + local subtree = tree:add(lsl_proto, buffer) |
| 25 | + |
| 26 | + local data = buffer():string() |
| 27 | + local newlinepos = data:find('\r\n') |
| 28 | + if newlinepos == nil then |
| 29 | + return |
| 30 | + end |
| 31 | + subtree:add(cmd_F, buffer(0, newlinepos-1)) |
| 32 | + buffer = buffer(newlinepos + 1) |
| 33 | + newlinepos = buffer():string():find('\r\n', newlinepos+1, true) |
| 34 | + if newlinepos == nil then |
| 35 | + return |
| 36 | + end |
| 37 | + subtree:add(content_F, buffer(0, newlinepos-1)) |
| 38 | + buffer = buffer(newlinepos + 1) |
| 39 | + local wspos = buffer():string():find(' ') |
| 40 | + subtree:add(ansport_F, buffer(0, wspos-1)) |
| 41 | + subtree:add(query_F, buffer(wspos)) |
| 42 | + elseif udp_src_f().value == 16571 then |
| 43 | + local subtree = tree:add(lsl_proto, buffer) |
| 44 | + subtree:add(cmd_F, 'shortinfo reply') |
| 45 | + |
| 46 | + local data = buffer():string() |
| 47 | + local newlinepos = data:find('\r\n') |
| 48 | + if newlinepos == nil then |
| 49 | + return |
| 50 | + end |
| 51 | + subtree:add(query_F, buffer(0, newlinepos-1)) |
| 52 | + buffer = buffer(newlinepos + 1) |
| 53 | + subtree:add(streaminfo_F, buffer(newlinepos+1)) |
| 54 | + end |
| 55 | + end |
| 56 | + DissectorTable.get('udp.port'):add(16571, lsl_proto) |
| 57 | +end |
0 commit comments