Openflow parser
This commit is contained in:
parent
70b0d8919e
commit
fc02a678de
338 changed files with 9081 additions and 0 deletions
32
lib/openflow/set_config.ex
Normal file
32
lib/openflow/set_config.ex
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
defmodule Openflow.SetConfig do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: "",
|
||||
aux_id: 0,
|
||||
flags: [], # default = "normal" is no special handling
|
||||
miss_send_len: 128
|
||||
)
|
||||
|
||||
alias __MODULE__
|
||||
|
||||
def ofp_type, do: 9
|
||||
|
||||
def new(options \\ []) do
|
||||
flags = Keyword.get(options, :flags, [])
|
||||
miss_send_len = Keyword.get(options, :miss_send_len, :no_buffer)
|
||||
%SetConfig{flags: flags, miss_send_len: miss_send_len}
|
||||
end
|
||||
|
||||
def read(<<flags_int::16, miss_send_len0::16>>) do
|
||||
flags = Openflow.Enums.int_to_flags(flags_int, :config_flags)
|
||||
miss_send_len = Openflow.Utils.get_enum(miss_send_len0, :controller_max_len)
|
||||
%SetConfig{flags: flags, miss_send_len: miss_send_len}
|
||||
end
|
||||
|
||||
def to_binary(%SetConfig{flags: flags, miss_send_len: miss_send_len0}) do
|
||||
flags_int = Openflow.Enums.flags_to_int(flags, :config_flags)
|
||||
miss_send_len = Openflow.Utils.get_enum(miss_send_len0, :controller_max_len)
|
||||
<<flags_int::16, miss_send_len::16>>
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue