docs: Add documents for openflow actions

This commit is contained in:
Eishun Kondoh 2019-03-20 11:02:26 +09:00
parent 15d8fd57f3
commit eda1fc5727
11 changed files with 214 additions and 9 deletions

View file

@ -1,18 +1,38 @@
defmodule Openflow.Action.SetMplsTtl do
@moduledoc """
Replace the existing MPLS TTL.\\
Only applies to the packets with an existing MPLS shim header.
"""
defstruct(ttl: 0)
alias __MODULE__
@type t :: %SetMplsTtl{ttl: 0..0xFF}
@spec ofpat() :: 15
def ofpat, do: 15
@doc """
Create a set_mpls_ttl action structure
## Example:
```elixir
iex> %SetMplsTtl{ttl: 64} = Openflow.Action.SetMplsTtl.new(64)
```
"""
@deprecated "OFPAT_SET_MPLS_TTL is deprecated in OpenFlow13, use SetField"
@spec new(0..0xFF) :: SetMplsTtl.t()
def new(ttl) do
%SetMplsTtl{ttl: ttl}
end
@spec to_binary(SetMplsTtl.t()) :: <<_::16, _::_*8>>
def to_binary(%SetMplsTtl{ttl: ttl}) do
<<15::16, 8::16, ttl::8, 0::size(3)-unit(8)>>
end
@spec read(<<_::16, _::_*8>>) :: SetMplsTtl.t()
def read(<<15::16, 8::16, ttl::8, _::size(3)-unit(8)>>) do
%SetMplsTtl{ttl: ttl}
end