a_iface: Include CSFB Indication into BSSMAP CLEAR COMMAND

When a call ends that has been established in an CSFB context, we should
add a CSFB Indication IE to the BSSMAP CLEAR COMMAND to instruct the BSC
to add further CSFB related IEs into the RR RELEASE.

- Check if an SGs association exists and add CSFB Indication IE

Change-Id: I6cfa4b3becdd0138d74e2e1eddd83a0b1568c1de
Related: OS#3778
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 0811734..3a7690d 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -416,10 +416,15 @@
 int a_iface_tx_clear_cmd(struct ran_conn *conn)
 {
 	struct msgb *msg;
+	struct vlr_subscr *vsub = conn->vsub;
+	bool csfb_ind = false;
 
 	LOGPCONN(conn, LOGL_INFO, "Tx BSSMAP CLEAR COMMAND to BSC\n");
 
-	msg = gsm0808_create_clear_command(GSM0808_CAUSE_CALL_CONTROL);
+	if (vsub && vsub->sgs_fsm->state == SGS_UE_ST_ASSOCIATED)
+		csfb_ind = true;
+
+	msg = gsm0808_create_clear_command2(GSM0808_CAUSE_CALL_CONTROL, csfb_ind);
 	return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
 }