31 lines
737 B
Elixir
31 lines
737 B
Elixir
defmodule Openflow.TableMod do
|
|
defstruct(
|
|
version: 4,
|
|
xid: 0,
|
|
datapath_id: "",
|
|
aux_id: 0,
|
|
table_id: 0,
|
|
config: 0
|
|
)
|
|
|
|
alias __MODULE__
|
|
|
|
def ofp_type, do: 17
|
|
|
|
def new(options) when is_list(options) do
|
|
%TableMod{
|
|
xid: Keyword.get(options, :xid, 0),
|
|
table_id: Keyword.get(options, :table_id, 0)
|
|
}
|
|
end
|
|
|
|
def read(<<table_id_int::8, _::size(3)-unit(8), config::32>>) do
|
|
table_id = Openflow.Utils.get_enum(table_id_int, :table_id)
|
|
%TableMod{table_id: table_id, config: config}
|
|
end
|
|
|
|
def to_binary(%TableMod{table_id: table_id, config: config}) do
|
|
table_id_int = Openflow.Utils.get_enum(table_id, :table_id)
|
|
<<table_id_int::8, 0::size(3)-unit(8), config::32>>
|
|
end
|
|
end
|