Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions mqtt/protocol5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -980,24 +980,31 @@ local function parse_packet_puback(ptype, flags, input)
return false, packet_type[ptype]..": unexpected flags value: "..flags
end
local read_data = input.read_func

-- DOC: 3.4.2 PUBACK Variable Header
-- Bytes 1 & 2: Packet Identifier
local packet_id, err = parse_uint16(read_data)
if not packet_id then
return false, packet_type[ptype]..": failed to parse packet_id: "..err
end
local packet = setmetatable({type=ptype, packet_id=packet_id, rc=0, properties={}, user_properties={}}, packet_mt)
-- If Remaining Length > 2, we have at least a Reason Code
if input.available > 0 then
-- DOC: 3.4.2.1 PUBACK Reason Code
-- DOC: 3.4.2.1 PUBACK Reason Code (Byte 3)
local rc, ok
rc, err = parse_uint8(read_data)
if not rc then
return false, packet_type[ptype]..": failed to parse rc: "..err
end
packet.rc = rc
-- DOC: 3.4.2.2 PUBACK Properties
ok, err = parse_properties(ptype, read_data, input, packet)
if not ok then
return false, packet_type[ptype]..": failed to parse packet properties: "..err

-- DOC: 3.4.2.2.1 If Remaining Length > 3, we have a Property Length field (Byte 4)
if input.available > 0 then
-- DOC: 3.4.2.2 PUBACK Properties
ok, err = parse_properties(ptype, read_data, input, packet)
if not ok then
return false, packet_type[ptype]..": failed to parse packet properties: "..err
end
end
end
return packet
Expand Down
Loading