Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 1 | /* |
Joey Armstrong | 14628cd | 2023-01-10 08:38:31 -0500 | [diff] [blame^] | 2 | * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 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 | |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 17 | package types |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 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" |
Andrea Campanella | 10426e2 | 2021-10-15 17:58:04 +0200 | [diff] [blame] | 22 | "github.com/opencord/omci-lib-go/v2" |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 23 | "github.com/opencord/voltha-protos/v5/go/openolt" |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 24 | "net" |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | type MessageType int |
| 28 | |
| 29 | const ( |
Matteo Scandolo | d7cc6d3 | 2020-02-26 16:51:12 -0800 | [diff] [blame] | 30 | OltIndication MessageType = 0 |
| 31 | NniIndication MessageType = 1 |
| 32 | PonIndication MessageType = 2 |
| 33 | OnuDiscIndication MessageType = 3 |
| 34 | OnuIndication MessageType = 4 |
| 35 | OMCI MessageType = 5 |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 36 | FlowAdd MessageType = 6 |
| 37 | FlowRemoved MessageType = 18 |
Matteo Scandolo | adc72a8 | 2020-09-08 18:46:08 -0700 | [diff] [blame] | 38 | StartEAPOL MessageType = 7 |
| 39 | StartDHCP MessageType = 8 |
Matteo Scandolo | d7cc6d3 | 2020-02-26 16:51:12 -0800 | [diff] [blame] | 40 | OnuPacketOut MessageType = 9 |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 41 | |
| 42 | // BBR messages |
Matteo Scandolo | d7cc6d3 | 2020-02-26 16:51:12 -0800 | [diff] [blame] | 43 | OmciIndication MessageType = 10 // this are OMCI messages going from the OLT to VOLTHA |
| 44 | SendEapolFlow MessageType = 11 |
| 45 | SendDhcpFlow MessageType = 12 |
| 46 | OnuPacketIn MessageType = 13 |
Scott Baker | 41724b8 | 2020-01-21 19:54:53 -0800 | [diff] [blame] | 47 | |
Arjun E K | 57a7fcb | 2020-01-30 06:44:45 +0000 | [diff] [blame] | 48 | //IGMP |
Matteo Scandolo | d7cc6d3 | 2020-02-26 16:51:12 -0800 | [diff] [blame] | 49 | IGMPMembershipReportV2 MessageType = 14 // Version 2 Membership Report (JOIN) |
| 50 | IGMPLeaveGroup MessageType = 15 // Leave Group |
Arjun E K | 57a7fcb | 2020-01-30 06:44:45 +0000 | [diff] [blame] | 51 | |
Matteo Scandolo | d7cc6d3 | 2020-02-26 16:51:12 -0800 | [diff] [blame] | 52 | AlarmIndication MessageType = 16 // message data is an openolt.AlarmIndication |
| 53 | IGMPMembershipReportV3 MessageType = 17 // Version 3 Membership Report |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 54 | UniStatusAlarm MessageType = 19 |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 55 | ) |
| 56 | |
| 57 | func (m MessageType) String() string { |
| 58 | names := [...]string{ |
| 59 | "OltIndication", |
| 60 | "NniIndication", |
| 61 | "PonIndication", |
| 62 | "OnuDiscIndication", |
| 63 | "OnuIndication", |
| 64 | "OMCI", |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 65 | "FlowAdd", |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 66 | "StartEAPOL", |
| 67 | "StartDHCP", |
| 68 | "OnuPacketOut", |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 69 | "OmciIndication", |
| 70 | "SendEapolFlow", |
| 71 | "SendDhcpFlow", |
| 72 | "OnuPacketIn", |
Arjun E K | 57a7fcb | 2020-01-30 06:44:45 +0000 | [diff] [blame] | 73 | "IGMPMembershipReportV2", |
| 74 | "IGMPLeaveGroup", |
Matteo Scandolo | ec170af | 2021-10-07 11:53:22 -0700 | [diff] [blame] | 75 | "AlarmIndication", |
Anand S Katti | 0954135 | 2020-01-29 15:54:01 +0530 | [diff] [blame] | 76 | "IGMPMembershipReportV3", |
Matteo Scandolo | eb6b5af | 2020-06-24 16:23:58 -0700 | [diff] [blame] | 77 | "FlowRemoved", |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 78 | "UniStatusAlarm", |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 79 | } |
| 80 | return names[m] |
| 81 | } |
| 82 | |
| 83 | type Message struct { |
| 84 | Type MessageType |
| 85 | Data interface{} |
| 86 | } |
| 87 | |
| 88 | type OltIndicationMessage struct { |
| 89 | OperState OperState |
| 90 | } |
| 91 | |
| 92 | type NniIndicationMessage struct { |
| 93 | OperState OperState |
| 94 | NniPortID uint32 |
| 95 | } |
| 96 | |
| 97 | type PonIndicationMessage struct { |
| 98 | OperState OperState |
| 99 | PonPortID uint32 |
| 100 | } |
| 101 | |
| 102 | type OnuDiscIndicationMessage struct { |
| 103 | OperState OperState |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | type OnuIndicationMessage struct { |
| 107 | OperState OperState |
| 108 | PonPortID uint32 |
| 109 | OnuID uint32 |
| 110 | OnuSN *openolt.SerialNumber |
| 111 | } |
| 112 | |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 113 | // these are OMCI messages going from VOLTHA to the OLT |
| 114 | // used by BBSim |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 115 | type OmciMessage struct { |
| 116 | OnuSN *openolt.SerialNumber |
| 117 | OnuID uint32 |
Matteo Scandolo | b591314 | 2021-03-19 16:10:18 -0700 | [diff] [blame] | 118 | OmciMsg *omci.OMCI |
| 119 | OmciPkt gopacket.Packet |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 122 | type UniStatusAlarmMessage struct { |
Himani Chawla | 13b1ee0 | 2021-03-15 01:43:53 +0530 | [diff] [blame] | 123 | OnuSN *openolt.SerialNumber |
| 124 | OnuID uint32 |
| 125 | AdminState uint8 |
| 126 | EntityID uint16 |
| 127 | RaiseOMCIAlarm bool |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | // these are OMCI messages going from the OLT to VOLTHA |
| 131 | // these messages are received by BBR |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 132 | type OmciIndicationMessage struct { |
| 133 | OnuSN *openolt.SerialNumber |
| 134 | OnuID uint32 |
| 135 | OmciInd *openolt.OmciIndication |
| 136 | } |
| 137 | |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 138 | type OnuFlowUpdateMessage struct { |
| 139 | PonPortID uint32 |
| 140 | OnuID uint32 |
| 141 | Flow *openolt.Flow |
| 142 | } |
| 143 | |
| 144 | type PacketMessage struct { |
| 145 | PonPortID uint32 |
| 146 | OnuID uint32 |
| 147 | } |
| 148 | |
Matteo Scandolo | 40e067f | 2019-10-16 16:59:41 -0700 | [diff] [blame] | 149 | type OnuPacketMessage struct { |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 150 | IntfId uint32 |
| 151 | OnuId uint32 |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 152 | PortNo uint32 |
Matteo Scandolo | 4a03626 | 2020-08-17 15:56:13 -0700 | [diff] [blame] | 153 | Packet gopacket.Packet |
| 154 | Type packetHandlers.PacketType |
| 155 | MacAddress net.HardwareAddr |
| 156 | GemPortId uint32 // this is used by BBR |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Onur Kalinagac | 9f9faca | 2021-01-21 14:04:34 +0000 | [diff] [blame] | 159 | type IgmpMessage struct { |
| 160 | GroupAddress string |
| 161 | } |
| 162 | |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 163 | type OperState int |
| 164 | |
| 165 | const ( |
| 166 | UP OperState = iota |
Shrey Baid | 688b424 | 2020-07-10 20:40:10 +0530 | [diff] [blame] | 167 | DOWN // The device has been discovered, but not yet activated |
Matteo Scandolo | 86e8ce6 | 2019-10-11 12:03:10 -0700 | [diff] [blame] | 168 | ) |
| 169 | |
| 170 | func (m OperState) String() string { |
| 171 | names := [...]string{ |
| 172 | "up", |
| 173 | "down", |
| 174 | } |
| 175 | return names[m] |
| 176 | } |