From patchwork Thu Apr 21 12:58:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 613094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3qrJjQ2mplz9t4b for ; Thu, 21 Apr 2016 22:59:06 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id DF33E13EBF; Thu, 21 Apr 2016 12:59:03 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 7725C13EB8 for ; Thu, 21 Apr 2016 12:59:02 +0000 (UTC) Received: from mail.sysmocom.de (mail.sysmocom.de [144.76.43.93]) by mail.sysmocom.de (Postfix) with ESMTP id 2FD711B1E9A; Thu, 21 Apr 2016 12:58:32 +0000 (UTC) Received: from pbell.local (shnet2-91.in-berlin.de [217.197.83.91]) by mail.sysmocom.de (Postfix) with ESMTPSA id D08731B1E99; Thu, 21 Apr 2016 12:58:31 +0000 (UTC) From: msuraev@sysmocom.de To: openbsc@lists.osmocom.org Subject: [PATCH] Addditional classmark check against A5/4 support Date: Thu, 21 Apr 2016 14:58:30 +0200 Message-Id: <1461243511-23101-1-git-send-email-msuraev@sysmocom.de> X-Mailer: git-send-email 2.8.1 X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Max Add classmark check function according to GSM 04.08 Chapter 10.5.1.7 Fix interface to use unsigned for unsigned value. --- include/osmocom/gsm/gsm_utils.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 99aae65..0fbfcba 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -119,7 +119,7 @@ int rxlev2dbm(uint8_t rxlev); uint8_t dbm2rxlev(int dbm); /* According to GSM 04.08 Chapter 10.5.1.6 */ -static inline int ms_cm2_a5n_support(uint8_t *cm2, int n) { +static inline int ms_cm2_a5n_support(uint8_t *cm2, unsigned n) { switch (n) { case 0: return 1; case 1: return (cm2[0] & (1<<3)) ? 0 : 1; @@ -130,6 +130,18 @@ static inline int ms_cm2_a5n_support(uint8_t *cm2, int n) { } } +/* According to GSM 04.08 Chapter 10.5.1.7 */ +static inline int ms_cm3_a5n_support(uint8_t *cm3, unsigned n) { + switch (n) { + case 4: return (cm3[0] & (1<<0)) ? 1 : 0; + case 5: return (cm3[0] & (1<<1)) ? 1 : 0; + case 6: return (cm3[0] & (1<<2)) ? 1 : 0; + case 7: return (cm3[0] & (1<<3)) ? 1 : 0; + default: + return 0; + } +} + /* According to GSM 04.08 Chapter 10.5.2.29 */ static inline int rach_max_trans_val2raw(int val) { return (val >> 1) & 3; } static inline int rach_max_trans_raw2val(int raw) {