blob: 33993f688e242af3ab38562633a1a0af3894e8c9 [file] [log] [blame]
Keita NISHIMOTO26dab092018-07-06 09:52:45 +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 main
18
19import (
20 "log"
Zack Williams86f87202018-10-05 10:36:32 -070021 "gerrit.opencord.org/voltha-bbsim/openolt"
Keita NISHIMOTO26dab092018-07-06 09:52:45 +090022 "golang.org/x/net/context"
Keita NISHIMOTO26dab092018-07-06 09:52:45 +090023 "time"
24)
25
26// gRPC Service
27func (s *server) DisableOlt(c context.Context, empty *openolt.Empty) (*openolt.Empty, error){
28 log.Printf("OLT receives DisableOLT()\n")
29 return new(openolt.Empty), nil
30}
31
32func (s *server) ReenableOlt(c context.Context, empty *openolt.Empty)(*openolt.Empty, error){
33 log.Printf("OLT receives Reenable()\n")
34 return new(openolt.Empty), nil
35}
36
37func (s *server) ActivateOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error){
38 log.Printf("OLT receives ActivateONU()\n")
39 result := validateONU(*onu, s.onus)
40 if result == true {
41 log.Printf("ONU %d activated succesufully.\n", onu.OnuId)
42 s.onus[onu.IntfId][onu.OnuId].internalState = ONU_ACTIVATED
43 //log.Printf("ActivateOnu(): %v", s.onus)
44 }
45 return new(openolt.Empty), nil
46}
47
48func (s *server) DeactivateOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error){
49 log.Printf("OLT receives DeactivateONU()\n")
50 return new(openolt.Empty), nil
51}
52
53func (s *server) DeleteOnu(c context.Context, onu *openolt.Onu) (*openolt.Empty, error){
54 log.Printf("OLT receives DeleteONU()\n")
55 return new(openolt.Empty), nil
56}
57
58func (s *server)OmciMsgOut(c context.Context, msg *openolt.OmciMsg)(*openolt.Empty, error){
59 //log.Printf("OLT %d receives OmciMsgOut to IF %v (ONU-ID: %v): %v.\n", s.olt.ID, msg.IntfId, msg.OnuId, msg.Pkt)
60 log.Printf("OLT %d receives OmciMsgOut to IF %v (ONU-ID: %v).\n", s.olt.ID, msg.IntfId, msg.OnuId)
61 return new(openolt.Empty), nil
62}
63
64func (s *server) OnuPacketOut(c context.Context, packet *openolt.OnuPacket)(*openolt.Empty, error){
65 log.Printf("OLT %d receives OnuPacketOut ().\n", s.olt.ID)
66 return new(openolt.Empty), nil
67}
68
69func (s *server) UplinkPacketOut(c context.Context, packet *openolt.UplinkPacket)(*openolt.Empty, error){
70 log.Printf("OLT %d receives UplinkPacketOut().\n", s.olt.ID)
71 return new(openolt.Empty), nil
72}
73
74func (s *server) FlowAdd(c context.Context, flow *openolt.Flow)(*openolt.Empty, error){
75 log.Printf("OLT %d receives FlowAdd().\n", s.olt.ID)
76 return new(openolt.Empty), nil
77}
78
79func (s *server) HeartbeatCheck(c context.Context, empty *openolt.Empty) (*openolt.Heartbeat, error){
80 log.Printf("OLT %d receives HeartbeatCheck().\n", s.olt.ID)
81 signature := new(openolt.Heartbeat)
82 signature.HeartbeatSignature = s.olt.HeartbeatSignature
83 return signature, nil
84}
85
86func (s *server) EnablePonIf(c context.Context, intf *openolt.Interface) (*openolt.Empty, error){
87 log.Printf("OLT %d receives EnablePonIf().\n", s.olt.ID)
88 return new(openolt.Empty), nil
89}
90
91func (s *server) DisablePonIf(c context.Context, intf *openolt.Interface) (*openolt.Empty, error){
92 log.Printf("OLT %d receives DisablePonIf().\n", s.olt.ID)
93 return new(openolt.Empty), nil
94}
95
96func (s *server) Reboot(c context.Context, empty *openolt.Empty,) (*openolt.Empty, error){
97 log.Printf("OLT %d receives Reboot ().\n", s.olt.ID)
98 return new(openolt.Empty), nil
99}
100
101func (s *server) EnableIndication(empty *openolt.Empty, stream openolt.Openolt_EnableIndicationServer) error {
102 log.Printf("OLT receives EnableInd.\n")
103 if err := activateOLT(s, stream); err != nil {
104 log.Printf("Failed to activate OLT: %v\n", err)
105 return err
106 }
107 // Infinite loop TODO: This should be a queue processing.
108 for {
109 time.Sleep(1 * time.Second)
110 }
111 return nil
Zack Williams86f87202018-10-05 10:36:32 -0700112}