quality: Add test cases for meter_mod message
This commit is contained in:
parent
a0ee397921
commit
c5e38155e1
4 changed files with 102 additions and 21 deletions
|
|
@ -6,17 +6,17 @@ defmodule Openflow.MeterBand.Drop do
|
|||
|
||||
alias __MODULE__
|
||||
|
||||
def new(options) do
|
||||
rate = Keyword.get(options, :rate, 0)
|
||||
burst_size = Keyword.get(options, :burst_size, 0)
|
||||
%Drop{rate: rate, burst_size: burst_size}
|
||||
end
|
||||
@type t :: %Drop{rate: 0..0xFFFFFFFF, burst_size: 0..0xFFFFFFFF}
|
||||
|
||||
def read(<<1::16, 16::16, rate::32, burst_size::32, _::size(4)-unit(8)>>) do
|
||||
%Drop{rate: rate, burst_size: burst_size}
|
||||
end
|
||||
@spec new(rate: 0..0xFFFFFFFF, burst_size: 0..0xFFFFFFFF) :: t()
|
||||
def new(options),
|
||||
do: %Drop{rate: options[:rate] || 0, burst_size: options[:burst_size] || 0}
|
||||
|
||||
def to_binary(%Drop{rate: rate, burst_size: burst_size}) do
|
||||
<<1::16, 16::16, rate::32, burst_size::32, 0::size(4)-unit(8)>>
|
||||
end
|
||||
@spec read(<<_::128>>) :: t()
|
||||
def read(<<1::16, 16::16, rate::32, burst_size::32, _::size(4)-unit(8)>>),
|
||||
do: %Drop{rate: rate, burst_size: burst_size}
|
||||
|
||||
@spec to_binary(t()) :: <<_::128>>
|
||||
def to_binary(%Drop{rate: rate, burst_size: burst_size}),
|
||||
do: <<1::16, 16::16, rate::32, burst_size::32, 0::size(4)-unit(8)>>
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue