blob: 880681b1f4f59f5001ad240f654844af306ca349 [file] [log] [blame]
Matteo Scandolo86e8ce62019-10-11 12:03:10 -07001/*
Joey Armstrong2c039362024-02-04 18:51:52 -05002 * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
Matteo Scandolo86e8ce62019-10-11 12:03:10 -07003
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 Scandolof9d43412021-01-12 11:11:34 -080017package types
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070018
19import (
20 "github.com/google/gopacket"
Matteo Scandolo40e067f2019-10-16 16:59:41 -070021 "github.com/opencord/bbsim/internal/bbsim/packetHandlers"
Andrea Campanella10426e22021-10-15 17:58:04 +020022 "github.com/opencord/omci-lib-go/v2"
David K. Bainbridgec415efe2021-08-19 13:05:21 +000023 "github.com/opencord/voltha-protos/v5/go/openolt"
Matteo Scandolo4a036262020-08-17 15:56:13 -070024 "net"
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070025)
26
27type MessageType int
28
29const (
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080030 OltIndication MessageType = 0
31 NniIndication MessageType = 1
32 PonIndication MessageType = 2
33 OnuDiscIndication MessageType = 3
34 OnuIndication MessageType = 4
35 OMCI MessageType = 5
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070036 FlowAdd MessageType = 6
37 FlowRemoved MessageType = 18
Matteo Scandoloadc72a82020-09-08 18:46:08 -070038 StartEAPOL MessageType = 7
39 StartDHCP MessageType = 8
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080040 OnuPacketOut MessageType = 9
Matteo Scandolo40e067f2019-10-16 16:59:41 -070041
42 // BBR messages
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080043 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 Baker41724b82020-01-21 19:54:53 -080047
Arjun E K57a7fcb2020-01-30 06:44:45 +000048 //IGMP
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080049 IGMPMembershipReportV2 MessageType = 14 // Version 2 Membership Report (JOIN)
50 IGMPLeaveGroup MessageType = 15 // Leave Group
Arjun E K57a7fcb2020-01-30 06:44:45 +000051
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080052 AlarmIndication MessageType = 16 // message data is an openolt.AlarmIndication
53 IGMPMembershipReportV3 MessageType = 17 // Version 3 Membership Report
Matteo Scandolof9d43412021-01-12 11:11:34 -080054 UniStatusAlarm MessageType = 19
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070055)
56
57func (m MessageType) String() string {
58 names := [...]string{
59 "OltIndication",
60 "NniIndication",
61 "PonIndication",
62 "OnuDiscIndication",
63 "OnuIndication",
64 "OMCI",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070065 "FlowAdd",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070066 "StartEAPOL",
67 "StartDHCP",
68 "OnuPacketOut",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070069 "OmciIndication",
70 "SendEapolFlow",
71 "SendDhcpFlow",
72 "OnuPacketIn",
Arjun E K57a7fcb2020-01-30 06:44:45 +000073 "IGMPMembershipReportV2",
74 "IGMPLeaveGroup",
Matteo Scandoloec170af2021-10-07 11:53:22 -070075 "AlarmIndication",
Anand S Katti09541352020-01-29 15:54:01 +053076 "IGMPMembershipReportV3",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070077 "FlowRemoved",
Matteo Scandolof9d43412021-01-12 11:11:34 -080078 "UniStatusAlarm",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070079 }
80 return names[m]
81}
82
83type Message struct {
84 Type MessageType
85 Data interface{}
86}
87
88type OltIndicationMessage struct {
89 OperState OperState
90}
91
92type NniIndicationMessage struct {
93 OperState OperState
94 NniPortID uint32
95}
96
97type PonIndicationMessage struct {
98 OperState OperState
99 PonPortID uint32
100}
101
102type OnuDiscIndicationMessage struct {
103 OperState OperState
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700104}
105
106type OnuIndicationMessage struct {
107 OperState OperState
108 PonPortID uint32
109 OnuID uint32
110 OnuSN *openolt.SerialNumber
111}
112
Matteo Scandolof9d43412021-01-12 11:11:34 -0800113// these are OMCI messages going from VOLTHA to the OLT
114// used by BBSim
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700115type OmciMessage struct {
116 OnuSN *openolt.SerialNumber
117 OnuID uint32
Matteo Scandolob5913142021-03-19 16:10:18 -0700118 OmciMsg *omci.OMCI
119 OmciPkt gopacket.Packet
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700120}
121
Matteo Scandolof9d43412021-01-12 11:11:34 -0800122type UniStatusAlarmMessage struct {
Himani Chawla13b1ee02021-03-15 01:43:53 +0530123 OnuSN *openolt.SerialNumber
124 OnuID uint32
125 AdminState uint8
126 EntityID uint16
127 RaiseOMCIAlarm bool
Matteo Scandolof9d43412021-01-12 11:11:34 -0800128}
129
130// these are OMCI messages going from the OLT to VOLTHA
131// these messages are received by BBR
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700132type OmciIndicationMessage struct {
133 OnuSN *openolt.SerialNumber
134 OnuID uint32
135 OmciInd *openolt.OmciIndication
136}
137
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700138type OnuFlowUpdateMessage struct {
139 PonPortID uint32
140 OnuID uint32
141 Flow *openolt.Flow
142}
143
144type PacketMessage struct {
145 PonPortID uint32
146 OnuID uint32
147}
148
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700149type OnuPacketMessage struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700150 IntfId uint32
151 OnuId uint32
Matteo Scandolo8a574812021-05-20 15:18:53 -0700152 PortNo uint32
Matteo Scandolo4a036262020-08-17 15:56:13 -0700153 Packet gopacket.Packet
154 Type packetHandlers.PacketType
155 MacAddress net.HardwareAddr
156 GemPortId uint32 // this is used by BBR
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700157}
158
Onur Kalinagac9f9faca2021-01-21 14:04:34 +0000159type IgmpMessage struct {
160 GroupAddress string
161}
162
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700163type OperState int
164
165const (
166 UP OperState = iota
Shrey Baid688b4242020-07-10 20:40:10 +0530167 DOWN // The device has been discovered, but not yet activated
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700168)
169
170func (m OperState) String() string {
171 names := [...]string{
172 "up",
173 "down",
174 }
175 return names[m]
176}