16015eac31faea549754ac8da40642e44109e040
[sim/e2-interface.git] / e2sim / src / base / e2sim.hpp
1 /*****************************************************************************
2 #                                                                            *
3 # Copyright 2020 AT&T Intellectual Property                                  *
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 #ifndef E2SIM_HPP
20 #define E2SIM_HPP
21
22 #include <unordered_map>
23
24 extern "C" {
25 #include "E2AP-PDU.h"
26 #include "OCTET_STRING.h"
27 }
28
29 typedef void (*SubscriptionCallback)(E2AP_PDU_t*);
30
31 class E2Sim;
32 class E2Sim {
33
34 private:
35
36   std::unordered_map<long, OCTET_STRING_t*> ran_functions_registered;
37   std::unordered_map<long, SubscriptionCallback> subscription_callbacks;
38
39   void wait_for_sctp_data();
40   
41 public:
42
43   void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqActionIdsAccepted[], long reqActionIdsRejected[], int accept_size, int reject_size, long reqRequestorId, long reqInstanceId);
44
45   void generate_e2apv1_indication_request_parameterized(E2AP_PDU *e2ap_pdu, long requestorId, long instanceId, long ranFunctionId, long actionId, long seqNum, uint8_t *ind_header_buf, int header_length, uint8_t *ind_message_buf, int message_length);  
46
47   SubscriptionCallback get_subscription_callback(long func_id);
48   
49   void register_e2sm(long func_id, OCTET_STRING_t* ostr);
50
51   void register_subscription_callback(long func_id, SubscriptionCallback cb);
52   
53   void encode_and_send_sctp_data(E2AP_PDU_t* pdu);
54
55   int run_loop(int argc, char* argv[]);
56
57 };
58
59 #endif