[PATCH 2/4] Add concolutional code generator for *CCH

msuraev at sysmocom.de msuraev at sysmocom.de
Mon Apr 11 14:22:47 UTC 2016


From: Max <msuraev at sysmocom.de>

Move convolutional code for *CCH channels from test to public API
because it's useful not only for testing. Note: the code was manually
generating with utils/conv_gen.py
---
 include/Makefile.am           |  1 +
 include/osmocom/gsm/gsm0503.h | 47 +++++++++++++++++++++++++++++
 src/gsm/Makefile.am           |  2 +-
 src/gsm/conv_xcch_gen.c       | 69 +++++++++++++++++++++++++++++++++++++++++++
 src/gsm/libosmogsm.map        |  1 +
 tests/Makefile.am             |  2 +-
 tests/conv/conv_test.c        | 32 +++-----------------
 7 files changed, 124 insertions(+), 30 deletions(-)
 create mode 100644 include/osmocom/gsm/gsm0503.h
 create mode 100644 src/gsm/conv_xcch_gen.c

diff --git a/include/Makefile.am b/include/Makefile.am
index 0e5ed74..e7888c5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -64,6 +64,7 @@ nobase_include_HEADERS = \
                        osmocom/gsm/gsm0411_utils.h \
                        osmocom/gsm/gsm0480.h \
                        osmocom/gsm/gsm0502.h \
+                       osmocom/gsm/gsm0503.h \
                        osmocom/gsm/gsm0808.h \
                        osmocom/gsm/gsm48.h \
                        osmocom/gsm/gsm48_ie.h \
diff --git a/include/osmocom/gsm/gsm0503.h b/include/osmocom/gsm/gsm0503.h
new file mode 100644
index 0000000..e68aa9a
--- /dev/null
+++ b/include/osmocom/gsm/gsm0503.h
@@ -0,0 +1,47 @@
+/*
+ * gsm0503.h
+ *
+ * Copyright (C) 2016 sysmocom s.f.m.c. GmbH
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#include <osmocom/core/conv.h>
+
+extern const uint8_t osmo_conv_gsm0503_xcch_output[][2];
+extern const uint8_t osmo_conv_gsm0503_xcch_state[][2];
+
+/*! \file conv_gen.h
+ * Osmocom convolutional encoder/decoder for xCCH channels, see 3GPP TS 05.03
+ */
+
+/*! \brief structure describing convolutional code xCCH
+ *
+ *  Non-recursive code, flushed, not punctured code.
+ */
+static const struct osmo_conv_code osmo_conv_gsm0503_xcch = {
+	.N = 2,
+	.K = 5,
+	.len = 224,
+	.term = CONV_TERM_FLUSH,
+	.next_output = osmo_conv_gsm0503_xcch_output,
+	.next_state  = osmo_conv_gsm0503_xcch_state,
+};
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index b0ea643..0ab2bd8 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -17,7 +17,7 @@ libgsmint_la_SOURCES =  a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \
 			gsm_utils.c rsl.c gsm48.c gsm48_ie.c gsm0808.c sysinfo.c \
 			gprs_cipher_core.c gsm0480.c abis_nm.c gsm0502.c \
 			gsm0411_utils.c gsm0411_smc.c gsm0411_smr.c \
-			lapd_core.c lapdm.c kasumi.c \
+			lapd_core.c lapdm.c kasumi.c conv_xcch_gen.c \
 			auth_core.c auth_comp128v1.c auth_comp128v23.c \
 			auth_milenage.c milenage/aes-encblock.c \
 			milenage/aes-internal.c milenage/aes-internal-enc.c \
diff --git a/src/gsm/conv_xcch_gen.c b/src/gsm/conv_xcch_gen.c
new file mode 100644
index 0000000..25fa226
--- /dev/null
+++ b/src/gsm/conv_xcch_gen.c
@@ -0,0 +1,69 @@
+
+/*
+ * Copyright (C) 2011-2016 Sylvain Munaut <tnt at 246tNt.com>
+ * Copyright (C) 2016 sysmocom s.f.m.c. GmbH
+ *
+ * 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 3 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>
+
+/*  *CCH convolutional code:
+        228 bits blocks, rate 1/2, k = 5
+        G0 = 1 + D3 + D4
+        G1 = 1 + D + D3 + D4
+ */
+
+/* .next_state */
+const uint8_t osmo_conv_gsm0503_xcch_state[][2] = {
+	{  0,  1 },
+	{  2,  3 },
+	{  4,  5 },
+	{  6,  7 },
+	{  8,  9 },
+	{ 10, 11 },
+	{ 12, 13 },
+	{ 14, 15 },
+	{  0,  1 },
+	{  2,  3 },
+	{  4,  5 },
+	{  6,  7 },
+	{  8,  9 },
+	{ 10, 11 },
+	{ 12, 13 },
+	{ 14, 15 },
+};
+
+/* .next_output */
+const uint8_t osmo_conv_gsm0503_xcch_output[][2] = {
+	{  0,  3 },
+	{  1,  2 },
+	{  0,  3 },
+	{  1,  2 },
+	{  3,  0 },
+	{  2,  1 },
+	{  3,  0 },
+	{  2,  1 },
+	{  3,  0 },
+	{  2,  1 },
+	{  3,  0 },
+	{  2,  1 },
+	{  0,  3 },
+	{  1,  2 },
+	{  0,  3 },
+	{  1,  2 },
+};
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index a3e4e14..53d112e 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -25,6 +25,7 @@ abis_nm_osmo_magic;
 abis_nm_ipa_magic;
 
 osmo_sitype_strs;
+osmo_conv_gsm0503_xcch;
 
 comp128;
 dbm2rxlev;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 03506af..3aaa99b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,7 +47,7 @@ bits_bitcomp_test_SOURCES = bits/bitcomp_test.c
 bits_bitcomp_test_LDADD = $(top_builddir)/src/libosmocore.la
 
 conv_conv_test_SOURCES = conv/conv_test.c
-conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la
+conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libgsmint.la
 
 gsm0808_gsm0808_test_SOURCES = gsm0808/gsm0808_test.c
 gsm0808_gsm0808_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/tests/conv/conv_test.c b/tests/conv/conv_test.c
index de62f23..6e99b2e 100644
--- a/tests/conv/conv_test.c
+++ b/tests/conv/conv_test.c
@@ -6,6 +6,7 @@
 #include <osmocom/core/bits.h>
 #include <osmocom/core/conv.h>
 #include <osmocom/core/utils.h>
+#include <osmocom/gsm/gsm0503.h>
 
 #define MAX_LEN_BITS	512
 #define MAX_LEN_BYTES	(512/8)
@@ -15,31 +16,6 @@
 /* Test codes                                                               */
 /* ------------------------------------------------------------------------ */
 
-/* GSM xCCH -> Non-recursive code, flushed, not punctured */
-static const uint8_t conv_gsm_xcch_next_output[][2] = {
-	{ 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 },
-	{ 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 },
-	{ 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 },
-	{ 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 },
-};
-
-static const uint8_t conv_gsm_xcch_next_state[][2] = {
-	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
-	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
-	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
-	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
-};
-
-static const struct osmo_conv_code conv_gsm_xcch = {
-	.N = 2,
-	.K = 5,
-	.len = 224,
-	.term = CONV_TERM_FLUSH,
-	.next_output = conv_gsm_xcch_next_output,
-	.next_state  = conv_gsm_xcch_next_state,
-};
-
-
 /* GSM TCH/AFS 7.95 -> Recursive code, flushed, with puncturing */
 static const uint8_t conv_gsm_tch_afs_7_95_next_output[][2] = {
 	{ 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 },
@@ -227,8 +203,8 @@ static const struct osmo_conv_code conv_trunc = {
 	.K = 5,
 	.len = 224,
 	.term = CONV_TERM_TRUNCATION,
-	.next_output = conv_gsm_xcch_next_output,
-	.next_state  = conv_gsm_xcch_next_state,
+	.next_output = osmo_conv_gsm0503_xcch_output,
+	.next_state  = osmo_conv_gsm0503_xcch_state,
 };
 
 
@@ -249,7 +225,7 @@ struct conv_test_vector {
 static const struct conv_test_vector tests[] = {
 	{
 		.name = "GSM xCCH (non-recursive, flushed, not punctured)",
-		.code = &conv_gsm_xcch,
+		.code = &osmo_conv_gsm0503_xcch,
 		.in_len  = 224,
 		.out_len = 456,
 		.has_vec = 1,
-- 
2.8.1




More information about the OpenBSC mailing list