Merge "Fixes to Indication sending"
[sim/e2-interface.git] / e2sim / src / base / e2sim.hpp
1 /*****************************************************************************
2 #                                                                            *
3 # Copyright 2020 AT&T Intellectual Property                                  *
4 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.      *
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 #ifndef E2SIM_HPP
21 #define E2SIM_HPP
22
23 #include <unordered_map>
24
25 extern "C" {
26 #include "E2AP-PDU.h"
27 #include "OCTET_STRING.h"
28 }
29
30 typedef void (*SubscriptionCallback)(E2AP_PDU_t*);
31
32 class E2Sim;
33 class E2Sim {
34
35 private:
36
37   std::unordered_map<long, OCTET_STRING_t*> ran_functions_registered;
38   std::unordered_map<long, SubscriptionCallback> subscription_callbacks;
39
40   void wait_for_sctp_data();
41   
42 public:
43
44   std::unordered_map<long, OCTET_STRING_t*> getRegistered_ran_functions();
45
46   void generate_e2apv1_subscription_response_success(E2AP_PDU *e2ap_pdu, long reqActionIdsAccepted[], long reqActionIdsRejected[], int accept_size, int reject_size, long reqRequestorId, long reqInstanceId);
47
48   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);  
49
50   SubscriptionCallback get_subscription_callback(long func_id);
51   
52   void register_e2sm(long func_id, OCTET_STRING_t* ostr);
53
54   void register_subscription_callback(long func_id, SubscriptionCallback cb);
55   
56   void encode_and_send_sctp_data(E2AP_PDU_t* pdu);
57
58   int run_loop(int argc, char* argv[]);
59
60 };
61
62 #endif