blob: 1d45ef737bbdf096a1a1a52d35394c2cb191abb0 [file] [log] [blame]
Matteo Scandolo4a036262020-08-17 15:56:13 -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 Scandolo618a6582020-09-09 12:21:29 -070020 "encoding/hex"
Matteo Scandolo4a036262020-08-17 15:56:13 -070021 "github.com/looplab/fsm"
22 "github.com/opencord/bbsim/internal/bbsim/packetHandlers"
23 "github.com/opencord/bbsim/internal/bbsim/responders/dhcp"
24 "github.com/opencord/bbsim/internal/bbsim/responders/eapol"
Matteo Scandolo618a6582020-09-09 12:21:29 -070025 "github.com/opencord/bbsim/internal/bbsim/responders/igmp"
Matteo Scandolo4a036262020-08-17 15:56:13 -070026 bbsimTypes "github.com/opencord/bbsim/internal/bbsim/types"
27 log "github.com/sirupsen/logrus"
28 "net"
29)
30
31var serviceLogger = log.WithFields(log.Fields{
32 "module": "SERVICE",
33})
34
35type ServiceIf interface {
Matteo Scandoloadc72a82020-09-08 18:46:08 -070036 HandlePackets() // start listening on the PacketCh
37 HandleAuth() // Sends the EapoStart packet
38 HandleDhcp(cTag int) // Sends the DHCPDiscover packet
Matteo Scandolo75ed5b92020-09-03 09:03:16 -070039
Matteo Scandoloadc72a82020-09-08 18:46:08 -070040 Initialize(stream bbsimTypes.Stream)
Matteo Scandolo75ed5b92020-09-03 09:03:16 -070041 Disable()
Matteo Scandolo4a036262020-08-17 15:56:13 -070042}
43
44type Service struct {
45 Name string
46 HwAddress net.HardwareAddr
47 Onu *Onu
48 CTag int
49 STag int
50 NeedsEapol bool
51 NeedsDhcp bool
52 NeedsIgmp bool
53 TechnologyProfileID int
54 UniTagMatch int
55 ConfigureMacAddress bool
Matteo Scandolo8d281372020-09-03 16:23:37 -070056 UsPonCTagPriority uint8
57 UsPonSTagPriority uint8
58 DsPonCTagPriority uint8
59 DsPonSTagPriority uint8
Matteo Scandolo4a036262020-08-17 15:56:13 -070060
61 // state
Matteo Scandolo75ed5b92020-09-03 09:03:16 -070062 GemPort uint32
63 InternalState *fsm.FSM
64 EapolState *fsm.FSM
65 DHCPState *fsm.FSM
Matteo Scandolo618a6582020-09-09 12:21:29 -070066 IGMPState *fsm.FSM
Matteo Scandoloadc72a82020-09-08 18:46:08 -070067 Channel chan Message // drive Service lifecycle
68 PacketCh chan OnuPacketMessage // handle packets
69 Stream bbsimTypes.Stream // the gRPC stream to communicate with the adapter, created in the initialize transition
Matteo Scandolo4a036262020-08-17 15:56:13 -070070}
71
72func NewService(name string, hwAddress net.HardwareAddr, onu *Onu, cTag int, sTag int,
73 needsEapol bool, needsDchp bool, needsIgmp bool, tpID int, uniTagMatch int, configMacAddress bool,
Matteo Scandolo8d281372020-09-03 16:23:37 -070074 usPonCTagPriority uint8, usPonSTagPriority uint8, dsPonCTagPriority uint8, dsPonSTagPriority uint8) (*Service, error) {
Matteo Scandolo4a036262020-08-17 15:56:13 -070075
76 service := Service{
77 Name: name,
78 HwAddress: hwAddress,
79 Onu: onu,
80 CTag: cTag,
81 STag: sTag,
82 NeedsEapol: needsEapol,
83 NeedsDhcp: needsDchp,
84 NeedsIgmp: needsIgmp,
85 TechnologyProfileID: tpID,
86 UniTagMatch: uniTagMatch,
87 ConfigureMacAddress: configMacAddress,
88 UsPonCTagPriority: usPonCTagPriority,
89 UsPonSTagPriority: usPonSTagPriority,
90 DsPonCTagPriority: dsPonCTagPriority,
91 DsPonSTagPriority: dsPonSTagPriority,
Matteo Scandolo4a036262020-08-17 15:56:13 -070092 }
93
Matteo Scandolo75ed5b92020-09-03 09:03:16 -070094 service.InternalState = fsm.NewFSM(
95 "created",
96 fsm.Events{
97 {Name: "initialized", Src: []string{"created", "disabled"}, Dst: "initialized"},
98 {Name: "disabled", Src: []string{"initialized"}, Dst: "disabled"},
99 },
100 fsm.Callbacks{
101 "enter_state": func(e *fsm.Event) {
102 service.logStateChange("InternalState", e.Src, e.Dst)
103 },
104 "enter_initialized": func(e *fsm.Event) {
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700105
106 stream, ok := e.Args[0].(bbsimTypes.Stream)
107 if !ok {
108 serviceLogger.Fatal("initialize invoke with wrong arguments")
109 }
110
111 service.Stream = stream
112
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700113 service.PacketCh = make(chan OnuPacketMessage)
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700114 service.Channel = make(chan Message)
115
116 go service.HandlePackets()
117 go service.HandleChannel()
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700118 },
119 "enter_disabled": func(e *fsm.Event) {
120 // reset the state machines
121 service.EapolState.SetState("created")
122 service.DHCPState.SetState("created")
123
124 // stop listening for packets
125 close(service.PacketCh)
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700126 close(service.Channel)
127
128 service.PacketCh = nil
129 service.Channel = nil
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700130 },
131 },
132 )
133
Matteo Scandolo4a036262020-08-17 15:56:13 -0700134 service.EapolState = fsm.NewFSM(
135 "created",
136 fsm.Events{
137 {Name: "start_auth", Src: []string{"created", "eap_start_sent", "eap_response_identity_sent", "eap_response_challenge_sent", "eap_response_success_received", "auth_failed"}, Dst: "auth_started"},
138 {Name: "eap_start_sent", Src: []string{"auth_started"}, Dst: "eap_start_sent"},
139 {Name: "eap_response_identity_sent", Src: []string{"eap_start_sent"}, Dst: "eap_response_identity_sent"},
140 {Name: "eap_response_challenge_sent", Src: []string{"eap_response_identity_sent"}, Dst: "eap_response_challenge_sent"},
141 {Name: "eap_response_success_received", Src: []string{"eap_response_challenge_sent"}, Dst: "eap_response_success_received"},
142 {Name: "auth_failed", Src: []string{"auth_started", "eap_start_sent", "eap_response_identity_sent", "eap_response_challenge_sent"}, Dst: "auth_failed"},
143 },
144 fsm.Callbacks{
145 "enter_state": func(e *fsm.Event) {
146 service.logStateChange("EapolState", e.Src, e.Dst)
147 },
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700148 "before_start_auth": func(e *fsm.Event) {
149 msg := Message{
150 Type: StartEAPOL,
151 }
152 service.Channel <- msg
153 },
Matteo Scandolo4a036262020-08-17 15:56:13 -0700154 },
155 )
156
157 service.DHCPState = fsm.NewFSM(
158 "created",
159 fsm.Events{
Matteo Scandolo7f656fb2020-09-08 15:18:15 -0700160 // TODO only allow transitions to dhcp_start from success or failure, not in-between states
161 // TODO forcefully fail DHCP if we don't get an ack in X seconds
162 {Name: "start_dhcp", Src: []string{"created", "dhcp_discovery_sent", "dhcp_request_sent", "dhcp_ack_received", "dhcp_failed"}, Dst: "dhcp_started"},
Matteo Scandolo4a036262020-08-17 15:56:13 -0700163 {Name: "dhcp_discovery_sent", Src: []string{"dhcp_started"}, Dst: "dhcp_discovery_sent"},
164 {Name: "dhcp_request_sent", Src: []string{"dhcp_discovery_sent"}, Dst: "dhcp_request_sent"},
165 {Name: "dhcp_ack_received", Src: []string{"dhcp_request_sent"}, Dst: "dhcp_ack_received"},
166 {Name: "dhcp_failed", Src: []string{"dhcp_started", "dhcp_discovery_sent", "dhcp_request_sent"}, Dst: "dhcp_failed"},
167 },
168 fsm.Callbacks{
169 "enter_state": func(e *fsm.Event) {
170 service.logStateChange("DHCPState", e.Src, e.Dst)
171 },
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700172 "before_start_dhcp": func(e *fsm.Event) {
173 msg := Message{
174 Type: StartDHCP,
175 }
176 service.Channel <- msg
177 },
Matteo Scandolo4a036262020-08-17 15:56:13 -0700178 },
179 )
180
Matteo Scandolo618a6582020-09-09 12:21:29 -0700181 service.IGMPState = fsm.NewFSM(
182 "created",
183 fsm.Events{
184 {Name: "igmp_join_start", Src: []string{"created", "igmp_left", "igmp_join_error", "igmp_join_started"}, Dst: "igmp_join_started"},
185 {Name: "igmp_join_startv3", Src: []string{"igmp_left", "igmp_join_error", "igmp_join_started"}, Dst: "igmp_join_started"},
186 {Name: "igmp_join_error", Src: []string{"igmp_join_started"}, Dst: "igmp_join_error"},
187 {Name: "igmp_leave", Src: []string{"igmp_join_started"}, Dst: "igmp_left"},
188 },
189 fsm.Callbacks{
190 "igmp_join_start": func(e *fsm.Event) {
191 msg := Message{
192 Type: IGMPMembershipReportV2,
193 }
194 service.Channel <- msg
195 },
196 "igmp_leave": func(e *fsm.Event) {
197 msg := Message{
198 Type: IGMPLeaveGroup}
199 service.Channel <- msg
200 },
201 "igmp_join_startv3": func(e *fsm.Event) {
202 msg := Message{
203 Type: IGMPMembershipReportV3,
204 }
205 service.Channel <- msg
206 },
207 },
208 )
209
Matteo Scandolo4a036262020-08-17 15:56:13 -0700210 return &service, nil
211}
212
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700213// HandleAuth is used to start EAPOL for a particular Service when the corresponding flow is received
214func (s *Service) HandleAuth() {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700215
216 if !s.NeedsEapol {
217 serviceLogger.WithFields(log.Fields{
218 "OnuId": s.Onu.ID,
219 "IntfId": s.Onu.PonPortID,
220 "OnuSn": s.Onu.Sn(),
221 "Name": s.Name,
222 "NeedsEapol": s.NeedsEapol,
223 }).Debug("Won't start authentication as EAPOL is not required")
224 return
225 }
226
Matteo Scandolo4a036262020-08-17 15:56:13 -0700227 if err := s.EapolState.Event("start_auth"); err != nil {
228 serviceLogger.WithFields(log.Fields{
229 "OnuId": s.Onu.ID,
230 "IntfId": s.Onu.PonPortID,
231 "OnuSn": s.Onu.Sn(),
232 "Name": s.Name,
233 "err": err.Error(),
234 }).Error("Can't start auth for this Service")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700235 }
236}
237
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700238// HandleDhcp is used to start DHCP for a particular Service when the corresponding flow is received
239func (s *Service) HandleDhcp(cTag int) {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700240
Matteo Scandolo4a036262020-08-17 15:56:13 -0700241 if s.CTag != cTag {
242 serviceLogger.WithFields(log.Fields{
243 "OnuId": s.Onu.ID,
244 "IntfId": s.Onu.PonPortID,
245 "OnuSn": s.Onu.Sn(),
246 "Name": s.Name,
Matteo Scandolo7f656fb2020-09-08 15:18:15 -0700247 }).Trace("DHCP flow is not for this service, ignoring")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700248 return
249 }
250
Matteo Scandolo4a036262020-08-17 15:56:13 -0700251 if !s.NeedsDhcp {
252 serviceLogger.WithFields(log.Fields{
253 "OnuId": s.Onu.ID,
254 "IntfId": s.Onu.PonPortID,
255 "OnuSn": s.Onu.Sn(),
256 "Name": s.Name,
257 "NeedsDhcp": s.NeedsDhcp,
Matteo Scandolo7f656fb2020-09-08 15:18:15 -0700258 }).Trace("Won't start DHCP as it is not required")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700259 return
260 }
261
Matteo Scandolo7f656fb2020-09-08 15:18:15 -0700262 // TODO check if the DHCP flow was received before starting auth
Matteo Scandolo4a036262020-08-17 15:56:13 -0700263
264 if err := s.DHCPState.Event("start_dhcp"); err != nil {
265 serviceLogger.WithFields(log.Fields{
266 "OnuId": s.Onu.ID,
267 "IntfId": s.Onu.PonPortID,
268 "OnuSn": s.Onu.Sn(),
269 "Name": s.Name,
270 "err": err.Error(),
271 }).Error("Can't start DHCP for this Service")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700272 }
273}
274
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700275func (s *Service) HandlePackets() {
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700276 serviceLogger.WithFields(log.Fields{
277 "OnuId": s.Onu.ID,
278 "IntfId": s.Onu.PonPortID,
279 "OnuSn": s.Onu.Sn(),
280 "GemPortId": s.GemPort,
281 "Name": s.Name,
282 }).Debug("Listening on Service Packet Channel")
283
284 defer func() {
285 serviceLogger.WithFields(log.Fields{
286 "OnuId": s.Onu.ID,
287 "IntfId": s.Onu.PonPortID,
288 "OnuSn": s.Onu.Sn(),
289 "GemPortId": s.GemPort,
290 "Name": s.Name,
291 }).Debug("Done Listening on Service Packet Channel")
292 }()
293
294 for msg := range s.PacketCh {
295 serviceLogger.WithFields(log.Fields{
296 "OnuId": s.Onu.ID,
297 "IntfId": s.Onu.PonPortID,
298 "OnuSn": s.Onu.Sn(),
299 "Name": s.Name,
300 "messageType": msg.Type,
Matteo Scandolo7f656fb2020-09-08 15:18:15 -0700301 }).Trace("Received message on Service Packet Channel")
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700302
303 if msg.Type == packetHandlers.EAPOL {
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700304 eapol.HandleNextPacket(msg.OnuId, msg.IntfId, s.GemPort, s.Onu.Sn(), s.Onu.PortNo, s.EapolState, msg.Packet, s.Stream, nil)
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700305 } else if msg.Type == packetHandlers.DHCP {
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700306 _ = dhcp.HandleNextPacket(s.Onu.PonPort.Olt.ID, s.Onu.ID, s.Onu.PonPortID, s.Name, s.Onu.Sn(), s.Onu.PortNo, s.CTag, s.GemPort, s.HwAddress, s.DHCPState, msg.Packet, s.UsPonCTagPriority, s.Stream)
Matteo Scandolo618a6582020-09-09 12:21:29 -0700307 } else if msg.Type == packetHandlers.IGMP {
308 log.Warn(hex.EncodeToString(msg.Packet.Data()))
309 _ = igmp.HandleNextPacket(s.Onu.PonPortID, s.Onu.ID, s.Onu.Sn(), s.Onu.PortNo, s.GemPort, s.HwAddress, msg.Packet, s.CTag, s.UsPonCTagPriority, s.Stream)
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700310 }
311 }
312}
313
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700314func (s *Service) HandleChannel() {
315 serviceLogger.WithFields(log.Fields{
316 "OnuId": s.Onu.ID,
317 "IntfId": s.Onu.PonPortID,
318 "OnuSn": s.Onu.Sn(),
319 "GemPortId": s.GemPort,
320 "Name": s.Name,
321 }).Debug("Listening on Service Channel")
322
323 defer func() {
324 serviceLogger.WithFields(log.Fields{
325 "OnuId": s.Onu.ID,
326 "IntfId": s.Onu.PonPortID,
327 "OnuSn": s.Onu.Sn(),
328 "GemPortId": s.GemPort,
329 "Name": s.Name,
330 }).Debug("Done Listening on Service Channel")
331 }()
332 for msg := range s.Channel {
Matteo Scandolo618a6582020-09-09 12:21:29 -0700333 switch msg.Type {
334 case StartEAPOL:
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700335 if err := s.handleEapolStart(s.Stream); err != nil {
336 serviceLogger.WithFields(log.Fields{
337 "OnuId": s.Onu.ID,
338 "IntfId": s.Onu.PonPortID,
339 "OnuSn": s.Onu.Sn(),
340 "Name": s.Name,
341 "err": err,
342 }).Error("Error while sending EapolStart packet")
343 _ = s.EapolState.Event("auth_failed")
344 }
Matteo Scandolo618a6582020-09-09 12:21:29 -0700345 case StartDHCP:
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700346 if err := s.handleDHCPStart(s.Stream); err != nil {
347 serviceLogger.WithFields(log.Fields{
348 "OnuId": s.Onu.ID,
349 "IntfId": s.Onu.PonPortID,
350 "OnuSn": s.Onu.Sn(),
351 "Name": s.Name,
352 "err": err,
353 }).Error("Error while sending DHCPDiscovery packet")
354 _ = s.DHCPState.Event("dhcp_failed")
Matteo Scandolo618a6582020-09-09 12:21:29 -0700355
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700356 }
Matteo Scandolo618a6582020-09-09 12:21:29 -0700357 case IGMPMembershipReportV2:
358 serviceLogger.WithFields(log.Fields{
359 "OnuId": s.Onu.ID,
360 "IntfId": s.Onu.PonPortID,
361 "OnuSn": s.Onu.Sn(),
362 "Name": s.Name,
363 }).Debug("Recieved IGMPMembershipReportV2 message on ONU channel")
364 _ = igmp.SendIGMPMembershipReportV2(s.Onu.PonPortID, s.Onu.ID, s.Onu.Sn(), s.Onu.PortNo, s.GemPort, s.HwAddress, s.CTag, s.UsPonCTagPriority, s.Stream)
365 case IGMPLeaveGroup:
366 serviceLogger.WithFields(log.Fields{
367 "OnuId": s.Onu.ID,
368 "IntfId": s.Onu.PonPortID,
369 "OnuSn": s.Onu.Sn(),
370 "Name": s.Name,
371 }).Debug("Recieved IGMPLeaveGroupV2 message on ONU channel")
372 _ = igmp.SendIGMPLeaveGroupV2(s.Onu.PonPortID, s.Onu.ID, s.Onu.Sn(), s.Onu.PortNo, s.GemPort, s.HwAddress, s.CTag, s.UsPonCTagPriority, s.Stream)
373 case IGMPMembershipReportV3:
374 serviceLogger.WithFields(log.Fields{
375 "OnuId": s.Onu.ID,
376 "IntfId": s.Onu.PonPortID,
377 "OnuSn": s.Onu.Sn(),
378 "Name": s.Name,
379 }).Debug("Recieved IGMPMembershipReportV3 message on ONU channel")
380 _ = igmp.SendIGMPMembershipReportV3(s.Onu.PonPortID, s.Onu.ID, s.Onu.Sn(), s.Onu.PortNo, s.GemPort, s.HwAddress, s.CTag, s.UsPonCTagPriority, s.Stream)
381
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700382 }
383 }
384}
385
386func (s *Service) Initialize(stream bbsimTypes.Stream) {
387 if err := s.InternalState.Event("initialized", stream); err != nil {
Matteo Scandolo75ed5b92020-09-03 09:03:16 -0700388 serviceLogger.WithFields(log.Fields{
389 "OnuId": s.Onu.ID,
390 "IntfId": s.Onu.PonPortID,
391 "OnuSn": s.Onu.Sn(),
392 "Name": s.Name,
393 "Err": err,
394 }).Error("Cannot initialize service")
395 }
396}
397
398func (s *Service) Disable() {
399 if err := s.InternalState.Event("disabled"); err != nil {
400 serviceLogger.WithFields(log.Fields{
401 "OnuId": s.Onu.ID,
402 "IntfId": s.Onu.PonPortID,
403 "OnuSn": s.Onu.Sn(),
404 "Name": s.Name,
405 "Err": err,
406 }).Error("Cannot disable service")
407 }
408}
409
Matteo Scandolo4a036262020-08-17 15:56:13 -0700410func (s *Service) handleEapolStart(stream bbsimTypes.Stream) error {
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700411 // TODO fail Auth if it does not succeed in 30 seconds
Matteo Scandolo4a036262020-08-17 15:56:13 -0700412 serviceLogger.WithFields(log.Fields{
413 "OnuId": s.Onu.ID,
414 "IntfId": s.Onu.PonPortID,
415 "OnuSn": s.Onu.Sn(),
416 "GemPort": s.GemPort,
417 "Name": s.Name,
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700418 }).Trace("handleEapolStart")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700419
420 if err := eapol.SendEapStart(s.Onu.ID, s.Onu.PonPortID, s.Onu.Sn(), s.Onu.PortNo,
421 s.HwAddress, s.GemPort, s.EapolState, stream); err != nil {
422 serviceLogger.WithFields(log.Fields{
423 "OnuId": s.Onu.ID,
424 "IntfId": s.Onu.PonPortID,
425 "OnuSn": s.Onu.Sn(),
426 "GemPort": s.GemPort,
427 "Name": s.Name,
428 }).Error("handleEapolStart")
429 return err
430 }
431 return nil
432}
433
434func (s *Service) handleDHCPStart(stream bbsimTypes.Stream) error {
Matteo Scandoloadc72a82020-09-08 18:46:08 -0700435 // TODO fail DHCP if it does not succeed in 30 seconds
Matteo Scandolo4a036262020-08-17 15:56:13 -0700436 serviceLogger.WithFields(log.Fields{
437 "OnuId": s.Onu.ID,
438 "IntfId": s.Onu.PonPortID,
439 "OnuSn": s.Onu.Sn(),
440 "Name": s.Name,
441 "GemPortId": s.GemPort,
442 }).Debugf("HandleDHCPStart")
443
Matteo Scandolo7f656fb2020-09-08 15:18:15 -0700444 if err := dhcp.SendDHCPDiscovery(s.Onu.PonPort.Olt.ID, s.Onu.PonPortID, s.Onu.ID, s.Name, int(s.CTag), s.GemPort,
Matteo Scandolo8d281372020-09-03 16:23:37 -0700445 s.Onu.Sn(), s.Onu.PortNo, s.DHCPState, s.HwAddress, s.UsPonCTagPriority, stream); err != nil {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700446 serviceLogger.WithFields(log.Fields{
447 "OnuId": s.Onu.ID,
448 "IntfId": s.Onu.PonPortID,
449 "OnuSn": s.Onu.Sn(),
450 "Name": s.Name,
451 "GemPortId": s.GemPort,
452 }).Error("HandleDHCPStart")
453 return err
454 }
455 return nil
456}
457
Matteo Scandolo4a036262020-08-17 15:56:13 -0700458func (s *Service) logStateChange(stateMachine string, src string, dst string) {
459 serviceLogger.WithFields(log.Fields{
460 "OnuId": s.Onu.ID,
461 "IntfId": s.Onu.PonPortID,
462 "OnuSn": s.Onu.Sn(),
463 "Name": s.Name,
464 }).Debugf("Changing Service.%s InternalState from %s to %s", stateMachine, src, dst)
465}