blob: a01dda17a8a88cb6bbfe84f4b1bbfa86981924be [file] [log] [blame]
Keita NISHIMOTO3b8b9c02018-10-09 09:40:01 +09001/*
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 device
18
19type oltState int
20
21type Olt struct {
22 ID uint32
23 NumPonIntf uint32
24 NumNniIntf uint32
25 Mac string
26 SerialNumber string
27 Manufacture string
28 Name string
29 InternalState oltState
30 OperState string
31 Intfs []intf
32 HeartbeatSignature uint32
33}
34
35type intf struct {
36 Type string
37 IntfID uint32
38 OperState string
39}
40
41const (
42 PRE_ENABLE oltState = iota
43 OLT_UP
44 PONIF_UP
45 ONU_DISCOVERED
46)
47
48func CreateOlt(oltid uint32, npon uint32, nnni uint32) *Olt {
49 olt := Olt{}
50 olt.ID = oltid
51 olt.NumPonIntf = npon
52 olt.NumNniIntf = nnni
53 olt.Name = "BBSIM OLT"
54 olt.InternalState = PRE_ENABLE
55 olt.OperState = "up"
56 olt.Intfs = make([]intf, olt.NumPonIntf+olt.NumNniIntf)
57 olt.HeartbeatSignature = oltid
58 for i := uint32(0); i < olt.NumNniIntf; i++ {
59 olt.Intfs[i].IntfID = i
60 olt.Intfs[i].OperState = "up"
61 olt.Intfs[i].Type = "nni"
62 }
63 for i := uint32(olt.NumNniIntf); i < olt.NumPonIntf+olt.NumNniIntf; i++ {
64 olt.Intfs[i].IntfID = i
65 olt.Intfs[i].OperState = "up"
66 olt.Intfs[i].Type = "pon"
67 }
68 return &olt
69}