Class: Match

Inherits:
Object
  • Object
show all
Defined in:
lib/openflowdev/match.rb

Overview

Copyright © 2015, BROCADE COMMUNICATIONS SYSTEMS, INC

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this

list of conditions and the following disclaimer.

  1. Redistributions in binary form must reproduce the above copyright notice,

this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  1. Neither the name of the copyright holder nor the names of its contributors

may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(eth_type: nil, ipv4_destination: nil, ipv4_source: nil, ipv6_source: nil, ipv6_destination: nil, ipv6_flabel: nil, ipv6_ext_header: nil, ethernet_destination: nil, ethernet_source: nil, in_port: nil, in_physical_port: nil, ip_protocol_num: nil, ip_dscp: nil, ip_ecn: nil, tcp_source_port: nil, tcp_destination_port: nil, udp_source_port: nil, udp_destination_port: nil, icmpv4_type: nil, icmpv4_code: nil, icmpv6_type: nil, icmpv6_code: nil, arp_op_code: nil, arp_source_ipv4: nil, arp_target_ipv4: nil, arp_source_hardware_address: nil, arp_target_hardware_address: nil, vlan_id: nil, vlan_pcp: nil, sctp_destination: nil, sctp_source: nil, mpls_label: nil, mpls_tc: nil, mpls_bos: nil, tunnel_id: nil, metadata: nil, metadata_mask: nil) ⇒ Match

Returns a new instance of Match.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/openflowdev/match.rb', line 41

def initialize(eth_type: nil, ipv4_destination: nil, ipv4_source: nil,
    ipv6_source: nil, ipv6_destination: nil, ipv6_flabel: nil,
    ipv6_ext_header: nil, ethernet_destination: nil, ethernet_source: nil,
    in_port: nil, in_physical_port: nil, ip_protocol_num: nil, ip_dscp: nil,
    ip_ecn: nil, tcp_source_port: nil, tcp_destination_port: nil,
    udp_source_port: nil, udp_destination_port: nil, icmpv4_type: nil,
    icmpv4_code: nil, icmpv6_type: nil, icmpv6_code: nil,
    arp_op_code: nil, arp_source_ipv4: nil, arp_target_ipv4: nil,
    arp_source_hardware_address: nil, arp_target_hardware_address: nil,
    vlan_id: nil, vlan_pcp: nil, sctp_destination: nil, sctp_source: nil,
    mpls_label: nil, mpls_tc: nil, mpls_bos: nil, tunnel_id: nil,
    metadata: nil, metadata_mask: nil)
  @eth_type = eth_type
  @ipv4_dst = ipv4_destination
  @ipv4_src = ipv4_source
  @ipv6_dst = ipv6_destination
  @ipv6_src = ipv6_source
  @ipv6_flabel = ipv6_flabel
  @ipv6_ext_hdr = ipv6_ext_header
  @ethernet_dst = ethernet_destination
  @ethernet_src = ethernet_source
  @in_port = in_port
  @in_phy_port = in_physical_port
  @ip_proto = ip_protocol_num
  @ip_dscp = ip_dscp
  @ip_ecn = ip_ecn
  @tcp_src_port = tcp_source_port
  @tcp_dst_port = tcp_destination_port
  @udp_dst_port = udp_destination_port
  @udp_src_port = udp_source_port
  @icmpv4_type = icmpv4_type
  @icmpv4_code = icmpv4_code
  @icmpv6_type = icmpv6_type
  @icmpv6_code = icmpv6_code
  @arp_op_code = arp_op_code
  @arp_src_ipv4 = arp_source_ipv4
  @arp_tgt_ipv4 = arp_target_ipv4
  @arp_src_hw_addr = arp_source_hardware_address
  @arp_tgt_hw_addr = arp_target_hardware_address
  @vlan_id = vlan_id
  @vlan_pcp = vlan_pcp
  @sctp_dst = sctp_destination
  @sctp_src = sctp_source
  @mpls_label = mpls_label
  @mpls_tc = mpls_tc
  @mpls_bos = mpls_bos
  @tunnel_id = tunnel_id
  @metdata = 
   = 
end

Instance Attribute Details

#arp_op_codeObject (readonly)

Returns the value of attribute arp_op_code.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def arp_op_code
  @arp_op_code
end

#arp_src_hw_addrObject (readonly)

Returns the value of attribute arp_src_hw_addr.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def arp_src_hw_addr
  @arp_src_hw_addr
end

#arp_src_ipv4Object (readonly)

Returns the value of attribute arp_src_ipv4.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def arp_src_ipv4
  @arp_src_ipv4
end

#arp_tgt_hw_addrObject (readonly)

Returns the value of attribute arp_tgt_hw_addr.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def arp_tgt_hw_addr
  @arp_tgt_hw_addr
end

#arp_tgt_ipv4Object (readonly)

Returns the value of attribute arp_tgt_ipv4.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def arp_tgt_ipv4
  @arp_tgt_ipv4
end

#eth_typeObject (readonly)

Returns the value of attribute eth_type.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def eth_type
  @eth_type
end

#ethernet_dstObject (readonly)

Returns the value of attribute ethernet_dst.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ethernet_dst
  @ethernet_dst
end

#ethernet_srcObject (readonly)

Returns the value of attribute ethernet_src.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ethernet_src
  @ethernet_src
end

#icmpv4_codeObject (readonly)

Returns the value of attribute icmpv4_code.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def icmpv4_code
  @icmpv4_code
end

#icmpv4_typeObject (readonly)

Returns the value of attribute icmpv4_type.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def icmpv4_type
  @icmpv4_type
end

#icmpv6_codeObject (readonly)

Returns the value of attribute icmpv6_code.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def icmpv6_code
  @icmpv6_code
end

#icmpv6_typeObject (readonly)

Returns the value of attribute icmpv6_type.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def icmpv6_type
  @icmpv6_type
end

#in_phy_portObject (readonly)

Returns the value of attribute in_phy_port.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def in_phy_port
  @in_phy_port
end

#in_portObject (readonly)

Returns the value of attribute in_port.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def in_port
  @in_port
end

#ip_dscpObject (readonly)

Returns the value of attribute ip_dscp.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ip_dscp
  @ip_dscp
end

#ip_ecnObject (readonly)

Returns the value of attribute ip_ecn.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ip_ecn
  @ip_ecn
end

#ip_protoObject (readonly)

Returns the value of attribute ip_proto.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ip_proto
  @ip_proto
end

#ipv4_dstObject (readonly)

Returns the value of attribute ipv4_dst.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ipv4_dst
  @ipv4_dst
end

#ipv4_srcObject (readonly)

Returns the value of attribute ipv4_src.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ipv4_src
  @ipv4_src
end

#ipv6_dstObject (readonly)

Returns the value of attribute ipv6_dst.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ipv6_dst
  @ipv6_dst
end

#ipv6_ext_hdrObject (readonly)

Returns the value of attribute ipv6_ext_hdr.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ipv6_ext_hdr
  @ipv6_ext_hdr
end

#ipv6_flabelObject (readonly)

Returns the value of attribute ipv6_flabel.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ipv6_flabel
  @ipv6_flabel
end

#ipv6_srcObject (readonly)

Returns the value of attribute ipv6_src.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def ipv6_src
  @ipv6_src
end

#metadataObject (readonly)

Returns the value of attribute metadata.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def 
  
end

#metadata_maskObject (readonly)

Returns the value of attribute metadata_mask.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def 
  
end

#mpls_bosObject (readonly)

Returns the value of attribute mpls_bos.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def mpls_bos
  @mpls_bos
end

#mpls_labelObject (readonly)

Returns the value of attribute mpls_label.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def mpls_label
  @mpls_label
end

#mpls_tcObject (readonly)

Returns the value of attribute mpls_tc.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def mpls_tc
  @mpls_tc
end

#sctp_dstObject (readonly)

Returns the value of attribute sctp_dst.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def sctp_dst
  @sctp_dst
end

#sctp_srcObject (readonly)

Returns the value of attribute sctp_src.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def sctp_src
  @sctp_src
end

#tcp_dst_portObject (readonly)

Returns the value of attribute tcp_dst_port.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def tcp_dst_port
  @tcp_dst_port
end

#tcp_src_portObject (readonly)

Returns the value of attribute tcp_src_port.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def tcp_src_port
  @tcp_src_port
end

#tunnel_idObject (readonly)

Returns the value of attribute tunnel_id.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def tunnel_id
  @tunnel_id
end

#udp_dst_portObject (readonly)

Returns the value of attribute udp_dst_port.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def udp_dst_port
  @udp_dst_port
end

#udp_src_portObject (readonly)

Returns the value of attribute udp_src_port.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def udp_src_port
  @udp_src_port
end

#vlan_idObject (readonly)

Returns the value of attribute vlan_id.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def vlan_id
  @vlan_id
end

#vlan_pcpObject (readonly)

Returns the value of attribute vlan_pcp.



33
34
35
# File 'lib/openflowdev/match.rb', line 33

def vlan_pcp
  @vlan_pcp
end

Instance Method Details

#to_hashObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/openflowdev/match.rb', line 92

def to_hash
  hash = {'ethernet-match' => {'ethernet-type' => {:type => @eth_type},
    'ethernet-destination' => {:address => @ethernet_dst},
    'ethernet-source' => {:address => @ethernet_src}},
    'ipv4-destination' => @ipv4_dst, 'ipv4-source' => @ipv4_src,
    'ipv6-destination' => @ipv6_dst, 'ipv6-source' => @ipv6_src,
    'ipv6-label' => {'ipv6-flabel' => @ipv6_flabel},
    'ipv6-ext-header' => {'ipv6-exthdr' => @ipv6_ext_hdr},
    'in-port' => @in_port, 'in_phy_port' => @in_phy_port,
    'ip-match' => {'ip-dscp' => @ip_dscp, 'ip-ecn' => @ip_ecn,
      'ip-protocol' => @ip_proto}, 'tcp-destination-port' => @tcp_dst_port,
    'tcp-source-port' => @tcp_src_port, 'udp-source-port' => @udp_src_port,
    'udp-destination-port' => @udp_dst_port, 'icmpv4-match' =>
      {'icmpv4-code' => @icmpv4_code, 'icmpv4-type' => @icmpv4_type},
    'icmpv6-match' => {'icmpv6-code' => @icmpv6_code, 'icmpv6-type' => @icmpv6_type},
    'arp-op' => @arp_op_code, 'arp-source-transport-address' => @arp_src_ipv4,
    'arp-source-hardware-address' => {:address => @arp_src_hw_addr},
    'arp-target-hardware-address' => {:address => @arp_tgt_hw_addr},
    'arp-target-transport-address' => @arp_tgt_ipv4,
    'vlan-match' => {'vlan-id' => {'vlan-id' => @vlan_id,
        'vlan-id-present' => !@vlan_id.nil?}, 'vlan-pcp' => @vlan_pcp},
    'sctp-source-port' => @sctp_src, 'sctp-destination-port' => @sctp_dst,
    'protocol-match-fields' => {'mpls-label' => @mpls_label,
      'mpls-tc' => @mpls_tc, 'mpls-bos' => @mpls_bos},
    :tunnel => {'tunnel-id' => @tunnel_id},
    :metadata => {:metadata => , 'metadata-mask' => }}
  hash.delete("vlan-match") if !@vlan_id
  hash
end