···185185 [0x002e] = "DateAdded",
186186}
187187188188--- Simple UTF-16BE to UTF-8 conversion (ASCII only)
189189-function utf16_to_utf8(buf)
190190- local out = ""
191191- local len = buf:len()
192192- for i = 0, len - 2, 2 do
193193- -- Pioneer DB strings are UTF-16BE. High byte first.
194194- local hi = buf(i, 1):uint()
195195- local lo = buf(i+1, 1):uint()
196196-197197- -- Stop at first null character pair
198198- if hi == 0 and lo == 0 then break end
199199-200200- -- Basic ASCII conversion
201201- if hi == 0 and lo < 128 then
202202- out = out .. string.char(lo)
203203- else
204204- out = out .. "?"
205205- end
206206- end
207207- return out
208208-end
209209-210188-- Label for specific arguments based on message type
211189function get_arg_label(msg_type, arg_idx, val)
212190 -- Many request types have DMST as the first argument
···312290 local chars = buf(offset+1, 4):uint()
313291 local byte_len = chars * 2
314292 if len - offset >= 5 + byte_len then
315315- local str = utf16_to_utf8(buf(offset+5, byte_len))
293293+ -- Use Wireshark's native UTF-16BE decoding
294294+ local enc = (ENC_UTF_16 or 2) + (ENC_BIG_ENDIAN or 0)
295295+ local str = buf(offset+5, byte_len):string(enc)
296296+ -- Strip trailing nulls to clean up UI display
297297+ str = str:gsub("%z", "")
298298+316299 -- Use f_db_field_bin for the highlight range to avoid "trailing stray chars" warning
317300 -- caused by Wireshark's internal string dissector seeing high-byte nulls.
318301 tree:add(f_db_field_bin, buf(offset+5, byte_len)):set_text(prefix .. ": \"" .. str .. "\"")
···331314-- ============================================================================
332315function p_djl.dissector(buf, pkt, root)
333316 local length = buf:len()
317317+ local src_port = pkt.src_port
318318+ local dst_port = pkt.dst_port
334319335320 -- TCP DB Port Discovery Response
336336- if (pkt.src_port == 12523 or pkt.dst_port == 12523) and length == 2 then
321321+ if (src_port == 12523 or dst_port == 12523) and length == 2 then
337322 local tree = root:add(p_djl, buf(0, 2))
338323 pkt.cols.protocol = "PDJL (DB Port)"
339324 tree:add(f_db_port, buf(0, 2))
···415400 msg_tree:set_len(current - off)
416401 off = current
417402 else
418418- if off == 0 and length == 5 and buf(0, 5):uint() == 0x1100000001 then
403403+ if off == 0 and length == 5 and buf(0, 1):uint() == 0x11 and buf(1, 4):uint() == 0x00000001 then
419404 pkt.cols.protocol = "PDJL (DB)"
420405 pkt.cols.info:set("DB: Greeting")
421406 root:add(p_djl, buf(0, 5)):append_text(": Greeting (0x00000001)")
···458443 end
459444460445 pkt.cols.info:fence()
461461-462462- local src_port = pkt.src_port
463463- local dst_port = pkt.dst_port
464446465447 if dst_port == 50000 or src_port == 50000 then
466448 tree:add(f_device_name, buf(0x0C, 20))