Feature/bundle support (#15)
* openflow: Add bundle support * openflow: Add bundle message generator and parser * openflow: Add bundle API
This commit is contained in:
parent
db68e81954
commit
ec1cdb6eff
9 changed files with 388 additions and 11 deletions
44
lib/openflow/onf_bundle_control.ex
Normal file
44
lib/openflow/onf_bundle_control.ex
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
defmodule Openflow.OnfBundleControl do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: "",
|
||||
aux_id: 0,
|
||||
# bundle header
|
||||
bundle_id: 0,
|
||||
type: :open_request,
|
||||
flags: []
|
||||
)
|
||||
|
||||
alias __MODULE__
|
||||
|
||||
# ONF Experimenter
|
||||
@experimenter 0x4F4E4600
|
||||
# BUNDLE_CONTROL
|
||||
@onf_type 2300
|
||||
|
||||
# experimenter
|
||||
def ofp_type, do: 4
|
||||
|
||||
def new(options \\ []) do
|
||||
%OnfBundleControl{
|
||||
xid: options[:xid] || 0,
|
||||
bundle_id: options[:bundle_id] || 0,
|
||||
type: options[:type] || :open_request,
|
||||
flags: options[:flags] || []
|
||||
}
|
||||
end
|
||||
|
||||
def to_binary(%OnfBundleControl{} = ctrl) do
|
||||
bundle_id = ctrl.bundle_id
|
||||
type_int = Openflow.Utils.get_enum(ctrl.type, :bundle_ctrl_type)
|
||||
flags_int = Openflow.Enums.flags_to_int(ctrl.flags, :bundle_flags)
|
||||
<<@experimenter::32, @onf_type::32, bundle_id::32, type_int::16, flags_int::16>>
|
||||
end
|
||||
|
||||
def read(<<@experimenter::32, @onf_type::32, bundle_id::32, type_int::16, flags_int::16>>) do
|
||||
type = Openflow.Utils.get_enum(type_int, :bundle_ctrl_type)
|
||||
flags = Openflow.Enums.int_to_flags(flags_int, :bundle_flags)
|
||||
%OnfBundleControl{bundle_id: bundle_id, type: type, flags: flags}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue