Change in libosmocore[master]: BSSGP: add logging macro wrappers

Max gerrit-no-reply at lists.osmocom.org
Mon Mar 11 15:15:06 UTC 2019


Max has uploaded this change for review. ( https://gerrit.osmocom.org/13205


Change subject: BSSGP: add logging macro wrappers
......................................................................

BSSGP: add logging macro wrappers

Add BSSGP-specific wrappers for LOGP/DEBUGP to unify log messages
similar to LOGPFSM* wrappers.

Change-Id: I8cd2bdb12aa3a5a7dfcb7a85fee35ec3a3a9820b
---
M include/osmocom/gprs/gprs_bssgp.h
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_bss.c
M src/gb/gprs_bssgp_util.c
4 files changed, 74 insertions(+), 111 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/05/13205/1

diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h
index 400c3e0..0b772cf 100644
--- a/include/osmocom/gprs/gprs_bssgp.h
+++ b/include/osmocom/gprs/gprs_bssgp.h
@@ -11,6 +11,12 @@
 
 #include <osmocom/gprs/protocol/gsm_08_18.h>
 
+#define LOGBSSGP(bvci, nsei, lvl, fmt, args...) \
+	LOGP(DBSSGP, lvl, "BSSGP (BVCI=%u, NSEI=%u) " fmt, bvci, nsei, ## args)
+
+#define DEBUGBSSGP(bvci, nsei, fmt, args...)				\
+	DEBUGP(DBSSGP, "BSSGP (BVCI=%u, NSEI=%u) " fmt, bvci, nsei, ## args)
+
 /* gprs_bssgp_util.c */
 extern struct gprs_ns_inst *bssgp_nsi;
 struct msgb *bssgp_msgb_alloc(void);
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 7acc9d9..b0a1089 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -94,8 +94,7 @@
 
 	llist_for_each_entry(bctx, &bssgp_bvc_ctxts, list) {
 		if (bctx->nsei == nsei && bctx->bvci != BVCI_SIGNALLING) {
-			LOGP(DBSSGP, LOGL_DEBUG, "NSEI=%u/BVCI=%u RESET due to %s\n",
-			     nsei, bctx->bvci, bssgp_cause_str(cause));
+			DEBUGBSSGP(bctx->bvci, nsei, "RESET due to %s\n", bssgp_cause_str(cause));
 			rc = bssgp_tx_bvc_reset(bctx, bctx->bvci, cause);
 			if (rc < 0)
 				return rc;
@@ -262,8 +261,7 @@
 	uint16_t bvci;
 
 	bvci = tlvp_val16be(tp, BSSGP_IE_BVCI);
-	DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx RESET cause=%s\n", bvci,
-		bssgp_cause_str(*TLVP_VAL(tp, BSSGP_IE_CAUSE)));
+	DEBUGBSSGP(bvci, nsei, "Rx RESET cause=%s\n", bssgp_cause_str(*TLVP_VAL(tp, BSSGP_IE_CAUSE)));
 
 	/* look-up or create the BTS context for this BVC */
 	bctx = btsctx_by_bvci_nsei(bvci, nsei);
@@ -277,15 +275,13 @@
 	 * informs us about its RAC + Cell ID, so we can create a mapping */
 	if (bvci != 0 && bvci != 1) {
 		if (!TLVP_PRESENT(tp, BSSGP_IE_CELL_ID)) {
-			LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx RESET "
-				"missing mandatory IE\n", bvci);
+			LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx RESET missing mandatory IE\n");
 			return -EINVAL;
 		}
 		/* actually extract RAC / CID */
 		bctx->cell_id = bssgp_parse_cell_id(&bctx->ra_id,
 						TLVP_VAL(tp, BSSGP_IE_CELL_ID));
-		LOGP(DBSSGP, LOGL_NOTICE, "Cell %s CI %u on BVCI %u\n",
-		     osmo_rai_name(&bctx->ra_id), bctx->cell_id, bvci);
+		LOGBSSGP(bvci, nsei, LOGL_NOTICE, "Cell %s CI %u\n", osmo_rai_name(&bctx->ra_id), bctx->cell_id);
 	}
 
 	/* Send NM_BVC_RESET.ind to NM */
@@ -313,13 +309,11 @@
 	bvci = tlvp_val16be(tp, BSSGP_IE_BVCI);
 	if (bvci == BVCI_SIGNALLING) {
 		/* 8.3.2: Signalling BVC shall never be blocked */
-		LOGP(DBSSGP, LOGL_ERROR, "NSEI=%u/BVCI=%u "
-			"received block for signalling BVC!?!\n",
-			nsei, msgb_bvci(msg));
+		LOGBSSGP(bvci, nsei, LOGL_ERROR, "received block for signalling BVC!?!\n");
 		return 0;
 	}
 
-	LOGP(DBSSGP, LOGL_INFO, "BSSGP Rx BVCI=%u BVC-BLOCK\n", bvci);
+	LOGBSSGP(bvci, nsei, LOGL_INFO, "Rx BVC-BLOCK\n");
 
 	ptp_ctx = btsctx_by_bvci_nsei(bvci, nsei);
 	if (!ptp_ctx)
@@ -351,13 +345,11 @@
 	bvci = tlvp_val16be(tp, BSSGP_IE_BVCI);
 	if (bvci == BVCI_SIGNALLING) {
 		/* 8.3.2: Signalling BVC shall never be blocked */
-		LOGP(DBSSGP, LOGL_ERROR, "NSEI=%u/BVCI=%u "
-			"received unblock for signalling BVC!?!\n",
-			nsei, msgb_bvci(msg));
+		LOGBSSGP(bvci, nsei, LOGL_ERROR, "received unblock for signalling BVC!?!\n");
 		return 0;
 	}
 
-	DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx BVC-UNBLOCK\n", bvci);
+	DEBUGBSSGP(bvci, nsei, "Rx BVC-UNBLOCK\n");
 
 	ptp_ctx = btsctx_by_bvci_nsei(bvci, nsei);
 	if (!ptp_ctx)
@@ -389,13 +381,13 @@
 	/* extract TLLI and parse TLV IEs */
 	msgb_tlli(msg) = osmo_ntohl(budh->tlli);
 
-	DEBUGP(DBSSGP, "BSSGP TLLI=0x%08x Rx UPLINK-UNITDATA\n", msgb_tlli(msg));
+	DEBUGBSSGP(ctx->bvci, ctx->nsei, "TLLI=0x%08x Rx UPLINK-UNITDATA\n", msgb_tlli(msg));
 
 	/* Cell ID and LLC_PDU are the only mandatory IE */
 	if (!TLVP_PRESENT(tp, BSSGP_IE_CELL_ID) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_LLC_PDU)) {
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP TLLI=0x%08x Rx UL-UD "
-			"missing mandatory IE\n", msgb_tlli(msg));
+		LOGBSSGP(ctx->bvci, ctx->nsei, LOGL_ERROR, "TLLI=0x%08x Rx UL-UD missing mandatory IE\n",
+			 msgb_tlli(msg));
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
@@ -424,15 +416,13 @@
 
 	if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) {
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx SUSPEND "
-			"missing mandatory IE\n", ns_bvci);
+		LOGBSSGP(ns_bvci, nsei, LOGL_ERROR, "Rx SUSPEND missing mandatory IE\n");
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
 	tlli = tlvp_val32be(tp, BSSGP_IE_TLLI);
 
-	DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx SUSPEND\n",
-		ns_bvci, tlli);
+	DEBUGBSSGP(ns_bvci, nsei, "TLLI=0x%08x Rx SUSPEND\n", tlli);
 
 	gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA));
 
@@ -466,15 +456,14 @@
 	if (!TLVP_PRESENT(tp, BSSGP_IE_TLLI) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_SUSPEND_REF_NR)) {
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx RESUME "
-			"missing mandatory IE\n", ns_bvci);
+		LOGBSSGP(ns_bvci, nsei, LOGL_ERROR, "Rx RESUME missing mandatory IE\n");
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
 	tlli = tlvp_val32be(tp, BSSGP_IE_TLLI);
 	suspend_ref = *TLVP_VAL(tp, BSSGP_IE_SUSPEND_REF_NR);
 
-	DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx RESUME\n", ns_bvci, tlli);
+	DEBUGBSSGP(ns_bvci, nsei, "TLLI=0x%08x Rx RESUME\n", tlli);
 
 	gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA));
 
@@ -509,15 +498,13 @@
 	    !TLVP_PRESENT(tp, BSSGP_IE_LLC_FRAMES_DISCARDED) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_BVCI) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_NUM_OCT_AFF)) {
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx LLC DISCARDED "
-			"missing mandatory IE\n", ctx->bvci);
+		LOGBSSGP(ctx->bvci, nsei, LOGL_ERROR, "Rx LLC DISCARDED missing mandatory IE\n");
 	}
 
 	if (TLVP_PRESENT(tp, BSSGP_IE_TLLI))
 		tlli = tlvp_val32be(tp, BSSGP_IE_TLLI);
 
-	DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=%08x Rx LLC DISCARDED\n",
-		ctx->bvci, tlli);
+	DEBUGBSSGP(ctx->bvci, nsei, "TLLI=%08x Rx LLC DISCARDED\n", tlli);
 
 	rate_ctr_inc(&ctx->ctrg->ctr[BSSGP_CTR_DISCARDED]);
 
@@ -541,22 +528,18 @@
 	enum gprs_bssgp_cause cause;
 
 	if (!TLVP_PRESENT(tp, BSSGP_IE_CAUSE)) {
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx STATUS "
-			"missing mandatory IE\n", bvci);
+		LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx STATUS missing mandatory IE\n");
 		cause = BSSGP_CAUSE_PROTO_ERR_UNSPEC;
 	} else {
 		cause = *TLVP_VAL(tp, BSSGP_IE_CAUSE);
 	}
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u Rx BVC STATUS, cause=%s\n",
-		bvci, bssgp_cause_str(cause));
+	LOGBSSGP(bvci, nsei, LOGL_NOTICE, "Rx BVC STATUS, cause=%s\n", bssgp_cause_str(cause));
 
 	if (cause == BSSGP_CAUSE_BVCI_BLOCKED || cause == BSSGP_CAUSE_UNKNOWN_BVCI) {
 		if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI))
-			LOGP(DBSSGP, LOGL_ERROR,
-				"BSSGP BVCI=%u Rx STATUS cause=%s "
-				"missing conditional BVCI IE\n",
-				bvci, bssgp_cause_str(cause));
+			LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx STATUS cause=%s missing conditional BVCI IE\n",
+				 bssgp_cause_str(cause));
 	}
 
 	if (bctx)
@@ -805,16 +788,14 @@
 	uint32_t old_r_def_ms = bctx->r_default_ms;
 	uint16_t nsei = msgb_nsei(msg);
 
-	DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx Flow Control BVC\n",
-		bctx->bvci);
+	DEBUGBSSGP(bctx->bvci, nsei, "Rx Flow Control BVC\n");
 
 	if (!TLVP_PRESENT(tp, BSSGP_IE_TAG) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_BVC_BUCKET_SIZE) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_BUCKET_LEAK_RATE) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_BMAX_DEFAULT_MS) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_R_DEFAULT_MS)) {
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx FC BVC "
-			"missing mandatory IE\n", bctx->bvci);
+		LOGBSSGP(bctx->bvci, nsei, LOGL_ERROR, "Rx FC BVC missing mandatory IE\n");
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
@@ -828,18 +809,18 @@
 	bctx->r_default_ms = 100 * tlvp_val16be(tp, BSSGP_IE_R_DEFAULT_MS) / 8;
 
 	if (old_leak_rate != 0 && bctx->fc->bucket_leak_rate == 0)
-		LOGP(DBSSGP, LOGL_NOTICE, "BSS instructs us to bucket leak "
-			"rate of 0, stopping all DL GPRS!\n");
+		LOGBSSGP(bctx->bvci, nsei, LOGL_NOTICE,
+			 "BSS instructs us to bucket leak rate of 0, stopping all DL GPRS!\n");
 	else if (old_leak_rate == 0 && bctx->fc->bucket_leak_rate != 0)
-		LOGP(DBSSGP, LOGL_NOTICE, "BSS instructs us to bucket leak "
-			"rate of != 0, restarting all DL GPRS!\n");
+		LOGBSSGP(bctx->bvci, nsei, LOGL_NOTICE,
+			 "BSS instructs us to bucket leak rate of != 0, restarting all DL GPRS!\n");
 
 	if (old_r_def_ms != 0 && bctx->r_default_ms == 0)
-		LOGP(DBSSGP, LOGL_NOTICE, "BSS instructs us to MS default "
-			"bucket leak rate of 0, stopping DL GPRS!\n");
+		LOGBSSGP(bctx->bvci, nsei, LOGL_NOTICE,
+			 "BSS instructs us to MS default bucket leak rate of 0, stopping DL GPRS!\n");
 	else if (old_r_def_ms == 0 && bctx->r_default_ms != 0)
-		LOGP(DBSSGP, LOGL_NOTICE, "BSS instructs us to MS default "
-			"bucket leak rate != 0, restarting DL GPRS!\n");
+		LOGBSSGP(bctx->bvci, nsei, LOGL_NOTICE,
+			 "BSS instructs us to MS default bucket leak rate != 0, restarting DL GPRS!\n");
 
 	/* reconfigure the timer for flow control based on new values */
 	fc_queue_timer_cfg(bctx->fc);
@@ -875,13 +856,12 @@
 		break;
 	case BSSGP_PDUT_RA_CAPABILITY:
 		/* BSS requests RA capability or IMSI */
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx RA CAPABILITY UPDATE\n",
-			bctx->bvci);
+		DEBUGBSSGP(bctx->bvci, bctx->nsei, "Rx RA CAPABILITY UPDATE\n");
 		/* FIXME: send GMM_RA_CAPABILITY_UPDATE.ind to GMM */
 		/* FIXME: send RA_CAPA_UPDATE_ACK */
 		break;
 	case BSSGP_PDUT_RADIO_STATUS:
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx RADIO STATUS\n", bctx->bvci);
+		DEBUGBSSGP(bctx->bvci, bctx->nsei, "Rx RADIO STATUS\n");
 		/* BSS informs us of some exception */
 		/* FIXME: send GMM_RADIO_STATUS.ind to GMM */
 		break;
@@ -891,8 +871,7 @@
 		break;
 	case BSSGP_PDUT_FLOW_CONTROL_MS:
 		/* BSS informs us of available bandwidth to one MS */
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx Flow Control MS\n",
-			bctx->bvci);
+		DEBUGBSSGP(bctx->bvci, bctx->nsei, "Rx Flow Control MS\n");
 		/* FIXME: actually implement flow control */
 		/* FIXME: Send FLOW_CONTROL_MS_ACK */
 		break;
@@ -904,8 +883,7 @@
 	case BSSGP_PDUT_CREATE_BSS_PFC_NACK:
 	case BSSGP_PDUT_MODIFY_BSS_PFC:
 	case BSSGP_PDUT_DELETE_BSS_PFC_ACK:
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s not [yet] "
-		       "implemented\n", bctx->bvci, bssgp_pdu_str(pdu_type));
+		DEBUGBSSGP(bctx->bvci, bctx->nsei, "Rx PDU type %s not [yet] implemented\n", bssgp_pdu_str(pdu_type));
 		rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
 		break;
 	/* those only exist in the SGSN -> BSS direction */
@@ -915,14 +893,12 @@
 	case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
 	case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK:
 	case BSSGP_PDUT_FLOW_CONTROL_MS_ACK:
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type %s only exists in DL\n",
-		       bctx->bvci, bssgp_pdu_str(pdu_type));
+		DEBUGBSSGP(bctx->bvci, bctx->nsei, "PDU type %s only exists in DL\n", bssgp_pdu_str(pdu_type));
 		bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
 		rc = -EINVAL;
 		break;
 	default:
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type %s unknown\n",
-		       bctx->bvci, bssgp_pdu_str(pdu_type));
+		DEBUGBSSGP(bctx->bvci, bctx->nsei, "PDU type %s unknown\n", bssgp_pdu_str(pdu_type));
 		rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
 		break;
 	}
@@ -940,6 +916,7 @@
 	int rc = 0;
 	uint16_t ns_bvci = msgb_bvci(msg);
 	uint16_t bvci = bctx ? bctx->bvci : ns_bvci;
+	uint16_t nsei = bctx ? bctx->nsei : msgb_nsei(msg);
 
 	switch (bgph->pdu_type) {
 	case BSSGP_PDUT_SUSPEND:
@@ -952,14 +929,13 @@
 		break;
 	case BSSGP_PDUT_FLUSH_LL_ACK:
 		/* BSS informs us it has performed LL FLUSH */
-		DEBUGP(DBSSGP, "BSSGP Rx BVCI=%u FLUSH LL ACK\n", bvci);
+		DEBUGBSSGP(bvci, nsei, "Rx FLUSH LL ACK\n");
 		/* FIXME: send NM_FLUSH_LL.res to NM */
 		break;
 	case BSSGP_PDUT_LLC_DISCARD:
 		/* BSS informs that some LLC PDU's have been discarded */
 		if (!bctx) {
-			LOGP(DBSSGP, LOGL_ERROR,
-			     "BSSGP Rx LLC-DISCARD missing mandatory BVCI\n");
+			LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx LLC-DISCARD missing mandatory BVCI\n");
 			goto err_mand_ie;
 		}
 		rc = bssgp_rx_llc_disc(msg, tp, bctx);
@@ -968,8 +944,7 @@
 		/* BSS tells us that BVC shall be blocked */
 		if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI) ||
 		    !TLVP_PRESENT(tp, BSSGP_IE_CAUSE)) {
-			LOGP(DBSSGP, LOGL_ERROR, "BSSGP Rx BVC-BLOCK "
-				"missing mandatory IE\n");
+			LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx BVC-BLOCK missing mandatory IE\n");
 			goto err_mand_ie;
 		}
 		rc = bssgp_rx_bvc_block(msg, tp);
@@ -977,21 +952,19 @@
 	case BSSGP_PDUT_BVC_UNBLOCK:
 		/* BSS tells us that BVC shall be unblocked */
 		if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI)) {
-			LOGP(DBSSGP, LOGL_ERROR, "BSSGP Rx BVC-UNBLOCK "
-				"missing mandatory IE\n");
+			LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx BVC-UNBLOCK missing mandatory IE\n");
 			goto err_mand_ie;
 		}
 		rc = bssgp_rx_bvc_unblock(msg, tp);
 		break;
 	case BSSGP_PDUT_BVC_RESET_ACK:
-		LOGP(DBSSGP, LOGL_ERROR, "BSSGP BVCI=%u Rx BVC-RESET-ACK\n", bvci);
+		LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx BVC-RESET-ACK\n");
 		break;
 	case BSSGP_PDUT_BVC_RESET:
 		/* BSS tells us that BVC init is required */
 		if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI) ||
 		    !TLVP_PRESENT(tp, BSSGP_IE_CAUSE)) {
-			LOGP(DBSSGP, LOGL_ERROR, "BSSGP Rx BVC-RESET "
-				"missing mandatory IE\n");
+			LOGBSSGP(bvci, nsei, LOGL_ERROR, "Rx BVC-RESET missing mandatory IE\n");
 			goto err_mand_ie;
 		}
 		rc = bssgp_rx_bvc_reset(msg, tp, ns_bvci);
@@ -1010,14 +983,12 @@
 	case BSSGP_PDUT_BVC_BLOCK_ACK:
 	case BSSGP_PDUT_BVC_UNBLOCK_ACK:
 	case BSSGP_PDUT_SGSN_INVOKE_TRACE:
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s only exists in DL\n",
-		       bvci, bssgp_pdu_str(pdu_type));
+		DEBUGBSSGP(bvci, nsei, "Rx PDU type %s only exists in DL\n", bssgp_pdu_str(pdu_type));
 		bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
 		rc = -EINVAL;
 		break;
 	default:
-		DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s unknown\n",
-			bvci, bssgp_pdu_str(pdu_type));
+		DEBUGBSSGP(bvci, nsei, "Rx PDU type %s unknown\n", bssgp_pdu_str(pdu_type));
 		rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
 		break;
 	}
@@ -1053,7 +1024,7 @@
 		rc = bssgp_tlv_parse(&tp, budh->data, data_len);
 	}
 	if (rc < 0) {
-		LOGP(DBSSGP, LOGL_ERROR, "Failed to parse BSSGP %s message. Invalid message was: %s\n",
+		LOGBSSGP(ns_bvci, ns_nsei, LOGL_ERROR, "Failed to parse %s message. Invalid message was: %s\n",
 		     bssgp_pdu_str(pdu_type), msgb_hexdump(msg));
 		if (pdu_type != BSSGP_PDUT_STATUS)
 			return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
@@ -1083,9 +1054,8 @@
 	 * registered if a BVCI is given. */
 	if (!bctx && bvci != BVCI_SIGNALLING &&
 	    pdu_type != BSSGP_PDUT_BVC_RESET) {
-		LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU "
-			"type %s for unknown BVCI\n", ns_nsei, bvci,
-			bssgp_pdu_str(pdu_type));
+		LOGBSSGP(ns_bvci, ns_nsei, LOGL_NOTICE, "Rejecting PDU type %s for unknown BVCI %u\n",
+			 bssgp_pdu_str(pdu_type), bvci);
 		return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
 	}
 
@@ -1096,10 +1066,8 @@
 	else if (bctx)
 		rc = bssgp_rx_ptp(msg, &tp, bctx);
 	else
-		LOGP(DBSSGP, LOGL_NOTICE,
-			"NSEI=%u/BVCI=%u Cannot handle PDU type %s for "
-			"unknown BVCI, NS BVCI %u\n",
-			ns_nsei, bvci, bssgp_pdu_str(pdu_type), ns_bvci);
+		LOGBSSGP(ns_bvci, ns_nsei, LOGL_NOTICE, "Cannot handle PDU type %s for unknown BVCI %u\n",
+			 bssgp_pdu_str(pdu_type), bvci);
 
 	return rc;
 }
@@ -1121,16 +1089,14 @@
 
 	/* Identifiers from UP: TLLI, BVCI, NSEI (all in msgb->cb) */
 	if (bvci <= BVCI_PTM ) {
-		LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to BVCI %u\n",
-			bvci);
+		LOGBSSGP(bvci, nsei, LOGL_ERROR, "Cannot send DL-UD to BVCI\n");
 		msgb_free(msg);
 		return -EINVAL;
 	}
 
 	bctx = btsctx_by_bvci_nsei(bvci, nsei);
 	if (!bctx) {
-		LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to unknown BVCI %u\n",
-			bvci);
+		LOGBSSGP(bvci, nsei, LOGL_ERROR, "Cannot send DL-UD to unknown BVCI\n");
 		msgb_free(msg);
 		return -ENODEV;
 	}
diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c
index f06c403..574b47a 100644
--- a/src/gb/gprs_bssgp_bss.c
+++ b/src/gb/gprs_bssgp_bss.c
@@ -60,8 +60,7 @@
 	struct bssgp_normal_hdr *bgph =
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=0) Tx SUSPEND (TLLI=0x%04x)\n",
-		tlli);
+	LOGBSSGP(0, nsei, LOGL_NOTICE, "Tx SUSPEND (TLLI=0x%04x)\n", tlli);
 	msgb_nsei(msg) = nsei;
 	msgb_bvci(msg) = 0; /* Signalling */
 	bgph->pdu_type = BSSGP_PDUT_SUSPEND;
@@ -80,7 +79,7 @@
 	struct bssgp_normal_hdr *bgph =
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=0) Tx RESUME (TLLI=0x%04x)\n",
+	LOGBSSGP(0, nsei, LOGL_NOTICE, "Tx RESUME (TLLI=0x%04x)\n",
 		tlli);
 	msgb_nsei(msg) = nsei;
 	msgb_bvci(msg) = 0; /* Signalling */
@@ -101,8 +100,7 @@
 	struct bssgp_normal_hdr *bgph =
 		(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx RA-CAPA-UPD (TLLI=0x%04x)\n",
-		bctx->bvci, tlli);
+	LOGBSSGP(bctx->bvci, bctx->nsei, LOGL_NOTICE, "Tx RA-CAPA-UPD (TLLI=0x%04x)\n", tlli);
 
 	/* set NSEI and BVCI in msgb cb */
 	msgb_nsei(msg) = bctx->nsei;
@@ -123,8 +121,7 @@
 	struct bssgp_normal_hdr *bgph =
 		(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx RADIO-STATUS ",
-		bctx->bvci);
+	LOGBSSGP(bctx->bvci, bctx->nsei, LOGL_NOTICE, "Tx RADIO-STATUS ");
 
 	/* set NSEI and BVCI in msgb cb */
 	msgb_nsei(msg) = bctx->nsei;
@@ -232,9 +229,8 @@
 	uint16_t _bvci = osmo_htons(bctx->bvci);
 	uint32_t _oct_aff = osmo_htonl(num_octets & 0xFFFFFF);
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx LLC-DISCARDED "
-	     "TLLI=0x%04x, FRAMES=%u, OCTETS=%u\n", bctx->bvci, tlli,
-	     num_frames, num_octets);
+	LOGBSSGP(bctx->bvci, bctx->nsei, LOGL_NOTICE, "Tx LLC-DISCARDED TLLI=0x%04x, FRAMES=%u, OCTETS=%u\n",
+		 tlli, num_frames, num_octets);
 	msgb_nsei(msg) = bctx->nsei;
 	msgb_bvci(msg) = 0; /* Signalling */
 	bgph->pdu_type = BSSGP_PDUT_LLC_DISCARD;
@@ -256,8 +252,7 @@
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 	uint16_t _bvci = osmo_htons(bctx->bvci);
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-BLOCK "
-		"CAUSE=%s\n", bctx->bvci, bssgp_cause_str(cause));
+	LOGBSSGP(bctx->bvci, bctx->nsei, LOGL_NOTICE, "Tx BVC-BLOCK CAUSE=%s\n", bssgp_cause_str(cause));
 
 	msgb_nsei(msg) = bctx->nsei;
 	msgb_bvci(msg) = 0; /* Signalling */
@@ -277,7 +272,7 @@
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 	uint16_t _bvci = osmo_htons(bctx->bvci);
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-UNBLOCK\n", bctx->bvci);
+	LOGBSSGP(bctx->bvci, bctx->nsei, LOGL_NOTICE, "Tx BVC-UNBLOCK\n");
 
 	msgb_nsei(msg) = bctx->nsei;
 	msgb_bvci(msg) = 0; /* Signalling */
@@ -296,8 +291,7 @@
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 	uint16_t _bvci = osmo_htons(bvci);
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-RESET "
-		"CAUSE=%s\n", bvci, bssgp_cause_str(cause));
+	LOGBSSGP(bvci, bctx->nsei, LOGL_NOTICE, "Tx BVC-RESET CAUSE=%s\n", bssgp_cause_str(cause));
 
 	msgb_nsei(msg) = bctx->nsei;
 	msgb_bvci(msg) = 0; /* Signalling */
diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c
index 95bf8285..fdc4868 100644
--- a/src/gb/gprs_bssgp_util.c
+++ b/src/gb/gprs_bssgp_util.c
@@ -216,7 +216,7 @@
 /* Chapter 10.4.14: Status */
 int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg)
 {
-	uint16_t nsei = msgb_nsei(orig_msg);
+	uint16_t nsei = msgb_nsei(orig_msg), b = bvci ? *bvci : 0;
 	struct msgb *msg = bssgp_msgb_alloc();
 	struct bssgp_normal_hdr *bgph =
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
@@ -225,18 +225,15 @@
 	   cause is either "BVCI blocked" or "BVCI unknown" */
 	if (cause == BSSGP_CAUSE_UNKNOWN_BVCI || cause == BSSGP_CAUSE_BVCI_BLOCKED) {
 		if (bvci == NULL)
-			LOGP(DBSSGP, LOGL_ERROR, "BSSGP Tx STATUS, cause=%s: "
-			     "missing conditional BVCI\n",
-			     bssgp_cause_str(cause));
+			LOGBSSGP(b, nsei, LOGL_ERROR, "Tx STATUS, cause=%s: missing conditional BVCI\n",
+				 bssgp_cause_str(cause));
 	} else {
 		if (bvci != NULL)
-			LOGP(DBSSGP, LOGL_ERROR, "BSSGP Tx STATUS, cause=%s: "
-			     "unexpected conditional BVCI\n",
-			     bssgp_cause_str(cause));
+			LOGBSSGP(b, nsei, LOGL_ERROR, "Tx STATUS, cause=%s: unexpected conditional BVCI\n",
+				 bssgp_cause_str(cause));
 	}
 
-	LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u Tx STATUS, cause=%s\n",
-		bvci ? *bvci : 0, bssgp_cause_str(cause));
+	LOGBSSGP(b, nsei, LOGL_NOTICE, "Tx STATUS, cause=%s\n", bssgp_cause_str(cause));
 	msgb_nsei(msg) = nsei;
 	msgb_bvci(msg) = 0;
 

-- 
To view, visit https://gerrit.osmocom.org/13205
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cd2bdb12aa3a5a7dfcb7a85fee35ec3a3a9820b
Gerrit-Change-Number: 13205
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190311/8c64d8a2/attachment-0001.html>


More information about the gerrit-log mailing list