Formatted
This commit is contained in:
parent
5fc01a9bec
commit
7635272fbd
150 changed files with 5055 additions and 4032 deletions
|
|
@ -1,11 +1,12 @@
|
|||
defmodule Openflow.Multipart.Table.Reply do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: nil, # virtual field
|
||||
aux_id: nil,
|
||||
flags: [],
|
||||
tables: []
|
||||
version: 4,
|
||||
xid: 0,
|
||||
# virtual field
|
||||
datapath_id: nil,
|
||||
aux_id: nil,
|
||||
flags: [],
|
||||
tables: []
|
||||
)
|
||||
|
||||
alias __MODULE__
|
||||
|
|
@ -18,21 +19,24 @@ defmodule Openflow.Multipart.Table.Reply do
|
|||
end
|
||||
|
||||
def append_body(%Reply{tables: tables} = message, %Reply{flags: [:more], tables: continue}) do
|
||||
%{message|tables: [continue|tables]}
|
||||
%{message | tables: [continue | tables]}
|
||||
end
|
||||
|
||||
def append_body(%Reply{tables: tables} = message, %Reply{flags: [], tables: continue}) do
|
||||
new_tables = [continue|tables]
|
||||
|> Enum.reverse
|
||||
|> List.flatten
|
||||
%{message|tables: new_tables}
|
||||
new_tables =
|
||||
[continue | tables]
|
||||
|> Enum.reverse()
|
||||
|> List.flatten()
|
||||
|
||||
%{message | tables: new_tables}
|
||||
end
|
||||
end
|
||||
|
||||
defmodule Openflow.Multipart.TableStats do
|
||||
defstruct(
|
||||
table_id: 0,
|
||||
active_count: 0,
|
||||
lookup_count: 0,
|
||||
table_id: 0,
|
||||
active_count: 0,
|
||||
lookup_count: 0,
|
||||
matched_count: 0
|
||||
)
|
||||
|
||||
|
|
@ -45,12 +49,20 @@ defmodule Openflow.Multipart.TableStats do
|
|||
# private functions
|
||||
|
||||
defp do_read(acc, ""), do: Enum.reverse(acc)
|
||||
|
||||
defp do_read(acc, <<table_stats_bin::24-bytes, rest::bytes>>) do
|
||||
do_read([codec(table_stats_bin)|acc], rest)
|
||||
do_read([codec(table_stats_bin) | acc], rest)
|
||||
end
|
||||
|
||||
defp codec(<<table_id::8, _::size(3)-unit(8), active_count::32, lookup_count::64, matched_count::64>>) do
|
||||
%TableStats{table_id: table_id, active_count: active_count,
|
||||
lookup_count: lookup_count, matched_count: matched_count}
|
||||
defp codec(
|
||||
<<table_id::8, _::size(3)-unit(8), active_count::32, lookup_count::64,
|
||||
matched_count::64>>
|
||||
) do
|
||||
%TableStats{
|
||||
table_id: table_id,
|
||||
active_count: active_count,
|
||||
lookup_count: lookup_count,
|
||||
matched_count: matched_count
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
defmodule Openflow.Multipart.Table.Request do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: nil, # virtual field
|
||||
version: 4,
|
||||
xid: 0,
|
||||
# virtual field
|
||||
datapath_id: nil,
|
||||
flags: []
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue