blob: f32e0481d047e0bf4287135b3d36d3e9938555ed [file] [log] [blame]
Zdravko Bozakov7401ff22019-05-28 22:45:12 +02001/*
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 flow
18
19import (
20 "gerrit.opencord.org/voltha-bbsim/common/logger"
21 openolt "gerrit.opencord.org/voltha-bbsim/protos"
22)
23
24var flowManager FlowManager
25
26// FlowManager interface for common methods of controller
27type FlowManager interface {
28 AddFlow(flow *openolt.Flow) error
29 DeleteFlow(flow *openolt.Flow) error
30 PortUp(portID uint32) error
31 PortDown(portID uint32) error
32 GetFlow(onuID uint32) ([]*openolt.Flow, error)
33}
34
35// DefaultFlowController empty struct
36type DefaultFlowController struct {
37}
38
39// InitializeFlowManager starts godc controller
40func InitializeFlowManager(OltID uint32) {
41 // Initialize flow controller as per custom implementation
42 logger.Debug("InitializeFlowManager for OLT %d", OltID)
43 flowManager = InitializeDefaultFlowController()
44 return
45}
46
47// AddFlow abstracts actual implementation of flow addition
48func AddFlow(flow *openolt.Flow) error {
49 return flowManager.AddFlow(flow)
50}
51
52// DeleteFlow abstracts actual implementation of flow deletion
53func DeleteFlow(flow *openolt.Flow) error {
54 return flowManager.DeleteFlow(flow)
55}
56
57// PortUp abstracts actual implementation of port up
58func PortUp(portID uint32) error {
59 return flowManager.PortUp(portID)
60}
61
62// PortDown abstracts actual implementation of port down
63func PortDown(portID uint32) error {
64 return flowManager.PortDown(portID)
65}
66
67// InitializeDefaultFlowController method to initialize default controller
68func InitializeDefaultFlowController() FlowManager {
69 logger.Debug("Default controller initialized")
70 return new(DefaultFlowController)
71}
72
73// AddFlow method implemented for DefaultFlowController
74func (fc *DefaultFlowController) AddFlow(flow *openolt.Flow) error {
75 logger.Debug("AddFlow invoked %v", flow)
76 return nil
77}
78
79// DeleteFlow implemented for DefaultFlowController
80func (fc *DefaultFlowController) DeleteFlow(flow *openolt.Flow) error {
81 logger.Debug("DeleteFlow invoked %v", flow)
82 return nil
83}
84
85// GetFlow implemented for DefaultFlowController
86func (fc *DefaultFlowController) GetFlow(onuID uint32) ([]*openolt.Flow, error) {
87 return nil, nil
88}
89
90// PortUp implemented for DefaultFlowController
91func (fc *DefaultFlowController) PortUp(portID uint32) error {
92 logger.Debug("PortUp invoked %d", portID)
93 return nil
94}
95
96// PortDown implemented for DefaultFlowController
97func (fc *DefaultFlowController) PortDown(portID uint32) error {
98 logger.Debug("PortDown invoked %d", portID)
99 return nil
100}