Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NXM_NX_CONJUNCTION_ID #302

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions features/open_flow13/match.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
19 changes: 18 additions & 1 deletion lib/pio/open_flow13/match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -906,6 +919,7 @@ class NiciraMatchExtension < BinData::Record
masked_reg6 MaskedReg6
reg7 Reg7
masked_reg7 MaskedReg7
conjunction_id ConjunctionId
end

def length
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down