lists.osmocom.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
October
September
August
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
List overview
Download
OpenBSC
April 2016
----- 2025 -----
October 2025
September 2025
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
openbsc@lists.osmocom.org
23 participants
111 discussions
Start a n
N
ew thread
[PATCH 1/2] Add concolutional code generator for *CCH
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Move convolutional code for *CCH channels from test to public API because it's useful not only for testing. --- include/Makefile.am | 1 + include/osmocom/core/conv.h | 2 +- include/osmocom/core/conv_gen.h | 46 +++++++++++++++++++++++++++++++ src/Makefile.am | 4 +-- src/conv_xcch_gen.c | 61 +++++++++++++++++++++++++++++++++++++++++ tests/conv/conv_test.c | 31 ++------------------- 6 files changed, 114 insertions(+), 31 deletions(-) create mode 100644 include/osmocom/core/conv_gen.h create mode 100644 src/conv_xcch_gen.c diff --git a/include/Makefile.am b/include/Makefile.am index 0e5ed74..7c10a72 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -9,6 +9,7 @@ nobase_include_HEADERS = \ osmocom/core/bitvec.h \ osmocom/core/bitcomp.h \ osmocom/core/conv.h \ + osmocom/core/conv_gen.h \ osmocom/core/crc16.h \ osmocom/core/crc16gen.h \ osmocom/core/crc32gen.h \ diff --git a/include/osmocom/core/conv.h b/include/osmocom/core/conv.h index e7f6bd6..42807fa 100644 --- a/include/osmocom/core/conv.h +++ b/include/osmocom/core/conv.h @@ -139,5 +139,5 @@ int osmo_conv_decode_get_output(struct osmo_conv_decoder *decoder, int osmo_conv_decode(const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output); - +#include <osmocom/core/conv_gen.h> /*! @} */ diff --git a/include/osmocom/core/conv_gen.h b/include/osmocom/core/conv_gen.h new file mode 100644 index 0000000..e4f1b65 --- /dev/null +++ b/include/osmocom/core/conv_gen.h @@ -0,0 +1,46 @@ +/* + * conv_gen.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 + +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. + * Generator polynomials: + * G0 = 1 + D3 + D4 + * G1 = 1 + D + D3 + D4 + */ +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/Makefile.am b/src/Makefile.am index 45a77e3..2555ff8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,14 +10,14 @@ lib_LTLIBRARIES = libosmocore.la libosmocore_la_LIBADD = $(BACKTRACE_LIB) $(TALLOC_LIBS) libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c bits.c \ bitvec.c bitcomp.c statistics.c \ - write_queue.c utils.c socket.c \ + conv_xcch_gen.c write_queue.c utils.c socket.c \ logging.c logging_syslog.c rate_ctr.c \ gsmtap_util.c crc16.c panic.c backtrace.c \ conv.c application.c rbtree.c strrb.c \ loggingrb.c crc8gen.c crc16gen.c crc32gen.c crc64gen.c \ macaddr.c stat_item.c stats.c stats_statsd.c prim.c -BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c +BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c conv_xcch_gen.c if ENABLE_PLUGIN libosmocore_la_SOURCES += plugin.c diff --git a/src/conv_xcch_gen.c b/src/conv_xcch_gen.c new file mode 100644 index 0000000..b948e7b --- /dev/null +++ b/src/conv_xcch_gen.c @@ -0,0 +1,61 @@ +/* + * conv_xcch_gen.c + * + * 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. + */ + +#include <stdint.h> + +const uint8_t osmo_conv_gsm0503_xcch_output[][2] = { + { 0, 3 }, + { 3, 0 }, + { 3, 0 }, + { 0, 3 }, + { 0, 3 }, + { 3, 0 }, + { 3, 0 }, + { 0, 3 }, + { 1, 2 }, + { 2, 1 }, + { 2, 1 }, + { 1, 2 }, + { 1, 2 }, + { 2, 1 }, + { 2, 1 }, + { 1, 2 }, +}; + +const uint8_t osmo_conv_gsm0503_xcch_state[][2] = { + { 0, 8 }, + { 0, 8 }, + { 1, 9 }, + { 1, 9 }, + { 2, 10 }, + { 2, 10 }, + { 3, 11 }, + { 3, 11 }, + { 4, 12 }, + { 4, 12 }, + { 5, 13 }, + { 5, 13 }, + { 6, 14 }, + { 6, 14 }, + { 7, 15 }, + { 7, 15 }, +}; diff --git a/tests/conv/conv_test.c b/tests/conv/conv_test.c index de62f23..baebdbe 100644 --- a/tests/conv/conv_test.c +++ b/tests/conv/conv_test.c @@ -15,31 +15,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 +202,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 +224,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
9 years, 6 months
2
2
0
0
[PATCH] Fix segfault with broken config
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Fixes OS#1691 --- openbsc/src/libbsc/bsc_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index 859d999..713109c 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -373,6 +373,9 @@ static int bootstrap_bts(struct gsm_bts *bts) { int i, n; + if (!bts->model) + return -EFAULT; + if (bts->model->start && !bts->model->started) { int ret = bts->model->start(bts->network); if (ret < 0) -- 2.8.1
9 years, 6 months
1
0
0
0
[PATCH] NAT: allow allocating BSC in arbitrary order
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Check for existing BSC before allocating new one. Track number of remaining BSCs on deallocation. Explicitly use BSC number in allocation function. --- openbsc/include/openbsc/bsc_nat.h | 3 ++- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 7 +++++-- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 14 ++++---------- openbsc/tests/bsc-nat/bsc_nat_test.c | 14 +++++++------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 7ede1fb..5ccc02e 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -325,7 +325,8 @@ struct bsc_nat_ussd_con { }; /* create and init the structures */ -struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token); +struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, + unsigned int number); struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num); struct bsc_config *bsc_config_by_token(struct bsc_nat *nat, const char *token, int len); void bsc_config_free(struct bsc_config *); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index cc7d442..37b01e3 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -155,14 +155,15 @@ struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat) return con; } -struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token) +struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, + unsigned int number) { struct bsc_config *conf = talloc_zero(nat, struct bsc_config); if (!conf) return NULL; conf->token = talloc_strdup(conf, token); - conf->nr = nat->num_bsc; + conf->nr = number; conf->nat = nat; conf->max_endpoints = 32; conf->paging_group = PAGIN_GROUP_UNASSIGNED; @@ -205,6 +206,8 @@ void bsc_config_free(struct bsc_config *cfg) llist_del(&cfg->entry); rate_ctr_group_free(cfg->stats.ctrg); talloc_free(cfg); + cfg->nat->num_bsc--; + OSMO_ASSERT(cfg->nat->num_bsc >= 0) } static void _add_lac(void *ctx, struct llist_head *list, int _lac) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 26b0fd6..b7b49e6 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -837,17 +837,11 @@ DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "BSC configuration\n" "Identifier of the BSC\n") { int bsc_nr = atoi(argv[0]); - struct bsc_config *bsc; + struct bsc_config *bsc = bsc_config_num(_nat, bsc_nr); - if (bsc_nr > _nat->num_bsc) { - vty_out(vty, "%% The next unused BSC number is %u%s", - _nat->num_bsc, VTY_NEWLINE); - return CMD_WARNING; - } else if (bsc_nr == _nat->num_bsc) { - /* allocate a new one */ - bsc = bsc_config_alloc(_nat, "unknown"); - } else - bsc = bsc_config_num(_nat, bsc_nr); + /* allocate a new one */ + if (!bsc) + bsc = bsc_config_alloc(_nat, "unknown", bsc_nr); if (!bsc) return CMD_WARNING; diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index a4b313c..a405763 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -316,7 +316,7 @@ static void test_contrack() printf("Testing connection tracking.\n"); nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - con->cfg = bsc_config_alloc(nat, "foo"); + con->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(con->cfg, 23); bsc_config_add_lac(con->cfg, 49); bsc_config_add_lac(con->cfg, 42); @@ -434,7 +434,7 @@ static void test_paging(void) nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - cfg = bsc_config_alloc(nat, "unknown"); + cfg = bsc_config_alloc(nat, "unknown", 0); con->cfg = cfg; bsc_config_add_lac(cfg, 23); con->authenticated = 1; @@ -476,7 +476,7 @@ static void test_mgcp_allocations(void) nat->mgcp_cfg->trunk.number_endpoints = 64; bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc->cfg->max_endpoints = 60; bsc_config_add_lac(bsc->cfg, 2323); bsc->last_endpoint = 0x22; @@ -522,7 +522,7 @@ static void test_mgcp_ass_tracking(void) mgcp_endpoints_allocate(&nat->mgcp_cfg->trunk); bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 2323); bsc->last_endpoint = 0x1e; con.bsc = bsc; @@ -874,7 +874,7 @@ static void test_cr_filter() struct bsc_nat *nat = bsc_nat_alloc(); struct bsc_connection *bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 1234); bsc->cfg->acc_lst_name = "bsc"; nat->acc_lst_name = "nat"; @@ -953,7 +953,7 @@ static void test_dt_filter() struct bsc_connection *bsc = bsc_connection_alloc(nat); struct nat_sccp_connection *con = talloc_zero(0, struct nat_sccp_connection); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 23); con->bsc = bsc; @@ -1525,7 +1525,7 @@ static void test_nat_extract_lac() /* initialize the testcase */ nat = bsc_nat_alloc(); bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); memset(&con, 0, sizeof(con)); con.bsc = bsc; -- 2.8.1
9 years, 6 months
1
0
0
0
[PATCH] NAT: allow allocating BSC in arbitrary order
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Check for existing BSC before allocating new one. Track number of remaining BSCs on deallocation. Explicitly use BSC number in allocation function. --- openbsc/include/openbsc/bsc_nat.h | 3 ++- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 9 +++++++-- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 14 ++++---------- openbsc/tests/bsc-nat/bsc_nat_test.c | 14 +++++++------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 7ede1fb..5ccc02e 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -325,7 +325,8 @@ struct bsc_nat_ussd_con { }; /* create and init the structures */ -struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token); +struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, + unsigned int number); struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num); struct bsc_config *bsc_config_by_token(struct bsc_nat *nat, const char *token, int len); void bsc_config_free(struct bsc_config *); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index cc7d442..1bf3266 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -155,14 +155,15 @@ struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat) return con; } -struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token) +struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, + unsigned int number) { struct bsc_config *conf = talloc_zero(nat, struct bsc_config); if (!conf) return NULL; conf->token = talloc_strdup(conf, token); - conf->nr = nat->num_bsc; + conf->nr = number; conf->nat = nat; conf->max_endpoints = 32; conf->paging_group = PAGIN_GROUP_UNASSIGNED; @@ -205,6 +206,10 @@ void bsc_config_free(struct bsc_config *cfg) llist_del(&cfg->entry); rate_ctr_group_free(cfg->stats.ctrg); talloc_free(cfg); + cfg->nat->num_bsc--; + if (cfg->nat->num_bsc < 0) + LOGP(DNAT, LOGL_ERROR, "Internal error while deallocating BSC " + "config: negative BSC index!\n"); } static void _add_lac(void *ctx, struct llist_head *list, int _lac) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 26b0fd6..b7b49e6 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -837,17 +837,11 @@ DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "BSC configuration\n" "Identifier of the BSC\n") { int bsc_nr = atoi(argv[0]); - struct bsc_config *bsc; + struct bsc_config *bsc = bsc_config_num(_nat, bsc_nr); - if (bsc_nr > _nat->num_bsc) { - vty_out(vty, "%% The next unused BSC number is %u%s", - _nat->num_bsc, VTY_NEWLINE); - return CMD_WARNING; - } else if (bsc_nr == _nat->num_bsc) { - /* allocate a new one */ - bsc = bsc_config_alloc(_nat, "unknown"); - } else - bsc = bsc_config_num(_nat, bsc_nr); + /* allocate a new one */ + if (!bsc) + bsc = bsc_config_alloc(_nat, "unknown", bsc_nr); if (!bsc) return CMD_WARNING; diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index a4b313c..a405763 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -316,7 +316,7 @@ static void test_contrack() printf("Testing connection tracking.\n"); nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - con->cfg = bsc_config_alloc(nat, "foo"); + con->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(con->cfg, 23); bsc_config_add_lac(con->cfg, 49); bsc_config_add_lac(con->cfg, 42); @@ -434,7 +434,7 @@ static void test_paging(void) nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - cfg = bsc_config_alloc(nat, "unknown"); + cfg = bsc_config_alloc(nat, "unknown", 0); con->cfg = cfg; bsc_config_add_lac(cfg, 23); con->authenticated = 1; @@ -476,7 +476,7 @@ static void test_mgcp_allocations(void) nat->mgcp_cfg->trunk.number_endpoints = 64; bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc->cfg->max_endpoints = 60; bsc_config_add_lac(bsc->cfg, 2323); bsc->last_endpoint = 0x22; @@ -522,7 +522,7 @@ static void test_mgcp_ass_tracking(void) mgcp_endpoints_allocate(&nat->mgcp_cfg->trunk); bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 2323); bsc->last_endpoint = 0x1e; con.bsc = bsc; @@ -874,7 +874,7 @@ static void test_cr_filter() struct bsc_nat *nat = bsc_nat_alloc(); struct bsc_connection *bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 1234); bsc->cfg->acc_lst_name = "bsc"; nat->acc_lst_name = "nat"; @@ -953,7 +953,7 @@ static void test_dt_filter() struct bsc_connection *bsc = bsc_connection_alloc(nat); struct nat_sccp_connection *con = talloc_zero(0, struct nat_sccp_connection); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 23); con->bsc = bsc; @@ -1525,7 +1525,7 @@ static void test_nat_extract_lac() /* initialize the testcase */ nat = bsc_nat_alloc(); bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); memset(&con, 0, sizeof(con)); con.bsc = bsc; -- 2.8.1
9 years, 6 months
4
4
0
0
[PATCH 1/2] NAT: extend debug output for ipaccess errors
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> --- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index f588e4b..f433324 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1321,8 +1321,8 @@ static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) bsc->cfg ? bsc->cfg->nr : -1); else LOGP(DNAT, LOGL_ERROR, - "Stream error on BSC Nr: %d. Failed to parse ip access message: %d\n", - bsc->cfg ? bsc->cfg->nr : -1, ret); + "Stream error on BSC Nr: %d. Failed to parse ip access message: %d (%s)\n", + bsc->cfg ? bsc->cfg->nr : -1, ret, strerror(-ret)); bsc_close_connection(bsc); return -1; -- 2.8.1
9 years, 6 months
3
4
0
0
[PATCH] NAT: allow allocating BSC in arbitrary order
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Check for existing BSC before allocating new one. Track number of remaining BSCs on deallocation. Explicitly use BSC number in allocation function. --- openbsc/include/openbsc/bsc_nat.h | 3 ++- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 7 +++++-- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 14 ++++---------- openbsc/tests/bsc-nat/bsc_nat_test.c | 14 +++++++------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 7ede1fb..5ccc02e 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -325,7 +325,8 @@ struct bsc_nat_ussd_con { }; /* create and init the structures */ -struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token); +struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, + unsigned int number); struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num); struct bsc_config *bsc_config_by_token(struct bsc_nat *nat, const char *token, int len); void bsc_config_free(struct bsc_config *); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index cc7d442..285f1aa 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -155,14 +155,15 @@ struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat) return con; } -struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token) +struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, + unsigned int number) { struct bsc_config *conf = talloc_zero(nat, struct bsc_config); if (!conf) return NULL; conf->token = talloc_strdup(conf, token); - conf->nr = nat->num_bsc; + conf->nr = number; conf->nat = nat; conf->max_endpoints = 32; conf->paging_group = PAGIN_GROUP_UNASSIGNED; @@ -205,6 +206,8 @@ void bsc_config_free(struct bsc_config *cfg) llist_del(&cfg->entry); rate_ctr_group_free(cfg->stats.ctrg); talloc_free(cfg); + cfg->nat->num_bsc--; + OSMO_ASSERT(num_bsc >= 0) } static void _add_lac(void *ctx, struct llist_head *list, int _lac) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 26b0fd6..b7b49e6 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -837,17 +837,11 @@ DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", "BSC configuration\n" "Identifier of the BSC\n") { int bsc_nr = atoi(argv[0]); - struct bsc_config *bsc; + struct bsc_config *bsc = bsc_config_num(_nat, bsc_nr); - if (bsc_nr > _nat->num_bsc) { - vty_out(vty, "%% The next unused BSC number is %u%s", - _nat->num_bsc, VTY_NEWLINE); - return CMD_WARNING; - } else if (bsc_nr == _nat->num_bsc) { - /* allocate a new one */ - bsc = bsc_config_alloc(_nat, "unknown"); - } else - bsc = bsc_config_num(_nat, bsc_nr); + /* allocate a new one */ + if (!bsc) + bsc = bsc_config_alloc(_nat, "unknown", bsc_nr); if (!bsc) return CMD_WARNING; diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index a4b313c..a405763 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -316,7 +316,7 @@ static void test_contrack() printf("Testing connection tracking.\n"); nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - con->cfg = bsc_config_alloc(nat, "foo"); + con->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(con->cfg, 23); bsc_config_add_lac(con->cfg, 49); bsc_config_add_lac(con->cfg, 42); @@ -434,7 +434,7 @@ static void test_paging(void) nat = bsc_nat_alloc(); con = bsc_connection_alloc(nat); - cfg = bsc_config_alloc(nat, "unknown"); + cfg = bsc_config_alloc(nat, "unknown", 0); con->cfg = cfg; bsc_config_add_lac(cfg, 23); con->authenticated = 1; @@ -476,7 +476,7 @@ static void test_mgcp_allocations(void) nat->mgcp_cfg->trunk.number_endpoints = 64; bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc->cfg->max_endpoints = 60; bsc_config_add_lac(bsc->cfg, 2323); bsc->last_endpoint = 0x22; @@ -522,7 +522,7 @@ static void test_mgcp_ass_tracking(void) mgcp_endpoints_allocate(&nat->mgcp_cfg->trunk); bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 2323); bsc->last_endpoint = 0x1e; con.bsc = bsc; @@ -874,7 +874,7 @@ static void test_cr_filter() struct bsc_nat *nat = bsc_nat_alloc(); struct bsc_connection *bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 1234); bsc->cfg->acc_lst_name = "bsc"; nat->acc_lst_name = "nat"; @@ -953,7 +953,7 @@ static void test_dt_filter() struct bsc_connection *bsc = bsc_connection_alloc(nat); struct nat_sccp_connection *con = talloc_zero(0, struct nat_sccp_connection); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); bsc_config_add_lac(bsc->cfg, 23); con->bsc = bsc; @@ -1525,7 +1525,7 @@ static void test_nat_extract_lac() /* initialize the testcase */ nat = bsc_nat_alloc(); bsc = bsc_connection_alloc(nat); - bsc->cfg = bsc_config_alloc(nat, "foo"); + bsc->cfg = bsc_config_alloc(nat, "foo", 0); memset(&con, 0, sizeof(con)); con.bsc = bsc; -- 2.8.1
9 years, 6 months
1
0
0
0
[PATCH] Remove trivial wrapper function
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Rename gsm48_tx_chan_mode_modify() to gsm48_lchan_modify() and remove corresponding wrapper code. --- openbsc/src/libbsc/gsm_04_08_utils.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 8c6dbef..635665a 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -463,7 +463,7 @@ int gsm48_send_rr_ass_cmd(struct gsm_lchan *dest_lchan, struct gsm_lchan *lchan, /* * fill the channel information element, this code * should probably be shared with rsl_rx_chan_rqd(), - * gsm48_tx_chan_mode_modify. But beware that 10.5.2.5 + * gsm48_lchan_modify(). But beware that 10.5.2.5 * 10.5.2.5.a have slightly different semantic for * the chan_desc. But as long as multi-slot configurations * are not used we seem to be fine. @@ -488,7 +488,7 @@ int gsm48_send_rr_ass_cmd(struct gsm_lchan *dest_lchan, struct gsm_lchan *lchan, } /* 9.1.5 Channel mode modify: Modify the mode on the MS side */ -int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, uint8_t mode) +int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t mode) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 CHN MOD"); struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); @@ -513,17 +513,6 @@ int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, uint8_t mode) return gsm48_sendmsg(msg); } -int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode) -{ - int rc; - - rc = gsm48_tx_chan_mode_modify(lchan, lchan_mode); - if (rc < 0) - return rc; - - return rc; -} - int gsm48_rx_rr_modif_ack(struct msgb *msg) { int rc; -- 2.8.1
9 years, 6 months
1
0
0
0
[PATCH] Add missing docs for bssgp bvc reset vty command
by msuraev@sysmocom.de
From: Max <msuraev(a)sysmocom.de> Fixes the build failure with extended tests enabled. --- src/gb/gprs_bssgp_vty.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index a3af69b..f23d75f 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -115,8 +115,14 @@ static void dump_bssgp(struct vty *vty, int stats) } DEFUN(bvc_reset, bvc_reset_cmd, - "bssgp bvc nsei <0-65535> bvci <0-65535> reset", - "Initiate BVC RESET procedure for a given NSEI and BVCI\n") + "bssgp bvc nsei <0-65535> bvci <0-65535> reset", + "Initiate BVC RESET procedure for a given NSEI and BVCI\n" + "Filter based on BSSGP Virtual Connection\n" + "NSEI of the BVC to be filtered\n" + "Network Service Entity Identifier (NSEI)\n" + "BVCI of the BVC to be filtered\n" + "BSSGP Virtual Connection Identifier (BVCI)\n" + "Perform reset procedure\n") { int r; uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]); -- 2.8.1
9 years, 6 months
1
0
0
0
[PATCH] ctrl: Extend ctrl command to optionally handle alg+ki
by Holger Hans Peter Freyther
From: Holger Hans Peter Freyther <holger(a)moiji-mobile.com> Extend the existing ctrl command to be able to specify the algorithm and Ki. In contrast to the VTY no size check is done. Together with the VTY this code only supports a small part of what is supported by libosmocore. The algorithm and ki are considered optional but if a valid and non none algorithm is passed, a KI must be passed as well. Extend the test coverage by passing the potential values. It is not verified that the KI/algorithm is stored. --- openbsc/src/libmsc/ctrl_commands.c | 59 ++++++++++++++++++++++++++++++++++++-- openbsc/tests/ctrl_test_runner.py | 27 +++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c index e48c6a3..566240c 100644 --- a/openbsc/src/libmsc/ctrl_commands.c +++ b/openbsc/src/libmsc/ctrl_commands.c @@ -24,9 +24,25 @@ #include <openbsc/db.h> #include <openbsc/debug.h> +static bool alg_supported(const char *alg) +{ + /* + * TODO: share this with the vty_interface and extend to all + * algorithms supported by libosmocore now. Make it table based + * as well. + */ + if (strcasecmp(alg, "none") == 0) + return true; + if (strcasecmp(alg, "xor") == 0) + return true; + if (strcasecmp(alg, "comp128v1") == 0) + return true; + return false; +} + static int verify_subscriber_modify(struct ctrl_cmd *cmd, const char *value, void *d) { - char *tmp, *imsi, *msisdn, *saveptr = NULL; + char *tmp, *imsi, *msisdn, *alg, *ki, *saveptr = NULL; int rc = 0; tmp = talloc_strdup(cmd, value); @@ -35,6 +51,8 @@ static int verify_subscriber_modify(struct ctrl_cmd *cmd, const char *value, voi imsi = strtok_r(tmp, ",", &saveptr); msisdn = strtok_r(NULL, ",", &saveptr); + alg = strtok_r(NULL, ",", &saveptr); + ki = strtok_r(NULL, ",", &saveptr); if (!imsi || !msisdn) rc = 1; @@ -42,6 +60,12 @@ static int verify_subscriber_modify(struct ctrl_cmd *cmd, const char *value, voi rc = 1; else if (strlen(msisdn) >= GSM_EXTENSION_LENGTH) rc = 1; + else if (alg) { + if (!alg_supported(alg)) + rc = 1; + else if (strcasecmp(alg, "none") != 0 && !ki) + rc = 1; + } talloc_free(tmp); return rc; @@ -56,7 +80,7 @@ static int get_subscriber_modify(struct ctrl_cmd *cmd, void *data) static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data) { struct gsm_network *net = cmd->node; - char *tmp, *imsi, *msisdn, *saveptr = NULL; + char *tmp, *imsi, *msisdn, *alg, *ki, *saveptr = NULL; struct gsm_subscriber* subscr; int rc; @@ -66,6 +90,8 @@ static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data) imsi = strtok_r(tmp, ",", &saveptr); msisdn = strtok_r(NULL, ",", &saveptr); + alg = strtok_r(NULL, ",", &saveptr); + ki = strtok_r(NULL, ",", &saveptr); subscr = subscr_get_by_imsi(net->subscr_group, imsi); if (!subscr) @@ -80,6 +106,35 @@ static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data) /* put it back to the db */ rc = db_sync_subscriber(subscr); db_subscriber_update(subscr); + + /* handle optional ciphering */ + if (!alg || strcasecmp(alg, "none") == 0) + db_sync_authinfo_for_subscr(NULL, subscr); + else { + struct gsm_auth_info ainfo = { 0, }; + /* the verify should make sure that this is okay */ + OSMO_ASSERT(alg); + OSMO_ASSERT(ki); + + if (strcasecmp(alg, "xor") == 0) + ainfo.auth_algo = AUTH_ALGO_XOR; + else if (strcasecmp(alg, "comp128v1") == 0) + ainfo.auth_algo = AUTH_ALGO_COMP128v1; + + rc = osmo_hexparse(ki, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki)); + if (rc < 0) { + subscr_put(subscr); + talloc_free(tmp); + cmd->reply = "Failed to parse KI"; + return CTRL_CMD_ERROR; + } + + ainfo.a3a8_ki_len = rc; + db_sync_authinfo_for_subscr(&ainfo, subscr); + rc = 0; + } + + db_sync_lastauthtuple_for_subscr(NULL, subscr); subscr_put(subscr); talloc_free(tmp); diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 21850e3..7a12643 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -469,6 +469,33 @@ class TestCtrlNITB(TestCtrlBase): self.assertEquals(r['var'], 'number-of-bts') self.assertEquals(r['value'], '1') + def testSubscriberAddWithKi(self): + """Test that we can set the algorithm to none, xor, comp128v1""" + + r = self.do_set('subscriber-modify-v1', '2620345,445566') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,none') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,xor') + self.assertEquals(r['mtype'], 'ERROR') + self.assertEquals(r['error'], 'Value failed verification.') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,comp128v1,00112233445566778899AABBCCDDEEFF') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,none') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + def testSubscriberAddRemove(self): r = self.do_set('subscriber-modify-v1', '2620345,445566') self.assertEquals(r['mtype'], 'SET_REPLY') -- 2.6.3
9 years, 6 months
3
2
0
0
[PATCH v2] ctrl: Extend ctrl command to optionally handle alg+ki
by Holger Hans Peter Freyther
From: Holger Hans Peter Freyther <holger(a)moiji-mobile.com> Extend the existing ctrl command to be able to specify the algorithm and Ki. In contrast to the VTY no size check is done. Together with the VTY this code only supports a small part of what is supported by libosmocore. The algorithm and ki are considered optional but if a valid and non none algorithm is passed, a KI must be passed as well. Extend the test coverage by passing the potential values. It is not verified that the KI/algorithm is stored. --- openbsc/src/libmsc/ctrl_commands.c | 60 ++++++++++++++++++++++++++++++++++++-- openbsc/tests/ctrl_test_runner.py | 27 +++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c index e48c6a3..9ac39de 100644 --- a/openbsc/src/libmsc/ctrl_commands.c +++ b/openbsc/src/libmsc/ctrl_commands.c @@ -24,9 +24,25 @@ #include <openbsc/db.h> #include <openbsc/debug.h> +static bool alg_supported(const char *alg) +{ + /* + * TODO: share this with the vty_interface and extend to all + * algorithms supported by libosmocore now. Make it table based + * as well. + */ + if (strcasecmp(alg, "none") == 0) + return true; + if (strcasecmp(alg, "xor") == 0) + return true; + if (strcasecmp(alg, "comp128v1") == 0) + return true; + return false; +} + static int verify_subscriber_modify(struct ctrl_cmd *cmd, const char *value, void *d) { - char *tmp, *imsi, *msisdn, *saveptr = NULL; + char *tmp, *imsi, *msisdn, *alg, *ki, *saveptr = NULL; int rc = 0; tmp = talloc_strdup(cmd, value); @@ -35,6 +51,8 @@ static int verify_subscriber_modify(struct ctrl_cmd *cmd, const char *value, voi imsi = strtok_r(tmp, ",", &saveptr); msisdn = strtok_r(NULL, ",", &saveptr); + alg = strtok_r(NULL, ",", &saveptr); + ki = strtok_r(NULL, ",", &saveptr); if (!imsi || !msisdn) rc = 1; @@ -42,6 +60,12 @@ static int verify_subscriber_modify(struct ctrl_cmd *cmd, const char *value, voi rc = 1; else if (strlen(msisdn) >= GSM_EXTENSION_LENGTH) rc = 1; + else if (alg) { + if (!alg_supported(alg)) + rc = 1; + else if (strcasecmp(alg, "none") != 0 && !ki) + rc = 1; + } talloc_free(tmp); return rc; @@ -56,7 +80,7 @@ static int get_subscriber_modify(struct ctrl_cmd *cmd, void *data) static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data) { struct gsm_network *net = cmd->node; - char *tmp, *imsi, *msisdn, *saveptr = NULL; + char *tmp, *imsi, *msisdn, *alg, *ki, *saveptr = NULL; struct gsm_subscriber* subscr; int rc; @@ -66,6 +90,8 @@ static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data) imsi = strtok_r(tmp, ",", &saveptr); msisdn = strtok_r(NULL, ",", &saveptr); + alg = strtok_r(NULL, ",", &saveptr); + ki = strtok_r(NULL, ",", &saveptr); subscr = subscr_get_by_imsi(net->subscr_group, imsi); if (!subscr) @@ -80,6 +106,36 @@ static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data) /* put it back to the db */ rc = db_sync_subscriber(subscr); db_subscriber_update(subscr); + + /* handle optional ciphering */ + if (alg) { + if (strcasecmp(alg, "none") == 0) + db_sync_authinfo_for_subscr(NULL, subscr); + else { + struct gsm_auth_info ainfo = { 0, }; + /* the verify should make sure that this is okay */ + OSMO_ASSERT(alg); + OSMO_ASSERT(ki); + + if (strcasecmp(alg, "xor") == 0) + ainfo.auth_algo = AUTH_ALGO_XOR; + else if (strcasecmp(alg, "comp128v1") == 0) + ainfo.auth_algo = AUTH_ALGO_COMP128v1; + + rc = osmo_hexparse(ki, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki)); + if (rc < 0) { + subscr_put(subscr); + talloc_free(tmp); + cmd->reply = "Failed to parse KI"; + return CTRL_CMD_ERROR; + } + + ainfo.a3a8_ki_len = rc; + db_sync_authinfo_for_subscr(&ainfo, subscr); + rc = 0; + } + db_sync_lastauthtuple_for_subscr(NULL, subscr); + } subscr_put(subscr); talloc_free(tmp); diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 21850e3..7a12643 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -469,6 +469,33 @@ class TestCtrlNITB(TestCtrlBase): self.assertEquals(r['var'], 'number-of-bts') self.assertEquals(r['value'], '1') + def testSubscriberAddWithKi(self): + """Test that we can set the algorithm to none, xor, comp128v1""" + + r = self.do_set('subscriber-modify-v1', '2620345,445566') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,none') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,xor') + self.assertEquals(r['mtype'], 'ERROR') + self.assertEquals(r['error'], 'Value failed verification.') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,comp128v1,00112233445566778899AABBCCDDEEFF') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + + r = self.do_set('subscriber-modify-v1', '2620345,445566,none') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'subscriber-modify-v1') + self.assertEquals(r['value'], 'OK') + def testSubscriberAddRemove(self): r = self.do_set('subscriber-modify-v1', '2620345,445566') self.assertEquals(r['mtype'], 'SET_REPLY') -- 2.6.3
9 years, 6 months
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
Results per page:
10
25
50
100
200