blob: d9ed6209e7fbae2a76c9bea227374056482052c5 [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
17package devices
18
19import (
20 "github.com/google/gopacket"
Matteo Scandolo40e067f2019-10-16 16:59:41 -070021 "github.com/opencord/bbsim/internal/bbsim/packetHandlers"
Matteo Scandolo3de9de02019-11-14 13:40:03 -080022 "github.com/opencord/voltha-protos/v2/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 Scandolod7cc6d32020-02-26 16:51:12 -080037 OnuPacketOut MessageType = 9
Matteo Scandolo40e067f2019-10-16 16:59:41 -070038
39 // BBR messages
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080040 OmciIndication MessageType = 10 // this are OMCI messages going from the OLT to VOLTHA
41 SendEapolFlow MessageType = 11
42 SendDhcpFlow MessageType = 12
43 OnuPacketIn MessageType = 13
Scott Baker41724b82020-01-21 19:54:53 -080044
Arjun E K57a7fcb2020-01-30 06:44:45 +000045 //IGMP
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080046 IGMPMembershipReportV2 MessageType = 14 // Version 2 Membership Report (JOIN)
47 IGMPLeaveGroup MessageType = 15 // Leave Group
Arjun E K57a7fcb2020-01-30 06:44:45 +000048
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080049 AlarmIndication MessageType = 16 // message data is an openolt.AlarmIndication
50 IGMPMembershipReportV3 MessageType = 17 // Version 3 Membership Report
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070051)
52
53func (m MessageType) String() string {
54 names := [...]string{
55 "OltIndication",
56 "NniIndication",
57 "PonIndication",
58 "OnuDiscIndication",
59 "OnuIndication",
60 "OMCI",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070061 "FlowAdd",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070062 "StartEAPOL",
63 "StartDHCP",
64 "OnuPacketOut",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070065 "OmciIndication",
66 "SendEapolFlow",
67 "SendDhcpFlow",
68 "OnuPacketIn",
Arjun E K57a7fcb2020-01-30 06:44:45 +000069 "IGMPMembershipReportV2",
70 "IGMPLeaveGroup",
Anand S Katti09541352020-01-29 15:54:01 +053071 "IGMPMembershipReportV3",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070072 "FlowRemoved",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070073 }
74 return names[m]
75}
76
77type Message struct {
78 Type MessageType
79 Data interface{}
80}
81
82type OltIndicationMessage struct {
83 OperState OperState
84}
85
86type NniIndicationMessage struct {
87 OperState OperState
88 NniPortID uint32
89}
90
91type PonIndicationMessage struct {
92 OperState OperState
93 PonPortID uint32
94}
95
96type OnuDiscIndicationMessage struct {
97 OperState OperState
Matteo Scandolo27428702019-10-11 16:21:16 -070098 Onu *Onu
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070099}
100
101type OnuIndicationMessage struct {
102 OperState OperState
103 PonPortID uint32
104 OnuID uint32
105 OnuSN *openolt.SerialNumber
106}
107
108type OmciMessage struct {
109 OnuSN *openolt.SerialNumber
110 OnuID uint32
111 omciMsg *openolt.OmciMsg
112}
113
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700114type OmciIndicationMessage struct {
115 OnuSN *openolt.SerialNumber
116 OnuID uint32
117 OmciInd *openolt.OmciIndication
118}
119
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700120type OnuFlowUpdateMessage struct {
121 PonPortID uint32
122 OnuID uint32
123 Flow *openolt.Flow
124}
125
126type PacketMessage struct {
127 PonPortID uint32
128 OnuID uint32
129}
130
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700131type OnuPacketMessage struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700132 IntfId uint32
133 OnuId uint32
134 Packet gopacket.Packet
135 Type packetHandlers.PacketType
136 MacAddress net.HardwareAddr
137 GemPortId uint32 // this is used by BBR
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700138}
139
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700140type OperState int
141
142const (
143 UP OperState = iota
Shrey Baid688b4242020-07-10 20:40:10 +0530144 DOWN // The device has been discovered, but not yet activated
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700145)
146
147func (m OperState) String() string {
148 names := [...]string{
149 "up",
150 "down",
151 }
152 return names[m]
153}