diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 9914d4abfa..f199ee0ca8 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -334,13 +334,9 @@ add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"") # Debug related options ######################################### -add_boolean_option(ASN_EMIT_DEBUG False "ASN1 coder/decoder Debug") -add_boolean_option(ASN_THREAD_SAFE True "ASN1 coder/decoder Debug") -add_boolean_option(MSG_PRINT True "print debug messages") +add_boolean_option(DEBUG_ASN1C False "ASN1 coder/decoder Debug traces, see common/utils/config.h, the logs are regular OAI logs, in the log group 'ASN'") add_boolean_option(DISABLE_XER_PRINT False "print XER Format") add_boolean_option(XER_PRINT False "print XER Format") -add_boolean_option(RRC_MSG_PRINT False "print RRC messages") -add_boolean_option(PDCP_MSG_PRINT False "print PDCP messages to /tmp/pdcp.log") add_boolean_option(DEBUG_PDCP_PAYLOAD False "print PDCP PDU to stdout") # if true, make sure that global and PDCP log levels are trace add_boolean_option(DEBUG_MAC_INTERFACE False "print MAC-RLC PDU exchange to stdout") # if true, make sure that global and PDCP log levels are trace add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if true, make sure that global and PDCP log levels are trace @@ -358,6 +354,12 @@ add_library(ITTI ) add_dependencies(ITTI rrc_flag) +# asn1c skeletons have hardcoded this flag to make customized debug logs +# OAI uses this feature to re-use OAI LOG_I(ASN, ...) +if (DEBUG_ASN1C) + add_definitions(-DHAVE_CONFIG_H) +endif() + ################################################## # ASN.1 grammar C code generation & dependencies # ################################################## diff --git a/common/utils/config.h b/common/utils/config.h new file mode 100644 index 0000000000..597ead7ed6 --- /dev/null +++ b/common/utils/config.h @@ -0,0 +1,56 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef UTILS_CONFIG_H_ASN1 +#define UTILS_CONFIG_H_ASN1 + +// This is hard coded file name "config.h" and HAVE_CONFIG_H_ in asn1c skeletons + +/* + * This file "config.h" will be used by asn1c if HAVE_CONFIG_H_ is defined and + * included. This logs asn1c encoder and decoder traces at execution time using + * the regular OAI logging system, i.e., LOG_I(ASN...); + * + * As it is very verbose, note that you can change the log level per module in + * source or in gdb, e.g., to only activate it for a short time. + * + * In code: + * ``` + * set_log(ASN, OAI_INFO); // enable logging + * // do your encoding here + * set_log(ASN, OAI_ERR); // disable logging + * ``` + * + * in gdb: + * ``` + * gdb> p set_log(ASN, 1) // disable log, 1 == OAI_ERR + * gdb> p set_log(ASN, 5) // enable log, 5 == OAI_INFO + * ``` + */ + +#include "common/utils/LOG/log.h" +#if DEBUG_ASN1C +#define ASN_DEBUG(x...) do{ LOG_I(ASN,x);LOG_I(ASN,"\n"); } while(false) +#else +#define ASN_DEBUG(x...) +#endif + +#endif /* UTILS_CONFIG_H_ASN1 */ diff --git a/openair2/F1AP/f1ap_common.c b/openair2/F1AP/f1ap_common.c index 338b5f0c2b..efcb1d161b 100644 --- a/openair2/F1AP/f1ap_common.c +++ b/openair2/F1AP/f1ap_common.c @@ -35,27 +35,6 @@ static f1ap_cudu_inst_t *f1_du_inst[NUMBER_OF_eNB_MAX]= {0}; static f1ap_cudu_inst_t *f1_cu_inst[NUMBER_OF_eNB_MAX]= {0}; -#if defined(EMIT_ASN_DEBUG_EXTERN) -int asn_debug = 0; -int asn1_xer_print = 0; - -inline void ASN_DEBUG(const char *fmt, ...) { - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) - fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - uint8_t F1AP_get_next_transaction_identifier(instance_t enb_mod_idP, instance_t cu_mod_idP) { static uint8_t transaction_identifier[NUMBER_OF_eNB_MAX]; transaction_identifier[enb_mod_idP+cu_mod_idP] = diff --git a/openair2/F1AP/f1ap_common.h b/openair2/F1AP/f1ap_common.h index 6b64e1b59e..e89e8a70cc 100644 --- a/openair2/F1AP/f1ap_common.h +++ b/openair2/F1AP/f1ap_common.h @@ -29,11 +29,6 @@ * \note * \warning */ - -#if HAVE_CONFIG_H_ - #include "config.h" -#endif - #ifndef F1AP_COMMON_H_ #define F1AP_COMMON_H_ @@ -43,10 +38,6 @@ #define F1AP_UE_IDENTIFIER_NUMBER 3 #define F1AP_TRANSACTION_IDENTIFIER_NUMBER 3 -#if defined(EMIT_ASN_DEBUG_EXTERN) - inline void ASN_DEBUG(const char *fmt, ...); -#endif - #include "F1AP_RAT-FrequencyPriorityInformation.h" #include "F1AP_DLUPTNLInformation-ToBeSetup-Item.h" #include "F1AP_PrivateMessage.h" diff --git a/openair2/M2AP/m2ap_common.c b/openair2/M2AP/m2ap_common.c index d288a0a114..aa090d124d 100644 --- a/openair2/M2AP/m2ap_common.c +++ b/openair2/M2AP/m2ap_common.c @@ -31,27 +31,6 @@ #include "m2ap_common.h" #include "M2AP_M2AP-PDU.h" -int asn_debug = 0; -int asn1_xer_print = 0; - -#if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...) -{ - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - ssize_t m2ap_generate_initiating_message( uint8_t **buffer, uint32_t *length, diff --git a/openair2/M2AP/m2ap_common.h b/openair2/M2AP/m2ap_common.h index 0a6895fcb7..2e84c51938 100644 --- a/openair2/M2AP/m2ap_common.h +++ b/openair2/M2AP/m2ap_common.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif +#ifndef M2AP_COMMON_H_ +#define M2AP_COMMON_H_ #include "M2AP_ProtocolIE-Field.h" #include "M2AP_M2AP-PDU.h" @@ -38,9 +36,6 @@ #include "common/ran_context.h" -#ifndef M2AP_COMMON_H_ -#define M2AP_COMMON_H_ - /** @defgroup _m2ap_impl_ M2AP Layer Reference Implementation * @ingroup _ref_implementation_ * @{ diff --git a/openair2/X2AP/x2ap_common.c b/openair2/X2AP/x2ap_common.c index 93a8c32513..a687b90666 100644 --- a/openair2/X2AP/x2ap_common.c +++ b/openair2/X2AP/x2ap_common.c @@ -31,27 +31,6 @@ #include "x2ap_common.h" #include "X2AP_X2AP-PDU.h" -int asn_debug = 0; -int asn1_xer_print = 0; - -#if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...) -{ - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - ssize_t x2ap_generate_initiating_message( uint8_t **buffer, uint32_t *length, diff --git a/openair2/X2AP/x2ap_common.h b/openair2/X2AP/x2ap_common.h index 7dd88ffa21..e7b86c77b9 100644 --- a/openair2/X2AP/x2ap_common.h +++ b/openair2/X2AP/x2ap_common.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif +#ifndef X2AP_COMMON_H_ +#define X2AP_COMMON_H_ #include "X2AP_ProtocolIE-Field.h" #include "X2AP_X2AP-PDU.h" @@ -35,9 +33,6 @@ #include "X2AP_asn_constant.h" #include "intertask_interface.h" -#ifndef X2AP_COMMON_H_ -#define X2AP_COMMON_H_ - /** @defgroup _x2ap_impl_ X2AP Layer Reference Implementation * @ingroup _ref_implementation_ * @{ diff --git a/openair3/COMMON/security_types.h b/openair3/COMMON/security_types.h index eb55e44d77..5494ffd994 100644 --- a/openair3/COMMON/security_types.h +++ b/openair3/COMMON/security_types.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H -# include "config.h" -#endif +#ifndef SECURITY_TYPES_H_ +#define SECURITY_TYPES_H_ #if !defined(HAVE_UINT128_T) # include @@ -31,8 +29,6 @@ #include #include -#ifndef SECURITY_TYPES_H_ -#define SECURITY_TYPES_H_ #define RAND_LENGTH_BITS (128) #define RAND_LENGTH_OCTETS (RAND_LENGTH_BITS/8) diff --git a/openair3/M3AP/m3ap_common.c b/openair3/M3AP/m3ap_common.c index 5501997638..e43275d96c 100644 --- a/openair3/M3AP/m3ap_common.c +++ b/openair3/M3AP/m3ap_common.c @@ -31,27 +31,6 @@ #include "m3ap_common.h" #include "M3AP_M3AP-PDU.h" -int asn_debug = 0; -int asn1_xer_print = 0; - -#if defined(EMIT_ASN_DEBUG_EXTERN) -inline void ASN_DEBUG(const char *fmt, ...) -{ - if (asn_debug) { - int adi = asn_debug_indent; - va_list ap; - va_start(ap, fmt); - fprintf(stderr, "[ASN1]"); - - while(adi--) fprintf(stderr, " "); - - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - } -} -#endif - ssize_t m3ap_generate_initiating_message( uint8_t **buffer, uint32_t *length, diff --git a/openair3/M3AP/m3ap_common.h b/openair3/M3AP/m3ap_common.h index c5f55bc70a..75c60db71a 100644 --- a/openair3/M3AP/m3ap_common.h +++ b/openair3/M3AP/m3ap_common.h @@ -18,10 +18,8 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif +#ifndef M3AP_COMMON_H_ +#define M3AP_COMMON_H_ #include "M3AP_ProtocolIE-Field.h" #include "M3AP_M3AP-PDU.h" @@ -35,8 +33,6 @@ #include "M3AP_asn_constant.h" #include "intertask_interface.h" -#ifndef M3AP_COMMON_H_ -#define M3AP_COMMON_H_ /** @defgroup _m3ap_impl_ M3AP Layer Reference Implementation * @ingroup _ref_implementation_ diff --git a/openair3/NGAP/ngap_common.h b/openair3/NGAP/ngap_common.h index a550b6e436..cfb9d63e59 100644 --- a/openair3/NGAP/ngap_common.h +++ b/openair3/NGAP/ngap_common.h @@ -33,23 +33,11 @@ */ -#if HAVE_CONFIG_H_ -# include "config.h" -#endif - #ifndef NGAP_COMMON_H_ #define NGAP_COMMON_H_ #include "common/utils/LOG/log.h" -/* replace ASN_DEBUG defined in asn_internal.h by oai tracing system - Would be cleaner to modify asn_internal.h but it seems to come - from non oai source, with BSD license, so prefer to do that here.. -*/ -#ifdef ASN_DEBUG -# undef ASN_DEBUG -#endif -#define ASN_DEBUG( x... ) LOG_I(ASN, x) #include "NGAP_ProtocolIE-Field.h" #include "NGAP_NGAP-PDU.h" diff --git a/openair3/S1AP/s1ap_common.h b/openair3/S1AP/s1ap_common.h index d383b622b6..9eee0d8dff 100644 --- a/openair3/S1AP/s1ap_common.h +++ b/openair3/S1AP/s1ap_common.h @@ -23,24 +23,10 @@ * @ingroup _ref_implementation_ * @{ */ - -#if HAVE_CONFIG_H_ -# include "config.h" -#endif - #ifndef S1AP_COMMON_H_ #define S1AP_COMMON_H_ - #include "common/utils/LOG/log.h" -/* replace ASN_DEBUG defined in asn_internal.h by oai tracing system - Would be cleaner to modify asn_internal.h but it seems to come - from non oai source, with BSD license, so prefer to do that here.. -*/ -#ifdef ASN_DEBUG -# undef ASN_DEBUG -#endif -#define ASN_DEBUG( x... ) LOG_I(ASN, x) #include "S1AP_ProtocolIE-Field.h" #include "S1AP_S1AP-PDU.h" @@ -63,7 +49,6 @@ #define S1AP_UE_ID_FMT "0x%06"PRIX32 -extern int asn_debug; extern int asn1_xer_print; #if defined(ENB_MODE) diff --git a/openair3/TEST/test_kdf.c b/openair3/TEST/test_kdf.c index 50a2ad347a..7e1b623e5e 100644 --- a/openair3/TEST/test_kdf.c +++ b/openair3/TEST/test_kdf.c @@ -24,10 +24,6 @@ #include #include -#if HAVE_CONFIG_H -# include "config.h" -#endif - #include "test_util.h" #include "secu_defs.h"