Initial commit of Admission Control xAPP and E2AP/X2AP definitions
[ric-app/admin.git] / src / message_processor_class.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
21 #pragma once
22 #include <iostream>
23 #include <cstring>
24 #include <rmr/RIC_message_types.h>
25 #include <rmr/rmr.h>
26 #include <mdclog/mdclog.h>
27 #include <NetworkProtector.h>
28 #include <e2ap_indication.hpp>
29 #include <e2ap_control.hpp>
30 #include <e2ap_control_response.hpp>
31 #include <subscription_handler.hpp>
32 #include <e2sm.hpp>
33
34 #ifdef __GNUC__
35 #define likely(x)  __builtin_expect((x), 1)
36 #define unlikely(x) __builtin_expect((x), 0)
37 #else
38 #define likely(x) (x)
39 #define unlikely(x) (x)
40 #endif
41
42 #define BUFFER_LENGTH 2048
43
44 class message_processor {
45
46 public:
47   message_processor();
48   ~message_processor(void);
49   
50   bool operator() (rmr_mbuf_t *);  
51   unsigned long const get_messages (void);
52   void register_subscription_handler(SubscriptionHandler *);
53   void register_protector(protector * );
54   void register_policy_handler (void  (*)(int, const char *, int, std::string &, bool));
55   std::vector<double> & get_metrics(void);
56   
57 private:
58
59   E2AP_PDU_t * e2ap_recv_pdu;
60   E2SM_gNB_X2_indicationHeader_t *e2sm_header; // used for decoding
61   E2SM_gNB_X2_indicationMessage_t *e2sm_message; // used for decoding
62   
63   E2AP_PDU_t * e2ap_gen_pdu; // just a placeholder for now
64
65   E2APRicIndication indication_data;
66   ric_indication indication_processor;
67
68   ric_control_helper control_data;
69   ric_control_request control_request_processor;
70   ric_control_response control_response_processor;
71   
72   e2sm_header_helper header_helper;
73   e2sm_message_helper message_helper;
74   e2sm_indication e2sm_indication_processor;
75   e2sm_control e2sm_control_processor;
76   
77   SubscriptionHandler * _ref_sub_handler;
78   protector  * _ref_protector;
79   void (* _ref_policy_handler) (int, const char *, int, std::string &, bool);
80   unsigned long _num_messages;
81
82   unsigned char *scratch_buffer;
83   size_t remaining_buffer;
84   unsigned int current_index;
85   unsigned long int num_indications, num_err_indications;
86 };
87
88
89 extern bool report_mode_only;
90 extern int verbose_flag;