tres/lib/openflow/nx_packet_in_format.ex
Eishun Kondoh 7635272fbd Formatted
2018-01-30 22:47:31 +09:00

30 lines
684 B
Elixir

defmodule Openflow.NxSetPacketInFormat do
defstruct(
version: 4,
xid: 0,
datapath_id: "",
aux_id: 0,
format: :standard
)
@experimenter 0x00002320
@nx_type 16
alias __MODULE__
def ofp_type, do: 4
def new(format \\ :standard) do
%NxSetPacketInFormat{format: format}
end
def read(<<@experimenter::32, @nx_type::32, format_int::32>>) do
format = Openflow.Enums.to_atom(format_int, :packet_in_format)
%NxSetPacketInFormat{format: format}
end
def to_binary(%NxSetPacketInFormat{format: format}) do
format_int = Openflow.Enums.to_int(format, :packet_in_format)
<<@experimenter::32, @nx_type::32, format_int::32>>
end
end