quality: Add some test cases for openflow messages

This commit is contained in:
Eishun Kondoh 2019-04-28 11:47:05 +09:00
parent 578c0d1bdc
commit f3fc896408
13 changed files with 1403 additions and 1321 deletions

View file

@ -11,11 +11,38 @@ defmodule Openflow.Features.Reply do
alias __MODULE__
@type t :: %Reply{
version: 4,
xid: 0..0xFFFFFFFF,
datapath_id: String.t() | nil,
n_buffers: 0..0xFFFFFFFF,
n_tables: 0..0xFF,
aux_id: 0..0xFF,
capabilities: [
:flow_stats
| :table_stats
| :port_stats
| :group_stats
| :ip_reasm
| :queue_stats
| :arp_match_ip
| :port_blocked
]
}
@spec ofp_type :: 6
def ofp_type, do: 6
def read(
<<datapath_id::64-bits, n_buf::32, n_tab::8, aux_id::8, _pad::16, caps_int::32, _rsv::32>>
) do
@spec read(<<_::192>>) :: t()
def read(<<
datapath_id::64-bits,
n_buf::32,
n_tab::8,
aux_id::8,
_pad::16,
caps_int::32,
_rsv::32
>>) do
dpid = Openflow.Utils.to_hex_string(datapath_id)
flags = Openflow.Enums.int_to_flags(caps_int, :switch_capabilities)
@ -28,6 +55,7 @@ defmodule Openflow.Features.Reply do
}
end
@spec to_binary(t()) :: <<_::192>>
def to_binary(%Reply{
datapath_id: datapath_id,
n_buffers: n_buf,