2 ==================================================================================
4 Copyright (c) 2018-2019 AT&T Intellectual Property.
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
25 #include <rmr/RIC_message_types.h>
27 #include <mdclog/mdclog.h>
28 #include <NetworkProtector.h>
29 #include <e2ap_indication.hpp>
30 #include <e2ap_control.hpp>
31 #include <e2ap_control_response.hpp>
32 #include <subscription_handler.hpp>
36 #define likely(x) __builtin_expect((x), 1)
37 #define unlikely(x) __builtin_expect((x), 0)
40 #define unlikely(x) (x)
44 #define MAX_RMR_RECV_SIZE 2<<15
49 E2AP_INDICATION_ERROR,
51 E2SM_INDICATION_HEADER_ERROR,
52 E2SM_CONTROL_HEADER_ERROR,
53 E2SM_CONTROL_MESSAGE_ERROR,
54 MISSING_HANDLER_ERROR,
57 } MessageProcessorStateTypes;
64 } ProcessingLevelTypes;
67 class message_processor {
70 message_processor(int mode=ALL, bool rep=true, size_t buffer_length = 2048, size_t reporting_interval = 100);
71 ~message_processor(void);
73 bool operator() (rmr_mbuf_t *);
74 unsigned long const get_messages (void);
75 void register_subscription_handler(subscription_handler *);
76 void register_protector(protector * );
77 void register_policy_handler (void (*)(int, const char *, int, std::string &, bool));
78 std::vector<double> & get_metrics(void);
79 int get_state (void) {return state;};
82 E2N_E2AP_PDU_t * e2ap_recv_pdu;
83 E2N_E2SM_gNB_X2_indicationHeader_t *e2sm_header; // used for decoding
84 E2N_E2SM_gNB_X2_indicationMessage_t *e2sm_message; // used for decoding
86 E2N_E2AP_PDU_t * e2ap_gen_pdu; // just a placeholder for now
88 ric_indication_helper indication_data;
89 ric_indication indication_processor;
91 ric_control_helper control_data;
92 ric_control_request control_request_processor;
93 ric_control_response control_response_processor;
95 e2sm_header_helper header_helper;
96 e2sm_message_helper message_helper;
97 e2sm_indication e2sm_indication_processor;
98 e2sm_control e2sm_control_processor;
100 subscription_handler * _ref_sub_handler;
101 protector * _ref_protector;
102 void (* _ref_policy_handler) (int, const char *, int, std::string &, bool);
103 unsigned long _num_messages;
105 unsigned char *scratch_buffer;
106 size_t remaining_buffer;
107 size_t current_index;
108 unsigned long int num_indications, num_err_indications;
109 int state = NO_ERROR;
110 int processing_level; // for debugging purposes
111 bool report_mode_only; // suppress e2ap control
112 size_t _buffer_size; // for storing encoding
114 // these two parameters are used to report average processing latency.
115 // processing latency is accumalated over every num_proc_packets
116 // and both values are reported out on std log. After each report
117 // counters are reset
119 size_t _reporting_interval; // number of packets in a measurement interval
120 size_t num_proc_packets;
121 double processing_duration; // for storing time to process
122 double processing_dev; // for storing standard deviation
123 double max_proc_duration ;
127 extern int verbose_flag;