#include "asn_constant.h"
#include "E2AP_if.h"
-
-#ifdef DEBUG
- static const bool debug = true;
-#else
- static const bool debug = true; //false;
-#endif
+static bool debugPrints = false;
const int64_t cMaxNrOfErrors = 256;
const uint64_t cMaxSizeOfOctetString = 1024;
uint8_t octets[4];
} IdOctects_t;
+//////////////////////////////////////////////////////////////////////
+void allowASN1DebugPrints(bool allowASN1DebugPrints) {
+ debugPrints = allowASN1DebugPrints;
+}
+
//////////////////////////////////////////////////////////////////////
const char* getE2ErrorString(uint64_t errorCode) {
/////////////////////////////////////////////////////////////////////
bool E2encode(E2AP_PDU_t* pE2AP_PDU, size_t* dataBufferSize, byte* dataBuffer, char* pLogBuffer) {
- // Debug print
- if (debug)
+ if (debugPrints)
asn_fprint(stdout, &asn_DEF_E2AP_PDU, pE2AP_PDU);
asn_enc_rval_t rval;
return false;
}
else {
- if (debug)
+ if (debugPrints)
sprintf(pLogBuffer,"Successfully encoded %s. Buffer size %zu, encoded size %zu",asn_DEF_E2AP_PDU.name, *dataBufferSize, rval.encoded);
ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pE2AP_PDU);
rval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, (void **)&pE2AP_PDU, dataBuffer, dataBufferSize);
switch (rval.code) {
case RC_OK:
- // Debug print
- if (debug) {
+ if (debugPrints) {
sprintf(pLogBuffer,"Successfully decoded E2AP-PDU");
asn_fprint(stdout, &asn_DEF_E2AP_PDU, pE2AP_PDU);
}
//////////////////////////////////////////////////////////////////////
// Function declarations
+void allowASN1DebugPrints(bool);
+
const char* getE2ErrorString(uint64_t);
typedef void* e2ap_pdu_ptr_t;
return b.String()
}
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func SetASN1DebugPrintStatus(logLevel int) {
+ if logLevel >= 4 {
+ fmt.Println("Setting ASN1 debug prints ON")
+ C.allowASN1DebugPrints(true)
+ } else {
+ fmt.Println("Setting ASN1 debug prints OFF")
+ C.allowASN1DebugPrints(false)
+ }
+}
+
//-----------------------------------------------------------------------------
// Public E2AP packer creators
//-----------------------------------------------------------------------------
e2SubsDb: CreateSdl(),
restSubsDb: CreateRESTSdl(),
Counters: xapp.Metric.RegisterCounterGroup(GetMetricsOpts(), "SUBMGR"),
- LoggerLevel: 4,
+ LoggerLevel: 1,
}
e2IfState.Init(c)
xapp.Resource.InjectRoute("/ric/v1/restsubscriptions", c.GetAllRestSubscriptions, "GET")
xapp.Resource.InjectRoute("/ric/v1/symptomdata", c.SymptomDataHandler, "GET")
- if readSubsFromDb == "false" {
- return c
+ if readSubsFromDb == "true" {
+ // Read subscriptions from db
+ c.ReadE2Subscriptions()
+ c.ReadRESTSubscriptions()
}
- // Read subscriptions from db
- c.ReadE2Subscriptions()
- c.ReadRESTSubscriptions()
-
go xapp.Subscription.Listen(c.RESTSubscriptionHandler, c.RESTQueryHandler, c.RESTSubscriptionDeleteHandler)
-
return c
}
c.LoggerLevel = int(xapp.Logger.GetLevel())
xapp.Logger.Debug("LoggerLevel= %v", c.LoggerLevel)
+ c.e2ap.SetASN1DebugPrintStatus(c.LoggerLevel)
// viper.GetDuration returns nanoseconds
e2tSubReqTimeout = viper.GetDuration("controls.e2tSubReqTimeout_ms") * 1000000
type E2ap struct {
}
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+func (c *E2ap) SetASN1DebugPrintStatus(logLevel int) {
+ e2ap_wrapper.SetASN1DebugPrintStatus(logLevel)
+}
+
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
mainCtrl.RmrControl.Init("SUBMGRCTL", srcId, rtgSvc)
mainCtrl.c = NewControl()
mainCtrl.c.UTTesting = true
- mainCtrl.c.LoggerLevel = int(xapp.Logger.GetLevel())
+ mainCtrl.c.LoggerLevel = 4
+ mainCtrl.c.e2ap.SetASN1DebugPrintStatus(mainCtrl.c.LoggerLevel)
xapp.Logger.Debug("Test: LoggerLevel %v", mainCtrl.c.LoggerLevel)
xapp.Logger.Debug("Replacing real db with test db")
mainCtrl.c.e2SubsDb = CreateMock() // This overrides real E2 Subscription database for testing