revert Update release tag to 4.0.10
[ric-plt/e2.git] / RIC-E2-TERMINATION / sctpThread.h
index 7112082..ebfda28 100644 (file)
@@ -50,6 +50,7 @@
 #include <map>
 #include <sys/inotify.h>
 #include <csignal>
+#include <future>
 
 #include <rmr/rmr.h>
 #include <rmr/RIC_message_types.h>
 
 #include "cxxopts.hpp"
 //#include "config-cpp/include/config-cpp/config-cpp.h"
+#include <zlib.h>
+#include <prometheus/counter.h>
+#include <prometheus/exposer.h>
+#include <prometheus/gateway.h>
+#include <prometheus/registry.h>
 
+using namespace prometheus;
 
 #include "mapWrapper.h"
-#include "statCollector.h"
 
 #include "base64.h"
 
@@ -106,8 +112,8 @@ namespace expr = boost::log::expressions;
 
 #define MAXEVENTS 128
 
-#define RECEIVE_SCTP_BUFFER_SIZE (128 * 1024)
-#define RECEIVE_XAPP_BUFFER_SIZE RECEIVE_SCTP_BUFFER_SIZE 
+#define RECEIVE_SCTP_BUFFER_SIZE (256 * 1024)
+#define RECEIVE_XAPP_BUFFER_SIZE RECEIVE_SCTP_BUFFER_SIZE
 
 typedef mapWrapper Sctp_Map_t;
 
@@ -117,6 +123,7 @@ typedef mapWrapper Sctp_Map_t;
 #define KA_MESSAGE_SIZE 2048
 
 typedef struct sctp_params {
+    int      epollTimeOut = -1;
     uint16_t rmrPort = 0;
     uint16_t sctpPort = SRC_PORT;
     int      epoll_fd = 0;
@@ -137,9 +144,28 @@ typedef struct sctp_params {
     string configFilePath {};
     string configFileName {};
     bool trace = true;
-    //shared_timed_mutex fence; // moved to mapWrapper
+    string prometheusMode {"pull"};
+    string prometheusPushAddress {"127.0.0.1:7676"};
+    shared_ptr<prometheus::Registry> prometheusRegistry;
+    string prometheusPort {"8088"};
+    Family<Counter> *prometheusFamily;
+    Gateway *prometheusGateway = nullptr;
+    Exposer *prometheusExposer = nullptr;
 } sctp_params_t;
 
+// RAN to RIC
+#define IN_INITI 0 //INITIATING
+#define IN_SUCC 1 //SUCCESSFULL
+#define IN_UN_SUCC 2 //UN-Successfull
+
+// RIC To RAN
+#define OUT_INITI 3 //INITIATING
+#define OUT_SUCC 4 //SUCCESSFULL
+#define OUT_UN_SUCC 5 //UN-Successfull
+
+#define MSG_COUNTER 0
+#define BYTES_COUNTER 1
+
 typedef struct ConnectedCU {
     int fileDescriptor = 0;
     char hostName[NI_MAXHOST] {};
@@ -151,8 +177,10 @@ typedef struct ConnectedCU {
     bool isConnected = false;
     bool gotSetup = false;
     sctp_params_t *sctpParams = nullptr;
+    Counter *counters[6][2][ProcedureCode_id_RICsubscriptionDelete + 1] {};
 } ConnectedCU_t ;
 
+
 #define MAX_RMR_BUFF_ARRY 32
 typedef struct RmrMessagesBuffer {
     char ka_message[KA_MESSAGE_SIZE] {};
@@ -179,7 +207,6 @@ typedef struct ReportingMessages {
     long outLen = 0;
     unsigned char base64Data[RECEIVE_SCTP_BUFFER_SIZE * 2] {};
     char buffer[RECEIVE_SCTP_BUFFER_SIZE * 8] {};
-    StatCollector *statCollector = nullptr;
 } ReportingMessages_t;
 
 cxxopts::ParseResult parse(int argc, char *argv[], sctp_params_t &pSctpParams);
@@ -318,6 +345,7 @@ int sendDirectionalSctpMsg(RmrMessagesBuffer_t &messagBuffer,
  * @param rmrMessageBuffer
  */
 void asnInitiatingRequest(E2AP_PDU_t *pdu,
+                          Sctp_Map_t *sctpMap,
                           ReportingMessages_t &message,
                           RmrMessagesBuffer_t &rmrMessageBuffer);
 /**
@@ -328,6 +356,7 @@ void asnInitiatingRequest(E2AP_PDU_t *pdu,
  * @param rmrMessageBuffer
  */
 void asnSuccsesfulMsg(E2AP_PDU_t *pdu,
+                      Sctp_Map_t *sctpMap,
                       ReportingMessages_t &message,
                       RmrMessagesBuffer_t &rmrMessageBuffer);
 /**
@@ -338,6 +367,7 @@ void asnSuccsesfulMsg(E2AP_PDU_t *pdu,
  * @param rmrMessageBuffer
  */
 void asnUnSuccsesfulMsg(E2AP_PDU_t *pdu,
+                        Sctp_Map_t *sctpMap,
                         ReportingMessages_t &message,
                         RmrMessagesBuffer_t &rmrMessageBuffer);