blob: e103cebe3f81ffaf67e0443a9bf9f6ab6f5d0b9b [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 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 Scandolo86e8ce62019-10-11 12:03:10 -070053)
54
55func (m MessageType) String() string {
56 names := [...]string{
57 "OltIndication",
58 "NniIndication",
59 "PonIndication",
60 "OnuDiscIndication",
61 "OnuIndication",
62 "OMCI",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070063 "FlowAdd",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070064 "StartEAPOL",
65 "StartDHCP",
66 "OnuPacketOut",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070067 "OmciIndication",
68 "SendEapolFlow",
69 "SendDhcpFlow",
70 "OnuPacketIn",
Arjun E K57a7fcb2020-01-30 06:44:45 +000071 "IGMPMembershipReportV2",
72 "IGMPLeaveGroup",
Anand S Katti09541352020-01-29 15:54:01 +053073 "IGMPMembershipReportV3",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070074 "FlowRemoved",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070075 }
76 return names[m]
77}
78
79type Message struct {
80 Type MessageType
81 Data interface{}
82}
83
84type OltIndicationMessage struct {
85 OperState OperState
86}
87
88type NniIndicationMessage struct {
89 OperState OperState
90 NniPortID uint32
91}
92
93type PonIndicationMessage struct {
94 OperState OperState
95 PonPortID uint32
96}
97
98type OnuDiscIndicationMessage struct {
99 OperState OperState
Matteo Scandolo27428702019-10-11 16:21:16 -0700100 Onu *Onu
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700101}
102
103type OnuIndicationMessage struct {
104 OperState OperState
105 PonPortID uint32
106 OnuID uint32
107 OnuSN *openolt.SerialNumber
108}
109
110type OmciMessage struct {
111 OnuSN *openolt.SerialNumber
112 OnuID uint32
113 omciMsg *openolt.OmciMsg
114}
115
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700116type OmciIndicationMessage struct {
117 OnuSN *openolt.SerialNumber
118 OnuID uint32
119 OmciInd *openolt.OmciIndication
120}
121
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700122type OnuFlowUpdateMessage struct {
123 PonPortID uint32
124 OnuID uint32
125 Flow *openolt.Flow
126}
127
128type PacketMessage struct {
129 PonPortID uint32
130 OnuID uint32
131}
132
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700133type OnuPacketMessage struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700134 IntfId uint32
135 OnuId uint32
136 Packet gopacket.Packet
137 Type packetHandlers.PacketType
138 MacAddress net.HardwareAddr
139 GemPortId uint32 // this is used by BBR
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700140}
141
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700142type OperState int
143
144const (
145 UP OperState = iota
Shrey Baid688b4242020-07-10 20:40:10 +0530146 DOWN // The device has been discovered, but not yet activated
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700147)
148
149func (m OperState) String() string {
150 names := [...]string{
151 "up",
152 "down",
153 }
154 return names[m]
155}