openflow-protocol 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openflow-protocol.rb +2 -1
  3. data/lib/openflow-protocol/actions/action.rb +30 -0
  4. data/lib/openflow-protocol/actions/action_enqueue.rb +16 -0
  5. data/lib/openflow-protocol/actions/action_output.rb +14 -0
  6. data/lib/openflow-protocol/actions/action_set_destination_port.rb +7 -0
  7. data/lib/openflow-protocol/actions/action_set_ip_destination.rb +7 -0
  8. data/lib/openflow-protocol/actions/action_set_ip_source.rb +13 -0
  9. data/lib/openflow-protocol/actions/action_set_ip_tos.rb +15 -0
  10. data/lib/openflow-protocol/actions/action_set_mac_destination.rb +7 -0
  11. data/lib/openflow-protocol/actions/action_set_mac_source.rb +15 -0
  12. data/lib/openflow-protocol/actions/action_set_source_port.rb +15 -0
  13. data/lib/openflow-protocol/actions/action_set_vlan_id.rb +15 -0
  14. data/lib/openflow-protocol/actions/action_set_vlan_pcp.rb +15 -0
  15. data/lib/openflow-protocol/actions/action_strip_vlan.rb +14 -0
  16. data/lib/openflow-protocol/actions/action_vendor.rb +13 -0
  17. data/lib/openflow-protocol/actions/actions.rb +9 -0
  18. data/lib/openflow-protocol/helpers/array_of_subclasses.rb +42 -0
  19. data/lib/openflow-protocol/helpers/superclass_base.rb +26 -0
  20. data/lib/openflow-protocol/messages/barrier_reply.rb +7 -0
  21. data/lib/openflow-protocol/messages/barrier_request.rb +7 -0
  22. data/lib/openflow-protocol/messages/echo_reply.rb +13 -0
  23. data/lib/openflow-protocol/messages/echo_request.rb +13 -0
  24. data/lib/openflow-protocol/messages/error.rb +69 -0
  25. data/lib/openflow-protocol/messages/features_reply.rb +44 -0
  26. data/lib/openflow-protocol/messages/features_request.rb +7 -0
  27. data/lib/openflow-protocol/messages/flow_mod.rb +24 -0
  28. data/lib/openflow-protocol/messages/flow_removed.rb +27 -0
  29. data/lib/openflow-protocol/messages/get_config_reply.rb +16 -0
  30. data/lib/openflow-protocol/messages/get_config_request.rb +7 -0
  31. data/lib/openflow-protocol/messages/hello.rb +7 -0
  32. data/lib/openflow-protocol/messages/message.rb +49 -0
  33. data/lib/openflow-protocol/messages/packet_in.rb +27 -0
  34. data/lib/openflow-protocol/messages/packet_out.rb +17 -0
  35. data/lib/openflow-protocol/messages/parser.rb +26 -0
  36. data/lib/openflow-protocol/messages/port_mod.rb +19 -0
  37. data/lib/openflow-protocol/messages/port_status.rb +18 -0
  38. data/lib/openflow-protocol/messages/queue_get_config_reply.rb +18 -0
  39. data/lib/openflow-protocol/messages/queue_get_config_request.rb +15 -0
  40. data/lib/openflow-protocol/messages/set_config.rb +7 -0
  41. data/lib/openflow-protocol/messages/statistics.rb +28 -0
  42. data/lib/openflow-protocol/messages/statistics/aggregate_statistics_reply.rb +14 -0
  43. data/lib/openflow-protocol/messages/statistics/aggregate_statistics_request.rb +7 -0
  44. data/lib/openflow-protocol/messages/statistics/description_statistics.rb +32 -0
  45. data/lib/openflow-protocol/messages/statistics/flow_statistics_reply.rb +25 -0
  46. data/lib/openflow-protocol/messages/statistics/flow_statistics_request.rb +14 -0
  47. data/lib/openflow-protocol/messages/statistics/port_statistics_reply.rb +24 -0
  48. data/lib/openflow-protocol/messages/statistics/port_statistics_request.rb +12 -0
  49. data/lib/openflow-protocol/messages/statistics/queue_statistics_reply.rb +16 -0
  50. data/lib/openflow-protocol/messages/statistics/queue_statistics_request.rb +13 -0
  51. data/lib/openflow-protocol/messages/statistics/table_statistics.rb +20 -0
  52. data/lib/openflow-protocol/messages/statistics/vendor_statistics.rb +11 -0
  53. data/lib/openflow-protocol/messages/statistics_reply.rb +26 -0
  54. data/lib/openflow-protocol/messages/statistics_request.rb +18 -0
  55. data/lib/openflow-protocol/messages/vendor.rb +14 -0
  56. data/lib/openflow-protocol/structs/match.rb +106 -0
  57. data/lib/openflow-protocol/structs/packet_queue.rb +14 -0
  58. data/lib/openflow-protocol/structs/physical_port.rb +50 -0
  59. data/lib/openflow-protocol/structs/port_number.rb +49 -0
  60. data/lib/openflow-protocol/structs/queue_properties/queue_properties.rb +9 -0
  61. data/lib/openflow-protocol/structs/queue_properties/queue_property.rb +20 -0
  62. data/lib/openflow-protocol/structs/queue_properties/queue_property_min_rate.rb +30 -0
  63. data/lib/openflow-protocol/structs/queue_properties/queue_property_none.rb +7 -0
  64. data/lib/openflow-protocol/version.rb +1 -1
  65. data/spec/actions/action_enqueue_spec.rb +4 -6
  66. data/spec/actions/action_output_spec.rb +4 -6
  67. data/spec/actions/action_set_destination_port_spec.rb +4 -6
  68. data/spec/actions/action_set_ip_destination_spec.rb +4 -6
  69. data/spec/actions/action_set_ip_source_spec.rb +4 -6
  70. data/spec/actions/action_set_ip_tos_spec.rb +4 -6
  71. data/spec/actions/action_set_mac_destination_spec.rb +4 -6
  72. data/spec/actions/action_set_mac_source_spec.rb +4 -6
  73. data/spec/actions/action_set_source_port_spec.rb +4 -6
  74. data/spec/actions/action_set_vlan_id_spec.rb +4 -6
  75. data/spec/actions/action_set_vlan_pcp_spec.rb +4 -6
  76. data/spec/actions/action_strip_vlan_spec.rb +3 -5
  77. data/spec/actions/action_vendor_spec.rb +4 -6
  78. data/spec/actions/actions_spec.rb +6 -8
  79. data/spec/messages/barrier_reply_spec.rb +9 -11
  80. data/spec/messages/barrier_request_spec.rb +9 -11
  81. data/spec/messages/echo_reply_spec.rb +13 -15
  82. data/spec/messages/echo_request_spec.rb +16 -18
  83. data/spec/messages/error_spec.rb +23 -20
  84. data/spec/messages/features_reply_spec.rb +11 -13
  85. data/spec/messages/features_request_spec.rb +9 -11
  86. data/spec/messages/flow_mod_spec.rb +12 -14
  87. data/spec/messages/flow_removed_spec.rb +9 -11
  88. data/spec/messages/get_config_reply_spec.rb +9 -11
  89. data/spec/messages/get_config_request_spec.rb +9 -11
  90. data/spec/messages/hello_spec.rb +9 -11
  91. data/spec/messages/packet_in_spec.rb +9 -11
  92. data/spec/messages/packet_out_spec.rb +10 -12
  93. data/spec/messages/parser_spec.rb +7 -9
  94. data/spec/messages/port_mod_spec.rb +9 -11
  95. data/spec/messages/port_status_spec.rb +10 -12
  96. data/spec/messages/queue_get_config_reply_spec.rb +9 -11
  97. data/spec/messages/queue_get_config_request_spec.rb +9 -11
  98. data/spec/messages/set_config_spec.rb +9 -11
  99. data/spec/messages/statistics/aggregate_statistics_reply_spec.rb +4 -6
  100. data/spec/messages/statistics/aggregate_statistics_request_spec.rb +4 -6
  101. data/spec/messages/statistics/description_statistics_spec.rb +11 -9
  102. data/spec/messages/statistics/flow_statistics_reply_spec.rb +4 -6
  103. data/spec/messages/statistics/flow_statistics_request_spec.rb +4 -6
  104. data/spec/messages/statistics/port_statistics_reply_spec.rb +4 -6
  105. data/spec/messages/statistics/port_statistics_request_spec.rb +4 -6
  106. data/spec/messages/statistics/queue_statistics_reply_spec.rb +4 -6
  107. data/spec/messages/statistics/queue_statistics_request_spec.rb +4 -6
  108. data/spec/messages/statistics/table_statistics_spec.rb +4 -6
  109. data/spec/messages/statistics/vendor_statistics_spec.rb +4 -6
  110. data/spec/messages/statistics_reply_spec.rb +62 -64
  111. data/spec/messages/statistics_request_spec.rb +45 -47
  112. data/spec/messages/vendor_spec.rb +13 -15
  113. data/spec/spec_helper.rb +1 -1
  114. data/spec/structs/match_spec.rb +7 -9
  115. data/spec/structs/packet_queue_spec.rb +5 -7
  116. data/spec/structs/physical_port_spec.rb +16 -18
  117. data/spec/structs/port_number_spec.rb +11 -13
  118. data/spec/structs/queue_properties/queue_properties_spec.rb +5 -7
  119. data/spec/structs/queue_properties/queue_property_min_rate_spec.rb +5 -7
  120. data/spec/structs/queue_properties/queue_property_none_spec.rb +3 -5
  121. metadata +78 -64
  122. data/lib/actions/action.rb +0 -26
  123. data/lib/actions/action_enqueue.rb +0 -12
  124. data/lib/actions/action_output.rb +0 -10
  125. data/lib/actions/action_set_destination_port.rb +0 -3
  126. data/lib/actions/action_set_ip_destination.rb +0 -3
  127. data/lib/actions/action_set_ip_source.rb +0 -9
  128. data/lib/actions/action_set_ip_tos.rb +0 -11
  129. data/lib/actions/action_set_mac_destination.rb +0 -3
  130. data/lib/actions/action_set_mac_source.rb +0 -11
  131. data/lib/actions/action_set_source_port.rb +0 -11
  132. data/lib/actions/action_set_vlan_id.rb +0 -11
  133. data/lib/actions/action_set_vlan_pcp.rb +0 -11
  134. data/lib/actions/action_strip_vlan.rb +0 -10
  135. data/lib/actions/action_vendor.rb +0 -9
  136. data/lib/actions/actions.rb +0 -5
  137. data/lib/helpers/array_of_subclasses.rb +0 -38
  138. data/lib/helpers/superclass_base.rb +0 -24
  139. data/lib/messages/barrier_reply.rb +0 -3
  140. data/lib/messages/barrier_request.rb +0 -3
  141. data/lib/messages/echo_reply.rb +0 -9
  142. data/lib/messages/echo_request.rb +0 -9
  143. data/lib/messages/error.rb +0 -61
  144. data/lib/messages/features_reply.rb +0 -40
  145. data/lib/messages/features_request.rb +0 -3
  146. data/lib/messages/flow_mod.rb +0 -20
  147. data/lib/messages/flow_removed.rb +0 -23
  148. data/lib/messages/get_config_reply.rb +0 -12
  149. data/lib/messages/get_config_request.rb +0 -3
  150. data/lib/messages/hello.rb +0 -3
  151. data/lib/messages/message.rb +0 -45
  152. data/lib/messages/packet_in.rb +0 -23
  153. data/lib/messages/packet_out.rb +0 -13
  154. data/lib/messages/parser.rb +0 -22
  155. data/lib/messages/port_mod.rb +0 -15
  156. data/lib/messages/port_status.rb +0 -14
  157. data/lib/messages/queue_get_config_reply.rb +0 -14
  158. data/lib/messages/queue_get_config_request.rb +0 -11
  159. data/lib/messages/set_config.rb +0 -3
  160. data/lib/messages/statistics.rb +0 -24
  161. data/lib/messages/statistics/aggregate_statistics_reply.rb +0 -10
  162. data/lib/messages/statistics/aggregate_statistics_request.rb +0 -3
  163. data/lib/messages/statistics/description_statistics.rb +0 -28
  164. data/lib/messages/statistics/flow_statistics_reply.rb +0 -21
  165. data/lib/messages/statistics/flow_statistics_request.rb +0 -10
  166. data/lib/messages/statistics/port_statistics_reply.rb +0 -20
  167. data/lib/messages/statistics/port_statistics_request.rb +0 -8
  168. data/lib/messages/statistics/queue_statistics_reply.rb +0 -12
  169. data/lib/messages/statistics/queue_statistics_request.rb +0 -9
  170. data/lib/messages/statistics/table_statistics.rb +0 -16
  171. data/lib/messages/statistics/vendor_statistics.rb +0 -7
  172. data/lib/messages/statistics_reply.rb +0 -22
  173. data/lib/messages/statistics_request.rb +0 -14
  174. data/lib/messages/vendor.rb +0 -10
  175. data/lib/structs/match.rb +0 -102
  176. data/lib/structs/packet_queue.rb +0 -10
  177. data/lib/structs/physical_port.rb +0 -46
  178. data/lib/structs/port_number.rb +0 -45
  179. data/lib/structs/queue_properties/queue_properties.rb +0 -5
  180. data/lib/structs/queue_properties/queue_property.rb +0 -16
  181. data/lib/structs/queue_properties/queue_property_min_rate.rb +0 -26
  182. data/lib/structs/queue_properties/queue_property_none.rb +0 -3
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe OFStatisticsRequest do
1
+ describe OpenFlow::Protocol::StatisticsRequest do
4
2
  let(:data) {
5
3
  [
6
4
  1, 16, 0, 12, 0, 0, 0, 1, # header
@@ -11,8 +9,8 @@ describe OFStatisticsRequest do
11
9
 
12
10
  context 'with description' do
13
11
  it 'should read binary' do
14
- msg = OFStatisticsRequest.read(data)
15
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
12
+ msg = OpenFlow::Protocol::StatisticsRequest.read(data)
13
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
16
14
  expect(msg.type).to eq(:statistics_request)
17
15
  expect(msg.len).to eq(12)
18
16
  expect(msg.xid).to eq(1)
@@ -21,12 +19,12 @@ describe OFStatisticsRequest do
21
19
  expect(msg.statistics).to be_empty
22
20
  end
23
21
  it 'should be parsable' do
24
- msg = OFParser.read(data)
25
- expect(msg.class).to eq(OFStatisticsRequest)
22
+ msg = OpenFlow::Protocol::Parser.read(data)
23
+ expect(msg.class).to eq(OpenFlow::Protocol::StatisticsRequest)
26
24
  end
27
25
  it 'should initialize with default values' do
28
- msg = OFStatisticsRequest.new
29
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
26
+ msg = OpenFlow::Protocol::StatisticsRequest.new
27
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
30
28
  expect(msg.type).to eq(:statistics_request)
31
29
  expect(msg.len).to eq(12)
32
30
  expect(msg.xid).to eq(0)
@@ -35,11 +33,11 @@ describe OFStatisticsRequest do
35
33
  expect(msg.statistics).to be_empty
36
34
  end
37
35
  it 'should initialize with some values' do
38
- msg = OFStatisticsRequest.new(
36
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
39
37
  xid: 1,
40
38
  statistic_type: :description
41
39
  )
42
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
40
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
43
41
  expect(msg.type).to eq(:statistics_request)
44
42
  expect(msg.len).to eq(12)
45
43
  expect(msg.xid).to eq(1)
@@ -51,7 +49,7 @@ describe OFStatisticsRequest do
51
49
 
52
50
  context 'with flow' do
53
51
  it 'should read binary' do
54
- msg = OFStatisticsRequest.read [
52
+ msg = OpenFlow::Protocol::StatisticsRequest.read [
55
53
  1, 16, 0, 56, 0, 0, 0, 1, # header
56
54
  0, 1, # statistic_type
57
55
  0, 0, # flags
@@ -78,7 +76,7 @@ describe OFStatisticsRequest do
78
76
  0, # padding
79
77
  0, 1 # out_port
80
78
  ].pack('C*')
81
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
79
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
82
80
  expect(msg.type).to eq(:statistics_request)
83
81
  expect(msg.len).to eq(56)
84
82
  expect(msg.xid).to eq(1)
@@ -87,8 +85,8 @@ describe OFStatisticsRequest do
87
85
  expect(msg.statistics.table_id).to eq(1)
88
86
  end
89
87
  it 'should initialize with default values' do
90
- msg = OFStatisticsRequest.new(statistic_type: :flow)
91
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
88
+ msg = OpenFlow::Protocol::StatisticsRequest.new(statistic_type: :flow)
89
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
92
90
  expect(msg.type).to eq(:statistics_request)
93
91
  expect(msg.len).to eq(56)
94
92
  expect(msg.xid).to eq(0)
@@ -97,14 +95,14 @@ describe OFStatisticsRequest do
97
95
  expect(msg.statistics.table_id).to eq(:all)
98
96
  end
99
97
  it 'should initialize with some values' do
100
- msg = OFStatisticsRequest.new(
98
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
101
99
  xid: 1,
102
100
  statistic_type: :flow,
103
101
  statistics: {
104
102
  table_id: 1
105
103
  }
106
104
  )
107
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
105
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
108
106
  expect(msg.type).to eq(:statistics_request)
109
107
  expect(msg.len).to eq(56)
110
108
  expect(msg.xid).to eq(1)
@@ -116,7 +114,7 @@ describe OFStatisticsRequest do
116
114
 
117
115
  context 'with aggregate' do
118
116
  it 'should read binary' do
119
- msg = OFStatisticsRequest.read [
117
+ msg = OpenFlow::Protocol::StatisticsRequest.read [
120
118
  1, 16, 0, 56, 0, 0, 0, 1, # header
121
119
  0, 2, # statistic_type
122
120
  0, 0, # flags
@@ -143,7 +141,7 @@ describe OFStatisticsRequest do
143
141
  0, # padding
144
142
  0, 1 # out_port
145
143
  ].pack('C*')
146
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
144
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
147
145
  expect(msg.type).to eq(:statistics_request)
148
146
  expect(msg.len).to eq(56)
149
147
  expect(msg.xid).to eq(1)
@@ -152,8 +150,8 @@ describe OFStatisticsRequest do
152
150
  expect(msg.statistics.table_id).to eq(1)
153
151
  end
154
152
  it 'should initialize with default values' do
155
- msg = OFStatisticsRequest.new(statistic_type: :aggregate)
156
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
153
+ msg = OpenFlow::Protocol::StatisticsRequest.new(statistic_type: :aggregate)
154
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
157
155
  expect(msg.type).to eq(:statistics_request)
158
156
  expect(msg.len).to eq(56)
159
157
  expect(msg.xid).to eq(0)
@@ -162,14 +160,14 @@ describe OFStatisticsRequest do
162
160
  expect(msg.statistics.table_id).to eq(:all)
163
161
  end
164
162
  it 'should initialize with some values' do
165
- msg = OFStatisticsRequest.new(
163
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
166
164
  xid: 1,
167
165
  statistic_type: :aggregate,
168
166
  statistics: {
169
167
  table_id: 1
170
168
  }
171
169
  )
172
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
170
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
173
171
  expect(msg.type).to eq(:statistics_request)
174
172
  expect(msg.len).to eq(56)
175
173
  expect(msg.xid).to eq(1)
@@ -181,12 +179,12 @@ describe OFStatisticsRequest do
181
179
 
182
180
  context 'with table' do
183
181
  it 'should read binary' do
184
- msg = OFStatisticsRequest.read [
182
+ msg = OpenFlow::Protocol::StatisticsRequest.read [
185
183
  1, 16, 0, 12, 0, 0, 0, 1, # header
186
184
  0, 3, # statistic_type
187
185
  0, 0, # flags
188
186
  ].pack('C*')
189
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
187
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
190
188
  expect(msg.type).to eq(:statistics_request)
191
189
  expect(msg.len).to eq(12)
192
190
  expect(msg.xid).to eq(1)
@@ -195,8 +193,8 @@ describe OFStatisticsRequest do
195
193
  expect(msg.statistics).to be_empty
196
194
  end
197
195
  it 'should initialize with default values' do
198
- msg = OFStatisticsRequest.new(statistic_type: :table)
199
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
196
+ msg = OpenFlow::Protocol::StatisticsRequest.new(statistic_type: :table)
197
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
200
198
  expect(msg.type).to eq(:statistics_request)
201
199
  expect(msg.len).to eq(12)
202
200
  expect(msg.xid).to eq(0)
@@ -205,11 +203,11 @@ describe OFStatisticsRequest do
205
203
  expect(msg.statistics).to be_empty
206
204
  end
207
205
  it 'should initialize with some values' do
208
- msg = OFStatisticsRequest.new(
206
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
209
207
  xid: 1,
210
208
  statistic_type: :table
211
209
  )
212
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
210
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
213
211
  expect(msg.type).to eq(:statistics_request)
214
212
  expect(msg.len).to eq(12)
215
213
  expect(msg.xid).to eq(1)
@@ -221,7 +219,7 @@ describe OFStatisticsRequest do
221
219
 
222
220
  context 'with port' do
223
221
  it 'should read binary' do
224
- msg = OFStatisticsRequest.read [
222
+ msg = OpenFlow::Protocol::StatisticsRequest.read [
225
223
  1, 16, 0, 20, 0, 0, 0, 1, # header
226
224
  0, 4, # statistic_type
227
225
  0, 0, # flags
@@ -230,7 +228,7 @@ describe OFStatisticsRequest do
230
228
  0, 1, # port_number
231
229
  0, 0, 0, 0, 0, 0 # padding
232
230
  ].pack('C*')
233
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
231
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
234
232
  expect(msg.type).to eq(:statistics_request)
235
233
  expect(msg.len).to eq(20)
236
234
  expect(msg.xid).to eq(1)
@@ -239,8 +237,8 @@ describe OFStatisticsRequest do
239
237
  expect(msg.statistics.port_number).to eq(1)
240
238
  end
241
239
  it 'should initialize with default values' do
242
- msg = OFStatisticsRequest.new(statistic_type: :port)
243
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
240
+ msg = OpenFlow::Protocol::StatisticsRequest.new(statistic_type: :port)
241
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
244
242
  expect(msg.type).to eq(:statistics_request)
245
243
  expect(msg.len).to eq(20)
246
244
  expect(msg.xid).to eq(0)
@@ -249,12 +247,12 @@ describe OFStatisticsRequest do
249
247
  expect(msg.statistics.port_number).to eq(:none)
250
248
  end
251
249
  it 'should initialize with some values' do
252
- msg = OFStatisticsRequest.new(
250
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
253
251
  xid: 1,
254
252
  statistic_type: :port,
255
253
  statistics: {port_number: 1}
256
254
  )
257
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
255
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
258
256
  expect(msg.type).to eq(:statistics_request)
259
257
  expect(msg.len).to eq(20)
260
258
  expect(msg.xid).to eq(1)
@@ -266,7 +264,7 @@ describe OFStatisticsRequest do
266
264
 
267
265
  context 'with queue' do
268
266
  it 'should read binary' do
269
- msg = OFStatisticsRequest.read [
267
+ msg = OpenFlow::Protocol::StatisticsRequest.read [
270
268
  1, 16, 0, 20, 0, 0, 0, 1, # header
271
269
  0, 5, # statistic_type
272
270
  0, 0, # flags
@@ -276,7 +274,7 @@ describe OFStatisticsRequest do
276
274
  0, 0, # padding
277
275
  0, 0, 0, 1 # queue_id
278
276
  ].pack('C*')
279
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
277
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
280
278
  expect(msg.type).to eq(:statistics_request)
281
279
  expect(msg.len).to eq(20)
282
280
  expect(msg.xid).to eq(1)
@@ -285,8 +283,8 @@ describe OFStatisticsRequest do
285
283
  expect(msg.statistics.port_number).to eq(1)
286
284
  end
287
285
  it 'should initialize with default values' do
288
- msg = OFStatisticsRequest.new(statistic_type: :queue)
289
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
286
+ msg = OpenFlow::Protocol::StatisticsRequest.new(statistic_type: :queue)
287
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
290
288
  expect(msg.type).to eq(:statistics_request)
291
289
  expect(msg.len).to eq(20)
292
290
  expect(msg.xid).to eq(0)
@@ -295,12 +293,12 @@ describe OFStatisticsRequest do
295
293
  expect(msg.statistics.port_number).to eq(:all)
296
294
  end
297
295
  it 'should initialize with some values' do
298
- msg = OFStatisticsRequest.new(
296
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
299
297
  xid: 1,
300
298
  statistic_type: :queue,
301
299
  statistics: {port_number: 1}
302
300
  )
303
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
301
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
304
302
  expect(msg.type).to eq(:statistics_request)
305
303
  expect(msg.len).to eq(20)
306
304
  expect(msg.xid).to eq(1)
@@ -312,7 +310,7 @@ describe OFStatisticsRequest do
312
310
 
313
311
  context 'with vendor' do
314
312
  it 'should read binary' do
315
- msg = OFStatisticsRequest.read [
313
+ msg = OpenFlow::Protocol::StatisticsRequest.read [
316
314
  1, 16, 0, 20, 0, 0, 0, 1, # header
317
315
  0xff, 0xff, # statistic_type
318
316
  0, 0, # flags
@@ -321,7 +319,7 @@ describe OFStatisticsRequest do
321
319
  0, 0, 0, 1, # vendor
322
320
  1, 2, 3, 4 # body
323
321
  ].pack('C*')
324
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
322
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
325
323
  expect(msg.type).to eq(:statistics_request)
326
324
  expect(msg.len).to eq(20)
327
325
  expect(msg.xid).to eq(1)
@@ -331,8 +329,8 @@ describe OFStatisticsRequest do
331
329
  expect(msg.statistics.body).to eq([1, 2, 3, 4].pack('C*'))
332
330
  end
333
331
  it 'should initialize with default values' do
334
- msg = OFStatisticsRequest.new(statistic_type: :vendor)
335
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
332
+ msg = OpenFlow::Protocol::StatisticsRequest.new(statistic_type: :vendor)
333
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
336
334
  expect(msg.type).to eq(:statistics_request)
337
335
  expect(msg.len).to eq(16)
338
336
  expect(msg.xid).to eq(0)
@@ -342,7 +340,7 @@ describe OFStatisticsRequest do
342
340
  expect(msg.statistics.body).to be_empty
343
341
  end
344
342
  it 'should initialize with some values' do
345
- msg = OFStatisticsRequest.new(
343
+ msg = OpenFlow::Protocol::StatisticsRequest.new(
346
344
  xid: 1,
347
345
  statistic_type: :vendor,
348
346
  statistics: {
@@ -350,7 +348,7 @@ describe OFStatisticsRequest do
350
348
  body: [1, 2, 3, 4].pack('C*')
351
349
  }
352
350
  )
353
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
351
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
354
352
  expect(msg.type).to eq(:statistics_request)
355
353
  expect(msg.len).to eq(20)
356
354
  expect(msg.xid).to eq(1)
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe OFVendor do
1
+ describe OpenFlow::Protocol::Vendor do
4
2
  let(:data) {
5
3
  [
6
4
  1, 4, 0, 12, 0, 0, 0, 1, # header
@@ -9,8 +7,8 @@ describe OFVendor do
9
7
  }
10
8
 
11
9
  it 'should read binary' do
12
- msg = OFVendor.read(data)
13
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
10
+ msg = OpenFlow::Protocol::Vendor.read(data)
11
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
14
12
  expect(msg.type).to eq(:vendor)
15
13
  expect(msg.len).to eq(12)
16
14
  expect(msg.xid).to eq(1)
@@ -18,16 +16,16 @@ describe OFVendor do
18
16
  expect(msg.data).to be_empty
19
17
  end
20
18
  it 'should be parsable' do
21
- msg = OFParser.read(data)
22
- expect(msg.class).to eq(OFVendor)
19
+ msg = OpenFlow::Protocol::Parser.read(data)
20
+ expect(msg.class).to eq(OpenFlow::Protocol::Vendor)
23
21
  end
24
22
  it 'should read binary with data' do
25
- msg = OFVendor.read [
23
+ msg = OpenFlow::Protocol::Vendor.read [
26
24
  1, 4, 0, 14, 0, 0, 0, 1, # header
27
25
  0, 0, 0, 1, # vendor
28
26
  10, 20 # data
29
27
  ].pack('C*')
30
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
28
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
31
29
  expect(msg.type).to eq(:vendor)
32
30
  expect(msg.len).to eq(14)
33
31
  expect(msg.xid).to eq(1)
@@ -35,8 +33,8 @@ describe OFVendor do
35
33
  expect(msg.data.length).to eq(2)
36
34
  end
37
35
  it 'should initialize with default values' do
38
- msg = OFVendor.new
39
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
36
+ msg = OpenFlow::Protocol::Vendor.new
37
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
40
38
  expect(msg.type).to eq(:vendor)
41
39
  expect(msg.len).to eq(12)
42
40
  expect(msg.xid).to eq(0)
@@ -44,8 +42,8 @@ describe OFVendor do
44
42
  expect(msg.data).to be_empty
45
43
  end
46
44
  it 'should initialize with some values' do
47
- msg = OFVendor.new(xid: 1, vendor: 1)
48
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
45
+ msg = OpenFlow::Protocol::Vendor.new(xid: 1, vendor: 1)
46
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
49
47
  expect(msg.type).to eq(:vendor)
50
48
  expect(msg.len).to eq(12)
51
49
  expect(msg.xid).to eq(1)
@@ -53,8 +51,8 @@ describe OFVendor do
53
51
  expect(msg.data).to be_empty
54
52
  end
55
53
  it 'should initialize with data' do
56
- msg = OFVendor.new(vendor: 1, data: [10, 20].pack('C*'))
57
- expect(msg.version).to eq(OFMessage::OFP_VERSION)
54
+ msg = OpenFlow::Protocol::Vendor.new(vendor: 1, data: [10, 20].pack('C*'))
55
+ expect(msg.version).to eq(OpenFlow::Protocol::Message::OFP_VERSION)
58
56
  expect(msg.type).to eq(:vendor)
59
57
  expect(msg.len).to eq(14)
60
58
  expect(msg.xid).to eq(0)
@@ -1,4 +1,4 @@
1
- require_relative '../lib/openflow-protocol'
1
+ require 'openflow-protocol'
2
2
 
3
3
  class String
4
4
  def pad(length, value = [0].pack('C*'))
@@ -1,8 +1,6 @@
1
- require 'spec_helper'
2
-
3
- describe OFMatch do
1
+ describe OpenFlow::Protocol::Match do
4
2
  it 'should read binary' do
5
- match = OFMatch.read [
3
+ match = OpenFlow::Protocol::Match.read [
6
4
  0, 0x30, 0x20, 0x4f, # wildcards
7
5
  0, 0, # in_port
8
6
  0, 0, 0, 0, 0, 0, # mac_source
@@ -43,8 +41,8 @@ describe OFMatch do
43
41
  expect(match.destination_port).to eq(3000)
44
42
  end
45
43
  it 'should initialize with default values' do
46
- match = OFMatch.new
47
- expect(match.wildcards).to eq(OFMatch::Wildcards::ALL_FLAGS)
44
+ match = OpenFlow::Protocol::Match.new
45
+ expect(match.wildcards).to eq(OpenFlow::Protocol::Match::Wildcards::ALL_FLAGS)
48
46
  expect(match.in_port).to eq(0)
49
47
  expect(match.mac_source).to eq('00:00:00:00:00:00')
50
48
  expect(match.mac_destination).to eq('00:00:00:00:00:00')
@@ -59,7 +57,7 @@ describe OFMatch do
59
57
  expect(match.destination_port).to eq(0)
60
58
  end
61
59
  it 'should initialize with some values' do
62
- match = OFMatch.new(
60
+ match = OpenFlow::Protocol::Match.new(
63
61
  wildcards: {
64
62
  in_port: true,
65
63
  mac_source: true,
@@ -101,7 +99,7 @@ describe OFMatch do
101
99
  expect(match.destination_port).to eq(3000)
102
100
  end
103
101
  it 'should initialize with wildcards as array' do
104
- match = OFMatch.new(
102
+ match = OpenFlow::Protocol::Match.new(
105
103
  wildcards: [:in_port, :mac_source, :mac_destination]
106
104
  )
107
105
  expect(match.wildcards).to eq(
@@ -111,7 +109,7 @@ describe OFMatch do
111
109
  )
112
110
  end
113
111
  it 'should initialize wildcards based on matching values given' do
114
- match = OFMatch.create(
112
+ match = OpenFlow::Protocol::Match.create(
115
113
  mac_source: '00:00:00:00:00:01',
116
114
  mac_destination: '00:00:00:00:00:02',
117
115
  mac_protocol: :ipv4,
@@ -1,8 +1,6 @@
1
- require 'spec_helper'
2
-
3
- describe OFPacketQueue do
1
+ describe OpenFlow::Protocol::PacketQueue do
4
2
  it 'should read binary' do
5
- queue = OFPacketQueue.read [
3
+ queue = OpenFlow::Protocol::PacketQueue.read [
6
4
  0, 0, 0, 1, # queue_id
7
5
  0, 24, # len
8
6
  0, 0, # padding
@@ -19,14 +17,14 @@ describe OFPacketQueue do
19
17
  expect(queue.properties.first.rate).to eq(100)
20
18
  end
21
19
  it 'should initialize with default values' do
22
- queue = OFPacketQueue.new
20
+ queue = OpenFlow::Protocol::PacketQueue.new
23
21
  expect(queue.queue_id).to eq(0)
24
22
  expect(queue.len).to eq(8)
25
23
  end
26
24
  it 'should initialize with some values' do
27
- queue = OFPacketQueue.new(
25
+ queue = OpenFlow::Protocol::PacketQueue.new(
28
26
  queue_id: 1,
29
- properties: [OFQueuePropertyMinRate.new(rate: 100)]
27
+ properties: [OpenFlow::Protocol::QueuePropertyMinRate.new(rate: 100)]
30
28
  )
31
29
  expect(queue.queue_id).to eq(1)
32
30
  expect(queue.len).to eq(24)