blob: 8bb1d25b0b39dd17a849be191d47fd46a2f4c543 [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 Scandolo86e8ce62019-10-11 12:03:10 -070023)
24
25type MessageType int
26
27const (
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080028 OltIndication MessageType = 0
29 NniIndication MessageType = 1
30 PonIndication MessageType = 2
31 OnuDiscIndication MessageType = 3
32 OnuIndication MessageType = 4
33 OMCI MessageType = 5
34 FlowUpdate MessageType = 6
35 StartEAPOL MessageType = 7
36 StartDHCP MessageType = 8
37 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",
61 "FlowUpdate",
62 "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 Scandolo86e8ce62019-10-11 12:03:10 -070072 }
73 return names[m]
74}
75
76type Message struct {
77 Type MessageType
78 Data interface{}
79}
80
81type OltIndicationMessage struct {
82 OperState OperState
83}
84
85type NniIndicationMessage struct {
86 OperState OperState
87 NniPortID uint32
88}
89
90type PonIndicationMessage struct {
91 OperState OperState
92 PonPortID uint32
93}
94
95type OnuDiscIndicationMessage struct {
96 OperState OperState
Matteo Scandolo27428702019-10-11 16:21:16 -070097 Onu *Onu
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070098}
99
100type OnuIndicationMessage struct {
101 OperState OperState
102 PonPortID uint32
103 OnuID uint32
104 OnuSN *openolt.SerialNumber
105}
106
107type OmciMessage struct {
108 OnuSN *openolt.SerialNumber
109 OnuID uint32
110 omciMsg *openolt.OmciMsg
111}
112
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700113type OmciIndicationMessage struct {
114 OnuSN *openolt.SerialNumber
115 OnuID uint32
116 OmciInd *openolt.OmciIndication
117}
118
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700119type OnuFlowUpdateMessage struct {
120 PonPortID uint32
121 OnuID uint32
122 Flow *openolt.Flow
123}
124
125type PacketMessage struct {
126 PonPortID uint32
127 OnuID uint32
128}
129
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700130type OnuPacketMessage struct {
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700131 IntfId uint32
132 OnuId uint32
133 Packet gopacket.Packet
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700134 Type packetHandlers.PacketType
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700135}
136
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700137type OperState int
138
139const (
140 UP OperState = iota
141 DOWN // The device has been discovered, but not yet activated
142)
143
144func (m OperState) String() string {
145 names := [...]string{
146 "up",
147 "down",
148 }
149 return names[m]
150}