Formatted
This commit is contained in:
parent
5fc01a9bec
commit
7635272fbd
150 changed files with 5055 additions and 4032 deletions
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Openflow.PortMod do
|
||||
defstruct(
|
||||
version: 4,
|
||||
xid: 0,
|
||||
version: 4,
|
||||
xid: 0,
|
||||
datapath_id: "",
|
||||
aux_id: 0,
|
||||
number: 0,
|
||||
hw_addr: "000000000000",
|
||||
config: [],
|
||||
mask: [],
|
||||
advertise: []
|
||||
aux_id: 0,
|
||||
number: 0,
|
||||
hw_addr: "000000000000",
|
||||
config: [],
|
||||
mask: [],
|
||||
advertise: []
|
||||
)
|
||||
|
||||
alias __MODULE__
|
||||
|
|
@ -24,9 +24,10 @@ defmodule Openflow.PortMod do
|
|||
%PortMod{number: port_no, hw_addr: hw_addr, config: config, mask: mask, advertise: advertise}
|
||||
end
|
||||
|
||||
def read(<<port_no_int::32, _::size(4)-unit(8), hw_addr_bin::6-bytes,
|
||||
_::size(2)-unit(8), config_int::32, mask_int::32,
|
||||
advertised_int::32, _::size(4)-unit(8)>>) do
|
||||
def read(
|
||||
<<port_no_int::32, _::size(4)-unit(8), hw_addr_bin::6-bytes, _::size(2)-unit(8),
|
||||
config_int::32, mask_int::32, advertised_int::32, _::size(4)-unit(8)>>
|
||||
) do
|
||||
port_no = Openflow.Utils.get_enum(port_no_int, :openflow13_port_no)
|
||||
hw_addr = Openflow.Utils.to_hex_string(hw_addr_bin)
|
||||
config = Openflow.Enums.int_to_flags(config_int, :port_config)
|
||||
|
|
@ -35,14 +36,20 @@ defmodule Openflow.PortMod do
|
|||
%PortMod{number: port_no, hw_addr: hw_addr, config: config, mask: mask, advertise: adv}
|
||||
end
|
||||
|
||||
def to_binary(%PortMod{number: port_no, hw_addr: hw_addr, config: config, mask: mask, advertise: adv}) do
|
||||
def to_binary(%PortMod{
|
||||
number: port_no,
|
||||
hw_addr: hw_addr,
|
||||
config: config,
|
||||
mask: mask,
|
||||
advertise: adv
|
||||
}) do
|
||||
port_no_int = Openflow.Utils.get_enum(port_no, :openflow13_port_no)
|
||||
hw_addr_bin = <<(String.to_integer(hw_addr, 16))::48>>
|
||||
hw_addr_bin = <<String.to_integer(hw_addr, 16)::48>>
|
||||
config_int = Openflow.Enums.flags_to_int(config, :port_config)
|
||||
mask_int = Openflow.Enums.flags_to_int(mask, :port_config)
|
||||
advertised_int = Openflow.Enums.flags_to_int(adv, :port_features)
|
||||
<<port_no_int::32, 0::size(4)-unit(8), hw_addr_bin::6-bytes,
|
||||
0::size(2)-unit(8), config_int::32, mask_int::32,
|
||||
advertised_int::32, 0::size(4)-unit(8)>>
|
||||
|
||||
<<port_no_int::32, 0::size(4)-unit(8), hw_addr_bin::6-bytes, 0::size(2)-unit(8),
|
||||
config_int::32, mask_int::32, advertised_int::32, 0::size(4)-unit(8)>>
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue