blob: 508815ca58026eef27945cdd7df1404197eb603b [file] [log] [blame]
Don Newton98fd8812019-09-23 15:15:02 -04001/*
David K. Bainbridge157bdab2020-01-16 14:38:05 -08002 Copyright 2020 the original author or authors.
Don Newton98fd8812019-09-23 15:15:02 -04003
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 openflow
18
19import (
Rohan Agrawalc32d9932020-06-15 11:01:47 +000020 "context"
Don Newton98fd8812019-09-23 15:15:02 -040021 "encoding/json"
David K. Bainbridgee05cf0c2021-08-19 03:16:50 +000022
Jonathan Hart828908c2020-04-15 14:23:45 -070023 ofp "github.com/opencord/goloxi/of13"
David K. Bainbridgee05cf0c2021-08-19 03:16:50 +000024 "github.com/opencord/voltha-lib-go/v7/pkg/log"
Don Newton98fd8812019-09-23 15:15:02 -040025)
26
Rohan Agrawalc32d9932020-06-15 11:01:47 +000027func (ofc *OFConnection) handleGetConfigRequest(ctx context.Context, request *ofp.GetConfigRequest) {
Girish Kumar01e0c632020-08-10 16:48:56 +000028 span, ctx := log.CreateChildSpan(ctx, "openflow-get-config")
29 defer span.Finish()
30
David K. Bainbridge157bdab2020-01-16 14:38:05 -080031 if logger.V(log.DebugLevel) {
Don Newton7577f072020-01-06 12:41:11 -050032 js, _ := json.Marshal(request)
Rohan Agrawalc32d9932020-06-15 11:01:47 +000033 logger.Debugw(ctx, "handleGetConfigRequest called",
David K. Bainbridge157bdab2020-01-16 14:38:05 -080034 log.Fields{
35 "device-id": ofc.DeviceID,
36 "request": js})
Don Newton7577f072020-01-06 12:41:11 -050037 }
Don Newton98fd8812019-09-23 15:15:02 -040038 reply := ofp.NewGetConfigReply()
Don Newtone0d34a82019-11-14 10:58:06 -050039 reply.SetVersion(4)
Don Newton98fd8812019-09-23 15:15:02 -040040 reply.SetXid(request.GetXid())
41 reply.SetMissSendLen(ofp.OFPCMLNoBuffer)
David K. Bainbridge157bdab2020-01-16 14:38:05 -080042 if logger.V(log.DebugLevel) {
Don Newton7577f072020-01-06 12:41:11 -050043 js, _ := json.Marshal(reply)
Rohan Agrawalc32d9932020-06-15 11:01:47 +000044 logger.Debugw(ctx, "handleGetConfigRequest reply",
David K. Bainbridge157bdab2020-01-16 14:38:05 -080045 log.Fields{
46 "device-id": ofc.DeviceID,
47 "reply": js})
Don Newton7577f072020-01-06 12:41:11 -050048 }
Rohan Agrawalc32d9932020-06-15 11:01:47 +000049 if err := ofc.SendMessage(ctx, reply); err != nil {
50 logger.Errorw(ctx, "handle-get-config-request-send-message", log.Fields{"error": err})
David K. Bainbridgecac73ac2020-02-19 07:00:12 -080051 }
Don Newton98fd8812019-09-23 15:15:02 -040052}