pio 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +33 -2
- data/examples/echo_read.rb +1 -1
- data/examples/features_read.rb +1 -1
- data/examples/flow_mod_new.rb +13 -0
- data/examples/flow_mod_read.rb +6 -0
- data/features/echo_read.feature +27 -3
- data/features/features_read.feature +46 -2
- data/features/flow_mod_read.feature +186 -0
- data/features/hello_read.feature +9 -0
- data/features/packet_data/flow_mod_add.raw +0 -0
- data/features/packet_data/flow_mod_delete.raw +0 -0
- data/features/packet_data/flow_mod_delete_strict.raw +0 -0
- data/features/packet_data/flow_mod_modify.raw +0 -0
- data/features/packet_data/flow_mod_modify_strict.raw +0 -0
- data/features/packet_in_read.feature +13 -0
- data/features/packet_out_read.feature +16 -0
- data/features/step_definitions/packet_data_steps.rb +10 -1
- data/lib/pio.rb +1 -0
- data/lib/pio/echo.rb +10 -8
- data/lib/pio/enqueue.rb +1 -1
- data/lib/pio/features.rb +64 -7
- data/lib/pio/flow_mod.rb +86 -0
- data/lib/pio/hello.rb +4 -74
- data/lib/pio/ipv4_address.rb +1 -1
- data/lib/pio/match.rb +167 -0
- data/lib/pio/open_flow.rb +1 -0
- data/lib/pio/open_flow/actions.rb +65 -0
- data/lib/pio/open_flow/flags.rb +12 -9
- data/lib/pio/open_flow/message.rb +105 -21
- data/lib/pio/open_flow/phy_port.rb +31 -27
- data/lib/pio/open_flow/type.rb +1 -0
- data/lib/pio/packet_in.rb +2 -12
- data/lib/pio/packet_out.rb +4 -74
- data/lib/pio/send_out_port.rb +1 -0
- data/lib/pio/type/ip_address.rb +2 -7
- data/lib/pio/version.rb +1 -1
- data/pio.gemspec +8 -8
- data/spec/pio/echo/reply_spec.rb +61 -6
- data/spec/pio/echo/request_spec.rb +61 -6
- data/spec/pio/features/reply_spec.rb +81 -4
- data/spec/pio/features/request_spec.rb +88 -41
- data/spec/pio/flow_mod_spec.rb +151 -0
- data/spec/pio/hello_spec.rb +73 -56
- data/spec/pio/match_spec.rb +194 -0
- data/spec/pio/packet_in_spec.rb +35 -38
- data/spec/pio/packet_out_spec.rb +243 -182
- data/spec/pio/wildcards_spec.rb +115 -0
- metadata +37 -30
- data/features/packet_data/echo.raw +0 -0
- data/lib/pio/echo/message.rb +0 -49
- data/lib/pio/echo/reply.rb +0 -41
- data/lib/pio/echo/request.rb +0 -43
- data/lib/pio/features/reply.rb +0 -88
- data/lib/pio/features/request.rb +0 -68
- data/lib/pio/open_flow/parser.rb +0 -22
- data/spec/pio/echo_spec.rb +0 -49
- data/spec/pio/features_spec.rb +0 -96
data/spec/pio/packet_in_spec.rb
CHANGED
@@ -13,6 +13,8 @@ describe Pio::PacketIn do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '.read' do
|
16
|
+
When(:result) { Pio::PacketIn.read(binary) }
|
17
|
+
|
16
18
|
context 'with a packet_in message' do
|
17
19
|
Given(:header_dump) do
|
18
20
|
[
|
@@ -31,28 +33,25 @@ describe Pio::PacketIn do
|
|
31
33
|
0x00
|
32
34
|
].pack('C*') + data_dump
|
33
35
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
Then {
|
40
|
-
Then {
|
41
|
-
Then {
|
42
|
-
|
43
|
-
Then {
|
44
|
-
Then {
|
45
|
-
|
46
|
-
Then {
|
47
|
-
Then {
|
48
|
-
Then {
|
49
|
-
Then { packet_in.in_port == 1 }
|
50
|
-
Then { packet_in.reason == :no_match }
|
51
|
-
Then { packet_in.data == data_dump }
|
36
|
+
Given(:binary) { header_dump + body_dump }
|
37
|
+
|
38
|
+
Then { result.class == Pio::PacketIn }
|
39
|
+
Then { result.ofp_version == 0x1 }
|
40
|
+
Then { result.message_type == 0xa }
|
41
|
+
Then { result.message_length == 0x4e }
|
42
|
+
Then { result.transaction_id == 0 }
|
43
|
+
Then { result.xid == 0 }
|
44
|
+
|
45
|
+
Then { !result.body.empty? }
|
46
|
+
Then { result.buffer_id == 0xffffff00 }
|
47
|
+
Then { result.total_len == 0x3c }
|
48
|
+
Then { result.in_port == 1 }
|
49
|
+
Then { result.reason == :no_match }
|
50
|
+
Then { result.data == data_dump }
|
52
51
|
end
|
53
52
|
|
54
|
-
context 'with a
|
55
|
-
Given(:
|
53
|
+
context 'with a Packet-In message generated with PacketIn.new' do
|
54
|
+
Given(:binary) do
|
56
55
|
Pio::PacketIn.new(
|
57
56
|
transaction_id: 0,
|
58
57
|
buffer_id: 0xffffff00,
|
@@ -61,30 +60,28 @@ describe Pio::PacketIn do
|
|
61
60
|
data: data_dump
|
62
61
|
).to_binary
|
63
62
|
end
|
64
|
-
When(:packet_in) { Pio::PacketIn.read(packet_in_dump) }
|
65
|
-
|
66
|
-
Then { packet_in.class == Pio::PacketIn }
|
67
|
-
Then { packet_in.ofp_version == 0x1 }
|
68
|
-
Then { packet_in.message_type == 0xa }
|
69
|
-
Then { packet_in.message_length == 0x4e }
|
70
|
-
Then { packet_in.transaction_id == 0 }
|
71
|
-
Then { packet_in.xid == 0 }
|
72
63
|
|
73
|
-
Then {
|
74
|
-
Then {
|
75
|
-
Then {
|
76
|
-
Then {
|
77
|
-
Then {
|
78
|
-
Then {
|
64
|
+
Then { result.class == Pio::PacketIn }
|
65
|
+
Then { result.ofp_version == 0x1 }
|
66
|
+
Then { result.message_type == 0xa }
|
67
|
+
Then { result.message_length == 0x4e }
|
68
|
+
Then { result.transaction_id == 0 }
|
69
|
+
Then { result.xid == 0 }
|
70
|
+
|
71
|
+
Then { !result.body.empty? }
|
72
|
+
Then { result.buffer_id == 0xffffff00 }
|
73
|
+
Then { result.total_len == 0x3c }
|
74
|
+
Then { result.in_port == 1 }
|
75
|
+
Then { result.reason == :no_match }
|
76
|
+
Then { result.data == data_dump }
|
79
77
|
end
|
80
78
|
|
81
79
|
context 'with a Hello message' do
|
82
|
-
Given(:
|
83
|
-
|
84
|
-
When(:result) { Pio::PacketIn.read(hello_dump) }
|
80
|
+
Given(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
|
85
81
|
|
86
82
|
Then do
|
87
|
-
result == Failure(Pio::ParseError,
|
83
|
+
result == Failure(Pio::ParseError,
|
84
|
+
'Invalid PacketIn message.')
|
88
85
|
end
|
89
86
|
end
|
90
87
|
end
|
data/spec/pio/packet_out_spec.rb
CHANGED
@@ -9,7 +9,6 @@ describe Pio::PacketOut do
|
|
9
9
|
0x00, 0x00, 0x00, 0x16
|
10
10
|
].pack('C*')
|
11
11
|
end
|
12
|
-
|
13
12
|
Given(:data_dump) do
|
14
13
|
[
|
15
14
|
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, 0x01, 0x02, 0x03, 0x04,
|
@@ -21,7 +20,6 @@ describe Pio::PacketOut do
|
|
21
20
|
0x00, 0x00, 0x00, 0x00
|
22
21
|
].pack('C*')
|
23
22
|
end
|
24
|
-
|
25
23
|
Given(:body_dump) do
|
26
24
|
[
|
27
25
|
0xff, 0xff, 0xff, 0xff,
|
@@ -31,260 +29,323 @@ describe Pio::PacketOut do
|
|
31
29
|
].pack('C*') + data_dump
|
32
30
|
end
|
33
31
|
|
34
|
-
Given(:packet_out_dump) { header_dump + body_dump }
|
35
|
-
|
36
32
|
describe '.read' do
|
33
|
+
When(:result) { Pio::PacketOut.read(binary) }
|
34
|
+
|
37
35
|
context 'with a Packet-Out message' do
|
38
|
-
When(:
|
39
|
-
|
36
|
+
When(:binary) { header_dump + body_dump }
|
37
|
+
|
38
|
+
Then { result.class == Pio::PacketOut }
|
39
|
+
Then { result.ofp_version == 0x1 }
|
40
|
+
Then { result.message_type == 0xd }
|
41
|
+
Then { result.message_length == 0x58 }
|
42
|
+
Then { result.transaction_id == 0x16 }
|
43
|
+
Then { result.xid == 0x16 }
|
44
|
+
|
45
|
+
Then { !result.body.empty? }
|
46
|
+
Then { result.buffer_id == 0xffffffff }
|
47
|
+
Then { result.in_port == 0xffff }
|
48
|
+
Then { result.actions_len == 0x8 }
|
49
|
+
Then { result.actions.length == 1 }
|
50
|
+
Then { result.actions[0].is_a? Pio::SendOutPort }
|
51
|
+
Then { result.actions[0].port_number == 2 }
|
52
|
+
Then { result.actions[0].max_len == 2**16 - 1 }
|
53
|
+
Then { result.data.length == 64 }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with a Packet-Out message generated with PacketOut.new' do
|
57
|
+
When(:binary) do
|
58
|
+
Pio::PacketOut.new(
|
59
|
+
transaction_id: 0x16,
|
60
|
+
buffer_id: 0xffffffff,
|
61
|
+
in_port: 0xffff,
|
62
|
+
actions: Pio::SendOutPort.new(2),
|
63
|
+
data: data_dump
|
64
|
+
).to_binary
|
40
65
|
end
|
41
66
|
|
42
|
-
Then {
|
43
|
-
Then {
|
44
|
-
Then {
|
45
|
-
Then {
|
46
|
-
Then {
|
47
|
-
Then {
|
48
|
-
|
49
|
-
Then { !
|
50
|
-
Then {
|
51
|
-
Then {
|
52
|
-
Then {
|
53
|
-
Then {
|
54
|
-
Then {
|
55
|
-
Then {
|
56
|
-
Then {
|
57
|
-
Then {
|
67
|
+
Then { result.class == Pio::PacketOut }
|
68
|
+
Then { result.ofp_version == 0x1 }
|
69
|
+
Then { result.message_type == 0xd }
|
70
|
+
Then { result.message_length == 0x58 }
|
71
|
+
Then { result.transaction_id == 0x16 }
|
72
|
+
Then { result.xid == 0x16 }
|
73
|
+
|
74
|
+
Then { !result.body.empty? }
|
75
|
+
Then { result.buffer_id == 0xffffffff }
|
76
|
+
Then { result.in_port == 0xffff }
|
77
|
+
Then { result.actions_len == 0x8 }
|
78
|
+
Then { result.actions.length == 1 }
|
79
|
+
Then { result.actions[0].is_a? Pio::SendOutPort }
|
80
|
+
Then { result.actions[0].port_number == 2 }
|
81
|
+
Then { result.actions[0].max_len == 2**16 - 1 }
|
82
|
+
Then { result.data.length == 64 }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'with a Hello message' do
|
86
|
+
When(:binary) { [1, 0, 0, 8, 0, 0, 0, 0].pack('C*') }
|
87
|
+
|
88
|
+
Then do
|
89
|
+
result == Failure(Pio::ParseError,
|
90
|
+
'Invalid PacketOut message.')
|
91
|
+
end
|
58
92
|
end
|
59
93
|
end
|
60
94
|
|
61
95
|
describe '.new' do
|
96
|
+
When(:result) { Pio::PacketOut.new(user_options) }
|
97
|
+
|
62
98
|
context 'with a SendOutPort action' do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
99
|
+
When(:user_options) do
|
100
|
+
{
|
101
|
+
transaction_id: 0x16,
|
102
|
+
buffer_id: 0xffffffff,
|
103
|
+
in_port: 0xffff,
|
104
|
+
actions: Pio::SendOutPort.new(2),
|
105
|
+
data: data_dump
|
106
|
+
}
|
69
107
|
end
|
70
108
|
|
71
|
-
Then {
|
72
|
-
Then {
|
73
|
-
Then {
|
74
|
-
Then {
|
75
|
-
Then {
|
76
|
-
|
77
|
-
Then { !
|
78
|
-
Then {
|
79
|
-
Then {
|
80
|
-
Then {
|
81
|
-
Then {
|
82
|
-
Then {
|
83
|
-
Then {
|
84
|
-
Then {
|
85
|
-
Then {
|
109
|
+
Then { result.ofp_version == 0x1 }
|
110
|
+
Then { result.message_type == 0xd }
|
111
|
+
Then { result.message_length == 0x58 }
|
112
|
+
Then { result.transaction_id == 0x16 }
|
113
|
+
Then { result.xid == 0x16 }
|
114
|
+
|
115
|
+
Then { !result.body.empty? }
|
116
|
+
Then { result.buffer_id == 0xffffffff }
|
117
|
+
Then { result.in_port == 0xffff }
|
118
|
+
Then { result.actions_len == 0x8 }
|
119
|
+
Then { result.actions.length == 1 }
|
120
|
+
Then { result.actions[0].is_a? Pio::SendOutPort }
|
121
|
+
Then { result.actions[0].port_number == 2 }
|
122
|
+
Then { result.actions[0].max_len == 2**16 - 1 }
|
123
|
+
Then { result.data.length == 64 }
|
86
124
|
|
87
125
|
context '#to_binary' do
|
88
|
-
When(:binary) {
|
89
|
-
|
126
|
+
When(:binary) { result.to_binary }
|
127
|
+
|
128
|
+
Then { binary == header_dump + body_dump }
|
90
129
|
end
|
91
130
|
end
|
92
131
|
|
93
132
|
context 'with a SetVlanVid action' do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
133
|
+
When(:user_options) do
|
134
|
+
{
|
135
|
+
transaction_id: 0x16,
|
136
|
+
buffer_id: 0xffffffff,
|
137
|
+
in_port: 0xffff,
|
138
|
+
actions: Pio::SetVlanVid.new(10),
|
139
|
+
data: data_dump
|
140
|
+
}
|
100
141
|
end
|
101
142
|
|
102
|
-
Then {
|
103
|
-
Then {
|
104
|
-
Then {
|
105
|
-
Then {
|
106
|
-
Then {
|
143
|
+
Then { result.message_length == 0x58 }
|
144
|
+
Then { result.actions_len == 0x8 }
|
145
|
+
Then { result.actions.length == 1 }
|
146
|
+
Then { result.actions[0].is_a? Pio::SetVlanVid }
|
147
|
+
Then { result.actions[0].vlan_id == 10 }
|
107
148
|
end
|
108
149
|
|
109
150
|
context 'with a SetVlanPriority action' do
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
151
|
+
When(:user_options) do
|
152
|
+
{
|
153
|
+
transaction_id: 0x16,
|
154
|
+
buffer_id: 0xffffffff,
|
155
|
+
in_port: 0xffff,
|
156
|
+
actions: Pio::SetVlanPriority.new(3),
|
157
|
+
data: data_dump
|
158
|
+
}
|
116
159
|
end
|
117
160
|
|
118
|
-
Then {
|
119
|
-
Then {
|
120
|
-
Then {
|
121
|
-
Then {
|
122
|
-
Then {
|
161
|
+
Then { result.message_length == 0x58 }
|
162
|
+
Then { result.actions_len == 0x8 }
|
163
|
+
Then { result.actions.length == 1 }
|
164
|
+
Then { result.actions[0].is_a? Pio::SetVlanPriority }
|
165
|
+
Then { result.actions[0].vlan_priority == 3 }
|
123
166
|
end
|
124
167
|
|
125
168
|
context 'with a StripVlanHeader action' do
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
169
|
+
When(:user_options) do
|
170
|
+
{
|
171
|
+
transaction_id: 0x16,
|
172
|
+
buffer_id: 0xffffffff,
|
173
|
+
in_port: 0xffff,
|
174
|
+
actions: Pio::StripVlanHeader.new,
|
175
|
+
data: data_dump
|
176
|
+
}
|
132
177
|
end
|
133
178
|
|
134
|
-
Then {
|
135
|
-
Then {
|
136
|
-
Then {
|
137
|
-
Then {
|
179
|
+
Then { result.message_length == 0x58 }
|
180
|
+
Then { result.actions_len == 0x8 }
|
181
|
+
Then { result.actions.length == 1 }
|
182
|
+
Then { result.actions[0].is_a? Pio::StripVlanHeader }
|
138
183
|
end
|
139
184
|
|
140
185
|
context 'with a SetEthSrcAddr action' do
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
186
|
+
When(:user_options) do
|
187
|
+
{
|
188
|
+
transaction_id: 0x16,
|
189
|
+
buffer_id: 0xffffffff,
|
190
|
+
in_port: 0xffff,
|
191
|
+
actions: Pio::SetEthSrcAddr.new('11:22:33:44:55:66'),
|
192
|
+
data: data_dump
|
193
|
+
}
|
147
194
|
end
|
148
195
|
|
149
|
-
Then {
|
150
|
-
Then {
|
151
|
-
Then {
|
152
|
-
Then {
|
153
|
-
Then {
|
196
|
+
Then { result.message_length == 0x60 }
|
197
|
+
Then { result.actions_len == 0x10 }
|
198
|
+
Then { result.actions.length == 1 }
|
199
|
+
Then { result.actions[0].is_a? Pio::SetEthSrcAddr }
|
200
|
+
Then { result.actions[0].mac_address == '11:22:33:44:55:66' }
|
154
201
|
end
|
155
202
|
|
156
203
|
context 'with a SetEthDstAddr action' do
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
204
|
+
When(:user_options) do
|
205
|
+
{
|
206
|
+
transaction_id: 0x16,
|
207
|
+
buffer_id: 0xffffffff,
|
208
|
+
in_port: 0xffff,
|
209
|
+
actions: Pio::SetEthDstAddr.new('11:22:33:44:55:66'),
|
210
|
+
data: data_dump
|
211
|
+
}
|
163
212
|
end
|
164
213
|
|
165
|
-
Then {
|
166
|
-
Then {
|
167
|
-
Then {
|
168
|
-
Then {
|
169
|
-
Then {
|
214
|
+
Then { result.message_length == 0x60 }
|
215
|
+
Then { result.actions_len == 0x10 }
|
216
|
+
Then { result.actions.length == 1 }
|
217
|
+
Then { result.actions[0].is_a? Pio::SetEthDstAddr }
|
218
|
+
Then { result.actions[0].mac_address == '11:22:33:44:55:66' }
|
170
219
|
end
|
171
220
|
|
172
221
|
context 'with a SetIpSrcAddr action' do
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
222
|
+
When(:user_options) do
|
223
|
+
{
|
224
|
+
transaction_id: 0x16,
|
225
|
+
buffer_id: 0xffffffff,
|
226
|
+
in_port: 0xffff,
|
227
|
+
actions: Pio::SetIpSrcAddr.new('1.2.3.4'),
|
228
|
+
data: data_dump
|
229
|
+
}
|
179
230
|
end
|
180
231
|
|
181
|
-
Then {
|
182
|
-
Then {
|
183
|
-
Then {
|
184
|
-
Then {
|
185
|
-
Then {
|
232
|
+
Then { result.message_length == 0x58 }
|
233
|
+
Then { result.actions_len == 0x8 }
|
234
|
+
Then { result.actions.length == 1 }
|
235
|
+
Then { result.actions[0].is_a? Pio::SetIpSrcAddr }
|
236
|
+
Then { result.actions[0].ip_address == '1.2.3.4' }
|
186
237
|
end
|
187
238
|
|
188
239
|
context 'with a SetIpDstAddr action' do
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
240
|
+
When(:user_options) do
|
241
|
+
{
|
242
|
+
transaction_id: 0x16,
|
243
|
+
buffer_id: 0xffffffff,
|
244
|
+
in_port: 0xffff,
|
245
|
+
actions: Pio::SetIpDstAddr.new('1.2.3.4'),
|
246
|
+
data: data_dump
|
247
|
+
}
|
195
248
|
end
|
196
249
|
|
197
|
-
Then {
|
198
|
-
Then {
|
199
|
-
Then {
|
200
|
-
Then {
|
201
|
-
Then {
|
250
|
+
Then { result.message_length == 0x58 }
|
251
|
+
Then { result.actions_len == 0x8 }
|
252
|
+
Then { result.actions.length == 1 }
|
253
|
+
Then { result.actions[0].is_a? Pio::SetIpDstAddr }
|
254
|
+
Then { result.actions[0].ip_address == '1.2.3.4' }
|
202
255
|
end
|
203
256
|
|
204
257
|
context 'with a SetIpTos action' do
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
258
|
+
When(:user_options) do
|
259
|
+
{
|
260
|
+
transaction_id: 0x16,
|
261
|
+
buffer_id: 0xffffffff,
|
262
|
+
in_port: 0xffff,
|
263
|
+
actions: Pio::SetIpTos.new(32),
|
264
|
+
data: data_dump
|
265
|
+
}
|
211
266
|
end
|
212
267
|
|
213
|
-
Then {
|
214
|
-
Then {
|
215
|
-
Then {
|
216
|
-
Then {
|
217
|
-
Then {
|
268
|
+
Then { result.message_length == 0x58 }
|
269
|
+
Then { result.actions_len == 0x8 }
|
270
|
+
Then { result.actions.length == 1 }
|
271
|
+
Then { result.actions[0].is_a? Pio::SetIpTos }
|
272
|
+
Then { result.actions[0].type_of_service == 32 }
|
218
273
|
end
|
219
274
|
|
220
275
|
context 'with a SetTransportSrcPort action' do
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
276
|
+
When(:user_options) do
|
277
|
+
{
|
278
|
+
transaction_id: 0x16,
|
279
|
+
buffer_id: 0xffffffff,
|
280
|
+
in_port: 0xffff,
|
281
|
+
actions: Pio::SetTransportSrcPort.new(100),
|
282
|
+
data: data_dump
|
283
|
+
}
|
227
284
|
end
|
228
285
|
|
229
|
-
Then {
|
230
|
-
Then {
|
231
|
-
Then {
|
232
|
-
Then {
|
233
|
-
Then {
|
286
|
+
Then { result.message_length == 0x58 }
|
287
|
+
Then { result.actions_len == 0x8 }
|
288
|
+
Then { result.actions.length == 1 }
|
289
|
+
Then { result.actions[0].is_a? Pio::SetTransportSrcPort }
|
290
|
+
Then { result.actions[0].port_number == 100 }
|
234
291
|
end
|
235
292
|
|
236
293
|
context 'with a SetTransportDstPort action' do
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
294
|
+
When(:user_options) do
|
295
|
+
{
|
296
|
+
transaction_id: 0x16,
|
297
|
+
buffer_id: 0xffffffff,
|
298
|
+
in_port: 0xffff,
|
299
|
+
actions: Pio::SetTransportDstPort.new(100),
|
300
|
+
data: data_dump
|
301
|
+
}
|
243
302
|
end
|
244
303
|
|
245
|
-
Then {
|
246
|
-
Then {
|
247
|
-
Then {
|
248
|
-
Then {
|
249
|
-
Then {
|
304
|
+
Then { result.message_length == 0x58 }
|
305
|
+
Then { result.actions_len == 0x8 }
|
306
|
+
Then { result.actions.length == 1 }
|
307
|
+
Then { result.actions[0].is_a? Pio::SetTransportDstPort }
|
308
|
+
Then { result.actions[0].port_number == 100 }
|
250
309
|
end
|
251
310
|
|
252
311
|
context 'with a Enqueue action' do
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
312
|
+
When(:user_options) do
|
313
|
+
{
|
314
|
+
transaction_id: 0x16,
|
315
|
+
buffer_id: 0xffffffff,
|
316
|
+
in_port: 0xffff,
|
317
|
+
actions: Pio::Enqueue.new(port_number: 1, queue_id: 2),
|
318
|
+
data: data_dump
|
319
|
+
}
|
260
320
|
end
|
261
321
|
|
262
|
-
Then {
|
263
|
-
Then {
|
264
|
-
Then {
|
265
|
-
Then {
|
266
|
-
Then {
|
267
|
-
Then {
|
322
|
+
Then { result.message_length == 0x60 }
|
323
|
+
Then { result.actions_len == 0x10 }
|
324
|
+
Then { result.actions.length == 1 }
|
325
|
+
Then { result.actions[0].is_a? Pio::Enqueue }
|
326
|
+
Then { result.actions[0].port_number == 1 }
|
327
|
+
Then { result.actions[0].queue_id == 2 }
|
268
328
|
end
|
269
329
|
|
270
330
|
context 'with SendOutPort and SetVlanVid action' do
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
331
|
+
When(:user_options) do
|
332
|
+
{
|
333
|
+
transaction_id: 0x16,
|
334
|
+
buffer_id: 0xffffffff,
|
335
|
+
in_port: 0xffff,
|
336
|
+
actions: [Pio::SendOutPort.new(2), Pio::SetVlanVid.new(10)],
|
337
|
+
data: data_dump
|
338
|
+
}
|
278
339
|
end
|
279
340
|
|
280
|
-
Then {
|
281
|
-
Then {
|
282
|
-
Then {
|
283
|
-
Then {
|
284
|
-
Then {
|
285
|
-
Then {
|
286
|
-
Then {
|
287
|
-
Then {
|
341
|
+
Then { result.message_length == 0x60 }
|
342
|
+
Then { result.actions_len == 0x10 }
|
343
|
+
Then { result.actions.length == 2 }
|
344
|
+
Then { result.actions[0].is_a? Pio::SendOutPort }
|
345
|
+
Then { result.actions[0].port_number == 2 }
|
346
|
+
Then { result.actions[0].max_len == 2**16 - 1 }
|
347
|
+
Then { result.actions[1].is_a? Pio::SetVlanVid }
|
348
|
+
Then { result.actions[1].vlan_id == 10 }
|
288
349
|
end
|
289
350
|
end
|
290
351
|
end
|