summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-10-12 01:29:33 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-11-12 16:06:46 +0100
commit35ce91de93be39ff074616264af26a2c155fa97e (patch)
tree094ceadaaf1256a4ac1f43df92588770aed33915
parent380c13c923463e648322ea57cca90fcf0caa3653 (diff)
iu: sort out confusion around asn_debug and asn1_xer_print
Before, I confused asn_debug with asn1_xer_print. Have two distinct VTY commands and fix documentation. Put the asn_debug and asn1_xer_print implementations in iu.c. Since they are globally defined, don't pass a pointer to iu_vty_init() but just use it directly. Might be considered less clean, but is also less bloat. Change-Id: Iccbadfe1585ba224f74cdfb5273b5ce29b6d78f0
-rw-r--r--openbsc/include/openbsc/iu.h6
-rw-r--r--openbsc/src/gprs/sgsn_main.c9
-rw-r--r--openbsc/src/gprs/sgsn_vty.c4
-rw-r--r--openbsc/src/libiu/iu.c10
-rw-r--r--openbsc/src/libiu/iu_vty.c27
5 files changed, 34 insertions, 22 deletions
diff --git a/openbsc/include/openbsc/iu.h b/openbsc/include/openbsc/iu.h
index f45a39d..dd962bf 100644
--- a/openbsc/include/openbsc/iu.h
+++ b/openbsc/include/openbsc/iu.h
@@ -15,6 +15,10 @@ struct RANAP_RAB_SetupOrModifiedItemIEs_s;
struct RANAP_GlobalRNC_ID;
struct RANAP_Cause;
+/* Debugging switches from asn1c and osmo-iuh */
+extern int asn_debug;
+extern int asn1_xer_print;
+
struct ue_conn_ctx {
struct llist_head list;
struct osmo_sccp_link *link;
@@ -67,4 +71,4 @@ int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp,
int iu_tx_common_id(struct ue_conn_ctx *ue_ctx, const char *imsi);
int iu_tx_release(struct ue_conn_ctx *ctx, const struct RANAP_Cause *cause);
-void iu_vty_init(int *asn_debug_p);
+void iu_vty_init(void);
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index b4be631..4cf4d22 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -311,12 +311,6 @@ static const struct log_info gprs_log_info = {
.num_cat = ARRAY_SIZE(gprs_categories),
};
-/* Implement the extern asn_debug from libasn1c to indicate whether the ASN.1
- * binary code decoded and encoded during Iu communication should be logged to
- * stderr. See osmocom's libasn1c, asn_internal.h, at "if (asn_debug)":
- * http://git.osmocom.org/libasn1c/tree/include/asn1c/asn_internal.h */
-int asn_debug = 0;
-
int sgsn_ranap_iu_event(struct ue_conn_ctx *ctx, enum iu_event_type type, void *data);
int main(int argc, char **argv)
@@ -344,9 +338,6 @@ int main(int argc, char **argv)
osmo_stats_vty_add_cmds(&gprs_log_info);
sgsn_vty_init();
ctrl_vty_init(tall_bsc_ctx);
-#ifdef BUILD_IU
- iu_vty_init(&asn_debug);
-#endif
handle_options(argc, argv);
diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index 1b477e5..5774d8c 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -1250,6 +1250,10 @@ int sgsn_vty_init(void)
install_element(SGSN_NODE, &cfg_no_comp_v42bis_cmd);
install_element(SGSN_NODE, &cfg_comp_v42bis_cmd);
install_element(SGSN_NODE, &cfg_comp_v42bisp_cmd);
+
+#ifdef BUILD_IU
+ iu_vty_init();
+#endif
return 0;
}
diff --git a/openbsc/src/libiu/iu.c b/openbsc/src/libiu/iu.c
index 7ca999f..7788b58 100644
--- a/openbsc/src/libiu/iu.c
+++ b/openbsc/src/libiu/iu.c
@@ -79,7 +79,15 @@ struct iu_rnc {
void *talloc_iu_ctx;
-int asn1_xer_print = 1;
+/* Implement the extern asn_debug from libasn1c to indicate whether to print
+ * asn.1 debug messages (see libasn1c). */
+int asn_debug = 0;
+
+/* Implement the extern asn1_xer_print to indicate whether the ASN.1 binary
+ * code decoded and encoded during Iu communication should be logged to stderr
+ * (see asn.1 generated code in osmo-iuh). */
+int asn1_xer_print = 0;
+
void *talloc_asn1_ctx;
iu_recv_cb_t global_iu_recv_cb = NULL;
diff --git a/openbsc/src/libiu/iu_vty.c b/openbsc/src/libiu/iu_vty.c
index 91eed96..cfa02ea 100644
--- a/openbsc/src/libiu/iu_vty.c
+++ b/openbsc/src/libiu/iu_vty.c
@@ -22,29 +22,34 @@
#include <osmocom/vty/command.h>
#include <osmocom/vty/logging.h>
-/* Pointer to the actual asn_debug value as passed from main scopes. */
-static int *g_asn_debug_p = NULL;
+#include <openbsc/iu.h>
DEFUN(logging_asn_debug,
logging_asn_debug_cmd,
"logging asn1-debug (1|0)",
LOGGING_STR
+ "Log ASN.1 debug messages to stderr\n"
+ "Log ASN.1 debug messages to stderr\n"
+ "Do not log ASN.1 debug messages to stderr\n")
+{
+ asn_debug = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
+DEFUN(logging_asn_xer_print,
+ logging_asn_xer_print_cmd,
+ "logging asn1-xer-print (1|0)",
+ LOGGING_STR
"Log human readable representations of all ASN.1 messages to stderr\n"
"Log decoded ASN.1 messages to stderr\n"
"Do not log decoded ASN.1 messages to stderr\n")
{
- if (!g_asn_debug_p) {
- vty_out(vty, "%%ASN.1 debugging not available%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- *g_asn_debug_p = atoi(argv[0]);
+ asn1_xer_print = atoi(argv[0]);
return CMD_SUCCESS;
}
-void iu_vty_init(int *asn_debug_p)
+void iu_vty_init(void)
{
- g_asn_debug_p = asn_debug_p;
-
install_element(CFG_LOG_NODE, &logging_asn_debug_cmd);
+ install_element(CFG_LOG_NODE, &logging_asn_xer_print_cmd);
}