Shad Ansari | 1106b02 | 2019-01-16 22:22:35 -0800 | [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 | package core |
| 17 | |
| 18 | type OnuOmciState struct { |
| 19 | gemPortId uint16 |
| 20 | mibUploadCtr uint16 |
| 21 | uniGInstance uint8 |
| 22 | tcontInstance uint8 |
| 23 | pptpInstance uint8 |
| 24 | state istate |
| 25 | } |
| 26 | |
| 27 | type istate int |
| 28 | |
| 29 | // TODO - Needs to reflect real ONU/OMCI state |
| 30 | const ( |
| 31 | INCOMPLETE istate = iota |
| 32 | DONE |
| 33 | ) |
| 34 | |
| 35 | var OnuOmciStateMap = map[OnuKey]*OnuOmciState{} |
| 36 | |
| 37 | func NewOnuOmciState() *OnuOmciState { |
| 38 | return &OnuOmciState{gemPortId: 0, mibUploadCtr: 0, uniGInstance: 1, tcontInstance: 0, pptpInstance: 1} |
| 39 | } |
| 40 | |
| 41 | func GetOnuOmciState(onuId uint32, intfId uint32) istate { |
Shad Ansari | 3259e6d | 2019-01-17 15:51:19 -0800 | [diff] [blame] | 42 | key := OnuKey{intfId, onuId} |
| 43 | if onu, ok := OnuOmciStateMap[key]; ok { |
| 44 | return onu.state |
| 45 | } else { |
| 46 | return INCOMPLETE |
| 47 | } |
Shad Ansari | 1106b02 | 2019-01-16 22:22:35 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | func GetGemPortId(onuId uint32, intfId uint32) uint16 { |
| 51 | key := OnuKey{intfId, onuId} |
| 52 | return (OnuOmciStateMap[key].gemPortId) |
| 53 | } |