defmodule Openflow.Multipart.Table.Reply do defstruct( version: 4, xid: 0, datapath_id: nil, # virtual field flags: [], tables: [] ) alias __MODULE__ def ofp_type, do: 18 def read(<>) do tables = Openflow.Multipart.TableStats.read(tables_bin) %Reply{tables: tables} end end defmodule Openflow.Multipart.TableStats do defstruct( table_id: 0, active_count: 0, lookup_count: 0, matched_count: 0 ) alias __MODULE__ def read(binary) do do_read([], binary) end # private functions defp do_read(acc, ""), do: Enum.reverse(acc) defp do_read(acc, <>) do do_read([codec(table_stats_bin)|acc], rest) end defp codec(<>) do %TableStats{table_id: table_id, active_count: active_count, lookup_count: lookup_count, matched_count: matched_count} end end