Add send_packet_out/1 to abstruct openflow protocol

This commit is contained in:
Eishun Kondoh 2018-08-29 22:56:40 +09:00
parent 2186642d58
commit d1b5777b73
4 changed files with 40 additions and 8 deletions

Binary file not shown.

View file

@ -4,7 +4,7 @@ use Mix.Config
config :tres,
protocol: :tcp,
port: 6633,
port: 6653,
max_connections: 10,
num_acceptors: 10,
callback_module: Tres.ExampleHandler,

View file

@ -81,12 +81,8 @@ defmodule LearningSwitch.Ofctl do
packet_out(packet_in, port_no || :flood)
end
defp packet_out(%PacketIn{datapath_id: datapath_id, data: data}, port_no) do
send_packet_out(
datapath_id,
data: data,
actions: [Output.new(port_no)]
)
defp packet_out(%PacketIn{} = pin, port_no) do
send_packet_out(packet_in: pin, actions: [Output.new(port_no)])
end
defp add_forwarding_flow_entry(_packet_in, nil), do: :noop

View file

@ -56,7 +56,43 @@ defmodule Tres.MessageHelper do
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
end
defp send_packet_out(datapath_id, options \\ []) do
defp send_packet_out(options \\ []) do
case options[:packet_in] do
%Openflow.PacketIn{} = pin ->
send_packet_out(
pin.datapath_id,
xid: options[:xid] || 0,
buffer_id: options[:buffer_id],
in_port: options[:in_port],
actions: options[:actions],
data: options[:data] || pin.data,
blocking: options[:blocking]
)
%Openflow.NxPacketIn2{continuation_bridge: nil} = pin ->
send_packet_out(
pin.datapath_id,
xid: options[:xid] || 0,
buffer_id: options[:buffer_id],
in_port: options[:in_port],
actions: options[:actions],
data: options[:data] || pin.packet,
blocking: options[:blocking]
)
%Openflow.NxPacketIn2{} = pin ->
send_nx_resume(
pin.datapath_id,
xid: options[:xid] || 0,
packet_in: options[:packet_in],
packet: options[:data] || pin.packet,
metadata: options[:metadata] || pin.metadata,
blocking: options[:blocking]
)
end
end
defp send_packet_out(datapath_id, options) do
packet_out = %Openflow.PacketOut{
xid: options[:xid] || 0,
buffer_id: options[:buffer_id] || :no_buffer,