95ab8ca95298ade70765f24285a5ce8dc66e7a85
[ric-app/hw.git] / src / xapp-formats / e2sm / e2sm_helpers.hpp
1 /*
2   ==================================================================================
3
4   Copyright (c) 2018-2019 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, softwares
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 /* Classes to handle E2 service model based on e2sm-gNB-X2-release-1-v040.asn */
21
22 #ifndef E2SM_HELPER_
23 #define E2SM_HELPER_
24
25 #include <errno.h>
26 #include <iostream>
27 #include <vector>
28 #include <sstream>
29
30  /* information holder for E2SM indication header */
31 typedef struct e2sm_header_helper e2sm_header_helper;
32 struct e2sm_header_helper {
33   int egNB_id_type;
34   
35   std::string egNB_id;
36   std::string plmn_id;
37   
38   long int interface_direction;
39   unsigned char* timestamp;
40 };
41
42 /* information holder for E2SM indication message */
43 typedef struct e2sm_message_helper e2sm_message_helper;
44 struct e2sm_message_helper {
45   unsigned char * x2ap_pdu;
46   size_t x2ap_pdu_size;
47 };
48
49   
50 /* information holder for E2SM Action Trigger Definition */
51 struct Item
52 {
53   Item(long int id, long int test, long int val_type, int value):interface_id(id), test(test), val_type(val_type), value_n(value){};
54   Item(long int id, long int test, long int val_type, std::string value):interface_id(id), test(test), val_type(val_type), value_s(value){};
55     
56   long int interface_id;
57   long int test;
58   long int  val_type;
59   long int value_n;
60   std::string value_s;
61     
62 };
63   
64 typedef struct e2sm_event_trigger_helper e2sm_event_trigger_helper;
65 struct e2sm_event_trigger_helper {
66     
67   int egNB_id_type;
68   std::string egNB_id;
69   std::string plmn_id;
70     
71   long int interface_direction;
72   long int procedure_code;
73     
74   long int message_type;
75
76     
77   std::vector<struct Item> * get_list(void){ return &protocol_ie_list; };
78   void add_protocol_ie_item(long int id, long int test , unsigned int val_type, long int value ){
79     // into list 
80     protocol_ie_list.emplace_back(id, test, val_type, value);
81   };
82   
83   void add_protocol_ie_item(long int id, long int  test, unsigned  int val_type, std::string  value){
84     //  into list 
85     protocol_ie_list.emplace_back(id, test, val_type, value);    
86   };
87    
88   void clear(void){
89     protocol_ie_list.clear();
90   }
91
92   std::string get_string(void) const {
93     std::stringstream ss;
94     ss << "egNB_ID_type = " << egNB_id_type << std::endl;
95     ss << "PLMN Id = " << plmn_id << std::endl;
96     ss << "Procedure Code = " << procedure_code << std::endl;
97     ss << "Message Type = " << message_type << std::endl;
98
99     std::string info;
100     info = ss.str();
101     return info;
102   }
103   
104     
105     
106 private:
107     
108   std::vector<struct Item> protocol_ie_list;
109     
110 };
111
112   
113
114
115 #endif