pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-iuh/+/26769 )
Change subject: Introduce dynamic log category for libosmo-rua/hnbap
......................................................................
Introduce dynamic log category for libosmo-rua/hnbap
Same as already done for libosmo-ranap.
This allows applications setting the cateogy dynamically, and will allow
untangling library tests using hnbgw log categories in this repo.
Change-Id: I5d09b67b115ad8938e5162a23accfcbafab139d4
---
M include/osmocom/hnbap/hnbap_common.h
M include/osmocom/ranap/ranap_common.h
M include/osmocom/rua/rua_common.h
M src/hnbap_common.c
M src/ranap_common_cn.c
M src/rua_common.c
M src/rua_msg_factory.c
M src/tests/Makefile.am
M src/tests/hnb-test.h
M src/tests/test-helpers.c
M src/tests/test-hnbap.c
M src/tests/test-ranap.c
M src/tests/test_common.c
M src/tests/test_common.h
14 files changed, 49 insertions(+), 23 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/include/osmocom/hnbap/hnbap_common.h b/include/osmocom/hnbap/hnbap_common.h
index 69a5383..af619e2 100644
--- a/include/osmocom/hnbap/hnbap_common.h
+++ b/include/osmocom/hnbap/hnbap_common.h
@@ -124,7 +124,8 @@
#include <osmocom/core/logging.h>
-#define HNBAP_DEBUG(x, args ...) DEBUGP(1, x, ## args)
+extern int _hnbap_DHNBAP;
+#define HNBAP_DEBUG(x, args ...) DEBUGP(_hnbap_DHNBAP, x, ## args)
extern int asn1_xer_print;
@@ -149,3 +150,5 @@
asn_TYPE_descriptor_t *type, void *sptr);
char *hnbap_cause_str(HNBAP_Cause_t *cause);
+
+void hnbap_set_log_area(int log_area);
diff --git a/include/osmocom/ranap/ranap_common.h b/include/osmocom/ranap/ranap_common.h
index 8899bd5..23359e1 100644
--- a/include/osmocom/ranap/ranap_common.h
+++ b/include/osmocom/ranap/ranap_common.h
@@ -593,8 +593,8 @@
struct gprs_ra_id;
-#define RANAP_DEBUG(x, args ...) DEBUGP(_ranap_DRANAP, x, ## args)
extern int _ranap_DRANAP;
+#define RANAP_DEBUG(x, args ...) DEBUGP(_ranap_DRANAP, x, ## args)
extern int asn1_xer_print;
diff --git a/include/osmocom/rua/rua_common.h b/include/osmocom/rua/rua_common.h
index 9b3a65c..7967c91 100644
--- a/include/osmocom/rua/rua_common.h
+++ b/include/osmocom/rua/rua_common.h
@@ -44,7 +44,8 @@
#include <osmocom/core/logging.h>
-#define RUA_DEBUG(x, args ...) DEBUGP(0, x, ## args)
+extern int _rua_DRUA;
+#define RUA_DEBUG(x, args ...) DEBUGP(_rua_DRUA, x, ## args)
extern int asn1_xer_print;
@@ -69,3 +70,5 @@
asn_TYPE_descriptor_t *type, void *sptr);
char *rua_cause_str(RUA_Cause_t *cause);
+
+void rua_set_log_area(int log_area);
diff --git a/src/hnbap_common.c b/src/hnbap_common.c
index ac42959..be7d570 100644
--- a/src/hnbap_common.c
+++ b/src/hnbap_common.c
@@ -24,7 +24,9 @@
#include <osmocom/core/msgb.h>
#include <osmocom/hnbap/hnbap_common.h>
-#include <osmocom/iuh/hnbgw.h>
+
+int _hnbap_DHNBAP = 0;
+#define DHNBAP _hnbap_DHNBAP
static const struct value_string hnbap_cause_radio_vals[] = {
{ HNBAP_CauseRadioNetwork_overload, "overload" },
@@ -242,3 +244,8 @@
return buff;
}
+
+void hnbap_set_log_area(int log_area)
+{
+ _hnbap_DHNBAP = log_area;
+}
diff --git a/src/ranap_common_cn.c b/src/ranap_common_cn.c
index d2c875e..03ce9ea 100644
--- a/src/ranap_common_cn.c
+++ b/src/ranap_common_cn.c
@@ -29,7 +29,7 @@
#include <osmocom/ranap/ranap_common_cn.h>
#include <osmocom/ranap/ranap_ies_defs.h>
-#include <osmocom/iuh/hnbgw.h>
+#define DRANAP _ranap_DRANAP
static int cn_ranap_rx_initiating_msg_co(void *ctx, RANAP_InitiatingMessage_t *imsg,
ranap_message *message)
diff --git a/src/rua_common.c b/src/rua_common.c
index 77ac591..f21bf8f 100644
--- a/src/rua_common.c
+++ b/src/rua_common.c
@@ -24,10 +24,12 @@
#include <osmocom/core/msgb.h>
#include <osmocom/rua/rua_common.h>
-#include <osmocom/iuh/hnbgw.h>
extern int asn1_xer_print;
+int _rua_DRUA = 0;
+#define DRUA _rua_DRUA
+
static const struct value_string rua_cause_radio_vals[] = {
{ RUA_CauseRadioNetwork_normal, "normal" },
{ RUA_CauseRadioNetwork_connect_failed, "connect failed" },
@@ -224,3 +226,8 @@
return buff;
}
+
+void rua_set_log_area(int log_area)
+{
+ _rua_DRUA = log_area;
+}
diff --git a/src/rua_msg_factory.c b/src/rua_msg_factory.c
index 7a6bebd..e974793 100644
--- a/src/rua_msg_factory.c
+++ b/src/rua_msg_factory.c
@@ -5,8 +5,10 @@
#include <osmocom/rua/rua_ies_defs.h>
#include <osmocom/rua/rua_msg_factory.h>
#include "asn1helpers.h"
-#include <osmocom/iuh/hnbgw.h>
+#define DRUA _rua_DRUA
+
+#define IUH_PPI_RUA 19
struct msgb *rua_new_udt(struct msgb *inmsg)
{
@@ -31,7 +33,7 @@
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RUA_ConnectionlessTransfer, &out);
- DEBUGP(DMAIN, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
+ DEBUGP(DRUA, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
msgb_sctp_ppid(msg) = IUH_PPI_RUA;
@@ -68,7 +70,7 @@
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RUA_Connect, &out);
- DEBUGP(DMAIN, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
+ DEBUGP(DRUA, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
msgb_sctp_ppid(msg) = IUH_PPI_RUA;
@@ -104,7 +106,7 @@
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RUA_DirectTransfer, &out);
- DEBUGP(DMAIN, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
+ DEBUGP(DRUA, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
msgb_sctp_ppid(msg) = IUH_PPI_RUA;
@@ -146,7 +148,7 @@
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RUA_Disconnect, &out);
- DEBUGP(DMAIN, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
+ DEBUGP(DRUA, "transmitting RUA payload of %u bytes\n", msgb_length(msg));
msgb_sctp_ppid(msg) = IUH_PPI_RUA;
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 2063524..1fca2a4 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -14,7 +14,7 @@
test_helpers_SOURCES = test-helpers.c test_common.c
test_helpers_LDADD = $(COMMON_LIBS) $(top_builddir)/src/libosmo-ranap.la
-test_hnbap_SOURCES = $(top_srcdir)/src/hnbap_common.c $(top_builddir)/src/hnbap_decoder.c
test-hnbap.c test_common.c
+test_hnbap_SOURCES = test-hnbap.c test_common.c
test_hnbap_LDADD = $(COMMON_LIBS) $(top_builddir)/src/libosmo-hnbap.la
$(top_builddir)/src/libosmo-ranap.la
hnb_test_SOURCES = hnb-test.c test_common.c hnb-test-ranap.c hnb-test-rua.c
diff --git a/src/tests/hnb-test.h b/src/tests/hnb-test.h
index 4af50a7..02efce0 100644
--- a/src/tests/hnb-test.h
+++ b/src/tests/hnb-test.h
@@ -7,10 +7,7 @@
#define DEBUG
#include <osmocom/core/logging.h>
-enum {
- DMAIN,
- DHNBAP,
-};
+#include "test_common.h"
/* 25.467 Section 7.1 */
diff --git a/src/tests/test-helpers.c b/src/tests/test-helpers.c
index cfe2140..5c617e5 100644
--- a/src/tests/test-helpers.c
+++ b/src/tests/test-helpers.c
@@ -209,6 +209,7 @@
asn1_xer_print = 0;
test_common_init();
+ ranap_set_log_area(DRANAP);
test_iu_helpers();
test_asn1_helpers();
diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c
index 2343c2d..48cca2b 100644
--- a/src/tests/test-hnbap.c
+++ b/src/tests/test-hnbap.c
@@ -173,6 +173,8 @@
int rc;
test_common_init();
+ ranap_set_log_area(DRANAP);
+ hnbap_set_log_area(DHNBAP);
log_set_log_level(osmo_stderr_target, LOGL_INFO);
diff --git a/src/tests/test-ranap.c b/src/tests/test-ranap.c
index a6df186..b3ea4cb 100644
--- a/src/tests/test-ranap.c
+++ b/src/tests/test-ranap.c
@@ -32,8 +32,6 @@
#include "test_common.h"
-#include <osmocom/iuh/hnbgw.h>
-
extern void *tall_msgb_ctx;
static void test_aper_int(uint32_t inp)
@@ -98,6 +96,7 @@
//asn_debug = 1;
test_common_init();
+ ranap_set_log_area(DRANAP);
test_aper_int(1);
test_aper_int(2);
diff --git a/src/tests/test_common.c b/src/tests/test_common.c
index bfe487f..899c73a 100644
--- a/src/tests/test_common.c
+++ b/src/tests/test_common.c
@@ -33,14 +33,14 @@
#include <netinet/sctp.h>
#include <arpa/inet.h>
+#include <asn1c/asn_internal.h>
+
#include <osmocom/core/application.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
-#include <osmocom/ranap/ranap_common.h>
-
-#include <osmocom/iuh/hnbgw.h>
+#include "test_common.h"
static const struct log_info_cat log_cat[] = {
[DMAIN] = {
@@ -83,8 +83,6 @@
if (rc < 0)
exit(1);
- ranap_set_log_area(DRANAP);
-
log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
log_set_use_color(osmo_stderr_target, 0);
log_set_print_category(osmo_stderr_target, 0);
diff --git a/src/tests/test_common.h b/src/tests/test_common.h
index 836d999..fdcac05 100644
--- a/src/tests/test_common.h
+++ b/src/tests/test_common.h
@@ -1,4 +1,11 @@
#pragma once
+enum {
+ DMAIN,
+ DHNBAP,
+ DRUA,
+ DRANAP,
+};
+
int test_common_init(void);
void test_common_cleanup(void);
--
To view, visit
https://gerrit.osmocom.org/c/osmo-iuh/+/26769
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I5d09b67b115ad8938e5162a23accfcbafab139d4
Gerrit-Change-Number: 26769
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged