18258e14372072b9a494c7635982366e748ef16b
[o-du/l2.git] / src / o1 / ves / VesEventHandler.cpp
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
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
19 /* This file contains functions to support the preparation of Common Header part
20    of VES Event*/
21
22
23 #include "VesEventHandler.hpp"
24 #include "PnfRegistration.hpp"
25
26 /*******************************************************************
27  *
28  * @brief prepare and send  Ves Message
29  *
30  * @details
31  *
32  *    Function : sendVesEvent
33  *
34  *    Functionality:
35  *      - prepare VES event and send to oam
36  *
37  * @params[in] void
38  * @return true     - success
39  *         false    - failure
40  *
41  * ****************************************************************/
42
43 bool VesEventHandler::send(VesEventType evtType)
44 {
45    //check event type and call funtions accordingly
46    bool ret = true;
47    //char *sendData;
48    O1_LOG("O1 VES : sendVesEvent started\n");
49    VesEvent *vesEvent;
50    //common header
51    switch(evtType)
52    {
53       case VesEventType::PNF_REGISTRATION:
54          {
55             O1_LOG("O1 VES : send PNP registration\n");
56             vesEvent = new PnfRegistration;
57             break;
58          }
59       case VesEventType::FAULT_NOTIFICATION:
60          O1_LOG("O1 VES : send VES fault notification\n");
61          break;
62       case VesEventType::PM_NOTIFICATION:
63          O1_LOG("O1 VES : send VES pm notification\n");
64          break;
65       case VesEventType::HEARTBEAT:
66          O1_LOG("O1 VES : send VES heartbeat \n");
67          break;
68       default:
69          O1_LOG("O1 VES : send VES msg Type is not avilable\n");
70          ret = false;
71          break;
72    }
73    if(!vesEvent->prepare()) {
74       O1_LOG("O1 VES : could not send VES Event\n");
75       ret = false;
76    }
77    else if (!vesEvent->send()) {
78       O1_LOG("O1 VES : could not send VES Event\n");
79       ret = false;
80    }
81    delete vesEvent;
82    return ret;
83 }
84 /**********************************************************************
85   End of file
86  **********************************************************************/