openflow/match: Refactored

This commit is contained in:
Eishun Kondoh 2019-07-09 11:58:23 +09:00
parent e65bf77a3c
commit 9ddd82fcab
27 changed files with 1201 additions and 1584 deletions

View file

@ -53,7 +53,7 @@ defmodule Openflow.Action.NxBundleLoad do
) :: t()
def new(options \\ []) do
dst_field = options[:dst_field] || raise "dst_field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(dst_field)
default_n_bits = Openflow.Match.n_bits_of(dst_field)
slaves = options[:slaves] || []
%NxBundleLoad{

View file

@ -31,7 +31,7 @@ defmodule Openflow.Action.NxFlowSpecLoad do
def new(options) do
dst = options[:dst] || raise(":dst must be specified")
src = options[:src] || raise(":src must be specified")
n_bits = options[:n_bits] || Openflow.Match.Field.n_bits_of(dst)
n_bits = options[:n_bits] || Openflow.Match.n_bits_of(dst)
%NxFlowSpecLoad{
src: src,
@ -90,7 +90,7 @@ defmodule Openflow.Action.NxFlowSpecLoad do
binary
dst = Openflow.Match.codec_header(dst_bin)
src = Openflow.Match.Field.codec(src_bin, dst)
src = Openflow.Match.decode_value(src_bin, dst)
flow_spec = %NxFlowSpecLoad{src: src, dst: dst, n_bits: n_bits, dst_offset: dst_ofs}
{flow_spec, rest}
end
@ -103,7 +103,7 @@ defmodule Openflow.Action.NxFlowSpecLoad do
end
defp codec_src(%NxFlowSpecLoad{src: src, dst: dst_field}) do
src_bin = Openflow.Match.Field.codec(src, dst_field)
src_bin = Openflow.Match.encode_value(src, dst_field)
{@learn_src_immediate, src_bin}
end
end

View file

@ -31,7 +31,7 @@ defmodule Openflow.Action.NxFlowSpecMatch do
def new(options \\ []) do
dst = options[:dst] || raise ":dst must be specified"
src = options[:src] || raise ":src must be specified"
n_bits = options[:n_bits] || Openflow.Match.Field.n_bits_of(dst)
n_bits = options[:n_bits] || Openflow.Match.n_bits_of(dst)
%NxFlowSpecMatch{
src: src,
@ -92,7 +92,7 @@ defmodule Openflow.Action.NxFlowSpecMatch do
binary
dst = Openflow.Match.codec_header(dst_bin)
src = Openflow.Match.Field.codec(src_bin, dst)
src = Openflow.Match.decode_value(src_bin, dst)
flow_spec = %NxFlowSpecMatch{src: src, dst: dst, n_bits: n_bits, dst_offset: dst_ofs}
{flow_spec, rest}
end
@ -105,7 +105,7 @@ defmodule Openflow.Action.NxFlowSpecMatch do
end
defp codec_src(%NxFlowSpecMatch{src: src, dst: dst_field}) do
src_bin = Openflow.Match.Field.codec(src, dst_field)
src_bin = Openflow.Match.encode_value(src, dst_field)
{@learn_src_immediate, src_bin}
end
end

View file

@ -19,7 +19,7 @@ defmodule Openflow.Action.NxFlowSpecOutput do
@spec new(src: atom(), n_bits: non_neg_integer(), src_offset: non_neg_integer()) :: t()
def new(options \\ []) do
src = options[:src] || raise ":src must be specified"
n_bits = options[:n_bits] || Openflow.Match.Field.n_bits_of(src)
n_bits = options[:n_bits] || Openflow.Match.n_bits_of(src)
%NxFlowSpecOutput{n_bits: n_bits, src: src, src_offset: options[:src_offset] || 0}
end

View file

@ -21,7 +21,7 @@ defmodule Openflow.Action.NxMultipath do
@spec new(Keyword.t()) :: %NxMultipath{}
def new(options) do
dst_field = options[:dst_field] || raise "dst_field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(dst_field)
default_n_bits = Openflow.Match.n_bits_of(dst_field)
%NxMultipath{
hash_field: options[:hash_field] || :eth_src,

View file

@ -30,7 +30,7 @@ defmodule Openflow.Action.NxOutputReg do
) :: t()
def new(options) do
src_field = options[:src_field] || raise "src_field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(src_field)
default_n_bits = Openflow.Match.n_bits_of(src_field)
%NxOutputReg{
n_bits: options[:n_bits] || default_n_bits,

View file

@ -30,7 +30,7 @@ defmodule Openflow.Action.NxOutputReg2 do
) :: t()
def new(options) do
src_field = options[:src_field] || raise "src_field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(src_field)
default_n_bits = Openflow.Match.n_bits_of(src_field)
%NxOutputReg2{
n_bits: options[:n_bits] || default_n_bits,

View file

@ -45,7 +45,7 @@ defmodule Openflow.Action.NxRegLoad do
def new(options \\ []) do
dst_field = options[:dst_field] || raise "dst_field must be specified"
value = options[:value] || raise "value must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(dst_field)
default_n_bits = Openflow.Match.n_bits_of(dst_field)
%NxRegLoad{
n_bits: options[:n_bits] || default_n_bits,
@ -61,7 +61,7 @@ defmodule Openflow.Action.NxRegLoad do
value_int =
load.value
|> Openflow.Match.Field.codec(load.dst_field)
|> Openflow.Match.encode_value(load.dst_field)
|> :binary.decode_unsigned(:big)
Experimenter.pack_exp_header(<<
@ -76,7 +76,7 @@ defmodule Openflow.Action.NxRegLoad do
def read(<<@experimenter::32, @nxast::16, body::bytes>>) do
<<ofs::10, n_bits::6, dst_field_bin::4-bytes, value_bin::bytes>> = body
dst_field = Openflow.Match.codec_header(dst_field_bin)
value = Openflow.Match.Field.codec(value_bin, dst_field)
value = Openflow.Match.decode_value(value_bin, dst_field)
%NxRegLoad{n_bits: n_bits + 1, offset: ofs, dst_field: dst_field, value: value}
end
end

View file

@ -147,7 +147,7 @@ defmodule Openflow.Action.NxRegMove do
def new(options \\ []) do
src_field = options[:src_field] || raise "src_field must be specified"
dst_field = options[:dst_field] || raise "dst_field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(dst_field)
default_n_bits = Openflow.Match.n_bits_of(dst_field)
%NxRegMove{
n_bits: options[:n_bits] || default_n_bits,

View file

@ -13,7 +13,7 @@ defmodule Openflow.Action.NxStackPop do
def new(options) do
field = options[:field] || raise "field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(field)
default_n_bits = Openflow.Match.n_bits_of(field)
%NxStackPop{
n_bits: options[:n_bits] || default_n_bits,

View file

@ -13,7 +13,7 @@ defmodule Openflow.Action.NxStackPush do
def new(options) do
field = options[:field] || raise "field must be specified"
default_n_bits = Openflow.Match.Field.n_bits_of(field)
default_n_bits = Openflow.Match.n_bits_of(field)
%NxStackPush{
n_bits: options[:n_bits] || default_n_bits,

View file

@ -2725,176 +2725,20 @@ defmodule Openflow.Enums do
_class, _reason -> :pbb_uca
end
def to_int(:packet_type, :openflow_basic) do
openflow_basic_to_int(:packet_type)
catch
_class, _reason -> :packet_type
end
def to_int(:gre_flags, :openflow_basic) do
openflow_basic_to_int(:gre_flags)
catch
_class, _reason -> :gre_flags
end
def to_int(:gre_ver, :openflow_basic) do
openflow_basic_to_int(:gre_ver)
catch
_class, _reason -> :gre_ver
end
def to_int(:gre_protocol, :openflow_basic) do
openflow_basic_to_int(:gre_protocol)
catch
_class, _reason -> :gre_protocol
end
def to_int(:gre_key, :openflow_basic) do
openflow_basic_to_int(:gre_key)
catch
_class, _reason -> :gre_key
end
def to_int(:gre_seqnum, :openflow_basic) do
openflow_basic_to_int(:gre_seqnum)
catch
_class, _reason -> :gre_seqnum
end
def to_int(:lisp_flags, :openflow_basic) do
openflow_basic_to_int(:lisp_flags)
catch
_class, _reason -> :lisp_flags
end
def to_int(:lisp_nonce, :openflow_basic) do
openflow_basic_to_int(:lisp_nonce)
catch
_class, _reason -> :lisp_nonce
end
def to_int(:lisp_id, :openflow_basic) do
openflow_basic_to_int(:lisp_id)
catch
_class, _reason -> :lisp_id
end
def to_int(:vxlan_flags, :openflow_basic) do
openflow_basic_to_int(:vxlan_flags)
catch
_class, _reason -> :vxlan_flags
end
def to_int(:vxlan_vni, :openflow_basic) do
openflow_basic_to_int(:vxlan_vni)
catch
_class, _reason -> :vxlan_vni
end
def to_int(:mpls_data_first_nibble, :openflow_basic) do
openflow_basic_to_int(:mpls_data_first_nibble)
catch
_class, _reason -> :mpls_data_first_nibble
end
def to_int(:mpls_ach_version, :openflow_basic) do
openflow_basic_to_int(:mpls_ach_version)
catch
_class, _reason -> :mpls_ach_version
end
def to_int(:mpls_ach_channel, :openflow_basic) do
openflow_basic_to_int(:mpls_ach_channel)
catch
_class, _reason -> :mpls_ach_channel
end
def to_int(:mpls_pw_metadata, :openflow_basic) do
openflow_basic_to_int(:mpls_pw_metadata)
catch
_class, _reason -> :mpls_pw_metadata
end
def to_int(:mpls_cw_flags, :openflow_basic) do
openflow_basic_to_int(:mpls_cw_flags)
catch
_class, _reason -> :mpls_cw_flags
end
def to_int(:mpls_cw_fragment, :openflow_basic) do
openflow_basic_to_int(:mpls_cw_fragment)
catch
_class, _reason -> :mpls_cw_fragment
end
def to_int(:mpls_cw_len, :openflow_basic) do
openflow_basic_to_int(:mpls_cw_len)
catch
_class, _reason -> :mpls_cw_len
end
def to_int(:mpls_cw_seq_num, :openflow_basic) do
openflow_basic_to_int(:mpls_cw_seq_num)
catch
_class, _reason -> :mpls_cw_seq_num
end
def to_int(:gtpu_flags, :openflow_basic) do
openflow_basic_to_int(:gtpu_flags)
catch
_class, _reason -> :gtpu_flags
end
def to_int(:gtpu_ver, :openflow_basic) do
openflow_basic_to_int(:gtpu_ver)
catch
_class, _reason -> :gtpu_ver
end
def to_int(:gtpu_msg_type, :openflow_basic) do
openflow_basic_to_int(:gtpu_msg_type)
catch
_class, _reason -> :gtpu_msg_type
end
def to_int(:gtpu_teid, :openflow_basic) do
openflow_basic_to_int(:gtpu_teid)
catch
_class, _reason -> :gtpu_teid
end
def to_int(:gtpu_extn_hdr, :openflow_basic) do
openflow_basic_to_int(:gtpu_extn_hdr)
catch
_class, _reason -> :gtpu_extn_hdr
end
def to_int(:gtpu_extn_udp_port, :openflow_basic) do
openflow_basic_to_int(:gtpu_extn_udp_port)
catch
_class, _reason -> :gtpu_extn_udp_port
end
def to_int(:gtpu_extn_sci, :openflow_basic) do
openflow_basic_to_int(:gtpu_extn_sci)
catch
_class, _reason -> :gtpu_extn_sci
end
def to_int(_int, :openflow_basic) do
throw(:bad_enum)
end
def to_int(:present, :vlan_id) do
vlan_id_to_int(:present)
def to_int(:vid_present, :vlan_id) do
vlan_id_to_int(:vid_present)
catch
_class, _reason -> :present
_class, _reason -> :vid_present
end
def to_int(:none, :vlan_id) do
vlan_id_to_int(:none)
def to_int(:vid_none, :vlan_id) do
vlan_id_to_int(:vid_none)
catch
_class, _reason -> :none
_class, _reason -> :vid_none
end
def to_int(_int, :vlan_id) do
@ -3017,6 +2861,22 @@ defmodule Openflow.Enums do
throw(:bad_enum)
end
def to_int(:policy_applied, :tun_gbp_flags) do
tun_gbp_flags_to_int(:policy_applied)
catch
_class, _reason -> :policy_applied
end
def to_int(:dont_learn, :tun_gbp_flags) do
tun_gbp_flags_to_int(:dont_learn)
catch
_class, _reason -> :dont_learn
end
def to_int(_int, :tun_gbp_flags) do
throw(:bad_enum)
end
def to_int(:new, :ct_state_flags) do
ct_state_flags_to_int(:new)
catch
@ -3175,90 +3035,16 @@ defmodule Openflow.Enums do
_class, _reason -> :nsh_c4
end
def to_int(:nsh_ttl, :nicira_ext_match) do
nicira_ext_match_to_int(:nsh_ttl)
catch
_class, _reason -> :nsh_ttl
end
def to_int(_int, :nicira_ext_match) do
throw(:bad_enum)
end
def to_int(:hp_udp_src_port_range, :hp_ext_match) do
hp_ext_match_to_int(:hp_udp_src_port_range)
catch
_class, _reason -> :hp_udp_src_port_range
end
def to_int(:hp_udp_dst_port_range, :hp_ext_match) do
hp_ext_match_to_int(:hp_udp_dst_port_range)
catch
_class, _reason -> :hp_udp_dst_port_range
end
def to_int(:hp_tcp_src_port_range, :hp_ext_match) do
hp_ext_match_to_int(:hp_tcp_src_port_range)
catch
_class, _reason -> :hp_tcp_src_port_range
end
def to_int(:hp_tcp_dst_port_range, :hp_ext_match) do
hp_ext_match_to_int(:hp_tcp_dst_port_range)
catch
_class, _reason -> :hp_tcp_dst_port_range
end
def to_int(:hp_tcp_flags, :hp_ext_match) do
hp_ext_match_to_int(:hp_tcp_flags)
catch
_class, _reason -> :hp_tcp_flags
end
def to_int(:hp_custom_1, :hp_ext_match) do
hp_ext_match_to_int(:hp_custom_1)
catch
_class, _reason -> :hp_custom_1
end
def to_int(:hp_custom_2, :hp_ext_match) do
hp_ext_match_to_int(:hp_custom_2)
catch
_class, _reason -> :hp_custom_2
end
def to_int(:hp_custom_3, :hp_ext_match) do
hp_ext_match_to_int(:hp_custom_3)
catch
_class, _reason -> :hp_custom_3
end
def to_int(:hp_custom_4, :hp_ext_match) do
hp_ext_match_to_int(:hp_custom_4)
catch
_class, _reason -> :hp_custom_4
end
def to_int(_int, :hp_ext_match) do
throw(:bad_enum)
end
def to_int(:l2_start, :hp_custom_match_type) do
hp_custom_match_type_to_int(:l2_start)
catch
_class, _reason -> :l2_start
end
def to_int(:l3_start, :hp_custom_match_type) do
hp_custom_match_type_to_int(:l3_start)
catch
_class, _reason -> :l3_start
end
def to_int(:l4_start, :hp_custom_match_type) do
hp_custom_match_type_to_int(:l4_start)
catch
_class, _reason -> :l4_start
end
def to_int(_int, :hp_custom_match_type) do
throw(:bad_enum)
end
def to_int(:onf_tcp_flags, :onf_ext_match) do
onf_ext_match_to_int(:onf_tcp_flags)
catch
@ -8141,162 +7927,6 @@ defmodule Openflow.Enums do
_class, _reason -> 41
end
def to_atom(0x2A, :openflow_basic) do
openflow_basic_to_atom(0x2A)
catch
_class, _reason -> 42
end
def to_atom(0x2B, :openflow_basic) do
openflow_basic_to_atom(0x2B)
catch
_class, _reason -> 43
end
def to_atom(0x2C, :openflow_basic) do
openflow_basic_to_atom(0x2C)
catch
_class, _reason -> 44
end
def to_atom(0x2D, :openflow_basic) do
openflow_basic_to_atom(0x2D)
catch
_class, _reason -> 45
end
def to_atom(0x2E, :openflow_basic) do
openflow_basic_to_atom(0x2E)
catch
_class, _reason -> 46
end
def to_atom(0x2F, :openflow_basic) do
openflow_basic_to_atom(0x2F)
catch
_class, _reason -> 47
end
def to_atom(0x30, :openflow_basic) do
openflow_basic_to_atom(0x30)
catch
_class, _reason -> 48
end
def to_atom(0x31, :openflow_basic) do
openflow_basic_to_atom(0x31)
catch
_class, _reason -> 49
end
def to_atom(0x32, :openflow_basic) do
openflow_basic_to_atom(0x32)
catch
_class, _reason -> 50
end
def to_atom(0x33, :openflow_basic) do
openflow_basic_to_atom(0x33)
catch
_class, _reason -> 51
end
def to_atom(0x34, :openflow_basic) do
openflow_basic_to_atom(0x34)
catch
_class, _reason -> 52
end
def to_atom(0x35, :openflow_basic) do
openflow_basic_to_atom(0x35)
catch
_class, _reason -> 53
end
def to_atom(0x36, :openflow_basic) do
openflow_basic_to_atom(0x36)
catch
_class, _reason -> 54
end
def to_atom(0x37, :openflow_basic) do
openflow_basic_to_atom(0x37)
catch
_class, _reason -> 55
end
def to_atom(0x38, :openflow_basic) do
openflow_basic_to_atom(0x38)
catch
_class, _reason -> 56
end
def to_atom(0x39, :openflow_basic) do
openflow_basic_to_atom(0x39)
catch
_class, _reason -> 57
end
def to_atom(0x3A, :openflow_basic) do
openflow_basic_to_atom(0x3A)
catch
_class, _reason -> 58
end
def to_atom(0x3B, :openflow_basic) do
openflow_basic_to_atom(0x3B)
catch
_class, _reason -> 59
end
def to_atom(0x3C, :openflow_basic) do
openflow_basic_to_atom(0x3C)
catch
_class, _reason -> 60
end
def to_atom(0x3D, :openflow_basic) do
openflow_basic_to_atom(0x3D)
catch
_class, _reason -> 61
end
def to_atom(0x3E, :openflow_basic) do
openflow_basic_to_atom(0x3E)
catch
_class, _reason -> 62
end
def to_atom(0x3F, :openflow_basic) do
openflow_basic_to_atom(0x3F)
catch
_class, _reason -> 63
end
def to_atom(0x40, :openflow_basic) do
openflow_basic_to_atom(0x40)
catch
_class, _reason -> 64
end
def to_atom(0x41, :openflow_basic) do
openflow_basic_to_atom(0x41)
catch
_class, _reason -> 65
end
def to_atom(0x42, :openflow_basic) do
openflow_basic_to_atom(0x42)
catch
_class, _reason -> 66
end
def to_atom(0x43, :openflow_basic) do
openflow_basic_to_atom(0x43)
catch
_class, _reason -> 67
end
def to_atom(_, :openflow_basic) do
throw(:bad_enum)
end
@ -8433,6 +8063,22 @@ defmodule Openflow.Enums do
throw(:bad_enum)
end
def to_atom(0x8, :tun_gbp_flags) do
tun_gbp_flags_to_atom(0x8)
catch
_class, _reason -> 8
end
def to_atom(0x40, :tun_gbp_flags) do
tun_gbp_flags_to_atom(0x40)
catch
_class, _reason -> 64
end
def to_atom(_, :tun_gbp_flags) do
throw(:bad_enum)
end
def to_atom(0x1, :ct_state_flags) do
ct_state_flags_to_atom(0x1)
catch
@ -8591,90 +8237,16 @@ defmodule Openflow.Enums do
_class, _reason -> 9
end
def to_atom(0xA, :nicira_ext_match) do
nicira_ext_match_to_atom(0xA)
catch
_class, _reason -> 10
end
def to_atom(_, :nicira_ext_match) do
throw(:bad_enum)
end
def to_atom(0x0, :hp_ext_match) do
hp_ext_match_to_atom(0x0)
catch
_class, _reason -> 0
end
def to_atom(0x1, :hp_ext_match) do
hp_ext_match_to_atom(0x1)
catch
_class, _reason -> 1
end
def to_atom(0x2, :hp_ext_match) do
hp_ext_match_to_atom(0x2)
catch
_class, _reason -> 2
end
def to_atom(0x3, :hp_ext_match) do
hp_ext_match_to_atom(0x3)
catch
_class, _reason -> 3
end
def to_atom(0x4, :hp_ext_match) do
hp_ext_match_to_atom(0x4)
catch
_class, _reason -> 4
end
def to_atom(0x5, :hp_ext_match) do
hp_ext_match_to_atom(0x5)
catch
_class, _reason -> 5
end
def to_atom(0x6, :hp_ext_match) do
hp_ext_match_to_atom(0x6)
catch
_class, _reason -> 6
end
def to_atom(0x7, :hp_ext_match) do
hp_ext_match_to_atom(0x7)
catch
_class, _reason -> 7
end
def to_atom(0x8, :hp_ext_match) do
hp_ext_match_to_atom(0x8)
catch
_class, _reason -> 8
end
def to_atom(_, :hp_ext_match) do
throw(:bad_enum)
end
def to_atom(0x1, :hp_custom_match_type) do
hp_custom_match_type_to_atom(0x1)
catch
_class, _reason -> 1
end
def to_atom(0x2, :hp_custom_match_type) do
hp_custom_match_type_to_atom(0x2)
catch
_class, _reason -> 2
end
def to_atom(0x3, :hp_custom_match_type) do
hp_custom_match_type_to_atom(0x3)
catch
_class, _reason -> 3
end
def to_atom(_, :hp_custom_match_type) do
throw(:bad_enum)
end
def to_atom(0x2A, :onf_ext_match) do
onf_ext_match_to_atom(0x2A)
catch
@ -11722,32 +11294,6 @@ defmodule Openflow.Enums do
def openflow_basic_to_int(:tunnel_id), do: 0x26
def openflow_basic_to_int(:ipv6_exthdr), do: 0x27
def openflow_basic_to_int(:pbb_uca), do: 0x29
def openflow_basic_to_int(:packet_type), do: 0x2A
def openflow_basic_to_int(:gre_flags), do: 0x2B
def openflow_basic_to_int(:gre_ver), do: 0x2C
def openflow_basic_to_int(:gre_protocol), do: 0x2D
def openflow_basic_to_int(:gre_key), do: 0x2E
def openflow_basic_to_int(:gre_seqnum), do: 0x2F
def openflow_basic_to_int(:lisp_flags), do: 0x30
def openflow_basic_to_int(:lisp_nonce), do: 0x31
def openflow_basic_to_int(:lisp_id), do: 0x32
def openflow_basic_to_int(:vxlan_flags), do: 0x33
def openflow_basic_to_int(:vxlan_vni), do: 0x34
def openflow_basic_to_int(:mpls_data_first_nibble), do: 0x35
def openflow_basic_to_int(:mpls_ach_version), do: 0x36
def openflow_basic_to_int(:mpls_ach_channel), do: 0x37
def openflow_basic_to_int(:mpls_pw_metadata), do: 0x38
def openflow_basic_to_int(:mpls_cw_flags), do: 0x39
def openflow_basic_to_int(:mpls_cw_fragment), do: 0x3A
def openflow_basic_to_int(:mpls_cw_len), do: 0x3B
def openflow_basic_to_int(:mpls_cw_seq_num), do: 0x3C
def openflow_basic_to_int(:gtpu_flags), do: 0x3D
def openflow_basic_to_int(:gtpu_ver), do: 0x3E
def openflow_basic_to_int(:gtpu_msg_type), do: 0x3F
def openflow_basic_to_int(:gtpu_teid), do: 0x40
def openflow_basic_to_int(:gtpu_extn_hdr), do: 0x41
def openflow_basic_to_int(:gtpu_extn_udp_port), do: 0x42
def openflow_basic_to_int(:gtpu_extn_sci), do: 0x43
def openflow_basic_to_int(_), do: throw(:bad_enum)
def openflow_basic_to_atom(0x0), do: :in_port
def openflow_basic_to_atom(0x1), do: :in_phy_port
@ -11790,38 +11336,12 @@ defmodule Openflow.Enums do
def openflow_basic_to_atom(0x26), do: :tunnel_id
def openflow_basic_to_atom(0x27), do: :ipv6_exthdr
def openflow_basic_to_atom(0x29), do: :pbb_uca
def openflow_basic_to_atom(0x2A), do: :packet_type
def openflow_basic_to_atom(0x2B), do: :gre_flags
def openflow_basic_to_atom(0x2C), do: :gre_ver
def openflow_basic_to_atom(0x2D), do: :gre_protocol
def openflow_basic_to_atom(0x2E), do: :gre_key
def openflow_basic_to_atom(0x2F), do: :gre_seqnum
def openflow_basic_to_atom(0x30), do: :lisp_flags
def openflow_basic_to_atom(0x31), do: :lisp_nonce
def openflow_basic_to_atom(0x32), do: :lisp_id
def openflow_basic_to_atom(0x33), do: :vxlan_flags
def openflow_basic_to_atom(0x34), do: :vxlan_vni
def openflow_basic_to_atom(0x35), do: :mpls_data_first_nibble
def openflow_basic_to_atom(0x36), do: :mpls_ach_version
def openflow_basic_to_atom(0x37), do: :mpls_ach_channel
def openflow_basic_to_atom(0x38), do: :mpls_pw_metadata
def openflow_basic_to_atom(0x39), do: :mpls_cw_flags
def openflow_basic_to_atom(0x3A), do: :mpls_cw_fragment
def openflow_basic_to_atom(0x3B), do: :mpls_cw_len
def openflow_basic_to_atom(0x3C), do: :mpls_cw_seq_num
def openflow_basic_to_atom(0x3D), do: :gtpu_flags
def openflow_basic_to_atom(0x3E), do: :gtpu_ver
def openflow_basic_to_atom(0x3F), do: :gtpu_msg_type
def openflow_basic_to_atom(0x40), do: :gtpu_teid
def openflow_basic_to_atom(0x41), do: :gtpu_extn_hdr
def openflow_basic_to_atom(0x42), do: :gtpu_extn_udp_port
def openflow_basic_to_atom(0x43), do: :gtpu_extn_sci
def openflow_basic_to_atom(_), do: throw(:bad_enum)
def vlan_id_to_int(:present), do: 0x1000
def vlan_id_to_int(:none), do: 0x0
def vlan_id_to_int(:vid_present), do: 0x1000
def vlan_id_to_int(:vid_none), do: 0x0
def vlan_id_to_int(_), do: throw(:bad_enum)
def vlan_id_to_atom(0x1000), do: :present
def vlan_id_to_atom(0x0), do: :none
def vlan_id_to_atom(0x1000), do: :vid_present
def vlan_id_to_atom(0x0), do: :vid_none
def vlan_id_to_atom(_), do: throw(:bad_enum)
def ipv6exthdr_flags_to_int(:nonext), do: 0x1
def ipv6exthdr_flags_to_int(:esp), do: 0x2
@ -11863,6 +11383,12 @@ defmodule Openflow.Enums do
def tcp_flags_to_atom(0x80), do: :cwr
def tcp_flags_to_atom(0x100), do: :ns
def tcp_flags_to_atom(_), do: throw(:bad_enum)
def tun_gbp_flags_to_int(:policy_applied), do: 0x8
def tun_gbp_flags_to_int(:dont_learn), do: 0x40
def tun_gbp_flags_to_int(_), do: throw(:bad_enum)
def tun_gbp_flags_to_atom(0x8), do: :policy_applied
def tun_gbp_flags_to_atom(0x40), do: :dont_learn
def tun_gbp_flags_to_atom(_), do: throw(:bad_enum)
def ct_state_flags_to_int(:new), do: 0x1
def ct_state_flags_to_int(:est), do: 0x2
def ct_state_flags_to_int(:rel), do: 0x4
@ -11908,6 +11434,7 @@ defmodule Openflow.Enums do
def nicira_ext_match_to_int(:nsh_c2), do: 0x7
def nicira_ext_match_to_int(:nsh_c3), do: 0x8
def nicira_ext_match_to_int(:nsh_c4), do: 0x9
def nicira_ext_match_to_int(:nsh_ttl), do: 0xA
def nicira_ext_match_to_int(_), do: throw(:bad_enum)
def nicira_ext_match_to_atom(0x1), do: :nsh_flags
def nicira_ext_match_to_atom(0x2), do: :nsh_mdtype
@ -11918,35 +11445,8 @@ defmodule Openflow.Enums do
def nicira_ext_match_to_atom(0x7), do: :nsh_c2
def nicira_ext_match_to_atom(0x8), do: :nsh_c3
def nicira_ext_match_to_atom(0x9), do: :nsh_c4
def nicira_ext_match_to_atom(0xA), do: :nsh_ttl
def nicira_ext_match_to_atom(_), do: throw(:bad_enum)
def hp_ext_match_to_int(:hp_udp_src_port_range), do: 0x0
def hp_ext_match_to_int(:hp_udp_dst_port_range), do: 0x1
def hp_ext_match_to_int(:hp_tcp_src_port_range), do: 0x2
def hp_ext_match_to_int(:hp_tcp_dst_port_range), do: 0x3
def hp_ext_match_to_int(:hp_tcp_flags), do: 0x4
def hp_ext_match_to_int(:hp_custom_1), do: 0x5
def hp_ext_match_to_int(:hp_custom_2), do: 0x6
def hp_ext_match_to_int(:hp_custom_3), do: 0x7
def hp_ext_match_to_int(:hp_custom_4), do: 0x8
def hp_ext_match_to_int(_), do: throw(:bad_enum)
def hp_ext_match_to_atom(0x0), do: :hp_udp_src_port_range
def hp_ext_match_to_atom(0x1), do: :hp_udp_dst_port_range
def hp_ext_match_to_atom(0x2), do: :hp_tcp_src_port_range
def hp_ext_match_to_atom(0x3), do: :hp_tcp_dst_port_range
def hp_ext_match_to_atom(0x4), do: :hp_tcp_flags
def hp_ext_match_to_atom(0x5), do: :hp_custom_1
def hp_ext_match_to_atom(0x6), do: :hp_custom_2
def hp_ext_match_to_atom(0x7), do: :hp_custom_3
def hp_ext_match_to_atom(0x8), do: :hp_custom_4
def hp_ext_match_to_atom(_), do: throw(:bad_enum)
def hp_custom_match_type_to_int(:l2_start), do: 0x1
def hp_custom_match_type_to_int(:l3_start), do: 0x2
def hp_custom_match_type_to_int(:l4_start), do: 0x3
def hp_custom_match_type_to_int(_), do: throw(:bad_enum)
def hp_custom_match_type_to_atom(0x1), do: :l2_start
def hp_custom_match_type_to_atom(0x2), do: :l3_start
def hp_custom_match_type_to_atom(0x3), do: :l4_start
def hp_custom_match_type_to_atom(_), do: throw(:bad_enum)
def onf_ext_match_to_int(:onf_tcp_flags), do: 0x2A
def onf_ext_match_to_int(:onf_actset_output), do: 0x2B
def onf_ext_match_to_int(:onf_pbb_uca), do: 0xA00
@ -12852,6 +12352,10 @@ defmodule Openflow.Enums do
Openflow.Utils.int_to_flags([], int, enum_of(:tcp_flags))
end
def int_to_flags(int, :tun_gbp_flags) do
Openflow.Utils.int_to_flags([], int, enum_of(:tun_gbp_flags))
end
def int_to_flags(int, :ct_state_flags) do
Openflow.Utils.int_to_flags([], int, enum_of(:ct_state_flags))
end
@ -12864,14 +12368,6 @@ defmodule Openflow.Enums do
Openflow.Utils.int_to_flags([], int, enum_of(:nicira_ext_match))
end
def int_to_flags(int, :hp_ext_match) do
Openflow.Utils.int_to_flags([], int, enum_of(:hp_ext_match))
end
def int_to_flags(int, :hp_custom_match_type) do
Openflow.Utils.int_to_flags([], int, enum_of(:hp_custom_match_type))
end
def int_to_flags(int, :onf_ext_match) do
Openflow.Utils.int_to_flags([], int, enum_of(:onf_ext_match))
end
@ -13240,6 +12736,10 @@ defmodule Openflow.Enums do
Openflow.Utils.flags_to_int(0, flags, enum_of(:tcp_flags))
end
def flags_to_int(flags, :tun_gbp_flags) do
Openflow.Utils.flags_to_int(0, flags, enum_of(:tun_gbp_flags))
end
def flags_to_int(flags, :ct_state_flags) do
Openflow.Utils.flags_to_int(0, flags, enum_of(:ct_state_flags))
end
@ -13252,14 +12752,6 @@ defmodule Openflow.Enums do
Openflow.Utils.flags_to_int(0, flags, enum_of(:nicira_ext_match))
end
def flags_to_int(flags, :hp_ext_match) do
Openflow.Utils.flags_to_int(0, flags, enum_of(:hp_ext_match))
end
def flags_to_int(flags, :hp_custom_match_type) do
Openflow.Utils.flags_to_int(0, flags, enum_of(:hp_custom_match_type))
end
def flags_to_int(flags, :onf_ext_match) do
Openflow.Utils.flags_to_int(0, flags, enum_of(:onf_ext_match))
end
@ -13978,36 +13470,10 @@ defmodule Openflow.Enums do
pbb_isid: 37,
tunnel_id: 38,
ipv6_exthdr: 39,
pbb_uca: 41,
packet_type: 42,
gre_flags: 43,
gre_ver: 44,
gre_protocol: 45,
gre_key: 46,
gre_seqnum: 47,
lisp_flags: 48,
lisp_nonce: 49,
lisp_id: 50,
vxlan_flags: 51,
vxlan_vni: 52,
mpls_data_first_nibble: 53,
mpls_ach_version: 54,
mpls_ach_channel: 55,
mpls_pw_metadata: 56,
mpls_cw_flags: 57,
mpls_cw_fragment: 58,
mpls_cw_len: 59,
mpls_cw_seq_num: 60,
gtpu_flags: 61,
gtpu_ver: 62,
gtpu_msg_type: 63,
gtpu_teid: 64,
gtpu_extn_hdr: 65,
gtpu_extn_udp_port: 66,
gtpu_extn_sci: 67
pbb_uca: 41
]
defp enum_of(:vlan_id), do: [present: 4096, none: 0]
defp enum_of(:vlan_id), do: [vid_present: 4096, vid_none: 0]
defp enum_of(:ipv6exthdr_flags),
do: [
@ -14025,6 +13491,8 @@ defmodule Openflow.Enums do
defp enum_of(:tcp_flags),
do: [fin: 1, syn: 2, rst: 4, psh: 8, ack: 16, urg: 32, ece: 64, cwr: 128, ns: 256]
defp enum_of(:tun_gbp_flags), do: [policy_applied: 8, dont_learn: 64]
defp enum_of(:ct_state_flags),
do: [new: 1, est: 2, rel: 4, rep: 8, inv: 16, trk: 32, snat: 64, dnat: 128]
@ -14041,23 +13509,10 @@ defmodule Openflow.Enums do
nsh_c1: 6,
nsh_c2: 7,
nsh_c3: 8,
nsh_c4: 9
nsh_c4: 9,
nsh_ttl: 10
]
defp enum_of(:hp_ext_match),
do: [
hp_udp_src_port_range: 0,
hp_udp_dst_port_range: 1,
hp_tcp_src_port_range: 2,
hp_tcp_dst_port_range: 3,
hp_tcp_flags: 4,
hp_custom_1: 5,
hp_custom_2: 6,
hp_custom_3: 7,
hp_custom_4: 8
]
defp enum_of(:hp_custom_match_type), do: [l2_start: 1, l3_start: 2, l4_start: 3]
defp enum_of(:onf_ext_match), do: [onf_tcp_flags: 42, onf_actset_output: 43, onf_pbb_uca: 2560]
defp enum_of(:buffer_id), do: [no_buffer: 4_294_967_295]
defp enum_of(:port_config), do: [port_down: 1, no_receive: 4, no_forward: 32, no_packet_in: 64]

File diff suppressed because it is too large Load diff

View file

@ -1,673 +0,0 @@
defmodule Openflow.Match.Field do
def codec(value0, field) when is_binary(value0) do
{type, format} = format_of(field)
n_bits = n_bits_of(field)
bit_size = bit_size(value0)
value =
if bit_size < n_bits do
head_pad_len = n_bits - bit_size
<<0::size(head_pad_len), value0::bytes>>
else
if bit_size > n_bits and type != :mac do
head_pad_len = bit_size - n_bits
<<_::size(head_pad_len), value::size(n_bits)-bits>> = value0
value
else
value0
end
end
formatting(value, type, format)
end
def codec(value, type) do
{type, format} = format_of(type)
formatting(value, type, format)
end
def n_bits_of(field) do
field
|> format_of
|> bit_size_of
end
def bit_size_of({:u8, _}), do: 8
def bit_size_of({:u24, _}), do: 24
def bit_size_of({:be16, _}), do: 16
def bit_size_of({:be32, _}), do: 32
def bit_size_of({:be64, _}), do: 64
def bit_size_of({:be128, _}), do: 128
def bit_size_of({:mac, _}), do: 48
# NXM0
def vendor_of(:nx_in_port), do: :nxm_0
def vendor_of(:nx_eth_dst), do: :nxm_0
def vendor_of(:nx_eth_src), do: :nxm_0
def vendor_of(:nx_eth_type), do: :nxm_0
def vendor_of(:nx_vlan_tci), do: :nxm_0
def vendor_of(:nx_ip_tos), do: :nxm_0
def vendor_of(:nx_ip_proto), do: :nxm_0
def vendor_of(:nx_ipv4_src), do: :nxm_0
def vendor_of(:nx_ipv4_dst), do: :nxm_0
def vendor_of(:nx_tcp_src), do: :nxm_0
def vendor_of(:nx_tcp_dst), do: :nxm_0
def vendor_of(:nx_udp_src), do: :nxm_0
def vendor_of(:nx_udp_dst), do: :nxm_0
def vendor_of(:nx_icmpv4_type), do: :nxm_0
def vendor_of(:nx_icmpv4_code), do: :nxm_0
def vendor_of(:nx_arp_op), do: :nxm_0
def vendor_of(:nx_arp_spa), do: :nxm_0
def vendor_of(:nx_arp_tpa), do: :nxm_0
def vendor_of(:nx_tcp_flags), do: :nxm_0
# NXM1
def vendor_of(:reg0), do: :nxm_1
def vendor_of(:reg1), do: :nxm_1
def vendor_of(:reg2), do: :nxm_1
def vendor_of(:reg3), do: :nxm_1
def vendor_of(:reg4), do: :nxm_1
def vendor_of(:reg5), do: :nxm_1
def vendor_of(:reg6), do: :nxm_1
def vendor_of(:reg7), do: :nxm_1
def vendor_of(:reg8), do: :nxm_1
def vendor_of(:reg9), do: :nxm_1
def vendor_of(:reg10), do: :nxm_1
def vendor_of(:reg11), do: :nxm_1
def vendor_of(:reg12), do: :nxm_1
def vendor_of(:reg13), do: :nxm_1
def vendor_of(:reg14), do: :nxm_1
def vendor_of(:reg15), do: :nxm_1
def vendor_of(:tun_id), do: :nxm_1
def vendor_of(:nx_arp_sha), do: :nxm_1
def vendor_of(:nx_arp_tha), do: :nxm_1
def vendor_of(:nx_ipv6_src), do: :nxm_1
def vendor_of(:nx_ipv6_dst), do: :nxm_1
def vendor_of(:nx_icmpv6_type), do: :nxm_1
def vendor_of(:nx_icmpv6_code), do: :nxm_1
def vendor_of(:nx_ipv6_nd_target), do: :nxm_1
def vendor_of(:nx_ipv6_nd_sll), do: :nxm_1
def vendor_of(:nx_ipv6_nd_tll), do: :nxm_1
def vendor_of(:nx_ip_frag), do: :nxm_1
def vendor_of(:nx_ipv6_label), do: :nxm_1
def vendor_of(:nx_ip_ecn), do: :nxm_1
def vendor_of(:nx_ip_ttl), do: :nxm_1
def vendor_of(:nx_mpls_ttl), do: :nxm_1
def vendor_of(:tun_src), do: :nxm_1
def vendor_of(:tun_dst), do: :nxm_1
def vendor_of(:pkt_mark), do: :nxm_1
def vendor_of(:dp_hash), do: :nxm_1
def vendor_of(:recirc_id), do: :nxm_1
def vendor_of(:conj_id), do: :nxm_1
def vendor_of(:nx_tun_gbp_id), do: :nxm_1
def vendor_of(:nx_tun_gbp_flags), do: :nxm_1
def vendor_of(:tun_metadata0), do: :nxm_1
def vendor_of(:tun_metadata1), do: :nxm_1
def vendor_of(:tun_metadata2), do: :nxm_1
def vendor_of(:tun_metadata3), do: :nxm_1
def vendor_of(:tun_metadata4), do: :nxm_1
def vendor_of(:tun_metadata5), do: :nxm_1
def vendor_of(:tun_metadata6), do: :nxm_1
def vendor_of(:tun_metadata7), do: :nxm_1
def vendor_of(:tun_metadata8), do: :nxm_1
def vendor_of(:tun_metadata9), do: :nxm_1
def vendor_of(:tun_metadata10), do: :nxm_1
def vendor_of(:tun_metadata11), do: :nxm_1
def vendor_of(:tun_metadata12), do: :nxm_1
def vendor_of(:tun_metadata13), do: :nxm_1
def vendor_of(:tun_metadata14), do: :nxm_1
def vendor_of(:tun_metadata15), do: :nxm_1
def vendor_of(:tun_metadata16), do: :nxm_1
def vendor_of(:tun_metadata17), do: :nxm_1
def vendor_of(:tun_metadata18), do: :nxm_1
def vendor_of(:tun_metadata19), do: :nxm_1
def vendor_of(:tun_metadata20), do: :nxm_1
def vendor_of(:tun_metadata21), do: :nxm_1
def vendor_of(:tun_metadata22), do: :nxm_1
def vendor_of(:tun_metadata23), do: :nxm_1
def vendor_of(:tun_metadata24), do: :nxm_1
def vendor_of(:tun_metadata25), do: :nxm_1
def vendor_of(:tun_metadata26), do: :nxm_1
def vendor_of(:tun_metadata27), do: :nxm_1
def vendor_of(:tun_metadata28), do: :nxm_1
def vendor_of(:tun_metadata29), do: :nxm_1
def vendor_of(:tun_metadata30), do: :nxm_1
def vendor_of(:tun_metadata31), do: :nxm_1
def vendor_of(:tun_metadata32), do: :nxm_1
def vendor_of(:tun_metadata33), do: :nxm_1
def vendor_of(:tun_metadata34), do: :nxm_1
def vendor_of(:tun_metadata35), do: :nxm_1
def vendor_of(:tun_metadata36), do: :nxm_1
def vendor_of(:tun_metadata37), do: :nxm_1
def vendor_of(:tun_metadata38), do: :nxm_1
def vendor_of(:tun_metadata39), do: :nxm_1
def vendor_of(:tun_metadata40), do: :nxm_1
def vendor_of(:tun_metadata41), do: :nxm_1
def vendor_of(:tun_metadata42), do: :nxm_1
def vendor_of(:tun_metadata43), do: :nxm_1
def vendor_of(:tun_metadata44), do: :nxm_1
def vendor_of(:tun_metadata45), do: :nxm_1
def vendor_of(:tun_metadata46), do: :nxm_1
def vendor_of(:tun_metadata47), do: :nxm_1
def vendor_of(:tun_metadata48), do: :nxm_1
def vendor_of(:tun_metadata49), do: :nxm_1
def vendor_of(:tun_metadata50), do: :nxm_1
def vendor_of(:tun_metadata51), do: :nxm_1
def vendor_of(:tun_metadata52), do: :nxm_1
def vendor_of(:tun_metadata53), do: :nxm_1
def vendor_of(:tun_metadata54), do: :nxm_1
def vendor_of(:tun_metadata55), do: :nxm_1
def vendor_of(:tun_metadata56), do: :nxm_1
def vendor_of(:tun_metadata57), do: :nxm_1
def vendor_of(:tun_metadata58), do: :nxm_1
def vendor_of(:tun_metadata59), do: :nxm_1
def vendor_of(:tun_metadata60), do: :nxm_1
def vendor_of(:tun_metadata61), do: :nxm_1
def vendor_of(:tun_metadata62), do: :nxm_1
def vendor_of(:tun_metadata63), do: :nxm_1
def vendor_of(:tun_flags), do: :nxm_1
def vendor_of(:ct_state), do: :nxm_1
def vendor_of(:ct_zone), do: :nxm_1
def vendor_of(:ct_mark), do: :nxm_1
def vendor_of(:ct_label), do: :nxm_1
def vendor_of(:tun_ipv6_src), do: :nxm_1
def vendor_of(:tun_ipv6_dst), do: :nxm_1
def vendor_of(:xxreg0), do: :nxm_1
def vendor_of(:xxreg1), do: :nxm_1
def vendor_of(:xxreg2), do: :nxm_1
def vendor_of(:xxreg3), do: :nxm_1
def vendor_of(:xxreg4), do: :nxm_1
def vendor_of(:xxreg5), do: :nxm_1
def vendor_of(:xxreg6), do: :nxm_1
def vendor_of(:xxreg7), do: :nxm_1
def vendor_of(:ct_ip_proto), do: :nxm_1
def vendor_of(:ct_ipv4_src), do: :nxm_1
def vendor_of(:ct_ipv4_dst), do: :nxm_1
def vendor_of(:ct_ipv6_src), do: :nxm_1
def vendor_of(:ct_ipv6_dst), do: :nxm_1
def vendor_of(:ct_tp_src), do: :nxm_1
def vendor_of(:ct_tp_dst), do: :nxm_1
# OpenFlow Basic
def vendor_of(:in_port), do: :openflow_basic
def vendor_of(:in_phy_port), do: :openflow_basic
def vendor_of(:metadata), do: :openflow_basic
def vendor_of(:eth_dst), do: :openflow_basic
def vendor_of(:eth_src), do: :openflow_basic
def vendor_of(:eth_type), do: :openflow_basic
def vendor_of(:vlan_vid), do: :openflow_basic
def vendor_of(:vlan_pcp), do: :openflow_basic
def vendor_of(:ip_dscp), do: :openflow_basic
def vendor_of(:ip_ecn), do: :openflow_basic
def vendor_of(:ip_proto), do: :openflow_basic
def vendor_of(:ipv4_src), do: :openflow_basic
def vendor_of(:ipv4_dst), do: :openflow_basic
def vendor_of(:tcp_src), do: :openflow_basic
def vendor_of(:tcp_dst), do: :openflow_basic
def vendor_of(:udp_src), do: :openflow_basic
def vendor_of(:udp_dst), do: :openflow_basic
def vendor_of(:sctp_src), do: :openflow_basic
def vendor_of(:sctp_dst), do: :openflow_basic
def vendor_of(:icmpv4_type), do: :openflow_basic
def vendor_of(:icmpv4_code), do: :openflow_basic
def vendor_of(:arp_op), do: :openflow_basic
def vendor_of(:arp_spa), do: :openflow_basic
def vendor_of(:arp_tpa), do: :openflow_basic
def vendor_of(:arp_sha), do: :openflow_basic
def vendor_of(:arp_tha), do: :openflow_basic
def vendor_of(:ipv6_src), do: :openflow_basic
def vendor_of(:ipv6_dst), do: :openflow_basic
def vendor_of(:ipv6_flabel), do: :openflow_basic
def vendor_of(:icmpv6_type), do: :openflow_basic
def vendor_of(:icmpv6_code), do: :openflow_basic
def vendor_of(:ipv6_nd_target), do: :openflow_basic
def vendor_of(:ipv6_nd_sll), do: :openflow_basic
def vendor_of(:ipv6_nd_tll), do: :openflow_basic
def vendor_of(:mpls_label), do: :openflow_basic
def vendor_of(:mpls_tc), do: :openflow_basic
def vendor_of(:mpls_bos), do: :openflow_basic
def vendor_of(:pbb_isid), do: :openflow_basic
def vendor_of(:tunnel_id), do: :openflow_basic
def vendor_of(:ipv6_exthdr), do: :openflow_basic
def vendor_of(:pbb_uca), do: :openflow_basic
def vendor_of(:packet_type), do: :openflow_basic
def vendor_of(:gre_flags), do: :openflow_basic
def vendor_of(:gre_ver), do: :openflow_basic
def vendor_of(:gre_protocol), do: :openflow_basic
def vendor_of(:gre_key), do: :openflow_basic
def vendor_of(:gre_seqnum), do: :openflow_basic
def vendor_of(:lisp_flags), do: :openflow_basic
def vendor_of(:lisp_nonce), do: :openflow_basic
def vendor_of(:lisp_id), do: :openflow_basic
def vendor_of(:vxlan_flags), do: :openflow_basic
def vendor_of(:vxlan_vni), do: :openflow_basic
def vendor_of(:mpls_data_first_nibble), do: :openflow_basic
def vendor_of(:mpls_ach_version), do: :openflow_basic
def vendor_of(:mpls_ach_channel), do: :openflow_basic
def vendor_of(:mpls_pw_metadata), do: :openflow_basic
def vendor_of(:mpls_cw_flags), do: :openflow_basic
def vendor_of(:mpls_cw_fragment), do: :openflow_basic
def vendor_of(:mpls_cw_len), do: :openflow_basic
def vendor_of(:mpls_cw_seq_num), do: :openflow_basic
def vendor_of(:gtpu_flags), do: :openflow_basic
def vendor_of(:gtpu_ver), do: :openflow_basic
def vendor_of(:gtpu_msg_type), do: :openflow_basic
def vendor_of(:gtpu_teid), do: :openflow_basic
def vendor_of(:gtpu_extn_hdr), do: :openflow_basic
def vendor_of(:gtpu_extn_udp_port), do: :openflow_basic
def vendor_of(:gtpu_extn_sci), do: :openflow_basic
# Packet Register
def vendor_of(:xreg0), do: :packet_register
def vendor_of(:xreg1), do: :packet_register
def vendor_of(:xreg2), do: :packet_register
def vendor_of(:xreg3), do: :packet_register
def vendor_of(:xreg4), do: :packet_register
def vendor_of(:xreg5), do: :packet_register
def vendor_of(:xreg6), do: :packet_register
def vendor_of(:xreg7), do: :packet_register
# Nicira Ext Match
def vendor_of(:nsh_flags), do: :nicira_ext_match
def vendor_of(:nsh_mdtype), do: :nicira_ext_match
def vendor_of(:nsh_np), do: :nicira_ext_match
def vendor_of(:nsh_spi), do: :nicira_ext_match
def vendor_of(:nsh_si), do: :nicira_ext_match
def vendor_of(:nsh_c1), do: :nicira_ext_match
def vendor_of(:nsh_c2), do: :nicira_ext_match
def vendor_of(:nsh_c3), do: :nicira_ext_match
def vendor_of(:nsh_c4), do: :nicira_ext_match
# HP Ext Match
def vendor_of(:hp_udp_src_port_range), do: :hp_ext_match
def vendor_of(:hp_udp_dst_port_range), do: :hp_ext_match
def vendor_of(:hp_tcp_src_port_range), do: :hp_ext_match
def vendor_of(:hp_tcp_dst_port_range), do: :hp_ext_match
def vendor_of(:hp_tcp_flags), do: :hp_ext_match
def vendor_of(:hp_custom_1), do: :hp_ext_match
def vendor_of(:hp_custom_2), do: :hp_ext_match
def vendor_of(:hp_custom_3), do: :hp_ext_match
def vendor_of(:hp_custom_4), do: :hp_ext_match
# ONF Ext Match
def vendor_of(:onf_tcp_flags), do: :onf_ext_match
def vendor_of(:onf_actset_output), do: :onf_ext_match
def vendor_of(:onf_pbb_uca), do: :onf_ext_match
# NXM0
def format_of(:nx_in_port), do: {:be16, :openflow10_port}
def format_of(:nx_eth_dst), do: {:mac, :ethernet}
def format_of(:nx_eth_src), do: {:mac, :ethernet}
def format_of(:nx_eth_type), do: {:be16, :hexadecimal}
def format_of(:nx_vlan_tci), do: {:be16, :hexadecimal}
def format_of(:nx_ip_tos), do: {:u8, :decimal}
def format_of(:nx_ip_proto), do: {:u8, :decimal}
def format_of(:nx_ipv4_src), do: {:be32, :ipv4}
def format_of(:nx_ipv4_dst), do: {:be32, :ipv4}
def format_of(:nx_tcp_src), do: {:be16, :decimal}
def format_of(:nx_tcp_dst), do: {:be16, :decimal}
def format_of(:nx_udp_src), do: {:be16, :decimal}
def format_of(:nx_udp_dst), do: {:be16, :decimal}
def format_of(:nx_icmpv4_type), do: {:u8, :decimal}
def format_of(:nx_icmpv4_code), do: {:u8, :decimal}
def format_of(:nx_arp_op), do: {:be16, :decimal}
def format_of(:nx_arp_spa), do: {:be32, :ipv4}
def format_of(:nx_arp_tpa), do: {:be32, :ipv4}
def format_of(:nx_tcp_flags), do: {:be16, :tcp_flags}
# NXM1
def format_of(:reg0), do: {:be32, :hexadecimal}
def format_of(:reg1), do: {:be32, :hexadecimal}
def format_of(:reg2), do: {:be32, :hexadecimal}
def format_of(:reg3), do: {:be32, :hexadecimal}
def format_of(:reg4), do: {:be32, :hexadecimal}
def format_of(:reg5), do: {:be32, :hexadecimal}
def format_of(:reg6), do: {:be32, :hexadecimal}
def format_of(:reg7), do: {:be32, :hexadecimal}
def format_of(:reg8), do: {:be32, :hexadecimal}
def format_of(:reg9), do: {:be32, :hexadecimal}
def format_of(:reg10), do: {:be32, :hexadecimal}
def format_of(:reg11), do: {:be32, :hexadecimal}
def format_of(:reg12), do: {:be32, :hexadecimal}
def format_of(:reg13), do: {:be32, :hexadecimal}
def format_of(:reg14), do: {:be32, :hexadecimal}
def format_of(:reg15), do: {:be32, :hexadecimal}
def format_of(:tun_id), do: {:be64, :hexadecimal}
def format_of(:nx_arp_sha), do: {:mac, :ethernet}
def format_of(:nx_arp_tha), do: {:mac, :ethernet}
def format_of(:nx_ipv6_src), do: {:be128, :ipv6}
def format_of(:nx_ipv6_dst), do: {:be128, :ipv6}
def format_of(:nx_icmpv6_type), do: {:u8, :decimal}
def format_of(:nx_icmpv6_code), do: {:u8, :decimal}
def format_of(:nx_ipv6_nd_target), do: {:be128, :ipv6}
def format_of(:nx_ipv6_nd_sll), do: {:mac, :ethernet}
def format_of(:nx_ipv6_nd_tll), do: {:mac, :ethernet}
def format_of(:nx_ip_frag), do: {:u8, :decimal}
def format_of(:nx_ipv6_label), do: {:be32, :hexadecimal}
def format_of(:nx_ip_ecn), do: {:u8, :decimal}
def format_of(:nx_ip_ttl), do: {:u8, :decimal}
def format_of(:nx_mpls_ttl), do: {:u8, :decimal}
def format_of(:tun_src), do: {:be32, :ipv4}
def format_of(:tun_dst), do: {:be32, :ipv4}
def format_of(:pkt_mark), do: {:be32, :hexadecimal}
def format_of(:dp_hash), do: {:be32, :hexadecimal}
def format_of(:recirc_id), do: {:be32, :hexadecimal}
def format_of(:conj_id), do: {:be32, :hexadecimal}
def format_of(:nx_tun_gbp_id), do: {:be16, :decimal}
def format_of(:nx_tun_gbp_flags), do: {:u8, :decimal}
def format_of(:tun_metadata0), do: {:dynamic, :bytes}
def format_of(:tun_metadata1), do: {:dynamic, :bytes}
def format_of(:tun_metadata2), do: {:dynamic, :bytes}
def format_of(:tun_metadata3), do: {:dynamic, :bytes}
def format_of(:tun_metadata4), do: {:dynamic, :bytes}
def format_of(:tun_metadata5), do: {:dynamic, :bytes}
def format_of(:tun_metadata6), do: {:dynamic, :bytes}
def format_of(:tun_metadata7), do: {:dynamic, :bytes}
def format_of(:tun_metadata8), do: {:dynamic, :bytes}
def format_of(:tun_metadata9), do: {:dynamic, :bytes}
def format_of(:tun_metadata10), do: {:dynamic, :bytes}
def format_of(:tun_metadata11), do: {:dynamic, :bytes}
def format_of(:tun_metadata12), do: {:dynamic, :bytes}
def format_of(:tun_metadata13), do: {:dynamic, :bytes}
def format_of(:tun_metadata14), do: {:dynamic, :bytes}
def format_of(:tun_metadata15), do: {:dynamic, :bytes}
def format_of(:tun_metadata16), do: {:dynamic, :bytes}
def format_of(:tun_metadata17), do: {:dynamic, :bytes}
def format_of(:tun_metadata18), do: {:dynamic, :bytes}
def format_of(:tun_metadata19), do: {:dynamic, :bytes}
def format_of(:tun_metadata20), do: {:dynamic, :bytes}
def format_of(:tun_metadata21), do: {:dynamic, :bytes}
def format_of(:tun_metadata22), do: {:dynamic, :bytes}
def format_of(:tun_metadata23), do: {:dynamic, :bytes}
def format_of(:tun_metadata24), do: {:dynamic, :bytes}
def format_of(:tun_metadata25), do: {:dynamic, :bytes}
def format_of(:tun_metadata26), do: {:dynamic, :bytes}
def format_of(:tun_metadata27), do: {:dynamic, :bytes}
def format_of(:tun_metadata28), do: {:dynamic, :bytes}
def format_of(:tun_metadata29), do: {:dynamic, :bytes}
def format_of(:tun_metadata30), do: {:dynamic, :bytes}
def format_of(:tun_metadata31), do: {:dynamic, :bytes}
def format_of(:tun_metadata32), do: {:dynamic, :bytes}
def format_of(:tun_metadata33), do: {:dynamic, :bytes}
def format_of(:tun_metadata34), do: {:dynamic, :bytes}
def format_of(:tun_metadata35), do: {:dynamic, :bytes}
def format_of(:tun_metadata36), do: {:dynamic, :bytes}
def format_of(:tun_metadata37), do: {:dynamic, :bytes}
def format_of(:tun_metadata38), do: {:dynamic, :bytes}
def format_of(:tun_metadata39), do: {:dynamic, :bytes}
def format_of(:tun_metadata40), do: {:dynamic, :bytes}
def format_of(:tun_metadata41), do: {:dynamic, :bytes}
def format_of(:tun_metadata42), do: {:dynamic, :bytes}
def format_of(:tun_metadata43), do: {:dynamic, :bytes}
def format_of(:tun_metadata44), do: {:dynamic, :bytes}
def format_of(:tun_metadata45), do: {:dynamic, :bytes}
def format_of(:tun_metadata46), do: {:dynamic, :bytes}
def format_of(:tun_metadata47), do: {:dynamic, :bytes}
def format_of(:tun_metadata48), do: {:dynamic, :bytes}
def format_of(:tun_metadata49), do: {:dynamic, :bytes}
def format_of(:tun_metadata50), do: {:dynamic, :bytes}
def format_of(:tun_metadata51), do: {:dynamic, :bytes}
def format_of(:tun_metadata52), do: {:dynamic, :bytes}
def format_of(:tun_metadata53), do: {:dynamic, :bytes}
def format_of(:tun_metadata54), do: {:dynamic, :bytes}
def format_of(:tun_metadata55), do: {:dynamic, :bytes}
def format_of(:tun_metadata56), do: {:dynamic, :bytes}
def format_of(:tun_metadata57), do: {:dynamic, :bytes}
def format_of(:tun_metadata58), do: {:dynamic, :bytes}
def format_of(:tun_metadata59), do: {:dynamic, :bytes}
def format_of(:tun_metadata60), do: {:dynamic, :bytes}
def format_of(:tun_metadata61), do: {:dynamic, :bytes}
def format_of(:tun_metadata62), do: {:dynamic, :bytes}
def format_of(:tun_metadata63), do: {:dynamic, :bytes}
def format_of(:tun_flags), do: {:be16, :decimal}
def format_of(:ct_state), do: {:be32, :ct_state}
def format_of(:ct_zone), do: {:be16, :hexadecimal}
def format_of(:ct_mark), do: {:be32, :hexadecimal}
def format_of(:ct_label), do: {:be128, :hexadecimal}
def format_of(:tun_ipv6_src), do: {:be128, :ipv6}
def format_of(:tun_ipv6_dst), do: {:be128, :ipv6}
def format_of(:xxreg0), do: {:be128, :hexadecimal}
def format_of(:xxreg1), do: {:be128, :hexadecimal}
def format_of(:xxreg2), do: {:be128, :hexadecimal}
def format_of(:xxreg3), do: {:be128, :hexadecimal}
def format_of(:xxreg4), do: {:be128, :hexadecimal}
def format_of(:xxreg5), do: {:be128, :hexadecimal}
def format_of(:xxreg6), do: {:be128, :hexadecimal}
def format_of(:xxreg7), do: {:be128, :hexadecimal}
def format_of(:ct_ip_proto), do: {:u8, :decimal}
def format_of(:ct_ipv4_src), do: {:be32, :ipv4}
def format_of(:ct_ipv4_dst), do: {:be32, :ipv4}
def format_of(:ct_ipv6_src), do: {:be128, :ipv6}
def format_of(:ct_ipv6_dst), do: {:be128, :ipv6}
def format_of(:ct_tp_src), do: {:be16, :decimal}
def format_of(:ct_tp_dst), do: {:be16, :decimal}
# OpenFlow Basic
def format_of(:in_port), do: {:be32, :openflow13_port}
def format_of(:in_phy_port), do: {:be32, :openflow13_port}
def format_of(:metadata), do: {:be64, :hexadecimal}
def format_of(:eth_dst), do: {:mac, :ethernet}
def format_of(:eth_src), do: {:mac, :ethernet}
def format_of(:eth_type), do: {:be16, :hexadecimal}
def format_of(:vlan_vid), do: {:be16, :hexadecimal}
def format_of(:vlan_pcp), do: {:u8, :decimal}
def format_of(:ip_dscp), do: {:u8, :decimal}
def format_of(:ip_ecn), do: {:u8, :decimal}
def format_of(:ip_proto), do: {:u8, :decimal}
def format_of(:ipv4_src), do: {:be32, :ipv4}
def format_of(:ipv4_dst), do: {:be32, :ipv4}
def format_of(:tcp_src), do: {:be16, :decimal}
def format_of(:tcp_dst), do: {:be16, :decimal}
def format_of(:udp_src), do: {:be16, :decimal}
def format_of(:udp_dst), do: {:be16, :decimal}
def format_of(:sctp_src), do: {:be16, :decimal}
def format_of(:sctp_dst), do: {:be16, :decimal}
def format_of(:icmpv4_type), do: {:u8, :decimal}
def format_of(:icmpv4_code), do: {:u8, :decimal}
def format_of(:arp_op), do: {:be16, :decimal}
def format_of(:arp_spa), do: {:be32, :ipv4}
def format_of(:arp_tpa), do: {:be32, :ipv4}
def format_of(:arp_sha), do: {:mac, :ethernet}
def format_of(:arp_tha), do: {:mac, :ethernet}
def format_of(:ipv6_src), do: {:be128, :ipv6}
def format_of(:ipv6_dst), do: {:be128, :ipv6}
def format_of(:ipv6_flabel), do: {:be32, :hexadecimal}
def format_of(:icmpv6_type), do: {:u8, :decimal}
def format_of(:icmpv6_code), do: {:u8, :decimal}
def format_of(:ipv6_nd_target), do: {:be128, :ipv6}
def format_of(:ipv6_nd_sll), do: {:mac, :ethernet}
def format_of(:ipv6_nd_tll), do: {:mac, :ethernet}
def format_of(:mpls_label), do: {:be32, :decimal}
def format_of(:mpls_tc), do: {:u8, :decimal}
def format_of(:mpls_bos), do: {:u8, :decimal}
def format_of(:pbb_isid), do: {:u24, :decimal}
def format_of(:tunnel_id), do: {:be64, :hexadecimal}
def format_of(:ipv6_exthdr), do: {:be16, :ipv6exthdr_flags}
def format_of(:pbb_uca), do: {:u8, :decimal}
def format_of(:packet_type), do: {:be32, :decimal}
def format_of(:gre_flags), do: {:be16, :decimal}
def format_of(:gre_ver), do: {:u8, :decimal}
def format_of(:gre_protocol), do: {:be16, :decimal}
def format_of(:gre_key), do: {:be32, :decimal}
def format_of(:gre_seqnum), do: {:be32, :decimal}
def format_of(:lisp_flags), do: {:u8, :decimal}
def format_of(:lisp_nonce), do: {:u24, :decimal}
def format_of(:lisp_id), do: {:be32, :decimal}
def format_of(:vxlan_flags), do: {:u8, :decimal}
def format_of(:vxlan_vni), do: {:u24, :decimal}
def format_of(:mpls_data_first_nibble), do: {:u8, :decimal}
def format_of(:mpls_ach_version), do: {:u8, :decimal}
def format_of(:mpls_ach_channel), do: {:be16, :decimal}
def format_of(:mpls_pw_metadata), do: {:u8, :decimal}
def format_of(:mpls_cw_flags), do: {:u8, :decimal}
def format_of(:mpls_cw_fragment), do: {:u8, :decimal}
def format_of(:mpls_cw_len), do: {:u8, :decimal}
def format_of(:mpls_cw_seq_num), do: {:be16, :decimal}
def format_of(:gtpu_flags), do: {:u8, :decimal}
def format_of(:gtpu_ver), do: {:u8, :decimal}
def format_of(:gtpu_msg_type), do: {:u8, :decimal}
def format_of(:gtpu_teid), do: {:be32, :decimal}
def format_of(:gtpu_extn_hdr), do: {:u8, :decimal}
def format_of(:gtpu_extn_udp_port), do: {:be16, :decimal}
def format_of(:gtpu_extn_sci), do: {:be16, :decimal}
# Packet Register
def format_of(:xreg0), do: {:be64, :hexadecimal}
def format_of(:xreg1), do: {:be64, :hexadecimal}
def format_of(:xreg2), do: {:be64, :hexadecimal}
def format_of(:xreg3), do: {:be64, :hexadecimal}
def format_of(:xreg4), do: {:be64, :hexadecimal}
def format_of(:xreg5), do: {:be64, :hexadecimal}
def format_of(:xreg6), do: {:be64, :hexadecimal}
def format_of(:xreg7), do: {:be64, :hexadecimal}
# Nicira Ext Match
def format_of(:nsh_flags), do: {:u8, :decimal}
def format_of(:nsh_mdtype), do: {:u8, :decimal}
def format_of(:nsh_np), do: {:u8, :decimal}
def format_of(:nsh_spi), do: {:be32, :decimal}
def format_of(:nsh_si), do: {:be32, :decimal}
def format_of(:nsh_c1), do: {:be32, :decimal}
def format_of(:nsh_c2), do: {:be32, :decimal}
def format_of(:nsh_c3), do: {:be32, :decimal}
def format_of(:nsh_c4), do: {:be32, :decimal}
# HP Ext Match
def format_of(:hp_udp_src_port_range), do: {:be32, :decimal}
def format_of(:hp_udp_dst_port_range), do: {:be32, :decimal}
def format_of(:hp_tcp_src_port_range), do: {:be32, :decimal}
def format_of(:hp_tcp_dst_port_range), do: {:be32, :decimal}
def format_of(:hp_tcp_flags), do: {:be16, :tcp_flags}
def format_of(:hp_custom_1), do: {:dynamic, :bytes}
def format_of(:hp_custom_2), do: {:dynamic, :bytes}
def format_of(:hp_custom_3), do: {:dynamic, :bytes}
def format_of(:hp_custom_4), do: {:dynamic, :bytes}
# ONF Ext Match
def format_of(:onf_tcp_flags), do: {:be16, :tcp_flags}
def format_of(:onf_actset_output), do: {:be32, :openflow13_port}
def format_of(:onf_pbb_uca), do: {:u8, :decimal}
# Formatting = decimal
def formatting(<<value::8>>, :u8, :decimal), do: value
def formatting(value, :u8, :decimal) when is_integer(value), do: <<value::8>>
def formatting(<<value::16>>, :be16, :decimal), do: value
def formatting(value, :be16, :decimal) when is_integer(value), do: <<value::16>>
def formatting(<<value::24>>, :u24, :decimal), do: value
def formatting(value, :u24, :decimal) when is_integer(value), do: <<value::24>>
def formatting(<<value::32>>, :be32, :decimal), do: value
def formatting(value, :be32, :decimal) when is_integer(value), do: <<value::32>>
def formatting(<<value::64>>, :be64, :decimal), do: value
def formatting(value, :be64, :decimal) when is_integer(value), do: <<value::64>>
def formatting(<<value::128>>, :be128, :decimal), do: value
def formatting(value, :be128, :decimal) when is_integer(value), do: <<value::128>>
# Formatting = hexadecimal
def formatting(<<value::16>>, :be16, :hexadecimal), do: value
def formatting(value, :be16, :hexadecimal) when is_integer(value), do: <<value::16>>
def formatting(<<value::24>>, :u24, :hexadecimal), do: value
def formatting(value, :u24, :hexadecimal) when is_integer(value), do: <<value::24>>
def formatting(<<value::32>>, :be32, :hexadecimal), do: value
def formatting(value, :be32, :hexadecimal) when is_integer(value), do: <<value::32>>
def formatting(<<value::64>>, :be64, :hexadecimal), do: value
def formatting(value, :be64, :hexadecimal) when is_integer(value), do: <<value::64>>
def formatting(<<value::128>>, :be128, :hexadecimal), do: value
def formatting(value, :be128, :hexadecimal) when is_integer(value), do: <<value::128>>
# Formatting = ethernet
def formatting(<<value::48-bits>>, :mac, :ethernet), do: Openflow.Utils.to_hex_string(value)
def formatting(value, :mac, :ethernet), do: <<String.to_integer(value, 16)::48>>
# Formatting = IPv4
def formatting(<<a1, a2, a3, a4>>, :be32, :ipv4), do: {a1, a2, a3, a4}
def formatting({a1, a2, a3, a4}, :be32, :ipv4), do: <<a1, a2, a3, a4>>
# Formatting = IPv6
def formatting(
<<a1::16, a2::16, a3::16, a4::16, a5::16, a6::16, a7::16, a8::16>>,
:be128,
:ipv6
) do
{a1, a2, a3, a4, a5, a6, a7, a8}
end
def formatting({a1, a2, a3, a4, a5, a6, a7, a8}, :be128, :ipv6) do
<<a1::16, a2::16, a3::16, a4::16, a5::16, a6::16, a7::16, a8::16>>
end
# Formatting = OpenFlow 1.0 port
def formatting(<<value::16>>, :be16, :openflow10_port) do
try do
Openflow.Enums.to_atom(value, :openflow10_port_no)
catch
:bad_enum -> value
end
end
def formatting(value, :be16, :openflow10_port) do
port_no =
try do
Openflow.Enums.to_int(value, :openflow10_port_no)
catch
:bad_enum -> value
end
<<port_no::16>>
end
# Formatting = OpenFlow 1.3 port
def formatting(<<value::32>>, :be32, :openflow13_port) do
try do
Openflow.Enums.to_atom(value, :openflow13_port_no)
catch
:bad_enum -> value
end
end
def formatting(value, :be32, :openflow13_port) do
port_no =
try do
Openflow.Enums.to_int(value, :openflow13_port_no)
catch
:bad_enum -> value
end
<<port_no::32>>
end
# TCP flags
def formatting(<<value::16>>, :be16, :tcp_flags) do
Openflow.Enums.int_to_flags(value, :tcp_flags)
end
def formatting(value, :be16, :tcp_flags) do
<<Openflow.Enums.flags_to_int(value, :tcp_flags)::16>>
end
# CT State
def formatting(<<value::32>>, :be32, :ct_state) do
Openflow.Enums.int_to_flags(value, :ct_state_flags)
end
def formatting(value, :be32, :ct_state) do
<<Openflow.Enums.flags_to_int(value, :ct_state_flags)::32>>
end
# CT State
def formatting(<<value::16>>, :be16, :ipv6exthdr_flags) do
Openflow.Enums.int_to_flags(value, :ipv6exthdr_flags)
end
def formatting(value, :be16, :ipv6exthdr_flags) do
<<Openflow.Enums.flags_to_int(value, :ipv6exthdr_flags)::16>>
end
# Other
def formatting(value, _, _) do
value
end
end