Refactored nicira extended actions

This commit is contained in:
Eishun Kondoh 2019-03-18 13:31:36 +09:00
parent efd08cf6dd
commit ffcba91395
51 changed files with 1015 additions and 819 deletions

View file

@ -4,18 +4,22 @@ defmodule Openflow.Action.NxPushMpls do
@experimenter 0x00002320
@nxast 23
alias __MODULE__
@eth_p_mpls_uc 0x8847
def new(ethertype \\ 0x8847) do
alias __MODULE__
alias Openflow.Action.Experimenter
def new(ethertype \\ @eth_p_mpls_uc) do
%NxPushMpls{ethertype: ethertype}
end
def to_binary(%NxPushMpls{ethertype: ethertype}) do
exp_body = <<@experimenter::32, @nxast::16, ethertype::16, 0::size(4)-unit(8)>>
exp_body_size = byte_size(exp_body)
padding_length = Openflow.Utils.padding(4 + exp_body_size, 8)
length = 4 + exp_body_size + padding_length
<<0xFFFF::16, length::16, exp_body::bytes, 0::size(padding_length)-unit(8)>>
Experimenter.pack_exp_header(<<
@experimenter::32,
@nxast::16,
ethertype::16,
0::size(4)-unit(8)
>>)
end
def read(<<@experimenter::32, @nxast::16, ethertype::16, _::size(4)-unit(8)>>) do