ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 AT&T Intellectual Property |
| 3 | * Copyright 2019 Nokia |
| 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. |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 16 | */ |
nm755n | 2e26814 | 2019-11-28 16:40:23 +0000 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 20 | * platform project (RICP). |
| 21 | */ |
| 22 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 23 | #ifndef X2_SCTP_THREAD_H |
| 24 | #define X2_SCTP_THREAD_H |
| 25 | |
| 26 | #include <algorithm> |
| 27 | |
| 28 | #include <cstdio> |
| 29 | #include <cerrno> |
| 30 | #include <cstdlib> |
| 31 | #include <cstring> |
| 32 | #include <random> |
| 33 | #include <sys/socket.h> |
| 34 | #include <arpa/inet.h> |
| 35 | #include <netinet/in_systm.h> |
| 36 | #include <netinet/in.h> |
| 37 | #include <netinet/ip.h> |
| 38 | #include <netinet/ip_icmp.h> |
| 39 | #include <netinet/sctp.h> |
| 40 | #include <thread> |
| 41 | #include <atomic> |
| 42 | #include <sys/param.h> |
| 43 | #include <sys/file.h> |
| 44 | #include <ctime> |
| 45 | #include <netdb.h> |
| 46 | #include <sys/epoll.h> |
| 47 | #include <mutex> |
| 48 | #include <shared_mutex> |
| 49 | #include <iterator> |
| 50 | #include <map> |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 51 | #include <sys/inotify.h> |
| 52 | #include <csignal> |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 53 | |
| 54 | #include <rmr/rmr.h> |
| 55 | #include <rmr/RIC_message_types.h> |
| 56 | #include <mdclog/mdclog.h> |
| 57 | #include <functional> |
| 58 | #include <iostream> |
| 59 | |
| 60 | #include <boost/algorithm/string/predicate.hpp> |
| 61 | #include <boost/lexical_cast.hpp> |
| 62 | #include <boost/move/utility.hpp> |
| 63 | #include <boost/log/sources/logger.hpp> |
| 64 | #include <boost/log/sources/record_ostream.hpp> |
| 65 | #include <boost/log/sources/global_logger_storage.hpp> |
| 66 | #include <boost/log/utility/setup/file.hpp> |
| 67 | #include <boost/log/utility/setup/common_attributes.hpp> |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 68 | #include <boost/filesystem.hpp> |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 69 | |
| 70 | #include <mdclog/mdclog.h> |
| 71 | |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 72 | #include "oranE2/E2AP-PDU.h" |
| 73 | #include "oranE2/ProtocolIE-Container.h" |
| 74 | #include "oranE2/InitiatingMessage.h" |
| 75 | #include "oranE2/SuccessfulOutcome.h" |
| 76 | #include "oranE2/UnsuccessfulOutcome.h" |
| 77 | #include "oranE2/ProtocolIE-Container.h" |
| 78 | #include "oranE2/ProtocolIE-Field.h" |
| 79 | #include "oranE2/GlobalE2node-gNB-ID.h" |
| 80 | #include "oranE2/GlobalE2node-en-gNB-ID.h" |
| 81 | #include "oranE2/GlobalE2node-ng-eNB-ID.h" |
| 82 | #include "oranE2/GlobalE2node-eNB-ID.h" |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 83 | |
| 84 | #include "cxxopts.hpp" |
| 85 | //#include "config-cpp/include/config-cpp/config-cpp.h" |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 86 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 87 | |
| 88 | #include "mapWrapper.h" |
aa7133@att.com | 16c799b | 2020-03-24 18:01:51 +0200 | [diff] [blame] | 89 | #include "statCollector.h" |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 90 | |
| 91 | #include "base64.h" |
| 92 | |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 93 | #include "ReadConfigFile.h" |
| 94 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 95 | using namespace std; |
| 96 | namespace logging = boost::log; |
| 97 | namespace src = boost::log::sources; |
| 98 | namespace keywords = boost::log::keywords; |
| 99 | namespace sinks = boost::log::sinks; |
| 100 | namespace posix_time = boost::posix_time; |
| 101 | namespace expr = boost::log::expressions; |
| 102 | |
| 103 | #define SRC_PORT 36422 |
| 104 | #define SA struct sockaddr |
| 105 | #define MAX_ENODB_NAME_SIZE 64 |
| 106 | |
| 107 | #define MAXEVENTS 128 |
| 108 | |
aa7133@att.com | 7c3e4c0 | 2020-03-25 16:37:19 +0200 | [diff] [blame] | 109 | #define RECEIVE_SCTP_BUFFER_SIZE (128 * 1024) |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 110 | #define RECEIVE_XAPP_BUFFER_SIZE RECEIVE_SCTP_BUFFER_SIZE |
| 111 | |
| 112 | typedef mapWrapper Sctp_Map_t; |
| 113 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 114 | |
aa7133@att.com | 16c799b | 2020-03-24 18:01:51 +0200 | [diff] [blame] | 115 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 116 | #define VOLUME_URL_SIZE 256 |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 117 | #define KA_MESSAGE_SIZE 2048 |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 118 | |
| 119 | typedef struct sctp_params { |
| 120 | uint16_t rmrPort = 0; |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 121 | uint16_t sctpPort = SRC_PORT; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 122 | int epoll_fd = 0; |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 123 | int listenFD = 0; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 124 | int rmrListenFd = 0; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 125 | int inotifyFD = 0; |
| 126 | int inotifyWD = 0; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 127 | void *rmrCtx = nullptr; |
| 128 | Sctp_Map_t *sctpMap = nullptr; |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 129 | char ka_message[KA_MESSAGE_SIZE] {}; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 130 | int ka_message_length = 0; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 131 | char rmrAddress[256] {}; // "tcp:portnumber" "tcp:5566" listen to all address on port 5566 |
| 132 | mdclog_severity_t logLevel = MDCLOG_INFO; |
| 133 | char volume[VOLUME_URL_SIZE]; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 134 | string myIP {}; |
| 135 | string fqdn {}; |
aa7133@att.com | 342843e | 2020-01-26 12:53:34 +0200 | [diff] [blame] | 136 | string podName {}; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 137 | string configFilePath {}; |
| 138 | string configFileName {}; |
| 139 | bool trace = true; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 140 | //shared_timed_mutex fence; // moved to mapWrapper |
| 141 | } sctp_params_t; |
| 142 | |
| 143 | typedef struct ConnectedCU { |
| 144 | int fileDescriptor = 0; |
| 145 | char hostName[NI_MAXHOST] {}; |
| 146 | char portNumber[NI_MAXSERV] {}; |
| 147 | char enodbName[MAX_ENODB_NAME_SIZE] {}; |
| 148 | char asnData[RECEIVE_SCTP_BUFFER_SIZE] {}; |
| 149 | size_t asnLength = 0; |
| 150 | int mtype = 0; |
| 151 | bool isConnected = false; |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 152 | bool gotSetup = false; |
| 153 | sctp_params_t *sctpParams = nullptr; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 154 | } ConnectedCU_t ; |
| 155 | |
| 156 | #define MAX_RMR_BUFF_ARRY 32 |
| 157 | typedef struct RmrMessagesBuffer { |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 158 | char ka_message[KA_MESSAGE_SIZE] {}; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 159 | int ka_message_len = 0; |
| 160 | void *rmrCtx = nullptr; |
| 161 | rmr_mbuf_t *sendMessage= nullptr; |
aa7133@att.com | 7c3e4c0 | 2020-03-25 16:37:19 +0200 | [diff] [blame] | 162 | //rmr_mbuf_t *sendBufferedMessages[MAX_RMR_BUFF_ARRY] {}; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 163 | rmr_mbuf_t *rcvMessage= nullptr; |
aa7133@att.com | 7c3e4c0 | 2020-03-25 16:37:19 +0200 | [diff] [blame] | 164 | //rmr_mbuf_t *rcvBufferedMessages[MAX_RMR_BUFF_ARRY] {}; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 165 | } RmrMessagesBuffer_t; |
| 166 | |
| 167 | typedef struct formatedMessage { |
| 168 | char enodbName[MAX_ENODB_NAME_SIZE]; |
| 169 | struct timespec time; |
| 170 | int messageType; |
| 171 | char direction; |
| 172 | ssize_t asnLength; |
| 173 | unsigned char *asndata; |
| 174 | } FormatedMessage_t; |
| 175 | |
| 176 | typedef struct ReportingMessages { |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 177 | FormatedMessage_t message {}; |
| 178 | ConnectedCU_t *peerInfo = nullptr; |
| 179 | long outLen = 0; |
| 180 | unsigned char base64Data[RECEIVE_SCTP_BUFFER_SIZE * 2] {}; |
| 181 | char buffer[RECEIVE_SCTP_BUFFER_SIZE * 8] {}; |
aa7133@att.com | 16c799b | 2020-03-24 18:01:51 +0200 | [diff] [blame] | 182 | StatCollector *statCollector = nullptr; |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 183 | } ReportingMessages_t; |
| 184 | |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 185 | cxxopts::ParseResult parse(int argc, char *argv[], sctp_params_t &pSctpParams); |
| 186 | |
| 187 | int buildInotify(sctp_params_t &sctpParams); |
| 188 | |
| 189 | void handleTermInit(sctp_params_t &sctpParams); |
| 190 | |
| 191 | void handleConfigChange(sctp_params_t *sctpParams); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 192 | |
| 193 | void listener(sctp_params_t *params); |
| 194 | |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 195 | void sendTermInit(sctp_params_t &sctpParams); |
| 196 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 197 | int setSocketNoBlocking(int socket); |
| 198 | |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 199 | void handleEinprogressMessages(struct epoll_event &event, |
| 200 | ReportingMessages_t &message, |
| 201 | RmrMessagesBuffer_t &rmrMessageBuffer, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 202 | sctp_params_t *params); |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 203 | |
| 204 | void handlepoll_error(struct epoll_event &event, |
| 205 | ReportingMessages_t &message, |
| 206 | RmrMessagesBuffer_t &rmrMessageBuffer, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 207 | sctp_params_t *params); |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 208 | |
| 209 | |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 210 | void cleanHashEntry(ConnectedCU_t *peerInfo, Sctp_Map_t *m); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 211 | |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * |
| 215 | * @param message |
| 216 | * @param rmrMessageBuffer |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 217 | */ |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 218 | void getRequestMetaData(ReportingMessages_t &message, RmrMessagesBuffer_t &rmrMessageBuffer); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 219 | |
| 220 | /** |
| 221 | * |
| 222 | * @param sctpMap |
| 223 | * @param messagBuffer |
| 224 | * @param message |
| 225 | * @param failedMesgId |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 226 | * @return |
| 227 | */ |
| 228 | int sendMessagetoCu(Sctp_Map_t *sctpMap, |
| 229 | RmrMessagesBuffer_t &messagBuffer, |
| 230 | ReportingMessages_t &message, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 231 | int failedMesgId); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 232 | |
| 233 | void sendFailedSendingMessagetoXapp(RmrMessagesBuffer_t &rmrMessageBuffer, |
| 234 | ReportingMessages_t &message, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 235 | int failedMesgId); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 236 | |
| 237 | int sendRequestToXapp(ReportingMessages_t &message, |
| 238 | int requestId, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 239 | RmrMessagesBuffer_t &rmrMmessageBuffer); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 240 | |
| 241 | /** |
| 242 | * |
| 243 | * @param message |
| 244 | * @param msgType |
| 245 | * @param requestType |
| 246 | * @param rmrMessageBuffer |
| 247 | * @param sctpMap |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 248 | * @return |
| 249 | */ |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 250 | /* |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 251 | int sendResponseToXapp(ReportingMessages_t &message, |
| 252 | int msgType, |
| 253 | int requestType, |
| 254 | RmrMessagesBuffer_t &rmrMessageBuffer, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 255 | Sctp_Map_t *sctpMap); |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 256 | */ |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 257 | |
| 258 | /** |
| 259 | * |
| 260 | * @param peerInfo |
| 261 | * @param message |
| 262 | * @param m |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 263 | * @return |
| 264 | */ |
| 265 | int sendSctpMsg(ConnectedCU_t *peerInfo, |
| 266 | ReportingMessages_t &message, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 267 | Sctp_Map_t *m); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 268 | |
| 269 | /** |
| 270 | * |
| 271 | * @param events |
| 272 | * @param sctpMap |
| 273 | * @param numOfMessages |
| 274 | * @param rmrMessageBuffer |
| 275 | * @param ts |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 276 | * @return |
| 277 | */ |
| 278 | int receiveDataFromSctp(struct epoll_event *events, |
| 279 | Sctp_Map_t *sctpMap, |
| 280 | int &numOfMessages, |
| 281 | RmrMessagesBuffer_t &rmrMessageBuffer, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 282 | struct timespec &ts); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 283 | |
| 284 | /** |
| 285 | * |
| 286 | * @param rmrAddress |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 287 | * @return |
| 288 | */ |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 289 | void getRmrContext(sctp_params_t &pSctpParams); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 290 | |
| 291 | /** |
| 292 | * |
| 293 | * @param epoll_fd |
| 294 | * @param rmrCtx |
| 295 | * @param sctpMap |
| 296 | * @param messagBuffer |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 297 | * @return |
| 298 | */ |
aa7133@att.com | 6680c3b | 2020-03-22 12:06:58 +0200 | [diff] [blame] | 299 | int receiveXappMessages(Sctp_Map_t *sctpMap, |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 300 | RmrMessagesBuffer_t &rmrMessageBuffer, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 301 | struct timespec &ts); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 302 | |
| 303 | /** |
| 304 | * |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 305 | * @param messagBuffer |
| 306 | * @param failedMsgId |
| 307 | * @param sctpMap |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 308 | * @return |
| 309 | */ |
| 310 | int sendDirectionalSctpMsg(RmrMessagesBuffer_t &messagBuffer, |
| 311 | ReportingMessages_t &message, |
| 312 | int failedMsgId, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 313 | Sctp_Map_t *sctpMap); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 314 | /** |
| 315 | * |
| 316 | * @param pdu |
| 317 | * @param message |
| 318 | * @param rmrMessageBuffer |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 319 | */ |
| 320 | void asnInitiatingRequest(E2AP_PDU_t *pdu, |
| 321 | ReportingMessages_t &message, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 322 | RmrMessagesBuffer_t &rmrMessageBuffer); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 323 | /** |
| 324 | * |
| 325 | * @param pdu |
| 326 | * @param message |
| 327 | * @param sctpMap |
| 328 | * @param rmrMessageBuffer |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 329 | */ |
| 330 | void asnSuccsesfulMsg(E2AP_PDU_t *pdu, |
| 331 | ReportingMessages_t &message, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 332 | RmrMessagesBuffer_t &rmrMessageBuffer); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 333 | /** |
| 334 | * |
| 335 | * @param pdu |
| 336 | * @param message |
| 337 | * @param sctpMap |
| 338 | * @param rmrMessageBuffer |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 339 | */ |
| 340 | void asnUnSuccsesfulMsg(E2AP_PDU_t *pdu, |
| 341 | ReportingMessages_t &message, |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 342 | RmrMessagesBuffer_t &rmrMessageBuffer); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 343 | |
| 344 | /** |
| 345 | * |
| 346 | * @param rmrMessageBuffer |
| 347 | * @param message |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 348 | * @return |
| 349 | */ |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 350 | int sendRmrMessage(RmrMessagesBuffer_t &rmrMessageBuffer, ReportingMessages_t &message); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 351 | /** |
| 352 | * |
| 353 | * @param epoll_fd |
| 354 | * @param peerInfo |
| 355 | * @param events |
| 356 | * @param sctpMap |
| 357 | * @param enodbName |
| 358 | * @param msgType |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 359 | * @returnsrc::logger_mt& lg = my_logger::get(); |
| 360 | */ |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 361 | int addToEpoll(int epoll_fd, ConnectedCU_t *peerInfo, uint32_t events, Sctp_Map_t *sctpMap, char *enodbName, int msgType); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 362 | /** |
| 363 | * |
| 364 | * @param epoll_fd |
| 365 | * @param peerInfo |
| 366 | * @param events |
| 367 | * @param sctpMap |
| 368 | * @param enodbName |
| 369 | * @param msgType |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 370 | * @return |
| 371 | */ |
aa7133@att.com | be92d71 | 2020-03-18 17:30:39 +0200 | [diff] [blame] | 372 | int modifyToEpoll(int epoll_fd, ConnectedCU_t *peerInfo, uint32_t events, Sctp_Map_t *sctpMap, char *enodbName, int msgType); |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 373 | |
| 374 | /** |
| 375 | * |
| 376 | * @param message |
| 377 | */ |
| 378 | void buildJsonMessage(ReportingMessages_t &message); |
| 379 | |
| 380 | /** |
| 381 | * |
| 382 | * |
| 383 | * @param state |
| 384 | * @return |
| 385 | */ |
| 386 | string translateRmrErrorMessages(int state); |
| 387 | |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 388 | |
| 389 | static inline uint64_t rdtscp(uint32_t &aux) { |
| 390 | uint64_t rax,rdx; |
| 391 | asm volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : :); |
aa7133@att.com | 84bd334 | 2020-03-16 18:04:57 +0200 | [diff] [blame] | 392 | return (rdx << (unsigned)32) + rax; |
ss412g | 3bac2da | 2020-01-05 11:52:19 +0200 | [diff] [blame] | 393 | } |
ss412g | 1a79bdf | 2019-10-24 12:03:05 +0300 | [diff] [blame] | 394 | #ifndef RIC_SCTP_CONNECTION_FAILURE |
| 395 | #define RIC_SCTP_CONNECTION_FAILURE 10080 |
| 396 | #endif |
| 397 | |
| 398 | #endif //X2_SCTP_THREAD_H |