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.PortStats.Reply do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: nil, # virtual field
|
||||
aux_id: nil,
|
||||
flags: [],
|
||||
ports: []
|
||||
version: 4,
|
||||
xid: 0,
|
||||
# virtual field
|
||||
datapath_id: nil,
|
||||
aux_id: nil,
|
||||
flags: [],
|
||||
ports: []
|
||||
)
|
||||
|
||||
alias __MODULE__
|
||||
|
|
@ -22,32 +23,35 @@ defmodule Openflow.Multipart.PortStats.Reply do
|
|||
end
|
||||
|
||||
def append_body(%Reply{ports: ports} = message, %Reply{flags: [:more], ports: continue}) do
|
||||
%{message|ports: [continue|ports]}
|
||||
%{message | ports: [continue | ports]}
|
||||
end
|
||||
|
||||
def append_body(%Reply{ports: ports} = message, %Reply{flags: [], ports: continue}) do
|
||||
new_ports = [continue|ports]
|
||||
|> Enum.reverse
|
||||
|> List.flatten
|
||||
%{message|ports: new_ports}
|
||||
new_ports =
|
||||
[continue | ports]
|
||||
|> Enum.reverse()
|
||||
|> List.flatten()
|
||||
|
||||
%{message | ports: new_ports}
|
||||
end
|
||||
end
|
||||
|
||||
defmodule Openflow.Multipart.PortStats do
|
||||
defstruct(
|
||||
port_number: 0,
|
||||
rx_packets: 0,
|
||||
tx_packets: 0,
|
||||
rx_bytes: 0,
|
||||
tx_bytes: 0,
|
||||
rx_dropped: 0,
|
||||
tx_dropped: 0,
|
||||
rx_errors: 0,
|
||||
tx_errors: 0,
|
||||
rx_frame_err: 0,
|
||||
rx_over_err: 0,
|
||||
rx_crc_err: 0,
|
||||
collisions: 0,
|
||||
duration_sec: 0,
|
||||
port_number: 0,
|
||||
rx_packets: 0,
|
||||
tx_packets: 0,
|
||||
rx_bytes: 0,
|
||||
tx_bytes: 0,
|
||||
rx_dropped: 0,
|
||||
tx_dropped: 0,
|
||||
rx_errors: 0,
|
||||
tx_errors: 0,
|
||||
rx_frame_err: 0,
|
||||
rx_over_err: 0,
|
||||
rx_crc_err: 0,
|
||||
collisions: 0,
|
||||
duration_sec: 0,
|
||||
duration_nsec: 0
|
||||
)
|
||||
|
||||
|
|
@ -60,30 +64,33 @@ defmodule Openflow.Multipart.PortStats do
|
|||
# private functions
|
||||
|
||||
defp do_read(acc, ""), do: Enum.reverse(acc)
|
||||
|
||||
defp do_read(acc, <<port_stats_bin::112-bytes, rest::bytes>>) do
|
||||
do_read([codec(port_stats_bin)|acc], rest)
|
||||
do_read([codec(port_stats_bin) | acc], rest)
|
||||
end
|
||||
|
||||
defp codec(<<port_no::32, _::size(4)-unit(8), rx_packets::64,
|
||||
tx_packets::64, rx_bytes::64, tx_bytes::64,
|
||||
rx_dropped::64, tx_dropped::64, rx_errors::64,
|
||||
tx_errors::64, rx_frame_err::64, rx_over_err::64,
|
||||
rx_crc_err::64, collisions::64,
|
||||
duration_sec::32, duration_nsec::32>>) do
|
||||
%PortStats{port_number: port_no,
|
||||
rx_packets: rx_packets,
|
||||
tx_packets: tx_packets,
|
||||
rx_bytes: rx_bytes,
|
||||
tx_bytes: tx_bytes,
|
||||
rx_dropped: rx_dropped,
|
||||
tx_dropped: tx_dropped,
|
||||
rx_errors: rx_errors,
|
||||
tx_errors: tx_errors,
|
||||
rx_frame_err: rx_frame_err,
|
||||
rx_over_err: rx_over_err,
|
||||
rx_crc_err: rx_crc_err,
|
||||
collisions: collisions,
|
||||
duration_sec: duration_sec,
|
||||
duration_nsec: duration_nsec}
|
||||
defp codec(
|
||||
<<port_no::32, _::size(4)-unit(8), rx_packets::64, tx_packets::64, rx_bytes::64,
|
||||
tx_bytes::64, rx_dropped::64, tx_dropped::64, rx_errors::64, tx_errors::64,
|
||||
rx_frame_err::64, rx_over_err::64, rx_crc_err::64, collisions::64, duration_sec::32,
|
||||
duration_nsec::32>>
|
||||
) do
|
||||
%PortStats{
|
||||
port_number: port_no,
|
||||
rx_packets: rx_packets,
|
||||
tx_packets: tx_packets,
|
||||
rx_bytes: rx_bytes,
|
||||
tx_bytes: tx_bytes,
|
||||
rx_dropped: rx_dropped,
|
||||
tx_dropped: tx_dropped,
|
||||
rx_errors: rx_errors,
|
||||
tx_errors: tx_errors,
|
||||
rx_frame_err: rx_frame_err,
|
||||
rx_over_err: rx_over_err,
|
||||
rx_crc_err: rx_crc_err,
|
||||
collisions: collisions,
|
||||
duration_sec: duration_sec,
|
||||
duration_nsec: duration_nsec
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
defmodule Openflow.Multipart.PortStats.Request do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: nil, # virtual field
|
||||
version: 4,
|
||||
xid: 0,
|
||||
# virtual field
|
||||
datapath_id: nil,
|
||||
flags: [],
|
||||
port_number: :any
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue