Wireshark dissector for Pro DJ Link protocol
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix utf-16 padded str parsing

Stella 84dd0c30 035774a3

+19 -8
+19 -8
pro_dj_link.lua
··· 188 188 -- Simple UTF-16BE to UTF-8 conversion (ASCII only) 189 189 function utf16_to_utf8(buf) 190 190 local out = "" 191 - for i = 0, buf:len()-1, 2 do 192 - local c = buf(i+1, 1):uint() 193 - if c == 0 then break end 194 - if c < 128 then 195 - out = out .. string.char(c) 191 + local len = buf:len() 192 + for i = 0, len - 2, 2 do 193 + -- Pioneer DB strings are UTF-16BE. High byte first. 194 + local hi = buf(i, 1):uint() 195 + local lo = buf(i+1, 1):uint() 196 + 197 + -- Stop at first null character pair 198 + if hi == 0 and lo == 0 then break end 199 + 200 + -- Basic ASCII conversion 201 + if hi == 0 and lo < 128 then 202 + out = out .. string.char(lo) 196 203 else 197 204 out = out .. "?" 198 205 end ··· 218 225 [7] = "Item Type", 219 226 [8] = "Flags", 220 227 [9] = "Artwork ID", 221 - [10] = "Position" 228 + [10] = "Position", 229 + [11] = "Unknown", 230 + [12] = "Unknown" 222 231 } 223 232 return labels[arg_idx] 224 233 elseif msg_type == 0x4201 then -- MenuFooter ··· 304 313 local byte_len = chars * 2 305 314 if len - offset >= 5 + byte_len then 306 315 local str = utf16_to_utf8(buf(offset+5, byte_len)) 307 - tree:add(f_db_field_str, buf(offset+5, byte_len)):set_text(prefix .. ": \"" .. str .. "\"") 316 + -- Use f_db_field_bin for the highlight range to avoid "trailing stray chars" warning 317 + -- caused by Wireshark's internal string dissector seeing high-byte nulls. 318 + tree:add(f_db_field_bin, buf(offset+5, byte_len)):set_text(prefix .. ": \"" .. str .. "\"") 308 319 bytes_consumed = 5 + byte_len 309 320 else 310 321 bytes_consumed = len - offset ··· 323 334 324 335 -- TCP DB Port Discovery Response 325 336 if (pkt.src_port == 12523 or pkt.dst_port == 12523) and length == 2 then 326 - 327 337 local tree = root:add(p_djl, buf(0, 2)) 328 338 pkt.cols.protocol = "PDJL (DB Port)" 329 339 tree:add(f_db_port, buf(0, 2)) 330 340 return 331 341 end 342 + 332 343 333 344 334 345 if length < 5 then return end