ASCI: Add callref to assignment command

The (optional) call reference is required to assign a calling subscriber
to a voice group/bcast channel. The BSC can then determine to which
existing VGCS/VBS channel the MS is assigned to.

This IE is part of the GSM standard TS 48.008 (see ยง3.2.1.1)

Change-Id: I7955c6e0eebc930f85f360dda46be17cbd39e181
Related: OS#4854
diff --git a/include/osmocom/msc/ran_msg.h b/include/osmocom/msc/ran_msg.h
index 0dadd4f..dc1483c 100644
--- a/include/osmocom/msc/ran_msg.h
+++ b/include/osmocom/msc/ran_msg.h
@@ -109,6 +109,8 @@
 	bool call_id_present;
 	uint32_t call_id;
 	struct osmo_lcls *lcls;
+	bool callref_present;
+	struct gsm0808_group_callref callref;
 };
 
 struct ran_cipher_mode_command {
diff --git a/src/libmsc/ran_msg_a.c b/src/libmsc/ran_msg_a.c
index 570a8d1..2533045 100644
--- a/src/libmsc/ran_msg_a.c
+++ b/src/libmsc/ran_msg_a.c
@@ -1375,13 +1375,6 @@
 	return 0;
 }
 
-static void _gsm0808_assignment_extend_osmux(struct msgb *msg, uint8_t cid)
-{
-	OSMO_ASSERT(msg->l3h[1] == msgb_l3len(msg) - 2); /*TL not in len */
-	msgb_tv_put(msg, GSM0808_IE_OSMO_OSMUX_CID, cid);
-	msg->l3h[1] = msgb_l3len(msg) - 2;
-}
-
 /* Compose a BSSAP Assignment Command.
  * Passing an RTP address is optional.
  * The msub is passed merely for error logging. */
@@ -1468,8 +1461,13 @@
 		return NULL;
 	}
 
+	/* Append optional IEs: Group Call Reference and Osmux CID */
+	OSMO_ASSERT(msg->l3h[1] == msgb_l3len(msg) - 2); /* TL not in len */
+	if (ac->callref_present)
+		gsm0808_enc_group_callref(msg, &ac->callref);
 	if (ac->osmux_present)
-		_gsm0808_assignment_extend_osmux(msg, ac->osmux_cid);
+		msgb_tv_put(msg, GSM0808_IE_OSMO_OSMUX_CID, ac->osmux_cid);
+	msg->l3h[1] = msgb_l3len(msg) - 2;
 	return msg;
 }