blob: fd1d4dc3abba31f3b0771a7992b709b5af5b5d11 [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 (
28 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
38 DyingGaspIndication MessageType = 10
Matteo Scandolo40e067f2019-10-16 16:59:41 -070039
40 // BBR messages
41 OmciIndication MessageType = 11 // this are OMCI messages going from the OLT to VOLTHA
42 SendEapolFlow MessageType = 12
43 SendDhcpFlow MessageType = 13
44 OnuPacketIn MessageType = 14
Scott Baker41724b82020-01-21 19:54:53 -080045
46 AlarmIndication MessageType = 15 // message data is an openolt.AlarmIndication
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070047)
48
49func (m MessageType) String() string {
50 names := [...]string{
51 "OltIndication",
52 "NniIndication",
53 "PonIndication",
54 "OnuDiscIndication",
55 "OnuIndication",
56 "OMCI",
57 "FlowUpdate",
58 "StartEAPOL",
59 "StartDHCP",
60 "OnuPacketOut",
61 "DyingGaspIndication",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070062 "OmciIndication",
63 "SendEapolFlow",
64 "SendDhcpFlow",
65 "OnuPacketIn",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070066 }
67 return names[m]
68}
69
70type Message struct {
71 Type MessageType
72 Data interface{}
73}
74
75type OltIndicationMessage struct {
76 OperState OperState
77}
78
79type NniIndicationMessage struct {
80 OperState OperState
81 NniPortID uint32
82}
83
84type PonIndicationMessage struct {
85 OperState OperState
86 PonPortID uint32
87}
88
89type OnuDiscIndicationMessage struct {
90 OperState OperState
Matteo Scandolo27428702019-10-11 16:21:16 -070091 Onu *Onu
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070092}
93
94type OnuIndicationMessage struct {
95 OperState OperState
96 PonPortID uint32
97 OnuID uint32
98 OnuSN *openolt.SerialNumber
99}
100
101type OmciMessage struct {
102 OnuSN *openolt.SerialNumber
103 OnuID uint32
104 omciMsg *openolt.OmciMsg
105}
106
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700107type OmciIndicationMessage struct {
108 OnuSN *openolt.SerialNumber
109 OnuID uint32
110 OmciInd *openolt.OmciIndication
111}
112
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700113type OnuFlowUpdateMessage struct {
114 PonPortID uint32
115 OnuID uint32
116 Flow *openolt.Flow
117}
118
119type PacketMessage struct {
120 PonPortID uint32
121 OnuID uint32
122}
123
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700124type OnuPacketMessage struct {
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700125 IntfId uint32
126 OnuId uint32
127 Packet gopacket.Packet
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700128 Type packetHandlers.PacketType
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700129}
130
131type DyingGaspIndicationMessage struct {
132 PonPortID uint32
133 OnuID uint32
134 Status string
135}
136
137type 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}