blob: b61ac18dbc36847fb14861020f7c21d6e399e6c0 [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 Scandolo86e8ce62019-10-11 12:03:10 -070022 "github.com/opencord/voltha-protos/go/openolt"
23)
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
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070045)
46
47func (m MessageType) String() string {
48 names := [...]string{
49 "OltIndication",
50 "NniIndication",
51 "PonIndication",
52 "OnuDiscIndication",
53 "OnuIndication",
54 "OMCI",
55 "FlowUpdate",
56 "StartEAPOL",
57 "StartDHCP",
58 "OnuPacketOut",
59 "DyingGaspIndication",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070060 "OmciIndication",
61 "SendEapolFlow",
62 "SendDhcpFlow",
63 "OnuPacketIn",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070064 }
65 return names[m]
66}
67
68type Message struct {
69 Type MessageType
70 Data interface{}
71}
72
73type OltIndicationMessage struct {
74 OperState OperState
75}
76
77type NniIndicationMessage struct {
78 OperState OperState
79 NniPortID uint32
80}
81
82type PonIndicationMessage struct {
83 OperState OperState
84 PonPortID uint32
85}
86
87type OnuDiscIndicationMessage struct {
88 OperState OperState
Matteo Scandolo27428702019-10-11 16:21:16 -070089 Onu *Onu
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070090}
91
92type OnuIndicationMessage struct {
93 OperState OperState
94 PonPortID uint32
95 OnuID uint32
96 OnuSN *openolt.SerialNumber
97}
98
99type OmciMessage struct {
100 OnuSN *openolt.SerialNumber
101 OnuID uint32
102 omciMsg *openolt.OmciMsg
103}
104
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700105type OmciIndicationMessage struct {
106 OnuSN *openolt.SerialNumber
107 OnuID uint32
108 OmciInd *openolt.OmciIndication
109}
110
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700111type OnuFlowUpdateMessage struct {
112 PonPortID uint32
113 OnuID uint32
114 Flow *openolt.Flow
115}
116
117type PacketMessage struct {
118 PonPortID uint32
119 OnuID uint32
120}
121
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700122type OnuPacketMessage struct {
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700123 IntfId uint32
124 OnuId uint32
125 Packet gopacket.Packet
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700126 Type packetHandlers.PacketType
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700127}
128
129type DyingGaspIndicationMessage struct {
130 PonPortID uint32
131 OnuID uint32
132 Status string
133}
134
135type OperState int
136
137const (
138 UP OperState = iota
139 DOWN // The device has been discovered, but not yet activated
140)
141
142func (m OperState) String() string {
143 names := [...]string{
144 "up",
145 "down",
146 }
147 return names[m]
148}