Fill Last Used E-UTRAN PLMN Id when in CSFB

Since recently, osmo-bsc behaves strictly as per specs, meaning it will
only send the "Cell selection indicator after release of all TCH and SDCCH IE"
in RR Channel Release iff:
* "Last Used E-UTRAN PLMN Id" was received in the CommonID sent MSC->BSC
* "Last Used E-UTRAN PLMN Id" was received insider "old BSS to new BSS Information"
  in the HandoverRequest sent MSC->BSC.
On the other hand, CSFB_Indicator from ClearCommand MSC->BSC is nw
ignored and not taken into account.

Hence, let's update osmo-msc to also behave correctly by sending the
Last Used E-UTRAN PLMN ID at CommonID tx time to avoid regressions in
CSFB support when running against newer osmo-bsc.

Let's keep sending the CSFB Indicator in ClearCommand as we used too, in
order to keep compatibility with older BSCs (as per spec).

Related: SYS#5337
Change-Id: Ic5f175b179973d0a50d94f00e15f5a3e332605fc
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index 33d6331..02aceef 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -476,6 +476,23 @@
 	       vsub->imsi, vsub->msisdn);
 }
 
+void vlr_subscr_set_last_used_eutran_plmn_id(struct vlr_subscr *vsub,
+					     const struct osmo_plmn_id *last_eutran_plmn)
+{
+	if (!vsub)
+		return;
+	if (last_eutran_plmn) {
+		vsub->sgs.last_eutran_plmn_present = true;
+		memcpy(&vsub->sgs.last_eutran_plmn, last_eutran_plmn, sizeof(*last_eutran_plmn));
+	} else {
+		vsub->sgs.last_eutran_plmn_present = false;
+	}
+	DEBUGP(DVLR, "set Last E-UTRAN PLMN ID on subscriber: %s\n",
+	       vsub->sgs.last_eutran_plmn_present ?
+	         osmo_plmn_name(&vsub->sgs.last_eutran_plmn) :
+		 "(none)");
+}
+
 bool vlr_subscr_matches_imsi(struct vlr_subscr *vsub, const char *imsi)
 {
 	return vsub && imsi && vsub->imsi[0] && !strcmp(vsub->imsi, imsi);