summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-17 16:35:27 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-22 16:08:38 +0000
commit812ba6dc63a75c39678dd3fe652768e76bf63183 (patch)
tree760a4307fe5a1de5d30f6115b6801018936c15b2 /include
parentbd9de2f66f82db66bbbe7e7df54bf8fee8e1a8ae (diff)
logging: centrally define ctx and filter indexes
It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Taking this opportunity to also prepare for a split of struct gsm_subscriber in openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter index constants for both subscriber types. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/core/logging.h19
-rw-r--r--include/osmocom/gprs/gprs_msgb.h4
2 files changed, 17 insertions, 6 deletions
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index fcf77f0e..b3685b81 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -89,8 +89,6 @@ void logp(int subsys, const char *file, int line, int cont, const char *format,
#define LOGL_ERROR 7 /*!< \brief error condition, requires user action */
#define LOGL_FATAL 8 /*!< \brief fatal, program aborted */
-#define LOG_FILTER_ALL 0x0001
-
/* logging levels defined by the library itself */
#define DLGLOBAL -1 /*!< global logging */
#define DLLAPD -2 /*!< LAPD implementation */
@@ -126,6 +124,23 @@ struct log_context {
void *ctx[LOG_MAX_CTX+1];
};
+enum logging_ctx_items {
+ LOGGING_CTX_GB_NSVC,
+ LOGGING_CTX_GB_BVC,
+ LOGGING_CTX_BSC_SUBSCR,
+ LOGGING_CTX_VLR_SUBSCR,
+ _LOGGING_CTX_COUNT
+};
+
+enum logging_filters {
+ LOGGING_FILTER_ALL,
+ LOGGING_FILTER_GB_NSVC,
+ LOGGING_FILTER_GB_BVC,
+ LOGGING_FILTER_BSC_SUBSCR,
+ LOGGING_FILTER_VLR_SUBSCR,
+ _LOGGING_FILTER_COUNT
+};
+
struct log_target;
/*! \brief Log filter function */
diff --git a/include/osmocom/gprs/gprs_msgb.h b/include/osmocom/gprs/gprs_msgb.h
index 06f5cca2..9ccc9a55 100644
--- a/include/osmocom/gprs/gprs_msgb.h
+++ b/include/osmocom/gprs/gprs_msgb.h
@@ -26,10 +26,6 @@ struct libgb_msgb_cb {
#define msgb_bcid(__x) LIBGB_MSGB_CB(__x)->bssgp_cell_id
#define msgb_llch(__x) LIBGB_MSGB_CB(__x)->llch
-/* logging contexts */
-#define GPRS_CTX_NSVC 0
-#define GPRS_CTX_BVC 1
-
#include <osmocom/core/logging.h>
int gprs_log_filter_fn(const struct log_context *ctx,
struct log_target *tar);