blob: 3afe7fbb9d435a564b1688179c795dff9676f86e [file] [log] [blame]
Matteo Scandolo86e8ce62019-10-11 12:03:10 -07001/*
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 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"
Matteo Scandolo4f4ac792020-10-01 16:33:21 -070022 "github.com/opencord/voltha-protos/v4/go/openolt"
Matteo Scandolo4a036262020-08-17 15:56:13 -070023 "net"
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070024)
25
26type MessageType int
27
28const (
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080029 OltIndication MessageType = 0
30 NniIndication MessageType = 1
31 PonIndication MessageType = 2
32 OnuDiscIndication MessageType = 3
33 OnuIndication MessageType = 4
34 OMCI MessageType = 5
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070035 FlowAdd MessageType = 6
36 FlowRemoved MessageType = 18
Matteo Scandoloadc72a82020-09-08 18:46:08 -070037 StartEAPOL MessageType = 7
38 StartDHCP MessageType = 8
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080039 OnuPacketOut MessageType = 9
Matteo Scandolo40e067f2019-10-16 16:59:41 -070040
41 // BBR messages
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080042 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 Baker41724b82020-01-21 19:54:53 -080046
Arjun E K57a7fcb2020-01-30 06:44:45 +000047 //IGMP
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080048 IGMPMembershipReportV2 MessageType = 14 // Version 2 Membership Report (JOIN)
49 IGMPLeaveGroup MessageType = 15 // Leave Group
Arjun E K57a7fcb2020-01-30 06:44:45 +000050
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080051 AlarmIndication MessageType = 16 // message data is an openolt.AlarmIndication
52 IGMPMembershipReportV3 MessageType = 17 // Version 3 Membership Report
Matteo Scandolof9d43412021-01-12 11:11:34 -080053 UniStatusAlarm MessageType = 19
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070054)
55
56func (m MessageType) String() string {
57 names := [...]string{
58 "OltIndication",
59 "NniIndication",
60 "PonIndication",
61 "OnuDiscIndication",
62 "OnuIndication",
63 "OMCI",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070064 "FlowAdd",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070065 "StartEAPOL",
66 "StartDHCP",
67 "OnuPacketOut",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070068 "OmciIndication",
69 "SendEapolFlow",
70 "SendDhcpFlow",
71 "OnuPacketIn",
Arjun E K57a7fcb2020-01-30 06:44:45 +000072 "IGMPMembershipReportV2",
73 "IGMPLeaveGroup",
Anand S Katti09541352020-01-29 15:54:01 +053074 "IGMPMembershipReportV3",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070075 "FlowRemoved",
Matteo Scandolof9d43412021-01-12 11:11:34 -080076 "UniStatusAlarm",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070077 }
78 return names[m]
79}
80
81type Message struct {
82 Type MessageType
83 Data interface{}
84}
85
86type OltIndicationMessage struct {
87 OperState OperState
88}
89
90type NniIndicationMessage struct {
91 OperState OperState
92 NniPortID uint32
93}
94
95type PonIndicationMessage struct {
96 OperState OperState
97 PonPortID uint32
98}
99
100type OnuDiscIndicationMessage struct {
101 OperState OperState
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700102}
103
104type OnuIndicationMessage struct {
105 OperState OperState
106 PonPortID uint32
107 OnuID uint32
108 OnuSN *openolt.SerialNumber
109}
110
Matteo Scandolof9d43412021-01-12 11:11:34 -0800111// these are OMCI messages going from VOLTHA to the OLT
112// used by BBSim
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700113type OmciMessage struct {
114 OnuSN *openolt.SerialNumber
115 OnuID uint32
Matteo Scandolof9d43412021-01-12 11:11:34 -0800116 OmciMsg *openolt.OmciMsg
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700117}
118
Matteo Scandolof9d43412021-01-12 11:11:34 -0800119type 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 Scandolo40e067f2019-10-16 16:59:41 -0700128type OmciIndicationMessage struct {
129 OnuSN *openolt.SerialNumber
130 OnuID uint32
131 OmciInd *openolt.OmciIndication
132}
133
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700134type OnuFlowUpdateMessage struct {
135 PonPortID uint32
136 OnuID uint32
137 Flow *openolt.Flow
138}
139
140type PacketMessage struct {
141 PonPortID uint32
142 OnuID uint32
143}
144
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700145type OnuPacketMessage struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700146 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 Scandolo86e8ce62019-10-11 12:03:10 -0700152}
153
Onur Kalinagac9f9faca2021-01-21 14:04:34 +0000154type IgmpMessage struct {
155 GroupAddress string
156}
157
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700158type OperState int
159
160const (
161 UP OperState = iota
Shrey Baid688b4242020-07-10 20:40:10 +0530162 DOWN // The device has been discovered, but not yet activated
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700163)
164
165func (m OperState) String() string {
166 names := [...]string{
167 "up",
168 "down",
169 }
170 return names[m]
171}