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 | 3de9de0 | 2019-11-14 13:40:03 -0800 | [diff] [blame] | 22 | "github.com/opencord/voltha-protos/v2/go/openolt" |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 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 |
Scott Baker | 41724b8 | 2020-01-21 19:54:53 -0800 | [diff] [blame] | 45 | |
Arjun E K | 57a7fcb | 2020-01-30 06:44:45 +0000 | [diff] [blame^] | 46 | //IGMP |
| 47 | IGMPMembershipReportV2 MessageType = 15 // Version 2 Membership Report (JOIN) |
| 48 | IGMPLeaveGroup MessageType = 16 // Leave Group |
| 49 | |
| 50 | AlarmIndication MessageType = 17 // message data is an openolt.AlarmIndication |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 51 | ) |
| 52 | |
| 53 | func (m MessageType) String() string { |
| 54 | names := [...]string{ |
| 55 | "OltIndication", |
| 56 | "NniIndication", |
| 57 | "PonIndication", |
| 58 | "OnuDiscIndication", |
| 59 | "OnuIndication", |
| 60 | "OMCI", |
| 61 | "FlowUpdate", |
| 62 | "StartEAPOL", |
| 63 | "StartDHCP", |
| 64 | "OnuPacketOut", |
| 65 | "DyingGaspIndication", |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 66 | "OmciIndication", |
| 67 | "SendEapolFlow", |
| 68 | "SendDhcpFlow", |
| 69 | "OnuPacketIn", |
Arjun E K | 57a7fcb | 2020-01-30 06:44:45 +0000 | [diff] [blame^] | 70 | "IGMPMembershipReportV2", |
| 71 | "IGMPLeaveGroup", |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 72 | } |
| 73 | return names[m] |
| 74 | } |
| 75 | |
| 76 | type Message struct { |
| 77 | Type MessageType |
| 78 | Data interface{} |
| 79 | } |
| 80 | |
| 81 | type OltIndicationMessage struct { |
| 82 | OperState OperState |
| 83 | } |
| 84 | |
| 85 | type NniIndicationMessage struct { |
| 86 | OperState OperState |
| 87 | NniPortID uint32 |
| 88 | } |
| 89 | |
| 90 | type PonIndicationMessage struct { |
| 91 | OperState OperState |
| 92 | PonPortID uint32 |
| 93 | } |
| 94 | |
| 95 | type OnuDiscIndicationMessage struct { |
| 96 | OperState OperState |
Matteo Scandolo | 2742870 | 2019-10-11 16:21:16 -0700 | [diff] [blame] | 97 | Onu *Onu |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | type OnuIndicationMessage struct { |
| 101 | OperState OperState |
| 102 | PonPortID uint32 |
| 103 | OnuID uint32 |
| 104 | OnuSN *openolt.SerialNumber |
| 105 | } |
| 106 | |
| 107 | type OmciMessage struct { |
| 108 | OnuSN *openolt.SerialNumber |
| 109 | OnuID uint32 |
| 110 | omciMsg *openolt.OmciMsg |
| 111 | } |
| 112 | |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 113 | type OmciIndicationMessage struct { |
| 114 | OnuSN *openolt.SerialNumber |
| 115 | OnuID uint32 |
| 116 | OmciInd *openolt.OmciIndication |
| 117 | } |
| 118 | |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 119 | type OnuFlowUpdateMessage struct { |
| 120 | PonPortID uint32 |
| 121 | OnuID uint32 |
| 122 | Flow *openolt.Flow |
| 123 | } |
| 124 | |
| 125 | type PacketMessage struct { |
| 126 | PonPortID uint32 |
| 127 | OnuID uint32 |
| 128 | } |
| 129 | |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 130 | type OnuPacketMessage struct { |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 131 | IntfId uint32 |
| 132 | OnuId uint32 |
| 133 | Packet gopacket.Packet |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 134 | Type packetHandlers.PacketType |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | type DyingGaspIndicationMessage struct { |
| 138 | PonPortID uint32 |
| 139 | OnuID uint32 |
| 140 | Status string |
| 141 | } |
| 142 | |
| 143 | type OperState int |
| 144 | |
| 145 | const ( |
| 146 | UP OperState = iota |
| 147 | DOWN // The device has been discovered, but not yet activated |
| 148 | ) |
| 149 | |
| 150 | func (m OperState) String() string { |
| 151 | names := [...]string{ |
| 152 | "up", |
| 153 | "down", |
| 154 | } |
| 155 | return names[m] |
| 156 | } |