gtp: Introduce new pdp APIs (and deprecate old ones) to support multiple GSN

Move static global pdp storage arrays to be per GSN. This way now
several GSN per process are supported without collisions.

* pdp_init() is defined in public API but it's actually only intended
for use (and currently only used) internally in gtp_new(). So let's
document that and re-use it for backward compatibility with now
deprecated API, where only one GSN per process is supported.

* Back pointer to gsn_t (pdp->gsn) moved from gtp.c:gtp_new() to
gtp_pdp_newpdp(), since it makes more sense to have it there. This way
backpointer is always set, even in case were app calls pdp_newpdp() API
directly instead of creating them through gtp.c, like osmo-sgsn does.

* Create new versions of required APIs with a pointer to gsn_t where the
pdp ctx is to be created/found. Some APIs receiving a pointer to a pdp
ctx can be left intact because we have a backpointer to its gsn_t.

* pdp_getpdp() is nowhere used, and makes little sense now that we have
pdpa reachable in gsn->pdpa, so let's deprecate it without adding a
replacement.

* Deprecate gtp.h gtp_newpdp(), since it's nowhere used and useless
(does same as new gtp_pdp_newpdp() and doesn't allow for old_pdp to be
passed as parameter).

Fixes: OS#2873
Change-Id: I653cbdc185165592d985e3efab6e3f1add97877b
diff --git a/gtp/gtp.c b/gtp/gtp.c
index 2b14026..84b8844 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -131,16 +131,12 @@
 	{ 0, NULL }
 };
 
-/* gtp_new */
-/* gtp_free */
-
+/* Deprecated, use gtp_pdp_newpdp() instead */
 int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp,
 	       uint64_t imsi, uint8_t nsapi)
 {
 	int rc;
-	rc = pdp_newpdp(pdp, imsi, nsapi, NULL);
-	if (!rc && *pdp)
-		(*pdp)->gsn = gsn;
+	rc = gtp_pdp_newpdp(gsn, pdp, imsi, nsapi, NULL);
 	return rc;
 }
 
@@ -849,7 +845,7 @@
 	queue_new(&(*gsn)->queue_resp);
 
 	/* Initialise pdp table */
-	pdp_init();
+	pdp_init(*gsn);
 
 	/* Initialise call back functions */
 	(*gsn)->cb_create_context_ind = 0;
@@ -1681,9 +1677,7 @@
 		}
 	}
 
-	pdp_newpdp(&pdp, pdp->imsi, pdp->nsapi, pdp);
-	if (pdp)
-		pdp->gsn = gsn;
+	gtp_pdp_newpdp(gsn, &pdp, pdp->imsi, pdp->nsapi, pdp);
 
 	/* Callback function to validate login */
 	if (gsn->cb_create_context_ind != 0)