blob: 9ab83fadfb20a51ef02cb9c5e89d8085050bff24 [file] [log] [blame]
Matteo Scandolo11006992019-08-28 11:29:46 -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
Matteo Scandolo4747d292019-08-05 11:50:18 -070017package devices
18
19import (
Matteo Scandolo40e067f2019-10-16 16:59:41 -070020 "context"
Matteo Scandolo99f18462019-10-28 14:14:28 -070021 "errors"
Matteo Scandolo3bc73742019-08-20 14:04:04 -070022 "fmt"
Zdravko Bozakov681364d2019-11-10 14:28:46 +010023 "net"
24
25 "time"
26
Matteo Scandolo40e067f2019-10-16 16:59:41 -070027 "github.com/cboling/omci"
Matteo Scandolo3bc73742019-08-20 14:04:04 -070028 "github.com/google/gopacket/layers"
Matteo Scandolo4747d292019-08-05 11:50:18 -070029 "github.com/looplab/fsm"
Matteo Scandolo075b1892019-10-07 12:11:07 -070030 "github.com/opencord/bbsim/internal/bbsim/packetHandlers"
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -070031 "github.com/opencord/bbsim/internal/bbsim/responders/dhcp"
32 "github.com/opencord/bbsim/internal/bbsim/responders/eapol"
Matteo Scandolo40e067f2019-10-16 16:59:41 -070033 "github.com/opencord/bbsim/internal/common"
34 omcilib "github.com/opencord/bbsim/internal/common/omci"
35 omcisim "github.com/opencord/omci-sim"
Matteo Scandolo3de9de02019-11-14 13:40:03 -080036 "github.com/opencord/voltha-protos/v2/go/openolt"
Matteo Scandolo4747d292019-08-05 11:50:18 -070037 log "github.com/sirupsen/logrus"
38)
39
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070040var onuLogger = log.WithFields(log.Fields{
41 "module": "ONU",
42})
43
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070044type Onu struct {
Matteo Scandoloe811ae92019-12-10 17:50:14 -080045 ID uint32
46 PonPortID uint32
47 PonPort PonPort
48 STag int
49 CTag int
50 Auth bool // automatically start EAPOL if set to true
51 Dhcp bool // automatically start DHCP if set to true
52 HwAddress net.HardwareAddr
53 InternalState *fsm.FSM
54 DiscoveryRetryDelay time.Duration
55
56 // ONU State
Matteo Scandolo27428702019-10-11 16:21:16 -070057 // PortNo comes with flows and it's used when sending packetIndications,
58 // There is one PortNo per UNI Port, for now we're only storing the first one
59 // FIXME add support for multiple UNIs
Matteo Scandolo99f18462019-10-28 14:14:28 -070060 PortNo uint32
61 DhcpFlowReceived bool
62
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070063 OperState *fsm.FSM
64 SerialNumber *openolt.SerialNumber
65
66 Channel chan Message // this Channel is to track state changes OMCI messages, EAPOL and DHCP packets
Matteo Scandolo40e067f2019-10-16 16:59:41 -070067
68 // OMCI params
69 tid uint16
70 hpTid uint16
71 seqNumber uint16
72 HasGemPort bool
73
74 DoneChannel chan bool // this channel is used to signal once the onu is complete (when the struct is used by BBR)
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070075}
76
Matteo Scandolo99f18462019-10-28 14:14:28 -070077func (o *Onu) Sn() string {
Matteo Scandolo40e067f2019-10-16 16:59:41 -070078 return common.OnuSnToString(o.SerialNumber)
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070079}
80
Matteo Scandoloc1147092019-10-29 09:38:33 -070081func CreateONU(olt OltDevice, pon PonPort, id uint32, sTag int, cTag int, auth bool, dhcp bool) *Onu {
Matteo Scandolo4747d292019-08-05 11:50:18 -070082
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -070083 o := Onu{
Matteo Scandoloe811ae92019-12-10 17:50:14 -080084 ID: id,
85 PonPortID: pon.ID,
86 PonPort: pon,
87 STag: sTag,
88 CTag: cTag,
89 Auth: auth,
90 Dhcp: dhcp,
91 HwAddress: net.HardwareAddr{0x2e, 0x60, 0x70, 0x13, byte(pon.ID), byte(id)},
92 PortNo: 0,
93 tid: 0x1,
94 hpTid: 0x8000,
95 seqNumber: 0,
96 DoneChannel: make(chan bool, 1),
97 DhcpFlowReceived: false,
98 DiscoveryRetryDelay: 60 * time.Second, // this is used to send OnuDiscoveryIndications until an activate call is received
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -070099 }
100 o.SerialNumber = o.NewSN(olt.ID, pon.ID, o.ID)
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700101
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700102 // NOTE this state machine is used to track the operational
103 // state as requested by VOLTHA
104 o.OperState = getOperStateFSM(func(e *fsm.Event) {
105 onuLogger.WithFields(log.Fields{
106 "ID": o.ID,
107 }).Debugf("Changing ONU OperState from %s to %s", e.Src, e.Dst)
108 })
109
110 // NOTE this state machine is used to activate the OMCI, EAPOL and DHCP clients
111 o.InternalState = fsm.NewFSM(
112 "created",
113 fsm.Events{
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700114 // DEVICE Lifecycle
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100115 {Name: "initialize", Src: []string{"created", "disabled"}, Dst: "initialized"},
116 {Name: "discover", Src: []string{"initialized"}, Dst: "discovered"},
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700117 {Name: "enable", Src: []string{"discovered", "disabled"}, Dst: "enabled"},
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700118 {Name: "receive_eapol_flow", Src: []string{"enabled", "gem_port_added"}, Dst: "eapol_flow_received"},
119 {Name: "add_gem_port", Src: []string{"enabled", "eapol_flow_received"}, Dst: "gem_port_added"},
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100120 // NOTE should disabled state be different for oper_disabled (emulating an error) and admin_disabled (received a disabled call via VOLTHA)?
121 {Name: "disable", Src: []string{"enabled", "eap_response_success_received", "auth_failed", "dhcp_ack_received", "dhcp_failed"}, Dst: "disabled"},
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700122 // EAPOL
Matteo Scandolo5e081b52019-11-21 14:34:25 -0800123 {Name: "start_auth", Src: []string{"eapol_flow_received", "gem_port_added", "eap_start_sent", "eap_response_identity_sent", "eap_response_challenge_sent", "eap_response_success_received", "auth_failed", "dhcp_ack_received", "dhcp_failed"}, Dst: "auth_started"},
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700124 {Name: "eap_start_sent", Src: []string{"auth_started"}, Dst: "eap_start_sent"},
125 {Name: "eap_response_identity_sent", Src: []string{"eap_start_sent"}, Dst: "eap_response_identity_sent"},
126 {Name: "eap_response_challenge_sent", Src: []string{"eap_response_identity_sent"}, Dst: "eap_response_challenge_sent"},
127 {Name: "eap_response_success_received", Src: []string{"eap_response_challenge_sent"}, Dst: "eap_response_success_received"},
128 {Name: "auth_failed", Src: []string{"auth_started", "eap_start_sent", "eap_response_identity_sent", "eap_response_challenge_sent"}, Dst: "auth_failed"},
129 // DHCP
Matteo Scandolofe9ac252019-10-25 11:40:17 -0700130 {Name: "start_dhcp", Src: []string{"eap_response_success_received", "dhcp_discovery_sent", "dhcp_request_sent", "dhcp_ack_received", "dhcp_failed"}, Dst: "dhcp_started"},
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700131 {Name: "dhcp_discovery_sent", Src: []string{"dhcp_started"}, Dst: "dhcp_discovery_sent"},
132 {Name: "dhcp_request_sent", Src: []string{"dhcp_discovery_sent"}, Dst: "dhcp_request_sent"},
133 {Name: "dhcp_ack_received", Src: []string{"dhcp_request_sent"}, Dst: "dhcp_ack_received"},
134 {Name: "dhcp_failed", Src: []string{"dhcp_started", "dhcp_discovery_sent", "dhcp_request_sent"}, Dst: "dhcp_failed"},
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700135 // BBR States
136 // TODO add start OMCI state
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100137 {Name: "send_eapol_flow", Src: []string{"initialized"}, Dst: "eapol_flow_sent"},
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700138 {Name: "send_dhcp_flow", Src: []string{"eapol_flow_sent"}, Dst: "dhcp_flow_sent"},
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700139 },
140 fsm.Callbacks{
141 "enter_state": func(e *fsm.Event) {
142 o.logStateChange(e.Src, e.Dst)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700143 },
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100144 "enter_initialized": func(e *fsm.Event) {
145 // create new channel for ProcessOnuMessages Go routine
146 o.Channel = make(chan Message, 2048)
147 },
148 "enter_discovered": func(e *fsm.Event) {
149 msg := Message{
150 Type: OnuDiscIndication,
151 Data: OnuDiscIndicationMessage{
152 Onu: &o,
153 OperState: UP,
154 },
155 }
156 o.Channel <- msg
157 },
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700158 "enter_enabled": func(event *fsm.Event) {
159 msg := Message{
160 Type: OnuIndication,
161 Data: OnuIndicationMessage{
162 OnuSN: o.SerialNumber,
163 PonPortID: o.PonPortID,
164 OperState: UP,
165 },
166 }
167 o.Channel <- msg
168 },
169 "enter_disabled": func(event *fsm.Event) {
170 msg := Message{
171 Type: OnuIndication,
172 Data: OnuIndicationMessage{
173 OnuSN: o.SerialNumber,
174 PonPortID: o.PonPortID,
175 OperState: DOWN,
176 },
177 }
178 o.Channel <- msg
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100179 // terminate the ONU's ProcessOnuMessages Go routine
180 close(o.Channel)
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700181 },
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700182 "enter_auth_started": func(e *fsm.Event) {
183 o.logStateChange(e.Src, e.Dst)
184 msg := Message{
185 Type: StartEAPOL,
186 Data: PacketMessage{
187 PonPortID: o.PonPortID,
188 OnuID: o.ID,
189 },
190 }
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700191 o.Channel <- msg
Matteo Scandolo4747d292019-08-05 11:50:18 -0700192 },
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700193 "enter_auth_failed": func(e *fsm.Event) {
194 onuLogger.WithFields(log.Fields{
195 "OnuId": o.ID,
196 "IntfId": o.PonPortID,
197 "OnuSn": o.Sn(),
198 }).Errorf("ONU failed to authenticate!")
199 },
Matteo Scandolo99f18462019-10-28 14:14:28 -0700200 "before_start_dhcp": func(e *fsm.Event) {
201 if o.DhcpFlowReceived == false {
202 e.Cancel(errors.New("cannot-go-to-dhcp-started-as-dhcp-flow-is-missing"))
203 }
204 },
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700205 "enter_dhcp_started": func(e *fsm.Event) {
206 msg := Message{
207 Type: StartDHCP,
208 Data: PacketMessage{
209 PonPortID: o.PonPortID,
210 OnuID: o.ID,
211 },
212 }
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700213 o.Channel <- msg
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700214 },
215 "enter_dhcp_failed": func(e *fsm.Event) {
216 onuLogger.WithFields(log.Fields{
217 "OnuId": o.ID,
218 "IntfId": o.PonPortID,
219 "OnuSn": o.Sn(),
220 }).Errorf("ONU failed to DHCP!")
221 },
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700222 "enter_eapol_flow_sent": func(e *fsm.Event) {
223 msg := Message{
224 Type: SendEapolFlow,
225 }
226 o.Channel <- msg
227 },
228 "enter_dhcp_flow_sent": func(e *fsm.Event) {
229 msg := Message{
230 Type: SendDhcpFlow,
231 }
232 o.Channel <- msg
233 },
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700234 },
235 )
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100236
Matteo Scandolo27428702019-10-11 16:21:16 -0700237 return &o
Matteo Scandolo4747d292019-08-05 11:50:18 -0700238}
239
William Kurkian0418bc82019-11-06 12:16:24 -0500240func (o *Onu) logStateChange(src string, dst string) {
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700241 onuLogger.WithFields(log.Fields{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700242 "OnuId": o.ID,
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700243 "IntfId": o.PonPortID,
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700244 "OnuSn": o.Sn(),
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700245 }).Debugf("Changing ONU InternalState from %s to %s", src, dst)
246}
247
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100248// ProcessOnuMessages starts indication channel for each ONU
David Bainbridge103cf022019-12-16 20:11:35 +0000249func (o *Onu) ProcessOnuMessages(ctx context.Context, stream openolt.Openolt_EnableIndicationServer, client openolt.OpenoltClient) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700250 onuLogger.WithFields(log.Fields{
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100251 "onuID": o.ID,
252 "onuSN": o.Sn(),
253 "ponPort": o.PonPortID,
254 }).Debug("Starting ONU Indication Channel")
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700255
David Bainbridge103cf022019-12-16 20:11:35 +0000256loop:
257 for {
258 select {
259 case <-ctx.Done():
260 onuLogger.WithFields(log.Fields{
261 "onuID": o.ID,
262 "onuSN": o.Sn(),
263 }).Tracef("ONU message handling canceled via context")
264 break loop
265 case message, ok := <-o.Channel:
266 if !ok || ctx.Err() != nil {
267 onuLogger.WithFields(log.Fields{
268 "onuID": o.ID,
269 "onuSN": o.Sn(),
270 }).Tracef("ONU message handling canceled via channel close")
271 break loop
Matteo Scandolo075b1892019-10-07 12:11:07 -0700272 }
David Bainbridge103cf022019-12-16 20:11:35 +0000273 onuLogger.WithFields(log.Fields{
274 "onuID": o.ID,
275 "onuSN": o.Sn(),
276 "messageType": message.Type,
277 }).Tracef("Received message on ONU Channel")
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700278
David Bainbridge103cf022019-12-16 20:11:35 +0000279 switch message.Type {
280 case OnuDiscIndication:
281 msg, _ := message.Data.(OnuDiscIndicationMessage)
282 // NOTE we need to slow down and send ONU Discovery Indication in batches to better emulate a real scenario
283 time.Sleep(time.Duration(int(o.ID)*o.PonPort.Olt.Delay) * time.Millisecond)
284 o.sendOnuDiscIndication(msg, stream)
285 case OnuIndication:
286 msg, _ := message.Data.(OnuIndicationMessage)
287 o.sendOnuIndication(msg, stream)
288 case OMCI:
289 msg, _ := message.Data.(OmciMessage)
290 o.handleOmciMessage(msg, stream)
291 case FlowUpdate:
292 msg, _ := message.Data.(OnuFlowUpdateMessage)
293 o.handleFlowUpdate(msg)
294 case StartEAPOL:
295 log.Infof("Receive StartEAPOL message on ONU Channel")
296 eapol.SendEapStart(o.ID, o.PonPortID, o.Sn(), o.PortNo, o.HwAddress, o.InternalState, stream)
297 case StartDHCP:
298 log.Infof("Receive StartDHCP message on ONU Channel")
299 // FIXME use id, ponId as SendEapStart
300 dhcp.SendDHCPDiscovery(o.PonPortID, o.ID, o.Sn(), o.PortNo, o.InternalState, o.HwAddress, o.CTag, stream)
301 case OnuPacketOut:
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700302
David Bainbridge103cf022019-12-16 20:11:35 +0000303 msg, _ := message.Data.(OnuPacketMessage)
304
305 log.WithFields(log.Fields{
306 "IntfId": msg.IntfId,
307 "OnuId": msg.OnuId,
308 "pktType": msg.Type,
309 }).Trace("Received OnuPacketOut Message")
310
311 if msg.Type == packetHandlers.EAPOL {
312 eapol.HandleNextPacket(msg.OnuId, msg.IntfId, o.Sn(), o.PortNo, o.InternalState, msg.Packet, stream, client)
313 } else if msg.Type == packetHandlers.DHCP {
314 // NOTE here we receive packets going from the DHCP Server to the ONU
315 // for now we expect them to be double-tagged, but ideally the should be single tagged
316 dhcp.HandleNextPacket(o.ID, o.PonPortID, o.Sn(), o.PortNo, o.HwAddress, o.CTag, o.InternalState, msg.Packet, stream)
317 }
318 case OnuPacketIn:
319 // NOTE we only receive BBR packets here.
320 // Eapol.HandleNextPacket can handle both BBSim and BBr cases so the call is the same
321 // in the DHCP case VOLTHA only act as a proxy, the behaviour is completely different thus we have a dhcp.HandleNextBbrPacket
322 msg, _ := message.Data.(OnuPacketMessage)
323
324 log.WithFields(log.Fields{
325 "IntfId": msg.IntfId,
326 "OnuId": msg.OnuId,
327 "pktType": msg.Type,
328 }).Trace("Received OnuPacketIn Message")
329
330 if msg.Type == packetHandlers.EAPOL {
331 eapol.HandleNextPacket(msg.OnuId, msg.IntfId, o.Sn(), o.PortNo, o.InternalState, msg.Packet, stream, client)
332 } else if msg.Type == packetHandlers.DHCP {
333 dhcp.HandleNextBbrPacket(o.ID, o.PonPortID, o.Sn(), o.STag, o.HwAddress, o.DoneChannel, msg.Packet, client)
334 }
335 case DyingGaspIndication:
336 msg, _ := message.Data.(DyingGaspIndicationMessage)
337 o.sendDyingGaspInd(msg, stream)
338 case OmciIndication:
339 msg, _ := message.Data.(OmciIndicationMessage)
340 o.handleOmci(msg, client)
341 case SendEapolFlow:
342 o.sendEapolFlow(client)
343 case SendDhcpFlow:
344 o.sendDhcpFlow(client)
345 default:
346 onuLogger.Warnf("Received unknown message data %v for type %v in OLT Channel", message.Data, message.Type)
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700347 }
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700348 }
349 }
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100350 onuLogger.WithFields(log.Fields{
351 "onuID": o.ID,
352 "onuSN": o.Sn(),
353 }).Debug("Stopped handling ONU Indication Channel")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700354}
355
William Kurkian0418bc82019-11-06 12:16:24 -0500356func (o *Onu) processOmciMessage(message omcisim.OmciChMessage) {
William Kurkian9dadc5b2019-10-22 13:51:57 -0400357 switch message.Type {
358 case omcisim.GemPortAdded:
359 log.WithFields(log.Fields{
360 "OnuId": message.Data.OnuId,
361 "IntfId": message.Data.IntfId,
362 }).Infof("GemPort Added")
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700363
William Kurkian9dadc5b2019-10-22 13:51:57 -0400364 // NOTE if we receive the GemPort but we don't have EAPOL flows
365 // go an intermediate state, otherwise start auth
366 if o.InternalState.Is("enabled") {
367 if err := o.InternalState.Event("add_gem_port"); err != nil {
368 log.Errorf("Can't go to gem_port_added: %v", err)
369 }
370 } else if o.InternalState.Is("eapol_flow_received") {
Matteo Scandolo3c656a12019-12-10 09:54:51 -0800371 if o.Auth == true {
372 if err := o.InternalState.Event("start_auth"); err != nil {
373 log.Warnf("Can't go to auth_started: %v", err)
374 }
375 } else {
376 onuLogger.WithFields(log.Fields{
377 "IntfId": o.PonPortID,
378 "OnuId": o.ID,
379 "SerialNumber": o.Sn(),
380 }).Warn("Not starting authentication as Auth bit is not set in CLI parameters")
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700381 }
382 }
383 }
384}
385
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100386func (o Onu) NewSN(oltid int, intfid uint32, onuid uint32) *openolt.SerialNumber {
Matteo Scandolo4747d292019-08-05 11:50:18 -0700387
388 sn := new(openolt.SerialNumber)
389
Matteo Scandolo47e69bb2019-08-28 15:41:12 -0700390 //sn = new(openolt.SerialNumber)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700391 sn.VendorId = []byte("BBSM")
392 sn.VendorSpecific = []byte{0, byte(oltid % 256), byte(intfid), byte(onuid)}
393
394 return sn
395}
396
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700397// NOTE handle_/process methods can change the ONU internal state as they are receiving messages
398// send method should not change the ONU state
399
William Kurkian0418bc82019-11-06 12:16:24 -0500400func (o *Onu) sendDyingGaspInd(msg DyingGaspIndicationMessage, stream openolt.Openolt_EnableIndicationServer) error {
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700401 alarmData := &openolt.AlarmIndication_DyingGaspInd{
402 DyingGaspInd: &openolt.DyingGaspIndication{
403 IntfId: msg.PonPortID,
404 OnuId: msg.OnuID,
405 Status: "on",
406 },
407 }
408 data := &openolt.Indication_AlarmInd{AlarmInd: &openolt.AlarmIndication{Data: alarmData}}
409
410 if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
411 onuLogger.Errorf("Failed to send DyingGaspInd : %v", err)
412 return err
413 }
414 onuLogger.WithFields(log.Fields{
415 "IntfId": msg.PonPortID,
416 "OnuSn": o.Sn(),
417 "OnuId": msg.OnuID,
418 }).Info("sendDyingGaspInd")
419 return nil
420}
421
William Kurkian0418bc82019-11-06 12:16:24 -0500422func (o *Onu) sendOnuDiscIndication(msg OnuDiscIndicationMessage, stream openolt.Openolt_EnableIndicationServer) {
Matteo Scandolo4747d292019-08-05 11:50:18 -0700423 discoverData := &openolt.Indication_OnuDiscInd{OnuDiscInd: &openolt.OnuDiscIndication{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700424 IntfId: msg.Onu.PonPortID,
Matteo Scandolo4747d292019-08-05 11:50:18 -0700425 SerialNumber: msg.Onu.SerialNumber,
426 }}
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700427
Matteo Scandolo4747d292019-08-05 11:50:18 -0700428 if err := stream.Send(&openolt.Indication{Data: discoverData}); err != nil {
Matteo Scandolo11006992019-08-28 11:29:46 -0700429 log.Errorf("Failed to send Indication_OnuDiscInd: %v", err)
Matteo Scandolo99f18462019-10-28 14:14:28 -0700430 return
Matteo Scandolo4747d292019-08-05 11:50:18 -0700431 }
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700432
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700433 onuLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -0700434 "IntfId": msg.Onu.PonPortID,
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700435 "OnuSn": msg.Onu.Sn(),
436 "OnuId": o.ID,
Matteo Scandolo4747d292019-08-05 11:50:18 -0700437 }).Debug("Sent Indication_OnuDiscInd")
Matteo Scandoloe811ae92019-12-10 17:50:14 -0800438
439 // after DiscoveryRetryDelay check if the state is the same and in case send a new OnuDiscIndication
440 go func(delay time.Duration) {
441 if o.InternalState.Current() == "discovered" {
442 time.Sleep(delay)
443 o.sendOnuDiscIndication(msg, stream)
444 }
445 }(o.DiscoveryRetryDelay)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700446}
447
William Kurkian0418bc82019-11-06 12:16:24 -0500448func (o *Onu) sendOnuIndication(msg OnuIndicationMessage, stream openolt.Openolt_EnableIndicationServer) {
Matteo Scandolo4747d292019-08-05 11:50:18 -0700449 // NOTE voltha returns an ID, but if we use that ID then it complains:
450 // expected_onu_id: 1, received_onu_id: 1024, event: ONU-id-mismatch, can happen if both voltha and the olt rebooted
451 // so we're using the internal ID that is 1
452 // o.ID = msg.OnuID
Matteo Scandolo4747d292019-08-05 11:50:18 -0700453
454 indData := &openolt.Indication_OnuInd{OnuInd: &openolt.OnuIndication{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700455 IntfId: o.PonPortID,
456 OnuId: o.ID,
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700457 OperState: msg.OperState.String(),
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700458 AdminState: o.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700459 SerialNumber: o.SerialNumber,
460 }}
461 if err := stream.Send(&openolt.Indication{Data: indData}); err != nil {
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700462 // TODO do we need to transition to a broken state?
Matteo Scandolo11006992019-08-28 11:29:46 -0700463 log.Errorf("Failed to send Indication_OnuInd: %v", err)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700464 }
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700465 onuLogger.WithFields(log.Fields{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700466 "IntfId": o.PonPortID,
467 "OnuId": o.ID,
468 "OperState": msg.OperState.String(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700469 "AdminState": msg.OperState.String(),
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700470 "OnuSn": o.Sn(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700471 }).Debug("Sent Indication_OnuInd")
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700472
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700473}
474
William Kurkian0418bc82019-11-06 12:16:24 -0500475func (o *Onu) handleOmciMessage(msg OmciMessage, stream openolt.Openolt_EnableIndicationServer) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700476
477 onuLogger.WithFields(log.Fields{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700478 "IntfId": o.PonPortID,
Matteo Scandolo27428702019-10-11 16:21:16 -0700479 "SerialNumber": o.Sn(),
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700480 "omciPacket": msg.omciMsg.Pkt,
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700481 }).Tracef("Received OMCI message")
482
483 var omciInd openolt.OmciIndication
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700484 respPkt, err := omcisim.OmciSim(o.PonPortID, o.ID, HexDecode(msg.omciMsg.Pkt))
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700485 if err != nil {
Matteo Scandolo27428702019-10-11 16:21:16 -0700486 onuLogger.WithFields(log.Fields{
487 "IntfId": o.PonPortID,
488 "SerialNumber": o.Sn(),
489 "omciPacket": omciInd.Pkt,
490 "msg": msg,
491 }).Errorf("Error handling OMCI message %v", msg)
492 return
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700493 }
494
495 omciInd.IntfId = o.PonPortID
496 omciInd.OnuId = o.ID
497 omciInd.Pkt = respPkt
498
499 omci := &openolt.Indication_OmciInd{OmciInd: &omciInd}
500 if err := stream.Send(&openolt.Indication{Data: omci}); err != nil {
Matteo Scandolo27428702019-10-11 16:21:16 -0700501 onuLogger.WithFields(log.Fields{
502 "IntfId": o.PonPortID,
503 "SerialNumber": o.Sn(),
504 "omciPacket": omciInd.Pkt,
505 "msg": msg,
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700506 }).Errorf("send omcisim indication failed: %v", err)
Matteo Scandolo27428702019-10-11 16:21:16 -0700507 return
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700508 }
509 onuLogger.WithFields(log.Fields{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700510 "IntfId": o.PonPortID,
Matteo Scandolo27428702019-10-11 16:21:16 -0700511 "SerialNumber": o.Sn(),
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700512 "omciPacket": omciInd.Pkt,
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700513 }).Tracef("Sent OMCI message")
514}
515
Matteo Scandolo27428702019-10-11 16:21:16 -0700516func (o *Onu) storePortNumber(portNo uint32) {
Matteo Scandolo813402b2019-10-23 19:24:52 -0700517 // NOTE this needed only as long as we don't support multiple UNIs
Matteo Scandolo27428702019-10-11 16:21:16 -0700518 // we need to add support for multiple UNIs
519 // the action plan is:
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700520 // - refactor the omcisim-sim library to use https://github.com/cboling/omci instead of canned messages
Matteo Scandolo27428702019-10-11 16:21:16 -0700521 // - change the library so that it reports a single UNI and remove this workaroung
522 // - add support for multiple UNIs in BBSim
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700523 if o.PortNo == 0 || portNo < o.PortNo {
Matteo Scandolo813402b2019-10-23 19:24:52 -0700524 onuLogger.WithFields(log.Fields{
525 "IntfId": o.PonPortID,
526 "OnuId": o.ID,
527 "SerialNumber": o.Sn(),
528 "OnuPortNo": o.PortNo,
529 "FlowPortNo": portNo,
530 }).Debug("Storing ONU portNo")
Matteo Scandolo27428702019-10-11 16:21:16 -0700531 o.PortNo = portNo
532 }
533}
534
William Kurkian0418bc82019-11-06 12:16:24 -0500535func (o *Onu) SetID(id uint32) {
536 o.ID = id
537}
538
Matteo Scandolo813402b2019-10-23 19:24:52 -0700539func (o *Onu) handleFlowUpdate(msg OnuFlowUpdateMessage) {
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700540 onuLogger.WithFields(log.Fields{
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700541 "DstPort": msg.Flow.Classifier.DstPort,
542 "EthType": fmt.Sprintf("%x", msg.Flow.Classifier.EthType),
543 "FlowId": msg.Flow.FlowId,
544 "FlowType": msg.Flow.FlowType,
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700545 "InnerVlan": msg.Flow.Classifier.IVid,
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700546 "IntfId": msg.Flow.AccessIntfId,
547 "IpProto": msg.Flow.Classifier.IpProto,
548 "OnuId": msg.Flow.OnuId,
549 "OnuSn": o.Sn(),
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700550 "OuterVlan": msg.Flow.Classifier.OVid,
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700551 "PortNo": msg.Flow.PortNo,
552 "SrcPort": msg.Flow.Classifier.SrcPort,
553 "UniID": msg.Flow.UniId,
554 }).Debug("ONU receives Flow")
555
Matteo Scandolo813402b2019-10-23 19:24:52 -0700556 if msg.Flow.UniId != 0 {
557 // as of now BBSim only support a single UNI, so ignore everything that is not targeted to it
558 onuLogger.WithFields(log.Fields{
559 "IntfId": o.PonPortID,
560 "OnuId": o.ID,
561 "SerialNumber": o.Sn(),
562 }).Debug("Ignoring flow as it's not for the first UNI")
563 return
564 }
565
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700566 if msg.Flow.Classifier.EthType == uint32(layers.EthernetTypeEAPOL) && msg.Flow.Classifier.OVid == 4091 {
Matteo Scandolo27428702019-10-11 16:21:16 -0700567 // NOTE storing the PortNO, it's needed when sending PacketIndications
Matteo Scandolo813402b2019-10-23 19:24:52 -0700568 o.storePortNumber(uint32(msg.Flow.PortNo))
Matteo Scandolo27428702019-10-11 16:21:16 -0700569
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700570 // NOTE if we receive the EAPOL flows but we don't have GemPorts
571 // go an intermediate state, otherwise start auth
572 if o.InternalState.Is("enabled") {
573 if err := o.InternalState.Event("receive_eapol_flow"); err != nil {
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700574 log.Warnf("Can't go to eapol_flow_received: %v", err)
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700575 }
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700576 } else if o.InternalState.Is("gem_port_added") {
Matteo Scandoloc1147092019-10-29 09:38:33 -0700577
578 if o.Auth == true {
579 if err := o.InternalState.Event("start_auth"); err != nil {
580 log.Warnf("Can't go to auth_started: %v", err)
581 }
582 } else {
583 onuLogger.WithFields(log.Fields{
584 "IntfId": o.PonPortID,
585 "OnuId": o.ID,
586 "SerialNumber": o.Sn(),
587 }).Warn("Not starting authentication as Auth bit is not set in CLI parameters")
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700588 }
Matteo Scandoloc1147092019-10-29 09:38:33 -0700589
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700590 }
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700591 } else if msg.Flow.Classifier.EthType == uint32(layers.EthernetTypeIPv4) &&
592 msg.Flow.Classifier.SrcPort == uint32(68) &&
593 msg.Flow.Classifier.DstPort == uint32(67) {
Matteo Scandolo99f18462019-10-28 14:14:28 -0700594
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100595 // keep track that we received the DHCP Flows so that we can transition the state to dhcp_started
Matteo Scandolo99f18462019-10-28 14:14:28 -0700596 o.DhcpFlowReceived = true
Matteo Scandoloc1147092019-10-29 09:38:33 -0700597
598 if o.Dhcp == true {
Zdravko Bozakov681364d2019-11-10 14:28:46 +0100599 // NOTE we are receiving multiple DHCP flows but we shouldn't call the transition multiple times
Matteo Scandoloc1147092019-10-29 09:38:33 -0700600 if err := o.InternalState.Event("start_dhcp"); err != nil {
601 log.Errorf("Can't go to dhcp_started: %v", err)
602 }
603 } else {
604 onuLogger.WithFields(log.Fields{
605 "IntfId": o.PonPortID,
606 "OnuId": o.ID,
607 "SerialNumber": o.Sn(),
608 }).Warn("Not starting DHCP as Dhcp bit is not set in CLI parameters")
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700609 }
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700610 }
611}
612
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700613// HexDecode converts the hex encoding to binary
614func HexDecode(pkt []byte) []byte {
615 p := make([]byte, len(pkt)/2)
616 for i, j := 0, 0; i < len(pkt); i, j = i+2, j+1 {
617 // Go figure this ;)
618 u := (pkt[i] & 15) + (pkt[i]>>6)*9
619 l := (pkt[i+1] & 15) + (pkt[i+1]>>6)*9
620 p[j] = u<<4 + l
621 }
622 onuLogger.Tracef("Omci decoded: %x.", p)
623 return p
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -0700624}
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700625
626// BBR methods
627
628func sendOmciMsg(pktBytes []byte, intfId uint32, onuId uint32, sn *openolt.SerialNumber, msgType string, client openolt.OpenoltClient) {
629 omciMsg := openolt.OmciMsg{
630 IntfId: intfId,
631 OnuId: onuId,
632 Pkt: pktBytes,
633 }
634
635 if _, err := client.OmciMsgOut(context.Background(), &omciMsg); err != nil {
636 log.WithFields(log.Fields{
637 "IntfId": intfId,
638 "OnuId": onuId,
639 "SerialNumber": common.OnuSnToString(sn),
640 "Pkt": omciMsg.Pkt,
641 }).Fatalf("Failed to send MIB Reset")
642 }
643 log.WithFields(log.Fields{
644 "IntfId": intfId,
645 "OnuId": onuId,
646 "SerialNumber": common.OnuSnToString(sn),
647 "Pkt": omciMsg.Pkt,
648 }).Tracef("Sent OMCI message %s", msgType)
649}
650
651func (onu *Onu) getNextTid(highPriority ...bool) uint16 {
652 var next uint16
653 if len(highPriority) > 0 && highPriority[0] {
654 next = onu.hpTid
655 onu.hpTid += 1
656 if onu.hpTid < 0x8000 {
657 onu.hpTid = 0x8000
658 }
659 } else {
660 next = onu.tid
661 onu.tid += 1
662 if onu.tid >= 0x8000 {
663 onu.tid = 1
664 }
665 }
666 return next
667}
668
669// TODO move this method in responders/omcisim
670func (o *Onu) StartOmci(client openolt.OpenoltClient) {
671 mibReset, _ := omcilib.CreateMibResetRequest(o.getNextTid(false))
672 sendOmciMsg(mibReset, o.PonPortID, o.ID, o.SerialNumber, "mibReset", client)
673}
674
675func (o *Onu) handleOmci(msg OmciIndicationMessage, client openolt.OpenoltClient) {
676 msgType, packet := omcilib.DecodeOmci(msg.OmciInd.Pkt)
677
678 log.WithFields(log.Fields{
679 "IntfId": msg.OmciInd.IntfId,
680 "OnuId": msg.OmciInd.OnuId,
681 "OnuSn": common.OnuSnToString(o.SerialNumber),
682 "Pkt": msg.OmciInd.Pkt,
683 "msgType": msgType,
684 }).Trace("ONU Receveives OMCI Msg")
685 switch msgType {
686 default:
Matteo Scandolo813402b2019-10-23 19:24:52 -0700687 log.WithFields(log.Fields{
688 "IntfId": msg.OmciInd.IntfId,
689 "OnuId": msg.OmciInd.OnuId,
690 "OnuSn": common.OnuSnToString(o.SerialNumber),
691 "Pkt": msg.OmciInd.Pkt,
692 "msgType": msgType,
693 }).Fatalf("unexpected frame: %v", packet)
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700694 case omci.MibResetResponseType:
695 mibUpload, _ := omcilib.CreateMibUploadRequest(o.getNextTid(false))
696 sendOmciMsg(mibUpload, o.PonPortID, o.ID, o.SerialNumber, "mibUpload", client)
697 case omci.MibUploadResponseType:
698 mibUploadNext, _ := omcilib.CreateMibUploadNextRequest(o.getNextTid(false), o.seqNumber)
699 sendOmciMsg(mibUploadNext, o.PonPortID, o.ID, o.SerialNumber, "mibUploadNext", client)
700 case omci.MibUploadNextResponseType:
701 o.seqNumber++
702
703 if o.seqNumber > 290 {
704 // NOTE we are done with the MIB Upload (290 is the number of messages the omci-sim library will respond to)
705 galEnet, _ := omcilib.CreateGalEnetRequest(o.getNextTid(false))
706 sendOmciMsg(galEnet, o.PonPortID, o.ID, o.SerialNumber, "CreateGalEnetRequest", client)
707 } else {
708 mibUploadNext, _ := omcilib.CreateMibUploadNextRequest(o.getNextTid(false), o.seqNumber)
709 sendOmciMsg(mibUploadNext, o.PonPortID, o.ID, o.SerialNumber, "mibUploadNext", client)
710 }
711 case omci.CreateResponseType:
712 // NOTE Creating a GemPort,
713 // BBsim actually doesn't care about the values, so we can do we want with the parameters
714 // In the same way we can create a GemPort even without setting up UNIs/TConts/...
715 // but we need the GemPort to trigger the state change
716
717 if !o.HasGemPort {
718 // NOTE this sends a CreateRequestType and BBSim replies with a CreateResponseType
719 // thus we send this request only once
720 gemReq, _ := omcilib.CreateGemPortRequest(o.getNextTid(false))
721 sendOmciMsg(gemReq, o.PonPortID, o.ID, o.SerialNumber, "CreateGemPortRequest", client)
722 o.HasGemPort = true
723 } else {
724 if err := o.InternalState.Event("send_eapol_flow"); err != nil {
725 onuLogger.WithFields(log.Fields{
726 "OnuId": o.ID,
727 "IntfId": o.PonPortID,
728 "OnuSn": o.Sn(),
729 }).Errorf("Error while transitioning ONU State %v", err)
730 }
731 }
732
733 }
734}
735
736func (o *Onu) sendEapolFlow(client openolt.OpenoltClient) {
737
738 classifierProto := openolt.Classifier{
739 EthType: uint32(layers.EthernetTypeEAPOL),
740 OVid: 4091,
741 }
742
743 actionProto := openolt.Action{}
744
745 downstreamFlow := openolt.Flow{
746 AccessIntfId: int32(o.PonPortID),
747 OnuId: int32(o.ID),
Matteo Scandolo813402b2019-10-23 19:24:52 -0700748 UniId: int32(0), // NOTE do not hardcode this, we need to support multiple UNIs
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700749 FlowId: uint32(o.ID),
750 FlowType: "downstream",
751 AllocId: int32(0),
752 NetworkIntfId: int32(0),
753 GemportId: int32(1), // FIXME use the same value as CreateGemPortRequest PortID, do not hardcode
754 Classifier: &classifierProto,
755 Action: &actionProto,
756 Priority: int32(100),
757 Cookie: uint64(o.ID),
758 PortNo: uint32(o.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
759 }
760
761 if _, err := client.FlowAdd(context.Background(), &downstreamFlow); err != nil {
762 log.WithFields(log.Fields{
763 "IntfId": o.PonPortID,
764 "OnuId": o.ID,
765 "FlowId": downstreamFlow.FlowId,
766 "PortNo": downstreamFlow.PortNo,
767 "SerialNumber": common.OnuSnToString(o.SerialNumber),
768 }).Fatalf("Failed to EAPOL Flow")
769 }
770 log.WithFields(log.Fields{
771 "IntfId": o.PonPortID,
772 "OnuId": o.ID,
773 "FlowId": downstreamFlow.FlowId,
774 "PortNo": downstreamFlow.PortNo,
775 "SerialNumber": common.OnuSnToString(o.SerialNumber),
776 }).Info("Sent EAPOL Flow")
777}
778
779func (o *Onu) sendDhcpFlow(client openolt.OpenoltClient) {
780 classifierProto := openolt.Classifier{
781 EthType: uint32(layers.EthernetTypeIPv4),
782 SrcPort: uint32(68),
783 DstPort: uint32(67),
784 }
785
786 actionProto := openolt.Action{}
787
788 downstreamFlow := openolt.Flow{
789 AccessIntfId: int32(o.PonPortID),
790 OnuId: int32(o.ID),
Matteo Scandolo813402b2019-10-23 19:24:52 -0700791 UniId: int32(0), // FIXME do not hardcode this
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700792 FlowId: uint32(o.ID),
793 FlowType: "downstream",
794 AllocId: int32(0),
795 NetworkIntfId: int32(0),
796 GemportId: int32(1), // FIXME use the same value as CreateGemPortRequest PortID, do not hardcode
797 Classifier: &classifierProto,
798 Action: &actionProto,
799 Priority: int32(100),
800 Cookie: uint64(o.ID),
801 PortNo: uint32(o.ID), // NOTE we are using this to map an incoming packetIndication to an ONU
802 }
803
804 if _, err := client.FlowAdd(context.Background(), &downstreamFlow); err != nil {
805 log.WithFields(log.Fields{
806 "IntfId": o.PonPortID,
807 "OnuId": o.ID,
808 "FlowId": downstreamFlow.FlowId,
809 "PortNo": downstreamFlow.PortNo,
810 "SerialNumber": common.OnuSnToString(o.SerialNumber),
811 }).Fatalf("Failed to send DHCP Flow")
812 }
813 log.WithFields(log.Fields{
814 "IntfId": o.PonPortID,
815 "OnuId": o.ID,
816 "FlowId": downstreamFlow.FlowId,
817 "PortNo": downstreamFlow.PortNo,
818 "SerialNumber": common.OnuSnToString(o.SerialNumber),
819 }).Info("Sent DHCP Flow")
820}