Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package core |
| 18 | |
| 19 | import ( |
Matteo Scandolo | 88e9189 | 2018-11-06 16:29:19 -0800 | [diff] [blame] | 20 | "net" |
| 21 | |
| 22 | "gerrit.opencord.org/voltha-bbsim/common/logger" |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 23 | "gerrit.opencord.org/voltha-bbsim/common/utils" |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 24 | "gerrit.opencord.org/voltha-bbsim/device" |
Mahir Gunyel | 9897f6e | 2019-05-22 14:54:05 -0700 | [diff] [blame] | 25 | "gerrit.opencord.org/voltha-bbsim/protos" |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 26 | "github.com/google/gopacket" |
| 27 | "github.com/google/gopacket/layers" |
Keita NISHIMOTO | 7bce769 | 2019-01-19 09:31:09 +0900 | [diff] [blame] | 28 | omci "github.com/opencord/omci-sim" |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 29 | log "github.com/sirupsen/logrus" |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 30 | "golang.org/x/net/context" |
| 31 | "google.golang.org/grpc" |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 32 | "google.golang.org/grpc/codes" |
| 33 | "google.golang.org/grpc/status" |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 34 | ) |
| 35 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 36 | // DisableOlt method sends OLT down indication |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 37 | func (s *Server) DisableOlt(c context.Context, empty *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 38 | logger.Debug("OLT receives DisableOLT()") |
Keita NISHIMOTO | b841749 | 2018-10-19 17:37:38 +0900 | [diff] [blame] | 39 | if s.EnableServer != nil { |
| 40 | if err := sendOltIndDown(*s.EnableServer); err != nil { |
| 41 | return new(openolt.Empty), err |
| 42 | } |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 43 | logger.Debug("Successfuly sent OLT DOWN indication") |
Keita NISHIMOTO | 9c6f6f1 | 2018-10-18 04:56:34 +0900 | [diff] [blame] | 44 | } |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 45 | return new(openolt.Empty), nil |
| 46 | } |
| 47 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 48 | // ReenableOlt method sends OLT up indication for re-enabling OLT |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 49 | func (s *Server) ReenableOlt(c context.Context, empty *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 50 | logger.Debug("OLT receives Reenable()") |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 51 | if s.EnableServer != nil { |
| 52 | if err := sendOltIndUp(*s.EnableServer, s.Olt); err != nil { |
| 53 | logger.Error("Failed to send OLT UP indication for reenable OLT: %v", err) |
| 54 | return new(openolt.Empty), err |
| 55 | } |
| 56 | logger.Debug("Successfuly sent OLT UP indication") |
| 57 | } |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 58 | return new(openolt.Empty), nil |
| 59 | } |
| 60 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 61 | // CollectStatistics method invoked by VOLTHA to get OLT statistics |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 62 | func (s *Server) CollectStatistics(c context.Context, empty *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 63 | logger.Debug("OLT receives CollectStatistics()") |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 64 | return new(openolt.Empty), nil |
| 65 | } |
| 66 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 67 | // GetDeviceInfo returns OLT info |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 68 | func (s *Server) GetDeviceInfo(c context.Context, empty *openolt.Empty) (*openolt.DeviceInfo, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 69 | logger.Debug("OLT receives GetDeviceInfo()") |
| 70 | devinfo := new(openolt.DeviceInfo) |
| 71 | devinfo.Vendor = "EdgeCore" |
| 72 | devinfo.Model = "asfvolt16" |
| 73 | devinfo.HardwareVersion = "" |
| 74 | devinfo.FirmwareVersion = "" |
| 75 | devinfo.Technology = "xgspon" |
Shad Ansari | 704c6f2 | 2018-11-13 14:57:53 -0800 | [diff] [blame] | 76 | devinfo.PonPorts = 16 |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 77 | devinfo.OnuIdStart = 1 |
| 78 | devinfo.OnuIdEnd = 255 |
| 79 | devinfo.AllocIdStart = 1024 |
| 80 | devinfo.AllocIdEnd = 16383 |
| 81 | devinfo.GemportIdStart = 1024 |
| 82 | devinfo.GemportIdEnd = 65535 |
| 83 | devinfo.FlowIdStart = 1 |
| 84 | devinfo.FlowIdEnd = 16383 |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 85 | devinfo.DeviceSerialNumber = s.Olt.SerialNumber |
Shad Ansari | 010c194 | 2018-11-08 09:32:24 -0800 | [diff] [blame] | 86 | |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 87 | return devinfo, nil |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 88 | } |
| 89 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 90 | // ActivateOnu method handles ONU activation request from VOLTHA |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 91 | func (s *Server) ActivateOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 92 | logger.Debug("OLT receives ActivateONU()") |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 93 | |
| 94 | matched, err := getOnuBySN(s.Onumap, onu.SerialNumber) |
| 95 | if err != nil { |
| 96 | logger.Fatal("%s", err) |
| 97 | return new(openolt.Empty), status.Errorf(codes.NotFound, "ONU not found with serial number %v", onu.SerialNumber) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 98 | } |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 99 | onuid := onu.OnuId |
| 100 | matched.OnuID = onuid |
| 101 | s.updateDevIntState(matched, device.ONU_ACTIVE) |
Mahir Gunyel | 9897f6e | 2019-05-22 14:54:05 -0700 | [diff] [blame] | 102 | s.Activate(matched) |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 103 | logger.Debug("ONU IntfID: %d OnuID: %d activated succesufully.", onu.IntfId, onu.OnuId) |
| 104 | |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 105 | return new(openolt.Empty), nil |
| 106 | } |
| 107 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 108 | // CreateTconts method should handle Tcont creation |
Shad Ansari | fd29844 | 2019-01-08 16:19:35 -0800 | [diff] [blame] | 109 | func (s *Server) CreateTconts(c context.Context, tconts *openolt.Tconts) (*openolt.Empty, error) { |
| 110 | logger.Debug("OLT receives CreateTconts()") |
| 111 | return new(openolt.Empty), nil |
| 112 | } |
| 113 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 114 | // RemoveTconts method should handle t-cont removal |
Shad Ansari | fd29844 | 2019-01-08 16:19:35 -0800 | [diff] [blame] | 115 | func (s *Server) RemoveTconts(c context.Context, tconts *openolt.Tconts) (*openolt.Empty, error) { |
| 116 | logger.Debug("OLT receives RemoveTconts()") |
| 117 | return new(openolt.Empty), nil |
| 118 | } |
| 119 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 120 | // DeactivateOnu method should handle ONU deactivation |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 121 | func (s *Server) DeactivateOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 122 | logger.Debug("OLT receives DeactivateONU()") |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 123 | return new(openolt.Empty), nil |
| 124 | } |
| 125 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 126 | // DeleteOnu handles ONU deletion request from VOLTHA |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 127 | func (s *Server) DeleteOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 128 | logger.Debug("OLT receives DeleteONU()") |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 129 | Onu, err := s.GetOnuByID(onu.OnuId, onu.IntfId) |
| 130 | if err != nil { |
| 131 | return new(openolt.Empty), err |
| 132 | } |
| 133 | |
| 134 | // Mark ONU internal state as ONU_FREE and reset onuID |
| 135 | Onu.InternalState = device.ONU_FREE |
| 136 | Onu.OnuID = 0 |
| 137 | |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 138 | return new(openolt.Empty), nil |
| 139 | } |
| 140 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 141 | // OmciMsgOut receives OMCI messages from voltha |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 142 | func (s *Server) OmciMsgOut(c context.Context, msg *openolt.OmciMsg) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 143 | logger.Debug("OLT %d receives OmciMsgOut to IF %v (ONU-ID: %v) pkt:%x.", s.Olt.ID, msg.IntfId, msg.OnuId, msg.Pkt) |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 144 | // Get ONU state |
| 145 | onu, err := s.GetOnuByID(msg.OnuId, msg.IntfId) |
| 146 | if err != nil { |
| 147 | logger.Error("ONU not found intfID %d, onuID %d", msg.IntfId, msg.OnuId) |
| 148 | return new(openolt.Empty), err |
| 149 | } |
| 150 | state := onu.GetIntState() |
| 151 | logger.Debug("ONU-ID: %v, ONU state: %d", msg.OnuId, state) |
| 152 | |
| 153 | // If ONU is ONU_INACTIVE or ONU_FREE do not send omci response |
| 154 | if state == device.ONU_INACTIVE || state == device.ONU_FREE { |
| 155 | logger.Info("ONU (IF %v ONU-ID: %v) is not ACTIVE, so not processing OmciMsg", msg.IntfId, msg.OnuId) |
| 156 | return new(openolt.Empty), nil |
| 157 | } |
Shad Ansari | a5c7989 | 2018-11-29 16:32:59 -0800 | [diff] [blame] | 158 | s.omciOut <- *msg |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 159 | return new(openolt.Empty), nil |
| 160 | } |
| 161 | |
| 162 | func (s *Server) OnuPacketOut(c context.Context, packet *openolt.OnuPacket) (*openolt.Empty, error) { |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 163 | onu, err := s.GetOnuByID(packet.OnuId, packet.IntfId) |
| 164 | if err != nil { |
| 165 | logger.Error("Failed in OnuPacketOut, %v", err) |
| 166 | return new(openolt.Empty), err |
| 167 | } |
Matteo Scandolo | 2a65914 | 2018-11-15 11:23:45 -0800 | [diff] [blame] | 168 | utils.LoggerWithOnu(onu).Debugf("OLT %d receives OnuPacketOut () to IF-ID:%d ONU-ID %d.", s.Olt.ID, packet.IntfId, packet.OnuId) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 169 | onuid := packet.OnuId |
| 170 | intfid := packet.IntfId |
| 171 | rawpkt := gopacket.NewPacket(packet.Pkt, layers.LayerTypeEthernet, gopacket.Default) |
| 172 | if err := s.onuPacketOut(intfid, onuid, rawpkt); err != nil { |
Matteo Scandolo | a286c74 | 2018-11-20 08:10:04 -0800 | [diff] [blame] | 173 | utils.LoggerWithOnu(onu).WithField("error", err).Errorf("OnuPacketOut Error ") |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 174 | return new(openolt.Empty), err |
| 175 | } |
| 176 | return new(openolt.Empty), nil |
| 177 | } |
| 178 | |
| 179 | func (s *Server) UplinkPacketOut(c context.Context, packet *openolt.UplinkPacket) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 180 | logger.Debug("OLT %d receives UplinkPacketOut().", s.Olt.ID) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 181 | rawpkt := gopacket.NewPacket(packet.Pkt, layers.LayerTypeEthernet, gopacket.Default) |
| 182 | if err := s.uplinkPacketOut(rawpkt); err != nil { |
| 183 | return new(openolt.Empty), err |
| 184 | } |
| 185 | return new(openolt.Empty), nil |
| 186 | } |
| 187 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 188 | // FlowAdd method should handle flows addition to datapath for OLT and ONU |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 189 | func (s *Server) FlowAdd(c context.Context, flow *openolt.Flow) (*openolt.Empty, error) { |
Keita NISHIMOTO | 26ebaa8 | 2019-03-07 10:00:35 +0900 | [diff] [blame] | 190 | logger.Debug("OLT %d receives FlowAdd() IntfID:%d OnuID:%d EType:%x GemPortID:%d", s.Olt.ID, flow.AccessIntfId, flow.OnuId, flow.Classifier.EthType, flow.GemportId) |
Zdravko Bozakov | edb6532 | 2019-04-11 14:49:32 +0200 | [diff] [blame] | 191 | onu, err := s.GetOnuByID(uint32(flow.OnuId), uint32(flow.AccessIntfId)) |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 192 | |
Keita NISHIMOTO | 7bce769 | 2019-01-19 09:31:09 +0900 | [diff] [blame] | 193 | if err == nil { |
| 194 | intfid := onu.IntfID |
| 195 | onuid := onu.OnuID |
Keita NISHIMOTO | 26ebaa8 | 2019-03-07 10:00:35 +0900 | [diff] [blame] | 196 | onu.GemportID = uint16(flow.GemportId) |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 197 | |
Keita NISHIMOTO | 7bce769 | 2019-01-19 09:31:09 +0900 | [diff] [blame] | 198 | utils.LoggerWithOnu(onu).WithFields(log.Fields{ |
| 199 | "olt": s.Olt.ID, |
| 200 | "c_tag": flow.Action.IVid, |
| 201 | }).Debug("OLT receives FlowAdd().") |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 202 | |
Keita NISHIMOTO | 7bce769 | 2019-01-19 09:31:09 +0900 | [diff] [blame] | 203 | if flow.Classifier.EthType == uint32(layers.EthernetTypeEAPOL) { |
Keita NISHIMOTO | 42db49e | 2019-01-29 07:49:41 +0900 | [diff] [blame] | 204 | omcistate := omci.GetOnuOmciState(onu.IntfID, onu.OnuID) |
Keita NISHIMOTO | 26ebaa8 | 2019-03-07 10:00:35 +0900 | [diff] [blame] | 205 | if omcistate != omci.DONE { |
| 206 | logger.Warn("FlowAdd() OMCI state %d is not \"DONE\"", omci.GetOnuOmciState(onu.OnuID, onu.IntfID)) |
Keita NISHIMOTO | 7bce769 | 2019-01-19 09:31:09 +0900 | [diff] [blame] | 207 | } |
Keita NISHIMOTO | 26ebaa8 | 2019-03-07 10:00:35 +0900 | [diff] [blame] | 208 | s.updateOnuIntState(intfid, onuid, device.ONU_OMCIACTIVE) |
Keita NISHIMOTO | 7bce769 | 2019-01-19 09:31:09 +0900 | [diff] [blame] | 209 | } |
| 210 | } |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 211 | return new(openolt.Empty), nil |
| 212 | } |
| 213 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 214 | // FlowRemove should handle flow deletion from datapath |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 215 | func (s *Server) FlowRemove(c context.Context, flow *openolt.Flow) (*openolt.Empty, error) { |
Keita NISHIMOTO | 7057aa6 | 2019-05-28 01:24:08 +0900 | [diff] [blame] | 216 | logger.Debug("OLT %d receives FlowRemove()", s.Olt.ID) |
| 217 | onu, err := s.GetOnuByID(uint32(flow.OnuId), uint32(flow.AccessIntfId)) |
| 218 | if err == nil{ |
| 219 | utils.LoggerWithOnu(onu).WithFields(log.Fields{ |
| 220 | "olt": s.Olt.ID, |
| 221 | "c_tag": flow.Action.IVid, |
| 222 | }).Debug("OLT receives FlowRemove().") |
| 223 | } |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 224 | return new(openolt.Empty), nil |
| 225 | } |
| 226 | |
| 227 | func (s *Server) HeartbeatCheck(c context.Context, empty *openolt.Empty) (*openolt.Heartbeat, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 228 | logger.Debug("OLT %d receives HeartbeatCheck().", s.Olt.ID) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 229 | signature := new(openolt.Heartbeat) |
| 230 | signature.HeartbeatSignature = s.Olt.HeartbeatSignature |
| 231 | return signature, nil |
| 232 | } |
| 233 | |
| 234 | func (s *Server) EnablePonIf(c context.Context, intf *openolt.Interface) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 235 | logger.Debug("OLT %d receives EnablePonIf().", s.Olt.ID) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 236 | return new(openolt.Empty), nil |
| 237 | } |
| 238 | |
| 239 | func (s *Server) DisablePonIf(c context.Context, intf *openolt.Interface) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 240 | logger.Debug("OLT %d receives DisablePonIf().", s.Olt.ID) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 241 | return new(openolt.Empty), nil |
| 242 | } |
| 243 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 244 | // Reboot method handles reboot of OLT |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 245 | func (s *Server) Reboot(c context.Context, empty *openolt.Empty) (*openolt.Empty, error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 246 | logger.Debug("OLT %d receives Reboot ().", s.Olt.ID) |
Keita NISHIMOTO | ca4da5f | 2018-10-15 22:48:52 +0900 | [diff] [blame] | 247 | // Initialize OLT & Env |
Keita NISHIMOTO | 9708e04 | 2018-10-27 09:24:44 +0900 | [diff] [blame] | 248 | logger.Debug("Initialized by Reboot") |
| 249 | s.Disable() |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 250 | return new(openolt.Empty), nil |
| 251 | } |
| 252 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 253 | // EnableIndication starts sending indications for OLT and ONU |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 254 | func (s *Server) EnableIndication(empty *openolt.Empty, stream openolt.Openolt_EnableIndicationServer) error { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 255 | logger.Debug("OLT receives EnableInd.") |
Keita NISHIMOTO | 9708e04 | 2018-10-27 09:24:44 +0900 | [diff] [blame] | 256 | defer func() { |
| 257 | logger.Debug("grpc EnableIndication Done") |
| 258 | }() |
| 259 | if err := s.Enable(&stream); err != nil { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 260 | logger.Error("Failed to Enable Core: %v", err) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 261 | return err |
| 262 | } |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 263 | return nil |
| 264 | } |
| 265 | |
Zdravko Bozakov | 8b9328c | 2019-05-15 05:13:34 +0200 | [diff] [blame] | 266 | // NewGrpcServer starts openolt gRPC server |
Keita NISHIMOTO | 9708e04 | 2018-10-27 09:24:44 +0900 | [diff] [blame] | 267 | func NewGrpcServer(addrport string) (l net.Listener, g *grpc.Server, e error) { |
Matteo Scandolo | 2aca22c | 2018-11-08 14:12:07 -0800 | [diff] [blame] | 268 | logger.Debug("Listening %s ...", addrport) |
Keita NISHIMOTO | 3b8b9c0 | 2018-10-09 09:40:01 +0900 | [diff] [blame] | 269 | g = grpc.NewServer() |
| 270 | l, e = net.Listen("tcp", addrport) |
| 271 | return |
| 272 | } |