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

local ffxiv_ipc_company_level_item = Proto("ffxiv_ipc_company_level_item", "FFXIV-IPC Company Level Item")

local company_level_item_fields = {
  members = ProtoField.uint16("ffxiv_ipc_company_level_item.members", "Members", base.DEC),
  index   = ProtoField.uint8("ffxiv_ipc_company_level_item.index", "Index", base.DEC),
  name    = ProtoField.string("ffxiv_ipc_company_level_item.name", "Name", base.UNICODE),
}

ffxiv_ipc_company_level_item.fields = company_level_item_fields

function ffxiv_ipc_company_level_item.dissector(tvbuf, pktinfo, root)
  local tree = root:add(ffxiv_ipc_company_level_item, tvbuf)
  pktinfo.cols.info:set("Company Level Item")

  local len = tvbuf:len()

  -- dissect the members field
  local members_tvbr = tvbuf:range(0, 2)
  local members_val  = members_tvbr:le_uint()
  tree:add_le(company_level_item_fields.members, members_tvbr, members_val)

  -- dissect the index field
  local index_tvbr = tvbuf:range(2, 1)
  local index_val  = index_tvbr:le_uint()
  tree:add_le(company_level_item_fields.index, index_tvbr, index_val)

  -- dissect the name field
  local name_tvbr = tvbuf:range(3, 32)
  local name_val  = name_tvbr:string(ENC_UTF_8)
  tree:add(company_level_item_fields.name, name_tvbr, name_val)

  local name_display = ", Name: " .. name_val
  pktinfo.cols.info:append(name_display)
  tree:append_text(name_display)

  return len
end