From: Max <msuraev(a)sysmocom.de>
---
include/osmocom/gsm/gsm0503.h | 5 +
src/gsm/Makefile.am | 1 +
src/gsm/conv_cs2_gen.c | 211 +++++++++++++++++++++++++++++
src/gsm/conv_cs3_gen.c | 299 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 516 insertions(+)
create mode 100644 src/gsm/conv_cs2_gen.c
create mode 100644 src/gsm/conv_cs3_gen.c
diff --git a/include/osmocom/gsm/gsm0503.h b/include/osmocom/gsm/gsm0503.h
index 46d86ad..764e2d1 100644
--- a/include/osmocom/gsm/gsm0503.h
+++ b/include/osmocom/gsm/gsm0503.h
@@ -35,3 +35,8 @@
* Non-recursive code, flushed, not punctured code.
*/
extern const struct osmo_conv_code osmo_conv_gsm0503_xcch;
+
+/*! \brief structures describing convolutional codes CS2/3
+ */
+extern const struct osmo_conv_code osmo_conv_gsm0503_cs2;
+extern const struct osmo_conv_code osmo_conv_gsm0503_cs3;
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 0ab2bd8..53d16b3 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -18,6 +18,7 @@ libgsmint_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c
comp128v23.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 conv_xcch_gen.c \
+ conv_cs2_gen.c conv_cs3_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_cs2_gen.c b/src/gsm/conv_cs2_gen.c
new file mode 100644
index 0000000..1ecca96
--- /dev/null
+++ b/src/gsm/conv_cs2_gen.c
@@ -0,0 +1,211 @@
+
+/*
+ * Copyright (C) 2011-2016 Sylvain Munaut <tnt(a)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>
+#include <osmocom/core/conv.h>
+
+static const uint8_t osmo_conv_gsm0503_cs2_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 uint8_t osmo_conv_gsm0503_cs2_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 int osmo_conv_gsm0503_cs2_puncture[] = {
+ 15,
+ 19,
+ 23,
+ 27,
+ 31,
+ 35,
+ 43,
+ 47,
+ 51,
+ 55,
+ 59,
+ 63,
+ 67,
+ 71,
+ 75,
+ 79,
+ 83,
+ 91,
+ 95,
+ 99,
+ 103,
+ 107,
+ 111,
+ 115,
+ 119,
+ 123,
+ 127,
+ 131,
+ 139,
+ 143,
+ 147,
+ 151,
+ 155,
+ 159,
+ 163,
+ 167,
+ 171,
+ 175,
+ 179,
+ 187,
+ 191,
+ 195,
+ 199,
+ 203,
+ 207,
+ 211,
+ 215,
+ 219,
+ 223,
+ 227,
+ 235,
+ 239,
+ 243,
+ 247,
+ 251,
+ 255,
+ 259,
+ 263,
+ 267,
+ 271,
+ 275,
+ 283,
+ 287,
+ 291,
+ 295,
+ 299,
+ 303,
+ 307,
+ 311,
+ 315,
+ 319,
+ 323,
+ 331,
+ 335,
+ 339,
+ 343,
+ 347,
+ 351,
+ 355,
+ 359,
+ 363,
+ 367,
+ 371,
+ 379,
+ 383,
+ 387,
+ 391,
+ 395,
+ 399,
+ 403,
+ 407,
+ 411,
+ 415,
+ 419,
+ 427,
+ 431,
+ 435,
+ 439,
+ 443,
+ 447,
+ 451,
+ 455,
+ 459,
+ 463,
+ 467,
+ 475,
+ 479,
+ 483,
+ 487,
+ 491,
+ 495,
+ 499,
+ 503,
+ 507,
+ 511,
+ 515,
+ 523,
+ 527,
+ 531,
+ 535,
+ 539,
+ 543,
+ 547,
+ 551,
+ 555,
+ 559,
+ 563,
+ 571,
+ 575,
+ 579,
+ 583,
+ 587,
+ -1,
+};
+
+/* CS2 convolutional code:
+ G0 = 1 + D3 + D4
+ G1 = 1 + D + D3 + D4
+ */
+const struct osmo_conv_code osmo_conv_gsm0503_cs2 = {
+ .N = 2,
+ .K = 5,
+ .len = 290,
+ .next_output = osmo_conv_gsm0503_cs2_output,
+ .next_state = osmo_conv_gsm0503_cs2_state,
+ .puncture = osmo_conv_gsm0503_cs2_puncture,
+};
diff --git a/src/gsm/conv_cs3_gen.c b/src/gsm/conv_cs3_gen.c
new file mode 100644
index 0000000..550452a
--- /dev/null
+++ b/src/gsm/conv_cs3_gen.c
@@ -0,0 +1,299 @@
+
+/*
+ * Copyright (C) 2011-2016 Sylvain Munaut <tnt(a)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>
+#include <osmocom/core/conv.h>
+
+static const uint8_t osmo_conv_gsm0503_cs3_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 uint8_t osmo_conv_gsm0503_cs3_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 int osmo_conv_gsm0503_cs3_puncture[] = {
+ 15,
+ 17,
+ 21,
+ 23,
+ 27,
+ 29,
+ 33,
+ 35,
+ 39,
+ 41,
+ 45,
+ 47,
+ 51,
+ 53,
+ 57,
+ 59,
+ 63,
+ 65,
+ 69,
+ 71,
+ 75,
+ 77,
+ 81,
+ 83,
+ 87,
+ 89,
+ 93,
+ 95,
+ 99,
+ 101,
+ 105,
+ 107,
+ 111,
+ 113,
+ 117,
+ 119,
+ 123,
+ 125,
+ 129,
+ 131,
+ 135,
+ 137,
+ 141,
+ 143,
+ 147,
+ 149,
+ 153,
+ 155,
+ 159,
+ 161,
+ 165,
+ 167,
+ 171,
+ 173,
+ 177,
+ 179,
+ 183,
+ 185,
+ 189,
+ 191,
+ 195,
+ 197,
+ 201,
+ 203,
+ 207,
+ 209,
+ 213,
+ 215,
+ 219,
+ 221,
+ 225,
+ 227,
+ 231,
+ 233,
+ 237,
+ 239,
+ 243,
+ 245,
+ 249,
+ 251,
+ 255,
+ 257,
+ 261,
+ 263,
+ 267,
+ 269,
+ 273,
+ 275,
+ 279,
+ 281,
+ 285,
+ 287,
+ 291,
+ 293,
+ 297,
+ 299,
+ 303,
+ 305,
+ 309,
+ 311,
+ 315,
+ 317,
+ 321,
+ 323,
+ 327,
+ 329,
+ 333,
+ 335,
+ 339,
+ 341,
+ 345,
+ 347,
+ 351,
+ 353,
+ 357,
+ 359,
+ 363,
+ 365,
+ 369,
+ 371,
+ 375,
+ 377,
+ 381,
+ 383,
+ 387,
+ 389,
+ 393,
+ 395,
+ 399,
+ 401,
+ 405,
+ 407,
+ 411,
+ 413,
+ 417,
+ 419,
+ 423,
+ 425,
+ 429,
+ 431,
+ 435,
+ 437,
+ 441,
+ 443,
+ 447,
+ 449,
+ 453,
+ 455,
+ 459,
+ 461,
+ 465,
+ 467,
+ 471,
+ 473,
+ 477,
+ 479,
+ 483,
+ 485,
+ 489,
+ 491,
+ 495,
+ 497,
+ 501,
+ 503,
+ 507,
+ 509,
+ 513,
+ 515,
+ 519,
+ 521,
+ 525,
+ 527,
+ 531,
+ 533,
+ 537,
+ 539,
+ 543,
+ 545,
+ 549,
+ 551,
+ 555,
+ 557,
+ 561,
+ 563,
+ 567,
+ 569,
+ 573,
+ 575,
+ 579,
+ 581,
+ 585,
+ 587,
+ 591,
+ 593,
+ 597,
+ 599,
+ 603,
+ 605,
+ 609,
+ 611,
+ 615,
+ 617,
+ 621,
+ 623,
+ 627,
+ 629,
+ 633,
+ 635,
+ 639,
+ 641,
+ 645,
+ 647,
+ 651,
+ 653,
+ 657,
+ 659,
+ 663,
+ 665,
+ 669,
+ 671,
+ -1,
+};
+
+/* CS3 convolutional code:
+ G0 = 1 + D3 + D4
+ G1 = 1 + D + D3 + D4
+ */
+const struct osmo_conv_code osmo_conv_gsm0503_cs3 = {
+ .N = 2,
+ .K = 5,
+ .len = 334,
+ .next_output = osmo_conv_gsm0503_cs3_output,
+ .next_state = osmo_conv_gsm0503_cs3_state,
+ .puncture = osmo_conv_gsm0503_cs3_puncture,
+};
--
2.5.0