[PATCH] Add return value to indicate unsopported cipher.

Max Max.Suraev at fairwaves.ru
Thu Nov 29 14:07:27 UTC 2012


---
 include/osmocom/gsm/a5.h |    2 +-
 src/gsm/a5.c             |    8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/osmocom/gsm/a5.h b/include/osmocom/gsm/a5.h
index 649dbab..f237c42 100644
--- a/include/osmocom/gsm/a5.h
+++ b/include/osmocom/gsm/a5.h
@@ -54,7 +54,7 @@ osmo_a5_fn_count(uint32_t fn)
 	 *  - 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);
+unsigned 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..68d703a 100644
--- a/src/gsm/a5.c
+++ b/src/gsm/a5.c
@@ -45,10 +45,10 @@
  *  \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
  *
- * Currently A5/[0-2] are supported.
+ * Currently A5/[0-2] are supported: 0 returned in this case, 1 s returned otherwise.
  * Either (or both) of dl/ul can be NULL if not needed.
  */
-void
+unsigned
 osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul)
 {
 	switch (n)
@@ -58,18 +58,22 @@ osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul)
 			memset(dl, 0x00, 114);
 		if (ul)
 			memset(ul, 0x00, 114);
+		return 1;
 		break;
 
 	case 1:
 		osmo_a5_1(key, fn, dl, ul);
+		return 1;
 		break;
 
 	case 2:
 		osmo_a5_2(key, fn, dl, ul);
+		return 1;
 		break;
 
 	default:
 		/* a5/[3..7] not supported here/yet */
+		return 0;
 		break;
 	}
 }
-- 
1.7.10.4


--------------090904030806030201060909--




More information about the baseband-devel mailing list