Fix to accept transaction_id to all message structs
This commit is contained in:
parent
bb74f3d8c4
commit
4803c61061
29 changed files with 118 additions and 34 deletions
|
|
@ -12,8 +12,8 @@ defmodule Openflow.Barrier.Request do
|
|||
|
||||
def ofp_type, do: 20
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read(_) do
|
||||
|
|
|
|||
|
|
@ -13,7 +13,13 @@ defmodule Openflow.Echo.Reply do
|
|||
|
||||
def ofp_type, do: 3
|
||||
|
||||
def new(data \\ "") do
|
||||
def new(options) when is_list(options) do
|
||||
%Reply{
|
||||
xid: options[:xid] || 0,
|
||||
data: options[:data] || ""
|
||||
}
|
||||
end
|
||||
def new(data) when is_binary(data) do
|
||||
%Reply{data: data}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,13 @@ defmodule Openflow.Echo.Request do
|
|||
|
||||
def ofp_type, do: 2
|
||||
|
||||
def new(data \\ "") do
|
||||
def new(options) when is_list(options) do
|
||||
%Request{
|
||||
xid: options[:xid] || 0,
|
||||
data: options[:data] || ""
|
||||
}
|
||||
end
|
||||
def new(data) when is_binary(data) do
|
||||
%Request{data: data}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ defmodule Openflow.Experimenter do
|
|||
|
||||
def new(options) do
|
||||
%Experimenter{
|
||||
xid: options[:xid] || 0,
|
||||
exp_id: Keyword.get(options, :exp_id, 0),
|
||||
exp_type: Keyword.get(options, :exp_type, 0),
|
||||
data: Keyword.get(options, :data, "")
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ defmodule Openflow.Features.Request do
|
|||
|
||||
def ofp_type, do: 5
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read(_) do
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ defmodule Openflow.FlowMod do
|
|||
def ofp_type, do: 14
|
||||
|
||||
def new(options \\ []) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
cookie = Keyword.get(options, :cookie, 0)
|
||||
cookie_mask = Keyword.get(options, :cookie_mask, 0)
|
||||
table_id = Keyword.get(options, :table_id, 0)
|
||||
|
|
@ -39,6 +40,7 @@ defmodule Openflow.FlowMod do
|
|||
instructions = Keyword.get(options, :instructions, [])
|
||||
|
||||
%FlowMod{
|
||||
xid: xid,
|
||||
cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: priority,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ defmodule Openflow.GetAsync.Request do
|
|||
|
||||
def ofp_type, do: 26
|
||||
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read(_) do
|
||||
%Request{}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ defmodule Openflow.GetConfig.Request do
|
|||
|
||||
def ofp_type, do: 7
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read(_) do
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@ defmodule Openflow.GroupMod do
|
|||
def ofp_type, do: 15
|
||||
|
||||
def new(options \\ []) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
command = Keyword.get(options, :command, :add)
|
||||
type = Keyword.get(options, :type, :all)
|
||||
group_id = Keyword.get(options, :group_id, 0)
|
||||
buckets = Keyword.get(options, :buckets, [])
|
||||
%GroupMod{command: command, type: type, group_id: group_id, buckets: buckets}
|
||||
%GroupMod{xid: xid, command: command, type: type, group_id: group_id, buckets: buckets}
|
||||
end
|
||||
|
||||
def read(<<command_int::16, type_int::8, _::8, group_id_int::32, buckets_bin::bytes>>) do
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ defmodule Openflow.Multipart.Aggregate.Request do
|
|||
def ofp_type, do: 18
|
||||
|
||||
def new(options) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
table_id = Keyword.get(options, :table_id, :all)
|
||||
out_port = Keyword.get(options, :out_port, :any)
|
||||
out_group = Keyword.get(options, :out_group, :any)
|
||||
|
|
@ -26,6 +27,7 @@ defmodule Openflow.Multipart.Aggregate.Request do
|
|||
match = Keyword.get(options, :match, [])
|
||||
|
||||
%Request{
|
||||
xid: xid,
|
||||
table_id: table_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ defmodule Openflow.Multipart.Desc.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read("") do
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ defmodule Openflow.Multipart.Flow.Request do
|
|||
def ofp_type, do: 18
|
||||
|
||||
def new(options \\ []) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
table_id = Keyword.get(options, :table_id, :all)
|
||||
out_port = Keyword.get(options, :out_port, :any)
|
||||
out_group = Keyword.get(options, :out_group, :any)
|
||||
|
|
@ -26,6 +27,7 @@ defmodule Openflow.Multipart.Flow.Request do
|
|||
match = Keyword.get(options, :match, Openflow.Match.new())
|
||||
|
||||
%Request{
|
||||
xid: xid,
|
||||
table_id: table_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Replace regexp Queue with: Group
|
||||
|
|
@ -1 +0,0 @@
|
|||
shun159@shun159.8967:1509553730
|
||||
|
|
@ -12,7 +12,14 @@ defmodule Openflow.Multipart.Group.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new(group_id \\ :all) do
|
||||
def new(options) when is_list(options) do
|
||||
%Request{
|
||||
xid: options[:xid] || 0,
|
||||
group_id: options[:group_id] || :all
|
||||
}
|
||||
end
|
||||
|
||||
def new(group_id) when is_integer(group_id) or is_atom(group_id) do
|
||||
%Request{group_id: group_id}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ defmodule Openflow.Multipart.GroupDesc.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read("") do
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ defmodule Openflow.Multipart.GroupFeatures.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read("") do
|
||||
|
|
|
|||
|
|
@ -12,10 +12,17 @@ defmodule Openflow.Multipart.Meter.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new(meter_id \\ :all) do
|
||||
def new(meter_id) when is_integer(meter_id) or is_atom(meter_id) do
|
||||
%Request{meter_id: meter_id}
|
||||
end
|
||||
|
||||
def new(options) when is_list(options) do
|
||||
%Request{
|
||||
xid: options[:xid] || 0,
|
||||
meter_id: options[:meter_id] || :all
|
||||
}
|
||||
end
|
||||
|
||||
def read(<<meter_id_int::32, _::size(4)-unit(8)>>) do
|
||||
meter_id = Openflow.Utils.get_enum(meter_id_int, :meter_id)
|
||||
%Request{meter_id: meter_id}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,17 @@ defmodule Openflow.Multipart.MeterConfig.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new(meter_id \\ :all) do
|
||||
def new(meter_id) when is_integer(meter_id) or is_atom(meter_id) do
|
||||
%Request{meter_id: meter_id}
|
||||
end
|
||||
|
||||
def new(options) when is_list(options) do
|
||||
%Request{
|
||||
xid: options[:xid] || 0,
|
||||
meter_id: options[:meter_id] || :all
|
||||
}
|
||||
end
|
||||
|
||||
def read(<<meter_id_int::32, _::size(4)-unit(8)>>) do
|
||||
meter_id = Openflow.Utils.get_enum(meter_id_int, :meter_id)
|
||||
%Request{meter_id: meter_id}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ defmodule Openflow.Multipart.PortDesc.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read("") do
|
||||
|
|
|
|||
|
|
@ -12,10 +12,17 @@ defmodule Openflow.Multipart.PortStats.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new(port_no \\ :any) do
|
||||
def new(port_no) when is_integer(port_no) or is_atom(port_no) do
|
||||
%Request{port_number: port_no}
|
||||
end
|
||||
|
||||
def new(options) when is_list(options) do
|
||||
%Request{
|
||||
xid: options[:xid] || 0,
|
||||
port_number: options[:port_no] || :any
|
||||
}
|
||||
end
|
||||
|
||||
def read(<<port_no_int::32, _::size(4)-unit(8)>>) do
|
||||
port_no = Openflow.Utils.get_enum(port_no_int, :openflow13_port_no)
|
||||
%Request{port_number: port_no}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ defmodule Openflow.Multipart.Queue.Request do
|
|||
def ofp_type, do: 18
|
||||
|
||||
def new(options) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
port_no = Keyword.get(options, :port_number, :any)
|
||||
queue_id = Keyword.get(options, :queue_id, :all)
|
||||
%Request{port_number: port_no, queue_id: queue_id}
|
||||
%Request{xid: xid, port_number: port_no, queue_id: queue_id}
|
||||
end
|
||||
|
||||
def read(<<port_no_int::32, queue_id_int::32>>) do
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ defmodule Openflow.Multipart.Table.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new do
|
||||
%Request{}
|
||||
def new(xid \\ 0) do
|
||||
%Request{xid: xid}
|
||||
end
|
||||
|
||||
def read("") do
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ defmodule Openflow.Multipart.TableFeatures.Request do
|
|||
|
||||
def ofp_type, do: 18
|
||||
|
||||
def new(tables \\ []) do
|
||||
%Request{tables: tables}
|
||||
def new(options \\ []) do
|
||||
%Request{
|
||||
xid: options[:xid] || 0,
|
||||
tables: options[:tables] || []
|
||||
}
|
||||
end
|
||||
|
||||
def read(<<tables_bin::bytes>>) do
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ defmodule Openflow.Role.Request do
|
|||
def ofp_type, do: 24
|
||||
|
||||
def new(options \\ []) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
role = Keyword.get(options, :role, :nochange)
|
||||
generation_id = Keyword.get(options, :generation_id, 0)
|
||||
%Request{role: role, generation_id: generation_id}
|
||||
%Request{xid: xid, role: role, generation_id: generation_id}
|
||||
end
|
||||
|
||||
def read(<<role_int::32, 0::size(4)-unit(8), generation_id::64>>) do
|
||||
|
|
|
|||
|
|
@ -18,6 +18,18 @@ defmodule Openflow.SetAsync do
|
|||
|
||||
def ofp_type, do: 28
|
||||
|
||||
def new(options \\ []) do
|
||||
%SetAsync{
|
||||
xid: options[:xid] || 0,
|
||||
packet_in_mask_master: options[:packet_in_mask_master],
|
||||
packet_in_mask_slave: options[:packet_in_mask_slave],
|
||||
port_status_mask_master: options[:port_status_mask_master],
|
||||
port_status_mask_slave: options[:port_status_mask_slave],
|
||||
flow_removed_mask_master: options[:flow_removed_mask_master],
|
||||
flow_removed_mask_slave: options[:flow_removed_mask_slave]
|
||||
}
|
||||
end
|
||||
|
||||
def read(
|
||||
<<packet_in_mask_master::32, packet_in_mask_slave::32, port_status_mask_master::32,
|
||||
port_status_mask_slave::32, flow_removed_mask_master::32, flow_removed_mask_slave::32>>
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ defmodule Openflow.SetConfig do
|
|||
def ofp_type, do: 9
|
||||
|
||||
def new(options \\ []) do
|
||||
xid = Keyword.get(options, :xid, 0)
|
||||
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}
|
||||
%SetConfig{xid: xid, flags: flags, miss_send_len: miss_send_len}
|
||||
end
|
||||
|
||||
def read(<<flags_int::16, miss_send_len0::16>>) do
|
||||
|
|
|
|||
|
|
@ -12,7 +12,13 @@ defmodule Openflow.TableMod do
|
|||
|
||||
def ofp_type, do: 17
|
||||
|
||||
def new(table_id) do
|
||||
def new(options) when is_list(options) do
|
||||
%TableMod{
|
||||
xid: options[:xid] || 0,
|
||||
table_id: options[:table_id] || 0
|
||||
}
|
||||
end
|
||||
def new(table_id) when is_integer(table_id) or is_atom(table_id) do
|
||||
%TableMod{table_id: table_id}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ defmodule Tres.MessageHelper do
|
|||
command = Tres.Utils.flow_command(:modify, options)
|
||||
|
||||
flow_mod = %Openflow.FlowMod{
|
||||
xid: options[:xid] || 0,
|
||||
cookie: options[:cookie] || 0,
|
||||
table_id: options[:table_id] || 0,
|
||||
command: command,
|
||||
|
|
@ -42,6 +43,7 @@ defmodule Tres.MessageHelper do
|
|||
command = Tres.Utils.flow_command(:delete, options)
|
||||
|
||||
flow_mod = %Openflow.FlowMod{
|
||||
xid: options[:xid] || 0,
|
||||
cookie: options[:cookie] || 0,
|
||||
cookie_mask: options[:cookie_mask] || 0,
|
||||
table_id: options[:table_id] || :all,
|
||||
|
|
@ -56,6 +58,7 @@ defmodule Tres.MessageHelper do
|
|||
|
||||
defp send_packet_out(datapath_id, options \\ []) do
|
||||
packet_out = %Openflow.PacketOut{
|
||||
xid: options[:xid] || 0,
|
||||
buffer_id: options[:buffer_id] || :no_buffer,
|
||||
in_port: options[:in_port] || :controller,
|
||||
actions: options[:actions] || [],
|
||||
|
|
@ -68,6 +71,7 @@ defmodule Tres.MessageHelper do
|
|||
defp send_group_mod_add(datapath_id, options \\ []) do
|
||||
group_mod =
|
||||
Openflow.GroupMod.new(
|
||||
xid: options[:xid] || 0,
|
||||
command: :add,
|
||||
type: options[:type] || :all,
|
||||
group_id: options[:group_id] || 0,
|
||||
|
|
@ -77,14 +81,19 @@ defmodule Tres.MessageHelper do
|
|||
send_message(group_mod, datapath_id)
|
||||
end
|
||||
|
||||
defp send_group_mod_delete(datapath_id, group_id) do
|
||||
group_mod = Openflow.GroupMod.new(command: :delete, group_id: group_id)
|
||||
defp send_group_mod_delete(datapath_id, options \\ []) do
|
||||
group_mod = Openflow.GroupMod.new(
|
||||
xid: options[:xid] || 0,
|
||||
command: :delete,
|
||||
group_id: options[:group_id] || :all
|
||||
)
|
||||
send_message(group_mod, datapath_id)
|
||||
end
|
||||
|
||||
defp send_group_mod_modify(datapath_id, options) do
|
||||
defp send_group_mod_modify(datapath_id, options \\ []) do
|
||||
group_mod =
|
||||
Openflow.GroupMod.new(
|
||||
xid: options[:xid] || 0,
|
||||
command: :modify,
|
||||
type: options[:type] || :all,
|
||||
group_id: options[:group_id] || 0,
|
||||
|
|
@ -97,6 +106,7 @@ defmodule Tres.MessageHelper do
|
|||
defp send_role_request(datapath_id, options) do
|
||||
role_request =
|
||||
Openflow.Role.Request.new(
|
||||
xid: options[:xid] || 0,
|
||||
role: options[:role] || :nochange,
|
||||
generation_id: options[:generation_id] || 0
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue