Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [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 ( |
| 20 | "encoding/binary" |
| 21 | "errors" |
| 22 | "fmt" |
| 23 | log "github.com/sirupsen/logrus" |
| 24 | ) |
| 25 | |
| 26 | type OmciMsgHandler func(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) |
| 27 | |
| 28 | var Handlers = map[OmciMsgType]OmciMsgHandler{ |
| 29 | 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, |
| 39 | Reboot: reboot, |
| 40 | } |
| 41 | |
| 42 | func mibReset(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 43 | var pkt []byte |
| 44 | |
| 45 | log.WithFields(log.Fields{ |
| 46 | "IntfId": key.IntfId, |
| 47 | "OnuId": key.OnuId, |
| 48 | }).Tracef("Omci MibReset") |
| 49 | OnuOmciStateMapLock.RLock() |
| 50 | if state, ok := OnuOmciStateMap[key]; ok { |
| 51 | log.WithFields(log.Fields{ |
| 52 | "IntfId": key.IntfId, |
| 53 | "OnuId": key.OnuId, |
| 54 | }).Tracef("Reseting OnuOmciState") |
| 55 | state.ResetOnuOmciState() |
| 56 | } |
| 57 | OnuOmciStateMapLock.RUnlock() |
| 58 | |
| 59 | pkt = []byte{ |
| 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 66 | return pkt, nil |
| 67 | } |
| 68 | |
| 69 | func mibUpload(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 70 | var pkt []byte |
| 71 | |
| 72 | log.WithFields(log.Fields{ |
| 73 | "IntfId": key.IntfId, |
| 74 | "OnuId": key.OnuId, |
| 75 | }).Tracef("Omci MibUpload") |
| 76 | |
| 77 | pkt = []byte{ |
| 78 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 84 | |
| 85 | pkt[8] = NumMibUploadsHigherByte |
| 86 | pkt[9] = NumMibUploadsLowerByte |
| 87 | |
| 88 | return pkt, nil |
| 89 | } |
| 90 | |
| 91 | func mibUploadNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 92 | var pkt []byte |
| 93 | OnuOmciStateMapLock.RLock() |
| 94 | state := OnuOmciStateMap[key] |
| 95 | OnuOmciStateMapLock.RUnlock() |
| 96 | // commandNumber is the "Command number" attribute received in "MIB Upload Next" OMCI message |
| 97 | commandNumber := (uint16(content[1])) | (uint16(content[0])<<8) |
| 98 | log.WithFields(log.Fields{ |
| 99 | "IntfId": key.IntfId, |
| 100 | "OnuId": key.OnuId, |
| 101 | "CommandNumber": commandNumber, |
| 102 | }).Tracef("Omci MibUploadNext") |
| 103 | |
| 104 | switch commandNumber { |
| 105 | case 0: |
| 106 | // ONT Data (2) |
| 107 | // log.Println("ONT DATA") |
| 108 | pkt = []byte{ |
| 109 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 110 | 0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, |
| 111 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 112 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 113 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 114 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 115 | case 1: |
| 116 | // Circuit Pack (6) - #1 |
| 117 | // log.Println("Circuit Pack") |
| 118 | pkt = []byte{ |
| 119 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 120 | 0x00, 0x06, 0x01, 0x01, 0xf0, 0x00, 0x2f, 0x04, |
| 121 | 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80, |
| 122 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 123 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, |
| 124 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 125 | case 2: |
| 126 | // Circuit Pack (6) - #2 |
| 127 | // log.Println("Circuit Pack") |
| 128 | pkt = []byte{ |
| 129 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 130 | 0x00, 0x06, 0x01, 0x01, 0x0f, 0x00, 0x42, 0x52, |
| 131 | 0x43, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 132 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 133 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 134 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 135 | case 3: |
| 136 | // Circuit Pack (6) - #3 |
| 137 | // log.Println("Circuit Pack") |
| 138 | pkt = []byte{ |
| 139 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 140 | 0x00, 0x06, 0x01, 0x01, 0x00, 0xf8, 0x20, 0x20, |
| 141 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 142 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 143 | 0x20, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, |
| 144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 145 | case 4: |
| 146 | // Circuit Pack (6) - #4 |
| 147 | // log.Println("Circuit Pack") |
| 148 | pkt = []byte{ |
| 149 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 150 | 0x00, 0x06, 0x01, 0x01, 0x00, 0x04, 0x00, 0x00, |
| 151 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 152 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 153 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 154 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 155 | case 5: |
| 156 | // Circuit Pack (6) - #5 |
| 157 | // log.Println("Circuit Pack") |
| 158 | pkt = []byte{ |
| 159 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 160 | 0x00, 0x06, 0x01, 0x80, 0xf0, 0x00, 0xee, 0x01, |
| 161 | 0x49, 0x53, 0x4b, 0x54, 0x71, 0xe8, 0x00, 0x80, |
| 162 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 163 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, |
| 164 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 165 | case 6: |
| 166 | // Circuit Pack (6) - #6 |
| 167 | // log.Println("Circuit Pack") |
| 168 | pkt = []byte{ |
| 169 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 170 | 0x00, 0x06, 0x01, 0x80, 0x0f, 0x00, 0x42, 0x52, |
| 171 | 0x43, 0x4d, 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} |
| 175 | case 7: |
| 176 | // Circuit Pack (6) - #7 |
| 177 | // log.Println("Circuit Pack") |
| 178 | pkt = []byte{ |
| 179 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 180 | 0x00, 0x06, 0x01, 0x80, 0x00, 0xf8, 0x20, 0x20, |
| 181 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 182 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, |
| 183 | 0x20, 0x20, 0x00, 0x08, 0x40, 0x10, 0x00, 0x00, |
| 184 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 185 | case 8: |
| 186 | // Circuit Pack (6) - #8 |
| 187 | // log.Println("Circuit Pack") |
| 188 | pkt = []byte{ |
| 189 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 190 | 0x00, 0x06, 0x01, 0x80, 0x00, 0x04, 0x00, 0x00, |
| 191 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 192 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 193 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 194 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 195 | case 9, 10, 11, 12: |
| 196 | // PPTP (11) |
| 197 | // log.Println("PPTP") |
| 198 | pkt = []byte{ |
| 199 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 200 | 0x00, 0x0b, 0x01, 0x01, 0xff, 0xfe, 0x00, 0x2f, |
| 201 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0xee, 0x00, |
| 202 | 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 203 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 204 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 205 | pkt[11] = state.pptpInstance // ME Instance |
| 206 | state.pptpInstance++ |
| 207 | case 13, 14, 15, 16, 17, 18, 19, 20: |
| 208 | // T-CONT (262) |
| 209 | // log.Println("T-CONT") |
| 210 | pkt = []byte{ |
| 211 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 212 | 0x01, 0x06, 0x80, 0x00, 0xe0, 0x00, 0xff, 0xff, |
| 213 | 0x01, 0x01, 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 | |
| 218 | state.tcontInstance++ |
| 219 | pkt[11] = state.tcontInstance // TCONT ME Instance |
| 220 | |
| 221 | case 21: |
| 222 | // ANI-G (263) |
| 223 | // log.Println("ANI-G") |
| 224 | pkt = []byte{ |
| 225 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 226 | 0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00, |
| 227 | 0x08, 0x00, 0x30, 0x00, 0x00, 0x05, 0x09, 0x00, |
| 228 | 0x00, 0xe0, 0x54, 0xff, 0xff, 0x00, 0x00, 0x0c, |
| 229 | 0x63, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 230 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 231 | case 22, 23, 24, 25: |
| 232 | // UNI-G (264) |
| 233 | // log.Println("UNI-G") |
| 234 | pkt = []byte{ |
| 235 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 236 | 0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00, |
| 237 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 238 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 239 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 240 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 241 | pkt[11] = state.uniGInstance // UNI-G ME Instance |
| 242 | state.uniGInstance++ |
| 243 | |
| 244 | case 26, 30, 34, 38, 42, 46, 50, 54, |
| 245 | 58, 62, 66, 70, 74, 78, 82, 86, |
| 246 | 90, 94, 98, 102, 106, 110, 114, 118, |
| 247 | 122, 126, 130, 134, 138, 142, 146, 150, |
| 248 | 154, 158, 162, 166, 170, 174, 178, 182, |
| 249 | 186, 190, 194, 198, 202, 206, 210, 214, |
| 250 | 218, 222, 226, 230, 234, 238, 242, 246, |
| 251 | 250, 254, 258, 262, 266, 270, 274, 278: |
| 252 | // Prior-Q with mask downstream |
| 253 | log.Tracef("Mib-upload for prior-q with mask") |
| 254 | // For downstream PQ, pkt[10] is 0x00 |
| 255 | // So the instanceId will be like 0x0001, 0x0002,... etc |
| 256 | pkt = []byte{ |
| 257 | 0x00, 0x42, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00, |
| 258 | 0x01, 0x15, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, |
| 259 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 260 | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 261 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 262 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 263 | } |
| 264 | state.priorQInstance++ |
| 265 | pkt[11] = state.priorQInstance |
| 266 | |
| 267 | case 27, 31, 35, 39, 43, 47, 51, 55, |
| 268 | 59, 63, 67, 71, 75, 79, 83, 87, |
| 269 | 91, 95, 99, 103, 107, 111, 115, 119, |
| 270 | 123, 127, 131, 135, 139, 143, 147, 151, |
| 271 | 155, 159, 163, 167, 171, 175, 179, 183, |
| 272 | 187, 191, 195, 199, 203, 207, 211, 215, |
| 273 | 219, 223, 227, 231, 235, 239, 243, 247, |
| 274 | 251, 255, 259, 263, 267, 271, 275, 279: |
| 275 | // Prior-Q with attribute list downstream |
| 276 | // log.Println("Mib-upload for prior-q with attribute list") |
| 277 | pkt = []byte{ |
| 278 | 0x00, 0x43, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00, |
| 279 | 0x01, 0x15, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x01, |
| 280 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
| 281 | 0x20, 0x00, 0x00, 0x01, 0x20, 0x01, 0x00, 0x01, |
| 282 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 283 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 284 | } |
| 285 | |
| 286 | pkt[11] = state.priorQInstance |
| 287 | |
| 288 | // Group 8 PriorQ to point to a particular TCONT |
| 289 | // Priority for each group of PriorQ is 0 - 7 |
| 290 | if state.priorQPriority % NumPriorQPerTcont == 0 { |
| 291 | state.tcontPointer++ |
| 292 | } |
| 293 | |
| 294 | // Only for verification. To be removed |
| 295 | if state.tcontPointer > state.tcontInstance { |
| 296 | log.Tracef("Error: Invalid TcontPointer") |
| 297 | break |
| 298 | } |
| 299 | |
| 300 | pkt[24] = state.tcontPointer |
| 301 | pkt[26] = state.priorQPriority % NumPriorQPerTcont |
| 302 | pkt[28] = state.tcontInstance |
| 303 | |
| 304 | case 28, 32, 36, 40, 44, 48, 52, 56, |
| 305 | 60, 64, 68, 72, 76, 80, 84, 88, |
| 306 | 92, 96, 100, 104, 108, 112, 116, 120, |
| 307 | 124, 128, 132, 136, 140, 144, 148, 152, |
| 308 | 156, 160, 164, 168, 172, 176, 180, 184, |
| 309 | 188, 192, 196, 200, 204, 208, 212, 216, |
| 310 | 220, 224, 228, 232, 236, 240, 244, 248, |
| 311 | 252, 256, 260, 264, 268, 272, 276, 280: |
| 312 | // Prior-Q with mask upstream |
| 313 | // log.Println("Mib-upload for prior-q with mask") |
| 314 | pkt = []byte{ |
| 315 | 0x00, 0x42, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00, |
| 316 | 0x01, 0x15, 0x80, 0x00, 0x00, 0x0f, 0xff, 0xff, |
| 317 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 318 | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 319 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 320 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 321 | } |
| 322 | pkt[11] = state.priorQInstance |
| 323 | |
| 324 | case 29, 33, 37, 41, 45, 49, 53, 57, |
| 325 | 61, 65, 69, 73, 77, 81, 85, 89, |
| 326 | 93, 97, 101, 105, 109, 113, 117, 121, |
| 327 | 125, 129, 133, 137, 141, 145, 149, 153, |
| 328 | 157, 161, 165, 169, 173, 177, 181, 185, |
| 329 | 189, 193, 197, 201, 205, 209, 213, 217, |
| 330 | 221, 225, 229, 233, 237, 241, 245, 249, |
| 331 | 253, 257, 261, 265, 269, 273, 277, 281: |
| 332 | // Prior-Q with attribute list upstream |
| 333 | // log.Println("Mib-upload for prior-q with attribute list") |
| 334 | // For upstream pkt[10] is fixed as 80 |
| 335 | // So for upstream PQ, instanceId will be like 0x8001, 0x8002 ... etc |
| 336 | pkt = []byte{ |
| 337 | 0x00, 0x43, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00, |
| 338 | 0x01, 0x15, 0x80, 0x00, 0xff, 0xf0, 0x00, 0x01, |
| 339 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
| 340 | 0x20, 0x00, 0x00, 0x80, 0x20, 0x01, 0x00, 0x01, |
| 341 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 342 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 343 | } |
| 344 | |
| 345 | pkt[11] = state.priorQInstance |
| 346 | pkt[24] = state.tcontPointer |
| 347 | pkt[26] = state.priorQPriority % NumPriorQPerTcont // Priority of this PriorQ |
| 348 | pkt[28] = state.tcontInstance |
| 349 | state.priorQPriority++ |
| 350 | |
| 351 | |
| 352 | case 282, 283, 284, 285, 286, 287, 288, 289: |
| 353 | // Traffic Scheduler |
| 354 | // log.Println("Traffic Scheduler") |
| 355 | pkt = []byte{ |
| 356 | 0x02, 0xa4, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00, |
| 357 | 0x01, 0x16, 0x80, 0x00, 0xf0, 0x00, 0x80, 0x00, |
| 358 | 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 359 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 360 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 361 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 362 | } |
| 363 | |
| 364 | pkt[15] = state.tcontInstance |
| 365 | state.tcontInstance++ |
| 366 | |
| 367 | case 290: |
| 368 | // ONT-2G |
| 369 | // log.Println("ONT-2G") |
| 370 | pkt = []byte{ |
| 371 | 0x00, 0x16, 0x2e, 0x0a, 0x00, 0x02, 0x00, 0x00, |
| 372 | 0x01, 0x01, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x40, |
| 373 | 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 374 | 0x00, 0x7f, 0x00, 0x00, 0x3f, 0x00, 0x01, 0x00, |
| 375 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 376 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 377 | } |
| 378 | |
| 379 | default: |
| 380 | state.extraMibUploadCtr++ |
| 381 | errstr := fmt.Sprintf("%v - Invalid MibUpload request: %d, extras: %d", key, state.mibUploadCtr, state) |
| 382 | return nil, errors.New(errstr) |
| 383 | } |
| 384 | |
| 385 | state.mibUploadCtr++ |
| 386 | return pkt, nil |
| 387 | } |
| 388 | |
| 389 | func set(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 390 | var pkt []byte |
| 391 | |
| 392 | pkt = []byte{ |
| 393 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 394 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 395 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 396 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 397 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 398 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 399 | |
| 400 | log.WithFields(log.Fields{ |
| 401 | "IntfId": key.IntfId, |
| 402 | "OnuId": key.OnuId, |
| 403 | }).Tracef("Omci Set") |
| 404 | |
| 405 | return pkt, nil |
| 406 | } |
| 407 | |
| 408 | func create(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 409 | var pkt []byte |
| 410 | |
| 411 | if class == GEMPortNetworkCTP { |
| 412 | OnuOmciStateMapLock.RLock() |
| 413 | defer OnuOmciStateMapLock.RUnlock() |
| 414 | if onuOmciState, ok := OnuOmciStateMap[key]; !ok { |
| 415 | log.WithFields(log.Fields{ |
| 416 | "IntfId": key.IntfId, |
| 417 | "OnuId": key.OnuId, |
| 418 | }).Tracef("ONU Key Error") |
| 419 | return nil, errors.New("ONU Key Error") |
| 420 | } else { |
| 421 | onuOmciState.gemPortId = binary.BigEndian.Uint16(content[:2]) |
| 422 | log.WithFields(log.Fields{ |
| 423 | "IntfId": key.IntfId, |
| 424 | "OnuId": key.OnuId, |
| 425 | }).Tracef("Gem Port Id %d", key, onuOmciState) |
| 426 | // FIXME |
| 427 | OnuOmciStateMap[key].state = DONE |
| 428 | omciCh <- OmciChMessage{ |
| 429 | Type: GemPortAdded, |
| 430 | Data: OmciChMessageData{ |
| 431 | OnuId: key.OnuId, |
| 432 | IntfId: key.IntfId, |
| 433 | }, |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | pkt = []byte{ |
| 439 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x01, |
| 440 | 0x00, 0x00, 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 | |
| 446 | log.WithFields(log.Fields{ |
| 447 | "IntfId": key.IntfId, |
| 448 | "OnuId": key.OnuId, |
| 449 | }).Tracef("Omci Create") |
| 450 | |
| 451 | return pkt, nil |
| 452 | } |
| 453 | |
| 454 | func get(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 455 | var pkt []byte |
| 456 | |
| 457 | pkt = []byte{ |
| 458 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x02, 0x01, |
| 459 | 0x00, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 460 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 461 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 462 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 463 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 464 | |
| 465 | pkt = GetAttributes(class, content, key, pkt) |
| 466 | |
| 467 | log.WithFields(log.Fields{ |
| 468 | "IntfId": key.IntfId, |
| 469 | "OnuId": key.OnuId, |
| 470 | }).Tracef("Omci Get") |
| 471 | return pkt, nil |
| 472 | } |
| 473 | |
| 474 | func getAllAlarms(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 475 | var pkt []byte |
| 476 | |
| 477 | pkt = []byte{ |
| 478 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 479 | 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 480 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 481 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 482 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 483 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 484 | |
| 485 | log.WithFields(log.Fields{ |
| 486 | "IntfId": key.IntfId, |
| 487 | "OnuId": key.OnuId, |
| 488 | }).Tracef("Omci GetAllAlarms") |
| 489 | |
| 490 | return pkt, nil |
| 491 | } |
| 492 | |
| 493 | func syncTime(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 494 | var pkt []byte |
| 495 | |
| 496 | pkt = []byte{ |
| 497 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 498 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 499 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 500 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 501 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 502 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 503 | |
| 504 | log.WithFields(log.Fields{ |
| 505 | "IntfId": key.IntfId, |
| 506 | "OnuId": key.OnuId, |
| 507 | }).Tracef("Omci syncTime") |
| 508 | |
| 509 | return pkt, nil |
| 510 | } |
| 511 | |
| 512 | func getAllAlarmsNext(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 513 | var pkt []byte |
| 514 | |
| 515 | pkt = []byte{ |
| 516 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 517 | 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, |
| 518 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 519 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 520 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 521 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 522 | |
| 523 | log.WithFields(log.Fields{ |
| 524 | "IntfId": key.IntfId, |
| 525 | "OnuId": key.OnuId, |
| 526 | }).Tracef("Omci GetAllAlarmsNext") |
| 527 | |
| 528 | return pkt, nil |
| 529 | } |
| 530 | |
| 531 | func delete(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 532 | var pkt []byte |
| 533 | |
| 534 | pkt = []byte{ |
| 535 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 536 | 0x00, 0x0b, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, |
| 537 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 538 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 539 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 540 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 541 | |
| 542 | log.WithFields(log.Fields{ |
| 543 | "IntfId": key.IntfId, |
| 544 | "OnuId": key.OnuId, |
| 545 | }).Tracef("Omci Delete") |
| 546 | |
| 547 | return pkt, nil |
| 548 | } |
| 549 | |
| 550 | func reboot(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) { |
| 551 | var pkt []byte |
| 552 | pkt = []byte{ |
| 553 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 554 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 555 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 556 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 557 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 558 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} |
| 559 | |
| 560 | log.WithFields(log.Fields{ |
| 561 | "IntfId": key.IntfId, |
| 562 | "OnuId": key.OnuId, |
| 563 | }).Tracef("Omci Reboot") |
| 564 | return pkt, nil |
| 565 | } |
| 566 | |