Formatted
This commit is contained in:
parent
5fc01a9bec
commit
7635272fbd
150 changed files with 5055 additions and 4032 deletions
|
|
@ -3,7 +3,7 @@ defmodule Openflow.FlowMod do
|
|||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: "",
|
||||
aux_id: 0,
|
||||
aux_id: 0,
|
||||
cookie: 0,
|
||||
cookie_mask: 0,
|
||||
table_id: 0,
|
||||
|
|
@ -35,26 +35,31 @@ defmodule Openflow.FlowMod do
|
|||
out_port = Keyword.get(options, :out_port, :any)
|
||||
out_group = Keyword.get(options, :out_group, :any)
|
||||
flags = Keyword.get(options, :flags, [])
|
||||
match = Keyword.get(options, :match, Openflow.Match.new)
|
||||
match = Keyword.get(options, :match, Openflow.Match.new())
|
||||
instructions = Keyword.get(options, :instructions, [])
|
||||
%FlowMod{cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: priority,
|
||||
table_id: table_id,
|
||||
command: command,
|
||||
idle_timeout: idle,
|
||||
hard_timeout: hard,
|
||||
buffer_id: buffer_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
flags: flags,
|
||||
match: match,
|
||||
instructions: instructions}
|
||||
|
||||
%FlowMod{
|
||||
cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: priority,
|
||||
table_id: table_id,
|
||||
command: command,
|
||||
idle_timeout: idle,
|
||||
hard_timeout: hard,
|
||||
buffer_id: buffer_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
flags: flags,
|
||||
match: match,
|
||||
instructions: instructions
|
||||
}
|
||||
end
|
||||
|
||||
def read(<<cookie::64, cookie_mask::64, table_id_int::8, command_int::8,
|
||||
idle::16, hard::16, prio::16, buffer_id_int::32, out_port_int::32,
|
||||
out_group_int::32, flags_int::16, _::size(2)-unit(8), rest::bytes>>) do
|
||||
def read(
|
||||
<<cookie::64, cookie_mask::64, table_id_int::8, command_int::8, idle::16, hard::16,
|
||||
prio::16, buffer_id_int::32, out_port_int::32, out_group_int::32, flags_int::16,
|
||||
_::size(2)-unit(8), rest::bytes>>
|
||||
) do
|
||||
table_id = Openflow.Utils.get_enum(table_id_int, :table_id)
|
||||
command = Openflow.Utils.get_enum(command_int, :flow_mod_command)
|
||||
buffer_id = Openflow.Utils.get_enum(buffer_id_int, :buffer_id)
|
||||
|
|
@ -64,35 +69,41 @@ defmodule Openflow.FlowMod do
|
|||
{match_fields, instructions_bin} = Openflow.Match.read(rest)
|
||||
match = Openflow.Match.new(match_fields)
|
||||
instructions = Openflow.Instruction.read(instructions_bin)
|
||||
%FlowMod{cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: prio,
|
||||
table_id: table_id,
|
||||
command: command,
|
||||
idle_timeout: idle,
|
||||
hard_timeout: hard,
|
||||
buffer_id: buffer_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
flags: flags,
|
||||
match: match,
|
||||
instructions: instructions}
|
||||
|
||||
%FlowMod{
|
||||
cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: prio,
|
||||
table_id: table_id,
|
||||
command: command,
|
||||
idle_timeout: idle,
|
||||
hard_timeout: hard,
|
||||
buffer_id: buffer_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
flags: flags,
|
||||
match: match,
|
||||
instructions: instructions
|
||||
}
|
||||
end
|
||||
|
||||
def to_binary(flow_mod) do
|
||||
%FlowMod{cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: prio,
|
||||
table_id: table_id,
|
||||
command: command,
|
||||
idle_timeout: idle,
|
||||
hard_timeout: hard,
|
||||
buffer_id: buffer_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
flags: flags,
|
||||
match: match_fields,
|
||||
instructions: instructions} = flow_mod
|
||||
%FlowMod{
|
||||
cookie: cookie,
|
||||
cookie_mask: cookie_mask,
|
||||
priority: prio,
|
||||
table_id: table_id,
|
||||
command: command,
|
||||
idle_timeout: idle,
|
||||
hard_timeout: hard,
|
||||
buffer_id: buffer_id,
|
||||
out_port: out_port,
|
||||
out_group: out_group,
|
||||
flags: flags,
|
||||
match: match_fields,
|
||||
instructions: instructions
|
||||
} = flow_mod
|
||||
|
||||
table_id_int = Openflow.Utils.get_enum(table_id, :table_id)
|
||||
command_int = Openflow.Utils.get_enum(command, :flow_mod_command)
|
||||
buffer_id_int = Openflow.Utils.get_enum(buffer_id, :buffer_id)
|
||||
|
|
@ -101,9 +112,9 @@ defmodule Openflow.FlowMod do
|
|||
flags_int = Openflow.Enums.flags_to_int(flags, :flow_mod_flags)
|
||||
match_fields_bin = Openflow.Match.to_binary(match_fields)
|
||||
instructions_bin = Openflow.Instruction.to_binary(instructions)
|
||||
<<cookie::64, cookie_mask::64, table_id_int::8, command_int::8,
|
||||
idle::16, hard::16, prio::16, buffer_id_int::32, out_port_int::32,
|
||||
out_group_int::32, flags_int::16, 0::size(2)-unit(8),
|
||||
|
||||
<<cookie::64, cookie_mask::64, table_id_int::8, command_int::8, idle::16, hard::16, prio::16,
|
||||
buffer_id_int::32, out_port_int::32, out_group_int::32, flags_int::16, 0::size(2)-unit(8),
|
||||
match_fields_bin::bytes, instructions_bin::bytes>>
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue