Sha256: 7aa2f9afd10d6193772093a14d224659fb36a2bd11ed79c6e1830b3a6fd3623c

Contents?: true

Size: 1.68 KB

Versions: 4

Compression:

Stored size: 1.68 KB

Contents

require 'pio/open_flow10/match'

module Pio
  # OpenFlow 1.0 exact match
  class ExactMatch
    # rubocop:disable MethodLength
    # rubocop:disable AbcSize
    def initialize(packet_in)
      data = packet_in.data
      case data
      when PacketIn::DataParser::IPv4Packet
        options = {
          in_port: packet_in.in_port,
          ether_source_address: packet_in.source_mac,
          ether_destination_address: packet_in.destination_mac,
          vlan_vid: data.vlan_vid,
          vlan_priority: data.vlan_pcp,
          ether_type: data.ether_type,
          ip_tos: data.ip_type_of_service,
          ip_protocol: data.ip_protocol,
          ip_source_address: data.ip_source_address,
          ip_destination_address: data.ip_destination_address,
          transport_source_port: data.transport_source_port,
          transport_destination_port: data.transport_destination_port
        }
      when Arp::Request
        options = {
          in_port: packet_in.in_port,
          ether_source_address: packet_in.source_mac,
          ether_destination_address: packet_in.destination_mac,
          vlan_vid: data.vlan_vid,
          vlan_priority: data.vlan_pcp,
          ether_type: data.ether_type,
          ip_tos: 0,
          ip_protocol: data.operation,
          ip_source_address: data.sender_protocol_address,
          ip_destination_address: data.target_protocol_address,
          transport_source_port: 0,
          transport_destination_port: 0
        }
      end
      @match = Pio::Match.new(options)
    end
    # rubocop:enable MethodLength
    # rubocop:enable AbcSize

    def method_missing(method, *args, &block)
      @match.__send__ method, *args, &block
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pio-0.21.1 lib/pio/open_flow10/exact_match.rb
pio-0.21.0 lib/pio/open_flow10/exact_match.rb
pio-0.20.1 lib/pio/open_flow10/exact_match.rb
pio-0.20.0 lib/pio/open_flow10/exact_match.rb