Changes to Subscription Handler
[ric-app/hw.git] / src / xapp-formats / e2sm / e2sm.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, 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 /* Classes to handle E2 service model based on e2sm-gNB-X2-release-1-v040.asn */
21
22 #ifndef E2SM_
23 #define E2SM_
24
25
26 #include <sstream>
27 #include <mdclog/mdclog.h>
28 #include <E2N_E2SM-gNB-X2-indicationHeader.h>
29 #include <E2N_E2SM-gNB-X2-indicationMessage.h>
30 #include <E2N_E2SM-gNB-X2-controlHeader.h>
31 #include <E2N_E2SM-gNB-X2-controlMessage.h>
32 #include <E2N_E2SM-gNB-X2-eventTriggerDefinition.h>
33
34 #include <E2N_GlobalGNB-ID.h>
35 #include <E2N_TypeOfMessage.h>
36 #include <E2N_InterfaceProtocolIE-Item.h>
37
38 #include<E2N_InterfaceProtocolIE-ID.h>
39 #include<E2N_InterfaceProtocolIE-Value.h>
40 #include<E2N_InterfaceProtocolIE-Test.h>
41 #include "../../xapp-formats/e2sm/e2sm_helpers.hpp"
42
43 #define INITIAL_LIST_SIZE 4
44
45   
46
47   
48 /* builder class for E2SM event trigger definition */
49
50 class e2sm_event_trigger {
51 public:
52   e2sm_event_trigger(void);
53   ~e2sm_event_trigger(void);
54     
55   bool set_fields(E2N_E2SM_gNB_X2_eventTriggerDefinition_t *, e2sm_event_trigger_helper &);
56   bool get_fields(E2N_E2SM_gNB_X2_eventTriggerDefinition_t *, e2sm_event_trigger_helper &);
57   bool encode_event_trigger(unsigned char *, size_t *, e2sm_event_trigger_helper &);
58
59   std::string  get_error (void) const {return error_string ;};
60   
61 private:
62
63   E2N_E2SM_gNB_X2_eventTriggerDefinition_t * event_trigger; // used for encoding
64   E2N_GlobalGNB_ID_t gNodeB_ID;
65   struct E2N_InterfaceProtocolIE_Item * ie_list;
66   unsigned int ie_list_size;
67     
68   //std::vector<struct InterfaceProtocolIE_Item> ie_list;
69   E2N_E2SM_gNB_X2_eventTriggerDefinition::E2N_E2SM_gNB_X2_eventTriggerDefinition__interfaceProtocolIE_List *condition_list;
70     
71   char errbuf[128];
72   size_t errbuf_len;
73   std::string error_string;
74 };
75   
76     
77 /* builder class for E2SM indication  using ASN1c */
78   
79 class e2sm_indication {
80 public:
81     
82   e2sm_indication(void);
83   ~e2sm_indication(void);
84     
85   E2N_E2SM_gNB_X2_indicationHeader_t * get_header(void);
86   E2N_E2SM_gNB_X2_indicationMessage_t * get_message(void);
87
88   bool set_header_fields(E2N_E2SM_gNB_X2_indicationHeader_t *, e2sm_header_helper &);
89   bool get_header_fields(E2N_E2SM_gNB_X2_indicationHeader_t *, e2sm_header_helper &);
90     
91   bool set_message_fields(E2N_E2SM_gNB_X2_indicationMessage_t *, e2sm_message_helper &);
92   bool get_message_fields(E2N_E2SM_gNB_X2_indicationMessage_t *, e2sm_message_helper &);
93
94   bool encode_indication_header(unsigned char * , size_t * , e2sm_header_helper &); 
95   bool encode_indication_message(unsigned char *, size_t *, e2sm_message_helper &);
96   std::string  get_error (void) const {return error_string ; };
97     
98 private:
99   
100   E2N_E2SM_gNB_X2_indicationHeader_t *header; // used for encoding
101   E2N_E2SM_gNB_X2_indicationMessage_t *message; // used for encoding
102     
103   char errbuf[128];
104   size_t errbuf_len;
105   E2N_GlobalGNB_ID_t gNodeB_ID;
106   std::string error_string;
107
108   
109 };
110
111 /* builder class for E2SM control  using ASN1c */
112   
113 class e2sm_control {
114 public:
115     
116   e2sm_control(void);
117   ~e2sm_control(void);
118     
119   E2N_E2SM_gNB_X2_controlHeader_t * get_header(void);
120   E2N_E2SM_gNB_X2_controlMessage_t * get_message(void);
121
122   bool set_header_fields(E2N_E2SM_gNB_X2_controlHeader_t *, e2sm_header_helper &);
123   bool get_header_fields(E2N_E2SM_gNB_X2_controlHeader_t *, e2sm_header_helper &);
124     
125   bool set_message_fields(E2N_E2SM_gNB_X2_controlMessage_t *, e2sm_message_helper &);
126   bool get_message_fields(E2N_E2SM_gNB_X2_controlMessage_t *, e2sm_message_helper &);
127
128   bool encode_control_header(unsigned char * , size_t * , e2sm_header_helper &); 
129   bool encode_control_message(unsigned char *, size_t *, e2sm_message_helper &);
130   std::string  get_error (void) const {return error_string ; };
131     
132 private:
133   
134   E2N_E2SM_gNB_X2_controlHeader_t *header; // used for encoding
135   E2N_E2SM_gNB_X2_controlMessage_t *message; // used for encoding
136     
137   char errbuf[128];
138   size_t errbuf_len;
139   E2N_GlobalGNB_ID_t gNodeB_ID;
140   std::string error_string;
141
142   
143 };
144
145 #endif