Class: Pio::OpenFlow13::Match::Options
- Inherits:
-
Object
- Object
- Pio::OpenFlow13::Match::Options
- Defined in:
- lib/pio/open_flow13/match.rb
Overview
Match.new option parser.
Instance Method Summary collapse
-
#initialize(user_attrs) ⇒ Options
constructor
rubocop:disable MethodLength rubocop:disable AbcSize rubocop:disable LineLength.
-
#to_hash ⇒ Object
rubocop:enable MethodLength rubocop:enable AbcSize rubocop:enable LineLength.
Constructor Details
#initialize(user_attrs) ⇒ Options
rubocop:disable MethodLength rubocop:disable AbcSize rubocop:disable LineLength
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'lib/pio/open_flow13/match.rb', line 1269 def initialize(user_attrs) @match_fields = [] %i[in_port ether_type ip_protocol vlan_vid vlan_pcp ip_dscp ip_ecn tcp_source_port tcp_destination_port udp_source_port udp_destination_port sctp_source_port sctp_destination_port icmpv4_type icmpv4_code arp_operation].each do |each| next unless user_attrs.key?(each) klass = Match.const_get(each.to_s.split('_').map(&:capitalize).join) @match_fields << { oxm_class: klass.superclass.const_get(:OXM_CLASS), class_payload: { oxm_field: klass.const_get(:OXM_FIELD), tlv_value: { each => user_attrs.fetch(each) } } } end %i[metadata destination_mac_address source_mac_address ipv4_source_address ipv4_destination_address arp_sender_protocol_address arp_target_protocol_address arp_sender_hardware_address arp_target_hardware_address ipv6_source_address ipv6_destination_address tunnel_id reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 packet_reg0 packet_reg1 packet_reg2 packet_reg3].each do |each| next unless user_attrs.key?(each) klass = Match.const_get(each.to_s.split('_').map(&:capitalize).join) mask_key = "#{each}_mask".to_sym @match_fields << { oxm_class: klass.superclass.const_get(:OXM_CLASS), class_payload: { oxm_field: klass.const_get(:OXM_FIELD), oxm_hasmask: user_attrs.key?(mask_key) ? 1 : 0, tlv_value: { each => user_attrs[each], mask_key => user_attrs[mask_key] } } } end end |
Instance Method Details
#to_hash ⇒ Object
rubocop:enable MethodLength rubocop:enable AbcSize rubocop:enable LineLength
1305 1306 1307 |
# File 'lib/pio/open_flow13/match.rb', line 1305 def to_hash { match_fields: @match_fields } end |