Implement Openflow Protocol and Callback system

This commit is contained in:
Eishun Kondoh 2017-11-20 13:38:24 +09:00
parent fc02a678de
commit e52fe31b79
48 changed files with 937 additions and 244 deletions

View file

@ -3,6 +3,7 @@ defmodule Openflow.Multipart.Flow.Reply do
version: 4,
xid: 0,
datapath_id: nil, # virtual field
aux_id: nil,
flags: [],
flows: []
)
@ -19,6 +20,16 @@ defmodule Openflow.Multipart.Flow.Reply do
flows = Openflow.Multipart.FlowStats.read(flows_bin)
%Reply{flows: flows}
end
def append_body(%Reply{flows: flows} = message, %Reply{flags: [:more], flows: continue}) do
%{message|flows: [continue|flows]}
end
def append_body(%Reply{flows: flows} = message, %Reply{flags: [], flows: continue}) do
new_flows = [continue|flows]
|> Enum.reverse
|> List.flatten
%{message|flows: new_flows}
end
end
defmodule Openflow.Multipart.FlowStats do

View file

@ -16,13 +16,13 @@ defmodule Openflow.Multipart.Flow.Request do
def ofp_type, do: 18
def new(options) do
def new(options \\ []) do
table_id = Keyword.get(options, :table_id, :all)
out_port = Keyword.get(options, :out_port, :any)
out_group = Keyword.get(options, :out_group, :any)
cookie = Keyword.get(options, :cookie, 0)
cookie_mask = Keyword.get(options, :cookie, 0)
match = Keyword.get(options, :match, [])
match = Keyword.get(options, :match, Openflow.Match.new)
%Request{table_id: table_id,
out_port: out_port,
out_group: out_group,