[PATCH] openbsc[master]: logging: use central filter and ctx consts from libosmocore

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Feb 17 16:30:18 UTC 2017


Review at  https://gerrit.osmocom.org/1845

logging: use central filter and ctx consts from libosmocore

The LCHAN and BTS filter contexts are actually never used, so drop them until
someone adds them properly.

Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067
Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
---
M openbsc/include/openbsc/debug.h
M openbsc/src/libbsc/abis_rsl.c
M openbsc/src/libbsc/e1_config.c
M openbsc/src/libbsc/paging.c
M openbsc/src/libcommon/debug.c
M openbsc/src/libmsc/gsm_04_08.c
M openbsc/src/libmsc/smpp_openbsc.c
7 files changed, 32 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/45/1845/1

diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h
index ca3d4ad..ca00fe9 100644
--- a/openbsc/include/openbsc/debug.h
+++ b/openbsc/include/openbsc/debug.h
@@ -41,21 +41,6 @@
 	Debug_LastEntry,
 };
 
-/* context */
-#define BSC_CTX_LCHAN	0
-#define BSC_CTX_SUBSCR	1
-#define BSC_CTX_BTS	2
-#define BSC_CTX_SCCP	3
-
-/* target */
-
-enum {
-	//DEBUG_FILTER_ALL = 1 << 0,
-	LOG_FILTER_IMSI = 1 << 1,
-	LOG_FILTER_NSVC = 1 << 2,
-	LOG_FILTER_BVC  = 1 << 3,
-};
-
 /* we don't need a header dependency for this... */
 struct gprs_nsvc;
 struct bssgp_bvc_ctx;
diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index 541a86d..04ff562 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -158,9 +158,8 @@
 		LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n",
 		     gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr);
 
-	log_set_context(BSC_CTX_LCHAN, lchan);
 	if (lchan->conn)
-		log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr);
+		log_set_context(LOGGING_CTX_SUBSCR, lchan->conn->subscr);
 
 	return lchan;
 }
diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c
index f1962c7..8910d21 100644
--- a/openbsc/src/libbsc/e1_config.c
+++ b/openbsc/src/libbsc/e1_config.c
@@ -134,7 +134,6 @@
 	struct e1inp_sign_link *link = msg->dst;
 	struct gsm_bts *bts;
 
-	log_set_context(BSC_CTX_BTS, link->trx->bts);
 	switch (link->type) {
 	case E1INP_SIGN_OML:
 		bts = link->trx->bts;
diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c
index 8c30637..b4d45c3 100644
--- a/openbsc/src/libbsc/paging.c
+++ b/openbsc/src/libbsc/paging.c
@@ -77,7 +77,7 @@
 	if (!bts->oml_link)
 		return;
 
-	log_set_context(BSC_CTX_SUBSCR, request->subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, request->subscr);
 
 	LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: "
 	     "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi,
@@ -91,7 +91,7 @@
 	page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
 						str_to_imsi(request->subscr->imsi));
 	gsm0808_page(bts, page_group, mi_len, mi, request->chan_type);
-	log_set_context(BSC_CTX_SUBSCR, NULL);
+	log_set_context(LOGGING_CTX_SUBSCR, NULL);
 }
 
 static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts)
@@ -255,7 +255,7 @@
 	gsm_cbfn *cbfn;
 	int msg;
 
-	log_set_context(BSC_CTX_SUBSCR, req->subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, req->subscr);
 
 	LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n",
 		req, req->subscr->imsi);
@@ -394,7 +394,7 @@
 {
 	struct gsm_bts *bts;
 
-	log_set_context(BSC_CTX_SUBSCR, subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, subscr);
 
 	/* Stop this first and dispatch the request */
 	if (_bts)
diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c
index cf5beeb..cd6e5b1 100644
--- a/openbsc/src/libcommon/debug.c
+++ b/openbsc/src/libcommon/debug.c
@@ -177,32 +177,25 @@
 	},
 };
 
-enum log_filter {
-	_FLT_ALL = LOG_FILTER_ALL,	/* libosmocore */
-	FLT_IMSI = 1,
-	FLT_NSVC = 2,
-	FLT_BVC  = 3,
-};
-
 static int filter_fn(const struct log_context *ctx,
 		     struct log_target *tar)
 {
-	struct gsm_subscriber *subscr = ctx->ctx[BSC_CTX_SUBSCR];
-	const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC];
-	const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC];
+	const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_SUBSCR];
+	const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC];
+	const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC];
 
-	if ((tar->filter_map & (1 << FLT_IMSI)) != 0
-	    && subscr && subscr == tar->filter_data[FLT_IMSI])
+	if ((tar->filter_map & (1 << LOGGING_FILTER_SUBSCR)) != 0
+	    && subscr && subscr == tar->filter_data[LOGGING_FILTER_SUBSCR])
 		return 1;
 
 	/* Filter on the NS Virtual Connection */
-	if ((tar->filter_map & (1 << FLT_NSVC)) != 0
-	    && nsvc && (nsvc == tar->filter_data[FLT_NSVC]))
+	if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0
+	    && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC]))
 		return 1;
 
 	/* Filter on the NS Virtual Connection */
-	if ((tar->filter_map & (1 << FLT_BVC)) != 0
-	    && bvc && (bvc == tar->filter_data[FLT_BVC]))
+	if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0
+	    && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC]))
 		return 1;
 
 	return 0;
@@ -216,16 +209,17 @@
 
 void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr)
 {
+	struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_SUBSCR];
+
 	/* free the old data */
-	if (target->filter_data[FLT_IMSI]) {
-		subscr_put(target->filter_data[FLT_IMSI]);
-		target->filter_data[FLT_IMSI] = NULL;
+	if (*fsub) {
+		subscr_put(*fsub);
+		*fsub = NULL;
 	}
 
 	if (subscr) {
-		target->filter_map |= (1 << FLT_IMSI);
-		target->filter_data[FLT_IMSI] = subscr_get(subscr);
-	} else {
-		target->filter_map &= ~(1 << FLT_IMSI);
-	}
+		target->filter_map |= (1 << LOGGING_FILTER_SUBSCR);
+		*fsub = subscr_get(subscr);
+	} else
+		target->filter_map &= ~(1 << LOGGING_FILTER_SUBSCR);
 }
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 1a64731..f008892 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -1457,7 +1457,7 @@
 		/* FIXME: request id? close channel? */
 		return -EINVAL;
 	}
-	log_set_context(BSC_CTX_SUBSCR, subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, subscr);
 	DEBUGP(DRR, "<- Channel was requested by %s\n",
 		subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi);
 
@@ -1982,7 +1982,7 @@
 		return -EIO;
 
 	/* Which subscriber do we want to track trans1 or trans2? */
-	log_set_context(BSC_CTX_SUBSCR, trans1->subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, trans1->subscr);
 
 	/* through-connect channel */
 	return tch_map(trans1->conn->lchan, trans2->conn->lchan);
@@ -2003,7 +2003,7 @@
 	if (!trans->conn)
 		return 0;
 
-	log_set_context(BSC_CTX_SUBSCR, trans->subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, trans->subscr);
 	lchan = trans->conn->lchan;
 	bts = lchan->ts->trx->bts;
 
@@ -3339,7 +3339,7 @@
 		mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE);
 		return -EIO;
 	}
-	log_set_context(BSC_CTX_SUBSCR, trans->subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, trans->subscr);
 	if (!trans->conn) {
 		LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n");
 		mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE);
@@ -3395,7 +3395,7 @@
 		mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT);
 		return -EIO;
 	}
-	log_set_context(BSC_CTX_SUBSCR, trans->subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, trans->subscr);
 	if (!trans->conn) {
 		LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n");
 		mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT);
@@ -3572,7 +3572,7 @@
 			LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n");
 			return -EIO;
 		}
-		log_set_context(BSC_CTX_SUBSCR, trans->subscr);
+		log_set_context(LOGGING_CTX_SUBSCR, trans->subscr);
 		if (!trans->conn) {
 			LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n");
 			return 0;
@@ -3646,7 +3646,7 @@
 						    data->imsi);
 
 		/* update the subscriber we deal with */
-		log_set_context(BSC_CTX_SUBSCR, subscr);
+		log_set_context(LOGGING_CTX_SUBSCR, subscr);
 
 		/* If subscriber is not found */
 		if (!subscr) {
@@ -3724,7 +3724,7 @@
 		subscr_put(subscr);
 	} else {
 		/* update the subscriber we deal with */
-		log_set_context(BSC_CTX_SUBSCR, trans->subscr);
+		log_set_context(LOGGING_CTX_SUBSCR, trans->subscr);
 	}
 
 	if (trans->conn)
diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c
index 657272e..fa564c1 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -67,7 +67,7 @@
 	}
 
 	/* tag the context in case we know it */
-	log_set_context(BSC_CTX_SUBSCR, subscr);
+	log_set_context(LOGGING_CTX_SUBSCR, subscr);
 	return subscr;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/1845
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list