Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -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 devices |
| 18 | |
| 19 | import ( |
| 20 | "github.com/google/gopacket" |
| 21 | "github.com/opencord/voltha-protos/go/openolt" |
| 22 | ) |
| 23 | |
| 24 | type MessageType int |
| 25 | |
| 26 | const ( |
| 27 | OltIndication MessageType = 0 |
| 28 | NniIndication MessageType = 1 |
| 29 | PonIndication MessageType = 2 |
| 30 | OnuDiscIndication MessageType = 3 |
| 31 | OnuIndication MessageType = 4 |
| 32 | OMCI MessageType = 5 |
| 33 | FlowUpdate MessageType = 6 |
| 34 | StartEAPOL MessageType = 7 |
| 35 | StartDHCP MessageType = 8 |
| 36 | OnuPacketOut MessageType = 9 |
| 37 | DyingGaspIndication MessageType = 10 |
| 38 | ) |
| 39 | |
| 40 | func (m MessageType) String() string { |
| 41 | names := [...]string{ |
| 42 | "OltIndication", |
| 43 | "NniIndication", |
| 44 | "PonIndication", |
| 45 | "OnuDiscIndication", |
| 46 | "OnuIndication", |
| 47 | "OMCI", |
| 48 | "FlowUpdate", |
| 49 | "StartEAPOL", |
| 50 | "StartDHCP", |
| 51 | "OnuPacketOut", |
| 52 | "DyingGaspIndication", |
| 53 | } |
| 54 | return names[m] |
| 55 | } |
| 56 | |
| 57 | type Message struct { |
| 58 | Type MessageType |
| 59 | Data interface{} |
| 60 | } |
| 61 | |
| 62 | type OltIndicationMessage struct { |
| 63 | OperState OperState |
| 64 | } |
| 65 | |
| 66 | type NniIndicationMessage struct { |
| 67 | OperState OperState |
| 68 | NniPortID uint32 |
| 69 | } |
| 70 | |
| 71 | type PonIndicationMessage struct { |
| 72 | OperState OperState |
| 73 | PonPortID uint32 |
| 74 | } |
| 75 | |
| 76 | type OnuDiscIndicationMessage struct { |
| 77 | OperState OperState |
| 78 | Onu Onu |
| 79 | } |
| 80 | |
| 81 | type OnuIndicationMessage struct { |
| 82 | OperState OperState |
| 83 | PonPortID uint32 |
| 84 | OnuID uint32 |
| 85 | OnuSN *openolt.SerialNumber |
| 86 | } |
| 87 | |
| 88 | type OmciMessage struct { |
| 89 | OnuSN *openolt.SerialNumber |
| 90 | OnuID uint32 |
| 91 | omciMsg *openolt.OmciMsg |
| 92 | } |
| 93 | |
| 94 | type OnuFlowUpdateMessage struct { |
| 95 | PonPortID uint32 |
| 96 | OnuID uint32 |
| 97 | Flow *openolt.Flow |
| 98 | } |
| 99 | |
| 100 | type PacketMessage struct { |
| 101 | PonPortID uint32 |
| 102 | OnuID uint32 |
| 103 | } |
| 104 | |
| 105 | type OnuPacketOutMessage struct { |
| 106 | IntfId uint32 |
| 107 | OnuId uint32 |
| 108 | Packet gopacket.Packet |
| 109 | } |
| 110 | |
| 111 | type DyingGaspIndicationMessage struct { |
| 112 | PonPortID uint32 |
| 113 | OnuID uint32 |
| 114 | Status string |
| 115 | } |
| 116 | |
| 117 | type OperState int |
| 118 | |
| 119 | const ( |
| 120 | UP OperState = iota |
| 121 | DOWN // The device has been discovered, but not yet activated |
| 122 | ) |
| 123 | |
| 124 | func (m OperState) String() string { |
| 125 | names := [...]string{ |
| 126 | "up", |
| 127 | "down", |
| 128 | } |
| 129 | return names[m] |
| 130 | } |