association_max_retrans to be taken from env variable
[ric-plt/e2.git] / RIC-E2-TERMINATION / sctpThread.h
index 6e22f7b..f1045f1 100644 (file)
@@ -41,6 +41,8 @@
 #include <atomic>
 #include <sys/param.h>
 #include <sys/file.h>
+#include <sys/types.h>
+#include <ifaddrs.h>
 #include <ctime>
 #include <netdb.h>
 #include <sys/epoll.h>
@@ -136,7 +138,6 @@ typedef struct sctp_params {
     char      ka_message[KA_MESSAGE_SIZE] {};
     int       ka_message_length = 0;
     char       rmrAddress[256] {}; // "tcp:port number" "tcp:5566" listen to all address on port 5566
-    mdclog_severity_t logLevel = MDCLOG_INFO;
     char volume[VOLUME_URL_SIZE];
     string myIP {};
     string fqdn {};
@@ -148,6 +149,7 @@ typedef struct sctp_params {
     string prometheusPort {"8088"};
     Family<Counter> *prometheusFamily;
     Exposer *prometheusExposer = nullptr;
+    Counter *e2tCounters[6][2][ProcedureCode_id_RICsubscriptionDeleteRequired + 1] {};
 } sctp_params_t;
 
 // RAN to RIC
@@ -163,6 +165,8 @@ typedef struct sctp_params {
 #define MSG_COUNTER 0
 #define BYTES_COUNTER 1
 
+#define INVALID_STREAM_ID -1
+
 typedef struct ConnectedCU {
     int fileDescriptor = 0;
     char hostName[NI_MAXHOST] {};
@@ -174,7 +178,9 @@ typedef struct ConnectedCU {
     bool isConnected = false;
     bool gotSetup = false;
     sctp_params_t *sctpParams = nullptr;
-    Counter *counters[6][2][ProcedureCode_id_RICsubscriptionDelete + 1] {};
+    Counter *counters[6][2][ProcedureCode_id_RICsubscriptionDeleteRequired + 1] {};
+    bool isSingleStream = false;
+    int singleStreamId = 0;
 } ConnectedCU_t ;
 
 
@@ -343,7 +349,7 @@ int sendDirectionalSctpMsg(RmrMessagesBuffer_t &messageBuffer,
 void asnInitiatingRequest(E2AP_PDU_t *pdu,
                           Sctp_Map_t *sctpMap,
                           ReportingMessages_t &message,
-                          RmrMessagesBuffer_t &rmrMessageBuffer);
+                          RmrMessagesBuffer_t &rmrMessageBuffer,int streamId);
 /**
  *
  * @param pdu
@@ -411,6 +417,15 @@ void buildJsonMessage(ReportingMessages_t &message);
  */
 string translateRmrErrorMessages(int state);
 
+int buildConfiguration(sctp_params_t &sctpParams);
+void startPrometheus(sctp_params_t &sctpParams);
+static int enable_log_change_notify(const char* fileName);
+static int register_log_change_notify(const char *fileName);
+static void * monitor_loglevel_change_handler(void* arg);
+void  update_mdc_log_level_severity(char* log_level);
+char* getinterfaceip();
+static char* parse_file(char* filename);
+
 
 static inline uint64_t rdtscp(uint32_t &aux) {
     uint64_t rax,rdx;
@@ -421,4 +436,12 @@ static inline uint64_t rdtscp(uint32_t &aux) {
 #define RIC_SCTP_CONNECTION_FAILURE  10080
 #endif
 
+#ifdef UNIT_TEST
+    #define FILE_DESCRIPTOR 53424 /*Dummy value for file descriptor only when UT is defined*/
+#endif
+
+int buildListeningPort(sctp_params_t &sctpParams);
+void buildE2TPrometheusCounters(sctp_params_t &sctpParams);
+
+int fetchStreamId(ConnectedCU_t *peerInfo, ReportingMessages_t &message);
 #endif //X2_SCTP_THREAD_H