gsm/a5: Return -ENOTSUP if the selected cipher is not supported

Extracted from a patch by Max Suraev Max.Suraev@fairwaves.ru>

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
diff --git a/include/osmocom/gsm/a5.h b/include/osmocom/gsm/a5.h
index 649dbab..2f78a92 100644
--- a/include/osmocom/gsm/a5.h
+++ b/include/osmocom/gsm/a5.h
@@ -54,7 +54,7 @@
 	 *  - fn is the _real_ GSM frame number.
 	 *    (converted internally to fn_count)
 	 */
-void osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul);
+int osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul);
 void osmo_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul);
 void osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul);
 
diff --git a/src/gsm/a5.c b/src/gsm/a5.c
index 356060a..de821e8 100644
--- a/src/gsm/a5.c
+++ b/src/gsm/a5.c
@@ -34,6 +34,7 @@
  *  \brief Osmocom GSM A5 ciphering algorithm implementation
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include <osmocom/gsm/a5.h>
@@ -44,11 +45,12 @@
  *  \param[in] fn Frame number
  *  \param[out] dl Pointer to array of ubits to return Downlink cipher stream
  *  \param[out] ul Pointer to array of ubits to return Uplink cipher stream
+ *  \returns 0 for success, -ENOTSUP for invalid cipher selection.
  *
  * Currently A5/[0-2] are supported.
  * Either (or both) of dl/ul can be NULL if not needed.
  */
-void
+int
 osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul)
 {
 	switch (n)
@@ -70,8 +72,10 @@
 
 	default:
 		/* a5/[3..7] not supported here/yet */
-		break;
+		return -ENOTSUP;
 	}
+
+	return 0;
 }