Add send_packet_out/1 to abstruct openflow protocol
This commit is contained in:
parent
2186642d58
commit
d1b5777b73
4 changed files with 40 additions and 8 deletions
BIN
bin/enum_gen
BIN
bin/enum_gen
Binary file not shown.
|
|
@ -4,7 +4,7 @@ use Mix.Config
|
||||||
|
|
||||||
config :tres,
|
config :tres,
|
||||||
protocol: :tcp,
|
protocol: :tcp,
|
||||||
port: 6633,
|
port: 6653,
|
||||||
max_connections: 10,
|
max_connections: 10,
|
||||||
num_acceptors: 10,
|
num_acceptors: 10,
|
||||||
callback_module: Tres.ExampleHandler,
|
callback_module: Tres.ExampleHandler,
|
||||||
|
|
|
||||||
|
|
@ -81,12 +81,8 @@ defmodule LearningSwitch.Ofctl do
|
||||||
packet_out(packet_in, port_no || :flood)
|
packet_out(packet_in, port_no || :flood)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp packet_out(%PacketIn{datapath_id: datapath_id, data: data}, port_no) do
|
defp packet_out(%PacketIn{} = pin, port_no) do
|
||||||
send_packet_out(
|
send_packet_out(packet_in: pin, actions: [Output.new(port_no)])
|
||||||
datapath_id,
|
|
||||||
data: data,
|
|
||||||
actions: [Output.new(port_no)]
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_forwarding_flow_entry(_packet_in, nil), do: :noop
|
defp add_forwarding_flow_entry(_packet_in, nil), do: :noop
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,43 @@ defmodule Tres.MessageHelper do
|
||||||
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
send_message(flow_mod, datapath_id, Keyword.get(options, :blocking, false))
|
||||||
end
|
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{
|
packet_out = %Openflow.PacketOut{
|
||||||
xid: options[:xid] || 0,
|
xid: options[:xid] || 0,
|
||||||
buffer_id: options[:buffer_id] || :no_buffer,
|
buffer_id: options[:buffer_id] || :no_buffer,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue