E2AP Abstraction Changes
[ric-app/hw.git] / src / xapp-asn / e2sm / e2sm_control.hpp
1 /*
2 ==================================================================================
3
4         Copyright (c) 2019-2020 AT&T Intellectual Property.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19 /*
20  * e2sm_indication.hpp
21  *
22  *  Created on: Apr, 2020
23  *      Author: Shraboni Jana
24  */
25
26 /* Classes to handle E2 service model based on e2sm-HelloWorld-v001.asn */
27 #ifndef SRC_XAPP_ASN_E2SM_E2SM_CONTROL_HPP_
28 #define SRC_XAPP_ASN_E2SM_E2SM_CONTROL_HPP_
29
30 #include <sstream>
31 #include <mdclog/mdclog.h>
32 #include <vector>
33 #include <string>
34 #include <E2SM-HelloWorld-ControlHeader.h>
35 #include <E2SM-HelloWorld-ControlMessage.h>
36 #include <E2SM-HelloWorld-ControlHeader-Format1.h>
37 #include <E2SM-HelloWorld-ControlMessage-Format1.h>
38 #include <HW-Header.h>
39 #include <HW-Message.h>
40
41 class HWControlHeader {
42 public:
43         HWControlHeader(void);
44         HWControlHeader(unsigned char*, size_t *, bool&);
45   ~HWControlHeader(void);
46    std::string  get_error (void) const {return _error_string ;};
47
48   long int get_hw_header(){return this->_hw_header;};
49
50   HWControlHeader& set_ricControlHeader(int param_header){
51                                 _hw_header = param_header; return *this;
52                         }
53
54
55   bool decode(unsigned char*, size_t *);
56   bool encode(unsigned char*, size_t *);
57
58
59 private:
60
61   long int _hw_header;
62   E2SM_HelloWorld_ControlHeader_t * _header; // used for encoding
63   E2SM_HelloWorld_ControlHeader_Format1_t _header_fmt1;
64
65   bool setfields(E2SM_HelloWorld_ControlHeader_t *);
66
67   size_t _errbuf_len = 128;
68   char _errbuf[128];
69   std::string _error_string;
70 };
71
72
73 class HWControlMessage {
74 public:
75         HWControlMessage(void);
76         HWControlMessage(unsigned char*, size_t *, bool&);
77   ~HWControlMessage(void);
78
79   std::string  get_error (void) const {return _error_string ;};
80   bool decode(unsigned char*, size_t *);
81   bool encode(unsigned char*, size_t *);
82
83
84   size_t get_hw_message_size(){return this->_hw_msg_size;};
85   unsigned char* get_hw_message(){return this->_hw_msg;};
86
87   HWControlMessage& set_ricControlMessage(std::string msg){
88                                 _hw_msg_size = strlen(msg.c_str());
89                                 strncpy((char*)_hw_msg,msg.c_str(),_hw_msg_size);
90                                 return *this;
91                         };
92
93 private:
94
95   size_t _hw_msg_size;
96   unsigned char _hw_msg[128];
97
98   E2SM_HelloWorld_ControlMessage_t* _message;
99   E2SM_HelloWorld_ControlMessage_Format1_t _message_fmt1;
100
101   bool setfields(E2SM_HelloWorld_ControlMessage_t *);
102
103   size_t _errbuf_len = 128;
104   char _errbuf[128];
105   std::string _error_string;
106 };
107
108 #endif /* SRC_XAPP_ASN_E2SM_E2SM_INDICATION_HPP_ */