Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
264 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'bindata' | ||
require 'pio/monkey_patch/integer' | ||
|
||
module Pio | ||
module OpenFlow | ||
# Datapath unique ID. The lower 48-bits are for a MAC address, | ||
# while the upper 16-bits are implementer-defined. | ||
class DatapathId < BinData::Primitive | ||
endian :big | ||
|
||
uint64 :datapath_id | ||
|
||
def set(value) | ||
unless value.unsigned_64bit? | ||
fail(ArgumentError, | ||
'Datapath ID should be an unsigned 64-bit integer.') | ||
end | ||
self.datapath_id = value | ||
end | ||
|
||
def get | ||
datapath_id | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'pio/open_flow10/features' | ||
|
||
describe Pio::Features::Reply do | ||
describe '.new' do | ||
it_should_behave_like('an OpenFlow message with Datapath ID', | ||
Pio::Features::Reply) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'pio/open_flow13/features_reply' | ||
|
||
describe Pio::Features::Reply do | ||
describe '.new' do | ||
it_should_behave_like('an OpenFlow message with Datapath ID', | ||
Pio::Features::Reply) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
shared_examples 'an OpenFlow message with Datapath ID' do |klass| | ||
When(:message) { klass.new(options) } | ||
|
||
context 'with { datapath_id: -1 }' do | ||
Given(:options) { { datapath_id: -1 } } | ||
Then do | ||
message == Failure(ArgumentError, | ||
'Datapath ID should be an unsigned 64-bit integer.') | ||
end | ||
end | ||
|
||
context 'with { datapath_id: 0 }' do | ||
Given(:options) { { datapath_id: 0 } } | ||
Then { message.datapath_id == 0 } | ||
end | ||
|
||
context 'with { datapath_id: 2**64 - 1 }' do | ||
Given(:options) { { datapath_id: 2**64 - 1 } } | ||
Then { message.datapath_id == 2**64 - 1 } | ||
end | ||
|
||
context 'with { datapath_id: 2**64 }' do | ||
Given(:options) { { datapath_id: 2**64 } } | ||
Then do | ||
message == Failure(ArgumentError, | ||
'Datapath ID should be an unsigned 64-bit integer.') | ||
end | ||
end | ||
end |