-- This file is generated by tools/json2lua.js

local enum = require('ffxiv_enum')
local ffxiv_ipc_container_info = Proto("ffxiv_ipc_container_info", "FFXIV-IPC Container Info")

local container_info_fields = {
  container_sequence = ProtoField.uint32("ffxiv_ipc_container_info.container_sequence", "containerSequence", base.DEC),
  num_items          = ProtoField.uint32("ffxiv_ipc_container_info.num_items", "numItems", base.DEC),
  container_id       = ProtoField.uint32("ffxiv_ipc_container_info.container_id", "containerId", base.DEC, enum.reverse.item_location),
  unknown            = ProtoField.uint32("ffxiv_ipc_container_info.unknown", "unknown", base.DEC),
}

ffxiv_ipc_container_info.fields = container_info_fields

function ffxiv_ipc_container_info.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_container_info, tvbuf)
  pktinfo.cols.info:set("Container Info")

  local len = tvbuf:len()

  -- dissect the container_sequence field
  local container_sequence_tvbr = tvbuf:range(0, 4)
  local container_sequence_val  = container_sequence_tvbr:le_uint()
  tree:add_le(container_info_fields.container_sequence, container_sequence_tvbr, container_sequence_val)

  -- dissect the num_items field
  local num_items_tvbr = tvbuf:range(4, 4)
  local num_items_val  = num_items_tvbr:le_uint()
  tree:add_le(container_info_fields.num_items, num_items_tvbr, num_items_val)

  local num_items_display = ", numItems: " .. num_items_val
  pktinfo.cols.info:append(num_items_display)
  tree:append_text(num_items_display)

  -- dissect the container_id field
  local container_id_tvbr = tvbuf:range(8, 4)
  local container_id_val  = container_id_tvbr:le_uint()
  tree:add_le(container_info_fields.container_id, container_id_tvbr, container_id_val)

  local container_id_display = ", containerId: " .. (enum.reverse.item_location[container_id_val] or "(unknown)")
  pktinfo.cols.info:append(container_id_display)
  tree:append_text(container_id_display)

  -- dissect the unknown field
  local unknown_tvbr = tvbuf:range(12, 4)
  local unknown_val  = unknown_tvbr:le_uint()
  tree:add_le(container_info_fields.unknown, unknown_tvbr, unknown_val)

  return len
end