gprs_ns2: move allocation of the SNS fsm into create_nse

The allocation of the SNS fsm can be done in create_nse
because the dialect is now known at that time.

Change-Id: I64e1f3dcc63d38e65bb486c9ac08d4032b7ad222
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 920fa68..890b656 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -677,6 +677,7 @@
 					 enum gprs_ns2_ll linklayer, enum gprs_ns2_dialect dialect)
 {
 	struct gprs_ns2_nse *nse;
+	char sns[16];
 
 	nse = gprs_ns2_nse_by_nsei(nsi, nsei);
 	if (nse) {
@@ -688,6 +689,15 @@
 	if (!nse)
 		return NULL;
 
+	if (dialect == NS2_DIALECT_SNS) {
+		snprintf(sns, sizeof(sns), "NSE%05u-SNS", nsei);
+		nse->bss_sns_fi = ns2_sns_bss_fsm_alloc(nse, sns);
+		if (!nse->bss_sns_fi) {
+			talloc_free(nse);
+			return NULL;
+		}
+	}
+
 	nse->dialect = dialect;
 	nse->ll = linklayer;
 	nse->nsei = nsei;
@@ -959,14 +969,11 @@
 		return -2;
 	}
 
-	nsvc = gprs_ns2_ip_bind_connect(bind, nse, remote);
-	if (!nsvc)
+	if (!nse->bss_sns_fi)
 		return -1;
 
-	if (!nse->bss_sns_fi)
-		nse->bss_sns_fi = ns2_sns_bss_fsm_alloc(nse, NULL);
-
-	if (!nse->bss_sns_fi)
+	nsvc = gprs_ns2_ip_bind_connect(bind, nse, remote);
+	if (!nsvc)
 		return -1;
 
 	return ns2_sns_bss_fsm_start(nse, nsvc, remote);