IuPS: Change GTP-U endpoint to SGSN in PMM_IDLE and page UE when data arrives

Change-Id: I47b73a40cbdda6b7c31fb2767f74f9f93d84056b
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index cb3d4ee..3d74647 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -109,6 +109,16 @@
 
 static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx);
 
+static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx)
+{
+	struct sgsn_pdp_ctx *pdp;
+	llist_for_each_entry(pdp, &mm_ctx->pdp_list, list) {
+		sgsn_pdp_upd_gtp_u(pdp,
+				   &sgsn->cfg.gtp_listenaddr.sin_addr,
+				   sizeof(sgsn->cfg.gtp_listenaddr.sin_addr));
+	}
+}
+
 void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
 {
 	if (ctx->pmm_state == state)
@@ -120,7 +130,8 @@
 	{
 		switch (state) {
 		case PMM_IDLE:
-			/* TODO: Change GTP-U endpoints to SGSN, start RA Upd timer */
+			/* TODO: start RA Upd timer */
+			mmctx_change_gtpu_endpoints_to_sgsn(ctx);
 			break;
 		case PMM_CONNECTED:
 			break;