Class: Pio::ExactMatch

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pio/exact_match.rb

Overview

OpenFlow 1.0 exact match

Instance Method Summary collapse

Constructor Details

#initialize(packet_in) ⇒ ExactMatch

rubocop:disable MethodLength rubocop:disable AbcSize



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pio/exact_match.rb', line 9

def initialize(packet_in)
  data = packet_in.parsed_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