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.
- checksums.yaml +4 -4
- data/lib/openflow-protocol.rb +2 -1
- data/lib/openflow-protocol/actions/action.rb +30 -0
- data/lib/openflow-protocol/actions/action_enqueue.rb +16 -0
- data/lib/openflow-protocol/actions/action_output.rb +14 -0
- data/lib/openflow-protocol/actions/action_set_destination_port.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_ip_destination.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_ip_source.rb +13 -0
- data/lib/openflow-protocol/actions/action_set_ip_tos.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_mac_destination.rb +7 -0
- data/lib/openflow-protocol/actions/action_set_mac_source.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_source_port.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_vlan_id.rb +15 -0
- data/lib/openflow-protocol/actions/action_set_vlan_pcp.rb +15 -0
- data/lib/openflow-protocol/actions/action_strip_vlan.rb +14 -0
- data/lib/openflow-protocol/actions/action_vendor.rb +13 -0
- data/lib/openflow-protocol/actions/actions.rb +9 -0
- data/lib/openflow-protocol/helpers/array_of_subclasses.rb +42 -0
- data/lib/openflow-protocol/helpers/superclass_base.rb +26 -0
- data/lib/openflow-protocol/messages/barrier_reply.rb +7 -0
- data/lib/openflow-protocol/messages/barrier_request.rb +7 -0
- data/lib/openflow-protocol/messages/echo_reply.rb +13 -0
- data/lib/openflow-protocol/messages/echo_request.rb +13 -0
- data/lib/openflow-protocol/messages/error.rb +69 -0
- data/lib/openflow-protocol/messages/features_reply.rb +44 -0
- data/lib/openflow-protocol/messages/features_request.rb +7 -0
- data/lib/openflow-protocol/messages/flow_mod.rb +24 -0
- data/lib/openflow-protocol/messages/flow_removed.rb +27 -0
- data/lib/openflow-protocol/messages/get_config_reply.rb +16 -0
- data/lib/openflow-protocol/messages/get_config_request.rb +7 -0
- data/lib/openflow-protocol/messages/hello.rb +7 -0
- data/lib/openflow-protocol/messages/message.rb +49 -0
- data/lib/openflow-protocol/messages/packet_in.rb +27 -0
- data/lib/openflow-protocol/messages/packet_out.rb +17 -0
- data/lib/openflow-protocol/messages/parser.rb +26 -0
- data/lib/openflow-protocol/messages/port_mod.rb +19 -0
- data/lib/openflow-protocol/messages/port_status.rb +18 -0
- data/lib/openflow-protocol/messages/queue_get_config_reply.rb +18 -0
- data/lib/openflow-protocol/messages/queue_get_config_request.rb +15 -0
- data/lib/openflow-protocol/messages/set_config.rb +7 -0
- data/lib/openflow-protocol/messages/statistics.rb +28 -0
- data/lib/openflow-protocol/messages/statistics/aggregate_statistics_reply.rb +14 -0
- data/lib/openflow-protocol/messages/statistics/aggregate_statistics_request.rb +7 -0
- data/lib/openflow-protocol/messages/statistics/description_statistics.rb +32 -0
- data/lib/openflow-protocol/messages/statistics/flow_statistics_reply.rb +25 -0
- data/lib/openflow-protocol/messages/statistics/flow_statistics_request.rb +14 -0
- data/lib/openflow-protocol/messages/statistics/port_statistics_reply.rb +24 -0
- data/lib/openflow-protocol/messages/statistics/port_statistics_request.rb +12 -0
- data/lib/openflow-protocol/messages/statistics/queue_statistics_reply.rb +16 -0
- data/lib/openflow-protocol/messages/statistics/queue_statistics_request.rb +13 -0
- data/lib/openflow-protocol/messages/statistics/table_statistics.rb +20 -0
- data/lib/openflow-protocol/messages/statistics/vendor_statistics.rb +11 -0
- data/lib/openflow-protocol/messages/statistics_reply.rb +26 -0
- data/lib/openflow-protocol/messages/statistics_request.rb +18 -0
- data/lib/openflow-protocol/messages/vendor.rb +14 -0
- data/lib/openflow-protocol/structs/match.rb +106 -0
- data/lib/openflow-protocol/structs/packet_queue.rb +14 -0
- data/lib/openflow-protocol/structs/physical_port.rb +50 -0
- data/lib/openflow-protocol/structs/port_number.rb +49 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_properties.rb +9 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property.rb +20 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property_min_rate.rb +30 -0
- data/lib/openflow-protocol/structs/queue_properties/queue_property_none.rb +7 -0
- data/lib/openflow-protocol/version.rb +1 -1
- data/spec/actions/action_enqueue_spec.rb +4 -6
- data/spec/actions/action_output_spec.rb +4 -6
- data/spec/actions/action_set_destination_port_spec.rb +4 -6
- data/spec/actions/action_set_ip_destination_spec.rb +4 -6
- data/spec/actions/action_set_ip_source_spec.rb +4 -6
- data/spec/actions/action_set_ip_tos_spec.rb +4 -6
- data/spec/actions/action_set_mac_destination_spec.rb +4 -6
- data/spec/actions/action_set_mac_source_spec.rb +4 -6
- data/spec/actions/action_set_source_port_spec.rb +4 -6
- data/spec/actions/action_set_vlan_id_spec.rb +4 -6
- data/spec/actions/action_set_vlan_pcp_spec.rb +4 -6
- data/spec/actions/action_strip_vlan_spec.rb +3 -5
- data/spec/actions/action_vendor_spec.rb +4 -6
- data/spec/actions/actions_spec.rb +6 -8
- data/spec/messages/barrier_reply_spec.rb +9 -11
- data/spec/messages/barrier_request_spec.rb +9 -11
- data/spec/messages/echo_reply_spec.rb +13 -15
- data/spec/messages/echo_request_spec.rb +16 -18
- data/spec/messages/error_spec.rb +23 -20
- data/spec/messages/features_reply_spec.rb +11 -13
- data/spec/messages/features_request_spec.rb +9 -11
- data/spec/messages/flow_mod_spec.rb +12 -14
- data/spec/messages/flow_removed_spec.rb +9 -11
- data/spec/messages/get_config_reply_spec.rb +9 -11
- data/spec/messages/get_config_request_spec.rb +9 -11
- data/spec/messages/hello_spec.rb +9 -11
- data/spec/messages/packet_in_spec.rb +9 -11
- data/spec/messages/packet_out_spec.rb +10 -12
- data/spec/messages/parser_spec.rb +7 -9
- data/spec/messages/port_mod_spec.rb +9 -11
- data/spec/messages/port_status_spec.rb +10 -12
- data/spec/messages/queue_get_config_reply_spec.rb +9 -11
- data/spec/messages/queue_get_config_request_spec.rb +9 -11
- data/spec/messages/set_config_spec.rb +9 -11
- data/spec/messages/statistics/aggregate_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/aggregate_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/description_statistics_spec.rb +11 -9
- data/spec/messages/statistics/flow_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/flow_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/port_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/port_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/queue_statistics_reply_spec.rb +4 -6
- data/spec/messages/statistics/queue_statistics_request_spec.rb +4 -6
- data/spec/messages/statistics/table_statistics_spec.rb +4 -6
- data/spec/messages/statistics/vendor_statistics_spec.rb +4 -6
- data/spec/messages/statistics_reply_spec.rb +62 -64
- data/spec/messages/statistics_request_spec.rb +45 -47
- data/spec/messages/vendor_spec.rb +13 -15
- data/spec/spec_helper.rb +1 -1
- data/spec/structs/match_spec.rb +7 -9
- data/spec/structs/packet_queue_spec.rb +5 -7
- data/spec/structs/physical_port_spec.rb +16 -18
- data/spec/structs/port_number_spec.rb +11 -13
- data/spec/structs/queue_properties/queue_properties_spec.rb +5 -7
- data/spec/structs/queue_properties/queue_property_min_rate_spec.rb +5 -7
- data/spec/structs/queue_properties/queue_property_none_spec.rb +3 -5
- metadata +78 -64
- data/lib/actions/action.rb +0 -26
- data/lib/actions/action_enqueue.rb +0 -12
- data/lib/actions/action_output.rb +0 -10
- data/lib/actions/action_set_destination_port.rb +0 -3
- data/lib/actions/action_set_ip_destination.rb +0 -3
- data/lib/actions/action_set_ip_source.rb +0 -9
- data/lib/actions/action_set_ip_tos.rb +0 -11
- data/lib/actions/action_set_mac_destination.rb +0 -3
- data/lib/actions/action_set_mac_source.rb +0 -11
- data/lib/actions/action_set_source_port.rb +0 -11
- data/lib/actions/action_set_vlan_id.rb +0 -11
- data/lib/actions/action_set_vlan_pcp.rb +0 -11
- data/lib/actions/action_strip_vlan.rb +0 -10
- data/lib/actions/action_vendor.rb +0 -9
- data/lib/actions/actions.rb +0 -5
- data/lib/helpers/array_of_subclasses.rb +0 -38
- data/lib/helpers/superclass_base.rb +0 -24
- data/lib/messages/barrier_reply.rb +0 -3
- data/lib/messages/barrier_request.rb +0 -3
- data/lib/messages/echo_reply.rb +0 -9
- data/lib/messages/echo_request.rb +0 -9
- data/lib/messages/error.rb +0 -61
- data/lib/messages/features_reply.rb +0 -40
- data/lib/messages/features_request.rb +0 -3
- data/lib/messages/flow_mod.rb +0 -20
- data/lib/messages/flow_removed.rb +0 -23
- data/lib/messages/get_config_reply.rb +0 -12
- data/lib/messages/get_config_request.rb +0 -3
- data/lib/messages/hello.rb +0 -3
- data/lib/messages/message.rb +0 -45
- data/lib/messages/packet_in.rb +0 -23
- data/lib/messages/packet_out.rb +0 -13
- data/lib/messages/parser.rb +0 -22
- data/lib/messages/port_mod.rb +0 -15
- data/lib/messages/port_status.rb +0 -14
- data/lib/messages/queue_get_config_reply.rb +0 -14
- data/lib/messages/queue_get_config_request.rb +0 -11
- data/lib/messages/set_config.rb +0 -3
- data/lib/messages/statistics.rb +0 -24
- data/lib/messages/statistics/aggregate_statistics_reply.rb +0 -10
- data/lib/messages/statistics/aggregate_statistics_request.rb +0 -3
- data/lib/messages/statistics/description_statistics.rb +0 -28
- data/lib/messages/statistics/flow_statistics_reply.rb +0 -21
- data/lib/messages/statistics/flow_statistics_request.rb +0 -10
- data/lib/messages/statistics/port_statistics_reply.rb +0 -20
- data/lib/messages/statistics/port_statistics_request.rb +0 -8
- data/lib/messages/statistics/queue_statistics_reply.rb +0 -12
- data/lib/messages/statistics/queue_statistics_request.rb +0 -9
- data/lib/messages/statistics/table_statistics.rb +0 -16
- data/lib/messages/statistics/vendor_statistics.rb +0 -7
- data/lib/messages/statistics_reply.rb +0 -22
- data/lib/messages/statistics_request.rb +0 -14
- data/lib/messages/vendor.rb +0 -10
- data/lib/structs/match.rb +0 -102
- data/lib/structs/packet_queue.rb +0 -10
- data/lib/structs/physical_port.rb +0 -46
- data/lib/structs/port_number.rb +0 -45
- data/lib/structs/queue_properties/queue_properties.rb +0 -5
- data/lib/structs/queue_properties/queue_property.rb +0 -16
- data/lib/structs/queue_properties/queue_property_min_rate.rb +0 -26
- data/lib/structs/queue_properties/queue_property_none.rb +0 -3
@@ -1,6 +1,4 @@
|
|
1
|
-
|
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 =
|
15
|
-
expect(msg.version).to eq(
|
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 =
|
25
|
-
expect(msg.class).to eq(
|
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 =
|
29
|
-
expect(msg.version).to eq(
|
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 =
|
36
|
+
msg = OpenFlow::Protocol::StatisticsRequest.new(
|
39
37
|
xid: 1,
|
40
38
|
statistic_type: :description
|
41
39
|
)
|
42
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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 =
|
91
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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 =
|
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(
|
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 =
|
156
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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 =
|
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(
|
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 =
|
199
|
-
expect(msg.version).to eq(
|
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 =
|
206
|
+
msg = OpenFlow::Protocol::StatisticsRequest.new(
|
209
207
|
xid: 1,
|
210
208
|
statistic_type: :table
|
211
209
|
)
|
212
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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 =
|
243
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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 =
|
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(
|
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 =
|
289
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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 =
|
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(
|
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 =
|
335
|
-
expect(msg.version).to eq(
|
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 =
|
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(
|
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
|
-
|
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 =
|
13
|
-
expect(msg.version).to eq(
|
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 =
|
22
|
-
expect(msg.class).to eq(
|
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 =
|
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(
|
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 =
|
39
|
-
expect(msg.version).to eq(
|
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 =
|
48
|
-
expect(msg.version).to eq(
|
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 =
|
57
|
-
expect(msg.version).to eq(
|
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)
|
data/spec/spec_helper.rb
CHANGED
data/spec/structs/match_spec.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe OFMatch do
|
1
|
+
describe OpenFlow::Protocol::Match do
|
4
2
|
it 'should read binary' do
|
5
|
-
match =
|
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 =
|
47
|
-
expect(match.wildcards).to eq(
|
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 =
|
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 =
|
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 =
|
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
|
-
|
2
|
-
|
3
|
-
describe OFPacketQueue do
|
1
|
+
describe OpenFlow::Protocol::PacketQueue do
|
4
2
|
it 'should read binary' do
|
5
|
-
queue =
|
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 =
|
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 =
|
25
|
+
queue = OpenFlow::Protocol::PacketQueue.new(
|
28
26
|
queue_id: 1,
|
29
|
-
properties: [
|
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)
|