blob: 56525200cd40f6d9ba541ec000fa4cad6751fcb8 [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
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070034 FlowAdd MessageType = 6
35 FlowRemoved MessageType = 18
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080036 StartEAPOL MessageType = 7
37 StartDHCP MessageType = 8
38 OnuPacketOut MessageType = 9
Matteo Scandolo40e067f2019-10-16 16:59:41 -070039
40 // BBR messages
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080041 OmciIndication MessageType = 10 // this are OMCI messages going from the OLT to VOLTHA
42 SendEapolFlow MessageType = 11
43 SendDhcpFlow MessageType = 12
44 OnuPacketIn MessageType = 13
Scott Baker41724b82020-01-21 19:54:53 -080045
Arjun E K57a7fcb2020-01-30 06:44:45 +000046 //IGMP
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080047 IGMPMembershipReportV2 MessageType = 14 // Version 2 Membership Report (JOIN)
48 IGMPLeaveGroup MessageType = 15 // Leave Group
Arjun E K57a7fcb2020-01-30 06:44:45 +000049
Matteo Scandolod7cc6d32020-02-26 16:51:12 -080050 AlarmIndication MessageType = 16 // message data is an openolt.AlarmIndication
51 IGMPMembershipReportV3 MessageType = 17 // Version 3 Membership Report
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070052)
53
54func (m MessageType) String() string {
55 names := [...]string{
56 "OltIndication",
57 "NniIndication",
58 "PonIndication",
59 "OnuDiscIndication",
60 "OnuIndication",
61 "OMCI",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070062 "FlowAdd",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070063 "StartEAPOL",
64 "StartDHCP",
65 "OnuPacketOut",
Matteo Scandolo40e067f2019-10-16 16:59:41 -070066 "OmciIndication",
67 "SendEapolFlow",
68 "SendDhcpFlow",
69 "OnuPacketIn",
Arjun E K57a7fcb2020-01-30 06:44:45 +000070 "IGMPMembershipReportV2",
71 "IGMPLeaveGroup",
Anand S Katti09541352020-01-29 15:54:01 +053072 "IGMPMembershipReportV3",
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -070073 "FlowRemoved",
Matteo Scandolo86e8ce62019-10-11 12:03:10 -070074 }
75 return names[m]
76}
77
78type Message struct {
79 Type MessageType
80 Data interface{}
81}
82
83type OltIndicationMessage struct {
84 OperState OperState
85}
86
87type NniIndicationMessage struct {
88 OperState OperState
89 NniPortID uint32
90}
91
92type PonIndicationMessage struct {
93 OperState OperState
94 PonPortID uint32
95}
96
97type OnuDiscIndicationMessage struct {
98 OperState OperState
Matteo Scandolo27428702019-10-11 16:21:16 -070099 Onu *Onu
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700100}
101
102type OnuIndicationMessage struct {
103 OperState OperState
104 PonPortID uint32
105 OnuID uint32
106 OnuSN *openolt.SerialNumber
107}
108
109type OmciMessage struct {
110 OnuSN *openolt.SerialNumber
111 OnuID uint32
112 omciMsg *openolt.OmciMsg
113}
114
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700115type OmciIndicationMessage struct {
116 OnuSN *openolt.SerialNumber
117 OnuID uint32
118 OmciInd *openolt.OmciIndication
119}
120
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700121type OnuFlowUpdateMessage struct {
122 PonPortID uint32
123 OnuID uint32
124 Flow *openolt.Flow
125}
126
127type PacketMessage struct {
128 PonPortID uint32
129 OnuID uint32
130}
131
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700132type OnuPacketMessage struct {
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700133 IntfId uint32
134 OnuId uint32
135 Packet gopacket.Packet
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700136 Type packetHandlers.PacketType
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700137}
138
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700139type OperState int
140
141const (
142 UP OperState = iota
Matteo Scandoloeb6b5af2020-06-24 16:23:58 -0700143 DOWN // The device has been discovered, but not yet activated
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700144)
145
146func (m OperState) String() string {
147 names := [...]string{
148 "up",
149 "down",
150 }
151 return names[m]
152}