libmsc/gsm_09_11.c: send GSUP PROS_SS ERROR message when needed

OsmoMSC should notify the remote SS/USSD entity if:

  - received GSUP message has unexpected session state;
  - received GSUP message has unknown session ID;
  - received GSUP message missing mandatory IE(s);
  - NCSS transaction establishment failed;
  - NCSS message delivery failed.

Change-Id: Ief9f8a197b0860072b671edfc55180f619860d9d
Related: (TTCN-3) Ie267ee174c5061cd3fc102a2824abe03d73f3aac
Related: OS#2931
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index 39b9711..4a7c348 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -475,7 +475,7 @@
 		/* Attempt to establish a new transaction */
 		trans = establish_nc_ss_trans(net, vsub, gsup_msg);
 		if (!trans) {
-			/* FIXME: send ERROR back to the HLR */
+			gsup_client_mux_tx_error_reply(gcm, gsup_msg, GMM_CAUSE_NET_FAIL);
 			return -EINVAL;
 		}
 
@@ -520,7 +520,7 @@
 	default:
 		LOG_TRANS(trans, LOGL_ERROR, "Unexpected session state %d\n",
 			gsup_msg->session_state);
-		/* FIXME: send ERROR back to the HLR */
+		gsup_client_mux_tx_error_reply(gcm, gsup_msg, GMM_CAUSE_MSGT_INCOMP_P_STATE);
 		msgb_free(ss_msg);
 		return -EINVAL;
 	}
@@ -530,7 +530,7 @@
 		if (!gsup_msg->ss_info || gsup_msg->ss_info_len < 2) {
 			LOG_TRANS(trans, LOGL_ERROR, "Missing mandatory Facility IE "
 				"for mapped 0x%02x message\n", gh->msg_type);
-			/* FIXME: send ERROR back to the HLR */
+			gsup_client_mux_tx_error_reply(gcm, gsup_msg, GMM_CAUSE_INV_MAND_INFO);
 			msgb_free(ss_msg);
 			return -EINVAL;
 		}
@@ -553,6 +553,7 @@
 	msc_a = trans->msc_a;
 	if (!msc_a) {
 		LOG_TRANS(trans, LOGL_ERROR, "Cannot send SS message, no local MSC-A role defined for subscriber\n");
+		gsup_client_mux_tx_error_reply(gcm, gsup_msg, GMM_CAUSE_NET_FAIL);
 		msgb_free(ss_msg);
 		return -EINVAL;
 	}