diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2016-09-23 01:48:59 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-03-07 01:06:38 +0700 |
commit | 3262f820b5cfb4c76448f605c9804f3e5ca1023d (patch) | |
tree | 1d62b0b5a454955e71e6ce91a869d54f1d8df154 /src/coding/gsm0503_parity.c | |
parent | 68930e85b5945db8ffea055fd178bc1f88b31d99 (diff) |
libosmocoding: migrate transcoding routines from OsmoBTS
There are some projects, such as GR-GSM and OsmocomBB, which would
benefit from using one shared implementation of GSM 05.03 code. So,
this commit introduces a new sub-library called libosmocoding, which
(for now) provides GSM, GPRS and EDGE transcoding routines, migrated
from OsmoBTS.
The original GSM 05.03 code from OsmoBTS was relicensed under
GPLv2-or-later with permission of copyright holders (Andreas Eversberg,
Alexander Chemeris and Tom Tsou).
The following data types are currently supported:
- xCCH
- PDTCH (CS 1-4 and MCS 1-9)
- TCH/FR
- TCH/HR
- TCH/AFS
- RCH/AHS
- RACH
- SCH
Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1
Diffstat (limited to 'src/coding/gsm0503_parity.c')
-rw-r--r-- | src/coding/gsm0503_parity.c | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/src/coding/gsm0503_parity.c b/src/coding/gsm0503_parity.c new file mode 100644 index 00000000..99198ba8 --- /dev/null +++ b/src/coding/gsm0503_parity.c @@ -0,0 +1,132 @@ +/* + * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu> + * (C) 2016 by Tom Tsou <tom.tsou@ettus.com> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <stdint.h> + +#include <osmocom/core/crcgen.h> +#include <osmocom/coding/gsm0503_parity.h> + +/* + * GSM (SACCH) parity (FIRE code) + * + * g(x) = (x^23 + 1)(x^17 + x^3 + 1) + * = x^40 + x^26 + x^23 + x^17 + x^3 + a1 + */ +const struct osmo_crc64gen_code gsm0503_fire_crc40 = { + .bits = 40, + .poly = 0x0004820009ULL, + .init = 0x0000000000ULL, + .remainder = 0xffffffffffULL, +}; + +/* + * GSM PDTCH CS-2, CS-3, CS-4 parity + * + * g(x) = x^16 + x^12 + x^5 + 1 + */ +const struct osmo_crc16gen_code gsm0503_cs234_crc16 = { + .bits = 16, + .poly = 0x1021, + .init = 0x0000, + .remainder = 0xffff, +}; + +/* + * EDGE MCS header parity + * + */ +const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = { + .bits = 8, + .poly = 0x49, + .init = 0x00, + .remainder = 0xff, +}; + +/* + * EDGE MCS data parity + * + */ +const struct osmo_crc16gen_code gsm0503_mcs_crc12 = { + .bits = 12, + .poly = 0x0d31, + .init = 0x0000, + .remainder = 0x0fff, +}; + +/* + * GSM RACH parity + * + * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1 + */ +const struct osmo_crc8gen_code gsm0503_rach_crc6 = { + .bits = 6, + .poly = 0x2f, + .init = 0x00, + .remainder = 0x3f, +}; + +/* + * GSM SCH parity + * + * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1 + */ +const struct osmo_crc16gen_code gsm0503_sch_crc10 = { + .bits = 10, + .poly = 0x175, + .init = 0x000, + .remainder = 0x3ff, +}; + +/* + * GSM TCH FR/HR/EFR parity + * + * g(x) = x^3 + x + 1 + */ +const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = { + .bits = 3, + .poly = 0x3, + .init = 0x0, + .remainder = 0x7, +}; + +/* + * GSM TCH EFR parity + * + * g(x) = x^8 + x^4 + x^3 + x^2 + 1 + */ +const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = { + .bits = 8, + .poly = 0x1d, + .init = 0x00, + .remainder = 0x00, +}; + +/* + * GSM AMR parity + * + * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1 + */ +const struct osmo_crc8gen_code gsm0503_amr_crc6 = { + .bits = 6, + .poly = 0x2f, + .init = 0x00, + .remainder = 0x3f, +}; |