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
|
|
@ -63,14 +63,18 @@ defmodule LearningSwitch.Ofctl do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp init_flow_tables(datapath_id) do
|
defp init_flow_tables(datapath_id) do
|
||||||
|
:ok = onf_bundle_open(datapath_id, bundle_id: 1, flags: [:atomic, :ordered])
|
||||||
|
|
||||||
for flow_options <- [
|
for flow_options <- [
|
||||||
add_default_broadcast_flow_entry(),
|
add_default_broadcast_flow_entry(),
|
||||||
add_default_flooding_flow_entry(),
|
add_default_flooding_flow_entry(),
|
||||||
add_multicast_mac_drop_flow_entry(),
|
add_multicast_mac_drop_flow_entry(),
|
||||||
add_ipv6_multicast_mac_drop_flow_entry(),
|
add_ipv6_multicast_mac_drop_flow_entry(),
|
||||||
add_default_forwarding_flow_entry()] do
|
add_default_forwarding_flow_entry()] do
|
||||||
send_flow_mod_add(datapath_id, flow_options)
|
send_flow_mod_add(datapath_id, Keyword.merge(flow_options, [bundle_id: 1, bundle_flags: [:atomic, :ordered]]))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
:ok = onf_bundle_commit(datapath_id, bundle_id: 1, flags: [:atomic, :ordered])
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_forwarding_flow_and_packet_out(packet_in, state) do
|
defp add_forwarding_flow_and_packet_out(packet_in, state) do
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
%{
|
%{
|
||||||
"binpp": {:git, "https://github.com/jtendo/binpp.git", "64bd68d215d1a6cd35871e7c134d7fe2e46214ea", [branch: "master"]},
|
"binpp": {:git, "https://github.com/jtendo/binpp.git", "64bd68d215d1a6cd35871e7c134d7fe2e46214ea", [branch: "master"]},
|
||||||
"eovsdb": {:git, "https://github.com/shun159/eovsdb.git", "1ff1572708d72fd25631c681f2102407903252a3", [branch: "master"]},
|
"eovsdb": {:git, "https://github.com/shun159/eovsdb.git", "1ff1572708d72fd25631c681f2102407903252a3", [branch: "master"]},
|
||||||
"jsone": {:git, "https://github.com/sile/jsone.git", "eecc9666c7165e1870b78a7a762549ae8d1c391b", [tag: "1.2.1"]},
|
"jsone": {:git, "https://github.com/sile/jsone.git", "b23d312a5ed051ea7ad0989a9f2cb1a9c3f9a502", [tag: "1.4.6"]},
|
||||||
"ranch": {:hex, :ranch, "1.4.0", "10272f95da79340fa7e8774ba7930b901713d272905d0012b06ca6d994f8826b", [], [], "hexpm"},
|
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"},
|
||||||
"uuid": {:git, "https://github.com/avtobiff/erlang-uuid.git", "585c2474afb4a597ae8c8bf6d21e5a9c73f18e0b", [tag: "v0.5.0"]},
|
"uuid": {:git, "https://github.com/avtobiff/erlang-uuid.git", "585c2474afb4a597ae8c8bf6d21e5a9c73f18e0b", [tag: "v0.5.0"]},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -990,6 +990,20 @@ defmodule Openflow.EnumGen do
|
||||||
apply_setfield_miss: 15,
|
apply_setfield_miss: 15,
|
||||||
experimenter: 0xFFFE,
|
experimenter: 0xFFFE,
|
||||||
experimenter_miss: 0xFFFF
|
experimenter_miss: 0xFFFF
|
||||||
|
],
|
||||||
|
bundle_ctrl_type: [
|
||||||
|
open_request: 0,
|
||||||
|
open_reply: 1,
|
||||||
|
close_request: 2,
|
||||||
|
close_reply: 3,
|
||||||
|
commit_request: 4,
|
||||||
|
commit_reply: 5,
|
||||||
|
discard_request: 6,
|
||||||
|
discard_reply: 7
|
||||||
|
],
|
||||||
|
bundle_flags: [
|
||||||
|
atomic: 1 <<< 0,
|
||||||
|
ordered: 1 <<< 1
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5101,6 +5101,74 @@ defmodule Openflow.Enums do
|
||||||
throw(:bad_enum)
|
throw(:bad_enum)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_int(:open_request, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:open_request)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :open_request
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:open_reply, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:open_reply)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :open_reply
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:close_request, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:close_request)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :close_request
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:close_reply, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:close_reply)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :close_reply
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:commit_request, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:commit_request)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :commit_request
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:commit_reply, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:commit_reply)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :commit_reply
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:discard_request, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:discard_request)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :discard_request
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:discard_reply, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_int(:discard_reply)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :discard_reply
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(_int, :bundle_ctrl_type) do
|
||||||
|
throw(:bad_enum)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:atomic, :bundle_flags) do
|
||||||
|
bundle_flags_to_int(:atomic)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :atomic
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(:ordered, :bundle_flags) do
|
||||||
|
bundle_flags_to_int(:ordered)
|
||||||
|
catch
|
||||||
|
_class, _reason -> :ordered
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_int(_int, :bundle_flags) do
|
||||||
|
throw(:bad_enum)
|
||||||
|
end
|
||||||
|
|
||||||
def to_atom(0x0, :openflow_codec) do
|
def to_atom(0x0, :openflow_codec) do
|
||||||
openflow_codec_to_atom(0x0)
|
openflow_codec_to_atom(0x0)
|
||||||
catch
|
catch
|
||||||
|
|
@ -10201,6 +10269,74 @@ defmodule Openflow.Enums do
|
||||||
throw(:bad_enum)
|
throw(:bad_enum)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_atom(0x0, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x0)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x1, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x1)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x2, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x2)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 2
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x3, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x3)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 3
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x4, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x4)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 4
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x5, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x5)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 5
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x6, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x6)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 6
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x7, :bundle_ctrl_type) do
|
||||||
|
bundle_ctrl_type_to_atom(0x7)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 7
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(_, :bundle_ctrl_type) do
|
||||||
|
throw(:bad_enum)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x1, :bundle_flags) do
|
||||||
|
bundle_flags_to_atom(0x1)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(0x2, :bundle_flags) do
|
||||||
|
bundle_flags_to_atom(0x2)
|
||||||
|
catch
|
||||||
|
_class, _reason -> 2
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_atom(_, :bundle_flags) do
|
||||||
|
throw(:bad_enum)
|
||||||
|
end
|
||||||
|
|
||||||
def openflow_codec_to_int(Openflow.Hello), do: 0x0
|
def openflow_codec_to_int(Openflow.Hello), do: 0x0
|
||||||
def openflow_codec_to_int(Openflow.ErrorMsg), do: 0x1
|
def openflow_codec_to_int(Openflow.ErrorMsg), do: 0x1
|
||||||
def openflow_codec_to_int(Openflow.Echo.Request), do: 0x2
|
def openflow_codec_to_int(Openflow.Echo.Request), do: 0x2
|
||||||
|
|
@ -11961,6 +12097,30 @@ defmodule Openflow.Enums do
|
||||||
def table_feature_prop_type_to_atom(0xFFFE), do: :experimenter
|
def table_feature_prop_type_to_atom(0xFFFE), do: :experimenter
|
||||||
def table_feature_prop_type_to_atom(0xFFFF), do: :experimenter_miss
|
def table_feature_prop_type_to_atom(0xFFFF), do: :experimenter_miss
|
||||||
def table_feature_prop_type_to_atom(_), do: throw(:bad_enum)
|
def table_feature_prop_type_to_atom(_), do: throw(:bad_enum)
|
||||||
|
def bundle_ctrl_type_to_int(:open_request), do: 0x0
|
||||||
|
def bundle_ctrl_type_to_int(:open_reply), do: 0x1
|
||||||
|
def bundle_ctrl_type_to_int(:close_request), do: 0x2
|
||||||
|
def bundle_ctrl_type_to_int(:close_reply), do: 0x3
|
||||||
|
def bundle_ctrl_type_to_int(:commit_request), do: 0x4
|
||||||
|
def bundle_ctrl_type_to_int(:commit_reply), do: 0x5
|
||||||
|
def bundle_ctrl_type_to_int(:discard_request), do: 0x6
|
||||||
|
def bundle_ctrl_type_to_int(:discard_reply), do: 0x7
|
||||||
|
def bundle_ctrl_type_to_int(_), do: throw(:bad_enum)
|
||||||
|
def bundle_ctrl_type_to_atom(0x0), do: :open_request
|
||||||
|
def bundle_ctrl_type_to_atom(0x1), do: :open_reply
|
||||||
|
def bundle_ctrl_type_to_atom(0x2), do: :close_request
|
||||||
|
def bundle_ctrl_type_to_atom(0x3), do: :close_reply
|
||||||
|
def bundle_ctrl_type_to_atom(0x4), do: :commit_request
|
||||||
|
def bundle_ctrl_type_to_atom(0x5), do: :commit_reply
|
||||||
|
def bundle_ctrl_type_to_atom(0x6), do: :discard_request
|
||||||
|
def bundle_ctrl_type_to_atom(0x7), do: :discard_reply
|
||||||
|
def bundle_ctrl_type_to_atom(_), do: throw(:bad_enum)
|
||||||
|
def bundle_flags_to_int(:atomic), do: 0x1
|
||||||
|
def bundle_flags_to_int(:ordered), do: 0x2
|
||||||
|
def bundle_flags_to_int(_), do: throw(:bad_enum)
|
||||||
|
def bundle_flags_to_atom(0x1), do: :atomic
|
||||||
|
def bundle_flags_to_atom(0x2), do: :ordered
|
||||||
|
def bundle_flags_to_atom(_), do: throw(:bad_enum)
|
||||||
|
|
||||||
def int_to_flags(int, :openflow_codec) do
|
def int_to_flags(int, :openflow_codec) do
|
||||||
Openflow.Utils.int_to_flags([], int, enum_of(:openflow_codec))
|
Openflow.Utils.int_to_flags([], int, enum_of(:openflow_codec))
|
||||||
|
|
@ -12322,6 +12482,14 @@ defmodule Openflow.Enums do
|
||||||
Openflow.Utils.int_to_flags([], int, enum_of(:table_feature_prop_type))
|
Openflow.Utils.int_to_flags([], int, enum_of(:table_feature_prop_type))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def int_to_flags(int, :bundle_ctrl_type) do
|
||||||
|
Openflow.Utils.int_to_flags([], int, enum_of(:bundle_ctrl_type))
|
||||||
|
end
|
||||||
|
|
||||||
|
def int_to_flags(int, :bundle_flags) do
|
||||||
|
Openflow.Utils.int_to_flags([], int, enum_of(:bundle_flags))
|
||||||
|
end
|
||||||
|
|
||||||
def flags_to_int(flags, :openflow_codec) do
|
def flags_to_int(flags, :openflow_codec) do
|
||||||
Openflow.Utils.flags_to_int(0, flags, enum_of(:openflow_codec))
|
Openflow.Utils.flags_to_int(0, flags, enum_of(:openflow_codec))
|
||||||
end
|
end
|
||||||
|
|
@ -12682,6 +12850,14 @@ defmodule Openflow.Enums do
|
||||||
Openflow.Utils.flags_to_int(0, flags, enum_of(:table_feature_prop_type))
|
Openflow.Utils.flags_to_int(0, flags, enum_of(:table_feature_prop_type))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def flags_to_int(flags, :bundle_ctrl_type) do
|
||||||
|
Openflow.Utils.flags_to_int(0, flags, enum_of(:bundle_ctrl_type))
|
||||||
|
end
|
||||||
|
|
||||||
|
def flags_to_int(flags, :bundle_flags) do
|
||||||
|
Openflow.Utils.flags_to_int(0, flags, enum_of(:bundle_flags))
|
||||||
|
end
|
||||||
|
|
||||||
defp enum_of(:openflow_codec),
|
defp enum_of(:openflow_codec),
|
||||||
do: [
|
do: [
|
||||||
{Openflow.Hello, 0},
|
{Openflow.Hello, 0},
|
||||||
|
|
@ -13555,4 +13731,18 @@ defmodule Openflow.Enums do
|
||||||
experimenter: 65534,
|
experimenter: 65534,
|
||||||
experimenter_miss: 65535
|
experimenter_miss: 65535
|
||||||
]
|
]
|
||||||
|
|
||||||
|
defp enum_of(:bundle_ctrl_type),
|
||||||
|
do: [
|
||||||
|
open_request: 0,
|
||||||
|
open_reply: 1,
|
||||||
|
close_request: 2,
|
||||||
|
close_reply: 3,
|
||||||
|
commit_request: 4,
|
||||||
|
commit_reply: 5,
|
||||||
|
discard_request: 6,
|
||||||
|
discard_reply: 7
|
||||||
|
]
|
||||||
|
|
||||||
|
defp enum_of(:bundle_flags), do: [atomic: 1, ordered: 2]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
50
lib/openflow/onf_bundle_add.ex
Normal file
50
lib/openflow/onf_bundle_add.ex
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
defmodule Openflow.OnfBundleAdd do
|
||||||
|
defstruct(
|
||||||
|
version: 4,
|
||||||
|
xid: 0,
|
||||||
|
datapath_id: "",
|
||||||
|
aux_id: 0,
|
||||||
|
# bundle header
|
||||||
|
bundle_id: 0,
|
||||||
|
flags: [],
|
||||||
|
message: nil
|
||||||
|
)
|
||||||
|
|
||||||
|
alias __MODULE__
|
||||||
|
|
||||||
|
# ONF Experimenter
|
||||||
|
@experimenter 0x4F4E4600
|
||||||
|
# BUNDLE_ADD
|
||||||
|
@onf_type 2301
|
||||||
|
|
||||||
|
@onf_bundle_add_message_size 24
|
||||||
|
|
||||||
|
# experimenter
|
||||||
|
def ofp_type, do: 4
|
||||||
|
|
||||||
|
def new(options \\ []) do
|
||||||
|
%OnfBundleAdd{
|
||||||
|
xid: options[:xid] || 0,
|
||||||
|
bundle_id: options[:bundle_id] || 0,
|
||||||
|
flags: options[:flags] || [],
|
||||||
|
message: options[:message]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_binary(%OnfBundleAdd{} = bundle_add) do
|
||||||
|
bundle_id = bundle_add.bundle_id
|
||||||
|
message_bin = Openflow.to_binary(%{bundle_add.message | xid: bundle_add.xid})
|
||||||
|
length = @onf_bundle_add_message_size + byte_size(message_bin)
|
||||||
|
pad_length = Openflow.Utils.pad_length(length, 8)
|
||||||
|
flags_int = Openflow.Enums.flags_to_int(bundle_add.flags, :bundle_flags)
|
||||||
|
|
||||||
|
<<@experimenter::32, @onf_type::32, bundle_id::32, 0::2-unit(8),
|
||||||
|
flags_int::16, message_bin::bytes, 0::size(pad_length)-unit(8)>>
|
||||||
|
end
|
||||||
|
|
||||||
|
def read(<<@experimenter::32, @onf_type::32, bundle_id::32, _pad::16, flags_int::16, message_bin::bytes>>) do
|
||||||
|
message = Openflow.read(message_bin)
|
||||||
|
flags = Openflow.Enums.int_to_flags(flags_int, :bundle_flags)
|
||||||
|
%OnfBundleAdd{bundle_id: bundle_id, flags: flags, message: message}
|
||||||
|
end
|
||||||
|
end
|
||||||
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
|
||||||
|
|
@ -17,7 +17,14 @@ defmodule Tres.MessageHelper do
|
||||||
instructions: options[:instructions] || []
|
instructions: options[:instructions] || []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags] || [], message: flow_mod)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_flow_mod_modify(datapath_id, options \\ []) do
|
defp send_flow_mod_modify(datapath_id, options \\ []) do
|
||||||
|
|
@ -36,7 +43,14 @@ defmodule Tres.MessageHelper do
|
||||||
instructions: options[:instructions] || []
|
instructions: options[:instructions] || []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags] || [], message: flow_mod)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_flow_mod_delete(datapath_id, options \\ []) do
|
defp send_flow_mod_delete(datapath_id, options \\ []) do
|
||||||
|
|
@ -53,7 +67,14 @@ defmodule Tres.MessageHelper do
|
||||||
match: options[:match] || Openflow.Match.new()
|
match: options[:match] || Openflow.Match.new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags] || [], message: flow_mod)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_packet_out(options \\ []) do
|
defp send_packet_out(options \\ []) do
|
||||||
|
|
@ -101,7 +122,14 @@ defmodule Tres.MessageHelper do
|
||||||
data: options[:data] || ""
|
data: options[:data] || ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(packet_out, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(packet_out, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags], message: packet_out)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_group_mod_add(datapath_id, options \\ []) do
|
defp send_group_mod_add(datapath_id, options \\ []) do
|
||||||
|
|
@ -114,7 +142,14 @@ defmodule Tres.MessageHelper do
|
||||||
buckets: options[:buckets] || []
|
buckets: options[:buckets] || []
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(group_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(group_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags] || [], message: group_mod)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_group_mod_delete(datapath_id, options \\ []) do
|
defp send_group_mod_delete(datapath_id, options \\ []) do
|
||||||
|
|
@ -125,7 +160,14 @@ defmodule Tres.MessageHelper do
|
||||||
group_id: options[:group_id] || :all
|
group_id: options[:group_id] || :all
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(group_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(group_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags] || [], message: group_mod)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_group_mod_modify(datapath_id, options \\ []) do
|
defp send_group_mod_modify(datapath_id, options \\ []) do
|
||||||
|
|
@ -138,7 +180,14 @@ defmodule Tres.MessageHelper do
|
||||||
buckets: options[:buckets] || []
|
buckets: options[:buckets] || []
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case options[:bundle_id] do
|
||||||
|
nil ->
|
||||||
send_message(group_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(group_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
|
||||||
|
bundle_id when is_integer(bundle_id) ->
|
||||||
|
bundle = Openflow.OnfBundleAdd.new(bundle_id: bundle_id, flags: options[:bundle_flags] || [], message: group_mod)
|
||||||
|
send_message(bundle, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_role_request(datapath_id, options) do
|
defp send_role_request(datapath_id, options) do
|
||||||
|
|
@ -193,6 +242,32 @@ defmodule Tres.MessageHelper do
|
||||||
resume = Openflow.NxResume.new(options)
|
resume = Openflow.NxResume.new(options)
|
||||||
send_message(resume, datapath_id, options[:blocking] || false)
|
send_message(resume, datapath_id, options[:blocking] || false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# ONF Bundle Control
|
||||||
|
|
||||||
|
defp onf_bundle_open(datapath_id, options \\ []) do
|
||||||
|
options2 = Keyword.merge(options, [type: :open_request])
|
||||||
|
bundle = Openflow.OnfBundleControl.new(options2)
|
||||||
|
send_message(bundle, datapath_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp onf_bundle_close(datapath_id, options) do
|
||||||
|
options2 = Keyword.merge(options, [type: :close_request])
|
||||||
|
bundle = Openflow.OnfBundleControl.new(options2)
|
||||||
|
send_message(bundle, datapath_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp onf_bundle_commit(datapath_id, options) do
|
||||||
|
options2 = Keyword.merge(options, [type: :commit_request])
|
||||||
|
bundle = Openflow.OnfBundleControl.new(options2)
|
||||||
|
send_message(bundle, datapath_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp onf_bundle_discard(datapath_id, options) do
|
||||||
|
options2 = Keyword.merge(options, [type: :discard_request])
|
||||||
|
bundle = Openflow.OnfBundleControl.new(options2)
|
||||||
|
send_message(bundle, datapath_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ defmodule Tres.SecureChannelState do
|
||||||
|
|
||||||
@spec get_transaction_id(:counters.counters_ref()) :: integer()
|
@spec get_transaction_id(:counters.counters_ref()) :: integer()
|
||||||
def get_transaction_id(counter_ref) do
|
def get_transaction_id(counter_ref) do
|
||||||
:counters.get(counter_ref, 1) &&& 0xffffffff
|
:counters.get(counter_ref, 1) &&& 0xFFFFFFFF
|
||||||
end
|
end
|
||||||
|
|
||||||
# private functions
|
# private functions
|
||||||
|
|
|
||||||
BIN
test/packet_data/onf_bundle_control.raw
Normal file
BIN
test/packet_data/onf_bundle_control.raw
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue