pio 0.27.1 → 0.27.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Rakefile +1 -1
  4. data/bin/{terminal-notifier → code_metrics} +2 -2
  5. data/bin/code_metrics-profile +16 -0
  6. data/features/icmpv6.pcap +0 -0
  7. data/features/open_flow10/aggregate_stats_reply.feature +1 -1
  8. data/features/open_flow10/aggregate_stats_request.feature +2 -2
  9. data/features/open_flow10/bad_request.feature +2 -2
  10. data/features/open_flow10/barrier_reply.feature +3 -18
  11. data/features/open_flow10/barrier_request.feature +3 -18
  12. data/features/open_flow10/description_stats_reply.feature +1 -1
  13. data/features/open_flow10/description_stats_request.feature +3 -3
  14. data/features/open_flow10/echo_reply.feature +4 -47
  15. data/features/open_flow10/echo_request.feature +4 -36
  16. data/features/open_flow10/exact_match.feature +20 -2
  17. data/features/open_flow10/features_reply.feature +65 -72
  18. data/features/open_flow10/features_request.feature +3 -22
  19. data/features/open_flow10/flow_mod.feature +5 -5
  20. data/features/open_flow10/flow_stats_reply.feature +2 -2
  21. data/features/open_flow10/flow_stats_request.feature +3 -4
  22. data/features/open_flow10/hello.feature +4 -20
  23. data/features/open_flow10/hello_failed.feature +4 -4
  24. data/features/open_flow10/packet_in.feature +2 -2
  25. data/features/open_flow10/packet_in_arp_reply.raw +0 -0
  26. data/features/open_flow10/packet_out.feature +1 -1
  27. data/features/open_flow10/port_status.feature +1 -1
  28. data/features/open_flow13/bad_request.feature +2 -2
  29. data/features/open_flow13/echo_reply.feature +5 -37
  30. data/features/open_flow13/echo_request.feature +5 -37
  31. data/features/open_flow13/features_reply.feature +3 -7
  32. data/features/open_flow13/features_request.feature +3 -18
  33. data/features/open_flow13/flow_mod.feature +5 -5
  34. data/features/open_flow13/hello.feature +4 -19
  35. data/features/open_flow13/hello_failed.feature +4 -4
  36. data/features/open_flow13/match.feature +4 -4
  37. data/features/open_flow13/packet_in.feature +3 -3
  38. data/features/open_flow13/packet_out.feature +3 -3
  39. data/features/parser.feature +10 -0
  40. data/lib/pio/arp/format.rb +20 -0
  41. data/lib/pio/ipv4_header.rb +20 -0
  42. data/lib/pio/open_flow.rb +0 -1
  43. data/lib/pio/open_flow/message.rb +51 -57
  44. data/lib/pio/open_flow/open_flow_header.rb +6 -10
  45. data/lib/pio/open_flow10.rb +20 -15
  46. data/lib/pio/open_flow10/aggregate_stats/reply.rb +20 -0
  47. data/lib/pio/open_flow10/aggregate_stats/request.rb +25 -0
  48. data/lib/pio/open_flow10/barrier/reply.rb +14 -0
  49. data/lib/pio/open_flow10/barrier/request.rb +14 -0
  50. data/lib/pio/open_flow10/description_stats/reply.rb +21 -0
  51. data/lib/pio/open_flow10/description_stats/request.rb +19 -0
  52. data/lib/pio/open_flow10/echo/reply.rb +16 -0
  53. data/lib/pio/open_flow10/echo/request.rb +16 -0
  54. data/lib/pio/open_flow10/error/bad_request.rb +27 -49
  55. data/lib/pio/open_flow10/error/hello_failed.rb +6 -28
  56. data/lib/pio/open_flow10/exact_match.rb +4 -39
  57. data/lib/pio/open_flow10/features/reply.rb +48 -72
  58. data/lib/pio/open_flow10/features/request.rb +4 -11
  59. data/lib/pio/open_flow10/flow_mod.rb +21 -51
  60. data/lib/pio/open_flow10/{flow_stats_reply.rb → flow_stats/reply.rb} +7 -23
  61. data/lib/pio/open_flow10/flow_stats/request.rb +25 -0
  62. data/lib/pio/open_flow10/hello.rb +3 -13
  63. data/lib/pio/open_flow10/match.rb +0 -18
  64. data/lib/pio/open_flow10/match10.rb +22 -0
  65. data/lib/pio/open_flow10/packet_in.rb +18 -42
  66. data/lib/pio/open_flow10/packet_out.rb +8 -31
  67. data/lib/pio/open_flow10/port_status.rb +11 -39
  68. data/lib/pio/open_flow10/stats_reply.rb +11 -8
  69. data/lib/pio/open_flow10/stats_request.rb +8 -8
  70. data/lib/pio/open_flow13.rb +13 -6
  71. data/lib/pio/open_flow13/echo/reply.rb +15 -0
  72. data/lib/pio/open_flow13/echo/request.rb +15 -0
  73. data/lib/pio/open_flow13/error/bad_request.rb +32 -49
  74. data/lib/pio/open_flow13/error/hello_failed.rb +7 -30
  75. data/lib/pio/open_flow13/features/reply.rb +27 -51
  76. data/lib/pio/open_flow13/features/request.rb +3 -10
  77. data/lib/pio/open_flow13/flow_mod.rb +29 -52
  78. data/lib/pio/open_flow13/hello.rb +18 -22
  79. data/lib/pio/open_flow13/packet_in.rb +26 -44
  80. data/lib/pio/open_flow13/packet_out.rb +16 -35
  81. data/lib/pio/open_flow13/stats_request.rb +5 -21
  82. data/lib/pio/parser.rb +5 -4
  83. data/lib/pio/version.rb +1 -1
  84. data/pio.gemspec +6 -6
  85. data/spec/pio/open_flow10/{echo_reply_spec.rb → echo/reply_spec.rb} +1 -1
  86. data/spec/pio/open_flow10/{echo_request_spec.rb → echo/request_spec.rb} +1 -1
  87. data/spec/pio/open_flow10/error/hello_failed_spec.rb +2 -2
  88. data/spec/pio/open_flow10/features/request_spec.rb +0 -5
  89. data/spec/pio/open_flow10/flow_mod_spec.rb +2 -4
  90. data/spec/pio/open_flow10/flow_stats_reply_spec.rb +1 -1
  91. data/spec/pio/open_flow10/flow_stats_request_spec.rb +2 -2
  92. data/spec/pio/open_flow10/packet_out_spec.rb +15 -18
  93. data/spec/pio/open_flow13/echo_reply_spec.rb +1 -1
  94. data/spec/pio/open_flow13/echo_request_spec.rb +1 -1
  95. data/spec/pio/open_flow13/error/hello_failed_spec.rb +2 -2
  96. data/spec/pio/open_flow13/features/request_spec.rb +5 -3
  97. data/spec/pio/open_flow13/hello_spec.rb +3 -3
  98. data/spec/support/shared_examples_for_openflow_messages.rb +5 -12
  99. metadata +92 -85
  100. data/lib/pio/open_flow/echo.rb +0 -44
  101. data/lib/pio/open_flow/format.rb +0 -46
  102. data/lib/pio/open_flow10/aggregate_stats_reply.rb +0 -38
  103. data/lib/pio/open_flow10/aggregate_stats_request.rb +0 -42
  104. data/lib/pio/open_flow10/barrier_reply.rb +0 -21
  105. data/lib/pio/open_flow10/barrier_request.rb +0 -22
  106. data/lib/pio/open_flow10/description_stats_reply.rb +0 -35
  107. data/lib/pio/open_flow10/description_stats_request.rb +0 -36
  108. data/lib/pio/open_flow10/echo.rb +0 -20
  109. data/lib/pio/open_flow10/flow_stats_request.rb +0 -64
  110. data/lib/pio/open_flow13/echo.rb +0 -20
  111. data/lib/pio/open_flow13/features.rb +0 -2
@@ -1,22 +1,25 @@
1
+ require 'pio/open_flow/message'
2
+ require 'pio/open_flow10/aggregate_stats/reply'
3
+ require 'pio/open_flow10/description_stats/reply'
4
+ require 'pio/open_flow10/flow_stats/reply'
5
+
1
6
  module Pio
2
7
  module OpenFlow10
3
8
  class Stats
4
9
  # Stats reply parser.
5
10
  class Reply
6
- # Stats reply format.
7
- class Format < BinData::Record
8
- extend OpenFlow::Format
9
-
10
- header version: 1, message_type: 17
11
- stats_type :stats_type
12
- end
13
-
14
11
  TYPES = {
15
12
  description: OpenFlow10::DescriptionStats::Reply,
16
13
  flow: OpenFlow10::FlowStats::Reply,
17
14
  aggregate: OpenFlow10::AggregateStats::Reply
18
15
  }
19
16
 
17
+ # Stats reply format.
18
+ class Format < OpenFlow::Message
19
+ open_flow_header version: 1, message_type: 17, message_length: 10
20
+ stats_type :stats_type
21
+ end
22
+
20
23
  def self.read(binary)
21
24
  TYPES.fetch(Format.read(binary).stats_type.to_sym).read(binary)
22
25
  rescue KeyError
@@ -1,22 +1,22 @@
1
+ require 'pio/open_flow/message'
2
+
1
3
  module Pio
2
4
  module OpenFlow10
3
5
  class Stats
4
6
  # Stats request parser.
5
7
  class Request
6
- # Stats request format.
7
- class Format < BinData::Record
8
- extend OpenFlow::Format
9
-
10
- header version: 1, message_type: 16
11
- stats_type :stats_type
12
- end
13
-
14
8
  TYPES = {
15
9
  description: OpenFlow10::DescriptionStats::Request,
16
10
  flow: OpenFlow10::FlowStats::Request,
17
11
  aggregate: OpenFlow10::AggregateStats::Request
18
12
  }
19
13
 
14
+ # Stats request format.
15
+ class Format < OpenFlow::Message
16
+ open_flow_header version: 1, message_type: 16, message_length: 10
17
+ stats_type :stats_type
18
+ end
19
+
20
20
  def self.read(binary)
21
21
  TYPES.fetch(Format.read(binary).stats_type.to_sym).read(binary)
22
22
  rescue KeyError
@@ -1,15 +1,22 @@
1
- require 'pio/open_flow13/apply'
2
- require 'pio/open_flow13/echo'
1
+ # Messages
2
+ require 'pio/open_flow13/echo/reply'
3
+ require 'pio/open_flow13/echo/request'
3
4
  require 'pio/open_flow13/error'
4
5
  require 'pio/open_flow13/error/bad_request'
5
6
  require 'pio/open_flow13/error/hello_failed'
6
- require 'pio/open_flow13/features'
7
+ require 'pio/open_flow13/features/reply'
8
+ require 'pio/open_flow13/features/request'
7
9
  require 'pio/open_flow13/flow_mod'
8
- require 'pio/open_flow13/goto_table'
9
10
  require 'pio/open_flow13/hello'
10
- require 'pio/open_flow13/meter'
11
11
  require 'pio/open_flow13/packet_in'
12
12
  require 'pio/open_flow13/packet_out'
13
- require 'pio/open_flow13/send_out_port'
14
13
  require 'pio/open_flow13/stats_request'
14
+
15
+ # Actions
16
+ require 'pio/open_flow13/send_out_port'
17
+
18
+ # Instructions
19
+ require 'pio/open_flow13/apply'
20
+ require 'pio/open_flow13/goto_table'
21
+ require 'pio/open_flow13/meter'
15
22
  require 'pio/open_flow13/write_metadata'
@@ -0,0 +1,15 @@
1
+ require 'pio/open_flow/message'
2
+
3
+ module Pio
4
+ module OpenFlow13
5
+ module Echo
6
+ # OpenFlow 1.3 Echo Reply message.
7
+ class Reply < OpenFlow::Message
8
+ open_flow_header version: 4, message_type: 3
9
+ string :body, read_length: -> { message_length - 8 }
10
+
11
+ alias_method :user_data, :body
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'pio/open_flow/message'
2
+
3
+ module Pio
4
+ module OpenFlow13
5
+ module Echo
6
+ # OpenFlow 1.3 Echo Request message.
7
+ class Request < OpenFlow::Message
8
+ open_flow_header version: 4, message_type: 2
9
+ string :body, read_length: -> { message_length - 8 }
10
+
11
+ alias_method :user_data, :body
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,4 +1,3 @@
1
- require 'pio/open_flow/format'
2
1
  require 'pio/open_flow/message'
3
2
  require 'pio/open_flow13/error/error_type13'
4
3
 
@@ -7,59 +6,43 @@ module Pio
7
6
  module Error
8
7
  # Bad request error.
9
8
  class BadRequest < OpenFlow::Message
10
- # Bad request error format.
11
- class Format < BinData::Record
12
- # enum ofp_bad_request_code
13
- class BadRequestCode < BinData::Primitive
14
- ERROR_CODES = {
15
- bad_version: 0,
16
- bad_type: 1,
17
- bad_multipart: 2,
18
- bad_experimenter: 3,
19
- bad_experimenter_type: 4,
20
- permissions_error: 5,
21
- bad_length: 6,
22
- buffer_empty: 7,
23
- buffer_unknown: 8,
24
- bad_table_id: 9,
25
- controller_is_slave: 10,
26
- bad_port: 11,
27
- bad_packet: 12,
28
- multipart_buffer_overflow: 13
29
- }
30
-
31
- endian :big
32
- uint16 :error_code
33
-
34
- def get
35
- ERROR_CODES.invert.fetch(error_code)
36
- end
37
-
38
- def set(value)
39
- self.error_code = ERROR_CODES.fetch(value)
40
- end
9
+ # enum ofp_bad_request_code
10
+ class BadRequestCode < BinData::Primitive
11
+ ERROR_CODES = {
12
+ bad_version: 0,
13
+ bad_type: 1,
14
+ bad_multipart: 2,
15
+ bad_experimenter: 3,
16
+ bad_experimenter_type: 4,
17
+ permissions_error: 5,
18
+ bad_length: 6,
19
+ buffer_empty: 7,
20
+ buffer_unknown: 8,
21
+ bad_table_id: 9,
22
+ controller_is_slave: 10,
23
+ bad_port: 11,
24
+ bad_packet: 12,
25
+ multipart_buffer_overflow: 13
26
+ }
27
+
28
+ endian :big
29
+ uint16 :error_code
30
+
31
+ def get
32
+ ERROR_CODES.invert.fetch(error_code)
41
33
  end
42
34
 
43
- # Bad request error body.
44
- class Body < BinData::Record
45
- endian :big
46
-
47
- error_type13 :error_type, value: -> { :bad_request }
48
- bad_request_code :error_code
49
- rest :raw_data
50
-
51
- def length
52
- 4 + raw_data.length
53
- end
35
+ def set(value)
36
+ self.error_code = ERROR_CODES.fetch(value)
54
37
  end
55
-
56
- extend OpenFlow::Format
57
-
58
- header version: 4, message_type: 1
59
- body :body
60
38
  end
61
39
 
62
- body_option :raw_data
40
+ open_flow_header version: 4,
41
+ message_type: 1,
42
+ message_length: -> { 12 + raw_data.length }
43
+ error_type13 :error_type, value: -> { :bad_request }
44
+ bad_request_code :error_code
45
+ rest :raw_data
63
46
  end
64
47
  end
65
48
  end
@@ -1,41 +1,18 @@
1
1
  require 'pio/open_flow/hello_failed_code'
2
- require 'pio/open_flow/format'
3
2
  require 'pio/open_flow/message'
3
+ require 'pio/open_flow13/error/error_type13'
4
4
 
5
- # Base module.
6
5
  module Pio
7
- # OpenFlow 1.3 messages
8
6
  module OpenFlow13
9
7
  module Error
10
8
  # Hello Failed error message
11
9
  class HelloFailed < OpenFlow::Message
12
- # Hello Failed error format.
13
- class Format < BinData::Record
14
- # Hello Failed error body.
15
- class Body < BinData::Record
16
- endian :big
17
-
18
- error_type13 :error_type
19
- hello_failed_code :error_code
20
- rest :description
21
-
22
- def length
23
- 4 + description.length
24
- end
25
- end
26
-
27
- extend OpenFlow::Format
28
-
29
- header version: 4, message_type: 1
30
- body :body
31
-
32
- def length
33
- 8 + body.length
34
- end
35
- end
36
-
37
- body_option :error_code
38
- body_option :description
10
+ open_flow_header version: 4,
11
+ message_type: 1,
12
+ message_length: -> { 12 + description.length }
13
+ error_type13 :error_type
14
+ hello_failed_code :error_code
15
+ rest :description
39
16
  end
40
17
  end
41
18
  end
@@ -1,62 +1,38 @@
1
- require 'pio/open_flow'
1
+ require 'pio/open_flow/message'
2
2
 
3
- # Base module.
4
3
  module Pio
5
- # OpenFlow 1.3 messages
6
4
  module OpenFlow13
7
5
  # Features Request and Reply message.
8
6
  class Features
9
7
  # Features Reply message.
10
8
  class Reply < OpenFlow::Message
11
- # Features Reply message body.
12
- class Body < BinData::Record
13
- extend OpenFlow::Flags
14
-
15
- flags_32bit(:capabilities,
16
- [:flow_stats,
17
- :table_stats,
18
- :port_stats,
19
- :group_stats,
20
- :NOT_USED,
21
- :ip_reasm,
22
- :queue_stats,
23
- :NOT_USED,
24
- :port_blocked])
25
-
26
- endian :big
27
-
28
- datapath_id :datapath_id
29
- uint32 :n_buffers
30
- uint8 :n_tables
31
- uint8 :auxiliary_id
32
- uint16 :padding
33
- hide :padding
34
- capabilities :capabilities
35
- uint32 :reserved
36
-
37
- def length
38
- 24
39
- end
9
+ extend OpenFlow::Flags
10
+
11
+ flags_32bit(:capabilities,
12
+ [:flow_stats,
13
+ :table_stats,
14
+ :port_stats,
15
+ :group_stats,
16
+ :NOT_USED,
17
+ :ip_reasm,
18
+ :queue_stats,
19
+ :NOT_USED,
20
+ :port_blocked])
21
+
22
+ open_flow_header version: 4, message_type: 6, message_length: 32
23
+ datapath_id :datapath_id
24
+ uint32 :n_buffers
25
+ uint8 :n_tables
26
+ uint8 :auxiliary_id
27
+ uint16 :padding
28
+ hide :padding
29
+ capabilities :capabilities
30
+ uint32 :reserved
31
+
32
+ def datapath_id
33
+ @format.datapath_id.to_i
40
34
  end
41
-
42
- # Features Reply message format.
43
- class Format < BinData::Record
44
- extend OpenFlow::Format
45
-
46
- header version: 4, message_type: 6
47
- body :body
48
-
49
- def datapath_id
50
- body.datapath_id.to_i
51
- end
52
- alias_method :dpid, :datapath_id
53
- end
54
-
55
- body_option :dpid
56
- body_option :datapath_id
57
- body_option :n_buffers
58
- body_option :n_tables
59
- body_option :capabilities
35
+ alias_method :dpid, :datapath_id
60
36
  end
61
37
  end
62
38
  end
@@ -1,20 +1,13 @@
1
- require 'pio/open_flow'
1
+ require 'pio/open_flow/message'
2
2
 
3
- # Base module.
4
3
  module Pio
5
- # OpenFlow 1.3 messages
6
4
  module OpenFlow13
7
5
  # Features Request and Reply message.
8
6
  class Features
9
7
  # Features Request message.
10
8
  class Request < OpenFlow::Message
11
- # Features Request message format.
12
- class Format < BinData::Record
13
- extend OpenFlow::Format
14
-
15
- header version: 4, message_type: 5
16
- string :body, value: ''
17
- end
9
+ open_flow_header version: 4, message_type: 5
10
+ string :body, value: ''
18
11
  end
19
12
  end
20
13
  end
@@ -2,7 +2,6 @@ require 'pio/open_flow'
2
2
  require 'pio/open_flow13/buffer_id'
3
3
  require 'pio/open_flow13/match'
4
4
 
5
- # Base module.
6
5
  module Pio
7
6
  module OpenFlow13
8
7
  # OpenFlow 1.3 FlowMod message parser and generator
@@ -103,57 +102,35 @@ module Pio
103
102
  end
104
103
  end
105
104
 
106
- # OpenFlow 1.3 FlowMod message body
107
- class Body < BinData::Record
108
- extend OpenFlow::Flags
109
- flags_16bit :flags,
110
- [:send_flow_rem,
111
- :check_overwrap,
112
- :reset_counts,
113
- :no_packet_counts,
114
- :no_byte_counts]
115
-
116
- endian :big
117
-
118
- uint64 :cookie
119
- uint64 :cookie_mask
120
- uint8 :table_id
121
- command :command
122
- uint16 :idle_timeout
123
- uint16 :hard_timeout
124
- uint16 :priority, initial_value: 0xffff
125
- buffer_id :buffer_id
126
- out_port :out_port
127
- out_group :out_group
128
- flags :flags
129
- string :padding, length: 2
130
- hide :padding
131
- oxm :match
132
- instructions :instructions
133
-
134
- def length
135
- 40 + match.length + instructions.length
136
- end
137
- end
138
-
139
- # OpenFlow 1.3 FlowMod message format
140
- class Format < BinData::Record
141
- extend OpenFlow::Format
142
-
143
- header version: 4, message_type: 14
144
- body :body
145
- end
146
-
147
- body_option :actions
148
- body_option :buffer_id
149
- body_option :command
150
- body_option :flags
151
- body_option :hard_timeout
152
- body_option :idle_timeout
153
- body_option :instructions
154
- body_option :match
155
- body_option :priority
156
- body_option :table_id
105
+ extend OpenFlow::Flags
106
+
107
+ flags_16bit :flags,
108
+ [:send_flow_rem,
109
+ :check_overwrap,
110
+ :reset_counts,
111
+ :no_packet_counts,
112
+ :no_byte_counts]
113
+
114
+ open_flow_header(version: 4,
115
+ message_type: 14,
116
+ message_length: lambda do
117
+ 48 + match.length + instructions.length
118
+ end)
119
+ uint64 :cookie
120
+ uint64 :cookie_mask
121
+ uint8 :table_id
122
+ command :command
123
+ uint16 :idle_timeout
124
+ uint16 :hard_timeout
125
+ uint16 :priority, initial_value: 0xffff
126
+ buffer_id :buffer_id
127
+ out_port :out_port
128
+ out_group :out_group
129
+ flags :flags
130
+ string :padding, length: 2
131
+ hide :padding
132
+ oxm :match
133
+ instructions :instructions
157
134
  end
158
135
  end
159
136
  end