Wireshark dissector for Pro DJ Link protocol
3
fork

Configure Feed

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

use wireshark's native utf16-to-utf8

Stella fd7d39d5 84dd0c30

+10 -28
+10 -28
pro_dj_link.lua
··· 185 185 [0x002e] = "DateAdded", 186 186 } 187 187 188 - -- Simple UTF-16BE to UTF-8 conversion (ASCII only) 189 - function utf16_to_utf8(buf) 190 - local out = "" 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) 203 - else 204 - out = out .. "?" 205 - end 206 - end 207 - return out 208 - end 209 - 210 188 -- Label for specific arguments based on message type 211 189 function get_arg_label(msg_type, arg_idx, val) 212 190 -- Many request types have DMST as the first argument ··· 312 290 local chars = buf(offset+1, 4):uint() 313 291 local byte_len = chars * 2 314 292 if len - offset >= 5 + byte_len then 315 - local str = utf16_to_utf8(buf(offset+5, byte_len)) 293 + -- Use Wireshark's native UTF-16BE decoding 294 + local enc = (ENC_UTF_16 or 2) + (ENC_BIG_ENDIAN or 0) 295 + local str = buf(offset+5, byte_len):string(enc) 296 + -- Strip trailing nulls to clean up UI display 297 + str = str:gsub("%z", "") 298 + 316 299 -- Use f_db_field_bin for the highlight range to avoid "trailing stray chars" warning 317 300 -- caused by Wireshark's internal string dissector seeing high-byte nulls. 318 301 tree:add(f_db_field_bin, buf(offset+5, byte_len)):set_text(prefix .. ": \"" .. str .. "\"") ··· 331 314 -- ============================================================================ 332 315 function p_djl.dissector(buf, pkt, root) 333 316 local length = buf:len() 317 + local src_port = pkt.src_port 318 + local dst_port = pkt.dst_port 334 319 335 320 -- TCP DB Port Discovery Response 336 - if (pkt.src_port == 12523 or pkt.dst_port == 12523) and length == 2 then 321 + if (src_port == 12523 or dst_port == 12523) and length == 2 then 337 322 local tree = root:add(p_djl, buf(0, 2)) 338 323 pkt.cols.protocol = "PDJL (DB Port)" 339 324 tree:add(f_db_port, buf(0, 2)) ··· 415 400 msg_tree:set_len(current - off) 416 401 off = current 417 402 else 418 - if off == 0 and length == 5 and buf(0, 5):uint() == 0x1100000001 then 403 + if off == 0 and length == 5 and buf(0, 1):uint() == 0x11 and buf(1, 4):uint() == 0x00000001 then 419 404 pkt.cols.protocol = "PDJL (DB)" 420 405 pkt.cols.info:set("DB: Greeting") 421 406 root:add(p_djl, buf(0, 5)):append_text(": Greeting (0x00000001)") ··· 458 443 end 459 444 460 445 pkt.cols.info:fence() 461 - 462 - local src_port = pkt.src_port 463 - local dst_port = pkt.dst_port 464 446 465 447 if dst_port == 50000 or src_port == 50000 then 466 448 tree:add(f_device_name, buf(0x0C, 20))