blob: 87d2f70d9eb9382d0d22f2ff6b883a5c7afe1fb6 [file] [log] [blame]
Shad Ansari2eac6a42018-11-14 22:35:39 -08001/*
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 core
18
Shad Ansari45806172018-11-19 17:13:08 -080019import (
Shad Ansaria5c79892018-11-29 16:32:59 -080020 "encoding/binary"
Shad Ansari1ac4c432019-01-14 22:00:00 -080021 "time"
Shad Ansaria5c79892018-11-29 16:32:59 -080022
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090023 "context"
24 "errors"
Shad Ansaria3384b02019-01-03 15:11:11 -080025
26 "gerrit.opencord.org/voltha-bbsim/common/logger"
27 "gerrit.opencord.org/voltha-bbsim/device"
28 "gerrit.opencord.org/voltha-bbsim/protos"
Shad Ansari45806172018-11-19 17:13:08 -080029)
30
Shad Ansarifd298442019-01-08 16:19:35 -080031const NumMibUploads byte = 26
Shad Ansari45806172018-11-19 17:13:08 -080032
33type OnuKey struct {
34 IntfId, OnuId uint32
35}
36
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090037type OnuOmciState struct {
Shad Ansarifd298442019-01-08 16:19:35 -080038 gemPortId uint16
39 mibUploadCtr uint16
40 uniGInstance uint8
41 tcontInstance uint8
42 pptpInstance uint8
43 init istate
Shad Ansari45806172018-11-19 17:13:08 -080044}
45
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090046type istate int
47
48const (
49 INCOMPLETE istate = iota
50 DONE
51)
52
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090053type OmciMsgHandler func(class OmciClass, content OmciContent, key OnuKey) ([]byte, error)
Shad Ansari8213c532018-12-11 13:53:34 -080054
55var Handlers = map[OmciMsgType]OmciMsgHandler{
56 MibReset: mibReset,
57 MibUpload: mibUpload,
58 MibUploadNext: mibUploadNext,
59 Set: set,
60 Create: create,
61 Get: get,
62 GetAllAlarms: getAllAlarms,
63}
64
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090065var OnuOmciStateMap = map[OnuKey]*OnuOmciState{}
Shad Ansari45806172018-11-19 17:13:08 -080066
Keita NISHIMOTO0c1c0832019-01-16 07:06:30 +090067func RunOmciResponder(ctx context.Context, omciOut chan openolt.OmciMsg, omciIn chan openolt.OmciIndication, onumap map[uint32][] *device.Onu, errch chan error) {
68 go func() { //For monitoring the OMCI states TODO: This part should be eliminated because it is out of scope of this library
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090069 t := time.NewTicker(1 * time.Second)
70 defer t.Stop()
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090071 for {
Shad Ansaria3384b02019-01-03 15:11:11 -080072 select {
73 case <-t.C:
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090074 logger.Debug("Monitor omci init state")
75 if isAllOmciInitDone(onumap) {
76 logger.Info("OmciRun - All the omci initialization wes done")
77 close(errch)
78 return
79 }
Shad Ansaria3384b02019-01-03 15:11:11 -080080 case <-ctx.Done():
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090081 logger.Debug("Omci Monitoring process was done")
82 return
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090083 }
Shad Ansari45806172018-11-19 17:13:08 -080084 }
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090085 }()
Shad Ansari8213c532018-12-11 13:53:34 -080086
Shad Ansaria3384b02019-01-03 15:11:11 -080087 go func() {
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090088 defer logger.Debug("Omci response process was done")
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +090089 for {
90 var resp openolt.OmciIndication
Shad Ansaria3384b02019-01-03 15:11:11 -080091 select {
92 case m := <-omciOut:
Shad Ansari1ac4c432019-01-14 22:00:00 -080093 transactionId, deviceId, msgType, class, instance, content, err := ParsePkt(HexDecode(m.Pkt))
Shad Ansaria3384b02019-01-03 15:11:11 -080094 if err != nil {
95 errch <- err
Keita NISHIMOTO2b694202018-12-18 07:30:55 +090096 return
Shad Ansaria3384b02019-01-03 15:11:11 -080097 }
98
99 logger.Debug("OmciRun - transactionId: %d msgType: %d, ME Class: %d, ME Instance: %d",
100 transactionId, msgType, class, instance)
101
102 key := OnuKey{m.IntfId, m.OnuId}
103 if _, ok := OnuOmciStateMap[key]; !ok {
104 OnuOmciStateMap[key] = NewOnuOmciState()
105 }
106
107 if _, ok := Handlers[msgType]; !ok {
108 logger.Warn("Ignore omci msg (msgType %d not handled)", msgType)
109 continue
110 }
111
112 resp.Pkt, err = Handlers[msgType](class, content, key)
113 if err != nil {
114 errch <- err
115 return
116 }
117 resp.Pkt[0] = byte(transactionId >> 8)
118 resp.Pkt[1] = byte(transactionId & 0xFF)
119 resp.Pkt[2] = 0x2<<4 | byte(msgType)
120 resp.Pkt[3] = deviceId
121 resp.IntfId = m.IntfId
122 resp.OnuId = m.OnuId
123 omciIn <- resp
124 case <-ctx.Done():
125 return
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900126 }
Shad Ansari45806172018-11-19 17:13:08 -0800127 }
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900128 }()
Shad Ansari2eac6a42018-11-14 22:35:39 -0800129}
Shad Ansari45806172018-11-19 17:13:08 -0800130
Shad Ansaria5c79892018-11-29 16:32:59 -0800131func HexDecode(pkt []byte) []byte {
132 // Convert the hex encoding to binary
133 // TODO - Change openolt adapter to send raw binary instead of hex encoded
Shad Ansari45806172018-11-19 17:13:08 -0800134 p := make([]byte, len(pkt)/2)
135 for i, j := 0, 0; i < len(pkt); i, j = i+2, j+1 {
Shad Ansaria5c79892018-11-29 16:32:59 -0800136 // Go figure this ;)
Shad Ansari45806172018-11-19 17:13:08 -0800137 u := (pkt[i] & 15) + (pkt[i]>>6)*9
138 l := (pkt[i+1] & 15) + (pkt[i+1]>>6)*9
139 p[j] = u<<4 + l
140 }
141 logger.Debug("Omci decoded: %x.", p)
Shad Ansaria5c79892018-11-29 16:32:59 -0800142 return p
Shad Ansari45806172018-11-19 17:13:08 -0800143}
144
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900145func NewOnuOmciState() *OnuOmciState {
Shad Ansarifd298442019-01-08 16:19:35 -0800146 return &OnuOmciState{gemPortId: 0, mibUploadCtr: 0, uniGInstance: 1, tcontInstance: 0, pptpInstance: 1}
Shad Ansari45806172018-11-19 17:13:08 -0800147}
148
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900149func mibReset(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansari45806172018-11-19 17:13:08 -0800150 var pkt []byte
151
152 logger.Debug("Omci MibReset")
153
154 pkt = []byte{
Shad Ansaria5c79892018-11-29 16:32:59 -0800155 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
Shad Ansari45806172018-11-19 17:13:08 -0800156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Shad Ansaria5c79892018-11-29 16:32:59 -0800160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900161 return pkt, nil
Shad Ansari45806172018-11-19 17:13:08 -0800162}
163
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900164func mibUpload(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansari45806172018-11-19 17:13:08 -0800165 var pkt []byte
166
167 logger.Debug("Omci MibUpload")
168
169 pkt = []byte{
Shad Ansaria5c79892018-11-29 16:32:59 -0800170 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
Shad Ansari45806172018-11-19 17:13:08 -0800171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Shad Ansaria5c79892018-11-29 16:32:59 -0800175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Shad Ansari45806172018-11-19 17:13:08 -0800176
177 pkt[9] = NumMibUploads // Number of subsequent MibUploadNext cmds
178
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900179 return pkt, nil
Shad Ansari45806172018-11-19 17:13:08 -0800180}
181
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900182func mibUploadNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansari45806172018-11-19 17:13:08 -0800183 var pkt []byte
184
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900185 state := OnuOmciStateMap[key]
Shad Ansari8213c532018-12-11 13:53:34 -0800186
Shad Ansarifd298442019-01-08 16:19:35 -0800187 logger.Debug("Omci MibUploadNext %d", state.mibUploadCtr)
188
Shad Ansari45806172018-11-19 17:13:08 -0800189 switch state.mibUploadCtr {
190 case 0:
Shad Ansaria3384b02019-01-03 15:11:11 -0800191 // ONT Data (2)
192 pkt = []byte{
193 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
194 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
199 case 1:
200 // Circuit Pack (6) - #1
201 pkt = []byte{
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
203 0x00, 0x06, 0x01, 0x01, 0xf0, 0x00, 0x2f, 0x04,
204 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80,
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
208 case 2:
209 // Circuit Pack (6) - #2
210 pkt = []byte{
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
212 0x00, 0x06, 0x01, 0x01, 0x0f, 0x00, 0x42, 0x52,
213 0x43, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
217 case 3:
218 // Circuit Pack (6) - #3
219 pkt = []byte{
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
221 0x00, 0x06, 0x01, 0x01, 0x00, 0xf8, 0x20, 0x20,
222 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
223 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
224 0x20, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
226 case 4:
227 // Circuit Pack (6) - #4
228 pkt = []byte{
229 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
230 0x00, 0x06, 0x01, 0x01, 0x00, 0x04, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
235 case 5:
236 // Circuit Pack (6) - #5
237 pkt = []byte{
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
239 0x00, 0x06, 0x01, 0x80, 0xf0, 0x00, 0xee, 0x01,
240 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
244 case 6:
245 // Circuit Pack (6) - #6
246 pkt = []byte{
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
248 0x00, 0x06, 0x01, 0x80, 0x0f, 0x00, 0x42, 0x52,
249 0x43, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
253 case 7:
254 // Circuit Pack (6) - #7
255 pkt = []byte{
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
257 0x00, 0x06, 0x01, 0x80, 0x00, 0xf8, 0x20, 0x20,
258 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
259 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
260 0x20, 0x20, 0x00, 0x08, 0x40, 0x10, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
262 case 8:
263 // Circuit Pack (6) - #8
264 pkt = []byte{
Shad Ansarifd298442019-01-08 16:19:35 -0800265 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
Shad Ansaria3384b02019-01-03 15:11:11 -0800266 0x00, 0x06, 0x01, 0x80, 0x00, 0x04, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Shad Ansarifd298442019-01-08 16:19:35 -0800271 case 9, 10, 11, 12:
272 // PPTP (11)
Shad Ansari45806172018-11-19 17:13:08 -0800273 pkt = []byte{
Shad Ansaria5c79892018-11-29 16:32:59 -0800274 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
Shad Ansari45806172018-11-19 17:13:08 -0800275 0x00, 0x0b, 0x01, 0x01, 0xff, 0xfe, 0x00, 0x2f,
276 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0xee, 0x00,
277 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Shad Ansaria5c79892018-11-29 16:32:59 -0800279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Shad Ansari45806172018-11-19 17:13:08 -0800280 pkt[11] = state.pptpInstance // ME Instance
281 state.pptpInstance++
Shad Ansarifd298442019-01-08 16:19:35 -0800282 case 13, 14, 15, 16, 17, 18, 19, 20:
283 // T-CONT (262)
284 pkt = []byte{
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
286 0x01, 0x06, 0x80, 0x00, 0xe0, 0x00, 0xff, 0xff,
287 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
291 pkt[11] = state.tcontInstance // TCONT ME Instance
292 state.tcontInstance++
293 case 21:
294 // ANI-G (263)
295 pkt = []byte{
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
297 0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00,
298 0x08, 0x00, 0x30, 0x00, 0x00, 0x05, 0x09, 0x00,
299 0x00, 0xe0, 0x54, 0xff, 0xff, 0x00, 0x00, 0x0c,
300 0x63, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
301 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
302 case 22, 23, 24, 25:
303 // UNI-G (264)
304 pkt = []byte{
305 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
306 0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00,
307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
311 pkt[11] = state.uniGInstance // UNI-G ME Instance
312 state.uniGInstance++
Shad Ansari45806172018-11-19 17:13:08 -0800313 default:
314 logger.Error("Invalid MibUpload request %d", state.mibUploadCtr)
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900315 return nil, errors.New("Invalid MibUpload request")
Shad Ansari45806172018-11-19 17:13:08 -0800316 }
317
318 state.mibUploadCtr++
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900319 return pkt, nil
Shad Ansari45806172018-11-19 17:13:08 -0800320}
321
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900322func set(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansari45806172018-11-19 17:13:08 -0800323 var pkt []byte
324
325 pkt = []byte{
Shad Ansaria5c79892018-11-29 16:32:59 -0800326 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
Shad Ansari45806172018-11-19 17:13:08 -0800327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Shad Ansaria5c79892018-11-29 16:32:59 -0800331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Shad Ansari45806172018-11-19 17:13:08 -0800332
333 logger.Debug("Omci Set")
334
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900335 return pkt, nil
Shad Ansari45806172018-11-19 17:13:08 -0800336}
337
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900338func create(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansari45806172018-11-19 17:13:08 -0800339 var pkt []byte
340
Shad Ansaria5c79892018-11-29 16:32:59 -0800341 if class == GEMPortNetworkCTP {
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900342 if onuOmciState, ok := OnuOmciStateMap[key]; !ok {
Shad Ansaria5c79892018-11-29 16:32:59 -0800343 logger.Error("ONU Key Error - IntfId: %d, OnuId:", key.IntfId, key.OnuId)
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900344 return nil, errors.New("ONU Key Error")
Shad Ansaria5c79892018-11-29 16:32:59 -0800345 } else {
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900346 onuOmciState.gemPortId = binary.BigEndian.Uint16(content[:2])
347 logger.Debug("Gem Port Id %d", onuOmciState.gemPortId)
348 OnuOmciStateMap[key].init = DONE
Shad Ansaria5c79892018-11-29 16:32:59 -0800349 }
350 }
351
Shad Ansari45806172018-11-19 17:13:08 -0800352 pkt = []byte{
Shad Ansaria5c79892018-11-29 16:32:59 -0800353 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x01,
Shad Ansari45806172018-11-19 17:13:08 -0800354 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Shad Ansaria5c79892018-11-29 16:32:59 -0800358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Shad Ansari45806172018-11-19 17:13:08 -0800359
360 logger.Debug("Omci Create")
361
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900362 return pkt, nil
Shad Ansari45806172018-11-19 17:13:08 -0800363}
364
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900365func get(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansari45806172018-11-19 17:13:08 -0800366 var pkt []byte
367
368 pkt = []byte{
Shad Ansaria5c79892018-11-29 16:32:59 -0800369 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x02, 0x01,
Shad Ansari45806172018-11-19 17:13:08 -0800370 0x00, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Shad Ansaria5c79892018-11-29 16:32:59 -0800374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Shad Ansari45806172018-11-19 17:13:08 -0800375
376 logger.Debug("Omci Get")
377
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900378 return pkt, nil
Shad Ansari45806172018-11-19 17:13:08 -0800379}
Shad Ansaria5c79892018-11-29 16:32:59 -0800380
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900381func getAllAlarms(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
Shad Ansaria5c79892018-11-29 16:32:59 -0800382 var pkt []byte
383
384 pkt = []byte{
385 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
386 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
388 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
390 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
391
392 logger.Debug("Omci GetAllAlarms")
393
Keita NISHIMOTO2b694202018-12-18 07:30:55 +0900394 return pkt, nil
Shad Ansaria5c79892018-11-29 16:32:59 -0800395}
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900396
Shad Ansaria3384b02019-01-03 15:11:11 -0800397func isAllOmciInitDone(onumap map[uint32][]*device.Onu) bool {
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900398 for _, onus := range onumap {
Shad Ansaria3384b02019-01-03 15:11:11 -0800399 for _, onu := range onus {
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900400 key := OnuKey{onu.IntfID, onu.OnuID}
401 state := OnuOmciStateMap[key]
Shad Ansaria3384b02019-01-03 15:11:11 -0800402 if state.init == INCOMPLETE {
Keita NISHIMOTO3af86da2018-12-12 10:34:43 +0900403 return false
404 }
405 }
406 }
407 return true
408}