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