Support sending OML Alerts via BTS

* extend BTS <-> PCU protocol with TXT messages
* use it to implement OML alerts support
* use it to implement version message
* add function to transmit both of them them
* send alerts for internal encoding problems as an example
* send version when BTS socket is connected

Note: requires corresponding change
If57459c0610f2c7b36d599b13087c8deef8bdd9e in libosmocore.

Related: OS#1614, 1615
Change-Id: If4ea5b3f7409df2fb030681ad468df6b711790a7
diff --git a/src/encoding.cpp b/src/encoding.cpp
index ea38b77..2f052a4 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -320,6 +320,13 @@
 	return plen;
 }
 
+static inline void log_alert_exit(const char * error)
+{
+	LOGP(DRLCMACUL, LOGL_ERROR, error);
+	pcu_tx_txt_ind(PCU_OML_ALERT, error);
+	exit(1);
+}
+
 /*
  * Immediate assignment, sent on the CCCH/AGCH
  * see GSM 04.08, 9.1.18 and GSM 44.018, 9.1.18 + 10.5.2.16
@@ -374,11 +381,10 @@
 	// A zero-length LV.  Just write L=0.
 	bitvec_write_field(dest, wp,0,8);
 
-	if ((wp % 8)) {
-		LOGP(DRLCMACUL, LOGL_ERROR, "Length of IMM.ASS without rest "
-			"octets is not multiple of 8 bits, PLEASE FIX!\n");
-		exit (0);
-	}
+	if ((wp % 8))
+		log_alert_exit("Length of IMM.ASS without rest octets is not "
+			       "multiple of 8 bits, PLEASE FIX!\n");
+
 	plen = wp / 8;
 
 	if (downlink)
@@ -618,11 +624,11 @@
 	{
 		bitvec_write_field(dest, wp,ptmsi[i],8); // PTMSI
 	}
-	if ((wp % 8)) {
-		LOGP(DRLCMACUL, LOGL_ERROR, "Length of PAG.REQ without rest "
-			"octets is not multiple of 8 bits, PLEASE FIX!\n");
-		exit (0);
-	}
+
+	if ((wp % 8))
+		log_alert_exit("Length of PAG.REQ without rest octets is not "
+			       "multiple of 8 bits, PLEASE FIX!\n");
+
 	plen = wp / 8;
 	bitvec_write_field(dest, wp,0x0,1); // "L" NLN(PCH) = off
 	bitvec_write_field(dest, wp,0x0,1); // "L" Priority1 = off