blob: b1168432dc6fcba56c9cdd10518f0e2ca9bbc5a0 [file] [log] [blame]
Matteo Scandolo813402b2019-10-23 19:24:52 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package devices
18
19import (
Matteo Scandolo813402b2019-10-23 19:24:52 -070020 "github.com/google/gopacket/layers"
21 "github.com/looplab/fsm"
Matteo Scandolof9d43412021-01-12 11:11:34 -080022 "github.com/opencord/bbsim/internal/bbsim/types"
Matteo Scandolo4f4ac792020-10-01 16:33:21 -070023 "github.com/opencord/voltha-protos/v4/go/openolt"
Matteo Scandolo813402b2019-10-23 19:24:52 -070024 "gotest.tools/assert"
Matteo Scandolo813402b2019-10-23 19:24:52 -070025 "testing"
26)
27
Matteo Scandolo4a036262020-08-17 15:56:13 -070028// test that BBR correctly sends the EAPOL Flow
Matteo Scandolo813402b2019-10-23 19:24:52 -070029func Test_Onu_SendEapolFlow(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -070030 onu := createMockOnu(1, 1)
Matteo Scandolo813402b2019-10-23 19:24:52 -070031
32 client := &mockClient{
33 FlowAddSpy: FlowAddSpy{
34 Calls: make(map[int]*openolt.Flow),
35 },
36 fail: false,
37 }
38
39 onu.sendEapolFlow(client)
40 assert.Equal(t, client.FlowAddSpy.CallCount, 1)
41
42 assert.Equal(t, client.FlowAddSpy.Calls[1].AccessIntfId, int32(onu.PonPortID))
43 assert.Equal(t, client.FlowAddSpy.Calls[1].OnuId, int32(onu.ID))
44 assert.Equal(t, client.FlowAddSpy.Calls[1].UniId, int32(0))
Matteo Scandolo4f4ac792020-10-01 16:33:21 -070045 assert.Equal(t, client.FlowAddSpy.Calls[1].FlowId, uint64(onu.ID))
Matteo Scandolo813402b2019-10-23 19:24:52 -070046 assert.Equal(t, client.FlowAddSpy.Calls[1].FlowType, "downstream")
47 assert.Equal(t, client.FlowAddSpy.Calls[1].PortNo, onu.ID)
48}
49
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070050// checks that the FlowId is added to the list
51func Test_HandleFlowAddFlowId(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -070052 onu := createMockOnu(1, 1)
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070053
54 flow := openolt.Flow{
Shrey Baid688b4242020-07-10 20:40:10 +053055 FlowId: 64,
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070056 Classifier: &openolt.Classifier{},
57 }
Matteo Scandolof9d43412021-01-12 11:11:34 -080058 msg := types.OnuFlowUpdateMessage{
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070059 OnuID: onu.ID,
60 PonPortID: onu.PonPortID,
61 Flow: &flow,
62 }
63 onu.handleFlowAdd(msg)
64 assert.Equal(t, len(onu.FlowIds), 1)
Matteo Scandolo4f4ac792020-10-01 16:33:21 -070065 assert.Equal(t, onu.FlowIds[0], uint64(64))
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070066}
67
Matteo Scandolo4a036262020-08-17 15:56:13 -070068// checks that we only remove the correct flow
69func Test_HandleFlowRemoveFlowId(t *testing.T) {
70 onu := createMockOnu(1, 1)
71
Matteo Scandolo4f4ac792020-10-01 16:33:21 -070072 onu.FlowIds = []uint64{1, 2, 34, 64, 92}
Matteo Scandolo4a036262020-08-17 15:56:13 -070073
74 flow := openolt.Flow{
75 FlowId: 64,
76 Classifier: &openolt.Classifier{},
77 }
Matteo Scandolof9d43412021-01-12 11:11:34 -080078 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo4a036262020-08-17 15:56:13 -070079 OnuID: onu.ID,
80 PonPortID: onu.PonPortID,
81 Flow: &flow,
82 }
83 onu.handleFlowRemove(msg)
84 assert.Equal(t, len(onu.FlowIds), 4)
Matteo Scandolo4f4ac792020-10-01 16:33:21 -070085 assert.Equal(t, onu.FlowIds[0], uint64(1))
86 assert.Equal(t, onu.FlowIds[1], uint64(2))
87 assert.Equal(t, onu.FlowIds[2], uint64(34))
88 assert.Equal(t, onu.FlowIds[3], uint64(92))
Matteo Scandolo4a036262020-08-17 15:56:13 -070089}
90
91// checks that when the last flow is removed we reset the stored flags in the ONU
92func Test_HandleFlowRemoveFlowId_LastFlow(t *testing.T) {
93 onu := createMockOnu(1, 1)
94
95 onu.InternalState = fsm.NewFSM(
96 "enabled",
97 fsm.Events{
98 {Name: "disable", Src: []string{"enabled"}, Dst: "disabled"},
99 },
100 fsm.Callbacks{},
101 )
102
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700103 onu.FlowIds = []uint64{64}
Matteo Scandolo4a036262020-08-17 15:56:13 -0700104
105 flow := openolt.Flow{
106 FlowId: 64,
107 Classifier: &openolt.Classifier{},
108 }
Matteo Scandolof9d43412021-01-12 11:11:34 -0800109 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo4a036262020-08-17 15:56:13 -0700110 OnuID: onu.ID,
111 PonPortID: onu.PonPortID,
112 Flow: &flow,
113 }
114 onu.handleFlowRemove(msg)
115 assert.Equal(t, len(onu.FlowIds), 0)
Matteo Scandolo4a036262020-08-17 15:56:13 -0700116}
117
118func TestOnu_HhandleEAPOLStart(t *testing.T) {
119 onu := createMockOnu(1, 1)
120 hsia := mockService{Name: "hsia"}
121 voip := mockService{Name: "voip"}
122
123 onu.Services = []ServiceIf{&hsia, &voip}
124
125 stream := mockStream{
126 Calls: make(map[int]*openolt.Indication),
127 }
128
129 onu.PonPort.Olt.OpenoltStream = &stream
130
131 flow := openolt.Flow{
132 AccessIntfId: int32(onu.PonPortID),
133 OnuId: int32(onu.ID),
134 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700135 FlowId: uint64(onu.ID),
Matteo Scandolo4a036262020-08-17 15:56:13 -0700136 FlowType: "downstream",
137 AllocId: int32(0),
138 NetworkIntfId: int32(0),
139 Classifier: &openolt.Classifier{
140 EthType: uint32(layers.EthernetTypeEAPOL),
141 OVid: 4091,
142 },
143 Action: &openolt.Action{},
144 Priority: int32(100),
145 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
146 }
147
Matteo Scandolof9d43412021-01-12 11:11:34 -0800148 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo4a036262020-08-17 15:56:13 -0700149 PonPortID: 1,
150 OnuID: 1,
151 Flow: &flow,
152 }
153
154 onu.handleFlowAdd(msg)
155
156 // check that we call HandleAuth on all the services
157 assert.Equal(t, hsia.HandleAuthCallCount, 1)
158 assert.Equal(t, voip.HandleAuthCallCount, 1)
159}
160
161// TODO all the following tests needs to be moved in the Service model
162
Matteo Scandolo813402b2019-10-23 19:24:52 -0700163// validates that when an ONU receives an EAPOL flow for UNI 0
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800164// and the GemPort has already been configured
Matteo Scandolo813402b2019-10-23 19:24:52 -0700165// it transition to auth_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700166func Test_HandleFlowAddEapolWithGem(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700167 t.Skip("Needs to be moved in the Service struct")
168 onu := createMockOnu(1, 1)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700169
170 onu.InternalState = fsm.NewFSM(
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800171 "enabled",
Matteo Scandolo813402b2019-10-23 19:24:52 -0700172 fsm.Events{
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800173 {Name: "start_auth", Src: []string{"enabled"}, Dst: "auth_started"},
Matteo Scandolo813402b2019-10-23 19:24:52 -0700174 },
175 fsm.Callbacks{},
176 )
177
178 flow := openolt.Flow{
179 AccessIntfId: int32(onu.PonPortID),
180 OnuId: int32(onu.ID),
181 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700182 FlowId: uint64(onu.ID),
Matteo Scandolo813402b2019-10-23 19:24:52 -0700183 FlowType: "downstream",
184 AllocId: int32(0),
185 NetworkIntfId: int32(0),
186 Classifier: &openolt.Classifier{
187 EthType: uint32(layers.EthernetTypeEAPOL),
188 OVid: 4091,
189 },
190 Action: &openolt.Action{},
191 Priority: int32(100),
192 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
193 }
194
Matteo Scandolof9d43412021-01-12 11:11:34 -0800195 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo813402b2019-10-23 19:24:52 -0700196 PonPortID: 1,
197 OnuID: 1,
198 Flow: &flow,
199 }
200
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700201 onu.handleFlowAdd(msg)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700202 assert.Equal(t, onu.InternalState.Current(), "auth_started")
203}
204
205// validates that when an ONU receives an EAPOL flow for UNI that is not 0
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800206// no action is taken (this is independent of GemPort status
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700207func Test_HandleFlowAddEapolWrongUNI(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700208 t.Skip("Needs to be moved in the Service struct")
209 onu := createMockOnu(1, 1)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700210
211 onu.InternalState = fsm.NewFSM(
212 "enabled",
213 fsm.Events{
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800214 {Name: "start_auth", Src: []string{"enabled"}, Dst: "auth_started"},
Matteo Scandolo813402b2019-10-23 19:24:52 -0700215 },
216 fsm.Callbacks{},
217 )
218
219 flow := openolt.Flow{
220 AccessIntfId: int32(onu.PonPortID),
221 OnuId: int32(onu.ID),
222 UniId: int32(1),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700223 FlowId: uint64(onu.ID),
Matteo Scandolo813402b2019-10-23 19:24:52 -0700224 FlowType: "downstream",
225 AllocId: int32(0),
226 NetworkIntfId: int32(0),
227 Classifier: &openolt.Classifier{
228 EthType: uint32(layers.EthernetTypeEAPOL),
229 OVid: 4091,
230 },
231 Action: &openolt.Action{},
232 Priority: int32(100),
233 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
234 }
235
Matteo Scandolof9d43412021-01-12 11:11:34 -0800236 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo813402b2019-10-23 19:24:52 -0700237 PonPortID: 1,
238 OnuID: 1,
239 Flow: &flow,
240 }
241
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700242 onu.handleFlowAdd(msg)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700243 assert.Equal(t, onu.InternalState.Current(), "enabled")
244}
245
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800246// validates that when an ONU receives a DHCP flow for UNI 0 and pbit 0
247// and the GemPort has already been configured
248// it transition to dhcp_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700249func Test_HandleFlowAddDhcp(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700250 t.Skip("Needs to be moved in the Service struct")
251 onu := createMockOnu(1, 1)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700252
253 onu.InternalState = fsm.NewFSM(
254 "eap_response_success_received",
255 fsm.Events{
256 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
257 },
258 fsm.Callbacks{},
259 )
260
261 flow := openolt.Flow{
262 AccessIntfId: int32(onu.PonPortID),
263 OnuId: int32(onu.ID),
264 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700265 FlowId: uint64(onu.ID),
Matteo Scandoloc1147092019-10-29 09:38:33 -0700266 FlowType: "downstream",
267 AllocId: int32(0),
268 NetworkIntfId: int32(0),
269 Classifier: &openolt.Classifier{
270 EthType: uint32(layers.EthernetTypeIPv4),
271 SrcPort: uint32(68),
272 DstPort: uint32(67),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800273 OPbits: 0,
Matteo Scandoloc1147092019-10-29 09:38:33 -0700274 },
275 Action: &openolt.Action{},
276 Priority: int32(100),
277 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
278 }
279
Matteo Scandolof9d43412021-01-12 11:11:34 -0800280 msg := types.OnuFlowUpdateMessage{
Matteo Scandoloc1147092019-10-29 09:38:33 -0700281 PonPortID: 1,
282 OnuID: 1,
283 Flow: &flow,
284 }
285
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700286 onu.handleFlowAdd(msg)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700287 assert.Equal(t, onu.InternalState.Current(), "dhcp_started")
Matteo Scandoloc1147092019-10-29 09:38:33 -0700288}
289
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800290// validates that when an ONU receives a DHCP flow for UNI 0 and pbit 255
291// and the GemPort has already been configured
292// it transition to dhcp_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700293func Test_HandleFlowAddDhcpPBit255(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700294 t.Skip("Needs to be moved in the Service struct")
295 onu := createMockOnu(1, 1)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700296
297 onu.InternalState = fsm.NewFSM(
298 "eap_response_success_received",
299 fsm.Events{
300 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
301 },
302 fsm.Callbacks{},
303 )
304
305 flow := openolt.Flow{
306 AccessIntfId: int32(onu.PonPortID),
307 OnuId: int32(onu.ID),
308 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700309 FlowId: uint64(onu.ID),
Matteo Scandolod74abba2020-04-16 16:36:44 -0700310 FlowType: "downstream",
311 AllocId: int32(0),
312 NetworkIntfId: int32(0),
313 Classifier: &openolt.Classifier{
314 EthType: uint32(layers.EthernetTypeIPv4),
315 SrcPort: uint32(68),
316 DstPort: uint32(67),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800317 OPbits: 255,
Matteo Scandolod74abba2020-04-16 16:36:44 -0700318 },
319 Action: &openolt.Action{},
320 Priority: int32(100),
321 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
322 }
323
Matteo Scandolof9d43412021-01-12 11:11:34 -0800324 msg := types.OnuFlowUpdateMessage{
Matteo Scandolod74abba2020-04-16 16:36:44 -0700325 PonPortID: 1,
326 OnuID: 1,
327 Flow: &flow,
328 }
329
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700330 onu.handleFlowAdd(msg)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700331 assert.Equal(t, onu.InternalState.Current(), "dhcp_started")
Matteo Scandolod74abba2020-04-16 16:36:44 -0700332}
333
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800334// validates that when an ONU receives a DHCP flow for UNI 0 and pbit not 0 or 255
335// and the GemPort has already been configured
336// it ignores the message
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700337func Test_HandleFlowAddDhcpIgnoreByPbit(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700338 t.Skip("Needs to be moved in the Service struct")
339 onu := createMockOnu(1, 1)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700340
341 onu.InternalState = fsm.NewFSM(
342 "eap_response_success_received",
343 fsm.Events{
344 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
345 },
346 fsm.Callbacks{},
347 )
348
349 flow := openolt.Flow{
350 AccessIntfId: int32(onu.PonPortID),
351 OnuId: int32(onu.ID),
352 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700353 FlowId: uint64(onu.ID),
Matteo Scandolod74abba2020-04-16 16:36:44 -0700354 FlowType: "downstream",
355 AllocId: int32(0),
356 NetworkIntfId: int32(0),
357 Classifier: &openolt.Classifier{
358 EthType: uint32(layers.EthernetTypeIPv4),
359 SrcPort: uint32(68),
360 DstPort: uint32(67),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800361 OPbits: 1,
Matteo Scandolod74abba2020-04-16 16:36:44 -0700362 },
363 Action: &openolt.Action{},
364 Priority: int32(100),
365 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
366 }
367
Matteo Scandolof9d43412021-01-12 11:11:34 -0800368 msg := types.OnuFlowUpdateMessage{
Matteo Scandolod74abba2020-04-16 16:36:44 -0700369 PonPortID: 1,
370 OnuID: 1,
371 Flow: &flow,
372 }
373
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700374 onu.handleFlowAdd(msg)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700375 assert.Equal(t, onu.InternalState.Current(), "eap_response_success_received")
Matteo Scandolod74abba2020-04-16 16:36:44 -0700376}
377
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800378// validates that when an ONU receives a DHCP flow for UNI 0
379// but the noDchp bit is set no action is taken
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700380func Test_HandleFlowAddDhcpNoDhcp(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700381 t.Skip("Needs to be moved in the Service struct")
382 onu := createMockOnu(1, 1)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700383
384 onu.InternalState = fsm.NewFSM(
385 "eap_response_success_received",
386 fsm.Events{
387 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
388 },
389 fsm.Callbacks{},
390 )
391
392 flow := openolt.Flow{
393 AccessIntfId: int32(onu.PonPortID),
394 OnuId: int32(onu.ID),
395 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700396 FlowId: uint64(onu.ID),
Matteo Scandoloc1147092019-10-29 09:38:33 -0700397 FlowType: "downstream",
398 AllocId: int32(0),
399 NetworkIntfId: int32(0),
400 Classifier: &openolt.Classifier{
401 EthType: uint32(layers.EthernetTypeIPv4),
402 SrcPort: uint32(68),
403 DstPort: uint32(67),
404 },
405 Action: &openolt.Action{},
406 Priority: int32(100),
407 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
408 }
409
Matteo Scandolof9d43412021-01-12 11:11:34 -0800410 msg := types.OnuFlowUpdateMessage{
Matteo Scandoloc1147092019-10-29 09:38:33 -0700411 PonPortID: 1,
412 OnuID: 1,
413 Flow: &flow,
414 }
415
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700416 onu.handleFlowAdd(msg)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700417 assert.Equal(t, onu.InternalState.Current(), "eap_response_success_received")
Matteo Scandoloc1147092019-10-29 09:38:33 -0700418}
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800419
420// validates that when an ONU receives a DHCP flow for UNI 0 and pbit not 0 or 255
421// and the GemPort has not already been configured
422// it transition to dhcp_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700423func Test_HandleFlowAddDhcpWithoutGem(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700424 t.Skip("Needs to be moved in the Service struct")
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700425 // NOTE that this feature is required as there is no guarantee that the gemport is the same
426 // one we received with the EAPOL flow
Matteo Scandolo4a036262020-08-17 15:56:13 -0700427 onu := createMockOnu(1, 1)
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800428
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800429 onu.InternalState = fsm.NewFSM(
430 "enabled",
431 fsm.Events{
432 {Name: "start_dhcp", Src: []string{"enabled"}, Dst: "dhcp_started"},
433 },
434 fsm.Callbacks{},
435 )
436
437 flow := openolt.Flow{
438 AccessIntfId: int32(onu.PonPortID),
439 OnuId: int32(onu.ID),
440 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700441 FlowId: uint64(onu.ID),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800442 FlowType: "downstream",
443 AllocId: int32(0),
444 NetworkIntfId: int32(0),
445 Classifier: &openolt.Classifier{
446 EthType: uint32(layers.EthernetTypeIPv4),
447 SrcPort: uint32(68),
448 DstPort: uint32(67),
449 OPbits: 0,
450 },
451 Action: &openolt.Action{},
452 Priority: int32(100),
453 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
454 }
455
Matteo Scandolof9d43412021-01-12 11:11:34 -0800456 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800457 PonPortID: 1,
458 OnuID: 1,
459 Flow: &flow,
460 }
461
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700462 onu.handleFlowAdd(msg)
Hardik Windlass7b3405b2020-07-08 15:10:05 +0530463}