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