ASN.1 debug printouts hided by default
 - ASN.1 debug printouts are made now on logger level >= 4

Change-Id: I2b3072825c16742c1cea9a8b1612d65c53b1bd3a
Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
diff --git a/e2ap/libe2ap_wrapper/E2AP_if.c b/e2ap/libe2ap_wrapper/E2AP_if.c
index 8686908..fe0d5d5 100644
--- a/e2ap/libe2ap_wrapper/E2AP_if.c
+++ b/e2ap/libe2ap_wrapper/E2AP_if.c
@@ -27,12 +27,7 @@
 #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;
@@ -75,6 +70,11 @@
 } IdOctects_t;
 
 //////////////////////////////////////////////////////////////////////
+void allowASN1DebugPrints(bool allowASN1DebugPrints) {
+    debugPrints = allowASN1DebugPrints;
+}
+
+//////////////////////////////////////////////////////////////////////
 const char* getE2ErrorString(uint64_t errorCode) {
 
     return E2ErrorStrings[errorCode];
@@ -83,8 +83,7 @@
 /////////////////////////////////////////////////////////////////////
 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;
@@ -100,7 +99,7 @@
         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);
@@ -653,8 +652,7 @@
     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);
         }
diff --git a/e2ap/libe2ap_wrapper/E2AP_if.h b/e2ap/libe2ap_wrapper/E2AP_if.h
index aab8aaa..c52db2b 100644
--- a/e2ap/libe2ap_wrapper/E2AP_if.h
+++ b/e2ap/libe2ap_wrapper/E2AP_if.h
@@ -429,6 +429,8 @@
 //////////////////////////////////////////////////////////////////////
 // Function declarations
 
+void allowASN1DebugPrints(bool);
+
 const char* getE2ErrorString(uint64_t);
 
 typedef void* e2ap_pdu_ptr_t;
diff --git a/e2ap/pkg/e2ap_wrapper/packer_e2ap.go b/e2ap/pkg/e2ap_wrapper/packer_e2ap.go
index dafac42..dcf84ab 100644
--- a/e2ap/pkg/e2ap_wrapper/packer_e2ap.go
+++ b/e2ap/pkg/e2ap_wrapper/packer_e2ap.go
@@ -1116,6 +1116,19 @@
 }
 
 //-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+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
 //-----------------------------------------------------------------------------