blob: 1ebaaea0eb76a1130141c36e54214863778f48cc [file] [log] [blame]
Shad Ansari1106b022019-01-16 22:22:35 -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
19import (
20 "encoding/binary"
21 "errors"
Keita NISHIMOTO21853b32019-01-25 19:29:59 +090022 "fmt"
Zdravko Bozakovf56cca42019-04-29 10:06:47 +020023 "log"
Shad Ansari1106b022019-01-16 22:22:35 -080024)
25
26type OmciMsgHandler func(class OmciClass, content OmciContent, key OnuKey) ([]byte, error)
27
28var Handlers = map[OmciMsgType]OmciMsgHandler{
Zdravko Bozakovf56cca42019-04-29 10:06:47 +020029 MibReset: mibReset,
30 MibUpload: mibUpload,
31 MibUploadNext: mibUploadNext,
32 Set: set,
33 Create: create,
34 Get: get,
35 GetAllAlarms: getAllAlarms,
36 GetAllAlarmsNext: getAllAlarmsNext,
37 SynchronizeTime: syncTime,
38 Delete: delete,
Zdravko Bozakov8e9d85a2019-05-27 21:02:59 +020039 Reboot: reboot,
Shad Ansari1106b022019-01-16 22:22:35 -080040}
41
42func mibReset(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
43 var pkt []byte
44
Zdravko Bozakovf56cca42019-04-29 10:06:47 +020045 log.Printf("%v - Omci MibReset", key)
46 if state, ok := OnuOmciStateMap[key]; ok {
47 log.Printf("%v - Reseting OnuOmciState", key)
Mahir Gunyeled7b07b2019-02-11 12:06:02 -080048 state.ResetOnuOmciState()
49 }
Shad Ansari1106b022019-01-16 22:22:35 -080050
51 pkt = []byte{
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
58 return pkt, nil
59}
60
61func mibUpload(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
62 var pkt []byte
63
Zdravko Bozakovf56cca42019-04-29 10:06:47 +020064 log.Printf("%v - Omci MibUpload", key)
Shad Ansari1106b022019-01-16 22:22:35 -080065
66 pkt = []byte{
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
73
Zdravko Bozakov3d762142019-07-15 16:57:17 +020074 pkt[8] = NumMibUploadsHigherByte
75 pkt[9] = NumMibUploadsLowerByte
Shad Ansari1106b022019-01-16 22:22:35 -080076
77 return pkt, nil
78}
79
80func mibUploadNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
81 var pkt []byte
82
83 state := OnuOmciStateMap[key]
84
Zdravko Bozakov8e9d85a2019-05-27 21:02:59 +020085 // commandNumber is the "Command number" attribute received in "MIB Upload Next" OMCI message
Zdravko Bozakov3d762142019-07-15 16:57:17 +020086 commandNumber := (uint16(content[1])) | (uint16(content[0])<<8)
Zdravko Bozakov8e9d85a2019-05-27 21:02:59 +020087 log.Printf("%v - Omci MibUploadNext %d", key, commandNumber)
Shad Ansari1106b022019-01-16 22:22:35 -080088
Zdravko Bozakov8e9d85a2019-05-27 21:02:59 +020089 switch commandNumber {
Shad Ansari1106b022019-01-16 22:22:35 -080090 case 0:
91 // ONT Data (2)
Zdravko Bozakov3d762142019-07-15 16:57:17 +020092 // log.Println("ONT DATA")
Shad Ansari1106b022019-01-16 22:22:35 -080093 pkt = []byte{
94 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
95 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
100 case 1:
101 // Circuit Pack (6) - #1
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200102 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800103 pkt = []byte{
104 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
105 0x00, 0x06, 0x01, 0x01, 0xf0, 0x00, 0x2f, 0x04,
106 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80,
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
110 case 2:
111 // Circuit Pack (6) - #2
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200112 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800113 pkt = []byte{
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
115 0x00, 0x06, 0x01, 0x01, 0x0f, 0x00, 0x42, 0x52,
116 0x43, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
117 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
120 case 3:
121 // Circuit Pack (6) - #3
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200122 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800123 pkt = []byte{
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
125 0x00, 0x06, 0x01, 0x01, 0x00, 0xf8, 0x20, 0x20,
126 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
127 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
128 0x20, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
130 case 4:
131 // Circuit Pack (6) - #4
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200132 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800133 pkt = []byte{
134 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
135 0x00, 0x06, 0x01, 0x01, 0x00, 0x04, 0x00, 0x00,
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
140 case 5:
141 // Circuit Pack (6) - #5
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200142 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800143 pkt = []byte{
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
145 0x00, 0x06, 0x01, 0x80, 0xf0, 0x00, 0xee, 0x01,
146 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80,
147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
150 case 6:
151 // Circuit Pack (6) - #6
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200152 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800153 pkt = []byte{
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
155 0x00, 0x06, 0x01, 0x80, 0x0f, 0x00, 0x42, 0x52,
156 0x43, 0x4d, 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}
160 case 7:
161 // Circuit Pack (6) - #7
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200162 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800163 pkt = []byte{
164 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
165 0x00, 0x06, 0x01, 0x80, 0x00, 0xf8, 0x20, 0x20,
166 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
167 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
168 0x20, 0x20, 0x00, 0x08, 0x40, 0x10, 0x00, 0x00,
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
170 case 8:
171 // Circuit Pack (6) - #8
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200172 // log.Println("Circuit Pack")
Shad Ansari1106b022019-01-16 22:22:35 -0800173 pkt = []byte{
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
175 0x00, 0x06, 0x01, 0x80, 0x00, 0x04, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
180 case 9, 10, 11, 12:
181 // PPTP (11)
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200182 // log.Println("PPTP")
Shad Ansari1106b022019-01-16 22:22:35 -0800183 pkt = []byte{
184 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
185 0x00, 0x0b, 0x01, 0x01, 0xff, 0xfe, 0x00, 0x2f,
186 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0xee, 0x00,
187 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
190 pkt[11] = state.pptpInstance // ME Instance
191 state.pptpInstance++
192 case 13, 14, 15, 16, 17, 18, 19, 20:
193 // T-CONT (262)
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200194 // log.Println("T-CONT")
Shad Ansari1106b022019-01-16 22:22:35 -0800195 pkt = []byte{
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
197 0x01, 0x06, 0x80, 0x00, 0xe0, 0x00, 0xff, 0xff,
198 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200202
Shad Ansari1106b022019-01-16 22:22:35 -0800203 state.tcontInstance++
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200204 pkt[11] = state.tcontInstance // TCONT ME Instance
205
Shad Ansari1106b022019-01-16 22:22:35 -0800206 case 21:
207 // ANI-G (263)
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200208 // log.Println("ANI-G")
Shad Ansari1106b022019-01-16 22:22:35 -0800209 pkt = []byte{
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
211 0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00,
212 0x08, 0x00, 0x30, 0x00, 0x00, 0x05, 0x09, 0x00,
213 0x00, 0xe0, 0x54, 0xff, 0xff, 0x00, 0x00, 0x0c,
214 0x63, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
216 case 22, 23, 24, 25:
217 // UNI-G (264)
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200218 // log.Println("UNI-G")
Shad Ansari1106b022019-01-16 22:22:35 -0800219 pkt = []byte{
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
221 0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00,
222 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
226 pkt[11] = state.uniGInstance // UNI-G ME Instance
227 state.uniGInstance++
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200228
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200229 case 26, 30, 34, 38, 42, 46, 50, 54,
230 58, 62, 66, 70, 74, 78, 82, 86,
231 90, 94, 98, 102, 106, 110, 114, 118,
232 122, 126, 130, 134, 138, 142, 146, 150,
233 154, 158, 162, 166, 170, 174, 178, 182,
234 186, 190, 194, 198, 202, 206, 210, 214,
235 218, 222, 226, 230, 234, 238, 242, 246,
236 250, 254, 258, 262, 266, 270, 274, 278:
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200237 // Prior-Q with mask downstream
238 log.Println("Mib-upload for prior-q with mask")
239 // For downstream PQ, pkt[10] is 0x00
240 // So the instanceId will be like 0x0001, 0x0002,... etc
241 pkt = []byte{
242 0x00, 0x42, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
243 0x01, 0x15, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff,
244 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
245 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 }
249 state.priorQInstance++
250 pkt[11] = state.priorQInstance
251
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200252 case 27, 31, 35, 39, 43, 47, 51, 55,
253 59, 63, 67, 71, 75, 79, 83, 87,
254 91, 95, 99, 103, 107, 111, 115, 119,
255 123, 127, 131, 135, 139, 143, 147, 151,
256 155, 159, 163, 167, 171, 175, 179, 183,
257 187, 191, 195, 199, 203, 207, 211, 215,
258 219, 223, 227, 231, 235, 239, 243, 247,
259 251, 255, 259, 263, 267, 271, 275, 279:
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200260 // Prior-Q with attribute list downstream
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200261 // log.Println("Mib-upload for prior-q with attribute list")
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200262 pkt = []byte{
263 0x00, 0x43, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
264 0x01, 0x15, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x01,
265 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
266 0x20, 0x00, 0x00, 0x01, 0x20, 0x01, 0x00, 0x01,
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 }
270
271 pkt[11] = state.priorQInstance
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200272
273 // Group 8 PriorQ to point to a particular TCONT
274 // Priority for each group of PriorQ is 0 - 7
275 if state.priorQPriority % NumPriorQPerTcont == 0 {
276 state.tcontPointer++
277 }
278
279 // Only for verification. To be removed
280 if state.tcontPointer > state.tcontInstance {
281 log.Println("Error: Invalid TcontPointer")
282 break
283 }
284
285 pkt[24] = state.tcontPointer
286 pkt[26] = state.priorQPriority % NumPriorQPerTcont
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200287 pkt[28] = state.tcontInstance
288
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200289 case 28, 32, 36, 40, 44, 48, 52, 56,
290 60, 64, 68, 72, 76, 80, 84, 88,
291 92, 96, 100, 104, 108, 112, 116, 120,
292 124, 128, 132, 136, 140, 144, 148, 152,
293 156, 160, 164, 168, 172, 176, 180, 184,
294 188, 192, 196, 200, 204, 208, 212, 216,
295 220, 224, 228, 232, 236, 240, 244, 248,
296 252, 256, 260, 264, 268, 272, 276, 280:
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200297 // Prior-Q with mask upstream
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200298 // log.Println("Mib-upload for prior-q with mask")
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200299 pkt = []byte{
300 0x00, 0x42, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
301 0x01, 0x15, 0x80, 0x00, 0x00, 0x0f, 0xff, 0xff,
302 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
303 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 }
307 pkt[11] = state.priorQInstance
308
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200309 case 29, 33, 37, 41, 45, 49, 53, 57,
310 61, 65, 69, 73, 77, 81, 85, 89,
311 93, 97, 101, 105, 109, 113, 117, 121,
312 125, 129, 133, 137, 141, 145, 149, 153,
313 157, 161, 165, 169, 173, 177, 181, 185,
314 189, 193, 197, 201, 205, 209, 213, 217,
315 221, 225, 229, 233, 237, 241, 245, 249,
316 253, 257, 261, 265, 269, 273, 277, 281:
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200317 // Prior-Q with attribute list upstream
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200318 // log.Println("Mib-upload for prior-q with attribute list")
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200319 // For upstream pkt[10] is fixed as 80
320 // So for upstream PQ, instanceId will be like 0x8001, 0x8002 ... etc
321 pkt = []byte{
322 0x00, 0x43, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
323 0x01, 0x15, 0x80, 0x00, 0xff, 0xf0, 0x00, 0x01,
324 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
325 0x20, 0x00, 0x00, 0x80, 0x20, 0x01, 0x00, 0x01,
326 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328 }
329
330 pkt[11] = state.priorQInstance
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200331 pkt[24] = state.tcontPointer
332 pkt[26] = state.priorQPriority % NumPriorQPerTcont // Priority of this PriorQ
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200333 pkt[28] = state.tcontInstance
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200334 state.priorQPriority++
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200335
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200336
337 case 282, 283, 284, 285, 286, 287, 288, 289:
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200338 // Traffic Scheduler
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200339 // log.Println("Traffic Scheduler")
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200340 pkt = []byte{
341 0x02, 0xa4, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
342 0x01, 0x16, 0x80, 0x00, 0xf0, 0x00, 0x80, 0x00,
343 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
344 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
345 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
347 }
348
349 pkt[15] = state.tcontInstance
350 state.tcontInstance++
351
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200352 case 290:
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200353 // ONT-2G
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200354 // log.Println("ONT-2G")
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200355 pkt = []byte{
356 0x00, 0x16, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00,
357 0x01, 0x01, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x40,
358 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
359 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x00, 0x01, 0x00,
360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 }
363
Shad Ansari1106b022019-01-16 22:22:35 -0800364 default:
Mahir Gunyeled7b07b2019-02-11 12:06:02 -0800365 state.extraMibUploadCtr++
366 errstr := fmt.Sprintf("%v - Invalid MibUpload request: %d, extras: %d", key, state.mibUploadCtr, state.extraMibUploadCtr)
Keita NISHIMOTO21853b32019-01-25 19:29:59 +0900367 return nil, errors.New(errstr)
Shad Ansari1106b022019-01-16 22:22:35 -0800368 }
369
370 state.mibUploadCtr++
371 return pkt, nil
372}
373
374func set(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
375 var pkt []byte
376
377 pkt = []byte{
378 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
381 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
383 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
384
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200385 log.Printf("%v - Omci Set", key)
Shad Ansari1106b022019-01-16 22:22:35 -0800386
387 return pkt, nil
388}
389
390func create(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
391 var pkt []byte
392
393 if class == GEMPortNetworkCTP {
394 if onuOmciState, ok := OnuOmciStateMap[key]; !ok {
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200395 log.Printf("%v - ONU Key Error", key)
Shad Ansari1106b022019-01-16 22:22:35 -0800396 return nil, errors.New("ONU Key Error")
397 } else {
398 onuOmciState.gemPortId = binary.BigEndian.Uint16(content[:2])
Mahir Gunyeled7b07b2019-02-11 12:06:02 -0800399 log.Printf("%v - Gem Port Id %d", key, onuOmciState.gemPortId)
Shad Ansari1106b022019-01-16 22:22:35 -0800400 // FIXME
401 OnuOmciStateMap[key].state = DONE
402 }
403 }
404
405 pkt = []byte{
406 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x01,
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
410 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
411 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
412
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200413 log.Printf("%v - Omci Create", key)
Shad Ansari1106b022019-01-16 22:22:35 -0800414
415 return pkt, nil
416}
417
418func get(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
419 var pkt []byte
420
421 pkt = []byte{
422 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x02, 0x01,
423 0x00, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
424 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
426 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
427 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
428
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200429 pkt = GetAttributes(class, content, key, pkt)
Shad Ansari1106b022019-01-16 22:22:35 -0800430
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200431 log.Printf("%v - Omci Get", key)
Shad Ansari1106b022019-01-16 22:22:35 -0800432 return pkt, nil
433}
434
435func getAllAlarms(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
436 var pkt []byte
437
438 pkt = []byte{
439 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
440 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
441 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
443 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
444 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
445
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200446 log.Printf("%v - Omci GetAllAlarms", key)
Shad Ansari1106b022019-01-16 22:22:35 -0800447
448 return pkt, nil
449}
Mahir Gunyel5b89e5e2019-02-15 09:34:14 -0800450
Mahir Gunyel5b89e5e2019-02-15 09:34:14 -0800451func syncTime(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
452 var pkt []byte
453
454 pkt = []byte{
455 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
456 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
457 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
458 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
461
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200462 log.Printf("%v - Omci syncTime", key)
Mahir Gunyel5b89e5e2019-02-15 09:34:14 -0800463
464 return pkt, nil
465}
466
467func getAllAlarmsNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
468 var pkt []byte
469
470 pkt = []byte{
471 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200472 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
Mahir Gunyel5b89e5e2019-02-15 09:34:14 -0800473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
476 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
477
Zdravko Bozakovf56cca42019-04-29 10:06:47 +0200478 log.Printf("%v - Omci GetAllAlarmsNext", key)
479
480 return pkt, nil
481}
482
483func delete(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
484 var pkt []byte
485
486 pkt = []byte{
487 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
488 0x00, 0x0b, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
489 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
491 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
493
494 log.Printf("%v - Omci Delete", key)
Mahir Gunyel5b89e5e2019-02-15 09:34:14 -0800495
496 return pkt, nil
497}
Zdravko Bozakov8e9d85a2019-05-27 21:02:59 +0200498
499func reboot(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
500 var pkt []byte
501 pkt = []byte{
502 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
503 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
504 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
505 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
506 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
507 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
508
509 log.Printf("%v - Omci Reboot", key)
510 return pkt, nil
511}
Zdravko Bozakov3d762142019-07-15 16:57:17 +0200512