diff --git a/CHANGELOG.md b/CHANGELOG.md index 9860c178..7df2903f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## develop (unreleased) ### New features +* [#302](https://github.com/trema/pio/pull/302): Add new classes `Pio::Match::ConjunctionId`. * [#300](https://github.com/trema/pio/pull/300): Add new classes `Pio::Match::PacketReg{0..3}`. ## 0.30.0 (11/17/2015) diff --git a/features/open_flow13/match.feature b/features/open_flow13/match.feature index 6e895082..36912976 100644 --- a/features/open_flow13/match.feature +++ b/features/open_flow13/match.feature @@ -448,6 +448,16 @@ Feature: Match | tunnel_id | 1 | | tunnel_id_mask | 9223372036854775808 | + Scenario: new(conjunction_id: 1) + When I try to create an OpenFlow message with: + """ + Pio::OpenFlow::Match.new(conjunction_id: 1) + """ + Then it should finish successfully + And the message has the following fields and values: + | field | value | + | conjunction_id | 1 | + Scenario: new(packet_reg0: 1) When I try to create an OpenFlow message with: """ diff --git a/lib/pio/open_flow13/match.rb b/lib/pio/open_flow13/match.rb index 9464354c..0084fcae 100644 --- a/lib/pio/open_flow13/match.rb +++ b/lib/pio/open_flow13/match.rb @@ -765,6 +765,19 @@ def length end end + # NXM_NX_CONJ_ID match field + class ConjunctionId < NiciraMatchExtensionValue + OXM_FIELD = 37 + + endian :big + + uint32 :conjunction_id + + def length + 4 + end + end + # OXM_PACKET_REG0 match field class PacketReg0 < PacketRegistersValue OXM_FIELD = 0 @@ -906,6 +919,7 @@ class NiciraMatchExtension < BinData::Record masked_reg6 MaskedReg6 reg7 Reg7 masked_reg7 MaskedReg7 + conjunction_id ConjunctionId end def length @@ -944,6 +958,8 @@ def choose_tlv_value masked? ? MaskedReg6 : Reg6 when Reg7::OXM_FIELD masked? ? MaskedReg7 : Reg7 + when ConjunctionId::OXM_FIELD + ConjunctionId else fail "Unknown OXM field value: #{oxm_field}" end @@ -1270,7 +1286,8 @@ def initialize(user_attrs) :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| + :icmpv4_type, :icmpv4_code, :arp_operation, + :conjunction_id].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),