Implement RR Classmark Enquiry

If the MSC sends a BSSMAP Classmark Request, send an RR Classmark Enquiry to
the MS.

(The reverse direction, i.e. sending a BSSMAP Classmark Update back to the MSC,
is already implemented.)

Related: OS#3043 (A5/3 encryption)
Related: osmo-ttcn3-hacks Idaab4d568cf986b4897ba008f6262c839d1592fb
Change-Id: If5db638fd6e8d9c2ef9e139e99f0fabe1ef16ddf
diff --git a/include/osmocom/bsc/gsm_04_08_rr.h b/include/osmocom/bsc/gsm_04_08_rr.h
index 7b7a62f..e2e861d 100644
--- a/include/osmocom/bsc/gsm_04_08_rr.h
+++ b/include/osmocom/bsc/gsm_04_08_rr.h
@@ -21,6 +21,7 @@
 		       uint8_t *classmark2_lv);
 int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn,
 			     struct msgb *msg, struct bsc_subscr *bsub);
+int gsm48_send_rr_classmark_enquiry(struct gsm_lchan *lchan);
 int gsm48_send_rr_ciph_mode(struct gsm_lchan *lchan, int want_imeisv);
 int gsm48_multirate_config(uint8_t *lv, const struct amr_multirate_conf *mr, const struct amr_mode *modes);
 struct msgb *gsm48_make_ho_cmd(struct gsm_lchan *new_lchan, uint8_t power_command, uint8_t ho_ref);
diff --git a/src/osmo-bsc/gsm_04_08_rr.c b/src/osmo-bsc/gsm_04_08_rr.c
index 2b4a1ba..35044a3 100644
--- a/src/osmo-bsc/gsm_04_08_rr.c
+++ b/src/osmo-bsc/gsm_04_08_rr.c
@@ -273,6 +273,21 @@
 	return rsl_siemens_mrpci(lchan, &mrpci);
 }
 
+/* 3GPP 44.018 9.1.12 Classmark Enquiry */
+int gsm48_send_rr_classmark_enquiry(struct gsm_lchan *lchan)
+{
+	struct msgb *msg = gsm48_msgb_alloc_name("GSM 44.018 Classmark Enquiry");
+	struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
+
+	msg->lchan = lchan;
+	gh->proto_discr = GSM48_PDISC_RR;
+	gh->msg_type = GSM48_MT_RR_CLSM_ENQ;
+
+	DEBUGP(DRR, "%s TX CLASSMARK ENQUIRY %u\n", gsm_lchan_name(lchan), msgb_length(msg));
+
+	return gsm48_sendmsg(msg);
+}
+
 /* Chapter 9.1.9: Ciphering Mode Command */
 int gsm48_send_rr_ciph_mode(struct gsm_lchan *lchan, int want_imeisv)
 {
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index d6b0b6d..97daa5c 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -870,6 +870,9 @@
 	case BSS_MAP_MSG_HANDOVER_CMD:
 		ret = bssmap_handle_handover_cmd(conn, msg, length);
 		break;
+	case BSS_MAP_MSG_CLASSMARK_RQST:
+		ret = gsm48_send_rr_classmark_enquiry(conn->lchan);
+		break;
 	default:
 		LOGP(DMSC, LOGL_NOTICE, "Unimplemented msg type: %s\n",
 			gsm0808_bssmap_name(msg->l4h[0]));