mtp: Attempt to fix the SCCP restart logic.

The SST is not necessary. We will have to assume the link is
established after having gotten the TRA on the Affected Point Code
and we will need to always handle the restart allowed.
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 78db37c..d71e504 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -321,6 +321,9 @@
 				return -1;
 
 			mtp_link_submit(link, msg);
+			link->sccp_up = 1;
+			link->was_up = 1;
+			LOGP(DINP, LOGL_INFO, "SCCP traffic allowed. %p\n", link);
 			return 0;
 			break;
 		}
@@ -405,6 +408,7 @@
 {
 	struct msgb *out;
 	struct sccp_con_ctrl_prt_mgt *prt;
+	struct sccp_parse_result sccp;
 
 	msg->l2h = &hdr->data[0];
 	if (msgb_l2len(msg) != l3_len) {
@@ -412,36 +416,27 @@
 		return -1;
 	}
 
+	if (!link->sccp_up) {
+		LOGP(DINP, LOGL_ERROR, "SCCP traffic is not allowed.\n");
+		return -1;
+	}
 
-	if (link->sccp_up) {
-		mtp_link_forward_sccp(link, msg, MTP_LINK_SLS(hdr->addr));
-		return 0;
-	} else {
-		struct sccp_parse_result sccp;
-		memset(&sccp, 0, sizeof(sccp));
-		if (sccp_parse_header(msg, &sccp) != 0) {
-			LOGP(DINP, LOGL_ERROR, "Failed to parsed SCCP header.\n");
-			return -1;
-		}
+	memset(&sccp, 0, sizeof(sccp));
+	if (sccp_parse_header(msg, &sccp) != 0) {
+		LOGP(DINP, LOGL_ERROR, "Failed to parsed SCCP header.\n");
+		return -1;
+	}
 
-		if (sccp_determine_msg_type(msg) != SCCP_MSG_TYPE_UDT) {
-			LOGP(DINP, LOGL_ERROR, "Dropping sccp data: 0x%x\n",
-			     sccp_determine_msg_type(msg));
-			return -1;
-		}
-
+	/* check if it is a SST */
+	if (sccp_determine_msg_type(msg) == SCCP_MSG_TYPE_UDT
+	    && msg->l3h[0] == SCCP_SST) {
 		if (msgb_l3len(msg) != 5) {
-			LOGP(DINP, LOGL_ERROR, "SCCP UDT msg of unexpected size: %u\n",
+			LOGP(DINP, LOGL_ERROR,
+			     "SCCP UDT msg of unexpected size: %u\n",
 			     msgb_l3len(msg));
 			return -1;
 		}
 
-		if (msg->l3h[0] != SCCP_SST) {
-			LOGP(DINP, LOGL_ERROR, "Expected SCCP SST but got 0x%x\n",
-			     msg->l3h[0]);
-			return -1;
-		}
-
 		prt = (struct sccp_con_ctrl_prt_mgt *) &msg->l3h[0];
 		if (prt->assn != 254 || prt->apoc != MTP_MAKE_APOC(link->opc)) {
 			LOGP(DINP, LOGL_ERROR, "Unknown SSN/APOC assn: %u, apoc: %u/%u\n",
@@ -453,11 +448,11 @@
 		if (!out)
 			return -1;
 
-		link->sccp_up = 1;
-		link->was_up = 1;
-		LOGP(DINP, LOGL_INFO, "SCCP is established. %p\n", link);
 		mtp_link_submit(link, out);
+		return 0;
 	}
+
+	mtp_link_forward_sccp(link, msg, MTP_LINK_SLS(hdr->addr));
 	return 0;
 }