msc_a,vlr: add ciphering_required (accurately named)

For establishing Layer 3, pass a flag from msc_a to VLR that indicates
to fail if encryption is not possible.

An earlier patch [1] renamed a previously existing flag ciphering_required
to try_ciphering, because the naming was not accurate. This new flag now
indicates exactly what its name suggests.

This new flag is needed for upcoming patch [2] to distinguish between
optional and mandatory encryption.

[1] Ia55085e3b36feb275bcf92fc91a4be7d1c24a6b9
[2] I5feda196fa481dd8a46b0e4721c64b7c6600f0d1

Related: OS#4830
Change-Id: I52090c5f5db997030da7c2ed9beca9c51f55f4cf
diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index fad5b77..7ce70c9 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -116,6 +116,18 @@
 		return net->a5_encryption_mask > 0x1;
 }
 
+bool msc_a_require_ciphering(const struct msc_a *msc_a)
+{
+	struct gsm_network *net = msc_a_net(msc_a);
+	bool is_utran = (msc_a->c.ran->type == OSMO_RAT_UTRAN_IU);
+	if (is_utran)
+		return net->uea_encryption_mask
+			&& ((net->uea_encryption_mask & (1 << OSMO_UTRAN_UEA0)) == 0);
+	else
+		return net->a5_encryption_mask
+			&& ((net->a5_encryption_mask & 0x1) == 0);
+}
+
 static void update_counters(struct osmo_fsm_inst *fi, bool conn_accepted)
 {
 	struct msc_a *msc_a = fi->priv;