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
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 18845d4..28f5ff3 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -325,7 +325,7 @@
 {
 	int ret;
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 
 	/* Increment number of Uplink bytes */
 	rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]);
@@ -360,7 +360,7 @@
 	struct msgb *msg = gprs_ns_msgb_alloc();
 	struct gprs_ns_hdr *nsh;
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 
 	if (!msg)
 		return -ENOMEM;
@@ -384,7 +384,7 @@
 	uint16_t nsvci = htons(nsvc->nsvci);
 	uint16_t nsei = htons(nsvc->nsei);
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 
 	if (!msg)
 		return -ENOMEM;
@@ -416,7 +416,7 @@
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci = htons(nsvc->nsvci);
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 
 	bvci = htons(bvci);
 
@@ -469,7 +469,7 @@
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci = htons(nsvc->nsvci);
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 
 	if (!msg)
 		return -ENOMEM;
@@ -497,7 +497,7 @@
  */
 int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc)
 {
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 	LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
@@ -510,7 +510,7 @@
  */
 int gprs_ns_tx_alive(struct gprs_nsvc *nsvc)
 {
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 	LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
@@ -523,7 +523,7 @@
  */
 int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc)
 {
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 	LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
@@ -548,7 +548,7 @@
 	enum ns_timeout tout = timer_mode_tout[mode];
 	unsigned int seconds = nsvc->nsi->timeout[tout];
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 	DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n",
 		nsvc->nsei, get_value_string(timer_mode_strs, mode),
 		seconds);
@@ -576,7 +576,7 @@
 	enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode];
 	unsigned int seconds = nsvc->nsi->timeout[tout];
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 	DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n",
 		nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode),
 		seconds);
@@ -638,7 +638,7 @@
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci, nsei;
 
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 	if (!msg)
 		return -ENOMEM;
 
@@ -692,7 +692,7 @@
 		msgb_free(msg);
 		return rc;
 	}
-	log_set_context(GPRS_CTX_NSVC, nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, nsvc);
 
 	msg->l2h = msgb_push(msg, sizeof(*nsh) + 3);
 	nsh = (struct gprs_ns_hdr *) msg->l2h;
@@ -1099,7 +1099,7 @@
 		struct gprs_nsvc *fallback_nsvc;
 
 		fallback_nsvc = nsi->unknown_nsvc;
-		log_set_context(GPRS_CTX_NSVC, fallback_nsvc);
+		log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc);
 		fallback_nsvc->ip.bts_addr = *saddr;
 		fallback_nsvc->ll = ll;
 
@@ -1215,7 +1215,7 @@
 	/* Only the RESET procedure creates a new NSVC */
 	if (nsh->pdu_type != NS_PDUT_RESET) {
 		/* Since we have no NSVC, we have to use a fake */
-		log_set_context(GPRS_CTX_NSVC, fallback_nsvc);
+		log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc);
 		LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x "
 		     "from %s for non-existing NS-VC\n",
 		     nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc));
@@ -1256,7 +1256,7 @@
 	if (!existing_nsvc) {
 		*new_nsvc = gprs_nsvc_create(nsi, 0xffff);
 		(*new_nsvc)->nsvci_is_valid = 0;
-		log_set_context(GPRS_CTX_NSVC, *new_nsvc);
+		log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc);
 		gprs_ns_ll_copy(*new_nsvc, fallback_nsvc);
 		LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n",
 		     gprs_ns_ll_str(fallback_nsvc));
@@ -1299,7 +1299,7 @@
 
 	msgb_nsei(msg) = (*nsvc)->nsei;
 
-	log_set_context(GPRS_CTX_NSVC, *nsvc);
+	log_set_context(LOGGING_CTX_GB_NSVC, *nsvc);
 
 	/* Increment number of Incoming bytes */
 	rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]);