blob: e0ad9fe24e9741c8df61902cc659917acc1ae4fb [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
103 onu.GemPortAdded = true
104
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700105 onu.FlowIds = []uint64{64}
Matteo Scandolo4a036262020-08-17 15:56:13 -0700106
107 flow := openolt.Flow{
108 FlowId: 64,
109 Classifier: &openolt.Classifier{},
110 }
Matteo Scandolof9d43412021-01-12 11:11:34 -0800111 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo4a036262020-08-17 15:56:13 -0700112 OnuID: onu.ID,
113 PonPortID: onu.PonPortID,
114 Flow: &flow,
115 }
116 onu.handleFlowRemove(msg)
117 assert.Equal(t, len(onu.FlowIds), 0)
118 assert.Equal(t, onu.GemPortAdded, false)
119}
120
121func TestOnu_HhandleEAPOLStart(t *testing.T) {
122 onu := createMockOnu(1, 1)
123 hsia := mockService{Name: "hsia"}
124 voip := mockService{Name: "voip"}
125
126 onu.Services = []ServiceIf{&hsia, &voip}
127
128 stream := mockStream{
129 Calls: make(map[int]*openolt.Indication),
130 }
131
132 onu.PonPort.Olt.OpenoltStream = &stream
133
134 flow := openolt.Flow{
135 AccessIntfId: int32(onu.PonPortID),
136 OnuId: int32(onu.ID),
137 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700138 FlowId: uint64(onu.ID),
Matteo Scandolo4a036262020-08-17 15:56:13 -0700139 FlowType: "downstream",
140 AllocId: int32(0),
141 NetworkIntfId: int32(0),
142 Classifier: &openolt.Classifier{
143 EthType: uint32(layers.EthernetTypeEAPOL),
144 OVid: 4091,
145 },
146 Action: &openolt.Action{},
147 Priority: int32(100),
148 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
149 }
150
Matteo Scandolof9d43412021-01-12 11:11:34 -0800151 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo4a036262020-08-17 15:56:13 -0700152 PonPortID: 1,
153 OnuID: 1,
154 Flow: &flow,
155 }
156
157 onu.handleFlowAdd(msg)
158
159 // check that we call HandleAuth on all the services
160 assert.Equal(t, hsia.HandleAuthCallCount, 1)
161 assert.Equal(t, voip.HandleAuthCallCount, 1)
162}
163
164// TODO all the following tests needs to be moved in the Service model
165
Matteo Scandolo813402b2019-10-23 19:24:52 -0700166// validates that when an ONU receives an EAPOL flow for UNI 0
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800167// and the GemPort has already been configured
Matteo Scandolo813402b2019-10-23 19:24:52 -0700168// it transition to auth_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700169func Test_HandleFlowAddEapolWithGem(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700170 t.Skip("Needs to be moved in the Service struct")
171 onu := createMockOnu(1, 1)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700172
173 onu.InternalState = fsm.NewFSM(
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800174 "enabled",
Matteo Scandolo813402b2019-10-23 19:24:52 -0700175 fsm.Events{
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800176 {Name: "start_auth", Src: []string{"enabled"}, Dst: "auth_started"},
Matteo Scandolo813402b2019-10-23 19:24:52 -0700177 },
178 fsm.Callbacks{},
179 )
180
181 flow := openolt.Flow{
182 AccessIntfId: int32(onu.PonPortID),
183 OnuId: int32(onu.ID),
184 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700185 FlowId: uint64(onu.ID),
Matteo Scandolo813402b2019-10-23 19:24:52 -0700186 FlowType: "downstream",
187 AllocId: int32(0),
188 NetworkIntfId: int32(0),
189 Classifier: &openolt.Classifier{
190 EthType: uint32(layers.EthernetTypeEAPOL),
191 OVid: 4091,
192 },
193 Action: &openolt.Action{},
194 Priority: int32(100),
195 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
196 }
197
Matteo Scandolof9d43412021-01-12 11:11:34 -0800198 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo813402b2019-10-23 19:24:52 -0700199 PonPortID: 1,
200 OnuID: 1,
201 Flow: &flow,
202 }
203
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700204 onu.handleFlowAdd(msg)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700205 assert.Equal(t, onu.InternalState.Current(), "auth_started")
206}
207
208// validates that when an ONU receives an EAPOL flow for UNI that is not 0
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800209// no action is taken (this is independent of GemPort status
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700210func Test_HandleFlowAddEapolWrongUNI(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700211 t.Skip("Needs to be moved in the Service struct")
212 onu := createMockOnu(1, 1)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700213
214 onu.InternalState = fsm.NewFSM(
215 "enabled",
216 fsm.Events{
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800217 {Name: "start_auth", Src: []string{"enabled"}, Dst: "auth_started"},
Matteo Scandolo813402b2019-10-23 19:24:52 -0700218 },
219 fsm.Callbacks{},
220 )
221
222 flow := openolt.Flow{
223 AccessIntfId: int32(onu.PonPortID),
224 OnuId: int32(onu.ID),
225 UniId: int32(1),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700226 FlowId: uint64(onu.ID),
Matteo Scandolo813402b2019-10-23 19:24:52 -0700227 FlowType: "downstream",
228 AllocId: int32(0),
229 NetworkIntfId: int32(0),
230 Classifier: &openolt.Classifier{
231 EthType: uint32(layers.EthernetTypeEAPOL),
232 OVid: 4091,
233 },
234 Action: &openolt.Action{},
235 Priority: int32(100),
236 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
237 }
238
Matteo Scandolof9d43412021-01-12 11:11:34 -0800239 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo813402b2019-10-23 19:24:52 -0700240 PonPortID: 1,
241 OnuID: 1,
242 Flow: &flow,
243 }
244
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700245 onu.handleFlowAdd(msg)
Matteo Scandolo813402b2019-10-23 19:24:52 -0700246 assert.Equal(t, onu.InternalState.Current(), "enabled")
247}
248
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800249// validates that when an ONU receives a DHCP flow for UNI 0 and pbit 0
250// and the GemPort has already been configured
251// it transition to dhcp_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700252func Test_HandleFlowAddDhcp(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700253 t.Skip("Needs to be moved in the Service struct")
254 onu := createMockOnu(1, 1)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700255
256 onu.InternalState = fsm.NewFSM(
257 "eap_response_success_received",
258 fsm.Events{
259 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
260 },
261 fsm.Callbacks{},
262 )
263
264 flow := openolt.Flow{
265 AccessIntfId: int32(onu.PonPortID),
266 OnuId: int32(onu.ID),
267 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700268 FlowId: uint64(onu.ID),
Matteo Scandoloc1147092019-10-29 09:38:33 -0700269 FlowType: "downstream",
270 AllocId: int32(0),
271 NetworkIntfId: int32(0),
272 Classifier: &openolt.Classifier{
273 EthType: uint32(layers.EthernetTypeIPv4),
274 SrcPort: uint32(68),
275 DstPort: uint32(67),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800276 OPbits: 0,
Matteo Scandoloc1147092019-10-29 09:38:33 -0700277 },
278 Action: &openolt.Action{},
279 Priority: int32(100),
280 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
281 }
282
Matteo Scandolof9d43412021-01-12 11:11:34 -0800283 msg := types.OnuFlowUpdateMessage{
Matteo Scandoloc1147092019-10-29 09:38:33 -0700284 PonPortID: 1,
285 OnuID: 1,
286 Flow: &flow,
287 }
288
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700289 onu.handleFlowAdd(msg)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700290 assert.Equal(t, onu.InternalState.Current(), "dhcp_started")
Matteo Scandoloc1147092019-10-29 09:38:33 -0700291}
292
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800293// validates that when an ONU receives a DHCP flow for UNI 0 and pbit 255
294// and the GemPort has already been configured
295// it transition to dhcp_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700296func Test_HandleFlowAddDhcpPBit255(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700297 t.Skip("Needs to be moved in the Service struct")
298 onu := createMockOnu(1, 1)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700299
300 onu.InternalState = fsm.NewFSM(
301 "eap_response_success_received",
302 fsm.Events{
303 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
304 },
305 fsm.Callbacks{},
306 )
307
308 flow := openolt.Flow{
309 AccessIntfId: int32(onu.PonPortID),
310 OnuId: int32(onu.ID),
311 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700312 FlowId: uint64(onu.ID),
Matteo Scandolod74abba2020-04-16 16:36:44 -0700313 FlowType: "downstream",
314 AllocId: int32(0),
315 NetworkIntfId: int32(0),
316 Classifier: &openolt.Classifier{
317 EthType: uint32(layers.EthernetTypeIPv4),
318 SrcPort: uint32(68),
319 DstPort: uint32(67),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800320 OPbits: 255,
Matteo Scandolod74abba2020-04-16 16:36:44 -0700321 },
322 Action: &openolt.Action{},
323 Priority: int32(100),
324 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
325 }
326
Matteo Scandolof9d43412021-01-12 11:11:34 -0800327 msg := types.OnuFlowUpdateMessage{
Matteo Scandolod74abba2020-04-16 16:36:44 -0700328 PonPortID: 1,
329 OnuID: 1,
330 Flow: &flow,
331 }
332
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700333 onu.handleFlowAdd(msg)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700334 assert.Equal(t, onu.InternalState.Current(), "dhcp_started")
Matteo Scandolod74abba2020-04-16 16:36:44 -0700335}
336
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800337// validates that when an ONU receives a DHCP flow for UNI 0 and pbit not 0 or 255
338// and the GemPort has already been configured
339// it ignores the message
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700340func Test_HandleFlowAddDhcpIgnoreByPbit(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700341 t.Skip("Needs to be moved in the Service struct")
342 onu := createMockOnu(1, 1)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700343
344 onu.InternalState = fsm.NewFSM(
345 "eap_response_success_received",
346 fsm.Events{
347 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
348 },
349 fsm.Callbacks{},
350 )
351
352 flow := openolt.Flow{
353 AccessIntfId: int32(onu.PonPortID),
354 OnuId: int32(onu.ID),
355 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700356 FlowId: uint64(onu.ID),
Matteo Scandolod74abba2020-04-16 16:36:44 -0700357 FlowType: "downstream",
358 AllocId: int32(0),
359 NetworkIntfId: int32(0),
360 Classifier: &openolt.Classifier{
361 EthType: uint32(layers.EthernetTypeIPv4),
362 SrcPort: uint32(68),
363 DstPort: uint32(67),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800364 OPbits: 1,
Matteo Scandolod74abba2020-04-16 16:36:44 -0700365 },
366 Action: &openolt.Action{},
367 Priority: int32(100),
368 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
369 }
370
Matteo Scandolof9d43412021-01-12 11:11:34 -0800371 msg := types.OnuFlowUpdateMessage{
Matteo Scandolod74abba2020-04-16 16:36:44 -0700372 PonPortID: 1,
373 OnuID: 1,
374 Flow: &flow,
375 }
376
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700377 onu.handleFlowAdd(msg)
Matteo Scandolod74abba2020-04-16 16:36:44 -0700378 assert.Equal(t, onu.InternalState.Current(), "eap_response_success_received")
Matteo Scandolod74abba2020-04-16 16:36:44 -0700379}
380
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800381// validates that when an ONU receives a DHCP flow for UNI 0
382// but the noDchp bit is set no action is taken
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700383func Test_HandleFlowAddDhcpNoDhcp(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700384 t.Skip("Needs to be moved in the Service struct")
385 onu := createMockOnu(1, 1)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700386
387 onu.InternalState = fsm.NewFSM(
388 "eap_response_success_received",
389 fsm.Events{
390 {Name: "start_dhcp", Src: []string{"eap_response_success_received"}, Dst: "dhcp_started"},
391 },
392 fsm.Callbacks{},
393 )
394
395 flow := openolt.Flow{
396 AccessIntfId: int32(onu.PonPortID),
397 OnuId: int32(onu.ID),
398 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700399 FlowId: uint64(onu.ID),
Matteo Scandoloc1147092019-10-29 09:38:33 -0700400 FlowType: "downstream",
401 AllocId: int32(0),
402 NetworkIntfId: int32(0),
403 Classifier: &openolt.Classifier{
404 EthType: uint32(layers.EthernetTypeIPv4),
405 SrcPort: uint32(68),
406 DstPort: uint32(67),
407 },
408 Action: &openolt.Action{},
409 Priority: int32(100),
410 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
411 }
412
Matteo Scandolof9d43412021-01-12 11:11:34 -0800413 msg := types.OnuFlowUpdateMessage{
Matteo Scandoloc1147092019-10-29 09:38:33 -0700414 PonPortID: 1,
415 OnuID: 1,
416 Flow: &flow,
417 }
418
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700419 onu.handleFlowAdd(msg)
Matteo Scandoloc1147092019-10-29 09:38:33 -0700420 assert.Equal(t, onu.InternalState.Current(), "eap_response_success_received")
Matteo Scandoloc1147092019-10-29 09:38:33 -0700421}
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800422
423// validates that when an ONU receives a DHCP flow for UNI 0 and pbit not 0 or 255
424// and the GemPort has not already been configured
425// it transition to dhcp_started state
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700426func Test_HandleFlowAddDhcpWithoutGem(t *testing.T) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700427 t.Skip("Needs to be moved in the Service struct")
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700428 // NOTE that this feature is required as there is no guarantee that the gemport is the same
429 // one we received with the EAPOL flow
Matteo Scandolo4a036262020-08-17 15:56:13 -0700430 onu := createMockOnu(1, 1)
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800431
432 onu.GemPortAdded = false
433
434 onu.InternalState = fsm.NewFSM(
435 "enabled",
436 fsm.Events{
437 {Name: "start_dhcp", Src: []string{"enabled"}, Dst: "dhcp_started"},
438 },
439 fsm.Callbacks{},
440 )
441
442 flow := openolt.Flow{
443 AccessIntfId: int32(onu.PonPortID),
444 OnuId: int32(onu.ID),
445 UniId: int32(0),
Matteo Scandolo4f4ac792020-10-01 16:33:21 -0700446 FlowId: uint64(onu.ID),
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800447 FlowType: "downstream",
448 AllocId: int32(0),
449 NetworkIntfId: int32(0),
450 Classifier: &openolt.Classifier{
451 EthType: uint32(layers.EthernetTypeIPv4),
452 SrcPort: uint32(68),
453 DstPort: uint32(67),
454 OPbits: 0,
455 },
456 Action: &openolt.Action{},
457 Priority: int32(100),
458 PortNo: uint32(onu.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
459 }
460
Matteo Scandolof9d43412021-01-12 11:11:34 -0800461 msg := types.OnuFlowUpdateMessage{
Matteo Scandolo5ff80082019-12-20 13:20:57 -0800462 PonPortID: 1,
463 OnuID: 1,
464 Flow: &flow,
465 }
466
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700467 onu.handleFlowAdd(msg)
Hardik Windlass7b3405b2020-07-08 15:10:05 +0530468}