sgsn: Cleanup GMM state transitions

Currently the GMM state is set to GMM-REGISTERED when an Attach
Accept or a RA Update Accept message is sent, even if a new P-TMSI is
included. In this case 04.08 requires (see 4.7.3.1.3 and 4.7.5.1.3),
that the state is set to GMM-COMMON-PROCEDURE-INITIATED when the
Accept is sent. When the Complete is received, the SGSN shall set
the state to GMM-REGISTERED.

This patch modifies the state updates accordingly.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 814b457..49ee2df 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -376,11 +376,7 @@
 	 * authorization */
 	OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
 
-	/* FIXME: If we were authorized, the state should be
-	 * GMM_COMMON_PROC_INIT until the Attach Complete is received, since a
-	 * P-TMSI is included, fix state handling in gprs_gmm.c */
-
-	/* OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); */
+	OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT);
 
 	/* we expect an attach accept/reject */
 	OSMO_ASSERT(sgsn_tx_counter == 1);