Sha256: 16f2b933f8f0361ac5b4810621f34cb12624b094c89bfdd3d966bbf5de016af0

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'pio/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,
          dl_src: packet_in.source_mac,
          dl_dst: packet_in.destination_mac,
          dl_vlan: data.vlan_vid,
          dl_vlan_pcp: data.vlan_pcp,
          dl_type: data.ether_type,
          nw_tos: data.ip_type_of_service,
          nw_proto: data.ip_protocol,
          nw_src: data.ip_source_address,
          nw_dst: data.ip_destination_address,
          tp_src: data.transport_source_port,
          tp_dst: data.transport_destination_port
        }
      when Arp::Request
        options = {
          in_port: packet_in.in_port,
          dl_src: packet_in.source_mac,
          dl_dst: packet_in.destination_mac,
          dl_vlan: data.vlan_vid,
          dl_vlan_pcp: data.vlan_pcp,
          dl_type: data.ether_type,
          nw_tos: 0,
          nw_proto: data.operation,
          nw_src: data.sender_protocol_address,
          nw_dst: data.target_protocol_address,
          tp_src: 0,
          tp_dst: 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

2 entries across 2 versions & 1 rubygems

Version Path
pio-0.19.0 lib/pio/exact_match.rb
pio-0.18.2 lib/pio/exact_match.rb