blob: 361142ca00174312f1b6031abc8813ecf4361454 [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 Scandolob5913142021-03-19 16:10:18 -070022 "github.com/opencord/omci-lib-go"
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",
Anand S Katti09541352020-01-29 15:54:01 +053075 "IGMPMembershipReportV3",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070076 "FlowRemoved",
Matteo Scandolof9d43412021-01-12 11:11:34 -080077 "UniStatusAlarm",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070078 }
79 return names[m]
80}
81
82type Message struct {
83 Type MessageType
84 Data interface{}
85}
86
87type OltIndicationMessage struct {
88 OperState OperState
89}
90
91type NniIndicationMessage struct {
92 OperState OperState
93 NniPortID uint32
94}
95
96type PonIndicationMessage struct {
97 OperState OperState
98 PonPortID uint32
99}
100
101type OnuDiscIndicationMessage struct {
102 OperState OperState
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700103}
104
105type OnuIndicationMessage struct {
106 OperState OperState
107 PonPortID uint32
108 OnuID uint32
109 OnuSN *openolt.SerialNumber
110}
111
Matteo Scandolof9d43412021-01-12 11:11:34 -0800112// these are OMCI messages going from VOLTHA to the OLT
113// used by BBSim
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700114type OmciMessage struct {
115 OnuSN *openolt.SerialNumber
116 OnuID uint32
Matteo Scandolob5913142021-03-19 16:10:18 -0700117 OmciMsg *omci.OMCI
118 OmciPkt gopacket.Packet
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700119}
120
Matteo Scandolof9d43412021-01-12 11:11:34 -0800121type UniStatusAlarmMessage struct {
Himani Chawla13b1ee02021-03-15 01:43:53 +0530122 OnuSN *openolt.SerialNumber
123 OnuID uint32
124 AdminState uint8
125 EntityID uint16
126 RaiseOMCIAlarm bool
Matteo Scandolof9d43412021-01-12 11:11:34 -0800127}
128
129// these are OMCI messages going from the OLT to VOLTHA
130// these messages are received by BBR
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700131type OmciIndicationMessage struct {
132 OnuSN *openolt.SerialNumber
133 OnuID uint32
134 OmciInd *openolt.OmciIndication
135}
136
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700137type OnuFlowUpdateMessage struct {
138 PonPortID uint32
139 OnuID uint32
140 Flow *openolt.Flow
141}
142
143type PacketMessage struct {
144 PonPortID uint32
145 OnuID uint32
146}
147
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700148type OnuPacketMessage struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700149 IntfId uint32
150 OnuId uint32
Matteo Scandolo8a574812021-05-20 15:18:53 -0700151 PortNo uint32
Matteo Scandolo4a036262020-08-17 15:56:13 -0700152 Packet gopacket.Packet
153 Type packetHandlers.PacketType
154 MacAddress net.HardwareAddr
155 GemPortId uint32 // this is used by BBR
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700156}
157
Onur Kalinagac9f9faca2021-01-21 14:04:34 +0000158type IgmpMessage struct {
159 GroupAddress string
160}
161
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700162type OperState int
163
164const (
165 UP OperState = iota
Shrey Baid688b4242020-07-10 20:40:10 +0530166 DOWN // The device has been discovered, but not yet activated
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700167)
168
169func (m OperState) String() string {
170 names := [...]string{
171 "up",
172 "down",
173 }
174 return names[m]
175}