-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Pio::OpenFlow13::Error::BadRequest.
- Loading branch information
Showing
18 changed files
with
199 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@open_flow13 | ||
Feature: Pio::Error::BadRequest | ||
|
||
Request was not understood error. | ||
|
||
Scenario: new (raw_data = Echo request 1.0) | ||
When I try to create an OpenFlow message with: | ||
""" | ||
Pio::Error::BadRequest.new(raw_data: Pio::OpenFlow10::Echo::Request.new.to_binary) | ||
""" | ||
Then it should finish successfully | ||
And the message has the following fields and values: | ||
| field | value | | ||
| ofp_version | 4 | | ||
| message_type | 1 | | ||
| message_length | 20 | | ||
| transaction_id | 0 | | ||
| xid | 0 | | ||
| error_type | :bad_request | | ||
| error_code | :bad_version | | ||
| raw_data.length | 8 | | ||
|
||
Scenario: read | ||
When I try to parse a file named "open_flow13/bad_request.raw" with "Pio::Error::BadRequest" class | ||
Then it should finish successfully | ||
And the message has the following fields and values: | ||
| field | value | | ||
| ofp_version | 4 | | ||
| message_type | 1 | | ||
| message_length | 20 | | ||
| transaction_id | 0 | | ||
| xid | 0 | | ||
| error_type | :bad_request | | ||
| error_code | :bad_version | | ||
| raw_data.length | 8 | |
Binary file not shown.
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'pio/open_flow10/error/error_type10' | ||
|
||
module Pio | ||
module OpenFlow10 | ||
# Error message parser | ||
|
2 changes: 1 addition & 1 deletion
2
lib/pio/open_flow10/bad_request.rb → lib/pio/open_flow10/error/bad_request.rb
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
lib/pio/open_flow10/hello_failed.rb → lib/pio/open_flow10/error/hello_failed.rb
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,66 @@ | ||
require 'pio/open_flow/format' | ||
require 'pio/open_flow/message' | ||
require 'pio/open_flow13/error/error_type13' | ||
|
||
module Pio | ||
module OpenFlow13 | ||
module Error | ||
# Bad request error. | ||
class BadRequest < OpenFlow::Message | ||
# Bad request error format. | ||
class Format < BinData::Record | ||
# enum ofp_bad_request_code | ||
class BadRequestCode < BinData::Primitive | ||
ERROR_CODES = { | ||
bad_version: 0, | ||
bad_type: 1, | ||
bad_multipart: 2, | ||
bad_experimenter: 3, | ||
bad_experimenter_type: 4, | ||
permissions_error: 5, | ||
bad_length: 6, | ||
buffer_empty: 7, | ||
buffer_unknown: 8, | ||
bad_table_id: 9, | ||
controller_is_slave: 10, | ||
bad_port: 11, | ||
bad_packet: 12, | ||
multipart_buffer_overflow: 13 | ||
} | ||
|
||
endian :big | ||
uint16 :error_code | ||
|
||
def get | ||
ERROR_CODES.invert.fetch(error_code) | ||
end | ||
|
||
def set(value) | ||
self.error_code = ERROR_CODES.fetch(value) | ||
end | ||
end | ||
|
||
# Bad request error body. | ||
class Body < BinData::Record | ||
endian :big | ||
|
||
error_type13 :error_type, value: -> { :bad_request } | ||
bad_request_code :error_code | ||
rest :raw_data | ||
|
||
def length | ||
4 + raw_data.length | ||
end | ||
end | ||
|
||
extend OpenFlow::Format | ||
|
||
header version: 4, message_type: 1 | ||
body :body | ||
end | ||
|
||
body_option :raw_data | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Pio | ||
module OpenFlow13 | ||
module Error | ||
# enum ofp_error_type | ||
class ErrorType13 < BinData::Primitive | ||
ERROR_TYPES = { | ||
hello_failed: 0, | ||
bad_request: 1, | ||
bad_action: 2, | ||
bad_instruction: 3, | ||
bad_match: 4, | ||
flow_mod_failed: 5, | ||
group_mod_failed: 6, | ||
port_mod_failed: 7, | ||
table_mod_failed: 8, | ||
queue_operation_failed: 9, | ||
switch_config_failed: 10, | ||
role_request_failed: 11, | ||
meter_mod_failed: 12, | ||
table_features_failed: 13, | ||
experimenter: 0xffff | ||
} | ||
|
||
endian :big | ||
uint16 :error_type | ||
|
||
def get | ||
ERROR_TYPES.invert.fetch(error_type) | ||
end | ||
|
||
def set(value) | ||
self.error_type = ERROR_TYPES.fetch(value) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'pio/open_flow/hello_failed_code' | ||
require 'pio/open_flow/format' | ||
require 'pio/open_flow/message' | ||
|
||
# Base module. | ||
module Pio | ||
# OpenFlow 1.3 messages | ||
module OpenFlow13 | ||
module Error | ||
# Hello Failed error message | ||
class HelloFailed < OpenFlow::Message | ||
# Hello Failed error format. | ||
class Format < BinData::Record | ||
# Hello Failed error body. | ||
class Body < BinData::Record | ||
endian :big | ||
|
||
error_type13 :error_type | ||
hello_failed_code :error_code | ||
rest :description | ||
|
||
def length | ||
4 + description.length | ||
end | ||
end | ||
|
||
extend OpenFlow::Format | ||
|
||
header version: 4, message_type: 1 | ||
body :body | ||
|
||
def length | ||
8 + body.length | ||
end | ||
end | ||
|
||
body_option :error_code | ||
body_option :description | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
spec/pio/open_flow10/hello_failed_spec.rb → ...io/open_flow10/error/hello_failed_spec.rb
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,6 @@ | ||
require 'pio/open_flow13/error/bad_request' | ||
|
||
describe Pio::OpenFlow13::Error::BadRequest do | ||
it_should_behave_like('an OpenFlow message', | ||
Pio::OpenFlow13::Error::BadRequest) | ||
end |
2 changes: 1 addition & 1 deletion
2
spec/pio/open_flow13/hello_failed_spec.rb → ...io/open_flow13/error/hello_failed_spec.rb
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