[gprs] Add new 'NS' and 'BSSGP' logging categories
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c
index 181756d..40bd52c 100644
--- a/openbsc/src/debug.c
+++ b/openbsc/src/debug.c
@@ -151,6 +151,16 @@
 		.description = "GPRS Packet Service",
 		.enabled = 1, .loglevel = LOGL_DEBUG,
 	},
+	[DNS] = {
+		.name = "DNS",
+		.description = "GPRS Network Service",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+	[DBSSGP] = {
+		.name = "DBSSGP",
+		.description = "GPRS BSSGP Protocol",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
 };
 
 enum log_ctxt {
diff --git a/openbsc/src/gprs/gprs_bssgp.c b/openbsc/src/gprs/gprs_bssgp.c
index 554738b..0f658b9 100644
--- a/openbsc/src/gprs/gprs_bssgp.c
+++ b/openbsc/src/gprs/gprs_bssgp.c
@@ -188,7 +188,7 @@
 	struct bssgp_normal_hdr *bgph =
 			(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
 
-	DEBUGPC(DGPRS, "BSSGP: TX STATUS, cause=%s\n", bssgp_cause_str(cause));
+	DEBUGPC(DBSSGP, "BSSGP: TX STATUS, cause=%s\n", bssgp_cause_str(cause));
 	msgb_nsei(msg) = msgb_nsei(orig_msg);
 	msgb_bvci(msg) = 0;
 
@@ -223,7 +223,7 @@
 	int rc;
 
 	bvci = ntohs(*(uint16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI));
-	DEBUGPC(DGPRS, "BVCI=%u, cause=%s\n", bvci,
+	DEBUGPC(DBSSGP, "BVCI=%u, cause=%s\n", bvci,
 		bssgp_cause_str(*TLVP_VAL(tp, BSSGP_IE_CAUSE)));
 
 	/* look-up or create the BTS context for this BVC */
@@ -235,14 +235,14 @@
 	 * 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(DGPRS, LOGL_ERROR, "BSSGP RESET BVCI=%u "
+			LOGP(DBSSGP, LOGL_ERROR, "BSSGP RESET BVCI=%u "
 				"missing mandatory IE\n", bvci);
 			return -EINVAL;
 		}
 		/* actually extract RAC / CID */
 		bctx->cell_id = bssgp_parse_cell_id(&bctx->ra_id,
 						TLVP_VAL(tp, BSSGP_IE_CELL_ID));
-		LOGP(DGPRS, LOGL_NOTICE, "Cell %u-%u-%u-%u CI %u on BVCI %u\n",
+		LOGP(DBSSGP, LOGL_NOTICE, "Cell %u-%u-%u-%u CI %u on BVCI %u\n",
 			bctx->ra_id.mcc, bctx->ra_id.mnc, bctx->ra_id.lac,
 			bctx->ra_id.rac, bctx->cell_id, bvci);
 	}
@@ -261,7 +261,7 @@
 	struct tlv_parsed tp;
 	int rc;
 
-	DEBUGP(DGPRS, "BSSGP UL-UD\n");
+	DEBUGP(DBSSGP, "BSSGP UL-UD\n");
 
 	/* extract TLLI and parse TLV IEs */
 	msgb_tlli(msg) = ntohl(budh->tlli);
@@ -289,7 +289,7 @@
 	struct tlv_parsed tp;
 	int rc;
 
-	DEBUGP(DGPRS, "BSSGP SUSPEND\n");
+	DEBUGP(DBSSGP, "BSSGP SUSPEND\n");
 
 	rc = bssgp_tlv_parse(&tp, bgph->data, data_len);
 	if (rc < 0)
@@ -311,7 +311,7 @@
 	struct tlv_parsed tp;
 	int rc;
 
-	DEBUGP(DGPRS, "BSSGP RESUME\n");
+	DEBUGP(DBSSGP, "BSSGP RESUME\n");
 
 	rc = bssgp_tlv_parse(&tp, bgph->data, data_len);
 	if (rc < 0)
@@ -329,7 +329,7 @@
 static int bssgp_rx_fc_bvc(struct msgb *msg, struct tlv_parsed *tp)
 {
 
-	DEBUGP(DGPRS, "BSSGP FC BVC\n");
+	DEBUGP(DBSSGP, "BSSGP FC BVC\n");
 
 	if (!TLVP_PRESENT(tp, BSSGP_IE_TAG) ||
 	    !TLVP_PRESENT(tp, BSSGP_IE_BVC_BUCKET_SIZE) ||
@@ -371,11 +371,11 @@
 		break;
 	case BSSGP_PDUT_RA_CAPABILITY:
 		/* BSS requests RA capability or IMSI */
-		DEBUGP(DGPRS, "BSSGP RA CAPABILITY UPDATE\n");
+		DEBUGP(DBSSGP, "BSSGP RA CAPABILITY UPDATE\n");
 		/* FIXME: send RA_CAPA_UPDATE_ACK */
 		break;
 	case BSSGP_PDUT_RADIO_STATUS:
-		DEBUGP(DGPRS, "BSSGP RADIO STATUS\n");
+		DEBUGP(DBSSGP, "BSSGP RADIO STATUS\n");
 		/* BSS informs us of some exception */
 		/* FIXME: notify GMM */
 		break;
@@ -389,13 +389,13 @@
 		break;
 	case BSSGP_PDUT_FLUSH_LL:
 		/* BSS informs MS has moved to one cell to other cell */
-		DEBUGP(DGPRS, "BSSGP FLUSH LL\n");
+		DEBUGP(DBSSGP, "BSSGP FLUSH LL\n");
 		/* FIXME: notify GMM */
 		/* Send FLUSH_LL_ACK */
 		break;
 	case BSSGP_PDUT_LLC_DISCARD:
 		/* BSS informs that some LLC PDU's have been discarded */
-		DEBUGP(DGPRS, "BSSGP LLC DISCARDED\n");
+		DEBUGP(DBSSGP, "BSSGP LLC DISCARDED\n");
 		/* FIXME: notify GMM */
 		break;
 	case BSSGP_PDUT_FLOW_CONTROL_BVC:
@@ -404,18 +404,18 @@
 		break;
 	case BSSGP_PDUT_FLOW_CONTROL_MS:
 		/* BSS informs us of available bandwidth to one MS */
-		DEBUGP(DGPRS, "BSSGP FC MS\n");
+		DEBUGP(DBSSGP, "BSSGP FC MS\n");
 		/* FIXME: actually implement flow control */
 		/* FIXME: Send FLOW_CONTROL_MS_ACK */
 		break;
 	case BSSGP_PDUT_BVC_BLOCK:
 		/* BSS tells us that BVC shall be blocked */
-		DEBUGP(DGPRS, "BSSGP BVC BLOCK ");
+		DEBUGP(DBSSGP, "BSSGP BVC BLOCK ");
 		if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI) ||
 		    !TLVP_PRESENT(&tp, BSSGP_IE_CAUSE))
 			goto err_mand_ie;
 		bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
-		DEBUGPC(DGPRS, "BVCI=%u, cause=%s\n", bvci,
+		DEBUGPC(DBSSGP, "BVCI=%u, cause=%s\n", bvci,
 			bssgp_cause_str(*TLVP_VAL(&tp, BSSGP_IE_CAUSE)));
 		/* We always acknowledge the BLOCKing */
 		rc = bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK_ACK,
@@ -423,18 +423,18 @@
 		break;
 	case BSSGP_PDUT_BVC_UNBLOCK:
 		/* BSS tells us that BVC shall be unblocked */
-		DEBUGP(DGPRS, "BSSGP BVC UNBLOCK ");
+		DEBUGP(DBSSGP, "BSSGP BVC UNBLOCK ");
 		if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
 			goto err_mand_ie;
 		bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
-		DEBUGPC(DGPRS, "BVCI=%u\n", bvci);
+		DEBUGPC(DBSSGP, "BVCI=%u\n", bvci);
 		/* We always acknowledge the unBLOCKing */
 		rc = bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_UNBLOCK_ACK,
 					  msgb_nsei(msg), bvci, ns_bvci);
 		break;
 	case BSSGP_PDUT_BVC_RESET:
 		/* BSS tells us that BVC init is required */
-		DEBUGP(DGPRS, "BSSGP BVC RESET ");
+		DEBUGP(DBSSGP, "BSSGP BVC RESET ");
 		if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI) ||
 		    !TLVP_PRESENT(&tp, BSSGP_IE_CAUSE))
 			goto err_mand_ie;
@@ -448,7 +448,7 @@
 	case BSSGP_PDUT_CREATE_BSS_PFC_NACK:
 	case BSSGP_PDUT_MODIFY_BSS_PFC:
 	case BSSGP_PDUT_DELETE_BSS_PFC_ACK:
-		DEBUGP(DGPRS, "BSSGP PDU type 0x%02x not [yet] implemented\n",
+		DEBUGP(DBSSGP, "BSSGP PDU type 0x%02x not [yet] implemented\n",
 			pdu_type);
 		break;
 	/* those only exist in the SGSN -> BSS direction */
@@ -466,12 +466,12 @@
 	case BSSGP_PDUT_BVC_BLOCK_ACK:
 	case BSSGP_PDUT_BVC_UNBLOCK_ACK:
 	case BSSGP_PDUT_SGSN_INVOKE_TRACE:
-		DEBUGP(DGPRS, "BSSGP PDU type 0x%02x only exists in DL\n",
+		DEBUGP(DBSSGP, "BSSGP PDU type 0x%02x only exists in DL\n",
 			pdu_type);
 		rc = -EINVAL;
 		break;
 	default:
-		DEBUGP(DGPRS, "BSSGP PDU type 0x%02x unknown\n", pdu_type);
+		DEBUGP(DBSSGP, "BSSGP PDU type 0x%02x unknown\n", pdu_type);
 		break;
 	}
 
@@ -496,7 +496,7 @@
 
 	/* Identifiers from UP: TLLI, BVCI, NSEI (all in msgb->cb) */
 	if (bvci < 2) {
-		LOGP(DGPRS, LOGL_ERROR, "Cannot send DL-UD to BVCI %u\n",
+		LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to BVCI %u\n",
 			bvci);
 		return -EINVAL;
 	}
diff --git a/openbsc/src/gprs/gprs_ns.c b/openbsc/src/gprs/gprs_ns.c
index 3d9bb89..be3d1d9 100644
--- a/openbsc/src/gprs/gprs_ns.c
+++ b/openbsc/src/gprs/gprs_ns.c
@@ -160,7 +160,7 @@
 		ret = nsip_sendmsg(nsvc, msg);
 		break;
 	default:
-		LOGP(DGPRS, LOGL_ERROR, "unsupported NS linklayer %u\n", nsvc->nsi->ll);
+		LOGP(DNS, LOGL_ERROR, "unsupported NS linklayer %u\n", nsvc->nsi->ll);
 		msgb_free(msg);
 		ret = -EIO;
 		break;
@@ -234,7 +234,7 @@
 		if (nsvc->alive_retries > NS_ALIVE_RETRIES) {
 			/* mark as dead and blocked */
 			nsvc->state = NSE_S_BLOCKED;
-			DEBUGP(DGPRS, "NSEI=%u Tns-alive expired more then "
+			DEBUGP(DNS, "NSEI=%u Tns-alive expired more then "
 				"%u times, blocking NS-VC\n", nsvc->nsei,
 				NS_ALIVE_RETRIES);
 			/* FIXME: inform higher layers */
@@ -273,7 +273,7 @@
 
 	nsh->pdu_type = NS_PDUT_RESET_ACK;
 
-	DEBUGP(DGPRS, "NSEI=%u Tx NS RESET ACK (NSVCI=%u)\n",
+	DEBUGP(DNS, "NSEI=%u Tx NS RESET ACK (NSVCI=%u)\n",
 		nsvc->nsei, nsvc->nsvci);
 
 	msgb_tvlv_put(msg, NS_IE_VCI, 2, (uint8_t *)&nsvci);
@@ -291,25 +291,25 @@
 
 	nsvc = nsvc_by_nsei(nsi, msgb_nsei(msg));
 	if (!nsvc) {
-		LOGP(DGPRS, LOGL_ERROR, "Unable to resolve NSEI %u "
+		LOGP(DNS, LOGL_ERROR, "Unable to resolve NSEI %u "
 			"to NS-VC!\n", msgb_nsei(msg));
 		return -EINVAL;
 	}
 
 	if (!(nsvc->state & NSE_S_ALIVE)) {
-		LOGP(DGPRS, LOGL_ERROR, "NSEI=%u is not alive, cannot send\n",
+		LOGP(DNS, LOGL_ERROR, "NSEI=%u is not alive, cannot send\n",
 			nsvc->nsei);
 		return -EBUSY;
 	}
 	if (nsvc->state & NSE_S_BLOCKED) {
-		LOGP(DGPRS, LOGL_ERROR, "NSEI=%u is blocked, cannot send\n",
+		LOGP(DNS, LOGL_ERROR, "NSEI=%u is blocked, cannot send\n",
 			nsvc->nsei);
 		return -EBUSY;
 	}
 
 	nsh = (struct gprs_ns_hdr *) msgb_push(msg, sizeof(*nsh) + 3);
 	if (!nsh) {
-		LOGP(DGPRS, LOGL_ERROR, "Not enough headroom for NS header\n");
+		LOGP(DNS, LOGL_ERROR, "Not enough headroom for NS header\n");
 		return -EIO;
 	}
 
@@ -344,17 +344,17 @@
 	uint8_t cause;
 	int rc;
 
-	DEBUGP(DGPRS, "NSEI=%u NS STATUS ", nsvc->nsei);
+	DEBUGP(DNS, "NSEI=%u NS STATUS ", nsvc->nsei);
 
 	rc = tlv_parse(&tp, &ns_att_tlvdef, nsh->data, msgb_l2len(msg), 0, 0);
 
 	if (!TLVP_PRESENT(&tp, NS_IE_CAUSE)) {
-		DEBUGPC(DGPRS, "missing cause IE\n");
+		DEBUGPC(DNS, "missing cause IE\n");
 		return -EINVAL;
 	}
 
 	cause = *TLVP_VAL(&tp, NS_IE_CAUSE);
-	DEBUGPC(DGPRS, "cause=%s\n", gprs_ns_cause_str(cause));
+	DEBUGPC(DNS, "cause=%s\n", gprs_ns_cause_str(cause));
 
 	return 0;
 }
@@ -374,7 +374,7 @@
 	    !TLVP_PRESENT(&tp, NS_IE_VCI) ||
 	    !TLVP_PRESENT(&tp, NS_IE_NSEI)) {
 		/* FIXME: respond with NS_CAUSE_MISSING_ESSENT_IE */
-		LOGP(DGPRS, LOGL_ERROR, "NS RESET Missing mandatory IE\n");
+		LOGP(DNS, LOGL_ERROR, "NS RESET Missing mandatory IE\n");
 		return -EINVAL;
 	}
 
@@ -382,7 +382,7 @@
 	nsvci = (uint16_t *) TLVP_VAL(&tp, NS_IE_VCI);
 	nsei = (uint16_t *) TLVP_VAL(&tp, NS_IE_NSEI);
 
-	DEBUGP(DGPRS, "NSEI=%u NS RESET (NSVCI=%u, cause=%s)\n",
+	DEBUGP(DNS, "NSEI=%u NS RESET (NSVCI=%u, cause=%s)\n",
 		nsvc->nsvci, nsvc->nsei, gprs_ns_cause_str(*cause));
 
 	nsvc->state = NSE_S_BLOCKED | NSE_S_ALIVE;
@@ -409,13 +409,13 @@
 	if (!nsvc) {
 		/* Only the RESET procedure creates a new NSVC */
 		if (nsh->pdu_type != NS_PDUT_RESET) {
-			LOGP(DGPRS, LOGL_INFO, "Ignoring NS PDU type 0x%0x "
+			LOGP(DNS, LOGL_INFO, "Ignoring NS PDU type 0x%0x "
 				"from %s for non-existing NS-VC\n",
 				nsh->pdu_type, inet_ntoa(saddr->sin_addr));
 			//gprs_ns_tx_reset(nsvc, NS_CAUSE_NSVC_UNKNOWN);
 			return -EIO;
 		}
-		LOGP(DGPRS, LOGL_INFO, "Creating NS-VC for BSS at %s:%u\n",
+		LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s:%u\n",
 			inet_ntoa(saddr->sin_addr), ntohs(saddr->sin_port));
 		nsvc = nsvc_create(nsi, 0xffff);
 		nsvc->ip.bts_addr = *saddr;
@@ -450,7 +450,7 @@
 		rc = gprs_ns_rx_reset(nsvc, msg);
 		break;
 	case NS_PDUT_RESET_ACK:
-		DEBUGP(DGPRS, "NSEI=%u Rx NS RESET ACK\n", nsvc->nsei);
+		DEBUGP(DNS, "NSEI=%u Rx NS RESET ACK\n", nsvc->nsei);
 		/* mark remote NS-VC as blocked + active */
 		nsvc->remote_state = NSE_S_BLOCKED | NSE_S_ALIVE;
 		if (nsvc->remote_end_is_sgsn) {
@@ -465,29 +465,29 @@
 		break;
 	case NS_PDUT_UNBLOCK:
 		/* Section 7.2: unblocking procedure */
-		DEBUGP(DGPRS, "NSEI=%u Rx NS UNBLOCK\n", nsvc->nsei);
+		DEBUGP(DNS, "NSEI=%u Rx NS UNBLOCK\n", nsvc->nsei);
 		nsvc->state &= ~NSE_S_BLOCKED;
 		rc = gprs_ns_tx_simple(nsvc, NS_PDUT_UNBLOCK_ACK);
 		break;
 	case NS_PDUT_UNBLOCK_ACK:
-		DEBUGP(DGPRS, "NSEI=%u Rx NS UNBLOCK ACK\n", nsvc->nsei);
+		DEBUGP(DNS, "NSEI=%u Rx NS UNBLOCK ACK\n", nsvc->nsei);
 		/* mark remote NS-VC as unblocked + active */
 		nsvc->remote_state = NSE_S_ALIVE;
 		if (nsvc->remote_end_is_sgsn)
 			nsvc->state = NSE_S_ALIVE;
 		break;
 	case NS_PDUT_BLOCK:
-		DEBUGP(DGPRS, "NSEI=%u Rx NS BLOCK\n", nsvc->nsei);
+		DEBUGP(DNS, "NSEI=%u Rx NS BLOCK\n", nsvc->nsei);
 		nsvc->state |= NSE_S_BLOCKED;
 		rc = gprs_ns_tx_simple(nsvc, NS_PDUT_UNBLOCK_ACK);
 		break;
 	case NS_PDUT_BLOCK_ACK:
-		DEBUGP(DGPRS, "NSEI=%u Rx NS BLOCK ACK\n", nsvc->nsei);
+		DEBUGP(DNS, "NSEI=%u Rx NS BLOCK ACK\n", nsvc->nsei);
 		/* mark remote NS-VC as blocked + active */
 		nsvc->remote_state = NSE_S_BLOCKED | NSE_S_ALIVE;
 		break;
 	default:
-		DEBUGP(DGPRS, "NSEI=%u Rx Unknown NS PDU type 0x%02x\n",
+		DEBUGP(DNS, "NSEI=%u Rx Unknown NS PDU type 0x%02x\n",
 			nsvc->nsei, nsh->pdu_type);
 		rc = -EINVAL;
 		break;
@@ -533,7 +533,7 @@
 	ret = recvfrom(bfd->fd, msg->data, NS_ALLOC_SIZE, 0,
 			(struct sockaddr *)saddr, &saddr_len);
 	if (ret < 0) {
-		LOGP(DGPRS, LOGL_ERROR, "recv error %s during NSIP recv\n",
+		LOGP(DNS, LOGL_ERROR, "recv error %s during NSIP recv\n",
 			strerror(errno));
 		msgb_free(msg);
 		*error = ret;
@@ -634,7 +634,7 @@
 
 	/* Initiate a RESET procedure */
 	if (gprs_ns_tx_reset(nsvc, NS_CAUSE_OM_INTERVENTION) < 0) {
-		LOGP(DGPRS, LOGL_ERROR, "NSEI=%u, error resetting NS-VC\n",
+		LOGP(DNS, LOGL_ERROR, "NSEI=%u, error resetting NS-VC\n",
 			nsei);
 	}
 	/* run a timer and re-transmit the reset request? */
diff --git a/openbsc/src/vty_interface_cmds.c b/openbsc/src/vty_interface_cmds.c
index efcd654..0c1abfc 100644
--- a/openbsc/src/vty_interface_cmds.c
+++ b/openbsc/src/vty_interface_cmds.c
@@ -142,7 +142,7 @@
 }
 
 /* FIXME: those have to be kept in sync with the log levels and categories */
-#define VTY_DEBUG_CATEGORIES "(rll|cc|mm|rr|rsl|nm|sms|pag|mncc|inp|mi|mib|mux|meas|sccp|msc|mgcp|ho|db|ref|gprs)"
+#define VTY_DEBUG_CATEGORIES "(rll|cc|mm|rr|rsl|nm|sms|pag|mncc|inp|mi|mib|mux|meas|sccp|msc|mgcp|ho|db|ref|gprs|ns|bssgp)"
 #define VTY_DEBUG_LEVELS "(everything|debug|info|notice|error|fatal)"
 DEFUN(logging_level,
       logging_level_cmd,