gtp: Make these regions runtime debuggable
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 996bd82..cfce244 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -185,7 +185,7 @@
 		return GTP1_HEADER_SIZE_LONG;
 	default:
 		LOGP(DLGTP, LOGL_ERROR,
-			"Unknown GTP packet version\n");
+			"Unknown GTP packet version: %d\n", version);
 		return 0;
 	}
 }
@@ -204,7 +204,7 @@
 	} else if ((packet->flags & 0xe2) == 0x22) {	/* Version 1 with seq */
 		return ntoh16(packet->gtp1l.h.seq);
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag: %u\n", packet->flags);
 		return 0;
 	}
 }
@@ -240,7 +240,7 @@
 	} else if ((packet->flags & 0xe7) == 0x20) {	/* Short version 1 */
 		return GTP1_HEADER_SIZE_SHORT;
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag: %u\n", packet->flags);
 		return 0;
 	}
 }
@@ -259,7 +259,7 @@
 	} else if ((packet->flags & 0xe0) == 0x20) {	/* Version 1 */
 		return ntoh32(packet->gtp1l.h.tei);
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag: %u\n", packet->flags);
 		return 0xffffffff;
 	}
 }
@@ -382,7 +382,7 @@
 			packet->gtp1l.h.tei = hton32(pdp->teic_gn);
 		fd = gsn->fd1c;
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag: %u\n", packet->flags);
 		return -1;
 	}
 
@@ -531,7 +531,7 @@
 		else if (pdp)
 			packet->gtp1l.h.tei = hton32(pdp->teic_gn);
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag: %u\n", packet->flags);
 		return -1;
 	}
 
@@ -552,8 +552,7 @@
 	/* Use new queue structure */
 	if (queue_newmsg(gsn->queue_resp, &qmsg, peer, seq)) {
 		gsn->err_queuefull++;
-		LOGP(DLGTP, LOGL_ERROR,
-			"Retransmit queue is full\n");
+		LOGP(DLGTP, LOGL_ERROR, "Retransmit queue is full\n");
 	} else {
 		memcpy(&qmsg->p, packet, sizeof(union gtp_packet));
 		qmsg->l = len;
@@ -590,7 +589,7 @@
 		packet->gtp1l.h.length = hton16(len - GTP1_HEADER_SIZE_SHORT);
 		packet->gtp1l.h.seq = hton16(seq);
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown packet flag: %u\n", packet->flags);
 		return -1;
 	}
 
@@ -651,8 +650,7 @@
 
 	/* We try to open file. On failure we will later try to create file */
 	if (!(f = fopen(filename, "r"))) {
-
-		LOGP(DLGTP, LOGL_ERROR,
+		LOGP(DLGTP, LOGL_NOTICE,
 			"State information file (%s) not found. Creating new file.\n",
 			filename);
 	} else {
@@ -1019,7 +1017,7 @@
 	if (pdp->secondary) {
 		if (pdp_getgtp1(&linked_pdp, pdp->teic_own)) {
 			LOGP(DLGTP, LOGL_ERROR,
-				"Unknown linked PDP context\n");
+				"Unknown linked PDP context: %u\n", pdp->teic_own);
 			return EOF;
 		}
 	}
@@ -1506,16 +1504,14 @@
 	in_addr2gsna(&pdp->gsnlc, &gsn->gsnc);
 	in_addr2gsna(&pdp->gsnlu, &gsn->gsnu);
 
-	if (GTP_DEBUG)
-		printf("gtp_create_pdp_ind: Before pdp_tidget\n");
+	DEBUGP(DLGTP, "gtp_create_pdp_ind: Before pdp_tidget\n");
 
 	if (!pdp_getimsi(&pdp_old, pdp->imsi, pdp->nsapi)) {
 		/* Found old pdp with same tid. Now the voodoo begins! */
 		/* 09.60 / 29.060 allows create on existing context to "steal" */
 		/* the context which was allready established */
 		/* We check that the APN, selection mode and MSISDN is the same */
-		if (GTP_DEBUG)
-			printf("gtp_create_pdp_ind: Old context found\n");
+		DEBUGP(DLGTP, "gtp_create_pdp_ind: Old context found\n");
 		if ((pdp->apn_req.l == pdp_old->apn_req.l)
 		    &&
 		    (!memcmp
@@ -1531,10 +1527,7 @@
 			 * QoS: MS will get originally negotiated QoS.
 			 * End user address (EUA). MS will get old EUA anyway.
 			 * Protocol configuration option (PCO): Only application can verify */
-
-			if (GTP_DEBUG)
-				printf
-				    ("gtp_create_pdp_ind: Old context found\n");
+			DEBUGP(DLGTP, "gtp_create_pdp_ind: Old context found\n");
 
 			/* Copy remote flow label */
 			pdp_old->flru = pdp->flru;
@@ -1564,16 +1557,13 @@
 						   GTPCAUSE_ACC_REQ);
 		} else {	/* This is not the same PDP context. Delete the old one. */
 
-			if (GTP_DEBUG)
-				printf
-				    ("gtp_create_pdp_ind: Deleting old context\n");
+			DEBUGP(DLGTP, "gtp_create_pdp_ind: Deleting old context\n");
 
 			if (gsn->cb_delete_context)
 				gsn->cb_delete_context(pdp_old);
 			pdp_freepdp(pdp_old);
 
-			if (GTP_DEBUG)
-				printf("gtp_create_pdp_ind: Deleted...\n");
+			DEBUGP(DLGTP, "gtp_create_pdp_ind: Deleted...\n");
 		}
 	}
 
@@ -1609,7 +1599,7 @@
 	if (pdp_getgtp1(&pdp, get_tei(pack))) {
 		gsn->err_unknownpdp++;
 		GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
-			    "Unknown PDP context\n");
+			    "Unknown PDP context: %u\n", get_tei(pack));
 		if (gsn->cb_conf)
 			gsn->cb_conf(type, EOF, NULL, cbp);
 		return EOF;
@@ -2014,7 +2004,8 @@
 			if (pdp_getgtp1(&pdp, get_tei(pack))) {
 				gsn->err_unknownpdp++;
 				GTP_LOGPKG(LOGL_ERROR, peer,
-					    pack, len, "Unknown PDP context\n");
+					pack, len, "Unknown PDP context: %u\n",
+					get_tei(pack));
 				return gtp_update_pdp_resp(gsn, version, peer,
 							   fd, pack, len, NULL,
 							   GTPCAUSE_NON_EXIST);
@@ -2031,7 +2022,7 @@
 			}
 		}
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown version\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown version: %d\n", version);
 		return EOF;
 	}
 
@@ -2300,7 +2291,7 @@
 
 	if (pdp_getgtp1(&linked_pdp, pdp->teic_own)) {
 		LOGP(DLGTP, LOGL_ERROR,
-			"Unknown linked PDP context\n");
+			"Unknown linked PDP context: %u\n", pdp->teic_own);
 		return EOF;
 	}
 
@@ -2310,7 +2301,7 @@
 				count++;
 		if (count <= 1) {
 			LOGP(DLGTP, LOGL_ERROR,
-				"Must use teardown for last context\n");
+				"Must use teardown for last context: %d\n", count);
 			return EOF;
 		}
 	}
@@ -2440,7 +2431,7 @@
 	if (pdp_getgtp1(&linked_pdp, get_tei(pack))) {
 		gsn->err_unknownpdp++;
 		GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
-			    "Unknown PDP context\n");
+			    "Unknown PDP context: %u\n", get_tei(pack));
 		return gtp_delete_pdp_resp(gsn, version, peer, fd, pack, len,
 					   NULL, NULL, GTPCAUSE_NON_EXIST,
 					   teardown);
@@ -2627,7 +2618,7 @@
 			hlen = GTP1_HEADER_SIZE_SHORT;
 	} else {
 		GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
-			    "Unknown version\n");
+			    "Unknown version: %d\n", version);
 	}
 
 	/* If the GPDU was not from the peer GSN tell him to delete context */
@@ -2787,9 +2778,9 @@
 			break;
 		default:
 			gsn->unknown++;
-			GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
-				    status,
-				    "Unknown GTP message type received\n");
+			GTP_LOGPKG(LOGL_ERROR, &peer, buffer, status,
+				"Unknown GTP message type received: %d\n",
+				pheader->type);
 			break;
 		}
 	}
@@ -2962,9 +2953,9 @@
 			break;
 		default:
 			gsn->unknown++;
-			GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
-				    status,
-				    "Unknown GTP message type received\n");
+			GTP_LOGPKG(LOGL_ERROR, &peer, buffer, status,
+				"Unknown GTP message type received: %u\n",
+				pheader->type);
 			break;
 		}
 	}
@@ -3092,9 +3083,9 @@
 			break;
 		default:
 			gsn->unknown++;
-			GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
-				    status,
-				    "Unknown GTP message type received\n");
+			GTP_LOGPKG(LOGL_ERROR, &peer, buffer, status,
+				"Unknown GTP message type received: %u\n",
+				pheader->type);
 			break;
 		}
 	}
@@ -3160,7 +3151,7 @@
 		}
 		memcpy(packet.gtp1l.p, pack, len);	/* TODO Should be avoided! */
 	} else {
-		LOGP(DLGTP, LOGL_ERROR, "Unknown version\n");
+		LOGP(DLGTP, LOGL_ERROR, "Unknown version: %d\n", pdp->version);
 		return EOF;
 	}
 
diff --git a/gtp/gtp.h b/gtp/gtp.h
index 39a902f..76c967b 100644
--- a/gtp/gtp.h
+++ b/gtp/gtp.h
@@ -12,8 +12,6 @@
 #ifndef _GTP_H
 #define _GTP_H
 
-#define GTP_DEBUG 0		/* Print debug information */
-
 #define GTP_MODE_GGSN 1
 #define GTP_MODE_SGSN 2
 
diff --git a/gtp/pdp.c b/gtp/pdp.c
index dc21bf8..e28ffac 100644
--- a/gtp/pdp.c
+++ b/gtp/pdp.c
@@ -16,6 +16,8 @@
 
 #include <../config.h>
 
+#include <osmocom/core/logging.h>
+
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
@@ -209,8 +211,7 @@
 	int hash = pdp_tidhash(tid);
 	struct pdp_t *pdp2;
 	struct pdp_t *pdp_prev = NULL;
-	if (PDP_DEBUG)
-		printf("Begin pdp_tidset tid = %llx\n", tid);
+	DEBUGP(DLGTP, "Begin pdp_tidset tid = %llx\n", tid);
 	pdp->tidnext = NULL;
 	pdp->tid = tid;
 	for (pdp2 = hashtid[hash]; pdp2; pdp2 = pdp2->tidnext)
@@ -219,8 +220,7 @@
 		hashtid[hash] = pdp;
 	else
 		pdp_prev->tidnext = pdp;
-	if (PDP_DEBUG)
-		printf("End pdp_tidset\n");
+	DEBUGP(DLGTP, "End pdp_tidset\n");
 	return 0;
 }
 
@@ -229,22 +229,19 @@
 	int hash = pdp_tidhash(pdp->tid);
 	struct pdp_t *pdp2;
 	struct pdp_t *pdp_prev = NULL;
-	if (PDP_DEBUG)
-		printf("Begin pdp_tiddel tid = %llx\n", pdp->tid);
+	DEBUGP(DLGTP, "Begin pdp_tiddel tid = %llx\n", pdp->tid);
 	for (pdp2 = hashtid[hash]; pdp2; pdp2 = pdp2->tidnext) {
 		if (pdp2 == pdp) {
 			if (!pdp_prev)
 				hashtid[hash] = pdp2->tidnext;
 			else
 				pdp_prev->tidnext = pdp2->tidnext;
-			if (PDP_DEBUG)
-				printf("End pdp_tiddel: PDP found\n");
+			DEBUGP(DLGTP, "End pdp_tiddel: PDP found\n");
 			return 0;
 		}
 		pdp_prev = pdp2;
 	}
-	if (PDP_DEBUG)
-		printf("End pdp_tiddel: PDP not found\n");
+	DEBUGP(DLGTP, "End pdp_tiddel: PDP not found\n");
 	return EOF;		/* End of linked list and not found */
 }
 
@@ -252,18 +249,15 @@
 {
 	int hash = pdp_tidhash(tid);
 	struct pdp_t *pdp2;
-	if (PDP_DEBUG)
-		printf("Begin pdp_tidget tid = %llx\n", tid);
+	DEBUGP(DLGTP, "Begin pdp_tidget tid = %llx\n", tid);
 	for (pdp2 = hashtid[hash]; pdp2; pdp2 = pdp2->tidnext) {
 		if (pdp2->tid == tid) {
 			*pdp = pdp2;
-			if (PDP_DEBUG)
-				printf("Begin pdp_tidget. Found\n");
+			DEBUGP(DLGTP, "Begin pdp_tidget. Found\n");
 			return 0;
 		}
 	}
-	if (PDP_DEBUG)
-		printf("Begin pdp_tidget. Not found\n");
+	DEBUGP(DLGTP, "Begin pdp_tidget. Not found\n");
 	return EOF;		/* End of linked list and not found */
 }
 
diff --git a/gtp/pdp.h b/gtp/pdp.h
index 6e30467..57af8b3 100644
--- a/gtp/pdp.h
+++ b/gtp/pdp.h
@@ -15,8 +15,6 @@
 #define PDP_MAX 1024		/* Max number of PDP contexts */
 #define PDP_MAXNSAPI 16		/* Max number of NSAPI */
 
-#define PDP_DEBUG 0		/* Print debug information */
-
 /* GTP Information elements from 29.060 v3.9.0 7.7 Information Elements */
 /* Also covers version 0. Note that version 0 6: QOS Profile was superceded *
  * by 135: QOS Profile in version 1 */