diff --git a/bin/enum_gen b/bin/enum_gen index 4e3eab9..ca26af7 100755 Binary files a/bin/enum_gen and b/bin/enum_gen differ diff --git a/config/config.exs b/config/config.exs index 6dc6fa7..40896b3 100644 --- a/config/config.exs +++ b/config/config.exs @@ -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, diff --git a/examples/learning_switch/lib/learning_switch/ofctl.ex b/examples/learning_switch/lib/learning_switch/ofctl.ex index bca155b..c060fec 100644 --- a/examples/learning_switch/lib/learning_switch/ofctl.ex +++ b/examples/learning_switch/lib/learning_switch/ofctl.ex @@ -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 diff --git a/lib/tres/message_helper.ex b/lib/tres/message_helper.ex index 33dceed..e91e088 100644 --- a/lib/tres/message_helper.ex +++ b/lib/tres/message_helper.ex @@ -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,