Skip to content

Commit

Permalink
Merge pull request #205 from trema/feature/barrier
Browse files Browse the repository at this point in the history
Add Barrier Request and Reply.
  • Loading branch information
yasuhito committed Jul 31, 2015
2 parents 2739221 + 9a0a6ff commit 255cb13
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### New features
* [#201](https://github.com/trema/pio/pull/201): Add oxm experimenter support (OpenFlow1.3).
* [#202](https://github.com/trema/pio/pull/202): Add `Pio::OpenFlow.switch_version` method.
* [#205](https://github.com/trema/pio/pull/205): Add new classes `Pio::OpenFlow10::Barrier::Request`, `Pio::OpenFlow10::Barrier::Reply`.


### Bugs fixed
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ supports the following packet formats:
- [Flow Mod](https://relishapp.com/trema/pio/docs/open-flow10/pio-flowmod)
- [Port Status](https://relishapp.com/trema/pio/docs/open-flow10/pio-portstatus)
- [Exact Match](https://relishapp.com/trema/pio/docs/open-flow10/pio-exactmatch)
- [Barrier Request](https://relishapp.com/trema/pio/docs/open-flow10/pio-barrier-request)
- [Barrier Reply](https://relishapp.com/trema/pio/docs/open-flow10/pio-barrier-reply)
- OpenFlow 1.3
- [Hello](https://relishapp.com/trema/pio/docs/open-flow13/pio-hello)
- [Echo Request](https://relishapp.com/trema/pio/docs/open-flow13/pio-echo-request)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'bundler/gem_tasks'

RELISH_PROJECT = 'trema/pio'
FLAY_THRESHOLD = 480
FLAY_THRESHOLD = 526

task default: :travis
task test: [:spec, :cucumber]
Expand Down
58 changes: 58 additions & 0 deletions features/open_flow10/barrier_reply.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@open_flow10
Feature: Pio::Barrier::Reply
Scenario: new
When I try to create an OpenFlow message with:
"""
Pio::Barrier::Reply.new
"""
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 19 |
| message_length | 8 |
| transaction_id | 0 |
| xid | 0 |
| body | |

Scenario: new(transaction_id: 123)
When I try to create an OpenFlow message with:
"""
Pio::Barrier::Reply.new(transaction_id: 123)
"""
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 19 |
| message_length | 8 |
| transaction_id | 123 |
| xid | 123 |
| body | |

Scenario: new(xid: 123)
When I try to create an OpenFlow message with:
"""
Pio::Barrier::Reply.new(xid: 123)
"""
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 19 |
| message_length | 8 |
| transaction_id | 123 |
| xid | 123 |
| body | |

Scenario: read
When I try to parse a file named "open_flow10/barrier_reply.raw" with "Barrier::Reply" class
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 19 |
| message_length | 8 |
| transaction_id | 0 |
| xid | 0 |
| body | |
58 changes: 58 additions & 0 deletions features/open_flow10/barrier_request.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@open_flow10
Feature: Pio::Barrier::Request
Scenario: new
When I try to create an OpenFlow message with:
"""
Pio::Barrier::Request.new
"""
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 18 |
| message_length | 8 |
| transaction_id | 0 |
| xid | 0 |
| body | |

Scenario: new(transaction_id: 123)
When I try to create an OpenFlow message with:
"""
Pio::Barrier::Request.new(transaction_id: 123)
"""
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 18 |
| message_length | 8 |
| transaction_id | 123 |
| xid | 123 |
| body | |

Scenario: new(xid: 123)
When I try to create an OpenFlow message with:
"""
Pio::Barrier::Request.new(xid: 123)
"""
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 18 |
| message_length | 8 |
| transaction_id | 123 |
| xid | 123 |
| body | |

Scenario: read
When I try to parse a file named "open_flow10/barrier_request.raw" with "Barrier::Request" class
Then it should finish successfully
And the message have the following fields and values:
| field | value |
| ofp_version | 1 |
| message_type | 18 |
| message_length | 8 |
| transaction_id | 0 |
| xid | 0 |
| body | |
11 changes: 5 additions & 6 deletions lib/pio/open_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ module Pio
# OpenFlow specific types.
module OpenFlow
def self.set_class_name(klass_name, open_flow_module)
if Pio.__send__(:const_defined?, klass_name)
Pio.__send__ :remove_const, klass_name
end
Pio.__send__(:const_set,
klass_name,
Pio.const_get(open_flow_module).const_get(klass_name))
return unless Pio.const_get(open_flow_module).const_defined?(klass_name)
Pio.__send__ :remove_const, klass_name if Pio.const_defined?(klass_name)
Pio.const_set(klass_name,
Pio.const_get(open_flow_module).const_get(klass_name))
nil
end

def self.switch_version(open_flow_module)
set_class_name :Barrier, open_flow_module
set_class_name :Echo, open_flow_module
set_class_name :Features, open_flow_module
set_class_name :FlowMod, open_flow_module
Expand Down
2 changes: 2 additions & 0 deletions lib/pio/open_flow10.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'pio/open_flow10/barrier_reply'
require 'pio/open_flow10/barrier_request'
require 'pio/open_flow10/echo'
require 'pio/open_flow10/exact_match'
require 'pio/open_flow10/features'
Expand Down
21 changes: 21 additions & 0 deletions lib/pio/open_flow10/barrier_reply.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'pio/open_flow/format'
require 'pio/open_flow/message'

module Pio
# OpenFlow 1.0 messages
module OpenFlow10
# OpenFlow 1.0 Barrier messages
module Barrier
# OpenFlow 1.0 Barrier Request message
class Reply < OpenFlow::Message
# OpenFlow 1.0 Barrier Request message format
class Format < BinData::Record
extend OpenFlow::Format

header version: 1, message_type: 19
string :body, value: ''
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/pio/open_flow10/barrier_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'pio/open_flow/format'
require 'pio/open_flow/message'

# Base module.
module Pio
# OpenFlow 1.0 messages
module OpenFlow10
# OpenFlow 1.0 Barrier messages
module Barrier
# OpenFlow 1.0 Barrier Request message
class Request < OpenFlow::Message
# OpenFlow 1.0 Barrier Request message format
class Format < BinData::Record
extend OpenFlow::Format

header version: 1, message_type: 18
string :body, value: ''
end
end
end
end
end

0 comments on commit 255cb13

Please sign in to comment.