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