sync R3 content from Azure
[ric-plt/e2mgr.git] / E2Manager / handlers / rmrmsghandlers / x2enb_configuration_update_handler.go
1 //
2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //      http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 package rmrmsghandlers
19
20 import "C"
21 import (
22         "e2mgr/converters"
23         "e2mgr/e2pdus"
24         "e2mgr/logger"
25         "e2mgr/models"
26         "e2mgr/rmrCgo"
27         "e2mgr/services/rmrsender"
28         "e2mgr/utils"
29 )
30
31 type X2EnbConfigurationUpdateHandler struct {
32         logger    *logger.Logger
33         rmrSender *rmrsender.RmrSender
34 }
35
36 func NewX2EnbConfigurationUpdateHandler(logger *logger.Logger, rmrSender *rmrsender.RmrSender) X2EnbConfigurationUpdateHandler {
37         return X2EnbConfigurationUpdateHandler{
38                 logger:    logger,
39                 rmrSender: rmrSender,
40         }
41 }
42
43 func (h X2EnbConfigurationUpdateHandler) Handle(request *models.NotificationRequest) {
44
45         refinedMessage, err := converters.UnpackX2apPduAndRefine(h.logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize)
46
47         if err != nil {
48                 h.logger.Errorf("#x2enb_configuration_update_handler.Handle - unpack failed. Error: %v", err)
49
50                 msg := models.NewRmrMessage(rmrCgo.RIC_ENB_CONFIGURATION_UPDATE_FAILURE, request.RanName, e2pdus.PackedX2EnbConfigurationUpdateFailure, request.TransactionId)
51                 _ = h.rmrSender.Send(msg)
52
53                 h.logger.Infof("#X2EnbConfigurationUpdateHandler.Handle - Summary: elapsed time for receiving and handling enb configuration update initiating message from E2 terminator: %f ms", utils.ElapsedTime(request.StartTime))
54                 return
55         }
56
57         h.logger.Infof("#x2enb_configuration_update_handler.Handle - Enb configuration update initiating message received")
58         h.logger.Debugf("#x2enb_configuration_update_handler.Handle - Enb configuration update initiating message payload: %s", refinedMessage.PduPrint)
59
60         msg := models.NewRmrMessage(rmrCgo.RIC_ENB_CONFIGURATION_UPDATE_ACK, request.RanName, e2pdus.PackedX2EnbConfigurationUpdateAck,request.TransactionId)
61         _ = h.rmrSender.Send(msg)
62
63         h.logger.Infof("#X2EnbConfigurationUpdateHandler.Handle - Summary: elapsed time for receiving and handling enb configuration update initiating message from E2 terminator: %f ms", utils.ElapsedTime(request.StartTime))
64 }