From gerrit-no-reply at lists.osmocom.org Wed Feb 1 02:50:52 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 02:50:52 +0000 Subject: openbsc[master]: vty tests: attempt to get at sporadic 'Broken Pipe' error In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 this patch doesn't seem to have the desired effect of catching the Broken Pipe exception ... so we should still tweak it? -- To view, visit https://gerrit.osmocom.org/1693 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 02:52:48 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 02:52:48 +0000 Subject: osmo-iuh[master]: cs RAB: add nAS_SynchronisationIndicator In-Reply-To: References: Message-ID: Patch Set 1: I have no idea really; I saw it in a real-world 3G voice trace, and there was a "fixme" comment in the code to add it... I added it in an attempt to fix the nano3G, but it had no effect. Now it's there so we might as well keep it to be more like the real-world trace. -- To view, visit https://gerrit.osmocom.org/1642 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 Gerrit-PatchSet: 1 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 02:53:40 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 02:53:40 +0000 Subject: osmo-iuh[master]: cs RAB: tweak sDU_ErrorRatio In-Reply-To: References: Message-ID: Patch Set 1: same as #1642 ... I should add such info to the log message, as Max has already pointed out -- To view, visit https://gerrit.osmocom.org/1644 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3169376bb182aba5926b7c974108bdc5fba04fa4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 02:56:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 02:56:13 +0000 Subject: openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: my impression was that we use everywhere... -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:10:59 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:10:59 +0000 Subject: openbsc[master]: add struct bsc_sub, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 4: (5 comments) I'm trying to factor this out from the VLR branch to start submitting while still focusing mostly on the VLR branch HEAD; in effect, this is still immature. Thanks for reviewing to pinpoint those immaturities. https://gerrit.osmocom.org/#/c/1682/4/openbsc/src/libbsc/bsc_subscriber.c File openbsc/src/libbsc/bsc_subscriber.c: Line 113: else in case of TMSI == GSM_RESERVED_TMSI, could print "unknown" instead, here. https://gerrit.osmocom.org/#/c/1682/4/openbsc/src/libbsc/bsc_vty.c File openbsc/src/libbsc/bsc_vty.c: Line 1024: vty_out(vty, " Use count: %d%s", bsub->use_count, VTY_NEWLINE); > ->name has some overlap.. shall we have tmsi != GSM_RESERVED_TMSI.. in the in principle yes, but what else can we print if neither IMSI nor TMSI are available? I think my decision was to then print GSM_RESERVED_TMSI... could also print "(unknown)" instead. https://gerrit.osmocom.org/#/c/1682/4/openbsc/src/libbsc/paging.c File openbsc/src/libbsc/paging.c: Line 80 > no replacement for this? I'm trying to push this away, see also https://gerrit.osmocom.org/#/c/1685/ Your opinion on #1685 would be much appreciated... I dimly remember that you said the IMSI filter didn't work so well anyway. True? https://gerrit.osmocom.org/#/c/1682/4/openbsc/src/libcommon-cs/common_cs.c File openbsc/src/libcommon-cs/common_cs.c: Line 73: net->bsc_subscribers = talloc_zero(net, struct llist_head); > only done to have a talloc context? for talloc yes, also thinking of a case in the OsmoCSCN where there are no bsc_subscribers ... so then the llist would be NULL altogether to indicate absence of libbsc. (hmm, did I add the null checks for that?) https://gerrit.osmocom.org/#/c/1682/4/openbsc/src/libmsc/gsm_subscriber.c File openbsc/src/libmsc/gsm_subscriber.c: Line 97: bsub = bsc_sub_have_by_imsi(conn->network->bsc_subscribers, subscr->imsi); (no bsc_subscribers NULL check here, or anywhere, really) -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:17:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:17:07 +0000 Subject: openbsc[master]: log: disable imsi filter In-Reply-To: References: Message-ID: Patch Set 3: The FSM logging isn't really an apt replacement for the IMSI filter. I'm still thinking about this ... how to achieve IMSI log filtering with two (three?) kinds of {bsc,vlr,gprs}_subscriber structs? I had one idea where we set a log level on a vlr_subscriber and provide a LOG_VSUB(vsub, subsys, level, ...) that we try to use everywhere where a subscriber is involved. That would mean to edit most of the logging lines we have though. The previous filter concept of setting a context for each select() seems niftier. But does it work well? -- To view, visit https://gerrit.osmocom.org/1685 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifecc3c55ae7c050ee53553d6f85d9afbede66ee3 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:18:40 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:18:40 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: common/port_numbers: add osmo-hlr VTY port 4258 In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: common/port_numbers: add osmo-hlr VTY port 4258 ...................................................................... common/port_numbers: add osmo-hlr VTY port 4258 Change-Id: Ibf66a7c31d1b48b002c25bb55784c99f54dad3a0 --- M common/chapters/port_numbers.adoc 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/common/chapters/port_numbers.adoc b/common/chapters/port_numbers.adoc index d59b3c5..bb1ad78 100644 --- a/common/chapters/port_numbers.adoc +++ b/common/chapters/port_numbers.adoc @@ -31,6 +31,7 @@ |TCP|4255|Control Interface|osmo-cscn |TCP|4256|telnet (VTY)|osmo-sip-connector |TCP|4257|Control Interface|ggsn (OpenGGSN) +|TCP|4258|telnet (VTY)|osmo-hlr |UDP|4729|GSMTAP|Almost every osmocom project |TCP|5000|A/IP|osmo-bsc, osmo-bsc_nat |UDP|2427|GSMTAP|osmo-pcu, osmo-bts -- To view, visit https://gerrit.osmocom.org/1703 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibf66a7c31d1b48b002c25bb55784c99f54dad3a0 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:18:48 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:18:48 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: common/port_numbers: place comment to remind of syncing port... In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: common/port_numbers: place comment to remind of syncing ports lists ...................................................................... common/port_numbers: place comment to remind of syncing ports lists Change-Id: Ib99271bfb435ef59fcfc0a2ac198d26770199344 --- M common/chapters/port_numbers.adoc 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/common/chapters/port_numbers.adoc b/common/chapters/port_numbers.adoc index bb1ad78..f70462c 100644 --- a/common/chapters/port_numbers.adoc +++ b/common/chapters/port_numbers.adoc @@ -37,3 +37,9 @@ |UDP|2427|GSMTAP|osmo-pcu, osmo-bts |UDP|23000|GPRS-NS over IP default port|osmo-pcu, osmo-sgsn, osmo-gbproxy |=============== +//// +ATTENTION: Keep this list in sync with all of: +https://osmocom.org/projects/cellular-infrastructure/wiki/PortNumbers +https://git.osmocom.org/libosmocore/tree/include/osmocom/vty/ports.h +https://git.osmocom.org/libosmocore/tree/include/osmocom/ctrl/ports.h +//// -- To view, visit https://gerrit.osmocom.org/1704 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib99271bfb435ef59fcfc0a2ac198d26770199344 Gerrit-PatchSet: 2 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:25:00 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:25:00 +0000 Subject: osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) https://gerrit.osmocom.org/#/c/1706/2/src/hlr.c File src/hlr.c: Line 23: #define _GNU_SOURCE > You don't get a compiler warning here? copied it from bsc_hack.c, no idea why it is there :P But no, I don't get a warning there, nor in bsc_hack.c. -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:26:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:26:47 +0000 Subject: osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) https://gerrit.osmocom.org/#/c/1706/2/src/hlr.c File src/hlr.c: Line 23: #define _GNU_SOURCE > copied it from bsc_hack.c, no idea why it is there :P seems to work well for me without it; is this needed for FreeBSD, maybe? I'd be fine with dropping it until problems show up. -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:44:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:44:56 +0000 Subject: [PATCH] osmo-hlr[master]: main: add and use root talloc ctx In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1705 to look at the new patch set (#2). main: add and use root talloc ctx Create hlr_ctx and pass on to DB and GSUP server code. Add call msgb_talloc_ctx_init(hlr_ctx). Instead of printing the entire talloc context on exit, just print the hlr_ctx upon SIGUSR1 (like our other binaries do). Otherwise we will get pages of talloc output on each program exit as soon as we add a VTY (next patch). Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4 --- M src/hlr.c 1 file changed, 7 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/05/1705/2 diff --git a/src/hlr.c b/src/hlr.c index 674a58b..bf0655e 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -516,6 +516,7 @@ return 0; } +static void *hlr_ctx = NULL; static struct osmo_gsup_server *gs; static void signal_hdlr(int signal) @@ -526,11 +527,12 @@ osmo_gsup_server_destroy(gs); db_close(g_dbc); log_fini(); + talloc_report_full(hlr_ctx, stderr); exit(0); break; case SIGUSR1: LOGP(DMAIN, LOGL_DEBUG, "Talloc Report due to SIGUSR1\n"); - talloc_report_full(NULL, stderr); + talloc_report_full(hlr_ctx, stderr); break; } } @@ -539,7 +541,8 @@ { int rc; - talloc_enable_leak_report_full(); + hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); + msgb_talloc_ctx_init(hlr_ctx, 0); rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { @@ -554,13 +557,13 @@ exit(1); } - g_dbc = db_open(NULL, "hlr.db"); + g_dbc = db_open(hlr_ctx, "hlr.db"); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); } - gs = osmo_gsup_server_create(NULL, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); -- To view, visit https://gerrit.osmocom.org/1705 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:44:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:44:56 +0000 Subject: [PATCH] osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1706 to look at the new patch set (#3). main: add option parsing with db file and default options Parse commandline options, supporting general Osmocom options as copied from osmo-nitb (bsc_hack.c): version, logging and daemonize options. Set the HLR database file from cmdline option, log the filename in db_open(). (VTY config file in next patch.) Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 --- M src/db.c M src/hlr.c 2 files changed, 91 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/1706/3 diff --git a/src/db.c b/src/db.c index 9d4e99e..1385502 100644 --- a/src/db.c +++ b/src/db.c @@ -75,6 +75,7 @@ unsigned int i; int rc; + LOGP(DDB, LOGL_NOTICE, "using database: %s\n", fname); LOGP(DDB, LOGL_INFO, "Compiled against SQLite3 lib version %s\n", SQLITE_VERSION); LOGP(DDB, LOGL_INFO, "Running with SQLite3 lib version %s\n", sqlite3_libversion()); diff --git a/src/hlr.c b/src/hlr.c index bf0655e..04ca0a6 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -20,6 +20,9 @@ #include #include +#define _GNU_SOURCE +#include + #include #include #include @@ -516,6 +519,82 @@ return 0; } +static void print_usage() +{ + printf("Usage: osmo-hlr\n"); +} + +static void print_help() +{ + printf(" -h --help This text.\n"); + printf(" -l --database db-name The database to use.\n"); + printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); + printf(" -D --daemonize Fork the process into a background daemon.\n"); + printf(" -s --disable-color Do not print ANSI colors in the log\n"); + printf(" -T --timestamp Prefix every log line with a timestamp.\n"); + printf(" -e --log-level number Set a global loglevel.\n"); +} + +struct { + const char *db_file; + bool daemonize; +} cmdline_opts = { + .db_file = "hlr.db", + .daemonize = false, +}; + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"database", 1, 0, 'l'}, + {"debug", 1, 0, 'd'}, + {"daemonize", 0, 0, 'D'}, + {"disable-color", 0, 0, 's'}, + {"log-level", 1, 0, 'e'}, + {"timestamp", 0, 0, 'T'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "hl:d:Dse:T", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_usage(); + print_help(); + exit(0); + case 'l': + cmdline_opts.db_file = optarg; + break; + case 'd': + log_parse_category_mask(osmo_stderr_target, optarg); + break; + case 'D': + cmdline_opts.daemonize = 1; + break; + case 's': + log_set_use_color(osmo_stderr_target, 0); + break; + case 'e': + log_set_log_level(osmo_stderr_target, atoi(optarg)); + break; + case 'T': + log_set_print_timestamp(osmo_stderr_target, 1); + break; + default: + /* catch unknown options *as well as* missing arguments. */ + fprintf(stderr, "Error in command line options. Exiting.\n"); + exit(-1); + break; + } + } +} + static void *hlr_ctx = NULL; static struct osmo_gsup_server *gs; @@ -549,6 +628,9 @@ fprintf(stderr, "Error initializing logging\n"); exit(1); } + + handle_options(argc, argv); + LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); rc = rand_init(); @@ -557,7 +639,7 @@ exit(1); } - g_dbc = db_open(hlr_ctx, "hlr.db"); + g_dbc = db_open(hlr_ctx, cmdline_opts.db_file); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); @@ -573,7 +655,13 @@ signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); - //osmo_daemonize(); + if (cmdline_opts.daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + exit(1); + } + } while (1) { osmo_select_main(0); -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:44:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:44:56 +0000 Subject: [PATCH] osmo-hlr[master]: main: add VTY and '-c config-file' option In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1707 to look at the new patch set (#3). main: add VTY and '-c config-file' option Add config file, mainly for logging control. Open VTY on the OMSO_VTY_PORT_HLR added to libosmocore in commit 92fa18e6b800a27aa064a5fb8321cddd7383ae20 aka change-id I08cb52d9399a27e6876e45da36f434708c4fddef. Add hlr_vty.h/c for standard VTY setup. Add -c option to pass config file. Add --version option. Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 --- M src/Makefile.am M src/hlr.c A src/hlr_vty.c A src/hlr_vty.h 4 files changed, 117 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/07/1707/3 diff --git a/src/Makefile.am b/src/Makefile.am index 6c6c9e6..9bbc13e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ gsup_server.h \ logging.h \ rand.h \ + hlr_vty.h \ $(NULL) bin_PROGRAMS = \ @@ -38,6 +39,7 @@ hlr.c \ logging.c \ rand_urandom.c \ + hlr_vty.c \ $(NULL) osmo_hlr_LDADD = \ diff --git a/src/hlr.c b/src/hlr.c index 04ca0a6..d55f7d6 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -29,12 +29,17 @@ #include #include #include +#include +#include +#include +#include #include "db.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "hlr_vty.h" static struct db_context *g_dbc; @@ -527,18 +532,22 @@ static void print_help() { printf(" -h --help This text.\n"); + printf(" -c --config-file filename The config file to use.\n"); printf(" -l --database db-name The database to use.\n"); printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); printf(" -D --daemonize Fork the process into a background daemon.\n"); printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -V --version Print the version of OsmoHLR.\n"); } struct { + const char *config_file; const char *db_file; bool daemonize; } cmdline_opts = { + .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", .daemonize = false, }; @@ -549,16 +558,18 @@ int option_index = 0, c; static struct option long_options[] = { {"help", 0, 0, 'h'}, + {"config-file", 1, 0, 'c'}, {"database", 1, 0, 'l'}, {"debug", 1, 0, 'd'}, {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, {"timestamp", 0, 0, 'T'}, + {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hl:d:Dse:T", + c = getopt_long(argc, argv, "hc:l:d:Dse:TV", long_options, &option_index); if (c == -1) break; @@ -568,6 +579,9 @@ print_usage(); print_help(); exit(0); + case 'c': + cmdline_opts.config_file = optarg; + break; case 'l': cmdline_opts.db_file = optarg; break; @@ -585,6 +599,10 @@ break; case 'T': log_set_print_timestamp(osmo_stderr_target, 1); + break; + case 'V': + print_version(1); + exit(0); break; default: /* catch unknown options *as well as* missing arguments. */ @@ -616,6 +634,12 @@ } } +static struct vty_app_info vty_info = { + .name = "OsmoHLR", + .version = PACKAGE_VERSION, + .is_config_node = hlr_vty_is_config_node, +}; + int main(int argc, char **argv) { int rc; @@ -629,7 +653,23 @@ exit(1); } + vty_init(&vty_info); handle_options(argc, argv); + hlr_vty_init(&hlr_log_info); + + rc = vty_read_config_file(cmdline_opts.config_file, NULL); + if (rc < 0) { + LOGP(DMAIN, LOGL_FATAL, + "Failed to parse the config file: '%s'\n", + cmdline_opts.config_file); + return rc; + } + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_HLR); + if (rc < 0) + return rc; LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); diff --git a/src/hlr_vty.c b/src/hlr_vty.c new file mode 100644 index 0000000..e4eef8f --- /dev/null +++ b/src/hlr_vty.c @@ -0,0 +1,44 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include "hlr_vty.h" + +int hlr_vty_is_config_node(struct vty *vty, int node) +{ + switch (node) { + /* add items that are not config */ + case CONFIG_NODE: + return 0; + + default: + return 1; + } +} + +void hlr_vty_init(const struct log_info *cat) +{ + logging_vty_add_cmds(cat); +} diff --git a/src/hlr_vty.h b/src/hlr_vty.h new file mode 100644 index 0000000..16c633a --- /dev/null +++ b/src/hlr_vty.h @@ -0,0 +1,30 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include +#include + +int hlr_vty_go_parent(struct vty *vty); +int hlr_vty_is_config_node(struct vty *vty, int node); +void hlr_vty_init(const struct log_info *cat); -- To view, visit https://gerrit.osmocom.org/1707 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:45:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:45:13 +0000 Subject: [PATCH] osmo-hlr[master]: comment: sql: describe auc_2g and auc_3g columns In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1709 to look at the new patch set (#3). comment: sql: describe auc_2g and auc_3g columns Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405 --- M sql/hlr.sql 1 file changed, 7 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/09/1709/3 diff --git a/sql/hlr.sql b/sql/hlr.sql index 354043c..5a02be3 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -53,17 +53,17 @@ CREATE TABLE auc_2g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id - algo_id_2g INTEGER NOT NULL, - ki VARCHAR(32) NOT NULL + algo_id_2g INTEGER NOT NULL, -- enum osmo_auth_algo value + ki VARCHAR(32) NOT NULL -- hex string: subscriber's secret key (128bit) ); CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id - algo_id_3g INTEGER NOT NULL, - k VARCHAR(32) NOT NULL, - op VARCHAR(32), - opc VARCHAR(32), - sqn INTEGER NOT NULL DEFAULT 0 + algo_id_3g INTEGER NOT NULL, -- enum osmo_auth_algo value + k VARCHAR(32) NOT NULL, -- hex string: subscriber's secret key (128bit) + op VARCHAR(32), -- hex string: operator's secret key (128bit) + opc VARCHAR(32), -- hex string: derived from OP and K (128bit) + sqn INTEGER NOT NULL DEFAULT 0 -- sequence number of key usage ); CREATE UNIQUE INDEX IF NOT EXISTS idx_subscr_imsi ON subscriber (imsi); -- To view, visit https://gerrit.osmocom.org/1709 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:45:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:45:13 +0000 Subject: [PATCH] osmo-hlr[master]: sql: limit VARCHAR size of key columns to 32 Message-ID: Review at https://gerrit.osmocom.org/1716 sql: limit VARCHAR size of key columns to 32 Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 --- M sql/hlr.sql 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/16/1716/1 diff --git a/sql/hlr.sql b/sql/hlr.sql index ab9d173..e05587b 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -54,15 +54,15 @@ CREATE TABLE auc_2g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_2g INTEGER NOT NULL, - ki VARCHAR NOT NULL + ki VARCHAR(32) NOT NULL ); CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_3g INTEGER NOT NULL, k VARCHAR(32) NOT NULL, - op VARCHAR, - opc VARCHAR, + op VARCHAR(32), + opc VARCHAR(32), sqn INTEGER ); -- To view, visit https://gerrit.osmocom.org/1716 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:45:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:45:13 +0000 Subject: [PATCH] osmo-hlr[master]: sql: auc_3g: set sqn NOT NULL DEFAULT 0 Message-ID: Review at https://gerrit.osmocom.org/1717 sql: auc_3g: set sqn NOT NULL DEFAULT 0 Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6 --- M sql/hlr.sql 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/17/1717/1 diff --git a/sql/hlr.sql b/sql/hlr.sql index e05587b..354043c 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -63,7 +63,7 @@ k VARCHAR(32) NOT NULL, op VARCHAR(32), opc VARCHAR(32), - sqn INTEGER + sqn INTEGER NOT NULL DEFAULT 0 ); CREATE UNIQUE INDEX IF NOT EXISTS idx_subscr_imsi ON subscriber (imsi); -- To view, visit https://gerrit.osmocom.org/1717 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 03:47:39 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 03:47:39 +0000 Subject: [PATCH] osmo-hlr[master]: main: add VTY and '-c config-file' option In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1707 to look at the new patch set (#4). main: add VTY and '-c config-file' option Add config file, mainly for logging control. Open VTY on the OMSO_VTY_PORT_HLR added to libosmocore in commit 92fa18e6b800a27aa064a5fb8321cddd7383ae20 aka change-id I08cb52d9399a27e6876e45da36f434708c4fddef. Add hlr_vty.h/c for standard VTY setup. Add -c option to pass config file. Add --version option. Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 --- M src/Makefile.am M src/hlr.c A src/hlr_vty.c A src/hlr_vty.h 4 files changed, 116 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/07/1707/4 diff --git a/src/Makefile.am b/src/Makefile.am index 6c6c9e6..9bbc13e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ gsup_server.h \ logging.h \ rand.h \ + hlr_vty.h \ $(NULL) bin_PROGRAMS = \ @@ -38,6 +39,7 @@ hlr.c \ logging.c \ rand_urandom.c \ + hlr_vty.c \ $(NULL) osmo_hlr_LDADD = \ diff --git a/src/hlr.c b/src/hlr.c index 04ca0a6..d55f7d6 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -29,12 +29,17 @@ #include #include #include +#include +#include +#include +#include #include "db.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "hlr_vty.h" static struct db_context *g_dbc; @@ -527,18 +532,22 @@ static void print_help() { printf(" -h --help This text.\n"); + printf(" -c --config-file filename The config file to use.\n"); printf(" -l --database db-name The database to use.\n"); printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); printf(" -D --daemonize Fork the process into a background daemon.\n"); printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -V --version Print the version of OsmoHLR.\n"); } struct { + const char *config_file; const char *db_file; bool daemonize; } cmdline_opts = { + .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", .daemonize = false, }; @@ -549,16 +558,18 @@ int option_index = 0, c; static struct option long_options[] = { {"help", 0, 0, 'h'}, + {"config-file", 1, 0, 'c'}, {"database", 1, 0, 'l'}, {"debug", 1, 0, 'd'}, {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, {"timestamp", 0, 0, 'T'}, + {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hl:d:Dse:T", + c = getopt_long(argc, argv, "hc:l:d:Dse:TV", long_options, &option_index); if (c == -1) break; @@ -568,6 +579,9 @@ print_usage(); print_help(); exit(0); + case 'c': + cmdline_opts.config_file = optarg; + break; case 'l': cmdline_opts.db_file = optarg; break; @@ -585,6 +599,10 @@ break; case 'T': log_set_print_timestamp(osmo_stderr_target, 1); + break; + case 'V': + print_version(1); + exit(0); break; default: /* catch unknown options *as well as* missing arguments. */ @@ -616,6 +634,12 @@ } } +static struct vty_app_info vty_info = { + .name = "OsmoHLR", + .version = PACKAGE_VERSION, + .is_config_node = hlr_vty_is_config_node, +}; + int main(int argc, char **argv) { int rc; @@ -629,7 +653,23 @@ exit(1); } + vty_init(&vty_info); handle_options(argc, argv); + hlr_vty_init(&hlr_log_info); + + rc = vty_read_config_file(cmdline_opts.config_file, NULL); + if (rc < 0) { + LOGP(DMAIN, LOGL_FATAL, + "Failed to parse the config file: '%s'\n", + cmdline_opts.config_file); + return rc; + } + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_HLR); + if (rc < 0) + return rc; LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); diff --git a/src/hlr_vty.c b/src/hlr_vty.c new file mode 100644 index 0000000..e4eef8f --- /dev/null +++ b/src/hlr_vty.c @@ -0,0 +1,44 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include "hlr_vty.h" + +int hlr_vty_is_config_node(struct vty *vty, int node) +{ + switch (node) { + /* add items that are not config */ + case CONFIG_NODE: + return 0; + + default: + return 1; + } +} + +void hlr_vty_init(const struct log_info *cat) +{ + logging_vty_add_cmds(cat); +} diff --git a/src/hlr_vty.h b/src/hlr_vty.h new file mode 100644 index 0000000..abc9804 --- /dev/null +++ b/src/hlr_vty.h @@ -0,0 +1,29 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include +#include + +int hlr_vty_is_config_node(struct vty *vty, int node); +void hlr_vty_init(const struct log_info *cat); -- To view, visit https://gerrit.osmocom.org/1707 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 04:03:20 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 04:03:20 +0000 Subject: openbsc[master]: SGSN: Integrate basic support for UMTS AKA In-Reply-To: References: Message-ID: Patch Set 4: (2 comments) > What about the TODO? AUTS and GSUP for the authentication failure > seem important? Right ... oversaw that (since it's a commit by Harald originally) https://gerrit.osmocom.org/#/c/1683/4/openbsc/src/gprs/gprs_gmm.c File openbsc/src/gprs/gprs_gmm.c: Line 537: else > Skip this else? yes Line 714: LOGMMCTXP(LOGL_NOTICE, ctx, "Mismatch: expected SRES = %s\n", > I think we print both things we compare to aid troubleshooting. osmo_hexdump works only once per va_args, and the received SRES is printed above as DEBUG log. This patch only clarifies the wording without changing that semantic. -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:50:59 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:50:59 +0000 Subject: osmo-hlr[master]: main: add VTY and '-c config-file' option In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1707 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:51:13 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:51:13 +0000 Subject: osmo-hlr[master]: sql: auc_3g: set sqn NOT NULL DEFAULT 0 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1717 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:51:51 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:51:51 +0000 Subject: osmo-hlr[master]: comment: sql: describe auc_2g and auc_3g columns In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1709 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:53:50 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:53:50 +0000 Subject: osmo-hlr[master]: sql: limit VARCHAR size of key columns to 32 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 On this topic.. sqlite3 ignores the size (https://sqlite.org/faq.html#q9) but I think it is good that we express our intent (e.g. when using mysql for the data) -- To view, visit https://gerrit.osmocom.org/1716 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:55:46 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:55:46 +0000 Subject: osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/1706/3/src/hlr.c File src/hlr.c: PS3, Line 538: r static? -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:56:04 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:56:04 +0000 Subject: osmo-hlr[master]: main: add and use root talloc ctx In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1705 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:57:14 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:57:14 +0000 Subject: openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: > my impression was that we use everywhere... well, we do. Follow the pack then? -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:59:00 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:59:00 +0000 Subject: osmo-iuh[master]: cs RAB: add nAS_SynchronisationIndicator In-Reply-To: References: Message-ID: Patch Set 1: > I have no idea really; I saw it in a real-world 3G voice trace, and > there was a "fixme" comment in the code to add it... I added it in > an attempt to fix the nano3G, but it had no effect. Now it's there > so we might as well keep it to be more like the real-world trace. that is good enough. Please put it into the commit message of each commit or create a merge commit that explains it in the merge once. The reason is.. in a year or two we will look at it.. know the specific meaning of these fields more and and wonder why we did this... -- To view, visit https://gerrit.osmocom.org/1642 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 Gerrit-PatchSet: 1 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 06:59:24 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 06:59:24 +0000 Subject: osmo-iuh[master]: cs RAB: add nAS_SynchronisationIndicator In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1642 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 Gerrit-PatchSet: 1 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 07:06:48 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 07:06:48 +0000 Subject: openbsc[master]: vty tests: attempt to get at sporadic 'Broken Pipe' error In-Reply-To: References: Message-ID: Patch Set 2: We don't have much of an option, do we? sending IPA identity(lol) at 03:38:00 failed sending IPA identity at 03:38:02 retrying (3 attempts left) sending IPA identity(lol) at 03:38:02 failed sending IPA identity at 03:38:02 retrying (2 attempts left) sending IPA identity(lol) at 03:38:02 failed sending IPA identity at 03:38:02 retrying (1 attempts left) sending IPA identity(lol) at 03:38:02 failed sending IPA identity at 03:38:02 giving up So.. the code does work.. can we print the pid of our OpenBSC process? and maybe do something like ps xua | grep pid to have it in the output? -- To view, visit https://gerrit.osmocom.org/1693 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 07:07:18 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 07:07:18 +0000 Subject: openbsc[master]: OM2000: use assoc_so *only* for TS objects In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1715 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie0a31cd93993da10f31eecf530a5a05773c11eb1 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:56:30 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Wed, 1 Feb 2017 12:56:30 +0000 Subject: libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Patch Set 4: > -1 because of tnt's comment. Using a "native" python way to define > commands.. will reduce code size, provide good help too. Well, I just made an attempt to use argparse instead of getopt. Of course, this way reduced the code size and provided some help automatically. But, personally for me, the new help message looks a bit confusing... And the message, that manually wrote by myself, looks more informative. Let's compare: usage: conv_gen.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P TARGET_PATH] {gen_codes,gen_vectors,gen_header} {gsm} positional arguments: {gen_codes,gen_vectors,gen_header} what to generate {gsm} convolutional code family optional arguments: -h, --help show this help message and exit -p PREFIX, --prefix PREFIX internal naming prefix -n TARGET_NAME, --target-name TARGET_NAME target name for generated file -P TARGET_PATH, --target-path TARGET_PATH target path for generated file witch the previous one. I looked for opportunity to customize the help output, but such approach requires to create a new class and redefine some internal methods. So, if usage of argparse is mandatory, I will rewrite the code, and will not care about help. -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:58:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 12:58:35 +0000 Subject: [PATCH] osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1706 to look at the new patch set (#4). main: add option parsing with db file and default options Parse commandline options, supporting general Osmocom options as copied from osmo-nitb (bsc_hack.c): version, logging and daemonize options. Set the HLR database file from cmdline option, log the filename in db_open(). (VTY config file in next patch.) Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 --- M src/db.c M src/hlr.c 2 files changed, 90 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/1706/4 diff --git a/src/db.c b/src/db.c index 9d4e99e..1385502 100644 --- a/src/db.c +++ b/src/db.c @@ -75,6 +75,7 @@ unsigned int i; int rc; + LOGP(DDB, LOGL_NOTICE, "using database: %s\n", fname); LOGP(DDB, LOGL_INFO, "Compiled against SQLite3 lib version %s\n", SQLITE_VERSION); LOGP(DDB, LOGL_INFO, "Running with SQLite3 lib version %s\n", sqlite3_libversion()); diff --git a/src/hlr.c b/src/hlr.c index bf0655e..e9d53cf 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -516,6 +518,82 @@ return 0; } +static void print_usage() +{ + printf("Usage: osmo-hlr\n"); +} + +static void print_help() +{ + printf(" -h --help This text.\n"); + printf(" -l --database db-name The database to use.\n"); + printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); + printf(" -D --daemonize Fork the process into a background daemon.\n"); + printf(" -s --disable-color Do not print ANSI colors in the log\n"); + printf(" -T --timestamp Prefix every log line with a timestamp.\n"); + printf(" -e --log-level number Set a global loglevel.\n"); +} + +struct { + const char *db_file; + bool daemonize; +} cmdline_opts = { + .db_file = "hlr.db", + .daemonize = false, +}; + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"database", 1, 0, 'l'}, + {"debug", 1, 0, 'd'}, + {"daemonize", 0, 0, 'D'}, + {"disable-color", 0, 0, 's'}, + {"log-level", 1, 0, 'e'}, + {"timestamp", 0, 0, 'T'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "hl:d:Dse:T", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_usage(); + print_help(); + exit(0); + case 'l': + cmdline_opts.db_file = optarg; + break; + case 'd': + log_parse_category_mask(osmo_stderr_target, optarg); + break; + case 'D': + cmdline_opts.daemonize = 1; + break; + case 's': + log_set_use_color(osmo_stderr_target, 0); + break; + case 'e': + log_set_log_level(osmo_stderr_target, atoi(optarg)); + break; + case 'T': + log_set_print_timestamp(osmo_stderr_target, 1); + break; + default: + /* catch unknown options *as well as* missing arguments. */ + fprintf(stderr, "Error in command line options. Exiting.\n"); + exit(-1); + break; + } + } +} + static void *hlr_ctx = NULL; static struct osmo_gsup_server *gs; @@ -549,6 +627,9 @@ fprintf(stderr, "Error initializing logging\n"); exit(1); } + + handle_options(argc, argv); + LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); rc = rand_init(); @@ -557,7 +638,7 @@ exit(1); } - g_dbc = db_open(hlr_ctx, "hlr.db"); + g_dbc = db_open(hlr_ctx, cmdline_opts.db_file); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); @@ -573,7 +654,13 @@ signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); - //osmo_daemonize(); + if (cmdline_opts.daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + exit(1); + } + } while (1) { osmo_select_main(0); -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:58:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 12:58:35 +0000 Subject: [PATCH] osmo-hlr[master]: main: add VTY and '-c config-file' option In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1707 to look at the new patch set (#5). main: add VTY and '-c config-file' option Add config file, mainly for logging control. Open VTY on the OMSO_VTY_PORT_HLR added to libosmocore in commit 92fa18e6b800a27aa064a5fb8321cddd7383ae20 aka change-id I08cb52d9399a27e6876e45da36f434708c4fddef. Add hlr_vty.h/c for standard VTY setup. Add -c option to pass config file. Add --version option. Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 --- M src/Makefile.am M src/hlr.c A src/hlr_vty.c A src/hlr_vty.h 4 files changed, 116 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/07/1707/5 diff --git a/src/Makefile.am b/src/Makefile.am index 6c6c9e6..9bbc13e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ gsup_server.h \ logging.h \ rand.h \ + hlr_vty.h \ $(NULL) bin_PROGRAMS = \ @@ -38,6 +39,7 @@ hlr.c \ logging.c \ rand_urandom.c \ + hlr_vty.c \ $(NULL) osmo_hlr_LDADD = \ diff --git a/src/hlr.c b/src/hlr.c index 6fc9604..cfd86cc 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -28,12 +28,17 @@ #include #include #include +#include +#include +#include +#include #include "db.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "hlr_vty.h" static struct db_context *g_dbc; @@ -526,18 +531,22 @@ static void print_help() { printf(" -h --help This text.\n"); + printf(" -c --config-file filename The config file to use.\n"); printf(" -l --database db-name The database to use.\n"); printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); printf(" -D --daemonize Fork the process into a background daemon.\n"); printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { + const char *config_file; const char *db_file; bool daemonize; } cmdline_opts = { + .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", .daemonize = false, }; @@ -548,16 +557,18 @@ int option_index = 0, c; static struct option long_options[] = { {"help", 0, 0, 'h'}, + {"config-file", 1, 0, 'c'}, {"database", 1, 0, 'l'}, {"debug", 1, 0, 'd'}, {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, {"timestamp", 0, 0, 'T'}, + {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hl:d:Dse:T", + c = getopt_long(argc, argv, "hc:l:d:Dse:TV", long_options, &option_index); if (c == -1) break; @@ -567,6 +578,9 @@ print_usage(); print_help(); exit(0); + case 'c': + cmdline_opts.config_file = optarg; + break; case 'l': cmdline_opts.db_file = optarg; break; @@ -584,6 +598,10 @@ break; case 'T': log_set_print_timestamp(osmo_stderr_target, 1); + break; + case 'V': + print_version(1); + exit(0); break; default: /* catch unknown options *as well as* missing arguments. */ @@ -615,6 +633,12 @@ } } +static struct vty_app_info vty_info = { + .name = "OsmoHLR", + .version = PACKAGE_VERSION, + .is_config_node = hlr_vty_is_config_node, +}; + int main(int argc, char **argv) { int rc; @@ -628,7 +652,23 @@ exit(1); } + vty_init(&vty_info); handle_options(argc, argv); + hlr_vty_init(&hlr_log_info); + + rc = vty_read_config_file(cmdline_opts.config_file, NULL); + if (rc < 0) { + LOGP(DMAIN, LOGL_FATAL, + "Failed to parse the config file: '%s'\n", + cmdline_opts.config_file); + return rc; + } + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_HLR); + if (rc < 0) + return rc; LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); diff --git a/src/hlr_vty.c b/src/hlr_vty.c new file mode 100644 index 0000000..e4eef8f --- /dev/null +++ b/src/hlr_vty.c @@ -0,0 +1,44 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include "hlr_vty.h" + +int hlr_vty_is_config_node(struct vty *vty, int node) +{ + switch (node) { + /* add items that are not config */ + case CONFIG_NODE: + return 0; + + default: + return 1; + } +} + +void hlr_vty_init(const struct log_info *cat) +{ + logging_vty_add_cmds(cat); +} diff --git a/src/hlr_vty.h b/src/hlr_vty.h new file mode 100644 index 0000000..abc9804 --- /dev/null +++ b/src/hlr_vty.h @@ -0,0 +1,29 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include +#include + +int hlr_vty_is_config_node(struct vty *vty, int node); +void hlr_vty_init(const struct log_info *cat); -- To view, visit https://gerrit.osmocom.org/1707 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:58:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 12:58:35 +0000 Subject: [PATCH] osmo-hlr[master]: cmdline_opts_fu Message-ID: Review at https://gerrit.osmocom.org/1718 cmdline_opts_fu Change-Id: I4e5f0e46fc588df75b1b2206b055e9fe844d6333 --- M src/hlr.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/18/1718/1 diff --git a/src/hlr.c b/src/hlr.c index e9d53cf..6fc9604 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -534,7 +534,7 @@ printf(" -e --log-level number Set a global loglevel.\n"); } -struct { +static struct { const char *db_file; bool daemonize; } cmdline_opts = { -- To view, visit https://gerrit.osmocom.org/1718 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4e5f0e46fc588df75b1b2206b055e9fe844d6333 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:58:54 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 12:58:54 +0000 Subject: [ABANDON] osmo-hlr[master]: cmdline_opts_fu In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cmdline_opts_fu ...................................................................... Abandoned glitch -- To view, visit https://gerrit.osmocom.org/1718 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I4e5f0e46fc588df75b1b2206b055e9fe844d6333 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:59:14 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 12:59:14 +0000 Subject: [PATCH] osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1706 to look at the new patch set (#5). main: add option parsing with db file and default options Parse commandline options, supporting general Osmocom options as copied from osmo-nitb (bsc_hack.c): version, logging and daemonize options. Set the HLR database file from cmdline option, log the filename in db_open(). (VTY config file in next patch.) Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 --- M src/db.c M src/hlr.c 2 files changed, 90 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/06/1706/5 diff --git a/src/db.c b/src/db.c index 9d4e99e..1385502 100644 --- a/src/db.c +++ b/src/db.c @@ -75,6 +75,7 @@ unsigned int i; int rc; + LOGP(DDB, LOGL_NOTICE, "using database: %s\n", fname); LOGP(DDB, LOGL_INFO, "Compiled against SQLite3 lib version %s\n", SQLITE_VERSION); LOGP(DDB, LOGL_INFO, "Running with SQLite3 lib version %s\n", sqlite3_libversion()); diff --git a/src/hlr.c b/src/hlr.c index bf0655e..6fc9604 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -516,6 +518,82 @@ return 0; } +static void print_usage() +{ + printf("Usage: osmo-hlr\n"); +} + +static void print_help() +{ + printf(" -h --help This text.\n"); + printf(" -l --database db-name The database to use.\n"); + printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); + printf(" -D --daemonize Fork the process into a background daemon.\n"); + printf(" -s --disable-color Do not print ANSI colors in the log\n"); + printf(" -T --timestamp Prefix every log line with a timestamp.\n"); + printf(" -e --log-level number Set a global loglevel.\n"); +} + +static struct { + const char *db_file; + bool daemonize; +} cmdline_opts = { + .db_file = "hlr.db", + .daemonize = false, +}; + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"database", 1, 0, 'l'}, + {"debug", 1, 0, 'd'}, + {"daemonize", 0, 0, 'D'}, + {"disable-color", 0, 0, 's'}, + {"log-level", 1, 0, 'e'}, + {"timestamp", 0, 0, 'T'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "hl:d:Dse:T", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_usage(); + print_help(); + exit(0); + case 'l': + cmdline_opts.db_file = optarg; + break; + case 'd': + log_parse_category_mask(osmo_stderr_target, optarg); + break; + case 'D': + cmdline_opts.daemonize = 1; + break; + case 's': + log_set_use_color(osmo_stderr_target, 0); + break; + case 'e': + log_set_log_level(osmo_stderr_target, atoi(optarg)); + break; + case 'T': + log_set_print_timestamp(osmo_stderr_target, 1); + break; + default: + /* catch unknown options *as well as* missing arguments. */ + fprintf(stderr, "Error in command line options. Exiting.\n"); + exit(-1); + break; + } + } +} + static void *hlr_ctx = NULL; static struct osmo_gsup_server *gs; @@ -549,6 +627,9 @@ fprintf(stderr, "Error initializing logging\n"); exit(1); } + + handle_options(argc, argv); + LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); rc = rand_init(); @@ -557,7 +638,7 @@ exit(1); } - g_dbc = db_open(hlr_ctx, "hlr.db"); + g_dbc = db_open(hlr_ctx, cmdline_opts.db_file); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); @@ -573,7 +654,13 @@ signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); - //osmo_daemonize(); + if (cmdline_opts.daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + exit(1); + } + } while (1) { osmo_select_main(0); -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 12:59:14 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 12:59:14 +0000 Subject: [PATCH] osmo-hlr[master]: main: add VTY and '-c config-file' option In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1707 to look at the new patch set (#6). main: add VTY and '-c config-file' option Add config file, mainly for logging control. Open VTY on the OMSO_VTY_PORT_HLR added to libosmocore in commit 92fa18e6b800a27aa064a5fb8321cddd7383ae20 aka change-id I08cb52d9399a27e6876e45da36f434708c4fddef. Add hlr_vty.h/c for standard VTY setup. Add -c option to pass config file. Add --version option. Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 --- M src/Makefile.am M src/hlr.c A src/hlr_vty.c A src/hlr_vty.h 4 files changed, 116 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/07/1707/6 diff --git a/src/Makefile.am b/src/Makefile.am index 6c6c9e6..9bbc13e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ gsup_server.h \ logging.h \ rand.h \ + hlr_vty.h \ $(NULL) bin_PROGRAMS = \ @@ -38,6 +39,7 @@ hlr.c \ logging.c \ rand_urandom.c \ + hlr_vty.c \ $(NULL) osmo_hlr_LDADD = \ diff --git a/src/hlr.c b/src/hlr.c index 6fc9604..cfd86cc 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -28,12 +28,17 @@ #include #include #include +#include +#include +#include +#include #include "db.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "hlr_vty.h" static struct db_context *g_dbc; @@ -526,18 +531,22 @@ static void print_help() { printf(" -h --help This text.\n"); + printf(" -c --config-file filename The config file to use.\n"); printf(" -l --database db-name The database to use.\n"); printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); printf(" -D --daemonize Fork the process into a background daemon.\n"); printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { + const char *config_file; const char *db_file; bool daemonize; } cmdline_opts = { + .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", .daemonize = false, }; @@ -548,16 +557,18 @@ int option_index = 0, c; static struct option long_options[] = { {"help", 0, 0, 'h'}, + {"config-file", 1, 0, 'c'}, {"database", 1, 0, 'l'}, {"debug", 1, 0, 'd'}, {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, {"timestamp", 0, 0, 'T'}, + {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hl:d:Dse:T", + c = getopt_long(argc, argv, "hc:l:d:Dse:TV", long_options, &option_index); if (c == -1) break; @@ -567,6 +578,9 @@ print_usage(); print_help(); exit(0); + case 'c': + cmdline_opts.config_file = optarg; + break; case 'l': cmdline_opts.db_file = optarg; break; @@ -584,6 +598,10 @@ break; case 'T': log_set_print_timestamp(osmo_stderr_target, 1); + break; + case 'V': + print_version(1); + exit(0); break; default: /* catch unknown options *as well as* missing arguments. */ @@ -615,6 +633,12 @@ } } +static struct vty_app_info vty_info = { + .name = "OsmoHLR", + .version = PACKAGE_VERSION, + .is_config_node = hlr_vty_is_config_node, +}; + int main(int argc, char **argv) { int rc; @@ -628,7 +652,23 @@ exit(1); } + vty_init(&vty_info); handle_options(argc, argv); + hlr_vty_init(&hlr_log_info); + + rc = vty_read_config_file(cmdline_opts.config_file, NULL); + if (rc < 0) { + LOGP(DMAIN, LOGL_FATAL, + "Failed to parse the config file: '%s'\n", + cmdline_opts.config_file); + return rc; + } + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_HLR); + if (rc < 0) + return rc; LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); diff --git a/src/hlr_vty.c b/src/hlr_vty.c new file mode 100644 index 0000000..e4eef8f --- /dev/null +++ b/src/hlr_vty.c @@ -0,0 +1,44 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include "hlr_vty.h" + +int hlr_vty_is_config_node(struct vty *vty, int node) +{ + switch (node) { + /* add items that are not config */ + case CONFIG_NODE: + return 0; + + default: + return 1; + } +} + +void hlr_vty_init(const struct log_info *cat) +{ + logging_vty_add_cmds(cat); +} diff --git a/src/hlr_vty.h b/src/hlr_vty.h new file mode 100644 index 0000000..abc9804 --- /dev/null +++ b/src/hlr_vty.h @@ -0,0 +1,29 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include +#include + +int hlr_vty_is_config_node(struct vty *vty, int node); +void hlr_vty_init(const struct log_info *cat); -- To view, visit https://gerrit.osmocom.org/1707 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:00:12 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:00:12 +0000 Subject: [PATCH] osmo-hlr[master]: cosmetic: sql: indicate VARCHAR size of key columns as 32 In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1716 to look at the new patch set (#2). cosmetic: sql: indicate VARCHAR size of key columns as 32 Notably this has no functional effect (according to https://sqlite.org/faq.html#q9 ), but it can't hurt to indicate intent. Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 --- M sql/hlr.sql 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/16/1716/2 diff --git a/sql/hlr.sql b/sql/hlr.sql index ab9d173..e05587b 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -54,15 +54,15 @@ CREATE TABLE auc_2g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_2g INTEGER NOT NULL, - ki VARCHAR NOT NULL + ki VARCHAR(32) NOT NULL ); CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_3g INTEGER NOT NULL, k VARCHAR(32) NOT NULL, - op VARCHAR, - opc VARCHAR, + op VARCHAR(32), + opc VARCHAR(32), sqn INTEGER ); -- To view, visit https://gerrit.osmocom.org/1716 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:00:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:00:50 +0000 Subject: [PATCH] osmo-hlr[master]: Add test suite skeleton with empty test (auc_3g_test) Message-ID: Review at https://gerrit.osmocom.org/1719 Add test suite skeleton with empty test (auc_3g_test) Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 --- M .gitignore M Makefile.am M configure.ac A tests/Makefile.am A tests/auc/Makefile.am A tests/auc/auc_3g_test.c A tests/auc/auc_3g_test.err A tests/auc/auc_3g_test.ok A tests/package.m4 A tests/testsuite.at 10 files changed, 179 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/19/1719/1 diff --git a/.gitignore b/.gitignore index d06928b..17c4737 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ src/osmo-hlr src/db_test + +tests/testsuite +tests/auc/auc_3g_test diff --git a/Makefile.am b/Makefile.am index 40dad90..0d60cee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = \ src \ sql \ + tests \ $(NULL) EXTRA_DIST = \ diff --git a/configure.ac b/configure.ac index 3ac99c7..fbc1326 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,8 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.9]) +AC_CONFIG_TESTDIR(tests) + dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -44,4 +46,6 @@ Makefile src/Makefile sql/Makefile + tests/Makefile + tests/auc/Makefile ) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..21c0e21 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,50 @@ +SUBDIRS = \ + auc \ + $(NULL) + +# The `:;' works around a Bash 3.2 bug when the output is not writeable. +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + :;{ \ + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = \ + testsuite.at \ + $(srcdir)/package.m4 \ + $(TESTSUITE) \ + $(NULL) + +TESTSUITE = $(srcdir)/testsuite + +DISTCLEANFILES = \ + atconfig \ + $(NULL) + +check-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + +installcheck-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ + $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || \ + $(SHELL) '$(TESTSUITE)' --clean + +AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ diff --git a/tests/auc/Makefile.am b/tests/auc/Makefile.am new file mode 100644 index 0000000..a663e45 --- /dev/null +++ b/tests/auc/Makefile.am @@ -0,0 +1,33 @@ +AM_CPPFLAGS = \ + $(all_includes) \ + -I$(top_srcdir)/src \ + $(NULL) + +AM_CFLAGS = \ + -Wall \ + -ggdb3 \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(NULL) + +AM_LDFLAGS = \ + $(NULL) + +EXTRA_DIST = \ + auc_3g_test.ok \ + $(NULL) + +noinst_PROGRAMS = \ + auc_3g_test \ + $(NULL) + +auc_3g_test_SOURCES = \ + auc_3g_test.c \ + $(NULL) + +auc_3g_test_LDADD = \ + $(top_srcdir)/src/auc.c \ + $(top_srcdir)/src/logging.c \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c new file mode 100644 index 0000000..1444f46 --- /dev/null +++ b/tests/auc/auc_3g_test.c @@ -0,0 +1,61 @@ +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include + +#include "logging.h" + +#define comment_start() fprintf(stderr, "===== %s\n", __func__); +#define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +uint8_t fake_rand[16] = { 0 }; + +int rand_get(uint8_t *rand, unsigned int len) +{ + OSMO_ASSERT(len <= sizeof(fake_rand)); + memcpy(rand, fake_rand, len); + return len; +} + +static void test_gen_vectors_3g_only(void) +{ + comment_start(); + comment_end(); +} + +int main() +{ + printf("auc_3g_test.c\n"); + osmo_init_logging(&hlr_log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + + test_gen_vectors_3g_only(); + + printf("Done\n"); + return 0; +} diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err new file mode 100644 index 0000000..c29640a --- /dev/null +++ b/tests/auc/auc_3g_test.err @@ -0,0 +1,3 @@ +===== test_gen_vectors_3g_only +===== test_gen_vectors_3g_only: SUCCESS + diff --git a/tests/auc/auc_3g_test.ok b/tests/auc/auc_3g_test.ok new file mode 100644 index 0000000..81272cd --- /dev/null +++ b/tests/auc/auc_3g_test.ok @@ -0,0 +1,2 @@ +auc_3g_test.c +Done diff --git a/tests/package.m4 b/tests/package.m4 new file mode 100644 index 0000000..825d8e6 --- /dev/null +++ b/tests/package.m4 @@ -0,0 +1,13 @@ +# Signature of the current package. +m4_define([AT_PACKAGE_NAME], + [osmo-hlr]) +m4_define([AT_PACKAGE_TARNAME], + [osmo-hlr]) +m4_define([AT_PACKAGE_VERSION], + [0.0.1.19-56f5-dirty]) +m4_define([AT_PACKAGE_STRING], + [osmo-hlr 0.0.1.19-56f5-dirty]) +m4_define([AT_PACKAGE_BUGREPORT], + [openbsc at lists.osmocom.org]) +m4_define([AT_PACKAGE_URL], + []) diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..b782074 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,9 @@ +AT_INIT +AT_BANNER([Regression tests.]) + +AT_SETUP([auc]) +AT_KEYWORDS([auc]) +cat $abs_srcdir/auc/auc_3g_test.ok > expout +cat $abs_srcdir/auc/auc_3g_test.err > experr +AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1719 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:00:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:00:50 +0000 Subject: [PATCH] osmo-hlr[master]: tests: auc_3g_test: implement vector generation test Message-ID: Review at https://gerrit.osmocom.org/1720 tests: auc_3g_test: implement vector generation test Change-Id: I291bccd62661ff5790dc43d91dc63a9e4b0e0ff2 --- M src/auc.c M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 3 files changed, 371 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/20/1720/1 diff --git a/src/auc.c b/src/auc.c index 7d8597a..bec3ea6 100644 --- a/src/auc.c +++ b/src/auc.c @@ -47,6 +47,7 @@ /* compute quintuples */ for (i = 0; i < num_vec; i++) { rc = rand_get(rand, sizeof(rand)); + DEBUGP(DAUC, "rand %s\n", osmo_hexdump_nospc(rand, sizeof(rand))); if (rc != sizeof(rand)) { LOGP(DAUC, LOGL_ERROR, "Unable to read %zu random " "bytes: rc=%d\n", sizeof(rand), rc); @@ -65,8 +66,9 @@ } } else if (aud3g) { /* 3G or 3G + 2G case */ - DEBUGP(DAUC, "compute vector [%u]/%u: 3G or 3G + 2G\n", - i, num_vec); + if (!aud2g) + DEBUGP(DAUC, "compute vector [%u]/%u: 3G only\n", + i, num_vec); if (rand_auts && auts) rc = osmo_auth_gen_vec_auts(vec+i, aud3g, rand_auts, diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 1444f46..bfca39f 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -25,10 +25,66 @@ #include #include -#include "logging.h" +#include -#define comment_start() fprintf(stderr, "===== %s\n", __func__); +#include "logging.h" +#include "auc.h" + +#define comment_start() fprintf(stderr, "\n===== %s\n", __func__); #define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + fprintf(stderr, #val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +const char *vec_str(const struct osmo_auth_vector *vec) +{ + static char buf[1024]; + char *pos = buf; + char *end = buf + sizeof(buf); + +#define append(what) \ + if (pos >= end) \ + return buf; \ + pos += snprintf(pos, sizeof(buf) - (pos - buf), \ + " " #what ": %s\n", \ + osmo_hexdump_nospc((void*)&vec->what, sizeof(vec->what))) + + append(rand); + append(autn); + append(ck); + append(ik); + append(res); + append(res_len); + append(kc); + append(sres); + append(auth_types); +#undef append + + return buf; +} + +#define VEC_IS(vec, expect) do { \ + const char *_is = vec_str(vec); \ + fprintf(stderr, "auth vector ==\n%s\n", _is); \ + if (strcmp(_is, expect)) { \ + fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ + expect); \ + char *a = _is; \ + char *b = expect; \ + for (; *a && *b; a++, b++) { \ + if (*a != *b) { \ + while (a > _is && *(a-1) != '\n') a--; \ + fprintf(stderr, "mismatch at %d:\n" \ + "%s", a - _is, a); \ + break; \ + } \ + } \ + OSMO_ASSERT(false); \ + } \ + } while (0) uint8_t fake_rand[16] = { 0 }; @@ -39,9 +95,213 @@ return len; } +static void test_gen_vectors_2g_only(void) +{ + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + + comment_start(); + + aud2g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); + + aud3g = (struct osmo_sub_auth_data){ {0} }; + + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){ {0} }; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 00000000000000000000000000000000\n" + " ck: 00000000000000000000000000000000\n" + " ik: 00000000000000000000000000000000\n" + " res: 00000000000000000000000000000000\n" + " res_len: 00\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 01000000\n" + ); + + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + + /* even though vec is not zero-initialized, it should produce the same + * result (regardless of the umts sequence nr) */ + aud3g.u.umts.sqn = 123; + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 00000000000000000000000000000000\n" + " ck: 00000000000000000000000000000000\n" + " ik: 00000000000000000000000000000000\n" + " res: 00000000000000000000000000000000\n" + " res_len: 00\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 01000000\n" + ); + + comment_end(); +} + +static void test_gen_vectors_2g_plus_3g(void) +{ + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + + comment_start(); + + aud2g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); + + aud3g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); + osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", + aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); + + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){ {0} }; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 03000000\n" + ); + + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + /* even though vec is not zero-initialized, it should produce the same + * result with the same sequence nr */ + aud3g.u.umts.sqn = 0; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 03000000\n" + ); + + comment_end(); +} + static void test_gen_vectors_3g_only(void) { + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + comment_start(); + + aud2g = (struct osmo_sub_auth_data){ 0 }; + + aud3g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); + osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", + aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); + + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){ {0} }; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 059a4f668f6fbe39\n" + " sres: 9b36efdf\n" + " auth_types: 03000000\n" + ); + + /* Note: 3GPP TS 33.102 6.8.1.2: c3 function to get GSM auth is + * KC[0..7] == CK[0..7] ^ CK[8..15] ^ IK[0..7] ^ IK[8..15] + * In [16]: hex( 0xf64735036e587131 + * ^ 0x9c679f4742a75ea1 + * ^ 0x27497388b6cb0446 + * ^ 0x48f396aa155b95ef) + * Out[16]: '0x59a4f668f6fbe39L' + * hence expecting kc: 059a4f668f6fbe39 + */ + + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + /* even though vec is not zero-initialized, it should produce the same + * result with the same sequence nr */ + aud3g.u.umts.sqn = 0; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 059a4f668f6fbe39\n" + " sres: 9b36efdf\n" + " auth_types: 03000000\n" + ); + comment_end(); } @@ -54,6 +314,8 @@ log_set_use_color(osmo_stderr_target, 0); log_set_print_category(osmo_stderr_target, 1); + test_gen_vectors_2g_only(); + test_gen_vectors_2g_plus_3g(); test_gen_vectors_3g_only(); printf("Done\n"); diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index c29640a..ec5ba28 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -1,3 +1,106 @@ + +===== test_gen_vectors_2g_only +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 2G only +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 00000000000000000000000000000000 + ck: 00000000000000000000000000000000 + ik: 00000000000000000000000000000000 + res: 00000000000000000000000000000000 + res_len: 00 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 01000000 + +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 2G only +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 00000000000000000000000000000000 + ck: 00000000000000000000000000000000 + ik: 00000000000000000000000000000000 + res: 00000000000000000000000000000000 + res_len: 00 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 01000000 + +===== test_gen_vectors_2g_only: SUCCESS + + +===== test_gen_vectors_2g_plus_3g +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: separate 2G + 3G +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 03000000 + +aud3g.u.umts.sqn == 1 +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: separate 2G + 3G +rc == 1 +aud3g.u.umts.sqn == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 03000000 + +===== test_gen_vectors_2g_plus_3g: SUCCESS + + ===== test_gen_vectors_3g_only +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 059a4f668f6fbe39 + sres: 9b36efdf + auth_types: 03000000 + +aud3g.u.umts.sqn == 1 +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 3G only +rc == 1 +aud3g.u.umts.sqn == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 059a4f668f6fbe39 + sres: 9b36efdf + auth_types: 03000000 + ===== test_gen_vectors_3g_only: SUCCESS -- To view, visit https://gerrit.osmocom.org/1720 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I291bccd62661ff5790dc43d91dc63a9e4b0e0ff2 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:17 +0000 Subject: [MERGED] osmo-hlr[master]: comment: sql: describe auc_2g and auc_3g columns In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: comment: sql: describe auc_2g and auc_3g columns ...................................................................... comment: sql: describe auc_2g and auc_3g columns Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405 --- M sql/hlr.sql 1 file changed, 7 insertions(+), 7 deletions(-) Approvals: Holger Freyther: Looks good to me, approved diff --git a/sql/hlr.sql b/sql/hlr.sql index 354043c..5a02be3 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -53,17 +53,17 @@ CREATE TABLE auc_2g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id - algo_id_2g INTEGER NOT NULL, - ki VARCHAR(32) NOT NULL + algo_id_2g INTEGER NOT NULL, -- enum osmo_auth_algo value + ki VARCHAR(32) NOT NULL -- hex string: subscriber's secret key (128bit) ); CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id - algo_id_3g INTEGER NOT NULL, - k VARCHAR(32) NOT NULL, - op VARCHAR(32), - opc VARCHAR(32), - sqn INTEGER NOT NULL DEFAULT 0 + algo_id_3g INTEGER NOT NULL, -- enum osmo_auth_algo value + k VARCHAR(32) NOT NULL, -- hex string: subscriber's secret key (128bit) + op VARCHAR(32), -- hex string: operator's secret key (128bit) + opc VARCHAR(32), -- hex string: derived from OP and K (128bit) + sqn INTEGER NOT NULL DEFAULT 0 -- sequence number of key usage ); CREATE UNIQUE INDEX IF NOT EXISTS idx_subscr_imsi ON subscriber (imsi); -- To view, visit https://gerrit.osmocom.org/1709 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie4edc69ff11a83a4c0f79097f43a2cb206dfe405 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:17 +0000 Subject: [MERGED] osmo-hlr[master]: sql: auc_3g: set sqn NOT NULL DEFAULT 0 In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: sql: auc_3g: set sqn NOT NULL DEFAULT 0 ...................................................................... sql: auc_3g: set sqn NOT NULL DEFAULT 0 Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6 --- M sql/hlr.sql 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Holger Freyther: Looks good to me, approved diff --git a/sql/hlr.sql b/sql/hlr.sql index e05587b..354043c 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -63,7 +63,7 @@ k VARCHAR(32) NOT NULL, op VARCHAR(32), opc VARCHAR(32), - sqn INTEGER + sqn INTEGER NOT NULL DEFAULT 0 ); CREATE UNIQUE INDEX IF NOT EXISTS idx_subscr_imsi ON subscriber (imsi); -- To view, visit https://gerrit.osmocom.org/1717 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibb765f30295b441e563bb0e06ed39987f79a60d6 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:17 +0000 Subject: [MERGED] osmo-hlr[master]: cosmetic: sql: indicate VARCHAR size of key columns as 32 In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: cosmetic: sql: indicate VARCHAR size of key columns as 32 ...................................................................... cosmetic: sql: indicate VARCHAR size of key columns as 32 Notably this has no functional effect (according to https://sqlite.org/faq.html#q9 ), but it can't hurt to indicate intent. Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 --- M sql/hlr.sql 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/hlr.sql b/sql/hlr.sql index ab9d173..e05587b 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -54,15 +54,15 @@ CREATE TABLE auc_2g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_2g INTEGER NOT NULL, - ki VARCHAR NOT NULL + ki VARCHAR(32) NOT NULL ); CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_3g INTEGER NOT NULL, k VARCHAR(32) NOT NULL, - op VARCHAR, - opc VARCHAR, + op VARCHAR(32), + opc VARCHAR(32), sqn INTEGER ); -- To view, visit https://gerrit.osmocom.org/1716 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2b0f9369318085c1482c6d2d8db56699466bfbf3 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:18 +0000 Subject: [MERGED] osmo-hlr[master]: sql: fix 3g_auc's column K data type In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: sql: fix 3g_auc's column K data type ...................................................................... sql: fix 3g_auc's column K data type K is the SIM card's 128bit secret key, so the type should be VARCHAR like the other key columns. The db code already reads the column as text and parses as hex, so a VARCHAR column matches that. Change-Id: Iaa8d33e303760bd15dcb7dc8bb8b9b24bf6c8f14 --- M sql/hlr.sql 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Holger Freyther: Looks good to me, approved diff --git a/sql/hlr.sql b/sql/hlr.sql index 5f0950c..ab9d173 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -60,7 +60,7 @@ CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_3g INTEGER NOT NULL, - k INTEGER NOT NULL, + k VARCHAR(32) NOT NULL, op VARCHAR, opc VARCHAR, sqn INTEGER -- To view, visit https://gerrit.osmocom.org/1708 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iaa8d33e303760bd15dcb7dc8bb8b9b24bf6c8f14 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:18 +0000 Subject: [MERGED] osmo-hlr[master]: main: add VTY and '-c config-file' option In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: main: add VTY and '-c config-file' option ...................................................................... main: add VTY and '-c config-file' option Add config file, mainly for logging control. Open VTY on the OMSO_VTY_PORT_HLR added to libosmocore in commit 92fa18e6b800a27aa064a5fb8321cddd7383ae20 aka change-id I08cb52d9399a27e6876e45da36f434708c4fddef. Add hlr_vty.h/c for standard VTY setup. Add -c option to pass config file. Add --version option. Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 --- M src/Makefile.am M src/hlr.c A src/hlr_vty.c A src/hlr_vty.h 4 files changed, 116 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 6c6c9e6..9bbc13e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ gsup_server.h \ logging.h \ rand.h \ + hlr_vty.h \ $(NULL) bin_PROGRAMS = \ @@ -38,6 +39,7 @@ hlr.c \ logging.c \ rand_urandom.c \ + hlr_vty.c \ $(NULL) osmo_hlr_LDADD = \ diff --git a/src/hlr.c b/src/hlr.c index 6fc9604..cfd86cc 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -28,12 +28,17 @@ #include #include #include +#include +#include +#include +#include #include "db.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "hlr_vty.h" static struct db_context *g_dbc; @@ -526,18 +531,22 @@ static void print_help() { printf(" -h --help This text.\n"); + printf(" -c --config-file filename The config file to use.\n"); printf(" -l --database db-name The database to use.\n"); printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); printf(" -D --daemonize Fork the process into a background daemon.\n"); printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { + const char *config_file; const char *db_file; bool daemonize; } cmdline_opts = { + .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", .daemonize = false, }; @@ -548,16 +557,18 @@ int option_index = 0, c; static struct option long_options[] = { {"help", 0, 0, 'h'}, + {"config-file", 1, 0, 'c'}, {"database", 1, 0, 'l'}, {"debug", 1, 0, 'd'}, {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, {"timestamp", 0, 0, 'T'}, + {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hl:d:Dse:T", + c = getopt_long(argc, argv, "hc:l:d:Dse:TV", long_options, &option_index); if (c == -1) break; @@ -567,6 +578,9 @@ print_usage(); print_help(); exit(0); + case 'c': + cmdline_opts.config_file = optarg; + break; case 'l': cmdline_opts.db_file = optarg; break; @@ -584,6 +598,10 @@ break; case 'T': log_set_print_timestamp(osmo_stderr_target, 1); + break; + case 'V': + print_version(1); + exit(0); break; default: /* catch unknown options *as well as* missing arguments. */ @@ -615,6 +633,12 @@ } } +static struct vty_app_info vty_info = { + .name = "OsmoHLR", + .version = PACKAGE_VERSION, + .is_config_node = hlr_vty_is_config_node, +}; + int main(int argc, char **argv) { int rc; @@ -628,7 +652,23 @@ exit(1); } + vty_init(&vty_info); handle_options(argc, argv); + hlr_vty_init(&hlr_log_info); + + rc = vty_read_config_file(cmdline_opts.config_file, NULL); + if (rc < 0) { + LOGP(DMAIN, LOGL_FATAL, + "Failed to parse the config file: '%s'\n", + cmdline_opts.config_file); + return rc; + } + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_HLR); + if (rc < 0) + return rc; LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); diff --git a/src/hlr_vty.c b/src/hlr_vty.c new file mode 100644 index 0000000..e4eef8f --- /dev/null +++ b/src/hlr_vty.c @@ -0,0 +1,44 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include "hlr_vty.h" + +int hlr_vty_is_config_node(struct vty *vty, int node) +{ + switch (node) { + /* add items that are not config */ + case CONFIG_NODE: + return 0; + + default: + return 1; + } +} + +void hlr_vty_init(const struct log_info *cat) +{ + logging_vty_add_cmds(cat); +} diff --git a/src/hlr_vty.h b/src/hlr_vty.h new file mode 100644 index 0000000..abc9804 --- /dev/null +++ b/src/hlr_vty.h @@ -0,0 +1,29 @@ +/* OsmoHLR VTY implementation */ + +/* (C) 2016 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include +#include + +int hlr_vty_is_config_node(struct vty *vty, int node); +void hlr_vty_init(const struct log_info *cat); -- To view, visit https://gerrit.osmocom.org/1707 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iedb884345a597371a337b0c67eb6013b7d5d1ce1 Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:18 +0000 Subject: [MERGED] osmo-hlr[master]: main: add option parsing with db file and default options In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: main: add option parsing with db file and default options ...................................................................... main: add option parsing with db file and default options Parse commandline options, supporting general Osmocom options as copied from osmo-nitb (bsc_hack.c): version, logging and daemonize options. Set the HLR database file from cmdline option, log the filename in db_open(). (VTY config file in next patch.) Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 --- M src/db.c M src/hlr.c 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/db.c b/src/db.c index 9d4e99e..1385502 100644 --- a/src/db.c +++ b/src/db.c @@ -75,6 +75,7 @@ unsigned int i; int rc; + LOGP(DDB, LOGL_NOTICE, "using database: %s\n", fname); LOGP(DDB, LOGL_INFO, "Compiled against SQLite3 lib version %s\n", SQLITE_VERSION); LOGP(DDB, LOGL_INFO, "Running with SQLite3 lib version %s\n", sqlite3_libversion()); diff --git a/src/hlr.c b/src/hlr.c index bf0655e..6fc9604 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -516,6 +518,82 @@ return 0; } +static void print_usage() +{ + printf("Usage: osmo-hlr\n"); +} + +static void print_help() +{ + printf(" -h --help This text.\n"); + printf(" -l --database db-name The database to use.\n"); + printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); + printf(" -D --daemonize Fork the process into a background daemon.\n"); + printf(" -s --disable-color Do not print ANSI colors in the log\n"); + printf(" -T --timestamp Prefix every log line with a timestamp.\n"); + printf(" -e --log-level number Set a global loglevel.\n"); +} + +static struct { + const char *db_file; + bool daemonize; +} cmdline_opts = { + .db_file = "hlr.db", + .daemonize = false, +}; + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"database", 1, 0, 'l'}, + {"debug", 1, 0, 'd'}, + {"daemonize", 0, 0, 'D'}, + {"disable-color", 0, 0, 's'}, + {"log-level", 1, 0, 'e'}, + {"timestamp", 0, 0, 'T'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "hl:d:Dse:T", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_usage(); + print_help(); + exit(0); + case 'l': + cmdline_opts.db_file = optarg; + break; + case 'd': + log_parse_category_mask(osmo_stderr_target, optarg); + break; + case 'D': + cmdline_opts.daemonize = 1; + break; + case 's': + log_set_use_color(osmo_stderr_target, 0); + break; + case 'e': + log_set_log_level(osmo_stderr_target, atoi(optarg)); + break; + case 'T': + log_set_print_timestamp(osmo_stderr_target, 1); + break; + default: + /* catch unknown options *as well as* missing arguments. */ + fprintf(stderr, "Error in command line options. Exiting.\n"); + exit(-1); + break; + } + } +} + static void *hlr_ctx = NULL; static struct osmo_gsup_server *gs; @@ -549,6 +627,9 @@ fprintf(stderr, "Error initializing logging\n"); exit(1); } + + handle_options(argc, argv); + LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); rc = rand_init(); @@ -557,7 +638,7 @@ exit(1); } - g_dbc = db_open(hlr_ctx, "hlr.db"); + g_dbc = db_open(hlr_ctx, cmdline_opts.db_file); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); @@ -573,7 +654,13 @@ signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); - //osmo_daemonize(); + if (cmdline_opts.daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + exit(1); + } + } while (1) { osmo_select_main(0); -- To view, visit https://gerrit.osmocom.org/1706 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I279d517e1310e398b0a2382349e62be8e65364c1 Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:01:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:01:18 +0000 Subject: [MERGED] osmo-hlr[master]: main: add and use root talloc ctx In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: main: add and use root talloc ctx ...................................................................... main: add and use root talloc ctx Create hlr_ctx and pass on to DB and GSUP server code. Add call msgb_talloc_ctx_init(hlr_ctx). Instead of printing the entire talloc context on exit, just print the hlr_ctx upon SIGUSR1 (like our other binaries do). Otherwise we will get pages of talloc output on each program exit as soon as we add a VTY (next patch). Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4 --- M src/hlr.c 1 file changed, 7 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/src/hlr.c b/src/hlr.c index 674a58b..bf0655e 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -516,6 +516,7 @@ return 0; } +static void *hlr_ctx = NULL; static struct osmo_gsup_server *gs; static void signal_hdlr(int signal) @@ -526,11 +527,12 @@ osmo_gsup_server_destroy(gs); db_close(g_dbc); log_fini(); + talloc_report_full(hlr_ctx, stderr); exit(0); break; case SIGUSR1: LOGP(DMAIN, LOGL_DEBUG, "Talloc Report due to SIGUSR1\n"); - talloc_report_full(NULL, stderr); + talloc_report_full(hlr_ctx, stderr); break; } } @@ -539,7 +541,8 @@ { int rc; - talloc_enable_leak_report_full(); + hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); + msgb_talloc_ctx_init(hlr_ctx, 0); rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { @@ -554,13 +557,13 @@ exit(1); } - g_dbc = db_open(NULL, "hlr.db"); + g_dbc = db_open(hlr_ctx, "hlr.db"); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); } - gs = osmo_gsup_server_create(NULL, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); -- To view, visit https://gerrit.osmocom.org/1705 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3c64cb4ad7a681b88c7409296ad3afeb8000e2a4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: ranap: make X.213 NSAP 160 bits long, zero padded In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1648 to look at the new patch set (#2). ranap: make X.213 NSAP 160 bits long, zero padded For IPv4 addresses, only 56bit of X.213 NSAP are used. The sysmocell5000 accepts such a field that is 56bits long, but the ip.access nano3G does not (and crashes instead). Both work when zero-padded to 160bits size. So far we used to send the IPv4 address as "raw" 32bits to the nano3G to avoid the crash. With this zero padding we no longer need such a workaround and can use identical config for both cells. Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 16 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/48/1648/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 02bbece..dc5ba08 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -639,7 +639,7 @@ unsigned int len; if (use_x213_nsap) { - len = 7; + len = 160/8; buf = CALLOC(len, sizeof(uint8_t)); buf[0] = 0x35; /* AFI For IANA ICP */ buf[1] = 0x00; /* See A.5.2.1.2.7 of X.213 */ diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index 3acafa8..8771113 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -90,8 +90,9 @@ 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 38 82 00 02 0D C0 35 - 00 01 0A 0B 0C 0D 40 09 26 00 00 + 28 14 00 3C 40 00 00 00 50 38 82 00 02 27 C0 35 + 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 + 00 00 00 40 09 26 00 00 00 @@ -100,14 +101,15 @@ 54 - 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 1A + 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 38 82 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 - 00 00 40 01 00 + 38 82 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 + 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 + 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 38 82 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 38 82 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) @@ -116,7 +118,8 @@ 38 04 12 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06 08 9E 00 00 00 00 B1 40 05 60 01 8C BA 7F 00 00 - 10 6E 35 00 01 1A 1B 1C 1D 00 11 22 33 44 + 11 3E 35 00 01 1A 1B 1C 1D 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 11 22 33 44 78 1C 00 00 00 00 @@ -125,13 +128,14 @@ 54 - 00 00 01 00 35 00 2E 38 04 12 DE 18 69 FF 80 0C + 00 00 01 00 35 00 3B 38 04 12 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06 08 9E 00 00 00 00 B1 40 05 - 60 01 8C BA 7F 00 00 10 6E 35 00 01 1A 1B 1C 1D - 00 11 22 33 44 40 06 78 1C 00 00 00 00 + 60 01 8C BA 7F 00 00 11 3E 35 00 01 1A 1B 1C 1D + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 22 + 33 44 40 06 78 1C 00 00 00 00 -00 00 00 44 00 00 01 00 36 40 3d 00 00 01 00 35 00 2e 38 04 12 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 00 00 b1 40 05 60 01 8c ba 7f 00 00 10 6e 35 00 01 1a 1b 1c 1d 00 11 22 33 44 40 06 78 1c 00 00 00 00 +00 00 00 51 00 00 01 00 36 40 4a 00 00 01 00 35 00 3b 38 04 12 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 00 00 b1 40 05 60 01 8c ba 7f 00 00 11 3e 35 00 01 1a 1b 1c 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 22 33 44 40 06 78 1c 00 00 00 00 ==> RESET CMD -- To view, visit https://gerrit.osmocom.org/1648 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: add more SDU_FormatInformationParameter items In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1649 to look at the new patch set (#2). cs RAB: add more SDU_FormatInformationParameter items This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I97e5c0b1e9ab9de00449b50a86d79a967af0d3f3 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 39 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/49/1649/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index dc5ba08..87d646b 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -494,6 +494,14 @@ sdui->sDU_FormatInformationParameters = fmtip; fmti = new_format_info_pars(81); ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(65); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(75); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(61); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(57); + ASN_SEQUENCE_ADD(fmtip, fmti); fmti = new_format_info_pars(39); ASN_SEQUENCE_ADD(fmtip, fmti); /* FIXME: could be 10 SDU descriptors for AMR! */ @@ -505,6 +513,14 @@ sdui->sDU_FormatInformationParameters = fmtip; fmti = new_format_info_pars(103); ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(99); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(84); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(87); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(76); + ASN_SEQUENCE_ADD(fmtip, fmti); fmti = new_format_info_pars(0); ASN_SEQUENCE_ADD(fmtip, fmti); /* FIXME: could be 10 SDU descriptors for AMR! */ @@ -516,6 +532,14 @@ sdui->sDU_FormatInformationParameters = fmtip; fmti = new_format_info_pars(60); ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(40); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(0); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(0); + ASN_SEQUENCE_ADD(fmtip, fmti); + fmti = new_format_info_pars(0); + ASN_SEQUENCE_ADD(fmtip, fmti); fmti = new_format_info_pars(0); ASN_SEQUENCE_ADD(fmtip, fmti); /* FIXME: could be 10 SDU descriptors for AMR! */ diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index 8771113..99d34ee 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -89,10 +89,12 @@ 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A - 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 38 82 00 02 27 C0 35 - 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 - 00 00 00 40 09 26 00 00 + 0A 80 00 51 40 00 41 40 00 4B 40 00 3D 40 00 39 + 40 00 27 20 28 54 00 67 40 00 63 40 00 54 40 00 + 57 40 00 4C 40 00 00 22 28 54 00 3C 40 00 28 40 + 00 00 40 00 00 40 00 00 40 00 00 00 50 38 82 00 + 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 00 00 00 + 00 00 00 00 00 00 00 40 09 26 00 00 00 @@ -101,15 +103,17 @@ 54 - 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 1A - 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 - 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 38 82 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 - 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 - 01 00 + 00 00 01 00 35 00 6C 78 02 CD 80 10 2F A7 20 1A + 2C 00 00 F4 4C 64 0A 0A 80 00 51 40 00 41 40 00 + 4B 40 00 3D 40 00 39 40 00 27 20 28 54 00 67 40 + 00 63 40 00 54 40 00 57 40 00 4C 40 00 00 22 28 + 54 00 3C 40 00 28 40 00 00 40 00 00 40 00 00 40 + 00 00 00 50 38 82 00 02 27 C0 35 00 01 0A 0B 0C + 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 + 26 00 00 40 01 00 -00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 38 82 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 +00 00 00 7d 00 00 01 00 36 40 76 00 00 01 00 35 00 6c 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 0a 80 00 51 40 00 41 40 00 4b 40 00 3d 40 00 39 40 00 27 20 28 54 00 67 40 00 63 40 00 54 40 00 57 40 00 4c 40 00 00 22 28 54 00 3c 40 00 28 40 00 00 40 00 00 40 00 00 40 00 00 00 50 38 82 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1649 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I97e5c0b1e9ab9de00449b50a86d79a967af0d3f3 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: add nAS_SynchronisationIndicator In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1642 to look at the new patch set (#2). cs RAB: add nAS_SynchronisationIndicator This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 19 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/42/1642/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 16a9d03..cd2ddfc 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -588,6 +588,14 @@ return rab; } +static RANAP_NAS_SynchronisationIndicator_t *new_rab_nas_sync_ind(int val) +{ + uint8_t val_buf = (val / 10) << 4; + RANAP_NAS_SynchronisationIndicator_t *nsi = CALLOC(1, sizeof(*nsi)); + BIT_STRING_fromBuf(nsi, &val_buf, 4); + return nsi; +} + static RANAP_RAB_Parameters_t *new_rab_par_data(uint32_t dl_max_bitrate, uint32_t ul_max_bitrate) { RANAP_RAB_Parameters_t *rab = CALLOC(1, sizeof(*rab)); @@ -729,7 +737,7 @@ RANAP_RAB_SetupOrModifyItemFirst_t first; memset(&first, 0, sizeof(first)); assign_new_ra_id(&first.rAB_ID, rab_id); - //first.nAS_SynchronisationIndicator = FIXME; + first.nAS_SynchronisationIndicator = new_rab_nas_sync_ind(60); first.rAB_Parameters = new_rab_par_voice(); first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_support_mode_for_predefined_SDU_sizes, 1); /* 2? */ first.transportLayerInformation = new_transp_info_rtp(rtp_ip, rtp_port, diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index bda3c8e..dc959eb 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -88,10 +88,10 @@ 53 - 38 02 D8 01 2F A7 20 2F A8 00 00 F4 4C 08 0A 02 - 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 - 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00 - 01 0A 0B 0C 0D 40 09 26 00 00 + 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A + 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 + 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 + 00 01 0A 0B 0C 0D 40 09 26 00 00 00 @@ -100,14 +100,14 @@ 54 - 00 00 01 00 35 00 3A 38 02 D8 01 2F A7 20 2F A8 - 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 - 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D - 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 - 00 40 01 00 + 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 2F + A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 + 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 + 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 + 00 00 40 01 00 -00 00 00 4b 00 00 01 00 36 40 44 00 00 01 00 35 00 3a 38 02 d8 01 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1642 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: lower guaranteedBitrate In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1643 to look at the new patch set (#2). cs RAB: lower guaranteedBitrate This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/43/1643/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index cd2ddfc..36a39c2 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -569,7 +569,7 @@ ASN_SEQUENCE_ADD(&rab->maxBitrate.list, new_long(12200)); rab->guaranteedBitRate = CALLOC(1, sizeof(*rab->guaranteedBitRate)); - ASN_SEQUENCE_ADD(rab->guaranteedBitRate, new_long(12200)); + ASN_SEQUENCE_ADD(rab->guaranteedBitRate, new_long(6700)); rab->deliveryOrder = RANAP_DeliveryOrder_delivery_order_requested; rab->maxSDU_Size = 244; diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index dc959eb..fdff38f 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -88,7 +88,7 @@ 53 - 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A + 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 @@ -100,14 +100,14 @@ 54 - 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 2F - A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 + 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 1A + 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 40 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1643 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: tweak sDU_ErrorRatio In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1644 to look at the new patch set (#2). cs RAB: tweak sDU_ErrorRatio This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I3169376bb182aba5926b7c974108bdc5fba04fa4 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/44/1644/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 36a39c2..89ffffb 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -487,7 +487,7 @@ switch (profile) { case SDUPAR_P_VOICE0: - sdui->sDU_ErrorRatio = new_sdu_error_ratio(1, 5); + sdui->sDU_ErrorRatio = new_sdu_error_ratio(7, 3); sdui->residualBitErrorRatio.mantissa = 1; sdui->residualBitErrorRatio.exponent = 6; sdui->deliveryOfErroneousSDU = RANAP_DeliveryOfErroneousSDU_yes; diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index fdff38f..0ab99b0 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -88,7 +88,7 @@ 53 - 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 08 0A + 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 @@ -101,13 +101,13 @@ 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 1A - 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 + 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 40 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1644 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I3169376bb182aba5926b7c974108bdc5fba04fa4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: set allocationOrRetentionPriority=lowest In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1645 to look at the new patch set (#2). cs RAB: set allocationOrRetentionPriority=lowest This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I0d7dc32bc93fa0a4d316f8378b3735dc11e87071 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/45/1645/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 89ffffb..65c1dab 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -581,7 +581,7 @@ ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui); rab->transferDelay = new_long(80); - rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_no_priority, 0, 1, 0); + rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_lowest, 0, 1, 0); rab->sourceStatisticsDescriptor = new_long(RANAP_SourceStatisticsDescriptor_speech); diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index 0ab99b0..e10a718 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -90,7 +90,7 @@ 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 + 28 14 00 3C 40 00 00 00 50 39 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 @@ -103,11 +103,11 @@ 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 + 39 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 40 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 39 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1645 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0d7dc32bc93fa0a4d316f8378b3735dc11e87071 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: toggle Pre_emptionVulnerability In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1646 to look at the new patch set (#2). cs RAB: toggle Pre_emptionVulnerability This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I0f4d5a5e56bb6a3a3dfd6db8292d30f55fccdbc1 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/46/1646/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 65c1dab..d7acf6c 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -581,7 +581,7 @@ ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui); rab->transferDelay = new_long(80); - rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_lowest, 0, 1, 0); + rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_lowest, 0, 0, 0); rab->sourceStatisticsDescriptor = new_long(RANAP_SourceStatisticsDescriptor_speech); diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index e10a718..8920d47 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -90,7 +90,7 @@ 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 39 02 00 02 0D C0 35 + 28 14 00 3C 40 00 00 00 50 38 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 @@ -103,11 +103,11 @@ 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 39 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 + 38 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 40 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 39 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 38 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1646 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0f4d5a5e56bb6a3a3dfd6db8292d30f55fccdbc1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:10:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:10:38 +0000 Subject: [PATCH] osmo-iuh[master]: cs RAB: toggle QueuingAllowed In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1647 to look at the new patch set (#2). cs RAB: toggle QueuingAllowed This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I39a541c193eed9c15b2ce8fda306bb226c70647f --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/47/1647/2 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index d7acf6c..02bbece 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -581,7 +581,7 @@ ASN_SEQUENCE_ADD(&rab->sDU_Parameters, sdui); rab->transferDelay = new_long(80); - rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_lowest, 0, 0, 0); + rab->allocationOrRetentionPriority = new_alloc_ret_prio(RANAP_PriorityLevel_lowest, 0, 0, 1); rab->sourceStatisticsDescriptor = new_long(RANAP_SourceStatisticsDescriptor_speech); diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index 8920d47..3acafa8 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -90,7 +90,7 @@ 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 38 02 00 02 0D C0 35 + 28 14 00 3C 40 00 00 00 50 38 82 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 @@ -103,11 +103,11 @@ 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 64 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 38 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 + 38 82 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 00 40 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 38 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 64 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 38 82 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1647 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I39a541c193eed9c15b2ce8fda306bb226c70647f Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:41:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:41:01 +0000 Subject: [PATCH] osmo-hlr[master]: Add test suite skeleton with empty test (auc_3g_test) In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1719 to look at the new patch set (#2). Add test suite skeleton with empty test (auc_3g_test) Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 --- M .gitignore M Makefile.am M configure.ac A tests/Makefile.am A tests/auc/Makefile.am A tests/auc/auc_3g_test.c A tests/auc/auc_3g_test.err A tests/auc/auc_3g_test.ok A tests/testsuite.at 9 files changed, 167 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/19/1719/2 diff --git a/.gitignore b/.gitignore index d06928b..17c4737 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ src/osmo-hlr src/db_test + +tests/testsuite +tests/auc/auc_3g_test diff --git a/Makefile.am b/Makefile.am index 40dad90..0d60cee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = \ src \ sql \ + tests \ $(NULL) EXTRA_DIST = \ diff --git a/configure.ac b/configure.ac index 3ac99c7..fbc1326 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,8 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.9]) +AC_CONFIG_TESTDIR(tests) + dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -44,4 +46,6 @@ Makefile src/Makefile sql/Makefile + tests/Makefile + tests/auc/Makefile ) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..21c0e21 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,50 @@ +SUBDIRS = \ + auc \ + $(NULL) + +# The `:;' works around a Bash 3.2 bug when the output is not writeable. +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + :;{ \ + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = \ + testsuite.at \ + $(srcdir)/package.m4 \ + $(TESTSUITE) \ + $(NULL) + +TESTSUITE = $(srcdir)/testsuite + +DISTCLEANFILES = \ + atconfig \ + $(NULL) + +check-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + +installcheck-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ + $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || \ + $(SHELL) '$(TESTSUITE)' --clean + +AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ diff --git a/tests/auc/Makefile.am b/tests/auc/Makefile.am new file mode 100644 index 0000000..1d506a7 --- /dev/null +++ b/tests/auc/Makefile.am @@ -0,0 +1,34 @@ +AM_CPPFLAGS = \ + $(all_includes) \ + -I$(top_srcdir)/src \ + $(NULL) + +AM_CFLAGS = \ + -Wall \ + -ggdb3 \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(NULL) + +AM_LDFLAGS = \ + $(NULL) + +EXTRA_DIST = \ + auc_3g_test.ok \ + auc_3g_test.err \ + $(NULL) + +noinst_PROGRAMS = \ + auc_3g_test \ + $(NULL) + +auc_3g_test_SOURCES = \ + auc_3g_test.c \ + $(NULL) + +auc_3g_test_LDADD = \ + $(top_srcdir)/src/auc.c \ + $(top_srcdir)/src/logging.c \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c new file mode 100644 index 0000000..1444f46 --- /dev/null +++ b/tests/auc/auc_3g_test.c @@ -0,0 +1,61 @@ +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include + +#include "logging.h" + +#define comment_start() fprintf(stderr, "===== %s\n", __func__); +#define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +uint8_t fake_rand[16] = { 0 }; + +int rand_get(uint8_t *rand, unsigned int len) +{ + OSMO_ASSERT(len <= sizeof(fake_rand)); + memcpy(rand, fake_rand, len); + return len; +} + +static void test_gen_vectors_3g_only(void) +{ + comment_start(); + comment_end(); +} + +int main() +{ + printf("auc_3g_test.c\n"); + osmo_init_logging(&hlr_log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + + test_gen_vectors_3g_only(); + + printf("Done\n"); + return 0; +} diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err new file mode 100644 index 0000000..c29640a --- /dev/null +++ b/tests/auc/auc_3g_test.err @@ -0,0 +1,3 @@ +===== test_gen_vectors_3g_only +===== test_gen_vectors_3g_only: SUCCESS + diff --git a/tests/auc/auc_3g_test.ok b/tests/auc/auc_3g_test.ok new file mode 100644 index 0000000..81272cd --- /dev/null +++ b/tests/auc/auc_3g_test.ok @@ -0,0 +1,2 @@ +auc_3g_test.c +Done diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..b782074 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,9 @@ +AT_INIT +AT_BANNER([Regression tests.]) + +AT_SETUP([auc]) +AT_KEYWORDS([auc]) +cat $abs_srcdir/auc/auc_3g_test.ok > expout +cat $abs_srcdir/auc/auc_3g_test.err > experr +AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1719 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:41:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:41:01 +0000 Subject: [PATCH] osmo-hlr[master]: auth: verify test sets from 3GPP TS 55.205 Message-ID: Review at https://gerrit.osmocom.org/1721 auth: verify test sets from 3GPP TS 55.205 Put to-text conversion of the 3GPP TS 55.205 PDF's section defining the test vectors in tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt and add python script to generate auc_ts_55_205_test_sets.c from that at build time. The generated auc_ts_55_205_test_sets.c runs through all 19 test sets, verifying that our gsm_milenage() matches the reference data. Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd --- M .gitignore M configure.ac M tests/auc/Makefile.am M tests/auc/auc_3g_test.c A tests/auc/auc_ts_55_205_test_sets.err A tests/auc/auc_ts_55_205_test_sets.ok A tests/auc/gen_ts_55_205_test_sets/Makefile.am A tests/auc/gen_ts_55_205_test_sets/func_template.c A tests/auc/gen_ts_55_205_test_sets/main_template.c A tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py A tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt M tests/testsuite.at 12 files changed, 1,609 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1721/1 diff --git a/.gitignore b/.gitignore index 17c4737..2e78dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.db +*.pyc .*.sw? .version Makefile @@ -25,3 +26,5 @@ tests/testsuite tests/auc/auc_3g_test +tests/auc/auc_ts_55_205_test_sets.c +tests/auc/auc_ts_55_205_test_sets diff --git a/configure.ac b/configure.ac index fbc1326..bfda9c5 100644 --- a/configure.ac +++ b/configure.ac @@ -48,4 +48,5 @@ sql/Makefile tests/Makefile tests/auc/Makefile + tests/auc/gen_ts_55_205_test_sets/Makefile ) diff --git a/tests/auc/Makefile.am b/tests/auc/Makefile.am index 1d506a7..761396b 100644 --- a/tests/auc/Makefile.am +++ b/tests/auc/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = gen_ts_55_205_test_sets + AM_CPPFLAGS = \ $(all_includes) \ -I$(top_srcdir)/src \ @@ -16,10 +18,14 @@ EXTRA_DIST = \ auc_3g_test.ok \ auc_3g_test.err \ + auc_ts_55_205_test_sets.ok \ + auc_ts_55_205_test_sets.err \ $(NULL) + noinst_PROGRAMS = \ auc_3g_test \ + auc_ts_55_205_test_sets \ $(NULL) auc_3g_test_SOURCES = \ @@ -32,3 +38,18 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(NULL) + +auc_ts_55_205_test_sets_SOURCES = \ + $(builddir)/auc_ts_55_205_test_sets.c \ + $(NULL) + +auc_ts_55_205_test_sets_LDADD = \ + $(top_srcdir)/src/auc.c \ + $(top_srcdir)/src/logging.c \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) + +auc_ts_55_205_test_sets.c: $(top_srcdir)/tests/auc/gen_ts_55_205_test_sets/* + $(top_srcdir)/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py > $@ + diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index bfca39f..0923a27 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -39,7 +40,7 @@ OSMO_ASSERT((val) expect_op); \ } while (0); -const char *vec_str(const struct osmo_auth_vector *vec) +char *vec_str(const struct osmo_auth_vector *vec) { static char buf[1024]; char *pos = buf; @@ -67,7 +68,7 @@ } #define VEC_IS(vec, expect) do { \ - const char *_is = vec_str(vec); \ + char *_is = vec_str(vec); \ fprintf(stderr, "auth vector ==\n%s\n", _is); \ if (strcmp(_is, expect)) { \ fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ @@ -78,7 +79,7 @@ if (*a != *b) { \ while (a > _is && *(a-1) != '\n') a--; \ fprintf(stderr, "mismatch at %d:\n" \ - "%s", a - _is, a); \ + "%s", (int)(a - _is), a); \ break; \ } \ } \ @@ -112,13 +113,13 @@ osmo_hexparse("EB215756028D60E3275E613320AEC880", aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); - aud3g = (struct osmo_sub_auth_data){ {0} }; + aud3g = (struct osmo_sub_auth_data){ 0 }; osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){ {0} }; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); @@ -134,7 +135,7 @@ " auth_types: 01000000\n" ); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); /* even though vec is not zero-initialized, it should produce the same * result (regardless of the umts sequence nr) */ @@ -188,7 +189,7 @@ fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){ {0} }; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); @@ -204,15 +205,15 @@ " auth_types: 03000000\n" ); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); /* even though vec is not zero-initialized, it should produce the same * result with the same sequence nr */ aud3g.u.umts.sqn = 0; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); VEC_IS(&vec, " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" @@ -254,7 +255,7 @@ fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){ {0} }; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); @@ -280,15 +281,15 @@ * hence expecting kc: 059a4f668f6fbe39 */ - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); /* even though vec is not zero-initialized, it should produce the same * result with the same sequence nr */ aud3g.u.umts.sqn = 0; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); VEC_IS(&vec, " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" diff --git a/tests/auc/auc_ts_55_205_test_sets.err b/tests/auc/auc_ts_55_205_test_sets.err new file mode 100644 index 0000000..9a26922 --- /dev/null +++ b/tests/auc/auc_ts_55_205_test_sets.err @@ -0,0 +1,304 @@ + +===== test_set_1 +aud3g.u.umts.sqn == 0 +DAUC rand 23553cbe9637a89d218ae64dae47bf35 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 23553cbe9637a89d218ae64dae47bf35 + ck: b40ba9a3c58b2a05bbf0d987b21bf8cb + ik: f769bcd751044604127672711c6d3441 + res: a54211d5e3ba50bf0000000000000000 + kc: eae4be823af9a08b + sres: 46f8416a + +===== test_set_1: SUCCESS + + +===== test_set_2 +aud3g.u.umts.sqn == 0 +DAUC rand 9f7c8d021accf4db213ccff0c7f71a6a +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 9f7c8d021accf4db213ccff0c7f71a6a + ck: 5dbdbb2954e8f3cde665b046179a5098 + ik: 59a92d3b476a0443487055cf88b2307b + res: 8011c48c0c214ed20000000000000000 + kc: aa01739b8caa976d + sres: 8c308a5e + +===== test_set_2: SUCCESS + + +===== test_set_3 +aud3g.u.umts.sqn == 0 +DAUC rand ce83dbc54ac0274a157c17f80d017bd6 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: ce83dbc54ac0274a157c17f80d017bd6 + ck: e203edb3971574f5a94b0d61b816345d + ik: 0c4524adeac041c4dd830d20854fc46b + res: f365cd683cd92e960000000000000000 + kc: 9a8ec95f408cc507 + sres: cfbce3fe + +===== test_set_3: SUCCESS + + +===== test_set_4 +aud3g.u.umts.sqn == 0 +DAUC rand 74b0cd6031a1c8339b2b6ce2b8c4a186 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 74b0cd6031a1c8339b2b6ce2b8c4a186 + ck: 7657766b373d1c2138f307e3de9242f9 + ik: 1c42e960d89b8fa99f2744e0708ccb53 + res: 5860fc1bce351e7e0000000000000000 + kc: cdc1dc0841b81a22 + sres: 9655e265 + +===== test_set_4: SUCCESS + + +===== test_set_5 +aud3g.u.umts.sqn == 0 +DAUC rand ee6466bc96202c5a557abbeff8babf63 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: ee6466bc96202c5a557abbeff8babf63 + ck: 3f8c7587fe8e4b233af676aede30ba3b + ik: a7466cc1e6b2a1337d49d3b66e95d7b4 + res: 16c8233f05a0ac280000000000000000 + kc: df75bc5ea899879f + sres: 13688f17 + +===== test_set_5: SUCCESS + + +===== test_set_6 +aud3g.u.umts.sqn == 0 +DAUC rand 194aa756013896b74b4a2a3b0af4539e +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 194aa756013896b74b4a2a3b0af4539e + ck: 4cd0846020f8fa0731dd47cbdc6be411 + ik: 88ab80a415f15c73711254a1d388f696 + res: 8c25a16cd918a1df0000000000000000 + kc: 84b417ae3aeab4f3 + sres: 553d00b3 + +===== test_set_6: SUCCESS + + +===== test_set_7 +aud3g.u.umts.sqn == 0 +DAUC rand 3a4c2b3245c50eb5c71d08639395764d +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 3a4c2b3245c50eb5c71d08639395764d + ck: 10f05bab75a99a5fbb98a9c287679c3b + ik: f9ec0865eb32f22369cade40c59c3a44 + res: a63241e1ffc3e5ab0000000000000000 + kc: 3b4e244cdc60ce03 + sres: 59f1a44a + +===== test_set_7: SUCCESS + + +===== test_set_8 +aud3g.u.umts.sqn == 0 +DAUC rand f761e5e93d603feb730e27556cb8a2ca +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: f761e5e93d603feb730e27556cb8a2ca + ck: 71236b7129f9b22ab77ea7a54c96da22 + ik: 90527ebaa5588968db41727325a04d9e + res: 4a90b2171ac83a760000000000000000 + kc: 8d4ec01de597acfe + sres: 50588861 + +===== test_set_8: SUCCESS + + +===== test_set_9 +aud3g.u.umts.sqn == 0 +DAUC rand 08eff828b13fdb562722c65c7f30a9b2 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 08eff828b13fdb562722c65c7f30a9b2 + ck: 08cef6d004ec61471a3c3cda048137fa + ik: ed0318ca5deb9206272f6e8fa64ba411 + res: 4bc2212d8624910a0000000000000000 + kc: d8debc4ffbcd60aa + sres: cde6b027 + +===== test_set_9: SUCCESS + + +===== test_set_10 +aud3g.u.umts.sqn == 0 +DAUC rand 679ac4dbacd7d233ff9d6806f4149ce3 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 679ac4dbacd7d233ff9d6806f4149ce3 + ck: 69b1cae7c7429d975e245cacb05a517c + ik: 74f24e8c26df58e1b38d7dcd4f1b7fbd + res: 6fc30fee6d1235230000000000000000 + kc: f0eaa50a1edcebb7 + sres: 02d13acd + +===== test_set_10: SUCCESS + + +===== test_set_11 +aud3g.u.umts.sqn == 0 +DAUC rand 4c47eb3076dc55fe5106cb2034b8cd78 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 4c47eb3076dc55fe5106cb2034b8cd78 + ck: 908c43f0569cb8f74bc971e706c36c5f + ik: c251df0d888dd9329bcf46655b226e40 + res: aefa357beac2a87a0000000000000000 + kc: 82dbab7f83f063da + sres: 44389d01 + +===== test_set_11: SUCCESS + + +===== test_set_12 +aud3g.u.umts.sqn == 0 +DAUC rand 311c4c929744d675b720f3b7e9b1cbd0 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 311c4c929744d675b720f3b7e9b1cbd0 + ck: 44c0f23c5493cfd241e48f197e1d1012 + ik: 0c9fb81613884c2535dd0eabf3b440d8 + res: 98dbbd099b3b408d0000000000000000 + kc: 3c66cb98cab2d33d + sres: 03e0fd84 + +===== test_set_12: SUCCESS + + +===== test_set_13 +aud3g.u.umts.sqn == 0 +DAUC rand cf7d0ab1d94306950bf12018fbd46887 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: cf7d0ab1d94306950bf12018fbd46887 + ck: 5af86b80edb70df5292cc1121cbad50c + ik: 7f4d6ae7440e18789a8b75ad3f42f03a + res: af4a411e1139f2c20000000000000000 + kc: 9612b5d88a4130bb + sres: be73b3dc + +===== test_set_13: SUCCESS + + +===== test_set_14 +aud3g.u.umts.sqn == 0 +DAUC rand 1f0f8578464fd59b64bed2d09436b57a +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 1f0f8578464fd59b64bed2d09436b57a + ck: 3f8c3f3ccf7625bf77fc94bcfd22fd26 + ik: abcbae8fd46115e9961a55d0da5f2078 + res: 7bffa5c2f41fbc050000000000000000 + kc: 75a150df3c6aed08 + sres: 8fe019c7 + +===== test_set_14: SUCCESS + + +===== test_set_15 +aud3g.u.umts.sqn == 0 +DAUC rand 59b75f14251c75031d0bcbac1c2c04c7 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 59b75f14251c75031d0bcbac1c2c04c7 + ck: d42b2d615e49a03ac275a5aef97af892 + ik: 0b3f8d024fe6bfafaa982b8f82e319c2 + res: 7e3f44c7591f6f450000000000000000 + kc: b7f92e426a36fec5 + sres: 27202b82 + +===== test_set_15: SUCCESS + + +===== test_set_16 +aud3g.u.umts.sqn == 0 +DAUC rand f69b78f300a0568bce9f0cb93c4be4c9 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: f69b78f300a0568bce9f0cb93c4be4c9 + ck: 6edaf99e5bd9f85d5f36d91c1272fb4b + ik: d61c853c280dd9c46f297baec386de17 + res: 70f6bdb9ad21525f0000000000000000 + kc: 88d9de10a22004c5 + sres: ddd7efe6 + +===== test_set_16: SUCCESS + + +===== test_set_17 +aud3g.u.umts.sqn == 0 +DAUC rand b120f1c1a0102a2f507dd543de68281f +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: b120f1c1a0102a2f507dd543de68281f + ck: 66195dbed0313274c5ca7766615fa25e + ik: 66bec707eb2afc476d7408a8f2927b36 + res: 479dd25c20792d630000000000000000 + kc: a819e577a8d6175b + sres: 67e4ff3f + +===== test_set_17: SUCCESS + + +===== test_set_18 +aud3g.u.umts.sqn == 0 +DAUC rand 81e92b6c0ee0e12ebceba8d92a99dfa5 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 81e92b6c0ee0e12ebceba8d92a99dfa5 + ck: 5349fbe098649f948f5d2e973a81c00f + ik: 9744871ad32bf9bbd1dd5ce54e3e2e5a + res: 28d7b0f2a2ec3de50000000000000000 + kc: 9a8d0e883ff0887a + sres: 8a3b8d17 + +===== test_set_18: SUCCESS + + +===== test_set_19 +aud3g.u.umts.sqn == 0 +DAUC rand 9fddc72092c6ad036b6e464789315b78 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 9fddc72092c6ad036b6e464789315b78 + ck: b5f2da03883b69f96bf52e029ed9ac45 + ik: b4721368bc16ea67875c5598688bb0ef + res: a95100e2760952cd0000000000000000 + kc: ed29b2f1c27f9f34 + sres: df58522f + +===== test_set_19: SUCCESS + diff --git a/tests/auc/auc_ts_55_205_test_sets.ok b/tests/auc/auc_ts_55_205_test_sets.ok new file mode 100644 index 0000000..4eed389 --- /dev/null +++ b/tests/auc/auc_ts_55_205_test_sets.ok @@ -0,0 +1,2 @@ +3GPP TS 55.205 Test Sets +Done diff --git a/tests/auc/gen_ts_55_205_test_sets/Makefile.am b/tests/auc/gen_ts_55_205_test_sets/Makefile.am new file mode 100644 index 0000000..3225384 --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = \ + func_template.c \ + main_template.c \ + pdftxt_2_c.py \ + ts55_205_test_sets.txt \ + $(NULL) diff --git a/tests/auc/gen_ts_55_205_test_sets/func_template.c b/tests/auc/gen_ts_55_205_test_sets/func_template.c new file mode 100644 index 0000000..36926eb --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/func_template.c @@ -0,0 +1,64 @@ +/* gen_ts_55_205_test_sets/func_template.c: Template to generate test code + * from 3GPP TS 55.205 test sets */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +static void {func_name}(void) +{{ + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + + comment_start(); + + aud2g = (struct osmo_sub_auth_data){{ 0 }}; + + aud3g = (struct osmo_sub_auth_data){{ + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }}; + + osmo_hexparse("{Ki}", + aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); + osmo_hexparse("{OPc}", + aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); + + osmo_hexparse("{RAND}", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){{ {{0}} }}; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: {RAND}\n" + " ck: {MIL3G-CK}\n" + " ik: {MIL3G-IK}\n" + " res: {MIL3G-RES}0000000000000000\n" + " kc: {Kc}\n" + " sres: {SRES#1}\n" + ); + + comment_end(); +}} diff --git a/tests/auc/gen_ts_55_205_test_sets/main_template.c b/tests/auc/gen_ts_55_205_test_sets/main_template.c new file mode 100644 index 0000000..c03b820 --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/main_template.c @@ -0,0 +1,115 @@ +/* gen_ts_55_205_test_sets/main_template.c: Template to generate test code + * from 3GPP TS 55.205 test sets */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include +#include + +#include + +#include "logging.h" +#include "auc.h" + +#define comment_start() fprintf(stderr, "\n===== %s\n", __func__); +#define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + fprintf(stderr, #val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +char *vec_str(const struct osmo_auth_vector *vec) +{ + static char buf[1024]; + char *pos = buf; + char *end = buf + sizeof(buf); + +#define append(what) \ + if (pos >= end) \ + return buf; \ + pos += snprintf(pos, sizeof(buf) - (pos - buf), \ + " " #what ": %s\n", \ + osmo_hexdump_nospc((void*)&vec->what, sizeof(vec->what))) + + append(rand); + append(ck); + append(ik); + append(res); + append(kc); + append(sres); +#undef append + + return buf; +} + +#define VEC_IS(vec, expect) do { \ + char *_is = vec_str(vec); \ + fprintf(stderr, "auth vector ==\n%s\n", _is); \ + if (strcmp(_is, expect)) { \ + fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ + expect); \ + char *a = _is; \ + char *b = expect; \ + for (; *a && *b; a++, b++) { \ + if (*a != *b) { \ + while (a > _is && *(a-1) != '\n') a--; \ + fprintf(stderr, "mismatch at %d:\n" \ + "%s", (int)(a - _is), a); \ + break; \ + } \ + } \ + OSMO_ASSERT(false); \ + } \ + } while (0) + +uint8_t fake_rand[16] = { 0 }; + +int rand_get(uint8_t *rand, unsigned int len) +{ + OSMO_ASSERT(len <= sizeof(fake_rand)); + memcpy(rand, fake_rand, len); + return len; +} + +FUNCTIONS + +int main() +{ + printf("3GPP TS 55.205 Test Sets\n"); + osmo_init_logging(&hlr_log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + +FUNCTION_CALLS + + printf("Done\n"); + return 0; +} diff --git a/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py b/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py new file mode 100755 index 0000000..0efa7ac --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 + +# Convert test sets pasted from 3GPP TS 55.205 to C code. + +# (C) 2016 by sysmocom s.f.m.c. GmbH +# +# All Rights Reserved +# +# Author: Neels Hofmeyr +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import sys, os + +script_dir = sys.path[0] + +fields = ( + 'Ki', + 'RAND', + 'OP', + 'OPc', + 'MIL3G-RES', + 'SRES#1', + 'SRES#2', + 'MIL3G-CK', + 'MIL3G-IK', + 'Kc', +) + +test_sets_lines = [] +test_set_lines = None + +for line in [l.strip() for l in open(os.path.join(script_dir, 'ts55_205_test_sets.txt'), 'r')]: + if line.startswith('Test Set'): + if test_set_lines: + test_sets_lines.append(test_set_lines) + test_set_lines = [] + elif len(line) == 8: + try: + is_hex = int(line, 16) + test_set_lines.append(line) + except ValueError: + pass + +if test_set_lines: + test_sets_lines.append(test_set_lines) + +# Magic fixups for PDF-to-text uselessness +idx = (( 0, 10, 15, 19), + ( 1, 11, 16, 20), + ( 2, 12, 17, 21), + ( 3, 13, 18, 22), + ( 4, 14), + ( 5, ), + ( 6, ), + ( 7, 23, 26, 28), + ( 8, 24, 27, 29), + ( 9, 25 ), + ) + +test_sets = [] +for l in test_sets_lines: + test_sets.append( [ ''.join([l[i] for i in li]) for li in idx ] ) + +func_templ = open(os.path.join(script_dir, 'func_template.c'), 'r').read() + +funcs = [] +func_calls = [] +nr = 0 +for test_set in test_sets: + nr += 1 + func_name = 'test_set_%d' % nr + kwargs = dict(zip(fields, test_set)) + kwargs['func_name'] = func_name + + func_calls.append('\t%s();' % func_name) + funcs.append(func_templ.format(**kwargs)) + +templ = open(os.path.join(script_dir, 'main_template.c')).read() + +code = templ.replace('FUNCTIONS', '\n'.join(funcs)).replace('FUNCTION_CALLS', '\n'.join(func_calls)) + +print(''' +/***** DO NOT EDIT THIS FILE -- THIS CODE IS GENERATED ***** + ***** by gen_ts_55_205_test_sets/pdftxt_2_c.py *****/ +''') +print(code) + diff --git a/tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt b/tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt new file mode 100644 index 0000000..0d4d14b --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt @@ -0,0 +1,972 @@ + +Test Set 1 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +465b5ce8 +23553cbe +cdc202d5 +cd63cb71 +a54211d5 +46f8416a +a54211d5 +b40ba9a3 +f769bcd7 +eae4be82 + +b199b49f +9637a89d +123e20f6 +954a9f4e +e3ba50bf + +aa5f0a2e +218ae64d +2b6d676a +48a5994e + +e238a6bc +ae47bf35 +c72cb318 +37a02baf + +c58b2a05 +51044604 +3af9a08b + +bbf0d987 +12767271 + +b21bf8cb +1c6d3441 + +Test Set 2 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +fec86ba6 +9f7c8d02 +dbc59adc +1006020f +8011c48c +8c308a5e +8011c48c +5dbdbb29 +59a92d3b +aa01739b + +eb707ed0 +1accf4db +b6f9a0ef +0a478bf6 +0c214ed2 + +8905757b +213ccff0 +735477b7 +b699f15c + +1bb44b8f +c7f71a6a +fadf8374 +062e42b3 + +54e8f3cd +476a0443 +8caa976d + +e665b046 +487055cf + +179a5098 +88b2307b + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +10 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 3 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +9e5944ae +ce83dbc5 +223014c5 +a64a507a +f365cd68 +cfbce3fe +f365cd68 +e203edb3 +0c4524ad +9a8ec95f + +a94b8116 +4ac0274a +806694c0 +e1a2a98b +3cd92e96 + +5c82fbf9 +157c17f8 +07ca1eee +b88eb421 + +f32db751 +0d017bd6 +f57f004f +0135dc87 + +971574f5 +eac041c4 +408cc507 + +a94b0d61 +dd830d20 + +b816345d +854fc46b + +Test Set 4 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +4ab1deb0 +74b0cd60 +2d16c5cd +dcf07cbd +5860fc1b +9655e265 +5860fc1b +7657766b +1c42e960 +cdc1dc08 + +5ca6ceb0 +31a1c833 +1fdf6b22 +51855290 +ce351e7e + +51fc98e7 +9b2b6ce2 +383584e3 +b92a07a9 + +7d026a84 +b8c4a186 +bef2a8d8 +891e523e + +373d1c21 +d89b8fa9 +41b81a22 + +38f307e3 +9f2744e0 + +de9242f9 +708ccb53 + +Test Set 5 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +6c38a116 +ee6466bc +1ba00a1a +3803ef53 +16c8233f +13688f17 +16c8233f +3f8c7587 +a7466cc1 +df75bc5e + +ac280c45 +96202c5a +7c6700ac +63b947c6 +05a0ac28 + +4f59332e +557abbef +8c3ff3e9 +aaa225e5 + +e35c8c4f +f8babf63 +6ad08725 +8fae3934 + +fe8e4b23 +e6b2a133 +a899879f + +3af676ae +7d49d3b6 + +de30ba3b +6e95d7b4 + +Test Set 6 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +2d609d4d +194aa756 +460a4838 +c35a0ab0 +8c25a16c +553d00b3 +8c25a16c +4cd08460 +88ab80a4 +84b417ae + +b0ac5bf0 +013896b7 +5427aa39 +bcbfc925 +d918a1df + +d2c0de26 +4b4a2a3b +264aac8e +2caff15f + +7014de0d +0af4539e +fc9e73e8 +24efbde0 + +20f8fa07 +15f15c73 +3aeab4f3 + +31dd47cb +711254a1 + +dc6be411 +d388f696 + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +11 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 7 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +a530a7fe +3a4c2b32 +511c6c4e +27953e49 +a63241e1 +59f1a44a +a63241e1 +10f05bab +f9ec0865 +3b4e244c + +428fad10 +45c50eb5 +83e38c89 +bc8af6dc +ffc3e5ab + +82c45edd +c71d0863 +b1c5d8dd +c6e730eb + +fce13884 +9395764d +e62426fa +80286be3 + +75a99a5f +eb32f223 +dc60ce03 + +bb98a9c2 +69cade40 + +87679c3b +c59c3a44 + +Test Set 8 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +d9151cf0 +f761e5e9 +75fc2233 +c4c93eff +4a90b217 +50588861 +4a90b217 +71236b71 +90527eba +8d4ec01d + +4896e258 +3d603feb +a44294ee +e8a08138 +1ac83a76 + +30bf2e08 +730e2755 +8e6de25c +c203d4c2 + +267b8360 +6cb8a2ca +4353d26b +7ce4e3d9 + +29f9b22a +a5588968 +e597acfe + +b77ea7a5 +db417273 + +4c96da22 +25a04d9e + +Test Set 9 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +a0e2971b +08eff828 +323792fa +82a26f22 +4bc2212d +cde6b027 +4bc2212d +08cef6d0 +ed0318ca +d8debc4f + +6822e8d3 +b13fdb56 +ca21fb4d +bba9e948 +8624910a + +54a18cc2 +2722c65c +5d6f13c1 +8f949a10 + +35624ecb +7f30a9b2 +45a9d2c1 +d98e9cc4 + +04ec6147 +5deb9206 +fbcd60aa + +1a3c3cda +272f6e8f + +048137fa +a64ba411 + +Test Set 10 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +0da6f7ba +679ac4db +4b9a26fa +0db1071f +6fc30fee +02d13acd +6fc30fee +69b1cae7 +74f24e8c +f0eaa50a + +86d5eac8 +acd7d233 +459e3acb +8767562c +6d123523 + +a19cf563 +ff9d6806 +ff36f401 +a43a0a64 + +ac58642d +f4149ce3 +5de3bdc1 +c41e8d08 + +c7429d97 +26df58e1 +1edcebb7 + +5e245cac +b38d7dcd + +b05a517c +4f1b7fbd + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +12 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 11 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +77b45843 +4c47eb30 +bf3286c7 +d483afae +aefa357b +44389d01 +aefa357b +908c43f0 +c251df0d +82dbab7f + +c88e58c1 +76dc55fe +a51409ce +562409a3 +eac2a87a + +0d202684 +5106cb20 +95724d50 +26b5bb0b + +515ed430 +34b8cd78 +3bfe6e70 +20c4d762 + +569cb8f7 +888dd932 +83f063da + +4bc971e7 +9bcf4665 + +06c36c5f +5b226e40 + +Test Set 12 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +729b1772 +311c4c92 +d04c9c35 +228c2f2f +98dbbd09 +03e0fd84 +98dbbd09 +44c0f23c +0c9fb816 +3c66cb98 + +9270dd87 +9744d675 +bd2262fa +06ac3268 +9b3b408d + +ccdf1bfe +b720f3b7 +810d2924 +a9e616ee + +29b4e9bb +e9b1cbd0 +d036fd13 +16db4ba1 + +5493cfd2 +13884c25 +cab2d33d + +41e48f19 +35dd0eab + +7e1d1012 +f3b440d8 + +Test Set 13 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +d32dd23e +cf7d0ab1 +fe75905b +d22a4b41 +af4a411e +be73b3dc +af4a411e +5af86b80 +7f4d6ae7 +9612b5d8 + +89dc6623 +d9430695 +9da47d35 +80a53257 +1139f2c2 + +54ca12eb +0bf12018 +6236d031 +08a5ff70 + +79dd32fa +fbd46887 +4e09c32e +d9f67ec7 + +edb70df5 +440e1878 +8a4130bb + +292cc112 +9a8b75ad + +1cbad50c +3f42f03a + +Test Set 14 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +af7c65e1 +1f0f8578 +0c7acb8d +a4cf5c81 +7bffa5c2 +8fe019c7 +7bffa5c2 +3f8c3f3c +abcbae8f +75a150df + +927221de +464fd59b +95b7d4a3 +55c08a7e +f41fbc05 + +591187a2 +64bed2d0 +1c5aca6d +ff418e54 + +c5987a53 +9436b57a +26345a88 +43b98e55 + +cf7625bf +d46115e9 +3c6aed08 + +77fc94bc +961a55d0 + +fd22fd26 +da5f2078 + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +13 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 15 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +5bd7ecd3 +59b75f14 +f967f760 +76089d3c +7e3f44c7 +27202b82 +7e3f44c7 +d42b2d61 +0b3f8d02 +b7f92e42 + +d3127a41 +251c7503 +38b920a9 +0ff3efdc +591f6f45 + +d12539be +1d0bcbac +cd25e10c +6e36721d + +d4e7cf71 +1c2c04c7 +08b49924 +4fceb747 + +5e49a03a +4fe6bfaf +6a36fec5 + +c275a5ae +aa982b8f + +f97af892 +82e319c2 + +Test Set 16 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +6cd1c6ce +f69b78f3 +078bfca9 +a219dc37 +70f6bdb9 +ddd7efe6 +70f6bdb9 +6edaf99e +d61c853c +88d9de10 + +b1e01e14 +00a0568b +564659ec +f1dc7d66 +ad21525f + +f1b82316 +ce9f0cb9 +d8851e84 +738b5843 + +a90b7f3d +3c4be4c9 +e6c59b48 +c799f206 + +5bd9f85d +280dd9c4 +a22004c5 + +5f36d91c +6f297bae + +1272fb4b +c386de17 + +Test Set 17 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +b73a90cb +b120f1c1 +b672047e +df0c6786 +479dd25c +67e4ff3f +479dd25c +66195dbe +66bec707 +a819e577 + +cf3afb62 +a0102a2f +003bb952 +8fa25f74 +20792d63 + +2dba83c5 +507dd543 +dca6cb8a +8b7044c6 + +8a8415df +de68281f +f0e5b779 +e7c245b8 + +d0313274 +eb2afc47 +a8d6175b + +c5ca7766 +6d7408a8 + +615fa25e +f2927b36 + +Test Set 18 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +51222502 +81e92b6c +c9e87632 +981d464c +28d7b0f2 +8a3b8d17 +28d7b0f2 +5349fbe0 +9744871a +9a8d0e88 + +14c33e72 +0ee0e12e +86b5b9ff +7c52eb6e +a2ec3de5 + +3a5dd523 +bceba8d9 +bdf56e12 +50362349 + +fc145fc0 +2a99dfa5 +97d0887b +84ad0bcf + +98649f94 +d32bf9bb +3ff0887a + +8f5d2e97 +d1dd5ce5 + +3a81c00f +4e3e2e5a + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +Test Set 19 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +90dca4ed +9fddc720 +3ffcfe5b +cb9cccc4 +a95100e2 +df58522f +a95100e2 +b5f2da03 +b4721368 +ed29b2f1 + +14 + +ETSI TS 155 205 V6.2.0 (2006-03) + +a45b53cf +92c6ad03 +7b111158 +b9258e6d +760952cd + +0f12d7c9 +6b6e4647 +9920d352 +ca476037 + +c3bc6a89 +89315b78 +8e84e655 +9fb82581 + +883b69f9 +bc16ea67 +c27f9f34 + +6bf52e02 +875c5598 + +9ed9ac45 +688bb0ef + diff --git a/tests/testsuite.at b/tests/testsuite.at index b782074..dc1de33 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -7,3 +7,10 @@ cat $abs_srcdir/auc/auc_3g_test.err > experr AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr]) AT_CLEANUP + +AT_SETUP([auc_ts_55_205_test_sets]) +AT_KEYWORDS([auc_ts_55_205_test_sets]) +cat $abs_srcdir/auc/auc_ts_55_205_test_sets.ok > expout +cat $abs_srcdir/auc/auc_ts_55_205_test_sets.err > experr +AT_CHECK([$abs_top_builddir/tests/auc/auc_ts_55_205_test_sets], [], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1721 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:45:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 13:45:07 +0000 Subject: openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: > well, we do. Follow the pack then? what now? are you being ironic?? :) I was going to abandon this now and adjusted #1682 to also use include "foo". I can change it back to <> again in a breeze, I just need an unambiguous opinion from reviewers. -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:57:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 13:57:48 +0000 Subject: osmo-iuh[master]: ranap: make X.213 NSAP 160 bits long, zero padded In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1648 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:58:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 13:58:13 +0000 Subject: osmo-iuh[master]: cs RAB: add nAS_SynchronisationIndicator In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1642 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 13:59:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 13:59:55 +0000 Subject: osmo-iuh[master]: cs RAB: lower guaranteedBitrate In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1643/2/src/ranap_msg_factory.c File src/ranap_msg_factory.c: PS2, Line 562: v I think it's best to add the guaranteed and max bitrate as function arguments here and use a #define for the default vailue (at least in case multiple callers call it, if it's only one caller the raw numbers are probably easier to read) -- To view, visit https://gerrit.osmocom.org/1643 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:00:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:00:17 +0000 Subject: osmo-iuh[master]: cs RAB: tweak sDU_ErrorRatio In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1644 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3169376bb182aba5926b7c974108bdc5fba04fa4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:01:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:01:36 +0000 Subject: osmo-iuh[master]: cs RAB: tweak sDU_ErrorRatio In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 I think this is pure operator policy. So there's no need to change our compile-time values. If at all, then those parameters should be made vty-configurable. But changing the hard-coded values from one set to another without a good reason every time we see a pcap file from some network doesn't make sense to me. -- To view, visit https://gerrit.osmocom.org/1644 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3169376bb182aba5926b7c974108bdc5fba04fa4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:01:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:01:44 +0000 Subject: osmo-iuh[master]: cs RAB: set allocationOrRetentionPriority=lowest In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 I think this is pure operator policy. So there's no need to change our compile-time values. If at all, then those parameters should be made vty-configurable. But changing the hard-coded values from one set to another without a good reason every time we see a pcap file from some network doesn't make sense to me. -- To view, visit https://gerrit.osmocom.org/1645 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0d7dc32bc93fa0a4d316f8378b3735dc11e87071 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:01:50 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:01:50 +0000 Subject: osmo-iuh[master]: cs RAB: toggle Pre_emptionVulnerability In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 I think this is pure operator policy. So there's no need to change our compile-time values. If at all, then those parameters should be made vty-configurable. But changing the hard-coded values from one set to another without a good reason every time we see a pcap file from some network doesn't make sense to me. -- To view, visit https://gerrit.osmocom.org/1646 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0f4d5a5e56bb6a3a3dfd6db8292d30f55fccdbc1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:01:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:01:58 +0000 Subject: osmo-iuh[master]: cs RAB: toggle QueuingAllowed In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 I think this is pure operator policy. So there's no need to change our compile-time values. If at all, then those parameters should be made vty-configurable. But changing the hard-coded values from one set to another without a good reason every time we see a pcap file from some network doesn't make sense to me. -- To view, visit https://gerrit.osmocom.org/1647 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I39a541c193eed9c15b2ce8fda306bb226c70647f Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:03:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:03:18 +0000 Subject: osmo-iuh[master]: cs RAB: add more SDU_FormatInformationParameter items In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 This introduces more different SDU sizes for different AMR(-WB?) codec mdoes. This is once again policy, and neither the old hard-coded value nor the new hardcoded values are "better" or "worse". If at all, it should be configurable, IMHO. Something like a list of codec modes, or a "profile" (set) of commonly used values that users can switch between. -- To view, visit https://gerrit.osmocom.org/1649 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I97e5c0b1e9ab9de00449b50a86d79a967af0d3f3 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:03:30 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:03:30 +0000 Subject: openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:03:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:03:41 +0000 Subject: openbsc[master]: paging.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1679 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4da0cb32476202d06902531d07faed8004f689f9 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:04:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:04:15 +0000 Subject: openbsc[master]: abis_om2000: drop unused function con_group_del() In-Reply-To: References: Message-ID: Patch Set 3: Code-Review-1 I would rather like to see the code completed to use the function than to see the function removed. -- To view, visit https://gerrit.osmocom.org/1680 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Idc47bf790fb680a3c322342170369993ec02f73a Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:04:24 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:04:24 +0000 Subject: openbsc[master]: gsm0408_rcv_cc: guard against NULL subscriber In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1662 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If067db7cc0dd3210d9eb1da15be6b637795a3ecf Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:05:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:05:13 +0000 Subject: openbsc[master]: log: disable imsi filter In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1685 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifecc3c55ae7c050ee53553d6f85d9afbede66ee3 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:06:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:06:17 +0000 Subject: openbsc[master]: SGSN: Integrate basic support for UMTS AKA In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:06:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:06:41 +0000 Subject: openbsc[master]: SGSN: Integrate basic support for UMTS AKA In-Reply-To: References: Message-ID: Patch Set 4: Code-Review-1 Indeed, without AUTS it doesn't make much sense, this needs to be added before we can merge it. -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:06:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:06:58 +0000 Subject: openbsc[master]: VTY: Print 3G auth tuples, not just 2G auth tuples In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1694 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I277e4347ee1486a39e6dc4e2363a593f328f9e3b Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:07:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:07:21 +0000 Subject: openbsc[master]: gsm48_tx_mm_auth_req(): support UMTS AUTN In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1695 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0d644559088706aa06b42b9bfe1f8c21ca6fa4da Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:07:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:07:58 +0000 Subject: openbsc[master]: add struct gprs_sub, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:08:59 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:08:59 +0000 Subject: openbsc[master]: add struct bsc_sub, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 4: (1 comment) https://gerrit.osmocom.org/#/c/1682/4/openbsc/include/openbsc/bsc_subscriber.h File openbsc/include/openbsc/bsc_subscriber.h: Line 10: struct bsc_sub { In general I would prefer if we retain the full _subscriber (so bsc_subscriber, gprs_subscriber) or at least bsc_subscr, gprs_subscr. "sub" just has too many other interpretations, like "sub-module" "subtract", ... -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:09:33 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:09:33 +0000 Subject: openbsc[master]: add struct bsc_sub, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:10:05 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:10:05 +0000 Subject: openbsc[master]: Introduce subscriber_connection ref-counting In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1681 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8c05e6c81f246ff8b5bf91312f80410b1a85f15e Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:10:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:10:40 +0000 Subject: osmo-hlr[master]: tests: auc_3g_test: implement vector generation test In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1720 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I291bccd62661ff5790dc43d91dc63a9e4b0e0ff2 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:11:08 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:11:08 +0000 Subject: osmo-hlr[master]: Add test suite skeleton with empty test (auc_3g_test) In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1719 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:11:33 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:11:33 +0000 Subject: osmo-hlr[master]: auth: verify test sets from 3GPP TS 55.205 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1721 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:11:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:11:34 +0000 Subject: [MERGED] osmo-hlr[master]: auth: verify test sets from 3GPP TS 55.205 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: auth: verify test sets from 3GPP TS 55.205 ...................................................................... auth: verify test sets from 3GPP TS 55.205 Put to-text conversion of the 3GPP TS 55.205 PDF's section defining the test vectors in tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt and add python script to generate auc_ts_55_205_test_sets.c from that at build time. The generated auc_ts_55_205_test_sets.c runs through all 19 test sets, verifying that our gsm_milenage() matches the reference data. Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd --- M .gitignore M configure.ac M tests/auc/Makefile.am M tests/auc/auc_3g_test.c A tests/auc/auc_ts_55_205_test_sets.err A tests/auc/auc_ts_55_205_test_sets.ok A tests/auc/gen_ts_55_205_test_sets/Makefile.am A tests/auc/gen_ts_55_205_test_sets/func_template.c A tests/auc/gen_ts_55_205_test_sets/main_template.c A tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py A tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt M tests/testsuite.at 12 files changed, 1,609 insertions(+), 14 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/.gitignore b/.gitignore index 17c4737..2e78dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.db +*.pyc .*.sw? .version Makefile @@ -25,3 +26,5 @@ tests/testsuite tests/auc/auc_3g_test +tests/auc/auc_ts_55_205_test_sets.c +tests/auc/auc_ts_55_205_test_sets diff --git a/configure.ac b/configure.ac index fbc1326..bfda9c5 100644 --- a/configure.ac +++ b/configure.ac @@ -48,4 +48,5 @@ sql/Makefile tests/Makefile tests/auc/Makefile + tests/auc/gen_ts_55_205_test_sets/Makefile ) diff --git a/tests/auc/Makefile.am b/tests/auc/Makefile.am index 1d506a7..761396b 100644 --- a/tests/auc/Makefile.am +++ b/tests/auc/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = gen_ts_55_205_test_sets + AM_CPPFLAGS = \ $(all_includes) \ -I$(top_srcdir)/src \ @@ -16,10 +18,14 @@ EXTRA_DIST = \ auc_3g_test.ok \ auc_3g_test.err \ + auc_ts_55_205_test_sets.ok \ + auc_ts_55_205_test_sets.err \ $(NULL) + noinst_PROGRAMS = \ auc_3g_test \ + auc_ts_55_205_test_sets \ $(NULL) auc_3g_test_SOURCES = \ @@ -32,3 +38,18 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(NULL) + +auc_ts_55_205_test_sets_SOURCES = \ + $(builddir)/auc_ts_55_205_test_sets.c \ + $(NULL) + +auc_ts_55_205_test_sets_LDADD = \ + $(top_srcdir)/src/auc.c \ + $(top_srcdir)/src/logging.c \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) + +auc_ts_55_205_test_sets.c: $(top_srcdir)/tests/auc/gen_ts_55_205_test_sets/* + $(top_srcdir)/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py > $@ + diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index bfca39f..0923a27 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -39,7 +40,7 @@ OSMO_ASSERT((val) expect_op); \ } while (0); -const char *vec_str(const struct osmo_auth_vector *vec) +char *vec_str(const struct osmo_auth_vector *vec) { static char buf[1024]; char *pos = buf; @@ -67,7 +68,7 @@ } #define VEC_IS(vec, expect) do { \ - const char *_is = vec_str(vec); \ + char *_is = vec_str(vec); \ fprintf(stderr, "auth vector ==\n%s\n", _is); \ if (strcmp(_is, expect)) { \ fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ @@ -78,7 +79,7 @@ if (*a != *b) { \ while (a > _is && *(a-1) != '\n') a--; \ fprintf(stderr, "mismatch at %d:\n" \ - "%s", a - _is, a); \ + "%s", (int)(a - _is), a); \ break; \ } \ } \ @@ -112,13 +113,13 @@ osmo_hexparse("EB215756028D60E3275E613320AEC880", aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); - aud3g = (struct osmo_sub_auth_data){ {0} }; + aud3g = (struct osmo_sub_auth_data){ 0 }; osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){ {0} }; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); @@ -134,7 +135,7 @@ " auth_types: 01000000\n" ); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); /* even though vec is not zero-initialized, it should produce the same * result (regardless of the umts sequence nr) */ @@ -188,7 +189,7 @@ fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){ {0} }; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); @@ -204,15 +205,15 @@ " auth_types: 03000000\n" ); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); /* even though vec is not zero-initialized, it should produce the same * result with the same sequence nr */ aud3g.u.umts.sqn = 0; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); VEC_IS(&vec, " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" @@ -254,7 +255,7 @@ fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){ {0} }; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); @@ -280,15 +281,15 @@ * hence expecting kc: 059a4f668f6fbe39 */ - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); /* even though vec is not zero-initialized, it should produce the same * result with the same sequence nr */ aud3g.u.umts.sqn = 0; - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); - VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64); VEC_IS(&vec, " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" diff --git a/tests/auc/auc_ts_55_205_test_sets.err b/tests/auc/auc_ts_55_205_test_sets.err new file mode 100644 index 0000000..9a26922 --- /dev/null +++ b/tests/auc/auc_ts_55_205_test_sets.err @@ -0,0 +1,304 @@ + +===== test_set_1 +aud3g.u.umts.sqn == 0 +DAUC rand 23553cbe9637a89d218ae64dae47bf35 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 23553cbe9637a89d218ae64dae47bf35 + ck: b40ba9a3c58b2a05bbf0d987b21bf8cb + ik: f769bcd751044604127672711c6d3441 + res: a54211d5e3ba50bf0000000000000000 + kc: eae4be823af9a08b + sres: 46f8416a + +===== test_set_1: SUCCESS + + +===== test_set_2 +aud3g.u.umts.sqn == 0 +DAUC rand 9f7c8d021accf4db213ccff0c7f71a6a +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 9f7c8d021accf4db213ccff0c7f71a6a + ck: 5dbdbb2954e8f3cde665b046179a5098 + ik: 59a92d3b476a0443487055cf88b2307b + res: 8011c48c0c214ed20000000000000000 + kc: aa01739b8caa976d + sres: 8c308a5e + +===== test_set_2: SUCCESS + + +===== test_set_3 +aud3g.u.umts.sqn == 0 +DAUC rand ce83dbc54ac0274a157c17f80d017bd6 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: ce83dbc54ac0274a157c17f80d017bd6 + ck: e203edb3971574f5a94b0d61b816345d + ik: 0c4524adeac041c4dd830d20854fc46b + res: f365cd683cd92e960000000000000000 + kc: 9a8ec95f408cc507 + sres: cfbce3fe + +===== test_set_3: SUCCESS + + +===== test_set_4 +aud3g.u.umts.sqn == 0 +DAUC rand 74b0cd6031a1c8339b2b6ce2b8c4a186 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 74b0cd6031a1c8339b2b6ce2b8c4a186 + ck: 7657766b373d1c2138f307e3de9242f9 + ik: 1c42e960d89b8fa99f2744e0708ccb53 + res: 5860fc1bce351e7e0000000000000000 + kc: cdc1dc0841b81a22 + sres: 9655e265 + +===== test_set_4: SUCCESS + + +===== test_set_5 +aud3g.u.umts.sqn == 0 +DAUC rand ee6466bc96202c5a557abbeff8babf63 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: ee6466bc96202c5a557abbeff8babf63 + ck: 3f8c7587fe8e4b233af676aede30ba3b + ik: a7466cc1e6b2a1337d49d3b66e95d7b4 + res: 16c8233f05a0ac280000000000000000 + kc: df75bc5ea899879f + sres: 13688f17 + +===== test_set_5: SUCCESS + + +===== test_set_6 +aud3g.u.umts.sqn == 0 +DAUC rand 194aa756013896b74b4a2a3b0af4539e +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 194aa756013896b74b4a2a3b0af4539e + ck: 4cd0846020f8fa0731dd47cbdc6be411 + ik: 88ab80a415f15c73711254a1d388f696 + res: 8c25a16cd918a1df0000000000000000 + kc: 84b417ae3aeab4f3 + sres: 553d00b3 + +===== test_set_6: SUCCESS + + +===== test_set_7 +aud3g.u.umts.sqn == 0 +DAUC rand 3a4c2b3245c50eb5c71d08639395764d +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 3a4c2b3245c50eb5c71d08639395764d + ck: 10f05bab75a99a5fbb98a9c287679c3b + ik: f9ec0865eb32f22369cade40c59c3a44 + res: a63241e1ffc3e5ab0000000000000000 + kc: 3b4e244cdc60ce03 + sres: 59f1a44a + +===== test_set_7: SUCCESS + + +===== test_set_8 +aud3g.u.umts.sqn == 0 +DAUC rand f761e5e93d603feb730e27556cb8a2ca +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: f761e5e93d603feb730e27556cb8a2ca + ck: 71236b7129f9b22ab77ea7a54c96da22 + ik: 90527ebaa5588968db41727325a04d9e + res: 4a90b2171ac83a760000000000000000 + kc: 8d4ec01de597acfe + sres: 50588861 + +===== test_set_8: SUCCESS + + +===== test_set_9 +aud3g.u.umts.sqn == 0 +DAUC rand 08eff828b13fdb562722c65c7f30a9b2 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 08eff828b13fdb562722c65c7f30a9b2 + ck: 08cef6d004ec61471a3c3cda048137fa + ik: ed0318ca5deb9206272f6e8fa64ba411 + res: 4bc2212d8624910a0000000000000000 + kc: d8debc4ffbcd60aa + sres: cde6b027 + +===== test_set_9: SUCCESS + + +===== test_set_10 +aud3g.u.umts.sqn == 0 +DAUC rand 679ac4dbacd7d233ff9d6806f4149ce3 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 679ac4dbacd7d233ff9d6806f4149ce3 + ck: 69b1cae7c7429d975e245cacb05a517c + ik: 74f24e8c26df58e1b38d7dcd4f1b7fbd + res: 6fc30fee6d1235230000000000000000 + kc: f0eaa50a1edcebb7 + sres: 02d13acd + +===== test_set_10: SUCCESS + + +===== test_set_11 +aud3g.u.umts.sqn == 0 +DAUC rand 4c47eb3076dc55fe5106cb2034b8cd78 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 4c47eb3076dc55fe5106cb2034b8cd78 + ck: 908c43f0569cb8f74bc971e706c36c5f + ik: c251df0d888dd9329bcf46655b226e40 + res: aefa357beac2a87a0000000000000000 + kc: 82dbab7f83f063da + sres: 44389d01 + +===== test_set_11: SUCCESS + + +===== test_set_12 +aud3g.u.umts.sqn == 0 +DAUC rand 311c4c929744d675b720f3b7e9b1cbd0 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 311c4c929744d675b720f3b7e9b1cbd0 + ck: 44c0f23c5493cfd241e48f197e1d1012 + ik: 0c9fb81613884c2535dd0eabf3b440d8 + res: 98dbbd099b3b408d0000000000000000 + kc: 3c66cb98cab2d33d + sres: 03e0fd84 + +===== test_set_12: SUCCESS + + +===== test_set_13 +aud3g.u.umts.sqn == 0 +DAUC rand cf7d0ab1d94306950bf12018fbd46887 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: cf7d0ab1d94306950bf12018fbd46887 + ck: 5af86b80edb70df5292cc1121cbad50c + ik: 7f4d6ae7440e18789a8b75ad3f42f03a + res: af4a411e1139f2c20000000000000000 + kc: 9612b5d88a4130bb + sres: be73b3dc + +===== test_set_13: SUCCESS + + +===== test_set_14 +aud3g.u.umts.sqn == 0 +DAUC rand 1f0f8578464fd59b64bed2d09436b57a +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 1f0f8578464fd59b64bed2d09436b57a + ck: 3f8c3f3ccf7625bf77fc94bcfd22fd26 + ik: abcbae8fd46115e9961a55d0da5f2078 + res: 7bffa5c2f41fbc050000000000000000 + kc: 75a150df3c6aed08 + sres: 8fe019c7 + +===== test_set_14: SUCCESS + + +===== test_set_15 +aud3g.u.umts.sqn == 0 +DAUC rand 59b75f14251c75031d0bcbac1c2c04c7 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 59b75f14251c75031d0bcbac1c2c04c7 + ck: d42b2d615e49a03ac275a5aef97af892 + ik: 0b3f8d024fe6bfafaa982b8f82e319c2 + res: 7e3f44c7591f6f450000000000000000 + kc: b7f92e426a36fec5 + sres: 27202b82 + +===== test_set_15: SUCCESS + + +===== test_set_16 +aud3g.u.umts.sqn == 0 +DAUC rand f69b78f300a0568bce9f0cb93c4be4c9 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: f69b78f300a0568bce9f0cb93c4be4c9 + ck: 6edaf99e5bd9f85d5f36d91c1272fb4b + ik: d61c853c280dd9c46f297baec386de17 + res: 70f6bdb9ad21525f0000000000000000 + kc: 88d9de10a22004c5 + sres: ddd7efe6 + +===== test_set_16: SUCCESS + + +===== test_set_17 +aud3g.u.umts.sqn == 0 +DAUC rand b120f1c1a0102a2f507dd543de68281f +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: b120f1c1a0102a2f507dd543de68281f + ck: 66195dbed0313274c5ca7766615fa25e + ik: 66bec707eb2afc476d7408a8f2927b36 + res: 479dd25c20792d630000000000000000 + kc: a819e577a8d6175b + sres: 67e4ff3f + +===== test_set_17: SUCCESS + + +===== test_set_18 +aud3g.u.umts.sqn == 0 +DAUC rand 81e92b6c0ee0e12ebceba8d92a99dfa5 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 81e92b6c0ee0e12ebceba8d92a99dfa5 + ck: 5349fbe098649f948f5d2e973a81c00f + ik: 9744871ad32bf9bbd1dd5ce54e3e2e5a + res: 28d7b0f2a2ec3de50000000000000000 + kc: 9a8d0e883ff0887a + sres: 8a3b8d17 + +===== test_set_18: SUCCESS + + +===== test_set_19 +aud3g.u.umts.sqn == 0 +DAUC rand 9fddc72092c6ad036b6e464789315b78 +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 9fddc72092c6ad036b6e464789315b78 + ck: b5f2da03883b69f96bf52e029ed9ac45 + ik: b4721368bc16ea67875c5598688bb0ef + res: a95100e2760952cd0000000000000000 + kc: ed29b2f1c27f9f34 + sres: df58522f + +===== test_set_19: SUCCESS + diff --git a/tests/auc/auc_ts_55_205_test_sets.ok b/tests/auc/auc_ts_55_205_test_sets.ok new file mode 100644 index 0000000..4eed389 --- /dev/null +++ b/tests/auc/auc_ts_55_205_test_sets.ok @@ -0,0 +1,2 @@ +3GPP TS 55.205 Test Sets +Done diff --git a/tests/auc/gen_ts_55_205_test_sets/Makefile.am b/tests/auc/gen_ts_55_205_test_sets/Makefile.am new file mode 100644 index 0000000..3225384 --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = \ + func_template.c \ + main_template.c \ + pdftxt_2_c.py \ + ts55_205_test_sets.txt \ + $(NULL) diff --git a/tests/auc/gen_ts_55_205_test_sets/func_template.c b/tests/auc/gen_ts_55_205_test_sets/func_template.c new file mode 100644 index 0000000..36926eb --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/func_template.c @@ -0,0 +1,64 @@ +/* gen_ts_55_205_test_sets/func_template.c: Template to generate test code + * from 3GPP TS 55.205 test sets */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +static void {func_name}(void) +{{ + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + + comment_start(); + + aud2g = (struct osmo_sub_auth_data){{ 0 }}; + + aud3g = (struct osmo_sub_auth_data){{ + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }}; + + osmo_hexparse("{Ki}", + aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); + osmo_hexparse("{OPc}", + aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); + + osmo_hexparse("{RAND}", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){{ {{0}} }}; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: {RAND}\n" + " ck: {MIL3G-CK}\n" + " ik: {MIL3G-IK}\n" + " res: {MIL3G-RES}0000000000000000\n" + " kc: {Kc}\n" + " sres: {SRES#1}\n" + ); + + comment_end(); +}} diff --git a/tests/auc/gen_ts_55_205_test_sets/main_template.c b/tests/auc/gen_ts_55_205_test_sets/main_template.c new file mode 100644 index 0000000..c03b820 --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/main_template.c @@ -0,0 +1,115 @@ +/* gen_ts_55_205_test_sets/main_template.c: Template to generate test code + * from 3GPP TS 55.205 test sets */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include +#include + +#include + +#include "logging.h" +#include "auc.h" + +#define comment_start() fprintf(stderr, "\n===== %s\n", __func__); +#define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + fprintf(stderr, #val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +char *vec_str(const struct osmo_auth_vector *vec) +{ + static char buf[1024]; + char *pos = buf; + char *end = buf + sizeof(buf); + +#define append(what) \ + if (pos >= end) \ + return buf; \ + pos += snprintf(pos, sizeof(buf) - (pos - buf), \ + " " #what ": %s\n", \ + osmo_hexdump_nospc((void*)&vec->what, sizeof(vec->what))) + + append(rand); + append(ck); + append(ik); + append(res); + append(kc); + append(sres); +#undef append + + return buf; +} + +#define VEC_IS(vec, expect) do { \ + char *_is = vec_str(vec); \ + fprintf(stderr, "auth vector ==\n%s\n", _is); \ + if (strcmp(_is, expect)) { \ + fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ + expect); \ + char *a = _is; \ + char *b = expect; \ + for (; *a && *b; a++, b++) { \ + if (*a != *b) { \ + while (a > _is && *(a-1) != '\n') a--; \ + fprintf(stderr, "mismatch at %d:\n" \ + "%s", (int)(a - _is), a); \ + break; \ + } \ + } \ + OSMO_ASSERT(false); \ + } \ + } while (0) + +uint8_t fake_rand[16] = { 0 }; + +int rand_get(uint8_t *rand, unsigned int len) +{ + OSMO_ASSERT(len <= sizeof(fake_rand)); + memcpy(rand, fake_rand, len); + return len; +} + +FUNCTIONS + +int main() +{ + printf("3GPP TS 55.205 Test Sets\n"); + osmo_init_logging(&hlr_log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + +FUNCTION_CALLS + + printf("Done\n"); + return 0; +} diff --git a/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py b/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py new file mode 100755 index 0000000..0efa7ac --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 + +# Convert test sets pasted from 3GPP TS 55.205 to C code. + +# (C) 2016 by sysmocom s.f.m.c. GmbH +# +# All Rights Reserved +# +# Author: Neels Hofmeyr +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import sys, os + +script_dir = sys.path[0] + +fields = ( + 'Ki', + 'RAND', + 'OP', + 'OPc', + 'MIL3G-RES', + 'SRES#1', + 'SRES#2', + 'MIL3G-CK', + 'MIL3G-IK', + 'Kc', +) + +test_sets_lines = [] +test_set_lines = None + +for line in [l.strip() for l in open(os.path.join(script_dir, 'ts55_205_test_sets.txt'), 'r')]: + if line.startswith('Test Set'): + if test_set_lines: + test_sets_lines.append(test_set_lines) + test_set_lines = [] + elif len(line) == 8: + try: + is_hex = int(line, 16) + test_set_lines.append(line) + except ValueError: + pass + +if test_set_lines: + test_sets_lines.append(test_set_lines) + +# Magic fixups for PDF-to-text uselessness +idx = (( 0, 10, 15, 19), + ( 1, 11, 16, 20), + ( 2, 12, 17, 21), + ( 3, 13, 18, 22), + ( 4, 14), + ( 5, ), + ( 6, ), + ( 7, 23, 26, 28), + ( 8, 24, 27, 29), + ( 9, 25 ), + ) + +test_sets = [] +for l in test_sets_lines: + test_sets.append( [ ''.join([l[i] for i in li]) for li in idx ] ) + +func_templ = open(os.path.join(script_dir, 'func_template.c'), 'r').read() + +funcs = [] +func_calls = [] +nr = 0 +for test_set in test_sets: + nr += 1 + func_name = 'test_set_%d' % nr + kwargs = dict(zip(fields, test_set)) + kwargs['func_name'] = func_name + + func_calls.append('\t%s();' % func_name) + funcs.append(func_templ.format(**kwargs)) + +templ = open(os.path.join(script_dir, 'main_template.c')).read() + +code = templ.replace('FUNCTIONS', '\n'.join(funcs)).replace('FUNCTION_CALLS', '\n'.join(func_calls)) + +print(''' +/***** DO NOT EDIT THIS FILE -- THIS CODE IS GENERATED ***** + ***** by gen_ts_55_205_test_sets/pdftxt_2_c.py *****/ +''') +print(code) + diff --git a/tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt b/tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt new file mode 100644 index 0000000..0d4d14b --- /dev/null +++ b/tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt @@ -0,0 +1,972 @@ + +Test Set 1 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +465b5ce8 +23553cbe +cdc202d5 +cd63cb71 +a54211d5 +46f8416a +a54211d5 +b40ba9a3 +f769bcd7 +eae4be82 + +b199b49f +9637a89d +123e20f6 +954a9f4e +e3ba50bf + +aa5f0a2e +218ae64d +2b6d676a +48a5994e + +e238a6bc +ae47bf35 +c72cb318 +37a02baf + +c58b2a05 +51044604 +3af9a08b + +bbf0d987 +12767271 + +b21bf8cb +1c6d3441 + +Test Set 2 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +fec86ba6 +9f7c8d02 +dbc59adc +1006020f +8011c48c +8c308a5e +8011c48c +5dbdbb29 +59a92d3b +aa01739b + +eb707ed0 +1accf4db +b6f9a0ef +0a478bf6 +0c214ed2 + +8905757b +213ccff0 +735477b7 +b699f15c + +1bb44b8f +c7f71a6a +fadf8374 +062e42b3 + +54e8f3cd +476a0443 +8caa976d + +e665b046 +487055cf + +179a5098 +88b2307b + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +10 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 3 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +9e5944ae +ce83dbc5 +223014c5 +a64a507a +f365cd68 +cfbce3fe +f365cd68 +e203edb3 +0c4524ad +9a8ec95f + +a94b8116 +4ac0274a +806694c0 +e1a2a98b +3cd92e96 + +5c82fbf9 +157c17f8 +07ca1eee +b88eb421 + +f32db751 +0d017bd6 +f57f004f +0135dc87 + +971574f5 +eac041c4 +408cc507 + +a94b0d61 +dd830d20 + +b816345d +854fc46b + +Test Set 4 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +4ab1deb0 +74b0cd60 +2d16c5cd +dcf07cbd +5860fc1b +9655e265 +5860fc1b +7657766b +1c42e960 +cdc1dc08 + +5ca6ceb0 +31a1c833 +1fdf6b22 +51855290 +ce351e7e + +51fc98e7 +9b2b6ce2 +383584e3 +b92a07a9 + +7d026a84 +b8c4a186 +bef2a8d8 +891e523e + +373d1c21 +d89b8fa9 +41b81a22 + +38f307e3 +9f2744e0 + +de9242f9 +708ccb53 + +Test Set 5 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +6c38a116 +ee6466bc +1ba00a1a +3803ef53 +16c8233f +13688f17 +16c8233f +3f8c7587 +a7466cc1 +df75bc5e + +ac280c45 +96202c5a +7c6700ac +63b947c6 +05a0ac28 + +4f59332e +557abbef +8c3ff3e9 +aaa225e5 + +e35c8c4f +f8babf63 +6ad08725 +8fae3934 + +fe8e4b23 +e6b2a133 +a899879f + +3af676ae +7d49d3b6 + +de30ba3b +6e95d7b4 + +Test Set 6 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +2d609d4d +194aa756 +460a4838 +c35a0ab0 +8c25a16c +553d00b3 +8c25a16c +4cd08460 +88ab80a4 +84b417ae + +b0ac5bf0 +013896b7 +5427aa39 +bcbfc925 +d918a1df + +d2c0de26 +4b4a2a3b +264aac8e +2caff15f + +7014de0d +0af4539e +fc9e73e8 +24efbde0 + +20f8fa07 +15f15c73 +3aeab4f3 + +31dd47cb +711254a1 + +dc6be411 +d388f696 + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +11 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 7 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +a530a7fe +3a4c2b32 +511c6c4e +27953e49 +a63241e1 +59f1a44a +a63241e1 +10f05bab +f9ec0865 +3b4e244c + +428fad10 +45c50eb5 +83e38c89 +bc8af6dc +ffc3e5ab + +82c45edd +c71d0863 +b1c5d8dd +c6e730eb + +fce13884 +9395764d +e62426fa +80286be3 + +75a99a5f +eb32f223 +dc60ce03 + +bb98a9c2 +69cade40 + +87679c3b +c59c3a44 + +Test Set 8 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +d9151cf0 +f761e5e9 +75fc2233 +c4c93eff +4a90b217 +50588861 +4a90b217 +71236b71 +90527eba +8d4ec01d + +4896e258 +3d603feb +a44294ee +e8a08138 +1ac83a76 + +30bf2e08 +730e2755 +8e6de25c +c203d4c2 + +267b8360 +6cb8a2ca +4353d26b +7ce4e3d9 + +29f9b22a +a5588968 +e597acfe + +b77ea7a5 +db417273 + +4c96da22 +25a04d9e + +Test Set 9 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +a0e2971b +08eff828 +323792fa +82a26f22 +4bc2212d +cde6b027 +4bc2212d +08cef6d0 +ed0318ca +d8debc4f + +6822e8d3 +b13fdb56 +ca21fb4d +bba9e948 +8624910a + +54a18cc2 +2722c65c +5d6f13c1 +8f949a10 + +35624ecb +7f30a9b2 +45a9d2c1 +d98e9cc4 + +04ec6147 +5deb9206 +fbcd60aa + +1a3c3cda +272f6e8f + +048137fa +a64ba411 + +Test Set 10 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +0da6f7ba +679ac4db +4b9a26fa +0db1071f +6fc30fee +02d13acd +6fc30fee +69b1cae7 +74f24e8c +f0eaa50a + +86d5eac8 +acd7d233 +459e3acb +8767562c +6d123523 + +a19cf563 +ff9d6806 +ff36f401 +a43a0a64 + +ac58642d +f4149ce3 +5de3bdc1 +c41e8d08 + +c7429d97 +26df58e1 +1edcebb7 + +5e245cac +b38d7dcd + +b05a517c +4f1b7fbd + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +12 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 11 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +77b45843 +4c47eb30 +bf3286c7 +d483afae +aefa357b +44389d01 +aefa357b +908c43f0 +c251df0d +82dbab7f + +c88e58c1 +76dc55fe +a51409ce +562409a3 +eac2a87a + +0d202684 +5106cb20 +95724d50 +26b5bb0b + +515ed430 +34b8cd78 +3bfe6e70 +20c4d762 + +569cb8f7 +888dd932 +83f063da + +4bc971e7 +9bcf4665 + +06c36c5f +5b226e40 + +Test Set 12 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +729b1772 +311c4c92 +d04c9c35 +228c2f2f +98dbbd09 +03e0fd84 +98dbbd09 +44c0f23c +0c9fb816 +3c66cb98 + +9270dd87 +9744d675 +bd2262fa +06ac3268 +9b3b408d + +ccdf1bfe +b720f3b7 +810d2924 +a9e616ee + +29b4e9bb +e9b1cbd0 +d036fd13 +16db4ba1 + +5493cfd2 +13884c25 +cab2d33d + +41e48f19 +35dd0eab + +7e1d1012 +f3b440d8 + +Test Set 13 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +d32dd23e +cf7d0ab1 +fe75905b +d22a4b41 +af4a411e +be73b3dc +af4a411e +5af86b80 +7f4d6ae7 +9612b5d8 + +89dc6623 +d9430695 +9da47d35 +80a53257 +1139f2c2 + +54ca12eb +0bf12018 +6236d031 +08a5ff70 + +79dd32fa +fbd46887 +4e09c32e +d9f67ec7 + +edb70df5 +440e1878 +8a4130bb + +292cc112 +9a8b75ad + +1cbad50c +3f42f03a + +Test Set 14 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +af7c65e1 +1f0f8578 +0c7acb8d +a4cf5c81 +7bffa5c2 +8fe019c7 +7bffa5c2 +3f8c3f3c +abcbae8f +75a150df + +927221de +464fd59b +95b7d4a3 +55c08a7e +f41fbc05 + +591187a2 +64bed2d0 +1c5aca6d +ff418e54 + +c5987a53 +9436b57a +26345a88 +43b98e55 + +cf7625bf +d46115e9 +3c6aed08 + +77fc94bc +961a55d0 + +fd22fd26 +da5f2078 + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +13 + +ETSI TS 155 205 V6.2.0 (2006-03) + +Test Set 15 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +5bd7ecd3 +59b75f14 +f967f760 +76089d3c +7e3f44c7 +27202b82 +7e3f44c7 +d42b2d61 +0b3f8d02 +b7f92e42 + +d3127a41 +251c7503 +38b920a9 +0ff3efdc +591f6f45 + +d12539be +1d0bcbac +cd25e10c +6e36721d + +d4e7cf71 +1c2c04c7 +08b49924 +4fceb747 + +5e49a03a +4fe6bfaf +6a36fec5 + +c275a5ae +aa982b8f + +f97af892 +82e319c2 + +Test Set 16 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +6cd1c6ce +f69b78f3 +078bfca9 +a219dc37 +70f6bdb9 +ddd7efe6 +70f6bdb9 +6edaf99e +d61c853c +88d9de10 + +b1e01e14 +00a0568b +564659ec +f1dc7d66 +ad21525f + +f1b82316 +ce9f0cb9 +d8851e84 +738b5843 + +a90b7f3d +3c4be4c9 +e6c59b48 +c799f206 + +5bd9f85d +280dd9c4 +a22004c5 + +5f36d91c +6f297bae + +1272fb4b +c386de17 + +Test Set 17 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +b73a90cb +b120f1c1 +b672047e +df0c6786 +479dd25c +67e4ff3f +479dd25c +66195dbe +66bec707 +a819e577 + +cf3afb62 +a0102a2f +003bb952 +8fa25f74 +20792d63 + +2dba83c5 +507dd543 +dca6cb8a +8b7044c6 + +8a8415df +de68281f +f0e5b779 +e7c245b8 + +d0313274 +eb2afc47 +a8d6175b + +c5ca7766 +6d7408a8 + +615fa25e +f2927b36 + +Test Set 18 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +51222502 +81e92b6c +c9e87632 +981d464c +28d7b0f2 +8a3b8d17 +28d7b0f2 +5349fbe0 +9744871a +9a8d0e88 + +14c33e72 +0ee0e12e +86b5b9ff +7c52eb6e +a2ec3de5 + +3a5dd523 +bceba8d9 +bdf56e12 +50362349 + +fc145fc0 +2a99dfa5 +97d0887b +84ad0bcf + +98649f94 +d32bf9bb +3ff0887a + +8f5d2e97 +d1dd5ce5 + +3a81c00f +4e3e2e5a + +ETSI + + 3GPP TS 55.205 version 6.2.0 Release 6 + +Test Set 19 +Ki +RAND +OP +OPc +MIL3G-RES +SRES#1 +SRES#2 +MIL3G-CK +MIL3G-IK +Kc + +90dca4ed +9fddc720 +3ffcfe5b +cb9cccc4 +a95100e2 +df58522f +a95100e2 +b5f2da03 +b4721368 +ed29b2f1 + +14 + +ETSI TS 155 205 V6.2.0 (2006-03) + +a45b53cf +92c6ad03 +7b111158 +b9258e6d +760952cd + +0f12d7c9 +6b6e4647 +9920d352 +ca476037 + +c3bc6a89 +89315b78 +8e84e655 +9fb82581 + +883b69f9 +bc16ea67 +c27f9f34 + +6bf52e02 +875c5598 + +9ed9ac45 +688bb0ef + diff --git a/tests/testsuite.at b/tests/testsuite.at index b782074..dc1de33 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -7,3 +7,10 @@ cat $abs_srcdir/auc/auc_3g_test.err > experr AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr]) AT_CLEANUP + +AT_SETUP([auc_ts_55_205_test_sets]) +AT_KEYWORDS([auc_ts_55_205_test_sets]) +cat $abs_srcdir/auc/auc_ts_55_205_test_sets.ok > expout +cat $abs_srcdir/auc/auc_ts_55_205_test_sets.err > experr +AT_CHECK([$abs_top_builddir/tests/auc/auc_ts_55_205_test_sets], [], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1721 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:11:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:11:34 +0000 Subject: [MERGED] osmo-hlr[master]: Add test suite skeleton with empty test (auc_3g_test) In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add test suite skeleton with empty test (auc_3g_test) ...................................................................... Add test suite skeleton with empty test (auc_3g_test) Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 --- M .gitignore M Makefile.am M configure.ac A tests/Makefile.am A tests/auc/Makefile.am A tests/auc/auc_3g_test.c A tests/auc/auc_3g_test.err A tests/auc/auc_3g_test.ok A tests/testsuite.at 9 files changed, 167 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/.gitignore b/.gitignore index d06928b..17c4737 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ src/osmo-hlr src/db_test + +tests/testsuite +tests/auc/auc_3g_test diff --git a/Makefile.am b/Makefile.am index 40dad90..0d60cee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = \ src \ sql \ + tests \ $(NULL) EXTRA_DIST = \ diff --git a/configure.ac b/configure.ac index 3ac99c7..fbc1326 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,8 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.9]) +AC_CONFIG_TESTDIR(tests) + dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -44,4 +46,6 @@ Makefile src/Makefile sql/Makefile + tests/Makefile + tests/auc/Makefile ) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..21c0e21 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,50 @@ +SUBDIRS = \ + auc \ + $(NULL) + +# The `:;' works around a Bash 3.2 bug when the output is not writeable. +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + :;{ \ + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = \ + testsuite.at \ + $(srcdir)/package.m4 \ + $(TESTSUITE) \ + $(NULL) + +TESTSUITE = $(srcdir)/testsuite + +DISTCLEANFILES = \ + atconfig \ + $(NULL) + +check-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + +installcheck-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ + $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || \ + $(SHELL) '$(TESTSUITE)' --clean + +AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ diff --git a/tests/auc/Makefile.am b/tests/auc/Makefile.am new file mode 100644 index 0000000..1d506a7 --- /dev/null +++ b/tests/auc/Makefile.am @@ -0,0 +1,34 @@ +AM_CPPFLAGS = \ + $(all_includes) \ + -I$(top_srcdir)/src \ + $(NULL) + +AM_CFLAGS = \ + -Wall \ + -ggdb3 \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(NULL) + +AM_LDFLAGS = \ + $(NULL) + +EXTRA_DIST = \ + auc_3g_test.ok \ + auc_3g_test.err \ + $(NULL) + +noinst_PROGRAMS = \ + auc_3g_test \ + $(NULL) + +auc_3g_test_SOURCES = \ + auc_3g_test.c \ + $(NULL) + +auc_3g_test_LDADD = \ + $(top_srcdir)/src/auc.c \ + $(top_srcdir)/src/logging.c \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c new file mode 100644 index 0000000..1444f46 --- /dev/null +++ b/tests/auc/auc_3g_test.c @@ -0,0 +1,61 @@ +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include + +#include "logging.h" + +#define comment_start() fprintf(stderr, "===== %s\n", __func__); +#define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +uint8_t fake_rand[16] = { 0 }; + +int rand_get(uint8_t *rand, unsigned int len) +{ + OSMO_ASSERT(len <= sizeof(fake_rand)); + memcpy(rand, fake_rand, len); + return len; +} + +static void test_gen_vectors_3g_only(void) +{ + comment_start(); + comment_end(); +} + +int main() +{ + printf("auc_3g_test.c\n"); + osmo_init_logging(&hlr_log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + + test_gen_vectors_3g_only(); + + printf("Done\n"); + return 0; +} diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err new file mode 100644 index 0000000..c29640a --- /dev/null +++ b/tests/auc/auc_3g_test.err @@ -0,0 +1,3 @@ +===== test_gen_vectors_3g_only +===== test_gen_vectors_3g_only: SUCCESS + diff --git a/tests/auc/auc_3g_test.ok b/tests/auc/auc_3g_test.ok new file mode 100644 index 0000000..81272cd --- /dev/null +++ b/tests/auc/auc_3g_test.ok @@ -0,0 +1,2 @@ +auc_3g_test.c +Done diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..b782074 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,9 @@ +AT_INIT +AT_BANNER([Regression tests.]) + +AT_SETUP([auc]) +AT_KEYWORDS([auc]) +cat $abs_srcdir/auc/auc_3g_test.ok > expout +cat $abs_srcdir/auc/auc_3g_test.err > experr +AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1719 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6359b0809ce8578850fd65887a568714fb35dbd8 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:11:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:11:35 +0000 Subject: [MERGED] osmo-hlr[master]: tests: auc_3g_test: implement vector generation test In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: tests: auc_3g_test: implement vector generation test ...................................................................... tests: auc_3g_test: implement vector generation test Change-Id: I291bccd62661ff5790dc43d91dc63a9e4b0e0ff2 --- M src/auc.c M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 3 files changed, 371 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/auc.c b/src/auc.c index 7d8597a..bec3ea6 100644 --- a/src/auc.c +++ b/src/auc.c @@ -47,6 +47,7 @@ /* compute quintuples */ for (i = 0; i < num_vec; i++) { rc = rand_get(rand, sizeof(rand)); + DEBUGP(DAUC, "rand %s\n", osmo_hexdump_nospc(rand, sizeof(rand))); if (rc != sizeof(rand)) { LOGP(DAUC, LOGL_ERROR, "Unable to read %zu random " "bytes: rc=%d\n", sizeof(rand), rc); @@ -65,8 +66,9 @@ } } else if (aud3g) { /* 3G or 3G + 2G case */ - DEBUGP(DAUC, "compute vector [%u]/%u: 3G or 3G + 2G\n", - i, num_vec); + if (!aud2g) + DEBUGP(DAUC, "compute vector [%u]/%u: 3G only\n", + i, num_vec); if (rand_auts && auts) rc = osmo_auth_gen_vec_auts(vec+i, aud3g, rand_auts, diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 1444f46..bfca39f 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -25,10 +25,66 @@ #include #include -#include "logging.h" +#include -#define comment_start() fprintf(stderr, "===== %s\n", __func__); +#include "logging.h" +#include "auc.h" + +#define comment_start() fprintf(stderr, "\n===== %s\n", __func__); #define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__); + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + fprintf(stderr, #val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +const char *vec_str(const struct osmo_auth_vector *vec) +{ + static char buf[1024]; + char *pos = buf; + char *end = buf + sizeof(buf); + +#define append(what) \ + if (pos >= end) \ + return buf; \ + pos += snprintf(pos, sizeof(buf) - (pos - buf), \ + " " #what ": %s\n", \ + osmo_hexdump_nospc((void*)&vec->what, sizeof(vec->what))) + + append(rand); + append(autn); + append(ck); + append(ik); + append(res); + append(res_len); + append(kc); + append(sres); + append(auth_types); +#undef append + + return buf; +} + +#define VEC_IS(vec, expect) do { \ + const char *_is = vec_str(vec); \ + fprintf(stderr, "auth vector ==\n%s\n", _is); \ + if (strcmp(_is, expect)) { \ + fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ + expect); \ + char *a = _is; \ + char *b = expect; \ + for (; *a && *b; a++, b++) { \ + if (*a != *b) { \ + while (a > _is && *(a-1) != '\n') a--; \ + fprintf(stderr, "mismatch at %d:\n" \ + "%s", a - _is, a); \ + break; \ + } \ + } \ + OSMO_ASSERT(false); \ + } \ + } while (0) uint8_t fake_rand[16] = { 0 }; @@ -39,9 +95,213 @@ return len; } +static void test_gen_vectors_2g_only(void) +{ + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + + comment_start(); + + aud2g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); + + aud3g = (struct osmo_sub_auth_data){ {0} }; + + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){ {0} }; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 00000000000000000000000000000000\n" + " ck: 00000000000000000000000000000000\n" + " ik: 00000000000000000000000000000000\n" + " res: 00000000000000000000000000000000\n" + " res_len: 00\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 01000000\n" + ); + + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + + /* even though vec is not zero-initialized, it should produce the same + * result (regardless of the umts sequence nr) */ + aud3g.u.umts.sqn = 123; + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 00000000000000000000000000000000\n" + " ck: 00000000000000000000000000000000\n" + " ik: 00000000000000000000000000000000\n" + " res: 00000000000000000000000000000000\n" + " res_len: 00\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 01000000\n" + ); + + comment_end(); +} + +static void test_gen_vectors_2g_plus_3g(void) +{ + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + + comment_start(); + + aud2g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); + + aud3g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); + osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", + aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); + + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){ {0} }; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 03000000\n" + ); + + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + /* even though vec is not zero-initialized, it should produce the same + * result with the same sequence nr */ + aud3g.u.umts.sqn = 0; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 241a5b16aeb8e400\n" + " sres: 429d5b27\n" + " auth_types: 03000000\n" + ); + + comment_end(); +} + static void test_gen_vectors_3g_only(void) { + struct osmo_sub_auth_data aud2g; + struct osmo_sub_auth_data aud3g; + struct osmo_auth_vector vec; + int rc; + comment_start(); + + aud2g = (struct osmo_sub_auth_data){ 0 }; + + aud3g = (struct osmo_sub_auth_data){ + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + osmo_hexparse("EB215756028D60E3275E613320AEC880", + aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); + osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", + aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); + + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + fake_rand, sizeof(fake_rand)); + + vec = (struct osmo_auth_vector){ {0} }; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 059a4f668f6fbe39\n" + " sres: 9b36efdf\n" + " auth_types: 03000000\n" + ); + + /* Note: 3GPP TS 33.102 6.8.1.2: c3 function to get GSM auth is + * KC[0..7] == CK[0..7] ^ CK[8..15] ^ IK[0..7] ^ IK[8..15] + * In [16]: hex( 0xf64735036e587131 + * ^ 0x9c679f4742a75ea1 + * ^ 0x27497388b6cb0446 + * ^ 0x48f396aa155b95ef) + * Out[16]: '0x59a4f668f6fbe39L' + * hence expecting kc: 059a4f668f6fbe39 + */ + + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + /* even though vec is not zero-initialized, it should produce the same + * result with the same sequence nr */ + aud3g.u.umts.sqn = 0; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d"); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 1, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d"); + + VEC_IS(&vec, + " rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n" + " autn: 8704f5ba55f30000d2ee44b22c8ea919\n" + " ck: f64735036e5871319c679f4742a75ea1\n" + " ik: 27497388b6cb044648f396aa155b95ef\n" + " res: e229c19e791f2e410000000000000000\n" + " res_len: 08\n" + " kc: 059a4f668f6fbe39\n" + " sres: 9b36efdf\n" + " auth_types: 03000000\n" + ); + comment_end(); } @@ -54,6 +314,8 @@ log_set_use_color(osmo_stderr_target, 0); log_set_print_category(osmo_stderr_target, 1); + test_gen_vectors_2g_only(); + test_gen_vectors_2g_plus_3g(); test_gen_vectors_3g_only(); printf("Done\n"); diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index c29640a..ec5ba28 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -1,3 +1,106 @@ + +===== test_gen_vectors_2g_only +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 2G only +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 00000000000000000000000000000000 + ck: 00000000000000000000000000000000 + ik: 00000000000000000000000000000000 + res: 00000000000000000000000000000000 + res_len: 00 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 01000000 + +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 2G only +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 00000000000000000000000000000000 + ck: 00000000000000000000000000000000 + ik: 00000000000000000000000000000000 + res: 00000000000000000000000000000000 + res_len: 00 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 01000000 + +===== test_gen_vectors_2g_only: SUCCESS + + +===== test_gen_vectors_2g_plus_3g +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: separate 2G + 3G +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 03000000 + +aud3g.u.umts.sqn == 1 +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: separate 2G + 3G +rc == 1 +aud3g.u.umts.sqn == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 241a5b16aeb8e400 + sres: 429d5b27 + auth_types: 03000000 + +===== test_gen_vectors_2g_plus_3g: SUCCESS + + ===== test_gen_vectors_3g_only +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 3G only +rc == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 059a4f668f6fbe39 + sres: 9b36efdf + auth_types: 03000000 + +aud3g.u.umts.sqn == 1 +aud3g.u.umts.sqn == 0 +DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC compute vector [0]/1: 3G only +rc == 1 +aud3g.u.umts.sqn == 1 +auth vector == + rand: 39fa2f4e3d523d8619a73b4f65c3e14d + autn: 8704f5ba55f30000d2ee44b22c8ea919 + ck: f64735036e5871319c679f4742a75ea1 + ik: 27497388b6cb044648f396aa155b95ef + res: e229c19e791f2e410000000000000000 + res_len: 08 + kc: 059a4f668f6fbe39 + sres: 9b36efdf + auth_types: 03000000 + ===== test_gen_vectors_3g_only: SUCCESS -- To view, visit https://gerrit.osmocom.org/1720 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I291bccd62661ff5790dc43d91dc63a9e4b0e0ff2 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:13:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:13:15 +0000 Subject: osmo-bts[master]: Fixes AMR HR DTX FSM logic. In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 I would love to merge this, but it would be greta to have more than a one-line commit log message about what it actually fixes. Thanks! -- To view, visit https://gerrit.osmocom.org/1659 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: jfdionne Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:14:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:14:55 +0000 Subject: [MERGED] osmo-iuh[master]: cs RAB: add nAS_SynchronisationIndicator In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: cs RAB: add nAS_SynchronisationIndicator ...................................................................... cs RAB: add nAS_SynchronisationIndicator This is mimicking the IEs found in a trace from a production 3G environment. We have no reason to add this other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 19 insertions(+), 11 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 16a9d03..cd2ddfc 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -588,6 +588,14 @@ return rab; } +static RANAP_NAS_SynchronisationIndicator_t *new_rab_nas_sync_ind(int val) +{ + uint8_t val_buf = (val / 10) << 4; + RANAP_NAS_SynchronisationIndicator_t *nsi = CALLOC(1, sizeof(*nsi)); + BIT_STRING_fromBuf(nsi, &val_buf, 4); + return nsi; +} + static RANAP_RAB_Parameters_t *new_rab_par_data(uint32_t dl_max_bitrate, uint32_t ul_max_bitrate) { RANAP_RAB_Parameters_t *rab = CALLOC(1, sizeof(*rab)); @@ -729,7 +737,7 @@ RANAP_RAB_SetupOrModifyItemFirst_t first; memset(&first, 0, sizeof(first)); assign_new_ra_id(&first.rAB_ID, rab_id); - //first.nAS_SynchronisationIndicator = FIXME; + first.nAS_SynchronisationIndicator = new_rab_nas_sync_ind(60); first.rAB_Parameters = new_rab_par_voice(); first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_support_mode_for_predefined_SDU_sizes, 1); /* 2? */ first.transportLayerInformation = new_transp_info_rtp(rtp_ip, rtp_port, diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index bda3c8e..dc959eb 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -88,10 +88,10 @@ 53 - 38 02 D8 01 2F A7 20 2F A8 00 00 F4 4C 08 0A 02 - 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 - 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 00 - 01 0A 0B 0C 0D 40 09 26 00 00 + 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A + 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 + 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 + 00 01 0A 0B 0C 0D 40 09 26 00 00 00 @@ -100,14 +100,14 @@ 54 - 00 00 01 00 35 00 3A 38 02 D8 01 2F A7 20 2F A8 - 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 - 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D - 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 00 - 00 40 01 00 + 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 2F + A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 + 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 + 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 + 00 00 40 01 00 -00 00 00 4b 00 00 01 00 36 40 44 00 00 01 00 35 00 3a 38 02 d8 01 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1642 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I14c22b0befb308bac2eded662fe13a58c8478743 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:18:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:18:17 +0000 Subject: openbsc[master]: sgsn: Fix deeply flawed copying logic for PDP context activa... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1686 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I564526e7cde2b8a2f0ce900492cd38fc23c176a7 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:19:05 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:19:05 +0000 Subject: [MERGED] osmo-pcu[master]: cosmetic: Fix log output In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: cosmetic: Fix log output ...................................................................... cosmetic: Fix log output In BTS::rcv_rach() the log output is messed up because of a stray "\n". This commit removes that. Change-Id: I40d01c71982ad83589f070cf0047a4ae04695411 --- M src/bts.cpp M tests/tbf/TbfTest.err 2 files changed, 32 insertions(+), 62 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/bts.cpp b/src/bts.cpp index e1c6dcc..21e9d96 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -552,8 +552,8 @@ Fn = Fn + m_cur_fn - m_cur_fn % 42432; LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF on RACH, " - "so we provide one \n" - "ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", ra, Fn, qta, is_11bit); + "so we provide one: ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", + ra, Fn, qta, is_11bit); sb = is_single_block(ra, burst_type, is_11bit, &ms_class, &priority); diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index 575b7fb..3412bde 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -1510,8 +1510,7 @@ MSG = 07 01 04 4d 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 Searching for first unallocated TFI: TRX=0 Found TFI=0. -MS requests UL TBF on RACH, so we provide one -ra=0x03 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x03 Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -1585,8 +1584,7 @@ Sending data request: trx=0 ts=0 sapi=3 arfcn=0 fn=0 block=0 data=33 34 34 2d 06 3f 30 0f 00 00 7d 80 00 07 00 df 12 23 34 48 00 23 2b 2b 2b 2b TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) append Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -1671,8 +1669,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) starting timer 0. TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) append Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -1806,8 +1803,7 @@ - Copying data unit 0 (BSN 0) msg block (BSN 0, CS-4): 07 01 00 29 52 41 55 5f 41 43 43 45 50 54 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654283 block=11 data=00 01 00 29 52 41 55 5f 41 43 43 45 50 54 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654232 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654232 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654232 (17,39,22), SBFn=2654335 TX: Immediate Assignment Uplink (AGCH) @@ -1883,8 +1879,7 @@ Modifying MS object, TLLI: 0xf5667788 confirmed New MS: TLLI = 0xf5667788, TA = 7, IMSI = 0011223344, LLC = 1 Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -1977,8 +1972,7 @@ Detaching TBF from MS object, TLLI = 0xf1223344, TBF = TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) ********** TBF ends here ********** Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654275 block=9 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654224 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654224 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654224 (17,31,14), SBFn=2654327 TX: Immediate Assignment Uplink (AGCH) @@ -2062,8 +2056,7 @@ - No gaps in received block, last block: BSN=0 CV=15 New MS: TLLI = 0xf1223344, TA = 7, IMSI = 0011223344, LLC = 2 Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -2157,8 +2150,7 @@ ********** TBF ends here ********** Searching for first unallocated TFI: TRX=0 Found TFI=0. -MS requests UL TBF on RACH, so we provide one -ra=0x03 Fn=2654275 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x03 Fn=2654275 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -2218,8 +2210,7 @@ - Scheduling Ack/Nack, because last block has CV==0. New MS: TLLI = 0xf1223344, TA = 7, IMSI = 0011223344, LLC = 2 Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -3354,8 +3345,7 @@ Destroying MS object, TLLI = 0x00000000 ********** TBF ends here ********** Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -3450,8 +3440,7 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) starting timer 0. TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) append Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -6236,8 +6225,7 @@ Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -6414,8 +6402,7 @@ Destroying MS object, TLLI = 0x00000000 ********** TBF ends here ********** Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -6678,8 +6665,7 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** -MS requests UL TBF on RACH, so we provide one -ra=0x78 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x78 Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6704,8 +6690,7 @@ TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=0 USF=0 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 78 8b 29 07 00 c8 00 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x79 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x79 Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6730,8 +6715,7 @@ TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=1 USF=1 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 79 8b 29 07 00 c8 42 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7a Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7a Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6756,8 +6740,7 @@ TBF(TFI=2 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=2 USF=2 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7a 8b 29 07 00 c8 84 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7b Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7b Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6782,8 +6765,7 @@ TBF(TFI=3 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=3 USF=3 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7b 8b 29 07 00 c8 c6 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7c Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7c Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6808,8 +6790,7 @@ TBF(TFI=4 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=4 USF=4 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7c 8b 29 07 00 c9 08 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7d Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7d Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6834,8 +6815,7 @@ TBF(TFI=5 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=5 USF=5 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7d 8b 29 07 00 c9 4a 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7e Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7e Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6860,8 +6840,7 @@ TBF(TFI=6 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=6 USF=6 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7e 8b 29 07 00 c9 8c 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7f Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7f Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -6878,15 +6857,13 @@ No PDCH resource sending Immediate Assignment Uplink (AGCH) reject Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=4d 06 3a 10 7f 8b 29 14 7f 8b 29 14 7f 8b 29 14 7f 8b 29 14 0b 2b 2b Destroying MS object, TLLI = 0x00000000 -MS requests UL TBF on RACH, so we provide one -ra=0x70 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x70 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation No PDCH available. No PDCH resource for single block allocation.sending Immediate Assignment Uplink (AGCH) reject Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=4d 06 3a 10 70 8b 29 14 70 8b 29 14 70 8b 29 14 70 8b 29 14 0b 2b 2b Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x73 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) @@ -8873,8 +8850,7 @@ TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to FLOW The MS object cannot fully confirm an unexpected TLLI: 0xffeeddcc, partly confirmed TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=FLOW) append -MS requests UL TBF on RACH, so we provide one -ra=0x78 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x78 Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -8899,8 +8875,7 @@ TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=0 USF=0 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 78 8b 29 07 00 c8 00 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x79 Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x79 Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -8925,8 +8900,7 @@ TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=1 USF=1 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 79 8b 29 07 00 c8 42 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7a Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7a Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -8951,8 +8925,7 @@ TBF(TFI=2 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=2 USF=2 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7a 8b 29 07 00 c8 84 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7b Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7b Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -8977,8 +8950,7 @@ TBF(TFI=3 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=3 USF=3 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7b 8b 29 07 00 c8 c6 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7c Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7c Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -9003,8 +8975,7 @@ TBF(TFI=4 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=4 USF=4 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7c 8b 29 07 00 c9 08 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7d Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7d Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 @@ -9029,8 +9000,7 @@ TBF(TFI=5 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=5 USF=5 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 7d 8b 29 07 00 c9 4a 70 0b 2b 2b 2b 2b 2b 2b 2b -MS requests UL TBF on RACH, so we provide one -ra=0x7e Fn=2654167 qta=31 is_11bit=0: +MS requests UL TBF on RACH, so we provide one: ra=0x7e Fn=2654167 qta=31 is_11bit=0: ********** TBF starts here ********** Allocating UL TBF: MS_CLASS=0/0 Creating MS object, TLLI = 0x00000000 -- To view, visit https://gerrit.osmocom.org/1687 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I40d01c71982ad83589f070cf0047a4ae04695411 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:22:39 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:22:39 +0000 Subject: libosmocore[master]: core/conv: implement optimized Viterbi decoder In-Reply-To: References: Message-ID: Patch Set 5: sylvain? thanks for 5 minutes of final checking :) -- To view, visit https://gerrit.osmocom.org/1337 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I74d355274b4176a7d924f91ef3c96912ce338fb2 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:25:07 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:25:07 +0000 Subject: osmo-bts[master]: DTX: fix "unexpected burst" error In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1611 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib064952331b4f89676ee68a3d8078b1d9debe570 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jean-Francois Dionne Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: jfdionne Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:25:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 14:25:15 +0000 Subject: [MERGED] osmo-bts[master]: DTX: fix "unexpected burst" error In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: DTX: fix "unexpected burst" error ...................................................................... DTX: fix "unexpected burst" error Fix error during FACCH interruption of DTX for AMR HR. Max's note: added fix for sysmobts. Change-Id: Ib064952331b4f89676ee68a3d8078b1d9debe570 Related: OS#1801 --- M src/osmo-bts-litecell15/l1_if.c M src/osmo-bts-sysmo/l1_if.c 2 files changed, 2 insertions(+), 0 deletions(-) Approvals: jfdionne: Looks good to me, but someone else must approve; Verified Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index 0c5ef6b..e1dcecf 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -417,6 +417,7 @@ if (sapi == GsmL1_Sapi_FacchH) { sapi = GsmL1_Sapi_TchH; subCh = L1SAP_CHAN2SS_TCHH(chan_nr); + u8BlockNbr = (u32Fn % 13) >> 2; } if (sapi == GsmL1_Sapi_TchH || sapi == GsmL1_Sapi_TchF) { /* FACCH interruption of DTX silence */ diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 490264f..ef965d4 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -412,6 +412,7 @@ if (sapi == GsmL1_Sapi_FacchH) { sapi = GsmL1_Sapi_TchH; subCh = L1SAP_CHAN2SS_TCHH(chan_nr); + u8BlockNbr = (u32Fn % 13) >> 2; } if (sapi == GsmL1_Sapi_TchH || sapi == GsmL1_Sapi_TchF) { /* FACCH interruption of DTX silence */ -- To view, visit https://gerrit.osmocom.org/1611 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib064952331b4f89676ee68a3d8078b1d9debe570 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jean-Francois Dionne Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: jfdionne From gerrit-no-reply at lists.osmocom.org Wed Feb 1 14:26:59 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 14:26:59 +0000 Subject: openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 > what now? are you being ironic?? :) sorry, emotion/intention translated badly here. Besides the technical difference of "" vs. <> (look up order, paths, etc) It is project policy. I think I am the minority here and then let's follow the majority here. What I was afraid of is that we accidentally pick-up a /usr/src/osmocom/openbsc.../gsm_data_shared.h.. but that is unlikely for now and we will deal with it once we have the problem (and we would have it with libosmocore/libosmo-abis/etc. anyway) -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 15:02:55 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 1 Feb 2017 15:02:55 +0000 Subject: [MERGED] openbsc[master]: sgsn: Fix deeply flawed copying logic for PDP context activa... In-Reply-To: References: Message-ID: Holger Freyther has submitted this change and it was merged. Change subject: sgsn: Fix deeply flawed copying logic for PDP context activation ...................................................................... sgsn: Fix deeply flawed copying logic for PDP context activation It is one of these changes that should have never worked but did for a long time. Only recently a corrupted GTP message was seen. The code in ccd2312d10e14747e8a4d26d8f72b052ffcfc282 tried to solve the right problem but was deeply flawed. * Make the code operate on the copied message and not the original one that is deleted by the underlaying layers on return * Add an out variable to determine if the msgb should be deleted and assume that by default it will be deleted. Change-Id: I564526e7cde2b8a2f0ce900492cd38fc23c176a7 --- M openbsc/src/gprs/gprs_gmm.c 1 file changed, 9 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index dc73693..6fde757 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -2169,6 +2169,7 @@ /* The context is gone while we made a request */ if (!lookup->mmctx) { + talloc_free(lookup->orig_msg); talloc_free(lookup); return; } @@ -2230,6 +2231,7 @@ lookup->sapi, &lookup->tp, 1); /* Now free it */ + talloc_free(lookup->orig_msg); talloc_free(lookup); return; @@ -2237,10 +2239,11 @@ gsm48_tx_gsm_act_pdp_rej(lookup->mmctx, lookup->ti, GMM_CAUSE_NET_FAIL, 0, NULL); lookup->mmctx->ggsn_lookup = NULL; + talloc_free(lookup->orig_msg); talloc_free(lookup); } -static int do_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg) +static int do_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, bool *delete) { struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); struct gsm48_act_pdp_ctx_req *act_req = (struct gsm48_act_pdp_ctx_req *) gh->data; @@ -2389,6 +2392,7 @@ LOGMMCTXP(LOGL_ERROR, mmctx, "Failed to start ares query.\n"); goto no_context; } + *delete = 0; return 0; @@ -2402,6 +2406,7 @@ static int gsm48_rx_gsm_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *_msg) { + bool delete = 1; struct msgb *msg; int rc; @@ -2428,8 +2433,9 @@ 0, NULL); } - rc = do_act_pdp_req(mmctx, _msg); - msgb_free(msg); + rc = do_act_pdp_req(mmctx, msg, &delete); + if (delete) + msgb_free(msg); return rc; } -- To view, visit https://gerrit.osmocom.org/1686 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I564526e7cde2b8a2f0ce900492cd38fc23c176a7 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 16:10:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 1 Feb 2017 16:10:28 +0000 Subject: [PATCH] osmo-hlr[master]: sql: add unique constraints to IMSI and MSISDN Message-ID: Review at https://gerrit.osmocom.org/1722 sql: add unique constraints to IMSI and MSISDN Todo for later: table subscriber_multi_msisdn possibly allows duplicating the MSISDN, so we should drop this table or have all MSISDNs in one table separate from 'subscriber'. Change-Id: I5737106a232e416d67a10634e6270a7a89cf1b05 --- M sql/hlr.sql 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/22/1722/1 diff --git a/sql/hlr.sql b/sql/hlr.sql index 5a02be3..9238871 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -3,9 +3,9 @@ CREATE TABLE subscriber ( id INTEGER PRIMARY KEY, -- Chapter 2.1.1.1 - imsi VARCHAR(15) NOT NULL, + imsi VARCHAR(15) UNIQUE NOT NULL, -- Chapter 2.1.2 - msisdn VARCHAR(15), + msisdn VARCHAR(15) UNIQUE, -- Chapter 2.2.3: Most recent / current IMEI imeisv VARCHAR, -- Chapter 2.4.5 -- To view, visit https://gerrit.osmocom.org/1722 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5737106a232e416d67a10634e6270a7a89cf1b05 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 16:35:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 16:35:28 +0000 Subject: osmo-hlr[master]: sql: add unique constraints to IMSI and MSISDN In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1722 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5737106a232e416d67a10634e6270a7a89cf1b05 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 16:35:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 16:35:38 +0000 Subject: osmo-bts[master]: rsl: Fix dropping of LAPDm UA message. In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1626 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie4f70c75f0137b4bd72d579b3a32575bac2fca38 Gerrit-PatchSet: 6 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Minh-Quang Nguyen Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 16:35:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 16:35:42 +0000 Subject: [MERGED] osmo-bts[master]: rsl: Fix dropping of LAPDm UA message. In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: rsl: Fix dropping of LAPDm UA message. ...................................................................... rsl: Fix dropping of LAPDm UA message. In some cases, when successive mobile originated calls are made, the LAPDm UA message gets lost because the channel is relased to early. Too overcome the problem we do not send relase indications immediately. Instead a flag will be set and the message stored and sent on the next TCH-RTS-IND. This commit adds the functionality to store the release indication msg, to rsl.c. It also addes the mechanism to forward the release indication to l1sap.c See also coresponding change in openbsc.git: Change-Id I15fc1ef8e9e83f009bde96de9a8e95702cffbce6 This patch is is a slightly improved/reformatted version of: https://gitlab.com/nrw_noa/osmo-bts/commit/95d1f15ad108c1c1869c1965144acd64c1395d8c Change-Id: Ie4f70c75f0137b4bd72d579b3a32575bac2fca38 --- M src/common/l1sap.c M src/common/rsl.c 2 files changed, 28 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/l1sap.c b/src/common/l1sap.c index b2f18d1..19b38af 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -714,6 +714,7 @@ uint8_t chan_nr, marker = 0; uint16_t seq; uint32_t fn, timestamp; + int rc; chan_nr = rts_ind->chan_nr; fn = rts_ind->fn; @@ -757,6 +758,16 @@ resp_l1sap = msgb_l1sap_prim(resp_msg); } + /* check for pending REL_IND */ + if (lchan->pending_rel_ind_msg) { + LOGP(DRSL, LOGL_INFO, "%s Forward REL_IND to L3\n", gsm_lchan_name(lchan)); + /* Forward it to L3 */ + rc = abis_bts_rsl_sendmsg(lchan->pending_rel_ind_msg); + lchan->pending_rel_ind_msg = NULL; + if (rc < 0) + return rc; + } + memset(resp_l1sap, 0, sizeof(*resp_l1sap)); osmo_prim_init(&resp_l1sap->oph, SAP_GSM_PH, PRIM_TCH, PRIM_OP_REQUEST, resp_msg); diff --git a/src/common/rsl.c b/src/common/rsl.c index b3e9afb..74d835f 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -2273,6 +2273,7 @@ } msg->trx = lchan->ts->trx; + msg->lchan = lchan; /* check if this is a measurement report from SACCH which needs special * processing before forwarding */ @@ -2281,6 +2282,22 @@ LOGP(DRSL, LOGL_INFO, "%s Handing RLL msg %s from LAPDm to MEAS REP\n", gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); + + /* REL_IND handling */ + if (rh->msg_type == RSL_MT_REL_IND) { + LOGP(DRSL, LOGL_INFO, "%s Scheduling %s to L3 in next associated TCH-RTS.ind\n", + gsm_lchan_name(lchan), + rsl_msg_name(rh->msg_type)); + + if(lchan->pending_rel_ind_msg) { + LOGP(DRSL, LOGL_INFO, "Dropping pending release indication message\n"); + msgb_free(lchan->pending_rel_ind_msg); + } + + lchan->pending_rel_ind_msg = msg; + return 0; + } + rc = rsl_tx_meas_res(lchan, msgb_l3(msg), msgb_l3len(msg)); msgb_free(msg); return rc; -- To view, visit https://gerrit.osmocom.org/1626 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie4f70c75f0137b4bd72d579b3a32575bac2fca38 Gerrit-PatchSet: 7 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Minh-Quang Nguyen From gerrit-no-reply at lists.osmocom.org Wed Feb 1 16:36:11 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 16:36:11 +0000 Subject: [MERGED] openbsc[master]: OM2000: use assoc_so *only* for TS objects In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: OM2000: use assoc_so *only* for TS objects ...................................................................... OM2000: use assoc_so *only* for TS objects all other objects always use the MO instance. The existing code likely is due to copy+paste mistakes. Change-Id: Ie0a31cd93993da10f31eecf530a5a05773c11eb1 --- M openbsc/src/libbsc/abis_om2000.c 1 file changed, 4 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/libbsc/abis_om2000.c b/openbsc/src/libbsc/abis_om2000.c index 6b334d4..6c987d8 100644 --- a/openbsc/src/libbsc/abis_om2000.c +++ b/openbsc/src/libbsc/abis_om2000.c @@ -803,7 +803,7 @@ switch (mo->class) { case OM2K_MO_CLS_TRXC: - trx = gsm_bts_trx_num(bts, mo->assoc_so); + trx = gsm_bts_trx_num(bts, mo->inst); if (!trx) return NULL; nm_state = &trx->mo.nm_state; @@ -832,12 +832,12 @@ nm_state = &bts->mo.nm_state; break; case OM2K_MO_CLS_TX: - trx = gsm_bts_trx_num(bts, mo->assoc_so); + trx = gsm_bts_trx_num(bts, mo->inst); if (!trx) return NULL; break; case OM2K_MO_CLS_RX: - trx = gsm_bts_trx_num(bts, mo->assoc_so); + trx = gsm_bts_trx_num(bts, mo->inst); if (!trx) return NULL; break; @@ -854,7 +854,7 @@ case OM2K_MO_CLS_TX: case OM2K_MO_CLS_RX: case OM2K_MO_CLS_TRXC: - return gsm_bts_trx_num(bts, mo->assoc_so); + return gsm_bts_trx_num(bts, mo->inst); case OM2K_MO_CLS_TS: trx = gsm_bts_trx_num(bts, mo->assoc_so); if (!trx) -- To view, visit https://gerrit.osmocom.org/1715 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie0a31cd93993da10f31eecf530a5a05773c11eb1 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 17:25:10 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 1 Feb 2017 17:25:10 +0000 Subject: [PATCH] osmo-bts[master]: octphy: Improve OML ADM state handling In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/906 to look at the new patch set (#13). octphy: Improve OML ADM state handling Improve state handling for for lock/unlock of OC_RADIO_CARRIER obj class. in bts_model_chg_adm_state() Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c --- M include/osmo-bts/phy_link.h M src/osmo-bts-octphy/l1_oml.c 2 files changed, 61 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/06/906/13 diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index 1f8450b..a7963d0 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -105,6 +105,8 @@ struct { /* logical transceiver number within one PHY */ uint32_t trx_id; + /* trx lock state variable */ + int trx_locked; } octphy; struct { /* configuration */ diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c index 08516ef..a68169e 100644 --- a/src/osmo-bts-octphy/l1_oml.c +++ b/src/osmo-bts-octphy/l1_oml.c @@ -1539,8 +1539,65 @@ int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj, uint8_t adm_state) { - /* TODO: implement this properly */ - /* blindly accept all state changes */ + int rc; + + struct gsm_bts_trx *trx; + struct phy_instance *pinst; + struct octphy_hdl *fl1h; + + switch (mo->obj_class) { + case NM_OC_RADIO_CARRIER: + + trx = ((struct gsm_bts_trx *)obj); + pinst = trx_phy_instance(trx); + fl1h = pinst->phy_link->u.octphy.hdl; + + if (mo->procedure_pending) { + LOGP(DL1C, LOGL_ERROR, "Discarding adm change command: " + "pending procedure on TRX %d\n", trx->nr); + return 0; + } + mo->procedure_pending = 1; + switch (adm_state) { + case NM_STATE_LOCKED: + + pinst->u.octphy.trx_locked = 1; + + /* Stop heartbeat check */ + osmo_timer_del(&fl1h->alive_timer); + + bts_model_trx_deact_rf(trx); + + /* Close TRX */ + rc = bts_model_trx_close(trx); + if (rc != 0) { + LOGP(DL1C, LOGL_ERROR, + "Cannot close TRX %d, it is already closed.\n", + trx->nr); + } + break; + + case NM_STATE_UNLOCKED: + + if (pinst->u.octphy.trx_locked) { + pinst->u.octphy.trx_locked = 0; + l1if_activate_rf(trx, 1); + } + + break; + + default: + break; + } + + mo->procedure_pending = 0; + break; + + default: + /* blindly accept all state changes */ + break; + } + mo->nm_state.administrative = adm_state; return oml_mo_statechg_ack(mo); } -- To view, visit https://gerrit.osmocom.org/906 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c Gerrit-PatchSet: 13 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 1 18:57:58 2017 From: gerrit-no-reply at lists.osmocom.org (jfdionne) Date: Wed, 1 Feb 2017 18:57:58 +0000 Subject: [PATCH] osmo-bts[master]: Fix AMR HR DTX FSM logic. In-Reply-To: References: Message-ID: Hello Max, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1659 to look at the new patch set (#2). Fix AMR HR DTX FSM logic. Fix SID_FIRST_INH detection during speech and when SID_FIRST is interrupted by FACCH. Fix SID_UPDATE_INH detection during silence and when SID_UPDATE is interrupted by FACCH. Add a delay for SID_FIRST to appear at the right time after FACCH. Fix extra byte sent in downlink for SID_FIRST and SID_UPDATE. Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69 --- M include/osmo-bts/dtx_dl_amr_fsm.h M include/osmo-bts/rsl.h M src/common/dtx_dl_amr_fsm.c M src/common/msg_utils.c M src/osmo-bts-litecell15/l1_if.c M src/osmo-bts-litecell15/tch.c M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/tch.c 8 files changed, 195 insertions(+), 73 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/59/1659/2 diff --git a/include/osmo-bts/dtx_dl_amr_fsm.h b/include/osmo-bts/dtx_dl_amr_fsm.h index f747f9f..c66ac7d 100644 --- a/include/osmo-bts/dtx_dl_amr_fsm.h +++ b/include/osmo-bts/dtx_dl_amr_fsm.h @@ -12,11 +12,15 @@ ST_VOICE, ST_SID_F1, ST_SID_F2, - ST_F1_INH, - ST_U_INH, + ST_F1_INH_V, + ST_F1_INH_F, + ST_U_INH_V, + ST_U_INH_F, ST_U_NOINH, - ST_F1_INH_REC, - ST_U_INH_REC, + ST_F1_INH_V_REC, + ST_F1_INH_F_REC, + ST_U_INH_V_REC, + ST_U_INH_F_REC, ST_SID_U, ST_ONSET_V, ST_ONSET_F, diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h index a2a6e3d..d5d0f1a 100644 --- a/include/osmo-bts/rsl.h +++ b/include/osmo-bts/rsl.h @@ -13,6 +13,7 @@ }; #define LCHAN_FN_DUMMY 0xFFFFFFFF +#define LCHAN_FN_WAIT 0xFFFFFFFE int msgb_queue_flush(struct llist_head *list); diff --git a/src/common/dtx_dl_amr_fsm.c b/src/common/dtx_dl_amr_fsm.c index 832e8b4..d599048 100644 --- a/src/common/dtx_dl_amr_fsm.c +++ b/src/common/dtx_dl_amr_fsm.c @@ -29,8 +29,13 @@ case E_FACCH: break; case E_SID_F: - case E_SID_U: osmo_fsm_inst_state_chg(fi, ST_SID_F1, 0, 0); + break; + case E_SID_U: + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); + break; + case E_INHIB: + osmo_fsm_inst_state_chg(fi, ST_F1_INH_V, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Inexpected event %d\n", event); @@ -49,17 +54,11 @@ case E_SID_U: osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; - case E_VOICE: - osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); - break; case E_FACCH: - osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_F, 0, 0); break; case E_FIRST: osmo_fsm_inst_state_chg(fi, ST_SID_F2, 0, 0); - break; - case E_INHIB: - osmo_fsm_inst_state_chg(fi, ST_F1_INH, 0, 0); break; case E_ONSET: osmo_fsm_inst_state_chg(fi, ST_ONSET_V, 0, 0); @@ -75,10 +74,7 @@ { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_SID_U, 0, 0); - break; - case E_VOICE: - osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; case E_FACCH: osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); @@ -93,11 +89,11 @@ } } -void dtx_fsm_f1_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_v(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_F1_INH_REC, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_V_REC, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -106,11 +102,11 @@ } } -void dtx_fsm_u_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_f(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_U_INH_REC, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_F_REC, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -119,9 +115,36 @@ } } -void dtx_fsm_f1_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_u_inh_v(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_U_INH_V_REC, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_f(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_U_INH_F_REC, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_f1_inh_v_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_VOICE: case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; @@ -132,11 +155,40 @@ } } -void dtx_fsm_u_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_f_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { + case E_FACCH: + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_FACCH, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_v_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_VOICE: case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_f_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_FACCH: + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_FACCH, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -176,13 +228,13 @@ { switch (event) { case E_FACCH: - osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_F, 0, 0); break; case E_VOICE: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; case E_INHIB: - osmo_fsm_inst_state_chg(fi, ST_U_INH, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_V, 0, 0); break; case E_SID_U: case E_SID_F: @@ -270,40 +322,54 @@ static struct osmo_fsm_state dtx_dl_amr_fsm_states[] = { /* default state for non-DTX and DTX when SPEECH is in progress */ [ST_VOICE] = { - .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH), - .out_state_mask = X(ST_SID_F1), + .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_INHIB), + .out_state_mask = X(ST_SID_F1) | X(ST_U_NOINH) | X(ST_F1_INH_V), .name = "Voice", .action = dtx_fsm_voice, }, /* SID-FIRST or SID-FIRST-P1 in case of AMR HR: start of silence period (might be interrupted in case of AMR HR) */ [ST_SID_F1]= { - .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_FIRST) | X(E_INHIB) | X(E_ONSET), - .out_state_mask = X(ST_U_NOINH) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_F1_INH) | X(ST_ONSET_V), + .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_FACCH) | X(E_FIRST) | X(E_ONSET), + .out_state_mask = X(ST_U_NOINH) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_ONSET_V), .name = "SID-FIRST (P1)", .action = dtx_fsm_sid_f1, }, /* SID-FIRST P2 (only for AMR HR): actual start of silence period in case of AMR HR */ [ST_SID_F2]= { - .in_event_mask = X(E_COMPL) | X(E_VOICE) | X(E_FACCH) | X(E_ONSET), - .out_state_mask = X(ST_SID_U) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_ONSET_V), + .in_event_mask = X(E_COMPL) | X(E_FACCH) | X(E_ONSET), + .out_state_mask = X(ST_U_NOINH) | X(ST_ONSET_F) | X(ST_ONSET_V), .name = "SID-FIRST (P2)", .action = dtx_fsm_sid_f2, }, /* SID-FIRST Inhibited: incoming SPEECH (only for AMR HR) */ - [ST_F1_INH]= { + [ST_F1_INH_V]= { .in_event_mask = X(E_COMPL), - .out_state_mask = X(ST_F1_INH_REC), - .name = "SID-FIRST (Inh)", - .action = dtx_fsm_f1_inh, + .out_state_mask = X(ST_F1_INH_V_REC), + .name = "SID-FIRST (Inh, SPEECH)", + .action = dtx_fsm_f1_inh_v, + }, + /* SID-FIRST Inhibited: incoming FACCH frame (only for AMR HR) */ + [ST_F1_INH_F]= { + .in_event_mask = X(E_COMPL), + .out_state_mask = X(ST_F1_INH_F_REC), + .name = "SID-FIRST (Inh, FACCH)", + .action = dtx_fsm_f1_inh_f, }, /* SID-UPDATE Inhibited: incoming SPEECH (only for AMR HR) */ - [ST_U_INH]= { + [ST_U_INH_V]= { .in_event_mask = X(E_COMPL), - .out_state_mask = X(ST_U_INH_REC), - .name = "SID-UPDATE (Inh)", - .action = dtx_fsm_u_inh, + .out_state_mask = X(ST_U_INH_V_REC), + .name = "SID-UPDATE (Inh, SPEECH)", + .action = dtx_fsm_u_inh_v, + }, + /* SID-UPDATE Inhibited: incoming FACCH frame (only for AMR HR) */ + [ST_U_INH_F]= { + .in_event_mask = X(E_COMPL), + .out_state_mask = X(ST_U_INH_F_REC), + .name = "SID-UPDATE (Inh, FACCH)", + .action = dtx_fsm_u_inh_f, }, /* SID-UPDATE: Inhibited not allowed (only for AMR HR) */ [ST_U_NOINH]= { @@ -314,24 +380,40 @@ }, /* SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ - [ST_F1_INH_REC]= { - .in_event_mask = X(E_COMPL), + [ST_F1_INH_V_REC]= { + .in_event_mask = X(E_COMPL) | X(E_VOICE), .out_state_mask = X(ST_VOICE), - .name = "SID-FIRST (Inh, Rec)", - .action = dtx_fsm_f1_inh_rec, + .name = "SID-FIRST (Inh, SPEECH, Rec)", + .action = dtx_fsm_f1_inh_v_rec, + }, + /* SID-FIRST Inhibition recursion in progress: + Inhibit itself was already sent, now have to send the data that caused it */ + [ST_F1_INH_F_REC]= { + .in_event_mask = X(E_COMPL) | X(E_FACCH), + .out_state_mask = X(ST_FACCH), + .name = "SID-FIRST (Inh, FACCH, Rec)", + .action = dtx_fsm_f1_inh_f_rec, }, /* SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ - [ST_U_INH_REC]= { - .in_event_mask = X(E_COMPL), + [ST_U_INH_V_REC]= { + .in_event_mask = X(E_COMPL) | X(E_VOICE), .out_state_mask = X(ST_VOICE), - .name = "SID-UPDATE (Inh, Rec)", - .action = dtx_fsm_u_inh_rec, + .name = "SID-UPDATE (Inh, SPEECH, Rec)", + .action = dtx_fsm_u_inh_v_rec, + }, + /* SID-UPDATE Inhibition recursion in progress: + Inhibit itself was already sent, now have to send the data that caused it */ + [ST_U_INH_F_REC]= { + .in_event_mask = X(E_COMPL) | X(E_FACCH), + .out_state_mask = X(ST_FACCH), + .name = "SID-UPDATE (Inh, FACCH, Rec)", + .action = dtx_fsm_u_inh_f_rec, }, /* Silence period with periodic comfort noise data updates */ [ST_SID_U]= { .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_INHIB) | X(E_SID_U) | X(E_SID_F), - .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH) | X(ST_U_NOINH), + .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH_V) | X(ST_U_INH_F) | X(ST_U_NOINH), .name = "SID-UPDATE (AMR/HR)", .action = dtx_fsm_sid_upd, }, @@ -365,8 +447,7 @@ .name = "ONSET (FACCH, Rec)", .action = dtx_fsm_onset_f_rec, }, - /* FACCH sending state: no SPEECH was observed before so once we're done - FSM should get back to silent period via SID-FIRST */ + /* FACCH sending state */ [ST_FACCH]= { .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_COMPL) | X(E_SID_U) | X(E_SID_F), .out_state_mask = X(ST_VOICE) | X(ST_SID_F1), diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c index 062f5e3..f936c98 100644 --- a/src/common/msg_utils.c +++ b/src/common/msg_utils.c @@ -137,7 +137,7 @@ size_t length, uint32_t fn, int update) { size_t amr = (update < 0) ? 0 : 2, - copy_len = OSMO_MIN(length + 1, + copy_len = OSMO_MIN(length, ARRAY_SIZE(lchan->tch.dtx.cache) - amr); lchan->tch.dtx.len = copy_len + amr; @@ -230,7 +230,7 @@ if (osmo_amr_is_speech(ft)) { /* AMR HR - SID-FIRST_P1 Inhibition */ - if (marker && dtx_is_first_p1(lchan)) + if (marker && lchan->tch.dtx.dl_amr_fsm->state == ST_VOICE) return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, E_INHIB, (void *)lchan); @@ -261,7 +261,8 @@ as FIRST regardless of actually decoded type */ dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, false); return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, - E_SID_F, (void *)lchan); + sti ? E_SID_U : E_SID_F, + (void *)lchan); } else if (lchan->tch.dtx.dl_amr_fsm->state != ST_FACCH) dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, sti); if (lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F2) @@ -319,12 +320,24 @@ already: we rely here on the order of RTS arrival from L1 - we expect that PH-DATA.req ALWAYS comes before PH-TCH.req for the same FN */ - if (lchan->tch.dtx.fn != LCHAN_FN_DUMMY) { - /* FACCH interruption is over */ - dtx_dispatch(lchan, E_COMPL); - return false; - } else - lchan->tch.dtx.fn = fn; + if(lchan->type == GSM_LCHAN_TCH_H) { + if (lchan->tch.dtx.fn != LCHAN_FN_DUMMY && + lchan->tch.dtx.fn != LCHAN_FN_WAIT) { + /* FACCH interruption is over */ + dtx_dispatch(lchan, E_COMPL); + return false; + } else if(lchan->tch.dtx.fn == LCHAN_FN_DUMMY) { + lchan->tch.dtx.fn = LCHAN_FN_WAIT; + } else + lchan->tch.dtx.fn = fn; + } else if(lchan->type == GSM_LCHAN_TCH_F) { + if (lchan->tch.dtx.fn != LCHAN_FN_DUMMY) { + /* FACCH interruption is over */ + dtx_dispatch(lchan, E_COMPL); + return false; + } else + lchan->tch.dtx.fn = fn; + } /* this FN was already used for FACCH or ONSET message so we just prepare things for next one */ return true; @@ -401,9 +414,14 @@ if (!dtx_dl_amr_enabled(lchan)) return false; - if (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH || - lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_REC || - lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH || + if (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_V || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_V_REC || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F_REC || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_V || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_V_REC || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F_REC || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_V || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F_REC || diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index e1dcecf..5977aa9 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -410,7 +410,9 @@ memcpy(l1p->u.phDataReq.msgUnitParam.u8Buffer, lchan->tch.dtx.facch, msgb_l2len(msg)); else if (dtx_dl_amr_enabled(lchan) && - lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) { + ((lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F))) { if (sapi == GsmL1_Sapi_FacchF) { sapi = GsmL1_Sapi_TchF; } @@ -424,9 +426,16 @@ /* cache FACCH data */ memcpy(lchan->tch.dtx.facch, msg->l2h, msgb_l2len(msg)); - /* prepare ONSET message */ - l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = - GsmL1_TchPlType_Amr_Onset; + /* prepare ONSET or INH message */ + if(lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_Onset; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidUpdateInH; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidFirstInH; /* ignored CMR/CMI pair */ l1p->u.phDataReq.msgUnitParam.u8Buffer[1] = 0; l1p->u.phDataReq.msgUnitParam.u8Buffer[2] = 0; diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c index 4b22b64..ffc1eb3 100644 --- a/src/osmo-bts-litecell15/tch.c +++ b/src/osmo-bts-litecell15/tch.c @@ -311,12 +311,12 @@ rtppayload_to_l1_amr(l1_payload + 2, rtp_pl, rtp_pl_len, ft); return 0; - case ST_F1_INH: + case ST_F1_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidFirstInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); return 1; - case ST_U_INH: + case ST_U_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidUpdateInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index ef965d4..c021368 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -405,7 +405,9 @@ memcpy(l1p->u.phDataReq.msgUnitParam.u8Buffer, lchan->tch.dtx.facch, msgb_l2len(msg)); else if (dtx_dl_amr_enabled(lchan) && - lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) { + ((lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F))) { if (sapi == GsmL1_Sapi_FacchF) { sapi = GsmL1_Sapi_TchF; } @@ -419,9 +421,16 @@ /* cache FACCH data */ memcpy(lchan->tch.dtx.facch, msg->l2h, msgb_l2len(msg)); - /* prepare ONSET message */ - l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = - GsmL1_TchPlType_Amr_Onset; + /* prepare ONSET or INH message */ + if(lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_Onset; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidUpdateInH; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidFirstInH; /* ignored CMR/CMI pair */ l1p->u.phDataReq.msgUnitParam.u8Buffer[1] = 0; l1p->u.phDataReq.msgUnitParam.u8Buffer[2] = 0; diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c index 8eb419b..55c4049 100644 --- a/src/osmo-bts-sysmo/tch.c +++ b/src/osmo-bts-sysmo/tch.c @@ -409,12 +409,12 @@ rtppayload_to_l1_amr(l1_payload + 2, rtp_pl, rtp_pl_len, ft); return 0; - case ST_F1_INH: + case ST_F1_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidFirstInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); return 1; - case ST_U_INH: + case ST_U_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidUpdateInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); -- To view, visit https://gerrit.osmocom.org/1659 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: jfdionne From gerrit-no-reply at lists.osmocom.org Wed Feb 1 19:13:14 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 19:13:14 +0000 Subject: osmo-bts[master]: Fix AMR HR DTX FSM logic. In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1659 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: jfdionne Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 19:13:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 19:13:16 +0000 Subject: [MERGED] osmo-bts[master]: Fix AMR HR DTX FSM logic. In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Fix AMR HR DTX FSM logic. ...................................................................... Fix AMR HR DTX FSM logic. Fix SID_FIRST_INH detection during speech and when SID_FIRST is interrupted by FACCH. Fix SID_UPDATE_INH detection during silence and when SID_UPDATE is interrupted by FACCH. Add a delay for SID_FIRST to appear at the right time after FACCH. Fix extra byte sent in downlink for SID_FIRST and SID_UPDATE. Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69 --- M include/osmo-bts/dtx_dl_amr_fsm.h M include/osmo-bts/rsl.h M src/common/dtx_dl_amr_fsm.c M src/common/msg_utils.c M src/osmo-bts-litecell15/l1_if.c M src/osmo-bts-litecell15/tch.c M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/tch.c 8 files changed, 195 insertions(+), 73 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmo-bts/dtx_dl_amr_fsm.h b/include/osmo-bts/dtx_dl_amr_fsm.h index f747f9f..c66ac7d 100644 --- a/include/osmo-bts/dtx_dl_amr_fsm.h +++ b/include/osmo-bts/dtx_dl_amr_fsm.h @@ -12,11 +12,15 @@ ST_VOICE, ST_SID_F1, ST_SID_F2, - ST_F1_INH, - ST_U_INH, + ST_F1_INH_V, + ST_F1_INH_F, + ST_U_INH_V, + ST_U_INH_F, ST_U_NOINH, - ST_F1_INH_REC, - ST_U_INH_REC, + ST_F1_INH_V_REC, + ST_F1_INH_F_REC, + ST_U_INH_V_REC, + ST_U_INH_F_REC, ST_SID_U, ST_ONSET_V, ST_ONSET_F, diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h index a2a6e3d..d5d0f1a 100644 --- a/include/osmo-bts/rsl.h +++ b/include/osmo-bts/rsl.h @@ -13,6 +13,7 @@ }; #define LCHAN_FN_DUMMY 0xFFFFFFFF +#define LCHAN_FN_WAIT 0xFFFFFFFE int msgb_queue_flush(struct llist_head *list); diff --git a/src/common/dtx_dl_amr_fsm.c b/src/common/dtx_dl_amr_fsm.c index 832e8b4..d599048 100644 --- a/src/common/dtx_dl_amr_fsm.c +++ b/src/common/dtx_dl_amr_fsm.c @@ -29,8 +29,13 @@ case E_FACCH: break; case E_SID_F: - case E_SID_U: osmo_fsm_inst_state_chg(fi, ST_SID_F1, 0, 0); + break; + case E_SID_U: + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); + break; + case E_INHIB: + osmo_fsm_inst_state_chg(fi, ST_F1_INH_V, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Inexpected event %d\n", event); @@ -49,17 +54,11 @@ case E_SID_U: osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; - case E_VOICE: - osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); - break; case E_FACCH: - osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_F, 0, 0); break; case E_FIRST: osmo_fsm_inst_state_chg(fi, ST_SID_F2, 0, 0); - break; - case E_INHIB: - osmo_fsm_inst_state_chg(fi, ST_F1_INH, 0, 0); break; case E_ONSET: osmo_fsm_inst_state_chg(fi, ST_ONSET_V, 0, 0); @@ -75,10 +74,7 @@ { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_SID_U, 0, 0); - break; - case E_VOICE: - osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; case E_FACCH: osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); @@ -93,11 +89,11 @@ } } -void dtx_fsm_f1_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_v(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_F1_INH_REC, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_V_REC, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -106,11 +102,11 @@ } } -void dtx_fsm_u_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_f(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_U_INH_REC, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_F_REC, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -119,9 +115,36 @@ } } -void dtx_fsm_f1_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_u_inh_v(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_U_INH_V_REC, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_f(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_U_INH_F_REC, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_f1_inh_v_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_VOICE: case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; @@ -132,11 +155,40 @@ } } -void dtx_fsm_u_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_f_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { + case E_FACCH: + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_FACCH, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_v_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_VOICE: case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_f_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_FACCH: + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_FACCH, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -176,13 +228,13 @@ { switch (event) { case E_FACCH: - osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_F, 0, 0); break; case E_VOICE: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; case E_INHIB: - osmo_fsm_inst_state_chg(fi, ST_U_INH, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_V, 0, 0); break; case E_SID_U: case E_SID_F: @@ -270,40 +322,54 @@ static struct osmo_fsm_state dtx_dl_amr_fsm_states[] = { /* default state for non-DTX and DTX when SPEECH is in progress */ [ST_VOICE] = { - .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH), - .out_state_mask = X(ST_SID_F1), + .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_INHIB), + .out_state_mask = X(ST_SID_F1) | X(ST_U_NOINH) | X(ST_F1_INH_V), .name = "Voice", .action = dtx_fsm_voice, }, /* SID-FIRST or SID-FIRST-P1 in case of AMR HR: start of silence period (might be interrupted in case of AMR HR) */ [ST_SID_F1]= { - .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_FIRST) | X(E_INHIB) | X(E_ONSET), - .out_state_mask = X(ST_U_NOINH) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_F1_INH) | X(ST_ONSET_V), + .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_FACCH) | X(E_FIRST) | X(E_ONSET), + .out_state_mask = X(ST_U_NOINH) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_ONSET_V), .name = "SID-FIRST (P1)", .action = dtx_fsm_sid_f1, }, /* SID-FIRST P2 (only for AMR HR): actual start of silence period in case of AMR HR */ [ST_SID_F2]= { - .in_event_mask = X(E_COMPL) | X(E_VOICE) | X(E_FACCH) | X(E_ONSET), - .out_state_mask = X(ST_SID_U) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_ONSET_V), + .in_event_mask = X(E_COMPL) | X(E_FACCH) | X(E_ONSET), + .out_state_mask = X(ST_U_NOINH) | X(ST_ONSET_F) | X(ST_ONSET_V), .name = "SID-FIRST (P2)", .action = dtx_fsm_sid_f2, }, /* SID-FIRST Inhibited: incoming SPEECH (only for AMR HR) */ - [ST_F1_INH]= { + [ST_F1_INH_V]= { .in_event_mask = X(E_COMPL), - .out_state_mask = X(ST_F1_INH_REC), - .name = "SID-FIRST (Inh)", - .action = dtx_fsm_f1_inh, + .out_state_mask = X(ST_F1_INH_V_REC), + .name = "SID-FIRST (Inh, SPEECH)", + .action = dtx_fsm_f1_inh_v, + }, + /* SID-FIRST Inhibited: incoming FACCH frame (only for AMR HR) */ + [ST_F1_INH_F]= { + .in_event_mask = X(E_COMPL), + .out_state_mask = X(ST_F1_INH_F_REC), + .name = "SID-FIRST (Inh, FACCH)", + .action = dtx_fsm_f1_inh_f, }, /* SID-UPDATE Inhibited: incoming SPEECH (only for AMR HR) */ - [ST_U_INH]= { + [ST_U_INH_V]= { .in_event_mask = X(E_COMPL), - .out_state_mask = X(ST_U_INH_REC), - .name = "SID-UPDATE (Inh)", - .action = dtx_fsm_u_inh, + .out_state_mask = X(ST_U_INH_V_REC), + .name = "SID-UPDATE (Inh, SPEECH)", + .action = dtx_fsm_u_inh_v, + }, + /* SID-UPDATE Inhibited: incoming FACCH frame (only for AMR HR) */ + [ST_U_INH_F]= { + .in_event_mask = X(E_COMPL), + .out_state_mask = X(ST_U_INH_F_REC), + .name = "SID-UPDATE (Inh, FACCH)", + .action = dtx_fsm_u_inh_f, }, /* SID-UPDATE: Inhibited not allowed (only for AMR HR) */ [ST_U_NOINH]= { @@ -314,24 +380,40 @@ }, /* SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ - [ST_F1_INH_REC]= { - .in_event_mask = X(E_COMPL), + [ST_F1_INH_V_REC]= { + .in_event_mask = X(E_COMPL) | X(E_VOICE), .out_state_mask = X(ST_VOICE), - .name = "SID-FIRST (Inh, Rec)", - .action = dtx_fsm_f1_inh_rec, + .name = "SID-FIRST (Inh, SPEECH, Rec)", + .action = dtx_fsm_f1_inh_v_rec, + }, + /* SID-FIRST Inhibition recursion in progress: + Inhibit itself was already sent, now have to send the data that caused it */ + [ST_F1_INH_F_REC]= { + .in_event_mask = X(E_COMPL) | X(E_FACCH), + .out_state_mask = X(ST_FACCH), + .name = "SID-FIRST (Inh, FACCH, Rec)", + .action = dtx_fsm_f1_inh_f_rec, }, /* SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ - [ST_U_INH_REC]= { - .in_event_mask = X(E_COMPL), + [ST_U_INH_V_REC]= { + .in_event_mask = X(E_COMPL) | X(E_VOICE), .out_state_mask = X(ST_VOICE), - .name = "SID-UPDATE (Inh, Rec)", - .action = dtx_fsm_u_inh_rec, + .name = "SID-UPDATE (Inh, SPEECH, Rec)", + .action = dtx_fsm_u_inh_v_rec, + }, + /* SID-UPDATE Inhibition recursion in progress: + Inhibit itself was already sent, now have to send the data that caused it */ + [ST_U_INH_F_REC]= { + .in_event_mask = X(E_COMPL) | X(E_FACCH), + .out_state_mask = X(ST_FACCH), + .name = "SID-UPDATE (Inh, FACCH, Rec)", + .action = dtx_fsm_u_inh_f_rec, }, /* Silence period with periodic comfort noise data updates */ [ST_SID_U]= { .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_INHIB) | X(E_SID_U) | X(E_SID_F), - .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH) | X(ST_U_NOINH), + .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH_V) | X(ST_U_INH_F) | X(ST_U_NOINH), .name = "SID-UPDATE (AMR/HR)", .action = dtx_fsm_sid_upd, }, @@ -365,8 +447,7 @@ .name = "ONSET (FACCH, Rec)", .action = dtx_fsm_onset_f_rec, }, - /* FACCH sending state: no SPEECH was observed before so once we're done - FSM should get back to silent period via SID-FIRST */ + /* FACCH sending state */ [ST_FACCH]= { .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_COMPL) | X(E_SID_U) | X(E_SID_F), .out_state_mask = X(ST_VOICE) | X(ST_SID_F1), diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c index 062f5e3..f936c98 100644 --- a/src/common/msg_utils.c +++ b/src/common/msg_utils.c @@ -137,7 +137,7 @@ size_t length, uint32_t fn, int update) { size_t amr = (update < 0) ? 0 : 2, - copy_len = OSMO_MIN(length + 1, + copy_len = OSMO_MIN(length, ARRAY_SIZE(lchan->tch.dtx.cache) - amr); lchan->tch.dtx.len = copy_len + amr; @@ -230,7 +230,7 @@ if (osmo_amr_is_speech(ft)) { /* AMR HR - SID-FIRST_P1 Inhibition */ - if (marker && dtx_is_first_p1(lchan)) + if (marker && lchan->tch.dtx.dl_amr_fsm->state == ST_VOICE) return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, E_INHIB, (void *)lchan); @@ -261,7 +261,8 @@ as FIRST regardless of actually decoded type */ dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, false); return osmo_fsm_inst_dispatch(lchan->tch.dtx.dl_amr_fsm, - E_SID_F, (void *)lchan); + sti ? E_SID_U : E_SID_F, + (void *)lchan); } else if (lchan->tch.dtx.dl_amr_fsm->state != ST_FACCH) dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, sti); if (lchan->tch.dtx.dl_amr_fsm->state == ST_SID_F2) @@ -319,12 +320,24 @@ already: we rely here on the order of RTS arrival from L1 - we expect that PH-DATA.req ALWAYS comes before PH-TCH.req for the same FN */ - if (lchan->tch.dtx.fn != LCHAN_FN_DUMMY) { - /* FACCH interruption is over */ - dtx_dispatch(lchan, E_COMPL); - return false; - } else - lchan->tch.dtx.fn = fn; + if(lchan->type == GSM_LCHAN_TCH_H) { + if (lchan->tch.dtx.fn != LCHAN_FN_DUMMY && + lchan->tch.dtx.fn != LCHAN_FN_WAIT) { + /* FACCH interruption is over */ + dtx_dispatch(lchan, E_COMPL); + return false; + } else if(lchan->tch.dtx.fn == LCHAN_FN_DUMMY) { + lchan->tch.dtx.fn = LCHAN_FN_WAIT; + } else + lchan->tch.dtx.fn = fn; + } else if(lchan->type == GSM_LCHAN_TCH_F) { + if (lchan->tch.dtx.fn != LCHAN_FN_DUMMY) { + /* FACCH interruption is over */ + dtx_dispatch(lchan, E_COMPL); + return false; + } else + lchan->tch.dtx.fn = fn; + } /* this FN was already used for FACCH or ONSET message so we just prepare things for next one */ return true; @@ -401,9 +414,14 @@ if (!dtx_dl_amr_enabled(lchan)) return false; - if (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH || - lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_REC || - lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH || + if (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_V || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_V_REC || + lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F_REC || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_V || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_V_REC || + lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F_REC || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_V || lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F_REC || diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index e1dcecf..5977aa9 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -410,7 +410,9 @@ memcpy(l1p->u.phDataReq.msgUnitParam.u8Buffer, lchan->tch.dtx.facch, msgb_l2len(msg)); else if (dtx_dl_amr_enabled(lchan) && - lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) { + ((lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F))) { if (sapi == GsmL1_Sapi_FacchF) { sapi = GsmL1_Sapi_TchF; } @@ -424,9 +426,16 @@ /* cache FACCH data */ memcpy(lchan->tch.dtx.facch, msg->l2h, msgb_l2len(msg)); - /* prepare ONSET message */ - l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = - GsmL1_TchPlType_Amr_Onset; + /* prepare ONSET or INH message */ + if(lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_Onset; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidUpdateInH; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidFirstInH; /* ignored CMR/CMI pair */ l1p->u.phDataReq.msgUnitParam.u8Buffer[1] = 0; l1p->u.phDataReq.msgUnitParam.u8Buffer[2] = 0; diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c index 4b22b64..ffc1eb3 100644 --- a/src/osmo-bts-litecell15/tch.c +++ b/src/osmo-bts-litecell15/tch.c @@ -311,12 +311,12 @@ rtppayload_to_l1_amr(l1_payload + 2, rtp_pl, rtp_pl_len, ft); return 0; - case ST_F1_INH: + case ST_F1_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidFirstInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); return 1; - case ST_U_INH: + case ST_U_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidUpdateInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index ef965d4..c021368 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -405,7 +405,9 @@ memcpy(l1p->u.phDataReq.msgUnitParam.u8Buffer, lchan->tch.dtx.facch, msgb_l2len(msg)); else if (dtx_dl_amr_enabled(lchan) && - lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) { + ((lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) || + (lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F))) { if (sapi == GsmL1_Sapi_FacchF) { sapi = GsmL1_Sapi_TchF; } @@ -419,9 +421,16 @@ /* cache FACCH data */ memcpy(lchan->tch.dtx.facch, msg->l2h, msgb_l2len(msg)); - /* prepare ONSET message */ - l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = - GsmL1_TchPlType_Amr_Onset; + /* prepare ONSET or INH message */ + if(lchan->tch.dtx.dl_amr_fsm->state == ST_ONSET_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_Onset; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_U_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidUpdateInH; + else if(lchan->tch.dtx.dl_amr_fsm->state == ST_F1_INH_F) + l1p->u.phDataReq.msgUnitParam.u8Buffer[0] = + GsmL1_TchPlType_Amr_SidFirstInH; /* ignored CMR/CMI pair */ l1p->u.phDataReq.msgUnitParam.u8Buffer[1] = 0; l1p->u.phDataReq.msgUnitParam.u8Buffer[2] = 0; diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c index 8eb419b..55c4049 100644 --- a/src/osmo-bts-sysmo/tch.c +++ b/src/osmo-bts-sysmo/tch.c @@ -409,12 +409,12 @@ rtppayload_to_l1_amr(l1_payload + 2, rtp_pl, rtp_pl_len, ft); return 0; - case ST_F1_INH: + case ST_F1_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidFirstInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); return 1; - case ST_U_INH: + case ST_U_INH_V: *payload_type = GsmL1_TchPlType_Amr_SidUpdateInH; *len = 3; dtx_cache_payload(lchan, rtp_pl, rtp_pl_len, fn, 0); -- To view, visit https://gerrit.osmocom.org/1659 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: jfdionne From gerrit-no-reply at lists.osmocom.org Wed Feb 1 19:13:27 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 19:13:27 +0000 Subject: [MERGED] osmo-hlr[master]: sql: add unique constraints to IMSI and MSISDN In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sql: add unique constraints to IMSI and MSISDN ...................................................................... sql: add unique constraints to IMSI and MSISDN Todo for later: table subscriber_multi_msisdn possibly allows duplicating the MSISDN, so we should drop this table or have all MSISDNs in one table separate from 'subscriber'. Change-Id: I5737106a232e416d67a10634e6270a7a89cf1b05 --- M sql/hlr.sql 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/sql/hlr.sql b/sql/hlr.sql index 5a02be3..9238871 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -3,9 +3,9 @@ CREATE TABLE subscriber ( id INTEGER PRIMARY KEY, -- Chapter 2.1.1.1 - imsi VARCHAR(15) NOT NULL, + imsi VARCHAR(15) UNIQUE NOT NULL, -- Chapter 2.1.2 - msisdn VARCHAR(15), + msisdn VARCHAR(15) UNIQUE, -- Chapter 2.2.3: Most recent / current IMEI imeisv VARCHAR, -- Chapter 2.4.5 -- To view, visit https://gerrit.osmocom.org/1722 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5737106a232e416d67a10634e6270a7a89cf1b05 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 1 19:14:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 19:14:58 +0000 Subject: openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Patch Set 3: I agree with Holgers PoV that it would be better to use "" for non-sytem(installed) headers. However, changing that for all code would be a separate patch, and until soembody bothers enough, consistency is a good idea. -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 19:16:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 19:16:15 +0000 Subject: osmo-bts[master]: octphy: Improve OML ADM state handling In-Reply-To: References: Message-ID: Patch Set 13: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/906 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c Gerrit-PatchSet: 13 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 1 19:16:19 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 1 Feb 2017 19:16:19 +0000 Subject: [MERGED] osmo-bts[master]: octphy: Improve OML ADM state handling In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: octphy: Improve OML ADM state handling ...................................................................... octphy: Improve OML ADM state handling Improve state handling for for lock/unlock of OC_RADIO_CARRIER obj class. in bts_model_chg_adm_state() Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c --- M include/osmo-bts/phy_link.h M src/osmo-bts-octphy/l1_oml.c 2 files changed, 61 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index 1f8450b..a7963d0 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -105,6 +105,8 @@ struct { /* logical transceiver number within one PHY */ uint32_t trx_id; + /* trx lock state variable */ + int trx_locked; } octphy; struct { /* configuration */ diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c index 08516ef..a68169e 100644 --- a/src/osmo-bts-octphy/l1_oml.c +++ b/src/osmo-bts-octphy/l1_oml.c @@ -1539,8 +1539,65 @@ int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj, uint8_t adm_state) { - /* TODO: implement this properly */ - /* blindly accept all state changes */ + int rc; + + struct gsm_bts_trx *trx; + struct phy_instance *pinst; + struct octphy_hdl *fl1h; + + switch (mo->obj_class) { + case NM_OC_RADIO_CARRIER: + + trx = ((struct gsm_bts_trx *)obj); + pinst = trx_phy_instance(trx); + fl1h = pinst->phy_link->u.octphy.hdl; + + if (mo->procedure_pending) { + LOGP(DL1C, LOGL_ERROR, "Discarding adm change command: " + "pending procedure on TRX %d\n", trx->nr); + return 0; + } + mo->procedure_pending = 1; + switch (adm_state) { + case NM_STATE_LOCKED: + + pinst->u.octphy.trx_locked = 1; + + /* Stop heartbeat check */ + osmo_timer_del(&fl1h->alive_timer); + + bts_model_trx_deact_rf(trx); + + /* Close TRX */ + rc = bts_model_trx_close(trx); + if (rc != 0) { + LOGP(DL1C, LOGL_ERROR, + "Cannot close TRX %d, it is already closed.\n", + trx->nr); + } + break; + + case NM_STATE_UNLOCKED: + + if (pinst->u.octphy.trx_locked) { + pinst->u.octphy.trx_locked = 0; + l1if_activate_rf(trx, 1); + } + + break; + + default: + break; + } + + mo->procedure_pending = 0; + break; + + default: + /* blindly accept all state changes */ + break; + } + mo->nm_state.administrative = adm_state; return oml_mo_statechg_ack(mo); } -- To view, visit https://gerrit.osmocom.org/906 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I034114beca95210169429d8ac1eb8648df12fc6c Gerrit-PatchSet: 14 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 00:18:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 00:18:41 +0000 Subject: [PATCH] openbsc[master]: compiler warning: bsc_vty: remove two unused vars Message-ID: Review at https://gerrit.osmocom.org/1723 compiler warning: bsc_vty: remove two unused vars Added in recent commit 42def7205ba91df4bbb7e3240be0df8c26c2d63e "Implement VTY configuration to control Early Classmark Sending" Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a --- M openbsc/src/libbsc/bsc_vty.c 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/23/1723/1 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index b28d4de..7d3b4af 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -2686,7 +2686,6 @@ "Early Classmark Sending is forbidden\n") { struct gsm_bts *bts = vty->index; - int rc, type; if (!strcmp(argv[0], "allowed")) bts->early_classmark_allowed = true; -- To view, visit https://gerrit.osmocom.org/1723 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:27:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:27:41 +0000 Subject: [MERGED] openbsc[master]: paging.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: paging.h: use '<>' include, not '""' ...................................................................... paging.h: use '<>' include, not '""' Also separate openbsc includes from osmocom/core includes. Change-Id: I4da0cb32476202d06902531d07faed8004f689f9 --- M openbsc/include/openbsc/paging.h 1 file changed, 3 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index 2a10f4e..689ff51 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -24,10 +24,11 @@ #include #include -#include "gsm_data.h" -#include "gsm_subscriber.h" #include +#include +#include + /** * A pending paging request */ -- To view, visit https://gerrit.osmocom.org/1679 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4da0cb32476202d06902531d07faed8004f689f9 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:27:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:27:42 +0000 Subject: [MERGED] openbsc[master]: osmo_bsc_grace.h: use '<>' include, not '""' In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmo_bsc_grace.h: use '<>' include, not '""' ...................................................................... osmo_bsc_grace.h: use '<>' include, not '""' Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 --- M openbsc/include/openbsc/osmo_bsc_grace.h 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Holger Freyther: Looks good to me, approved diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index e9c1a0a..af77b2f 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -21,7 +21,7 @@ #ifndef OSMO_BSC_GRACE_H #define OSMO_BSC_GRACE_H -#include "gsm_data.h" +#include struct osmo_msc_data; -- To view, visit https://gerrit.osmocom.org/1678 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:32:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:32:21 +0000 Subject: [ABANDON] osmo-iuh[master]: cs RAB: tweak sDU_ErrorRatio In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cs RAB: tweak sDU_ErrorRatio ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1644 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I3169376bb182aba5926b7c974108bdc5fba04fa4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:33:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:33:02 +0000 Subject: [ABANDON] osmo-iuh[master]: cs RAB: set allocationOrRetentionPriority=lowest In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cs RAB: set allocationOrRetentionPriority=lowest ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1645 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I0d7dc32bc93fa0a4d316f8378b3735dc11e87071 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:33:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:33:42 +0000 Subject: [ABANDON] osmo-iuh[master]: cs RAB: toggle Pre_emptionVulnerability In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cs RAB: toggle Pre_emptionVulnerability ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1646 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I0f4d5a5e56bb6a3a3dfd6db8292d30f55fccdbc1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:34:19 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:34:19 +0000 Subject: [ABANDON] osmo-iuh[master]: cs RAB: toggle QueuingAllowed In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cs RAB: toggle QueuingAllowed ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1647 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I39a541c193eed9c15b2ce8fda306bb226c70647f Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:35:12 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:35:12 +0000 Subject: [ABANDON] osmo-iuh[master]: cs RAB: add more SDU_FormatInformationParameter items In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cs RAB: add more SDU_FormatInformationParameter items ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1649 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I97e5c0b1e9ab9de00449b50a86d79a967af0d3f3 Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 03:35:44 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 03:35:44 +0000 Subject: [ABANDON] openbsc[master]: abis_om2000: drop unused function con_group_del() In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: abis_om2000: drop unused function con_group_del() ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1680 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Idc47bf790fb680a3c322342170369993ec02f73a Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 04:04:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 04:04:38 +0000 Subject: [PATCH] osmo-iuh[master]: ranap: make X.213 NSAP 160 bits long, zero padded In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1648 to look at the new patch set (#3). ranap: make X.213 NSAP 160 bits long, zero padded For IPv4 addresses, only 56bit of X.213 NSAP are used. The sysmocell5000 accepts such a field that is 56bits long, but the ip.access nano3G does not (and crashes instead). Both work when zero-padded to 160bits size. So far we used to send the IPv4 address as "raw" 32bits to the nano3G to avoid the crash. With this zero padding we no longer need such a workaround and can use identical config for both cells. Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 16 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/48/1648/3 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index cd2ddfc..4634a07 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -639,7 +639,7 @@ unsigned int len; if (use_x213_nsap) { - len = 7; + len = 160/8; buf = CALLOC(len, sizeof(uint8_t)); buf[0] = 0x35; /* AFI For IANA ICP */ buf[1] = 0x00; /* See A.5.2.1.2.7 of X.213 */ diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index dc959eb..bd44d33 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -90,8 +90,9 @@ 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 - 00 01 0A 0B 0C 0D 40 09 26 00 00 + 28 14 00 3C 40 00 00 00 50 3D 02 00 02 27 C0 35 + 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 + 00 00 00 40 09 26 00 00 00 @@ -100,14 +101,15 @@ 54 - 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 2F + 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 - 00 00 40 01 00 + 3D 02 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 + 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 + 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) @@ -116,7 +118,8 @@ 38 04 12 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06 08 9E 00 00 00 00 B1 40 05 60 01 8C BA 7F 00 00 - 10 6E 35 00 01 1A 1B 1C 1D 00 11 22 33 44 + 11 3E 35 00 01 1A 1B 1C 1D 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 11 22 33 44 78 1C 00 00 00 00 @@ -125,13 +128,14 @@ 54 - 00 00 01 00 35 00 2E 38 04 12 DE 18 69 FF 80 0C + 00 00 01 00 35 00 3B 38 04 12 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06 08 9E 00 00 00 00 B1 40 05 - 60 01 8C BA 7F 00 00 10 6E 35 00 01 1A 1B 1C 1D - 00 11 22 33 44 40 06 78 1C 00 00 00 00 + 60 01 8C BA 7F 00 00 11 3E 35 00 01 1A 1B 1C 1D + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 22 + 33 44 40 06 78 1C 00 00 00 00 -00 00 00 44 00 00 01 00 36 40 3d 00 00 01 00 35 00 2e 38 04 12 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 00 00 b1 40 05 60 01 8c ba 7f 00 00 10 6e 35 00 01 1a 1b 1c 1d 00 11 22 33 44 40 06 78 1c 00 00 00 00 +00 00 00 51 00 00 01 00 36 40 4a 00 00 01 00 35 00 3b 38 04 12 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 00 00 b1 40 05 60 01 8c ba 7f 00 00 11 3e 35 00 01 1a 1b 1c 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 22 33 44 40 06 78 1c 00 00 00 00 ==> RESET CMD -- To view, visit https://gerrit.osmocom.org/1648 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 04:04:39 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 04:04:39 +0000 Subject: [MERGED] osmo-iuh[master]: ranap: make X.213 NSAP 160 bits long, zero padded In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: ranap: make X.213 NSAP 160 bits long, zero padded ...................................................................... ranap: make X.213 NSAP 160 bits long, zero padded For IPv4 addresses, only 56bit of X.213 NSAP are used. The sysmocell5000 accepts such a field that is 56bits long, but the ip.access nano3G does not (and crashes instead). Both work when zero-padded to 160bits size. So far we used to send the IPv4 address as "raw" 32bits to the nano3G to avoid the crash. With this zero padding we no longer need such a workaround and can use identical config for both cells. Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index cd2ddfc..4634a07 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -639,7 +639,7 @@ unsigned int len; if (use_x213_nsap) { - len = 7; + len = 160/8; buf = CALLOC(len, sizeof(uint8_t)); buf[0] = 0x35; /* AFI For IANA ICP */ buf[1] = 0x00; /* See A.5.2.1.2.7 of X.213 */ diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index dc959eb..bd44d33 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -90,8 +90,9 @@ 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 - 28 14 00 3C 40 00 00 00 50 3D 02 00 02 0D C0 35 - 00 01 0A 0B 0C 0D 40 09 26 00 00 + 28 14 00 3C 40 00 00 00 50 3D 02 00 02 27 C0 35 + 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 + 00 00 00 40 09 26 00 00 00 @@ -100,14 +101,15 @@ 54 - 00 00 01 00 35 00 3B 78 02 CD 80 10 2F A7 20 2F + 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 - 3D 02 00 02 0D C0 35 00 01 0A 0B 0C 0D 40 09 26 - 00 00 40 01 00 + 3D 02 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 + 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 + 01 00 -00 00 00 4c 00 00 01 00 36 40 45 00 00 01 00 35 00 3b 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 0d c0 35 00 01 0a 0b 0c 0d 40 09 26 00 00 40 01 00 +00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) @@ -116,7 +118,8 @@ 38 04 12 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06 08 9E 00 00 00 00 B1 40 05 60 01 8C BA 7F 00 00 - 10 6E 35 00 01 1A 1B 1C 1D 00 11 22 33 44 + 11 3E 35 00 01 1A 1B 1C 1D 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 11 22 33 44 78 1C 00 00 00 00 @@ -125,13 +128,14 @@ 54 - 00 00 01 00 35 00 2E 38 04 12 DE 18 69 FF 80 0C + 00 00 01 00 35 00 3B 38 04 12 DE 18 69 FF 80 0C 34 FF 00 1F 40 08 06 08 9E 00 00 00 00 B1 40 05 - 60 01 8C BA 7F 00 00 10 6E 35 00 01 1A 1B 1C 1D - 00 11 22 33 44 40 06 78 1C 00 00 00 00 + 60 01 8C BA 7F 00 00 11 3E 35 00 01 1A 1B 1C 1D + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 22 + 33 44 40 06 78 1C 00 00 00 00 -00 00 00 44 00 00 01 00 36 40 3d 00 00 01 00 35 00 2e 38 04 12 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 00 00 b1 40 05 60 01 8c ba 7f 00 00 10 6e 35 00 01 1a 1b 1c 1d 00 11 22 33 44 40 06 78 1c 00 00 00 00 +00 00 00 51 00 00 01 00 36 40 4a 00 00 01 00 35 00 3b 38 04 12 de 18 69 ff 80 0c 34 ff 00 1f 40 08 06 08 9e 00 00 00 00 b1 40 05 60 01 8c ba 7f 00 00 11 3e 35 00 01 1a 1b 1c 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 22 33 44 40 06 78 1c 00 00 00 00 ==> RESET CMD -- To view, visit https://gerrit.osmocom.org/1648 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I070bbfe887ab93d08322df30571050a381d082d5 Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 04:04:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 04:04:56 +0000 Subject: [PATCH] osmo-iuh[master]: new_rab_par_voice(): add bitrate params, call with (6700, 12... In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1643 to look at the new patch set (#3). new_rab_par_voice(): add bitrate params, call with (6700, 12200) The guaranteedBitrate lowers from 12200 to 6700, which is mimicking the values found in a trace from a production 3G environment. So far we have no reason to choose these values other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 9 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/43/1643/3 diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 4634a07..64d87f9 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -559,7 +559,8 @@ } /* See Chapter 5 of TS 26.102 */ -static RANAP_RAB_Parameters_t *new_rab_par_voice(void) +static RANAP_RAB_Parameters_t *new_rab_par_voice(long bitrate_guaranteed, + long bitrate_max) { RANAP_RAB_Parameters_t *rab = CALLOC(1, sizeof(*rab)); RANAP_SDU_ParameterItem_t *sdui; @@ -567,9 +568,9 @@ rab->trafficClass = RANAP_TrafficClass_conversational; rab->rAB_AsymmetryIndicator = RANAP_RAB_AsymmetryIndicator_symmetric_bidirectional; - ASN_SEQUENCE_ADD(&rab->maxBitrate.list, new_long(12200)); + ASN_SEQUENCE_ADD(&rab->maxBitrate.list, new_long(bitrate_max)); rab->guaranteedBitRate = CALLOC(1, sizeof(*rab->guaranteedBitRate)); - ASN_SEQUENCE_ADD(rab->guaranteedBitRate, new_long(12200)); + ASN_SEQUENCE_ADD(rab->guaranteedBitRate, new_long(bitrate_guaranteed)); rab->deliveryOrder = RANAP_DeliveryOrder_delivery_order_requested; rab->maxSDU_Size = 244; @@ -738,7 +739,7 @@ memset(&first, 0, sizeof(first)); assign_new_ra_id(&first.rAB_ID, rab_id); first.nAS_SynchronisationIndicator = new_rab_nas_sync_ind(60); - first.rAB_Parameters = new_rab_par_voice(); + first.rAB_Parameters = new_rab_par_voice(6700, 12200); first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_support_mode_for_predefined_SDU_sizes, 1); /* 2? */ first.transportLayerInformation = new_transp_info_rtp(rtp_ip, rtp_port, use_x213_nsap); diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index bd44d33..2a8de8f 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -88,7 +88,7 @@ 53 - 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A + 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 @@ -101,15 +101,15 @@ 54 - 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 2F - A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 + 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 1A + 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 -00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 +00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1643 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 04:15:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 04:15:50 +0000 Subject: openbsc[master]: vty tests: attempt to get at sporadic 'Broken Pipe' error In-Reply-To: References: Message-ID: Patch Set 2: -Code-Review > sending IPA identity(lol) at 03:38:00 > failed sending IPA identity at 03:38:02 > retrying (3 attempts left) oh hey, nice -- I thought I saw a run of this patch with a Broken Pipe happening and not being caught by this. I'll see about the ps when I get the time... -- To view, visit https://gerrit.osmocom.org/1693 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 04:18:19 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 04:18:19 +0000 Subject: openbsc[master]: vty tests: attempt to get at sporadic 'Broken Pipe' error In-Reply-To: References: Message-ID: Patch Set 2: It's still there on jenkins: http://jenkins.osmocom.org/jenkins/job/OpenBSC-gerrit/1765/ is a test for this patch and shows: testVtyTree (__main__.TestVTYSGSN) ... Launch: ./src/gprs/osmo-sgsn -c ./doc/examples/osmo-sgsn/osmo-sgsn.cfg from /build/openbsc ok ====================================================================== ERROR: testBSCreload (__main__.TestVTYNAT) ---------------------------------------------------------------------- Traceback (most recent call last): File "./vty_test_runner.py", line 785, in testBSCreload b0 = nat_bsc_sock_test(0, "lol") File "./vty_test_runner.py", line 1290, in nat_bsc_sock_test ipa_handle_resp(bsc, tk, verbose) File "./vty_test_runner.py", line 1264, in ipa_handle_resp x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) error: [Errno 32] Broken pipe ---------------------------------------------------------------------- Ran 43 tests in 89.423s FAILED (errors=1) -- To view, visit https://gerrit.osmocom.org/1693 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 13:38:20 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Thu, 2 Feb 2017 13:38:20 +0000 Subject: libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Patch Set 4: > usage: conv_gen.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P > TARGET_PATH] > {gen_codes,gen_vectors,gen_header} {gsm} > witch the previous one. I looked for opportunity to customize the > help output, > but such approach requires to create a new class and redefine some > internal methods. > > So, if usage of argparse is mandatory, I will rewrite the code, and > will not care about help. okay I see that you can not describe gen_codes here. I think it is still better to use argparse and if needed write a formatter_class or custom command (e.g. how is gen_codes, gen_vectors added tot he parser?) -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 13:51:53 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Thu, 2 Feb 2017 13:51:53 +0000 Subject: libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Patch Set 4: > > usage: conv_gen.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P > > TARGET_PATH] > > {gen_codes,gen_vectors,gen_header} {gsm} > > > > witch the previous one. I looked for opportunity to customize the > > help output, > > but such approach requires to create a new class and redefine > some > > internal methods. > > > > So, if usage of argparse is mandatory, I will rewrite the code, > and > > will not care about help. > > okay I see that you can not describe gen_codes here. I think it is > still better to use argparse and if needed write a formatter_class > or custom command (e.g. how is gen_codes, gen_vectors added tot he > parser?) Well, thanks for your answer. I'll rewrite it soon... -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 16:32:09 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 2 Feb 2017 16:32:09 +0000 Subject: [PATCH] osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1711 to look at the new patch set (#2). octphy: Fix VTY commands The VTY commands show phy 0 rf-port-stats and show phy 0 clk-sync-stats do not output their results on the VTY console. If one of those commands is entered the user is prompted to view the logtext. This commit fixes the problem octphy_hw_api.c contains two value_string structs (radio_std_vals and clocksync_state_vals) which are now exported in octphy_hw_api.h in order to access them from octphy_vty.c Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 --- M src/osmo-bts-octphy/octphy_hw_api.c M src/osmo-bts-octphy/octphy_hw_api.h M src/osmo-bts-octphy/octphy_vty.c 3 files changed, 132 insertions(+), 45 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/11/1711/2 diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c index dc23676..6666f77 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.c +++ b/src/osmo-bts-octphy/octphy_hw_api.c @@ -29,6 +29,7 @@ #include "l1_if.h" #include "l1_oml.h" #include "l1_utils.h" +#include "octphy_hw_api.h" #include #include @@ -105,18 +106,12 @@ return l1if_req_compl(fl1h, msg, rf_port_info_compl_cb, NULL); } -static const struct value_string radio_std_vals[] = { - { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, - { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, - { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, - { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, - { 0, NULL } -}; - /* Chapter 12.10 */ static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h; @@ -136,12 +131,16 @@ psr->TxStats.ulTxAveragePeriodUs, psr->TxStats.ulFrequencyKhz); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.10 */ -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index) +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_RF_PORT_STATS_CMD *psc; @@ -156,7 +155,7 @@ mOCTVC1_HW_MSG_RF_PORT_STATS_CMD_SWAP(psc); - return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, NULL); + return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, cb_data); } static const struct value_string rx_gain_mode_vals[] = { @@ -276,28 +275,6 @@ { 0, NULL } }; -static const struct value_string clocksync_state_vals[] = { - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, - "Uninitialized" }, -/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to - * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef - * statement ensures that older headers still work. */ -#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, -#else - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, -#endif - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, - "No External Clock" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, - "Loss of Ext Clock" }, - { 0, NULL } -}; - /* Chapter 12.15 */ static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) @@ -336,6 +313,8 @@ static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) resp->l2h; @@ -349,12 +328,16 @@ csr->ulPllFractionalFreqHz, csr->ulSlipCnt, csr->ulSyncLosseCnt, csr->ulSourceState, csr->ulDacValue); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.16 */ -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h) +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD *csc; @@ -366,6 +349,6 @@ mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD_SWAP(csc); - return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, NULL); + return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, cb_data); } diff --git a/src/osmo-bts-octphy/octphy_hw_api.h b/src/osmo-bts-octphy/octphy_hw_api.h index bc8ab68..78b7208 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.h +++ b/src/osmo-bts-octphy/octphy_hw_api.h @@ -2,13 +2,53 @@ #include #include "l1_if.h" +#include + +static const struct value_string radio_std_vals[] = { + { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, + { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, + { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, + { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, + { 0, NULL } +}; + +static const struct value_string clocksync_state_vals[] = { + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, + "Uninitialized" }, +/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to + * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef + * statement ensures that older headers still work. */ +#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, +#else + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, +#endif + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, + "No External Clock" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, + "Loss of Ext Clock" }, + { 0, NULL } +}; + +typedef void octphy_hw_get_cb(struct msgb *resp, void *data); + +struct octphy_hw_get_cb_data { + octphy_hw_get_cb* cb; + void *data; +}; int octphy_hw_get_pcb_info(struct octphy_hdl *fl1h); int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index); -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index); +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data); int octphy_hw_get_rf_ant_rx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_rf_ant_tx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h); -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h); +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data); diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index e134fc5..41292c0 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -164,6 +164,42 @@ return CMD_SUCCESS; } +void show_rf_port_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + + if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) { + vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE); + return; + } + + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = + (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "RF-PORT-STATS:%s", VTY_NEWLINE); + vty_out(vty, "Idx=%d%s", psr->ulPortIndex, VTY_NEWLINE); + vty_out(vty, "RadioStandard=%s%s", + get_value_string(radio_std_vals, psr->ulRadioStandard), + VTY_NEWLINE); + vty_out(vty, "Rx Bytes=%u%s", psr->RxStats.ulRxByteCnt, VTY_NEWLINE); + vty_out(vty, "Rx Overflow=%u%s", psr->RxStats.ulRxOverflowCnt, + VTY_NEWLINE); + vty_out(vty, "Rx AvgBps=%u%s", psr->RxStats.ulRxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Rx Period=%u%s", psr->RxStats.ulRxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Rx Freq=%u%s", psr->RxStats.ulFrequencyKhz, VTY_NEWLINE); + vty_out(vty, "Tx Bytes=%u%s", psr->TxStats.ulTxByteCnt, VTY_NEWLINE); + vty_out(vty, "Tx Underflow=%u%s", psr->TxStats.ulTxUnderflowCnt, + VTY_NEWLINE); + vty_out(vty, "Tx AvgBps=%u%s", psr->TxStats.ulTxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Tx Period=%u%s", psr->TxStats.ulTxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Tx Freq=%u%s", psr->TxStats.ulFrequencyKhz, VTY_NEWLINE); +} + DEFUN(show_rf_port_stats, show_rf_port_stats_cmd, "show phy <0-255> rf-port-stats <0-1>", "Show statistics for the RF Port\n" @@ -171,14 +207,43 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1])); + cb_data.cb = show_rf_port_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); + octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]), + &cb_data); return CMD_SUCCESS; +} + +void show_clk_sync_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + + if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) != + msgb_l2len(resp)) { + vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE); + return; + } + + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = + (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "CLOCK-SYNC-MGR-STATS:%s", VTY_NEWLINE); + vty_out(vty, "State=%s%s", + get_value_string(clocksync_state_vals, csr->ulState), + VTY_NEWLINE); + vty_out(vty, "ClockError=%d%s", csr->lClockError, VTY_NEWLINE); + vty_out(vty, "DroppedCycles=%d%s", csr->lDroppedCycles, VTY_NEWLINE); + vty_out(vty, "PllFreqHz=%u%s", csr->ulPllFreqHz, VTY_NEWLINE); + vty_out(vty, "PllFract=%u%s", csr->ulPllFractionalFreqHz, VTY_NEWLINE); + vty_out(vty, "SlipCnt=%u%s", csr->ulSlipCnt, VTY_NEWLINE); + vty_out(vty, "SyncLosses=%u%s", csr->ulSyncLosseCnt, VTY_NEWLINE); + vty_out(vty, "SourceState=%u%s", csr->ulSourceState, VTY_NEWLINE); + vty_out(vty, "DacValue=%u%s", csr->ulDacValue, VTY_NEWLINE); } DEFUN(show_clk_sync_stats, show_clk_sync_stats_cmd, @@ -187,13 +252,12 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl); + cb_data.cb = show_clk_sync_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); - + octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl, &cb_data); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 16:46:21 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 2 Feb 2017 16:46:21 +0000 Subject: [PATCH] osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1711 to look at the new patch set (#3). octphy: Fix VTY commands The VTY commands show phy 0 rf-port-stats and show phy 0 clk-sync-stats do not output their results on the VTY console. If one of those commands is entered the user is prompted to view the logtext, which is an uncomfortable solution. This commit adds the missing functionality to print the information in the VTY as well. octphy_hw_api.c contains two value_string structs (radio_std_vals and clocksync_state_vals) which are now exported in octphy_hw_api.h in order to access them from octphy_vty.c Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 --- M src/osmo-bts-octphy/octphy_hw_api.c M src/osmo-bts-octphy/octphy_hw_api.h M src/osmo-bts-octphy/octphy_vty.c 3 files changed, 132 insertions(+), 45 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/11/1711/3 diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c index dc23676..6666f77 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.c +++ b/src/osmo-bts-octphy/octphy_hw_api.c @@ -29,6 +29,7 @@ #include "l1_if.h" #include "l1_oml.h" #include "l1_utils.h" +#include "octphy_hw_api.h" #include #include @@ -105,18 +106,12 @@ return l1if_req_compl(fl1h, msg, rf_port_info_compl_cb, NULL); } -static const struct value_string radio_std_vals[] = { - { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, - { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, - { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, - { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, - { 0, NULL } -}; - /* Chapter 12.10 */ static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h; @@ -136,12 +131,16 @@ psr->TxStats.ulTxAveragePeriodUs, psr->TxStats.ulFrequencyKhz); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.10 */ -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index) +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_RF_PORT_STATS_CMD *psc; @@ -156,7 +155,7 @@ mOCTVC1_HW_MSG_RF_PORT_STATS_CMD_SWAP(psc); - return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, NULL); + return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, cb_data); } static const struct value_string rx_gain_mode_vals[] = { @@ -276,28 +275,6 @@ { 0, NULL } }; -static const struct value_string clocksync_state_vals[] = { - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, - "Uninitialized" }, -/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to - * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef - * statement ensures that older headers still work. */ -#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, -#else - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, -#endif - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, - "No External Clock" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, - "Loss of Ext Clock" }, - { 0, NULL } -}; - /* Chapter 12.15 */ static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) @@ -336,6 +313,8 @@ static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) resp->l2h; @@ -349,12 +328,16 @@ csr->ulPllFractionalFreqHz, csr->ulSlipCnt, csr->ulSyncLosseCnt, csr->ulSourceState, csr->ulDacValue); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.16 */ -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h) +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD *csc; @@ -366,6 +349,6 @@ mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD_SWAP(csc); - return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, NULL); + return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, cb_data); } diff --git a/src/osmo-bts-octphy/octphy_hw_api.h b/src/osmo-bts-octphy/octphy_hw_api.h index bc8ab68..78b7208 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.h +++ b/src/osmo-bts-octphy/octphy_hw_api.h @@ -2,13 +2,53 @@ #include #include "l1_if.h" +#include + +static const struct value_string radio_std_vals[] = { + { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, + { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, + { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, + { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, + { 0, NULL } +}; + +static const struct value_string clocksync_state_vals[] = { + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, + "Uninitialized" }, +/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to + * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef + * statement ensures that older headers still work. */ +#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, +#else + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, +#endif + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, + "No External Clock" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, + "Loss of Ext Clock" }, + { 0, NULL } +}; + +typedef void octphy_hw_get_cb(struct msgb *resp, void *data); + +struct octphy_hw_get_cb_data { + octphy_hw_get_cb* cb; + void *data; +}; int octphy_hw_get_pcb_info(struct octphy_hdl *fl1h); int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index); -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index); +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data); int octphy_hw_get_rf_ant_rx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_rf_ant_tx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h); -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h); +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data); diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index e134fc5..41292c0 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -164,6 +164,42 @@ return CMD_SUCCESS; } +void show_rf_port_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + + if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) { + vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE); + return; + } + + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = + (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "RF-PORT-STATS:%s", VTY_NEWLINE); + vty_out(vty, "Idx=%d%s", psr->ulPortIndex, VTY_NEWLINE); + vty_out(vty, "RadioStandard=%s%s", + get_value_string(radio_std_vals, psr->ulRadioStandard), + VTY_NEWLINE); + vty_out(vty, "Rx Bytes=%u%s", psr->RxStats.ulRxByteCnt, VTY_NEWLINE); + vty_out(vty, "Rx Overflow=%u%s", psr->RxStats.ulRxOverflowCnt, + VTY_NEWLINE); + vty_out(vty, "Rx AvgBps=%u%s", psr->RxStats.ulRxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Rx Period=%u%s", psr->RxStats.ulRxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Rx Freq=%u%s", psr->RxStats.ulFrequencyKhz, VTY_NEWLINE); + vty_out(vty, "Tx Bytes=%u%s", psr->TxStats.ulTxByteCnt, VTY_NEWLINE); + vty_out(vty, "Tx Underflow=%u%s", psr->TxStats.ulTxUnderflowCnt, + VTY_NEWLINE); + vty_out(vty, "Tx AvgBps=%u%s", psr->TxStats.ulTxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Tx Period=%u%s", psr->TxStats.ulTxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Tx Freq=%u%s", psr->TxStats.ulFrequencyKhz, VTY_NEWLINE); +} + DEFUN(show_rf_port_stats, show_rf_port_stats_cmd, "show phy <0-255> rf-port-stats <0-1>", "Show statistics for the RF Port\n" @@ -171,14 +207,43 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1])); + cb_data.cb = show_rf_port_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); + octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]), + &cb_data); return CMD_SUCCESS; +} + +void show_clk_sync_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + + if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) != + msgb_l2len(resp)) { + vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE); + return; + } + + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = + (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "CLOCK-SYNC-MGR-STATS:%s", VTY_NEWLINE); + vty_out(vty, "State=%s%s", + get_value_string(clocksync_state_vals, csr->ulState), + VTY_NEWLINE); + vty_out(vty, "ClockError=%d%s", csr->lClockError, VTY_NEWLINE); + vty_out(vty, "DroppedCycles=%d%s", csr->lDroppedCycles, VTY_NEWLINE); + vty_out(vty, "PllFreqHz=%u%s", csr->ulPllFreqHz, VTY_NEWLINE); + vty_out(vty, "PllFract=%u%s", csr->ulPllFractionalFreqHz, VTY_NEWLINE); + vty_out(vty, "SlipCnt=%u%s", csr->ulSlipCnt, VTY_NEWLINE); + vty_out(vty, "SyncLosses=%u%s", csr->ulSyncLosseCnt, VTY_NEWLINE); + vty_out(vty, "SourceState=%u%s", csr->ulSourceState, VTY_NEWLINE); + vty_out(vty, "DacValue=%u%s", csr->ulDacValue, VTY_NEWLINE); } DEFUN(show_clk_sync_stats, show_clk_sync_stats_cmd, @@ -187,13 +252,12 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl); + cb_data.cb = show_clk_sync_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); - + octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl, &cb_data); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:03:10 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 2 Feb 2017 17:03:10 +0000 Subject: [PATCH] libosmocore[master]: lapd_core: Improve debug output Message-ID: Review at https://gerrit.osmocom.org/1724 lapd_core: Improve debug output The debug output of lapd core has no references to the dl objects, since we have multiple links, seeing which action is for which object is impossible. This commit adds pointer references (dl=%p) to each log line. Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda --- M src/gsm/lapd_core.c 1 file changed, 190 insertions(+), 144 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/24/1724/1 diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index bf5c388..84b1828 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -197,7 +197,7 @@ { if (osmo_timer_pending(&dl->t200)) return; - LOGP(DLLAPD, LOGL_INFO, "start T200\n"); + LOGP(DLLAPD, LOGL_INFO, "start T200 (dl=%p)\n", dl); osmo_timer_schedule(&dl->t200, dl->t200_sec, dl->t200_usec); } @@ -205,7 +205,7 @@ { if (osmo_timer_pending(&dl->t203)) return; - LOGP(DLLAPD, LOGL_INFO, "start T203\n"); + LOGP(DLLAPD, LOGL_INFO, "start T203 (dl=%p)\n", dl); osmo_timer_schedule(&dl->t203, dl->t203_sec, dl->t203_usec); } @@ -213,7 +213,7 @@ { if (!osmo_timer_pending(&dl->t200)) return; - LOGP(DLLAPD, LOGL_INFO, "stop T200\n"); + LOGP(DLLAPD, LOGL_INFO, "stop T200 (dl=%p)\n", dl); osmo_timer_del(&dl->t200); } @@ -221,14 +221,14 @@ { if (!osmo_timer_pending(&dl->t203)) return; - LOGP(DLLAPD, LOGL_INFO, "stop T203\n"); + LOGP(DLLAPD, LOGL_INFO, "stop T203 (dl=%p)\n", dl); osmo_timer_del(&dl->t203); } static void lapd_dl_newstate(struct lapd_datalink *dl, uint32_t state) { - LOGP(DLLAPD, LOGL_INFO, "new state %s -> %s\n", - lapd_state_names[dl->state], lapd_state_names[state]); + LOGP(DLLAPD, LOGL_INFO, "new state %s -> %s (dl=%p)\n", + lapd_state_names[dl->state], lapd_state_names[state], dl); if (state != LAPD_STATE_MF_EST && dl->state == LAPD_STATE_MF_EST) { /* stop T203 on leaving MF EST state, if running */ @@ -289,7 +289,8 @@ } LOGP(DLLAPD, LOGL_INFO, "Init DL layer: sequence range = %d, k = %d, " - "history range = %d\n", dl->v_range, dl->k, dl->range_hist); + "history range = %d (dl=%p)\n", dl->v_range, dl->k, + dl->range_hist, dl); lapd_dl_newstate(dl, LAPD_STATE_IDLE); @@ -304,7 +305,7 @@ { if (dl->state == LAPD_STATE_IDLE) return; - LOGP(DLLAPD, LOGL_INFO, "Resetting LAPDm instance\n"); + LOGP(DLLAPD, LOGL_INFO, "Resetting LAPDm instance (dl=%p)\n", dl); /* enter idle state (and remove eventual cont_res) */ lapd_dl_newstate(dl, LAPD_STATE_IDLE); /* flush buffer */ @@ -378,8 +379,9 @@ struct lapd_datalink *dl = lctx->dl; struct osmo_dlsap_prim dp; - LOGP(DLLAPD, LOGL_NOTICE, "sending MDL-ERROR-IND cause %s\n", - rsl_rlm_cause_name(cause)); + LOGP(DLLAPD, LOGL_NOTICE, + "sending MDL-ERROR-IND cause %d from state %s (dl=%p)\n", + cause, lapd_state_names[dl->state], dl); osmo_prim_init(&dp.oph, 0, PRIM_MDL_ERROR, PRIM_OP_INDICATION, NULL); dp.u.error_ind.cause = cause; return dl->send_dlsap(&dp, lctx); @@ -534,6 +536,8 @@ struct osmo_dlsap_prim dp; struct msgb *msg; + LOGP(DLLAPD, LOGL_DEBUG, "lapd reestablish (dl=%p)\n", dl); + msg = lapd_msgb_alloc(0, "DUMMY"); osmo_prim_init(&dp.oph, 0, PRIM_DL_EST, PRIM_OP_REQUEST, msg); @@ -545,8 +549,8 @@ { struct lapd_datalink *dl = data; - LOGP(DLLAPD, LOGL_INFO, "Timeout T200 (%p) state=%d\n", dl, - (int) dl->state); + LOGP(DLLAPD, LOGL_INFO, "Timeout T200 state=%s (dl=%p)\n", + lapd_state_names[dl->state], dl); switch (dl->state) { case LAPD_STATE_SABM_SENT: @@ -615,7 +619,7 @@ struct lapd_msg_ctx nctx; LOGP(DLLAPD, LOGL_INFO, "retransmit last frame" - " V(S)=%d\n", vs); + " V(S)=%d (dl=%p)\n", vs, dl); /* Create I frame (segment) from tx_hist */ memcpy(&nctx, &dl->lctx, sizeof(nctx)); /* keep nctx.ldp */ @@ -647,7 +651,7 @@ lapd_send_rnr(&dl->lctx, 1, 1); } else { LOGP(DLLAPD, LOGL_INFO, "unhandled, " - "pls. fix\n"); + "pls. fix (dl=%p)\n", dl); } } /* restart T200 (PH-READY-TO-SEND) */ @@ -659,13 +663,13 @@ if (!dl->reestablish) break; LOGP(DLLAPD, LOGL_NOTICE, "N200 reached, performing " - "reestablishment.\n"); + "reestablishment. (dl=%p)\n", dl); lapd_reestablish(dl); } break; default: LOGP(DLLAPD, LOGL_INFO, "T200 expired in unexpected " - "dl->state %d\n", (int) dl->state); + "dl->state %s (dl=%p)\n", lapd_state_names[dl->state], dl); } } @@ -674,12 +678,12 @@ { struct lapd_datalink *dl = data; - LOGP(DLLAPD, LOGL_INFO, "Timeout T203 (%p) state=%d\n", dl, - (int) dl->state); + LOGP(DLLAPD, LOGL_INFO, "Timeout T203 state=%s (dl=%p)\n", + lapd_state_names[dl->state], dl); if (dl->state != LAPD_STATE_MF_EST) { LOGP(DLLAPD, LOGL_ERROR, "T203 fired outside MF EST state, " - "please fix!\n"); + "please fix! (dl=%p)\n", dl); return; } @@ -689,11 +693,13 @@ lapd_dl_newstate(dl, LAPD_STATE_TIMER_RECOV); /* transmit a supervisory command with P bit set to 1 as follows: */ if (!dl->own_busy) { - LOGP(DLLAPD, LOGL_INFO, "transmit an RR poll command\n"); + LOGP(DLLAPD, LOGL_INFO, + "transmit an RR poll command (dl=%p)\n", dl); /* Send RR with P=1 */ lapd_send_rr(&dl->lctx, 1, 1); } else { - LOGP(DLLAPD, LOGL_INFO, "transmit an RNR poll command\n"); + LOGP(DLLAPD, LOGL_INFO, + "transmit an RNR poll command (dl=%p)\n", dl); /* Send RNR with P=1 */ lapd_send_rnr(&dl->lctx, 1, 1); } @@ -743,7 +749,7 @@ */ if (sub_mod(nr, dl->v_ack, dl->v_range) > sub_mod(dl->v_send, dl->v_ack, dl->v_range)) { - LOGP(DLLAPD, LOGL_NOTICE, "N(R) sequence error\n"); + LOGP(DLLAPD, LOGL_NOTICE, "N(R) sequence error (dl=%p)\n", dl); mdl_error(MDL_CAUSE_SEQ_ERR, lctx); } } @@ -756,7 +762,7 @@ if (t200_reset && !rej) { if (dl->tx_hist[sub_mod(dl->v_send, 1, dl->range_hist)].msg) { LOGP(DLLAPD, LOGL_INFO, "start T200, due to unacked I " - "frame(s)\n"); + "frame(s) (dl=%p)\n", dl); lapd_start_t200(dl); } } @@ -789,13 +795,14 @@ prim = PRIM_DL_EST; op = PRIM_OP_INDICATION; - LOGP(DLLAPD, LOGL_INFO, "SABM(E) received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "SABM(E) received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.7.1 */ dl->seq_err_cond = 0; /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { - LOGP(DLLAPD, LOGL_ERROR, "SABM response error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "SABM response error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -805,7 +812,8 @@ * set, AN MDL-ERROR-INDICATION is sent to MM. */ if (lctx->more || length > lctx->n201) { - LOGP(DLLAPD, LOGL_ERROR, "SABM too large error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "SABM too large error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; @@ -816,7 +824,7 @@ break; case LAPD_STATE_MF_EST: LOGP(DLLAPD, LOGL_INFO, "SABM command, multiple " - "frame established state\n"); + "frame established state (dl=%p)\n", dl); /* If link is lost on the remote side, we start over * and send DL-ESTABLISH indication again. */ /* Additionally, continue in case of content resoltion @@ -829,13 +837,13 @@ /* If no content resolution, this is a * re-establishment. */ LOGP(DLLAPD, LOGL_INFO, - "Remote reestablish\n"); + "Remote reestablish (dl=%p)\n", dl); break; } if (!dl->cont_res) { LOGP(DLLAPD, LOGL_INFO, "SABM command not " - "allowed in state %s\n", - lapd_state_names[dl->state]); + "allowed in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); mdl_error(MDL_CAUSE_SABM_MF, lctx); msgb_free(msg); return 0; @@ -848,8 +856,8 @@ if (memcmp(dl->cont_res->data, msg->data, length)) { LOGP(DLLAPD, LOGL_INFO, "Another SABM " - "with diffrent content - " - "ignoring!\n"); + "with diffrent content - " + "ignoring! (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -872,8 +880,8 @@ /* check for contention resoultion */ if (dl->tx_hist[0].msg && dl->tx_hist[0].msg->len) { LOGP(DLLAPD, LOGL_NOTICE, "SABM not allowed " - "during contention resolution (state %s)\n", - lapd_state_names[dl->state]); + "during contention resolution (state=%s, dl=%p)\n", + lapd_state_names[dl->state], dl); mdl_error(MDL_CAUSE_SABM_INFO_NOTALL, lctx); } lapd_send_ua(lctx, length, msg->l3h); @@ -899,7 +907,8 @@ dl->cont_res = lapd_msgb_alloc(length, "CONT RES"); memcpy(msgb_put(dl->cont_res, length), msg->l3h, length); - LOGP(DLLAPD, LOGL_NOTICE, "Store content res.\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Store content res. (dl=%p)\n", dl); } /* send notification to L3 */ if (length == 0) { @@ -913,11 +922,12 @@ } break; case LAPD_U_DM: - LOGP(DLLAPD, LOGL_INFO, "DM received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "DM received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.cmd) { - LOGP(DLLAPD, LOGL_ERROR, "DM command error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "DM command error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -935,12 +945,12 @@ case LAPD_STATE_MF_EST: if (lctx->p_f) { LOGP(DLLAPD, LOGL_INFO, "unsolicited DM " - "response\n"); + "response (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_DM_RESP, lctx); } else { LOGP(DLLAPD, LOGL_INFO, "unsolicited DM " "response, multiple frame established " - "state\n"); + "state (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_DM_RESP_MF, lctx); /* reestablish */ if (!dl->reestablish) { @@ -948,7 +958,7 @@ return 0; } LOGP(DLLAPD, LOGL_NOTICE, "Performing " - "reestablishment.\n"); + "reestablishment. (dl=%p)\n", dl); lapd_reestablish(dl); } msgb_free(msg); @@ -958,14 +968,14 @@ if (!lctx->p_f) { LOGP(DLLAPD, LOGL_INFO, "unsolicited DM " "response, multiple frame established " - "state\n"); + "state (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_DM_RESP_MF, lctx); msgb_free(msg); /* reestablish */ if (!dl->reestablish) return 0; LOGP(DLLAPD, LOGL_NOTICE, "Performing " - "reestablishment.\n"); + "reestablishment. (dl=%p)\n", dl); return lapd_reestablish(dl); } break; @@ -983,7 +993,7 @@ /* 5.4.5 all other frame types shall be discarded */ default: LOGP(DLLAPD, LOGL_INFO, "unsolicited DM response! " - "(discarding)\n"); + "(discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -995,11 +1005,11 @@ msgb_free(msg); break; case LAPD_U_UI: - LOGP(DLLAPD, LOGL_INFO, "UI received\n"); + LOGP(DLLAPD, LOGL_INFO, "UI received (dl=%p)\n", dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { LOGP(DLLAPD, LOGL_ERROR, "UI indicates response " - "error\n"); + "error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1010,8 +1020,8 @@ */ if (length > lctx->n201 || lctx->more) { LOGP(DLLAPD, LOGL_ERROR, "UI too large error " - "(%d > N201(%d) or M=%d)\n", length, - lctx->n201, lctx->more); + "(%d > N201(%d) or M=%d) (dl=%p)\n", length, + lctx->n201, lctx->more, dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; @@ -1022,7 +1032,8 @@ /* 5.3.3 UI frames received with the length indicator * set to "0" shall be ignored */ - LOGP(DLLAPD, LOGL_INFO, "length=0 (discarding)\n"); + LOGP(DLLAPD, LOGL_INFO, + "length=0 (discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -1034,8 +1045,8 @@ prim = PRIM_DL_REL; op = PRIM_OP_INDICATION; - LOGP(DLLAPD, LOGL_INFO, "DISC received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "DISC received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); @@ -1043,7 +1054,8 @@ dl->seq_err_cond = 0; /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { - LOGP(DLLAPD, LOGL_ERROR, "DISC response error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "DISC response error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1055,19 +1067,21 @@ * parameters" is sent to the mobile management entity. */ LOGP(DLLAPD, LOGL_ERROR, - "U frame iwth incorrect parameters "); + "U frame iwth incorrect parameters (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; } switch (dl->state) { case LAPD_STATE_IDLE: - LOGP(DLLAPD, LOGL_INFO, "DISC in idle state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in idle state (dl=%p)\n", dl); /* send DM with F=P */ msgb_free(msg); return lapd_send_dm(lctx); case LAPD_STATE_SABM_SENT: - LOGP(DLLAPD, LOGL_INFO, "DISC in SABM state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in SABM state (dl=%p)\n", dl); /* 5.4.6.2 send DM with F=P */ lapd_send_dm(lctx); /* stop Timer T200 */ @@ -1079,10 +1093,12 @@ lctx); case LAPD_STATE_MF_EST: case LAPD_STATE_TIMER_RECOV: - LOGP(DLLAPD, LOGL_INFO, "DISC in est state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in est state (dl=%p)\n", dl); break; case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_INFO, "DISC in disc state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in disc state (dl=%p)\n", dl); prim = PRIM_DL_REL; op = PRIM_OP_CONFIRM; break; @@ -1102,12 +1118,12 @@ msgb_free(msg); break; case LAPD_U_UA: - LOGP(DLLAPD, LOGL_INFO, "UA received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "UA received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.cmd) { LOGP(DLLAPD, LOGL_ERROR, "UA indicates command " - "error\n"); + "error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1117,7 +1133,8 @@ * set, AN MDL-ERROR-INDICATION is sent to MM. */ if (lctx->more || length > lctx->n201) { - LOGP(DLLAPD, LOGL_ERROR, "UA too large error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "UA too large error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; @@ -1127,7 +1144,8 @@ /* 5.4.1.2 A UA response with the F bit set to "0" * shall be ignored. */ - LOGP(DLLAPD, LOGL_INFO, "F=0 (discarding)\n"); + LOGP(DLLAPD, LOGL_INFO, + "F=0 (discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -1137,12 +1155,13 @@ case LAPD_STATE_MF_EST: case LAPD_STATE_TIMER_RECOV: LOGP(DLLAPD, LOGL_INFO, "unsolicited UA response! " - "(discarding)\n"); + "(discarding) (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_UA_RESP, lctx); msgb_free(msg); return 0; case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_INFO, "UA in disconnect state\n"); + LOGP(DLLAPD, LOGL_INFO, + "UA in disconnect state (dl=%p)\n", dl); /* stop Timer T200 */ lapd_stop_t200(dl); /* go to idle state */ @@ -1156,11 +1175,11 @@ /* 5.4.5 all other frame types shall be discarded */ default: LOGP(DLLAPD, LOGL_INFO, "unsolicited UA response! " - "(discarding)\n"); + "(discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } - LOGP(DLLAPD, LOGL_INFO, "UA in SABM state\n"); + LOGP(DLLAPD, LOGL_INFO, "UA in SABM state (dl=%p)\n", dl); /* stop Timer T200 */ lapd_stop_t200(dl); /* compare UA with SABME if contention resolution is applied */ @@ -1169,7 +1188,7 @@ || !!memcmp(dl->tx_hist[0].msg->data, msg->l3h, length)) { LOGP(DLLAPD, LOGL_INFO, "**** UA response " - "mismatches ****\n"); + "mismatches **** (dl=%p)\n", dl); rc = send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, lctx); msgb_free(msg); @@ -1193,19 +1212,22 @@ msgb_free(msg); break; case LAPD_U_FRMR: - LOGP(DLLAPD, LOGL_NOTICE, "Frame reject received\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Frame reject received (dl=%p)\n", dl); /* send MDL ERROR INIDCATION to L3 */ mdl_error(MDL_CAUSE_FRMR, lctx); msgb_free(msg); /* reestablish */ if (!dl->reestablish) break; - LOGP(DLLAPD, LOGL_NOTICE, "Performing reestablishment.\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Performing reestablishment. (dl=%p)\n", dl); rc = lapd_reestablish(dl); break; default: /* G.3.1 */ - LOGP(DLLAPD, LOGL_NOTICE, "Unnumbered frame not allowed.\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Unnumbered frame not allowed. (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1225,7 +1247,7 @@ * primitive with cause "S frame with incorrect * parameters" is sent to the mobile management entity. */ LOGP(DLLAPD, LOGL_ERROR, - "S frame with incorrect parameters\n"); + "S frame with incorrect parameters (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_SFRM_INC_PARAM, lctx); return -EIO; @@ -1235,7 +1257,8 @@ && lctx->p_f && dl->state != LAPD_STATE_TIMER_RECOV) { /* 5.4.2.2: Inidcate error on supervisory reponse F=1 */ - LOGP(DLLAPD, LOGL_NOTICE, "S frame response with F=1 error\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "S frame response with F=1 error (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_SPRV_RESP, lctx); } @@ -1248,14 +1271,15 @@ /* fall though */ case LAPD_STATE_SABM_SENT: case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_NOTICE, "S frame ignored in this state\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "S frame ignored in this state (dl=%p)\n", dl); msgb_free(msg); return 0; } switch (lctx->s_u) { case LAPD_S_RR: - LOGP(DLLAPD, LOGL_INFO, "RR received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "RR received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.5.3.1: Acknowlege all tx frames up the the N(R)-1 */ lapd_acknowledge(lctx); @@ -1264,9 +1288,9 @@ && lctx->p_f) { if (!dl->own_busy && !dl->seq_err_cond) { LOGP(DLLAPD, LOGL_INFO, "RR frame command " - "with polling bit set and we are not " - "busy, so we reply with RR frame " - "response\n"); + "with polling bit set and we are not " + "busy, so we reply with RR frame " + "response (dl=%p)\n", dl); lapd_send_rr(lctx, 1, 0); /* NOTE: In case of sequence error condition, * the REJ frame has been transmitted when @@ -1275,8 +1299,9 @@ */ } else if (dl->own_busy) { LOGP(DLLAPD, LOGL_INFO, "RR frame command " - "with polling bit set and we are busy, " - "so we reply with RR frame response\n"); + "with polling bit set and we are busy, " + "so we reply with RR frame response (dl=%p)\n", + dl); lapd_send_rnr(lctx, 1, 0); } } else if (lctx->cr == dl->cr.rem2loc.resp @@ -1284,7 +1309,7 @@ && dl->state == LAPD_STATE_TIMER_RECOV) { LOGP(DLLAPD, LOGL_INFO, "RR response with F==1, " "and we are in timer recovery state, so " - "we leave that state\n"); + "we leave that state (dl=%p)\n", dl); /* V(S) to the N(R) in the RR frame */ dl->v_send = lctx->n_recv; /* stop Timer T200 */ @@ -1297,8 +1322,8 @@ break; case LAPD_S_RNR: - LOGP(DLLAPD, LOGL_INFO, "RNR received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "RNR received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.5.3.1: Acknowlege all tx frames up the the N(R)-1 */ lapd_acknowledge(lctx); @@ -1312,21 +1337,21 @@ LOGP(DLLAPD, LOGL_INFO, "RNR poll " "command and we are not busy, " "so we reply with RR final " - "response\n"); + "response (dl=%p)\n", dl); /* Send RR with F=1 */ lapd_send_rr(lctx, 1, 0); } else { LOGP(DLLAPD, LOGL_INFO, "RNR poll " "command and we are busy, so " "we reply with RNR final " - "response\n"); + "response (dl=%p)\n", dl); /* Send RNR with F=1 */ lapd_send_rnr(lctx, 1, 0); } } else if (dl->state == LAPD_STATE_TIMER_RECOV) { LOGP(DLLAPD, LOGL_INFO, "RNR poll response " "and we in timer recovery state, so " - "we leave that state\n"); + "we leave that state (dl=%p)\n", dl); /* 5.5.7 Clear timer recovery condition */ lapd_dl_newstate(dl, LAPD_STATE_MF_EST); /* V(S) to the N(R) in the RNR frame */ @@ -1334,15 +1359,15 @@ } } else LOGP(DLLAPD, LOGL_INFO, "RNR not polling/final state " - "received\n"); + "received (dl=%p)\n", dl); /* Send message, if possible due to acknowledged data */ lapd_send_i(lctx, __LINE__); break; case LAPD_S_REJ: - LOGP(DLLAPD, LOGL_INFO, "REJ received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "REJ received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.5.3.1: Acknowlege all tx frames up the the N(R)-1 */ lapd_acknowledge(lctx); @@ -1362,7 +1387,7 @@ "state and not in own busy " "condition received, so we " "respond with RR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rr(lctx, 1, 0); /* NOTE: In case of sequence error * condition, the REJ frame has been @@ -1376,21 +1401,24 @@ "state and in own busy " "condition received, so we " "respond with RNR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rnr(lctx, 1, 0); } } else LOGP(DLLAPD, LOGL_INFO, "REJ response or not " "polling command not in timer recovery " - "state received\n"); + "state received (dl=%p)\n", dl); /* send MDL ERROR INIDCATION to L3 */ if (lctx->cr == dl->cr.rem2loc.resp && lctx->p_f) { + LOGP(DLLAPD, LOGL_ERROR, + "unsolicited supervisory response! (dl=%p)\n", + dl); mdl_error(MDL_CAUSE_UNSOL_SPRV_RESP, lctx); } } else if (lctx->cr == dl->cr.rem2loc.resp && lctx->p_f) { LOGP(DLLAPD, LOGL_INFO, "REJ poll response in timer " - "recovery state received\n"); + "recovery state received (dl=%p)\n", dl); /* Clear an existing peer receiver busy condition */ dl->peer_busy = 0; /* V(S) and V(A) to the N(R) in the REJ frame */ @@ -1412,7 +1440,7 @@ "state and not in own busy " "condition received, so we " "respond with RR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rr(lctx, 1, 0); /* NOTE: In case of sequence error * condition, the REJ frame has been @@ -1426,13 +1454,13 @@ "state and in own busy " "condition received, so we " "respond with RNR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rnr(lctx, 1, 0); } } else LOGP(DLLAPD, LOGL_INFO, "REJ response or not " "polling command in timer recovery " - "state received\n"); + "state received (dl=%p)\n", dl); } /* FIXME: 5.5.4.2 2) */ @@ -1443,7 +1471,8 @@ break; default: /* G.3.1 */ - LOGP(DLLAPD, LOGL_ERROR, "Supervisory frame not allowed.\n"); + LOGP(DLLAPD, LOGL_ERROR, + "Supervisory frame not allowed. (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1461,12 +1490,13 @@ int length = lctx->length; int rc; - LOGP(DLLAPD, LOGL_INFO, "I received in state %s on SAPI(%u)\n", - lapd_state_names[dl->state], lctx->sapi); + LOGP(DLLAPD, LOGL_INFO, "I received in state %s on SAPI(%u) (dl=%p)\n", + lapd_state_names[dl->state], lctx->sapi, dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { - LOGP(DLLAPD, LOGL_ERROR, "I frame response not allowed\n"); + LOGP(DLLAPD, LOGL_ERROR, + "I frame response not allowed (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1477,7 +1507,8 @@ * to a numerical value L>N201 or L=0, an MDL-ERROR-INDICATION * primitive with cause "I frame with incorrect length" * is sent to the mobile management entity. */ - LOGP(DLLAPD, LOGL_ERROR, "I frame length not allowed\n"); + LOGP(DLLAPD, LOGL_ERROR, + "I frame length not allowed (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_IFRM_INC_LEN, lctx); return -EIO; @@ -1488,7 +1519,8 @@ * cause "I frame with incorrect use of M bit" is sent to the * mobile management entity. */ if (lctx->more && length < lctx->n201) { - LOGP(DLLAPD, LOGL_ERROR, "I frame with M bit too short\n"); + LOGP(DLLAPD, LOGL_ERROR, + "I frame with M bit too short (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_IFRM_INC_MBITS, lctx); return -EIO; @@ -1503,7 +1535,8 @@ /* fall though */ case LAPD_STATE_SABM_SENT: case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_NOTICE, "I frame ignored in this state\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "I frame ignored in this state (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -1511,7 +1544,7 @@ /* 5.7.1: N(s) sequence error */ if (ns != dl->v_recv) { LOGP(DLLAPD, LOGL_NOTICE, "N(S) sequence error: N(S)=%u, " - "V(R)=%u\n", ns, dl->v_recv); + "V(R)=%u (dl=%p)\n", ns, dl->v_recv, dl); /* discard data */ msgb_free(msg); if (dl->seq_err_cond != 1) { @@ -1545,7 +1578,8 @@ /* Increment receiver state */ dl->v_recv = inc_mod(dl->v_recv, dl->v_range); - LOGP(DLLAPD, LOGL_INFO, "incrementing V(R) to %u\n", dl->v_recv); + LOGP(DLLAPD, LOGL_INFO, "incrementing V(R) to %u (dl=%p)\n", + dl->v_recv, dl); /* 5.5.3.1: Acknowlege all transmitted frames up the the N(R)-1 */ lapd_acknowledge(lctx); /* V(A) is also set here */ @@ -1554,7 +1588,8 @@ if (!dl->own_busy) { /* if the frame carries a complete segment */ if (!lctx->more && !dl->rcv_buffer) { - LOGP(DLLAPD, LOGL_INFO, "message in single I frame\n"); + LOGP(DLLAPD, LOGL_INFO, + "message in single I frame (dl=%p)\n", dl); /* send a DATA INDICATION to L3 */ msgb_trim(msg, length); rc = send_dl_l3(PRIM_DL_DATA, PRIM_OP_INDICATION, lctx, @@ -1563,7 +1598,7 @@ /* create rcv_buffer */ if (!dl->rcv_buffer) { LOGP(DLLAPD, LOGL_INFO, "message in multiple " - "I frames (first message)\n"); + "I frames (first message) (dl=%p)\n", dl); dl->rcv_buffer = lapd_msgb_alloc(dl->maxf, "LAPD RX"); dl->rcv_buffer->l3h = dl->rcv_buffer->data; @@ -1571,7 +1606,7 @@ /* concat. rcv_buffer */ if (msgb_l3len(dl->rcv_buffer) + length > dl->maxf) { LOGP(DLLAPD, LOGL_NOTICE, "Received frame " - "overflow!\n"); + "overflow! (dl=%p)\n", dl); } else { memcpy(msgb_put(dl->rcv_buffer, length), msg->l3h, length); @@ -1579,14 +1614,14 @@ /* if the last segment was received */ if (!lctx->more) { LOGP(DLLAPD, LOGL_INFO, "message in multiple " - "I frames (last message)\n"); + "I frames (last message) (dl=%p)\n", dl); rc = send_dl_l3(PRIM_DL_DATA, PRIM_OP_INDICATION, lctx, dl->rcv_buffer); dl->rcv_buffer = NULL; } else LOGP(DLLAPD, LOGL_INFO, "message in multiple " - "I frames (next message)\n"); + "I frames (next message) (dl=%p)\n", dl); msgb_free(msg); } @@ -1599,11 +1634,13 @@ /* 5.5.2.1 */ /* check if we are not in own receiver busy */ if (!dl->own_busy) { - LOGP(DLLAPD, LOGL_INFO, "we are not busy, send RR\n"); + LOGP(DLLAPD, LOGL_INFO, + "we are not busy, send RR (dl=%p)\n", dl); /* Send RR with F=1 */ rc = lapd_send_rr(lctx, 1, 0); } else { - LOGP(DLLAPD, LOGL_INFO, "we are busy, send RNR\n"); + LOGP(DLLAPD, LOGL_INFO, + "we are busy, send RNR (dl=%p)\n", dl); /* Send RNR with F=1 */ rc = lapd_send_rnr(lctx, 1, 0); } @@ -1621,14 +1658,16 @@ if (rc) { LOGP(DLLAPD, LOGL_INFO, "we are not busy and " - "have no pending data, send RR\n"); + "have no pending data, send RR (dl=%p)\n", + dl); /* Send RR with F=0 */ return lapd_send_rr(lctx, 0, 0); } /* all I or one RR is sent, we are done */ return 0; } else { - LOGP(DLLAPD, LOGL_INFO, "we are busy, send RNR\n"); + LOGP(DLLAPD, LOGL_INFO, + "we are busy, send RNR (dl=%p)\n", dl); /* Send RNR with F=0 */ rc = lapd_send_rnr(lctx, 0, 0); } @@ -1656,7 +1695,8 @@ rc = lapd_rx_i(msg, lctx); break; default: - LOGP(DLLAPD, LOGL_NOTICE, "unknown LAPD format\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "unknown LAPD format (dl=%p)\n", lctx->dl); msgb_free(msg); rc = -EINVAL; } @@ -1695,9 +1735,10 @@ if (msg->len) LOGP(DLLAPD, LOGL_INFO, "perform establishment with content " - "(SABM)\n"); + "(SABM) (dl=%p)\n", dl); else - LOGP(DLLAPD, LOGL_INFO, "perform normal establishm. (SABM)\n"); + LOGP(DLLAPD, LOGL_INFO, + "perform normal establishm. (SABM), (dl=%p)\n", dl); /* Flush send-queue */ /* Clear send-buffer */ @@ -1753,13 +1794,14 @@ if (msgb_l3len(msg) == 0) { LOGP(DLLAPD, LOGL_ERROR, - "writing an empty message is not possible.\n"); + "writing an empty message is not possible. (dl=%p)\n", dl); msgb_free(msg); return -1; } LOGP(DLLAPD, LOGL_INFO, - "writing message to send-queue: l3len: %d\n", msgb_l3len(msg)); + "writing message to send-queue: l3len: %d (dl=%p)\n", + msgb_l3len(msg), dl); /* Write data into the send queue */ msgb_enqueue(&dl->send_queue, msg); @@ -1782,17 +1824,19 @@ struct lapd_msg_ctx nctx; - LOGP(DLLAPD, LOGL_INFO, "%s() called from line %d\n", __func__, line); + LOGP(DLLAPD, LOGL_INFO, + "%s() called from line %d (dl=%p)\n", __func__, line, dl); next_frame: if (dl->peer_busy) { - LOGP(DLLAPD, LOGL_INFO, "peer busy, not sending\n"); + LOGP(DLLAPD, LOGL_INFO, "peer busy, not sending (dl=%p)\n", dl); return rc; } if (dl->state == LAPD_STATE_TIMER_RECOV) { - LOGP(DLLAPD, LOGL_INFO, "timer recovery, not sending\n"); + LOGP(DLLAPD, LOGL_INFO, + "timer recovery, not sending (dl=%p)\n", dl); return rc; } @@ -1804,8 +1848,8 @@ * 5.5.7. */ if (dl->v_send == add_mod(dl->v_ack, k, dl->v_range)) { LOGP(DLLAPD, LOGL_INFO, "k frames outstanding, not sending " - "more (k=%u V(S)=%u V(A)=%u)\n", k, dl->v_send, - dl->v_ack); + "more (k=%u V(S)=%u V(A)=%u) (dl=%p)\n", k, dl->v_send, + dl->v_ack, dl); return rc; } @@ -1822,7 +1866,7 @@ if (!dl->send_buffer) return rc; LOGP(DLLAPD, LOGL_INFO, "get message from " - "send-queue\n"); + "send-queue (dl=%p)\n", dl); } /* How much is left in the send-buffer? */ @@ -1832,9 +1876,9 @@ if (length > lctx->n201) length = lctx->n201; LOGP(DLLAPD, LOGL_INFO, "msg-len %d sent %d left %d N201 %d " - "length %d first byte %02x\n", + "length %d first byte %02x (dl=%p)\n", msgb_l3len(dl->send_buffer), dl->send_out, left, - lctx->n201, length, dl->send_buffer->l3h[0]); + lctx->n201, length, dl->send_buffer->l3h[0], dl); /* If message in send-buffer is completely sent */ if (left == 0) { msgb_free(dl->send_buffer); @@ -1842,8 +1886,8 @@ goto next_message; } - LOGP(DLLAPD, LOGL_INFO, "send I frame %sV(S)=%d\n", - (left > length) ? "segment " : "", dl->v_send); + LOGP(DLLAPD, LOGL_INFO, "send I frame %sV(S)=%d (dl=%p)\n", + (left > length) ? "segment " : "", dl->v_send, dl); /* Create I frame (segment) and transmit-buffer content */ msg = lapd_msgb_alloc(length, "LAPD I"); @@ -1876,7 +1920,7 @@ dl->send_out += length; } else { LOGP(DLLAPD, LOGL_INFO, "resend I frame from tx buffer " - "V(S)=%d\n", dl->v_send); + "V(S)=%d (dl=%p)\n", dl->v_send, dl); /* Create I frame (segment) from tx_hist */ length = dl->tx_hist[h].msg->len; @@ -1924,16 +1968,16 @@ struct lapd_datalink *dl = lctx->dl; struct msgb *msg = dp->oph.msg; - LOGP(DLLAPD, LOGL_INFO, "perform suspension\n"); + LOGP(DLLAPD, LOGL_INFO, "perform suspension (dl=%p)\n", dl); /* put back the send-buffer to the send-queue (first position) */ if (dl->send_buffer) { LOGP(DLLAPD, LOGL_INFO, "put frame in sendbuffer back to " - "queue\n"); + "queue (dl=%p)\n", dl); llist_add(&dl->send_buffer->list, &dl->send_queue); dl->send_buffer = NULL; } else - LOGP(DLLAPD, LOGL_INFO, "no frame in sendbuffer\n"); + LOGP(DLLAPD, LOGL_INFO, "no frame in sendbuffer (dl=%p)\n", dl); /* Clear transmit buffer, but keep send buffer */ lapd_dl_flush_tx(dl); @@ -1953,8 +1997,9 @@ struct msgb *msg = dp->oph.msg; struct lapd_msg_ctx nctx; - LOGP(DLLAPD, LOGL_INFO, "perform re-establishment (SABM) length=%d\n", - msg->len); + LOGP(DLLAPD, LOGL_INFO, + "perform re-establishment (SABM) length=%d (dl=%p)\n", + msg->len, dl); /* be sure that history is empty */ lapd_dl_flush_hist(dl); @@ -2024,7 +2069,7 @@ /* local release */ if (dp->u.rel_req.mode) { - LOGP(DLLAPD, LOGL_INFO, "perform local release\n"); + LOGP(DLLAPD, LOGL_INFO, "perform local release (dl=%p)\n", dl); msgb_free(msg); /* stop Timer T200 */ lapd_stop_t200(dl); @@ -2044,7 +2089,7 @@ /* flush tx_hist */ lapd_dl_flush_hist(dl); - LOGP(DLLAPD, LOGL_INFO, "perform normal release (DISC)\n"); + LOGP(DLLAPD, LOGL_INFO, "perform normal release (DISC) (dl=%p)\n", dl); /* Push LAPD header on msgb */ /* assemble message */ @@ -2169,21 +2214,22 @@ } } if (!supported) { - LOGP(DLLAPD, LOGL_NOTICE, "Message %u/%u unsupported.\n", - dp->oph.primitive, dp->oph.operation); + LOGP(DLLAPD, LOGL_NOTICE, + "Message %u/%u unsupported. (dl=%p)\n", dp->oph.primitive, + dp->oph.operation, dl); msgb_free(msg); return 0; } if (i == L2DOWNSLLEN) { LOGP(DLLAPD, LOGL_NOTICE, "Message %u/%u unhandled at this " - "state %s.\n", dp->oph.primitive, dp->oph.operation, - lapd_state_names[dl->state]); + "state %s. (dl=%p)\n", dp->oph.primitive, + dp->oph.operation, lapd_state_names[dl->state], dl); msgb_free(msg); return 0; } - LOGP(DLLAPD, LOGL_INFO, "Message %s received in state %s\n", - l2downstatelist[i].name, lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "Message %s received in state %s (dl=%p)\n", + l2downstatelist[i].name, lapd_state_names[dl->state], dl); rc = l2downstatelist[i].rout(dp, lctx); -- To view, visit https://gerrit.osmocom.org/1724 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:03:11 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 2 Feb 2017 17:03:11 +0000 Subject: [PATCH] libosmocore[master]: select: add functionality to check socket state Message-ID: Review at https://gerrit.osmocom.org/1725 select: add functionality to check socket state osmo_fd_register() is used to register socket file descriptors, after registering a socket, there is no way to test if the socket is still registered or actually registered at all. This commit adds a new function osmo_fd_register_check() that can be used to check in advance, if the socket fd is registered, before performing further operations. Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 --- M include/osmocom/core/select.h M src/select.c 2 files changed, 26 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/1725/1 diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index 2753637..a912ea7 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -1,6 +1,7 @@ #pragma once #include +#include /*! \defgroup select Select loop abstraction * @{ @@ -35,6 +36,7 @@ unsigned int priv_nr; }; +bool osmo_fd_register_check(struct osmo_fd *fd); int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); diff --git a/src/select.c b/src/select.c index da27368..d7c89f3 100644 --- a/src/select.c +++ b/src/select.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,23 @@ static int maxfd = 0; static LLIST_HEAD(osmo_fds); static int unregistered_count; + + +/*! \brief Check if a file descriptor is already registered + * \param[in] fd osmocom file descriptor to be checked + * \returns true if registered; otherwise false + */ +bool osmo_fd_register_check(struct osmo_fd *fd) +{ + struct osmo_fd *entry; + llist_for_each_entry(entry, &osmo_fds, list) { + if (entry == fd) { + return true; + } + } + + return false; +} /*! \brief Register a new file descriptor with select loop abstraction * \param[in] fd osmocom file descriptor to be registered @@ -76,12 +94,9 @@ maxfd = fd->fd; #ifdef BSC_FD_CHECK - struct osmo_fd *entry; - llist_for_each_entry(entry, &osmo_fds, list) { - if (entry == fd) { - fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); - return 0; - } + if (osmo_fd_register_check(fd)) { + fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); + return 0; } #endif @@ -95,6 +110,9 @@ */ void osmo_fd_unregister(struct osmo_fd *fd) { + /* Note: when fd is inside the osmo_fds list (not registered before) + * this function will crash! If in doubt, check file descriptor with + * osmo_fd_register_check() */ unregistered_count++; llist_del(&fd->list); } -- To view, visit https://gerrit.osmocom.org/1725 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:03:11 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 2 Feb 2017 17:03:11 +0000 Subject: [PATCH] libosmocore[master]: lapd_core: fix program flow Message-ID: Review at https://gerrit.osmocom.org/1726 lapd_core: fix program flow when the lapd core is in state LAPD_STATE_SABM_SENT, and the retransmission counter exceeds (link down) lapd_t200_cb() will send an RELASE_INDICATION and an MDL_ERROR_INDICATION to L3. This action is done before the state is processed. This seems to be no problem with standard retransmission counts (n200), but may cause timing problems that lead to deadlock states when custom timer configurations are in use. (Ericsson RBS). This commit moves the functions calls for sending the indications mentioned above to the very end of the if branch to relax the timing again. (See lapd_t200_cb()) Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a --- M src/gsm/lapd_core.c 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/1726/1 diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 84b1828..5af82aa 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -556,11 +556,6 @@ case LAPD_STATE_SABM_SENT: /* 5.4.1.3 */ if (dl->retrans_ctr + 1 >= dl->n200_est_rel + 1) { - /* send RELEASE INDICATION to L3 */ - send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, - &dl->lctx); - /* send MDL ERROR INIDCATION to L3 */ - mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); @@ -569,6 +564,11 @@ /* NOTE: we must not change any other states or buffers * and queues, since we may reconnect after handover * failure. the buffered messages is replaced there */ + /* send RELEASE INDICATION to L3 */ + send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, + &dl->lctx); + /* send MDL ERROR INIDCATION to L3 */ + mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); break; } /* retransmit SABM command */ -- To view, visit https://gerrit.osmocom.org/1726 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:03:12 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 2 Feb 2017 17:03:12 +0000 Subject: [PATCH] libosmocore[master]: lapd_core: Fix MDL-ERROR ind after RELEASE ind Message-ID: Review at https://gerrit.osmocom.org/1727 lapd_core: Fix MDL-ERROR ind after RELEASE ind in lapd_t200_cb() The RELEASE INDICATION is transmitted before the MDL ERROR INIDCATION, this prevents the MDL ERROR INDICATION from being sent because the RELASE INDICATION close to connection eraly. This commit puts the messages into the correct order. Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 --- M src/gsm/lapd_core.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/1727/1 diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 5af82aa..5ee88a4 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -564,11 +564,11 @@ /* NOTE: we must not change any other states or buffers * and queues, since we may reconnect after handover * failure. the buffered messages is replaced there */ + /* send MDL ERROR INIDCATION to L3 */ + mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); /* send RELEASE INDICATION to L3 */ send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, &dl->lctx); - /* send MDL ERROR INIDCATION to L3 */ - mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); break; } /* retransmit SABM command */ @@ -581,10 +581,10 @@ case LAPD_STATE_DISC_SENT: /* 5.4.4.3 */ if (dl->retrans_ctr + 1 >= dl->n200_est_rel + 1) { - /* send RELEASE INDICATION to L3 */ - send_dl_simple(PRIM_DL_REL, PRIM_OP_CONFIRM, &dl->lctx); /* send MDL ERROR INIDCATION to L3 */ mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); + /* send RELEASE INDICATION to L3 */ + send_dl_simple(PRIM_DL_REL, PRIM_OP_CONFIRM, &dl->lctx); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); -- To view, visit https://gerrit.osmocom.org/1727 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:18:12 2017 From: gerrit-no-reply at lists.osmocom.org (ikostov) Date: Thu, 2 Feb 2017 17:18:12 +0000 Subject: [PATCH] osmo-gsm-manuals[master]: SGSN: editing OAP as per os#1874 Message-ID: Review at https://gerrit.osmocom.org/1728 SGSN: editing OAP as per os#1874 Change-Id: Idab734e8dff947496cd0ce27c9c44bc7ef5a139e --- M common/chapters/oap.adoc 1 file changed, 5 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/28/1728/1 diff --git a/common/chapters/oap.adoc b/common/chapters/oap.adoc index 15a14ca..544da81 100644 --- a/common/chapters/oap.adoc +++ b/common/chapters/oap.adoc @@ -1,5 +1,6 @@ == Osmocom Authentication Protocol (OAP) +=== General The Osmocom Authentication Protocol employs mutual authentication to register a client with a server over an IPA connection. Milenage is used as the authentication algorithm, where client and server have a shared @@ -195,14 +196,11 @@ ==== Sync Error -Direction: Server -> Client +Not used. -[options="header",cols="5%,20%,45%,10%,10%,10%"] -|=== -|IEI|IE|Type|Presence|Format|Length -| |Message Type|<>|M|V|1 -|02|Cause|GMM Cause, TS 04.08: 10.5.5.14|M|TLV|3 -|=== +==== Sync Result + +Not used. === Information Elements -- To view, visit https://gerrit.osmocom.org/1728 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idab734e8dff947496cd0ce27c9c44bc7ef5a139e Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:43:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 17:43:38 +0000 Subject: [PATCH] osmo-bts[master]: sysmobts: Add correct nominal transmit power for sysmoBTS 1020 Message-ID: Review at https://gerrit.osmocom.org/1729 sysmobts: Add correct nominal transmit power for sysmoBTS 1020 The sysmoBTS 1020 is a 2W BTS, hence its nominal transmit powre is 33dBm. We must handle this correctly based on the model-nr in the EEPROM. As a result, proper power ramping will be made during start of the unit by default. Change-Id: I91a78dadfd7d2e1bc74c8086808c55effdcdd132 --- M src/osmo-bts-sysmo/utils.c 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/29/1729/1 diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..8f54e6f 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -125,6 +125,8 @@ case 1002: /* 200mW (23 dBm) nominal power */ return 23; + case 1020: + return 33; case 2050: /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) * if the second TRX is not used. */ -- To view, visit https://gerrit.osmocom.org/1729 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I91a78dadfd7d2e1bc74c8086808c55effdcdd132 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 2 17:43:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 17:43:38 +0000 Subject: [PATCH] osmo-bts[master]: sysmobts_eeprom.h: Fix/extend model number definitions Message-ID: Review at https://gerrit.osmocom.org/1730 sysmobts_eeprom.h: Fix/extend model number definitions Fix the model number definition for the 1020 and add the one for 1002. Change-Id: Iba4cfbbda1000d7e34eca614b3a6165d2feb65e1 --- M src/osmo-bts-sysmo/misc/sysmobts_eeprom.h 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/30/1730/1 diff --git a/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h b/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h index f49db1f..0dec4f6 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h @@ -21,7 +21,8 @@ } __attribute__((packed)); enum sysmobts_model_number { - MODEL_SYSMOBTS_1020 = 1002, + MODEL_SYSMOBTS_1002 = 1002, + MODEL_SYSMOBTS_1020 = 1020, MODEL_SYSMOBTS_2050 = 2050, }; -- To view, visit https://gerrit.osmocom.org/1730 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iba4cfbbda1000d7e34eca614b3a6165d2feb65e1 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:31:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 19:31:08 +0000 Subject: [PATCH] libosmocore[master]: GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 Message-ID: Review at https://gerrit.osmocom.org/1731 GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 GSUP transmits AUTS for UMTS authentication procedures, and OAP uses the same procedures to authenticate. osmo-gen-vec is a utility program that passes AUTS to our osmo_auth_gen_vec_auts() API. According to 3GPP 33.102 6.3.3, AUTS = SQN^AK || MAC-S, which are 6 || 8 == 14 bytes. This is confirmed by 24.008 9.2.3a where the TLV has 16 bytes, TL = 2 and AUTS being the V = 14. It is not harmful for milenage_gen_vec_auts() to pass two more AUTS bytes. But writing 16 bytes to a GSUP struct is a potential problem when passing in a 14 byte long AUTS buffer to the GSUP API, which then reads past the AUTS buffer. The API implies the length, so far to be 16, so passing in a 14 byte buffer to GSUP would require copying to a larger buffer first. Fix this by using a length of 14 for AUTS everywhere instead. This constitues an ABI breakage, we may handle it as a "fix before an official release", otherwise we need a version bump. The OAP protocol document has also been updated, needs an update in the osmo-gsm-manuals as well. Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 --- M TODO-RELEASE M doc/osmocom-authn-protocol.txt M include/osmocom/gsm/oap.h M src/gsm/gsup.c M tests/oap/oap_test.c M utils/osmo-auc-gen.c 6 files changed, 9 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/1731/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index 5c6bfa3..a23fcea 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -8,3 +8,6 @@ # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line libosmocore new function osmo_sock_get_name() +libosmogsm/gsup ABI change fix AUTS length to 14, not 16 (length is implicit) +libosmogsm/oap ABI change fix AUTS length to 14, not 16 (length is implicit) +osmo-auc-gen UI change fix AUTS length to 14, not 16 (length is implicit) diff --git a/doc/osmocom-authn-protocol.txt b/doc/osmocom-authn-protocol.txt index 6d057be..ad4fba0 100644 --- a/doc/osmocom-authn-protocol.txt +++ b/doc/osmocom-authn-protocol.txt @@ -181,7 +181,7 @@ IEI Info Element Type Pres. Format Length Message type 4.2.1 M V 1 - 20 AUTS octet string (16) M TLV 18 + 20 AUTS octet string (14) M TLV 16 3.2.8. Sync Error diff --git a/include/osmocom/gsm/oap.h b/include/osmocom/gsm/oap.h index d973013..ff561bf 100644 --- a/include/osmocom/gsm/oap.h +++ b/include/osmocom/gsm/oap.h @@ -64,7 +64,7 @@ int xres_present; uint8_t xres[8]; int auts_present; - uint8_t auts[16]; + uint8_t auts[14]; }; int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data, diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index 22f57ab..b1b97ca 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -497,7 +497,7 @@ } if (gsup_msg->auts) - msgb_tlv_put(msg, OSMO_GSUP_AUTS_IE, 16, gsup_msg->auts); + msgb_tlv_put(msg, OSMO_GSUP_AUTS_IE, 14, gsup_msg->auts); if (gsup_msg->rand) msgb_tlv_put(msg, OSMO_GSUP_RAND_IE, 16, gsup_msg->rand); diff --git a/tests/oap/oap_test.c b/tests/oap/oap_test.c index ccf4906..0c4c16e 100644 --- a/tests/oap/oap_test.c +++ b/tests/oap/oap_test.c @@ -155,8 +155,8 @@ printf("- Sync Request\n"); CLEAR(); oap_msg.message_type = OAP_MSGT_SYNC_REQUEST; - osmo_hexparse("102030405060708090a0b0c0d0e0f001", - oap_msg.auts, 16); + osmo_hexparse("102030405060708090a0b0c0d0e0", + oap_msg.auts, 14); oap_msg.auts_present = 1; CHECK(); diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 3b3e557..4c3e891 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -87,7 +87,7 @@ { struct osmo_auth_vector _vec; struct osmo_auth_vector *vec = &_vec; - uint8_t _rand[16], _auts[16]; + uint8_t _rand[16], _auts[14]; int rc, option_index; int rand_is_set = 0; int auts_is_set = 0; -- To view, visit https://gerrit.osmocom.org/1731 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:31:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 19:31:08 +0000 Subject: [PATCH] libosmocore[master]: gsm48: add UMTS AKA res+sync IEIs, msg type and cause val Message-ID: Review at https://gerrit.osmocom.org/1732 gsm48: add UMTS AKA res+sync IEIs, msg type and cause val According to 3GPP TS 24.008 9.2.3a, 9.2.3, 10.5.3.6 Change-Id: I745061ce8eb88aa23080dadcdbfe2d703c362a30 --- M include/osmocom/gsm/protocol/gsm_04_08.h 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/32/1732/1 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 767aa3d..bbc2774 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -1116,6 +1116,7 @@ #define GSM48_MT_MM_AUTH_REJ 0x11 #define GSM48_MT_MM_AUTH_REQ 0x12 #define GSM48_MT_MM_AUTH_RESP 0x14 +#define GSM48_MT_MM_AUTH_FAIL 0x1c #define GSM48_MT_MM_ID_REQ 0x18 #define GSM48_MT_MM_ID_RESP 0x19 #define GSM48_MT_MM_TMSI_REALL_CMD 0x1a @@ -1302,6 +1303,8 @@ /* Additional MM elements */ #define GSM48_IE_LOCATION_AREA 0x13 #define GSM48_IE_AUTN 0x20 +#define GSM48_IE_AUTH_RES_EXT 0x21 +#define GSM48_IE_AUTS 0x22 #define GSM48_IE_PRIORITY_LEV 0x80 #define GSM48_IE_FOLLOW_ON_PROC 0xa1 #define GSM48_IE_CTS_PERMISSION 0xa2 @@ -1418,6 +1421,7 @@ GSM48_REJECT_LOC_NOT_ALLOWED = 12, GSM48_REJECT_ROAMING_NOT_ALLOWED = 13, GSM48_REJECT_NETWORK_FAILURE = 17, + GSM48_REJECT_SYNCH_FAILURE = 21, GSM48_REJECT_CONGESTION = 22, GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33, -- To view, visit https://gerrit.osmocom.org/1732 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I745061ce8eb88aa23080dadcdbfe2d703c362a30 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:34:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 19:34:22 +0000 Subject: [PATCH] libosmocore[master]: GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1731 to look at the new patch set (#2). GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 GSUP transmits AUTS for UMTS authentication procedures, and OAP uses the same procedures to authenticate. osmo-gen-vec is a utility program that passes AUTS to our osmo_auth_gen_vec_auts() API. According to 3GPP 33.102 6.3.3, AUTS = SQN^AK || MAC-S, which are 6 || 8 == 14 bytes. This is confirmed by 24.008 9.2.3a where the TLV has 16 bytes, TL = 2 and AUTS being the V = 14. It is not harmful for milenage_gen_vec_auts() to pass two more AUTS bytes. But writing 16 bytes to a GSUP struct is a potential problem when passing in a 14 byte long AUTS buffer to the GSUP API, which then reads past the AUTS buffer. The API implies the length, so far to be 16, so passing in a 14 byte buffer to GSUP would require copying to a larger buffer first. Fix this by using a length of 14 for AUTS everywhere instead. This constitues an ABI breakage, we may handle it as a "fix before an official release", otherwise we need a version bump. The OAP protocol document has also been updated, needs an update in the osmo-gsm-manuals as well. Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 --- M TODO-RELEASE M doc/osmocom-authn-protocol.txt M include/osmocom/gsm/oap.h M src/gsm/gsup.c M tests/oap/oap_test.c M tests/oap/oap_test.ok M utils/osmo-auc-gen.c 7 files changed, 10 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/1731/2 diff --git a/TODO-RELEASE b/TODO-RELEASE index 5c6bfa3..a23fcea 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -8,3 +8,6 @@ # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line libosmocore new function osmo_sock_get_name() +libosmogsm/gsup ABI change fix AUTS length to 14, not 16 (length is implicit) +libosmogsm/oap ABI change fix AUTS length to 14, not 16 (length is implicit) +osmo-auc-gen UI change fix AUTS length to 14, not 16 (length is implicit) diff --git a/doc/osmocom-authn-protocol.txt b/doc/osmocom-authn-protocol.txt index 6d057be..ad4fba0 100644 --- a/doc/osmocom-authn-protocol.txt +++ b/doc/osmocom-authn-protocol.txt @@ -181,7 +181,7 @@ IEI Info Element Type Pres. Format Length Message type 4.2.1 M V 1 - 20 AUTS octet string (16) M TLV 18 + 20 AUTS octet string (14) M TLV 16 3.2.8. Sync Error diff --git a/include/osmocom/gsm/oap.h b/include/osmocom/gsm/oap.h index d973013..ff561bf 100644 --- a/include/osmocom/gsm/oap.h +++ b/include/osmocom/gsm/oap.h @@ -64,7 +64,7 @@ int xres_present; uint8_t xres[8]; int auts_present; - uint8_t auts[16]; + uint8_t auts[14]; }; int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data, diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index 22f57ab..b1b97ca 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -497,7 +497,7 @@ } if (gsup_msg->auts) - msgb_tlv_put(msg, OSMO_GSUP_AUTS_IE, 16, gsup_msg->auts); + msgb_tlv_put(msg, OSMO_GSUP_AUTS_IE, 14, gsup_msg->auts); if (gsup_msg->rand) msgb_tlv_put(msg, OSMO_GSUP_RAND_IE, 16, gsup_msg->rand); diff --git a/tests/oap/oap_test.c b/tests/oap/oap_test.c index ccf4906..0c4c16e 100644 --- a/tests/oap/oap_test.c +++ b/tests/oap/oap_test.c @@ -155,8 +155,8 @@ printf("- Sync Request\n"); CLEAR(); oap_msg.message_type = OAP_MSGT_SYNC_REQUEST; - osmo_hexparse("102030405060708090a0b0c0d0e0f001", - oap_msg.auts, 16); + osmo_hexparse("102030405060708090a0b0c0d0e0", + oap_msg.auts, 14); oap_msg.auts_present = 1; CHECK(); diff --git a/tests/oap/oap_test.ok b/tests/oap/oap_test.ok index 9260d44..4c09929 100644 --- a/tests/oap/oap_test.ok +++ b/tests/oap/oap_test.ok @@ -37,6 +37,6 @@ ok - Sync Request encoded message: -0c 25 10 10 20 30 40 50 60 70 80 90 a0 b0 c0 d0 e0 f0 01 +0c 25 0e 10 20 30 40 50 60 70 80 90 a0 b0 c0 d0 e0 ok Done. diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 3b3e557..4c3e891 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -87,7 +87,7 @@ { struct osmo_auth_vector _vec; struct osmo_auth_vector *vec = &_vec; - uint8_t _rand[16], _auts[16]; + uint8_t _rand[16], _auts[14]; int rc, option_index; int rand_is_set = 0; int auts_is_set = 0; -- To view, visit https://gerrit.osmocom.org/1731 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:12 +0000 Subject: libosmocore[master]: GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1731 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:24 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:24 +0000 Subject: libosmocore[master]: gsm48: add UMTS AKA res+sync IEIs, msg type and cause val In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1732 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I745061ce8eb88aa23080dadcdbfe2d703c362a30 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:26 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:26 +0000 Subject: [MERGED] libosmocore[master]: gsm48: add UMTS AKA res+sync IEIs, msg type and cause val In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gsm48: add UMTS AKA res+sync IEIs, msg type and cause val ...................................................................... gsm48: add UMTS AKA res+sync IEIs, msg type and cause val According to 3GPP TS 24.008 9.2.3a, 9.2.3, 10.5.3.6 Change-Id: I745061ce8eb88aa23080dadcdbfe2d703c362a30 --- M include/osmocom/gsm/protocol/gsm_04_08.h 1 file changed, 4 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 767aa3d..bbc2774 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -1116,6 +1116,7 @@ #define GSM48_MT_MM_AUTH_REJ 0x11 #define GSM48_MT_MM_AUTH_REQ 0x12 #define GSM48_MT_MM_AUTH_RESP 0x14 +#define GSM48_MT_MM_AUTH_FAIL 0x1c #define GSM48_MT_MM_ID_REQ 0x18 #define GSM48_MT_MM_ID_RESP 0x19 #define GSM48_MT_MM_TMSI_REALL_CMD 0x1a @@ -1302,6 +1303,8 @@ /* Additional MM elements */ #define GSM48_IE_LOCATION_AREA 0x13 #define GSM48_IE_AUTN 0x20 +#define GSM48_IE_AUTH_RES_EXT 0x21 +#define GSM48_IE_AUTS 0x22 #define GSM48_IE_PRIORITY_LEV 0x80 #define GSM48_IE_FOLLOW_ON_PROC 0xa1 #define GSM48_IE_CTS_PERMISSION 0xa2 @@ -1418,6 +1421,7 @@ GSM48_REJECT_LOC_NOT_ALLOWED = 12, GSM48_REJECT_ROAMING_NOT_ALLOWED = 13, GSM48_REJECT_NETWORK_FAILURE = 17, + GSM48_REJECT_SYNCH_FAILURE = 21, GSM48_REJECT_CONGESTION = 22, GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33, -- To view, visit https://gerrit.osmocom.org/1732 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I745061ce8eb88aa23080dadcdbfe2d703c362a30 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:32 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:32 +0000 Subject: [MERGED] libosmocore[master]: GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 ...................................................................... GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16 GSUP transmits AUTS for UMTS authentication procedures, and OAP uses the same procedures to authenticate. osmo-gen-vec is a utility program that passes AUTS to our osmo_auth_gen_vec_auts() API. According to 3GPP 33.102 6.3.3, AUTS = SQN^AK || MAC-S, which are 6 || 8 == 14 bytes. This is confirmed by 24.008 9.2.3a where the TLV has 16 bytes, TL = 2 and AUTS being the V = 14. It is not harmful for milenage_gen_vec_auts() to pass two more AUTS bytes. But writing 16 bytes to a GSUP struct is a potential problem when passing in a 14 byte long AUTS buffer to the GSUP API, which then reads past the AUTS buffer. The API implies the length, so far to be 16, so passing in a 14 byte buffer to GSUP would require copying to a larger buffer first. Fix this by using a length of 14 for AUTS everywhere instead. This constitues an ABI breakage, we may handle it as a "fix before an official release", otherwise we need a version bump. The OAP protocol document has also been updated, needs an update in the osmo-gsm-manuals as well. Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 --- M TODO-RELEASE M doc/osmocom-authn-protocol.txt M include/osmocom/gsm/oap.h M src/gsm/gsup.c M tests/oap/oap_test.c M tests/oap/oap_test.ok M utils/osmo-auc-gen.c 7 files changed, 10 insertions(+), 7 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index 5c6bfa3..a23fcea 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -8,3 +8,6 @@ # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line libosmocore new function osmo_sock_get_name() +libosmogsm/gsup ABI change fix AUTS length to 14, not 16 (length is implicit) +libosmogsm/oap ABI change fix AUTS length to 14, not 16 (length is implicit) +osmo-auc-gen UI change fix AUTS length to 14, not 16 (length is implicit) diff --git a/doc/osmocom-authn-protocol.txt b/doc/osmocom-authn-protocol.txt index 6d057be..ad4fba0 100644 --- a/doc/osmocom-authn-protocol.txt +++ b/doc/osmocom-authn-protocol.txt @@ -181,7 +181,7 @@ IEI Info Element Type Pres. Format Length Message type 4.2.1 M V 1 - 20 AUTS octet string (16) M TLV 18 + 20 AUTS octet string (14) M TLV 16 3.2.8. Sync Error diff --git a/include/osmocom/gsm/oap.h b/include/osmocom/gsm/oap.h index d973013..ff561bf 100644 --- a/include/osmocom/gsm/oap.h +++ b/include/osmocom/gsm/oap.h @@ -64,7 +64,7 @@ int xres_present; uint8_t xres[8]; int auts_present; - uint8_t auts[16]; + uint8_t auts[14]; }; int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data, diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index 22f57ab..b1b97ca 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -497,7 +497,7 @@ } if (gsup_msg->auts) - msgb_tlv_put(msg, OSMO_GSUP_AUTS_IE, 16, gsup_msg->auts); + msgb_tlv_put(msg, OSMO_GSUP_AUTS_IE, 14, gsup_msg->auts); if (gsup_msg->rand) msgb_tlv_put(msg, OSMO_GSUP_RAND_IE, 16, gsup_msg->rand); diff --git a/tests/oap/oap_test.c b/tests/oap/oap_test.c index ccf4906..0c4c16e 100644 --- a/tests/oap/oap_test.c +++ b/tests/oap/oap_test.c @@ -155,8 +155,8 @@ printf("- Sync Request\n"); CLEAR(); oap_msg.message_type = OAP_MSGT_SYNC_REQUEST; - osmo_hexparse("102030405060708090a0b0c0d0e0f001", - oap_msg.auts, 16); + osmo_hexparse("102030405060708090a0b0c0d0e0", + oap_msg.auts, 14); oap_msg.auts_present = 1; CHECK(); diff --git a/tests/oap/oap_test.ok b/tests/oap/oap_test.ok index 9260d44..4c09929 100644 --- a/tests/oap/oap_test.ok +++ b/tests/oap/oap_test.ok @@ -37,6 +37,6 @@ ok - Sync Request encoded message: -0c 25 10 10 20 30 40 50 60 70 80 90 a0 b0 c0 d0 e0 f0 01 +0c 25 0e 10 20 30 40 50 60 70 80 90 a0 b0 c0 d0 e0 ok Done. diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 3b3e557..4c3e891 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -87,7 +87,7 @@ { struct osmo_auth_vector _vec; struct osmo_auth_vector *vec = &_vec; - uint8_t _rand[16], _auts[16]; + uint8_t _rand[16], _auts[14]; int rc, option_index; int rand_is_set = 0; int auts_is_set = 0; -- To view, visit https://gerrit.osmocom.org/1731 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:43 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:43 +0000 Subject: osmo-bts[master]: sysmobts_eeprom.h: Fix/extend model number definitions In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1730 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iba4cfbbda1000d7e34eca614b3a6165d2feb65e1 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:45 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:45 +0000 Subject: osmo-bts[master]: sysmobts: Add correct nominal transmit power for sysmoBTS 1020 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1729 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I91a78dadfd7d2e1bc74c8086808c55effdcdd132 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:48 +0000 Subject: [MERGED] osmo-bts[master]: sysmobts: Add correct nominal transmit power for sysmoBTS 1020 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sysmobts: Add correct nominal transmit power for sysmoBTS 1020 ...................................................................... sysmobts: Add correct nominal transmit power for sysmoBTS 1020 The sysmoBTS 1020 is a 2W BTS, hence its nominal transmit powre is 33dBm. We must handle this correctly based on the model-nr in the EEPROM. As a result, proper power ramping will be made during start of the unit by default. Change-Id: I91a78dadfd7d2e1bc74c8086808c55effdcdd132 --- M src/osmo-bts-sysmo/utils.c 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..8f54e6f 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -125,6 +125,8 @@ case 1002: /* 200mW (23 dBm) nominal power */ return 23; + case 1020: + return 33; case 2050: /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) * if the second TRX is not used. */ -- To view, visit https://gerrit.osmocom.org/1729 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I91a78dadfd7d2e1bc74c8086808c55effdcdd132 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:50:54 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:50:54 +0000 Subject: [MERGED] osmo-bts[master]: sysmobts_eeprom.h: Fix/extend model number definitions In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sysmobts_eeprom.h: Fix/extend model number definitions ...................................................................... sysmobts_eeprom.h: Fix/extend model number definitions Fix the model number definition for the 1020 and add the one for 1002. Change-Id: Iba4cfbbda1000d7e34eca614b3a6165d2feb65e1 --- M src/osmo-bts-sysmo/misc/sysmobts_eeprom.h 1 file changed, 2 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h b/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h index f49db1f..0dec4f6 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h @@ -21,7 +21,8 @@ } __attribute__((packed)); enum sysmobts_model_number { - MODEL_SYSMOBTS_1020 = 1002, + MODEL_SYSMOBTS_1002 = 1002, + MODEL_SYSMOBTS_1020 = 1020, MODEL_SYSMOBTS_2050 = 2050, }; -- To view, visit https://gerrit.osmocom.org/1730 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iba4cfbbda1000d7e34eca614b3a6165d2feb65e1 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:57:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:57:36 +0000 Subject: osmo-gsm-manuals[master]: SGSN: editing OAP as per os#1874 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1728 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Idab734e8dff947496cd0ce27c9c44bc7ef5a139e Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 19:57:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 19:57:38 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: SGSN: editing OAP as per os#1874 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: SGSN: editing OAP as per os#1874 ...................................................................... SGSN: editing OAP as per os#1874 Change-Id: Idab734e8dff947496cd0ce27c9c44bc7ef5a139e --- M common/chapters/oap.adoc 1 file changed, 5 insertions(+), 7 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/common/chapters/oap.adoc b/common/chapters/oap.adoc index 15a14ca..544da81 100644 --- a/common/chapters/oap.adoc +++ b/common/chapters/oap.adoc @@ -1,5 +1,6 @@ == Osmocom Authentication Protocol (OAP) +=== General The Osmocom Authentication Protocol employs mutual authentication to register a client with a server over an IPA connection. Milenage is used as the authentication algorithm, where client and server have a shared @@ -195,14 +196,11 @@ ==== Sync Error -Direction: Server -> Client +Not used. -[options="header",cols="5%,20%,45%,10%,10%,10%"] -|=== -|IEI|IE|Type|Presence|Format|Length -| |Message Type|<>|M|V|1 -|02|Cause|GMM Cause, TS 04.08: 10.5.5.14|M|TLV|3 -|=== +==== Sync Result + +Not used. === Information Elements -- To view, visit https://gerrit.osmocom.org/1728 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idab734e8dff947496cd0ce27c9c44bc7ef5a139e Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:00:08 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:00:08 +0000 Subject: libosmocore[master]: lapd_core: Improve debug output In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 in general it would be more useful to have some kind of human-readable ID other than the pointer. Something like "This is LAPD instance for SAPI3 on bts0/trx1/ts5/lchan3" How to do this? Include a string member in the lapd_datalink, and have the user set that string when creating the datalink. This is e.g. how we do it in osmo_fsm. But let's merge this patch for now, and keep the above in mind as a future improvement. Please open a ticket to that regard. -- To view, visit https://gerrit.osmocom.org/1724 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:03:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:03:34 +0000 Subject: libosmocore[master]: select: add functionality to check socket state In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1725/1/src/select.c File src/select.c: Line 54: bool osmo_fd_register_check(struct osmo_fd *fd) please rename to osmo_fd_is_registered() which is more obvious. -- To view, visit https://gerrit.osmocom.org/1725 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:03:52 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:03:52 +0000 Subject: libosmocore[master]: lapd_core: fix program flow In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1726 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:04:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:04:02 +0000 Subject: libosmocore[master]: lapd_core: Fix MDL-ERROR ind after RELEASE ind In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1727 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:04:32 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:04:32 +0000 Subject: osmo-iuh[master]: new_rab_par_voice(): add bitrate params, call with (6700, 12... In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1643 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:04:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:04:34 +0000 Subject: [MERGED] osmo-iuh[master]: new_rab_par_voice(): add bitrate params, call with (6700, 12... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: new_rab_par_voice(): add bitrate params, call with (6700, 12200) ...................................................................... new_rab_par_voice(): add bitrate params, call with (6700, 12200) The guaranteedBitrate lowers from 12200 to 6700, which is mimicking the values found in a trace from a production 3G environment. So far we have no reason to choose these values other than knowing that other operators seem to do this. This came up while trying to fix voice RAB for the nano3G, but this patch had no effect on that. Now that it's here, we might as well keep it. Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f --- M src/ranap_msg_factory.c M src/tests/test-ranap.ok 2 files changed, 9 insertions(+), 8 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 4634a07..64d87f9 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -559,7 +559,8 @@ } /* See Chapter 5 of TS 26.102 */ -static RANAP_RAB_Parameters_t *new_rab_par_voice(void) +static RANAP_RAB_Parameters_t *new_rab_par_voice(long bitrate_guaranteed, + long bitrate_max) { RANAP_RAB_Parameters_t *rab = CALLOC(1, sizeof(*rab)); RANAP_SDU_ParameterItem_t *sdui; @@ -567,9 +568,9 @@ rab->trafficClass = RANAP_TrafficClass_conversational; rab->rAB_AsymmetryIndicator = RANAP_RAB_AsymmetryIndicator_symmetric_bidirectional; - ASN_SEQUENCE_ADD(&rab->maxBitrate.list, new_long(12200)); + ASN_SEQUENCE_ADD(&rab->maxBitrate.list, new_long(bitrate_max)); rab->guaranteedBitRate = CALLOC(1, sizeof(*rab->guaranteedBitRate)); - ASN_SEQUENCE_ADD(rab->guaranteedBitRate, new_long(12200)); + ASN_SEQUENCE_ADD(rab->guaranteedBitRate, new_long(bitrate_guaranteed)); rab->deliveryOrder = RANAP_DeliveryOrder_delivery_order_requested; rab->maxSDU_Size = 244; @@ -738,7 +739,7 @@ memset(&first, 0, sizeof(first)); assign_new_ra_id(&first.rAB_ID, rab_id); first.nAS_SynchronisationIndicator = new_rab_nas_sync_ind(60); - first.rAB_Parameters = new_rab_par_voice(); + first.rAB_Parameters = new_rab_par_voice(6700, 12200); first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_support_mode_for_predefined_SDU_sizes, 1); /* 2? */ first.transportLayerInformation = new_transp_info_rtp(rtp_ip, rtp_port, use_x213_nsap); diff --git a/src/tests/test-ranap.ok b/src/tests/test-ranap.ok index bd44d33..2a8de8f 100644 --- a/src/tests/test-ranap.ok +++ b/src/tests/test-ranap.ok @@ -88,7 +88,7 @@ 53 - 78 02 CD 80 10 2F A7 20 2F A8 00 00 F4 4C 08 0A + 78 02 CD 80 10 2F A7 20 1A 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 @@ -101,15 +101,15 @@ 54 - 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 2F - A8 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 + 00 00 01 00 35 00 48 78 02 CD 80 10 2F A7 20 1A + 2C 00 00 F4 4C 08 0A 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3C 40 00 00 00 50 3D 02 00 02 27 C0 35 00 01 0A 0B 0C 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 -00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 2f a8 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 +00 00 00 59 00 00 01 00 36 40 52 00 00 01 00 35 00 48 78 02 cd 80 10 2f a7 20 1a 2c 00 00 f4 4c 08 0a 02 80 00 51 40 00 27 20 28 14 00 67 40 00 00 22 28 14 00 3c 40 00 00 00 50 3d 02 00 02 27 c0 35 00 01 0a 0b 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 40 09 26 00 00 40 01 00 ==> RAB ASSIGNMENT COMMAND (DATA) -- To view, visit https://gerrit.osmocom.org/1643 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia7eecca43d62a6a020466e9b8dc8b566ca988f9f Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:04:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:04:55 +0000 Subject: openbsc[master]: compiler warning: bsc_vty: remove two unused vars In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1723 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 2 20:04:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 2 Feb 2017 20:04:57 +0000 Subject: [MERGED] openbsc[master]: compiler warning: bsc_vty: remove two unused vars In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: compiler warning: bsc_vty: remove two unused vars ...................................................................... compiler warning: bsc_vty: remove two unused vars Added in recent commit 42def7205ba91df4bbb7e3240be0df8c26c2d63e "Implement VTY configuration to control Early Classmark Sending" Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a --- M openbsc/src/libbsc/bsc_vty.c 1 file changed, 0 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index b28d4de..7d3b4af 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -2686,7 +2686,6 @@ "Early Classmark Sending is forbidden\n") { struct gsm_bts *bts = vty->index; - int rc, type; if (!strcmp(argv[0], "allowed")) bts->early_classmark_allowed = true; -- To view, visit https://gerrit.osmocom.org/1723 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 23:37:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 23:37:23 +0000 Subject: [MERGED] openbsc[master]: gsm0408_rcv_cc: guard against NULL subscriber In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: gsm0408_rcv_cc: guard against NULL subscriber ...................................................................... gsm0408_rcv_cc: guard against NULL subscriber Check conn->subscr against NULL. gsm0408_rcv_cc() dereferences many conn members without checking presence: the bts and lchan members may be expected to be NULL in the ongoing MSC split and 3G developments. But the conn->subscr is initially NULL, so an MS sending a CC message before something like a LU or CM Service Request will result in a segfault. Prevent that. Note: the upcoming VLR will be more restrictive on what messages are processed, this is a "backport" to the situation on current master. Change-Id: If067db7cc0dd3210d9eb1da15be6b637795a3ecf --- M openbsc/src/libmsc/gsm_04_08.c 1 file changed, 5 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1e25754..8380710 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -3605,6 +3605,11 @@ return -EINVAL; } + if (!conn->subscr) { + LOGP(DCC, LOGL_ERROR, "Invalid conn, no subscriber\n"); + return -EINVAL; + } + /* Find transaction */ trans = trans_find_by_id(conn, GSM48_PDISC_CC, transaction_id); -- To view, visit https://gerrit.osmocom.org/1662 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If067db7cc0dd3210d9eb1da15be6b637795a3ecf Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 2 23:38:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 2 Feb 2017 23:38:46 +0000 Subject: [MERGED] openbsc[master]: vty tests: attempt to get at sporadic 'Broken Pipe' error In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: vty tests: attempt to get at sporadic 'Broken Pipe' error ...................................................................... vty tests: attempt to get at sporadic 'Broken Pipe' error Add verbose logging as well as three retries around the place that often fails on our build server with a 'Broken Pipe' error. Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4 --- M openbsc/tests/vty_test_runner.py 1 file changed, 15 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 89b7a19..7b25d10 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1257,7 +1257,21 @@ def ipa_handle_resp(x, tk, verbose = False): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: - x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) + retries = 3 + while True: + print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) + try: + x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) + print "\tdone sending IPA identity(%s) at %s" % (tk, + time.strftime("%T")) + break + except: + print "\tfailed sending IPA identity at", time.strftime("%T") + if retries < 1: + print "\tgiving up" + raise + print "\tretrying (%d attempts left)" % retries + retries -= 1 else: if (verbose): print "\tBSC <- NAT: ", s -- To view, visit https://gerrit.osmocom.org/1693 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 01:33:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 01:33:42 +0000 Subject: [PATCH] openbsc[master]: gsm_04_08: implement parsing of UMTS Auth responses Message-ID: Review at https://gerrit.osmocom.org/1733 gsm_04_08: implement parsing of UMTS Auth responses Parse the longer UMTS res from the extended Auth Response Parameter IE. Parse the R99 Authentication Failure and AUTS in case of cause GSM_REJECT_SYNCH_FAILURE which indicates a SQN re-sync request. Both still end in 'not implemented' error logs, which are the places where the upcoming VLR that supports UMTS AKA will integrate. Depends on recently added constants in libosmocore in commit 55a43b801385e07a484217925ecf2379b9f54fcf aka change-id I745061ce8eb88aa23080dadcdbfe2d703c362a30 Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec --- M openbsc/src/libmsc/gsm_04_08.c 1 file changed, 222 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/33/1733/1 diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 8380710..7fc8f82 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1108,15 +1108,126 @@ return 0; } -/* Chapter 9.2.3: Authentication Response */ -static int gsm48_rx_mm_auth_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) +static int parse_gsm_auth_resp(uint8_t *res, uint8_t *res_len, + struct gsm_subscriber_connection *conn, + struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); struct gsm48_auth_resp *ar = (struct gsm48_auth_resp*) gh->data; - struct gsm_network *net = conn->network; - DEBUGP(DMM, "MM AUTHENTICATION RESPONSE (sres = %s): ", - osmo_hexdump(ar->sres, 4)); + if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*ar)) { + LOGP(DMM, LOGL_ERROR, + "%s: MM AUTHENTICATION RESPONSE:" + " l3 length invalid: %u\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + return -EINVAL; + } + + *res_len = sizeof(ar->sres); + memcpy(res, ar->sres, sizeof(ar->sres)); + return 0; +} + +static int parse_umts_auth_resp(uint8_t *res, uint8_t *res_len, + struct gsm_subscriber_connection *conn, + struct msgb *msg) +{ + struct gsm48_hdr *gh; + uint8_t *data; + uint8_t iei; + uint8_t ie_len; + unsigned int data_len; + + /* First parse the GSM part */ + if (parse_gsm_auth_resp(res, res_len, conn, msg)) + return -EINVAL; + OSMO_ASSERT(*res_len == 4); + + /* Then add the extended res part */ + gh = msgb_l3(msg); + data = gh->data + sizeof(struct gsm48_auth_resp); + data_len = msgb_l3len(msg) - (data - (uint8_t*)msgb_l3(msg)); + + if (data_len < 3) { + LOGP(DMM, LOGL_ERROR, + "%s: MM AUTHENTICATION RESPONSE:" + " l3 length invalid: %u\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + return -EINVAL; + } + + iei = data[0]; + ie_len = data[1]; + if (iei != GSM48_IE_AUTH_RES_EXT) { + LOGP(DMM, LOGL_ERROR, + "%s: MM R99 AUTHENTICATION RESPONSE:" + " expected IEI 0x%02x, got 0x%02x\n", + subscr_name(conn->subscr), + GSM48_IE_AUTH_RES_EXT, iei); + return -EINVAL; + } + + if (ie_len > 12) { + LOGP(DMM, LOGL_ERROR, + "%s: MM R99 AUTHENTICATION RESPONSE:" + " extended Auth Resp IE 0x%02x is too large: %u bytes\n", + subscr_name(conn->subscr), GSM48_IE_AUTH_RES_EXT, ie_len); + return -EINVAL; + } + + *res_len += ie_len; + memcpy(res + 4, &data[2], ie_len); + return 0; +} + +/* Chapter 9.2.3: Authentication Response */ +static int gsm48_rx_mm_auth_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) +{ + struct gsm_network *net = conn->network; + uint8_t res[16]; + uint8_t res_len; + int rc; + bool is_r99; + + if (!conn->subscr) { + LOGP(DMM, LOGL_ERROR, + "MM AUTHENTICATION RESPONSE: invalid: no subscriber\n"); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + if (msgb_l3len(msg) > + sizeof(struct gsm48_hdr) + sizeof(struct gsm48_auth_resp)) { + rc = parse_umts_auth_resp(res, &res_len, conn, msg); + is_r99 = true; + } else { + rc = parse_gsm_auth_resp(res, &res_len, conn, msg); + is_r99 = false; + } + + if (rc) { + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + DEBUGP(DMM, "%s: MM %s AUTHENTICATION RESPONSE (%s = %s)\n", + subscr_name(conn->subscr), + is_r99 ? "R99" : "GSM", is_r99 ? "res" : "sres", + osmo_hexdump_nospc(res, res_len)); + + /* Future: vlr_sub_rx_auth_resp(conn->vsub, is_r99, + * conn->via_iface == IFACE_IU, + * res, res_len); + */ + + if (res_len != 4) { + LOGP(DMM, LOGL_ERROR, + "%s: MM AUTHENTICATION RESPONSE:" + " UMTS authentication not supported\n", + subscr_name(conn->subscr)); + } /* Safety check */ if (!conn->sec_operation) { @@ -1125,7 +1236,7 @@ } /* Validate SRES */ - if (memcmp(conn->sec_operation->atuple.vec.sres, ar->sres,4)) { + if (memcmp(conn->sec_operation->atuple.vec.sres, res, 4)) { int rc; gsm_cbfn *cb = conn->sec_operation->cb; @@ -1146,6 +1257,108 @@ /* Start ciphering */ return gsm0808_cipher_mode(conn, net->a5_encryption, conn->sec_operation->atuple.vec.kc, 8, 0); +} + +static int gsm48_rx_mm_auth_fail(struct gsm_subscriber_connection *conn, struct msgb *msg) +{ + struct gsm48_hdr *gh = msgb_l3(msg); + uint8_t cause; + uint8_t auts_tag; + uint8_t auts_len; + uint8_t *auts; + int rc; + + if (!conn->sec_operation) { + DEBUGP(DMM, "%s: MM R99 AUTHENTICATION FAILURE:" + " No authentication/cipher operation in progress\n", + subscr_name(conn->subscr)); + return -EINVAL; + } + + if (!conn->subscr) { + LOGP(DMM, LOGL_ERROR, + "MM R99 AUTHENTICATION FAILURE: invalid: no subscriber\n"); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + if (msgb_l3len(msg) < sizeof(*gh) + 1) { + LOGP(DMM, LOGL_ERROR, + "%s: MM R99 AUTHENTICATION FAILURE:" + " l3 length invalid: %u\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + cause = gh->data[0]; + + if (cause != GSM48_REJECT_SYNCH_FAILURE) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE: cause 0x%0x\n", + subscr_name(conn->subscr), cause); + rc = gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return rc; + } + + /* This is a Synch Failure procedure, which should pass an AUTS to + * resynchronize the sequence nr with the HLR. Expecting exactly one + * TLV with 14 bytes of AUTS. */ + + if (msgb_l3len(msg) < sizeof(*gh) + 1 + 2) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE:" + " invalid Synch Failure: missing AUTS IE\n", + subscr_name(conn->subscr)); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + auts_tag = gh->data[1]; + auts_len = gh->data[2]; + auts = &gh->data[3]; + + if (auts_tag != GSM48_IE_AUTS + || auts_len != 14) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE:" + " invalid Synch Failure:" + " expected AUTS IE 0x%02x of 14 bytes," + " got IE 0x%02x of %u bytes\n", + subscr_name(conn->subscr), + GSM48_IE_AUTS, auts_tag, auts_len); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + if (msgb_l3len(msg) < sizeof(*gh) + 1 + 2 + auts_len) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE:" + " invalid Synch Failure msg: message truncated (%u)\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + /* We have an AUTS IE with exactly 14 bytes of AUTS and the msgb is + * large enough. */ + + DEBUGP(DMM, "%s: MM R99 AUTHENTICATION SYNCH (AUTS = %s)\n", + subscr_name(conn->subscr), osmo_hexdump_nospc(auts, 14)); + + /* Future: vlr_sub_rx_auth_fail(conn->vsub, auts); */ + + LOGP(DMM, LOGL_ERROR, "%s: MM R99 AUTHENTICATION not supported\n", + subscr_name(conn->subscr)); + rc = gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return rc; } /* Receive a GSM 04.08 Mobility Management (MM) message */ @@ -1182,6 +1395,9 @@ case GSM48_MT_MM_AUTH_RESP: rc = gsm48_rx_mm_auth_resp(conn, msg); break; + case GSM48_MT_MM_AUTH_FAIL: + rc = gsm48_rx_mm_auth_fail(conn, msg); + break; default: LOGP(DMM, LOGL_NOTICE, "Unknown GSM 04.08 MM msg type 0x%02x\n", gh->msg_type); -- To view, visit https://gerrit.osmocom.org/1733 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 02:28:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 02:28:08 +0000 Subject: [PATCH] libosmocore[master]: osmo-gen-vec: cosmetic: clarify output upon AUTS Message-ID: Review at https://gerrit.osmocom.org/1734 osmo-gen-vec: cosmetic: clarify output upon AUTS When calculating a re-sync vector using AUTS, osmo-gen-vec used to print SQN.MS + 2, the new SQN after vector generation, labeled 'SEQ.MS'. Firstly, s/SEQ/SQN. Secondly, print SQN.MS as umts.sqn - 2, which is the actual SQN recovered from the AUTS. As explained in the comment, SQN.MS + 1 is used to generate the vector, and then umts.sqn is increased a second time to indicate the next SQN. With AUTS calculated from SQN.MS == 23, the output was: AUTS success: SEQ.MS = 25 Output now: AUTS success: SQN.MS = 23, generated vector with SQN = 24, next SQN = 25 Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e --- M utils/osmo-auc-gen.c 1 file changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/1734/1 diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 4c3e891..872d6f3 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -251,8 +251,21 @@ else dump_auth_vec(vec); + /* Print SQN from AUTS. It makes sense to print actually three SQN + * to clarify: + * After recovering SQN.MS from AUTS, milenage_gen_vec_auts() does: + * aud->u.umts.sqn = 1 + (osmo_load64be_ext(sqn_out, 6) >> 16); + * Then calls milenage_gen_vec(), which, after it is done, does: + * aud->u.umts.sqn++; + */ if (auts_is_set) - printf("AUTS success: SEQ.MS = %" PRIu64 "\n", test_aud.u.umts.sqn); + printf("AUTS success: SQN.MS = %" PRIu64 + ", generated vector with SQN = %" PRIu64 + ", next SQN = %" PRIu64 "\n", + test_aud.u.umts.sqn - 2, + test_aud.u.umts.sqn - 1, + test_aud.u.umts.sqn + ); exit(0); } -- To view, visit https://gerrit.osmocom.org/1734 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 03:18:48 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 03:18:48 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve sporadic 'Broken Pipe' e... Message-ID: Review at https://gerrit.osmocom.org/1735 vty tests: more attempts to resolve sporadic 'Broken Pipe' error Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d --- M openbsc/tests/vty_test_runner.py 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/35/1735/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 7b25d10..3fbe20d 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1267,10 +1267,12 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + print "\tself.proc.poll(): ", repr(self.proc.poll()) if retries < 1: print "\tgiving up" raise - print "\tretrying (%d attempts left)" % retries + print "\tretrying in a second (%d attempts left)" % retries + time.sleep(1) retries -= 1 else: if (verbose): -- To view, visit https://gerrit.osmocom.org/1735 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 03:25:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 03:25:35 +0000 Subject: [PATCH] openbsc[master]: vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 b... Message-ID: Review at https://gerrit.osmocom.org/1736 vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 bytes Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 --- M openbsc/tests/vty_test_runner.py 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/36/1736/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 3fbe20d..3c25a66 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1239,6 +1239,7 @@ def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) + self.assertEquals(len(s), 4*2) if "0001fe00" == s: if (verbose): print "\tBSC <- NAT: PING?" -- To view, visit https://gerrit.osmocom.org/1736 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 03:26:52 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Fri, 3 Feb 2017 03:26:52 +0000 Subject: openbsc[master]: vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 b... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1736 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 03:27:42 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Fri, 3 Feb 2017 03:27:42 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve sporadic 'Broken Pipe' e... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 Okay, didn't know poll but let's hope it is uing waitpid with NOHANG :) -- To view, visit https://gerrit.osmocom.org/1735 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 03:29:54 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 03:29:54 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve sporadic 'Broken Pipe' e... In-Reply-To: References: Message-ID: Patch Set 1: "if poll() returns None, the process has not terminated yet"... (from subprocess module) -- To view, visit https://gerrit.osmocom.org/1735 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 03:49:15 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 03:49:15 +0000 Subject: [PATCH] openbsc[master]: vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 b... In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1736 to look at the new patch set (#2). vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 bytes Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 --- M openbsc/tests/vty_test_runner.py 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/36/1736/2 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 3fbe20d..64fd86d 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1239,6 +1239,8 @@ def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) + if len(s) != 4*2: + raise Exception("expected to receive 4 bytes, but got %d (%r)" % (len(s)/2, s)) if "0001fe00" == s: if (verbose): print "\tBSC <- NAT: PING?" -- To view, visit https://gerrit.osmocom.org/1736 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:09:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:09:23 +0000 Subject: [PATCH] libosmocore[master]: osmo_auth*: fix ordering of function args Message-ID: Review at https://gerrit.osmocom.org/1737 osmo_auth*: fix ordering of function args milenage_gen_vec() has parameter ordering of (..., auts, rand_auts, rand). osmo_auth_gen_vec_auts() has (..., rand_auts, auts, rand), but actually feeds args in the same order, so that its rand_auts becomes auts, and its auts becomes rand_auts. Interestingly enough, API user osmo-gen-vec.c also adheres to this misordering and in turn passes auts for osmo_auth_gen_vec_auts()'s rand_auts and vice versa, so that it matches milenage_gen_vec(). So both the implementation (milenage_*) and the API user use the same ordering, just osmo_auth_gen_vec_auts() and osmo_auth_impl{ .gen_vec_auts() } in-between have the argument names swapped. Any current user of this API would need to adhere to this swapping or will not get successful AUTS resolution to a SQN. So the least impact fix is to rename the args without any actual functional change. So swap the names rand_auts and auts for osmo_auth_gen_vec_auts() and osmo_auth_impl{ .gen_vec_auts() }. (Also adjust API doc ordering) Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 --- M include/osmocom/crypt/auth.h M src/gsm/auth_core.c 2 files changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/1737/1 diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index 37b8a8a..7c6072b 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -74,7 +74,7 @@ /* \brief callback for generationg auth vectors + re-sync */ int (*gen_vec_auts)(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, - const uint8_t *rand_auts, const uint8_t *auts, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand); }; @@ -83,7 +83,7 @@ int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, - const uint8_t *rand_auts, const uint8_t *auts, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand); int osmo_auth_register(struct osmo_auth_impl *impl); diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index 3aac069..3b1a5c6 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -170,8 +170,8 @@ /*! \brief Generate authentication vector and re-sync sequence * \param[out] vec Generated authentication vector * \param[in] aud Subscriber-specific key material - * \param[in] rand_auts RAND value sent by the SIM/MS * \param[in] auts AUTS value sent by the SIM/MS + * \param[in] rand_auts RAND value sent by the SIM/MS * \param[in] _rand Random challenge to be used to generate vector * \returns 0 on success, negative error on failure * @@ -184,7 +184,7 @@ */ int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, - const uint8_t *rand_auts, const uint8_t *auts, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand) { struct osmo_auth_impl *impl = selected_auths[aud->algo]; @@ -192,7 +192,7 @@ if (!impl || !impl->gen_vec_auts) return -ENOENT; - return impl->gen_vec_auts(vec, aud, rand_auts, auts, _rand); + return impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); } static const struct value_string auth_alg_vals[] = { -- To view, visit https://gerrit.osmocom.org/1737 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:26:16 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:26:16 +0000 Subject: openbsc[master]: vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 b... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1736 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:26:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:26:28 +0000 Subject: [MERGED] openbsc[master]: vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 b... In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 bytes ...................................................................... vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 bytes Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 --- M openbsc/tests/vty_test_runner.py 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 3fbe20d..64fd86d 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1239,6 +1239,8 @@ def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) + if len(s) != 4*2: + raise Exception("expected to receive 4 bytes, but got %d (%r)" % (len(s)/2, s)) if "0001fe00" == s: if (verbose): print "\tBSC <- NAT: PING?" -- To view, visit https://gerrit.osmocom.org/1736 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:26:29 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:26:29 +0000 Subject: [MERGED] openbsc[master]: vty tests: more attempts to resolve sporadic 'Broken Pipe' e... In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: vty tests: more attempts to resolve sporadic 'Broken Pipe' error ...................................................................... vty tests: more attempts to resolve sporadic 'Broken Pipe' error Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d --- M openbsc/tests/vty_test_runner.py 1 file changed, 3 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 7b25d10..3fbe20d 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1267,10 +1267,12 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + print "\tself.proc.poll(): ", repr(self.proc.poll()) if retries < 1: print "\tgiving up" raise - print "\tretrying (%d attempts left)" % retries + print "\tretrying in a second (%d attempts left)" % retries + time.sleep(1) retries -= 1 else: if (verbose): -- To view, visit https://gerrit.osmocom.org/1735 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:36:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:36:31 +0000 Subject: [MERGED] openbsc[master]: gsm48_tx_mm_auth_req(): support UMTS AUTN In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: gsm48_tx_mm_auth_req(): support UMTS AUTN ...................................................................... gsm48_tx_mm_auth_req(): support UMTS AUTN To be able to do R99 UMTS authentication, we need to send along AUTN bytes in the Authentication Request. Add autn parameter to gsm48_tx_mm_auth_req() and conditionally append the R99 AUTN TLV to the Authentication Request message. Change-Id: I0d644559088706aa06b42b9bfe1f8c21ca6fa4da --- M openbsc/include/openbsc/gsm_04_08.h M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/token_auth.c 3 files changed, 24 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index fd0b89d..cb632f6 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -53,7 +53,8 @@ void gsm_net_update_ctype(struct gsm_network *net); int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn); -int gsm48_tx_mm_auth_req(struct gsm_subscriber_connection *conn, uint8_t *rand, int key_seq); +int gsm48_tx_mm_auth_req(struct gsm_subscriber_connection *conn, uint8_t *rand, + uint8_t *autn, int key_seq); int gsm48_tx_mm_auth_rej(struct gsm_subscriber_connection *conn); int gsm48_tx_mm_serv_ack(struct gsm_subscriber_connection *conn); int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn, diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 8380710..407104f 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -238,7 +238,8 @@ /* Then do whatever is needed ... */ if (rc == AUTH_DO_AUTH_THEN_CIPH) { /* Start authentication */ - return gsm48_tx_mm_auth_req(conn, op->atuple.vec.rand, op->atuple.key_seq); + return gsm48_tx_mm_auth_req(conn, op->atuple.vec.rand, NULL, + op->atuple.key_seq); } else if (rc == AUTH_DO_CIPH) { /* Start ciphering directly */ return gsm0808_cipher_mode(conn, net->a5_encryption, @@ -875,14 +876,24 @@ return gsm48_conn_sendmsg(msg, conn, NULL); } -/* Section 9.2.2 */ -int gsm48_tx_mm_auth_req(struct gsm_subscriber_connection *conn, uint8_t *rand, int key_seq) +/*! Send an Authentication Request to MS on the given subscriber connection + * according to 3GPP/ETSI TS 24.008, Section 9.2.2. + * \param[in] conn Subscriber connection to send on. + * \param[in] rand Random challenge token to send, must be 16 bytes long. + * \param[in] autn r99: In case of UMTS mutual authentication, AUTN token to + * send; must be 16 bytes long, or pass NULL for plain GSM auth. + * \param[in] key_seq auth tuple's sequence number. + */ +int gsm48_tx_mm_auth_req(struct gsm_subscriber_connection *conn, uint8_t *rand, + uint8_t *autn, int key_seq) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 AUTH REQ"); struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); struct gsm48_auth_req *ar = (struct gsm48_auth_req *) msgb_put(msg, sizeof(*ar)); DEBUGP(DMM, "-> AUTH REQ (rand = %s)\n", osmo_hexdump(rand, 16)); + if (autn) + DEBUGP(DMM, " AUTH REQ (autn = %s)\n", osmo_hexdump(autn, 16)); msg->lchan = conn->lchan; gh->proto_discr = GSM48_PDISC_MM; @@ -891,9 +902,15 @@ ar->key_seq = key_seq; /* 16 bytes RAND parameters */ + osmo_static_assert(sizeof(ar->rand) == 16, sizeof_auth_req_r99_rand); if (rand) memcpy(ar->rand, rand, 16); + + /* 16 bytes AUTN */ + if (autn) + msgb_tlv_put(msg, GSM48_IE_AUTN, 16, autn); + return gsm48_conn_sendmsg(msg, conn, NULL); } diff --git a/openbsc/src/libmsc/token_auth.c b/openbsc/src/libmsc/token_auth.c index 95fd9b3..5af1e98 100644 --- a/openbsc/src/libmsc/token_auth.c +++ b/openbsc/src/libmsc/token_auth.c @@ -106,7 +106,7 @@ if (conn) { uint8_t auth_rand[16]; /* kick the subscriber off the network */ - gsm48_tx_mm_auth_req(conn, auth_rand, 0); + gsm48_tx_mm_auth_req(conn, auth_rand, NULL, 0); gsm48_tx_mm_auth_rej(conn); /* FIXME: close the channel early ?*/ //gsm48_send_rr_Release(lchan); @@ -143,7 +143,7 @@ conn = connection_for_subscr(sms->receiver); if (conn) { /* kick the subscriber off the network */ - gsm48_tx_mm_auth_req(conn, auth_rand, 0); + gsm48_tx_mm_auth_req(conn, auth_rand, NULL, 0); gsm48_tx_mm_auth_rej(conn); /* FIXME: close the channel early ?*/ //gsm48_send_rr_Release(lchan); -- To view, visit https://gerrit.osmocom.org/1695 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0d644559088706aa06b42b9bfe1f8c21ca6fa4da Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:57:14 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:57:14 +0000 Subject: [PATCH] openbsc[master]: Revert "vty tests: more attempts to resolve sporadic 'Broken... Message-ID: Review at https://gerrit.osmocom.org/1738 Revert "vty tests: more attempts to resolve sporadic 'Broken Pipe' error" 'self' will not be accessible in that context, so this patch isn't useful. This reverts commit b39053ad6de50df5a2efcb4ec0c6551020b513e1. Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece --- M openbsc/tests/vty_test_runner.py 1 file changed, 1 insertion(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/38/1738/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 64fd86d..608aef4 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1269,12 +1269,10 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") - print "\tself.proc.poll(): ", repr(self.proc.poll()) if retries < 1: print "\tgiving up" raise - print "\tretrying in a second (%d attempts left)" % retries - time.sleep(1) + print "\tretrying (%d attempts left)" % retries retries -= 1 else: if (verbose): -- To view, visit https://gerrit.osmocom.org/1738 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:57:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:57:28 +0000 Subject: openbsc[master]: Revert "vty tests: more attempts to resolve sporadic 'Broken... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1738 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 04:57:30 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 04:57:30 +0000 Subject: [MERGED] openbsc[master]: Revert "vty tests: more attempts to resolve sporadic 'Broken... In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: Revert "vty tests: more attempts to resolve sporadic 'Broken Pipe' error" ...................................................................... Revert "vty tests: more attempts to resolve sporadic 'Broken Pipe' error" 'self' will not be accessible in that context, so this patch isn't useful. This reverts commit b39053ad6de50df5a2efcb4ec0c6551020b513e1. Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece --- M openbsc/tests/vty_test_runner.py 1 file changed, 1 insertion(+), 3 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved; Verified diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 64fd86d..608aef4 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1269,12 +1269,10 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") - print "\tself.proc.poll(): ", repr(self.proc.poll()) if retries < 1: print "\tgiving up" raise - print "\tretrying in a second (%d attempts left)" % retries - time.sleep(1) + print "\tretrying (%d attempts left)" % retries retries -= 1 else: if (verbose): -- To view, visit https://gerrit.osmocom.org/1738 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 05:03:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 05:03:38 +0000 Subject: [PATCH] osmo-hlr[master]: UMTS AKA resync: fix argument ordering Message-ID: Review at https://gerrit.osmocom.org/1739 UMTS AKA resync: fix argument ordering According to libosmocore change-id I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 this argument ordering will not result in successful AUTS. Pass in order auts, auts_rand so that these are passed correctly to our milenage code. Change-Id: I6aa19004ec27bad5e9c2bf688d9bbc55d697ccb0 --- M src/auc.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/39/1739/1 diff --git a/src/auc.c b/src/auc.c index bec3ea6..3f3db34 100644 --- a/src/auc.c +++ b/src/auc.c @@ -71,8 +71,8 @@ i, num_vec); if (rand_auts && auts) rc = osmo_auth_gen_vec_auts(vec+i, aud3g, - rand_auts, - auts, rand); + auts, rand_auts, + rand); else rc = osmo_auth_gen_vec(vec+i, aud3g, rand); if (rc < 0) { -- To view, visit https://gerrit.osmocom.org/1739 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6aa19004ec27bad5e9c2bf688d9bbc55d697ccb0 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 09:16:41 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Fri, 3 Feb 2017 09:16:41 +0000 Subject: [PATCH] libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1584 to look at the new patch set (#5). utils/conv_gen.py: improve application flexibility This change makes the conv_gen application more interactive and flexible, allowing to generate not only code definitions but also the test vectors and header files in the future. Moreover, it becomes possible to select exact code family, such as GSM, GMR etc. Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 --- M src/gsm/Makefile.am M utils/conv_gen.py 2 files changed, 38 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/1584/5 diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 4ec441f..653bdb9 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -35,6 +35,6 @@ # Convolutional codes generation gsm0503_conv.c: - $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py + $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_codes gsm CLEANFILES = gsm0503_conv.c diff --git a/utils/conv_gen.py b/utils/conv_gen.py index 60580ed..e6eb50c 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -23,7 +23,7 @@ */ """ -import sys, os, math +import sys, os, math, argparse from functools import reduce import conv_codes_gsm @@ -254,12 +254,14 @@ code = ConvolutionalCode(0, polys, name = name) code.print_state_and_output(fi) -def generate_codes(codes, path, prefix): +def generate_codes(codes, path, prefix, name): # Open a new file for writing - f = open(os.path.join(path, prefix + "_conv.c"), 'w') + f = open(os.path.join(path, name), 'w') f.write(mod_license + "\n") f.write("#include \n") f.write("#include \n\n") + + sys.stderr.write("Generating convolutional codes...\n") # Print shared tables first if hasattr(codes, "shared_polys"): @@ -279,12 +281,40 @@ code.gen_tables(prefix, f, shared_tables = shared) +def parse_argv(): + parser = argparse.ArgumentParser() + + # Positional arguments + parser.add_argument("action", + help = "what to generate", + choices = ["gen_codes"]) + parser.add_argument("family", + help = "convolutional code family", + choices = ["gsm"]) + + # Optional arguments + parser.add_argument("-p", "--prefix", + help = "internal naming prefix") + parser.add_argument("-n", "--target-name", + help = "target name for generated file") + parser.add_argument("-P", "--target-path", + help = "target path for generated file") + + return parser.parse_args() + if __name__ == '__main__': - path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() + # Parse and verify arguments + argv = parse_argv() + path = argv.target_path or os.getcwd() - sys.stderr.write("Generating convolutional codes...\n") + # Determine convolutional code family + if argv.family == "gsm": + codes = conv_codes_gsm + prefix = argv.prefix or "gsm0503" - # Generate GSM specific codes - generate_codes(conv_codes_gsm, path, "gsm0503") + # What to generate? + if argv.action == "gen_codes": + name = argv.target_name or prefix + "_conv.c" + generate_codes(codes, path, prefix, name) sys.stderr.write("Generation complete.\n") -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Fri Feb 3 09:16:41 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Fri, 3 Feb 2017 09:16:41 +0000 Subject: [PATCH] libosmocore[master]: utils/conv_gen.py: add test vectors generation feature In-Reply-To: References: Message-ID: Hello Max, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1585 to look at the new patch set (#7). utils/conv_gen.py: add test vectors generation feature Change-Id: Ie10c47ee952f253b1ba77ecf6e79f2c033545bc1 --- M utils/conv_gen.py 1 file changed, 76 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/1585/7 diff --git a/utils/conv_gen.py b/utils/conv_gen.py index e6eb50c..e929d3f 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -30,13 +30,16 @@ class ConvolutionalCode(object): def __init__(self, block_len, polys, name, - description = None, puncture = [], term_type = None): + description = None, puncture = [], term_type = None, + vec_in = None, vec_out = None): # Save simple params self.block_len = block_len self.k = 1 self.puncture = puncture self.rate_inv = len(polys) self.term_type = term_type + self.vec_in = vec_in + self.vec_out = vec_out # Infos self.name = name @@ -226,6 +229,44 @@ fi.write("\t.puncture = %s_puncture,\n" % self.name) fi.write("};\n\n") + def calc_out_len(self): + out_len = self.block_len * self.rate_inv + + # By default CONV_TERM_FLUSH + if self.term_type is None: + out_len += self.rate_inv * (self.k - 1) + + if len(self.puncture): + out_len -= len(self.puncture) - 1 + + return out_len + + def gen_test_vector(self, fi, prefix): + code_name = "%s_%s" % (prefix, self.name) + + fi.write("\t{\n") + fi.write("\t\t.name = \"%s\",\n" % code_name) + fi.write("\t\t.code = &%s,\n" % code_name) + + fi.write("\t\t.in_len = %d,\n" % self.block_len) + fi.write("\t\t.out_len = %d,\n" % self.calc_out_len()) + + # Print pre computed vectors if preset + if self.vec_in is not None and self.vec_out is not None: + fi.write("\t\t.has_vec = 1,\n") + fi.write("\t\t.vec_in = {\n") + print_formatted(self.vec_in, "0x%02x, ", 8, fi, indent = "\t\t\t") + fi.write("\t\t},\n") + fi.write("\t\t.vec_out = {\n") + print_formatted(self.vec_out, "0x%02x, ", 8, fi, indent = "\t\t\t") + fi.write("\t\t},\n") + else: + fi.write("\t\t.has_vec = 0,\n") + fi.write("\t\t.vec_in = { },\n") + fi.write("\t\t.vec_out = { },\n") + + fi.write("\t},\n") + poly = lambda *args: sum([(1 << x) for x in args]) def combine(src, sel, nb): @@ -281,13 +322,41 @@ code.gen_tables(prefix, f, shared_tables = shared) +def generate_vectors(codes, path, prefix, name, inc = None): + # Open a new file for writing + f = open(os.path.join(path, name), 'w') + f.write(mod_license + "\n") + + # Print includes + if inc is not None: + for item in inc: + f.write("%s\n" % item) + f.write("#include \n") + f.write("#include \"conv.h\"\n\n") + + sys.stderr.write("Generating test vectors...\n") + + vec_count = len(codes.conv_codes) + f.write("const int %s_vectors_len = %d;\n\n" + % (prefix, vec_count)) + + f.write("const struct conv_test_vector %s_vectors[%d] = {\n" + % (prefix, vec_count)) + + # Generate the vectors one by one + for code in codes.conv_codes: + sys.stderr.write("Generate '%s' test vector\n" % code.name) + code.gen_test_vector(f, prefix) + + f.write("};\n") + def parse_argv(): parser = argparse.ArgumentParser() # Positional arguments parser.add_argument("action", help = "what to generate", - choices = ["gen_codes"]) + choices = ["gen_codes", "gen_vectors"]) parser.add_argument("family", help = "convolutional code family", choices = ["gsm"]) @@ -306,15 +375,20 @@ # Parse and verify arguments argv = parse_argv() path = argv.target_path or os.getcwd() + inc = None # Determine convolutional code family if argv.family == "gsm": codes = conv_codes_gsm prefix = argv.prefix or "gsm0503" + inc = [ "#include " ] # What to generate? if argv.action == "gen_codes": name = argv.target_name or prefix + "_conv.c" generate_codes(codes, path, prefix, name) + elif argv.action == "gen_vectors": + name = argv.target_name or prefix + "_test_vectors.c" + generate_vectors(codes, path, prefix, name, inc) sys.stderr.write("Generation complete.\n") -- To view, visit https://gerrit.osmocom.org/1585 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie10c47ee952f253b1ba77ecf6e79f2c033545bc1 Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Fri Feb 3 09:16:41 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Fri, 3 Feb 2017 09:16:41 +0000 Subject: [PATCH] libosmocore[master]: utils/conv_gen.py: add header generation feature In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1593 to look at the new patch set (#4). utils/conv_gen.py: add header generation feature Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea --- M utils/conv_gen.py 1 file changed, 44 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/1593/4 diff --git a/utils/conv_gen.py b/utils/conv_gen.py index e929d3f..1ffeb3f 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -168,6 +168,20 @@ # Up to 12 numbers should be placed per line print_formatted(self.puncture, "%3d, ", 12, fi) + def print_description(self, fi, brief = False): + if brief is True: + fi.write("/*! \\brief ") + fi.write("structure describing %s\n" + % self.description[0]) + for line in self.description[1:]: + fi.write(" * %s\n" % line) + else: + fi.write("/**\n") + for line in self.description: + fi.write(" * %s\n" % line) + + fi.write(" */\n") + def print_state_and_output(self, fi): pack = lambda n: \ sum([x << (self.rate_inv - i - 1) for i, x in enumerate(n)]) @@ -205,10 +219,7 @@ # Write description as a multi-line comment if self.description is not None: - fi.write("/**\n") - for line in self.description: - fi.write(" * %s\n" % line) - fi.write(" */\n") + self.print_description(fi) # Print a final convolutional code definition fi.write("const struct osmo_conv_code %s_%s = {\n" % (pref, self.name)) @@ -350,13 +361,38 @@ f.write("};\n") +def generate_header(codes, path, prefix, name, description = None): + # Open a new file for writing + f = open(os.path.join(path, name), 'w') + + # Print license and includes + f.write(mod_license + "\n") + f.write("#pragma once\n\n") + f.write("#include \n") + f.write("#include \n\n") + + # Print general file description if preset + if description is not None: + f.write("/*! \\file %s.h\n" % prefix) + f.write(" * %s\n" % description) + f.write(" */\n\n") + + sys.stderr.write("Generating header file...\n") + + # Generate declarations one by one + for code in codes.conv_codes: + sys.stderr.write("Generate '%s' declaration\n" % code.name) + code.print_description(f, True) + f.write("extern const struct osmo_conv_code %s_%s;\n\n" + % (prefix, code.name)) + def parse_argv(): parser = argparse.ArgumentParser() # Positional arguments parser.add_argument("action", help = "what to generate", - choices = ["gen_codes", "gen_vectors"]) + choices = ["gen_codes", "gen_vectors", "gen_header"]) parser.add_argument("family", help = "convolutional code family", choices = ["gsm"]) @@ -390,5 +426,8 @@ elif argv.action == "gen_vectors": name = argv.target_name or prefix + "_test_vectors.c" generate_vectors(codes, path, prefix, name, inc) + elif argv.action == "gen_header": + name = argv.target_name or prefix + ".h" + generate_header(codes, path, prefix, name) sys.stderr.write("Generation complete.\n") -- To view, visit https://gerrit.osmocom.org/1593 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Fri Feb 3 09:16:41 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Fri, 3 Feb 2017 09:16:41 +0000 Subject: [PATCH] libosmocore[master]: gsm0503.h: generate header automatically In-Reply-To: References: Message-ID: Hello Max, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1594 to look at the new patch set (#6). gsm0503.h: generate header automatically Since we have automatic header generation, implemented in the utils/conv_gen.py, it's time to use this feature! Change-Id: I21caa4e433b2cc1861611e35350a9671da444c2a --- M .gitignore M include/Makefile.am D include/osmocom/gsm/gsm0503.h 3 files changed, 7 insertions(+), 174 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/1594/6 diff --git a/.gitignore b/.gitignore index fb159c3..c1bde0f 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,7 @@ src/gsm/gsm0503_conv.c include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h +include/osmocom/gsm/gsm0503.h # vi files *.sw? diff --git a/include/Makefile.am b/include/Makefile.am index 0a300a8..770a9c6 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -143,3 +143,9 @@ osmocom/core/crc%gen.h: osmocom/core/crcXXgen.h.tpl $(AM_V_GEN)$(MKDIR_P) $(dir $@) $(AM_V_GEN)sed -e's/XX/$*/g' $< > $@ + +osmocom/gsm/gsm0503.h: + $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_header gsm \ + --target-path $(top_srcdir)/include/osmocom/gsm/ + +CLEANFILES = osmocom/gsm/gsm0503.h diff --git a/include/osmocom/gsm/gsm0503.h b/include/osmocom/gsm/gsm0503.h deleted file mode 100644 index de28ad2..0000000 --- a/include/osmocom/gsm/gsm0503.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 - -#include - -/*! \file gsm0503.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. - */ -extern const struct osmo_conv_code gsm0503_xcch; - -/*! \brief structure describing convolutional code RACH - */ -extern const struct osmo_conv_code gsm0503_rach; - -/*! \brief structure describing convolutional code SCH - */ -extern const struct osmo_conv_code gsm0503_sch; - -/*! \brief structures describing convolutional codes CS2/3 - */ -extern const struct osmo_conv_code gsm0503_cs2; -extern const struct osmo_conv_code gsm0503_cs3; - -/*! \brief structure describing convolutional code TCH/FR - */ -extern const struct osmo_conv_code gsm0503_tch_fr; - -/*! \brief structure describing convolutional code TCH/HR - */ -extern const struct osmo_conv_code gsm0503_tch_hr; - -/*! \brief structure describing convolutional code TCH/AFS 12.2 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_12_2; - -/*! \brief structure describing convolutional code TCH/AFS 10.2 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_10_2; - -/*! \brief structure describing convolutional code TCH/AFS 7.95 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_7_95; - -/*! \brief structure describing convolutional code TCH/AFS 7.4 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_7_4; - -/*! \brief structure describing convolutional code TCH/AFS 6.7 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_6_7; - -/*! \brief structure describing convolutional code TCH/AFS 5.9 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_5_9; - -/*! \brief structure describing convolutional code TCH/AFS 5.15 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_5_15; - -/*! \brief structure describing convolutional code TCH/AFS 4.75 - */ -extern const struct osmo_conv_code gsm0503_tch_afs_4_75; - -/*! \brief structure describing convolutional code TCH/AHS 7.95 - */ -extern const struct osmo_conv_code gsm0503_tch_ahs_7_95; - -/*! \brief structure describing convolutional code TCH/AHS 7.4 - */ -extern const struct osmo_conv_code gsm0503_tch_ahs_7_4; - -/*! \brief structure describing convolutional code TCH/AHS 6.7 - */ -extern const struct osmo_conv_code gsm0503_tch_ahs_6_7; - -/*! \brief structure describing convolutional code TCH/AHS 5.9 - */ -extern const struct osmo_conv_code gsm0503_tch_ahs_5_9; - -/*! \brief structure describing convolutional code TCH/AHS 5.15 - */ -extern const struct osmo_conv_code gsm0503_tch_ahs_5_15; - -/*! \brief structure describing convolutional code TCH/AHS 4.75 - */ -extern const struct osmo_conv_code gsm0503_tch_ahs_4_75; - -/*! \brief structure describing convolutional code EDGE MCS-1 DL HDR - */ -extern const struct osmo_conv_code gsm0503_mcs1_dl_hdr; - -/*! \brief structure describing convolutional code EDGE MCS-1 UL HDR - */ -extern const struct osmo_conv_code gsm0503_mcs1_ul_hdr; - -/*! \brief structure describing convolutional code EDGE MCS-1 - */ -extern const struct osmo_conv_code gsm0503_mcs1; - -/*! \brief structure describing convolutional code EDGE MCS-2 - */ -extern const struct osmo_conv_code gsm0503_mcs2; - -/*! \brief structure describing convolutional code EDGE MCS-3 - */ -extern const struct osmo_conv_code gsm0503_mcs3; - -/*! \brief structure describing convolutional code EDGE MCS-4 - */ -extern const struct osmo_conv_code gsm0503_mcs4; - -/*! \brief structure describing convolutional code EDGE MCS-5 DL HDR - */ -extern const struct osmo_conv_code gsm0503_mcs5_dl_hdr; - -/*! \brief structure describing convolutional code EDGE MCS-5 UL HDR - */ -extern const struct osmo_conv_code gsm0503_mcs5_ul_hdr; - -/*! \brief structure describing convolutional code EDGE MCS-5 - */ -extern const struct osmo_conv_code gsm0503_mcs5; - -/*! \brief structure describing convolutional code EDGE MCS-6 - */ -extern const struct osmo_conv_code gsm0503_mcs6; - -/*! \brief structure describing convolutional code EDGE MCS-7 DL HDR - */ -extern const struct osmo_conv_code gsm0503_mcs7_dl_hdr; - -/*! \brief structure describing convolutional code EDGE MCS-7 UL HDR - */ -extern const struct osmo_conv_code gsm0503_mcs7_ul_hdr; - -/*! \brief structure describing convolutional code EDGE MCS-7 - */ -extern const struct osmo_conv_code gsm0503_mcs7; - -/*! \brief structure describing convolutional code EDGE MCS-8 - */ -extern const struct osmo_conv_code gsm0503_mcs8; - -/*! \brief structure describing convolutional code EDGE MCS-9 - */ -extern const struct osmo_conv_code gsm0503_mcs9; -- To view, visit https://gerrit.osmocom.org/1594 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I21caa4e433b2cc1861611e35350a9671da444c2a Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy From gerrit-no-reply at lists.osmocom.org Fri Feb 3 09:16:41 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Fri, 3 Feb 2017 09:16:41 +0000 Subject: [PATCH] libosmocore[master]: tests/conv: add GSM 05.03 specific test In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1628 to look at the new patch set (#2). tests/conv: add GSM 05.03 specific test This change extends the convolutional code test coverage, adding the GSM 05.03 specific test vectors, generated by the conv_gen.py. Inspired by Tom's patch: http://lists.osmocom.org/pipermail/openbsc/2014-April/007364.html Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a --- M .gitignore M tests/Makefile.am A tests/conv/conv_gsm0503_test.c A tests/conv/conv_gsm0503_test.ok M tests/testsuite.at 5 files changed, 228 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/28/1628/2 diff --git a/.gitignore b/.gitignore index c1bde0f..d5caa61 100644 --- a/.gitignore +++ b/.gitignore @@ -117,6 +117,7 @@ include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h include/osmocom/gsm/gsm0503.h +tests/conv/gsm0503_test_vectors.c # vi files *.sw? diff --git a/tests/Makefile.am b/tests/Makefile.am index 889eb8d..84a7f5e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,7 @@ smscb/gsm0341_test stats/stats_test \ bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \ tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_test \ - write_queue/wqueue_test + write_queue/wqueue_test conv/conv_gsm0503_test if ENABLE_MSGFILE check_PROGRAMS += msgfile/msgfile_test @@ -56,6 +56,9 @@ conv_conv_test_SOURCES = conv/conv_test.c conv/conv.c conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libgsmint.la + +conv_conv_gsm0503_test_SOURCES = conv/conv_gsm0503_test.c conv/conv.c conv/gsm0503_test_vectors.c +conv_conv_gsm0503_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 @@ -176,9 +179,9 @@ bitvec/bitvec_test.ok msgb/msgb_test.ok bits/bitcomp_test.ok \ sim/sim_test.ok tlv/tlv_test.ok gsup/gsup_test.ok \ oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \ - write_queue/wqueue_test.ok + write_queue/wqueue_test.ok conv/conv_gsm0503_test.ok -DISTCLEANFILES = atconfig atlocal +DISTCLEANFILES = atconfig atlocal conv/gsm0503_test_vectors.c noinst_HEADERS = conv/conv.h TESTSUITE = $(srcdir)/testsuite @@ -199,3 +202,7 @@ $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at mv $@.tmp $@ + +conv/gsm0503_test_vectors.c: + $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_vectors gsm \ + --target-path $(top_srcdir)/tests/conv/ diff --git a/tests/conv/conv_gsm0503_test.c b/tests/conv/conv_gsm0503_test.c new file mode 100644 index 0000000..6704129 --- /dev/null +++ b/tests/conv/conv_gsm0503_test.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "conv.h" + +/* Forward declaration of GSM 05.03 specific test vectors */ +extern const struct conv_test_vector gsm0503_vectors[]; +extern const int gsm0503_vectors_len; + +int main(int argc, char *argv[]) +{ + int rc, i; + + for (i = 0; i < gsm0503_vectors_len; i++) { + rc = do_check(&gsm0503_vectors[i]); + if (rc) + return rc; + } + + return 0; +} diff --git a/tests/conv/conv_gsm0503_test.ok b/tests/conv/conv_gsm0503_test.ok new file mode 100644 index 0000000..05761f2 --- /dev/null +++ b/tests/conv/conv_gsm0503_test.ok @@ -0,0 +1,183 @@ +[+] Testing: gsm0503_xcch +[.] Input length : ret = 224 exp = 224 -> OK +[.] Output length : ret = 456 exp = 456 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_rach +[.] Input length : ret = 14 exp = 14 -> OK +[.] Output length : ret = 36 exp = 36 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_sch +[.] Input length : ret = 35 exp = 35 -> OK +[.] Output length : ret = 78 exp = 78 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_cs2 +[.] Input length : ret = 290 exp = 290 -> OK +[.] Output length : ret = 456 exp = 456 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_cs3 +[.] Input length : ret = 334 exp = 334 -> OK +[.] Output length : ret = 456 exp = 456 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_12_2 +[.] Input length : ret = 250 exp = 250 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_10_2 +[.] Input length : ret = 210 exp = 210 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_7_95 +[.] Input length : ret = 165 exp = 165 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_7_4 +[.] Input length : ret = 154 exp = 154 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_6_7 +[.] Input length : ret = 140 exp = 140 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_5_9 +[.] Input length : ret = 124 exp = 124 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_5_15 +[.] Input length : ret = 109 exp = 109 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_4_75 +[.] Input length : ret = 101 exp = 101 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_fr +[.] Input length : ret = 185 exp = 185 -> OK +[.] Output length : ret = 378 exp = 378 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_hr +[.] Input length : ret = 98 exp = 98 -> OK +[.] Output length : ret = 211 exp = 211 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_7_95 +[.] Input length : ret = 129 exp = 129 -> OK +[.] Output length : ret = 188 exp = 188 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_7_4 +[.] Input length : ret = 126 exp = 126 -> OK +[.] Output length : ret = 196 exp = 196 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_6_7 +[.] Input length : ret = 116 exp = 116 -> OK +[.] Output length : ret = 200 exp = 200 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_5_9 +[.] Input length : ret = 108 exp = 108 -> OK +[.] Output length : ret = 208 exp = 208 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_5_15 +[.] Input length : ret = 97 exp = 97 -> OK +[.] Output length : ret = 212 exp = 212 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_4_75 +[.] Input length : ret = 89 exp = 89 -> OK +[.] Output length : ret = 212 exp = 212 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_mcs1_dl_hdr +[.] Input length : ret = 36 exp = 36 -> OK +[.] Output length : ret = 108 exp = 108 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_mcs1_ul_hdr +[.] Input length : ret = 39 exp = 39 -> OK +[.] Output length : ret = 117 exp = 117 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK diff --git a/tests/testsuite.at b/tests/testsuite.at index 426c74c..be6f9bc 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -39,6 +39,12 @@ AT_CHECK([$abs_top_builddir/tests/conv/conv_test], [0], [expout]) AT_CLEANUP +AT_SETUP([conv_gsm0503]) +AT_KEYWORDS([conv_gsm0503]) +cat $abs_srcdir/conv/conv_gsm0503_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/conv/conv_gsm0503_test], [0], [expout]) +AT_CLEANUP + AT_SETUP([msgb]) AT_KEYWORDS([msgb]) cat $abs_srcdir/msgb/msgb_test.ok > expout -- To view, visit https://gerrit.osmocom.org/1628 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Fri Feb 3 11:36:51 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Fri, 3 Feb 2017 11:36:51 +0000 Subject: [PATCH] libosmocore[master]: fixup Message-ID: Review at https://gerrit.osmocom.org/1740 fixup Change-Id: I541787411fccbe3866c16a0e80ff46dc786a5583 --- M include/osmocom/core/select.h M src/select.c 2 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/40/1740/1 diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index a912ea7..c2b51a4 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -36,7 +36,7 @@ unsigned int priv_nr; }; -bool osmo_fd_register_check(struct osmo_fd *fd); +bool osmo_fd_is_registered(struct osmo_fd *fd); int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); diff --git a/src/select.c b/src/select.c index d7c89f3..ab0734e 100644 --- a/src/select.c +++ b/src/select.c @@ -51,7 +51,7 @@ * \param[in] fd osmocom file descriptor to be checked * \returns true if registered; otherwise false */ -bool osmo_fd_register_check(struct osmo_fd *fd) +bool osmo_fd_is_registered(struct osmo_fd *fd) { struct osmo_fd *entry; llist_for_each_entry(entry, &osmo_fds, list) { @@ -94,7 +94,7 @@ maxfd = fd->fd; #ifdef BSC_FD_CHECK - if (osmo_fd_register_check(fd)) { + if (osmo_fd_is_registered(fd)) { fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); return 0; } @@ -112,7 +112,7 @@ { /* Note: when fd is inside the osmo_fds list (not registered before) * this function will crash! If in doubt, check file descriptor with - * osmo_fd_register_check() */ + * osmo_fd_is_registered() */ unregistered_count++; llist_del(&fd->list); } -- To view, visit https://gerrit.osmocom.org/1740 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I541787411fccbe3866c16a0e80ff46dc786a5583 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Fri Feb 3 11:39:32 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Fri, 3 Feb 2017 11:39:32 +0000 Subject: [ABANDON] libosmocore[master]: fixup In-Reply-To: References: Message-ID: dexter has abandoned this change. Change subject: fixup ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1740 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I541787411fccbe3866c16a0e80ff46dc786a5583 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 11:41:13 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Fri, 3 Feb 2017 11:41:13 +0000 Subject: [PATCH] libosmocore[master]: select: add functionality to check socket state In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1725 to look at the new patch set (#2). select: add functionality to check socket state osmo_fd_register() is used to register socket file descriptors, after registering a socket, there is no way to test if the socket is still registered or actually registered at all. This commit adds a new function osmo_fd_register_check() that can be used to check in advance, if the socket fd is registered, before performing further operations. Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 --- M include/osmocom/core/select.h M src/select.c 2 files changed, 26 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/1725/2 diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index 2753637..c2b51a4 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -1,6 +1,7 @@ #pragma once #include +#include /*! \defgroup select Select loop abstraction * @{ @@ -35,6 +36,7 @@ unsigned int priv_nr; }; +bool osmo_fd_is_registered(struct osmo_fd *fd); int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); diff --git a/src/select.c b/src/select.c index da27368..ab0734e 100644 --- a/src/select.c +++ b/src/select.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,23 @@ static int maxfd = 0; static LLIST_HEAD(osmo_fds); static int unregistered_count; + + +/*! \brief Check if a file descriptor is already registered + * \param[in] fd osmocom file descriptor to be checked + * \returns true if registered; otherwise false + */ +bool osmo_fd_is_registered(struct osmo_fd *fd) +{ + struct osmo_fd *entry; + llist_for_each_entry(entry, &osmo_fds, list) { + if (entry == fd) { + return true; + } + } + + return false; +} /*! \brief Register a new file descriptor with select loop abstraction * \param[in] fd osmocom file descriptor to be registered @@ -76,12 +94,9 @@ maxfd = fd->fd; #ifdef BSC_FD_CHECK - struct osmo_fd *entry; - llist_for_each_entry(entry, &osmo_fds, list) { - if (entry == fd) { - fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); - return 0; - } + if (osmo_fd_is_registered(fd)) { + fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); + return 0; } #endif @@ -95,6 +110,9 @@ */ void osmo_fd_unregister(struct osmo_fd *fd) { + /* Note: when fd is inside the osmo_fds list (not registered before) + * this function will crash! If in doubt, check file descriptor with + * osmo_fd_is_registered() */ unregistered_count++; llist_del(&fd->list); } -- To view, visit https://gerrit.osmocom.org/1725 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 11:41:13 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Fri, 3 Feb 2017 11:41:13 +0000 Subject: [PATCH] libosmocore[master]: lapd_core: fix program flow In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1726 to look at the new patch set (#3). lapd_core: fix program flow when the lapd core is in state LAPD_STATE_SABM_SENT, and the retransmission counter exceeds (link down) lapd_t200_cb() will send an RELASE_INDICATION and an MDL_ERROR_INDICATION to L3. This action is done before the state is processed. This seems to be no problem with standard retransmission counts (n200), but may cause timing problems that lead to deadlock states when custom timer configurations are in use. (Ericsson RBS). This commit moves the functions calls for sending the indications mentioned above to the very end of the if branch to relax the timing again. (See lapd_t200_cb()) Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a --- M src/gsm/lapd_core.c 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/1726/3 diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 84b1828..5af82aa 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -556,11 +556,6 @@ case LAPD_STATE_SABM_SENT: /* 5.4.1.3 */ if (dl->retrans_ctr + 1 >= dl->n200_est_rel + 1) { - /* send RELEASE INDICATION to L3 */ - send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, - &dl->lctx); - /* send MDL ERROR INIDCATION to L3 */ - mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); @@ -569,6 +564,11 @@ /* NOTE: we must not change any other states or buffers * and queues, since we may reconnect after handover * failure. the buffered messages is replaced there */ + /* send RELEASE INDICATION to L3 */ + send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, + &dl->lctx); + /* send MDL ERROR INIDCATION to L3 */ + mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); break; } /* retransmit SABM command */ -- To view, visit https://gerrit.osmocom.org/1726 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 11:41:13 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Fri, 3 Feb 2017 11:41:13 +0000 Subject: [PATCH] libosmocore[master]: lapd_core: Fix MDL-ERROR ind after RELEASE ind In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1727 to look at the new patch set (#3). lapd_core: Fix MDL-ERROR ind after RELEASE ind in lapd_t200_cb() The RELEASE INDICATION is transmitted before the MDL ERROR INIDCATION, this prevents the MDL ERROR INDICATION from being sent because the RELASE INDICATION close to connection eraly. This commit puts the messages into the correct order. Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 --- M src/gsm/lapd_core.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/1727/3 diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 5af82aa..5ee88a4 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -564,11 +564,11 @@ /* NOTE: we must not change any other states or buffers * and queues, since we may reconnect after handover * failure. the buffered messages is replaced there */ + /* send MDL ERROR INIDCATION to L3 */ + mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); /* send RELEASE INDICATION to L3 */ send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, &dl->lctx); - /* send MDL ERROR INIDCATION to L3 */ - mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); break; } /* retransmit SABM command */ @@ -581,10 +581,10 @@ case LAPD_STATE_DISC_SENT: /* 5.4.4.3 */ if (dl->retrans_ctr + 1 >= dl->n200_est_rel + 1) { - /* send RELEASE INDICATION to L3 */ - send_dl_simple(PRIM_DL_REL, PRIM_OP_CONFIRM, &dl->lctx); /* send MDL ERROR INIDCATION to L3 */ mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); + /* send RELEASE INDICATION to L3 */ + send_dl_simple(PRIM_DL_REL, PRIM_OP_CONFIRM, &dl->lctx); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); -- To view, visit https://gerrit.osmocom.org/1727 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 15:11:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 15:11:13 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error Message-ID: Review at https://gerrit.osmocom.org/1741 vty tests: more attempts to resolve 'Broken Pipe' error Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 --- M openbsc/tests/vty_test_runner.py 1 file changed, 17 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/41/1741/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..3f6e3df 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -781,10 +781,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1256,11 +1256,13 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1271,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,16 +1285,22 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() ipa_handle_small(bsc, verbose) return bsc -- To view, visit https://gerrit.osmocom.org/1741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 15:49:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 15:49:17 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1741 to look at the new patch set (#2). vty tests: more attempts to resolve 'Broken Pipe' error Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 --- M openbsc/tests/vty_test_runner.py 1 file changed, 34 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/41/1741/2 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..d57d770 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -781,10 +781,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1237,6 +1237,15 @@ " connected yet: %r %r" % (ip, port)) return conn +def cmd(what): + print '\n> %s' % what + subprocess.call(what, shell=True) + print '' + +def checkxxx(): + cmd('cat /proc/net/tcp'); + cmd('ps xua | grep osmo'); + def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1256,11 +1265,15 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1282,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,17 +1296,29 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + checkxxx() + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() ipa_handle_small(bsc, verbose) + checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 15:56:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 15:56:47 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1741 to look at the new patch set (#3). vty tests: more attempts to resolve 'Broken Pipe' error Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 --- M openbsc/tests/vty_test_runner.py 1 file changed, 35 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/41/1741/3 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..db8c09c 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -19,6 +19,7 @@ import time import unittest import socket +import subprocess import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil @@ -781,10 +782,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1237,6 +1238,15 @@ " connected yet: %r %r" % (ip, port)) return conn +def cmd(what): + print '\n> %s' % what + subprocess.call(what, shell=True) + print '' + +def checkxxx(): + cmd('cat /proc/net/tcp'); + cmd('ps xua | grep osmo'); + def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1256,11 +1266,15 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1283,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,17 +1297,29 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + checkxxx() + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() ipa_handle_small(bsc, verbose) + checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 16:05:20 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Fri, 3 Feb 2017 16:05:20 +0000 Subject: [PATCH] openbsc[master]: om2000: add VTY command to delete CON groups Message-ID: Review at https://gerrit.osmocom.org/1742 om2000: add VTY command to delete CON groups The currently unused function abis_om2000_vty.c:con_group_del() allows deleting OM 2000 connection groups. This commit adds a matching VTY command to make use of it. Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80 --- M openbsc/src/libbsc/abis_om2000_vty.c 1 file changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/42/1742/1 diff --git a/openbsc/src/libbsc/abis_om2000_vty.c b/openbsc/src/libbsc/abis_om2000_vty.c index adad479..060fb8b 100644 --- a/openbsc/src/libbsc/abis_om2000_vty.c +++ b/openbsc/src/libbsc/abis_om2000_vty.c @@ -342,6 +342,31 @@ return CMD_SUCCESS; } +DEFUN(del_om2k_con_group, del_om2k_con_group_cmd, + "del-connection-group <1-31>", + "Delete a CON (Concentrator) Connection Group\n" + "CON Connection Group Number\n") +{ + struct gsm_bts *bts = vty->index; + int rc; + uint8_t cgid = atoi(argv[0]); + + if (bts->type != GSM_BTS_TYPE_RBS2000) { + vty_out(vty, "%% CON MO only exists in RBS2000%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + rc = con_group_del(bts, cgid); + if (rc != 0) { + vty_out(vty, "%% Cannot delete CON Group%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + #define CON_PATH_HELP "CON Path (In/Out)\n" \ "Add CON Path to Concentration Group\n" \ "Delete CON Path from Concentration Group\n" \ @@ -551,6 +576,7 @@ install_element(BTS_NODE, &cfg_bts_is_conn_list_cmd); install_element(BTS_NODE, &cfg_om2k_con_group_cmd); + install_element(BTS_NODE, &del_om2k_con_group_cmd); return 0; } -- To view, visit https://gerrit.osmocom.org/1742 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Fri Feb 3 16:08:40 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 16:08:40 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1741 to look at the new patch set (#4). vty tests: more attempts to resolve 'Broken Pipe' error Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 --- M openbsc/tests/vty_test_runner.py 1 file changed, 39 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/41/1741/4 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..f434360 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -19,6 +19,7 @@ import time import unittest import socket +import subprocess import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil @@ -781,10 +782,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1237,6 +1238,19 @@ " connected yet: %r %r" % (ip, port)) return conn +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def checkxxx(): + cmd('cat /proc/net/tcp'); + cmd('ps xua | grep osmo'); + def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1256,11 +1270,15 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1287,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,17 +1301,29 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + checkxxx() + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() ipa_handle_small(bsc, verbose) + checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 16:23:39 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 16:23:39 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (2) Message-ID: Review at https://gerrit.osmocom.org/1743 vty tests: more attempts to resolve 'Broken Pipe' error (2) Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda --- M openbsc/tests/vty_test_runner.py 1 file changed, 39 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/43/1743/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..f434360 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -19,6 +19,7 @@ import time import unittest import socket +import subprocess import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil @@ -781,10 +782,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1237,6 +1238,19 @@ " connected yet: %r %r" % (ip, port)) return conn +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def checkxxx(): + cmd('cat /proc/net/tcp'); + cmd('ps xua | grep osmo'); + def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1256,11 +1270,15 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1287,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,17 +1301,29 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + checkxxx() + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() ipa_handle_small(bsc, verbose) + checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1743 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 16:23:48 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 16:23:48 +0000 Subject: [PATCH] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (3) Message-ID: Review at https://gerrit.osmocom.org/1744 vty tests: more attempts to resolve 'Broken Pipe' error (3) Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c --- M openbsc/tests/vty_test_runner.py 1 file changed, 39 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/44/1744/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..f434360 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -19,6 +19,7 @@ import time import unittest import socket +import subprocess import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil @@ -781,10 +782,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1237,6 +1238,19 @@ " connected yet: %r %r" % (ip, port)) return conn +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def checkxxx(): + cmd('cat /proc/net/tcp'); + cmd('ps xua | grep osmo'); + def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1256,11 +1270,15 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1287,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,17 +1301,29 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + checkxxx() + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() ipa_handle_small(bsc, verbose) + checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1744 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 17:40:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 17:40:27 +0000 Subject: [PATCH] libosmocore[master]: osmo-auc-gen: cosmetic: clarify output upon AUTS In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1734 to look at the new patch set (#2). osmo-auc-gen: cosmetic: clarify output upon AUTS When calculating a re-sync vector using AUTS, osmo-gen-vec used to print SQN.MS + 2, the new SQN after vector generation, labeled 'SEQ.MS'. Firstly, s/SEQ/SQN. Secondly, print SQN.MS as umts.sqn - 2, which is the actual SQN recovered from the AUTS. As explained in the comment, SQN.MS + 1 is used to generate the vector, and then umts.sqn is increased a second time to indicate the next SQN. With AUTS calculated from SQN.MS == 23, the output was: AUTS success: SEQ.MS = 25 Output now: AUTS success: SQN.MS = 23, generated vector with SQN = 24, next SQN = 25 Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e --- M utils/osmo-auc-gen.c 1 file changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/1734/2 diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 4c3e891..872d6f3 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -251,8 +251,21 @@ else dump_auth_vec(vec); + /* Print SQN from AUTS. It makes sense to print actually three SQN + * to clarify: + * After recovering SQN.MS from AUTS, milenage_gen_vec_auts() does: + * aud->u.umts.sqn = 1 + (osmo_load64be_ext(sqn_out, 6) >> 16); + * Then calls milenage_gen_vec(), which, after it is done, does: + * aud->u.umts.sqn++; + */ if (auts_is_set) - printf("AUTS success: SEQ.MS = %" PRIu64 "\n", test_aud.u.umts.sqn); + printf("AUTS success: SQN.MS = %" PRIu64 + ", generated vector with SQN = %" PRIu64 + ", next SQN = %" PRIu64 "\n", + test_aud.u.umts.sqn - 2, + test_aud.u.umts.sqn - 1, + test_aud.u.umts.sqn + ); exit(0); } -- To view, visit https://gerrit.osmocom.org/1734 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 17:40:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 3 Feb 2017 17:40:27 +0000 Subject: [PATCH] libosmocore[master]: osmo-auc-gen: cmdline help: list algorithms; error messages Message-ID: Review at https://gerrit.osmocom.org/1745 osmo-auc-gen: cmdline help: list algorithms; error messages In the -h help output, list the names of available algorithms. In case of option parsing failure, also print help() (so that e.g. for a typo in the algorithm, the list of algorithms is printed along with the error message). If there are -2/-3 or -a missing, show an error message that explains this. Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886 --- M utils/osmo-auc-gen.c 1 file changed, 10 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/1745/1 diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 872d6f3..f0cfa79 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -70,6 +70,7 @@ static void help() { + int alg; printf( "-2 --2g\tUse 2G (GSM) authentication\n" "-3 --3g\tUse 3G (UMTS) authentication\n" "-a --algorithm\tSpecify name of the algorithm\n" @@ -81,6 +82,11 @@ "-A --auts\tSpecify AUTS (only for 3G)\n" "-r --rand\tSpecify random value\n" "-I --ipsec\tOutput in triplets.dat format for strongswan\n"); + + fprintf(stderr, "\nAvailable algorithms for option -a:\n"); + for (alg = 1; alg < _OSMO_AUTH_ALG_NUM; alg++) + fprintf(stderr, " %s\n", + osmo_auth_alg_name(alg)); } int main(int argc, char **argv) @@ -209,7 +215,8 @@ } if (rc < 0) { - fprintf(stderr, "Error parsing argument of option `%c'\n", c); + help(); + fprintf(stderr, "\nError parsing argument of option `%c'\n", c); exit(2); } } @@ -229,6 +236,8 @@ if (test_aud.type == OSMO_AUTH_TYPE_NONE || test_aud.algo == OSMO_AUTH_ALG_NONE) { help(); + fprintf(stderr, "\nError: you need to pass at least" + " -2 or -3, as well as an algorithm to use.\n"); exit(2); } -- To view, visit https://gerrit.osmocom.org/1745 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 3 18:08:05 2017 From: gerrit-no-reply at lists.osmocom.org (ikostov) Date: Fri, 3 Feb 2017 18:08:05 +0000 Subject: [PATCH] osmo-gsm-manuals[master]: GSUP, OAP: fix AUTS length to 14, not 16 Message-ID: Review at https://gerrit.osmocom.org/1746 GSUP, OAP: fix AUTS length to 14, not 16 https://gerrit.osmocom.org/1731 Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 --- M OsmoSGSN/chapters/gsup.adoc M common/chapters/oap.adoc 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/46/1746/1 diff --git a/OsmoSGSN/chapters/gsup.adoc b/OsmoSGSN/chapters/gsup.adoc index 2a9563b..45c0e1d 100644 --- a/OsmoSGSN/chapters/gsup.adoc +++ b/OsmoSGSN/chapters/gsup.adoc @@ -616,7 +616,7 @@ [[gsup-ie-auts]] ==== AUTS -The 16-byte Authentication Synchronization Nonce generated by the USIM +The 14-byte Authentication Synchronization Nonce generated by the USIM in case the UMTS Authentication and Key Agreement Algorithm needs to re-synchronize the sequence counters between AUC and USIM. diff --git a/common/chapters/oap.adoc b/common/chapters/oap.adoc index 544da81..596aa11 100644 --- a/common/chapters/oap.adoc +++ b/common/chapters/oap.adoc @@ -191,7 +191,7 @@ |=== |IEI|IE|Type|Presence|Format|Length | |Message Type|<>|M|V|1 -|20|AUTS|octet string (16)|TLV|18 +|20|AUTS|octet string (14)|TLV|18 |=== ==== Sync Error -- To view, visit https://gerrit.osmocom.org/1746 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov From gerrit-no-reply at lists.osmocom.org Fri Feb 3 19:53:22 2017 From: gerrit-no-reply at lists.osmocom.org (jfdionne) Date: Fri, 3 Feb 2017 19:53:22 +0000 Subject: [PATCH] osmo-bts[master]: Fix SACCH channel release indication not sent to BSC after l... Message-ID: Review at https://gerrit.osmocom.org/1747 Fix SACCH channel release indication not sent to BSC after location update. Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/47/1747/1 diff --git a/src/common/rsl.c b/src/common/rsl.c index 74d835f..5c4e4ff 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -2284,7 +2284,8 @@ gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); /* REL_IND handling */ - if (rh->msg_type == RSL_MT_REL_IND) { + if (rh->msg_type == RSL_MT_REL_IND && + (lchan->type == GSM_LCHAN_TCH_F || lchan->type == GSM_LCHAN_TCH_H)) { LOGP(DRSL, LOGL_INFO, "%s Scheduling %s to L3 in next associated TCH-RTS.ind\n", gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); -- To view, visit https://gerrit.osmocom.org/1747 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:38:29 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:38:29 +0000 Subject: osmo-bts[master]: Fix SACCH channel release indication not sent to BSC after l... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 I'm sorry, once again the commit log needs more description about te problem it fixes. -- To view, visit https://gerrit.osmocom.org/1747 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:38:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:38:42 +0000 Subject: osmo-gsm-manuals[master]: GSUP, OAP: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1746 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:39:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:39:12 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (3) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1744 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:39:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:39:21 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (2) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1743 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:40:31 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:40:31 +0000 Subject: openbsc[master]: gsm_04_08: implement parsing of UMTS Auth responses In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1733 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:41:11 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:41:11 +0000 Subject: libosmocore[master]: osmo_auth*: fix ordering of function args In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1737 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:41:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:41:36 +0000 Subject: osmo-hlr[master]: UMTS AKA resync: fix argument ordering In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1739 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6aa19004ec27bad5e9c2bf688d9bbc55d697ccb0 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:42:31 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:42:31 +0000 Subject: libosmocore[master]: select: add functionality to check socket state In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1725 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:42:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:42:47 +0000 Subject: openbsc[master]: om2000: add VTY command to delete CON groups In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1742 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:43:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:43:20 +0000 Subject: [MERGED] openbsc[master]: om2000: add VTY command to delete CON groups In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: om2000: add VTY command to delete CON groups ...................................................................... om2000: add VTY command to delete CON groups The currently unused function abis_om2000_vty.c:con_group_del() allows deleting OM 2000 connection groups. This commit adds a matching VTY command to make use of it. Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80 --- M openbsc/src/libbsc/abis_om2000_vty.c 1 file changed, 26 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libbsc/abis_om2000_vty.c b/openbsc/src/libbsc/abis_om2000_vty.c index adad479..060fb8b 100644 --- a/openbsc/src/libbsc/abis_om2000_vty.c +++ b/openbsc/src/libbsc/abis_om2000_vty.c @@ -342,6 +342,31 @@ return CMD_SUCCESS; } +DEFUN(del_om2k_con_group, del_om2k_con_group_cmd, + "del-connection-group <1-31>", + "Delete a CON (Concentrator) Connection Group\n" + "CON Connection Group Number\n") +{ + struct gsm_bts *bts = vty->index; + int rc; + uint8_t cgid = atoi(argv[0]); + + if (bts->type != GSM_BTS_TYPE_RBS2000) { + vty_out(vty, "%% CON MO only exists in RBS2000%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + rc = con_group_del(bts, cgid); + if (rc != 0) { + vty_out(vty, "%% Cannot delete CON Group%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + #define CON_PATH_HELP "CON Path (In/Out)\n" \ "Add CON Path to Concentration Group\n" \ "Delete CON Path from Concentration Group\n" \ @@ -551,6 +576,7 @@ install_element(BTS_NODE, &cfg_bts_is_conn_list_cmd); install_element(BTS_NODE, &cfg_om2k_con_group_cmd); + install_element(BTS_NODE, &del_om2k_con_group_cmd); return 0; } -- To view, visit https://gerrit.osmocom.org/1742 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 3 21:43:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 3 Feb 2017 21:43:38 +0000 Subject: [MERGED] libosmocore[master]: lapd_core: Improve debug output In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: lapd_core: Improve debug output ...................................................................... lapd_core: Improve debug output The debug output of lapd core has no references to the dl objects, since we have multiple links, seeing which action is for which object is impossible. This commit adds pointer references (dl=%p) to each log line. Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda --- M src/gsm/lapd_core.c 1 file changed, 190 insertions(+), 144 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index bf5c388..84b1828 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -197,7 +197,7 @@ { if (osmo_timer_pending(&dl->t200)) return; - LOGP(DLLAPD, LOGL_INFO, "start T200\n"); + LOGP(DLLAPD, LOGL_INFO, "start T200 (dl=%p)\n", dl); osmo_timer_schedule(&dl->t200, dl->t200_sec, dl->t200_usec); } @@ -205,7 +205,7 @@ { if (osmo_timer_pending(&dl->t203)) return; - LOGP(DLLAPD, LOGL_INFO, "start T203\n"); + LOGP(DLLAPD, LOGL_INFO, "start T203 (dl=%p)\n", dl); osmo_timer_schedule(&dl->t203, dl->t203_sec, dl->t203_usec); } @@ -213,7 +213,7 @@ { if (!osmo_timer_pending(&dl->t200)) return; - LOGP(DLLAPD, LOGL_INFO, "stop T200\n"); + LOGP(DLLAPD, LOGL_INFO, "stop T200 (dl=%p)\n", dl); osmo_timer_del(&dl->t200); } @@ -221,14 +221,14 @@ { if (!osmo_timer_pending(&dl->t203)) return; - LOGP(DLLAPD, LOGL_INFO, "stop T203\n"); + LOGP(DLLAPD, LOGL_INFO, "stop T203 (dl=%p)\n", dl); osmo_timer_del(&dl->t203); } static void lapd_dl_newstate(struct lapd_datalink *dl, uint32_t state) { - LOGP(DLLAPD, LOGL_INFO, "new state %s -> %s\n", - lapd_state_names[dl->state], lapd_state_names[state]); + LOGP(DLLAPD, LOGL_INFO, "new state %s -> %s (dl=%p)\n", + lapd_state_names[dl->state], lapd_state_names[state], dl); if (state != LAPD_STATE_MF_EST && dl->state == LAPD_STATE_MF_EST) { /* stop T203 on leaving MF EST state, if running */ @@ -289,7 +289,8 @@ } LOGP(DLLAPD, LOGL_INFO, "Init DL layer: sequence range = %d, k = %d, " - "history range = %d\n", dl->v_range, dl->k, dl->range_hist); + "history range = %d (dl=%p)\n", dl->v_range, dl->k, + dl->range_hist, dl); lapd_dl_newstate(dl, LAPD_STATE_IDLE); @@ -304,7 +305,7 @@ { if (dl->state == LAPD_STATE_IDLE) return; - LOGP(DLLAPD, LOGL_INFO, "Resetting LAPDm instance\n"); + LOGP(DLLAPD, LOGL_INFO, "Resetting LAPDm instance (dl=%p)\n", dl); /* enter idle state (and remove eventual cont_res) */ lapd_dl_newstate(dl, LAPD_STATE_IDLE); /* flush buffer */ @@ -378,8 +379,9 @@ struct lapd_datalink *dl = lctx->dl; struct osmo_dlsap_prim dp; - LOGP(DLLAPD, LOGL_NOTICE, "sending MDL-ERROR-IND cause %s\n", - rsl_rlm_cause_name(cause)); + LOGP(DLLAPD, LOGL_NOTICE, + "sending MDL-ERROR-IND cause %d from state %s (dl=%p)\n", + cause, lapd_state_names[dl->state], dl); osmo_prim_init(&dp.oph, 0, PRIM_MDL_ERROR, PRIM_OP_INDICATION, NULL); dp.u.error_ind.cause = cause; return dl->send_dlsap(&dp, lctx); @@ -534,6 +536,8 @@ struct osmo_dlsap_prim dp; struct msgb *msg; + LOGP(DLLAPD, LOGL_DEBUG, "lapd reestablish (dl=%p)\n", dl); + msg = lapd_msgb_alloc(0, "DUMMY"); osmo_prim_init(&dp.oph, 0, PRIM_DL_EST, PRIM_OP_REQUEST, msg); @@ -545,8 +549,8 @@ { struct lapd_datalink *dl = data; - LOGP(DLLAPD, LOGL_INFO, "Timeout T200 (%p) state=%d\n", dl, - (int) dl->state); + LOGP(DLLAPD, LOGL_INFO, "Timeout T200 state=%s (dl=%p)\n", + lapd_state_names[dl->state], dl); switch (dl->state) { case LAPD_STATE_SABM_SENT: @@ -615,7 +619,7 @@ struct lapd_msg_ctx nctx; LOGP(DLLAPD, LOGL_INFO, "retransmit last frame" - " V(S)=%d\n", vs); + " V(S)=%d (dl=%p)\n", vs, dl); /* Create I frame (segment) from tx_hist */ memcpy(&nctx, &dl->lctx, sizeof(nctx)); /* keep nctx.ldp */ @@ -647,7 +651,7 @@ lapd_send_rnr(&dl->lctx, 1, 1); } else { LOGP(DLLAPD, LOGL_INFO, "unhandled, " - "pls. fix\n"); + "pls. fix (dl=%p)\n", dl); } } /* restart T200 (PH-READY-TO-SEND) */ @@ -659,13 +663,13 @@ if (!dl->reestablish) break; LOGP(DLLAPD, LOGL_NOTICE, "N200 reached, performing " - "reestablishment.\n"); + "reestablishment. (dl=%p)\n", dl); lapd_reestablish(dl); } break; default: LOGP(DLLAPD, LOGL_INFO, "T200 expired in unexpected " - "dl->state %d\n", (int) dl->state); + "dl->state %s (dl=%p)\n", lapd_state_names[dl->state], dl); } } @@ -674,12 +678,12 @@ { struct lapd_datalink *dl = data; - LOGP(DLLAPD, LOGL_INFO, "Timeout T203 (%p) state=%d\n", dl, - (int) dl->state); + LOGP(DLLAPD, LOGL_INFO, "Timeout T203 state=%s (dl=%p)\n", + lapd_state_names[dl->state], dl); if (dl->state != LAPD_STATE_MF_EST) { LOGP(DLLAPD, LOGL_ERROR, "T203 fired outside MF EST state, " - "please fix!\n"); + "please fix! (dl=%p)\n", dl); return; } @@ -689,11 +693,13 @@ lapd_dl_newstate(dl, LAPD_STATE_TIMER_RECOV); /* transmit a supervisory command with P bit set to 1 as follows: */ if (!dl->own_busy) { - LOGP(DLLAPD, LOGL_INFO, "transmit an RR poll command\n"); + LOGP(DLLAPD, LOGL_INFO, + "transmit an RR poll command (dl=%p)\n", dl); /* Send RR with P=1 */ lapd_send_rr(&dl->lctx, 1, 1); } else { - LOGP(DLLAPD, LOGL_INFO, "transmit an RNR poll command\n"); + LOGP(DLLAPD, LOGL_INFO, + "transmit an RNR poll command (dl=%p)\n", dl); /* Send RNR with P=1 */ lapd_send_rnr(&dl->lctx, 1, 1); } @@ -743,7 +749,7 @@ */ if (sub_mod(nr, dl->v_ack, dl->v_range) > sub_mod(dl->v_send, dl->v_ack, dl->v_range)) { - LOGP(DLLAPD, LOGL_NOTICE, "N(R) sequence error\n"); + LOGP(DLLAPD, LOGL_NOTICE, "N(R) sequence error (dl=%p)\n", dl); mdl_error(MDL_CAUSE_SEQ_ERR, lctx); } } @@ -756,7 +762,7 @@ if (t200_reset && !rej) { if (dl->tx_hist[sub_mod(dl->v_send, 1, dl->range_hist)].msg) { LOGP(DLLAPD, LOGL_INFO, "start T200, due to unacked I " - "frame(s)\n"); + "frame(s) (dl=%p)\n", dl); lapd_start_t200(dl); } } @@ -789,13 +795,14 @@ prim = PRIM_DL_EST; op = PRIM_OP_INDICATION; - LOGP(DLLAPD, LOGL_INFO, "SABM(E) received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "SABM(E) received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.7.1 */ dl->seq_err_cond = 0; /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { - LOGP(DLLAPD, LOGL_ERROR, "SABM response error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "SABM response error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -805,7 +812,8 @@ * set, AN MDL-ERROR-INDICATION is sent to MM. */ if (lctx->more || length > lctx->n201) { - LOGP(DLLAPD, LOGL_ERROR, "SABM too large error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "SABM too large error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; @@ -816,7 +824,7 @@ break; case LAPD_STATE_MF_EST: LOGP(DLLAPD, LOGL_INFO, "SABM command, multiple " - "frame established state\n"); + "frame established state (dl=%p)\n", dl); /* If link is lost on the remote side, we start over * and send DL-ESTABLISH indication again. */ /* Additionally, continue in case of content resoltion @@ -829,13 +837,13 @@ /* If no content resolution, this is a * re-establishment. */ LOGP(DLLAPD, LOGL_INFO, - "Remote reestablish\n"); + "Remote reestablish (dl=%p)\n", dl); break; } if (!dl->cont_res) { LOGP(DLLAPD, LOGL_INFO, "SABM command not " - "allowed in state %s\n", - lapd_state_names[dl->state]); + "allowed in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); mdl_error(MDL_CAUSE_SABM_MF, lctx); msgb_free(msg); return 0; @@ -848,8 +856,8 @@ if (memcmp(dl->cont_res->data, msg->data, length)) { LOGP(DLLAPD, LOGL_INFO, "Another SABM " - "with diffrent content - " - "ignoring!\n"); + "with diffrent content - " + "ignoring! (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -872,8 +880,8 @@ /* check for contention resoultion */ if (dl->tx_hist[0].msg && dl->tx_hist[0].msg->len) { LOGP(DLLAPD, LOGL_NOTICE, "SABM not allowed " - "during contention resolution (state %s)\n", - lapd_state_names[dl->state]); + "during contention resolution (state=%s, dl=%p)\n", + lapd_state_names[dl->state], dl); mdl_error(MDL_CAUSE_SABM_INFO_NOTALL, lctx); } lapd_send_ua(lctx, length, msg->l3h); @@ -899,7 +907,8 @@ dl->cont_res = lapd_msgb_alloc(length, "CONT RES"); memcpy(msgb_put(dl->cont_res, length), msg->l3h, length); - LOGP(DLLAPD, LOGL_NOTICE, "Store content res.\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Store content res. (dl=%p)\n", dl); } /* send notification to L3 */ if (length == 0) { @@ -913,11 +922,12 @@ } break; case LAPD_U_DM: - LOGP(DLLAPD, LOGL_INFO, "DM received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "DM received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.cmd) { - LOGP(DLLAPD, LOGL_ERROR, "DM command error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "DM command error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -935,12 +945,12 @@ case LAPD_STATE_MF_EST: if (lctx->p_f) { LOGP(DLLAPD, LOGL_INFO, "unsolicited DM " - "response\n"); + "response (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_DM_RESP, lctx); } else { LOGP(DLLAPD, LOGL_INFO, "unsolicited DM " "response, multiple frame established " - "state\n"); + "state (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_DM_RESP_MF, lctx); /* reestablish */ if (!dl->reestablish) { @@ -948,7 +958,7 @@ return 0; } LOGP(DLLAPD, LOGL_NOTICE, "Performing " - "reestablishment.\n"); + "reestablishment. (dl=%p)\n", dl); lapd_reestablish(dl); } msgb_free(msg); @@ -958,14 +968,14 @@ if (!lctx->p_f) { LOGP(DLLAPD, LOGL_INFO, "unsolicited DM " "response, multiple frame established " - "state\n"); + "state (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_DM_RESP_MF, lctx); msgb_free(msg); /* reestablish */ if (!dl->reestablish) return 0; LOGP(DLLAPD, LOGL_NOTICE, "Performing " - "reestablishment.\n"); + "reestablishment. (dl=%p)\n", dl); return lapd_reestablish(dl); } break; @@ -983,7 +993,7 @@ /* 5.4.5 all other frame types shall be discarded */ default: LOGP(DLLAPD, LOGL_INFO, "unsolicited DM response! " - "(discarding)\n"); + "(discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -995,11 +1005,11 @@ msgb_free(msg); break; case LAPD_U_UI: - LOGP(DLLAPD, LOGL_INFO, "UI received\n"); + LOGP(DLLAPD, LOGL_INFO, "UI received (dl=%p)\n", dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { LOGP(DLLAPD, LOGL_ERROR, "UI indicates response " - "error\n"); + "error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1010,8 +1020,8 @@ */ if (length > lctx->n201 || lctx->more) { LOGP(DLLAPD, LOGL_ERROR, "UI too large error " - "(%d > N201(%d) or M=%d)\n", length, - lctx->n201, lctx->more); + "(%d > N201(%d) or M=%d) (dl=%p)\n", length, + lctx->n201, lctx->more, dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; @@ -1022,7 +1032,8 @@ /* 5.3.3 UI frames received with the length indicator * set to "0" shall be ignored */ - LOGP(DLLAPD, LOGL_INFO, "length=0 (discarding)\n"); + LOGP(DLLAPD, LOGL_INFO, + "length=0 (discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -1034,8 +1045,8 @@ prim = PRIM_DL_REL; op = PRIM_OP_INDICATION; - LOGP(DLLAPD, LOGL_INFO, "DISC received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "DISC received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); @@ -1043,7 +1054,8 @@ dl->seq_err_cond = 0; /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { - LOGP(DLLAPD, LOGL_ERROR, "DISC response error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "DISC response error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1055,19 +1067,21 @@ * parameters" is sent to the mobile management entity. */ LOGP(DLLAPD, LOGL_ERROR, - "U frame iwth incorrect parameters "); + "U frame iwth incorrect parameters (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; } switch (dl->state) { case LAPD_STATE_IDLE: - LOGP(DLLAPD, LOGL_INFO, "DISC in idle state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in idle state (dl=%p)\n", dl); /* send DM with F=P */ msgb_free(msg); return lapd_send_dm(lctx); case LAPD_STATE_SABM_SENT: - LOGP(DLLAPD, LOGL_INFO, "DISC in SABM state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in SABM state (dl=%p)\n", dl); /* 5.4.6.2 send DM with F=P */ lapd_send_dm(lctx); /* stop Timer T200 */ @@ -1079,10 +1093,12 @@ lctx); case LAPD_STATE_MF_EST: case LAPD_STATE_TIMER_RECOV: - LOGP(DLLAPD, LOGL_INFO, "DISC in est state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in est state (dl=%p)\n", dl); break; case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_INFO, "DISC in disc state\n"); + LOGP(DLLAPD, LOGL_INFO, + "DISC in disc state (dl=%p)\n", dl); prim = PRIM_DL_REL; op = PRIM_OP_CONFIRM; break; @@ -1102,12 +1118,12 @@ msgb_free(msg); break; case LAPD_U_UA: - LOGP(DLLAPD, LOGL_INFO, "UA received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "UA received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.cmd) { LOGP(DLLAPD, LOGL_ERROR, "UA indicates command " - "error\n"); + "error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1117,7 +1133,8 @@ * set, AN MDL-ERROR-INDICATION is sent to MM. */ if (lctx->more || length > lctx->n201) { - LOGP(DLLAPD, LOGL_ERROR, "UA too large error\n"); + LOGP(DLLAPD, LOGL_ERROR, + "UA too large error (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_UFRM_INC_PARAM, lctx); return -EIO; @@ -1127,7 +1144,8 @@ /* 5.4.1.2 A UA response with the F bit set to "0" * shall be ignored. */ - LOGP(DLLAPD, LOGL_INFO, "F=0 (discarding)\n"); + LOGP(DLLAPD, LOGL_INFO, + "F=0 (discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -1137,12 +1155,13 @@ case LAPD_STATE_MF_EST: case LAPD_STATE_TIMER_RECOV: LOGP(DLLAPD, LOGL_INFO, "unsolicited UA response! " - "(discarding)\n"); + "(discarding) (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_UA_RESP, lctx); msgb_free(msg); return 0; case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_INFO, "UA in disconnect state\n"); + LOGP(DLLAPD, LOGL_INFO, + "UA in disconnect state (dl=%p)\n", dl); /* stop Timer T200 */ lapd_stop_t200(dl); /* go to idle state */ @@ -1156,11 +1175,11 @@ /* 5.4.5 all other frame types shall be discarded */ default: LOGP(DLLAPD, LOGL_INFO, "unsolicited UA response! " - "(discarding)\n"); + "(discarding) (dl=%p)\n", dl); msgb_free(msg); return 0; } - LOGP(DLLAPD, LOGL_INFO, "UA in SABM state\n"); + LOGP(DLLAPD, LOGL_INFO, "UA in SABM state (dl=%p)\n", dl); /* stop Timer T200 */ lapd_stop_t200(dl); /* compare UA with SABME if contention resolution is applied */ @@ -1169,7 +1188,7 @@ || !!memcmp(dl->tx_hist[0].msg->data, msg->l3h, length)) { LOGP(DLLAPD, LOGL_INFO, "**** UA response " - "mismatches ****\n"); + "mismatches **** (dl=%p)\n", dl); rc = send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, lctx); msgb_free(msg); @@ -1193,19 +1212,22 @@ msgb_free(msg); break; case LAPD_U_FRMR: - LOGP(DLLAPD, LOGL_NOTICE, "Frame reject received\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Frame reject received (dl=%p)\n", dl); /* send MDL ERROR INIDCATION to L3 */ mdl_error(MDL_CAUSE_FRMR, lctx); msgb_free(msg); /* reestablish */ if (!dl->reestablish) break; - LOGP(DLLAPD, LOGL_NOTICE, "Performing reestablishment.\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Performing reestablishment. (dl=%p)\n", dl); rc = lapd_reestablish(dl); break; default: /* G.3.1 */ - LOGP(DLLAPD, LOGL_NOTICE, "Unnumbered frame not allowed.\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "Unnumbered frame not allowed. (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1225,7 +1247,7 @@ * primitive with cause "S frame with incorrect * parameters" is sent to the mobile management entity. */ LOGP(DLLAPD, LOGL_ERROR, - "S frame with incorrect parameters\n"); + "S frame with incorrect parameters (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_SFRM_INC_PARAM, lctx); return -EIO; @@ -1235,7 +1257,8 @@ && lctx->p_f && dl->state != LAPD_STATE_TIMER_RECOV) { /* 5.4.2.2: Inidcate error on supervisory reponse F=1 */ - LOGP(DLLAPD, LOGL_NOTICE, "S frame response with F=1 error\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "S frame response with F=1 error (dl=%p)\n", dl); mdl_error(MDL_CAUSE_UNSOL_SPRV_RESP, lctx); } @@ -1248,14 +1271,15 @@ /* fall though */ case LAPD_STATE_SABM_SENT: case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_NOTICE, "S frame ignored in this state\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "S frame ignored in this state (dl=%p)\n", dl); msgb_free(msg); return 0; } switch (lctx->s_u) { case LAPD_S_RR: - LOGP(DLLAPD, LOGL_INFO, "RR received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "RR received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.5.3.1: Acknowlege all tx frames up the the N(R)-1 */ lapd_acknowledge(lctx); @@ -1264,9 +1288,9 @@ && lctx->p_f) { if (!dl->own_busy && !dl->seq_err_cond) { LOGP(DLLAPD, LOGL_INFO, "RR frame command " - "with polling bit set and we are not " - "busy, so we reply with RR frame " - "response\n"); + "with polling bit set and we are not " + "busy, so we reply with RR frame " + "response (dl=%p)\n", dl); lapd_send_rr(lctx, 1, 0); /* NOTE: In case of sequence error condition, * the REJ frame has been transmitted when @@ -1275,8 +1299,9 @@ */ } else if (dl->own_busy) { LOGP(DLLAPD, LOGL_INFO, "RR frame command " - "with polling bit set and we are busy, " - "so we reply with RR frame response\n"); + "with polling bit set and we are busy, " + "so we reply with RR frame response (dl=%p)\n", + dl); lapd_send_rnr(lctx, 1, 0); } } else if (lctx->cr == dl->cr.rem2loc.resp @@ -1284,7 +1309,7 @@ && dl->state == LAPD_STATE_TIMER_RECOV) { LOGP(DLLAPD, LOGL_INFO, "RR response with F==1, " "and we are in timer recovery state, so " - "we leave that state\n"); + "we leave that state (dl=%p)\n", dl); /* V(S) to the N(R) in the RR frame */ dl->v_send = lctx->n_recv; /* stop Timer T200 */ @@ -1297,8 +1322,8 @@ break; case LAPD_S_RNR: - LOGP(DLLAPD, LOGL_INFO, "RNR received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "RNR received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.5.3.1: Acknowlege all tx frames up the the N(R)-1 */ lapd_acknowledge(lctx); @@ -1312,21 +1337,21 @@ LOGP(DLLAPD, LOGL_INFO, "RNR poll " "command and we are not busy, " "so we reply with RR final " - "response\n"); + "response (dl=%p)\n", dl); /* Send RR with F=1 */ lapd_send_rr(lctx, 1, 0); } else { LOGP(DLLAPD, LOGL_INFO, "RNR poll " "command and we are busy, so " "we reply with RNR final " - "response\n"); + "response (dl=%p)\n", dl); /* Send RNR with F=1 */ lapd_send_rnr(lctx, 1, 0); } } else if (dl->state == LAPD_STATE_TIMER_RECOV) { LOGP(DLLAPD, LOGL_INFO, "RNR poll response " "and we in timer recovery state, so " - "we leave that state\n"); + "we leave that state (dl=%p)\n", dl); /* 5.5.7 Clear timer recovery condition */ lapd_dl_newstate(dl, LAPD_STATE_MF_EST); /* V(S) to the N(R) in the RNR frame */ @@ -1334,15 +1359,15 @@ } } else LOGP(DLLAPD, LOGL_INFO, "RNR not polling/final state " - "received\n"); + "received (dl=%p)\n", dl); /* Send message, if possible due to acknowledged data */ lapd_send_i(lctx, __LINE__); break; case LAPD_S_REJ: - LOGP(DLLAPD, LOGL_INFO, "REJ received in state %s\n", - lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "REJ received in state %s (dl=%p)\n", + lapd_state_names[dl->state], dl); /* 5.5.3.1: Acknowlege all tx frames up the the N(R)-1 */ lapd_acknowledge(lctx); @@ -1362,7 +1387,7 @@ "state and not in own busy " "condition received, so we " "respond with RR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rr(lctx, 1, 0); /* NOTE: In case of sequence error * condition, the REJ frame has been @@ -1376,21 +1401,24 @@ "state and in own busy " "condition received, so we " "respond with RNR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rnr(lctx, 1, 0); } } else LOGP(DLLAPD, LOGL_INFO, "REJ response or not " "polling command not in timer recovery " - "state received\n"); + "state received (dl=%p)\n", dl); /* send MDL ERROR INIDCATION to L3 */ if (lctx->cr == dl->cr.rem2loc.resp && lctx->p_f) { + LOGP(DLLAPD, LOGL_ERROR, + "unsolicited supervisory response! (dl=%p)\n", + dl); mdl_error(MDL_CAUSE_UNSOL_SPRV_RESP, lctx); } } else if (lctx->cr == dl->cr.rem2loc.resp && lctx->p_f) { LOGP(DLLAPD, LOGL_INFO, "REJ poll response in timer " - "recovery state received\n"); + "recovery state received (dl=%p)\n", dl); /* Clear an existing peer receiver busy condition */ dl->peer_busy = 0; /* V(S) and V(A) to the N(R) in the REJ frame */ @@ -1412,7 +1440,7 @@ "state and not in own busy " "condition received, so we " "respond with RR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rr(lctx, 1, 0); /* NOTE: In case of sequence error * condition, the REJ frame has been @@ -1426,13 +1454,13 @@ "state and in own busy " "condition received, so we " "respond with RNR final " - "response\n"); + "response (dl=%p)\n", dl); lapd_send_rnr(lctx, 1, 0); } } else LOGP(DLLAPD, LOGL_INFO, "REJ response or not " "polling command in timer recovery " - "state received\n"); + "state received (dl=%p)\n", dl); } /* FIXME: 5.5.4.2 2) */ @@ -1443,7 +1471,8 @@ break; default: /* G.3.1 */ - LOGP(DLLAPD, LOGL_ERROR, "Supervisory frame not allowed.\n"); + LOGP(DLLAPD, LOGL_ERROR, + "Supervisory frame not allowed. (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1461,12 +1490,13 @@ int length = lctx->length; int rc; - LOGP(DLLAPD, LOGL_INFO, "I received in state %s on SAPI(%u)\n", - lapd_state_names[dl->state], lctx->sapi); + LOGP(DLLAPD, LOGL_INFO, "I received in state %s on SAPI(%u) (dl=%p)\n", + lapd_state_names[dl->state], lctx->sapi, dl); /* G.2.2 Wrong value of the C/R bit */ if (lctx->cr == dl->cr.rem2loc.resp) { - LOGP(DLLAPD, LOGL_ERROR, "I frame response not allowed\n"); + LOGP(DLLAPD, LOGL_ERROR, + "I frame response not allowed (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_FRM_UNIMPL, lctx); return -EINVAL; @@ -1477,7 +1507,8 @@ * to a numerical value L>N201 or L=0, an MDL-ERROR-INDICATION * primitive with cause "I frame with incorrect length" * is sent to the mobile management entity. */ - LOGP(DLLAPD, LOGL_ERROR, "I frame length not allowed\n"); + LOGP(DLLAPD, LOGL_ERROR, + "I frame length not allowed (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_IFRM_INC_LEN, lctx); return -EIO; @@ -1488,7 +1519,8 @@ * cause "I frame with incorrect use of M bit" is sent to the * mobile management entity. */ if (lctx->more && length < lctx->n201) { - LOGP(DLLAPD, LOGL_ERROR, "I frame with M bit too short\n"); + LOGP(DLLAPD, LOGL_ERROR, + "I frame with M bit too short (dl=%p)\n", dl); msgb_free(msg); mdl_error(MDL_CAUSE_IFRM_INC_MBITS, lctx); return -EIO; @@ -1503,7 +1535,8 @@ /* fall though */ case LAPD_STATE_SABM_SENT: case LAPD_STATE_DISC_SENT: - LOGP(DLLAPD, LOGL_NOTICE, "I frame ignored in this state\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "I frame ignored in this state (dl=%p)\n", dl); msgb_free(msg); return 0; } @@ -1511,7 +1544,7 @@ /* 5.7.1: N(s) sequence error */ if (ns != dl->v_recv) { LOGP(DLLAPD, LOGL_NOTICE, "N(S) sequence error: N(S)=%u, " - "V(R)=%u\n", ns, dl->v_recv); + "V(R)=%u (dl=%p)\n", ns, dl->v_recv, dl); /* discard data */ msgb_free(msg); if (dl->seq_err_cond != 1) { @@ -1545,7 +1578,8 @@ /* Increment receiver state */ dl->v_recv = inc_mod(dl->v_recv, dl->v_range); - LOGP(DLLAPD, LOGL_INFO, "incrementing V(R) to %u\n", dl->v_recv); + LOGP(DLLAPD, LOGL_INFO, "incrementing V(R) to %u (dl=%p)\n", + dl->v_recv, dl); /* 5.5.3.1: Acknowlege all transmitted frames up the the N(R)-1 */ lapd_acknowledge(lctx); /* V(A) is also set here */ @@ -1554,7 +1588,8 @@ if (!dl->own_busy) { /* if the frame carries a complete segment */ if (!lctx->more && !dl->rcv_buffer) { - LOGP(DLLAPD, LOGL_INFO, "message in single I frame\n"); + LOGP(DLLAPD, LOGL_INFO, + "message in single I frame (dl=%p)\n", dl); /* send a DATA INDICATION to L3 */ msgb_trim(msg, length); rc = send_dl_l3(PRIM_DL_DATA, PRIM_OP_INDICATION, lctx, @@ -1563,7 +1598,7 @@ /* create rcv_buffer */ if (!dl->rcv_buffer) { LOGP(DLLAPD, LOGL_INFO, "message in multiple " - "I frames (first message)\n"); + "I frames (first message) (dl=%p)\n", dl); dl->rcv_buffer = lapd_msgb_alloc(dl->maxf, "LAPD RX"); dl->rcv_buffer->l3h = dl->rcv_buffer->data; @@ -1571,7 +1606,7 @@ /* concat. rcv_buffer */ if (msgb_l3len(dl->rcv_buffer) + length > dl->maxf) { LOGP(DLLAPD, LOGL_NOTICE, "Received frame " - "overflow!\n"); + "overflow! (dl=%p)\n", dl); } else { memcpy(msgb_put(dl->rcv_buffer, length), msg->l3h, length); @@ -1579,14 +1614,14 @@ /* if the last segment was received */ if (!lctx->more) { LOGP(DLLAPD, LOGL_INFO, "message in multiple " - "I frames (last message)\n"); + "I frames (last message) (dl=%p)\n", dl); rc = send_dl_l3(PRIM_DL_DATA, PRIM_OP_INDICATION, lctx, dl->rcv_buffer); dl->rcv_buffer = NULL; } else LOGP(DLLAPD, LOGL_INFO, "message in multiple " - "I frames (next message)\n"); + "I frames (next message) (dl=%p)\n", dl); msgb_free(msg); } @@ -1599,11 +1634,13 @@ /* 5.5.2.1 */ /* check if we are not in own receiver busy */ if (!dl->own_busy) { - LOGP(DLLAPD, LOGL_INFO, "we are not busy, send RR\n"); + LOGP(DLLAPD, LOGL_INFO, + "we are not busy, send RR (dl=%p)\n", dl); /* Send RR with F=1 */ rc = lapd_send_rr(lctx, 1, 0); } else { - LOGP(DLLAPD, LOGL_INFO, "we are busy, send RNR\n"); + LOGP(DLLAPD, LOGL_INFO, + "we are busy, send RNR (dl=%p)\n", dl); /* Send RNR with F=1 */ rc = lapd_send_rnr(lctx, 1, 0); } @@ -1621,14 +1658,16 @@ if (rc) { LOGP(DLLAPD, LOGL_INFO, "we are not busy and " - "have no pending data, send RR\n"); + "have no pending data, send RR (dl=%p)\n", + dl); /* Send RR with F=0 */ return lapd_send_rr(lctx, 0, 0); } /* all I or one RR is sent, we are done */ return 0; } else { - LOGP(DLLAPD, LOGL_INFO, "we are busy, send RNR\n"); + LOGP(DLLAPD, LOGL_INFO, + "we are busy, send RNR (dl=%p)\n", dl); /* Send RNR with F=0 */ rc = lapd_send_rnr(lctx, 0, 0); } @@ -1656,7 +1695,8 @@ rc = lapd_rx_i(msg, lctx); break; default: - LOGP(DLLAPD, LOGL_NOTICE, "unknown LAPD format\n"); + LOGP(DLLAPD, LOGL_NOTICE, + "unknown LAPD format (dl=%p)\n", lctx->dl); msgb_free(msg); rc = -EINVAL; } @@ -1695,9 +1735,10 @@ if (msg->len) LOGP(DLLAPD, LOGL_INFO, "perform establishment with content " - "(SABM)\n"); + "(SABM) (dl=%p)\n", dl); else - LOGP(DLLAPD, LOGL_INFO, "perform normal establishm. (SABM)\n"); + LOGP(DLLAPD, LOGL_INFO, + "perform normal establishm. (SABM), (dl=%p)\n", dl); /* Flush send-queue */ /* Clear send-buffer */ @@ -1753,13 +1794,14 @@ if (msgb_l3len(msg) == 0) { LOGP(DLLAPD, LOGL_ERROR, - "writing an empty message is not possible.\n"); + "writing an empty message is not possible. (dl=%p)\n", dl); msgb_free(msg); return -1; } LOGP(DLLAPD, LOGL_INFO, - "writing message to send-queue: l3len: %d\n", msgb_l3len(msg)); + "writing message to send-queue: l3len: %d (dl=%p)\n", + msgb_l3len(msg), dl); /* Write data into the send queue */ msgb_enqueue(&dl->send_queue, msg); @@ -1782,17 +1824,19 @@ struct lapd_msg_ctx nctx; - LOGP(DLLAPD, LOGL_INFO, "%s() called from line %d\n", __func__, line); + LOGP(DLLAPD, LOGL_INFO, + "%s() called from line %d (dl=%p)\n", __func__, line, dl); next_frame: if (dl->peer_busy) { - LOGP(DLLAPD, LOGL_INFO, "peer busy, not sending\n"); + LOGP(DLLAPD, LOGL_INFO, "peer busy, not sending (dl=%p)\n", dl); return rc; } if (dl->state == LAPD_STATE_TIMER_RECOV) { - LOGP(DLLAPD, LOGL_INFO, "timer recovery, not sending\n"); + LOGP(DLLAPD, LOGL_INFO, + "timer recovery, not sending (dl=%p)\n", dl); return rc; } @@ -1804,8 +1848,8 @@ * 5.5.7. */ if (dl->v_send == add_mod(dl->v_ack, k, dl->v_range)) { LOGP(DLLAPD, LOGL_INFO, "k frames outstanding, not sending " - "more (k=%u V(S)=%u V(A)=%u)\n", k, dl->v_send, - dl->v_ack); + "more (k=%u V(S)=%u V(A)=%u) (dl=%p)\n", k, dl->v_send, + dl->v_ack, dl); return rc; } @@ -1822,7 +1866,7 @@ if (!dl->send_buffer) return rc; LOGP(DLLAPD, LOGL_INFO, "get message from " - "send-queue\n"); + "send-queue (dl=%p)\n", dl); } /* How much is left in the send-buffer? */ @@ -1832,9 +1876,9 @@ if (length > lctx->n201) length = lctx->n201; LOGP(DLLAPD, LOGL_INFO, "msg-len %d sent %d left %d N201 %d " - "length %d first byte %02x\n", + "length %d first byte %02x (dl=%p)\n", msgb_l3len(dl->send_buffer), dl->send_out, left, - lctx->n201, length, dl->send_buffer->l3h[0]); + lctx->n201, length, dl->send_buffer->l3h[0], dl); /* If message in send-buffer is completely sent */ if (left == 0) { msgb_free(dl->send_buffer); @@ -1842,8 +1886,8 @@ goto next_message; } - LOGP(DLLAPD, LOGL_INFO, "send I frame %sV(S)=%d\n", - (left > length) ? "segment " : "", dl->v_send); + LOGP(DLLAPD, LOGL_INFO, "send I frame %sV(S)=%d (dl=%p)\n", + (left > length) ? "segment " : "", dl->v_send, dl); /* Create I frame (segment) and transmit-buffer content */ msg = lapd_msgb_alloc(length, "LAPD I"); @@ -1876,7 +1920,7 @@ dl->send_out += length; } else { LOGP(DLLAPD, LOGL_INFO, "resend I frame from tx buffer " - "V(S)=%d\n", dl->v_send); + "V(S)=%d (dl=%p)\n", dl->v_send, dl); /* Create I frame (segment) from tx_hist */ length = dl->tx_hist[h].msg->len; @@ -1924,16 +1968,16 @@ struct lapd_datalink *dl = lctx->dl; struct msgb *msg = dp->oph.msg; - LOGP(DLLAPD, LOGL_INFO, "perform suspension\n"); + LOGP(DLLAPD, LOGL_INFO, "perform suspension (dl=%p)\n", dl); /* put back the send-buffer to the send-queue (first position) */ if (dl->send_buffer) { LOGP(DLLAPD, LOGL_INFO, "put frame in sendbuffer back to " - "queue\n"); + "queue (dl=%p)\n", dl); llist_add(&dl->send_buffer->list, &dl->send_queue); dl->send_buffer = NULL; } else - LOGP(DLLAPD, LOGL_INFO, "no frame in sendbuffer\n"); + LOGP(DLLAPD, LOGL_INFO, "no frame in sendbuffer (dl=%p)\n", dl); /* Clear transmit buffer, but keep send buffer */ lapd_dl_flush_tx(dl); @@ -1953,8 +1997,9 @@ struct msgb *msg = dp->oph.msg; struct lapd_msg_ctx nctx; - LOGP(DLLAPD, LOGL_INFO, "perform re-establishment (SABM) length=%d\n", - msg->len); + LOGP(DLLAPD, LOGL_INFO, + "perform re-establishment (SABM) length=%d (dl=%p)\n", + msg->len, dl); /* be sure that history is empty */ lapd_dl_flush_hist(dl); @@ -2024,7 +2069,7 @@ /* local release */ if (dp->u.rel_req.mode) { - LOGP(DLLAPD, LOGL_INFO, "perform local release\n"); + LOGP(DLLAPD, LOGL_INFO, "perform local release (dl=%p)\n", dl); msgb_free(msg); /* stop Timer T200 */ lapd_stop_t200(dl); @@ -2044,7 +2089,7 @@ /* flush tx_hist */ lapd_dl_flush_hist(dl); - LOGP(DLLAPD, LOGL_INFO, "perform normal release (DISC)\n"); + LOGP(DLLAPD, LOGL_INFO, "perform normal release (DISC) (dl=%p)\n", dl); /* Push LAPD header on msgb */ /* assemble message */ @@ -2169,21 +2214,22 @@ } } if (!supported) { - LOGP(DLLAPD, LOGL_NOTICE, "Message %u/%u unsupported.\n", - dp->oph.primitive, dp->oph.operation); + LOGP(DLLAPD, LOGL_NOTICE, + "Message %u/%u unsupported. (dl=%p)\n", dp->oph.primitive, + dp->oph.operation, dl); msgb_free(msg); return 0; } if (i == L2DOWNSLLEN) { LOGP(DLLAPD, LOGL_NOTICE, "Message %u/%u unhandled at this " - "state %s.\n", dp->oph.primitive, dp->oph.operation, - lapd_state_names[dl->state]); + "state %s. (dl=%p)\n", dp->oph.primitive, + dp->oph.operation, lapd_state_names[dl->state], dl); msgb_free(msg); return 0; } - LOGP(DLLAPD, LOGL_INFO, "Message %s received in state %s\n", - l2downstatelist[i].name, lapd_state_names[dl->state]); + LOGP(DLLAPD, LOGL_INFO, "Message %s received in state %s (dl=%p)\n", + l2downstatelist[i].name, lapd_state_names[dl->state], dl); rc = l2downstatelist[i].rout(dp, lctx); -- To view, visit https://gerrit.osmocom.org/1724 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 00:52:49 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 00:52:49 +0000 Subject: [PATCH] openbsc[master]: gprs/sgsn_vty: fix typo in comment Message-ID: Review at https://gerrit.osmocom.org/1748 gprs/sgsn_vty: fix typo in comment Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b --- M openbsc/src/gprs/sgsn_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/48/1748/1 diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 4a97687..b0c6ceb 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -63,7 +63,7 @@ #define GSM0408_T3360_SECS 6 /* waiting for AUTH/CIPH RESP */ #define GSM0408_T3370_SECS 6 /* waiting for ID RESP */ -/* Section 11.2.2 / Table 11.4a MM timers netwokr side */ +/* Section 11.2.2 / Table 11.4a MM timers network side */ #define GSM0408_T3313_SECS 30 /* waiting for paging response */ #define GSM0408_T3314_SECS 44 /* force to STBY on expiry, Ready timer */ #define GSM0408_T3316_SECS 44 -- To view, visit https://gerrit.osmocom.org/1748 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 00:52:49 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 00:52:49 +0000 Subject: [PATCH] openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef Message-ID: Review at https://gerrit.osmocom.org/1749 gprs_sgsn.c: initialize ptmsi with 0xdeadbeef Found by valgrind. Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a --- M openbsc/src/gprs/gprs_sgsn.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/49/1749/1 diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index e85e1a9..40a66d9 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -610,7 +610,7 @@ uint32_t sgsn_alloc_ptmsi(void) { struct sgsn_mm_ctx *mm; - uint32_t ptmsi; + uint32_t ptmsi = 0xdeadbeef; int max_retries = 100; restart: -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 00:52:49 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 00:52:49 +0000 Subject: [PATCH] openbsc[master]: libmsc/update_db_revision_3(): free memleaking db result Message-ID: Review at https://gerrit.osmocom.org/1750 libmsc/update_db_revision_3(): free memleaking db result Found by ASAN Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 --- M openbsc/src/libmsc/db.c 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/50/1750/1 diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 68dac76..9fa6415 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -346,6 +346,8 @@ LOGP(DDB, LOGL_ERROR, "Failed to commit the transaction (upgrade from rev 3)\n"); return -EINVAL; + } else { + dbi_result_free(result); } /* Shrink DB file size by actually wiping out SMS_3 table data */ -- To view, visit https://gerrit.osmocom.org/1750 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 00:52:50 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 00:52:50 +0000 Subject: [PATCH] openbsc[master]: tests: fix leaks by talloc ctx Message-ID: Review at https://gerrit.osmocom.org/1751 tests: fix leaks by talloc ctx Found by ASAN. Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 --- M openbsc/tests/gbproxy/gbproxy_test.c M openbsc/tests/gtphub/gtphub_test.c M openbsc/tests/mgcp/mgcp_test.c M openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c M openbsc/tests/oap/oap_client_test.c M openbsc/tests/slhc/slhc_test.c M openbsc/tests/sndcp_xid/sndcp_xid_test.c M openbsc/tests/trau/trau_test.c M openbsc/tests/v42bis/v42bis_test.c M openbsc/tests/xid/xid_test.c 10 files changed, 28 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/51/1751/1 diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c index 577daa9..b251147 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.c +++ b/openbsc/tests/gbproxy/gbproxy_test.c @@ -53,6 +53,8 @@ struct llist_head *received_messages = NULL; +void *tctx = NULL; + /* override, requires '-Wl,--wrap=RAND_bytes' */ int __real_RAND_bytes(unsigned char *buf, int num); int mock_RAND_bytes(unsigned char *buf, int num); @@ -1660,7 +1662,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; @@ -2001,7 +2003,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 0; gbcfg.core_mnc = 0; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; @@ -2235,7 +2237,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; @@ -2554,7 +2556,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; @@ -2738,7 +2740,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; gbcfg.acquire_imsi = 1; @@ -3064,7 +3066,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; gbcfg.acquire_imsi = 1; @@ -4844,7 +4846,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 0; gbcfg.core_mnc = 0; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; gbcfg.acquire_imsi = 1; @@ -4936,7 +4938,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + tctx = talloc_named_const(NULL, 0, "gbproxy_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); @@ -4965,6 +4968,7 @@ test_gbproxy_keep_info(); test_gbproxy_tlli_expire(); test_gbproxy_stored_messages(); + talloc_free(tctx); printf("===== GbProxy test END\n\n"); exit(EXIT_SUCCESS); diff --git a/openbsc/tests/gtphub/gtphub_test.c b/openbsc/tests/gtphub/gtphub_test.c index e7c27d2..4574ff1 100644 --- a/openbsc/tests/gtphub/gtphub_test.c +++ b/openbsc/tests/gtphub/gtphub_test.c @@ -1781,6 +1781,7 @@ talloc_report_full(osmo_gtphub_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(osmo_gtphub_ctx) == 1); + talloc_free(osmo_gtphub_ctx); return 0; } diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index b2d237e..a645f92 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -1203,7 +1203,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *mgcp_talloc = talloc_named_const(NULL, 0, "mgcp_test"); + msgb_talloc_ctx_init(mgcp_talloc, 0); osmo_init_logging(&log_info); test_strline(); @@ -1222,6 +1223,8 @@ test_no_name(); test_osmux_cid(); + talloc_free(mgcp_talloc); + printf("Done\n"); return EXIT_SUCCESS; } diff --git a/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c b/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c index ee138b8..39975e5 100644 --- a/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c +++ b/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c @@ -273,6 +273,7 @@ talloc_free(trx); talloc_report_full(ctx, stderr); OSMO_ASSERT(talloc_total_blocks(ctx) == 1); + talloc_free(ctx); return 0; } diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c index e6501cb..a5311fc 100644 --- a/openbsc/tests/oap/oap_client_test.c +++ b/openbsc/tests/oap/oap_client_test.c @@ -252,7 +252,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "oap_client_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&info); OSMO_ASSERT(osmo_stderr_target); @@ -263,6 +264,7 @@ log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); test_oap_api(); + talloc_free(tctx); printf("Done\n"); return 0; diff --git a/openbsc/tests/slhc/slhc_test.c b/openbsc/tests/slhc/slhc_test.c index d2e1cd9..6411b35 100644 --- a/openbsc/tests/slhc/slhc_test.c +++ b/openbsc/tests/slhc/slhc_test.c @@ -261,6 +261,7 @@ talloc_report_full(ctx, stderr); OSMO_ASSERT(talloc_total_blocks(ctx) == 1); + talloc_free(ctx); return 0; } diff --git a/openbsc/tests/sndcp_xid/sndcp_xid_test.c b/openbsc/tests/sndcp_xid/sndcp_xid_test.c index 151dd2b..524afa3 100644 --- a/openbsc/tests/sndcp_xid/sndcp_xid_test.c +++ b/openbsc/tests/sndcp_xid/sndcp_xid_test.c @@ -273,6 +273,7 @@ talloc_report_full(xid_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1); + talloc_free(xid_ctx); return 0; } diff --git a/openbsc/tests/trau/trau_test.c b/openbsc/tests/trau/trau_test.c index c74e6db..3464515 100644 --- a/openbsc/tests/trau/trau_test.c +++ b/openbsc/tests/trau/trau_test.c @@ -66,7 +66,8 @@ unsigned char data[33]; int i; - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "trau_test"); + msgb_talloc_ctx_init(tctx, 0); memset(data, 0x00, sizeof(data)); test_trau_fr_efr(data); @@ -76,6 +77,7 @@ for (i = 0; i < sizeof(data); i++) data[i] = random(); test_trau_fr_efr(data); + talloc_free(tctx); printf("Done\n"); return 0; } diff --git a/openbsc/tests/v42bis/v42bis_test.c b/openbsc/tests/v42bis/v42bis_test.c index 7e90785..21ee421 100644 --- a/openbsc/tests/v42bis/v42bis_test.c +++ b/openbsc/tests/v42bis/v42bis_test.c @@ -424,6 +424,7 @@ printf("Done\n"); talloc_report_full(v42bis_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(v42bis_ctx) == 1); + talloc_free(v42bis_ctx); return 0; } diff --git a/openbsc/tests/xid/xid_test.c b/openbsc/tests/xid/xid_test.c index b77a4ae..de40067 100644 --- a/openbsc/tests/xid/xid_test.c +++ b/openbsc/tests/xid/xid_test.c @@ -153,6 +153,7 @@ talloc_report_full(xid_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1); + talloc_free(xid_ctx); return 0; } -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 00:52:50 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 00:52:50 +0000 Subject: [PATCH] openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx Message-ID: Review at https://gerrit.osmocom.org/1752 tests/bsc & bsc-nat: fix mem leaks of talloc ctx Found by ASAN. Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 --- M openbsc/tests/bsc-nat/bsc_nat_test.c M openbsc/tests/bsc/bsc_test.c 2 files changed, 6 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/52/1752/1 diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index 2914a01..32a0432 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -1551,7 +1551,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "bsc_nat_test"); + msgb_talloc_ctx_init(tctx, 0); sccp_set_log_area(DSCCP); osmo_init_logging(&log_info); @@ -1572,7 +1573,7 @@ test_mgcp_allocations(); test_barr_list_parsing(); test_nat_extract_lac(); - + talloc_free(tctx); printf("Testing execution completed.\n"); return 0; } diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c index 7174828..6850b31 100644 --- a/openbsc/tests/bsc/bsc_test.c +++ b/openbsc/tests/bsc/bsc_test.c @@ -199,11 +199,12 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "bsc_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&log_info); test_scan(); - + talloc_free(tctx); printf("Testing execution completed.\n"); return 0; } -- To view, visit https://gerrit.osmocom.org/1752 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 00:57:48 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 00:57:48 +0000 Subject: [PATCH] openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef In-Reply-To: References: Message-ID: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef Fix uninitialized memory access warning. Found by valgrind. Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a --- M openbsc/src/gprs/gprs_sgsn.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/49/1749/2 diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index e85e1a9..40a66d9 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -610,7 +610,7 @@ uint32_t sgsn_alloc_ptmsi(void) { struct sgsn_mm_ctx *mm; - uint32_t ptmsi; + uint32_t ptmsi = 0xdeadbeef; int max_retries = 100; restart: -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 02:11:27 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 02:11:27 +0000 Subject: [PATCH] osmo-pcu[master]: remove pcu own bitvector implementation Message-ID: Review at https://gerrit.osmocom.org/1753 remove pcu own bitvector implementation use osmocom bitvec which is exact the same, but use a pointer instead of a reference. Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 --- M src/Makefile.am D src/bitvector.cpp D src/bitvector.h M src/bts.cpp A src/bts.cpp.orig M src/csn1.cpp M src/csn1.h M src/egprs_rlc_compression.cpp M src/encoding.cpp M src/gprs_bssgp_pcu.cpp M src/gprs_rlcmac.cpp M src/gprs_rlcmac.h M src/gsm_rlcmac.cpp M src/pcu_main.cpp M src/tbf.cpp M src/tbf_ul.cpp M tests/rlcmac/RLCMACTest.cpp M tests/tbf/TbfTest.cpp M tests/types/TypesTest.cpp 19 files changed, 2,222 insertions(+), 644 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/53/1753/1 diff --git a/src/Makefile.am b/src/Makefile.am index 7cc239b..97de06d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,6 @@ gprs_ms.cpp \ gprs_ms_storage.cpp \ gsm_timer.cpp \ - bitvector.cpp \ pcu_l1_if.cpp \ pcu_vty.c \ pcu_vty_functions.cpp \ @@ -80,7 +79,6 @@ gprs_ms_storage.h \ pcu_l1_if.h \ gsm_timer.h \ - bitvector.h \ pcu_vty.h \ pcu_vty_functions.h \ tbf.h \ diff --git a/src/bitvector.cpp b/src/bitvector.cpp deleted file mode 100644 index dcb3baf..0000000 --- a/src/bitvector.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* bitvector.cpp - * - * Copyright (C) 2012 Ivan Klyuchnikov - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/*! \addtogroup bitvector - * @{ - */ - -/*! \file bitvector.cpp - * \brief Additional functions for Osmocom bit vector abstraction. - */ - -#include -extern "C" { -#include -} - -void *bv_tall_ctx; - -struct bitvec *bitvec_alloc(unsigned size) -{ - struct bitvec *bv = talloc_zero(bv_tall_ctx, struct bitvec); - bv->data_len = size; - bv->cur_bit = 0; - bv->data = talloc_zero_array(bv_tall_ctx, uint8_t, size); - return bv; -} - -void bitvec_free(struct bitvec *bv) -{ - talloc_free(bv->data); - talloc_free(bv); -} - -unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer) -{ - unsigned int i = 0; - for (i = 0; i < bv->data_len; i++) - { - buffer[i] = bv->data[i]; - } - return i; -} - -unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer) -{ - unsigned int i = 0; - for (i = 0; i < bv->data_len; i++) - { - bv->data[i] = buffer[i]; - } - return i; -} - - -int bitvec_unhex(struct bitvec *bv, const char* src) -{ - unsigned val; - unsigned write_index = 0; - unsigned digits = bv->data_len*2; - for (unsigned i=0; icur_bit = read_index; - - for (i = 0; i < len; i++) { - int bit = bitvec_get_bit_pos((const struct bitvec *)bv, bv->cur_bit); - if (bit < 0) - return bit; - if (bit) - ui |= ((uint64_t)1 << (len - i - 1)); - bv->cur_bit++; - } - read_index += len; - return ui; -} - - -int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index, - uint64_t val, unsigned len) -{ - unsigned int i; - int rc; - bv->cur_bit = write_index; - for (i = 0; i < len; i++) { - bit_value bit = L; - if (val & ((uint64_t)1 << (len - i - 1))) - bit = H; - rc = bitvec_set_bit(bv, bit); - if (rc) - return rc; - } - write_index += len; - return 0; -} diff --git a/src/bitvector.h b/src/bitvector.h deleted file mode 100644 index 246824d..0000000 --- a/src/bitvector.h +++ /dev/null @@ -1,52 +0,0 @@ -/* bitvector.h - * - * Copyright (C) 2012 Ivan Klyuchnikov - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef BITVECTOR_H -#define BITVECTOR_H - -/*! \defgroup bitvector Bit vectors - * @{ - */ - -/*! \file bitvector.h - * \brief Additional functions for Osmocom bit vector abstraction. - */ - -extern "C" { -#include -} - -struct bitvec *bitvec_alloc(unsigned size); -void bitvec_free(struct bitvec *bv); -int bitvec_unhex(struct bitvec *bv, const char* src); -unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer); -unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer); -uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len); -int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len); - - -static inline int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len) -{ - /* Call the libosmocore variant */ - return ::bitvec_write_field(bv, &write_index, val, len); -} - -/*! }@ */ - -#endif // BITVECTOR_H diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..e857380 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -618,7 +618,7 @@ tsc = tbf->tsc(); } } - bitvec *immediate_assignment = bitvec_alloc(22) /* without plen */; + bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx) /* without plen */; bitvec_unhex(immediate_assignment, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); @@ -758,7 +758,7 @@ unsigned int ts = tbf->first_ts; LOGP(DRLCMAC, LOGL_INFO, "TX: START %s Immediate Assignment Downlink (PCH)\n", tbf_name(tbf)); - bitvec *immediate_assignment = bitvec_alloc(22); /* without plen */ + bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx); /* without plen */ bitvec_unhex(immediate_assignment, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); /* use request reference that has maximum distance to current time, * so the assignment will not conflict with possible RACH requests. */ @@ -856,7 +856,7 @@ talloc_free(pag); return NULL; } - bitvec *pag_vec = bitvec_alloc(23); + bitvec *pag_vec = bitvec_alloc(23, tall_pcu_ctx); if (!pag_vec) { msgb_free(msg); talloc_free(pag); @@ -1577,7 +1577,7 @@ rc = rcv_data_block(data, fn, meas, cs); break; case GPRS_RLCMAC_CONTROL_BLOCK: - block = bitvec_alloc(len); + block = bitvec_alloc(len, tall_pcu_ctx); if (!block) return -ENOMEM; bitvec_unpack(block, data); diff --git a/src/bts.cpp.orig b/src/bts.cpp.orig new file mode 100644 index 0000000..08ea05d --- /dev/null +++ b/src/bts.cpp.orig @@ -0,0 +1,1748 @@ +/* + * Copyright (C) 2013 by Holger Hans Peter Freyther + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +extern "C" { + #include + #include + #include + #include +} + +#include + +#include +#include + +extern void *tall_pcu_ctx; + +static BTS s_bts; + +/** + * For gcc-4.4 compat do not use extended initializer list but keep the + * order from the enum here. Once we support GCC4.7 and up we can change + * the code below. + */ +static const struct rate_ctr_desc bts_ctr_description[] = { + { "tbf.dl.alloc", "TBF DL Allocated "}, + { "tbf.dl.freed", "TBF DL Freed "}, + { "tbf.dl.aborted", "TBF DL Aborted "}, + { "tbf.ul.alloc", "TBF UL Allocated "}, + { "tbf.ul.freed", "TBF UL Freed "}, + { "tbf.ul.aborted", "TBF UL Aborted "}, + { "tbf.reused", "TBF Reused "}, + { "tbf.alloc.algo-a", "TBF Alloc Algo A "}, + { "tbf.alloc.algo-b", "TBF Alloc Algo B "}, + { "tbf.failed.egprs-only", "TBF Failed EGPRS-only"}, + { "rlc.sent", "RLC Sent "}, + { "rlc.resent", "RLC Resent "}, + { "rlc.restarted", "RLC Restarted "}, + { "rlc.stalled", "RLC Stalled "}, + { "rlc.nacked", "RLC Nacked "}, + { "rlc.final_block_resent", "RLC Final Blk resent "}, + { "rlc.ass.timedout", "RLC Assign Timeout "}, + { "rlc.ass.failed", "RLC Assign Failed "}, + { "rlc.ack.timedout", "RLC Ack Timeout "}, + { "rlc.ack.failed", "RLC Ack Failed "}, + { "rlc.rel.timedout", "RLC Release Timeout "}, + { "rlc.late-block", "RLC Late Block "}, + { "rlc.sent-dummy", "RLC Sent Dummy "}, + { "rlc.sent-control", "RLC Sent Control "}, + { "rlc.dl_bytes", "RLC DL Bytes "}, + { "rlc.dl_payload_bytes", "RLC DL Payload Bytes "}, + { "rlc.ul_bytes", "RLC UL Bytes "}, + { "rlc.ul_payload_bytes", "RLC UL Payload Bytes "}, + { "decode.errors", "Decode Errors "}, + { "sba.allocated", "SBA Allocated "}, + { "sba.freed", "SBA Freed "}, + { "sba.timedout", "SBA Timeout "}, + { "llc.timeout", "Timedout Frames "}, + { "llc.dropped", "Dropped Frames "}, + { "llc.scheduled", "Scheduled Frames "}, + { "llc.dl_bytes", "RLC encapsulated PDUs"}, + { "llc.ul_bytes", "full PDUs received "}, + { "rach.requests", "RACH requests "}, + { "11bit_rach.requests", "11BIT_RACH requests "}, + { "spb.uplink_first_segment", "First seg of UL SPB "}, + { "spb.uplink_second_segment", "Second seg of UL SPB "}, + { "spb.downlink_first_segment", "First seg of DL SPB "}, + { "spb.downlink_second_segment","Second seg of DL SPB "}, + { "immediate.assignment_UL", "Immediate Assign UL "}, + { "immediate.assignment_rej", "Immediate Assign Rej "}, + { "immediate.assignment_DL", "Immediate Assign DL "}, + { "channel.request_description","Channel Request Desc "}, + { "pkt.ul_assignment", "Packet UL Assignment "}, + { "pkt.access_reject", "Packet Access Reject "}, + { "pkt.dl_assignment", "Packet DL Assignment "}, + { "ul.control", "UL control Block "}, + { "ul.assignment_poll_timeout", "UL Assign Timeout "}, + { "ul.assignment_failed", "UL Assign Failed "}, + { "dl.assignment_timeout", "DL Assign Timeout "}, + { "dl.assignment_failed", "DL Assign Failed "}, + { "pkt.ul_ack_nack_timeout", "PUAN Poll Timeout "}, + { "pkt.ul_ack_nack_failed", "PUAN poll Failed "}, + { "pkt.dl_ack_nack_timeout", "PDAN poll Timeout "}, + { "pkt.dl_ack_nack_failed", "PDAN poll Failed "}, + { "gprs.downlink_cs1", "CS1 downlink "}, + { "gprs.downlink_cs2", "CS2 downlink "}, + { "gprs.downlink_cs3", "CS3 downlink "}, + { "gprs.downlink_cs4", "CS4 downlink "}, + { "egprs.downlink_mcs1", "MCS1 downlink "}, + { "egprs.downlink_mcs2", "MCS2 downlink "}, + { "egprs.downlink_mcs3", "MCS3 downlink "}, + { "egprs.downlink_mcs4", "MCS4 downlink "}, + { "egprs.downlink_mcs5", "MCS5 downlink "}, + { "egprs.downlink_mcs6", "MCS6 downlink "}, + { "egprs.downlink_mcs7", "MCS7 downlink "}, + { "egprs.downlink_mcs8", "MCS8 downlink "}, + { "egprs.downlink_mcs9", "MCS9 downlink "}, + { "gprs.uplink_cs1", "CS1 Uplink "}, + { "gprs.uplink_cs2", "CS2 Uplink "}, + { "gprs.uplink_cs3", "CS3 Uplink "}, + { "gprs.uplink_cs4", "CS4 Uplink "}, + { "egprs.uplink_mcs1", "MCS1 Uplink "}, + { "egprs.uplink_mcs2", "MCS2 Uplink "}, + { "egprs.uplink_mcs3", "MCS3 Uplink "}, + { "egprs.uplink_mcs4", "MCS4 Uplink "}, + { "egprs.uplink_mcs5", "MCS5 Uplink "}, + { "egprs.uplink_mcs6", "MCS6 Uplink "}, + { "egprs.uplink_mcs7", "MCS7 Uplink "}, + { "egprs.uplink_mcs8", "MCS8 Uplink "}, + { "egprs.uplink_mcs9", "MCS9 Uplink "}, +}; + +static const struct rate_ctr_group_desc bts_ctrg_desc = { + "bts", + "BTS Statistics", + OSMO_STATS_CLASS_GLOBAL, + ARRAY_SIZE(bts_ctr_description), + bts_ctr_description, +}; + +static const struct osmo_stat_item_desc bts_stat_item_description[] = { + { "ms.present", "MS Present ", + OSMO_STAT_ITEM_NO_UNIT, 4, 0}, +}; + +static const struct osmo_stat_item_group_desc bts_statg_desc = { + "bts", + "BTS Statistics", + OSMO_STATS_CLASS_GLOBAL, + ARRAY_SIZE(bts_stat_item_description), + bts_stat_item_description, +}; + +BTS* BTS::main_bts() +{ + return &s_bts; +} + +struct gprs_rlcmac_bts *BTS::bts_data() +{ + return &m_bts; +} + +struct gprs_rlcmac_bts *bts_main_data() +{ + return BTS::main_bts()->bts_data(); +} + +struct rate_ctr_group *bts_main_data_stats() +{ + return BTS::main_bts()->rate_counters(); +} + +BTS::BTS() + : m_cur_fn(0) + , m_cur_blk_fn(-1) + , m_pollController(*this) + , m_sba(*this) + , m_ms_store(this) +{ + memset(&m_bts, 0, sizeof(m_bts)); + m_bts.bts = this; + + /* initialize back pointers */ + for (size_t trx_no = 0; trx_no < ARRAY_SIZE(m_bts.trx); ++trx_no) { + struct gprs_rlcmac_trx *trx = &m_bts.trx[trx_no]; + trx->trx_no = trx_no; + trx->bts = this; + + for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ++ts_no) { + struct gprs_rlcmac_pdch *pdch = &trx->pdch[ts_no]; + pdch->ts_no = ts_no; + pdch->trx = trx; + } + } + + m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 0); + m_statg = osmo_stat_item_group_alloc(tall_pcu_ctx, &bts_statg_desc, 0); +} + +BTS::~BTS() +{ + /* this can cause counter updates and must not be left to the + * m_ms_store's destructor */ + m_ms_store.cleanup(); + + rate_ctr_group_free(m_ratectrs); + osmo_stat_item_group_free(m_statg); +} + + +void BTS::set_current_frame_number(int fn) +{ + /* The UL frame numbers lag 3 behind the DL frames and the data + * indication is only sent after all 4 frames of the block have been + * received. Sometimes there is an idle frame between the end of one + * and start of another frame (every 3 blocks). So the timeout should + * definitely be there if we're more than 8 frames past poll_fn. Let's + * stay on the safe side and say 13 or more. An additional delay can + * happen due to the block processing time in the DSP, so the delay of + * decoded blocks relative to the timing clock can be much larger. + * Values up to 50 frames have been observed under load. */ + const static int max_delay = 60; + + m_cur_fn = fn; + m_pollController.expireTimedout(m_cur_fn, max_delay); +} + +void BTS::set_current_block_frame_number(int fn, unsigned max_delay) +{ + int delay = 0; + const int late_block_delay_thresh = 13; + const int fn_update_ok_min_delay = -500; + const int fn_update_ok_max_delay = 0; + + /* frame numbers in the received blocks are assumed to be strongly + * monotonic. */ + if (m_cur_blk_fn >= 0) { + int delta = (fn + 2715648 * 3 / 2 - m_cur_blk_fn) % 2715648 - 2715648/2; + if (delta <= 0) + return; + } + + /* Check block delay vs. the current frame number */ + if (current_frame_number() != 0) + delay = (fn + 2715648 * 3 / 2 - current_frame_number()) % 2715648 + - 2715648/2; + if (delay <= -late_block_delay_thresh) { + LOGP(DRLCMAC, LOGL_NOTICE, + "Late RLC block, FN delta: %d FN: %d curFN: %d\n", + delay, fn, current_frame_number()); + rlc_late_block(); + } + + m_cur_blk_fn = fn; + if (delay < fn_update_ok_min_delay || delay > fn_update_ok_max_delay || + current_frame_number() == 0) + m_cur_fn = fn; + + m_pollController.expireTimedout(fn, max_delay); +} + +int BTS::add_paging(uint8_t chan_needed, uint8_t *identity_lv) +{ + uint8_t l, trx, ts, any_tbf = 0; + struct gprs_rlcmac_tbf *tbf; + LListHead *pos; + struct gprs_rlcmac_paging *pag; + uint8_t slot_mask[8]; + int8_t first_ts; /* must be signed */ + + LListHead *tbfs_lists[] = { + &m_ul_tbfs, + &m_dl_tbfs, + NULL + }; + + + LOGP(DRLCMAC, LOGL_INFO, "Add RR paging: chan-needed=%d MI=%s\n", + chan_needed, osmo_hexdump(identity_lv + 1, identity_lv[0])); + + /* collect slots to page + * Mark slots for every TBF, but only mark one of it. + * Mark only the first slot found. + * Don't mark, if TBF uses a different slot that is already marked. */ + memset(slot_mask, 0, sizeof(slot_mask)); + for (l = 0; tbfs_lists[l]; l++) { + llist_for_each(pos, tbfs_lists[l]) { + tbf = pos->entry(); + first_ts = -1; + for (ts = 0; ts < 8; ts++) { + if (tbf->pdch[ts]) { + /* remember the first slot found */ + if (first_ts < 0) + first_ts = ts; + /* break, if we already marked a slot */ + if ((slot_mask[tbf->trx->trx_no] & (1 << ts))) + break; + } + } + /* mark first slot found, if none is marked already */ + if (ts == 8 && first_ts >= 0) { + LOGP(DRLCMAC, LOGL_DEBUG, "- %s uses " + "TRX=%d TS=%d, so we mark\n", + tbf_name(tbf), + tbf->trx->trx_no, first_ts); + slot_mask[tbf->trx->trx_no] |= (1 << first_ts); + } else + LOGP(DRLCMAC, LOGL_DEBUG, "- %s uses " + "already marked TRX=%d TS=%d\n", + tbf_name(tbf), + tbf->trx->trx_no, ts); + } + } + + /* Now we have a list of marked slots. Every TBF uses at least one + * of these slots. */ + + /* schedule paging to all marked slots */ + for (trx = 0; trx < 8; trx++) { + if (slot_mask[trx] == 0) + continue; + for (ts = 0; ts < 8; ts++) { + if ((slot_mask[trx] & (1 << ts))) { + /* schedule */ + pag = talloc_zero(tall_pcu_ctx, + struct gprs_rlcmac_paging); + if (!pag) + return -ENOMEM; + pag->chan_needed = chan_needed; + memcpy(pag->identity_lv, identity_lv, + identity_lv[0] + 1); + m_bts.trx[trx].pdch[ts].add_paging(pag); + LOGP(DRLCMAC, LOGL_INFO, "Paging on PACCH of " + "TRX=%d TS=%d\n", trx, ts); + any_tbf = 1; + } + } + } + + if (!any_tbf) + LOGP(DRLCMAC, LOGL_INFO, "No paging, because no TBF\n"); + + return 0; +} + +gprs_rlcmac_dl_tbf *BTS::dl_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts) +{ + struct gprs_rlcmac_dl_tbf *tbf; + LListHead *pos; + + /* only one TBF can poll on specific TS/FN, because scheduler can only + * schedule one downlink control block (with polling) at a FN per TS */ + llist_for_each(pos, &m_dl_tbfs) { + tbf = as_dl_tbf(pos->entry()); + if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) + && tbf->poll_state == GPRS_RLCMAC_POLL_SCHED + && tbf->poll_fn == fn && tbf->trx->trx_no == trx + && tbf->poll_ts == ts) { + return tbf; + } + } + return NULL; +} +gprs_rlcmac_ul_tbf *BTS::ul_tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts) +{ + struct gprs_rlcmac_ul_tbf *tbf; + LListHead *pos; + + /* only one TBF can poll on specific TS/FN, because scheduler can only + * schedule one downlink control block (with polling) at a FN per TS */ + llist_for_each(pos, &m_ul_tbfs) { + tbf = as_ul_tbf(pos->entry()); + if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) + && tbf->poll_state == GPRS_RLCMAC_POLL_SCHED + && tbf->poll_fn == fn && tbf->trx->trx_no == trx + && tbf->poll_ts == ts) { + return tbf; + } + } + return NULL; +} + +/* lookup downlink TBF Entity (by TFI) */ +gprs_rlcmac_dl_tbf *BTS::dl_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts) +{ + if (trx >= 8 || ts >= 8) + return NULL; + + return m_bts.trx[trx].pdch[ts].dl_tbf_by_tfi(tfi); +} + +/* lookup uplink TBF Entity (by TFI) */ +gprs_rlcmac_ul_tbf *BTS::ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts) +{ + if (trx >= 8 || ts >= 8) + return NULL; + + return m_bts.trx[trx].pdch[ts].ul_tbf_by_tfi(tfi); +} + +/* + * Search for free TFI and return TFI, TRX. + * This method returns the first TFI that is currently not used in any PDCH of + * a TRX. The first TRX that contains such an TFI is returned. Negative values + * indicate errors. + */ +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, + uint8_t *_trx, int8_t use_trx) +{ + struct gprs_rlcmac_pdch *pdch; + uint32_t free_tfis; + bool has_pdch = false; + uint8_t trx_from, trx_to, trx, ts, tfi; + + if (use_trx >= 0 && use_trx < 8) + trx_from = trx_to = use_trx; + else { + trx_from = 0; + trx_to = 7; + } + + /* find a TFI that is unused on all PDCH */ + for (trx = trx_from; trx <= trx_to; trx++) { + bool trx_has_pdch = false; + + free_tfis = 0xffffffff; + + for (ts = 0; ts < 8; ts++) { + pdch = &m_bts.trx[trx].pdch[ts]; + if (!pdch->is_enabled()) + continue; + free_tfis &= ~pdch->assigned_tfi(dir); + trx_has_pdch = true; + has_pdch = true; + } + if (trx_has_pdch && free_tfis) + break; + + free_tfis = 0; + } + if (!has_pdch) { + LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); + return -EINVAL; + } + + if (!free_tfis) { + LOGP(DRLCMAC, LOGL_NOTICE, "No TFI available.\n"); + return -EBUSY; + } + + + LOGP(DRLCMAC, LOGL_DEBUG, + "Searching for first unallocated TFI: TRX=%d\n", trx); + + /* find the first */ + for (tfi = 0; tfi < 32; tfi++) { + if (free_tfis & 1 << tfi) + break; + } + + OSMO_ASSERT(tfi < 32); + + LOGP(DRLCMAC, LOGL_DEBUG, " Found TFI=%d.\n", tfi); + *_trx = trx; + return tfi; +} + +int BTS::rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn) +{ + struct gprs_rlcmac_dl_tbf *dl_tbf = NULL; + uint8_t plen; + uint32_t tlli; + GprsMs *ms; + + /* move to IA Rest Octets */ + plen = data[0] >> 2; + data += 1 + plen; + + if ((*data & 0xf0) != 0xd0) { + LOGP(DRLCMAC, LOGL_ERROR, "Got IMM.ASS confirm, but rest " + "octets do not start with bit sequence 'HH01' " + "(Packet Downlink Assignment)\n"); + return -EINVAL; + } + + /* get TLLI from downlink assignment */ + tlli = (*data++) << 28; + tlli |= (*data++) << 20; + tlli |= (*data++) << 12; + tlli |= (*data++) << 4; + tlli |= (*data++) >> 4; + + ms = ms_by_tlli(tlli); + if (ms) + dl_tbf = ms->dl_tbf(); + if (!dl_tbf) { + LOGP(DRLCMAC, LOGL_ERROR, "Got IMM.ASS confirm, but TLLI=%08x " + "does not exit\n", tlli); + return -EINVAL; + } + + LOGP(DRLCMAC, LOGL_DEBUG, "Got IMM.ASS confirm for TLLI=%08x\n", tlli); + + if (dl_tbf->m_wait_confirm) + tbf_timer_start(dl_tbf, 1, Tassign_agch); + + return 0; +} + +int BTS::rcv_imm_ass_cnf_dt(uint32_t tlli, uint32_t fn) +{ + GprsMs *ms; + struct gprs_rlcmac_dl_tbf *dl_tbf = NULL; + + ms = ms_by_tlli(tlli); + if (ms) + dl_tbf = ms->dl_tbf(); + if (!dl_tbf) { + LOGP(DRLCMAC, LOGL_ERROR, "Got IMM.ASS confirm, but TLLI=%08x " + "does not exit\n", tlli); + return -EINVAL; + } + + LOGP(DRLCMAC, LOGL_DEBUG, "Got IMM.ASS confirm for TLLI=%08x\n", tlli); + + if (dl_tbf->m_wait_confirm) + tbf_timer_start(dl_tbf, 1, Tassign_agch); + + return 0; +} + +int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, + enum ph_burst_type burst_type) +{ + struct gprs_rlcmac_ul_tbf *tbf = NULL; + uint8_t trx_no, ts_no = 0; + uint8_t sb = 0; + uint32_t sb_fn = 0; + int rc = 0; + int plen; + uint8_t usf = 7; + uint8_t tsc = 0, ta = qta2ta(qta); + uint16_t ms_class = 0; + uint16_t priority = 0; + bool failure = false; + + rach_frame(); + + /* Santizize frame number */ + Fn = Fn % 42432; + + /* Restore the full frame number + * (See also 3GPP TS 44.018, section 10.5.2.38) */ + Fn = Fn + m_cur_fn - m_cur_fn % 42432; + + if (is_11bit) + rach_frame_11bit(); + + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF on RACH, " + "so we provide one \n" + "ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", ra, Fn, qta, is_11bit); + + sb = is_single_block(ra, burst_type, is_11bit, &ms_class, &priority); + + if (sb) { + rc = sba()->alloc(&trx_no, &ts_no, &sb_fn, ta); + if (rc < 0) { + failure = true; + LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource for " + "single block allocation." + "sending Immediate " + "Assignment Uplink (AGCH) reject\n"); + } else { + tsc = m_bts.trx[trx_no].pdch[ts_no].tsc; + + LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] RACH " + " qbit-ta=%d ra=0x%02x, Fn=%d (%d,%d,%d)," + " SBFn=%d\n", + qta, ra, + Fn, (Fn / (26 * 51)) % 32, Fn % 51, Fn % 26, + sb_fn); + LOGP(DRLCMAC, LOGL_INFO, "TX: Immediate Assignment " + "Uplink (AGCH)\n"); + } + } else { + // Create new TBF + #warning "Copy and paste with other routines.." + + if (is_11bit) { + tbf = tbf_alloc_ul_tbf(&m_bts, NULL, -1, 0, + ms_class, 1); + } else { + /* set class to 0, since we don't know the multislot + * class yet */ + tbf = tbf_alloc_ul_tbf(&m_bts, NULL, -1, 0, 0, 1); + } + + if (!tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource sending " + "Immediate Assignment Uplink (AGCH) " + "reject\n"); + rc = -EBUSY; + failure = true; + } else { + tbf->set_ta(ta); + tbf->set_state(GPRS_RLCMAC_FLOW); + tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH); + tbf_timer_start(tbf, 3169, m_bts.t3169, 0); + LOGP(DRLCMAC, LOGL_DEBUG, "%s [UPLINK] START\n", + tbf_name(tbf)); + LOGP(DRLCMAC, LOGL_DEBUG, "%s RX: [PCU <- BTS] RACH " + "qbit-ta=%d ra=0x%02x, Fn=%d " + " (%d,%d,%d)\n", + tbf_name(tbf), + qta, ra, Fn, (Fn / (26 * 51)) % 32, + Fn % 51, Fn % 26); + LOGP(DRLCMAC, LOGL_INFO, "%s TX: START Immediate " + "Assignment Uplink (AGCH)\n", + tbf_name(tbf)); + trx_no = tbf->trx->trx_no; + ts_no = tbf->first_ts; + usf = tbf->m_usf[ts_no]; + tsc = tbf->tsc(); + } + } + bitvec *immediate_assignment = bitvec_alloc(22) /* without plen */; + bitvec_unhex(immediate_assignment, + "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + + + if (failure) { + plen = Encoding::write_immediate_assignment_reject( + immediate_assignment, ra, Fn, + burst_type); + immediate_assignment_reject(); + } + else { + LOGP(DRLCMAC, LOGL_DEBUG, + " - TRX=%d (%d) TS=%d TA=%d TSC=%d TFI=%d USF=%d\n", + trx_no, m_bts.trx[trx_no].arfcn, ts_no, ta, tsc, + tbf ? tbf->tfi() : -1, usf); + + plen = Encoding::write_immediate_assignment( + tbf, immediate_assignment, 0, ra, Fn, ta, + m_bts.trx[trx_no].arfcn, ts_no, tsc, usf, 0, sb_fn, + m_bts.alpha, m_bts.gamma, -1, burst_type, sb); + } + + if (plen >= 0) { + immediate_assignment_ul_tbf(); + pcu_l1if_tx_agch(immediate_assignment, plen); + } + + bitvec_free(immediate_assignment); + + return rc; +} + +uint8_t BTS::is_single_block(uint16_t ra, enum ph_burst_type burst_type, + uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority) +{ + uint8_t sb = 0, val = 0; + + if (!is_11bit && (burst_type == GSM_L1_BURST_TYPE_ACCESS_0)) { + + if ((ra & 0xf8) == 0x70) { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single block " + "allocation\n"); + sb = 1; + } else if (m_bts.force_two_phase) { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single " + "phase access, but we force two phase " + "access\n"); + sb = 1; + } + + } else if (is_11bit && + ((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) || + (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) { + + val = !!(ra & (1 << 10)); + + if (!val) { + if (m_bts.force_two_phase) { + LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS 11 bit RACH " + "received. MS requests single phase " + "access but we force two phase " + "access\n"); + sb = 1; + } else { + sb = 0; + *ms_class = (ra & 0x3e0) >> 5; + *priority = (ra & 0x18) >> 3; + } + + } else { + LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS 11 bit RACH received." + "MS requests single block allocation\n"); + sb = 1; + } + + } else if (is_11bit && + (burst_type == GSM_L1_BURST_TYPE_ACCESS_0)) { + LOGP(DRLCMAC, LOGL_ERROR, + "Error: GPRS 11 bit RACH not supported\n"); + + } else if (burst_type == GSM_L1_BURST_TYPE_NONE) { + LOGP(DRLCMAC, LOGL_DEBUG, "pcu has not received burst type " + "from bts \n"); + + if ((ra & 0xf8) == 0x70) { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single block " + "allocation\n"); + sb = 1; + } else if (m_bts.force_two_phase) { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests single " + "phase access, but we force two phase " + "access\n"); + sb = 1; + } + } + + return sb; +} + +/* depending on the current TBF, we assign on PACCH or AGCH */ +void BTS::trigger_dl_ass( + struct gprs_rlcmac_dl_tbf *dl_tbf, + struct gprs_rlcmac_tbf *old_tbf) +{ + /* stop pending timer */ + dl_tbf->stop_timer(); + + /* check for downlink tbf: */ + if (old_tbf) { + LOGP(DRLCMAC, LOGL_DEBUG, "Send dowlink assignment on " + "PACCH, because %s exists\n", tbf_name(old_tbf)); + old_tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_SEND_ASS; + + old_tbf->was_releasing = old_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE); + + /* change state */ + dl_tbf->set_state(GPRS_RLCMAC_ASSIGN); + if (!(dl_tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) + dl_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH); + /* start timer */ + tbf_timer_start(dl_tbf, 0, Tassign_pacch); + } else { + uint32_t tlli = ntohl(dl_tbf->tlli()); + LOGP(DRLCMAC, LOGL_DEBUG, "Send dowlink assignment for %s on PCH, no TBF exist (IMSI=%s)\n", tbf_name(dl_tbf), dl_tbf->imsi()); + dl_tbf->was_releasing = dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE); + /* change state */ + dl_tbf->set_state(GPRS_RLCMAC_ASSIGN); + dl_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH); + /* send immediate assignment */ + /* FIXME TLLI != P-TMSI, but our sgsn use TLLI == P-TMSI */ + gprs_rlcmac_paging_request((uint8_t *)&tlli, sizeof(dl_tbf->tlli()), dl_tbf->imsi()); + dl_tbf->bts->snd_dl_ass(dl_tbf, 0, dl_tbf->imsi()); + dl_tbf->m_wait_confirm = 1; + /* start timer */ + tbf_timer_start(dl_tbf, 0, Tassign_pacch); + + } +} + +void BTS::snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi) +{ + int plen; + unsigned int ts = tbf->first_ts; + + LOGP(DRLCMAC, LOGL_INFO, "TX: START %s Immediate Assignment Downlink (PCH)\n", tbf_name(tbf)); + bitvec *immediate_assignment = bitvec_alloc(22); /* without plen */ + bitvec_unhex(immediate_assignment, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + /* use request reference that has maximum distance to current time, + * so the assignment will not conflict with possible RACH requests. */ + LOGP(DRLCMAC, LOGL_DEBUG, " - TRX=%d (%d) TS=%d TA=%d pollFN=%d\n", + tbf->trx->trx_no, tbf->trx->arfcn, + ts, tbf->ta(), poll ? tbf->poll_fn : -1); + plen = Encoding::write_immediate_assignment(tbf, immediate_assignment, 1, 125, + (tbf->pdch[ts]->last_rts_fn + 21216) % 2715648, tbf->ta(), + tbf->trx->arfcn, ts, tbf->tsc(), 7, poll, + tbf->poll_fn, m_bts.alpha, m_bts.gamma, -1); + if (plen >= 0) { + immediate_assignment_dl_tbf(); + if (this->bts_data()->use_direct_tlli) + pcu_l1if_tx_agch_dt(tbf->tlli(), immediate_assignment, plen); + else + pcu_l1if_tx_agch(immediate_assignment, plen); + } + + bitvec_free(immediate_assignment); +} + + +GprsMs *BTS::ms_alloc(uint8_t ms_class, uint8_t egprs_ms_class) +{ + GprsMs *ms; + ms = ms_store().create_ms(); + + ms->set_timeout(m_bts.ms_idle_sec); + ms->set_ms_class(ms_class); + ms->set_egprs_ms_class(egprs_ms_class); + + return ms; +} + +/* + * PDCH code below. TODO: move to a separate file + */ + +void gprs_rlcmac_pdch::enable() +{ + /* TODO: Check if there are still allocated resources.. */ + INIT_LLIST_HEAD(&paging_list); + m_is_enabled = 1; +} + +void gprs_rlcmac_pdch::disable() +{ + /* TODO.. kick free_resources once we know the TRX/TS we are on */ + m_is_enabled = 0; +} + +void gprs_rlcmac_pdch::free_resources() +{ + struct gprs_rlcmac_paging *pag; + + /* we are not enabled. there should be no resources */ + if (!is_enabled()) + return; + + /* kick all TBF on slot */ + gprs_rlcmac_tbf::free_all(this); + + /* flush all pending paging messages */ + while ((pag = dequeue_paging())) + talloc_free(pag); + + trx->bts->sba()->free_resources(this); +} + +struct gprs_rlcmac_paging *gprs_rlcmac_pdch::dequeue_paging() +{ + struct gprs_rlcmac_paging *pag; + + if (llist_empty(&paging_list)) + return NULL; + pag = llist_entry(paging_list.next, struct gprs_rlcmac_paging, list); + llist_del(&pag->list); + + return pag; +} + +struct msgb *gprs_rlcmac_pdch::packet_paging_request() +{ + struct gprs_rlcmac_paging *pag; + struct msgb *msg; + unsigned wp = 0, len; + + /* no paging, no message */ + pag = dequeue_paging(); + if (!pag) + return NULL; + + LOGP(DRLCMAC, LOGL_DEBUG, "Scheduling paging\n"); + + /* alloc message */ + msg = msgb_alloc(23, "pag ctrl block"); + if (!msg) { + talloc_free(pag); + return NULL; + } + bitvec *pag_vec = bitvec_alloc(23); + if (!pag_vec) { + msgb_free(msg); + talloc_free(pag); + return NULL; + } + wp = Encoding::write_packet_paging_request(pag_vec); + + /* loop until message is full */ + while (pag) { + /* try to add paging */ + if ((pag->identity_lv[1] & 0x07) == 4) { + /* TMSI */ + LOGP(DRLCMAC, LOGL_DEBUG, "- TMSI=0x%08x\n", + ntohl(*((uint32_t *)(pag->identity_lv + 1)))); + len = 1 + 1 + 1 + 32 + 2 + 1; + if (pag->identity_lv[0] != 5) { + LOGP(DRLCMAC, LOGL_ERROR, "TMSI paging with " + "MI != 5 octets!\n"); + goto continue_next; + } + } else { + /* MI */ + LOGP(DRLCMAC, LOGL_DEBUG, "- MI=%s\n", + osmo_hexdump(pag->identity_lv + 1, + pag->identity_lv[0])); + len = 1 + 1 + 1 + 4 + (pag->identity_lv[0]<<3) + 2 + 1; + if (pag->identity_lv[0] > 8) { + LOGP(DRLCMAC, LOGL_ERROR, "Paging with " + "MI > 8 octets!\n"); + goto continue_next; + } + } + if (wp + len > 184) { + LOGP(DRLCMAC, LOGL_DEBUG, "- Does not fit, so schedule " + "next time\n"); + /* put back paging record, because does not fit */ + llist_add_tail(&pag->list, &paging_list); + break; + } + Encoding::write_repeated_page_info(pag_vec, wp, pag->identity_lv[0], + pag->identity_lv + 1, pag->chan_needed); + +continue_next: + talloc_free(pag); + pag = dequeue_paging(); + } + + bitvec_pack(pag_vec, msgb_put(msg, 23)); + RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t); + LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Paging Request +++++++++++++++++++++++++\n"); + decode_gsm_rlcmac_downlink(pag_vec, mac_control_block); + LOGPC(DCSN1, LOGL_NOTICE, "\n"); + LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- TX : Packet Paging Request -------------------------\n"); + bitvec_free(pag_vec); + talloc_free(mac_control_block); + + return msg; +} + +void gprs_rlcmac_pdch::add_paging(struct gprs_rlcmac_paging *pag) +{ + llist_add(&pag->list, &paging_list); +} + +void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet, uint32_t fn) +{ + struct gprs_rlcmac_tbf *tbf, *new_tbf; + uint32_t tlli = 0; + + tlli = packet->TLLI; + tbf = bts()->ul_tbf_by_poll_fn(fn, trx_no(), ts_no); + if (!tbf) + tbf = bts()->dl_tbf_by_poll_fn(fn, trx_no(), ts_no); + + if (!tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "RX: [PCU <- BTS] PACKET CONTROL ACK with " + "unknown FN=%u TLLI=0x%08x (TRX %d TS %d)\n", + fn, tlli, trx_no(), ts_no); + return; + } + tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF); + + LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] %s Packet Control Ack\n", tbf_name(tbf)); + tbf->poll_state = GPRS_RLCMAC_POLL_NONE; + + /* check if this control ack belongs to packet uplink ack */ + if (tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_WAIT_ACK) { + LOGP(DRLCMAC, LOGL_DEBUG, "TBF: [UPLINK] END %s\n", tbf_name(tbf)); + tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE; + if ((tbf->state_flags & + (1 << GPRS_RLCMAC_FLAG_TO_UL_ACK))) { + tbf->state_flags &= + ~(1 << GPRS_RLCMAC_FLAG_TO_UL_ACK); + LOGP(DRLCMAC, LOGL_NOTICE, "Recovered uplink " + "ack for UL %s\n", tbf_name(tbf)); + } + tbf_free(tbf); + return; + } + if (tbf->dl_ass_state == GPRS_RLCMAC_DL_ASS_WAIT_ACK) { + LOGP(DRLCMAC, LOGL_DEBUG, "TBF: [UPLINK] DOWNLINK ASSIGNED %s\n", tbf_name(tbf)); + /* reset N3105 */ + tbf->n3105 = 0; + tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE; + + new_tbf = tbf->ms() ? tbf->ms()->dl_tbf() : NULL; + if (!new_tbf) { + LOGP(DRLCMAC, LOGL_ERROR, "Got ACK, but DL " + "TBF is gone TLLI=0x%08x\n", tlli); + return; + } + if (tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE) && + tbf->direction == new_tbf->direction) + tbf_free(tbf); + + if ((new_tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) { + /* We now know that the PACCH really existed */ + LOGP(DRLCMAC, LOGL_INFO, + "The TBF has been confirmed on the PACCH, " + "changed type from CCCH to PACCH for %s\n", + tbf_name(new_tbf)); + new_tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH); + new_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH); + } + new_tbf->set_state(GPRS_RLCMAC_FLOW); + /* stop pending assignment timer */ + new_tbf->stop_timer(); + if ((new_tbf->state_flags & + (1 << GPRS_RLCMAC_FLAG_TO_DL_ASS))) { + new_tbf->state_flags &= + ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ASS); + LOGP(DRLCMAC, LOGL_NOTICE, "Recovered downlink " + "assignment for %s\n", tbf_name(new_tbf)); + } + tbf_assign_control_ts(new_tbf); + return; + } + if (tbf->ul_ass_state == GPRS_RLCMAC_UL_ASS_WAIT_ACK) { + LOGP(DRLCMAC, LOGL_DEBUG, "TBF: [DOWNLINK] UPLINK ASSIGNED %s\n", tbf_name(tbf)); + /* reset N3105 */ + tbf->n3105 = 0; + tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE; + + new_tbf = tbf->ms() ? tbf->ms()->ul_tbf() : NULL; + if (!new_tbf) { + LOGP(DRLCMAC, LOGL_ERROR, "Got ACK, but UL " + "TBF is gone TLLI=0x%08x\n", tlli); + return; + } + if (tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE) && + tbf->direction == new_tbf->direction) + tbf_free(tbf); + + new_tbf->set_state(GPRS_RLCMAC_FLOW); + if ((new_tbf->state_flags & + (1 << GPRS_RLCMAC_FLAG_TO_UL_ASS))) { + new_tbf->state_flags &= + ~(1 << GPRS_RLCMAC_FLAG_TO_UL_ASS); + LOGP(DRLCMAC, LOGL_NOTICE, "Recovered uplink " + "assignment for UL %s\n", tbf_name(new_tbf)); + } + tbf_assign_control_ts(new_tbf); + /* there might be LLC packets waiting in the queue, but the DL + * TBF might have been released while the UL TBF has been + * established */ + if (new_tbf->ms()->need_dl_tbf()) + new_tbf->establish_dl_tbf_on_pacch(); + + return; + } + LOGP(DRLCMAC, LOGL_ERROR, "Error: received PACET CONTROL ACK " + "at no request\n"); +} + +static void get_rx_qual_meas(struct pcu_l1_meas *meas, uint8_t rx_qual_enc) +{ + static const int16_t rx_qual_map[] = { + 0, /* 0,14 % */ + 0, /* 0,28 % */ + 1, /* 0,57 % */ + 1, /* 1,13 % */ + 2, /* 2,26 % */ + 5, /* 4,53 % */ + 9, /* 9,05 % */ + 18, /* 18,10 % */ + }; + + meas->set_ms_rx_qual(rx_qual_map[ + OSMO_MIN(rx_qual_enc, ARRAY_SIZE(rx_qual_map)-1) + ]); +} + +static void get_meas(struct pcu_l1_meas *meas, + const Packet_Resource_Request_t *qr) +{ + unsigned i; + + meas->set_ms_c_value(qr->C_VALUE); + if (qr->Exist_SIGN_VAR) + meas->set_ms_sign_var((qr->SIGN_VAR + 2) / 4); /* SIGN_VAR * 0.25 dB */ + + for (i = 0; i < OSMO_MIN(ARRAY_SIZE(qr->Slot), ARRAY_SIZE(meas->ts)); i++) + { + if (qr->Slot[i].Exist) { + LOGP(DRLCMAC, LOGL_INFO, + "Packet resource request: i_level[%d] = %d\n", + i, qr->Slot[i].I_LEVEL); + meas->set_ms_i_level(i, -2 * qr->Slot[i].I_LEVEL); + } + } +} + +static void get_meas(struct pcu_l1_meas *meas, + const Channel_Quality_Report_t *qr) +{ + unsigned i; + + get_rx_qual_meas(meas, qr->RXQUAL); + meas->set_ms_c_value(qr->C_VALUE); + meas->set_ms_sign_var((qr->SIGN_VAR + 2) / 4); /* SIGN_VAR * 0.25 dB */ + + for (i = 0; i < OSMO_MIN(ARRAY_SIZE(qr->Slot), ARRAY_SIZE(meas->ts)); i++) + { + if (qr->Slot[i].Exist) { + LOGP(DRLCMAC, LOGL_INFO, + "Channel quality report: i_level[%d] = %d\n", + i, qr->Slot[i].I_LEVEL_TN); + meas->set_ms_i_level(i, -2 * qr->Slot[i].I_LEVEL_TN); + } + } +} + +void gprs_rlcmac_pdch::rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *ack_nack, uint32_t fn) +{ + int8_t tfi = 0; /* must be signed */ + struct gprs_rlcmac_dl_tbf *tbf; + int rc; + struct pcu_l1_meas meas; + int num_blocks; + uint8_t bits_data[RLC_GPRS_WS/8]; + bitvec bits; + int bsn_begin, bsn_end; + char show_bits[RLC_GPRS_WS + 1]; + + tfi = ack_nack->DOWNLINK_TFI; + tbf = bts()->dl_tbf_by_poll_fn(fn, trx_no(), ts_no); + if (!tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "RX: [PCU <- BTS] PACKET DOWNLINK ACK with " + "unknown FN=%u TFI=%d (TRX %d TS %d)\n", + fn, tfi, trx_no(), ts_no); + return; + } + if (tbf->tfi() != tfi) { + LOGP(DRLCMAC, LOGL_NOTICE, "RX: [PCU <- BTS] PACKET DOWNLINK ACK with " + "wrong TFI=%d, ignoring!\n", tfi); + return; + } + tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_DL_ACK); + if ((tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK))) { + tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK); + LOGP(DRLCMAC, LOGL_NOTICE, "Recovered downlink ack " + "for %s\n", tbf_name(tbf)); + } + /* reset N3105 */ + tbf->n3105 = 0; + tbf->stop_t3191(); + LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] %s Packet Downlink Ack/Nack\n", tbf_name(tbf)); + tbf->poll_state = GPRS_RLCMAC_POLL_NONE; + + bits.data = bits_data; + bits.data_len = sizeof(bits_data); + bits.cur_bit = 0; + + num_blocks = Decoding::decode_gprs_acknack_bits( + &ack_nack->Ack_Nack_Description, &bits, + &bsn_begin, &bsn_end, &tbf->m_window); + + LOGP(DRLCMAC, LOGL_DEBUG, + "Got GPRS DL ACK bitmap: SSN: %d, BSN %d to %d - 1 (%d blocks), " + "\"%s\"\n", + ack_nack->Ack_Nack_Description.STARTING_SEQUENCE_NUMBER, + bsn_begin, bsn_end, num_blocks, + (Decoding::extract_rbb(&bits, show_bits), show_bits)); + + rc = tbf->rcvd_dl_ack( + ack_nack->Ack_Nack_Description.FINAL_ACK_INDICATION, + bsn_begin, &bits); + if (rc == 1) { + tbf_free(tbf); + return; + } + /* check for channel request */ + if (ack_nack->Exist_Channel_Request_Description) { + + bts()->channel_request_description(); + + /* This call will register the new TBF with the MS on success */ + gprs_rlcmac_ul_tbf *ul_tbf = tbf_alloc_ul(bts_data(), + tbf->trx->trx_no, + tbf->ms_class(), tbf->ms()->egprs_ms_class(), + tbf->tlli(), tbf->ta(), tbf->ms()); + + /* schedule uplink assignment or reject*/ + if (ul_tbf) { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack " + "message, so we provide one:\n"); + tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS; + } else { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack " + "message, so we pacekt access reject:\n"); + tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ; + } + } + /* get measurements */ + if (tbf->ms()) { + get_meas(&meas, &ack_nack->Channel_Quality_Report); + tbf->ms()->update_l1_meas(&meas); + } +} + +void gprs_rlcmac_pdch::rcv_control_egprs_dl_ack_nack(EGPRS_PD_AckNack_t *ack_nack, uint32_t fn) +{ + int8_t tfi = 0; /* must be signed */ + struct gprs_rlcmac_dl_tbf *tbf; + struct pcu_l1_meas meas; + int rc; + int num_blocks; + uint8_t bits_data[RLC_EGPRS_MAX_WS/8]; + char show_bits[RLC_EGPRS_MAX_WS + 1]; + bitvec bits; + int bsn_begin, bsn_end; + + tfi = ack_nack->DOWNLINK_TFI; + tbf = bts()->dl_tbf_by_poll_fn(fn, trx_no(), ts_no); + if (!tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "EGPRS PACKET DOWNLINK ACK with " + "unknown FN=%u TFI=%d (TRX %d TS %d)\n", + fn, tfi, trx_no(), ts_no); + return; + } + if (tbf->tfi() != tfi) { + LOGP(DRLCMAC, LOGL_NOTICE, "EGPRS PACKET DOWNLINK ACK with " + "wrong TFI=%d, ignoring!\n", tfi); + return; + } + tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_DL_ACK); + if ((tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK))) { + tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK); + LOGP(DRLCMAC, LOGL_NOTICE, "Recovered EGPRS downlink ack " + "for %s\n", tbf_name(tbf)); + } + /* reset N3105 */ + tbf->n3105 = 0; + tbf->stop_t3191(); + LOGP(DRLCMAC, LOGL_DEBUG, + "RX: [PCU <- BTS] %s EGPRS Packet Downlink Ack/Nack\n", + tbf_name(tbf)); + tbf->poll_state = GPRS_RLCMAC_POLL_NONE; + + LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS ACK/NACK: " + "ut: %d, final: %d, bow: %d, eow: %d, ssn: %d, have_crbb: %d, " + "urbb_len:%d, %p, %p, %d, %d, win: %d-%d, urbb: %s\n", + (int)ack_nack->EGPRS_AckNack.UnionType, + (int)ack_nack->EGPRS_AckNack.Desc.FINAL_ACK_INDICATION, + (int)ack_nack->EGPRS_AckNack.Desc.BEGINNING_OF_WINDOW, + (int)ack_nack->EGPRS_AckNack.Desc.END_OF_WINDOW, + (int)ack_nack->EGPRS_AckNack.Desc.STARTING_SEQUENCE_NUMBER, + (int)ack_nack->EGPRS_AckNack.Desc.Exist_CRBB, + (int)ack_nack->EGPRS_AckNack.Desc.URBB_LENGTH, + (void *)&ack_nack->EGPRS_AckNack.UnionType, + (void *)&ack_nack->EGPRS_AckNack.Desc, + (int)offsetof(EGPRS_AckNack_t, Desc), + (int)offsetof(EGPRS_AckNack_w_len_t, Desc), + tbf->m_window.v_a(), + tbf->m_window.v_s(), + osmo_hexdump((const uint8_t *)&ack_nack->EGPRS_AckNack.Desc.URBB, + sizeof(ack_nack->EGPRS_AckNack.Desc.URBB))); + + bits.data = bits_data; + bits.data_len = sizeof(bits_data); + bits.cur_bit = 0; + + num_blocks = Decoding::decode_egprs_acknack_bits( + &ack_nack->EGPRS_AckNack.Desc, &bits, + &bsn_begin, &bsn_end, &tbf->m_window); + + LOGP(DRLCMAC, LOGL_DEBUG, + "Got EGPRS DL ACK bitmap: SSN: %d, BSN %d to %d - 1 (%d blocks), " + "\"%s\"\n", + ack_nack->EGPRS_AckNack.Desc.STARTING_SEQUENCE_NUMBER, + bsn_begin, bsn_end, num_blocks, + (Decoding::extract_rbb(&bits, show_bits), show_bits) + ); + + rc = tbf->rcvd_dl_ack( + ack_nack->EGPRS_AckNack.Desc.FINAL_ACK_INDICATION, + bsn_begin, &bits); + if (rc == 1) { + tbf_free(tbf); + return; + } + + /* check for channel request */ + if (ack_nack->Exist_ChannelRequestDescription) { + + bts()->channel_request_description(); + + /* This call will register the new TBF with the MS on success */ + gprs_rlcmac_ul_tbf *ul_tbf = tbf_alloc_ul(bts_data(), + tbf->trx->trx_no, + tbf->ms_class(), tbf->ms()->egprs_ms_class(), + tbf->tlli(), tbf->ta(), tbf->ms()); + + /* schedule uplink assignment or reject*/ + if (ul_tbf) { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack " + "message, so we provide one:\n"); + tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS; + } else { + LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack " + "message, so we send packet access reject:\n"); + tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ; + } + } + + /* get measurements */ + if (tbf->ms()) { + /* TODO: Implement Measurements parsing for EGPRS */ + /* + get_meas(&meas, &ack_nack->Channel_Quality_Report); + tbf->ms()->update_l1_meas(&meas); + */ + } +} + +void gprs_rlcmac_pdch::rcv_resource_request(Packet_Resource_Request_t *request, uint32_t fn) +{ + struct gprs_rlcmac_sba *sba; + + if (request->ID.UnionType) { + struct gprs_rlcmac_ul_tbf *ul_tbf = NULL; + struct gprs_rlcmac_dl_tbf *dl_tbf = NULL; + uint32_t tlli = request->ID.u.TLLI; + uint8_t ms_class = 0; + uint8_t egprs_ms_class = 0; + uint8_t ta = GSM48_TA_INVALID; + struct pcu_l1_meas meas; + + GprsMs *ms = bts()->ms_by_tlli(tlli); + /* Keep the ms, even if it gets idle temporarily */ + GprsMs::Guard guard(ms); + + if (ms) { + ul_tbf = ms->ul_tbf(); + dl_tbf = ms->dl_tbf(); + ta = ms->ta(); + } + + LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] Resource Request over PDCH\n"); + + /* We got a RACH so the MS was in packet idle mode and thus + * didn't have any active TBFs */ + if (ul_tbf) { + LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from " + "TLLI=0x%08x while %s still " + "exists. Killing pending UL TBF\n", + tlli, tbf_name(ul_tbf)); + tbf_free(ul_tbf); + ul_tbf = NULL; + } + + if (dl_tbf) { + LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from " + "TLLI=0x%08x while %s still exists. " + "Release pending DL TBF\n", tlli, + tbf_name(dl_tbf)); + tbf_free(dl_tbf); + dl_tbf = NULL; + } + LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] MS requests UL TBF " + "in packet resource request of single " + "block, so we provide one:\n"); + sba = bts()->sba()->find(this, fn); + if (!sba) { + LOGP(DRLCMAC, LOGL_NOTICE, "MS requests UL TBF " + "in packet resource request of single " + "block, but there is no resource request " + "scheduled!\n"); + } else { + ta = sba->ta; + bts()->sba()->free_sba(sba); + } + if (request->Exist_MS_Radio_Access_capability) { + ms_class = Decoding::get_ms_class_by_capability( + &request->MS_Radio_Access_capability); + egprs_ms_class = + Decoding::get_egprs_ms_class_by_capability( + &request->MS_Radio_Access_capability); + } + if (!ms_class) + LOGP(DRLCMAC, LOGL_NOTICE, "MS does not give us a class.\n"); + if (egprs_ms_class) + LOGP(DRLCMAC, LOGL_NOTICE, + "MS supports EGPRS multislot class %d.\n", + egprs_ms_class); + ul_tbf = tbf_alloc_ul(bts_data(), trx_no(), ms_class, + egprs_ms_class, tlli, ta, ms); + if (!ul_tbf) + return; + + /* set control ts to current MS's TS, until assignment complete */ + LOGP(DRLCMAC, LOGL_DEBUG, "Change control TS to %d until assinment is complete.\n", ts_no); + ul_tbf->control_ts = ts_no; + /* schedule uplink assignment */ + ul_tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS; + + /* get capabilities */ + if (ul_tbf->ms()) + ul_tbf->ms()->set_egprs_ms_class(egprs_ms_class); + + /* get measurements */ + if (ul_tbf->ms()) { + get_meas(&meas, request); + ul_tbf->ms()->update_l1_meas(&meas); + } + return; + } + + if (request->ID.u.Global_TFI.UnionType) { + struct gprs_rlcmac_dl_tbf *dl_tbf; + int8_t tfi = request->ID.u.Global_TFI.u.DOWNLINK_TFI; + dl_tbf = bts()->dl_tbf_by_tfi(tfi, trx_no(), ts_no); + if (!dl_tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "PACKET RESSOURCE REQ unknown downlink TFI=%d\n", tfi); + return; + } + LOGP(DRLCMAC, LOGL_ERROR, + "RX: [PCU <- BTS] %s FIXME: Packet resource request\n", + tbf_name(dl_tbf)); + } else { + struct gprs_rlcmac_ul_tbf *ul_tbf; + int8_t tfi = request->ID.u.Global_TFI.u.UPLINK_TFI; + ul_tbf = bts()->ul_tbf_by_tfi(tfi, trx_no(), ts_no); + if (!ul_tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "PACKET RESSOURCE REQ unknown uplink TFI=%d\n", tfi); + return; + } + LOGP(DRLCMAC, LOGL_ERROR, + "RX: [PCU <- BTS] %s FIXME: Packet resource request\n", + tbf_name(ul_tbf)); + } +} + +void gprs_rlcmac_pdch::rcv_measurement_report(Packet_Measurement_Report_t *report, uint32_t fn) +{ + struct gprs_rlcmac_sba *sba; + + LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] Measurement Report\n"); + sba = bts()->sba()->find(this, fn); + if (!sba) { + LOGP(DRLCMAC, LOGL_NOTICE, "MS send measurement " + "in packet resource request of single " + "block, but there is no resource request " + "scheduled! TLLI=0x%08x\n", report->TLLI); + } else { + GprsMs *ms = bts()->ms_store().get_ms(report->TLLI); + if (!ms) + LOGP(DRLCMAC, LOGL_NOTICE, "MS send measurement " + "but TLLI 0x%08x is unknown\n", report->TLLI); + else + ms->set_ta(sba->ta); + + bts()->sba()->free_sba(sba); + } + gprs_rlcmac_meas_rep(report); +} + +/* Received Uplink RLC control block. */ +int gprs_rlcmac_pdch::rcv_control_block( + bitvec *rlc_block, uint32_t fn) +{ + RlcMacUplink_t * ul_control_block = (RlcMacUplink_t *)talloc_zero(tall_pcu_ctx, RlcMacUplink_t); + LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ RX : Uplink Control Block +++++++++++++++++++++++++\n"); + decode_gsm_rlcmac_uplink(rlc_block, ul_control_block); + LOGPC(DCSN1, LOGL_NOTICE, "\n"); + LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- RX : Uplink Control Block -------------------------\n"); + bts()->rlc_rcvd_control(); + switch (ul_control_block->u.MESSAGE_TYPE) { + case MT_PACKET_CONTROL_ACK: + rcv_control_ack(&ul_control_block->u.Packet_Control_Acknowledgement, fn); + break; + case MT_PACKET_DOWNLINK_ACK_NACK: + rcv_control_dl_ack_nack(&ul_control_block->u.Packet_Downlink_Ack_Nack, fn); + break; + case MT_EGPRS_PACKET_DOWNLINK_ACK_NACK: + rcv_control_egprs_dl_ack_nack(&ul_control_block->u.Egprs_Packet_Downlink_Ack_Nack, fn); + break; + case MT_PACKET_RESOURCE_REQUEST: + rcv_resource_request(&ul_control_block->u.Packet_Resource_Request, fn); + break; + case MT_PACKET_MEASUREMENT_REPORT: + rcv_measurement_report(&ul_control_block->u.Packet_Measurement_Report, fn); + break; + case MT_PACKET_UPLINK_DUMMY_CONTROL_BLOCK: + /* ignoring it. change the SI to not force sending these? */ + break; + default: + bts()->decode_error(); + LOGP(DRLCMAC, LOGL_NOTICE, + "RX: [PCU <- BTS] unknown control block(%d) received\n", + ul_control_block->u.MESSAGE_TYPE); + } + talloc_free(ul_control_block); + return 1; +} + + +/* received RLC/MAC block from L1 */ +int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn, + struct pcu_l1_meas *meas) +{ + GprsCodingScheme cs = GprsCodingScheme::getBySizeUL(len); + if (!cs) { + bts()->decode_error(); + LOGP(DRLCMACUL, LOGL_ERROR, "Dropping data block with invalid" + "length: %d)\n", len); + return -EINVAL; + } + + bts()->rlc_ul_bytes(len); + + LOGP(DRLCMACUL, LOGL_DEBUG, "Got RLC block, coding scheme: %s, " + "length: %d (%d))\n", cs.name(), len, cs.usedSizeUL()); + + if (cs.isGprs()) + return rcv_block_gprs(data, fn, meas, cs); + + if (cs.isEgprs()) + return rcv_data_block(data, fn, meas, cs); + + bts()->decode_error(); + LOGP(DRLCMACUL, LOGL_ERROR, "Unsupported coding scheme %s\n", + cs.name()); + return -EINVAL; +} + +/*! \brief process egprs and gprs data blocks */ +int gprs_rlcmac_pdch::rcv_data_block(uint8_t *data, uint32_t fn, + struct pcu_l1_meas *meas, GprsCodingScheme cs) +{ + int rc; + struct gprs_rlc_data_info rlc_dec; + struct gprs_rlcmac_ul_tbf *tbf; + unsigned len = cs.sizeUL(); + + /* These are always data blocks, since EGPRS still uses CS-1 for + * control blocks (see 44.060, section 10.3, 1st par.) + */ + if (cs.isEgprs()) { + if (!bts()->bts_data()->egprs_enabled) { + LOGP(DRLCMACUL, LOGL_ERROR, + "Got %s RLC block but EGPRS is not enabled\n", + cs.name()); + return -EINVAL; + } + } + + LOGP(DRLCMACUL, LOGL_DEBUG, " UL data: %s\n", osmo_hexdump(data, len)); + rc = Decoding::rlc_parse_ul_data_header(&rlc_dec, data, cs); + if (rc < 0) { + LOGP(DRLCMAC, LOGL_ERROR, + "Got %s RLC block but header parsing has failed\n", + cs.name()); + bts()->decode_error(); + return rc; + } + + LOGP(DRLCMACUL, LOGL_INFO, + "Got %s RLC block: " + "R=%d, SI=%d, TFI=%d, CPS=%d, RSB=%d, " + "rc=%d\n", + cs.name(), + rlc_dec.r, rlc_dec.si, rlc_dec.tfi, rlc_dec.cps, rlc_dec.rsb, + rc); + + /* find TBF inst from given TFI */ + tbf = ul_tbf_by_tfi(rlc_dec.tfi); + if (!tbf) { + LOGP(DRLCMAC, LOGL_NOTICE, "UL DATA unknown TFI=%d\n", + rlc_dec.tfi); + return 0; + } + LOGP(DRLCMAC, LOGL_DEBUG, "[RX: PCU <- BTS] %s UL data\n", tbf->name()); + + return tbf->rcv_data_block_acknowledged(&rlc_dec, data, meas); +} + +int gprs_rlcmac_pdch::rcv_block_gprs(uint8_t *data, uint32_t fn, + struct pcu_l1_meas *meas, GprsCodingScheme cs) +{ + unsigned payload = data[0] >> 6; + bitvec *block; + int rc = 0; + unsigned len = cs.maxBytesUL(); + + switch (payload) { + case GPRS_RLCMAC_DATA_BLOCK: + rc = rcv_data_block(data, fn, meas, cs); + break; + case GPRS_RLCMAC_CONTROL_BLOCK: + block = bitvec_alloc(len); + if (!block) + return -ENOMEM; + bitvec_unpack(block, data); + rc = rcv_control_block(block, fn); + bitvec_free(block); + break; + case GPRS_RLCMAC_CONTROL_BLOCK_OPT: + LOGP(DRLCMAC, LOGL_NOTICE, "GPRS_RLCMAC_CONTROL_BLOCK_OPT block payload is not supported.\n"); + break; + default: + LOGP(DRLCMAC, LOGL_NOTICE, "Unknown RLCMAC block payload(%u).\n", payload); + rc = -EINVAL; + } + + return rc; +} + +void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, + uint8_t ta) +{ + struct gprs_rlcmac_ul_tbf *tbf = + bts_main_data()->bts->ul_tbf_by_poll_fn(fn, trx_no, ts); + if (!tbf) + LOGP(DL1IF, LOGL_DEBUG, "[%s] update TA = %u ignored due to " + "unknown UL TBF on TRX = %d, TS = %d, FN = %d\n", + p, ta, trx_no, ts, fn); + else if (tbf->ta() != ta) { + LOGP(DL1IF, LOGL_INFO, "[%s] Updating TA %u -> %u on " + "TRX = %d, TS = %d, FN = %d\n", + p, tbf->ta(), ta, trx_no, ts, fn); + tbf->set_ta(ta); + } +} + +gprs_rlcmac_tbf *gprs_rlcmac_pdch::tbf_from_list_by_tfi( + LListHead *tbf_list, uint8_t tfi, + enum gprs_rlcmac_tbf_direction dir) +{ + gprs_rlcmac_tbf *tbf; + LListHead *pos; + + llist_for_each(pos, tbf_list) { + tbf = pos->entry(); + if (tbf->tfi() != tfi) + continue; + if (!tbf->pdch[ts_no]) + continue; + return tbf; + } + return NULL; +} + +gprs_rlcmac_ul_tbf *gprs_rlcmac_pdch::ul_tbf_by_tfi(uint8_t tfi) +{ + return as_ul_tbf(tbf_by_tfi(tfi, GPRS_RLCMAC_UL_TBF)); +} + +gprs_rlcmac_dl_tbf *gprs_rlcmac_pdch::dl_tbf_by_tfi(uint8_t tfi) +{ + return as_dl_tbf(tbf_by_tfi(tfi, GPRS_RLCMAC_DL_TBF)); +} + +/* lookup TBF Entity (by TFI) */ +gprs_rlcmac_tbf *gprs_rlcmac_pdch::tbf_by_tfi(uint8_t tfi, + enum gprs_rlcmac_tbf_direction dir) +{ + struct gprs_rlcmac_tbf *tbf; + + if (tfi >= 32) + return NULL; + + tbf = m_tbfs[dir][tfi]; + + if (!tbf) + return NULL; + + if (tbf->state_is_not(GPRS_RLCMAC_RELEASING)) { + return tbf; + } + + return NULL; +} + +void gprs_rlcmac_pdch::attach_tbf(gprs_rlcmac_tbf *tbf) +{ + gprs_rlcmac_ul_tbf *ul_tbf; + + if (m_tbfs[tbf->direction][tbf->tfi()]) + LOGP(DRLCMAC, LOGL_ERROR, "PDCH(TS %d, TRX %d): " + "%s has not been detached, overwriting it\n", + ts_no, trx_no(), + m_tbfs[tbf->direction][tbf->tfi()]->name()); + + m_num_tbfs[tbf->direction] += 1; + if (tbf->direction == GPRS_RLCMAC_UL_TBF) { + ul_tbf = as_ul_tbf(tbf); + m_assigned_usf |= 1 << ul_tbf->m_usf[ts_no]; + } + m_assigned_tfi[tbf->direction] |= 1UL << tbf->tfi(); + m_tbfs[tbf->direction][tbf->tfi()] = tbf; + + LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Attaching %s, %d TBFs, " + "USFs = %02x, TFIs = %08x.\n", + ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction], + m_assigned_usf, m_assigned_tfi[tbf->direction]); +} + +void gprs_rlcmac_pdch::detach_tbf(gprs_rlcmac_tbf *tbf) +{ + gprs_rlcmac_ul_tbf *ul_tbf; + + OSMO_ASSERT(m_num_tbfs[tbf->direction] > 0); + + m_num_tbfs[tbf->direction] -= 1; + if (tbf->direction == GPRS_RLCMAC_UL_TBF) { + ul_tbf = as_ul_tbf(tbf); + m_assigned_usf &= ~(1 << ul_tbf->m_usf[ts_no]); + } + m_assigned_tfi[tbf->direction] &= ~(1UL << tbf->tfi()); + m_tbfs[tbf->direction][tbf->tfi()] = NULL; + + LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Detaching %s, %d TBFs, " + "USFs = %02x, TFIs = %08x.\n", + ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction], + m_assigned_usf, m_assigned_tfi[tbf->direction]); +} + +void gprs_rlcmac_pdch::reserve(enum gprs_rlcmac_tbf_direction dir) +{ + m_num_reserved[dir] += 1; +} + +void gprs_rlcmac_pdch::unreserve(enum gprs_rlcmac_tbf_direction dir) +{ + OSMO_ASSERT(m_num_reserved[dir] > 0); + m_num_reserved[dir] -= 1; +} + +void gprs_rlcmac_trx::reserve_slots(enum gprs_rlcmac_tbf_direction dir, + uint8_t slots) +{ + unsigned i; + for (i = 0; i < ARRAY_SIZE(pdch); i += 1) + if (slots & (1 << i)) + pdch[i].reserve(dir); +} + +void gprs_rlcmac_trx::unreserve_slots(enum gprs_rlcmac_tbf_direction dir, + uint8_t slots) +{ + unsigned i; + for (i = 0; i < ARRAY_SIZE(pdch); i += 1) + if (slots & (1 << i)) + pdch[i].unreserve(dir); +} diff --git a/src/csn1.cpp b/src/csn1.cpp index a1698a5..6203a44 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -64,15 +64,15 @@ readIndex -= relative_bit_offset; if (bit_shift >= 0) { - result = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) >> bit_shift; + result = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) >> bit_shift; readIndex-= bit_shift; result &= maskBits[no_of_bits]; } else { - guint8 hight_part = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) & maskBits[8 - relative_bit_offset]; + guint8 hight_part = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) & maskBits[8 - relative_bit_offset]; hight_part = (guint8) (hight_part << (-bit_shift)); - result = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) >> (8 + bit_shift); + result = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) >> (8 + bit_shift); readIndex = readIndex - (8 - (-bit_shift)); result |= hight_part; } @@ -133,7 +133,7 @@ static gboolean existNextElement(bitvec *vector, unsigned& readIndex, guint8 Tag) { - guint8 res = bitvec_read_field(vector, readIndex, 1); + guint8 res = bitvec_read_field(vector, &readIndex, 1); if (Tag == STANDARD_TAG) { return (res > 0); @@ -167,7 +167,7 @@ if (remaining_bits_len > 0) { pui8 = pui8DATA(data, pDescr->offset); - *pui8 = bitvec_read_field(vector, readIndex, 1); + *pui8 = bitvec_read_field(vector, &readIndex, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); /* end add the bit value to protocol tree */ } @@ -202,21 +202,21 @@ { if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32; LOGPC(DCSN1, LOGL_NOTICE, "%s = 0x%08x | ", pDescr->sz , *pui32); @@ -264,21 +264,21 @@ { if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8 + (guint8)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); @@ -308,7 +308,7 @@ remaining_bits_len -= no_of_bits; if (no_of_bits <= 8) { - guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); + guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); @@ -347,7 +347,7 @@ pui8 = pui8DATA(data, pDescr->offset); do { - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -401,7 +401,7 @@ LOGPC(DCSN1, LOGL_NOTICE, "%s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { pui8 += nSize; @@ -430,7 +430,7 @@ { for(unsigned ib = 0; ib < 4; ib++) { - guint8 ui8 = bitvec_read_field(vector, readIndex, 8); + guint8 ui8 = bitvec_read_field(vector, &readIndex, 8); pui8 = pui8DATA(data, pDescr->offset+ib); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); @@ -440,7 +440,7 @@ { for(unsigned ib = 0; ib < 8; ib++) { - guint8 ui8 = bitvec_read_field(vector, readIndex, 8); + guint8 ui8 = bitvec_read_field(vector, &readIndex, 8); pui8 = pui8DATA(data, pDescr->offset+ib); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); @@ -467,7 +467,7 @@ csnStream_t arT = *ar; LOGPC(DCSN1, LOGL_NOTICE, " : %s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); LOGPC(DCSN1, LOGL_NOTICE, ": End %s | ", pDescr->sz); if (Status >= 0) { @@ -493,7 +493,7 @@ while (count > 0) { guint8 no_of_bits = pChoice->bits; - guint8 value = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 value = bitvec_read_field(vector, &readIndex, no_of_bits); if (value == pChoice->value) { CSN_DESCR descr[2]; @@ -510,7 +510,7 @@ remaining_bits_len -= no_of_bits; csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, descr, vector, readIndex, data); + Status = csnStreamDecoder(&arT, descr, vector, readIndex, data); if (Status >= 0) { @@ -541,7 +541,7 @@ guint8 length_len = pDescr->i; gint16 Status = -1; - guint8 length = bitvec_read_field(vector, readIndex, length_len); + guint8 length = bitvec_read_field(vector, &readIndex, length_len); LOGPC(DCSN1, LOGL_NOTICE, "%s length = %d | ", pDescr->sz , (int)length); bit_offset += length_len; @@ -550,7 +550,7 @@ csnStreamInit(&arT, bit_offset, length); arT.direction = 1; LOGPC(DCSN1, LOGL_NOTICE, "ptr = %p | offset = %d | ", (void *)data, (int)pDescr->offset); - Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset)); + Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset)); if (Status >= 0) { @@ -595,7 +595,7 @@ } else { - index |= bitvec_read_field(vector, readIndex, 1); + index |= bitvec_read_field(vector, &readIndex, 1); } remaining_bits_len--; bit_offset++; @@ -618,7 +618,7 @@ { pui8 = pui8DATA(data, pDescr->offset); *pui8 = 0x00; - if (bitvec_read_field(vector, readIndex, 1) > 0) + if (bitvec_read_field(vector, &readIndex, 1) > 0) { *pui8 = 0x01; } @@ -644,21 +644,21 @@ if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); @@ -686,21 +686,21 @@ { if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8 + (guint8)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); @@ -728,7 +728,7 @@ { if (no_of_bits <= 8) { - guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); + guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); @@ -767,7 +767,7 @@ while (nCount > 0) { - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -780,7 +780,7 @@ while (nCount > 0) { - *pui16 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui16 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , *pui16); pui16++; bit_offset += no_of_bits; @@ -830,7 +830,7 @@ { LOGPC(DCSN1, LOGL_NOTICE, "%s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { pui8 += nSize; @@ -856,13 +856,13 @@ if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32; } else if (no_of_bits <= 64) { - guint64 ui64 = bitvec_read_field(vector, readIndex, no_of_bits); + guint64 ui64 = bitvec_read_field(vector, &readIndex, no_of_bits); pui64 = pui64DATA(data, pDescr->offset); *pui64 = ui64; LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); @@ -888,7 +888,7 @@ csnStream_t arT = *ar; LOGPC(DCSN1, LOGL_NOTICE, " : %s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); LOGPC(DCSN1, LOGL_NOTICE, " : End %s | ", pDescr->sz); if (Status >= 0) { @@ -923,11 +923,11 @@ if (CSN_EXIST_LH == pDescr->type) { - fExist = get_masked_bits8(vector, readIndex, bit_offset, 1); + fExist = get_masked_bits8(vector, readIndex, bit_offset, 1); } else { - fExist = bitvec_read_field(vector, readIndex, 1); + fExist = bitvec_read_field(vector, &readIndex, 1); } *pui8 = fExist; @@ -966,7 +966,7 @@ /* the "regular" M_NEXT_EXIST description element */ fExist = 0x00; - if (bitvec_read_field(vector, readIndex, 1)) + if (bitvec_read_field(vector, &readIndex, 1)) { fExist = 0x01; } @@ -1059,7 +1059,7 @@ if (nB1 > 0) { /* take care of the first byte - it will be right aligned */ - *pui8 = bitvec_read_field(vector, readIndex, nB1); + *pui8 = bitvec_read_field(vector, &readIndex, nB1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= nB1; @@ -1069,7 +1069,7 @@ /* remaining no_of_bits is a multiple of 8 or 0 */ while (no_of_bits > 0) { - *pui8 = bitvec_read_field(vector, readIndex, 8); + *pui8 = bitvec_read_field(vector, &readIndex, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; @@ -1113,14 +1113,14 @@ while (no_of_bits >= 8) { - *pui8 = bitvec_read_field(vector, readIndex, 8); + *pui8 = bitvec_read_field(vector, &readIndex, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; } if (no_of_bits > 0) { - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -1144,13 +1144,13 @@ guint8 bits_to_handle = remaining_bits_len%8; if (bits_to_handle > 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, readIndex, bits_to_handle)); + LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, bits_to_handle)); remaining_bits_len -= bits_to_handle; bit_offset += bits_to_handle; } else if (bits_to_handle == 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, readIndex, 8)); + LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, 8)); remaining_bits_len -= 8; bit_offset += 8; } @@ -1191,7 +1191,7 @@ while (count > 0) { readIndex -= 8; - *pui8 = bitvec_read_field(vector, readIndex, 8); + *pui8 = bitvec_read_field(vector, &readIndex, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += 8; @@ -1217,14 +1217,14 @@ pui8 = pui8DATA(data, pDescr->offset); - while (existNextElement(vector, readIndex, Tag)) + while (existNextElement(vector, readIndex, Tag)) { /* tag control shows existence of next list elements */ LOGPC(DCSN1, LOGL_NOTICE, "%s = Exist | ", pDescr->sz); bit_offset++; remaining_bits_len--; /* extract and store no_of_bits long element from bitstream */ - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; remaining_bits_len -= no_of_bits; @@ -1238,7 +1238,7 @@ bit_offset += no_of_bits; } - LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, readIndex, 1)); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1)); /* existNextElement() returned FALSE, 1 bit consumed */ bit_offset++; @@ -1258,7 +1258,7 @@ guint8 ElementCount = 0; pui8 = pui8DATA(data, pDescr->offset); - while (existNextElement(vector, readIndex, Tag)) + while (existNextElement(vector, readIndex, Tag)) { /* tag control shows existence of next list elements */ LOGPC(DCSN1, LOGL_NOTICE, "%s = Exist | ", pDescr->sz); /* existNextElement() returned TRUE, 1 bit consumed */ @@ -1270,7 +1270,7 @@ csnStream_t arT = *ar; gint16 Status; csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { /* successful completion */ @@ -1290,7 +1290,7 @@ } } - LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, readIndex, 1)); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1)); /* existNextElement() returned FALSE, 1 bit consumed */ bit_offset++; @@ -1331,7 +1331,7 @@ LOGPC(DCSN1, LOGL_NOTICE, "%s { | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { /* successful completion */ @@ -1351,7 +1351,7 @@ /* control of next element's tag */ LOGPC(DCSN1, LOGL_NOTICE, "%s } | ", pDescr->sz); - EndOfList = !(existNextElement(vector, readIndex, Tag)); + EndOfList = !(existNextElement(vector, readIndex, Tag)); bit_offset++; remaining_bits_len--; /* 1 bit consumed (tag) */ @@ -1372,7 +1372,7 @@ if (no_of_bits <= 32) { - ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); } else { @@ -1449,7 +1449,7 @@ if (remaining_bits_len > 0) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); /* end add the bit value to protocol tree */ } @@ -1483,19 +1483,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); } else @@ -1528,19 +1528,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(*pui8 - (guint8)pDescr->descr.value)); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned short)(*pui16 - (guint16)pDescr->descr.value)); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned int)(*pui32 - (guint16)pDescr->descr.value)); } else @@ -1569,12 +1569,12 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); // TODO : Change get_masked_bits8() writeIndex -= no_of_bits; guint8 ui8 = get_masked_bits8(vector, writeIndex, bit_offset, no_of_bits); writeIndex -= no_of_bits; - bitvec_write_field(vector, writeIndex, ui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, ui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } @@ -1612,7 +1612,7 @@ pui8 = pui8DATA(data, pDescr->offset); do { - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -1697,7 +1697,7 @@ for(unsigned ib = 0; ib < 4; ib++) { pui8 = pui8DATA(data, pDescr->offset+ib); - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); } } @@ -1706,7 +1706,7 @@ for(unsigned ib = 0; ib < 8; ib++) { pui8 = pui8DATA(data, pDescr->offset+ib); - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); } } @@ -1761,7 +1761,7 @@ guint8 no_of_bits = pChoice->bits; guint8 value = pChoice->value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pChoice->descr.sz , (unsigned)value); - bitvec_write_field(vector, writeIndex, value, no_of_bits); + bitvec_write_field(vector, &writeIndex, value, no_of_bits); CSN_DESCR descr[2]; gint16 Status; @@ -1807,7 +1807,7 @@ csnStreamInit(&arT, bit_offset, remaining_bits_len); Status = serialize(&arT, vector, writeIndex, pvDATA(data, pDescr->offset)); - bitvec_write_field(vector, lengthIndex, writeIndex-lengthIndex-length_len, length_len); + bitvec_write_field(vector, &lengthIndex, writeIndex-lengthIndex-length_len, length_len); LOGPC(DCSN1, LOGL_NOTICE, "%s length = %u | ", pDescr->sz , (unsigned)(writeIndex-lengthIndex)); if (Status >= 0) @@ -1846,7 +1846,7 @@ /* Assign UnionType */ pui8 = pui8DATA(data, pDescr->offset); //read index from data and write to vector - bitvec_write_field(vector, writeIndex, *pui8, Bits); + bitvec_write_field(vector, &writeIndex, *pui8, Bits); //decode index writeIndex -= Bits; @@ -1861,7 +1861,7 @@ } else { - index |= bitvec_read_field(vector, writeIndex, 1); + index |= bitvec_read_field(vector, &writeIndex, 1); } remaining_bits_len--; @@ -1870,7 +1870,7 @@ } writeIndex -= Bits; - bitvec_write_field(vector, writeIndex, index, Bits); + bitvec_write_field(vector, &writeIndex, index, Bits); /* script index to continue on, limited in case we do not have a power of 2 */ @@ -1883,7 +1883,7 @@ case CSN_BIT: { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); remaining_bits_len -= 1; bit_offset++; @@ -1907,19 +1907,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); } else @@ -1946,19 +1946,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(*pui8 - (guint8)pDescr->descr.value)); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned short)(*pui16 - (guint16)pDescr->descr.value)); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned int)(*pui32 - (guint16)pDescr->descr.value)); } else @@ -1987,12 +1987,12 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); // TODO : Change get_masked_bits8() writeIndex -= no_of_bits; guint8 ui8 = get_masked_bits8(vector, writeIndex, bit_offset, no_of_bits); writeIndex -= no_of_bits; - bitvec_write_field(vector, writeIndex, ui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, ui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } @@ -2030,7 +2030,7 @@ pui8 = pui8DATA(data, pDescr->offset); do { - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -2112,13 +2112,13 @@ if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); } else if (no_of_bits <= 64) { pui64 = pui64DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui64, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui64, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); } else @@ -2176,7 +2176,7 @@ unsigned exist = 0; pui8 = pui8DATA(data, pDescr->offset); exist = *pui8; - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); writeIndex--; if (CSN_EXIST_LH == pDescr->type) { @@ -2184,10 +2184,10 @@ } else { - fExist = bitvec_read_field(vector, writeIndex, 1); + fExist = bitvec_read_field(vector, &writeIndex, 1); } writeIndex--; - bitvec_write_field(vector, writeIndex, fExist, 1); + bitvec_write_field(vector, &writeIndex, fExist, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz, (unsigned)fExist); pDescr++; remaining_bits_len -= 1; @@ -2217,7 +2217,7 @@ break; } - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); fExist = *pui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); remaining_bits_len -= 1; @@ -2257,11 +2257,11 @@ } /* the "regular" M_NEXT_EXIST_LH description element */ - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); writeIndex--; fExist = get_masked_bits8(vector,writeIndex, bit_offset, 1); writeIndex--; - bitvec_write_field(vector, writeIndex, fExist, 1); + bitvec_write_field(vector, &writeIndex, fExist, 1); pui8++; remaining_bits_len -= 1; @@ -2310,7 +2310,7 @@ if (nB1 > 0) { /* take care of the first byte - it will be right aligned */ - bitvec_write_field(vector, writeIndex, *pui8, nB1); + bitvec_write_field(vector, &writeIndex, *pui8, nB1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= nB1; @@ -2320,7 +2320,7 @@ /* remaining no_of_bits is a multiple of 8 or 0 */ while (no_of_bits > 0) { - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; @@ -2366,14 +2366,14 @@ while (no_of_bits > 0) { - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; } if (nB1 > 0) { - bitvec_write_field(vector, writeIndex, *pui8, nB1); + bitvec_write_field(vector, &writeIndex, *pui8, nB1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= nB1; @@ -2405,14 +2405,14 @@ * < padding bits > ::= { null | 0 < spare padding > ! < Ignore : 1 bit** = < no string > > } ; */ guint8 fl = filler&(0xff>>(8-bits_to_handle + 1)); - bitvec_write_field(vector, writeIndex, fl, bits_to_handle); + bitvec_write_field(vector, &writeIndex, fl, bits_to_handle); LOGPC(DCSN1, LOGL_NOTICE, "%u|", fl); remaining_bits_len -= bits_to_handle; bit_offset += bits_to_handle; } else if (bits_to_handle == 0) { - bitvec_write_field(vector, writeIndex, filler, 8); + bitvec_write_field(vector, &writeIndex, filler, 8); LOGPC(DCSN1, LOGL_NOTICE, "%u|", filler); remaining_bits_len -= 8; bit_offset += 8; @@ -2453,7 +2453,7 @@ while (count > 0) { - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += 8; @@ -2480,13 +2480,13 @@ ElementCount = *pui8DATA(data, (gint16)pDescr->descr.value); while (ElementCount > 0) { /* tag control shows existence of next list elements */ - bitvec_write_field(vector, writeIndex, Tag, 1); + bitvec_write_field(vector, &writeIndex, Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag); bit_offset++; remaining_bits_len--; /* extract and store no_of_bits long element from bitstream */ - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; remaining_bits_len -= no_of_bits; @@ -2500,7 +2500,7 @@ bit_offset += no_of_bits; } - bitvec_write_field(vector, writeIndex, !Tag, 1); + bitvec_write_field(vector, &writeIndex, !Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(!Tag)); bit_offset++; remaining_bits_len--; @@ -2522,7 +2522,7 @@ while (ElementCount > 0) { /* tag control shows existence of next list elements */ - bitvec_write_field(vector, writeIndex, Tag, 1); + bitvec_write_field(vector, &writeIndex, Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag); bit_offset++; @@ -2553,7 +2553,7 @@ } } - bitvec_write_field(vector, writeIndex, !Tag, 1); + bitvec_write_field(vector, &writeIndex, !Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(!Tag)); bit_offset++; @@ -2591,7 +2591,7 @@ { /* get data element */ if (ElementCount != ElementNum) { - bitvec_write_field(vector, writeIndex, Tag, 1); + bitvec_write_field(vector, &writeIndex, Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag); bit_offset++; remaining_bits_len--; @@ -2618,7 +2618,7 @@ } } - bitvec_write_field(vector, writeIndex, !Tag, 1); + bitvec_write_field(vector, &writeIndex, !Tag, 1); bit_offset++; remaining_bits_len--; Tag = STANDARD_TAG; /* in case it was set to "reversed" */ @@ -2629,7 +2629,7 @@ case CSN_FIXED: { /* Verify the fixed bits */ guint8 no_of_bits = (guint8) pDescr->i; - bitvec_write_field(vector, writeIndex, pDescr->offset, no_of_bits); + bitvec_write_field(vector, &writeIndex, pDescr->offset, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)pDescr->offset); remaining_bits_len -= no_of_bits; bit_offset += no_of_bits; diff --git a/src/csn1.h b/src/csn1.h index 96f7558..3f5b849 100644 --- a/src/csn1.h +++ b/src/csn1.h @@ -25,7 +25,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +extern "C" { +#include +} + #include #include #ifndef _PACKET_CSN1_H_ diff --git a/src/egprs_rlc_compression.cpp b/src/egprs_rlc_compression.cpp index 82605ff..7eeb7d2 100644 --- a/src/egprs_rlc_compression.cpp +++ b/src/egprs_rlc_compression.cpp @@ -528,10 +528,10 @@ /* put run length of Ones in uncompressed bitmap */ while (run_length != 0) { if (run_length > 8) { - bitvec_write_field(dest, wp, data, 8); + bitvec_write_field(dest, &wp, data, 8); run_length = run_length - 8; } else { - bitvec_write_field(dest, wp, data, run_length); + bitvec_write_field(dest, &wp, data, run_length); run_length = 0; } } @@ -581,7 +581,7 @@ *codewrd_bitmap = t4_term[start][*run_len_cnt]; *codewrd_len = t4_term_length[start][*run_len_cnt]; } - bitvec_write_field(crbb_vec, writeIndex, *codewrd_bitmap, *codewrd_len); + bitvec_write_field(crbb_vec, &writeIndex, *codewrd_bitmap, *codewrd_len); } /* Compress received block bitmap */ diff --git a/src/encoding.cpp b/src/encoding.cpp index ea38b77..ed8fdaa 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -40,12 +40,12 @@ static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai) { if (tai < 0) { /* No TIMING_ADVANCE_INDEX: */ - bitvec_write_field(dest, wp, 0, 1); + bitvec_write_field(dest, &wp, 0, 1); return false; } /* TIMING_ADVANCE_INDEX: */ - bitvec_write_field(dest, wp, 1, 1); - bitvec_write_field(dest, wp, tai, 4); + bitvec_write_field(dest, &wp, 1, 1); + bitvec_write_field(dest, &wp, tai, 4); return true; } @@ -53,10 +53,10 @@ static inline void write_ta(bitvec *dest, unsigned& wp, int8_t ta) { if (ta < 0) /* No TIMING_ADVANCE_VALUE: */ - bitvec_write_field(dest, wp, 0, 1); + bitvec_write_field(dest, &wp, 0, 1); else { /* TIMING_ADVANCE_VALUE: */ - bitvec_write_field(dest, wp, 1, 1); - bitvec_write_field(dest, wp, ta, 6); + bitvec_write_field(dest, &wp, 1, 1); + bitvec_write_field(dest, &wp, ta, 6); } } @@ -70,7 +70,7 @@ { write_ta(dest, wp, ta); if (write_tai(dest, wp, tai)) /* TIMING_ADVANCE_TIMESLOT_NUMBER: */ - bitvec_write_field(dest, wp, ts, 3); + bitvec_write_field(dest, &wp, ts, 3); } static int write_ia_rest_downlink( @@ -85,40 +85,40 @@ return -EINVAL; } // GSM 04.08 10.5.2.16 IA Rest Octets - bitvec_write_field_lh(dest, wp, 3, 2); // "HH" - bitvec_write_field(dest, wp, 1, 2); // "01" Packet Downlink Assignment - bitvec_write_field(dest, wp,tbf->tlli(),32); // TLLI - bitvec_write_field(dest, wp,0x1,1); // switch TFI : on - bitvec_write_field(dest, wp,tbf->tfi(),5); // TFI - bitvec_write_field(dest, wp,0x0,1); // RLC acknowledged mode + bitvec_write_field(dest, &wp, 3, 2); // "HH" + bitvec_write_field(dest, &wp, 1, 2); // "01" Packet Downlink Assignment + bitvec_write_field(dest, &wp,tbf->tlli(),32); // TLLI + bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on + bitvec_write_field(dest, &wp,tbf->tfi(),5); // TFI + bitvec_write_field(dest, &wp,0x0,1); // RLC acknowledged mode if (alpha) { - bitvec_write_field(dest, wp,0x1,1); // ALPHA = present - bitvec_write_field(dest, wp,alpha,4); // ALPHA + bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present + bitvec_write_field(dest, &wp,alpha,4); // ALPHA } else { - bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present + bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present } - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter - bitvec_write_field(dest, wp,polling,1); // Polling Bit - bitvec_write_field(dest, wp, ta_valid, 1); // N. B: NOT related to TAI! + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,polling,1); // Polling Bit + bitvec_write_field(dest, &wp, ta_valid, 1); // N. B: NOT related to TAI! write_tai(dest, wp, ta_idx); if (polling) { - bitvec_write_field(dest, wp,0x1,1); // TBF Starting TIME present - bitvec_write_field(dest, wp,(fn / (26 * 51)) % 32,5); // T1' - bitvec_write_field(dest, wp,fn % 51,6); // T3 - bitvec_write_field(dest, wp,fn % 26,5); // T2 + bitvec_write_field(dest, &wp,0x1,1); // TBF Starting TIME present + bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1' + bitvec_write_field(dest, &wp,fn % 51,6); // T3 + bitvec_write_field(dest, &wp,fn % 26,5); // T2 } else { - bitvec_write_field(dest, wp,0x0,1); // TBF Starting TIME present + bitvec_write_field(dest, &wp,0x0,1); // TBF Starting TIME present } - bitvec_write_field(dest, wp,0x0,1); // P0 not present - // bitvec_write_field(dest, wp,0x1,1); // P0 not present - // bitvec_write_field(dest, wp,0xb,4); + bitvec_write_field(dest, &wp,0x0,1); // P0 not present + // bitvec_write_field(dest, &wp,0x1,1); // P0 not present + // bitvec_write_field(dest, &wp,,0xb,4); if (tbf->is_egprs_enabled()) { /* see GMS 44.018, 10.5.2.16 */ unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32; - bitvec_write_field_lh(dest, wp, 1, 1); // "H" - bitvec_write_field(dest, wp, ws_enc,5); // EGPRS Window Size - bitvec_write_field(dest, wp, 0x0,2); // LINK_QUALITY_MEASUREMENT_MODE - bitvec_write_field(dest, wp, 0,1); // BEP_PERIOD2 not present + bitvec_write_field(dest, &wp, 1, 1); // "H" + bitvec_write_field(dest, &wp, ws_enc, 5); // EGPRS Window Size + bitvec_write_field(dest, &wp, 0x0, 2); // LINK_QUALITY_MEASUREMENT_MODE + bitvec_write_field(dest, &wp, 0, 1); // BEP_PERIOD2 not present } return 0; @@ -133,40 +133,40 @@ OSMO_ASSERT(!tbf || !tbf->is_egprs_enabled()); // GMS 04.08 10.5.2.37b 10.5.2.16 - bitvec_write_field_lh(dest, wp, 3, 2); // "HH" - bitvec_write_field(dest, wp, 0, 2); // "0" Packet Uplink Assignment + bitvec_write_field(dest, &wp, 3, 2); // "HH" + bitvec_write_field(dest, &wp, 0, 2); // "0" Packet Uplink Assignment if (tbf == NULL) { - bitvec_write_field(dest, wp, 0, 1); // Block Allocation : Single Block Allocation + bitvec_write_field(dest, &wp, 0, 1); // Block Allocation : Single Block Allocation if (alpha) { - bitvec_write_field(dest, wp,0x1,1); // ALPHA = present - bitvec_write_field(dest, wp,alpha,4); // ALPHA = present + bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present + bitvec_write_field(dest, &wp,alpha,4); // ALPHA = present } else - bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter write_tai(dest, wp, ta_idx); - bitvec_write_field(dest, wp, 1, 1); // TBF_STARTING_TIME_FLAG - bitvec_write_field(dest, wp,(fn / (26 * 51)) % 32,5); // T1' - bitvec_write_field(dest, wp,fn % 51,6); // T3 - bitvec_write_field(dest, wp,fn % 26,5); // T2 + bitvec_write_field(dest, &wp, 1, 1); // TBF_STARTING_TIME_FLAG + bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1' + bitvec_write_field(dest, &wp,fn % 51,6); // T3 + bitvec_write_field(dest, &wp,fn % 26,5); // T2 } else { - bitvec_write_field(dest, wp, 1, 1); // Block Allocation : Not Single Block Allocation - bitvec_write_field(dest, wp, tbf->tfi(), 5); // TFI_ASSIGNMENT Temporary Flow Identity - bitvec_write_field(dest, wp, 0, 1); // POLLING - bitvec_write_field(dest, wp, 0, 1); // ALLOCATION_TYPE: dynamic - bitvec_write_field(dest, wp, usf, 3); // USF - bitvec_write_field(dest, wp, 0, 1); // USF_GRANULARITY - bitvec_write_field(dest, wp, 0, 1); // "0" power control: Not Present - bitvec_write_field(dest, wp, tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND - bitvec_write_field(dest, wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING + bitvec_write_field(dest, &wp, 1, 1); // Block Allocation : Not Single Block Allocation + bitvec_write_field(dest, &wp, tbf->tfi(), 5); // TFI_ASSIGNMENT Temporary Flow Identity + bitvec_write_field(dest, &wp, 0, 1); // POLLING + bitvec_write_field(dest, &wp, 0, 1); // ALLOCATION_TYPE: dynamic + bitvec_write_field(dest, &wp, usf, 3); // USF + bitvec_write_field(dest, &wp, 0, 1); // USF_GRANULARITY + bitvec_write_field(dest, &wp, 0, 1); // "0" power control: Not Present + bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING if (alpha) { - bitvec_write_field(dest, wp,0x1,1); // ALPHA = present - bitvec_write_field(dest, wp,alpha,4); // ALPHA + bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present + bitvec_write_field(dest, &wp,alpha,4); // ALPHA } else - bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter /* note: there is no choise for TAI and no starting time */ - bitvec_write_field(dest, wp, 0, 1); // switch TIMING_ADVANCE_INDEX = off - bitvec_write_field(dest, wp, 0, 1); // TBF_STARTING_TIME_FLAG + bitvec_write_field(dest, &wp, 0, 1); // switch TIMING_ADVANCE_INDEX = off + bitvec_write_field(dest, &wp, 0, 1); // TBF_STARTING_TIME_FLAG } return 0; } @@ -183,60 +183,60 @@ extended_ra = (ra & 0x1F); - bitvec_write_field(dest, wp, 1, 2); /* LH */ - bitvec_write_field(dest, wp, 0, 2); /* 0 EGPRS Uplink Assignment */ - bitvec_write_field(dest, wp, extended_ra, 5); /* Extended RA */ - bitvec_write_field(dest, wp, 0, 1); /* Access technology Request */ + bitvec_write_field(dest, &wp, 1, 2); /* LH */ + bitvec_write_field(dest, &wp, 0, 2); /* 0 EGPRS Uplink Assignment */ + bitvec_write_field(dest, &wp, extended_ra, 5); /* Extended RA */ + bitvec_write_field(dest, &wp, 0, 1); /* Access technology Request */ if (tbf == NULL) { - bitvec_write_field(dest, wp, 0, 1); /* multiblock allocation */ + bitvec_write_field(dest, &wp, 0, 1); /* multiblock allocation */ if (alpha) { - bitvec_write_field(dest, wp, 0x1, 1); /* ALPHA =yes */ - bitvec_write_field(dest, wp, alpha, 4); /* ALPHA */ + bitvec_write_field(dest, &wp, 0x1, 1); /* ALPHA =yes */ + bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */ } else { - bitvec_write_field(dest, wp, 0x0, 1); /* ALPHA = no */ + bitvec_write_field(dest, &wp, 0x0, 1); /* ALPHA = no */ } - bitvec_write_field(dest, wp, gamma, 5); /* GAMMA power contrl */ - bitvec_write_field(dest, wp, (fn / (26 * 51)) % 32, 5);/* T1' */ - bitvec_write_field(dest, wp, fn % 51, 6); /* T3 */ - bitvec_write_field(dest, wp, fn % 26, 5); /* T2 */ - bitvec_write_field(dest, wp, 0, 2); /* Radio block allocation */ + bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */ + bitvec_write_field(dest, &wp, (fn / (26 * 51)) % 32, 5);/* T1' */ + bitvec_write_field(dest, &wp, fn % 51, 6); /* T3 */ + bitvec_write_field(dest, &wp, fn % 26, 5); /* T2 */ + bitvec_write_field(dest, &wp, 0, 2); /* Radio block allocation */ - bitvec_write_field(dest, wp, 0, 1); + bitvec_write_field(dest, &wp, 0, 1); } else { ws_enc = (tbf->m_window.ws() - 64) / 32; - bitvec_write_field(dest, wp, 1, 1); /* single block alloc */ - bitvec_write_field(dest, wp, tbf->tfi(), 5);/* TFI assignment */ - bitvec_write_field(dest, wp, 0, 1); /* polling bit */ - bitvec_write_field(dest, wp, 0, 1); /* constant */ - bitvec_write_field(dest, wp, usf, 3); /* USF bit */ - bitvec_write_field(dest, wp, 0, 1); /* USF granularity */ - bitvec_write_field(dest, wp, 0, 1); /* P0 */ + bitvec_write_field(dest, &wp, 1, 1); /* single block alloc */ + bitvec_write_field(dest, &wp, tbf->tfi(), 5);/* TFI assignment */ + bitvec_write_field(dest, &wp, 0, 1); /* polling bit */ + bitvec_write_field(dest, &wp, 0, 1); /* constant */ + bitvec_write_field(dest, &wp, usf, 3); /* USF bit */ + bitvec_write_field(dest, &wp, 0, 1); /* USF granularity */ + bitvec_write_field(dest, &wp, 0, 1); /* P0 */ /* MCS */ - bitvec_write_field(dest, wp, tbf->current_cs().to_num()-1, 4); + bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 4); /* tlli channel block */ - bitvec_write_field(dest, wp, tbf->tlli(), 1); - bitvec_write_field(dest, wp, 0, 1); /* BEP period present */ - bitvec_write_field(dest, wp, 0, 1); /* resegmentation */ - bitvec_write_field(dest, wp, ws_enc, 5);/* egprs window_size */ + bitvec_write_field(dest, &wp, tbf->tlli(), 1); + bitvec_write_field(dest, &wp, 0, 1); /* BEP period present */ + bitvec_write_field(dest, &wp, 0, 1); /* resegmentation */ + bitvec_write_field(dest, &wp, ws_enc, 5);/* egprs window_size */ if (alpha) { - bitvec_write_field(dest, wp, 0x1, 1); /* ALPHA =yes */ - bitvec_write_field(dest, wp, alpha, 4); /* ALPHA */ + bitvec_write_field(dest, &wp, 0x1, 1); /* ALPHA =yes */ + bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */ } else { - bitvec_write_field(dest, wp, 0x0, 1); /* ALPHA = no */ + bitvec_write_field(dest, &wp, 0x0, 1); /* ALPHA = no */ } - bitvec_write_field(dest, wp, gamma, 5); /* GAMMA power contrl */ - bitvec_write_field(dest, wp, 0, 1); /* TIMING_ADVANCE_INDEX */ - bitvec_write_field(dest, wp, 0, 1); /* TBF_STARTING_TIME_FLAG */ - bitvec_write_field(dest, wp, 0, 1); /* NULL */ + bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */ + bitvec_write_field(dest, &wp, 0, 1); /* TIMING_ADVANCE_INDEX */ + bitvec_write_field(dest, &wp, 0, 1); /* TBF_STARTING_TIME_FLAG */ + bitvec_write_field(dest, &wp, 0, 1); /* NULL */ } return 0; @@ -255,17 +255,17 @@ int plen; int i; - bitvec_write_field(dest, wp, 0x0, 4); // Skip Indicator - bitvec_write_field(dest, wp, 0x6, 4); // Protocol Discriminator - bitvec_write_field(dest, wp, 0x3A, 8); // Immediate Assign Message Type + bitvec_write_field(dest, &wp, 0x0, 4); // Skip Indicator + bitvec_write_field(dest, &wp, 0x6, 4); // Protocol Discriminator + bitvec_write_field(dest, &wp, 0x3A, 8); // Immediate Assign Message Type // feature indicator - bitvec_write_field(dest, wp, 0x0, 1); // spare - bitvec_write_field(dest, wp, 0x0, 1); // spare - bitvec_write_field(dest, wp, 0x0, 1); // no cs - bitvec_write_field(dest, wp, 0x1, 1); // implicit detach for PS + bitvec_write_field(dest, &wp, 0x0, 1); // spare + bitvec_write_field(dest, &wp, 0x0, 1); // spare + bitvec_write_field(dest, &wp, 0x0, 1); // no cs + bitvec_write_field(dest, &wp, 0x1, 1); // implicit detach for PS - bitvec_write_field(dest, wp, 0x0, 4); // Page Mode + bitvec_write_field(dest, &wp, 0x0, 4); // Page Mode /* * 9.1.20.2 of 44.018 version 11.7.0 Release 11 * Filling of the message @@ -279,18 +279,18 @@ if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) || (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) { //9.1.20.2a of 44.018 version 11.7.0 Release 11 - bitvec_write_field(dest, wp, 0x7f, 8); /* RACH value */ + bitvec_write_field(dest, &wp, 0x7f, 8); /* RACH value */ } else { - bitvec_write_field(dest, wp, ra, 8); /* RACH value */ + bitvec_write_field(dest, &wp, ra, 8); /* RACH value */ } - bitvec_write_field(dest, wp, + bitvec_write_field(dest, &wp, (ref_fn / (26 * 51)) % 32, 5); // T1' - bitvec_write_field(dest, wp, ref_fn % 51, 6); // T3 - bitvec_write_field(dest, wp, ref_fn % 26, 5); // T2 + bitvec_write_field(dest, &wp, ref_fn % 51, 6); // T3 + bitvec_write_field(dest, &wp, ref_fn % 26, 5); // T2 /* TODO: Make it configurable */ - bitvec_write_field(dest, wp, 20, 8); //Wait Indication 1 + bitvec_write_field(dest, &wp, 20, 8); //Wait Indication 1 } plen = wp / 8; @@ -308,14 +308,14 @@ uint8_t extended_ra = 0; extended_ra = (ra & 0x1F); - bitvec_write_field(dest, wp, 0x1, 1); - bitvec_write_field(dest, wp, extended_ra, 5); /* Extended RA */ + bitvec_write_field(dest, &wp, 0x1, 1); + bitvec_write_field(dest, &wp, extended_ra, 5); /* Extended RA */ } else { - bitvec_write_field(dest, wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); } - bitvec_write_field(dest, wp, 0x0, 1); - bitvec_write_field(dest, wp, 0x0, 1); - bitvec_write_field(dest, wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); return plen; } @@ -335,44 +335,44 @@ int plen; int rc; - bitvec_write_field(dest, wp,0x0,4); // Skip Indicator - bitvec_write_field(dest, wp,0x6,4); // Protocol Discriminator - bitvec_write_field(dest, wp,0x3F,8); // Immediate Assignment Message Type + bitvec_write_field(dest, &wp,0x0,4); // Skip Indicator + bitvec_write_field(dest, &wp,0x6,4); // Protocol Discriminator + bitvec_write_field(dest, &wp,0x3F,8); // Immediate Assignment Message Type // 10.5.2.25b Dedicated mode or TBF - bitvec_write_field(dest, wp,0x0,1); // spare - bitvec_write_field(dest, wp,0x0,1); // TMA : Two-message assignment: No meaning - bitvec_write_field(dest, wp,downlink,1); // Downlink : Downlink assignment to mobile in packet idle mode - bitvec_write_field(dest, wp,0x1,1); // T/D : TBF or dedicated mode: this message assigns a Temporary Block Flow (TBF). + bitvec_write_field(dest, &wp,0x0,1); // spare + bitvec_write_field(dest, &wp,0x0,1); // TMA : Two-message assignment: No meaning + bitvec_write_field(dest, &wp,downlink,1); // Downlink : Downlink assignment to mobile in packet idle mode + bitvec_write_field(dest, &wp,0x1,1); // T/D : TBF or dedicated mode: this message assigns a Temporary Block Flow (TBF). - bitvec_write_field(dest, wp,0x0,4); // Page Mode + bitvec_write_field(dest, &wp,0x0,4); // Page Mode // GSM 04.08 10.5.2.25a Packet Channel Description - bitvec_write_field(dest, wp,0x1,5); // Channel type - bitvec_write_field(dest, wp,ts,3); // TN - bitvec_write_field(dest, wp,tsc,3); // TSC - bitvec_write_field(dest, wp,0x0,3); // non-hopping RF channel configuraion - bitvec_write_field(dest, wp,arfcn,10); // ARFCN + bitvec_write_field(dest, &wp,0x1,5); // Channel type + bitvec_write_field(dest, &wp,ts,3); // TN + bitvec_write_field(dest, &wp,tsc,3); // TSC + bitvec_write_field(dest, &wp,0x0,3); // non-hopping RF channel configuraion + bitvec_write_field(dest, &wp,arfcn,10); // ARFCN //10.5.2.30 Request Reference if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) || (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) { - bitvec_write_field(dest, wp, 0x7f, 8); /* RACH value */ + bitvec_write_field(dest, &wp, 0x7f, 8); /* RACH value */ } else { - bitvec_write_field(dest, wp, ra, 8); /* RACH value */ + bitvec_write_field(dest, &wp, ra, 8); /* RACH value */ } - bitvec_write_field(dest, wp,(ref_fn / (26 * 51)) % 32,5); // T1' - bitvec_write_field(dest, wp,ref_fn % 51,6); // T3 - bitvec_write_field(dest, wp,ref_fn % 26,5); // T2 + bitvec_write_field(dest, &wp,(ref_fn / (26 * 51)) % 32,5); // T1' + bitvec_write_field(dest, &wp,ref_fn % 51,6); // T3 + bitvec_write_field(dest, &wp,ref_fn % 26,5); // T2 // 10.5.2.40 Timing Advance - bitvec_write_field(dest, wp,0x0,2); // spare - bitvec_write_field(dest, wp,ta,6); // Timing Advance value + bitvec_write_field(dest, &wp,0x0,2); // spare + bitvec_write_field(dest, &wp,ta,6); // Timing Advance value // No mobile allocation in non-hopping systems. // A zero-length LV. Just write L=0. - bitvec_write_field(dest, wp,0,8); + bitvec_write_field(dest, &wp,0,8); if ((wp % 8)) { LOGP(DRLCMACUL, LOGL_ERROR, "Length of IMM.ASS without rest " @@ -420,83 +420,83 @@ /* timeslot assigned for the Continuous Timing Advance procedure */ uint8_t ta_ts = 0; /* FIXME: supply it as parameter from caller */ - bitvec_write_field(dest, wp,0x1,2); // Payload Type - bitvec_write_field(dest, wp,0x0,2); // Uplink block with TDMA framenumber (N+13) - bitvec_write_field(dest, wp,poll,1); // Suppl/Polling Bit - bitvec_write_field(dest, wp,0x0,3); // Uplink state flag - bitvec_write_field(dest, wp,0xa,6); // MESSAGE TYPE + bitvec_write_field(dest, &wp,0x1,2); // Payload Type + bitvec_write_field(dest, &wp,0x0,2); // Uplink block with TDMA framenumber (N+13) + bitvec_write_field(dest, &wp,poll,1); // Suppl/Polling Bit + bitvec_write_field(dest, &wp,0x0,3); // Uplink state flag + bitvec_write_field(dest, &wp,0xa,6); // MESSAGE TYPE - bitvec_write_field(dest, wp,0x0,2); // Page Mode + bitvec_write_field(dest, &wp,0x0,2); // Page Mode - bitvec_write_field(dest, wp,0x0,1); // switch PERSIST_LEVEL: off + bitvec_write_field(dest, &wp,0x0,1); // switch PERSIST_LEVEL: off if (use_tlli) { - bitvec_write_field(dest, wp,0x2,2); // switch TLLI : on - bitvec_write_field(dest, wp,tlli,32); // TLLI + bitvec_write_field(dest, &wp,0x2,2); // switch TLLI : on + bitvec_write_field(dest, &wp,tlli,32); // TLLI } else { - bitvec_write_field(dest, wp,0x0,1); // switch TFI : on - bitvec_write_field(dest, wp,old_downlink,1); // 0=UPLINK TFI, 1=DL TFI - bitvec_write_field(dest, wp,old_tfi,5); // TFI + bitvec_write_field(dest, &wp,0x0,1); // switch TFI : on + bitvec_write_field(dest, &wp,old_downlink,1); // 0=UPLINK TFI, 1=DL TFI + bitvec_write_field(dest, &wp,old_tfi,5); // TFI } if (!use_egprs) { - bitvec_write_field(dest, wp,0x0,1); // Message escape - bitvec_write_field(dest, wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND - bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING + bitvec_write_field(dest, &wp,0x0,1); // Message escape + bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts); } else { /* EPGRS */ unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32; - bitvec_write_field(dest, wp,0x1,1); // Message escape - bitvec_write_field(dest, wp,0x0,2); // EGPRS message contents - bitvec_write_field(dest, wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp,0x0,1); // No COMPACT reduced MA - bitvec_write_field(dest, wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE + bitvec_write_field(dest, &wp,0x1,1); // Message escape + bitvec_write_field(dest, &wp,0x0,2); // EGPRS message contents + bitvec_write_field(dest, &wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp,0x0,1); // No COMPACT reduced MA + bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE /* 0: no RESEGMENT, 1: Segmentation*/ - bitvec_write_field(dest, wp, 0x1, 1); - bitvec_write_field(dest, wp,ws_enc,5); // EGPRS Window Size - bitvec_write_field(dest, wp,0x0,1); // No Access Technologies Request - bitvec_write_field(dest, wp,0x0,1); // No ARAC RETRANSMISSION REQUEST - bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING - bitvec_write_field(dest, wp,0x0,1); // No BEP_PERIOD2 + bitvec_write_field(dest, &wp, 0x1, 1); + bitvec_write_field(dest, &wp,ws_enc,5); // EGPRS Window Size + bitvec_write_field(dest, &wp,0x0,1); // No Access Technologies Request + bitvec_write_field(dest, &wp,0x0,1); // No ARAC RETRANSMISSION REQUEST + bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING + bitvec_write_field(dest, &wp,0x0,1); // No BEP_PERIOD2 write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts); - bitvec_write_field(dest, wp,0x0,1); // No Packet Extended Timing Advance + bitvec_write_field(dest, &wp,0x0,1); // No Packet Extended Timing Advance } #if 1 - bitvec_write_field(dest, wp,0x1,1); // Frequency Parameters information elements = present - bitvec_write_field(dest, wp,tbf->tsc(),3); // Training Sequence Code (TSC) - bitvec_write_field(dest, wp,0x0,2); // ARFCN = present - bitvec_write_field(dest, wp,tbf->trx->arfcn,10); // ARFCN + bitvec_write_field(dest, &wp,0x1,1); // Frequency Parameters information elements = present + bitvec_write_field(dest, &wp,tbf->tsc(),3); // Training Sequence Code (TSC) + bitvec_write_field(dest, &wp,0x0,2); // ARFCN = present + bitvec_write_field(dest, &wp,tbf->trx->arfcn,10); // ARFCN #else - bitvec_write_field(dest, wp,0x0,1); // Frequency Parameters = off + bitvec_write_field(dest, &wp,0x0,1); // Frequency Parameters = off #endif - bitvec_write_field(dest, wp,0x1,2); // Dynamic Allocation + bitvec_write_field(dest, &wp,0x1,2); // Dynamic Allocation - bitvec_write_field(dest, wp,0x0,1); // Extended Dynamic Allocation = off - bitvec_write_field(dest, wp,0x0,1); // P0 = off + bitvec_write_field(dest, &wp,0x0,1); // Extended Dynamic Allocation = off + bitvec_write_field(dest, &wp,0x0,1); // P0 = off - bitvec_write_field(dest, wp,0x0,1); // USF_GRANULARITY - bitvec_write_field(dest, wp,0x1,1); // switch TFI : on - bitvec_write_field(dest, wp,tbf->tfi(),5);// TFI + bitvec_write_field(dest, &wp,0x0,1); // USF_GRANULARITY + bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on + bitvec_write_field(dest, &wp,tbf->tfi(),5);// TFI - bitvec_write_field(dest, wp,0x0,1); // - bitvec_write_field(dest, wp,0x0,1); // TBF Starting Time = off + bitvec_write_field(dest, &wp,0x0,1); // + bitvec_write_field(dest, &wp,0x0,1); // TBF Starting Time = off if (alpha || gamma) { - bitvec_write_field(dest, wp,0x1,1); // Timeslot Allocation with Power Control - bitvec_write_field(dest, wp,alpha,4); // ALPHA + bitvec_write_field(dest, &wp,0x1,1); // Timeslot Allocation with Power Control + bitvec_write_field(dest, &wp,alpha,4); // ALPHA } else - bitvec_write_field(dest, wp,0x0,1); // Timeslot Allocation + bitvec_write_field(dest, &wp,0x0,1); // Timeslot Allocation for (ts = 0; ts < 8; ts++) { if (tbf->pdch[ts]) { - bitvec_write_field(dest, wp,0x1,1); // USF_TN(i): on - bitvec_write_field(dest, wp,tbf->m_usf[ts],3); // USF_TN(i) + bitvec_write_field(dest, &wp,0x1,1); // USF_TN(i): on + bitvec_write_field(dest, &wp,tbf->m_usf[ts],3); // USF_TN(i) if (alpha || gamma) - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter } else - bitvec_write_field(dest, wp,0x0,1); // USF_TN(i): off + bitvec_write_field(dest, &wp,0x0,1); // USF_TN(i): off } - // bitvec_write_field(dest, wp,0x0,1); // Measurement Mapping struct not present + // bitvec_write_field(dest, &wp,0x0,1); // Measurement Mapping struct not present } @@ -603,20 +603,20 @@ unsigned wp = 0; int plen; - bitvec_write_field(dest, wp,0x0,4); // Skip Indicator - bitvec_write_field(dest, wp,0x6,4); // Protocol Discriminator - bitvec_write_field(dest, wp,0x21,8); // Paging Request Message Type + bitvec_write_field(dest, &wp,0x0,4); // Skip Indicator + bitvec_write_field(dest, &wp,0x6,4); // Protocol Discriminator + bitvec_write_field(dest, &wp,0x21,8); // Paging Request Message Type - bitvec_write_field(dest, wp,0x0,4); // Page Mode - bitvec_write_field(dest, wp,0x0,4); // Channel Needed + bitvec_write_field(dest, &wp,0x0,4); // Page Mode + bitvec_write_field(dest, &wp,0x0,4); // Channel Needed // Mobile Identity - bitvec_write_field(dest, wp,ptmsi_len+1,8); // Mobile Identity length - bitvec_write_field(dest, wp,0xf,4); // unused - bitvec_write_field(dest, wp,0x4,4); // PTMSI type + bitvec_write_field(dest, &wp,ptmsi_len+1,8); // Mobile Identity length + bitvec_write_field(dest, &wp,0xf,4); // unused + bitvec_write_field(dest, &wp,0x4,4); // PTMSI type for (int i = 0; i < ptmsi_len; i++) { - bitvec_write_field(dest, wp,ptmsi[i],8); // PTMSI + bitvec_write_field(dest, &wp,ptmsi[i],8); // PTMSI } if ((wp % 8)) { LOGP(DRLCMACUL, LOGL_ERROR, "Length of PAG.REQ without rest " @@ -624,12 +624,12 @@ exit (0); } plen = wp / 8; - bitvec_write_field(dest, wp,0x0,1); // "L" NLN(PCH) = off - bitvec_write_field(dest, wp,0x0,1); // "L" Priority1 = off - bitvec_write_field(dest, wp,0x1,1); // "L" Priority2 = off - bitvec_write_field(dest, wp,0x0,1); // "L" Group Call information = off - bitvec_write_field(dest, wp,0x0,1); // "H" Packet Page Indication 1 = packet paging procedure - bitvec_write_field(dest, wp,0x1,1); // "H" Packet Page Indication 2 = packet paging procedure + bitvec_write_field(dest, &wp,0x0,1); // "L" NLN(PCH) = off + bitvec_write_field(dest, &wp,0x0,1); // "L" Priority1 = off + bitvec_write_field(dest, &wp,0x1,1); // "L" Priority2 = off + bitvec_write_field(dest, &wp,0x0,1); // "L" Group Call information = off + bitvec_write_field(dest, &wp,0x0,1); // "H" Packet Page Indication 1 = packet paging procedure + bitvec_write_field(dest, &wp,0x1,1); // "H" Packet Page Indication 2 = packet paging procedure return plen; } @@ -667,13 +667,13 @@ LOGP(DRLCMACUL, LOGL_DEBUG, "- V(N): \"%s\" R=Received " "I=Invalid\n", rbb); - bitvec_write_field(dest, wp, is_final, 1); // FINAL_ACK_INDICATION - bitvec_write_field(dest, wp, window->ssn(), 7); // STARTING_SEQUENCE_NUMBER + bitvec_write_field(dest, &wp, is_final, 1); // FINAL_ACK_INDICATION + bitvec_write_field(dest, &wp, window->ssn(), 7); // STARTING_SEQUENCE_NUMBER for (int i = 0; i < 64; i++) { /* Set bit at the appropriate position (see 3GPP TS 04.60 9.1.8.1) */ bool is_ack = (rbb[i] == 'R'); - bitvec_write_field(dest, wp, is_ack, 1); + bitvec_write_field(dest, &wp, is_ack, 1); } } @@ -682,20 +682,20 @@ struct gprs_rlcmac_ul_tbf *tbf, bool is_final) { - bitvec_write_field(dest, wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND write_packet_ack_nack_desc_gprs(bts, dest, wp, &tbf->m_window, is_final); - bitvec_write_field(dest, wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Timing Advance - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Power Control Parameters - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Extension Bits - bitvec_write_field(dest, wp, 0, 1); // fixed 0 - bitvec_write_field(dest, wp, 1, 1); // 1: have Additions R99 - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Extended Timing Advance - bitvec_write_field(dest, wp, 1, 1); // TBF_EST (enabled) - bitvec_write_field(dest, wp, 0, 1); // 0: don't have REL 5 + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Timing Advance + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Power Control Parameters + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Extension Bits + bitvec_write_field(dest, &wp, 0, 1); // fixed 0 + bitvec_write_field(dest, &wp, 1, 1); // 1: have Additions R99 + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Extended Timing Advance + bitvec_write_field(dest, &wp, 1, 1); // TBF_EST (enabled) + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5 }; static void write_packet_ack_nack_desc_egprs( @@ -810,37 +810,37 @@ /* EGPRS Ack/Nack Description IE */ if (len_coded == false) { - bitvec_write_field(dest, wp, 0, 1); // 0: don't have length + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have length } else { - bitvec_write_field(dest, wp, 1, 1); // 1: have length - bitvec_write_field(dest, wp, len, 8); // length + bitvec_write_field(dest, &wp, 1, 1); // 1: have length + bitvec_write_field(dest, &wp, len, 8); // length } - bitvec_write_field(dest, wp, is_final, 1); // FINAL_ACK_INDICATION - bitvec_write_field(dest, wp, bow, 1); // BEGINNING_OF_WINDOW - bitvec_write_field(dest, wp, eow, 1); // END_OF_WINDOW - bitvec_write_field(dest, wp, ssn, 11); // STARTING_SEQUENCE_NUMBER + bitvec_write_field(dest, &wp, is_final, 1); // FINAL_ACK_INDICATION + bitvec_write_field(dest, &wp, bow, 1); // BEGINNING_OF_WINDOW + bitvec_write_field(dest, &wp, eow, 1); // END_OF_WINDOW + bitvec_write_field(dest, &wp, ssn, 11); // STARTING_SEQUENCE_NUMBER if (is_compressed) { - bitvec_write_field(dest, wp, 1, 1); // CRBB_Exist - bitvec_write_field(dest, wp, crbb_len, 7); // CRBB_LENGTH + bitvec_write_field(dest, &wp, 1, 1); // CRBB_Exist + bitvec_write_field(dest, &wp, crbb_len, 7); // CRBB_LENGTH crbb_start_clr_code = (0x80 & ucmp_vec.data[0])>>7; - bitvec_write_field(dest, wp, crbb_start_clr_code, 1); // CRBB_clr_code + bitvec_write_field(dest, &wp, crbb_start_clr_code, 1); // CRBB_clr_code LOGP(DRLCMACUL, LOGL_DEBUG, "EGPRS CRBB, crbb_len = %d, crbb_start_clr_code = %d\n", crbb_len, crbb_start_clr_code); while (crbb_len != 0) { if (crbb_len > 8) { - bitvec_write_field(dest, wp, crbb_bitmap[iter], 8); + bitvec_write_field(dest, &wp, crbb_bitmap[iter], 8); crbb_len = crbb_len - 8; iter++; } else { - bitvec_write_field(dest, wp, crbb_bitmap[iter], crbb_len); + bitvec_write_field(dest, &wp, crbb_bitmap[iter], crbb_len); crbb_len = 0; } } esn_crbb = window->mod_sns(esn_crbb + uclen_crbb); } else { - bitvec_write_field(dest, wp, 0, 1); // CRBB_Exist + bitvec_write_field(dest, &wp, 0, 1); // CRBB_Exist } LOGP(DRLCMACUL, LOGL_DEBUG, "EGPRS URBB, urbb len = %d, SSN = %d, ESN_CRBB = %d, " @@ -853,7 +853,7 @@ for (i = urbb_len; i > 0; i--) { /* Set bit at the appropriate position (see 3GPP TS 04.60 12.3.1) */ bool is_ack = window->m_v_n.is_received(esn_crbb + i); - bitvec_write_field(dest, wp, is_ack, 1); + bitvec_write_field(dest, &wp, is_ack, 1); } } @@ -861,29 +861,29 @@ struct gprs_rlcmac_bts *bts, bitvec * dest, unsigned& wp, struct gprs_rlcmac_ul_tbf *tbf, bool is_final) { - bitvec_write_field(dest, wp, 0, 2); // fixed 00 + bitvec_write_field(dest, &wp, 0, 2); // fixed 00 /* CHANNEL_CODING_COMMAND */ - bitvec_write_field(dest, wp, + bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 4); /* 0: no RESEGMENT, 1: Segmentation*/ - bitvec_write_field(dest, wp, 1, 1); - bitvec_write_field(dest, wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it? - bitvec_write_field(dest, wp, 0, 1); // 0: no PRR_RETRANSMISSION_REQUEST, TODO: clarify - bitvec_write_field(dest, wp, 0, 1); // 0: no ARAC_RETRANSMISSION_REQUEST, TODO: clarify - bitvec_write_field(dest, wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, 1, 1); // TBF_EST (enabled) - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Timing Advance - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Extended Timing Advance - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Power Control Parameters - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Extension Bits + bitvec_write_field(dest, &wp, 1, 1); + bitvec_write_field(dest, &wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it? + bitvec_write_field(dest, &wp, 0, 1); // 0: no PRR_RETRANSMISSION_REQUEST, TODO: clarify + bitvec_write_field(dest, &wp, 0, 1); // 0: no ARAC_RETRANSMISSION_REQUEST, TODO: clarify + bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, 1, 1); // TBF_EST (enabled) + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Timing Advance + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Extended Timing Advance + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Power Control Parameters + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Extension Bits /* -2 for last bit 0 mandatory and REL5 not supported */ unsigned bits_ack_nack = dest->data_len * 8 - wp - 2; write_packet_ack_nack_desc_egprs(bts, dest, wp, &tbf->m_window, is_final, bits_ack_nack); - bitvec_write_field(dest, wp, 0, 1); // fixed 0 - bitvec_write_field(dest, wp, 0, 1); // 0: don't have REL 5 + bitvec_write_field(dest, &wp, 0, 1); // fixed 0 + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5 }; void Encoding::write_packet_uplink_ack( @@ -896,23 +896,23 @@ LOGP(DRLCMACUL, LOGL_DEBUG, "Encoding Ack/Nack for %s " "(final=%d)\n", tbf_name(tbf), is_final); - bitvec_write_field(dest, wp, 0x1, 2); // Payload Type - bitvec_write_field(dest, wp, rrbp, 2); // Uplink block with TDMA framenumber - bitvec_write_field(dest, wp, is_final, 1); // Suppl/Polling Bit - bitvec_write_field(dest, wp, 0x0, 3); // Uplink state flag - bitvec_write_field(dest, wp, 0x9, 6); // MESSAGE TYPE Uplink Ack/Nack - bitvec_write_field(dest, wp, 0x0, 2); // Page Mode + bitvec_write_field(dest, &wp, 0x1, 2); // Payload Type + bitvec_write_field(dest, &wp, rrbp, 2); // Uplink block with TDMA framenumber + bitvec_write_field(dest, &wp, is_final, 1); // Suppl/Polling Bit + bitvec_write_field(dest, &wp, 0x0, 3); // Uplink state flag + bitvec_write_field(dest, &wp, 0x9, 6); // MESSAGE TYPE Uplink Ack/Nack + bitvec_write_field(dest, &wp, 0x0, 2); // Page Mode - bitvec_write_field(dest, wp, 0x0, 2); // fixed 00 - bitvec_write_field(dest, wp, tbf->tfi(), 5); // Uplink TFI + bitvec_write_field(dest, &wp, 0x0, 2); // fixed 00 + bitvec_write_field(dest, &wp, tbf->tfi(), 5); // Uplink TFI if (tbf->is_egprs_enabled()) { /* PU_AckNack_EGPRS = on */ - bitvec_write_field(dest, wp, 1, 1); // 1: EGPRS + bitvec_write_field(dest, &wp, 1, 1); // 1: EGPRS write_packet_uplink_ack_egprs(bts, dest, wp, tbf, is_final); } else { /* PU_AckNack_GPRS = on */ - bitvec_write_field(dest, wp, 0, 1); // 0: GPRS + bitvec_write_field(dest, &wp, 0, 1); // 0: GPRS write_packet_uplink_ack_gprs(bts, dest, wp, tbf, is_final); } @@ -926,15 +926,15 @@ { unsigned wp = 0; - bitvec_write_field(dest, wp,0x1,2); // Payload Type - bitvec_write_field(dest, wp,0x0,3); // No polling - bitvec_write_field(dest, wp,0x0,3); // Uplink state flag - bitvec_write_field(dest, wp,0x22,6); // MESSAGE TYPE + bitvec_write_field(dest, &wp,0x1,2); // Payload Type + bitvec_write_field(dest, &wp,0x0,3); // No polling + bitvec_write_field(dest, &wp,0x0,3); // Uplink state flag + bitvec_write_field(dest, &wp,0x22,6); // MESSAGE TYPE - bitvec_write_field(dest, wp,0x0,2); // Page Mode + bitvec_write_field(dest, &wp,0x0,2); // Page Mode - bitvec_write_field(dest, wp,0x0,1); // No PERSISTENCE_LEVEL - bitvec_write_field(dest, wp,0x0,1); // No NLN + bitvec_write_field(dest, &wp,0x0,1); // No PERSISTENCE_LEVEL + bitvec_write_field(dest, &wp,0x0,1); // No NLN return wp; } @@ -942,24 +942,24 @@ unsigned Encoding::write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len, uint8_t *identity, uint8_t chan_needed) { - bitvec_write_field(dest, wp,0x1,1); // Repeated Page info exists + bitvec_write_field(dest, &wp,0x1,1); // Repeated Page info exists - bitvec_write_field(dest, wp,0x1,1); // RR connection paging + bitvec_write_field(dest, &wp,0x1,1); // RR connection paging if ((identity[0] & 0x07) == 4) { - bitvec_write_field(dest, wp,0x0,1); // TMSI + bitvec_write_field(dest, &wp,0x0,1); // TMSI identity++; len--; } else { - bitvec_write_field(dest, wp,0x0,1); // MI - bitvec_write_field(dest, wp,len,4); // MI len + bitvec_write_field(dest, &wp,0x0,1); // MI + bitvec_write_field(dest, &wp,len,4); // MI len } while (len) { - bitvec_write_field(dest, wp,*identity++,8); // MI data + bitvec_write_field(dest, &wp,*identity++,8); // MI data len--; } - bitvec_write_field(dest, wp,chan_needed,2); // CHANNEL_NEEDED - bitvec_write_field(dest, wp,0x0,1); // No eMLPP_PRIORITY + bitvec_write_field(dest, &wp,chan_needed,2); // CHANNEL_NEEDED + bitvec_write_field(dest, &wp,0x0,1); // No eMLPP_PRIORITY return wp; } @@ -1490,17 +1490,17 @@ { unsigned wp = 0; - bitvec_write_field(dest, wp, 0x1, 2); // Payload Type - bitvec_write_field(dest, wp, 0x0, 2); // Uplink block with TDMA FN - bitvec_write_field(dest, wp, 0, 1); // No Polling Bit - bitvec_write_field(dest, wp, 0x0, 3); // Uplink state flag - bitvec_write_field(dest, wp, + bitvec_write_field(dest, &wp, 0x1, 2); // Payload Type + bitvec_write_field(dest, &wp, 0x0, 2); // Uplink block with TDMA FN + bitvec_write_field(dest, &wp, 0, 1); // No Polling Bit + bitvec_write_field(dest, &wp, 0x0, 3); // Uplink state flag + bitvec_write_field(dest, &wp, MT_PACKET_ACCESS_REJECT, 6); // MESSAGE TYPE - bitvec_write_field(dest, wp, 0, 2); // fixed 00 - bitvec_write_field(dest, wp, 0x0, 1); // TLLI / G-RNTI : bit (32) - bitvec_write_field(dest, wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, 1, 1); // WAIT_INDICATION size in seconds + bitvec_write_field(dest, &wp, 0, 2); // fixed 00 + bitvec_write_field(dest, &wp, 0x0, 1); // TLLI / G-RNTI : bit (32) + bitvec_write_field(dest, &wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, 1, 1); // WAIT_INDICATION size in seconds /* TODO: make it configurable */ - bitvec_write_field(dest, wp, 5, 8); // WAIT_INDICATION value - bitvec_write_field(dest, wp, 0, 1); // WAIT_INDICATION size in seconds + bitvec_write_field(dest, &wp, 5, 8); // WAIT_INDICATION value + bitvec_write_field(dest, &wp, 0, 1); // WAIT_INDICATION size in seconds } diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index da1d26c..71bd139 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -90,7 +90,7 @@ LOGP(DBSSGP, LOGL_DEBUG, "Got BSSGP RA Capability of size %d\n", cap_len); - block = bitvec_alloc(cap_len); + block = bitvec_alloc(cap_len, tall_pcu_ctx); bitvec_unpack(block, cap); /* TS 24.008, 10.5.5.12a */ diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index ac8f2d1..16870c3 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -33,7 +33,7 @@ const char *imsi) { LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH)\n"); - bitvec *paging_request = bitvec_alloc(23); + bitvec *paging_request = bitvec_alloc(23, tall_pcu_ctx); bitvec_unhex(paging_request, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); int plen = Encoding::write_paging_request(paging_request, ptmsi, ptmsi_len); pcu_l1if_tx_pch(paging_request, plen, (char *)imsi); diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index 589bd8f..be1e686 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -22,13 +22,13 @@ #define GPRS_RLCMAC_H #ifdef __cplusplus -#include #include #include extern "C" { #include #include +#include } #endif diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.cpp index 6b43aa6..6323b09 100644 --- a/src/gsm_rlcmac.cpp +++ b/src/gsm_rlcmac.cpp @@ -4799,7 +4799,7 @@ { csnStream_t ar; unsigned readIndex = 0; - guint8 payload_type = bitvec_read_field(vector, readIndex, 2); + guint8 payload_type = bitvec_read_field(vector, &readIndex, 2); if (payload_type == PAYLOAD_TYPE_DATA) { @@ -4814,7 +4814,7 @@ data->NrOfBits = 23 * 8; csnStreamInit(&ar, 0, data->NrOfBits); readIndex += 6; - data->u.MESSAGE_TYPE = bitvec_read_field(vector, readIndex, 6); + data->u.MESSAGE_TYPE = bitvec_read_field(vector, &readIndex, 6); readIndex = 0; switch (data->u.MESSAGE_TYPE) { @@ -4907,10 +4907,10 @@ gint bit_offset = 0; gint bit_length; unsigned readIndex = 0; - data->PAYLOAD_TYPE = bitvec_read_field(vector, readIndex, 2); - data->RRBP = bitvec_read_field(vector, readIndex, 2); - data->SP = bitvec_read_field(vector, readIndex, 1); - data->USF = bitvec_read_field(vector, readIndex, 3); + data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2); + data->RRBP = bitvec_read_field(vector, &readIndex, 2); + data->SP = bitvec_read_field(vector, &readIndex, 1); + data->USF = bitvec_read_field(vector, &readIndex, 3); if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA) { @@ -4929,27 +4929,27 @@ bit_offset = 8; if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_CTRL_OPT_OCTET) { - data->RBSN = bitvec_read_field(vector, readIndex, 1); - data->RTI = bitvec_read_field(vector, readIndex, 5); - data->FS = bitvec_read_field(vector, readIndex, 1); - data->AC = bitvec_read_field(vector, readIndex, 1); + data->RBSN = bitvec_read_field(vector, &readIndex, 1); + data->RTI = bitvec_read_field(vector, &readIndex, 5); + data->FS = bitvec_read_field(vector, &readIndex, 1); + data->AC = bitvec_read_field(vector, &readIndex, 1); bit_offset += 8; if (data->AC == 1) { - data->PR = bitvec_read_field(vector, readIndex, 2); - data->TFI = bitvec_read_field(vector, readIndex, 5); - data->D = bitvec_read_field(vector, readIndex, 1); + data->PR = bitvec_read_field(vector, &readIndex, 2); + data->TFI = bitvec_read_field(vector, &readIndex, 5); + data->D = bitvec_read_field(vector, &readIndex, 1); bit_offset += 8; } if ((data->RBSN == 1) && (data->FS == 0)) { - data->RBSNe = bitvec_read_field(vector, readIndex, 3); - data->FSe = bitvec_read_field(vector, readIndex, 1); - data->spare = bitvec_read_field(vector, readIndex, 4); + data->RBSNe = bitvec_read_field(vector, &readIndex, 3); + data->FSe = bitvec_read_field(vector, &readIndex, 1); + data->spare = bitvec_read_field(vector, &readIndex, 4); bit_offset += 8; } } - data->u.MESSAGE_TYPE = bitvec_read_field(vector, readIndex, 6); + data->u.MESSAGE_TYPE = bitvec_read_field(vector, &readIndex, 6); } /* Initialize the contexts */ @@ -5206,30 +5206,30 @@ else { /* First print the message type and create a tree item */ - bitvec_write_field(vector, writeIndex, data->PAYLOAD_TYPE, 2); - bitvec_write_field(vector, writeIndex, data->RRBP, 2); - bitvec_write_field(vector, writeIndex, data->SP, 1); - bitvec_write_field(vector, writeIndex, data->USF, 3); + bitvec_write_field(vector, &writeIndex, data->PAYLOAD_TYPE, 2); + bitvec_write_field(vector, &writeIndex, data->RRBP, 2); + bitvec_write_field(vector, &writeIndex, data->SP, 1); + bitvec_write_field(vector, &writeIndex, data->USF, 3); bit_offset = 8; if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_CTRL_OPT_OCTET) { - bitvec_write_field(vector, writeIndex, data->RBSN, 1); - bitvec_write_field(vector, writeIndex, data->RTI, 5); - bitvec_write_field(vector, writeIndex, data->FS, 1); - bitvec_write_field(vector, writeIndex, data->AC, 1); + bitvec_write_field(vector, &writeIndex, data->RBSN, 1); + bitvec_write_field(vector, &writeIndex, data->RTI, 5); + bitvec_write_field(vector, &writeIndex, data->FS, 1); + bitvec_write_field(vector, &writeIndex, data->AC, 1); bit_offset += 8; if (data->AC == 1) { - bitvec_write_field(vector, writeIndex, data->PR, 2); - bitvec_write_field(vector, writeIndex, data->TFI, 5); - bitvec_write_field(vector, writeIndex, data->D, 1); + bitvec_write_field(vector, &writeIndex, data->PR, 2); + bitvec_write_field(vector, &writeIndex, data->TFI, 5); + bitvec_write_field(vector, &writeIndex, data->D, 1); bit_offset += 8; } if ((data->RBSN == 1) && (data->FS == 0)) { - bitvec_write_field(vector, writeIndex, data->RBSNe, 3); - bitvec_write_field(vector, writeIndex, data->FSe, 1); - bitvec_write_field(vector, writeIndex, data->spare, 4); + bitvec_write_field(vector, &writeIndex, data->RBSNe, 3); + bitvec_write_field(vector, &writeIndex, data->FSe, 1); + bitvec_write_field(vector, &writeIndex, data->spare, 4); bit_offset += 8; } } @@ -5378,32 +5378,32 @@ { unsigned readIndex = 0; //unsigned dataLen = 0; - guint8 payload_type = bitvec_read_field(vector, readIndex, 2); + guint8 payload_type = bitvec_read_field(vector, &readIndex, 2); if (payload_type == PAYLOAD_TYPE_DATA) { readIndex = 0; // MAC header - data->PAYLOAD_TYPE = bitvec_read_field(vector, readIndex, 2); - data->CV = bitvec_read_field(vector, readIndex, 4); - data->SI = bitvec_read_field(vector, readIndex, 1); - data->R = bitvec_read_field(vector, readIndex, 1); + data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2); + data->CV = bitvec_read_field(vector, &readIndex, 4); + data->SI = bitvec_read_field(vector, &readIndex, 1); + data->R = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "CV = %u ", (unsigned)(data->CV)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "SI = %u ", (unsigned)(data->SI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "R = %u ", (unsigned)(data->R)); // Octet 1 - data->spare = bitvec_read_field(vector, readIndex, 1); - data->PI = bitvec_read_field(vector, readIndex, 1); - data->TFI = bitvec_read_field(vector, readIndex, 5); - data->TI = bitvec_read_field(vector, readIndex, 1); + data->spare = bitvec_read_field(vector, &readIndex, 1); + data->PI = bitvec_read_field(vector, &readIndex, 1); + data->TFI = bitvec_read_field(vector, &readIndex, 5); + data->TI = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "spare = %u ", (unsigned)(data->spare)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PI = %u ", (unsigned)(data->PI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TI = %u ", (unsigned)(data->TI)); // Octet 2 - data->BSN = bitvec_read_field(vector, readIndex, 7); - data->E_1 = bitvec_read_field(vector, readIndex, 1); + data->BSN = bitvec_read_field(vector, &readIndex, 7); + data->E_1 = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1)); @@ -5414,9 +5414,9 @@ unsigned i = 0; do { - data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, readIndex, 6); - data->M[i] = bitvec_read_field(vector, readIndex, 1); - data->E[i] = bitvec_read_field(vector, readIndex, 1); + data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, &readIndex, 6); + data->M[i] = bitvec_read_field(vector, &readIndex, 1); + data->E[i] = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i])); @@ -5425,12 +5425,12 @@ } if(data->TI == 1) // TLLI field is present { - data->TLLI = bitvec_read_field(vector, readIndex, 32); + data->TLLI = bitvec_read_field(vector, &readIndex, 32); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TLLI = %08x ", data->TLLI); if (data->PI == 1) // PFI is present if TI field indicates presence of TLLI { - data->PFI = bitvec_read_field(vector, readIndex, 7); - data->E_2 = bitvec_read_field(vector, readIndex, 1); + data->PFI = bitvec_read_field(vector, &readIndex, 7); + data->E_2 = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PFI = %u ", (unsigned)(data->PFI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_2 = %u ", (unsigned)(data->E_2)); } @@ -5440,7 +5440,7 @@ assert(dataLen <= 20); for (unsigned i = 0; i < dataLen; i++) { - data->RLC_DATA[i] = bitvec_read_field(vector, readIndex, 8); + data->RLC_DATA[i] = bitvec_read_field(vector, &readIndex, 8); LOGPC(DRLCMACDATA, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i])); } LOGPC(DRLCMACDATA, LOGL_NOTICE, "\n"); @@ -5459,26 +5459,26 @@ if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA) { // MAC header - bitvec_write_field(vector, writeIndex, data->PAYLOAD_TYPE, 2); - bitvec_write_field(vector, writeIndex, data->RRBP, 2); - bitvec_write_field(vector, writeIndex, data->SP, 1); - bitvec_write_field(vector, writeIndex, data->USF, 3); + bitvec_write_field(vector, &writeIndex, data->PAYLOAD_TYPE, 2); + bitvec_write_field(vector, &writeIndex, data->RRBP, 2); + bitvec_write_field(vector, &writeIndex, data->SP, 1); + bitvec_write_field(vector, &writeIndex, data->USF, 3); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "RRBP = %u ", (unsigned)(data->RRBP)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "SP = %u ", (unsigned)(data->SP)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "USF = %u ", (unsigned)(data->USF)); // Octet 1 - bitvec_write_field(vector, writeIndex, data->PR, 2); - bitvec_write_field(vector, writeIndex, data->TFI, 5); - bitvec_write_field(vector, writeIndex, data->FBI, 1); + bitvec_write_field(vector, &writeIndex, data->PR, 2); + bitvec_write_field(vector, &writeIndex, data->TFI, 5); + bitvec_write_field(vector, &writeIndex, data->FBI, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PR = %u ", (unsigned)(data->PR)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "FBI = %u ", (unsigned)(data->FBI)); // Octet 2 - bitvec_write_field(vector, writeIndex, data->BSN, 7); - bitvec_write_field(vector, writeIndex, data->E_1, 1); + bitvec_write_field(vector, &writeIndex, data->BSN, 7); + bitvec_write_field(vector, &writeIndex, data->E_1, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1)); @@ -5488,9 +5488,9 @@ unsigned i = 0; do { - bitvec_write_field(vector, writeIndex, data->LENGTH_INDICATOR[i], 6); - bitvec_write_field(vector, writeIndex, data->M[i], 1); - bitvec_write_field(vector, writeIndex, data->E[i], 1); + bitvec_write_field(vector, &writeIndex, data->LENGTH_INDICATOR[i], 6); + bitvec_write_field(vector, &writeIndex, data->M[i], 1); + bitvec_write_field(vector, &writeIndex, data->E[i], 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i])); @@ -5503,7 +5503,7 @@ assert(dataNumOctets <= 20); for (unsigned i = 0; i < dataNumOctets; i++) { - bitvec_write_field(vector, writeIndex, data->RLC_DATA[i], 8); + bitvec_write_field(vector, &writeIndex, data->RLC_DATA[i], 8); LOGPC(DRLCMACDATA, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i])); } LOGPC(DRLCMACDATA, LOGL_NOTICE, "\n"); diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 0a0362b..c61eb6d 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -168,7 +168,6 @@ tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); if (!tall_pcu_ctx) return -ENOMEM; - bv_tall_ctx = tall_pcu_ctx; bts = bts_main_data(); bts->fc_interval = 1; diff --git a/src/tbf.cpp b/src/tbf.cpp index 0d28c5c..2c0c07f 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -1112,7 +1112,7 @@ msg = msgb_alloc(23, "rlcmac_dl_ass"); if (!msg) return NULL; - bitvec *ass_vec = bitvec_alloc(23); + bitvec *ass_vec = bitvec_alloc(23, tall_pcu_ctx); if (!ass_vec) { msgb_free(msg); return NULL; @@ -1159,7 +1159,7 @@ msg = msgb_alloc(23, "rlcmac_ul_ass_rej"); - bitvec *packet_access_rej = bitvec_alloc(23); + bitvec *packet_access_rej = bitvec_alloc(23, tall_pcu_ctx); bitvec_unhex(packet_access_rej, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); @@ -1216,7 +1216,7 @@ if (!msg) return NULL; LOGP(DRLCMAC, LOGL_INFO, "%ss start Packet Uplink Assignment (PACCH)\n", tbf_name(new_tbf)); - bitvec *ass_vec = bitvec_alloc(23); + bitvec *ass_vec = bitvec_alloc(23, tall_pcu_ctx); if (!ass_vec) { msgb_free(msg); return NULL; diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 2598174..1eee41a 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -121,7 +121,7 @@ msg = msgb_alloc(23, "rlcmac_ul_ack"); if (!msg) return NULL; - bitvec *ack_vec = bitvec_alloc(23); + bitvec *ack_vec = bitvec_alloc(23, tall_pcu_ctx); if (!ack_vec) { msgb_free(msg); return NULL; diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp index 97e5e60..9155809 100644 --- a/tests/rlcmac/RLCMACTest.cpp +++ b/tests/rlcmac/RLCMACTest.cpp @@ -83,9 +83,9 @@ cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; } -void testRlcMacDownlink() +void testRlcMacDownlink(void *test_ctx) { - struct bitvec *resultVector = bitvec_alloc(23); + struct bitvec *resultVector = bitvec_alloc(23, test_ctx); bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); std::string testData[] = { @@ -106,7 +106,7 @@ cout << " DOWNLINK " << endl; for (int i = 0; i < testDataSize; i++) { - bitvec *vector = bitvec_alloc(23); + bitvec *vector = bitvec_alloc(23, test_ctx); bitvec_unhex(vector, testData[i].c_str()); cout << "vector1 = "; for (int i = 0; i < 23; i++) @@ -150,9 +150,9 @@ } -void testRlcMacUplink() +void testRlcMacUplink(void *test_ctx) { - struct bitvec *resultVector = bitvec_alloc(23); + struct bitvec *resultVector = bitvec_alloc(23, test_ctx); bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); std::string testData[] = { @@ -169,7 +169,7 @@ cout << " UPLINK " << endl; for (int i = 0; i < testDataSize; i++) { - bitvec *vector = bitvec_alloc(23); + bitvec *vector = bitvec_alloc(23, test_ctx); bitvec_unhex(vector, testData[i].c_str()); cout << "vector1 = "; for (int i = 0; i < 23; i++) @@ -212,9 +212,9 @@ bitvec_free(resultVector); } -void testCsnLeftAlignedVarBmpBounds() +void testCsnLeftAlignedVarBmpBounds(void *test_ctx) { - bitvec *vector = bitvec_alloc(23); + bitvec *vector = bitvec_alloc(23, test_ctx); bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000"); RlcMacUplink_t data; @@ -229,10 +229,12 @@ int main(int argc, char *argv[]) { + void *ctx = talloc_named_const(NULL, 1, "RLCMACTest"); osmo_init_logging(&gprs_log_info); //printSizeofRLCMAC(); - testRlcMacDownlink(); - testRlcMacUplink(); - testCsnLeftAlignedVarBmpBounds(); + testRlcMacDownlink(ctx); + testRlcMacUplink(ctx); + testCsnLeftAlignedVarBmpBounds(ctx); + talloc_free(ctx); } diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index e367ce6..f042262 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -595,7 +595,7 @@ meas.set_rssi(31); - rlc_block = bitvec_alloc(23); + rlc_block = bitvec_alloc(23, tall_pcu_ctx); encode_gsm_rlcmac_uplink(rlc_block, ulreq); num_bytes = bitvec_pack(rlc_block, &buf[0]); @@ -2573,7 +2573,7 @@ OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); - block = bitvec_alloc(23); + block = bitvec_alloc(23, tall_pcu_ctx); bitvec_unpack(block, data_msg); diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp index ee1c817..7d09108 100644 --- a/tests/types/TypesTest.cpp +++ b/tests/types/TypesTest.cpp @@ -430,7 +430,7 @@ void test_immediate_assign_rej() { uint8_t plen; - bitvec *immediate_assignment_rej = bitvec_alloc(22); + bitvec *immediate_assignment_rej = bitvec_alloc(22, tall_pcu_ctx); bitvec_unhex(immediate_assignment_rej, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 02:20:54 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 02:20:54 +0000 Subject: [PATCH] osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1753 to look at the new patch set (#2). remove pcu own bitvector implementation The osmocore bitvec is exact the same, but use a pointer instead of a reference. Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 --- M src/Makefile.am D src/bitvector.cpp D src/bitvector.h M src/bts.cpp M src/csn1.cpp M src/csn1.h M src/egprs_rlc_compression.cpp M src/encoding.cpp M src/gprs_bssgp_pcu.cpp M src/gprs_rlcmac.cpp M src/gprs_rlcmac.h M src/gsm_rlcmac.cpp M src/pcu_main.cpp M src/tbf.cpp M src/tbf_ul.cpp M tests/rlcmac/RLCMACTest.cpp M tests/tbf/TbfTest.cpp M tests/types/TypesTest.cpp 18 files changed, 474 insertions(+), 644 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/53/1753/2 diff --git a/src/Makefile.am b/src/Makefile.am index 7cc239b..97de06d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,6 @@ gprs_ms.cpp \ gprs_ms_storage.cpp \ gsm_timer.cpp \ - bitvector.cpp \ pcu_l1_if.cpp \ pcu_vty.c \ pcu_vty_functions.cpp \ @@ -80,7 +79,6 @@ gprs_ms_storage.h \ pcu_l1_if.h \ gsm_timer.h \ - bitvector.h \ pcu_vty.h \ pcu_vty_functions.h \ tbf.h \ diff --git a/src/bitvector.cpp b/src/bitvector.cpp deleted file mode 100644 index dcb3baf..0000000 --- a/src/bitvector.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* bitvector.cpp - * - * Copyright (C) 2012 Ivan Klyuchnikov - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/*! \addtogroup bitvector - * @{ - */ - -/*! \file bitvector.cpp - * \brief Additional functions for Osmocom bit vector abstraction. - */ - -#include -extern "C" { -#include -} - -void *bv_tall_ctx; - -struct bitvec *bitvec_alloc(unsigned size) -{ - struct bitvec *bv = talloc_zero(bv_tall_ctx, struct bitvec); - bv->data_len = size; - bv->cur_bit = 0; - bv->data = talloc_zero_array(bv_tall_ctx, uint8_t, size); - return bv; -} - -void bitvec_free(struct bitvec *bv) -{ - talloc_free(bv->data); - talloc_free(bv); -} - -unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer) -{ - unsigned int i = 0; - for (i = 0; i < bv->data_len; i++) - { - buffer[i] = bv->data[i]; - } - return i; -} - -unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer) -{ - unsigned int i = 0; - for (i = 0; i < bv->data_len; i++) - { - bv->data[i] = buffer[i]; - } - return i; -} - - -int bitvec_unhex(struct bitvec *bv, const char* src) -{ - unsigned val; - unsigned write_index = 0; - unsigned digits = bv->data_len*2; - for (unsigned i=0; icur_bit = read_index; - - for (i = 0; i < len; i++) { - int bit = bitvec_get_bit_pos((const struct bitvec *)bv, bv->cur_bit); - if (bit < 0) - return bit; - if (bit) - ui |= ((uint64_t)1 << (len - i - 1)); - bv->cur_bit++; - } - read_index += len; - return ui; -} - - -int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index, - uint64_t val, unsigned len) -{ - unsigned int i; - int rc; - bv->cur_bit = write_index; - for (i = 0; i < len; i++) { - bit_value bit = L; - if (val & ((uint64_t)1 << (len - i - 1))) - bit = H; - rc = bitvec_set_bit(bv, bit); - if (rc) - return rc; - } - write_index += len; - return 0; -} diff --git a/src/bitvector.h b/src/bitvector.h deleted file mode 100644 index 246824d..0000000 --- a/src/bitvector.h +++ /dev/null @@ -1,52 +0,0 @@ -/* bitvector.h - * - * Copyright (C) 2012 Ivan Klyuchnikov - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef BITVECTOR_H -#define BITVECTOR_H - -/*! \defgroup bitvector Bit vectors - * @{ - */ - -/*! \file bitvector.h - * \brief Additional functions for Osmocom bit vector abstraction. - */ - -extern "C" { -#include -} - -struct bitvec *bitvec_alloc(unsigned size); -void bitvec_free(struct bitvec *bv); -int bitvec_unhex(struct bitvec *bv, const char* src); -unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer); -unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer); -uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len); -int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len); - - -static inline int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len) -{ - /* Call the libosmocore variant */ - return ::bitvec_write_field(bv, &write_index, val, len); -} - -/*! }@ */ - -#endif // BITVECTOR_H diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..e857380 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -618,7 +618,7 @@ tsc = tbf->tsc(); } } - bitvec *immediate_assignment = bitvec_alloc(22) /* without plen */; + bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx) /* without plen */; bitvec_unhex(immediate_assignment, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); @@ -758,7 +758,7 @@ unsigned int ts = tbf->first_ts; LOGP(DRLCMAC, LOGL_INFO, "TX: START %s Immediate Assignment Downlink (PCH)\n", tbf_name(tbf)); - bitvec *immediate_assignment = bitvec_alloc(22); /* without plen */ + bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx); /* without plen */ bitvec_unhex(immediate_assignment, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); /* use request reference that has maximum distance to current time, * so the assignment will not conflict with possible RACH requests. */ @@ -856,7 +856,7 @@ talloc_free(pag); return NULL; } - bitvec *pag_vec = bitvec_alloc(23); + bitvec *pag_vec = bitvec_alloc(23, tall_pcu_ctx); if (!pag_vec) { msgb_free(msg); talloc_free(pag); @@ -1577,7 +1577,7 @@ rc = rcv_data_block(data, fn, meas, cs); break; case GPRS_RLCMAC_CONTROL_BLOCK: - block = bitvec_alloc(len); + block = bitvec_alloc(len, tall_pcu_ctx); if (!block) return -ENOMEM; bitvec_unpack(block, data); diff --git a/src/csn1.cpp b/src/csn1.cpp index a1698a5..6203a44 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -64,15 +64,15 @@ readIndex -= relative_bit_offset; if (bit_shift >= 0) { - result = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) >> bit_shift; + result = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) >> bit_shift; readIndex-= bit_shift; result &= maskBits[no_of_bits]; } else { - guint8 hight_part = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) & maskBits[8 - relative_bit_offset]; + guint8 hight_part = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) & maskBits[8 - relative_bit_offset]; hight_part = (guint8) (hight_part << (-bit_shift)); - result = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) >> (8 + bit_shift); + result = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) >> (8 + bit_shift); readIndex = readIndex - (8 - (-bit_shift)); result |= hight_part; } @@ -133,7 +133,7 @@ static gboolean existNextElement(bitvec *vector, unsigned& readIndex, guint8 Tag) { - guint8 res = bitvec_read_field(vector, readIndex, 1); + guint8 res = bitvec_read_field(vector, &readIndex, 1); if (Tag == STANDARD_TAG) { return (res > 0); @@ -167,7 +167,7 @@ if (remaining_bits_len > 0) { pui8 = pui8DATA(data, pDescr->offset); - *pui8 = bitvec_read_field(vector, readIndex, 1); + *pui8 = bitvec_read_field(vector, &readIndex, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); /* end add the bit value to protocol tree */ } @@ -202,21 +202,21 @@ { if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32; LOGPC(DCSN1, LOGL_NOTICE, "%s = 0x%08x | ", pDescr->sz , *pui32); @@ -264,21 +264,21 @@ { if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8 + (guint8)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); @@ -308,7 +308,7 @@ remaining_bits_len -= no_of_bits; if (no_of_bits <= 8) { - guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); + guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); @@ -347,7 +347,7 @@ pui8 = pui8DATA(data, pDescr->offset); do { - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -401,7 +401,7 @@ LOGPC(DCSN1, LOGL_NOTICE, "%s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { pui8 += nSize; @@ -430,7 +430,7 @@ { for(unsigned ib = 0; ib < 4; ib++) { - guint8 ui8 = bitvec_read_field(vector, readIndex, 8); + guint8 ui8 = bitvec_read_field(vector, &readIndex, 8); pui8 = pui8DATA(data, pDescr->offset+ib); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); @@ -440,7 +440,7 @@ { for(unsigned ib = 0; ib < 8; ib++) { - guint8 ui8 = bitvec_read_field(vector, readIndex, 8); + guint8 ui8 = bitvec_read_field(vector, &readIndex, 8); pui8 = pui8DATA(data, pDescr->offset+ib); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); @@ -467,7 +467,7 @@ csnStream_t arT = *ar; LOGPC(DCSN1, LOGL_NOTICE, " : %s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); LOGPC(DCSN1, LOGL_NOTICE, ": End %s | ", pDescr->sz); if (Status >= 0) { @@ -493,7 +493,7 @@ while (count > 0) { guint8 no_of_bits = pChoice->bits; - guint8 value = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 value = bitvec_read_field(vector, &readIndex, no_of_bits); if (value == pChoice->value) { CSN_DESCR descr[2]; @@ -510,7 +510,7 @@ remaining_bits_len -= no_of_bits; csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, descr, vector, readIndex, data); + Status = csnStreamDecoder(&arT, descr, vector, readIndex, data); if (Status >= 0) { @@ -541,7 +541,7 @@ guint8 length_len = pDescr->i; gint16 Status = -1; - guint8 length = bitvec_read_field(vector, readIndex, length_len); + guint8 length = bitvec_read_field(vector, &readIndex, length_len); LOGPC(DCSN1, LOGL_NOTICE, "%s length = %d | ", pDescr->sz , (int)length); bit_offset += length_len; @@ -550,7 +550,7 @@ csnStreamInit(&arT, bit_offset, length); arT.direction = 1; LOGPC(DCSN1, LOGL_NOTICE, "ptr = %p | offset = %d | ", (void *)data, (int)pDescr->offset); - Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset)); + Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset)); if (Status >= 0) { @@ -595,7 +595,7 @@ } else { - index |= bitvec_read_field(vector, readIndex, 1); + index |= bitvec_read_field(vector, &readIndex, 1); } remaining_bits_len--; bit_offset++; @@ -618,7 +618,7 @@ { pui8 = pui8DATA(data, pDescr->offset); *pui8 = 0x00; - if (bitvec_read_field(vector, readIndex, 1) > 0) + if (bitvec_read_field(vector, &readIndex, 1) > 0) { *pui8 = 0x01; } @@ -644,21 +644,21 @@ if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); @@ -686,21 +686,21 @@ { if (no_of_bits <= 8) { - guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits); + guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8 + (guint8)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { - guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits); + guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits); pui16 = pui16DATA(data, pDescr->offset); *pui16 = ui16 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32 + (guint16)pDescr->descr.value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); @@ -728,7 +728,7 @@ { if (no_of_bits <= 8) { - guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); + guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits); pui8 = pui8DATA(data, pDescr->offset); *pui8 = ui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); @@ -767,7 +767,7 @@ while (nCount > 0) { - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -780,7 +780,7 @@ while (nCount > 0) { - *pui16 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui16 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , *pui16); pui16++; bit_offset += no_of_bits; @@ -830,7 +830,7 @@ { LOGPC(DCSN1, LOGL_NOTICE, "%s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { pui8 += nSize; @@ -856,13 +856,13 @@ if (no_of_bits <= 32) { - guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); pui32 = pui32DATA(data, pDescr->offset); *pui32 = ui32; } else if (no_of_bits <= 64) { - guint64 ui64 = bitvec_read_field(vector, readIndex, no_of_bits); + guint64 ui64 = bitvec_read_field(vector, &readIndex, no_of_bits); pui64 = pui64DATA(data, pDescr->offset); *pui64 = ui64; LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); @@ -888,7 +888,7 @@ csnStream_t arT = *ar; LOGPC(DCSN1, LOGL_NOTICE, " : %s | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset)); LOGPC(DCSN1, LOGL_NOTICE, " : End %s | ", pDescr->sz); if (Status >= 0) { @@ -923,11 +923,11 @@ if (CSN_EXIST_LH == pDescr->type) { - fExist = get_masked_bits8(vector, readIndex, bit_offset, 1); + fExist = get_masked_bits8(vector, readIndex, bit_offset, 1); } else { - fExist = bitvec_read_field(vector, readIndex, 1); + fExist = bitvec_read_field(vector, &readIndex, 1); } *pui8 = fExist; @@ -966,7 +966,7 @@ /* the "regular" M_NEXT_EXIST description element */ fExist = 0x00; - if (bitvec_read_field(vector, readIndex, 1)) + if (bitvec_read_field(vector, &readIndex, 1)) { fExist = 0x01; } @@ -1059,7 +1059,7 @@ if (nB1 > 0) { /* take care of the first byte - it will be right aligned */ - *pui8 = bitvec_read_field(vector, readIndex, nB1); + *pui8 = bitvec_read_field(vector, &readIndex, nB1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= nB1; @@ -1069,7 +1069,7 @@ /* remaining no_of_bits is a multiple of 8 or 0 */ while (no_of_bits > 0) { - *pui8 = bitvec_read_field(vector, readIndex, 8); + *pui8 = bitvec_read_field(vector, &readIndex, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; @@ -1113,14 +1113,14 @@ while (no_of_bits >= 8) { - *pui8 = bitvec_read_field(vector, readIndex, 8); + *pui8 = bitvec_read_field(vector, &readIndex, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; } if (no_of_bits > 0) { - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -1144,13 +1144,13 @@ guint8 bits_to_handle = remaining_bits_len%8; if (bits_to_handle > 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, readIndex, bits_to_handle)); + LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, bits_to_handle)); remaining_bits_len -= bits_to_handle; bit_offset += bits_to_handle; } else if (bits_to_handle == 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, readIndex, 8)); + LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, 8)); remaining_bits_len -= 8; bit_offset += 8; } @@ -1191,7 +1191,7 @@ while (count > 0) { readIndex -= 8; - *pui8 = bitvec_read_field(vector, readIndex, 8); + *pui8 = bitvec_read_field(vector, &readIndex, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += 8; @@ -1217,14 +1217,14 @@ pui8 = pui8DATA(data, pDescr->offset); - while (existNextElement(vector, readIndex, Tag)) + while (existNextElement(vector, readIndex, Tag)) { /* tag control shows existence of next list elements */ LOGPC(DCSN1, LOGL_NOTICE, "%s = Exist | ", pDescr->sz); bit_offset++; remaining_bits_len--; /* extract and store no_of_bits long element from bitstream */ - *pui8 = bitvec_read_field(vector, readIndex, no_of_bits); + *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; remaining_bits_len -= no_of_bits; @@ -1238,7 +1238,7 @@ bit_offset += no_of_bits; } - LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, readIndex, 1)); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1)); /* existNextElement() returned FALSE, 1 bit consumed */ bit_offset++; @@ -1258,7 +1258,7 @@ guint8 ElementCount = 0; pui8 = pui8DATA(data, pDescr->offset); - while (existNextElement(vector, readIndex, Tag)) + while (existNextElement(vector, readIndex, Tag)) { /* tag control shows existence of next list elements */ LOGPC(DCSN1, LOGL_NOTICE, "%s = Exist | ", pDescr->sz); /* existNextElement() returned TRUE, 1 bit consumed */ @@ -1270,7 +1270,7 @@ csnStream_t arT = *ar; gint16 Status; csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { /* successful completion */ @@ -1290,7 +1290,7 @@ } } - LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, readIndex, 1)); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1)); /* existNextElement() returned FALSE, 1 bit consumed */ bit_offset++; @@ -1331,7 +1331,7 @@ LOGPC(DCSN1, LOGL_NOTICE, "%s { | ", pDescr->sz); csnStreamInit(&arT, bit_offset, remaining_bits_len); - Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); + Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); if (Status >= 0) { /* successful completion */ @@ -1351,7 +1351,7 @@ /* control of next element's tag */ LOGPC(DCSN1, LOGL_NOTICE, "%s } | ", pDescr->sz); - EndOfList = !(existNextElement(vector, readIndex, Tag)); + EndOfList = !(existNextElement(vector, readIndex, Tag)); bit_offset++; remaining_bits_len--; /* 1 bit consumed (tag) */ @@ -1372,7 +1372,7 @@ if (no_of_bits <= 32) { - ui32 = bitvec_read_field(vector, readIndex, no_of_bits); + ui32 = bitvec_read_field(vector, &readIndex, no_of_bits); } else { @@ -1449,7 +1449,7 @@ if (remaining_bits_len > 0) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); /* end add the bit value to protocol tree */ } @@ -1483,19 +1483,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); } else @@ -1528,19 +1528,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(*pui8 - (guint8)pDescr->descr.value)); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned short)(*pui16 - (guint16)pDescr->descr.value)); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned int)(*pui32 - (guint16)pDescr->descr.value)); } else @@ -1569,12 +1569,12 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); // TODO : Change get_masked_bits8() writeIndex -= no_of_bits; guint8 ui8 = get_masked_bits8(vector, writeIndex, bit_offset, no_of_bits); writeIndex -= no_of_bits; - bitvec_write_field(vector, writeIndex, ui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, ui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } @@ -1612,7 +1612,7 @@ pui8 = pui8DATA(data, pDescr->offset); do { - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -1697,7 +1697,7 @@ for(unsigned ib = 0; ib < 4; ib++) { pui8 = pui8DATA(data, pDescr->offset+ib); - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); } } @@ -1706,7 +1706,7 @@ for(unsigned ib = 0; ib < 8; ib++) { pui8 = pui8DATA(data, pDescr->offset+ib); - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8); } } @@ -1761,7 +1761,7 @@ guint8 no_of_bits = pChoice->bits; guint8 value = pChoice->value; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pChoice->descr.sz , (unsigned)value); - bitvec_write_field(vector, writeIndex, value, no_of_bits); + bitvec_write_field(vector, &writeIndex, value, no_of_bits); CSN_DESCR descr[2]; gint16 Status; @@ -1807,7 +1807,7 @@ csnStreamInit(&arT, bit_offset, remaining_bits_len); Status = serialize(&arT, vector, writeIndex, pvDATA(data, pDescr->offset)); - bitvec_write_field(vector, lengthIndex, writeIndex-lengthIndex-length_len, length_len); + bitvec_write_field(vector, &lengthIndex, writeIndex-lengthIndex-length_len, length_len); LOGPC(DCSN1, LOGL_NOTICE, "%s length = %u | ", pDescr->sz , (unsigned)(writeIndex-lengthIndex)); if (Status >= 0) @@ -1846,7 +1846,7 @@ /* Assign UnionType */ pui8 = pui8DATA(data, pDescr->offset); //read index from data and write to vector - bitvec_write_field(vector, writeIndex, *pui8, Bits); + bitvec_write_field(vector, &writeIndex, *pui8, Bits); //decode index writeIndex -= Bits; @@ -1861,7 +1861,7 @@ } else { - index |= bitvec_read_field(vector, writeIndex, 1); + index |= bitvec_read_field(vector, &writeIndex, 1); } remaining_bits_len--; @@ -1870,7 +1870,7 @@ } writeIndex -= Bits; - bitvec_write_field(vector, writeIndex, index, Bits); + bitvec_write_field(vector, &writeIndex, index, Bits); /* script index to continue on, limited in case we do not have a power of 2 */ @@ -1883,7 +1883,7 @@ case CSN_BIT: { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); remaining_bits_len -= 1; bit_offset++; @@ -1907,19 +1907,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); } else @@ -1946,19 +1946,19 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(*pui8 - (guint8)pDescr->descr.value)); } else if (no_of_bits <= 16) { pui16 = pui16DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned short)(*pui16 - (guint16)pDescr->descr.value)); } else if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned int)(*pui32 - (guint16)pDescr->descr.value)); } else @@ -1987,12 +1987,12 @@ if (no_of_bits <= 8) { pui8 = pui8DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); // TODO : Change get_masked_bits8() writeIndex -= no_of_bits; guint8 ui8 = get_masked_bits8(vector, writeIndex, bit_offset, no_of_bits); writeIndex -= no_of_bits; - bitvec_write_field(vector, writeIndex, ui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, ui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); } @@ -2030,7 +2030,7 @@ pui8 = pui8DATA(data, pDescr->offset); do { - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += no_of_bits; @@ -2112,13 +2112,13 @@ if (no_of_bits <= 32) { pui32 = pui32DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui32, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32); } else if (no_of_bits <= 64) { pui64 = pui64DATA(data, pDescr->offset); - bitvec_write_field(vector, writeIndex, *pui64, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui64, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); } else @@ -2176,7 +2176,7 @@ unsigned exist = 0; pui8 = pui8DATA(data, pDescr->offset); exist = *pui8; - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); writeIndex--; if (CSN_EXIST_LH == pDescr->type) { @@ -2184,10 +2184,10 @@ } else { - fExist = bitvec_read_field(vector, writeIndex, 1); + fExist = bitvec_read_field(vector, &writeIndex, 1); } writeIndex--; - bitvec_write_field(vector, writeIndex, fExist, 1); + bitvec_write_field(vector, &writeIndex, fExist, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz, (unsigned)fExist); pDescr++; remaining_bits_len -= 1; @@ -2217,7 +2217,7 @@ break; } - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); fExist = *pui8; LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); remaining_bits_len -= 1; @@ -2257,11 +2257,11 @@ } /* the "regular" M_NEXT_EXIST_LH description element */ - bitvec_write_field(vector, writeIndex, *pui8, 1); + bitvec_write_field(vector, &writeIndex, *pui8, 1); writeIndex--; fExist = get_masked_bits8(vector,writeIndex, bit_offset, 1); writeIndex--; - bitvec_write_field(vector, writeIndex, fExist, 1); + bitvec_write_field(vector, &writeIndex, fExist, 1); pui8++; remaining_bits_len -= 1; @@ -2310,7 +2310,7 @@ if (nB1 > 0) { /* take care of the first byte - it will be right aligned */ - bitvec_write_field(vector, writeIndex, *pui8, nB1); + bitvec_write_field(vector, &writeIndex, *pui8, nB1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= nB1; @@ -2320,7 +2320,7 @@ /* remaining no_of_bits is a multiple of 8 or 0 */ while (no_of_bits > 0) { - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; @@ -2366,14 +2366,14 @@ while (no_of_bits > 0) { - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= 8; } if (nB1 > 0) { - bitvec_write_field(vector, writeIndex, *pui8, nB1); + bitvec_write_field(vector, &writeIndex, *pui8, nB1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; no_of_bits -= nB1; @@ -2405,14 +2405,14 @@ * < padding bits > ::= { null | 0 < spare padding > ! < Ignore : 1 bit** = < no string > > } ; */ guint8 fl = filler&(0xff>>(8-bits_to_handle + 1)); - bitvec_write_field(vector, writeIndex, fl, bits_to_handle); + bitvec_write_field(vector, &writeIndex, fl, bits_to_handle); LOGPC(DCSN1, LOGL_NOTICE, "%u|", fl); remaining_bits_len -= bits_to_handle; bit_offset += bits_to_handle; } else if (bits_to_handle == 0) { - bitvec_write_field(vector, writeIndex, filler, 8); + bitvec_write_field(vector, &writeIndex, filler, 8); LOGPC(DCSN1, LOGL_NOTICE, "%u|", filler); remaining_bits_len -= 8; bit_offset += 8; @@ -2453,7 +2453,7 @@ while (count > 0) { - bitvec_write_field(vector, writeIndex, *pui8, 8); + bitvec_write_field(vector, &writeIndex, *pui8, 8); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; bit_offset += 8; @@ -2480,13 +2480,13 @@ ElementCount = *pui8DATA(data, (gint16)pDescr->descr.value); while (ElementCount > 0) { /* tag control shows existence of next list elements */ - bitvec_write_field(vector, writeIndex, Tag, 1); + bitvec_write_field(vector, &writeIndex, Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag); bit_offset++; remaining_bits_len--; /* extract and store no_of_bits long element from bitstream */ - bitvec_write_field(vector, writeIndex, *pui8, no_of_bits); + bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8); pui8++; remaining_bits_len -= no_of_bits; @@ -2500,7 +2500,7 @@ bit_offset += no_of_bits; } - bitvec_write_field(vector, writeIndex, !Tag, 1); + bitvec_write_field(vector, &writeIndex, !Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(!Tag)); bit_offset++; remaining_bits_len--; @@ -2522,7 +2522,7 @@ while (ElementCount > 0) { /* tag control shows existence of next list elements */ - bitvec_write_field(vector, writeIndex, Tag, 1); + bitvec_write_field(vector, &writeIndex, Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag); bit_offset++; @@ -2553,7 +2553,7 @@ } } - bitvec_write_field(vector, writeIndex, !Tag, 1); + bitvec_write_field(vector, &writeIndex, !Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(!Tag)); bit_offset++; @@ -2591,7 +2591,7 @@ { /* get data element */ if (ElementCount != ElementNum) { - bitvec_write_field(vector, writeIndex, Tag, 1); + bitvec_write_field(vector, &writeIndex, Tag, 1); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag); bit_offset++; remaining_bits_len--; @@ -2618,7 +2618,7 @@ } } - bitvec_write_field(vector, writeIndex, !Tag, 1); + bitvec_write_field(vector, &writeIndex, !Tag, 1); bit_offset++; remaining_bits_len--; Tag = STANDARD_TAG; /* in case it was set to "reversed" */ @@ -2629,7 +2629,7 @@ case CSN_FIXED: { /* Verify the fixed bits */ guint8 no_of_bits = (guint8) pDescr->i; - bitvec_write_field(vector, writeIndex, pDescr->offset, no_of_bits); + bitvec_write_field(vector, &writeIndex, pDescr->offset, no_of_bits); LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)pDescr->offset); remaining_bits_len -= no_of_bits; bit_offset += no_of_bits; diff --git a/src/csn1.h b/src/csn1.h index 96f7558..3f5b849 100644 --- a/src/csn1.h +++ b/src/csn1.h @@ -25,7 +25,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +extern "C" { +#include +} + #include #include #ifndef _PACKET_CSN1_H_ diff --git a/src/egprs_rlc_compression.cpp b/src/egprs_rlc_compression.cpp index 82605ff..7eeb7d2 100644 --- a/src/egprs_rlc_compression.cpp +++ b/src/egprs_rlc_compression.cpp @@ -528,10 +528,10 @@ /* put run length of Ones in uncompressed bitmap */ while (run_length != 0) { if (run_length > 8) { - bitvec_write_field(dest, wp, data, 8); + bitvec_write_field(dest, &wp, data, 8); run_length = run_length - 8; } else { - bitvec_write_field(dest, wp, data, run_length); + bitvec_write_field(dest, &wp, data, run_length); run_length = 0; } } @@ -581,7 +581,7 @@ *codewrd_bitmap = t4_term[start][*run_len_cnt]; *codewrd_len = t4_term_length[start][*run_len_cnt]; } - bitvec_write_field(crbb_vec, writeIndex, *codewrd_bitmap, *codewrd_len); + bitvec_write_field(crbb_vec, &writeIndex, *codewrd_bitmap, *codewrd_len); } /* Compress received block bitmap */ diff --git a/src/encoding.cpp b/src/encoding.cpp index ea38b77..ed8fdaa 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -40,12 +40,12 @@ static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai) { if (tai < 0) { /* No TIMING_ADVANCE_INDEX: */ - bitvec_write_field(dest, wp, 0, 1); + bitvec_write_field(dest, &wp, 0, 1); return false; } /* TIMING_ADVANCE_INDEX: */ - bitvec_write_field(dest, wp, 1, 1); - bitvec_write_field(dest, wp, tai, 4); + bitvec_write_field(dest, &wp, 1, 1); + bitvec_write_field(dest, &wp, tai, 4); return true; } @@ -53,10 +53,10 @@ static inline void write_ta(bitvec *dest, unsigned& wp, int8_t ta) { if (ta < 0) /* No TIMING_ADVANCE_VALUE: */ - bitvec_write_field(dest, wp, 0, 1); + bitvec_write_field(dest, &wp, 0, 1); else { /* TIMING_ADVANCE_VALUE: */ - bitvec_write_field(dest, wp, 1, 1); - bitvec_write_field(dest, wp, ta, 6); + bitvec_write_field(dest, &wp, 1, 1); + bitvec_write_field(dest, &wp, ta, 6); } } @@ -70,7 +70,7 @@ { write_ta(dest, wp, ta); if (write_tai(dest, wp, tai)) /* TIMING_ADVANCE_TIMESLOT_NUMBER: */ - bitvec_write_field(dest, wp, ts, 3); + bitvec_write_field(dest, &wp, ts, 3); } static int write_ia_rest_downlink( @@ -85,40 +85,40 @@ return -EINVAL; } // GSM 04.08 10.5.2.16 IA Rest Octets - bitvec_write_field_lh(dest, wp, 3, 2); // "HH" - bitvec_write_field(dest, wp, 1, 2); // "01" Packet Downlink Assignment - bitvec_write_field(dest, wp,tbf->tlli(),32); // TLLI - bitvec_write_field(dest, wp,0x1,1); // switch TFI : on - bitvec_write_field(dest, wp,tbf->tfi(),5); // TFI - bitvec_write_field(dest, wp,0x0,1); // RLC acknowledged mode + bitvec_write_field(dest, &wp, 3, 2); // "HH" + bitvec_write_field(dest, &wp, 1, 2); // "01" Packet Downlink Assignment + bitvec_write_field(dest, &wp,tbf->tlli(),32); // TLLI + bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on + bitvec_write_field(dest, &wp,tbf->tfi(),5); // TFI + bitvec_write_field(dest, &wp,0x0,1); // RLC acknowledged mode if (alpha) { - bitvec_write_field(dest, wp,0x1,1); // ALPHA = present - bitvec_write_field(dest, wp,alpha,4); // ALPHA + bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present + bitvec_write_field(dest, &wp,alpha,4); // ALPHA } else { - bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present + bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present } - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter - bitvec_write_field(dest, wp,polling,1); // Polling Bit - bitvec_write_field(dest, wp, ta_valid, 1); // N. B: NOT related to TAI! + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,polling,1); // Polling Bit + bitvec_write_field(dest, &wp, ta_valid, 1); // N. B: NOT related to TAI! write_tai(dest, wp, ta_idx); if (polling) { - bitvec_write_field(dest, wp,0x1,1); // TBF Starting TIME present - bitvec_write_field(dest, wp,(fn / (26 * 51)) % 32,5); // T1' - bitvec_write_field(dest, wp,fn % 51,6); // T3 - bitvec_write_field(dest, wp,fn % 26,5); // T2 + bitvec_write_field(dest, &wp,0x1,1); // TBF Starting TIME present + bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1' + bitvec_write_field(dest, &wp,fn % 51,6); // T3 + bitvec_write_field(dest, &wp,fn % 26,5); // T2 } else { - bitvec_write_field(dest, wp,0x0,1); // TBF Starting TIME present + bitvec_write_field(dest, &wp,0x0,1); // TBF Starting TIME present } - bitvec_write_field(dest, wp,0x0,1); // P0 not present - // bitvec_write_field(dest, wp,0x1,1); // P0 not present - // bitvec_write_field(dest, wp,0xb,4); + bitvec_write_field(dest, &wp,0x0,1); // P0 not present + // bitvec_write_field(dest, &wp,0x1,1); // P0 not present + // bitvec_write_field(dest, &wp,,0xb,4); if (tbf->is_egprs_enabled()) { /* see GMS 44.018, 10.5.2.16 */ unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32; - bitvec_write_field_lh(dest, wp, 1, 1); // "H" - bitvec_write_field(dest, wp, ws_enc,5); // EGPRS Window Size - bitvec_write_field(dest, wp, 0x0,2); // LINK_QUALITY_MEASUREMENT_MODE - bitvec_write_field(dest, wp, 0,1); // BEP_PERIOD2 not present + bitvec_write_field(dest, &wp, 1, 1); // "H" + bitvec_write_field(dest, &wp, ws_enc, 5); // EGPRS Window Size + bitvec_write_field(dest, &wp, 0x0, 2); // LINK_QUALITY_MEASUREMENT_MODE + bitvec_write_field(dest, &wp, 0, 1); // BEP_PERIOD2 not present } return 0; @@ -133,40 +133,40 @@ OSMO_ASSERT(!tbf || !tbf->is_egprs_enabled()); // GMS 04.08 10.5.2.37b 10.5.2.16 - bitvec_write_field_lh(dest, wp, 3, 2); // "HH" - bitvec_write_field(dest, wp, 0, 2); // "0" Packet Uplink Assignment + bitvec_write_field(dest, &wp, 3, 2); // "HH" + bitvec_write_field(dest, &wp, 0, 2); // "0" Packet Uplink Assignment if (tbf == NULL) { - bitvec_write_field(dest, wp, 0, 1); // Block Allocation : Single Block Allocation + bitvec_write_field(dest, &wp, 0, 1); // Block Allocation : Single Block Allocation if (alpha) { - bitvec_write_field(dest, wp,0x1,1); // ALPHA = present - bitvec_write_field(dest, wp,alpha,4); // ALPHA = present + bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present + bitvec_write_field(dest, &wp,alpha,4); // ALPHA = present } else - bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter write_tai(dest, wp, ta_idx); - bitvec_write_field(dest, wp, 1, 1); // TBF_STARTING_TIME_FLAG - bitvec_write_field(dest, wp,(fn / (26 * 51)) % 32,5); // T1' - bitvec_write_field(dest, wp,fn % 51,6); // T3 - bitvec_write_field(dest, wp,fn % 26,5); // T2 + bitvec_write_field(dest, &wp, 1, 1); // TBF_STARTING_TIME_FLAG + bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1' + bitvec_write_field(dest, &wp,fn % 51,6); // T3 + bitvec_write_field(dest, &wp,fn % 26,5); // T2 } else { - bitvec_write_field(dest, wp, 1, 1); // Block Allocation : Not Single Block Allocation - bitvec_write_field(dest, wp, tbf->tfi(), 5); // TFI_ASSIGNMENT Temporary Flow Identity - bitvec_write_field(dest, wp, 0, 1); // POLLING - bitvec_write_field(dest, wp, 0, 1); // ALLOCATION_TYPE: dynamic - bitvec_write_field(dest, wp, usf, 3); // USF - bitvec_write_field(dest, wp, 0, 1); // USF_GRANULARITY - bitvec_write_field(dest, wp, 0, 1); // "0" power control: Not Present - bitvec_write_field(dest, wp, tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND - bitvec_write_field(dest, wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING + bitvec_write_field(dest, &wp, 1, 1); // Block Allocation : Not Single Block Allocation + bitvec_write_field(dest, &wp, tbf->tfi(), 5); // TFI_ASSIGNMENT Temporary Flow Identity + bitvec_write_field(dest, &wp, 0, 1); // POLLING + bitvec_write_field(dest, &wp, 0, 1); // ALLOCATION_TYPE: dynamic + bitvec_write_field(dest, &wp, usf, 3); // USF + bitvec_write_field(dest, &wp, 0, 1); // USF_GRANULARITY + bitvec_write_field(dest, &wp, 0, 1); // "0" power control: Not Present + bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING if (alpha) { - bitvec_write_field(dest, wp,0x1,1); // ALPHA = present - bitvec_write_field(dest, wp,alpha,4); // ALPHA + bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present + bitvec_write_field(dest, &wp,alpha,4); // ALPHA } else - bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter /* note: there is no choise for TAI and no starting time */ - bitvec_write_field(dest, wp, 0, 1); // switch TIMING_ADVANCE_INDEX = off - bitvec_write_field(dest, wp, 0, 1); // TBF_STARTING_TIME_FLAG + bitvec_write_field(dest, &wp, 0, 1); // switch TIMING_ADVANCE_INDEX = off + bitvec_write_field(dest, &wp, 0, 1); // TBF_STARTING_TIME_FLAG } return 0; } @@ -183,60 +183,60 @@ extended_ra = (ra & 0x1F); - bitvec_write_field(dest, wp, 1, 2); /* LH */ - bitvec_write_field(dest, wp, 0, 2); /* 0 EGPRS Uplink Assignment */ - bitvec_write_field(dest, wp, extended_ra, 5); /* Extended RA */ - bitvec_write_field(dest, wp, 0, 1); /* Access technology Request */ + bitvec_write_field(dest, &wp, 1, 2); /* LH */ + bitvec_write_field(dest, &wp, 0, 2); /* 0 EGPRS Uplink Assignment */ + bitvec_write_field(dest, &wp, extended_ra, 5); /* Extended RA */ + bitvec_write_field(dest, &wp, 0, 1); /* Access technology Request */ if (tbf == NULL) { - bitvec_write_field(dest, wp, 0, 1); /* multiblock allocation */ + bitvec_write_field(dest, &wp, 0, 1); /* multiblock allocation */ if (alpha) { - bitvec_write_field(dest, wp, 0x1, 1); /* ALPHA =yes */ - bitvec_write_field(dest, wp, alpha, 4); /* ALPHA */ + bitvec_write_field(dest, &wp, 0x1, 1); /* ALPHA =yes */ + bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */ } else { - bitvec_write_field(dest, wp, 0x0, 1); /* ALPHA = no */ + bitvec_write_field(dest, &wp, 0x0, 1); /* ALPHA = no */ } - bitvec_write_field(dest, wp, gamma, 5); /* GAMMA power contrl */ - bitvec_write_field(dest, wp, (fn / (26 * 51)) % 32, 5);/* T1' */ - bitvec_write_field(dest, wp, fn % 51, 6); /* T3 */ - bitvec_write_field(dest, wp, fn % 26, 5); /* T2 */ - bitvec_write_field(dest, wp, 0, 2); /* Radio block allocation */ + bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */ + bitvec_write_field(dest, &wp, (fn / (26 * 51)) % 32, 5);/* T1' */ + bitvec_write_field(dest, &wp, fn % 51, 6); /* T3 */ + bitvec_write_field(dest, &wp, fn % 26, 5); /* T2 */ + bitvec_write_field(dest, &wp, 0, 2); /* Radio block allocation */ - bitvec_write_field(dest, wp, 0, 1); + bitvec_write_field(dest, &wp, 0, 1); } else { ws_enc = (tbf->m_window.ws() - 64) / 32; - bitvec_write_field(dest, wp, 1, 1); /* single block alloc */ - bitvec_write_field(dest, wp, tbf->tfi(), 5);/* TFI assignment */ - bitvec_write_field(dest, wp, 0, 1); /* polling bit */ - bitvec_write_field(dest, wp, 0, 1); /* constant */ - bitvec_write_field(dest, wp, usf, 3); /* USF bit */ - bitvec_write_field(dest, wp, 0, 1); /* USF granularity */ - bitvec_write_field(dest, wp, 0, 1); /* P0 */ + bitvec_write_field(dest, &wp, 1, 1); /* single block alloc */ + bitvec_write_field(dest, &wp, tbf->tfi(), 5);/* TFI assignment */ + bitvec_write_field(dest, &wp, 0, 1); /* polling bit */ + bitvec_write_field(dest, &wp, 0, 1); /* constant */ + bitvec_write_field(dest, &wp, usf, 3); /* USF bit */ + bitvec_write_field(dest, &wp, 0, 1); /* USF granularity */ + bitvec_write_field(dest, &wp, 0, 1); /* P0 */ /* MCS */ - bitvec_write_field(dest, wp, tbf->current_cs().to_num()-1, 4); + bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 4); /* tlli channel block */ - bitvec_write_field(dest, wp, tbf->tlli(), 1); - bitvec_write_field(dest, wp, 0, 1); /* BEP period present */ - bitvec_write_field(dest, wp, 0, 1); /* resegmentation */ - bitvec_write_field(dest, wp, ws_enc, 5);/* egprs window_size */ + bitvec_write_field(dest, &wp, tbf->tlli(), 1); + bitvec_write_field(dest, &wp, 0, 1); /* BEP period present */ + bitvec_write_field(dest, &wp, 0, 1); /* resegmentation */ + bitvec_write_field(dest, &wp, ws_enc, 5);/* egprs window_size */ if (alpha) { - bitvec_write_field(dest, wp, 0x1, 1); /* ALPHA =yes */ - bitvec_write_field(dest, wp, alpha, 4); /* ALPHA */ + bitvec_write_field(dest, &wp, 0x1, 1); /* ALPHA =yes */ + bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */ } else { - bitvec_write_field(dest, wp, 0x0, 1); /* ALPHA = no */ + bitvec_write_field(dest, &wp, 0x0, 1); /* ALPHA = no */ } - bitvec_write_field(dest, wp, gamma, 5); /* GAMMA power contrl */ - bitvec_write_field(dest, wp, 0, 1); /* TIMING_ADVANCE_INDEX */ - bitvec_write_field(dest, wp, 0, 1); /* TBF_STARTING_TIME_FLAG */ - bitvec_write_field(dest, wp, 0, 1); /* NULL */ + bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */ + bitvec_write_field(dest, &wp, 0, 1); /* TIMING_ADVANCE_INDEX */ + bitvec_write_field(dest, &wp, 0, 1); /* TBF_STARTING_TIME_FLAG */ + bitvec_write_field(dest, &wp, 0, 1); /* NULL */ } return 0; @@ -255,17 +255,17 @@ int plen; int i; - bitvec_write_field(dest, wp, 0x0, 4); // Skip Indicator - bitvec_write_field(dest, wp, 0x6, 4); // Protocol Discriminator - bitvec_write_field(dest, wp, 0x3A, 8); // Immediate Assign Message Type + bitvec_write_field(dest, &wp, 0x0, 4); // Skip Indicator + bitvec_write_field(dest, &wp, 0x6, 4); // Protocol Discriminator + bitvec_write_field(dest, &wp, 0x3A, 8); // Immediate Assign Message Type // feature indicator - bitvec_write_field(dest, wp, 0x0, 1); // spare - bitvec_write_field(dest, wp, 0x0, 1); // spare - bitvec_write_field(dest, wp, 0x0, 1); // no cs - bitvec_write_field(dest, wp, 0x1, 1); // implicit detach for PS + bitvec_write_field(dest, &wp, 0x0, 1); // spare + bitvec_write_field(dest, &wp, 0x0, 1); // spare + bitvec_write_field(dest, &wp, 0x0, 1); // no cs + bitvec_write_field(dest, &wp, 0x1, 1); // implicit detach for PS - bitvec_write_field(dest, wp, 0x0, 4); // Page Mode + bitvec_write_field(dest, &wp, 0x0, 4); // Page Mode /* * 9.1.20.2 of 44.018 version 11.7.0 Release 11 * Filling of the message @@ -279,18 +279,18 @@ if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) || (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) { //9.1.20.2a of 44.018 version 11.7.0 Release 11 - bitvec_write_field(dest, wp, 0x7f, 8); /* RACH value */ + bitvec_write_field(dest, &wp, 0x7f, 8); /* RACH value */ } else { - bitvec_write_field(dest, wp, ra, 8); /* RACH value */ + bitvec_write_field(dest, &wp, ra, 8); /* RACH value */ } - bitvec_write_field(dest, wp, + bitvec_write_field(dest, &wp, (ref_fn / (26 * 51)) % 32, 5); // T1' - bitvec_write_field(dest, wp, ref_fn % 51, 6); // T3 - bitvec_write_field(dest, wp, ref_fn % 26, 5); // T2 + bitvec_write_field(dest, &wp, ref_fn % 51, 6); // T3 + bitvec_write_field(dest, &wp, ref_fn % 26, 5); // T2 /* TODO: Make it configurable */ - bitvec_write_field(dest, wp, 20, 8); //Wait Indication 1 + bitvec_write_field(dest, &wp, 20, 8); //Wait Indication 1 } plen = wp / 8; @@ -308,14 +308,14 @@ uint8_t extended_ra = 0; extended_ra = (ra & 0x1F); - bitvec_write_field(dest, wp, 0x1, 1); - bitvec_write_field(dest, wp, extended_ra, 5); /* Extended RA */ + bitvec_write_field(dest, &wp, 0x1, 1); + bitvec_write_field(dest, &wp, extended_ra, 5); /* Extended RA */ } else { - bitvec_write_field(dest, wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); } - bitvec_write_field(dest, wp, 0x0, 1); - bitvec_write_field(dest, wp, 0x0, 1); - bitvec_write_field(dest, wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); + bitvec_write_field(dest, &wp, 0x0, 1); return plen; } @@ -335,44 +335,44 @@ int plen; int rc; - bitvec_write_field(dest, wp,0x0,4); // Skip Indicator - bitvec_write_field(dest, wp,0x6,4); // Protocol Discriminator - bitvec_write_field(dest, wp,0x3F,8); // Immediate Assignment Message Type + bitvec_write_field(dest, &wp,0x0,4); // Skip Indicator + bitvec_write_field(dest, &wp,0x6,4); // Protocol Discriminator + bitvec_write_field(dest, &wp,0x3F,8); // Immediate Assignment Message Type // 10.5.2.25b Dedicated mode or TBF - bitvec_write_field(dest, wp,0x0,1); // spare - bitvec_write_field(dest, wp,0x0,1); // TMA : Two-message assignment: No meaning - bitvec_write_field(dest, wp,downlink,1); // Downlink : Downlink assignment to mobile in packet idle mode - bitvec_write_field(dest, wp,0x1,1); // T/D : TBF or dedicated mode: this message assigns a Temporary Block Flow (TBF). + bitvec_write_field(dest, &wp,0x0,1); // spare + bitvec_write_field(dest, &wp,0x0,1); // TMA : Two-message assignment: No meaning + bitvec_write_field(dest, &wp,downlink,1); // Downlink : Downlink assignment to mobile in packet idle mode + bitvec_write_field(dest, &wp,0x1,1); // T/D : TBF or dedicated mode: this message assigns a Temporary Block Flow (TBF). - bitvec_write_field(dest, wp,0x0,4); // Page Mode + bitvec_write_field(dest, &wp,0x0,4); // Page Mode // GSM 04.08 10.5.2.25a Packet Channel Description - bitvec_write_field(dest, wp,0x1,5); // Channel type - bitvec_write_field(dest, wp,ts,3); // TN - bitvec_write_field(dest, wp,tsc,3); // TSC - bitvec_write_field(dest, wp,0x0,3); // non-hopping RF channel configuraion - bitvec_write_field(dest, wp,arfcn,10); // ARFCN + bitvec_write_field(dest, &wp,0x1,5); // Channel type + bitvec_write_field(dest, &wp,ts,3); // TN + bitvec_write_field(dest, &wp,tsc,3); // TSC + bitvec_write_field(dest, &wp,0x0,3); // non-hopping RF channel configuraion + bitvec_write_field(dest, &wp,arfcn,10); // ARFCN //10.5.2.30 Request Reference if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) || (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) { - bitvec_write_field(dest, wp, 0x7f, 8); /* RACH value */ + bitvec_write_field(dest, &wp, 0x7f, 8); /* RACH value */ } else { - bitvec_write_field(dest, wp, ra, 8); /* RACH value */ + bitvec_write_field(dest, &wp, ra, 8); /* RACH value */ } - bitvec_write_field(dest, wp,(ref_fn / (26 * 51)) % 32,5); // T1' - bitvec_write_field(dest, wp,ref_fn % 51,6); // T3 - bitvec_write_field(dest, wp,ref_fn % 26,5); // T2 + bitvec_write_field(dest, &wp,(ref_fn / (26 * 51)) % 32,5); // T1' + bitvec_write_field(dest, &wp,ref_fn % 51,6); // T3 + bitvec_write_field(dest, &wp,ref_fn % 26,5); // T2 // 10.5.2.40 Timing Advance - bitvec_write_field(dest, wp,0x0,2); // spare - bitvec_write_field(dest, wp,ta,6); // Timing Advance value + bitvec_write_field(dest, &wp,0x0,2); // spare + bitvec_write_field(dest, &wp,ta,6); // Timing Advance value // No mobile allocation in non-hopping systems. // A zero-length LV. Just write L=0. - bitvec_write_field(dest, wp,0,8); + bitvec_write_field(dest, &wp,0,8); if ((wp % 8)) { LOGP(DRLCMACUL, LOGL_ERROR, "Length of IMM.ASS without rest " @@ -420,83 +420,83 @@ /* timeslot assigned for the Continuous Timing Advance procedure */ uint8_t ta_ts = 0; /* FIXME: supply it as parameter from caller */ - bitvec_write_field(dest, wp,0x1,2); // Payload Type - bitvec_write_field(dest, wp,0x0,2); // Uplink block with TDMA framenumber (N+13) - bitvec_write_field(dest, wp,poll,1); // Suppl/Polling Bit - bitvec_write_field(dest, wp,0x0,3); // Uplink state flag - bitvec_write_field(dest, wp,0xa,6); // MESSAGE TYPE + bitvec_write_field(dest, &wp,0x1,2); // Payload Type + bitvec_write_field(dest, &wp,0x0,2); // Uplink block with TDMA framenumber (N+13) + bitvec_write_field(dest, &wp,poll,1); // Suppl/Polling Bit + bitvec_write_field(dest, &wp,0x0,3); // Uplink state flag + bitvec_write_field(dest, &wp,0xa,6); // MESSAGE TYPE - bitvec_write_field(dest, wp,0x0,2); // Page Mode + bitvec_write_field(dest, &wp,0x0,2); // Page Mode - bitvec_write_field(dest, wp,0x0,1); // switch PERSIST_LEVEL: off + bitvec_write_field(dest, &wp,0x0,1); // switch PERSIST_LEVEL: off if (use_tlli) { - bitvec_write_field(dest, wp,0x2,2); // switch TLLI : on - bitvec_write_field(dest, wp,tlli,32); // TLLI + bitvec_write_field(dest, &wp,0x2,2); // switch TLLI : on + bitvec_write_field(dest, &wp,tlli,32); // TLLI } else { - bitvec_write_field(dest, wp,0x0,1); // switch TFI : on - bitvec_write_field(dest, wp,old_downlink,1); // 0=UPLINK TFI, 1=DL TFI - bitvec_write_field(dest, wp,old_tfi,5); // TFI + bitvec_write_field(dest, &wp,0x0,1); // switch TFI : on + bitvec_write_field(dest, &wp,old_downlink,1); // 0=UPLINK TFI, 1=DL TFI + bitvec_write_field(dest, &wp,old_tfi,5); // TFI } if (!use_egprs) { - bitvec_write_field(dest, wp,0x0,1); // Message escape - bitvec_write_field(dest, wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND - bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING + bitvec_write_field(dest, &wp,0x0,1); // Message escape + bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts); } else { /* EPGRS */ unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32; - bitvec_write_field(dest, wp,0x1,1); // Message escape - bitvec_write_field(dest, wp,0x0,2); // EGPRS message contents - bitvec_write_field(dest, wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp,0x0,1); // No COMPACT reduced MA - bitvec_write_field(dest, wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE + bitvec_write_field(dest, &wp,0x1,1); // Message escape + bitvec_write_field(dest, &wp,0x0,2); // EGPRS message contents + bitvec_write_field(dest, &wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp,0x0,1); // No COMPACT reduced MA + bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE /* 0: no RESEGMENT, 1: Segmentation*/ - bitvec_write_field(dest, wp, 0x1, 1); - bitvec_write_field(dest, wp,ws_enc,5); // EGPRS Window Size - bitvec_write_field(dest, wp,0x0,1); // No Access Technologies Request - bitvec_write_field(dest, wp,0x0,1); // No ARAC RETRANSMISSION REQUEST - bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING - bitvec_write_field(dest, wp,0x0,1); // No BEP_PERIOD2 + bitvec_write_field(dest, &wp, 0x1, 1); + bitvec_write_field(dest, &wp,ws_enc,5); // EGPRS Window Size + bitvec_write_field(dest, &wp,0x0,1); // No Access Technologies Request + bitvec_write_field(dest, &wp,0x0,1); // No ARAC RETRANSMISSION REQUEST + bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING + bitvec_write_field(dest, &wp,0x0,1); // No BEP_PERIOD2 write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts); - bitvec_write_field(dest, wp,0x0,1); // No Packet Extended Timing Advance + bitvec_write_field(dest, &wp,0x0,1); // No Packet Extended Timing Advance } #if 1 - bitvec_write_field(dest, wp,0x1,1); // Frequency Parameters information elements = present - bitvec_write_field(dest, wp,tbf->tsc(),3); // Training Sequence Code (TSC) - bitvec_write_field(dest, wp,0x0,2); // ARFCN = present - bitvec_write_field(dest, wp,tbf->trx->arfcn,10); // ARFCN + bitvec_write_field(dest, &wp,0x1,1); // Frequency Parameters information elements = present + bitvec_write_field(dest, &wp,tbf->tsc(),3); // Training Sequence Code (TSC) + bitvec_write_field(dest, &wp,0x0,2); // ARFCN = present + bitvec_write_field(dest, &wp,tbf->trx->arfcn,10); // ARFCN #else - bitvec_write_field(dest, wp,0x0,1); // Frequency Parameters = off + bitvec_write_field(dest, &wp,0x0,1); // Frequency Parameters = off #endif - bitvec_write_field(dest, wp,0x1,2); // Dynamic Allocation + bitvec_write_field(dest, &wp,0x1,2); // Dynamic Allocation - bitvec_write_field(dest, wp,0x0,1); // Extended Dynamic Allocation = off - bitvec_write_field(dest, wp,0x0,1); // P0 = off + bitvec_write_field(dest, &wp,0x0,1); // Extended Dynamic Allocation = off + bitvec_write_field(dest, &wp,0x0,1); // P0 = off - bitvec_write_field(dest, wp,0x0,1); // USF_GRANULARITY - bitvec_write_field(dest, wp,0x1,1); // switch TFI : on - bitvec_write_field(dest, wp,tbf->tfi(),5);// TFI + bitvec_write_field(dest, &wp,0x0,1); // USF_GRANULARITY + bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on + bitvec_write_field(dest, &wp,tbf->tfi(),5);// TFI - bitvec_write_field(dest, wp,0x0,1); // - bitvec_write_field(dest, wp,0x0,1); // TBF Starting Time = off + bitvec_write_field(dest, &wp,0x0,1); // + bitvec_write_field(dest, &wp,0x0,1); // TBF Starting Time = off if (alpha || gamma) { - bitvec_write_field(dest, wp,0x1,1); // Timeslot Allocation with Power Control - bitvec_write_field(dest, wp,alpha,4); // ALPHA + bitvec_write_field(dest, &wp,0x1,1); // Timeslot Allocation with Power Control + bitvec_write_field(dest, &wp,alpha,4); // ALPHA } else - bitvec_write_field(dest, wp,0x0,1); // Timeslot Allocation + bitvec_write_field(dest, &wp,0x0,1); // Timeslot Allocation for (ts = 0; ts < 8; ts++) { if (tbf->pdch[ts]) { - bitvec_write_field(dest, wp,0x1,1); // USF_TN(i): on - bitvec_write_field(dest, wp,tbf->m_usf[ts],3); // USF_TN(i) + bitvec_write_field(dest, &wp,0x1,1); // USF_TN(i): on + bitvec_write_field(dest, &wp,tbf->m_usf[ts],3); // USF_TN(i) if (alpha || gamma) - bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter + bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter } else - bitvec_write_field(dest, wp,0x0,1); // USF_TN(i): off + bitvec_write_field(dest, &wp,0x0,1); // USF_TN(i): off } - // bitvec_write_field(dest, wp,0x0,1); // Measurement Mapping struct not present + // bitvec_write_field(dest, &wp,0x0,1); // Measurement Mapping struct not present } @@ -603,20 +603,20 @@ unsigned wp = 0; int plen; - bitvec_write_field(dest, wp,0x0,4); // Skip Indicator - bitvec_write_field(dest, wp,0x6,4); // Protocol Discriminator - bitvec_write_field(dest, wp,0x21,8); // Paging Request Message Type + bitvec_write_field(dest, &wp,0x0,4); // Skip Indicator + bitvec_write_field(dest, &wp,0x6,4); // Protocol Discriminator + bitvec_write_field(dest, &wp,0x21,8); // Paging Request Message Type - bitvec_write_field(dest, wp,0x0,4); // Page Mode - bitvec_write_field(dest, wp,0x0,4); // Channel Needed + bitvec_write_field(dest, &wp,0x0,4); // Page Mode + bitvec_write_field(dest, &wp,0x0,4); // Channel Needed // Mobile Identity - bitvec_write_field(dest, wp,ptmsi_len+1,8); // Mobile Identity length - bitvec_write_field(dest, wp,0xf,4); // unused - bitvec_write_field(dest, wp,0x4,4); // PTMSI type + bitvec_write_field(dest, &wp,ptmsi_len+1,8); // Mobile Identity length + bitvec_write_field(dest, &wp,0xf,4); // unused + bitvec_write_field(dest, &wp,0x4,4); // PTMSI type for (int i = 0; i < ptmsi_len; i++) { - bitvec_write_field(dest, wp,ptmsi[i],8); // PTMSI + bitvec_write_field(dest, &wp,ptmsi[i],8); // PTMSI } if ((wp % 8)) { LOGP(DRLCMACUL, LOGL_ERROR, "Length of PAG.REQ without rest " @@ -624,12 +624,12 @@ exit (0); } plen = wp / 8; - bitvec_write_field(dest, wp,0x0,1); // "L" NLN(PCH) = off - bitvec_write_field(dest, wp,0x0,1); // "L" Priority1 = off - bitvec_write_field(dest, wp,0x1,1); // "L" Priority2 = off - bitvec_write_field(dest, wp,0x0,1); // "L" Group Call information = off - bitvec_write_field(dest, wp,0x0,1); // "H" Packet Page Indication 1 = packet paging procedure - bitvec_write_field(dest, wp,0x1,1); // "H" Packet Page Indication 2 = packet paging procedure + bitvec_write_field(dest, &wp,0x0,1); // "L" NLN(PCH) = off + bitvec_write_field(dest, &wp,0x0,1); // "L" Priority1 = off + bitvec_write_field(dest, &wp,0x1,1); // "L" Priority2 = off + bitvec_write_field(dest, &wp,0x0,1); // "L" Group Call information = off + bitvec_write_field(dest, &wp,0x0,1); // "H" Packet Page Indication 1 = packet paging procedure + bitvec_write_field(dest, &wp,0x1,1); // "H" Packet Page Indication 2 = packet paging procedure return plen; } @@ -667,13 +667,13 @@ LOGP(DRLCMACUL, LOGL_DEBUG, "- V(N): \"%s\" R=Received " "I=Invalid\n", rbb); - bitvec_write_field(dest, wp, is_final, 1); // FINAL_ACK_INDICATION - bitvec_write_field(dest, wp, window->ssn(), 7); // STARTING_SEQUENCE_NUMBER + bitvec_write_field(dest, &wp, is_final, 1); // FINAL_ACK_INDICATION + bitvec_write_field(dest, &wp, window->ssn(), 7); // STARTING_SEQUENCE_NUMBER for (int i = 0; i < 64; i++) { /* Set bit at the appropriate position (see 3GPP TS 04.60 9.1.8.1) */ bool is_ack = (rbb[i] == 'R'); - bitvec_write_field(dest, wp, is_ack, 1); + bitvec_write_field(dest, &wp, is_ack, 1); } } @@ -682,20 +682,20 @@ struct gprs_rlcmac_ul_tbf *tbf, bool is_final) { - bitvec_write_field(dest, wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND write_packet_ack_nack_desc_gprs(bts, dest, wp, &tbf->m_window, is_final); - bitvec_write_field(dest, wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Timing Advance - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Power Control Parameters - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Extension Bits - bitvec_write_field(dest, wp, 0, 1); // fixed 0 - bitvec_write_field(dest, wp, 1, 1); // 1: have Additions R99 - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Extended Timing Advance - bitvec_write_field(dest, wp, 1, 1); // TBF_EST (enabled) - bitvec_write_field(dest, wp, 0, 1); // 0: don't have REL 5 + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Timing Advance + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Power Control Parameters + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Extension Bits + bitvec_write_field(dest, &wp, 0, 1); // fixed 0 + bitvec_write_field(dest, &wp, 1, 1); // 1: have Additions R99 + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Extended Timing Advance + bitvec_write_field(dest, &wp, 1, 1); // TBF_EST (enabled) + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5 }; static void write_packet_ack_nack_desc_egprs( @@ -810,37 +810,37 @@ /* EGPRS Ack/Nack Description IE */ if (len_coded == false) { - bitvec_write_field(dest, wp, 0, 1); // 0: don't have length + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have length } else { - bitvec_write_field(dest, wp, 1, 1); // 1: have length - bitvec_write_field(dest, wp, len, 8); // length + bitvec_write_field(dest, &wp, 1, 1); // 1: have length + bitvec_write_field(dest, &wp, len, 8); // length } - bitvec_write_field(dest, wp, is_final, 1); // FINAL_ACK_INDICATION - bitvec_write_field(dest, wp, bow, 1); // BEGINNING_OF_WINDOW - bitvec_write_field(dest, wp, eow, 1); // END_OF_WINDOW - bitvec_write_field(dest, wp, ssn, 11); // STARTING_SEQUENCE_NUMBER + bitvec_write_field(dest, &wp, is_final, 1); // FINAL_ACK_INDICATION + bitvec_write_field(dest, &wp, bow, 1); // BEGINNING_OF_WINDOW + bitvec_write_field(dest, &wp, eow, 1); // END_OF_WINDOW + bitvec_write_field(dest, &wp, ssn, 11); // STARTING_SEQUENCE_NUMBER if (is_compressed) { - bitvec_write_field(dest, wp, 1, 1); // CRBB_Exist - bitvec_write_field(dest, wp, crbb_len, 7); // CRBB_LENGTH + bitvec_write_field(dest, &wp, 1, 1); // CRBB_Exist + bitvec_write_field(dest, &wp, crbb_len, 7); // CRBB_LENGTH crbb_start_clr_code = (0x80 & ucmp_vec.data[0])>>7; - bitvec_write_field(dest, wp, crbb_start_clr_code, 1); // CRBB_clr_code + bitvec_write_field(dest, &wp, crbb_start_clr_code, 1); // CRBB_clr_code LOGP(DRLCMACUL, LOGL_DEBUG, "EGPRS CRBB, crbb_len = %d, crbb_start_clr_code = %d\n", crbb_len, crbb_start_clr_code); while (crbb_len != 0) { if (crbb_len > 8) { - bitvec_write_field(dest, wp, crbb_bitmap[iter], 8); + bitvec_write_field(dest, &wp, crbb_bitmap[iter], 8); crbb_len = crbb_len - 8; iter++; } else { - bitvec_write_field(dest, wp, crbb_bitmap[iter], crbb_len); + bitvec_write_field(dest, &wp, crbb_bitmap[iter], crbb_len); crbb_len = 0; } } esn_crbb = window->mod_sns(esn_crbb + uclen_crbb); } else { - bitvec_write_field(dest, wp, 0, 1); // CRBB_Exist + bitvec_write_field(dest, &wp, 0, 1); // CRBB_Exist } LOGP(DRLCMACUL, LOGL_DEBUG, "EGPRS URBB, urbb len = %d, SSN = %d, ESN_CRBB = %d, " @@ -853,7 +853,7 @@ for (i = urbb_len; i > 0; i--) { /* Set bit at the appropriate position (see 3GPP TS 04.60 12.3.1) */ bool is_ack = window->m_v_n.is_received(esn_crbb + i); - bitvec_write_field(dest, wp, is_ack, 1); + bitvec_write_field(dest, &wp, is_ack, 1); } } @@ -861,29 +861,29 @@ struct gprs_rlcmac_bts *bts, bitvec * dest, unsigned& wp, struct gprs_rlcmac_ul_tbf *tbf, bool is_final) { - bitvec_write_field(dest, wp, 0, 2); // fixed 00 + bitvec_write_field(dest, &wp, 0, 2); // fixed 00 /* CHANNEL_CODING_COMMAND */ - bitvec_write_field(dest, wp, + bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 4); /* 0: no RESEGMENT, 1: Segmentation*/ - bitvec_write_field(dest, wp, 1, 1); - bitvec_write_field(dest, wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it? - bitvec_write_field(dest, wp, 0, 1); // 0: no PRR_RETRANSMISSION_REQUEST, TODO: clarify - bitvec_write_field(dest, wp, 0, 1); // 0: no ARAC_RETRANSMISSION_REQUEST, TODO: clarify - bitvec_write_field(dest, wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, 1, 1); // TBF_EST (enabled) - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Timing Advance - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Extended Timing Advance - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Power Control Parameters - bitvec_write_field(dest, wp, 0, 1); // 0: don't have Extension Bits + bitvec_write_field(dest, &wp, 1, 1); + bitvec_write_field(dest, &wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it? + bitvec_write_field(dest, &wp, 0, 1); // 0: no PRR_RETRANSMISSION_REQUEST, TODO: clarify + bitvec_write_field(dest, &wp, 0, 1); // 0: no ARAC_RETRANSMISSION_REQUEST, TODO: clarify + bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, 1, 1); // TBF_EST (enabled) + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Timing Advance + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Extended Timing Advance + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Power Control Parameters + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Extension Bits /* -2 for last bit 0 mandatory and REL5 not supported */ unsigned bits_ack_nack = dest->data_len * 8 - wp - 2; write_packet_ack_nack_desc_egprs(bts, dest, wp, &tbf->m_window, is_final, bits_ack_nack); - bitvec_write_field(dest, wp, 0, 1); // fixed 0 - bitvec_write_field(dest, wp, 0, 1); // 0: don't have REL 5 + bitvec_write_field(dest, &wp, 0, 1); // fixed 0 + bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5 }; void Encoding::write_packet_uplink_ack( @@ -896,23 +896,23 @@ LOGP(DRLCMACUL, LOGL_DEBUG, "Encoding Ack/Nack for %s " "(final=%d)\n", tbf_name(tbf), is_final); - bitvec_write_field(dest, wp, 0x1, 2); // Payload Type - bitvec_write_field(dest, wp, rrbp, 2); // Uplink block with TDMA framenumber - bitvec_write_field(dest, wp, is_final, 1); // Suppl/Polling Bit - bitvec_write_field(dest, wp, 0x0, 3); // Uplink state flag - bitvec_write_field(dest, wp, 0x9, 6); // MESSAGE TYPE Uplink Ack/Nack - bitvec_write_field(dest, wp, 0x0, 2); // Page Mode + bitvec_write_field(dest, &wp, 0x1, 2); // Payload Type + bitvec_write_field(dest, &wp, rrbp, 2); // Uplink block with TDMA framenumber + bitvec_write_field(dest, &wp, is_final, 1); // Suppl/Polling Bit + bitvec_write_field(dest, &wp, 0x0, 3); // Uplink state flag + bitvec_write_field(dest, &wp, 0x9, 6); // MESSAGE TYPE Uplink Ack/Nack + bitvec_write_field(dest, &wp, 0x0, 2); // Page Mode - bitvec_write_field(dest, wp, 0x0, 2); // fixed 00 - bitvec_write_field(dest, wp, tbf->tfi(), 5); // Uplink TFI + bitvec_write_field(dest, &wp, 0x0, 2); // fixed 00 + bitvec_write_field(dest, &wp, tbf->tfi(), 5); // Uplink TFI if (tbf->is_egprs_enabled()) { /* PU_AckNack_EGPRS = on */ - bitvec_write_field(dest, wp, 1, 1); // 1: EGPRS + bitvec_write_field(dest, &wp, 1, 1); // 1: EGPRS write_packet_uplink_ack_egprs(bts, dest, wp, tbf, is_final); } else { /* PU_AckNack_GPRS = on */ - bitvec_write_field(dest, wp, 0, 1); // 0: GPRS + bitvec_write_field(dest, &wp, 0, 1); // 0: GPRS write_packet_uplink_ack_gprs(bts, dest, wp, tbf, is_final); } @@ -926,15 +926,15 @@ { unsigned wp = 0; - bitvec_write_field(dest, wp,0x1,2); // Payload Type - bitvec_write_field(dest, wp,0x0,3); // No polling - bitvec_write_field(dest, wp,0x0,3); // Uplink state flag - bitvec_write_field(dest, wp,0x22,6); // MESSAGE TYPE + bitvec_write_field(dest, &wp,0x1,2); // Payload Type + bitvec_write_field(dest, &wp,0x0,3); // No polling + bitvec_write_field(dest, &wp,0x0,3); // Uplink state flag + bitvec_write_field(dest, &wp,0x22,6); // MESSAGE TYPE - bitvec_write_field(dest, wp,0x0,2); // Page Mode + bitvec_write_field(dest, &wp,0x0,2); // Page Mode - bitvec_write_field(dest, wp,0x0,1); // No PERSISTENCE_LEVEL - bitvec_write_field(dest, wp,0x0,1); // No NLN + bitvec_write_field(dest, &wp,0x0,1); // No PERSISTENCE_LEVEL + bitvec_write_field(dest, &wp,0x0,1); // No NLN return wp; } @@ -942,24 +942,24 @@ unsigned Encoding::write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len, uint8_t *identity, uint8_t chan_needed) { - bitvec_write_field(dest, wp,0x1,1); // Repeated Page info exists + bitvec_write_field(dest, &wp,0x1,1); // Repeated Page info exists - bitvec_write_field(dest, wp,0x1,1); // RR connection paging + bitvec_write_field(dest, &wp,0x1,1); // RR connection paging if ((identity[0] & 0x07) == 4) { - bitvec_write_field(dest, wp,0x0,1); // TMSI + bitvec_write_field(dest, &wp,0x0,1); // TMSI identity++; len--; } else { - bitvec_write_field(dest, wp,0x0,1); // MI - bitvec_write_field(dest, wp,len,4); // MI len + bitvec_write_field(dest, &wp,0x0,1); // MI + bitvec_write_field(dest, &wp,len,4); // MI len } while (len) { - bitvec_write_field(dest, wp,*identity++,8); // MI data + bitvec_write_field(dest, &wp,*identity++,8); // MI data len--; } - bitvec_write_field(dest, wp,chan_needed,2); // CHANNEL_NEEDED - bitvec_write_field(dest, wp,0x0,1); // No eMLPP_PRIORITY + bitvec_write_field(dest, &wp,chan_needed,2); // CHANNEL_NEEDED + bitvec_write_field(dest, &wp,0x0,1); // No eMLPP_PRIORITY return wp; } @@ -1490,17 +1490,17 @@ { unsigned wp = 0; - bitvec_write_field(dest, wp, 0x1, 2); // Payload Type - bitvec_write_field(dest, wp, 0x0, 2); // Uplink block with TDMA FN - bitvec_write_field(dest, wp, 0, 1); // No Polling Bit - bitvec_write_field(dest, wp, 0x0, 3); // Uplink state flag - bitvec_write_field(dest, wp, + bitvec_write_field(dest, &wp, 0x1, 2); // Payload Type + bitvec_write_field(dest, &wp, 0x0, 2); // Uplink block with TDMA FN + bitvec_write_field(dest, &wp, 0, 1); // No Polling Bit + bitvec_write_field(dest, &wp, 0x0, 3); // Uplink state flag + bitvec_write_field(dest, &wp, MT_PACKET_ACCESS_REJECT, 6); // MESSAGE TYPE - bitvec_write_field(dest, wp, 0, 2); // fixed 00 - bitvec_write_field(dest, wp, 0x0, 1); // TLLI / G-RNTI : bit (32) - bitvec_write_field(dest, wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI - bitvec_write_field(dest, wp, 1, 1); // WAIT_INDICATION size in seconds + bitvec_write_field(dest, &wp, 0, 2); // fixed 00 + bitvec_write_field(dest, &wp, 0x0, 1); // TLLI / G-RNTI : bit (32) + bitvec_write_field(dest, &wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI + bitvec_write_field(dest, &wp, 1, 1); // WAIT_INDICATION size in seconds /* TODO: make it configurable */ - bitvec_write_field(dest, wp, 5, 8); // WAIT_INDICATION value - bitvec_write_field(dest, wp, 0, 1); // WAIT_INDICATION size in seconds + bitvec_write_field(dest, &wp, 5, 8); // WAIT_INDICATION value + bitvec_write_field(dest, &wp, 0, 1); // WAIT_INDICATION size in seconds } diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index da1d26c..71bd139 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -90,7 +90,7 @@ LOGP(DBSSGP, LOGL_DEBUG, "Got BSSGP RA Capability of size %d\n", cap_len); - block = bitvec_alloc(cap_len); + block = bitvec_alloc(cap_len, tall_pcu_ctx); bitvec_unpack(block, cap); /* TS 24.008, 10.5.5.12a */ diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index ac8f2d1..16870c3 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -33,7 +33,7 @@ const char *imsi) { LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH)\n"); - bitvec *paging_request = bitvec_alloc(23); + bitvec *paging_request = bitvec_alloc(23, tall_pcu_ctx); bitvec_unhex(paging_request, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); int plen = Encoding::write_paging_request(paging_request, ptmsi, ptmsi_len); pcu_l1if_tx_pch(paging_request, plen, (char *)imsi); diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index 589bd8f..be1e686 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -22,13 +22,13 @@ #define GPRS_RLCMAC_H #ifdef __cplusplus -#include #include #include extern "C" { #include #include +#include } #endif diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.cpp index 6b43aa6..6323b09 100644 --- a/src/gsm_rlcmac.cpp +++ b/src/gsm_rlcmac.cpp @@ -4799,7 +4799,7 @@ { csnStream_t ar; unsigned readIndex = 0; - guint8 payload_type = bitvec_read_field(vector, readIndex, 2); + guint8 payload_type = bitvec_read_field(vector, &readIndex, 2); if (payload_type == PAYLOAD_TYPE_DATA) { @@ -4814,7 +4814,7 @@ data->NrOfBits = 23 * 8; csnStreamInit(&ar, 0, data->NrOfBits); readIndex += 6; - data->u.MESSAGE_TYPE = bitvec_read_field(vector, readIndex, 6); + data->u.MESSAGE_TYPE = bitvec_read_field(vector, &readIndex, 6); readIndex = 0; switch (data->u.MESSAGE_TYPE) { @@ -4907,10 +4907,10 @@ gint bit_offset = 0; gint bit_length; unsigned readIndex = 0; - data->PAYLOAD_TYPE = bitvec_read_field(vector, readIndex, 2); - data->RRBP = bitvec_read_field(vector, readIndex, 2); - data->SP = bitvec_read_field(vector, readIndex, 1); - data->USF = bitvec_read_field(vector, readIndex, 3); + data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2); + data->RRBP = bitvec_read_field(vector, &readIndex, 2); + data->SP = bitvec_read_field(vector, &readIndex, 1); + data->USF = bitvec_read_field(vector, &readIndex, 3); if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA) { @@ -4929,27 +4929,27 @@ bit_offset = 8; if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_CTRL_OPT_OCTET) { - data->RBSN = bitvec_read_field(vector, readIndex, 1); - data->RTI = bitvec_read_field(vector, readIndex, 5); - data->FS = bitvec_read_field(vector, readIndex, 1); - data->AC = bitvec_read_field(vector, readIndex, 1); + data->RBSN = bitvec_read_field(vector, &readIndex, 1); + data->RTI = bitvec_read_field(vector, &readIndex, 5); + data->FS = bitvec_read_field(vector, &readIndex, 1); + data->AC = bitvec_read_field(vector, &readIndex, 1); bit_offset += 8; if (data->AC == 1) { - data->PR = bitvec_read_field(vector, readIndex, 2); - data->TFI = bitvec_read_field(vector, readIndex, 5); - data->D = bitvec_read_field(vector, readIndex, 1); + data->PR = bitvec_read_field(vector, &readIndex, 2); + data->TFI = bitvec_read_field(vector, &readIndex, 5); + data->D = bitvec_read_field(vector, &readIndex, 1); bit_offset += 8; } if ((data->RBSN == 1) && (data->FS == 0)) { - data->RBSNe = bitvec_read_field(vector, readIndex, 3); - data->FSe = bitvec_read_field(vector, readIndex, 1); - data->spare = bitvec_read_field(vector, readIndex, 4); + data->RBSNe = bitvec_read_field(vector, &readIndex, 3); + data->FSe = bitvec_read_field(vector, &readIndex, 1); + data->spare = bitvec_read_field(vector, &readIndex, 4); bit_offset += 8; } } - data->u.MESSAGE_TYPE = bitvec_read_field(vector, readIndex, 6); + data->u.MESSAGE_TYPE = bitvec_read_field(vector, &readIndex, 6); } /* Initialize the contexts */ @@ -5206,30 +5206,30 @@ else { /* First print the message type and create a tree item */ - bitvec_write_field(vector, writeIndex, data->PAYLOAD_TYPE, 2); - bitvec_write_field(vector, writeIndex, data->RRBP, 2); - bitvec_write_field(vector, writeIndex, data->SP, 1); - bitvec_write_field(vector, writeIndex, data->USF, 3); + bitvec_write_field(vector, &writeIndex, data->PAYLOAD_TYPE, 2); + bitvec_write_field(vector, &writeIndex, data->RRBP, 2); + bitvec_write_field(vector, &writeIndex, data->SP, 1); + bitvec_write_field(vector, &writeIndex, data->USF, 3); bit_offset = 8; if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_CTRL_OPT_OCTET) { - bitvec_write_field(vector, writeIndex, data->RBSN, 1); - bitvec_write_field(vector, writeIndex, data->RTI, 5); - bitvec_write_field(vector, writeIndex, data->FS, 1); - bitvec_write_field(vector, writeIndex, data->AC, 1); + bitvec_write_field(vector, &writeIndex, data->RBSN, 1); + bitvec_write_field(vector, &writeIndex, data->RTI, 5); + bitvec_write_field(vector, &writeIndex, data->FS, 1); + bitvec_write_field(vector, &writeIndex, data->AC, 1); bit_offset += 8; if (data->AC == 1) { - bitvec_write_field(vector, writeIndex, data->PR, 2); - bitvec_write_field(vector, writeIndex, data->TFI, 5); - bitvec_write_field(vector, writeIndex, data->D, 1); + bitvec_write_field(vector, &writeIndex, data->PR, 2); + bitvec_write_field(vector, &writeIndex, data->TFI, 5); + bitvec_write_field(vector, &writeIndex, data->D, 1); bit_offset += 8; } if ((data->RBSN == 1) && (data->FS == 0)) { - bitvec_write_field(vector, writeIndex, data->RBSNe, 3); - bitvec_write_field(vector, writeIndex, data->FSe, 1); - bitvec_write_field(vector, writeIndex, data->spare, 4); + bitvec_write_field(vector, &writeIndex, data->RBSNe, 3); + bitvec_write_field(vector, &writeIndex, data->FSe, 1); + bitvec_write_field(vector, &writeIndex, data->spare, 4); bit_offset += 8; } } @@ -5378,32 +5378,32 @@ { unsigned readIndex = 0; //unsigned dataLen = 0; - guint8 payload_type = bitvec_read_field(vector, readIndex, 2); + guint8 payload_type = bitvec_read_field(vector, &readIndex, 2); if (payload_type == PAYLOAD_TYPE_DATA) { readIndex = 0; // MAC header - data->PAYLOAD_TYPE = bitvec_read_field(vector, readIndex, 2); - data->CV = bitvec_read_field(vector, readIndex, 4); - data->SI = bitvec_read_field(vector, readIndex, 1); - data->R = bitvec_read_field(vector, readIndex, 1); + data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2); + data->CV = bitvec_read_field(vector, &readIndex, 4); + data->SI = bitvec_read_field(vector, &readIndex, 1); + data->R = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "CV = %u ", (unsigned)(data->CV)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "SI = %u ", (unsigned)(data->SI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "R = %u ", (unsigned)(data->R)); // Octet 1 - data->spare = bitvec_read_field(vector, readIndex, 1); - data->PI = bitvec_read_field(vector, readIndex, 1); - data->TFI = bitvec_read_field(vector, readIndex, 5); - data->TI = bitvec_read_field(vector, readIndex, 1); + data->spare = bitvec_read_field(vector, &readIndex, 1); + data->PI = bitvec_read_field(vector, &readIndex, 1); + data->TFI = bitvec_read_field(vector, &readIndex, 5); + data->TI = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "spare = %u ", (unsigned)(data->spare)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PI = %u ", (unsigned)(data->PI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TI = %u ", (unsigned)(data->TI)); // Octet 2 - data->BSN = bitvec_read_field(vector, readIndex, 7); - data->E_1 = bitvec_read_field(vector, readIndex, 1); + data->BSN = bitvec_read_field(vector, &readIndex, 7); + data->E_1 = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1)); @@ -5414,9 +5414,9 @@ unsigned i = 0; do { - data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, readIndex, 6); - data->M[i] = bitvec_read_field(vector, readIndex, 1); - data->E[i] = bitvec_read_field(vector, readIndex, 1); + data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, &readIndex, 6); + data->M[i] = bitvec_read_field(vector, &readIndex, 1); + data->E[i] = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i])); @@ -5425,12 +5425,12 @@ } if(data->TI == 1) // TLLI field is present { - data->TLLI = bitvec_read_field(vector, readIndex, 32); + data->TLLI = bitvec_read_field(vector, &readIndex, 32); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TLLI = %08x ", data->TLLI); if (data->PI == 1) // PFI is present if TI field indicates presence of TLLI { - data->PFI = bitvec_read_field(vector, readIndex, 7); - data->E_2 = bitvec_read_field(vector, readIndex, 1); + data->PFI = bitvec_read_field(vector, &readIndex, 7); + data->E_2 = bitvec_read_field(vector, &readIndex, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PFI = %u ", (unsigned)(data->PFI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_2 = %u ", (unsigned)(data->E_2)); } @@ -5440,7 +5440,7 @@ assert(dataLen <= 20); for (unsigned i = 0; i < dataLen; i++) { - data->RLC_DATA[i] = bitvec_read_field(vector, readIndex, 8); + data->RLC_DATA[i] = bitvec_read_field(vector, &readIndex, 8); LOGPC(DRLCMACDATA, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i])); } LOGPC(DRLCMACDATA, LOGL_NOTICE, "\n"); @@ -5459,26 +5459,26 @@ if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA) { // MAC header - bitvec_write_field(vector, writeIndex, data->PAYLOAD_TYPE, 2); - bitvec_write_field(vector, writeIndex, data->RRBP, 2); - bitvec_write_field(vector, writeIndex, data->SP, 1); - bitvec_write_field(vector, writeIndex, data->USF, 3); + bitvec_write_field(vector, &writeIndex, data->PAYLOAD_TYPE, 2); + bitvec_write_field(vector, &writeIndex, data->RRBP, 2); + bitvec_write_field(vector, &writeIndex, data->SP, 1); + bitvec_write_field(vector, &writeIndex, data->USF, 3); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "RRBP = %u ", (unsigned)(data->RRBP)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "SP = %u ", (unsigned)(data->SP)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "USF = %u ", (unsigned)(data->USF)); // Octet 1 - bitvec_write_field(vector, writeIndex, data->PR, 2); - bitvec_write_field(vector, writeIndex, data->TFI, 5); - bitvec_write_field(vector, writeIndex, data->FBI, 1); + bitvec_write_field(vector, &writeIndex, data->PR, 2); + bitvec_write_field(vector, &writeIndex, data->TFI, 5); + bitvec_write_field(vector, &writeIndex, data->FBI, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "PR = %u ", (unsigned)(data->PR)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "FBI = %u ", (unsigned)(data->FBI)); // Octet 2 - bitvec_write_field(vector, writeIndex, data->BSN, 7); - bitvec_write_field(vector, writeIndex, data->E_1, 1); + bitvec_write_field(vector, &writeIndex, data->BSN, 7); + bitvec_write_field(vector, &writeIndex, data->E_1, 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN)); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1)); @@ -5488,9 +5488,9 @@ unsigned i = 0; do { - bitvec_write_field(vector, writeIndex, data->LENGTH_INDICATOR[i], 6); - bitvec_write_field(vector, writeIndex, data->M[i], 1); - bitvec_write_field(vector, writeIndex, data->E[i], 1); + bitvec_write_field(vector, &writeIndex, data->LENGTH_INDICATOR[i], 6); + bitvec_write_field(vector, &writeIndex, data->M[i], 1); + bitvec_write_field(vector, &writeIndex, data->E[i], 1); LOGPC(DRLCMACDATA, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i])); LOGPC(DRLCMACDATA, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i])); @@ -5503,7 +5503,7 @@ assert(dataNumOctets <= 20); for (unsigned i = 0; i < dataNumOctets; i++) { - bitvec_write_field(vector, writeIndex, data->RLC_DATA[i], 8); + bitvec_write_field(vector, &writeIndex, data->RLC_DATA[i], 8); LOGPC(DRLCMACDATA, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i])); } LOGPC(DRLCMACDATA, LOGL_NOTICE, "\n"); diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 0a0362b..c61eb6d 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -168,7 +168,6 @@ tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); if (!tall_pcu_ctx) return -ENOMEM; - bv_tall_ctx = tall_pcu_ctx; bts = bts_main_data(); bts->fc_interval = 1; diff --git a/src/tbf.cpp b/src/tbf.cpp index 0d28c5c..2c0c07f 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -1112,7 +1112,7 @@ msg = msgb_alloc(23, "rlcmac_dl_ass"); if (!msg) return NULL; - bitvec *ass_vec = bitvec_alloc(23); + bitvec *ass_vec = bitvec_alloc(23, tall_pcu_ctx); if (!ass_vec) { msgb_free(msg); return NULL; @@ -1159,7 +1159,7 @@ msg = msgb_alloc(23, "rlcmac_ul_ass_rej"); - bitvec *packet_access_rej = bitvec_alloc(23); + bitvec *packet_access_rej = bitvec_alloc(23, tall_pcu_ctx); bitvec_unhex(packet_access_rej, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); @@ -1216,7 +1216,7 @@ if (!msg) return NULL; LOGP(DRLCMAC, LOGL_INFO, "%ss start Packet Uplink Assignment (PACCH)\n", tbf_name(new_tbf)); - bitvec *ass_vec = bitvec_alloc(23); + bitvec *ass_vec = bitvec_alloc(23, tall_pcu_ctx); if (!ass_vec) { msgb_free(msg); return NULL; diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 2598174..1eee41a 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -121,7 +121,7 @@ msg = msgb_alloc(23, "rlcmac_ul_ack"); if (!msg) return NULL; - bitvec *ack_vec = bitvec_alloc(23); + bitvec *ack_vec = bitvec_alloc(23, tall_pcu_ctx); if (!ack_vec) { msgb_free(msg); return NULL; diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp index 97e5e60..9155809 100644 --- a/tests/rlcmac/RLCMACTest.cpp +++ b/tests/rlcmac/RLCMACTest.cpp @@ -83,9 +83,9 @@ cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; } -void testRlcMacDownlink() +void testRlcMacDownlink(void *test_ctx) { - struct bitvec *resultVector = bitvec_alloc(23); + struct bitvec *resultVector = bitvec_alloc(23, test_ctx); bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); std::string testData[] = { @@ -106,7 +106,7 @@ cout << " DOWNLINK " << endl; for (int i = 0; i < testDataSize; i++) { - bitvec *vector = bitvec_alloc(23); + bitvec *vector = bitvec_alloc(23, test_ctx); bitvec_unhex(vector, testData[i].c_str()); cout << "vector1 = "; for (int i = 0; i < 23; i++) @@ -150,9 +150,9 @@ } -void testRlcMacUplink() +void testRlcMacUplink(void *test_ctx) { - struct bitvec *resultVector = bitvec_alloc(23); + struct bitvec *resultVector = bitvec_alloc(23, test_ctx); bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); std::string testData[] = { @@ -169,7 +169,7 @@ cout << " UPLINK " << endl; for (int i = 0; i < testDataSize; i++) { - bitvec *vector = bitvec_alloc(23); + bitvec *vector = bitvec_alloc(23, test_ctx); bitvec_unhex(vector, testData[i].c_str()); cout << "vector1 = "; for (int i = 0; i < 23; i++) @@ -212,9 +212,9 @@ bitvec_free(resultVector); } -void testCsnLeftAlignedVarBmpBounds() +void testCsnLeftAlignedVarBmpBounds(void *test_ctx) { - bitvec *vector = bitvec_alloc(23); + bitvec *vector = bitvec_alloc(23, test_ctx); bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000"); RlcMacUplink_t data; @@ -229,10 +229,12 @@ int main(int argc, char *argv[]) { + void *ctx = talloc_named_const(NULL, 1, "RLCMACTest"); osmo_init_logging(&gprs_log_info); //printSizeofRLCMAC(); - testRlcMacDownlink(); - testRlcMacUplink(); - testCsnLeftAlignedVarBmpBounds(); + testRlcMacDownlink(ctx); + testRlcMacUplink(ctx); + testCsnLeftAlignedVarBmpBounds(ctx); + talloc_free(ctx); } diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index e367ce6..f042262 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -595,7 +595,7 @@ meas.set_rssi(31); - rlc_block = bitvec_alloc(23); + rlc_block = bitvec_alloc(23, tall_pcu_ctx); encode_gsm_rlcmac_uplink(rlc_block, ulreq); num_bytes = bitvec_pack(rlc_block, &buf[0]); @@ -2573,7 +2573,7 @@ OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW)); - block = bitvec_alloc(23); + block = bitvec_alloc(23, tall_pcu_ctx); bitvec_unpack(block, data_msg); diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp index ee1c817..7d09108 100644 --- a/tests/types/TypesTest.cpp +++ b/tests/types/TypesTest.cpp @@ -430,7 +430,7 @@ void test_immediate_assign_rej() { uint8_t plen; - bitvec *immediate_assignment_rej = bitvec_alloc(22); + bitvec *immediate_assignment_rej = bitvec_alloc(22, tall_pcu_ctx); bitvec_unhex(immediate_assignment_rej, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 02:47:59 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 02:47:59 +0000 Subject: openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx In-Reply-To: References: Message-ID: Patch Set 1: We have to be careful here. Is there a real leak and you silence it because of the recursive nature of talloc_free(ctx) or is it just a context being leaked by talloc? For the commit message it would help to know which leak was fixed. -- To view, visit https://gerrit.osmocom.org/1752 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 02:48:21 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 02:48:21 +0000 Subject: openbsc[master]: libmsc/update_db_revision_3(): free memleaking db result In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1750 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 02:49:47 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 02:49:47 +0000 Subject: openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef In-Reply-To: References: Message-ID: Patch Set 1: Please put the error in there as well. RAND_bytes should always write to the memory first. -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 02:50:02 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 02:50:02 +0000 Subject: openbsc[master]: gprs/sgsn_vty: fix typo in comment In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1748 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 03:41:16 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 03:41:16 +0000 Subject: [PATCH] osmo-pcu[master]: tbf.cpp: use new tlli instead of old tlli In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1663 to look at the new patch set (#2). tbf.cpp: use new tlli instead of old tlli The old tlli might be 0x00000000. Change-Id: I2fd6fec022506e203d05e91c36ccd9e020ff816c --- M src/tbf.cpp M tests/tbf/TbfTest.err 2 files changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/63/1663/2 diff --git a/src/tbf.cpp b/src/tbf.cpp index 0d28c5c..d9eb4bb 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -1311,7 +1311,7 @@ if (dl_tbf && dl_tbf->ms() != ms()) { LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from " "TLLI=0x%08x while %s still exists. " - "Killing pending DL TBF\n", tlli(), + "Killing pending DL TBF\n", new_tlli, tbf_name(dl_tbf)); tbf_free(dl_tbf); dl_tbf = NULL; @@ -1319,7 +1319,7 @@ if (ul_tbf && ul_tbf->ms() != ms()) { LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from " "TLLI=0x%08x while %s still exists. " - "Killing pending UL TBF\n", tlli(), + "Killing pending UL TBF\n", new_tlli, tbf_name(ul_tbf)); tbf_free(ul_tbf); ul_tbf = NULL; diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index 575b7fb..b8fb451 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -2192,7 +2192,7 @@ - BSN 0 storing in window (0..63) TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW): data_length=20, data=f1 22 33 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Decoded premier TLLI=0x00000000 of UL DATA TFI=0. -Got RACH from TLLI=0x00000000 while TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) still exists. Killing pending DL TBF +Got RACH from TLLI=0xf1223344 while TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) still exists. Killing pending DL TBF TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) changes state from ASSIGN to RELEASING TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=RELEASING) free TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=RELEASING) stopping timer 0. -- To view, visit https://gerrit.osmocom.org/1663 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I2fd6fec022506e203d05e91c36ccd9e020ff816c Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sat Feb 4 03:50:41 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 03:50:41 +0000 Subject: [PATCH] openbsc[master]: tests: fix leaks by talloc ctx In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1751 to look at the new patch set (#2). tests: fix leaks by talloc ctx When using talloc with a NULL context an anonymous ctx will be created, but never freed. Found by ASAN. Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 --- M openbsc/tests/gbproxy/gbproxy_test.c M openbsc/tests/gtphub/gtphub_test.c M openbsc/tests/mgcp/mgcp_test.c M openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c M openbsc/tests/oap/oap_client_test.c M openbsc/tests/slhc/slhc_test.c M openbsc/tests/sndcp_xid/sndcp_xid_test.c M openbsc/tests/trau/trau_test.c M openbsc/tests/v42bis/v42bis_test.c M openbsc/tests/xid/xid_test.c 10 files changed, 28 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/51/1751/2 diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c index 577daa9..b251147 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.c +++ b/openbsc/tests/gbproxy/gbproxy_test.c @@ -53,6 +53,8 @@ struct llist_head *received_messages = NULL; +void *tctx = NULL; + /* override, requires '-Wl,--wrap=RAND_bytes' */ int __real_RAND_bytes(unsigned char *buf, int num); int mock_RAND_bytes(unsigned char *buf, int num); @@ -1660,7 +1662,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; @@ -2001,7 +2003,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 0; gbcfg.core_mnc = 0; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; @@ -2235,7 +2237,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; @@ -2554,7 +2556,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; @@ -2738,7 +2740,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; gbcfg.acquire_imsi = 1; @@ -3064,7 +3066,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; gbcfg.acquire_imsi = 1; @@ -4844,7 +4846,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 0; gbcfg.core_mnc = 0; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; gbcfg.acquire_imsi = 1; @@ -4936,7 +4938,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + tctx = talloc_named_const(NULL, 0, "gbproxy_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); @@ -4965,6 +4968,7 @@ test_gbproxy_keep_info(); test_gbproxy_tlli_expire(); test_gbproxy_stored_messages(); + talloc_free(tctx); printf("===== GbProxy test END\n\n"); exit(EXIT_SUCCESS); diff --git a/openbsc/tests/gtphub/gtphub_test.c b/openbsc/tests/gtphub/gtphub_test.c index e7c27d2..4574ff1 100644 --- a/openbsc/tests/gtphub/gtphub_test.c +++ b/openbsc/tests/gtphub/gtphub_test.c @@ -1781,6 +1781,7 @@ talloc_report_full(osmo_gtphub_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(osmo_gtphub_ctx) == 1); + talloc_free(osmo_gtphub_ctx); return 0; } diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index b2d237e..a645f92 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -1203,7 +1203,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *mgcp_talloc = talloc_named_const(NULL, 0, "mgcp_test"); + msgb_talloc_ctx_init(mgcp_talloc, 0); osmo_init_logging(&log_info); test_strline(); @@ -1222,6 +1223,8 @@ test_no_name(); test_osmux_cid(); + talloc_free(mgcp_talloc); + printf("Done\n"); return EXIT_SUCCESS; } diff --git a/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c b/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c index ee138b8..39975e5 100644 --- a/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c +++ b/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c @@ -273,6 +273,7 @@ talloc_free(trx); talloc_report_full(ctx, stderr); OSMO_ASSERT(talloc_total_blocks(ctx) == 1); + talloc_free(ctx); return 0; } diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c index e6501cb..a5311fc 100644 --- a/openbsc/tests/oap/oap_client_test.c +++ b/openbsc/tests/oap/oap_client_test.c @@ -252,7 +252,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "oap_client_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&info); OSMO_ASSERT(osmo_stderr_target); @@ -263,6 +264,7 @@ log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); test_oap_api(); + talloc_free(tctx); printf("Done\n"); return 0; diff --git a/openbsc/tests/slhc/slhc_test.c b/openbsc/tests/slhc/slhc_test.c index d2e1cd9..6411b35 100644 --- a/openbsc/tests/slhc/slhc_test.c +++ b/openbsc/tests/slhc/slhc_test.c @@ -261,6 +261,7 @@ talloc_report_full(ctx, stderr); OSMO_ASSERT(talloc_total_blocks(ctx) == 1); + talloc_free(ctx); return 0; } diff --git a/openbsc/tests/sndcp_xid/sndcp_xid_test.c b/openbsc/tests/sndcp_xid/sndcp_xid_test.c index 151dd2b..524afa3 100644 --- a/openbsc/tests/sndcp_xid/sndcp_xid_test.c +++ b/openbsc/tests/sndcp_xid/sndcp_xid_test.c @@ -273,6 +273,7 @@ talloc_report_full(xid_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1); + talloc_free(xid_ctx); return 0; } diff --git a/openbsc/tests/trau/trau_test.c b/openbsc/tests/trau/trau_test.c index c74e6db..3464515 100644 --- a/openbsc/tests/trau/trau_test.c +++ b/openbsc/tests/trau/trau_test.c @@ -66,7 +66,8 @@ unsigned char data[33]; int i; - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "trau_test"); + msgb_talloc_ctx_init(tctx, 0); memset(data, 0x00, sizeof(data)); test_trau_fr_efr(data); @@ -76,6 +77,7 @@ for (i = 0; i < sizeof(data); i++) data[i] = random(); test_trau_fr_efr(data); + talloc_free(tctx); printf("Done\n"); return 0; } diff --git a/openbsc/tests/v42bis/v42bis_test.c b/openbsc/tests/v42bis/v42bis_test.c index 7e90785..21ee421 100644 --- a/openbsc/tests/v42bis/v42bis_test.c +++ b/openbsc/tests/v42bis/v42bis_test.c @@ -424,6 +424,7 @@ printf("Done\n"); talloc_report_full(v42bis_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(v42bis_ctx) == 1); + talloc_free(v42bis_ctx); return 0; } diff --git a/openbsc/tests/xid/xid_test.c b/openbsc/tests/xid/xid_test.c index b77a4ae..de40067 100644 --- a/openbsc/tests/xid/xid_test.c +++ b/openbsc/tests/xid/xid_test.c @@ -153,6 +153,7 @@ talloc_report_full(xid_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1); + talloc_free(xid_ctx); return 0; } -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 03:52:15 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 03:52:15 +0000 Subject: [PATCH] openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1752 to look at the new patch set (#2). tests/bsc & bsc-nat: fix mem leaks of talloc ctx When using talloc with a NULL context an anonymous ctx will be created, but never freed. Found by ASAN. Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 --- M openbsc/tests/bsc-nat/bsc_nat_test.c M openbsc/tests/bsc/bsc_test.c 2 files changed, 6 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/52/1752/2 diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index 2914a01..32a0432 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -1551,7 +1551,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "bsc_nat_test"); + msgb_talloc_ctx_init(tctx, 0); sccp_set_log_area(DSCCP); osmo_init_logging(&log_info); @@ -1572,7 +1573,7 @@ test_mgcp_allocations(); test_barr_list_parsing(); test_nat_extract_lac(); - + talloc_free(tctx); printf("Testing execution completed.\n"); return 0; } diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c index 7174828..6850b31 100644 --- a/openbsc/tests/bsc/bsc_test.c +++ b/openbsc/tests/bsc/bsc_test.c @@ -199,11 +199,12 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "bsc_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&log_info); test_scan(); - + talloc_free(tctx); printf("Testing execution completed.\n"); return 0; } -- To view, visit https://gerrit.osmocom.org/1752 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 03:53:40 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 03:53:40 +0000 Subject: openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx In-Reply-To: References: Message-ID: Patch Set 2: > We have to be careful here. Is there a real leak and you silence it > because of the recursive nature of talloc_free(ctx) or is it just a > context being leaked by talloc? > > For the commit message it would help to know which leak was fixed. I see. So we should add talloc asserts on the allocated memblocks. Wich some tests already do. I've updated the commit message. -- To view, visit https://gerrit.osmocom.org/1752 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 03:56:03 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 03:56:03 +0000 Subject: osmo-pcu[master]: tbf.cpp: use new tlli instead of old tlli In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/1663/2/src/tbf.cpp File src/tbf.cpp: Line 1314: "Killing pending DL TBF\n", new_tlli, hehe, seeing the change in test output.. does printing the TLLI twice have any value? dl_tbf->tlli() == new_tlli all the time (same for ul_tbf?). At least I would think this is an invariant. :) -- To view, visit https://gerrit.osmocom.org/1663 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2fd6fec022506e203d05e91c36ccd9e020ff816c Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 4 03:57:20 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 03:57:20 +0000 Subject: [ABANDON] libosmocore[master]: socket: export osmo_sockaddr_equal() as library function In-Reply-To: References: Message-ID: lynxis lazus has abandoned this change. Change subject: socket: export osmo_sockaddr_equal() as library function ...................................................................... Abandoned won't be used anymore. -- To view, visit https://gerrit.osmocom.org/1148 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I174fe1b894e5da0fefed81f95546c24776233421 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:05:56 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 05:05:56 +0000 Subject: [PATCH] openbsc[master]: gprs/sgsn: rename gprs->mm_state -> gmm_state Message-ID: Review at https://gerrit.osmocom.org/1754 gprs/sgsn: rename gprs->mm_state -> gmm_state GMM is the right term. MM state is already occupied. Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/src/gprs/sgsn_libgtp.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c 6 files changed, 81 insertions(+), 66 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/54/1754/1 diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index dc165d3..f50de11 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -36,9 +36,9 @@ PMM_DETACHED, PMM_CONNECTED, PMM_IDLE, - MM_IDLE = PMM_DETACHED, - MM_READY = PMM_CONNECTED, - MM_STANDBY = PMM_IDLE, + MM_IDLE, + MM_READY, + MM_STANDBY, }; enum gprs_mm_ctr { @@ -126,7 +126,7 @@ enum sgsn_ran_type ran_type; char imsi[GSM23003_IMSI_MAX_DIGITS+1]; - enum gprs_gmm_state mm_state; + enum gprs_gmm_state gmm_state; enum gprs_pmm_state pmm_state; /* Iu: page when in PMM-IDLE mode */ uint32_t p_tmsi; uint32_t p_tmsi_old; /* old P-TMSI before new is confirmed */ diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 6fde757..9ac1077 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -119,24 +119,37 @@ void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state) { + if (ctx->ran_type != MM_CTX_T_UTRAN_Iu) + return; + if (ctx->pmm_state == state) return; LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %i to %i\n", ctx->pmm_state, state); - if (ctx->ran_type == MM_CTX_T_UTRAN_Iu) - { - switch (state) { - case PMM_IDLE: - /* TODO: start RA Upd timer */ - mmctx_change_gtpu_endpoints_to_sgsn(ctx); - break; - case PMM_CONNECTED: - break; - default: - break; - } + switch (state) { + case PMM_IDLE: + /* TODO: start RA Upd timer */ + mmctx_change_gtpu_endpoints_to_sgsn(ctx); + break; + case PMM_CONNECTED: + break; + default: + break; } + + ctx->pmm_state = state; +} + +void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state) +{ + if (ctx->ran_type != MM_CTX_T_GERAN_Gb) + return; + + if (ctx->pmm_state == state) + return; + + LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %i to %i\n", ctx->pmm_state, state); ctx->pmm_state = state; } @@ -274,9 +287,9 @@ LOGMMCTXP(LOGL_INFO, ctx, "Cleaning MM context due to %s\n", log_text); /* Mark MM state as deregistered */ - ctx->mm_state = GMM_DEREGISTERED; - + ctx->gmm_state = GMM_DEREGISTERED; mmctx_set_pmm_state(ctx, PMM_DETACHED); + mmctx_set_pmm_state(ctx, MM_IDLE); sgsn_mm_ctx_cleanup_free(ctx); } @@ -882,7 +895,7 @@ memset(&sig_data, 0, sizeof(sig_data)); sig_data.mm = mmctx; osmo_signal_dispatch(SS_SGSN, S_SGSN_ATTACH, &sig_data); - ctx->mm_state = GMM_REGISTERED_NORMAL; + ctx->gmm_state = GMM_REGISTERED_NORMAL; #endif return gsm48_tx_gmm_att_ack(ctx); @@ -921,7 +934,7 @@ void gsm0408_gprs_access_granted(struct sgsn_mm_ctx *ctx) { - switch (ctx->mm_state) { + switch (ctx->gmm_state) { case GMM_COMMON_PROC_INIT: LOGMMCTXP(LOGL_NOTICE, ctx, "Authorized, continuing procedure, IMSI=%s\n", @@ -941,7 +954,7 @@ if (gmm_cause == SGSN_ERROR_CAUSE_NONE) gmm_cause = GMM_CAUSE_GPRS_NOTALLOWED; - switch (ctx->mm_state) { + switch (ctx->gmm_state) { case GMM_COMMON_PROC_INIT: LOGMMCTXP(LOGL_NOTICE, ctx, "Not authorized, rejecting ATTACH REQUEST " @@ -1225,11 +1238,11 @@ #ifdef PTMSI_ALLOC /* Allocate a new P-TMSI (+ P-TMSI signature) and update TLLI */ /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */ - if (ctx->mm_state != GMM_COMMON_PROC_INIT) { + if (ctx->gmm_state != GMM_COMMON_PROC_INIT) { ctx->p_tmsi_old = ctx->p_tmsi; ctx->p_tmsi = sgsn_alloc_ptmsi(); } - ctx->mm_state = GMM_COMMON_PROC_INIT; + ctx->gmm_state = GMM_COMMON_PROC_INIT; #endif if (ctx->ran_type == MM_CTX_T_GERAN_Gb) { @@ -1500,10 +1513,10 @@ mmctx->ra.mcc, mmctx->ra.mnc, mmctx->ra.lac, mmctx->ra.rac); - mmctx->mm_state = GMM_COMMON_PROC_INIT; + mmctx->gmm_state = GMM_COMMON_PROC_INIT; } } else if (!gprs_ra_id_equals(&mmctx->ra, &old_ra_id) || - mmctx->mm_state == GMM_DEREGISTERED) + mmctx->gmm_state == GMM_DEREGISTERED) { /* We cannot use the mmctx */ LOGMMCTXP(LOGL_INFO, mmctx, @@ -1545,7 +1558,7 @@ #ifdef PTMSI_ALLOC /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */ - if (mmctx->mm_state != GMM_COMMON_PROC_INIT) { + if (mmctx->gmm_state != GMM_COMMON_PROC_INIT) { mmctx->p_tmsi_old = mmctx->p_tmsi; mmctx->p_tmsi = sgsn_alloc_ptmsi(); } @@ -1553,10 +1566,10 @@ mmctx->t3350_mode = GMM_T3350_MODE_RAU; mmctx_timer_start(mmctx, 3350, sgsn->cfg.timers.T3350); - mmctx->mm_state = GMM_COMMON_PROC_INIT; + mmctx->gmm_state = GMM_COMMON_PROC_INIT; #else /* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */ - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; memset(&sig_data, 0, sizeof(sig_data)); sig_data.mm = mmctx; @@ -1679,7 +1692,7 @@ goto rejected; } - ctx->mm_state = GMM_COMMON_PROC_INIT; + ctx->gmm_state = GMM_COMMON_PROC_INIT; ctx->iu.service.type = service_type; @@ -1831,8 +1844,9 @@ gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new); } - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; mmctx_set_pmm_state(mmctx, PMM_CONNECTED); + mmctx_set_mm_state(mmctx, MM_READY); rc = 0; memset(&sig_data, 0, sizeof(sig_data)); @@ -1854,8 +1868,9 @@ gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new); } - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; mmctx_set_pmm_state(mmctx, PMM_CONNECTED); + mmctx_set_mm_state(mmctx, MM_READY); rc = 0; memset(&sig_data, 0, sizeof(sig_data)); @@ -2682,15 +2697,15 @@ return -EINVAL; } - if (mmctx->mm_state != GMM_REGISTERED_NORMAL && - mmctx->mm_state != GMM_REGISTERED_SUSPENDED) { + if (mmctx->gmm_state != GMM_REGISTERED_NORMAL && + mmctx->gmm_state != GMM_REGISTERED_SUSPENDED) { LOGMMCTXP(LOGL_NOTICE, mmctx, "SUSPEND request while state " "!= REGISTERED (TLLI=%08x)\n", tlli); return -EINVAL; } /* Transition from REGISTERED_NORMAL to REGISTERED_SUSPENDED */ - mmctx->mm_state = GMM_REGISTERED_SUSPENDED; + mmctx->gmm_state = GMM_REGISTERED_SUSPENDED; return 0; } @@ -2708,8 +2723,8 @@ return -EINVAL; } - if (mmctx->mm_state != GMM_REGISTERED_NORMAL && - mmctx->mm_state != GMM_REGISTERED_SUSPENDED) { + if (mmctx->gmm_state != GMM_REGISTERED_NORMAL && + mmctx->gmm_state != GMM_REGISTERED_SUSPENDED) { LOGMMCTXP(LOGL_NOTICE, mmctx, "RESUME request while state " "!= SUSPENDED (TLLI=%08x)\n", tlli); /* FIXME: should we not simply ignore it? */ @@ -2717,7 +2732,7 @@ } /* Transition from SUSPENDED to NORMAL */ - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; return 0; } diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index e85e1a9..3fb1104 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -222,7 +222,7 @@ memcpy(&ctx->ra, raid, sizeof(ctx->ra)); ctx->ran_type = MM_CTX_T_GERAN_Gb; ctx->gb.tlli = tlli; - ctx->mm_state = GMM_DEREGISTERED; + ctx->gmm_state = GMM_DEREGISTERED; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ciph_algo = sgsn->cfg.cipher; LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n", @@ -247,7 +247,7 @@ ctx->ran_type = MM_CTX_T_UTRAN_Iu; ctx->iu.ue_ctx = uectx; ctx->iu.new_key = 1; - ctx->mm_state = GMM_DEREGISTERED; + ctx->gmm_state = GMM_DEREGISTERED; ctx->pmm_state = PMM_DETACHED; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0); @@ -658,7 +658,7 @@ static void drop_one_pdp(struct sgsn_pdp_ctx *pdp) { - if (pdp->mm->mm_state == GMM_REGISTERED_NORMAL) + if (pdp->mm->gmm_state == GMM_REGISTERED_NORMAL) gsm48_tx_gsm_deact_pdp_req(pdp, GSM_CAUSE_NET_FAIL); else { /* FIXME: GPRS paging in case MS is SUSPENDED */ diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 072b9ba..062de44 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -676,7 +676,7 @@ msgb_bvci(msg) = mm->gb.bvci; msgb_nsei(msg) = mm->gb.nsei; - switch (mm->mm_state) { + switch (mm->gmm_state) { case GMM_REGISTERED_SUSPENDED: /* initiate PS PAGING procedure */ memset(&pinfo, 0, sizeof(pinfo)); @@ -695,7 +695,7 @@ break; default: LOGP(DGPRS, LOGL_ERROR, "GTP DATA IND for TLLI %08X in state " - "%u\n", mm->gb.tlli, mm->mm_state); + "%u\n", mm->gb.tlli, mm->gmm_state); msgb_free(msg); return -1; } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 4a97687..bbc2274 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -485,7 +485,7 @@ pfx, mm->msisdn, mm->gb.tlli, mm->hlr, VTY_NEWLINE); vty_out(vty, "%s MM State: %s, Routeing Area: %u-%u-%u-%u, " "Cell ID: %u%s", pfx, - get_value_string(gprs_mm_st_strs, mm->mm_state), + get_value_string(gprs_mm_st_strs, mm->gmm_state), mm->ra.mcc, mm->ra.mnc, mm->ra.lac, mm->ra.rac, mm->gb.cell_id, VTY_NEWLINE); diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index e1fd2e7..bcda9a0 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -191,7 +191,7 @@ lle = gprs_lle_get_or_create(tlli, 3); ctx = sgsn_mm_ctx_alloc(tlli, raid); - ctx->mm_state = GMM_REGISTERED_NORMAL; + ctx->gmm_state = GMM_REGISTERED_NORMAL; ctx->gb.llme = lle->llme; ictx = sgsn_mm_ctx_by_tlli(tlli, raid); @@ -979,7 +979,7 @@ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an identity request (IMEI) */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -999,7 +999,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); retry_attach_req: @@ -1039,7 +1039,7 @@ send_0408_message(ctx->gb.llme, local_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); @@ -1567,7 +1567,7 @@ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an identity request (IMEI) */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -1587,7 +1587,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an attach accept/reject */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -1601,7 +1601,7 @@ send_0408_message(ctx->gb.llme, foreign_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); @@ -1715,7 +1715,7 @@ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); ptmsi1 = ctx->p_tmsi; @@ -1732,7 +1732,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); /* we expect an attach accept */ @@ -1747,7 +1747,7 @@ /* the allocated P-TMSI should be the same */ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == old_ptmsi); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -1764,7 +1764,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -1777,7 +1777,7 @@ /* we expect an RA update accept */ OSMO_ASSERT(sgsn_tx_counter == 1); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); OSMO_ASSERT(ctx->p_tmsi != ptmsi1); @@ -1792,7 +1792,7 @@ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx); OSMO_ASSERT(received_ptmsi == ptmsi2); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi == ptmsi2); @@ -1804,7 +1804,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi2); @@ -1940,7 +1940,7 @@ ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid1); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); /* we expect an identity request (IMEI) */ @@ -1956,7 +1956,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(ms_tlli, &raid1)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an attach accept */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -1975,7 +1975,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -1990,7 +1990,7 @@ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK); // OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); OSMO_ASSERT(ctx->p_tmsi != ptmsi1); @@ -2007,7 +2007,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); OSMO_ASSERT(ctx->gb.tlli == ms_tlli); @@ -2052,7 +2052,7 @@ ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); /* we expect an attach accept */ @@ -2075,7 +2075,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -2089,7 +2089,7 @@ OSMO_ASSERT(sgsn_tx_counter == 1); OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); OSMO_ASSERT(ctx->p_tmsi != ptmsi1); @@ -2106,7 +2106,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); OSMO_ASSERT(ctx->gb.tlli == ms_tlli); -- To view, visit https://gerrit.osmocom.org/1754 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:05:57 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 05:05:57 +0000 Subject: [PATCH] openbsc[master]: gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb() Message-ID: Review at https://gerrit.osmocom.org/1755 gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb() Postfix the ran type to clarify the purpose. Because of the new support of the Iu ran type, there are 2 functions to allocate a mm ctx. For Iu it's sgsn_mm_ctx_alloc_iu(). For gb it should be named in the same way. Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95 --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/tests/sgsn/sgsn_test.c 4 files changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/55/1755/1 diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index f50de11..2cc5b0c 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -244,7 +244,7 @@ const struct gprs_ra_id *raid); /* Allocate a new SGSN MM context */ -struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli, +struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli, const struct gprs_ra_id *raid); struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx); diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 9ac1077..db27276 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -1146,7 +1146,7 @@ if (msg->dst) ctx = sgsn_mm_ctx_alloc_iu(msg->dst); else - ctx = sgsn_mm_ctx_alloc(0, &ra_id); + ctx = sgsn_mm_ctx_alloc_gb(0, &ra_id); if (!ctx) { reject_cause = GMM_CAUSE_NET_FAIL; goto rejected; @@ -1172,7 +1172,7 @@ if (msg->dst) ctx = sgsn_mm_ctx_alloc_iu(msg->dst); else - ctx = sgsn_mm_ctx_alloc(msgb_tlli(msg), &ra_id); + ctx = sgsn_mm_ctx_alloc_gb(msgb_tlli(msg), &ra_id); ctx->p_tmsi = tmsi; } if (ctx->ran_type == MM_CTX_T_GERAN_Gb) { diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 3fb1104..6d49e19 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -209,8 +209,8 @@ } -/* Allocate a new SGSN MM context */ -struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli, +/* Allocate a new SGSN MM context for GERAN_Gb */ +struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli, const struct gprs_ra_id *raid) { struct sgsn_mm_ctx *ctx; diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index bcda9a0..0aa142f 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -190,7 +190,7 @@ int old_count = count(gprs_llme_list()); lle = gprs_lle_get_or_create(tlli, 3); - ctx = sgsn_mm_ctx_alloc(tlli, raid); + ctx = sgsn_mm_ctx_alloc_gb(tlli, raid); ctx->gmm_state = GMM_REGISTERED_NORMAL; ctx->gb.llme = lle->llme; -- To view, visit https://gerrit.osmocom.org/1755 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:05:57 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 05:05:57 +0000 Subject: [PATCH] openbsc[master]: gprs/gprs_mm: add value_strings for PMM & MM states Message-ID: Review at https://gerrit.osmocom.org/1756 gprs/gprs_mm: add value_strings for PMM & MM states Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be --- M openbsc/src/gprs/gprs_gmm.c 1 file changed, 15 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/56/1756/1 diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index db27276..1026474 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -105,6 +105,15 @@ }, }; +static const struct value_string gprs_pmm_state_names[] = { + { PMM_DETACHED, "PMM DETACH" }, + { PMM_CONNECTED, "PMM CONNECTED" }, + { PMM_IDLE, "PMM IDLE" }, + { MM_IDLE, "MM IDLE" }, + { MM_READY, "MM READY" }, + { MM_STANDBY, "MM STANDBY" }, +}; + static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx); static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx) @@ -125,7 +134,9 @@ if (ctx->pmm_state == state) return; - LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %i to %i\n", ctx->pmm_state, state); + LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %s to %s\n", + get_value_string(gprs_pmm_state_names, ctx->pmm_state), + get_value_string(gprs_pmm_state_names, state)); switch (state) { case PMM_IDLE: @@ -149,7 +160,9 @@ if (ctx->pmm_state == state) return; - LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %i to %i\n", ctx->pmm_state, state); + LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %s to %s\n", + get_value_string(gprs_pmm_state_names, ctx->pmm_state), + get_value_string(gprs_pmm_state_names, state)); ctx->pmm_state = state; } -- To view, visit https://gerrit.osmocom.org/1756 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:05:57 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 05:05:57 +0000 Subject: [PATCH] openbsc[master]: gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE Message-ID: Review at https://gerrit.osmocom.org/1757 gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE Previous the state was only set in Iu mode. Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df --- M openbsc/src/gprs/gprs_sgsn.c 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/57/1757/1 diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 6d49e19..260e032 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -223,6 +223,7 @@ ctx->ran_type = MM_CTX_T_GERAN_Gb; ctx->gb.tlli = tlli; ctx->gmm_state = GMM_DEREGISTERED; + ctx->pmm_state = MM_IDLE; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ciph_algo = sgsn->cfg.cipher; LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n", -- To view, visit https://gerrit.osmocom.org/1757 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:07:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 4 Feb 2017 05:07:50 +0000 Subject: [PATCH] osmo-gsm-manuals[master]: GSUP, OAP: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1746 to look at the new patch set (#2). GSUP, OAP: fix AUTS length to 14, not 16 https://gerrit.osmocom.org/1731 Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 --- M OsmoSGSN/chapters/gsup.adoc M common/chapters/oap.adoc 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/46/1746/2 diff --git a/OsmoSGSN/chapters/gsup.adoc b/OsmoSGSN/chapters/gsup.adoc index 2a9563b..45c0e1d 100644 --- a/OsmoSGSN/chapters/gsup.adoc +++ b/OsmoSGSN/chapters/gsup.adoc @@ -616,7 +616,7 @@ [[gsup-ie-auts]] ==== AUTS -The 16-byte Authentication Synchronization Nonce generated by the USIM +The 14-byte Authentication Synchronization Nonce generated by the USIM in case the UMTS Authentication and Key Agreement Algorithm needs to re-synchronize the sequence counters between AUC and USIM. diff --git a/common/chapters/oap.adoc b/common/chapters/oap.adoc index 544da81..3c5ad35 100644 --- a/common/chapters/oap.adoc +++ b/common/chapters/oap.adoc @@ -191,7 +191,7 @@ |=== |IEI|IE|Type|Presence|Format|Length | |Message Type|<>|M|V|1 -|20|AUTS|octet string (16)|TLV|18 +|20|AUTS|octet string (14)|TLV|16 |=== ==== Sync Error -- To view, visit https://gerrit.osmocom.org/1746 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 Gerrit-PatchSet: 2 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:08:12 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 4 Feb 2017 05:08:12 +0000 Subject: osmo-gsm-manuals[master]: GSUP, OAP: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1746 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 Gerrit-PatchSet: 2 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:10:12 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 4 Feb 2017 05:10:12 +0000 Subject: osmo-gsm-manuals[master]: GSUP, OAP: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Patch Set 2: I also fixed the TLV combined size from 18 to 16 -- To view, visit https://gerrit.osmocom.org/1746 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 Gerrit-PatchSet: 2 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:16:26 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 4 Feb 2017 05:16:26 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: GSUP, OAP: fix AUTS length to 14, not 16 In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: GSUP, OAP: fix AUTS length to 14, not 16 ...................................................................... GSUP, OAP: fix AUTS length to 14, not 16 https://gerrit.osmocom.org/1731 Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 --- M OsmoSGSN/chapters/gsup.adoc M common/chapters/oap.adoc 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/OsmoSGSN/chapters/gsup.adoc b/OsmoSGSN/chapters/gsup.adoc index 2a9563b..45c0e1d 100644 --- a/OsmoSGSN/chapters/gsup.adoc +++ b/OsmoSGSN/chapters/gsup.adoc @@ -616,7 +616,7 @@ [[gsup-ie-auts]] ==== AUTS -The 16-byte Authentication Synchronization Nonce generated by the USIM +The 14-byte Authentication Synchronization Nonce generated by the USIM in case the UMTS Authentication and Key Agreement Algorithm needs to re-synchronize the sequence counters between AUC and USIM. diff --git a/common/chapters/oap.adoc b/common/chapters/oap.adoc index 544da81..3c5ad35 100644 --- a/common/chapters/oap.adoc +++ b/common/chapters/oap.adoc @@ -191,7 +191,7 @@ |=== |IEI|IE|Type|Presence|Format|Length | |Message Type|<>|M|V|1 -|20|AUTS|octet string (16)|TLV|18 +|20|AUTS|octet string (14)|TLV|16 |=== ==== Sync Error -- To view, visit https://gerrit.osmocom.org/1746 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926 Gerrit-PatchSet: 2 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sat Feb 4 05:36:29 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 05:36:29 +0000 Subject: osmo-pcu[master]: tbf.cpp: use new tlli instead of old tlli In-Reply-To: References: Message-ID: Patch Set 2: Please let this change settle some time. As long the set_tlli_from_ul is only called for a newly assigned UL TBF with unknown TLLI, it doesn't make sense to use the old tlli, because it will be always 0x0. -- To view, visit https://gerrit.osmocom.org/1663 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2fd6fec022506e203d05e91c36ccd9e020ff816c Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 06:01:38 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 06:01:38 +0000 Subject: openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef In-Reply-To: References: Message-ID: Patch Set 2: I also though WTF How could this happened, when I saw it. But I can not reproduce it atm. The man page describes under the point of RAND_pseudo_bytes(): "The contents of buf is mixed into the entropy pool before retrieving the new pseudo-random bytes unless disabled at compile time (see FAQ). But sgsn is using RAND_bytes(). It might be a side effect of a Use-after-free which I traced down before. Should I abandon this change or should we take it anyhow? -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 06:17:23 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 06:17:23 +0000 Subject: openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef In-Reply-To: References: Message-ID: Patch Set 2: I found a way to reproduce this bug. I've to use gcc with -O1 -fno-omit-framepoint (gcc (GCC) 6.3.1 20170109) Interesting is also, that it only happen when using GCC, with LLVM/clang it doesn't happen. (clang version 3.9.1 (tags/RELEASE_391/final)) -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 06:18:23 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Sat, 4 Feb 2017 06:18:23 +0000 Subject: [PATCH] openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1749 to look at the new patch set (#3). gprs_sgsn.c: initialize ptmsi with 0xdeadbeef Fix uninitialized memory access warning. "Conditional jump or move depends on uninitialised value" Found by valgrind. Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a --- M openbsc/src/gprs/gprs_sgsn.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/49/1749/3 diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index e85e1a9..40a66d9 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -610,7 +610,7 @@ uint32_t sgsn_alloc_ptmsi(void) { struct sgsn_mm_ctx *mm; - uint32_t ptmsi; + uint32_t ptmsi = 0xdeadbeef; int max_retries = 100; restart: -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Sat Feb 4 11:01:29 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 11:01:29 +0000 Subject: openbsc[master]: gprs_sgsn.c: initialize ptmsi with 0xdeadbeef In-Reply-To: References: Message-ID: Patch Set 3: > I found a way to reproduce this bug. > I've to use gcc with -O1 -fno-omit-framepoint (gcc (GCC) 6.3.1 > 20170109) > Interesting is also, that it only happen when using GCC, with > LLVM/clang it doesn't happen. (clang version 3.9.1 > (tags/RELEASE_391/final)) the valgrind output would be nice to have here. -- To view, visit https://gerrit.osmocom.org/1749 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:33:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:33:35 +0000 Subject: openbsc[master]: tests: fix leaks by talloc ctx In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:33:52 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:33:52 +0000 Subject: openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1752 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:36:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:36:34 +0000 Subject: openbsc[master]: gprs/sgsn: rename gprs->mm_state -> gmm_state In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 might be useful to extend the commit log message as to what GMM state and what MM state is (maybe with spec reference?) -- To view, visit https://gerrit.osmocom.org/1754 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:38:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:38:40 +0000 Subject: openbsc[master]: gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1755 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:38:54 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:38:54 +0000 Subject: openbsc[master]: gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1757 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:39:09 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:39:09 +0000 Subject: openbsc[master]: gprs/gprs_mm: add value_strings for PMM & MM states In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1756 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:39:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:39:47 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:42:32 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:42:32 +0000 Subject: osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:44:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:44:51 +0000 Subject: libosmocore[master]: osmo-auc-gen: cmdline help: list algorithms; error messages In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1745 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:46:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:46:17 +0000 Subject: libosmocore[master]: osmo-auc-gen: cosmetic: clarify output upon AUTS In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1734 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:46:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:46:20 +0000 Subject: [MERGED] libosmocore[master]: osmo-auc-gen: cosmetic: clarify output upon AUTS In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: osmo-auc-gen: cosmetic: clarify output upon AUTS ...................................................................... osmo-auc-gen: cosmetic: clarify output upon AUTS When calculating a re-sync vector using AUTS, osmo-gen-vec used to print SQN.MS + 2, the new SQN after vector generation, labeled 'SEQ.MS'. Firstly, s/SEQ/SQN. Secondly, print SQN.MS as umts.sqn - 2, which is the actual SQN recovered from the AUTS. As explained in the comment, SQN.MS + 1 is used to generate the vector, and then umts.sqn is increased a second time to indicate the next SQN. With AUTS calculated from SQN.MS == 23, the output was: AUTS success: SEQ.MS = 25 Output now: AUTS success: SQN.MS = 23, generated vector with SQN = 24, next SQN = 25 Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e --- M utils/osmo-auc-gen.c 1 file changed, 14 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 4c3e891..872d6f3 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -251,8 +251,21 @@ else dump_auth_vec(vec); + /* Print SQN from AUTS. It makes sense to print actually three SQN + * to clarify: + * After recovering SQN.MS from AUTS, milenage_gen_vec_auts() does: + * aud->u.umts.sqn = 1 + (osmo_load64be_ext(sqn_out, 6) >> 16); + * Then calls milenage_gen_vec(), which, after it is done, does: + * aud->u.umts.sqn++; + */ if (auts_is_set) - printf("AUTS success: SEQ.MS = %" PRIu64 "\n", test_aud.u.umts.sqn); + printf("AUTS success: SQN.MS = %" PRIu64 + ", generated vector with SQN = %" PRIu64 + ", next SQN = %" PRIu64 "\n", + test_aud.u.umts.sqn - 2, + test_aud.u.umts.sqn - 1, + test_aud.u.umts.sqn + ); exit(0); } -- To view, visit https://gerrit.osmocom.org/1734 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:50:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:50:35 +0000 Subject: libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:50:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:50:49 +0000 Subject: libosmocore[master]: utils/conv_gen.py: add test vectors generation feature In-Reply-To: References: Message-ID: Patch Set 7: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1585 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie10c47ee952f253b1ba77ecf6e79f2c033545bc1 Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:50:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:50:56 +0000 Subject: libosmocore[master]: utils/conv_gen.py: add header generation feature In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1593 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:51:03 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:51:03 +0000 Subject: libosmocore[master]: gsm0503.h: generate header automatically In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1594 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I21caa4e433b2cc1861611e35350a9671da444c2a Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 14:51:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 4 Feb 2017 14:51:51 +0000 Subject: libosmocore[master]: tests/conv: add GSM 05.03 specific test In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1628 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 4 15:11:33 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 4 Feb 2017 15:11:33 +0000 Subject: osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) I will have to look carefully. On first sight you seem to add the & at all call sites. Another approach is outlined in the comment of bitvector.h In general I agree with this change (after max had moved the code to libosmocore) https://gerrit.osmocom.org/#/c/1753/2/src/bitvector.h File src/bitvector.h: Line 44 This was one "trick" to use function overloading and outer scope look-up to not have to update all client code.. -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 6 10:09:21 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 6 Feb 2017 10:09:21 +0000 Subject: [PATCH] osmo-gsm-manuals[master]: Sync DTX FSM with OsmoBTS code Message-ID: Review at https://gerrit.osmocom.org/1758 Sync DTX FSM with OsmoBTS code Change-Id: I050a07db99bc0038cfd2a9646a450f714653d804 --- M OsmoBTS/dtx.dot M OsmoBTS/rtp-amr.adoc 2 files changed, 70 insertions(+), 35 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/58/1758/1 diff --git a/OsmoBTS/dtx.dot b/OsmoBTS/dtx.dot index 1c60ee7..b9f0b5f 100644 --- a/OsmoBTS/dtx.dot +++ b/OsmoBTS/dtx.dot @@ -1,43 +1,68 @@ digraph dtx_dl_amr_fsm { - node [shape = doublecircle] ST_VOICE ST_FACCH_V ST_FACCH ST_SID_U + node [shape = doublecircle] ST_VOICE ST_FACCH ST_U_NOINH node [shape = circle] // default state for non-DTX and DTX when SPEECH is in progress ST_VOICE -> ST_SID_F1 [ label = "E_SID_F" ] - ST_VOICE -> ST_SID_F1 [ label = "E_SID_U" ] + ST_VOICE -> ST_F1_INH_V [ label = "E_INHIB" ] + ST_VOICE -> ST_U_NOINH [ label = "E_SID_U" ] ST_VOICE -> ST_VOICE [ label = "E_VOICE" ] ST_VOICE -> ST_VOICE [ label = "E_FACCH" ] // SID-FIRST or SID-FIRST-P1 in case of AMR HR: start of silence period (might be interrupted in case of AMR HR) ST_SID_F1 -> ST_SID_F1 [ label = "E_SID_F" ] - ST_SID_F1 -> ST_SID_U [ label = "E_SID_U" ] - ST_SID_F1 -> ST_VOICE [ label = "E_VOICE" ] - ST_SID_F1 -> ST_ONSET_F [ label = "E_FACCH" ] - ST_SID_F1 -> ST_SID_F2 [ label = "E_COMPL" ] - ST_SID_F1 -> ST_F1_INH [ label = "E_INHIB" ] + ST_SID_F1 -> ST_U_NOINH [ label = "E_SID_U" ] + ST_SID_F1 -> ST_F1_INH_F [ label = "E_FACCH" ] + ST_SID_F1 -> ST_SID_F2 [ label = "E_FIRST" ] ST_SID_F1 -> ST_ONSET_V [ label = "E_ONSET" ] // SID-FIRST P2 (only for AMR HR): actual start of silence period in case of AMR HR - ST_SID_F2 -> ST_SID_U [ label = "E_SID_U" ] - ST_SID_F2 -> ST_VOICE [ label = "E_VOICE" ] + ST_SID_F2 -> ST_U_NOINH [ label = "E_COMPL" ] ST_SID_F2 -> ST_ONSET_F [ label = "E_FACCH" ] ST_SID_F2 -> ST_ONSET_V [ label = "E_ONSET" ] - // SID-FIRST Inhibited: incoming SPEECH or FACCH (only for AMR HR) - ST_F1_INH -> ST_VOICE [ label = "E_VOICE" ] - ST_F1_INH -> ST_FACCH_V [ label = "E_FACCH" ] + // SID-FIRST Inhibited: incoming SPEECH (only for AMR HR) + ST_F1_INH_V -> ST_F1_INH_V_REC [ label = "E_COMPL" ] - // SID-UPDATE Inhibited: incoming SPEECH or FACCH (only for AMR HR) - ST_U_INH -> ST_VOICE [ label = "E_VOICE" ] - ST_U_INH -> ST_FACCH [ label = "E_FACCH" ] + // SID-FIRST Inhibited: incoming FACCH frame (only for AMR HR) + ST_F1_INH_F -> ST_F1_INH_F_REC [ label = "E_COMPL" ] - // Silence period with periodic comfort noise data updates - ST_SID_U -> ST_ONSET_F [ label = "E_FACCH" ] + // SID-UPDATE Inhibited: incoming SPEECH (only for AMR HR) + ST_U_INH_V -> ST_U_INH_V_REC [ label = "E_COMPL" ] + + // SID-UPDATE Inhibited: incoming FACCH frame (only for AMR HR) + ST_U_INH_F -> ST_U_INH_F_REC [ label = "E_COMPL" ] + + // Silence period with periodic comfort noise data updates (no Inhibition) + ST_U_NOINH -> ST_ONSET_F [ label = "E_FACCH" ] + ST_U_NOINH -> ST_VOICE [ label = "E_VOICE" ] + ST_U_NOINH -> ST_U_NOINH [ label = "E_SID_U" ] + ST_U_NOINH -> ST_U_NOINH [ label = "E_SID_F" ] + ST_U_NOINH -> ST_ONSET_V [ label = "E_ONSET" ] + ST_U_NOINH -> ST_SID_U [ label = "E_COMPL" ] + + // SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_F1_INH_V_REC -> ST_VOICE [ label = "E_COMPL" ] + ST_F1_INH_V_REC -> ST_VOICE [ label = "E_VOICE" ] + + // SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_F1_INH_F_REC -> ST_FACCH [ label = "E_COMPL" ] + ST_F1_INH_F_REC -> ST_FACCH [ label = "E_VOICE" ] + + // SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_U_INH_V_REC -> ST_VOICE [ label = "E_COMPL" ] + ST_U_INH_V_REC -> ST_VOICE [ label = "E_VOICE" ] + + // SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_U_INH_F_REC -> ST_FACCH [ label = "E_COMPL" ] + ST_U_INH_F_REC -> ST_FACCH [ label = "E_VOICE" ] + + // Silence period with periodic comfort noise data updates (can be inhibited) + ST_SID_U -> ST_U_INH_F [ label = "E_FACCH" ] ST_SID_U -> ST_VOICE [ label = "E_VOICE" ] - ST_SID_U -> ST_U_INH [ label = "E_INHIB" ] - ST_SID_U -> ST_SID_U [ label = "E_SID_U" ] - ST_SID_U -> ST_SID_U [ label = "E_SID_F" ] - ST_SID_U -> ST_ONSET_V [ label = "E_ONSET" ] + ST_SID_U -> ST_U_INH_V [ label = "E_INHIB" ] + ST_SID_U -> ST_U_NOINH [ label = "E_SID_U" ] + ST_SID_U -> ST_U_NOINH [ label = "E_SID_F" ] // ONSET - end of silent period due to incoming SPEECH frame ST_ONSET_V -> ST_ONSET_V_REC [ label = "E_COMPL" ] @@ -45,21 +70,16 @@ // ONSET - end of silent period due to incoming FACCH frame ST_ONSET_F -> ST_ONSET_F_REC [ label = "E_COMPL" ] - // ONSET recursion in progress: ONSET itself was already sent, now have to send the voice that caused it - ST_ONSET_V_REC -> ST_VOICE [ label = "E_COMPL" ] - // ONSET recursion in progress: ONSET itself was already sent, now have to send the data that caused it ST_ONSET_F_REC -> ST_FACCH [ label = "E_COMPL" ] - // FACCH sending state: SPEECH was observed before so once we're done FSM should get back to VOICE state - ST_FACCH_V -> ST_FACCH_V [ label = "E_FACCH" ] - ST_FACCH_V -> ST_VOICE [ label = "E_VOICE" ] - ST_FACCH_V -> ST_VOICE [ label = "E_SID_U" ] - ST_FACCH_V -> ST_SID_F1 [ label = "E_SID_F" ] + // ONSET recursion in progress: ONSET itself was already sent, now have to send the voice that caused it + ST_ONSET_V_REC -> ST_VOICE [ label = "E_COMPL" ] - // FACCH sending state: no SPEECH was observed before so once we're done FSM should get back to silent period via SID-FIRST - ST_FACCH -> ST_FACCH [ label = "E_FACCH" ] + // FACCH sending state ST_FACCH -> ST_VOICE [ label = "E_VOICE" ] - ST_FACCH -> ST_SID_F1 [ label = "E_SID_U" ] - ST_FACCH -> ST_SID_F1 [ label = "E_SID_F" ] + ST_FACCH -> ST_FACCH [ label = "E_FACCH" ] + ST_FACCH -> ST_FACCH [ label = "E_SID_U" ] + ST_FACCH -> ST_FACCH [ label = "E_SID_F" ] + ST_FACCH -> ST_SID_F1 [ label = "E_COMPL" ] } diff --git a/OsmoBTS/rtp-amr.adoc b/OsmoBTS/rtp-amr.adoc index f7eda11..982a5af 100644 --- a/OsmoBTS/rtp-amr.adoc +++ b/OsmoBTS/rtp-amr.adoc @@ -1322,10 +1322,25 @@ include::dtx.dot[] ---- -The idea is that each state corresponds to the particular message type which have to be send to L1 while state transition happens on incoming events like FACCH or Voice frames. There are 3 different classes of of events driving this FSM: +The idea is that each state corresponds to the particular message type which have to be send to L1 next while state transition happens on incoming events like FACCH or Voice frames. There are 3 different classes of of events driving this FSM: * Voice frame types: E_VOICE, E_SID_U, E_SID_F * Incoming FACCH: E_FACCH * Internal: E_ONSET, E_INHIB, E_COMPL -They represent different types of incoming RTP frames (Voice, SID UPDATE and SID FIRST correspondingly), incoming FACCH events or important events internal to DTX operations. The latter are Onset (interruption of silence period), Inhibition (of currently transmitted SID FIRST or UPDATE) and Completion (of silence initiation). \ No newline at end of file +They represent different types of incoming RTP frames (Voice, SID UPDATE and SID FIRST correspondingly), incoming FACCH events or important events internal to DTX operations. The latter are Onset (interruption of silence period), Inhibition (of currently transmitted SID FIRST or UPDATE) and Completion (of silence initiation). + +The double-circled states are "stationary" meaning that FSM can stay for longer periods in them. Other states are "transient" - the FSM have to switch away during next step. In practice this is implemented using E_COMPL signal which is issued in corresponding RTS handler or internal function (in case of SID First P1 -> P2 transition). + +The FSM states are grouped as follows: + +* ST_VOICE: talkspurt, normal voice transmission +* ST_FACCH: transmission of higher-priority FACCH frame, interrupting current DTX state +* ST_ONSET*: handling of Onset event (interruption of silence period) +* ST_SID_F*: silence initiation +* ST_*_REC: sending of 2nd event for L1 during the same FN +* ST_*_INH: handling of Inhibition event (interruption of transmission of previous event) + +The latter are specific to AMR HR where transmission of particular message by L1 takes longer so it can be aborted due to another incoming event. Note that for AMR FR only subset of this FSM is active (ST_SID_F2 and *INH states are never reached). This is implemented by signal emitting functions. + +Note that the FSM states describe only the situation when we got to send something to L1, the transmission of Empty frames suppressing the actual radio transmission is done by other code. -- To view, visit https://gerrit.osmocom.org/1758 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I050a07db99bc0038cfd2a9646a450f714653d804 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 6 12:46:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 12:46:21 +0000 Subject: openbsc[master]: add struct bsc_sub, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 4: Would you be fine with calling the structs *_subscriber and still prefix the functions with the shorter *_sub_? Background: In vlr.h, we have subscriber related things except vlr_subscriber itself prefixed 'vlr_sub_' (from you). I actually liked its brevity because I had to type a lot of subscriber (and it's a word that I often mistype for some reason). That's why I went on to use bsc_sub_ and gprs_sub_, and thought why not name the structs the same as the function prefix. (still leaving as -2 because the issue that testing this failed is not resolved yet; but will be fairly soon) -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 6 13:16:45 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 6 Feb 2017 13:16:45 +0000 Subject: [PATCH] openbsc[master]: Attempt to fix nightly builds Message-ID: Review at https://gerrit.osmocom.org/1759 Attempt to fix nightly builds The fix introduced in dac5867af5ff90d4beb70fc30a5743f60f159e3a did not work because autotools in our OE are too old. Use alternative way to include custom m4 macros to fix it. Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464 --- M openbsc/Makefile.am M openbsc/configure.ac 2 files changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/59/1759/1 diff --git a/openbsc/Makefile.am b/openbsc/Makefile.am index f7eda56..31a54ea 100644 --- a/openbsc/Makefile.am +++ b/openbsc/Makefile.am @@ -1,5 +1,8 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 +## FIXME: automake >= 1.13 or autoconf >= 2.70 provide better suited AC_CONFIG_MACRO_DIRS for configure.ac +## remove line below when OE toolchain is updated to version which include those +ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = \ $(all_includes) \ -I$(top_srcdir)/include \ diff --git a/openbsc/configure.ac b/openbsc/configure.ac index 6d373a5..7e244bc 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -9,9 +9,6 @@ AM_INIT_AUTOMAKE([dist-bzip2]) AC_CONFIG_TESTDIR(tests) -dnl FIXME: Remove this once we do not need local macro copies anymore (after upgrade to newer OE?) -AC_CONFIG_MACRO_DIRS([m4]) - dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -- To view, visit https://gerrit.osmocom.org/1759 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 6 13:45:26 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 13:45:26 +0000 Subject: [PATCH] libosmocore[master]: bssgp_fc_test: do not use real time Message-ID: Review at https://gerrit.osmocom.org/1760 bssgp_fc_test: do not use real time Employ osmo_gettimeofday_override_* to take bssgp_fc_test off real time. The jenkins build slave often failed the test based on sporadic time delays due to server load and randomly rejected good patches. This patch ends that. Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9 Related: OS#1809 --- M tests/gb/bssgp_fc_test.c 1 file changed, 8 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/1760/1 diff --git a/tests/gb/bssgp_fc_test.c b/tests/gb/bssgp_fc_test.c index d77f141..27d8fcc 100644 --- a/tests/gb/bssgp_fc_test.c +++ b/tests/gb/bssgp_fc_test.c @@ -70,6 +70,12 @@ struct bssgp_flow_control *fc = talloc_zero(NULL, struct bssgp_flow_control); int i; + osmo_gettimeofday_override_time = (struct timeval){ + .tv_sec = 1486385000, + .tv_usec = 423423, + }; + osmo_gettimeofday_override = true; + bssgp_fc_init(fc, bucket_size_max, bucket_leak_rate, max_queue_depth, fc_out_cb); @@ -83,7 +89,8 @@ } while (1) { - usleep(100000); + osmo_gettimeofday_override_add(0, 100000); + osmo_timers_check(); osmo_timers_prepare(); osmo_timers_update(); -- To view, visit https://gerrit.osmocom.org/1760 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 6 13:47:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 13:47:17 +0000 Subject: [MERGED] libosmocore[master]: osmo-auc-gen: cmdline help: list algorithms; error messages In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmo-auc-gen: cmdline help: list algorithms; error messages ...................................................................... osmo-auc-gen: cmdline help: list algorithms; error messages In the -h help output, list the names of available algorithms. In case of option parsing failure, also print help() (so that e.g. for a typo in the algorithm, the list of algorithms is printed along with the error message). If there are -2/-3 or -a missing, show an error message that explains this. Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886 --- M utils/osmo-auc-gen.c 1 file changed, 10 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 872d6f3..f0cfa79 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -70,6 +70,7 @@ static void help() { + int alg; printf( "-2 --2g\tUse 2G (GSM) authentication\n" "-3 --3g\tUse 3G (UMTS) authentication\n" "-a --algorithm\tSpecify name of the algorithm\n" @@ -81,6 +82,11 @@ "-A --auts\tSpecify AUTS (only for 3G)\n" "-r --rand\tSpecify random value\n" "-I --ipsec\tOutput in triplets.dat format for strongswan\n"); + + fprintf(stderr, "\nAvailable algorithms for option -a:\n"); + for (alg = 1; alg < _OSMO_AUTH_ALG_NUM; alg++) + fprintf(stderr, " %s\n", + osmo_auth_alg_name(alg)); } int main(int argc, char **argv) @@ -209,7 +215,8 @@ } if (rc < 0) { - fprintf(stderr, "Error parsing argument of option `%c'\n", c); + help(); + fprintf(stderr, "\nError parsing argument of option `%c'\n", c); exit(2); } } @@ -229,6 +236,8 @@ if (test_aud.type == OSMO_AUTH_TYPE_NONE || test_aud.algo == OSMO_AUTH_ALG_NONE) { help(); + fprintf(stderr, "\nError: you need to pass at least" + " -2 or -3, as well as an algorithm to use.\n"); exit(2); } -- To view, visit https://gerrit.osmocom.org/1745 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 6 14:08:56 2017 From: gerrit-no-reply at lists.osmocom.org (jfdionne) Date: Mon, 6 Feb 2017 14:08:56 +0000 Subject: [PATCH] osmo-bts[master]: Fix SACCH channel release indication not sent to BSC after l... In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1747 to look at the new patch set (#2). Fix SACCH channel release indication not sent to BSC after location update. Based on GSM 04.08 3.4.13 RR connection release procedure, after the network sends a deactivate SACCH it receives DISC from MS which cause BTS to send RLL release indication to BSC in order to stop T3109 timer. It has been found that after a location update BSC never receives RLL release indication which causes a T3109 timeout because no TCH is currently allocated. This fix ensures RLL release indication to be sent to BSC when no TCH is allocated in the particular case of a location update. Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/47/1747/2 diff --git a/src/common/rsl.c b/src/common/rsl.c index 74d835f..5c4e4ff 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -2284,7 +2284,8 @@ gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); /* REL_IND handling */ - if (rh->msg_type == RSL_MT_REL_IND) { + if (rh->msg_type == RSL_MT_REL_IND && + (lchan->type == GSM_LCHAN_TCH_F || lchan->type == GSM_LCHAN_TCH_H)) { LOGP(DRSL, LOGL_INFO, "%s Scheduling %s to L3 in next associated TCH-RTS.ind\n", gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); -- To view, visit https://gerrit.osmocom.org/1747 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 6 14:09:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 14:09:04 +0000 Subject: [MERGED] openbsc[master]: VTY: Print 3G auth tuples, not just 2G auth tuples In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: VTY: Print 3G auth tuples, not just 2G auth tuples ...................................................................... VTY: Print 3G auth tuples, not just 2G auth tuples Change-Id: I277e4347ee1486a39e6dc4e2363a593f328f9e3b Related: OS#1592 --- M openbsc/src/gprs/sgsn_vty.c 1 file changed, 24 insertions(+), 9 deletions(-) Approvals: Harald Welte: Looks good to me, approved Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 4a97687..246867d 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -1,5 +1,5 @@ /* - * (C) 2010-2013 by Harald Welte + * (C) 2010-2016 by Harald Welte * (C) 2010 by On-Waves * (C) 2015 by Holger Hans Peter Freyther * All Rights Reserved @@ -696,15 +696,30 @@ vty_out(vty, " A3A8 tuple (used %d times): ", at->use_count); - vty_out(vty, " seq # : %d, ", + vty_out(vty, " CKSN: %d, ", at->key_seq); - vty_out(vty, " RAND : %s, ", - osmo_hexdump(at->vec.rand, sizeof(at->vec.rand))); - vty_out(vty, " SRES : %s, ", - osmo_hexdump(at->vec.sres, sizeof(at->vec.sres))); - vty_out(vty, " Kc : %s%s", - osmo_hexdump(at->vec.kc, sizeof(at->vec.kc)), - VTY_NEWLINE); + if (at->vec.auth_types & OSMO_AUTH_TYPE_GSM) { + vty_out(vty, "RAND: %s, ", + osmo_hexdump(at->vec.rand, + sizeof(at->vec.rand))); + vty_out(vty, "SRES: %s, ", + osmo_hexdump(at->vec.sres, + sizeof(at->vec.sres))); + vty_out(vty, "Kc: %s%s", + osmo_hexdump(at->vec.kc, + sizeof(at->vec.kc)), VTY_NEWLINE); + } + if (at->vec.auth_types & OSMO_AUTH_TYPE_UMTS) { + vty_out(vty, " AUTN: %s, ", + osmo_hexdump(at->vec.autn, + sizeof(at->vec.autn))); + vty_out(vty, "RES: %s, ", + osmo_hexdump(at->vec.res, at->vec.res_len)); + vty_out(vty, "IK: %s, ", + osmo_hexdump(at->vec.ik, sizeof(at->vec.ik))); + vty_out(vty, "CK: %s, ", + osmo_hexdump(at->vec.ck, sizeof(at->vec.ck))); + } } llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) { -- To view, visit https://gerrit.osmocom.org/1694 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I277e4347ee1486a39e6dc4e2363a593f328f9e3b Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 6 14:09:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 14:09:04 +0000 Subject: [MERGED] openbsc[master]: gsm_04_08: implement parsing of UMTS Auth responses In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: gsm_04_08: implement parsing of UMTS Auth responses ...................................................................... gsm_04_08: implement parsing of UMTS Auth responses Parse the longer UMTS res from the extended Auth Response Parameter IE. Parse the R99 Authentication Failure and AUTS in case of cause GSM_REJECT_SYNCH_FAILURE which indicates a SQN re-sync request. Both still end in 'not implemented' error logs, which are the places where the upcoming VLR that supports UMTS AKA will integrate. Depends on recently added constants in libosmocore in commit 55a43b801385e07a484217925ecf2379b9f54fcf aka change-id I745061ce8eb88aa23080dadcdbfe2d703c362a30 Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec --- M openbsc/src/libmsc/gsm_04_08.c 1 file changed, 222 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 407104f..e5402d0 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1125,15 +1125,126 @@ return 0; } -/* Chapter 9.2.3: Authentication Response */ -static int gsm48_rx_mm_auth_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) +static int parse_gsm_auth_resp(uint8_t *res, uint8_t *res_len, + struct gsm_subscriber_connection *conn, + struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); struct gsm48_auth_resp *ar = (struct gsm48_auth_resp*) gh->data; - struct gsm_network *net = conn->network; - DEBUGP(DMM, "MM AUTHENTICATION RESPONSE (sres = %s): ", - osmo_hexdump(ar->sres, 4)); + if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*ar)) { + LOGP(DMM, LOGL_ERROR, + "%s: MM AUTHENTICATION RESPONSE:" + " l3 length invalid: %u\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + return -EINVAL; + } + + *res_len = sizeof(ar->sres); + memcpy(res, ar->sres, sizeof(ar->sres)); + return 0; +} + +static int parse_umts_auth_resp(uint8_t *res, uint8_t *res_len, + struct gsm_subscriber_connection *conn, + struct msgb *msg) +{ + struct gsm48_hdr *gh; + uint8_t *data; + uint8_t iei; + uint8_t ie_len; + unsigned int data_len; + + /* First parse the GSM part */ + if (parse_gsm_auth_resp(res, res_len, conn, msg)) + return -EINVAL; + OSMO_ASSERT(*res_len == 4); + + /* Then add the extended res part */ + gh = msgb_l3(msg); + data = gh->data + sizeof(struct gsm48_auth_resp); + data_len = msgb_l3len(msg) - (data - (uint8_t*)msgb_l3(msg)); + + if (data_len < 3) { + LOGP(DMM, LOGL_ERROR, + "%s: MM AUTHENTICATION RESPONSE:" + " l3 length invalid: %u\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + return -EINVAL; + } + + iei = data[0]; + ie_len = data[1]; + if (iei != GSM48_IE_AUTH_RES_EXT) { + LOGP(DMM, LOGL_ERROR, + "%s: MM R99 AUTHENTICATION RESPONSE:" + " expected IEI 0x%02x, got 0x%02x\n", + subscr_name(conn->subscr), + GSM48_IE_AUTH_RES_EXT, iei); + return -EINVAL; + } + + if (ie_len > 12) { + LOGP(DMM, LOGL_ERROR, + "%s: MM R99 AUTHENTICATION RESPONSE:" + " extended Auth Resp IE 0x%02x is too large: %u bytes\n", + subscr_name(conn->subscr), GSM48_IE_AUTH_RES_EXT, ie_len); + return -EINVAL; + } + + *res_len += ie_len; + memcpy(res + 4, &data[2], ie_len); + return 0; +} + +/* Chapter 9.2.3: Authentication Response */ +static int gsm48_rx_mm_auth_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) +{ + struct gsm_network *net = conn->network; + uint8_t res[16]; + uint8_t res_len; + int rc; + bool is_r99; + + if (!conn->subscr) { + LOGP(DMM, LOGL_ERROR, + "MM AUTHENTICATION RESPONSE: invalid: no subscriber\n"); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + if (msgb_l3len(msg) > + sizeof(struct gsm48_hdr) + sizeof(struct gsm48_auth_resp)) { + rc = parse_umts_auth_resp(res, &res_len, conn, msg); + is_r99 = true; + } else { + rc = parse_gsm_auth_resp(res, &res_len, conn, msg); + is_r99 = false; + } + + if (rc) { + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + DEBUGP(DMM, "%s: MM %s AUTHENTICATION RESPONSE (%s = %s)\n", + subscr_name(conn->subscr), + is_r99 ? "R99" : "GSM", is_r99 ? "res" : "sres", + osmo_hexdump_nospc(res, res_len)); + + /* Future: vlr_sub_rx_auth_resp(conn->vsub, is_r99, + * conn->via_iface == IFACE_IU, + * res, res_len); + */ + + if (res_len != 4) { + LOGP(DMM, LOGL_ERROR, + "%s: MM AUTHENTICATION RESPONSE:" + " UMTS authentication not supported\n", + subscr_name(conn->subscr)); + } /* Safety check */ if (!conn->sec_operation) { @@ -1142,7 +1253,7 @@ } /* Validate SRES */ - if (memcmp(conn->sec_operation->atuple.vec.sres, ar->sres,4)) { + if (memcmp(conn->sec_operation->atuple.vec.sres, res, 4)) { int rc; gsm_cbfn *cb = conn->sec_operation->cb; @@ -1163,6 +1274,108 @@ /* Start ciphering */ return gsm0808_cipher_mode(conn, net->a5_encryption, conn->sec_operation->atuple.vec.kc, 8, 0); +} + +static int gsm48_rx_mm_auth_fail(struct gsm_subscriber_connection *conn, struct msgb *msg) +{ + struct gsm48_hdr *gh = msgb_l3(msg); + uint8_t cause; + uint8_t auts_tag; + uint8_t auts_len; + uint8_t *auts; + int rc; + + if (!conn->sec_operation) { + DEBUGP(DMM, "%s: MM R99 AUTHENTICATION FAILURE:" + " No authentication/cipher operation in progress\n", + subscr_name(conn->subscr)); + return -EINVAL; + } + + if (!conn->subscr) { + LOGP(DMM, LOGL_ERROR, + "MM R99 AUTHENTICATION FAILURE: invalid: no subscriber\n"); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + if (msgb_l3len(msg) < sizeof(*gh) + 1) { + LOGP(DMM, LOGL_ERROR, + "%s: MM R99 AUTHENTICATION FAILURE:" + " l3 length invalid: %u\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + cause = gh->data[0]; + + if (cause != GSM48_REJECT_SYNCH_FAILURE) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE: cause 0x%0x\n", + subscr_name(conn->subscr), cause); + rc = gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return rc; + } + + /* This is a Synch Failure procedure, which should pass an AUTS to + * resynchronize the sequence nr with the HLR. Expecting exactly one + * TLV with 14 bytes of AUTS. */ + + if (msgb_l3len(msg) < sizeof(*gh) + 1 + 2) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE:" + " invalid Synch Failure: missing AUTS IE\n", + subscr_name(conn->subscr)); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + auts_tag = gh->data[1]; + auts_len = gh->data[2]; + auts = &gh->data[3]; + + if (auts_tag != GSM48_IE_AUTS + || auts_len != 14) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE:" + " invalid Synch Failure:" + " expected AUTS IE 0x%02x of 14 bytes," + " got IE 0x%02x of %u bytes\n", + subscr_name(conn->subscr), + GSM48_IE_AUTS, auts_tag, auts_len); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + if (msgb_l3len(msg) < sizeof(*gh) + 1 + 2 + auts_len) { + LOGP(DMM, LOGL_INFO, + "%s: MM R99 AUTHENTICATION FAILURE:" + " invalid Synch Failure msg: message truncated (%u)\n", + subscr_name(conn->subscr), msgb_l3len(msg)); + gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return -EINVAL; + } + + /* We have an AUTS IE with exactly 14 bytes of AUTS and the msgb is + * large enough. */ + + DEBUGP(DMM, "%s: MM R99 AUTHENTICATION SYNCH (AUTS = %s)\n", + subscr_name(conn->subscr), osmo_hexdump_nospc(auts, 14)); + + /* Future: vlr_sub_rx_auth_fail(conn->vsub, auts); */ + + LOGP(DMM, LOGL_ERROR, "%s: MM R99 AUTHENTICATION not supported\n", + subscr_name(conn->subscr)); + rc = gsm48_tx_mm_auth_rej(conn); + release_security_operation(conn); + return rc; } /* Receive a GSM 04.08 Mobility Management (MM) message */ @@ -1199,6 +1412,9 @@ case GSM48_MT_MM_AUTH_RESP: rc = gsm48_rx_mm_auth_resp(conn, msg); break; + case GSM48_MT_MM_AUTH_FAIL: + rc = gsm48_rx_mm_auth_fail(conn, msg); + break; default: LOGP(DMM, LOGL_NOTICE, "Unknown GSM 04.08 MM msg type 0x%02x\n", gh->msg_type); -- To view, visit https://gerrit.osmocom.org/1733 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 6 14:09:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 14:09:23 +0000 Subject: [MERGED] osmo-hlr[master]: UMTS AKA resync: fix argument ordering In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: UMTS AKA resync: fix argument ordering ...................................................................... UMTS AKA resync: fix argument ordering According to libosmocore change-id I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 this argument ordering will not result in successful AUTS. Pass in order auts, auts_rand so that these are passed correctly to our milenage code. Change-Id: I6aa19004ec27bad5e9c2bf688d9bbc55d697ccb0 --- M src/auc.c 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/auc.c b/src/auc.c index bec3ea6..3f3db34 100644 --- a/src/auc.c +++ b/src/auc.c @@ -71,8 +71,8 @@ i, num_vec); if (rand_auts && auts) rc = osmo_auth_gen_vec_auts(vec+i, aud3g, - rand_auts, - auts, rand); + auts, rand_auts, + rand); else rc = osmo_auth_gen_vec(vec+i, aud3g, rand); if (rc < 0) { -- To view, visit https://gerrit.osmocom.org/1739 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6aa19004ec27bad5e9c2bf688d9bbc55d697ccb0 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 6 14:09:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 6 Feb 2017 14:09:31 +0000 Subject: [MERGED] libosmocore[master]: osmo_auth*: fix ordering of function args In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmo_auth*: fix ordering of function args ...................................................................... osmo_auth*: fix ordering of function args milenage_gen_vec() has parameter ordering of (..., auts, rand_auts, rand). osmo_auth_gen_vec_auts() has (..., rand_auts, auts, rand), but actually feeds args in the same order, so that its rand_auts becomes auts, and its auts becomes rand_auts. Interestingly enough, API user osmo-gen-vec.c also adheres to this misordering and in turn passes auts for osmo_auth_gen_vec_auts()'s rand_auts and vice versa, so that it matches milenage_gen_vec(). So both the implementation (milenage_*) and the API user use the same ordering, just osmo_auth_gen_vec_auts() and osmo_auth_impl{ .gen_vec_auts() } in-between have the argument names swapped. Any current user of this API would need to adhere to this swapping or will not get successful AUTS resolution to a SQN. So the least impact fix is to rename the args without any actual functional change. So swap the names rand_auts and auts for osmo_auth_gen_vec_auts() and osmo_auth_impl{ .gen_vec_auts() }. (Also adjust API doc ordering) Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 --- M include/osmocom/crypt/auth.h M src/gsm/auth_core.c 2 files changed, 5 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index 37b8a8a..7c6072b 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -74,7 +74,7 @@ /* \brief callback for generationg auth vectors + re-sync */ int (*gen_vec_auts)(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, - const uint8_t *rand_auts, const uint8_t *auts, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand); }; @@ -83,7 +83,7 @@ int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, - const uint8_t *rand_auts, const uint8_t *auts, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand); int osmo_auth_register(struct osmo_auth_impl *impl); diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index 3aac069..3b1a5c6 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -170,8 +170,8 @@ /*! \brief Generate authentication vector and re-sync sequence * \param[out] vec Generated authentication vector * \param[in] aud Subscriber-specific key material - * \param[in] rand_auts RAND value sent by the SIM/MS * \param[in] auts AUTS value sent by the SIM/MS + * \param[in] rand_auts RAND value sent by the SIM/MS * \param[in] _rand Random challenge to be used to generate vector * \returns 0 on success, negative error on failure * @@ -184,7 +184,7 @@ */ int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, - const uint8_t *rand_auts, const uint8_t *auts, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand) { struct osmo_auth_impl *impl = selected_auths[aud->algo]; @@ -192,7 +192,7 @@ if (!impl || !impl->gen_vec_auts) return -ENOENT; - return impl->gen_vec_auts(vec, aud, rand_auts, auts, _rand); + return impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); } static const struct value_string auth_alg_vals[] = { -- To view, visit https://gerrit.osmocom.org/1737 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:39:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:39:41 +0000 Subject: osmo-bts[master]: Fix SACCH channel release indication not sent to BSC after l... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1747 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:39:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:39:42 +0000 Subject: [MERGED] osmo-bts[master]: Fix SACCH channel release indication not sent to BSC after l... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Fix SACCH channel release indication not sent to BSC after location update. ...................................................................... Fix SACCH channel release indication not sent to BSC after location update. Based on GSM 04.08 3.4.13 RR connection release procedure, after the network sends a deactivate SACCH it receives DISC from MS which cause BTS to send RLL release indication to BSC in order to stop T3109 timer. It has been found that after a location update BSC never receives RLL release indication which causes a T3109 timeout because no TCH is currently allocated. This fix ensures RLL release indication to be sent to BSC when no TCH is allocated in the particular case of a location update. Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/rsl.c b/src/common/rsl.c index 74d835f..5c4e4ff 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -2284,7 +2284,8 @@ gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); /* REL_IND handling */ - if (rh->msg_type == RSL_MT_REL_IND) { + if (rh->msg_type == RSL_MT_REL_IND && + (lchan->type == GSM_LCHAN_TCH_F || lchan->type == GSM_LCHAN_TCH_H)) { LOGP(DRSL, LOGL_INFO, "%s Scheduling %s to L3 in next associated TCH-RTS.ind\n", gsm_lchan_name(lchan), rsl_msg_name(rh->msg_type)); -- To view, visit https://gerrit.osmocom.org/1747 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibe2a365641eb8c9a7f0a462b7393ec3fd28cc366 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: jfdionne Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:39:52 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:39:52 +0000 Subject: libosmocore[master]: bssgp_fc_test: do not use real time In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1760 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:39:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:39:55 +0000 Subject: [MERGED] libosmocore[master]: bssgp_fc_test: do not use real time In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: bssgp_fc_test: do not use real time ...................................................................... bssgp_fc_test: do not use real time Employ osmo_gettimeofday_override_* to take bssgp_fc_test off real time. The jenkins build slave often failed the test based on sporadic time delays due to server load and randomly rejected good patches. This patch ends that. Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9 Related: OS#1809 --- M tests/gb/bssgp_fc_test.c 1 file changed, 8 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/gb/bssgp_fc_test.c b/tests/gb/bssgp_fc_test.c index d77f141..27d8fcc 100644 --- a/tests/gb/bssgp_fc_test.c +++ b/tests/gb/bssgp_fc_test.c @@ -70,6 +70,12 @@ struct bssgp_flow_control *fc = talloc_zero(NULL, struct bssgp_flow_control); int i; + osmo_gettimeofday_override_time = (struct timeval){ + .tv_sec = 1486385000, + .tv_usec = 423423, + }; + osmo_gettimeofday_override = true; + bssgp_fc_init(fc, bucket_size_max, bucket_leak_rate, max_queue_depth, fc_out_cb); @@ -83,7 +89,8 @@ } while (1) { - usleep(100000); + osmo_gettimeofday_override_add(0, 100000); + osmo_timers_check(); osmo_timers_prepare(); osmo_timers_update(); -- To view, visit https://gerrit.osmocom.org/1760 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:40:00 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:40:00 +0000 Subject: openbsc[master]: Attempt to fix nightly builds In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1759 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:40:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:40:02 +0000 Subject: [MERGED] openbsc[master]: Attempt to fix nightly builds In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Attempt to fix nightly builds ...................................................................... Attempt to fix nightly builds The fix introduced in dac5867af5ff90d4beb70fc30a5743f60f159e3a did not work because autotools in our OE are too old. Use alternative way to include custom m4 macros to fix it. Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464 --- M openbsc/Makefile.am M openbsc/configure.ac 2 files changed, 3 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/Makefile.am b/openbsc/Makefile.am index f7eda56..31a54ea 100644 --- a/openbsc/Makefile.am +++ b/openbsc/Makefile.am @@ -1,5 +1,8 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 +## FIXME: automake >= 1.13 or autoconf >= 2.70 provide better suited AC_CONFIG_MACRO_DIRS for configure.ac +## remove line below when OE toolchain is updated to version which include those +ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = \ $(all_includes) \ -I$(top_srcdir)/include \ diff --git a/openbsc/configure.ac b/openbsc/configure.ac index 6d373a5..7e244bc 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -9,9 +9,6 @@ AM_INIT_AUTOMAKE([dist-bzip2]) AC_CONFIG_TESTDIR(tests) -dnl FIXME: Remove this once we do not need local macro copies anymore (after upgrade to newer OE?) -AC_CONFIG_MACRO_DIRS([m4]) - dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -- To view, visit https://gerrit.osmocom.org/1759 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:40:14 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:40:14 +0000 Subject: osmo-gsm-manuals[master]: Sync DTX FSM with OsmoBTS code In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1758 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I050a07db99bc0038cfd2a9646a450f714653d804 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:40:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:40:16 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: Sync DTX FSM with OsmoBTS code In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Sync DTX FSM with OsmoBTS code ...................................................................... Sync DTX FSM with OsmoBTS code Change-Id: I050a07db99bc0038cfd2a9646a450f714653d804 --- M OsmoBTS/dtx.dot M OsmoBTS/rtp-amr.adoc 2 files changed, 70 insertions(+), 35 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/OsmoBTS/dtx.dot b/OsmoBTS/dtx.dot index 1c60ee7..b9f0b5f 100644 --- a/OsmoBTS/dtx.dot +++ b/OsmoBTS/dtx.dot @@ -1,43 +1,68 @@ digraph dtx_dl_amr_fsm { - node [shape = doublecircle] ST_VOICE ST_FACCH_V ST_FACCH ST_SID_U + node [shape = doublecircle] ST_VOICE ST_FACCH ST_U_NOINH node [shape = circle] // default state for non-DTX and DTX when SPEECH is in progress ST_VOICE -> ST_SID_F1 [ label = "E_SID_F" ] - ST_VOICE -> ST_SID_F1 [ label = "E_SID_U" ] + ST_VOICE -> ST_F1_INH_V [ label = "E_INHIB" ] + ST_VOICE -> ST_U_NOINH [ label = "E_SID_U" ] ST_VOICE -> ST_VOICE [ label = "E_VOICE" ] ST_VOICE -> ST_VOICE [ label = "E_FACCH" ] // SID-FIRST or SID-FIRST-P1 in case of AMR HR: start of silence period (might be interrupted in case of AMR HR) ST_SID_F1 -> ST_SID_F1 [ label = "E_SID_F" ] - ST_SID_F1 -> ST_SID_U [ label = "E_SID_U" ] - ST_SID_F1 -> ST_VOICE [ label = "E_VOICE" ] - ST_SID_F1 -> ST_ONSET_F [ label = "E_FACCH" ] - ST_SID_F1 -> ST_SID_F2 [ label = "E_COMPL" ] - ST_SID_F1 -> ST_F1_INH [ label = "E_INHIB" ] + ST_SID_F1 -> ST_U_NOINH [ label = "E_SID_U" ] + ST_SID_F1 -> ST_F1_INH_F [ label = "E_FACCH" ] + ST_SID_F1 -> ST_SID_F2 [ label = "E_FIRST" ] ST_SID_F1 -> ST_ONSET_V [ label = "E_ONSET" ] // SID-FIRST P2 (only for AMR HR): actual start of silence period in case of AMR HR - ST_SID_F2 -> ST_SID_U [ label = "E_SID_U" ] - ST_SID_F2 -> ST_VOICE [ label = "E_VOICE" ] + ST_SID_F2 -> ST_U_NOINH [ label = "E_COMPL" ] ST_SID_F2 -> ST_ONSET_F [ label = "E_FACCH" ] ST_SID_F2 -> ST_ONSET_V [ label = "E_ONSET" ] - // SID-FIRST Inhibited: incoming SPEECH or FACCH (only for AMR HR) - ST_F1_INH -> ST_VOICE [ label = "E_VOICE" ] - ST_F1_INH -> ST_FACCH_V [ label = "E_FACCH" ] + // SID-FIRST Inhibited: incoming SPEECH (only for AMR HR) + ST_F1_INH_V -> ST_F1_INH_V_REC [ label = "E_COMPL" ] - // SID-UPDATE Inhibited: incoming SPEECH or FACCH (only for AMR HR) - ST_U_INH -> ST_VOICE [ label = "E_VOICE" ] - ST_U_INH -> ST_FACCH [ label = "E_FACCH" ] + // SID-FIRST Inhibited: incoming FACCH frame (only for AMR HR) + ST_F1_INH_F -> ST_F1_INH_F_REC [ label = "E_COMPL" ] - // Silence period with periodic comfort noise data updates - ST_SID_U -> ST_ONSET_F [ label = "E_FACCH" ] + // SID-UPDATE Inhibited: incoming SPEECH (only for AMR HR) + ST_U_INH_V -> ST_U_INH_V_REC [ label = "E_COMPL" ] + + // SID-UPDATE Inhibited: incoming FACCH frame (only for AMR HR) + ST_U_INH_F -> ST_U_INH_F_REC [ label = "E_COMPL" ] + + // Silence period with periodic comfort noise data updates (no Inhibition) + ST_U_NOINH -> ST_ONSET_F [ label = "E_FACCH" ] + ST_U_NOINH -> ST_VOICE [ label = "E_VOICE" ] + ST_U_NOINH -> ST_U_NOINH [ label = "E_SID_U" ] + ST_U_NOINH -> ST_U_NOINH [ label = "E_SID_F" ] + ST_U_NOINH -> ST_ONSET_V [ label = "E_ONSET" ] + ST_U_NOINH -> ST_SID_U [ label = "E_COMPL" ] + + // SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_F1_INH_V_REC -> ST_VOICE [ label = "E_COMPL" ] + ST_F1_INH_V_REC -> ST_VOICE [ label = "E_VOICE" ] + + // SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_F1_INH_F_REC -> ST_FACCH [ label = "E_COMPL" ] + ST_F1_INH_F_REC -> ST_FACCH [ label = "E_VOICE" ] + + // SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_U_INH_V_REC -> ST_VOICE [ label = "E_COMPL" ] + ST_U_INH_V_REC -> ST_VOICE [ label = "E_VOICE" ] + + // SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it + ST_U_INH_F_REC -> ST_FACCH [ label = "E_COMPL" ] + ST_U_INH_F_REC -> ST_FACCH [ label = "E_VOICE" ] + + // Silence period with periodic comfort noise data updates (can be inhibited) + ST_SID_U -> ST_U_INH_F [ label = "E_FACCH" ] ST_SID_U -> ST_VOICE [ label = "E_VOICE" ] - ST_SID_U -> ST_U_INH [ label = "E_INHIB" ] - ST_SID_U -> ST_SID_U [ label = "E_SID_U" ] - ST_SID_U -> ST_SID_U [ label = "E_SID_F" ] - ST_SID_U -> ST_ONSET_V [ label = "E_ONSET" ] + ST_SID_U -> ST_U_INH_V [ label = "E_INHIB" ] + ST_SID_U -> ST_U_NOINH [ label = "E_SID_U" ] + ST_SID_U -> ST_U_NOINH [ label = "E_SID_F" ] // ONSET - end of silent period due to incoming SPEECH frame ST_ONSET_V -> ST_ONSET_V_REC [ label = "E_COMPL" ] @@ -45,21 +70,16 @@ // ONSET - end of silent period due to incoming FACCH frame ST_ONSET_F -> ST_ONSET_F_REC [ label = "E_COMPL" ] - // ONSET recursion in progress: ONSET itself was already sent, now have to send the voice that caused it - ST_ONSET_V_REC -> ST_VOICE [ label = "E_COMPL" ] - // ONSET recursion in progress: ONSET itself was already sent, now have to send the data that caused it ST_ONSET_F_REC -> ST_FACCH [ label = "E_COMPL" ] - // FACCH sending state: SPEECH was observed before so once we're done FSM should get back to VOICE state - ST_FACCH_V -> ST_FACCH_V [ label = "E_FACCH" ] - ST_FACCH_V -> ST_VOICE [ label = "E_VOICE" ] - ST_FACCH_V -> ST_VOICE [ label = "E_SID_U" ] - ST_FACCH_V -> ST_SID_F1 [ label = "E_SID_F" ] + // ONSET recursion in progress: ONSET itself was already sent, now have to send the voice that caused it + ST_ONSET_V_REC -> ST_VOICE [ label = "E_COMPL" ] - // FACCH sending state: no SPEECH was observed before so once we're done FSM should get back to silent period via SID-FIRST - ST_FACCH -> ST_FACCH [ label = "E_FACCH" ] + // FACCH sending state ST_FACCH -> ST_VOICE [ label = "E_VOICE" ] - ST_FACCH -> ST_SID_F1 [ label = "E_SID_U" ] - ST_FACCH -> ST_SID_F1 [ label = "E_SID_F" ] + ST_FACCH -> ST_FACCH [ label = "E_FACCH" ] + ST_FACCH -> ST_FACCH [ label = "E_SID_U" ] + ST_FACCH -> ST_FACCH [ label = "E_SID_F" ] + ST_FACCH -> ST_SID_F1 [ label = "E_COMPL" ] } diff --git a/OsmoBTS/rtp-amr.adoc b/OsmoBTS/rtp-amr.adoc index f7eda11..982a5af 100644 --- a/OsmoBTS/rtp-amr.adoc +++ b/OsmoBTS/rtp-amr.adoc @@ -1322,10 +1322,25 @@ include::dtx.dot[] ---- -The idea is that each state corresponds to the particular message type which have to be send to L1 while state transition happens on incoming events like FACCH or Voice frames. There are 3 different classes of of events driving this FSM: +The idea is that each state corresponds to the particular message type which have to be send to L1 next while state transition happens on incoming events like FACCH or Voice frames. There are 3 different classes of of events driving this FSM: * Voice frame types: E_VOICE, E_SID_U, E_SID_F * Incoming FACCH: E_FACCH * Internal: E_ONSET, E_INHIB, E_COMPL -They represent different types of incoming RTP frames (Voice, SID UPDATE and SID FIRST correspondingly), incoming FACCH events or important events internal to DTX operations. The latter are Onset (interruption of silence period), Inhibition (of currently transmitted SID FIRST or UPDATE) and Completion (of silence initiation). \ No newline at end of file +They represent different types of incoming RTP frames (Voice, SID UPDATE and SID FIRST correspondingly), incoming FACCH events or important events internal to DTX operations. The latter are Onset (interruption of silence period), Inhibition (of currently transmitted SID FIRST or UPDATE) and Completion (of silence initiation). + +The double-circled states are "stationary" meaning that FSM can stay for longer periods in them. Other states are "transient" - the FSM have to switch away during next step. In practice this is implemented using E_COMPL signal which is issued in corresponding RTS handler or internal function (in case of SID First P1 -> P2 transition). + +The FSM states are grouped as follows: + +* ST_VOICE: talkspurt, normal voice transmission +* ST_FACCH: transmission of higher-priority FACCH frame, interrupting current DTX state +* ST_ONSET*: handling of Onset event (interruption of silence period) +* ST_SID_F*: silence initiation +* ST_*_REC: sending of 2nd event for L1 during the same FN +* ST_*_INH: handling of Inhibition event (interruption of transmission of previous event) + +The latter are specific to AMR HR where transmission of particular message by L1 takes longer so it can be aborted due to another incoming event. Note that for AMR FR only subset of this FSM is active (ST_SID_F2 and *INH states are never reached). This is implemented by signal emitting functions. + +Note that the FSM states describe only the situation when we got to send something to L1, the transmission of Empty frames suppressing the actual radio transmission is done by other code. -- To view, visit https://gerrit.osmocom.org/1758 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I050a07db99bc0038cfd2a9646a450f714653d804 Gerrit-PatchSet: 2 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:07 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:07 +0000 Subject: [MERGED] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: vty tests: more attempts to resolve 'Broken Pipe' error ...................................................................... vty tests: more attempts to resolve 'Broken Pipe' error Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 --- M openbsc/tests/vty_test_runner.py 1 file changed, 39 insertions(+), 7 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 608aef4..f434360 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -19,6 +19,7 @@ import time import unittest import socket +import subprocess import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil @@ -781,10 +782,10 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port) - b0 = nat_bsc_sock_test(0, "lol") - b1 = nat_bsc_sock_test(1, "xyu") - b2 = nat_bsc_sock_test(5, "key") + msc = nat_msc_test(self, ip, port, verbose=True) + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) self.assertTrue(3 == nat_bsc_num_con(self)) @@ -1237,6 +1238,19 @@ " connected yet: %r %r" % (ip, port)) return conn +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def checkxxx(): + cmd('cat /proc/net/tcp'); + cmd('ps xua | grep osmo'); + def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1256,11 +1270,15 @@ if (verbose): print "\tBSC <- NAT: ", s -def ipa_handle_resp(x, tk, verbose = False): +def ipa_handle_resp(x, tk, verbose = False, proc=None): s = data2str(x.recv(38)) if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1269,6 +1287,8 @@ break except: print "\tfailed sending IPA identity at", time.strftime("%T") + if proc: + print "\tproc.poll() = %r" % proc.poll() if retries < 1: print "\tgiving up" raise @@ -1281,17 +1301,29 @@ def nat_bsc_num_con(x): return len(x.vty.command("show bsc connections").split('\n')) -def nat_bsc_sock_test(nr, tk, verbose = False): +def nat_bsc_sock_test(nr, tk, verbose = False, proc=None): bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bsc.bind(('127.0.0.1', 0)) bsc.connect(('127.0.0.1', 5000)) if (verbose): print "BSC%d " %nr print "\tconnected to %s:%d" % bsc.getpeername() + if proc: + print "\tproc.poll() = %r" % proc.poll() + print "\tproc.pid = %r" % proc.pid + checkxxx() ipa_handle_small(bsc, verbose) - ipa_handle_resp(bsc, tk, verbose) + checkxxx() + ipa_handle_resp(bsc, tk, verbose, proc=proc) + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() bsc.recv(27) # MGCP msg + if proc: + print "\tproc.poll() = %r" % proc.poll() + checkxxx() ipa_handle_small(bsc, verbose) + checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846 Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:12 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (3) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1744 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:17 +0000 Subject: [MERGED] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (3) In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: vty tests: more attempts to resolve 'Broken Pipe' error (3) ...................................................................... vty tests: more attempts to resolve 'Broken Pipe' error (3) Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c --- 0 files changed, 0 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified -- To view, visit https://gerrit.osmocom.org/1744 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:32 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:32 +0000 Subject: [MERGED] openbsc[master]: gprs/gprs_mm: add value_strings for PMM & MM states In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gprs/gprs_mm: add value_strings for PMM & MM states ...................................................................... gprs/gprs_mm: add value_strings for PMM & MM states Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be --- M openbsc/src/gprs/gprs_gmm.c 1 file changed, 15 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index db27276..1026474 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -105,6 +105,15 @@ }, }; +static const struct value_string gprs_pmm_state_names[] = { + { PMM_DETACHED, "PMM DETACH" }, + { PMM_CONNECTED, "PMM CONNECTED" }, + { PMM_IDLE, "PMM IDLE" }, + { MM_IDLE, "MM IDLE" }, + { MM_READY, "MM READY" }, + { MM_STANDBY, "MM STANDBY" }, +}; + static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx); static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx) @@ -125,7 +134,9 @@ if (ctx->pmm_state == state) return; - LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %i to %i\n", ctx->pmm_state, state); + LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %s to %s\n", + get_value_string(gprs_pmm_state_names, ctx->pmm_state), + get_value_string(gprs_pmm_state_names, state)); switch (state) { case PMM_IDLE: @@ -149,7 +160,9 @@ if (ctx->pmm_state == state) return; - LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %i to %i\n", ctx->pmm_state, state); + LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %s to %s\n", + get_value_string(gprs_pmm_state_names, ctx->pmm_state), + get_value_string(gprs_pmm_state_names, state)); ctx->pmm_state = state; } -- To view, visit https://gerrit.osmocom.org/1756 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:34 +0000 Subject: [MERGED] openbsc[master]: gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE ...................................................................... gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE Previous the state was only set in Iu mode. Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df --- M openbsc/src/gprs/gprs_sgsn.c 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 6d49e19..260e032 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -223,6 +223,7 @@ ctx->ran_type = MM_CTX_T_GERAN_Gb; ctx->gb.tlli = tlli; ctx->gmm_state = GMM_DEREGISTERED; + ctx->pmm_state = MM_IDLE; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ciph_algo = sgsn->cfg.cipher; LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n", -- To view, visit https://gerrit.osmocom.org/1757 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:34 +0000 Subject: [MERGED] openbsc[master]: gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb() In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb() ...................................................................... gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb() Postfix the ran type to clarify the purpose. Because of the new support of the Iu ran type, there are 2 functions to allocate a mm ctx. For Iu it's sgsn_mm_ctx_alloc_iu(). For gb it should be named in the same way. Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95 --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/tests/sgsn/sgsn_test.c 4 files changed, 6 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index f50de11..2cc5b0c 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -244,7 +244,7 @@ const struct gprs_ra_id *raid); /* Allocate a new SGSN MM context */ -struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli, +struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli, const struct gprs_ra_id *raid); struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx); diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 9ac1077..db27276 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -1146,7 +1146,7 @@ if (msg->dst) ctx = sgsn_mm_ctx_alloc_iu(msg->dst); else - ctx = sgsn_mm_ctx_alloc(0, &ra_id); + ctx = sgsn_mm_ctx_alloc_gb(0, &ra_id); if (!ctx) { reject_cause = GMM_CAUSE_NET_FAIL; goto rejected; @@ -1172,7 +1172,7 @@ if (msg->dst) ctx = sgsn_mm_ctx_alloc_iu(msg->dst); else - ctx = sgsn_mm_ctx_alloc(msgb_tlli(msg), &ra_id); + ctx = sgsn_mm_ctx_alloc_gb(msgb_tlli(msg), &ra_id); ctx->p_tmsi = tmsi; } if (ctx->ran_type == MM_CTX_T_GERAN_Gb) { diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 3fb1104..6d49e19 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -209,8 +209,8 @@ } -/* Allocate a new SGSN MM context */ -struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli, +/* Allocate a new SGSN MM context for GERAN_Gb */ +struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli, const struct gprs_ra_id *raid) { struct sgsn_mm_ctx *ctx; diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index bcda9a0..0aa142f 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -190,7 +190,7 @@ int old_count = count(gprs_llme_list()); lle = gprs_lle_get_or_create(tlli, 3); - ctx = sgsn_mm_ctx_alloc(tlli, raid); + ctx = sgsn_mm_ctx_alloc_gb(tlli, raid); ctx->gmm_state = GMM_REGISTERED_NORMAL; ctx->gb.llme = lle->llme; -- To view, visit https://gerrit.osmocom.org/1755 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:35 +0000 Subject: [MERGED] openbsc[master]: gprs/sgsn: rename gprs->mm_state -> gmm_state In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gprs/sgsn: rename gprs->mm_state -> gmm_state ...................................................................... gprs/sgsn: rename gprs->mm_state -> gmm_state GMM is the right term. MM state is already occupied. Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/src/gprs/sgsn_libgtp.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c 6 files changed, 81 insertions(+), 66 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index dc165d3..f50de11 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -36,9 +36,9 @@ PMM_DETACHED, PMM_CONNECTED, PMM_IDLE, - MM_IDLE = PMM_DETACHED, - MM_READY = PMM_CONNECTED, - MM_STANDBY = PMM_IDLE, + MM_IDLE, + MM_READY, + MM_STANDBY, }; enum gprs_mm_ctr { @@ -126,7 +126,7 @@ enum sgsn_ran_type ran_type; char imsi[GSM23003_IMSI_MAX_DIGITS+1]; - enum gprs_gmm_state mm_state; + enum gprs_gmm_state gmm_state; enum gprs_pmm_state pmm_state; /* Iu: page when in PMM-IDLE mode */ uint32_t p_tmsi; uint32_t p_tmsi_old; /* old P-TMSI before new is confirmed */ diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 6fde757..9ac1077 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -119,24 +119,37 @@ void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state) { + if (ctx->ran_type != MM_CTX_T_UTRAN_Iu) + return; + if (ctx->pmm_state == state) return; LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %i to %i\n", ctx->pmm_state, state); - if (ctx->ran_type == MM_CTX_T_UTRAN_Iu) - { - switch (state) { - case PMM_IDLE: - /* TODO: start RA Upd timer */ - mmctx_change_gtpu_endpoints_to_sgsn(ctx); - break; - case PMM_CONNECTED: - break; - default: - break; - } + switch (state) { + case PMM_IDLE: + /* TODO: start RA Upd timer */ + mmctx_change_gtpu_endpoints_to_sgsn(ctx); + break; + case PMM_CONNECTED: + break; + default: + break; } + + ctx->pmm_state = state; +} + +void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state) +{ + if (ctx->ran_type != MM_CTX_T_GERAN_Gb) + return; + + if (ctx->pmm_state == state) + return; + + LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %i to %i\n", ctx->pmm_state, state); ctx->pmm_state = state; } @@ -274,9 +287,9 @@ LOGMMCTXP(LOGL_INFO, ctx, "Cleaning MM context due to %s\n", log_text); /* Mark MM state as deregistered */ - ctx->mm_state = GMM_DEREGISTERED; - + ctx->gmm_state = GMM_DEREGISTERED; mmctx_set_pmm_state(ctx, PMM_DETACHED); + mmctx_set_pmm_state(ctx, MM_IDLE); sgsn_mm_ctx_cleanup_free(ctx); } @@ -882,7 +895,7 @@ memset(&sig_data, 0, sizeof(sig_data)); sig_data.mm = mmctx; osmo_signal_dispatch(SS_SGSN, S_SGSN_ATTACH, &sig_data); - ctx->mm_state = GMM_REGISTERED_NORMAL; + ctx->gmm_state = GMM_REGISTERED_NORMAL; #endif return gsm48_tx_gmm_att_ack(ctx); @@ -921,7 +934,7 @@ void gsm0408_gprs_access_granted(struct sgsn_mm_ctx *ctx) { - switch (ctx->mm_state) { + switch (ctx->gmm_state) { case GMM_COMMON_PROC_INIT: LOGMMCTXP(LOGL_NOTICE, ctx, "Authorized, continuing procedure, IMSI=%s\n", @@ -941,7 +954,7 @@ if (gmm_cause == SGSN_ERROR_CAUSE_NONE) gmm_cause = GMM_CAUSE_GPRS_NOTALLOWED; - switch (ctx->mm_state) { + switch (ctx->gmm_state) { case GMM_COMMON_PROC_INIT: LOGMMCTXP(LOGL_NOTICE, ctx, "Not authorized, rejecting ATTACH REQUEST " @@ -1225,11 +1238,11 @@ #ifdef PTMSI_ALLOC /* Allocate a new P-TMSI (+ P-TMSI signature) and update TLLI */ /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */ - if (ctx->mm_state != GMM_COMMON_PROC_INIT) { + if (ctx->gmm_state != GMM_COMMON_PROC_INIT) { ctx->p_tmsi_old = ctx->p_tmsi; ctx->p_tmsi = sgsn_alloc_ptmsi(); } - ctx->mm_state = GMM_COMMON_PROC_INIT; + ctx->gmm_state = GMM_COMMON_PROC_INIT; #endif if (ctx->ran_type == MM_CTX_T_GERAN_Gb) { @@ -1500,10 +1513,10 @@ mmctx->ra.mcc, mmctx->ra.mnc, mmctx->ra.lac, mmctx->ra.rac); - mmctx->mm_state = GMM_COMMON_PROC_INIT; + mmctx->gmm_state = GMM_COMMON_PROC_INIT; } } else if (!gprs_ra_id_equals(&mmctx->ra, &old_ra_id) || - mmctx->mm_state == GMM_DEREGISTERED) + mmctx->gmm_state == GMM_DEREGISTERED) { /* We cannot use the mmctx */ LOGMMCTXP(LOGL_INFO, mmctx, @@ -1545,7 +1558,7 @@ #ifdef PTMSI_ALLOC /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */ - if (mmctx->mm_state != GMM_COMMON_PROC_INIT) { + if (mmctx->gmm_state != GMM_COMMON_PROC_INIT) { mmctx->p_tmsi_old = mmctx->p_tmsi; mmctx->p_tmsi = sgsn_alloc_ptmsi(); } @@ -1553,10 +1566,10 @@ mmctx->t3350_mode = GMM_T3350_MODE_RAU; mmctx_timer_start(mmctx, 3350, sgsn->cfg.timers.T3350); - mmctx->mm_state = GMM_COMMON_PROC_INIT; + mmctx->gmm_state = GMM_COMMON_PROC_INIT; #else /* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */ - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; memset(&sig_data, 0, sizeof(sig_data)); sig_data.mm = mmctx; @@ -1679,7 +1692,7 @@ goto rejected; } - ctx->mm_state = GMM_COMMON_PROC_INIT; + ctx->gmm_state = GMM_COMMON_PROC_INIT; ctx->iu.service.type = service_type; @@ -1831,8 +1844,9 @@ gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new); } - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; mmctx_set_pmm_state(mmctx, PMM_CONNECTED); + mmctx_set_mm_state(mmctx, MM_READY); rc = 0; memset(&sig_data, 0, sizeof(sig_data)); @@ -1854,8 +1868,9 @@ gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new); } - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; mmctx_set_pmm_state(mmctx, PMM_CONNECTED); + mmctx_set_mm_state(mmctx, MM_READY); rc = 0; memset(&sig_data, 0, sizeof(sig_data)); @@ -2682,15 +2697,15 @@ return -EINVAL; } - if (mmctx->mm_state != GMM_REGISTERED_NORMAL && - mmctx->mm_state != GMM_REGISTERED_SUSPENDED) { + if (mmctx->gmm_state != GMM_REGISTERED_NORMAL && + mmctx->gmm_state != GMM_REGISTERED_SUSPENDED) { LOGMMCTXP(LOGL_NOTICE, mmctx, "SUSPEND request while state " "!= REGISTERED (TLLI=%08x)\n", tlli); return -EINVAL; } /* Transition from REGISTERED_NORMAL to REGISTERED_SUSPENDED */ - mmctx->mm_state = GMM_REGISTERED_SUSPENDED; + mmctx->gmm_state = GMM_REGISTERED_SUSPENDED; return 0; } @@ -2708,8 +2723,8 @@ return -EINVAL; } - if (mmctx->mm_state != GMM_REGISTERED_NORMAL && - mmctx->mm_state != GMM_REGISTERED_SUSPENDED) { + if (mmctx->gmm_state != GMM_REGISTERED_NORMAL && + mmctx->gmm_state != GMM_REGISTERED_SUSPENDED) { LOGMMCTXP(LOGL_NOTICE, mmctx, "RESUME request while state " "!= SUSPENDED (TLLI=%08x)\n", tlli); /* FIXME: should we not simply ignore it? */ @@ -2717,7 +2732,7 @@ } /* Transition from SUSPENDED to NORMAL */ - mmctx->mm_state = GMM_REGISTERED_NORMAL; + mmctx->gmm_state = GMM_REGISTERED_NORMAL; return 0; } diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index e85e1a9..3fb1104 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -222,7 +222,7 @@ memcpy(&ctx->ra, raid, sizeof(ctx->ra)); ctx->ran_type = MM_CTX_T_GERAN_Gb; ctx->gb.tlli = tlli; - ctx->mm_state = GMM_DEREGISTERED; + ctx->gmm_state = GMM_DEREGISTERED; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ciph_algo = sgsn->cfg.cipher; LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n", @@ -247,7 +247,7 @@ ctx->ran_type = MM_CTX_T_UTRAN_Iu; ctx->iu.ue_ctx = uectx; ctx->iu.new_key = 1; - ctx->mm_state = GMM_DEREGISTERED; + ctx->gmm_state = GMM_DEREGISTERED; ctx->pmm_state = PMM_DETACHED; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0); @@ -658,7 +658,7 @@ static void drop_one_pdp(struct sgsn_pdp_ctx *pdp) { - if (pdp->mm->mm_state == GMM_REGISTERED_NORMAL) + if (pdp->mm->gmm_state == GMM_REGISTERED_NORMAL) gsm48_tx_gsm_deact_pdp_req(pdp, GSM_CAUSE_NET_FAIL); else { /* FIXME: GPRS paging in case MS is SUSPENDED */ diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 072b9ba..062de44 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -676,7 +676,7 @@ msgb_bvci(msg) = mm->gb.bvci; msgb_nsei(msg) = mm->gb.nsei; - switch (mm->mm_state) { + switch (mm->gmm_state) { case GMM_REGISTERED_SUSPENDED: /* initiate PS PAGING procedure */ memset(&pinfo, 0, sizeof(pinfo)); @@ -695,7 +695,7 @@ break; default: LOGP(DGPRS, LOGL_ERROR, "GTP DATA IND for TLLI %08X in state " - "%u\n", mm->gb.tlli, mm->mm_state); + "%u\n", mm->gb.tlli, mm->gmm_state); msgb_free(msg); return -1; } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 246867d..85e4e91 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -485,7 +485,7 @@ pfx, mm->msisdn, mm->gb.tlli, mm->hlr, VTY_NEWLINE); vty_out(vty, "%s MM State: %s, Routeing Area: %u-%u-%u-%u, " "Cell ID: %u%s", pfx, - get_value_string(gprs_mm_st_strs, mm->mm_state), + get_value_string(gprs_mm_st_strs, mm->gmm_state), mm->ra.mcc, mm->ra.mnc, mm->ra.lac, mm->ra.rac, mm->gb.cell_id, VTY_NEWLINE); diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index e1fd2e7..bcda9a0 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -191,7 +191,7 @@ lle = gprs_lle_get_or_create(tlli, 3); ctx = sgsn_mm_ctx_alloc(tlli, raid); - ctx->mm_state = GMM_REGISTERED_NORMAL; + ctx->gmm_state = GMM_REGISTERED_NORMAL; ctx->gb.llme = lle->llme; ictx = sgsn_mm_ctx_by_tlli(tlli, raid); @@ -979,7 +979,7 @@ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an identity request (IMEI) */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -999,7 +999,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); retry_attach_req: @@ -1039,7 +1039,7 @@ send_0408_message(ctx->gb.llme, local_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); @@ -1567,7 +1567,7 @@ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an identity request (IMEI) */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -1587,7 +1587,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an attach accept/reject */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -1601,7 +1601,7 @@ send_0408_message(ctx->gb.llme, foreign_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); @@ -1715,7 +1715,7 @@ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); ptmsi1 = ctx->p_tmsi; @@ -1732,7 +1732,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); /* we expect an attach accept */ @@ -1747,7 +1747,7 @@ /* the allocated P-TMSI should be the same */ ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == old_ptmsi); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -1764,7 +1764,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -1777,7 +1777,7 @@ /* we expect an RA update accept */ OSMO_ASSERT(sgsn_tx_counter == 1); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); OSMO_ASSERT(ctx->p_tmsi != ptmsi1); @@ -1792,7 +1792,7 @@ received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx); OSMO_ASSERT(received_ptmsi == ptmsi2); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi == ptmsi2); @@ -1804,7 +1804,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi2); @@ -1940,7 +1940,7 @@ ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid1); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); /* we expect an identity request (IMEI) */ @@ -1956,7 +1956,7 @@ * authorization */ OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(ms_tlli, &raid1)); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); /* we expect an attach accept */ OSMO_ASSERT(sgsn_tx_counter == 1); @@ -1975,7 +1975,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -1990,7 +1990,7 @@ OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK); // OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); OSMO_ASSERT(ctx->p_tmsi != ptmsi1); @@ -2007,7 +2007,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); OSMO_ASSERT(ctx->gb.tlli == ms_tlli); @@ -2052,7 +2052,7 @@ ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2); OSMO_ASSERT(ctx != NULL); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); /* we expect an attach accept */ @@ -2075,7 +2075,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); @@ -2089,7 +2089,7 @@ OSMO_ASSERT(sgsn_tx_counter == 1); OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK); - OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); + OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT); OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1); OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI); OSMO_ASSERT(ctx->p_tmsi != ptmsi1); @@ -2106,7 +2106,7 @@ /* we don't expect a response */ OSMO_ASSERT(sgsn_tx_counter == 0); - OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); + OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); OSMO_ASSERT(ctx->gb.tlli == ms_tlli); -- To view, visit https://gerrit.osmocom.org/1754 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 00:41:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 00:41:48 +0000 Subject: [MERGED] openbsc[master]: gprs/sgsn_vty: fix typo in comment In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gprs/sgsn_vty: fix typo in comment ...................................................................... gprs/sgsn_vty: fix typo in comment Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b --- M openbsc/src/gprs/sgsn_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 85e4e91..3ce054f 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -63,7 +63,7 @@ #define GSM0408_T3360_SECS 6 /* waiting for AUTH/CIPH RESP */ #define GSM0408_T3370_SECS 6 /* waiting for ID RESP */ -/* Section 11.2.2 / Table 11.4a MM timers netwokr side */ +/* Section 11.2.2 / Table 11.4a MM timers network side */ #define GSM0408_T3313_SECS 30 /* waiting for paging response */ #define GSM0408_T3314_SECS 44 /* force to STBY on expiry, Ready timer */ #define GSM0408_T3316_SECS 44 -- To view, visit https://gerrit.osmocom.org/1748 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 10:50:54 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 7 Feb 2017 10:50:54 +0000 Subject: [PATCH] libosmo-netif[master]: Fix potential NULL dereference In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1639 to look at the new patch set (#2). Fix potential NULL dereference Change-Id: I5baf369dbf3948565614476980a32be59abaf42a --- M src/osmux.c 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/39/1639/2 diff --git a/src/osmux.c b/src/osmux.c index 0bee9cc..913d68f 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -394,7 +394,8 @@ LOGP(DLMIB, LOGL_DEBUG, "invoking delivery function\n"); #endif batch_msg = osmux_build_batch(batch, h->batch_size, h->batch_factor); - + if (!batch_msg) + return; h->stats.output_osmux_msgs++; h->stats.output_osmux_bytes += batch_msg->len; -- To view, visit https://gerrit.osmocom.org/1639 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5baf369dbf3948565614476980a32be59abaf42a Gerrit-PatchSet: 2 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 7 13:53:51 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 7 Feb 2017 13:53:51 +0000 Subject: [MERGED] libosmocore[master]: select: add functionality to check socket state In-Reply-To: References: Message-ID: dexter has submitted this change and it was merged. Change subject: select: add functionality to check socket state ...................................................................... select: add functionality to check socket state osmo_fd_register() is used to register socket file descriptors, after registering a socket, there is no way to test if the socket is still registered or actually registered at all. This commit adds a new function osmo_fd_register_check() that can be used to check in advance, if the socket fd is registered, before performing further operations. Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 --- M include/osmocom/core/select.h M src/select.c 2 files changed, 26 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index 2753637..c2b51a4 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -1,6 +1,7 @@ #pragma once #include +#include /*! \defgroup select Select loop abstraction * @{ @@ -35,6 +36,7 @@ unsigned int priv_nr; }; +bool osmo_fd_is_registered(struct osmo_fd *fd); int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); diff --git a/src/select.c b/src/select.c index da27368..ab0734e 100644 --- a/src/select.c +++ b/src/select.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,23 @@ static int maxfd = 0; static LLIST_HEAD(osmo_fds); static int unregistered_count; + + +/*! \brief Check if a file descriptor is already registered + * \param[in] fd osmocom file descriptor to be checked + * \returns true if registered; otherwise false + */ +bool osmo_fd_is_registered(struct osmo_fd *fd) +{ + struct osmo_fd *entry; + llist_for_each_entry(entry, &osmo_fds, list) { + if (entry == fd) { + return true; + } + } + + return false; +} /*! \brief Register a new file descriptor with select loop abstraction * \param[in] fd osmocom file descriptor to be registered @@ -76,12 +94,9 @@ maxfd = fd->fd; #ifdef BSC_FD_CHECK - struct osmo_fd *entry; - llist_for_each_entry(entry, &osmo_fds, list) { - if (entry == fd) { - fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); - return 0; - } + if (osmo_fd_is_registered(fd)) { + fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); + return 0; } #endif @@ -95,6 +110,9 @@ */ void osmo_fd_unregister(struct osmo_fd *fd) { + /* Note: when fd is inside the osmo_fds list (not registered before) + * this function will crash! If in doubt, check file descriptor with + * osmo_fd_is_registered() */ unregistered_count++; llist_del(&fd->list); } -- To view, visit https://gerrit.osmocom.org/1725 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter From gerrit-no-reply at lists.osmocom.org Tue Feb 7 13:54:00 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 7 Feb 2017 13:54:00 +0000 Subject: [MERGED] libosmocore[master]: lapd_core: fix program flow In-Reply-To: References: Message-ID: dexter has submitted this change and it was merged. Change subject: lapd_core: fix program flow ...................................................................... lapd_core: fix program flow when the lapd core is in state LAPD_STATE_SABM_SENT, and the retransmission counter exceeds (link down) lapd_t200_cb() will send an RELASE_INDICATION and an MDL_ERROR_INDICATION to L3. This action is done before the state is processed. This seems to be no problem with standard retransmission counts (n200), but may cause timing problems that lead to deadlock states when custom timer configurations are in use. (Ericsson RBS). This commit moves the functions calls for sending the indications mentioned above to the very end of the if branch to relax the timing again. (See lapd_t200_cb()) Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a --- M src/gsm/lapd_core.c 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 84b1828..5af82aa 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -556,11 +556,6 @@ case LAPD_STATE_SABM_SENT: /* 5.4.1.3 */ if (dl->retrans_ctr + 1 >= dl->n200_est_rel + 1) { - /* send RELEASE INDICATION to L3 */ - send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, - &dl->lctx); - /* send MDL ERROR INIDCATION to L3 */ - mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); @@ -569,6 +564,11 @@ /* NOTE: we must not change any other states or buffers * and queues, since we may reconnect after handover * failure. the buffered messages is replaced there */ + /* send RELEASE INDICATION to L3 */ + send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, + &dl->lctx); + /* send MDL ERROR INIDCATION to L3 */ + mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); break; } /* retransmit SABM command */ -- To view, visit https://gerrit.osmocom.org/1726 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter From gerrit-no-reply at lists.osmocom.org Tue Feb 7 13:54:03 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 7 Feb 2017 13:54:03 +0000 Subject: [MERGED] libosmocore[master]: lapd_core: Fix MDL-ERROR ind after RELEASE ind In-Reply-To: References: Message-ID: dexter has submitted this change and it was merged. Change subject: lapd_core: Fix MDL-ERROR ind after RELEASE ind ...................................................................... lapd_core: Fix MDL-ERROR ind after RELEASE ind in lapd_t200_cb() The RELEASE INDICATION is transmitted before the MDL ERROR INIDCATION, this prevents the MDL ERROR INDICATION from being sent because the RELASE INDICATION close to connection eraly. This commit puts the messages into the correct order. Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 --- M src/gsm/lapd_core.c 1 file changed, 4 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 5af82aa..5ee88a4 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -564,11 +564,11 @@ /* NOTE: we must not change any other states or buffers * and queues, since we may reconnect after handover * failure. the buffered messages is replaced there */ + /* send MDL ERROR INIDCATION to L3 */ + mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); /* send RELEASE INDICATION to L3 */ send_dl_simple(PRIM_DL_REL, PRIM_OP_INDICATION, &dl->lctx); - /* send MDL ERROR INIDCATION to L3 */ - mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); break; } /* retransmit SABM command */ @@ -581,10 +581,10 @@ case LAPD_STATE_DISC_SENT: /* 5.4.4.3 */ if (dl->retrans_ctr + 1 >= dl->n200_est_rel + 1) { - /* send RELEASE INDICATION to L3 */ - send_dl_simple(PRIM_DL_REL, PRIM_OP_CONFIRM, &dl->lctx); /* send MDL ERROR INIDCATION to L3 */ mdl_error(MDL_CAUSE_T200_EXPIRED, &dl->lctx); + /* send RELEASE INDICATION to L3 */ + send_dl_simple(PRIM_DL_REL, PRIM_OP_CONFIRM, &dl->lctx); /* flush tx and send buffers */ lapd_dl_flush_tx(dl); lapd_dl_flush_send(dl); -- To view, visit https://gerrit.osmocom.org/1727 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iae74777138fc27828f511e3aa321d1981861f4a5 Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter From gerrit-no-reply at lists.osmocom.org Tue Feb 7 14:05:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 7 Feb 2017 14:05:45 +0000 Subject: [PATCH] osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy Message-ID: Review at https://gerrit.osmocom.org/1761 all models: fix vty write: bts_model_config_write_phy The vty write for phy/inst is broken, leading to a written-out config being unparsable; fix all of these: - in common/vty.c, actually call bts_model_config_write_phy_inst(). - in sysmo and lc15 write the phy instance elements in bts_model_config_write_phy_inst() and not in bts_model_config_write_phy(), which lead to writing the members above their parent 'instance'. - sysmo and lc15 omit the bts_model_config_write_phy_inst() implementation. - sysmo writes 'clock-source None' when clk_src is zero, leading to unparsable config (related: OS#1944). Instead omit the 'clock-source' when zero. - octphy omits the bts_model_config_write_phy() implementation. Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 --- M src/common/vty.c M src/osmo-bts-litecell15/lc15bts_vty.c M src/osmo-bts-octphy/octphy_vty.c M src/osmo-bts-sysmo/sysmobts_vty.c 4 files changed, 19 insertions(+), 21 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/61/1761/1 diff --git a/src/common/vty.c b/src/common/vty.c index b48afa4..646ac87 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -358,6 +358,7 @@ if (!pinst) break; vty_out(vty, " instance %u%s", pinst->num, VTY_NEWLINE); + bts_model_config_write_phy_inst(vty, pinst); } } diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c index 0ffe663..46f73ab 100644 --- a/src/osmo-bts-litecell15/lc15bts_vty.c +++ b/src/osmo-bts-litecell15/lc15bts_vty.c @@ -329,7 +329,11 @@ vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power,VTY_NEWLINE); } -static void write_phy_inst(struct vty *vty, struct phy_instance *pinst) +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { int i; @@ -344,14 +348,6 @@ if (pinst->u.lc15.calib_path) vty_out(vty, " trx-calibration-path %s%s", pinst->u.lc15.calib_path, VTY_NEWLINE); -} - -void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) -{ - struct phy_instance *pinst; - - llist_for_each_entry(pinst, &plink->instances, list) - write_phy_inst(vty, pinst); } int bts_model_vty_init(struct gsm_bts *bts) diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index c2d1fbb..abfac1e 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -219,6 +219,10 @@ VTY_NEWLINE); } +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ +} + void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) { } diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index e67d8be..330c9ce 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -443,7 +443,11 @@ VTY_NEWLINE); } -static void write_phy_inst(struct vty *vty, struct phy_instance *pinst) +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { int i; @@ -464,17 +468,10 @@ if (pinst->u.sysmobts.calib_path) vty_out(vty, " trx-calibration-path %s%s", pinst->u.sysmobts.calib_path, VTY_NEWLINE); - vty_out(vty, " clock-source %s%s", - get_value_string(femtobts_clksrc_names, - pinst->u.sysmobts.clk_src), VTY_NEWLINE); -} - -void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) -{ - struct phy_instance *pinst; - - llist_for_each_entry(pinst, &plink->instances, list) - write_phy_inst(vty, pinst); + if (pinst->u.sysmobts.clk_src) + vty_out(vty, " clock-source %s%s", + get_value_string(femtobts_clksrc_names, + pinst->u.sysmobts.clk_src), VTY_NEWLINE); } int bts_model_vty_init(struct gsm_bts *bts) -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 7 15:48:14 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 7 Feb 2017 15:48:14 +0000 Subject: [PATCH] openbsc[master]: gprs/gprs_gmm: implement T3314. Timeout to reset MM state to... Message-ID: Review at https://gerrit.osmocom.org/1762 gprs/gprs_gmm: implement T3314. Timeout to reset MM state to STANDBY When a MS MM state is READY the exakt location is known (PCU). T3141 set the MM state to STANDBY, where only the RA is known. Introduce a second set of timer variables, because state timer can run while another packet state timer is timing out. Change-Id: I4ce23ebe50d141076c20c9c56990b7103cd25e55 --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c 3 files changed, 100 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/62/1762/1 diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 2cc5b0c..e7dcfad 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -208,6 +208,10 @@ unsigned int T; /* Txxxx number */ unsigned int num_T_exp; /* number of consecutive T expirations */ + /* timer for pmm state */ + struct osmo_timer_list state_timer; + unsigned int state_T; /* Txxxx number but only used for pmm_states */ + enum gprs_t3350_mode t3350_mode; uint8_t t3370_id_type; uint8_t pending_req; /* the request's message type */ diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 1026474..5e12654 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -116,6 +116,12 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx); +static void mmctx_state_timer_cb(void *_mm); +static void mmctx_state_timer_start(struct sgsn_mm_ctx *mm, unsigned int T, int seconds); +static void mmctx_state_timer_stop(struct sgsn_mm_ctx *mm, unsigned int T); + +static void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg); + static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx) { struct sgsn_pdp_ctx *pdp; @@ -164,8 +170,78 @@ get_value_string(gprs_pmm_state_names, ctx->pmm_state), get_value_string(gprs_pmm_state_names, state)); + switch (state) { + case MM_READY: + /* T3314 change state to MM_STANDBY */ + mmctx_state_timer_start(ctx, 3314, sgsn->cfg.timers.T3314); + break; + case MM_IDLE: + mmctx_state_timer_stop(ctx, 3314); + break; + case MM_STANDBY: + mmctx_state_timer_stop(ctx, 3314); + break; + default: + /* when changing to state != MM_READY */ + break; + } + ctx->pmm_state = state; } + +void mmctx_recv_pdu(struct sgsn_mm_ctx *ctx, struct msgb *msg) +{ + msgid2mmctx(ctx, msg); + + if (ctx->ran_type != MM_CTX_T_GERAN_Gb) + return; + + switch (ctx->pmm_state) { + case MM_STANDBY: + mmctx_set_mm_state(ctx, MM_READY); + break; + case MM_READY: /* the timer is started when switching to READY */ + mmctx_state_timer_start(ctx, 3314, sgsn->cfg.timers.T3314); + break; + default: + break; + } +} + +static void mmctx_state_timer_cb(void *_mm) +{ + struct sgsn_mm_ctx *mm = _mm; + + if (mm->ran_type != MM_CTX_T_GERAN_Gb) + return; + + switch (mm->state_T) { + case 3314: + if (mm->pmm_state == MM_READY) + mmctx_set_mm_state(mm, MM_STANDBY); + break; + default: + LOGMMCTXP(LOGL_ERROR, mm, "state timer expired in unknown mode %u\n", + mm->state_T); + break; + } +} + +static void mmctx_state_timer_start(struct sgsn_mm_ctx *mm, unsigned int T, int seconds) +{ + mm->state_T = T; + mm->state_timer.data = mm; + mm->state_timer.cb = &mmctx_state_timer_cb; + + osmo_timer_schedule(&mm->state_timer, seconds, 0); +} + +static void mmctx_state_timer_stop(struct sgsn_mm_ctx *mm, unsigned int T) +{ + if (mm->state_T == T) + osmo_timer_del(&mm->state_timer); +} + #ifdef BUILD_IU int sgsn_ranap_rab_ass_resp(struct sgsn_mm_ctx *ctx, RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies); @@ -2659,6 +2735,21 @@ return rc; } +/* Update the MM context, called also for other PDUs than MM PDU from Gb */ +void gsm0408_gprs_notify_pdu_gb(struct msgb *msg) +{ + struct sgsn_mm_ctx *mmctx; + struct gprs_ra_id ra_id; + + bssgp_parse_cell_id(&ra_id, msgb_bcid(msg)); + mmctx = sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &ra_id); + if (!mmctx) { + return; + } + + mmctx_recv_pdu(mmctx, msg); +} + /* Main entry point for incoming 04.08 GPRS messages from Gb */ int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, bool drop_cipherable) diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 260e032..c3de671 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -314,6 +314,11 @@ osmo_timer_del(&mm->timer); } + if (osmo_timer_pending(&mm->state_timer)) { + LOGMMCTXP(LOGL_INFO, mm, "Cancelling MM timer %u\n", mm->state_T); + osmo_timer_del(&mm->state_timer); + } + memset(&sig_data, 0, sizeof(sig_data)); sig_data.mm = mm; osmo_signal_dispatch(SS_SGSN, S_SGSN_MM_FREE, &sig_data); -- To view, visit https://gerrit.osmocom.org/1762 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ce23ebe50d141076c20c9c56990b7103cd25e55 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 7 16:30:11 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 7 Feb 2017 16:30:11 +0000 Subject: [PATCH] libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1582 to look at the new patch set (#3). vty: fix "everything" logging option * clarify use of unused parameters * change internal static function int check_log_to_target() to more appropriate bool log_to_target() * add explicit level for "logging level ... everything" so it really logs everything instead of nothing for a given category * fix "logging level all everything" with explicit global loglevel check Fixes: OS#71 Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c --- M include/osmocom/core/logging.h M include/osmocom/vty/logging.h M src/logging.c M src/vty/logging_vty.c M tests/vty/vty_test.c 5 files changed, 34 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1582/3 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..aef145d 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -88,6 +88,8 @@ #define LOGL_NOTICE 5 /*!< \brief abnormal/unexpected condition */ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ +/* N. B: check that you do not clash with internal LOGL_EVERY from logging.c + before adding anything to above */ #define LOG_FILTER_ALL 0x0001 @@ -299,8 +301,8 @@ void log_del_target(struct log_target *target); /* Generate command string for VTY use */ -const char *log_vty_command_string(const struct log_info *info); -const char *log_vty_command_description(const struct log_info *info); +const char *log_vty_command_string(const struct log_info *unused_info); +const char *log_vty_command_description(const struct log_info *unused_info); struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index 9e4b98f..a23a1ad 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -4,6 +4,6 @@ #define FILTER_STR "Filter log messages\n" struct log_info; -void logging_vty_add_cmds(const struct log_info *cat); +void logging_vty_add_cmds(const struct log_info *unused_info); struct vty; struct log_target *osmo_log_vty2tgt(struct vty *vty); diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..86e3c25 100644 --- a/src/logging.c +++ b/src/logging.c @@ -55,9 +55,10 @@ LLIST_HEAD(osmo_log_target_list); #define LOGLEVEL_DEFS 6 /* Number of loglevels.*/ +#define LOGL_EVERY 32 /* Special loglevel for "everything". */ static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1] = { - { 0, "EVERYTHING" }, + { LOGL_EVERY, "EVERYTHING" }, { LOGL_DEBUG, "DEBUG" }, { LOGL_INFO, "INFO" }, { LOGL_NOTICE, "NOTICE" }, @@ -138,7 +139,7 @@ /*! \brief descriptive string for each log level */ /* You have to keep this in sync with the structure loglevel_strs. */ const char *loglevel_descriptions[LOGLEVEL_DEFS+1] = { - "Don't use. It doesn't log anything", + "Log everything (use with extreme care)", "Log debug messages and higher levels", "Log informational messages and higher levels", "Log noticeable messages and higher levels", @@ -159,6 +160,10 @@ */ int log_parse_level(const char *lvl) { + /* explicit check for "everything" loglevel */ + if (!strcmp(lvl, "everything")) + return LOGL_EVERY; + return get_string_value(loglevel_strs, lvl); } @@ -168,6 +173,8 @@ */ const char *log_level_str(unsigned int lvl) { + if (lvl == LOGL_EVERY) + return "everything"; return get_value_string(loglevel_strs, lvl); } @@ -352,36 +359,44 @@ return subsys; } -static inline int check_log_to_target(struct log_target *tar, int subsys, int level) +static inline bool log_to_target(struct log_target *tar, int subsys, int level) { struct log_category *category; category = &tar->categories[subsys]; + /* Check if special log level "everything" is enabled globally */ + if (tar->loglevel == LOGL_EVERY) + return true; + /* subsystem is not supposed to be logged */ if (!category->enabled) - return 0; + return false; /* Check the global log level */ if (tar->loglevel != 0 && level < tar->loglevel) - return 0; + return true; + + /* Check if special log level "everything" is enabled for category */ + if (category->loglevel == LOGL_EVERY) + return true; /* Check the category log level */ if (tar->loglevel == 0 && category->loglevel != 0 && level < category->loglevel) - return 0; + return false; /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ if ((tar->filter_map & LOG_FILTER_ALL) != 0) - return 1; + return true; if (osmo_log_info->filter_fn) return osmo_log_info->filter_fn(&log_context, tar); /* TODO: Check the filter/selector too? */ - return 1; + return true; } /*! \brief vararg version of logging function @@ -402,7 +417,7 @@ llist_for_each_entry(tar, &osmo_log_target_list, entry) { va_list bp; - if (!check_log_to_target(tar, subsys, level)) + if (!log_to_target(tar, subsys, level)) continue; /* According to the manpage, vsnprintf leaves the value of ap @@ -978,7 +993,7 @@ /* TODO: The following could/should be cached (update on config) */ llist_for_each_entry(tar, &osmo_log_target_list, entry) { - if (!check_log_to_target(tar, subsys, level)) + if (!log_to_target(tar, subsys, level)) continue; /* This might get logged (ignoring filters) */ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..1c51ec7 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -737,7 +737,7 @@ return 1; } -void logging_vty_add_cmds(const struct log_info *cat) +void logging_vty_add_cmds(const struct log_info *unused_info) { install_element_ve(&enable_logging_cmd); install_element_ve(&disable_logging_cmd); @@ -750,8 +750,8 @@ install_element_ve(&logging_set_category_mask_old_cmd); /* Logging level strings are generated dynamically. */ - logging_level_cmd.string = log_vty_command_string(cat); - logging_level_cmd.doc = log_vty_command_description(cat); + logging_level_cmd.string = log_vty_command_string(NULL); + logging_level_cmd.doc = log_vty_command_description(NULL); install_element_ve(&logging_level_cmd); install_element_ve(&show_logging_vty_cmd); install_element_ve(&show_alarms_cmd); diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 865c93e..51a6529 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -318,7 +318,7 @@ vty_init(&vty_info); /* Setup VTY commands */ - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(); test_cmd_string_from_valstr(); -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 7 16:41:46 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 7 Feb 2017 16:41:46 +0000 Subject: [PATCH] openbsc[master]: vty: remove ignored logging parameters In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1583 to look at the new patch set (#2). vty: remove ignored logging parameters Since ce9fec3e896571835ac5bfd2980d6836f2b29f0d libosmocore ignores parameters to log_vty_command_* functions. Hence parameter of logging_vty_add_cmds() is ignored too. As we depend on much later libosmocore version anyway, we can simplify code somewhat by removing parameters which will be ignored anyway. Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991 --- M openbsc/include/openbsc/vty.h M openbsc/src/gprs/gb_proxy_main.c M openbsc/src/gprs/gtphub_main.c M openbsc/src/gprs/sgsn_main.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/osmo-bsc/osmo_bsc_main.c M openbsc/src/osmo-bsc_mgcp/mgcp_main.c M openbsc/src/osmo-bsc_nat/bsc_nat.c M openbsc/src/osmo-bsc_nat/bsc_nat_vty.c M openbsc/src/osmo-nitb/bsc_hack.c 10 files changed, 12 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/83/1583/2 diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index ad2cd2a..f79eab5 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -44,7 +44,7 @@ extern void bsc_replace_string(void *ctx, char **dst, const char *newstr); struct log_info; -int bsc_vty_init(const struct log_info *cat, struct gsm_network *network); +int bsc_vty_init(struct gsm_network *network); int bsc_vty_init_extra(void); struct gsm_network *gsmnet_from_vty(struct vty *vty); diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c index 04875c7..69a93b6 100644 --- a/openbsc/src/gprs/gb_proxy_main.c +++ b/openbsc/src/gprs/gb_proxy_main.c @@ -241,7 +241,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&gprs_log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&gprs_log_info); gbproxy_vty_init(); diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c index 46360f9..73a122c 100644 --- a/openbsc/src/gprs/gtphub_main.c +++ b/openbsc/src/gprs/gtphub_main.c @@ -311,7 +311,7 @@ vty_info.copyright = gtphub_copyright; vty_init(&vty_info); - logging_vty_add_cmds(>phub_log_info); + logging_vty_add_cmds(NULL); gtphub_vty_init(hub, cfg); rate_ctr_init(osmo_gtphub_ctx); diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index b4be631..af5cced 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -340,7 +340,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&gprs_log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&gprs_log_info); sgsn_vty_init(); ctrl_vty_init(tall_bsc_ctx); diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 01ee4df..81fec8e 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -3830,7 +3830,7 @@ extern int bsc_vty_init_extra(void); -int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) +int bsc_vty_init(struct gsm_network *network) { cfg_ts_pchan_cmd.string = vty_cmd_string_from_valstr(tall_bsc_ctx, @@ -3866,7 +3866,7 @@ install_element_ve(&show_paging_cmd); install_element_ve(&show_paging_group_cmd); - logging_vty_add_cmds(cat); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(); install_element(GSMNET_NODE, &cfg_net_neci_cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 1d96bb4..adce775 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -212,7 +212,7 @@ /* This needs to precede handle_options() */ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - bsc_vty_init(&log_info, bsc_gsmnet); + bsc_vty_init(bsc_gsmnet); bsc_msg_lst_vty_init(tall_bsc_ctx, &access_lists, BSC_NODE); ctrl_vty_init(tall_bsc_ctx); diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index 964768e..4ea0700 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -220,7 +220,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&log_info); mgcp_vty_init(); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index a4dd679..80e89fd 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1616,7 +1616,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&log_info); bsc_nat_vty_init(nat); ctrl_vty_init(tall_bsc_ctx); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 706e507..deb98fc 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1329,8 +1329,8 @@ /* called by the telnet interface... we have our own init above */ -int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) +int bsc_vty_init(struct gsm_network *network) { - logging_vty_add_cmds(cat); + logging_vty_add_cmds(NULL); return 0; } diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index bbcdd1b..2bdfada 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -283,7 +283,7 @@ } /* Initialize VTY */ - bsc_vty_init(&log_info, bsc_gsmnet); + bsc_vty_init(bsc_gsmnet); ctrl_vty_init(tall_bsc_ctx); #ifdef BUILD_SMPP -- To view, visit https://gerrit.osmocom.org/1583 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 7 16:45:36 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 7 Feb 2017 16:45:36 +0000 Subject: osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Patch Set 1: How it wasn't caught by tests? Maybe add explicit test to make sure this won't be broken again? -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 17:17:08 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 7 Feb 2017 17:17:08 +0000 Subject: openbsc[master]: gprs/gprs_gmm: implement T3314. Timeout to reset MM state to... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 tests are also misisng... -- To view, visit https://gerrit.osmocom.org/1762 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4ce23ebe50d141076c20c9c56990b7103cd25e55 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 19:17:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 19:17:41 +0000 Subject: [PATCH] osmo-bts[master]: Revert "sysmobts: Add correct nominal transmit power for sys... Message-ID: Review at https://gerrit.osmocom.org/1763 Revert "sysmobts: Add correct nominal transmit power for sysmoBTS 1020" This reverts commit 1965b0d88082e427930f95071e992f0d9be79047, which was a premature change. The 10dB gain are not the power of the TRX board, but are due to an internal, factory mounted PA, i.e. the trx_power_params.pa. This will be introduced after adding a set of tx_power.c unit tests. Change-Id: I524b63c51fb0fe1f90ced28486a8e712f2dc50ae --- M src/osmo-bts-sysmo/utils.c 1 file changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/63/1763/1 diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index 8f54e6f..a636ae1 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -125,8 +125,6 @@ case 1002: /* 200mW (23 dBm) nominal power */ return 23; - case 1020: - return 33; case 2050: /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) * if the second TRX is not used. */ -- To view, visit https://gerrit.osmocom.org/1763 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I524b63c51fb0fe1f90ced28486a8e712f2dc50ae Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 7 19:17:43 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 19:17:43 +0000 Subject: [PATCH] osmo-bts[master]: tx_power: various cosmetic fixes in comments Message-ID: Review at https://gerrit.osmocom.org/1764 tx_power: various cosmetic fixes in comments Change-Id: I542b74d79bc8ffedd7c435b41b042edd5152f61c --- M src/common/tx_power.c 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/64/1764/1 diff --git a/src/common/tx_power.c b/src/common/tx_power.c index d8c90b2..f8adb6a 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -58,7 +58,7 @@ } /* calculate the target total output power required, reduced by both - * OML and RSL, but ignoring the attenutation required for power ramping and + * OML and RSL, but ignoring the attenuation required for power ramping and * thermal management */ int get_p_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie) { @@ -71,7 +71,7 @@ } /* calculate the actual total output power required, taking into account the - * attenutation required for power ramping but not thermal management */ + * attenuation required for power ramping but not thermal management */ int get_p_actual_mdBm(struct gsm_bts_trx *trx, int p_target_mdBm) { struct trx_power_params *tpp = &trx->power_params; @@ -81,7 +81,7 @@ } /* calculate the effective total output power required, taking into account the - * attenutation required for power ramping and thermal management */ + * attenuation required for power ramping and thermal management */ int get_p_eff_mdBm(struct gsm_bts_trx *trx, int p_target_mdBm) { struct trx_power_params *tpp = &trx->power_params; @@ -144,7 +144,7 @@ * one hand side to avoid very fast dynamic load changes towards the PA power * supply, but is also needed in order to avoid a DoS by too many subscriber * attempting to register at the same time. Rather, grow the cell slowly in - * radius than start with the full raduis at once. */ + * radius than start with the full radius at once. */ static int we_are_ramping_up(struct gsm_bts_trx *trx) { @@ -158,7 +158,7 @@ static void power_ramp_do_step(struct gsm_bts_trx *trx, int first); -/* timer call-back for the ramp tumer */ +/* timer call-back for the ramp timer */ static void power_ramp_timer_cb(void *_trx) { struct gsm_bts_trx *trx = _trx; -- To view, visit https://gerrit.osmocom.org/1764 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I542b74d79bc8ffedd7c435b41b042edd5152f61c Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 7 19:17:43 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 19:17:43 +0000 Subject: [PATCH] osmo-bts[master]: tx_power: Change PA calibration tables to use delta vales Message-ID: Review at https://gerrit.osmocom.org/1765 tx_power: Change PA calibration tables to use delta vales It seems more user friendly to look at a calibration table in terms of the delta (positive or negative) compared to the nominal gain value, rather than a collection of absolute gain values. It has the added benefit that the (API/data model) user doesn't have to specify a gain value for each ARFCN, but rather can rely on the default nominal gain in absence of a calibration table for this specific unit. Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad --- M include/osmo-bts/tx_power.h M src/common/tx_power.c 2 files changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/65/1765/1 diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h index 1d76864..8d099bc 100644 --- a/include/osmo-bts/tx_power.h +++ b/include/osmo-bts/tx_power.h @@ -8,7 +8,7 @@ /* PA calibration table */ struct pa_calibration { - int gain_mdB[1024]; /* gain provided at given ARFCN */ + int delta_mdB[1024]; /* gain delta at given ARFCN */ /* FIXME: thermal calibration */ }; diff --git a/src/common/tx_power.c b/src/common/tx_power.c index f8adb6a..c517918 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -33,12 +33,12 @@ static int get_pa_drive_level_mdBm(const struct power_amp *pa, int desired_p_out_mdBm, unsigned int arfcn) { - if (arfcn >= ARRAY_SIZE(pa->calib.gain_mdB)) + if (arfcn >= ARRAY_SIZE(pa->calib.delta_mdB)) return INT_MIN; /* FIXME: temperature compensation */ - return desired_p_out_mdBm - pa->calib.gain_mdB[arfcn]; + return desired_p_out_mdBm - pa->nominal_gain_mdB - pa->calib.delta_mdB[arfcn]; } /* maximum output power of the system */ -- To view, visit https://gerrit.osmocom.org/1765 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 7 19:17:43 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 19:17:43 +0000 Subject: [PATCH] osmo-bts[master]: Add new unit-test about transmit power computation code Message-ID: Review at https://gerrit.osmocom.org/1766 Add new unit-test about transmit power computation code Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.ok 7 files changed, 220 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/66/1766/1 diff --git a/.gitignore b/.gitignore index 224b77c..5ee9565 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/handover_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..843815c 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,9 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [ignore]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..d0645e5 --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..606fe3e --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,199 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include +#include +#include + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + .calib.gain_mdB = { to_mdB(10), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + .calib.gain_mdB = { to_mdB(17), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + printf("CHANGE_POWER(%u)\n", p_trxout_mdBm); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DHO].loglevel = LOGL_DEBUG; + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* FIXME: Test power ramping */ +} diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..e46e149 --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,4 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 7 19:17:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 19:17:44 +0000 Subject: [PATCH] osmo-bts[master]: sysmobts: fully support trx_power_params Message-ID: Review at https://gerrit.osmocom.org/1767 sysmobts: fully support trx_power_params The simplistic approach of sysmobts_get_nominal_power() is insufficient to cope for devices that have an internal PA. The Actual transceiver board is driven to a certain level (0..23 dBm typically), and the external PA must be handled independent of that. Increasing the return value of sysmobts_get_nominal_power() would result in the sysmoBTS mainboard attempting to reach a higher power, which is wrong. This change affects sysmoBTS 1020 and 1100. It causes power-ramping to be used by default. For 1002 and 2050, no behavior change is expected. Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 --- M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/sysmobts_vty.c M src/osmo-bts-sysmo/utils.c M src/osmo-bts-sysmo/utils.h M tests/tx_power/tx_power_test.c 5 files changed, 44 insertions(+), 34 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/67/1767/1 diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index c021368..8eb6fcc 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1309,7 +1310,7 @@ LOGP(DL1C, LOGL_INFO, "Using external attenuator.\n"); sysp->u.activateRfReq.rfTrx.u8UseExtAtten = 1; sysp->u.activateRfReq.rfTrx.fMaxTxPower = - sysmobts_get_nominal_power(trx); + (float) get_p_trxout_target_mdBm(trx, 0) / 1000; } #endif /* 2.2.0 */ #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,8,1) @@ -1797,6 +1798,44 @@ #endif +static void set_power_param(struct trx_power_params *out, + int trx_p_max_out_dBm, + int int_pa_nominal_gain_dB) +{ + out->trx_p_max_out_mdBm = to_mdB(trx_p_max_out_dBm); + out->pa.nominal_gain_mdB = to_mdB(int_pa_nominal_gain_dB); +} + +static void fill_trx_power_params(struct gsm_bts_trx *trx, + struct phy_instance *pinst) +{ + struct femtol1_hdl *fl1h = pinst->u.sysmobts.hdl; + + switch (fl1h->hw_info.model_nr) { + case 1020: + set_power_param(&trx->power_params, 23, 10); + break; + case 1100: + set_power_param(&trx->power_params, 23, 17); + break; + case 2050: + set_power_param(&trx->power_params, 37, 0); + break; + default: + LOGP(DL1C, LOGL_NOTICE, "Unknown/Unsupported " + "sysmoBTS Model Number %u\n", + fl1h->hw_info.model_nr); + /* fall-through */ + case 0xffff: + /* sysmoBTS 1002 without any setting in EEPROM */ + LOGP(DL1C, LOGL_NOTICE, "Assuming 1002 for sysmoBTS " + "Model number %u\n", fl1h->hw_info.model_nr); + case 1002: + set_power_param(&trx->power_params, 23, 0); + } +} + + int bts_model_phy_link_open(struct phy_link *plink) { struct phy_instance *pinst = phy_instance_by_num(plink, 0); @@ -1812,16 +1851,17 @@ return -EIO; } + fill_trx_power_params(pinst->trx, pinst); + bts = pinst->trx->bts; if (pinst->trx == bts->c0) { int rc; - rc = sysmobts_get_nominal_power(bts->c0); + rc = get_p_max_out_mdBm(bts->c0); if (rc < 0) { LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal " "transmit power. Assuming 23dBm.\n"); } bts->c0->nominal_power = rc; - bts->c0->power_params.trx_p_max_out_mdBm = to_mdB(rc); } phy_link_state_set(plink, PHY_LINK_CONNECTED); diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index e67d8be..a1e6555 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -438,7 +438,7 @@ void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx) { - if (trx->nominal_power != sysmobts_get_nominal_power(trx)) + if (trx->nominal_power != get_p_max_out_mdBm(trx)) vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power, VTY_NEWLINE); } diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..be6051a 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -112,29 +112,3 @@ /* give up */ return -1; } - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx) -{ - struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); - - switch (fl1h->hw_info.model_nr) { - case 0: - case 0xffff: - /* old units have empty flash where the model number is - * stored in later units */ - case 1002: - /* 200mW (23 dBm) nominal power */ - return 23; - case 2050: - /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) - * if the second TRX is not used. */ - return 37; - default: - LOGP(DL1C, LOGL_ERROR, "Model number %u/0x%x not known.\n", - fl1h->hw_info.model_nr, fl1h->hw_info.model_nr); - break; - } - return -1; -} - - diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h index 58e3324..45908d5 100644 --- a/src/osmo-bts-sysmo/utils.h +++ b/src/osmo-bts-sysmo/utils.h @@ -9,6 +9,4 @@ int band_femto2osmo(GsmL1_FreqBand_t band); int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn); - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx); #endif diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c index 606fe3e..f9e4ae9 100644 --- a/tests/tx_power/tx_power_test.c +++ b/tests/tx_power/tx_power_test.c @@ -52,7 +52,6 @@ .user_gain_mdB = 0, .pa = { .nominal_gain_mdB = to_mdB(10), - .calib.gain_mdB = { to_mdB(10), }, }, .user_pa = { .nominal_gain_mdB = 0, @@ -67,7 +66,6 @@ .user_gain_mdB = 0, .pa = { .nominal_gain_mdB = to_mdB(17), - .calib.gain_mdB = { to_mdB(17), }, }, .user_pa = { .nominal_gain_mdB = 0, -- To view, visit https://gerrit.osmocom.org/1767 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:08:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:08:48 +0000 Subject: [PATCH] osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1766 to look at the new patch set (#2). Add new unit-test for transmit power computation code This tests the computations of the tx_power.c code using sysmoBTS 1002, 1020, 1100 and 2050 values, as well as the power ramping code. Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.err A tests/tx_power/tx_power_test.ok 8 files changed, 320 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/66/1766/2 diff --git a/.gitignore b/.gitignore index 224b77c..b449f92 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/tx_power_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..bfc9bad 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,10 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +cat $abs_srcdir/tx_power/tx_power_test.err > experr +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [experr]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..d0645e5 --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..32a2ab8 --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,241 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + .calib.gain_mdB = { to_mdB(10), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + .calib.gain_mdB = { to_mdB(17), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + struct trx_power_params *tpp = &trx->power_params; + + printf("CHANGE_POWER(%d)\n", p_trxout_mdBm); + + if (tpp->ramp.attenuation_mdB == 0) + exit(0); + + power_trx_change_compl(trx, p_trxout_mdBm); + return 0; +} + +static void test_power_ramp(struct gsm_bts_trx *trx, int dBm) +{ + printf("Testing tx_power ramping for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + + power_ramp_start(trx, to_mdB(dBm), 0); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DL1C].loglevel = LOGL_DEBUG; + log_set_print_filename(osmo_stderr_target, 0); + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* test error case / excess power (40 dBm is too much) */ + test_power_ramp(trx, 40); + /* test actaul ramping to full 33 dBm */ + test_power_ramp(trx, 33); + + while (1) { + osmo_select_main(0); + } +} diff --git a/tests/tx_power/tx_power_test.err b/tests/tx_power/tx_power_test.err new file mode 100644 index 0000000..bf33b42 --- /dev/null +++ b/tests/tx_power/tx_power_test.err @@ -0,0 +1,38 @@ +power_ramp_start(cur=0, tgt=40000) +Asked to ramp power up to 40000 mdBm, which exceeds P_max_out (33000) +power_ramp_start(cur=0, tgt=33000) +ramp_timer_cb(cur_pout=2000, tgt_pout=33000, ramp_att=31000, therm_att=0, user_gain=0) +ramping TRX board output power to -8000 mdBm. +ramp_timer_cb(cur_pout=4000, tgt_pout=33000, ramp_att=29000, therm_att=0, user_gain=0) +ramping TRX board output power to -6000 mdBm. +ramp_timer_cb(cur_pout=6000, tgt_pout=33000, ramp_att=27000, therm_att=0, user_gain=0) +ramping TRX board output power to -4000 mdBm. +ramp_timer_cb(cur_pout=8000, tgt_pout=33000, ramp_att=25000, therm_att=0, user_gain=0) +ramping TRX board output power to -2000 mdBm. +ramp_timer_cb(cur_pout=10000, tgt_pout=33000, ramp_att=23000, therm_att=0, user_gain=0) +ramping TRX board output power to 0 mdBm. +ramp_timer_cb(cur_pout=12000, tgt_pout=33000, ramp_att=21000, therm_att=0, user_gain=0) +ramping TRX board output power to 2000 mdBm. +ramp_timer_cb(cur_pout=14000, tgt_pout=33000, ramp_att=19000, therm_att=0, user_gain=0) +ramping TRX board output power to 4000 mdBm. +ramp_timer_cb(cur_pout=16000, tgt_pout=33000, ramp_att=17000, therm_att=0, user_gain=0) +ramping TRX board output power to 6000 mdBm. +ramp_timer_cb(cur_pout=18000, tgt_pout=33000, ramp_att=15000, therm_att=0, user_gain=0) +ramping TRX board output power to 8000 mdBm. +ramp_timer_cb(cur_pout=20000, tgt_pout=33000, ramp_att=13000, therm_att=0, user_gain=0) +ramping TRX board output power to 10000 mdBm. +ramp_timer_cb(cur_pout=22000, tgt_pout=33000, ramp_att=11000, therm_att=0, user_gain=0) +ramping TRX board output power to 12000 mdBm. +ramp_timer_cb(cur_pout=24000, tgt_pout=33000, ramp_att=9000, therm_att=0, user_gain=0) +ramping TRX board output power to 14000 mdBm. +ramp_timer_cb(cur_pout=26000, tgt_pout=33000, ramp_att=7000, therm_att=0, user_gain=0) +ramping TRX board output power to 16000 mdBm. +ramp_timer_cb(cur_pout=28000, tgt_pout=33000, ramp_att=5000, therm_att=0, user_gain=0) +ramping TRX board output power to 18000 mdBm. +ramp_timer_cb(cur_pout=30000, tgt_pout=33000, ramp_att=3000, therm_att=0, user_gain=0) +ramping TRX board output power to 20000 mdBm. +ramp_timer_cb(cur_pout=32000, tgt_pout=33000, ramp_att=1000, therm_att=0, user_gain=0) +ramping TRX board output power to 22000 mdBm. +ramp_timer_cb(cur_pout=33000, tgt_pout=33000, ramp_att=0, therm_att=0, user_gain=0) +ramping TRX board output power to 23000 mdBm. + \ No newline at end of file diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..ceb88ab --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,23 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 +Testing tx_power ramping for sysmoBTS 1020 +Testing tx_power ramping for sysmoBTS 1020 +CHANGE_POWER(-8000) +CHANGE_POWER(-6000) +CHANGE_POWER(-4000) +CHANGE_POWER(-2000) +CHANGE_POWER(0) +CHANGE_POWER(2000) +CHANGE_POWER(4000) +CHANGE_POWER(6000) +CHANGE_POWER(8000) +CHANGE_POWER(10000) +CHANGE_POWER(12000) +CHANGE_POWER(14000) +CHANGE_POWER(16000) +CHANGE_POWER(18000) +CHANGE_POWER(20000) +CHANGE_POWER(22000) +CHANGE_POWER(23000) -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:09:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:09:37 +0000 Subject: osmo-bts[master]: Revert "sysmobts: Add correct nominal transmit power for sys... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1763 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I524b63c51fb0fe1f90ced28486a8e712f2dc50ae Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:09:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:09:40 +0000 Subject: osmo-bts[master]: tx_power: various cosmetic fixes in comments In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1764 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I542b74d79bc8ffedd7c435b41b042edd5152f61c Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:09:45 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:09:45 +0000 Subject: osmo-bts[master]: tx_power: Change PA calibration tables to use delta vales In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1765 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:09:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:09:51 +0000 Subject: osmo-bts[master]: tx_power: Change PA calibration tables to use delta vales In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1765 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:09:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:09:56 +0000 Subject: osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:10:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:10:15 +0000 Subject: osmo-bts[master]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 this needs verification before merging. -- To view, visit https://gerrit.osmocom.org/1767 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:10:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:10:20 +0000 Subject: osmo-bts[master]: tx_power: Change PA calibration tables to use delta vales In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1765 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:20:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:20:51 +0000 Subject: [PATCH] osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1766 to look at the new patch set (#3). Add new unit-test for transmit power computation code This tests the computations of the tx_power.c code using sysmoBTS 1002, 1020, 1100 and 2050 values, as well as the power ramping code. Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.err A tests/tx_power/tx_power_test.ok 8 files changed, 320 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/66/1766/3 diff --git a/.gitignore b/.gitignore index 224b77c..b449f92 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/tx_power_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..bfc9bad 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,10 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +cat $abs_srcdir/tx_power/tx_power_test.err > experr +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [experr]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..3d4377a --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok tx_power_test.err + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..32a2ab8 --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,241 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + .calib.gain_mdB = { to_mdB(10), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + .calib.gain_mdB = { to_mdB(17), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + struct trx_power_params *tpp = &trx->power_params; + + printf("CHANGE_POWER(%d)\n", p_trxout_mdBm); + + if (tpp->ramp.attenuation_mdB == 0) + exit(0); + + power_trx_change_compl(trx, p_trxout_mdBm); + return 0; +} + +static void test_power_ramp(struct gsm_bts_trx *trx, int dBm) +{ + printf("Testing tx_power ramping for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + + power_ramp_start(trx, to_mdB(dBm), 0); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DL1C].loglevel = LOGL_DEBUG; + log_set_print_filename(osmo_stderr_target, 0); + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* test error case / excess power (40 dBm is too much) */ + test_power_ramp(trx, 40); + /* test actaul ramping to full 33 dBm */ + test_power_ramp(trx, 33); + + while (1) { + osmo_select_main(0); + } +} diff --git a/tests/tx_power/tx_power_test.err b/tests/tx_power/tx_power_test.err new file mode 100644 index 0000000..bf33b42 --- /dev/null +++ b/tests/tx_power/tx_power_test.err @@ -0,0 +1,38 @@ +power_ramp_start(cur=0, tgt=40000) +Asked to ramp power up to 40000 mdBm, which exceeds P_max_out (33000) +power_ramp_start(cur=0, tgt=33000) +ramp_timer_cb(cur_pout=2000, tgt_pout=33000, ramp_att=31000, therm_att=0, user_gain=0) +ramping TRX board output power to -8000 mdBm. +ramp_timer_cb(cur_pout=4000, tgt_pout=33000, ramp_att=29000, therm_att=0, user_gain=0) +ramping TRX board output power to -6000 mdBm. +ramp_timer_cb(cur_pout=6000, tgt_pout=33000, ramp_att=27000, therm_att=0, user_gain=0) +ramping TRX board output power to -4000 mdBm. +ramp_timer_cb(cur_pout=8000, tgt_pout=33000, ramp_att=25000, therm_att=0, user_gain=0) +ramping TRX board output power to -2000 mdBm. +ramp_timer_cb(cur_pout=10000, tgt_pout=33000, ramp_att=23000, therm_att=0, user_gain=0) +ramping TRX board output power to 0 mdBm. +ramp_timer_cb(cur_pout=12000, tgt_pout=33000, ramp_att=21000, therm_att=0, user_gain=0) +ramping TRX board output power to 2000 mdBm. +ramp_timer_cb(cur_pout=14000, tgt_pout=33000, ramp_att=19000, therm_att=0, user_gain=0) +ramping TRX board output power to 4000 mdBm. +ramp_timer_cb(cur_pout=16000, tgt_pout=33000, ramp_att=17000, therm_att=0, user_gain=0) +ramping TRX board output power to 6000 mdBm. +ramp_timer_cb(cur_pout=18000, tgt_pout=33000, ramp_att=15000, therm_att=0, user_gain=0) +ramping TRX board output power to 8000 mdBm. +ramp_timer_cb(cur_pout=20000, tgt_pout=33000, ramp_att=13000, therm_att=0, user_gain=0) +ramping TRX board output power to 10000 mdBm. +ramp_timer_cb(cur_pout=22000, tgt_pout=33000, ramp_att=11000, therm_att=0, user_gain=0) +ramping TRX board output power to 12000 mdBm. +ramp_timer_cb(cur_pout=24000, tgt_pout=33000, ramp_att=9000, therm_att=0, user_gain=0) +ramping TRX board output power to 14000 mdBm. +ramp_timer_cb(cur_pout=26000, tgt_pout=33000, ramp_att=7000, therm_att=0, user_gain=0) +ramping TRX board output power to 16000 mdBm. +ramp_timer_cb(cur_pout=28000, tgt_pout=33000, ramp_att=5000, therm_att=0, user_gain=0) +ramping TRX board output power to 18000 mdBm. +ramp_timer_cb(cur_pout=30000, tgt_pout=33000, ramp_att=3000, therm_att=0, user_gain=0) +ramping TRX board output power to 20000 mdBm. +ramp_timer_cb(cur_pout=32000, tgt_pout=33000, ramp_att=1000, therm_att=0, user_gain=0) +ramping TRX board output power to 22000 mdBm. +ramp_timer_cb(cur_pout=33000, tgt_pout=33000, ramp_att=0, therm_att=0, user_gain=0) +ramping TRX board output power to 23000 mdBm. + \ No newline at end of file diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..ceb88ab --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,23 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 +Testing tx_power ramping for sysmoBTS 1020 +Testing tx_power ramping for sysmoBTS 1020 +CHANGE_POWER(-8000) +CHANGE_POWER(-6000) +CHANGE_POWER(-4000) +CHANGE_POWER(-2000) +CHANGE_POWER(0) +CHANGE_POWER(2000) +CHANGE_POWER(4000) +CHANGE_POWER(6000) +CHANGE_POWER(8000) +CHANGE_POWER(10000) +CHANGE_POWER(12000) +CHANGE_POWER(14000) +CHANGE_POWER(16000) +CHANGE_POWER(18000) +CHANGE_POWER(20000) +CHANGE_POWER(22000) +CHANGE_POWER(23000) -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:26:30 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:26:30 +0000 Subject: osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Patch Set 3: WTF? The code I pushed into gerrit does not resemble the code that is shown here ?!? It keeps showing an old version of the patch. -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:26:50 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:26:50 +0000 Subject: [ABANDON] osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Harald Welte has abandoned this change. Change subject: Add new unit-test for transmit power computation code ...................................................................... Abandoned gerrit fails to recognize new versions. -- To view, visit https://gerrit.osmocom.org/1766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I8fd9637c97c410e8462b3bb997d601846383958e Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:27:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:27:04 +0000 Subject: [MERGED] osmo-bts[master]: tx_power: Change PA calibration tables to use delta vales In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: tx_power: Change PA calibration tables to use delta vales ...................................................................... tx_power: Change PA calibration tables to use delta vales It seems more user friendly to look at a calibration table in terms of the delta (positive or negative) compared to the nominal gain value, rather than a collection of absolute gain values. It has the added benefit that the (API/data model) user doesn't have to specify a gain value for each ARFCN, but rather can rely on the default nominal gain in absence of a calibration table for this specific unit. Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad --- M include/osmo-bts/tx_power.h M src/common/tx_power.c 2 files changed, 3 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h index 1d76864..8d099bc 100644 --- a/include/osmo-bts/tx_power.h +++ b/include/osmo-bts/tx_power.h @@ -8,7 +8,7 @@ /* PA calibration table */ struct pa_calibration { - int gain_mdB[1024]; /* gain provided at given ARFCN */ + int delta_mdB[1024]; /* gain delta at given ARFCN */ /* FIXME: thermal calibration */ }; diff --git a/src/common/tx_power.c b/src/common/tx_power.c index f8adb6a..c517918 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -33,12 +33,12 @@ static int get_pa_drive_level_mdBm(const struct power_amp *pa, int desired_p_out_mdBm, unsigned int arfcn) { - if (arfcn >= ARRAY_SIZE(pa->calib.gain_mdB)) + if (arfcn >= ARRAY_SIZE(pa->calib.delta_mdB)) return INT_MIN; /* FIXME: temperature compensation */ - return desired_p_out_mdBm - pa->calib.gain_mdB[arfcn]; + return desired_p_out_mdBm - pa->nominal_gain_mdB - pa->calib.delta_mdB[arfcn]; } /* maximum output power of the system */ -- To view, visit https://gerrit.osmocom.org/1765 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:27:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:27:04 +0000 Subject: [MERGED] osmo-bts[master]: tx_power: various cosmetic fixes in comments In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: tx_power: various cosmetic fixes in comments ...................................................................... tx_power: various cosmetic fixes in comments Change-Id: I542b74d79bc8ffedd7c435b41b042edd5152f61c --- M src/common/tx_power.c 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/tx_power.c b/src/common/tx_power.c index d8c90b2..f8adb6a 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -58,7 +58,7 @@ } /* calculate the target total output power required, reduced by both - * OML and RSL, but ignoring the attenutation required for power ramping and + * OML and RSL, but ignoring the attenuation required for power ramping and * thermal management */ int get_p_target_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_ie) { @@ -71,7 +71,7 @@ } /* calculate the actual total output power required, taking into account the - * attenutation required for power ramping but not thermal management */ + * attenuation required for power ramping but not thermal management */ int get_p_actual_mdBm(struct gsm_bts_trx *trx, int p_target_mdBm) { struct trx_power_params *tpp = &trx->power_params; @@ -81,7 +81,7 @@ } /* calculate the effective total output power required, taking into account the - * attenutation required for power ramping and thermal management */ + * attenuation required for power ramping and thermal management */ int get_p_eff_mdBm(struct gsm_bts_trx *trx, int p_target_mdBm) { struct trx_power_params *tpp = &trx->power_params; @@ -144,7 +144,7 @@ * one hand side to avoid very fast dynamic load changes towards the PA power * supply, but is also needed in order to avoid a DoS by too many subscriber * attempting to register at the same time. Rather, grow the cell slowly in - * radius than start with the full raduis at once. */ + * radius than start with the full radius at once. */ static int we_are_ramping_up(struct gsm_bts_trx *trx) { @@ -158,7 +158,7 @@ static void power_ramp_do_step(struct gsm_bts_trx *trx, int first); -/* timer call-back for the ramp tumer */ +/* timer call-back for the ramp timer */ static void power_ramp_timer_cb(void *_trx) { struct gsm_bts_trx *trx = _trx; -- To view, visit https://gerrit.osmocom.org/1764 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I542b74d79bc8ffedd7c435b41b042edd5152f61c Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:27:05 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:27:05 +0000 Subject: [MERGED] osmo-bts[master]: Revert "sysmobts: Add correct nominal transmit power for sys... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Revert "sysmobts: Add correct nominal transmit power for sysmoBTS 1020" ...................................................................... Revert "sysmobts: Add correct nominal transmit power for sysmoBTS 1020" This reverts commit 1965b0d88082e427930f95071e992f0d9be79047, which was a premature change. The 10dB gain are not the power of the TRX board, but are due to an internal, factory mounted PA, i.e. the trx_power_params.pa. This will be introduced after adding a set of tx_power.c unit tests. Change-Id: I524b63c51fb0fe1f90ced28486a8e712f2dc50ae --- M src/osmo-bts-sysmo/utils.c 1 file changed, 0 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index 8f54e6f..a636ae1 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -125,8 +125,6 @@ case 1002: /* 200mW (23 dBm) nominal power */ return 23; - case 1020: - return 33; case 2050: /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) * if the second TRX is not used. */ -- To view, visit https://gerrit.osmocom.org/1763 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I524b63c51fb0fe1f90ced28486a8e712f2dc50ae Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:30:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:30:47 +0000 Subject: [PATCH] osmo-bts[master]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1767 to look at the new patch set (#4). sysmobts: fully support trx_power_params The simplistic approach of sysmobts_get_nominal_power() is insufficient to cope for devices that have an internal PA. The Actual transceiver board is driven to a certain level (0..23 dBm typically), and the external PA must be handled independent of that. Increasing the return value of sysmobts_get_nominal_power() would result in the sysmoBTS mainboard attempting to reach a higher power, which is wrong. This change affects sysmoBTS 1020 and 1100. It causes power-ramping to be used by default. For 1002 and 2050, no behavior change is expected. Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 --- M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/sysmobts_vty.c M src/osmo-bts-sysmo/utils.c M src/osmo-bts-sysmo/utils.h M tests/tx_power/tx_power_test.c 5 files changed, 44 insertions(+), 34 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/67/1767/4 diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index c021368..8eb6fcc 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1309,7 +1310,7 @@ LOGP(DL1C, LOGL_INFO, "Using external attenuator.\n"); sysp->u.activateRfReq.rfTrx.u8UseExtAtten = 1; sysp->u.activateRfReq.rfTrx.fMaxTxPower = - sysmobts_get_nominal_power(trx); + (float) get_p_trxout_target_mdBm(trx, 0) / 1000; } #endif /* 2.2.0 */ #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,8,1) @@ -1797,6 +1798,44 @@ #endif +static void set_power_param(struct trx_power_params *out, + int trx_p_max_out_dBm, + int int_pa_nominal_gain_dB) +{ + out->trx_p_max_out_mdBm = to_mdB(trx_p_max_out_dBm); + out->pa.nominal_gain_mdB = to_mdB(int_pa_nominal_gain_dB); +} + +static void fill_trx_power_params(struct gsm_bts_trx *trx, + struct phy_instance *pinst) +{ + struct femtol1_hdl *fl1h = pinst->u.sysmobts.hdl; + + switch (fl1h->hw_info.model_nr) { + case 1020: + set_power_param(&trx->power_params, 23, 10); + break; + case 1100: + set_power_param(&trx->power_params, 23, 17); + break; + case 2050: + set_power_param(&trx->power_params, 37, 0); + break; + default: + LOGP(DL1C, LOGL_NOTICE, "Unknown/Unsupported " + "sysmoBTS Model Number %u\n", + fl1h->hw_info.model_nr); + /* fall-through */ + case 0xffff: + /* sysmoBTS 1002 without any setting in EEPROM */ + LOGP(DL1C, LOGL_NOTICE, "Assuming 1002 for sysmoBTS " + "Model number %u\n", fl1h->hw_info.model_nr); + case 1002: + set_power_param(&trx->power_params, 23, 0); + } +} + + int bts_model_phy_link_open(struct phy_link *plink) { struct phy_instance *pinst = phy_instance_by_num(plink, 0); @@ -1812,16 +1851,17 @@ return -EIO; } + fill_trx_power_params(pinst->trx, pinst); + bts = pinst->trx->bts; if (pinst->trx == bts->c0) { int rc; - rc = sysmobts_get_nominal_power(bts->c0); + rc = get_p_max_out_mdBm(bts->c0); if (rc < 0) { LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal " "transmit power. Assuming 23dBm.\n"); } bts->c0->nominal_power = rc; - bts->c0->power_params.trx_p_max_out_mdBm = to_mdB(rc); } phy_link_state_set(plink, PHY_LINK_CONNECTED); diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index e67d8be..a1e6555 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -438,7 +438,7 @@ void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx) { - if (trx->nominal_power != sysmobts_get_nominal_power(trx)) + if (trx->nominal_power != get_p_max_out_mdBm(trx)) vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power, VTY_NEWLINE); } diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..be6051a 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -112,29 +112,3 @@ /* give up */ return -1; } - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx) -{ - struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); - - switch (fl1h->hw_info.model_nr) { - case 0: - case 0xffff: - /* old units have empty flash where the model number is - * stored in later units */ - case 1002: - /* 200mW (23 dBm) nominal power */ - return 23; - case 2050: - /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) - * if the second TRX is not used. */ - return 37; - default: - LOGP(DL1C, LOGL_ERROR, "Model number %u/0x%x not known.\n", - fl1h->hw_info.model_nr, fl1h->hw_info.model_nr); - break; - } - return -1; -} - - diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h index 58e3324..45908d5 100644 --- a/src/osmo-bts-sysmo/utils.h +++ b/src/osmo-bts-sysmo/utils.h @@ -9,6 +9,4 @@ int band_femto2osmo(GsmL1_FreqBand_t band); int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn); - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx); #endif diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c index 32a2ab8..d657362 100644 --- a/tests/tx_power/tx_power_test.c +++ b/tests/tx_power/tx_power_test.c @@ -57,7 +57,6 @@ .user_gain_mdB = 0, .pa = { .nominal_gain_mdB = to_mdB(10), - .calib.gain_mdB = { to_mdB(10), }, }, .user_pa = { .nominal_gain_mdB = 0, @@ -76,7 +75,6 @@ .user_gain_mdB = 0, .pa = { .nominal_gain_mdB = to_mdB(17), - .calib.gain_mdB = { to_mdB(17), }, }, .user_pa = { .nominal_gain_mdB = 0, -- To view, visit https://gerrit.osmocom.org/1767 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:30:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:30:47 +0000 Subject: [PATCH] osmo-bts[master]: Add new unit-test for transmit power computation code Message-ID: Review at https://gerrit.osmocom.org/1768 Add new unit-test for transmit power computation code This tests the computations of the tx_power.c code using sysmoBTS 1002, 1020, 1100 and 2050 values, as well as the power ramping code. Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.err A tests/tx_power/tx_power_test.ok 8 files changed, 320 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/68/1768/1 diff --git a/.gitignore b/.gitignore index 224b77c..b449f92 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/tx_power_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..bfc9bad 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,10 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +cat $abs_srcdir/tx_power/tx_power_test.err > experr +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [experr]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..3d4377a --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok tx_power_test.err + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..32a2ab8 --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,241 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + .calib.gain_mdB = { to_mdB(10), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + .calib.gain_mdB = { to_mdB(17), }, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + struct trx_power_params *tpp = &trx->power_params; + + printf("CHANGE_POWER(%d)\n", p_trxout_mdBm); + + if (tpp->ramp.attenuation_mdB == 0) + exit(0); + + power_trx_change_compl(trx, p_trxout_mdBm); + return 0; +} + +static void test_power_ramp(struct gsm_bts_trx *trx, int dBm) +{ + printf("Testing tx_power ramping for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + + power_ramp_start(trx, to_mdB(dBm), 0); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DL1C].loglevel = LOGL_DEBUG; + log_set_print_filename(osmo_stderr_target, 0); + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* test error case / excess power (40 dBm is too much) */ + test_power_ramp(trx, 40); + /* test actaul ramping to full 33 dBm */ + test_power_ramp(trx, 33); + + while (1) { + osmo_select_main(0); + } +} diff --git a/tests/tx_power/tx_power_test.err b/tests/tx_power/tx_power_test.err new file mode 100644 index 0000000..bf33b42 --- /dev/null +++ b/tests/tx_power/tx_power_test.err @@ -0,0 +1,38 @@ +power_ramp_start(cur=0, tgt=40000) +Asked to ramp power up to 40000 mdBm, which exceeds P_max_out (33000) +power_ramp_start(cur=0, tgt=33000) +ramp_timer_cb(cur_pout=2000, tgt_pout=33000, ramp_att=31000, therm_att=0, user_gain=0) +ramping TRX board output power to -8000 mdBm. +ramp_timer_cb(cur_pout=4000, tgt_pout=33000, ramp_att=29000, therm_att=0, user_gain=0) +ramping TRX board output power to -6000 mdBm. +ramp_timer_cb(cur_pout=6000, tgt_pout=33000, ramp_att=27000, therm_att=0, user_gain=0) +ramping TRX board output power to -4000 mdBm. +ramp_timer_cb(cur_pout=8000, tgt_pout=33000, ramp_att=25000, therm_att=0, user_gain=0) +ramping TRX board output power to -2000 mdBm. +ramp_timer_cb(cur_pout=10000, tgt_pout=33000, ramp_att=23000, therm_att=0, user_gain=0) +ramping TRX board output power to 0 mdBm. +ramp_timer_cb(cur_pout=12000, tgt_pout=33000, ramp_att=21000, therm_att=0, user_gain=0) +ramping TRX board output power to 2000 mdBm. +ramp_timer_cb(cur_pout=14000, tgt_pout=33000, ramp_att=19000, therm_att=0, user_gain=0) +ramping TRX board output power to 4000 mdBm. +ramp_timer_cb(cur_pout=16000, tgt_pout=33000, ramp_att=17000, therm_att=0, user_gain=0) +ramping TRX board output power to 6000 mdBm. +ramp_timer_cb(cur_pout=18000, tgt_pout=33000, ramp_att=15000, therm_att=0, user_gain=0) +ramping TRX board output power to 8000 mdBm. +ramp_timer_cb(cur_pout=20000, tgt_pout=33000, ramp_att=13000, therm_att=0, user_gain=0) +ramping TRX board output power to 10000 mdBm. +ramp_timer_cb(cur_pout=22000, tgt_pout=33000, ramp_att=11000, therm_att=0, user_gain=0) +ramping TRX board output power to 12000 mdBm. +ramp_timer_cb(cur_pout=24000, tgt_pout=33000, ramp_att=9000, therm_att=0, user_gain=0) +ramping TRX board output power to 14000 mdBm. +ramp_timer_cb(cur_pout=26000, tgt_pout=33000, ramp_att=7000, therm_att=0, user_gain=0) +ramping TRX board output power to 16000 mdBm. +ramp_timer_cb(cur_pout=28000, tgt_pout=33000, ramp_att=5000, therm_att=0, user_gain=0) +ramping TRX board output power to 18000 mdBm. +ramp_timer_cb(cur_pout=30000, tgt_pout=33000, ramp_att=3000, therm_att=0, user_gain=0) +ramping TRX board output power to 20000 mdBm. +ramp_timer_cb(cur_pout=32000, tgt_pout=33000, ramp_att=1000, therm_att=0, user_gain=0) +ramping TRX board output power to 22000 mdBm. +ramp_timer_cb(cur_pout=33000, tgt_pout=33000, ramp_att=0, therm_att=0, user_gain=0) +ramping TRX board output power to 23000 mdBm. + \ No newline at end of file diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..ceb88ab --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,23 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 +Testing tx_power ramping for sysmoBTS 1020 +Testing tx_power ramping for sysmoBTS 1020 +CHANGE_POWER(-8000) +CHANGE_POWER(-6000) +CHANGE_POWER(-4000) +CHANGE_POWER(-2000) +CHANGE_POWER(0) +CHANGE_POWER(2000) +CHANGE_POWER(4000) +CHANGE_POWER(6000) +CHANGE_POWER(8000) +CHANGE_POWER(10000) +CHANGE_POWER(12000) +CHANGE_POWER(14000) +CHANGE_POWER(16000) +CHANGE_POWER(18000) +CHANGE_POWER(20000) +CHANGE_POWER(22000) +CHANGE_POWER(23000) -- To view, visit https://gerrit.osmocom.org/1768 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 7 20:33:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 7 Feb 2017 20:33:38 +0000 Subject: [PATCH] osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Add new unit-test for transmit power computation code This tests the computations of the tx_power.c code using sysmoBTS 1002, 1020, 1100 and 2050 values, as well as the power ramping code. Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.err A tests/tx_power/tx_power_test.ok 8 files changed, 318 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/68/1768/2 diff --git a/.gitignore b/.gitignore index 224b77c..b449f92 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/tx_power_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..bfc9bad 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,10 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +cat $abs_srcdir/tx_power/tx_power_test.err > experr +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [experr]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..3d4377a --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok tx_power_test.err + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..d657362 --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,239 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + struct trx_power_params *tpp = &trx->power_params; + + printf("CHANGE_POWER(%d)\n", p_trxout_mdBm); + + if (tpp->ramp.attenuation_mdB == 0) + exit(0); + + power_trx_change_compl(trx, p_trxout_mdBm); + return 0; +} + +static void test_power_ramp(struct gsm_bts_trx *trx, int dBm) +{ + printf("Testing tx_power ramping for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + + power_ramp_start(trx, to_mdB(dBm), 0); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DL1C].loglevel = LOGL_DEBUG; + log_set_print_filename(osmo_stderr_target, 0); + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* test error case / excess power (40 dBm is too much) */ + test_power_ramp(trx, 40); + /* test actaul ramping to full 33 dBm */ + test_power_ramp(trx, 33); + + while (1) { + osmo_select_main(0); + } +} diff --git a/tests/tx_power/tx_power_test.err b/tests/tx_power/tx_power_test.err new file mode 100644 index 0000000..bf33b42 --- /dev/null +++ b/tests/tx_power/tx_power_test.err @@ -0,0 +1,38 @@ +power_ramp_start(cur=0, tgt=40000) +Asked to ramp power up to 40000 mdBm, which exceeds P_max_out (33000) +power_ramp_start(cur=0, tgt=33000) +ramp_timer_cb(cur_pout=2000, tgt_pout=33000, ramp_att=31000, therm_att=0, user_gain=0) +ramping TRX board output power to -8000 mdBm. +ramp_timer_cb(cur_pout=4000, tgt_pout=33000, ramp_att=29000, therm_att=0, user_gain=0) +ramping TRX board output power to -6000 mdBm. +ramp_timer_cb(cur_pout=6000, tgt_pout=33000, ramp_att=27000, therm_att=0, user_gain=0) +ramping TRX board output power to -4000 mdBm. +ramp_timer_cb(cur_pout=8000, tgt_pout=33000, ramp_att=25000, therm_att=0, user_gain=0) +ramping TRX board output power to -2000 mdBm. +ramp_timer_cb(cur_pout=10000, tgt_pout=33000, ramp_att=23000, therm_att=0, user_gain=0) +ramping TRX board output power to 0 mdBm. +ramp_timer_cb(cur_pout=12000, tgt_pout=33000, ramp_att=21000, therm_att=0, user_gain=0) +ramping TRX board output power to 2000 mdBm. +ramp_timer_cb(cur_pout=14000, tgt_pout=33000, ramp_att=19000, therm_att=0, user_gain=0) +ramping TRX board output power to 4000 mdBm. +ramp_timer_cb(cur_pout=16000, tgt_pout=33000, ramp_att=17000, therm_att=0, user_gain=0) +ramping TRX board output power to 6000 mdBm. +ramp_timer_cb(cur_pout=18000, tgt_pout=33000, ramp_att=15000, therm_att=0, user_gain=0) +ramping TRX board output power to 8000 mdBm. +ramp_timer_cb(cur_pout=20000, tgt_pout=33000, ramp_att=13000, therm_att=0, user_gain=0) +ramping TRX board output power to 10000 mdBm. +ramp_timer_cb(cur_pout=22000, tgt_pout=33000, ramp_att=11000, therm_att=0, user_gain=0) +ramping TRX board output power to 12000 mdBm. +ramp_timer_cb(cur_pout=24000, tgt_pout=33000, ramp_att=9000, therm_att=0, user_gain=0) +ramping TRX board output power to 14000 mdBm. +ramp_timer_cb(cur_pout=26000, tgt_pout=33000, ramp_att=7000, therm_att=0, user_gain=0) +ramping TRX board output power to 16000 mdBm. +ramp_timer_cb(cur_pout=28000, tgt_pout=33000, ramp_att=5000, therm_att=0, user_gain=0) +ramping TRX board output power to 18000 mdBm. +ramp_timer_cb(cur_pout=30000, tgt_pout=33000, ramp_att=3000, therm_att=0, user_gain=0) +ramping TRX board output power to 20000 mdBm. +ramp_timer_cb(cur_pout=32000, tgt_pout=33000, ramp_att=1000, therm_att=0, user_gain=0) +ramping TRX board output power to 22000 mdBm. +ramp_timer_cb(cur_pout=33000, tgt_pout=33000, ramp_att=0, therm_att=0, user_gain=0) +ramping TRX board output power to 23000 mdBm. + \ No newline at end of file diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..ceb88ab --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,23 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 +Testing tx_power ramping for sysmoBTS 1020 +Testing tx_power ramping for sysmoBTS 1020 +CHANGE_POWER(-8000) +CHANGE_POWER(-6000) +CHANGE_POWER(-4000) +CHANGE_POWER(-2000) +CHANGE_POWER(0) +CHANGE_POWER(2000) +CHANGE_POWER(4000) +CHANGE_POWER(6000) +CHANGE_POWER(8000) +CHANGE_POWER(10000) +CHANGE_POWER(12000) +CHANGE_POWER(14000) +CHANGE_POWER(16000) +CHANGE_POWER(18000) +CHANGE_POWER(20000) +CHANGE_POWER(22000) +CHANGE_POWER(23000) -- To view, visit https://gerrit.osmocom.org/1768 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:12:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:12:47 +0000 Subject: osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1768 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:12:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:12:51 +0000 Subject: [MERGED] osmo-bts[master]: Add new unit-test for transmit power computation code In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add new unit-test for transmit power computation code ...................................................................... Add new unit-test for transmit power computation code This tests the computations of the tx_power.c code using sysmoBTS 1002, 1020, 1100 and 2050 values, as well as the power ramping code. Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 --- M .gitignore M configure.ac M tests/Makefile.am M tests/testsuite.at A tests/tx_power/Makefile.am A tests/tx_power/tx_power_test.c A tests/tx_power/tx_power_test.err A tests/tx_power/tx_power_test.ok 8 files changed, 318 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/.gitignore b/.gitignore index 224b77c..b449f92 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ tests/misc/misc_test tests/bursts/bursts_test tests/handover/handover_test +tests/tx_power/tx_power_test tests/testsuite tests/testsuite.log diff --git a/configure.ac b/configure.ac index 3fd6b8a..001e10e 100644 --- a/configure.ac +++ b/configure.ac @@ -144,4 +144,5 @@ tests/misc/Makefile tests/bursts/Makefile tests/handover/Makefile + tests/tx_power/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 54ff029..6635ae7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher agch misc bursts handover +SUBDIRS = paging cipher agch misc bursts handover tx_power if ENABLE_SYSMOBTS SUBDIRS += sysmobts diff --git a/tests/testsuite.at b/tests/testsuite.at index 171fade..bfc9bad 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -36,3 +36,10 @@ cat $abs_srcdir/handover/handover_test.ok > expout AT_CHECK([$abs_top_builddir/tests/handover/handover_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([tx_power]) +AT_KEYWORDS([tx_power]) +cat $abs_srcdir/tx_power/tx_power_test.ok > expout +cat $abs_srcdir/tx_power/tx_power_test.err > experr +AT_CHECK([$abs_top_builddir/tests/tx_power/tx_power_test], [], [expout], [experr]) +AT_CLEANUP diff --git a/tests/tx_power/Makefile.am b/tests/tx_power/Makefile.am new file mode 100644 index 0000000..3d4377a --- /dev/null +++ b/tests/tx_power/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)$(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) +noinst_PROGRAMS = tx_power_test +EXTRA_DIST = tx_power_test.ok tx_power_test.err + +tx_power_test_SOURCES = tx_power_test.c $(srcdir)/../stubs.c +tx_power_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c new file mode 100644 index 0000000..d657362 --- /dev/null +++ b/tests/tx_power/tx_power_test.c @@ -0,0 +1,239 @@ +/* Test cases for tx_power.c Transmit Power Computation */ + +/* (C) 2017 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + + +static const struct trx_power_params tpp_1002 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(23), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1020 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(33), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(10), + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_1100 = { + .trx_p_max_out_mdBm = to_mdB(23), + .p_total_tgt_mdBm = to_mdB(40), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = to_mdB(17), + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static const struct trx_power_params tpp_2050 = { + .trx_p_max_out_mdBm = to_mdB(37), + .p_total_tgt_mdBm = to_mdB(37), + .p_total_cur_mdBm = 0, + .thermal_attenuation_mdB = 0, + .user_gain_mdB = 0, + .pa = { + .nominal_gain_mdB = 0, + }, + .user_pa = { + .nominal_gain_mdB = 0, + }, + .ramp = { + .step_size_mdB = to_mdB(2), + .step_interval_sec = 1, + }, +}; + +static void test_sbts1002(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1002\n"); + trx->power_params = tpp_1002; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(23)); + /* at max_power_red = 0, we expect full 23dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(23)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 21dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(21)); + /* at 1 step (of 2dB), we expect full 23-2-2=19 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(19)); + /* at 2 steps (= 4dB), we expect 23-2-4=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts1020(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(33)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(33)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 31dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(31)); + /* at 1 step (of 2dB), we expect full 33-2-2=29 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(29)); + /* at 2 steps (= 4dB), we expect 33-2-4-10=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + + +static void test_sbts1100(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 1100\n"); + trx->power_params = tpp_1100; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(40)); + /* at max_power_red = 0, we expect full 33dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(40)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 38dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(38)); + /* at 1 step (of 2dB), we expect full 40-2-2=36 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(36)); + /* at 2 steps (= 4dB), we expect 40-2-4-17=17*/ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(17)); +} + +static void test_sbts2050(struct gsm_bts_trx *trx) +{ + printf("Testing tx_power calculation for sysmoBTS 2050\n"); + trx->power_params = tpp_2050; + trx->max_power_red = 0; + OSMO_ASSERT(get_p_max_out_mdBm(trx) == to_mdB(37)); + /* at max_power_red = 0, we expect full 37dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(37)); + trx->max_power_red = 2; + /* at max_power_red = 2, we expect 35dBm */ + OSMO_ASSERT(get_p_nominal_mdBm(trx) == to_mdB(35)); + /* at 1 step (of 2dB), we expect full 37-2-2=33 dBm */ + OSMO_ASSERT(get_p_target_mdBm(trx, 1) == to_mdB(33)); + /* at 2 steps (= 4dB), we expect 37-2-4=31dBm */ + OSMO_ASSERT(get_p_trxout_target_mdBm(trx, 2) == to_mdB(31)); +} + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + struct trx_power_params *tpp = &trx->power_params; + + printf("CHANGE_POWER(%d)\n", p_trxout_mdBm); + + if (tpp->ramp.attenuation_mdB == 0) + exit(0); + + power_trx_change_compl(trx, p_trxout_mdBm); + return 0; +} + +static void test_power_ramp(struct gsm_bts_trx *trx, int dBm) +{ + printf("Testing tx_power ramping for sysmoBTS 1020\n"); + trx->power_params = tpp_1020; + trx->max_power_red = 0; + + power_ramp_start(trx, to_mdB(dBm), 0); +} + +int main(int argc, char **argv) +{ + static struct gsm_bts *bts; + struct gsm_bts_trx *trx; + void *tall_bts_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 0); + + bts_log_init(NULL); + osmo_stderr_target->categories[DL1C].loglevel = LOGL_DEBUG; + log_set_print_filename(osmo_stderr_target, 0); + + bts = gsm_bts_alloc(tall_bts_ctx); + if (!bts) { + fprintf(stderr, "Failed to create BTS structure\n"); + exit(1); + } + trx = gsm_bts_trx_alloc(bts); + if (!trx) { + fprintf(stderr, "Failed to TRX structure\n"); + exit(1); + } + + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + test_sbts1002(trx); + test_sbts1020(trx); + test_sbts1100(trx); + test_sbts2050(trx); + + /* test error case / excess power (40 dBm is too much) */ + test_power_ramp(trx, 40); + /* test actaul ramping to full 33 dBm */ + test_power_ramp(trx, 33); + + while (1) { + osmo_select_main(0); + } +} diff --git a/tests/tx_power/tx_power_test.err b/tests/tx_power/tx_power_test.err new file mode 100644 index 0000000..bf33b42 --- /dev/null +++ b/tests/tx_power/tx_power_test.err @@ -0,0 +1,38 @@ +power_ramp_start(cur=0, tgt=40000) +Asked to ramp power up to 40000 mdBm, which exceeds P_max_out (33000) +power_ramp_start(cur=0, tgt=33000) +ramp_timer_cb(cur_pout=2000, tgt_pout=33000, ramp_att=31000, therm_att=0, user_gain=0) +ramping TRX board output power to -8000 mdBm. +ramp_timer_cb(cur_pout=4000, tgt_pout=33000, ramp_att=29000, therm_att=0, user_gain=0) +ramping TRX board output power to -6000 mdBm. +ramp_timer_cb(cur_pout=6000, tgt_pout=33000, ramp_att=27000, therm_att=0, user_gain=0) +ramping TRX board output power to -4000 mdBm. +ramp_timer_cb(cur_pout=8000, tgt_pout=33000, ramp_att=25000, therm_att=0, user_gain=0) +ramping TRX board output power to -2000 mdBm. +ramp_timer_cb(cur_pout=10000, tgt_pout=33000, ramp_att=23000, therm_att=0, user_gain=0) +ramping TRX board output power to 0 mdBm. +ramp_timer_cb(cur_pout=12000, tgt_pout=33000, ramp_att=21000, therm_att=0, user_gain=0) +ramping TRX board output power to 2000 mdBm. +ramp_timer_cb(cur_pout=14000, tgt_pout=33000, ramp_att=19000, therm_att=0, user_gain=0) +ramping TRX board output power to 4000 mdBm. +ramp_timer_cb(cur_pout=16000, tgt_pout=33000, ramp_att=17000, therm_att=0, user_gain=0) +ramping TRX board output power to 6000 mdBm. +ramp_timer_cb(cur_pout=18000, tgt_pout=33000, ramp_att=15000, therm_att=0, user_gain=0) +ramping TRX board output power to 8000 mdBm. +ramp_timer_cb(cur_pout=20000, tgt_pout=33000, ramp_att=13000, therm_att=0, user_gain=0) +ramping TRX board output power to 10000 mdBm. +ramp_timer_cb(cur_pout=22000, tgt_pout=33000, ramp_att=11000, therm_att=0, user_gain=0) +ramping TRX board output power to 12000 mdBm. +ramp_timer_cb(cur_pout=24000, tgt_pout=33000, ramp_att=9000, therm_att=0, user_gain=0) +ramping TRX board output power to 14000 mdBm. +ramp_timer_cb(cur_pout=26000, tgt_pout=33000, ramp_att=7000, therm_att=0, user_gain=0) +ramping TRX board output power to 16000 mdBm. +ramp_timer_cb(cur_pout=28000, tgt_pout=33000, ramp_att=5000, therm_att=0, user_gain=0) +ramping TRX board output power to 18000 mdBm. +ramp_timer_cb(cur_pout=30000, tgt_pout=33000, ramp_att=3000, therm_att=0, user_gain=0) +ramping TRX board output power to 20000 mdBm. +ramp_timer_cb(cur_pout=32000, tgt_pout=33000, ramp_att=1000, therm_att=0, user_gain=0) +ramping TRX board output power to 22000 mdBm. +ramp_timer_cb(cur_pout=33000, tgt_pout=33000, ramp_att=0, therm_att=0, user_gain=0) +ramping TRX board output power to 23000 mdBm. + \ No newline at end of file diff --git a/tests/tx_power/tx_power_test.ok b/tests/tx_power/tx_power_test.ok new file mode 100644 index 0000000..ceb88ab --- /dev/null +++ b/tests/tx_power/tx_power_test.ok @@ -0,0 +1,23 @@ +Testing tx_power calculation for sysmoBTS 1002 +Testing tx_power calculation for sysmoBTS 1020 +Testing tx_power calculation for sysmoBTS 1100 +Testing tx_power calculation for sysmoBTS 2050 +Testing tx_power ramping for sysmoBTS 1020 +Testing tx_power ramping for sysmoBTS 1020 +CHANGE_POWER(-8000) +CHANGE_POWER(-6000) +CHANGE_POWER(-4000) +CHANGE_POWER(-2000) +CHANGE_POWER(0) +CHANGE_POWER(2000) +CHANGE_POWER(4000) +CHANGE_POWER(6000) +CHANGE_POWER(8000) +CHANGE_POWER(10000) +CHANGE_POWER(12000) +CHANGE_POWER(14000) +CHANGE_POWER(16000) +CHANGE_POWER(18000) +CHANGE_POWER(20000) +CHANGE_POWER(22000) +CHANGE_POWER(23000) -- To view, visit https://gerrit.osmocom.org/1768 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1cc88d4c6edff326e2e67d4f869aa02c9b2b1ac5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:24:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:24:04 +0000 Subject: openbsc[master]: vty: remove ignored logging parameters In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1583 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:28:03 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:28:03 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 (2 comments) let's keep this in review for a bit until other people had a chance to comment. It is quite a singnificant change from the (many years long) broken behavior... https://gerrit.osmocom.org/#/c/1582/3/src/logging.c File src/logging.c: Line 163: /* explicit check for "everything" loglevel */ we can see from the two lines of code that it is an explicit check. However, what I cannot see is why it is required, given that the loglevel_strs contain a corresponding record. Please check if this is really needed, and if so: clarify in the comment. Only difference seems to be the case? Line 176: if (lvl == LOGL_EVERY) same as above? -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:28:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:28:42 +0000 Subject: libosmo-netif[master]: Fix potential NULL dereference In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1639 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5baf369dbf3948565614476980a32be59abaf42a Gerrit-PatchSet: 2 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:28:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:28:44 +0000 Subject: [MERGED] libosmo-netif[master]: Fix potential NULL dereference In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Fix potential NULL dereference ...................................................................... Fix potential NULL dereference Change-Id: I5baf369dbf3948565614476980a32be59abaf42a --- M src/osmux.c 1 file changed, 2 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmux.c b/src/osmux.c index 0bee9cc..913d68f 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -394,7 +394,8 @@ LOGP(DLMIB, LOGL_DEBUG, "invoking delivery function\n"); #endif batch_msg = osmux_build_batch(batch, h->batch_size, h->batch_factor); - + if (!batch_msg) + return; h->stats.output_osmux_msgs++; h->stats.output_osmux_bytes += batch_msg->len; -- To view, visit https://gerrit.osmocom.org/1639 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5baf369dbf3948565614476980a32be59abaf42a Gerrit-PatchSet: 2 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:30:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:30:18 +0000 Subject: osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:33:00 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:33:00 +0000 Subject: openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (2) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1743 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 08:33:11 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 08:33:11 +0000 Subject: [MERGED] openbsc[master]: vty tests: more attempts to resolve 'Broken Pipe' error (2) In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: vty tests: more attempts to resolve 'Broken Pipe' error (2) ...................................................................... vty tests: more attempts to resolve 'Broken Pipe' error (2) Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda --- 0 files changed, 0 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified -- To view, visit https://gerrit.osmocom.org/1743 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 09:37:39 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 09:37:39 +0000 Subject: [MERGED] openbsc[master]: vty: remove ignored logging parameters In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: vty: remove ignored logging parameters ...................................................................... vty: remove ignored logging parameters Since ce9fec3e896571835ac5bfd2980d6836f2b29f0d libosmocore ignores parameters to log_vty_command_* functions. Hence parameter of logging_vty_add_cmds() is ignored too. As we depend on much later libosmocore version anyway, we can simplify code somewhat by removing parameters which will be ignored anyway. Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991 --- M openbsc/include/openbsc/vty.h M openbsc/src/gprs/gb_proxy_main.c M openbsc/src/gprs/gtphub_main.c M openbsc/src/gprs/sgsn_main.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/osmo-bsc/osmo_bsc_main.c M openbsc/src/osmo-bsc_mgcp/mgcp_main.c M openbsc/src/osmo-bsc_nat/bsc_nat.c M openbsc/src/osmo-bsc_nat/bsc_nat_vty.c M openbsc/src/osmo-nitb/bsc_hack.c 10 files changed, 12 insertions(+), 12 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index ad2cd2a..f79eab5 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -44,7 +44,7 @@ extern void bsc_replace_string(void *ctx, char **dst, const char *newstr); struct log_info; -int bsc_vty_init(const struct log_info *cat, struct gsm_network *network); +int bsc_vty_init(struct gsm_network *network); int bsc_vty_init_extra(void); struct gsm_network *gsmnet_from_vty(struct vty *vty); diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c index 04875c7..69a93b6 100644 --- a/openbsc/src/gprs/gb_proxy_main.c +++ b/openbsc/src/gprs/gb_proxy_main.c @@ -241,7 +241,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&gprs_log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&gprs_log_info); gbproxy_vty_init(); diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c index 46360f9..73a122c 100644 --- a/openbsc/src/gprs/gtphub_main.c +++ b/openbsc/src/gprs/gtphub_main.c @@ -311,7 +311,7 @@ vty_info.copyright = gtphub_copyright; vty_init(&vty_info); - logging_vty_add_cmds(>phub_log_info); + logging_vty_add_cmds(NULL); gtphub_vty_init(hub, cfg); rate_ctr_init(osmo_gtphub_ctx); diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index b4be631..af5cced 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -340,7 +340,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&gprs_log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&gprs_log_info); sgsn_vty_init(); ctrl_vty_init(tall_bsc_ctx); diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 7d3b4af..00acbc7 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -3851,7 +3851,7 @@ extern int bsc_vty_init_extra(void); -int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) +int bsc_vty_init(struct gsm_network *network) { cfg_ts_pchan_cmd.string = vty_cmd_string_from_valstr(tall_bsc_ctx, @@ -3887,7 +3887,7 @@ install_element_ve(&show_paging_cmd); install_element_ve(&show_paging_group_cmd); - logging_vty_add_cmds(cat); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(); install_element(GSMNET_NODE, &cfg_net_neci_cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 1d96bb4..adce775 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -212,7 +212,7 @@ /* This needs to precede handle_options() */ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - bsc_vty_init(&log_info, bsc_gsmnet); + bsc_vty_init(bsc_gsmnet); bsc_msg_lst_vty_init(tall_bsc_ctx, &access_lists, BSC_NODE); ctrl_vty_init(tall_bsc_ctx); diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index 964768e..4ea0700 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -220,7 +220,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&log_info); mgcp_vty_init(); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index a4dd679..80e89fd 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1616,7 +1616,7 @@ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(&log_info); bsc_nat_vty_init(nat); ctrl_vty_init(tall_bsc_ctx); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 706e507..deb98fc 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1329,8 +1329,8 @@ /* called by the telnet interface... we have our own init above */ -int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) +int bsc_vty_init(struct gsm_network *network) { - logging_vty_add_cmds(cat); + logging_vty_add_cmds(NULL); return 0; } diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index bbcdd1b..2bdfada 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -283,7 +283,7 @@ } /* Initialize VTY */ - bsc_vty_init(&log_info, bsc_gsmnet); + bsc_vty_init(bsc_gsmnet); ctrl_vty_init(tall_bsc_ctx); #ifdef BUILD_SMPP -- To view, visit https://gerrit.osmocom.org/1583 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 09:59:41 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 09:59:41 +0000 Subject: osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Patch Set 2: (2 comments) https://gerrit.osmocom.org/#/c/1753/2/src/csn1.cpp File src/csn1.cpp: Line 404: Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); Whitespace change? Just double-checking. https://gerrit.osmocom.org/#/c/1753/2/src/encoding.cpp File src/encoding.cpp: Line 88: bitvec_write_field(dest, &wp, 3, 2); // "HH" You sure it's a safe replacement? Have you tested it with actual phone? -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 8 11:02:55 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 8 Feb 2017 11:02:55 +0000 Subject: osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Patch Set 2: (2 comments) https://gerrit.osmocom.org/#/c/1753/2/src/csn1.cpp File src/csn1.cpp: Line 404: Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8); > Whitespace change? Just double-checking. Yes, better not have it.. https://gerrit.osmocom.org/#/c/1753/2/src/encoding.cpp File src/encoding.cpp: Line 88: bitvec_write_field(dest, &wp, 3, 2); // "HH" > You sure it's a safe replacement? Have you tested it with actual phone? Just a safety question or do you see something? -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 8 11:05:33 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 11:05:33 +0000 Subject: osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Patch Set 2: > Just a safety question or do you see something? Just to be on a safe side: functions are nearly identical but one deals with 0/1 and other with L/H so I think it's better to test that it works. In this particular case it should be obvious if it breaks or not when phone connects to gprs. -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 13:35:20 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 13:35:20 +0000 Subject: [ABANDON] openbsc[master]: log: disable imsi filter In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: log: disable imsi filter ...................................................................... Abandoned consensus to apply this now isn't firm enough. Rather replace this with a different mechanism. -- To view, visit https://gerrit.osmocom.org/1685 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ifecc3c55ae7c050ee53553d6f85d9afbede66ee3 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 13:43:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 13:43:13 +0000 Subject: osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Patch Set 1: > How it wasn't caught by tests? Maybe add explicit test to make sure > this won't be broken again? Well, we still don't have VTY tests for osmo-bts. The missing _write_phy_inst() wasn't caught because it was never called. The missing _write_phy() in octphy should have resulted in an undefined reference, not sure why it isn't caught. -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 13:47:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 13:47:22 +0000 Subject: osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Patch Set 1: > The missing _write_phy() in octphy should have resulted in an > undefined reference, not sure why it isn't caught. ah sorry, in oct it was also the _inst() one. -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 13:53:43 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 13:53:43 +0000 Subject: [PATCH] osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1761 to look at the new patch set (#2). all models: fix vty write: bts_model_config_write_phy The vty write for phy/inst is broken, leading to a written-out config being unparsable; fix all of these: - in common/vty.c, actually call bts_model_config_write_phy_inst(). - in sysmo and lc15 write the phy instance elements in bts_model_config_write_phy_inst() and not in bts_model_config_write_phy(), which lead to writing the members above their parent 'instance'. - sysmo, lc15 and oct omit the bts_model_config_write_phy_inst() implementation. This did not cause a compilation problem because it was in fact never called. - sysmo writes 'clock-source None' when clk_src is zero, leading to unparsable config (related: OS#1944). Instead omit the 'clock-source' when zero. - osmo-bts-trx seems to be the only part that lacks nothing, yet it also didn't work properly because bts_model_config_write_phy_inst() was never called. This problem existed since commit d784e50747b8cf0ce505489e1451f75be5ccbd4b "Introduce new phy_link and phy_instance abstraction" Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 --- M src/common/vty.c M src/osmo-bts-litecell15/lc15bts_vty.c M src/osmo-bts-octphy/octphy_vty.c M src/osmo-bts-sysmo/sysmobts_vty.c 4 files changed, 19 insertions(+), 21 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/61/1761/2 diff --git a/src/common/vty.c b/src/common/vty.c index b48afa4..646ac87 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -358,6 +358,7 @@ if (!pinst) break; vty_out(vty, " instance %u%s", pinst->num, VTY_NEWLINE); + bts_model_config_write_phy_inst(vty, pinst); } } diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c index 0ffe663..46f73ab 100644 --- a/src/osmo-bts-litecell15/lc15bts_vty.c +++ b/src/osmo-bts-litecell15/lc15bts_vty.c @@ -329,7 +329,11 @@ vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power,VTY_NEWLINE); } -static void write_phy_inst(struct vty *vty, struct phy_instance *pinst) +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { int i; @@ -344,14 +348,6 @@ if (pinst->u.lc15.calib_path) vty_out(vty, " trx-calibration-path %s%s", pinst->u.lc15.calib_path, VTY_NEWLINE); -} - -void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) -{ - struct phy_instance *pinst; - - llist_for_each_entry(pinst, &plink->instances, list) - write_phy_inst(vty, pinst); } int bts_model_vty_init(struct gsm_bts *bts) diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index c2d1fbb..abfac1e 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -219,6 +219,10 @@ VTY_NEWLINE); } +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ +} + void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) { } diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index e67d8be..330c9ce 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -443,7 +443,11 @@ VTY_NEWLINE); } -static void write_phy_inst(struct vty *vty, struct phy_instance *pinst) +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { int i; @@ -464,17 +468,10 @@ if (pinst->u.sysmobts.calib_path) vty_out(vty, " trx-calibration-path %s%s", pinst->u.sysmobts.calib_path, VTY_NEWLINE); - vty_out(vty, " clock-source %s%s", - get_value_string(femtobts_clksrc_names, - pinst->u.sysmobts.clk_src), VTY_NEWLINE); -} - -void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) -{ - struct phy_instance *pinst; - - llist_for_each_entry(pinst, &plink->instances, list) - write_phy_inst(vty, pinst); + if (pinst->u.sysmobts.clk_src) + vty_out(vty, " clock-source %s%s", + get_value_string(femtobts_clksrc_names, + pinst->u.sysmobts.clk_src), VTY_NEWLINE); } int bts_model_vty_init(struct gsm_bts *bts) -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 13:55:55 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 13:55:55 +0000 Subject: libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Patch Set 5: (Vadim, once you have CR+2 and V+1, you can click 'Submit' to merge the change) -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 13:59:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 13:59:17 +0000 Subject: libosmocore[master]: tests/conv: separate test logic In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 assuming that you haven't hidden functional changes in this patch, it looks fine -- To view, visit https://gerrit.osmocom.org/1627 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Idbdc7e19cb9b9a36cd1fccd621cd858e87530d98 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 14:03:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 14:03:37 +0000 Subject: [PATCH] libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1582 to look at the new patch set (#4). vty: fix "everything" logging option * clarify use of unused parameters * change internal static function int check_log_to_target() to more appropriate bool log_to_target() * add explicit level for "logging level ... everything" so it really logs everything instead of nothing for a given category * fix "logging level all everything" with explicit global loglevel check Fixes: OS#71 Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c --- M include/osmocom/core/logging.h M include/osmocom/vty/logging.h M src/logging.c M src/vty/logging_vty.c M tests/vty/vty_test.c 5 files changed, 28 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1582/4 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..aef145d 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -88,6 +88,8 @@ #define LOGL_NOTICE 5 /*!< \brief abnormal/unexpected condition */ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ +/* N. B: check that you do not clash with internal LOGL_EVERY from logging.c + before adding anything to above */ #define LOG_FILTER_ALL 0x0001 @@ -299,8 +301,8 @@ void log_del_target(struct log_target *target); /* Generate command string for VTY use */ -const char *log_vty_command_string(const struct log_info *info); -const char *log_vty_command_description(const struct log_info *info); +const char *log_vty_command_string(const struct log_info *unused_info); +const char *log_vty_command_description(const struct log_info *unused_info); struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index 9e4b98f..a23a1ad 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -4,6 +4,6 @@ #define FILTER_STR "Filter log messages\n" struct log_info; -void logging_vty_add_cmds(const struct log_info *cat); +void logging_vty_add_cmds(const struct log_info *unused_info); struct vty; struct log_target *osmo_log_vty2tgt(struct vty *vty); diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..c5751c0 100644 --- a/src/logging.c +++ b/src/logging.c @@ -55,9 +55,10 @@ LLIST_HEAD(osmo_log_target_list); #define LOGLEVEL_DEFS 6 /* Number of loglevels.*/ +#define LOGL_EVERY 32 /* Special loglevel for "everything". */ static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1] = { - { 0, "EVERYTHING" }, + { LOGL_EVERY, "EVERYTHING" }, { LOGL_DEBUG, "DEBUG" }, { LOGL_INFO, "INFO" }, { LOGL_NOTICE, "NOTICE" }, @@ -138,7 +139,7 @@ /*! \brief descriptive string for each log level */ /* You have to keep this in sync with the structure loglevel_strs. */ const char *loglevel_descriptions[LOGLEVEL_DEFS+1] = { - "Don't use. It doesn't log anything", + "Log everything (use with extreme care)", "Log debug messages and higher levels", "Log informational messages and higher levels", "Log noticeable messages and higher levels", @@ -352,36 +353,44 @@ return subsys; } -static inline int check_log_to_target(struct log_target *tar, int subsys, int level) +static inline bool log_to_target(struct log_target *tar, int subsys, int level) { struct log_category *category; category = &tar->categories[subsys]; + /* Check if special log level "everything" is enabled globally */ + if (tar->loglevel == LOGL_EVERY) + return true; + /* subsystem is not supposed to be logged */ if (!category->enabled) - return 0; + return false; /* Check the global log level */ if (tar->loglevel != 0 && level < tar->loglevel) - return 0; + return true; + + /* Check if special log level "everything" is enabled for category */ + if (category->loglevel == LOGL_EVERY) + return true; /* Check the category log level */ if (tar->loglevel == 0 && category->loglevel != 0 && level < category->loglevel) - return 0; + return false; /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ if ((tar->filter_map & LOG_FILTER_ALL) != 0) - return 1; + return true; if (osmo_log_info->filter_fn) return osmo_log_info->filter_fn(&log_context, tar); /* TODO: Check the filter/selector too? */ - return 1; + return true; } /*! \brief vararg version of logging function @@ -402,7 +411,7 @@ llist_for_each_entry(tar, &osmo_log_target_list, entry) { va_list bp; - if (!check_log_to_target(tar, subsys, level)) + if (!log_to_target(tar, subsys, level)) continue; /* According to the manpage, vsnprintf leaves the value of ap @@ -978,7 +987,7 @@ /* TODO: The following could/should be cached (update on config) */ llist_for_each_entry(tar, &osmo_log_target_list, entry) { - if (!check_log_to_target(tar, subsys, level)) + if (!log_to_target(tar, subsys, level)) continue; /* This might get logged (ignoring filters) */ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..1c51ec7 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -737,7 +737,7 @@ return 1; } -void logging_vty_add_cmds(const struct log_info *cat) +void logging_vty_add_cmds(const struct log_info *unused_info) { install_element_ve(&enable_logging_cmd); install_element_ve(&disable_logging_cmd); @@ -750,8 +750,8 @@ install_element_ve(&logging_set_category_mask_old_cmd); /* Logging level strings are generated dynamically. */ - logging_level_cmd.string = log_vty_command_string(cat); - logging_level_cmd.doc = log_vty_command_description(cat); + logging_level_cmd.string = log_vty_command_string(NULL); + logging_level_cmd.doc = log_vty_command_description(NULL); install_element_ve(&logging_level_cmd); install_element_ve(&show_logging_vty_cmd); install_element_ve(&show_alarms_cmd); diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 865c93e..51a6529 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -318,7 +318,7 @@ vty_init(&vty_info); /* Setup VTY commands */ - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(NULL); osmo_stats_vty_add_cmds(); test_cmd_string_from_valstr(); -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Wed Feb 8 14:04:17 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 14:04:17 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 4: Good catch - those are leftovers from previous fix attempts and are not necessary anymore. -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 14:08:03 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 14:08:03 +0000 Subject: osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Patch Set 3: (3 comments) please also address the two commit message comments above (summary, quotes) https://gerrit.osmocom.org/#/c/1711/3/src/osmo-bts-octphy/octphy_vty.c File src/osmo-bts-octphy/octphy_vty.c: Line 172: vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE); ": invalid msgb size (%d bytes, expected %d bytes)" if (sizeof > msgb_l2len) would be enough? Line 176: tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = heh didn't you say recently that variables should be declared at the top of the function? It's Osmocom convention anyway. Line 227: vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE); (same as above) -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 8 14:12:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 14:12:23 +0000 Subject: osmo-bts[master]: Use system-installed pcuif_proto.h instead of local copy In-Reply-To: References: Message-ID: Patch Set 8: hmm, seems weird to stall this patch because of a missing convention that hasn't stopped any other patches from being merged before. We should still take on the Osmocom version tagging discussion, but it is frankly not happening. What do you think about your -1, Harald? -- To view, visit https://gerrit.osmocom.org/1258 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4dd2537aeef60c7d154e90f279dc4e7c2392ff76 Gerrit-PatchSet: 8 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 14:15:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 14:15:21 +0000 Subject: openbsc[master]: libbsc: add chreq type for CHREQ_T_PDCH_ONE_PHASE & CHREQ_T_... In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1360 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie7f4ed000cf1b40d269873cf0ddf5ff9f5bbc18a Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 15:52:45 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 15:52:45 +0000 Subject: [PATCH] libosmocore[master]: fix various compiler warnings (on FreeBSD-11.0) Message-ID: Review at https://gerrit.osmocom.org/1769 fix various compiler warnings (on FreeBSD-11.0) FreeBSD 11.0 uses clang version 3.8.0 which spits various warnings during libosmocore compilation. Let's clean this up a bit. Change-Id: Ic14572e6970bd0b8916604fabf807f1608fa07e5 --- M src/ctrl/control_if.c M src/gsm/abis_nm.c M src/gsm/ipa.c M utils/osmo-sim-test.c 4 files changed, 6 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/1769/1 diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index df39486..b4afd55 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -131,7 +131,7 @@ return -ENOMEM; cmd->id = "0"; /* It's a TRAP! */ - cmd->variable = name; + cmd->variable = (char *) name; cmd->reply = value; r = ctrl_cmd_send_to_all(ctrl, cmd); talloc_free(cmd); diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index 10aae9a..155084a 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -571,7 +571,7 @@ return NULL; } if (len) - msgb_tl16v_put(nmsg, NM_ATT_ADD_TEXT, len, add_text); + msgb_tl16v_put(nmsg, NM_ATT_ADD_TEXT, len, (const uint8_t *) add_text); return nmsg; } diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c index 6dc3ab6..f44c328 100644 --- a/src/gsm/ipa.c +++ b/src/gsm/ipa.c @@ -28,6 +28,7 @@ #include #include +#include #include #include diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c index 7b79c58..d822bec 100644 --- a/utils/osmo-sim-test.c +++ b/utils/osmo-sim-test.c @@ -37,7 +37,7 @@ const uint8_t *data, uint8_t data_len) { struct msgb *msg, *resp; - char *dst; + uint8_t *dst; msg = osim_new_apdumsg(0x00, 0xA4, p1, p2, data_len, 256); dst = msgb_put(msg, data_len); @@ -65,7 +65,7 @@ } /* 11.1.9 */ -static int verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, uint8_t *pin) +static int verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, char *pin) { struct msgb *msg; char *pindst; @@ -75,7 +75,7 @@ return -EINVAL; msg = osim_new_apdumsg(0x00, 0x20, 0x00, pin_nr, 8, 0); - pindst = msgb_put(msg, 8); + pindst = (char *) msgb_put(msg, 8); memset(pindst, 0xFF, 8); strncpy(pindst, pin, strlen(pin)); -- To view, visit https://gerrit.osmocom.org/1769 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic14572e6970bd0b8916604fabf807f1608fa07e5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:10:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 16:10:01 +0000 Subject: libosmocore[master]: fix various compiler warnings (on FreeBSD-11.0) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1769 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic14572e6970bd0b8916604fabf807f1608fa07e5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:10:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 16:10:02 +0000 Subject: [MERGED] libosmocore[master]: fix various compiler warnings (on FreeBSD-11.0) In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: fix various compiler warnings (on FreeBSD-11.0) ...................................................................... fix various compiler warnings (on FreeBSD-11.0) FreeBSD 11.0 uses clang version 3.8.0 which spits various warnings during libosmocore compilation. Let's clean this up a bit. Change-Id: Ic14572e6970bd0b8916604fabf807f1608fa07e5 --- M src/ctrl/control_if.c M src/gsm/abis_nm.c M src/gsm/ipa.c M utils/osmo-sim-test.c 4 files changed, 6 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index df39486..b4afd55 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -131,7 +131,7 @@ return -ENOMEM; cmd->id = "0"; /* It's a TRAP! */ - cmd->variable = name; + cmd->variable = (char *) name; cmd->reply = value; r = ctrl_cmd_send_to_all(ctrl, cmd); talloc_free(cmd); diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index 10aae9a..155084a 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -571,7 +571,7 @@ return NULL; } if (len) - msgb_tl16v_put(nmsg, NM_ATT_ADD_TEXT, len, add_text); + msgb_tl16v_put(nmsg, NM_ATT_ADD_TEXT, len, (const uint8_t *) add_text); return nmsg; } diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c index 6dc3ab6..f44c328 100644 --- a/src/gsm/ipa.c +++ b/src/gsm/ipa.c @@ -28,6 +28,7 @@ #include #include +#include #include #include diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c index 7b79c58..d822bec 100644 --- a/utils/osmo-sim-test.c +++ b/utils/osmo-sim-test.c @@ -37,7 +37,7 @@ const uint8_t *data, uint8_t data_len) { struct msgb *msg, *resp; - char *dst; + uint8_t *dst; msg = osim_new_apdumsg(0x00, 0xA4, p1, p2, data_len, 256); dst = msgb_put(msg, data_len); @@ -65,7 +65,7 @@ } /* 11.1.9 */ -static int verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, uint8_t *pin) +static int verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, char *pin) { struct msgb *msg; char *pindst; @@ -75,7 +75,7 @@ return -EINVAL; msg = osim_new_apdumsg(0x00, 0x20, 0x00, pin_nr, 8, 0); - pindst = msgb_put(msg, 8); + pindst = (char *) msgb_put(msg, 8); memset(pindst, 0xFF, 8); strncpy(pindst, pin, strlen(pin)); -- To view, visit https://gerrit.osmocom.org/1769 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic14572e6970bd0b8916604fabf807f1608fa07e5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:10:11 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Wed, 8 Feb 2017 16:10:11 +0000 Subject: [PATCH] libosmocore[master]: Fix type of abis_nm_att_tlvdef_ipa variable Message-ID: Review at https://gerrit.osmocom.org/1770 Fix type of abis_nm_att_tlvdef_ipa variable abis_nm_att_tlvdef_ipa should not be a const, because this variable is modified by tlv_def_patch function during initializing oml attribute definitions in osmo-bts code. This bug was introduced during moving oml definitions from osmo-bts to libosmocore, when type of abis_nm_att_tlvdef_ipa was changed from struct tlv_definition to const struct tlv_definition. Change-Id: I57acf45bf5debe24c7ceb6c45ef0940e89e51a61 --- M include/osmocom/gsm/abis_nm.h M src/gsm/abis_nm.c 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/70/1770/1 diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h index 14dbc08..0d81be3 100644 --- a/include/osmocom/gsm/abis_nm.h +++ b/include/osmocom/gsm/abis_nm.h @@ -34,7 +34,7 @@ const char *abis_nm_avail_name(uint8_t avail); const char *abis_nm_test_name(uint8_t test); extern const struct tlv_definition abis_nm_osmo_att_tlvdef; -extern const struct tlv_definition abis_nm_att_tlvdef_ipa; +extern struct tlv_definition abis_nm_att_tlvdef_ipa; /*! \brief write a human-readable OML header to the debug log * \param[in] ss Logging sub-system diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index 10aae9a..5dddde2 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -291,7 +291,7 @@ }; /*! \brief GSM A-bis OML IPA TLV parser definition */ -const struct tlv_definition abis_nm_att_tlvdef_ipa = { +struct tlv_definition abis_nm_att_tlvdef_ipa = { .def = { /* ip.access specifics */ [NM_ATT_IPACC_DST_IP] = { TLV_TYPE_FIXED, 4 }, -- To view, visit https://gerrit.osmocom.org/1770 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I57acf45bf5debe24c7ceb6c45ef0940e89e51a61 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:11:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 16:11:20 +0000 Subject: osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:12:23 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 16:12:23 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:14:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 16:14:56 +0000 Subject: libosmocore[master]: Fix type of abis_nm_att_tlvdef_ipa variable In-Reply-To: References: Message-ID: Patch Set 1: good catch. but I'm not sure about the solution. the proper solution might be to create a copy in osmo-bts. So the library only provides const data fro the respective dialects, and the application must make a local copy and merge/modify/patch the local copy only. This also would address use cases where a single application needs to understand multiple dialects (and thus have multiple differently patched tables). -- To view, visit https://gerrit.osmocom.org/1770 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I57acf45bf5debe24c7ceb6c45ef0940e89e51a61 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:29:42 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 8 Feb 2017 16:29:42 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello lynxis lazus, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#5). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Missing for merge: - SOL_PACKET is not portable to *BSD Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 276 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/5 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..5042758 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,245 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + return ret; + } else if (ret < 0) { + perror("read "); + return ret; + } + msgb_put(msg, ret); + + return e1inp_rx_ts_lapd(&line->ts[0], msg); +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char *sock_path = line->sock_path; + int ret = 0; + int i; + + LOGP(DLINP, LOGL_NOTICE, "unixsocket: line update\n"); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg, &config->fd, e1inp_dlsap_up, + e1i_ts, &lapd_profile_abis); + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 5 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:32:41 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 8 Feb 2017 16:32:41 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 5: > this won't be merged as long as there's a compiled-in > non-modifieable socket /tmp/oml_rsl This is now fixed, the socket path can be now modified from VTY. -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 5 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:38:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 16:38:27 +0000 Subject: [PATCH] osmo-pcu[master]: Fix dozens of compiler warnings across the board Message-ID: Review at https://gerrit.osmocom.org/1771 Fix dozens of compiler warnings across the board Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d --- M src/pcu_vty.c M src/tbf.cpp M tests/alloc/AllocTest.cpp M tests/bitcomp/BitcompTest.cpp M tests/edge/EdgeTest.cpp M tests/llc/LlcTest.cpp M tests/tbf/TbfTest.cpp 7 files changed, 39 insertions(+), 81 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/71/1771/1 diff --git a/src/pcu_vty.c b/src/pcu_vty.c index 535d512..3b5996c 100644 --- a/src/pcu_vty.c +++ b/src/pcu_vty.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/src/tbf.cpp b/src/tbf.cpp index 0d28c5c..820131c 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -171,13 +171,13 @@ bts(bts_), m_tfi(0), m_created_ts(0), + m_ctrs(NULL), m_ms(NULL), m_ta(GSM48_TA_INVALID), m_ms_class(0), m_list(this), m_ms_list(this), - m_egprs_enabled(false), - m_ctrs(NULL) + m_egprs_enabled(false) { /* The classes of these members do not have proper constructors yet. * Just set them to 0 like talloc_zero did */ @@ -854,9 +854,9 @@ gprs_rlcmac_dl_tbf::BandWidth::BandWidth() : dl_bw_octets(0), + dl_throughput(0), dl_loss_lost(0), - dl_loss_received(0), - dl_throughput(0) + dl_loss_received(0) { timerclear(&dl_bw_tv); timerclear(&dl_loss_tv); diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index f7794f7..308c802 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -170,7 +170,7 @@ { for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i) if (tbf->pdch[i]) - printf("PDCH[%d] is used for %s\n", i, dir); + printf("PDCH[%zu] is used for %s\n", i, dir); printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir); printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir); } diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp index fd3b0df..31b6d11 100644 --- a/tests/bitcomp/BitcompTest.cpp +++ b/tests/bitcomp/BitcompTest.cpp @@ -121,7 +121,7 @@ } /* To verify the result with expected result */ -int check_result(bitvec bits, uint8_t *exp_data, int exp_len) +int check_result(bitvec bits, uint8_t *exp_data, unsigned int exp_len) { if (bits.cur_bit != exp_len) return 0; @@ -147,7 +147,7 @@ { bitvec dest; int init_flag = 1; - int itr; + unsigned int itr; int rc; uint8_t bits_data[RLC_EGPRS_MAX_WS/8]; diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 3537aa7..86c08f5 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -40,6 +40,7 @@ #include #include +#include void *tall_pcu_ctx; int16_t spoof_mnc = 0, spoof_mcc = 0; @@ -1001,7 +1002,7 @@ OSMO_ASSERT(rdbi.e == 1); OSMO_ASSERT(rdbi.cv == 0); OSMO_ASSERT(write_offset == (int)rdbi.data_len); - OSMO_ASSERT(count_payload == rdbi.data_len); + OSMO_ASSERT(rdbi.data_len <= INT_MAX && count_payload == (int)rdbi.data_len); OSMO_ASSERT(num_chunks == 1); OSMO_ASSERT(data[0] == 0); @@ -1027,7 +1028,8 @@ OSMO_ASSERT(rdbi.e == 0); OSMO_ASSERT(rdbi.cv == 0); OSMO_ASSERT(write_offset == (int)rdbi.data_len); - OSMO_ASSERT(count_payload == rdbi.data_len - 1); + OSMO_ASSERT((rdbi.data_len - 1) <= INT_MAX + && count_payload == (int)(rdbi.data_len - 1)); OSMO_ASSERT(num_chunks == 1); OSMO_ASSERT(data[0] == (((rdbi.data_len-1) << 1) | (1 << 0))); @@ -1054,7 +1056,8 @@ OSMO_ASSERT(rdbi.e == 0); OSMO_ASSERT(rdbi.cv == 0); OSMO_ASSERT(write_offset == (int)rdbi.data_len); - OSMO_ASSERT(count_payload == rdbi.data_len - 2); + OSMO_ASSERT((rdbi.data_len - 2) <= INT_MAX + && count_payload == (int)(rdbi.data_len - 2)); OSMO_ASSERT(num_chunks == 2); OSMO_ASSERT(data[0] == (((rdbi.data_len-2) << 1) | (0 << 0))); @@ -1194,16 +1197,12 @@ uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, uint8_t ms_class) { - GprsMs *ms; struct pcu_l1_meas meas; int tfi = 0; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; uint8_t data[79] = {0}; struct gprs_rlc_ul_header_egprs_2 *egprs2 = NULL; egprs2 = (struct gprs_rlc_ul_header_egprs_2 *) data; - bts = the_bts->bts_data(); tfi = 1; @@ -1288,10 +1287,7 @@ uint32_t fn = 2654218; uint16_t qta = 31; uint32_t tlli = 0xf1223344; - const char *imsi = "0011223344"; uint8_t ms_class = 1; - gprs_rlcmac_ul_tbf *ul_tbf; - GprsMs *ms; printf("=== start %s ===\n", __func__); setup_bts(&the_bts, ts_no, 10); @@ -1305,18 +1301,14 @@ uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, uint8_t ms_class) { - uint8_t trx_no = 0; int tfi = 0; - struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; uint8_t data[155] = {0}; struct gprs_rlc_ul_header_egprs_1 *egprs1 = NULL; struct gprs_rlc_data_info rlc; GprsCodingScheme cs; - int rc, offs; + int rc; egprs1 = (struct gprs_rlc_ul_header_egprs_1 *) data; - bts = the_bts->bts_data(); tfi = 1; @@ -1409,10 +1401,7 @@ uint32_t fn = 2654218; uint16_t qta = 31; uint32_t tlli = 0xf1223344; - const char *imsi = "0011223344"; uint8_t ms_class = 1; - gprs_rlcmac_ul_tbf *ul_tbf; - GprsMs *ms; printf("=== start %s ===\n", __func__); setup_bts(&the_bts, ts_no, 12); diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp index e972cf4..8df010e 100644 --- a/tests/llc/LlcTest.cpp +++ b/tests/llc/LlcTest.cpp @@ -66,7 +66,7 @@ llc_msg = queue->dequeue(&info_res); OSMO_ASSERT(llc_msg != NULL); - fprintf(stderr, "dequeued msg, length %d (expected %d), data %s\n", + fprintf(stderr, "dequeued msg, length %u (expected %zu), data %s\n", msgb_length(llc_msg), len, msgb_hexdump(llc_msg)); OSMO_ASSERT(msgb_length(llc_msg) == len); @@ -239,7 +239,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index e367ce6..79e49ec 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -633,7 +633,7 @@ uint32_t rach_fn = *fn - 51; uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_pdch *pdch; gprs_rlcmac_bts *bts; @@ -701,7 +701,7 @@ /* send fake data */ uint8_t data_msg[42] = { 0xf << 2, /* GPRS_RLCMAC_DATA_BLOCK << 6, CV = 15 */ - tfi << 1, + (uint8_t)(tfi << 1), 1, /* BSN:7, E:1 */ }; @@ -1222,17 +1222,14 @@ uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, uint8_t ms_class, uint8_t egprs_ms_class) { - GprsMs *ms; uint32_t rach_fn = *fn - 51; uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; - struct gprs_rlcmac_pdch *pdch; gprs_rlcmac_bts *bts; RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; meas.set_rssi(31); @@ -1298,15 +1295,10 @@ OSMO_ASSERT(ul_tbf); OSMO_ASSERT(ul_tbf->ta() == qta / 4); GprsMs *ms; - uint32_t rach_fn = *fn - 51; - uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; @@ -1386,15 +1378,10 @@ OSMO_ASSERT(ul_tbf); OSMO_ASSERT(ul_tbf->ta() == qta / 4); GprsMs *ms; - uint32_t rach_fn = *fn - 51; - uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; check_tbf(ul_tbf); @@ -1473,16 +1460,11 @@ uint8_t ms_class, uint8_t egprs_ms_class) { GprsMs *ms; - uint32_t rach_fn = *fn - 51; - uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; @@ -1918,7 +1900,7 @@ fprintf(stderr, "Got '%s', TA=%d\n", ul_tbf->name(), ul_tbf->ta()); send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"RAU_ACCEPT", 10); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); /* Send Packet Downlink Assignment to MS */ @@ -1941,7 +1923,7 @@ /* The PCU cannot know yet, that both TBF belong to the same MS */ OSMO_ASSERT(ms1 != ms2); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); /* Send some downlink data along with the new TLLI and the IMSI so that @@ -1951,7 +1933,7 @@ ms = the_bts.ms_by_imsi(imsi); OSMO_ASSERT(ms == ms2); - fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size()); ms = the_bts.ms_by_tlli(tlli1); @@ -1987,7 +1969,7 @@ send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20); send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); OSMO_ASSERT(ms1->llc_queue()->size() == 2); @@ -2004,7 +1986,7 @@ ms_class, 0); ms2 = ul_tbf->ms(); - fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size()); /* This should be the same MS object */ @@ -2048,7 +2030,7 @@ send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20); send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); OSMO_ASSERT(ms1->llc_queue()->size() == 2); @@ -2064,7 +2046,7 @@ ul_tbf = establish_ul_tbf_single_phase(&the_bts, ts_no, tlli1, &fn, qta); ms2 = ul_tbf->ms(); - fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size()); /* There should be a different MS object */ @@ -2119,7 +2101,7 @@ send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)buf, rc); } - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); /* Send Packet Downlink Assignment to MS */ @@ -2370,7 +2352,7 @@ uint32_t rach_fn = *fn - 51; uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_pdch *pdch; gprs_rlcmac_bts *bts; @@ -2742,12 +2724,9 @@ unsigned i; uint8_t ms_class = 11; uint8_t egprs_ms_class = 11; - uint32_t fn = 0; uint8_t trx_no; uint32_t tlli = 0xffeeddcc; uint8_t test_data[512]; - - uint8_t rbb[64/8]; gprs_rlcmac_dl_tbf *dl_tbf; @@ -2777,7 +2756,6 @@ static void tbf_cleanup(gprs_rlcmac_dl_tbf *dl_tbf) { - uint32_t fn = 0; uint8_t rbb[64/8]; /* Receive a final ACK */ @@ -2792,19 +2770,16 @@ } static void egprs_spb_to_normal_validation(BTS *the_bts, - int mcs, int demanded_mcs) + unsigned int mcs, unsigned int demanded_mcs) { uint32_t fn = 0; gprs_rlcmac_dl_tbf *dl_tbf; - uint8_t block_nr = 0; - int index1 = 0; - uint8_t bn; uint16_t bsn1, bsn2, bsn3; struct msgb *msg; struct gprs_rlc_dl_header_egprs_3 *egprs3; struct gprs_rlc_dl_header_egprs_2 *egprs2; - printf("Testing retx for MCS %d to reseg_mcs %d\n", mcs, demanded_mcs); + printf("Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs); dl_tbf = tbf_init(the_bts, mcs); @@ -2886,18 +2861,16 @@ tbf_cleanup(dl_tbf); } + static void establish_and_use_egprs_dl_tbf_for_spb(BTS *the_bts, - int mcs, int demanded_mcs) + unsigned int mcs, unsigned int demanded_mcs) { uint32_t fn = 0; gprs_rlcmac_dl_tbf *dl_tbf; - uint8_t block_nr = 0; - int index1 = 0; - uint8_t bn; struct msgb *msg; struct gprs_rlc_dl_header_egprs_3 *egprs3; - printf("Testing retx for MCS %d to reseg_mcs %d\n", mcs, demanded_mcs); + printf("Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs); dl_tbf = tbf_init(the_bts, mcs); @@ -2989,16 +2962,13 @@ } static void establish_and_use_egprs_dl_tbf_for_retx(BTS *the_bts, - int mcs, int demanded_mcs) + unsigned int mcs, unsigned int demanded_mcs) { uint32_t fn = 0; gprs_rlcmac_dl_tbf *dl_tbf; - uint8_t block_nr = 0; - int index1 = 0; - uint8_t bn; struct msgb *msg; - printf("Testing retx for MCS %d - %d\n", mcs, demanded_mcs); + printf("Testing retx for MCS %u - %u\n", mcs, demanded_mcs); dl_tbf = tbf_init(the_bts, mcs); @@ -3137,7 +3107,6 @@ BTS the_bts; gprs_rlcmac_bts *bts; uint8_t ts_no = 4; - int i, j; printf("=== start %s ===\n", __func__); @@ -3167,7 +3136,6 @@ BTS the_bts; gprs_rlcmac_bts *bts; uint8_t ts_no = 4; - int i, j; printf("=== start %s ===\n", __func__); -- To view, visit https://gerrit.osmocom.org/1771 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:38:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 16:38:27 +0000 Subject: [PATCH] osmo-pcu[master]: tests: edge, tbf: assert return values Message-ID: Review at https://gerrit.osmocom.org/1772 tests: edge, tbf: assert return values Numerous calls assign a return value without asserting its value. Add assertions and thus also eliminate compiler warnings about unused values. Change-Id: I7f14198cfd747dae68b8aaa3b8d6ff7fc49ab824 --- M tests/edge/EdgeTest.cpp M tests/tbf/TbfTest.cpp 2 files changed, 16 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/72/1772/1 diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 86c08f5..16a39e9 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -1226,6 +1226,7 @@ egprs2->pi = 0; data[4] = 0x20; /* Setting E field */ rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 487); offs = rlc.data_offs_bits[0] / 8; OSMO_ASSERT(offs == 4); OSMO_ASSERT(rlc.tfi == 1); @@ -1250,6 +1251,7 @@ egprs2->pi = 0; data[10] = 0x20; /* Setting E field */ rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 679); offs = rlc.data_offs_bits[0] / 8; OSMO_ASSERT(offs == 10); OSMO_ASSERT(rlc.num_data_blocks == 1); @@ -1271,6 +1273,7 @@ egprs2->pi = 0; data[10] = 0x20; /* Setting E field */ rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 679); offs = rlc.data_offs_bits[0] / 8; OSMO_ASSERT(offs == 10); OSMO_ASSERT(rlc.tfi == 1); @@ -1330,6 +1333,7 @@ data[5] = 0xc0; data[5 + 57] = 1; rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 946); OSMO_ASSERT(rlc.num_data_blocks == 2); OSMO_ASSERT(rlc.block_info[0].e == 1); OSMO_ASSERT(rlc.block_info[0].ti == 1); @@ -1357,6 +1361,7 @@ data[5] = 0xc0; data[5 + 69] = 1; rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 1138); OSMO_ASSERT(rlc.num_data_blocks == 2); OSMO_ASSERT(rlc.block_info[0].e == 1); OSMO_ASSERT(rlc.block_info[0].ti == 1); @@ -1384,6 +1389,7 @@ data[5] = 0xc0; data[5 + 75] = 1; rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 1234); OSMO_ASSERT(rlc.num_data_blocks == 2); OSMO_ASSERT(rlc.block_info[0].e == 1); OSMO_ASSERT(rlc.block_info[0].ti == 1); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 79e49ec..7d786b4 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -2985,7 +2985,7 @@ fn = fn_add_blocks(fn, 1); /* Send 2 RLC data block */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); - + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3006,6 +3006,7 @@ fn = fn_add_blocks(fn, 1); /* Retransmit the first RLC data block with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_nacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3014,6 +3015,7 @@ fn = fn_add_blocks(fn, 1); /* Retransmit the second RLC data block with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(1)->cs_current_trans.to_num() @@ -3023,6 +3025,7 @@ fn = fn_add_blocks(fn, 1); /* Send first RLC data block BSN 0 */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() == mcs); @@ -3030,6 +3033,7 @@ fn = fn_add_blocks(fn, 1); /* Send second RLC data block BSN 1 */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(1)->cs_current_trans.to_num() == mcs); @@ -3046,6 +3050,7 @@ fn = fn_add_blocks(fn, 1); /* Send first, second RLC data blocks with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3057,6 +3062,7 @@ fn = fn_add_blocks(fn, 1); /* Send first,second RLC data blocks */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3072,6 +3078,7 @@ fn = fn_add_blocks(fn, 1); /* Send first,second RLC data blocks with demanded_mcs*/ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3084,6 +3091,7 @@ fn = fn_add_blocks(fn, 1); /* Send first RLC data block */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() == mcs); @@ -3094,6 +3102,7 @@ fn = fn_add_blocks(fn, 1); /* Send first RLC data block with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() == mcs); -- To view, visit https://gerrit.osmocom.org/1772 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7f14198cfd747dae68b8aaa3b8d6ff7fc49ab824 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:38:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 16:38:27 +0000 Subject: [PATCH] osmo-pcu[master]: main, tests: use msgb_talloc_ctx_init() (new) Message-ID: Review at https://gerrit.osmocom.org/1773 main, tests: use msgb_talloc_ctx_init() (new) msgb_set_talloc_ctx() is deprecated since libosmocore commit f45334be29016a36594aacc07c90e262e4994525 / change-id I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08 --- M src/pcu_main.cpp M tests/alloc/AllocTest.cpp M tests/edge/EdgeTest.cpp M tests/emu/pcu_emu.cpp M tests/ms/MsTest.cpp M tests/tbf/TbfTest.cpp 6 files changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/73/1773/1 diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 0a0362b..338096b 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -217,7 +217,7 @@ */ bts->dl_arq_type = EGPRS_ARQ1; - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&gprs_log_info); osmo_stats_init(tall_pcu_ctx); diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index 308c802..e26c432 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -848,7 +848,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 16a39e9..73aed37 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -1424,7 +1424,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp index 3725c8d..957ddf6 100644 --- a/tests/emu/pcu_emu.cpp +++ b/tests/emu/pcu_emu.cpp @@ -110,7 +110,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&gprs_log_info); vty_init(&pcu_vty_info); pcu_vty_init(&gprs_log_info); diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp index 0930354..d66f578 100644 --- a/tests/ms/MsTest.cpp +++ b/tests/ms/MsTest.cpp @@ -538,7 +538,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 7d786b4..00aa4a8 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -3361,7 +3361,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); -- To view, visit https://gerrit.osmocom.org/1773 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:40:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 16:40:04 +0000 Subject: [PATCH] osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS Message-ID: Review at https://gerrit.osmocom.org/1774 dl tbf: calculate CPS only for EGPRS Patch-by: Aravind Sirsikar Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd --- M src/tbf_dl.cpp 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/74/1774/1 diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 78f06e9..14b272a 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -762,8 +762,9 @@ msg_data, block_data); } - OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); - rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); + /* Calculate CPS only for EGPRS case */ + if (cs.isEgprs()) + rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); /* If the TBF has just started, relate frames_since_last_poll to the * current fn */ -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:40:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 16:40:04 +0000 Subject: [PATCH] osmo-pcu[master]: dl tbf: initialize punct values and verify Message-ID: Review at https://gerrit.osmocom.org/1775 dl tbf: initialize punct values and verify Solves a sanitizer issue where punct2 is unset when passed to gprs_rlc_mcs_cps() and thus takes a value not defined in the enum. Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 --- M src/rlc.cpp M src/tbf_dl.cpp 2 files changed, 37 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/75/1775/1 diff --git a/src/rlc.cpp b/src/rlc.cpp index d13045e..acd4169 100644 --- a/src/rlc.cpp +++ b/src/rlc.cpp @@ -378,6 +378,36 @@ enum egprs_puncturing_values punct, enum egprs_puncturing_values punct2, int with_padding) { + /* validate that punct and punct2 are as expected */ + switch (GprsCodingScheme::Scheme(cs)) { + case GprsCodingScheme::MCS9: + case GprsCodingScheme::MCS8: + case GprsCodingScheme::MCS7: + if (punct2 == EGPRS_PS_INVALID) { + LOGP(DRLCMACDL, LOGL_ERROR, + "Invalid punct2 value for coding scheme %d: %d\n", + GprsCodingScheme::Scheme(cs), punct2); + return -1; + } + /* fall through */ + case GprsCodingScheme::MCS6: + case GprsCodingScheme::MCS5: + case GprsCodingScheme::MCS4: + case GprsCodingScheme::MCS3: + case GprsCodingScheme::MCS2: + case GprsCodingScheme::MCS1: + if (punct == EGPRS_PS_INVALID) { + LOGP(DRLCMACDL, LOGL_ERROR, + "Invalid punct value for coding scheme %d: %d\n", + GprsCodingScheme::Scheme(cs), punct); + return -1; + } + break; + default: + return -1; + } + + /* See 3GPP TS 44.060 10.4.8a.3.1, 10.4.8a.2.1, 10.4.8a.1.1 */ switch (GprsCodingScheme::Scheme(cs)) { case GprsCodingScheme::MCS1: return 0b1011 + punct % EGPRS_MAX_PS_NUM_2; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 14b272a..d871c4d 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -627,10 +627,16 @@ GprsCodingScheme cs; int bsns[ARRAY_SIZE(rlc.block_info)]; unsigned num_bsns; - enum egprs_puncturing_values punct[ARRAY_SIZE(rlc.block_info)]; bool need_padding = false; enum egprs_rlcmac_dl_spb spb = EGPRS_RLCMAC_DL_NO_RETX; unsigned int spb_status = get_egprs_dl_spb_status(index); + + enum egprs_puncturing_values punct[2] = { + EGPRS_PS_INVALID, EGPRS_PS_INVALID + }; + osmo_static_assert(ARRAY_SIZE(rlc.block_info) == 2, + rlc_block_info_size_is_two); + /* * TODO: This is an experimental work-around to put 2 BSN into * MSC-7 to MCS-9 encoded messages. It just sends the same BSN -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:46:11 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 16:46:11 +0000 Subject: [PATCH] osmo-bts[master]: Cosmetic fixes Message-ID: Review at https://gerrit.osmocom.org/1776 Cosmetic fixes * print actual value causing error and the check range * fix log error message typo * use preprocessor #if 0 to avoid compilation warning for disabled code Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 --- M src/common/scheduler.c M src/osmo-bts-trx/gsm0503_coding.c 2 files changed, 12 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/76/1776/1 diff --git a/src/common/scheduler.c b/src/common/scheduler.c index 724fb5a..27b7630 100644 --- a/src/common/scheduler.c +++ b/src/common/scheduler.c @@ -305,11 +305,11 @@ goto wrong_type; } if (prim_fn > 100) { - LOGP(DL1C, LOGL_NOTICE, "Prim for trx=%u ts=%u at fn=%u " - "is out of range, or channel %s with type %s is " - "already disabled. If this happens in conjunction " - "with PCU, increase 'rts-advance' by 5. " - "(current fn=%u)\n", l1t->trx->nr, tn, + LOGP(DL1C, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at " + "fn=%u is out of range (100), or channel %s with " + "type %s is already disabled. If this happens in " + "conjunction with PCU, increase 'rts-advance' by 5." + " (current fn=%u)\n", prim_fn, l1t->trx->nr, tn, l1sap->u.data.fn, get_lchan_by_chan_nr(l1t->trx, chan_nr)->name, get_value_string(trx_chan_type_names, chan), fn); @@ -1609,10 +1609,12 @@ no_data: /* in case of C0, we need a dummy burst to maintain RF power */ if (bits == NULL && l1t->trx == l1t->trx->bts->c0) { -if (0) if (chan != TRXC_IDLE) // hack - LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u " - "burst=%d on C0, so filling with dummy burst\n", - trx_chan_desc[chan].name, fn, tn, bid); +#if 0 + if (chan != TRXC_IDLE) // hack + LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u " + "burst=%d on C0, so filling with dummy burst\n", + trx_chan_desc[chan].name, fn, tn, bid); +#endif bits = (ubit_t *) dummy_burst; } diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c index 4c4f7f1..4278974 100644 --- a/src/osmo-bts-trx/gsm0503_coding.c +++ b/src/osmo-bts-trx/gsm0503_coding.c @@ -1845,7 +1845,7 @@ rv = osmo_crc8gen_check_bits(&gsm0503_tch_fr_crc3, d + 73, 22, p); if (rv) { - LOGP(DL1C, LOGL_NOTICE, "tch_fr_decode(): error checking CRC8 for an HR frame\n"); + LOGP(DL1C, LOGL_NOTICE, "tch_hr_decode(): error checking CRC8 for an HR frame (%d/%d bits)\n", *n_errors, *n_bits_total); return -1; } -- To view, visit https://gerrit.osmocom.org/1776 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Wed Feb 8 16:47:16 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Wed, 8 Feb 2017 16:47:16 +0000 Subject: libosmocore[master]: Fix type of abis_nm_att_tlvdef_ipa variable In-Reply-To: References: Message-ID: Patch Set 1: > good catch. but I'm not sure about the solution. the proper > solution might be to create a copy in osmo-bts. So the library > only provides const data fro the respective dialects, and the > application must make a local copy and merge/modify/patch the local > copy only. > > This also would address use cases where a single application needs > to understand multiple dialects (and thus have multiple differently > patched tables). Yes, agree, it is better to create a copy in application, I will prepare patch for osmo-bts and submit it for review. -- To view, visit https://gerrit.osmocom.org/1770 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I57acf45bf5debe24c7ceb6c45ef0940e89e51a61 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:00:33 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:00:33 +0000 Subject: libosmocore[master]: Add minimal testing of socket.c helper functions In-Reply-To: References: Message-ID: Patch Set 5: 'make check' works fine here when testing in a local freebsd-11.0 and freebsd-10.3 VM. I am at a loss why the FreeBSD builder has some issues with the socket tests. -- To view, visit https://gerrit.osmocom.org/1698 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:13:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 17:13:23 +0000 Subject: [PATCH] osmo-bts[master]: fix missing ~ in bit logic for lchan->si.valid in rsl_rx_sac... Message-ID: Review at https://gerrit.osmocom.org/1777 fix missing ~ in bit logic for lchan->si.valid in rsl_rx_sacch_inf_mod() Upon rx of a SACCH INFO Modify for an lchan that has no L3 INFO IE, clear only the si.valid bit in question, instead of clearing all but the one in question. BTW, It first looked like it could be, but is *not* the cause for OS#1945 (SI5ter never sent to MS). Change-Id: I0df20b6643b0bfd219ce1df594075838d8406719 --- M src/common/rsl.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/77/1777/1 diff --git a/src/common/rsl.c b/src/common/rsl.c index 5c4e4ff..7ab43cd 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1345,7 +1345,7 @@ gsm_lchan_name(lchan), get_value_string(osmo_sitype_strs, osmo_si)); } else { - lchan->si.valid &= (1 << osmo_si); + lchan->si.valid &= ~(1 << osmo_si); LOGP(DRSL, LOGL_INFO, "%s Rx RSL Disabling SACCH FILLING (SI%s)\n", gsm_lchan_name(lchan), get_value_string(osmo_sitype_strs, osmo_si)); -- To view, visit https://gerrit.osmocom.org/1777 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0df20b6643b0bfd219ce1df594075838d8406719 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:14:29 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 8 Feb 2017 17:14:29 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello lynxis lazus, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#6). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Missing for merge: - SOL_PACKET is not portable to *BSD Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 277 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/6 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..70944ce --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,246 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + return ret; + } else if (ret < 0) { + perror("read "); + return ret; + } + msgb_put(msg, ret); + + return e1inp_rx_ts_lapd(&line->ts[0], msg); +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char *sock_path = line->sock_path; + int ret = 0; + int i; + + LOGP(DLINP, LOGL_NOTICE, "unixsocket: line update\n"); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg, &config->fd, e1inp_dlsap_up, + e1i_ts, &lapd_profile_abis); + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 6 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:18:44 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 8 Feb 2017 17:18:44 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello lynxis lazus, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#7). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 277 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/7 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..70944ce --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,246 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + return ret; + } else if (ret < 0) { + perror("read "); + return ret; + } + msgb_put(msg, ret); + + return e1inp_rx_ts_lapd(&line->ts[0], msg); +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char *sock_path = line->sock_path; + int ret = 0; + int i; + + LOGP(DLINP, LOGL_NOTICE, "unixsocket: line update\n"); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg, &config->fd, e1inp_dlsap_up, + e1i_ts, &lapd_profile_abis); + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 7 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:23:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:23:18 +0000 Subject: [PATCH] libosmocore[master]: Add minimal testing of socket.c helper functions In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1698 to look at the new patch set (#6). Add minimal testing of socket.c helper functions Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79 --- M .gitignore M tests/Makefile.am A tests/socket/socket_test.c A tests/socket/socket_test.err A tests/socket/socket_test.ok M tests/testsuite.at 6 files changed, 97 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/98/1698/6 diff --git a/.gitignore b/.gitignore index fb159c3..ad8354e 100644 --- a/.gitignore +++ b/.gitignore @@ -98,6 +98,7 @@ tests/fsm/fsm_test tests/write_queue/wqueue_test tests/oap/oap_test +tests/socket/socket_test utils/osmo-arfcn utils/osmo-auc-gen diff --git a/tests/Makefile.am b/tests/Makefile.am index b9eb8f2..5731bf8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,7 @@ smscb/gsm0341_test stats/stats_test \ bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \ tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_test \ - write_queue/wqueue_test + write_queue/wqueue_test socket/socket_test if ENABLE_MSGFILE check_PROGRAMS += msgfile/msgfile_test @@ -140,6 +140,9 @@ write_queue_wqueue_test_SOURCES = write_queue/wqueue_test.c write_queue_wqueue_test_LDADD = $(top_builddir)/src/libosmocore.la +socket_socket_test_SOURCES = socket/socket_test.c +socket_socket_test_LDADD = $(top_builddir)/src/libosmocore.la + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ @@ -176,7 +179,8 @@ bitvec/bitvec_test.ok msgb/msgb_test.ok bits/bitcomp_test.ok \ sim/sim_test.ok tlv/tlv_test.ok gsup/gsup_test.ok \ oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \ - write_queue/wqueue_test.ok + write_queue/wqueue_test.ok socket/socket_test.ok \ + socket/socket_test.err DISTCLEANFILES = atconfig atlocal diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c new file mode 100644 index 0000000..75088e5 --- /dev/null +++ b/tests/socket/socket_test.c @@ -0,0 +1,78 @@ +/* + * (C) 2017 by Harald Welte + * 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 +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "../config.h" + +static int test_sockinit(void) +{ + int fd, rc; + char *name; + + printf("Checking osmo_sock_init() with bind to a random local UDP port\n"); + fd = osmo_sock_init(AF_INET, SOCK_DGRAM, IPPROTO_UDP, + "0.0.0.0", 0, OSMO_SOCK_F_BIND); + OSMO_ASSERT(fd >= 0); + name = osmo_sock_get_name(NULL, fd); + /* expect it to be not connected. We cannot match on INADDR_ANY, + * as apparently that won't work on FreeBSD if there's only one + * address (e.g. 127.0.0.1) assigned to the entire system, like + * the Osmocom FreeBSD build slaves */ + OSMO_ASSERT(!strncmp(name, "(NULL<->", 7)); + talloc_free(name); + /* expect it to be blocking */ + rc = fcntl(fd, F_GETFL); + OSMO_ASSERT(!(rc & O_NONBLOCK)); + close(fd); + + printf("Checking for OSMO_SOCK_F_NONBLOCK\n"); + fd = osmo_sock_init(AF_INET, SOCK_DGRAM, IPPROTO_UDP, + "0.0.0.0", 0, OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK); + OSMO_ASSERT(fd >= 0); + /* expect it to be blocking */ + rc = fcntl(fd, F_GETFL); + OSMO_ASSERT(rc & O_NONBLOCK); + close(fd); + + printf("Checking for invalid flags\n"); + fd = osmo_sock_init(AF_INET, SOCK_DGRAM, IPPROTO_UDP, + "0.0.0.0", 0, OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT); + OSMO_ASSERT(fd < 0); + + return 0; +} + +int main(int argc, char *argv[]) +{ + test_sockinit(); + return 0; +} diff --git a/tests/socket/socket_test.err b/tests/socket/socket_test.err new file mode 100644 index 0000000..5367239 --- /dev/null +++ b/tests/socket/socket_test.err @@ -0,0 +1 @@ +invalid: both bind and connect flags set: 0.0.0.0:0 diff --git a/tests/socket/socket_test.ok b/tests/socket/socket_test.ok new file mode 100644 index 0000000..d6ec40e --- /dev/null +++ b/tests/socket/socket_test.ok @@ -0,0 +1,3 @@ +Checking osmo_sock_init() with bind to a random local UDP port +Checking for OSMO_SOCK_F_NONBLOCK +Checking for invalid flags diff --git a/tests/testsuite.at b/tests/testsuite.at index 426c74c..d6181c9 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -228,3 +228,11 @@ touch experr AT_CHECK([$abs_top_builddir/tests/oap/oap_test], [0], [expout], [experr]) AT_CLEANUP + +AT_SETUP([socket]) +AT_KEYWORDS([socket]) +cat $abs_srcdir/socket/socket_test.ok > expout +cat $abs_srcdir/socket/socket_test.err > experr +touch experr +AT_CHECK([$abs_top_builddir/tests/socket/socket_test], [0], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1698 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:26:35 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 17:26:35 +0000 Subject: [PATCH] osmo-bts[master]: osmo-bts-trx: cosmetic fixes In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1776 to look at the new patch set (#2). osmo-bts-trx: cosmetic fixes * print actual value causing error and the check range * fix log error message typo * use preprocessor #if 0 to avoid compilation warning for disabled code * do not attempt to send 0-length bursts to avoid flood of errors after bts startup Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 --- M src/common/scheduler.c M src/osmo-bts-trx/gsm0503_coding.c M src/osmo-bts-trx/scheduler_trx.c 3 files changed, 14 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/76/1776/2 diff --git a/src/common/scheduler.c b/src/common/scheduler.c index 724fb5a..27b7630 100644 --- a/src/common/scheduler.c +++ b/src/common/scheduler.c @@ -305,11 +305,11 @@ goto wrong_type; } if (prim_fn > 100) { - LOGP(DL1C, LOGL_NOTICE, "Prim for trx=%u ts=%u at fn=%u " - "is out of range, or channel %s with type %s is " - "already disabled. If this happens in conjunction " - "with PCU, increase 'rts-advance' by 5. " - "(current fn=%u)\n", l1t->trx->nr, tn, + LOGP(DL1C, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at " + "fn=%u is out of range (100), or channel %s with " + "type %s is already disabled. If this happens in " + "conjunction with PCU, increase 'rts-advance' by 5." + " (current fn=%u)\n", prim_fn, l1t->trx->nr, tn, l1sap->u.data.fn, get_lchan_by_chan_nr(l1t->trx, chan_nr)->name, get_value_string(trx_chan_type_names, chan), fn); @@ -1609,10 +1609,12 @@ no_data: /* in case of C0, we need a dummy burst to maintain RF power */ if (bits == NULL && l1t->trx == l1t->trx->bts->c0) { -if (0) if (chan != TRXC_IDLE) // hack - LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u " - "burst=%d on C0, so filling with dummy burst\n", - trx_chan_desc[chan].name, fn, tn, bid); +#if 0 + if (chan != TRXC_IDLE) // hack + LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u " + "burst=%d on C0, so filling with dummy burst\n", + trx_chan_desc[chan].name, fn, tn, bid); +#endif bits = (ubit_t *) dummy_burst; } diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c index 4c4f7f1..4278974 100644 --- a/src/osmo-bts-trx/gsm0503_coding.c +++ b/src/osmo-bts-trx/gsm0503_coding.c @@ -1845,7 +1845,7 @@ rv = osmo_crc8gen_check_bits(&gsm0503_tch_fr_crc3, d + 73, 22, p); if (rv) { - LOGP(DL1C, LOGL_NOTICE, "tch_fr_decode(): error checking CRC8 for an HR frame\n"); + LOGP(DL1C, LOGL_NOTICE, "tch_hr_decode(): error checking CRC8 for an HR frame (%d/%d bits)\n", *n_errors, *n_bits_total); return -1; } diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index d946ad5..e499d12 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -1375,7 +1375,8 @@ continue; } else gain = 0; - trx_if_data(l1h, tn, fn, gain, bits, nbits); + if (nbits) + trx_if_data(l1h, tn, fn, gain, bits, nbits); } } -- To view, visit https://gerrit.osmocom.org/1776 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:40:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:40:58 +0000 Subject: libosmocore[master]: Add minimal testing of socket.c helper functions In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1698 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:41:00 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:41:00 +0000 Subject: [MERGED] libosmocore[master]: Add minimal testing of socket.c helper functions In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add minimal testing of socket.c helper functions ...................................................................... Add minimal testing of socket.c helper functions Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79 --- M .gitignore M tests/Makefile.am A tests/socket/socket_test.c A tests/socket/socket_test.err A tests/socket/socket_test.ok M tests/testsuite.at 6 files changed, 97 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/.gitignore b/.gitignore index fb159c3..ad8354e 100644 --- a/.gitignore +++ b/.gitignore @@ -98,6 +98,7 @@ tests/fsm/fsm_test tests/write_queue/wqueue_test tests/oap/oap_test +tests/socket/socket_test utils/osmo-arfcn utils/osmo-auc-gen diff --git a/tests/Makefile.am b/tests/Makefile.am index b9eb8f2..5731bf8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,7 @@ smscb/gsm0341_test stats/stats_test \ bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \ tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_test \ - write_queue/wqueue_test + write_queue/wqueue_test socket/socket_test if ENABLE_MSGFILE check_PROGRAMS += msgfile/msgfile_test @@ -140,6 +140,9 @@ write_queue_wqueue_test_SOURCES = write_queue/wqueue_test.c write_queue_wqueue_test_LDADD = $(top_builddir)/src/libosmocore.la +socket_socket_test_SOURCES = socket/socket_test.c +socket_socket_test_LDADD = $(top_builddir)/src/libosmocore.la + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ @@ -176,7 +179,8 @@ bitvec/bitvec_test.ok msgb/msgb_test.ok bits/bitcomp_test.ok \ sim/sim_test.ok tlv/tlv_test.ok gsup/gsup_test.ok \ oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \ - write_queue/wqueue_test.ok + write_queue/wqueue_test.ok socket/socket_test.ok \ + socket/socket_test.err DISTCLEANFILES = atconfig atlocal diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c new file mode 100644 index 0000000..75088e5 --- /dev/null +++ b/tests/socket/socket_test.c @@ -0,0 +1,78 @@ +/* + * (C) 2017 by Harald Welte + * 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 +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "../config.h" + +static int test_sockinit(void) +{ + int fd, rc; + char *name; + + printf("Checking osmo_sock_init() with bind to a random local UDP port\n"); + fd = osmo_sock_init(AF_INET, SOCK_DGRAM, IPPROTO_UDP, + "0.0.0.0", 0, OSMO_SOCK_F_BIND); + OSMO_ASSERT(fd >= 0); + name = osmo_sock_get_name(NULL, fd); + /* expect it to be not connected. We cannot match on INADDR_ANY, + * as apparently that won't work on FreeBSD if there's only one + * address (e.g. 127.0.0.1) assigned to the entire system, like + * the Osmocom FreeBSD build slaves */ + OSMO_ASSERT(!strncmp(name, "(NULL<->", 7)); + talloc_free(name); + /* expect it to be blocking */ + rc = fcntl(fd, F_GETFL); + OSMO_ASSERT(!(rc & O_NONBLOCK)); + close(fd); + + printf("Checking for OSMO_SOCK_F_NONBLOCK\n"); + fd = osmo_sock_init(AF_INET, SOCK_DGRAM, IPPROTO_UDP, + "0.0.0.0", 0, OSMO_SOCK_F_BIND|OSMO_SOCK_F_NONBLOCK); + OSMO_ASSERT(fd >= 0); + /* expect it to be blocking */ + rc = fcntl(fd, F_GETFL); + OSMO_ASSERT(rc & O_NONBLOCK); + close(fd); + + printf("Checking for invalid flags\n"); + fd = osmo_sock_init(AF_INET, SOCK_DGRAM, IPPROTO_UDP, + "0.0.0.0", 0, OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT); + OSMO_ASSERT(fd < 0); + + return 0; +} + +int main(int argc, char *argv[]) +{ + test_sockinit(); + return 0; +} diff --git a/tests/socket/socket_test.err b/tests/socket/socket_test.err new file mode 100644 index 0000000..5367239 --- /dev/null +++ b/tests/socket/socket_test.err @@ -0,0 +1 @@ +invalid: both bind and connect flags set: 0.0.0.0:0 diff --git a/tests/socket/socket_test.ok b/tests/socket/socket_test.ok new file mode 100644 index 0000000..d6ec40e --- /dev/null +++ b/tests/socket/socket_test.ok @@ -0,0 +1,3 @@ +Checking osmo_sock_init() with bind to a random local UDP port +Checking for OSMO_SOCK_F_NONBLOCK +Checking for invalid flags diff --git a/tests/testsuite.at b/tests/testsuite.at index 426c74c..d6181c9 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -228,3 +228,11 @@ touch experr AT_CHECK([$abs_top_builddir/tests/oap/oap_test], [0], [expout], [experr]) AT_CLEANUP + +AT_SETUP([socket]) +AT_KEYWORDS([socket]) +cat $abs_srcdir/socket/socket_test.ok > expout +cat $abs_srcdir/socket/socket_test.err > experr +touch experr +AT_CHECK([$abs_top_builddir/tests/socket/socket_test], [0], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1698 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:41:24 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:41:24 +0000 Subject: libosmocore[master]: Fix type of abis_nm_att_tlvdef_ipa variable In-Reply-To: References: Message-ID: Patch Set 1: Ok, then I'll abandon this patch. Thanks! -- To view, visit https://gerrit.osmocom.org/1770 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I57acf45bf5debe24c7ceb6c45ef0940e89e51a61 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:41:26 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:41:26 +0000 Subject: [ABANDON] libosmocore[master]: Fix type of abis_nm_att_tlvdef_ipa variable In-Reply-To: References: Message-ID: Harald Welte has abandoned this change. Change subject: Fix type of abis_nm_att_tlvdef_ipa variable ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1770 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I57acf45bf5debe24c7ceb6c45ef0940e89e51a61 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:43:10 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:43:10 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 7: Code-Review+1 It might still be good to have a reasonable default, to make it 'simply work' without user invention, but to have the line number encoded in that default. But then, if multiple instances of OsmoNITB/OsmoBSC were running, that wouldn't help either. so let.s keep it as-is. -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 7 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 17:43:31 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 17:43:31 +0000 Subject: openbsc[master]: add struct bsc_sub, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 4: > Would you be fine with calling the structs *_subscriber and still > prefix the functions with the shorter *_sub_? yes. -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 18:08:36 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 18:08:36 +0000 Subject: [PATCH] osmo-bts[master]: SACCH: fix sending of SI with an enum value > 7 Message-ID: Review at https://gerrit.osmocom.org/1778 SACCH: fix sending of SI with an enum value > 7 In copy_sacch_si_to_lchan(), the variable to hold the bit mask for SI-is-valid was chosen as uint8_t, and as a result none of the SIs with an enum value >= 8 would ever be sent. Use int for enum value and uint32_t for the bit mask. Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Fixes: #1945 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/78/1778/1 diff --git a/src/common/rsl.c b/src/common/rsl.c index 7ab43cd..c657b0f 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -687,8 +687,8 @@ for (i = 0; i < ARRAY_SIZE(rsl_sacch_sitypes); i++) { uint8_t rsl_si = rsl_sacch_sitypes[i]; - uint8_t osmo_si = osmo_rsl2sitype(rsl_si); - uint8_t osmo_si_shifted = (1 << osmo_si); + int osmo_si = osmo_rsl2sitype(rsl_si); + uint32_t osmo_si_shifted = (1 << osmo_si); if (osmo_si == SYSINFO_TYPE_NONE) continue; if (!(bts->si_valid & osmo_si_shifted)) { -- To view, visit https://gerrit.osmocom.org/1778 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 18:10:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 18:10:45 +0000 Subject: [PATCH] osmo-bts[master]: cosmetic: lchan_sacch_get: early-exit instead of nested-if Message-ID: Review at https://gerrit.osmocom.org/1779 cosmetic: lchan_sacch_get: early-exit instead of nested-if Change-Id: I1fbf7d7f619cc8194c8094cf4a1826b6114f0e11 --- M src/common/sysinfo.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/79/1779/1 diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index d0a476d..177ed58 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -151,10 +151,10 @@ uint32_t tmp; for (tmp = lchan->si.last + 1; tmp != lchan->si.last; tmp = (tmp + 1) % _MAX_SYSINFO_TYPE) { - if (lchan->si.valid & (1 << tmp)) { - lchan->si.last = tmp; - return lchan->si.buf[tmp]; - } + if (!(lchan->si.valid & (1 << tmp))) + continue; + lchan->si.last = tmp; + return lchan->si.buf[tmp]; } return NULL; } -- To view, visit https://gerrit.osmocom.org/1779 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1fbf7d7f619cc8194c8094cf4a1826b6114f0e11 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 18:17:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 18:17:41 +0000 Subject: [PATCH] osmo-bts[master]: SACCH: fix sending of SI with an enum value > 7 In-Reply-To: References: Message-ID: SACCH: fix sending of SI with an enum value > 7 In copy_sacch_si_to_lchan(), the variable to hold the bit mask for SI-is-valid was chosen as uint8_t, and as a result none of the SIs with an enum value >= 8 would ever be sent. Use int for enum value and uint32_t for the bit mask. Fixes: OS#1945 Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/78/1778/2 diff --git a/src/common/rsl.c b/src/common/rsl.c index 7ab43cd..c657b0f 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -687,8 +687,8 @@ for (i = 0; i < ARRAY_SIZE(rsl_sacch_sitypes); i++) { uint8_t rsl_si = rsl_sacch_sitypes[i]; - uint8_t osmo_si = osmo_rsl2sitype(rsl_si); - uint8_t osmo_si_shifted = (1 << osmo_si); + int osmo_si = osmo_rsl2sitype(rsl_si); + uint32_t osmo_si_shifted = (1 << osmo_si); if (osmo_si == SYSINFO_TYPE_NONE) continue; if (!(bts->si_valid & osmo_si_shifted)) { -- To view, visit https://gerrit.osmocom.org/1778 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 18:34:30 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 18:34:30 +0000 Subject: [PATCH] osmo-bts[master]: SACCH: fix sending of SI with an enum value > 7 In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1778 to look at the new patch set (#3). SACCH: fix sending of SI with an enum value > 7 In copy_sacch_si_to_lchan(), the variable to hold the bit mask for SI-is-valid was chosen as uint8_t, and as a result none of the SIs with an enum value >= 8 would ever be sent. Use int for enum value and uint32_t for the bit mask. Fixes: #1945 Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/78/1778/3 diff --git a/src/common/rsl.c b/src/common/rsl.c index 7ab43cd..c657b0f 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -687,8 +687,8 @@ for (i = 0; i < ARRAY_SIZE(rsl_sacch_sitypes); i++) { uint8_t rsl_si = rsl_sacch_sitypes[i]; - uint8_t osmo_si = osmo_rsl2sitype(rsl_si); - uint8_t osmo_si_shifted = (1 << osmo_si); + int osmo_si = osmo_rsl2sitype(rsl_si); + uint32_t osmo_si_shifted = (1 << osmo_si); if (osmo_si == SYSINFO_TYPE_NONE) continue; if (!(bts->si_valid & osmo_si_shifted)) { -- To view, visit https://gerrit.osmocom.org/1778 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 18:34:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 8 Feb 2017 18:34:31 +0000 Subject: [PATCH] osmo-bts[master]: SACCH SI: assert that SI enum vals fit in bit mask Message-ID: Review at https://gerrit.osmocom.org/1781 SACCH SI: assert that SI enum vals fit in bit mask In case our SI enums ever move past 31, this static assert will warn us to enlarge osmo_si_shifted. Change-Id: I4185d7de590329ff5f523b241721c586ffdbcd8b --- M src/common/rsl.c 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/81/1781/1 diff --git a/src/common/rsl.c b/src/common/rsl.c index c657b0f..2f6c0c6 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -689,6 +689,9 @@ uint8_t rsl_si = rsl_sacch_sitypes[i]; int osmo_si = osmo_rsl2sitype(rsl_si); uint32_t osmo_si_shifted = (1 << osmo_si); + osmo_static_assert(_MAX_SYSINFO_TYPE <= sizeof(osmo_si_shifted) * 8, + si_enum_vals_fit_in_bit_mask); + if (osmo_si == SYSINFO_TYPE_NONE) continue; if (!(bts->si_valid & osmo_si_shifted)) { -- To view, visit https://gerrit.osmocom.org/1781 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4185d7de590329ff5f523b241721c586ffdbcd8b Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 8 18:34:36 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 8 Feb 2017 18:34:36 +0000 Subject: osmo-bts[master]: SACCH: fix sending of SI with an enum value > 7 In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1778/2/src/common/rsl.c File src/common/rsl.c: Line 690: int osmo_si = osmo_rsl2sitype(rsl_si); I think it's better to use variable of the type returned by function - in this case "enum osmo_sysinfo_type". -- To view, visit https://gerrit.osmocom.org/1778 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 8 19:54:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 19:54:47 +0000 Subject: osmo-bts[master]: fix missing ~ in bit logic for lchan->si.valid in rsl_rx_sac... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1777 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0df20b6643b0bfd219ce1df594075838d8406719 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 19:55:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 19:55:01 +0000 Subject: osmo-bts[master]: SACCH: fix sending of SI with an enum value > 7 In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1778 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 19:55:03 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 19:55:03 +0000 Subject: [MERGED] osmo-bts[master]: SACCH: fix sending of SI with an enum value > 7 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: SACCH: fix sending of SI with an enum value > 7 ...................................................................... SACCH: fix sending of SI with an enum value > 7 In copy_sacch_si_to_lchan(), the variable to hold the bit mask for SI-is-valid was chosen as uint8_t, and as a result none of the SIs with an enum value >= 8 would ever be sent. Use int for enum value and uint32_t for the bit mask. Fixes: #1945 Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 --- M src/common/rsl.c 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/rsl.c b/src/common/rsl.c index 7ab43cd..c657b0f 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -687,8 +687,8 @@ for (i = 0; i < ARRAY_SIZE(rsl_sacch_sitypes); i++) { uint8_t rsl_si = rsl_sacch_sitypes[i]; - uint8_t osmo_si = osmo_rsl2sitype(rsl_si); - uint8_t osmo_si_shifted = (1 << osmo_si); + int osmo_si = osmo_rsl2sitype(rsl_si); + uint32_t osmo_si_shifted = (1 << osmo_si); if (osmo_si == SYSINFO_TYPE_NONE) continue; if (!(bts->si_valid & osmo_si_shifted)) { -- To view, visit https://gerrit.osmocom.org/1778 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I85fa9a50691601bcd103845c6811caa061a39824 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Wed Feb 8 19:55:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 19:55:04 +0000 Subject: [MERGED] osmo-bts[master]: fix missing ~ in bit logic for lchan->si.valid in rsl_rx_sac... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: fix missing ~ in bit logic for lchan->si.valid in rsl_rx_sacch_inf_mod() ...................................................................... fix missing ~ in bit logic for lchan->si.valid in rsl_rx_sacch_inf_mod() Upon rx of a SACCH INFO Modify for an lchan that has no L3 INFO IE, clear only the si.valid bit in question, instead of clearing all but the one in question. BTW, It first looked like it could be, but is *not* the cause for OS#1945 (SI5ter never sent to MS). Change-Id: I0df20b6643b0bfd219ce1df594075838d8406719 --- M src/common/rsl.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/rsl.c b/src/common/rsl.c index 5c4e4ff..7ab43cd 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1345,7 +1345,7 @@ gsm_lchan_name(lchan), get_value_string(osmo_sitype_strs, osmo_si)); } else { - lchan->si.valid &= (1 << osmo_si); + lchan->si.valid &= ~(1 << osmo_si); LOGP(DRSL, LOGL_INFO, "%s Rx RSL Disabling SACCH FILLING (SI%s)\n", gsm_lchan_name(lchan), get_value_string(osmo_sitype_strs, osmo_si)); -- To view, visit https://gerrit.osmocom.org/1777 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0df20b6643b0bfd219ce1df594075838d8406719 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 8 20:00:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 20:00:18 +0000 Subject: osmo-bts[master]: SACCH SI: assert that SI enum vals fit in bit mask In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1781 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4185d7de590329ff5f523b241721c586ffdbcd8b Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 8 20:00:22 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 8 Feb 2017 20:00:22 +0000 Subject: [MERGED] osmo-bts[master]: SACCH SI: assert that SI enum vals fit in bit mask In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: SACCH SI: assert that SI enum vals fit in bit mask ...................................................................... SACCH SI: assert that SI enum vals fit in bit mask In case our SI enums ever move past 31, this static assert will warn us to enlarge osmo_si_shifted. Change-Id: I4185d7de590329ff5f523b241721c586ffdbcd8b --- M src/common/rsl.c 1 file changed, 3 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/rsl.c b/src/common/rsl.c index c657b0f..2f6c0c6 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -689,6 +689,9 @@ uint8_t rsl_si = rsl_sacch_sitypes[i]; int osmo_si = osmo_rsl2sitype(rsl_si); uint32_t osmo_si_shifted = (1 << osmo_si); + osmo_static_assert(_MAX_SYSINFO_TYPE <= sizeof(osmo_si_shifted) * 8, + si_enum_vals_fit_in_bit_mask); + if (osmo_si == SYSINFO_TYPE_NONE) continue; if (!(bts->si_valid & osmo_si_shifted)) { -- To view, visit https://gerrit.osmocom.org/1781 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4185d7de590329ff5f523b241721c586ffdbcd8b Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 9 03:31:09 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 9 Feb 2017 03:31:09 +0000 Subject: osmo-pcu[master]: Sanitizer fix for invalid value of egprs_puncturing_values In-Reply-To: References: Message-ID: Patch Set 4: my version of this fix is https://gerrit.osmocom.org/1775 -- To view, visit https://gerrit.osmocom.org/1411 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice54edc7e4a936eb2f2dd8a243673a30dceef542 Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: arvind.sirsikar Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 03:35:09 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Thu, 9 Feb 2017 03:35:09 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1775/1/src/tbf_dl.cpp File src/tbf_dl.cpp: Line 634: enum egprs_puncturing_values punct[2] = { Why hard coding of 2. Cant there be more blocks? -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 9 06:40:00 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Thu, 9 Feb 2017 06:40:00 +0000 Subject: [MERGED] libosmocore[master]: utils/conv_gen.py: improve application flexibility In-Reply-To: References: Message-ID: Vadim Yanitskiy has submitted this change and it was merged. Change subject: utils/conv_gen.py: improve application flexibility ...................................................................... utils/conv_gen.py: improve application flexibility This change makes the conv_gen application more interactive and flexible, allowing to generate not only code definitions but also the test vectors and header files in the future. Moreover, it becomes possible to select exact code family, such as GSM, GMR etc. Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 --- M src/gsm/Makefile.am M utils/conv_gen.py 2 files changed, 38 insertions(+), 8 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 4ec441f..653bdb9 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -35,6 +35,6 @@ # Convolutional codes generation gsm0503_conv.c: - $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py + $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_codes gsm CLEANFILES = gsm0503_conv.c diff --git a/utils/conv_gen.py b/utils/conv_gen.py index 60580ed..e6eb50c 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -23,7 +23,7 @@ */ """ -import sys, os, math +import sys, os, math, argparse from functools import reduce import conv_codes_gsm @@ -254,12 +254,14 @@ code = ConvolutionalCode(0, polys, name = name) code.print_state_and_output(fi) -def generate_codes(codes, path, prefix): +def generate_codes(codes, path, prefix, name): # Open a new file for writing - f = open(os.path.join(path, prefix + "_conv.c"), 'w') + f = open(os.path.join(path, name), 'w') f.write(mod_license + "\n") f.write("#include \n") f.write("#include \n\n") + + sys.stderr.write("Generating convolutional codes...\n") # Print shared tables first if hasattr(codes, "shared_polys"): @@ -279,12 +281,40 @@ code.gen_tables(prefix, f, shared_tables = shared) +def parse_argv(): + parser = argparse.ArgumentParser() + + # Positional arguments + parser.add_argument("action", + help = "what to generate", + choices = ["gen_codes"]) + parser.add_argument("family", + help = "convolutional code family", + choices = ["gsm"]) + + # Optional arguments + parser.add_argument("-p", "--prefix", + help = "internal naming prefix") + parser.add_argument("-n", "--target-name", + help = "target name for generated file") + parser.add_argument("-P", "--target-path", + help = "target path for generated file") + + return parser.parse_args() + if __name__ == '__main__': - path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() + # Parse and verify arguments + argv = parse_argv() + path = argv.target_path or os.getcwd() - sys.stderr.write("Generating convolutional codes...\n") + # Determine convolutional code family + if argv.family == "gsm": + codes = conv_codes_gsm + prefix = argv.prefix or "gsm0503" - # Generate GSM specific codes - generate_codes(conv_codes_gsm, path, "gsm0503") + # What to generate? + if argv.action == "gen_codes": + name = argv.target_name or prefix + "_conv.c" + generate_codes(codes, path, prefix, name) sys.stderr.write("Generation complete.\n") -- To view, visit https://gerrit.osmocom.org/1584 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Thu Feb 9 06:49:49 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Thu, 9 Feb 2017 06:49:49 +0000 Subject: [PATCH] libosmocore[master]: tests/conv: add GSM 05.03 specific test In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1628 to look at the new patch set (#3). tests/conv: add GSM 05.03 specific test This change extends the convolutional code test coverage, adding the GSM 05.03 specific test vectors, generated by the conv_gen.py. Inspired by Tom's patch: http://lists.osmocom.org/pipermail/openbsc/2014-April/007364.html Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a --- M .gitignore M tests/Makefile.am A tests/conv/conv_gsm0503_test.c A tests/conv/conv_gsm0503_test.ok M tests/testsuite.at 5 files changed, 229 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/28/1628/3 diff --git a/.gitignore b/.gitignore index 3672e1e..b05d6ff 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,7 @@ include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h include/osmocom/gsm/gsm0503.h +tests/conv/gsm0503_test_vectors.c # vi files *.sw? diff --git a/tests/Makefile.am b/tests/Makefile.am index 5aa0287..a0dd6cd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,8 @@ smscb/gsm0341_test stats/stats_test \ bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \ tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_test \ - write_queue/wqueue_test socket/socket_test + write_queue/wqueue_test socket/socket_test \ + conv/conv_gsm0503_test if ENABLE_MSGFILE check_PROGRAMS += msgfile/msgfile_test @@ -56,6 +57,9 @@ conv_conv_test_SOURCES = conv/conv_test.c conv/conv.c conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libgsmint.la + +conv_conv_gsm0503_test_SOURCES = conv/conv_gsm0503_test.c conv/conv.c conv/gsm0503_test_vectors.c +conv_conv_gsm0503_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 @@ -180,9 +184,9 @@ sim/sim_test.ok tlv/tlv_test.ok gsup/gsup_test.ok \ oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \ write_queue/wqueue_test.ok socket/socket_test.ok \ - socket/socket_test.err + socket/socket_test.err conv/conv_gsm0503_test.ok -DISTCLEANFILES = atconfig atlocal +DISTCLEANFILES = atconfig atlocal conv/gsm0503_test_vectors.c noinst_HEADERS = conv/conv.h TESTSUITE = $(srcdir)/testsuite @@ -203,3 +207,7 @@ $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at mv $@.tmp $@ + +conv/gsm0503_test_vectors.c: + $(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_vectors gsm \ + --target-path $(top_srcdir)/tests/conv/ diff --git a/tests/conv/conv_gsm0503_test.c b/tests/conv/conv_gsm0503_test.c new file mode 100644 index 0000000..6704129 --- /dev/null +++ b/tests/conv/conv_gsm0503_test.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "conv.h" + +/* Forward declaration of GSM 05.03 specific test vectors */ +extern const struct conv_test_vector gsm0503_vectors[]; +extern const int gsm0503_vectors_len; + +int main(int argc, char *argv[]) +{ + int rc, i; + + for (i = 0; i < gsm0503_vectors_len; i++) { + rc = do_check(&gsm0503_vectors[i]); + if (rc) + return rc; + } + + return 0; +} diff --git a/tests/conv/conv_gsm0503_test.ok b/tests/conv/conv_gsm0503_test.ok new file mode 100644 index 0000000..05761f2 --- /dev/null +++ b/tests/conv/conv_gsm0503_test.ok @@ -0,0 +1,183 @@ +[+] Testing: gsm0503_xcch +[.] Input length : ret = 224 exp = 224 -> OK +[.] Output length : ret = 456 exp = 456 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_rach +[.] Input length : ret = 14 exp = 14 -> OK +[.] Output length : ret = 36 exp = 36 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_sch +[.] Input length : ret = 35 exp = 35 -> OK +[.] Output length : ret = 78 exp = 78 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_cs2 +[.] Input length : ret = 290 exp = 290 -> OK +[.] Output length : ret = 456 exp = 456 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_cs3 +[.] Input length : ret = 334 exp = 334 -> OK +[.] Output length : ret = 456 exp = 456 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_12_2 +[.] Input length : ret = 250 exp = 250 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_10_2 +[.] Input length : ret = 210 exp = 210 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_7_95 +[.] Input length : ret = 165 exp = 165 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_7_4 +[.] Input length : ret = 154 exp = 154 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_6_7 +[.] Input length : ret = 140 exp = 140 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_5_9 +[.] Input length : ret = 124 exp = 124 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_5_15 +[.] Input length : ret = 109 exp = 109 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_afs_4_75 +[.] Input length : ret = 101 exp = 101 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_fr +[.] Input length : ret = 185 exp = 185 -> OK +[.] Output length : ret = 378 exp = 378 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_hr +[.] Input length : ret = 98 exp = 98 -> OK +[.] Output length : ret = 211 exp = 211 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_7_95 +[.] Input length : ret = 129 exp = 129 -> OK +[.] Output length : ret = 188 exp = 188 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_7_4 +[.] Input length : ret = 126 exp = 126 -> OK +[.] Output length : ret = 196 exp = 196 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_6_7 +[.] Input length : ret = 116 exp = 116 -> OK +[.] Output length : ret = 200 exp = 200 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_5_9 +[.] Input length : ret = 108 exp = 108 -> OK +[.] Output length : ret = 208 exp = 208 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_5_15 +[.] Input length : ret = 97 exp = 97 -> OK +[.] Output length : ret = 212 exp = 212 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_tch_ahs_4_75 +[.] Input length : ret = 89 exp = 89 -> OK +[.] Output length : ret = 212 exp = 212 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_mcs1_dl_hdr +[.] Input length : ret = 36 exp = 36 -> OK +[.] Output length : ret = 108 exp = 108 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: gsm0503_mcs1_ul_hdr +[.] Input length : ret = 39 exp = 39 -> OK +[.] Output length : ret = 117 exp = 117 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK diff --git a/tests/testsuite.at b/tests/testsuite.at index d6181c9..f13e3ab 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -39,6 +39,12 @@ AT_CHECK([$abs_top_builddir/tests/conv/conv_test], [0], [expout]) AT_CLEANUP +AT_SETUP([conv_gsm0503]) +AT_KEYWORDS([conv_gsm0503]) +cat $abs_srcdir/conv/conv_gsm0503_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/conv/conv_gsm0503_test], [0], [expout]) +AT_CLEANUP + AT_SETUP([msgb]) AT_KEYWORDS([msgb]) cat $abs_srcdir/msgb/msgb_test.ok > expout -- To view, visit https://gerrit.osmocom.org/1628 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Thu Feb 9 09:39:19 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 9 Feb 2017 09:39:19 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello lynxis lazus, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#8). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 283 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/8 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..07285dd --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,252 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/rsl_oml" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + return ret; + } else if (ret < 0) { + perror("read "); + return ret; + } + msgb_put(msg, ret); + + return e1inp_rx_ts_lapd(&line->ts[0], msg); +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char *sock_path; + int ret = 0; + int i; + + if (line->sock_path) + sock_path = line->sock_path; + else + sock_path = UNIXSOCKET_SOCK_PATH_DEFAULT; + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg, &config->fd, e1inp_dlsap_up, + e1i_ts, &lapd_profile_abis); + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 8 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Thu Feb 9 09:50:39 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 9 Feb 2017 09:50:39 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 8: > It might still be good to have a reasonable default, to make it > 'simply work' without user invention, but to have the line number > encoded in that default. But then, if multiple instances of > OsmoNITB/OsmoBSC were running, that wouldn't help either. so let.s > keep it as-is. In many cases we will have a single BTS, single BSC situation. I think a simple default makes a lot of sense. In a more complex setups the user will have to configure it properly which is fine. -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 8 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 11:07:59 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 11:07:59 +0000 Subject: libosmocore[master]: tests/conv: add GSM 05.03 specific test In-Reply-To: References: Message-ID: Patch Set 3: I wonder if it's related to asan error in 933. -- To view, visit https://gerrit.osmocom.org/1628 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 11:56:12 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Thu, 9 Feb 2017 11:56:12 +0000 Subject: libosmocore[master]: tests/conv: add GSM 05.03 specific test In-Reply-To: References: Message-ID: Patch Set 3: > I wonder if it's related to asan error in 933. No, it isn't related to 933. Sylvain or Tom should know the reason. I think, EDGE codes aren't supported by current code. -- To view, visit https://gerrit.osmocom.org/1628 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 12:38:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 9 Feb 2017 12:38:45 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/1775/1/src/tbf_dl.cpp File src/tbf_dl.cpp: Line 634: enum egprs_puncturing_values punct[2] = { > Why hard coding of 2. Cant there be more blocks? ARRAY_SIZE(rlc.block_info) always results in 2. The call below to gprs_rlc_mcs_cps() also implies that punct has a length of two, since exactly the two array items are passed to the function. Anything else than a size of two would frankly not make sense, and if someone changes the block_info size things would break silently before this patch. This patch ensures that we will not miss this if the block_info size changes: the static assert below will highlight that something needs to be adjusted here. Hence I fixate it on 2 and can use the inline initialization as above (without a for loop). -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 9 12:47:47 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 12:47:47 +0000 Subject: [PATCH] osmo-bts[master]: osmo-bts-trx: cosmetic fixes In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1776 to look at the new patch set (#3). osmo-bts-trx: cosmetic fixes * print actual value causing error and the check range * fix log error message typo * use preprocessor #if 0 to avoid compilation warning for disabled code * do not attempt to send 0-length bursts to avoid flood of errors after bts startup * don't set DTXu marker for broken frames Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 --- M src/common/scheduler.c M src/osmo-bts-trx/gsm0503_coding.c M src/osmo-bts-trx/scheduler_trx.c 3 files changed, 18 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/76/1776/3 diff --git a/src/common/scheduler.c b/src/common/scheduler.c index 724fb5a..27b7630 100644 --- a/src/common/scheduler.c +++ b/src/common/scheduler.c @@ -305,11 +305,11 @@ goto wrong_type; } if (prim_fn > 100) { - LOGP(DL1C, LOGL_NOTICE, "Prim for trx=%u ts=%u at fn=%u " - "is out of range, or channel %s with type %s is " - "already disabled. If this happens in conjunction " - "with PCU, increase 'rts-advance' by 5. " - "(current fn=%u)\n", l1t->trx->nr, tn, + LOGP(DL1C, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at " + "fn=%u is out of range (100), or channel %s with " + "type %s is already disabled. If this happens in " + "conjunction with PCU, increase 'rts-advance' by 5." + " (current fn=%u)\n", prim_fn, l1t->trx->nr, tn, l1sap->u.data.fn, get_lchan_by_chan_nr(l1t->trx, chan_nr)->name, get_value_string(trx_chan_type_names, chan), fn); @@ -1609,10 +1609,12 @@ no_data: /* in case of C0, we need a dummy burst to maintain RF power */ if (bits == NULL && l1t->trx == l1t->trx->bts->c0) { -if (0) if (chan != TRXC_IDLE) // hack - LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u " - "burst=%d on C0, so filling with dummy burst\n", - trx_chan_desc[chan].name, fn, tn, bid); +#if 0 + if (chan != TRXC_IDLE) // hack + LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u " + "burst=%d on C0, so filling with dummy burst\n", + trx_chan_desc[chan].name, fn, tn, bid); +#endif bits = (ubit_t *) dummy_burst; } diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c index 4c4f7f1..9e04452 100644 --- a/src/osmo-bts-trx/gsm0503_coding.c +++ b/src/osmo-bts-trx/gsm0503_coding.c @@ -1687,7 +1687,7 @@ if (steal > 0) { rv = _xcch_decode_cB(tch_data, cB, n_errors, n_bits_total); if (rv) { - LOGP(DL1C, LOGL_NOTICE, "tch_fr_decode(): error decoding FACCH frame (%d/%d bits)\n", *n_errors, *n_bits_total); + LOGP(DL1C, LOGL_NOTICE, "tch_fr_decode(): error decoding FACCH/F frame (%d/%d bits)\n", *n_errors, *n_bits_total); return -1; } @@ -1823,7 +1823,7 @@ rv = _xcch_decode_cB(tch_data, cB, n_errors, n_bits_total); if (rv) { - LOGP(DL1C, LOGL_NOTICE, "tch_hr_decode(): error decoding FACCH frame (%d/%d bits)\n", *n_errors, *n_bits_total); + LOGP(DL1C, LOGL_NOTICE, "tch_hr_decode(): error decoding FACCH/H frame (%d/%d bits)\n", *n_errors, *n_bits_total); return -1; } @@ -1845,7 +1845,7 @@ rv = osmo_crc8gen_check_bits(&gsm0503_tch_fr_crc3, d + 73, 22, p); if (rv) { - LOGP(DL1C, LOGL_NOTICE, "tch_fr_decode(): error checking CRC8 for an HR frame\n"); + LOGP(DL1C, LOGL_NOTICE, "tch_hr_decode(): error checking CRC8 for an HR frame (%d/%d bits)\n", *n_errors, *n_bits_total); return -1; } diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index d946ad5..da92d20 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -1236,7 +1236,8 @@ rc = tch_hr_decode(tch_data, *bursts_p, (((fn + 26 - 10) % 26) >> 2) & 1, &n_errors, &n_bits_total); - lchan_set_marker(osmo_hr_check_sid(tch_data, rc), lchan); /* DTXu */ + if (rc) /* DTXu */ + lchan_set_marker(osmo_hr_check_sid(tch_data, rc), lchan); break; case GSM48_CMODE_SPEECH_AMR: /* AMR */ /* the first FN 0,8,17 or 1,9,18 defines that CMI is included @@ -1375,7 +1376,8 @@ continue; } else gain = 0; - trx_if_data(l1h, tn, fn, gain, bits, nbits); + if (nbits) + trx_if_data(l1h, tn, fn, gain, bits, nbits); } } -- To view, visit https://gerrit.osmocom.org/1776 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou From gerrit-no-reply at lists.osmocom.org Thu Feb 9 12:58:29 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 9 Feb 2017 12:58:29 +0000 Subject: osmo-bts[master]: LC15: fix coding style In-Reply-To: References: Message-ID: Patch Set 1: has this trivial review been sitting here for 5 months? We will abandon this soon. -- To view, visit https://gerrit.osmocom.org/807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I18d07822df1f36a6855b72f83e2d73d221aa8735 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Minh-Quang Nguyen Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Minh-Quang Nguyen Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 13:06:54 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 9 Feb 2017 13:06:54 +0000 Subject: openbsc[master]: tests: fix leaks by talloc ctx In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) https://gerrit.osmocom.org/#/c/1751/2/openbsc/tests/gtphub/gtphub_test.c File openbsc/tests/gtphub/gtphub_test.c: Line 1784: talloc_free(osmo_gtphub_ctx); I'm not sure this makes sense. The line above verifies that there are no memleaks, and when the test exits, the entire memory of the process will be freed. ... BTW the source code for the 'git' program does this generally: it hardly ever frees anything because it assumes to be a short-lived process to be cleaned up by the kernel on exit ;) -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 9 14:53:01 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 9 Feb 2017 14:53:01 +0000 Subject: [PATCH] libosmocore[master]: cosmetic: replace fprintf with LOGP Message-ID: Review at https://gerrit.osmocom.org/1782 cosmetic: replace fprintf with LOGP socket.c still uses fprintf to output error messages. This commit replaces the fprintf with proper LOGP messages. Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 --- M src/socket.c M tests/socket/socket_test.c M tests/socket/socket_test.err 3 files changed, 27 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1782/1 diff --git a/src/socket.c b/src/socket.c index 3c5548f..2c1b547 100644 --- a/src/socket.c +++ b/src/socket.c @@ -73,7 +73,7 @@ if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) == (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) { - fprintf(stderr, "invalid: both bind and connect flags set:" + LOGP(DLGLOBAL, LOGL_ERROR, "invalid: both bind and connect flags set:" " %s:%u\n", host, port); return -EINVAL; } @@ -97,7 +97,7 @@ rc = getaddrinfo(host, portbuf, &hints, &result); if (rc != 0) { - fprintf(stderr, "getaddrinfo returned NULL: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo returned NULL: %s:%u: %s\n", host, port, strerror(errno)); return -EINVAL; } @@ -114,7 +114,7 @@ continue; if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot set this socket unblocking:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -131,7 +131,7 @@ rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (rc < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot setsockopt socket:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -145,7 +145,7 @@ freeaddrinfo(result); if (rp == NULL) { - fprintf(stderr, "unable to connect/bind socket: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect/bind socket: %s:%u: %s\n", host, port, strerror(errno)); return -ENODEV; } @@ -247,7 +247,8 @@ s = getnameinfo(ss, sa_len, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (s != 0) { - perror("getnameinfo failed"); + LOGP(DLGLOBAL, LOGL_ERROR, "getnameinfo failed:" + " %s\n", strerror(errno)); return s; } @@ -292,7 +293,8 @@ struct ifaddrs *ifaddr, *ifa; if (getifaddrs(&ifaddr) == -1) { - perror("getifaddrs"); + LOGP(DLGLOBAL, LOGL_ERROR, "getifaddrs:" + " %s\n", strerror(errno)); return -EIO; } @@ -359,7 +361,9 @@ if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - perror("cannot set this socket unblocking"); + LOGP(DLGLOBAL, LOGL_ERROR, + "cannot set this socket unblocking: %s\n", + strerror(errno)); close(sfd); return -EINVAL; } diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c index 75088e5..dabff7b 100644 --- a/tests/socket/socket_test.c +++ b/tests/socket/socket_test.c @@ -30,6 +30,7 @@ #include #include +#include #include "../config.h" @@ -71,8 +72,19 @@ return 0; } +const struct log_info_cat default_categories[] = { +}; + +static struct log_info info = { + .cat = default_categories, + .num_cat = ARRAY_SIZE(default_categories), +}; + int main(int argc, char *argv[]) { + osmo_init_logging(&info); + test_sockinit(); - return 0; + + return EXIT_SUCCESS; } diff --git a/tests/socket/socket_test.err b/tests/socket/socket_test.err index 5367239..750233a 100644 --- a/tests/socket/socket_test.err +++ b/tests/socket/socket_test.err @@ -1 +1,2 @@ -invalid: both bind and connect flags set: 0.0.0.0:0 +<0000> socket.c:77 invalid: both bind and connect flags set: 0.0.0.0:0 + \ No newline at end of file -- To view, visit https://gerrit.osmocom.org/1782 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Thu Feb 9 15:04:29 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 9 Feb 2017 15:04:29 +0000 Subject: [PATCH] libosmocore[master]: cosmetic: replace fprintf with LOGP In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1782 to look at the new patch set (#2). cosmetic: replace fprintf with LOGP socket.c still uses fprintf to output error messages. This commit replaces the fprintf with proper LOGP messages. Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 --- M src/socket.c M tests/socket/socket_test.c M tests/socket/socket_test.err 3 files changed, 28 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1782/2 diff --git a/src/socket.c b/src/socket.c index 3c5548f..2c1b547 100644 --- a/src/socket.c +++ b/src/socket.c @@ -73,7 +73,7 @@ if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) == (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) { - fprintf(stderr, "invalid: both bind and connect flags set:" + LOGP(DLGLOBAL, LOGL_ERROR, "invalid: both bind and connect flags set:" " %s:%u\n", host, port); return -EINVAL; } @@ -97,7 +97,7 @@ rc = getaddrinfo(host, portbuf, &hints, &result); if (rc != 0) { - fprintf(stderr, "getaddrinfo returned NULL: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo returned NULL: %s:%u: %s\n", host, port, strerror(errno)); return -EINVAL; } @@ -114,7 +114,7 @@ continue; if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot set this socket unblocking:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -131,7 +131,7 @@ rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (rc < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot setsockopt socket:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -145,7 +145,7 @@ freeaddrinfo(result); if (rp == NULL) { - fprintf(stderr, "unable to connect/bind socket: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect/bind socket: %s:%u: %s\n", host, port, strerror(errno)); return -ENODEV; } @@ -247,7 +247,8 @@ s = getnameinfo(ss, sa_len, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (s != 0) { - perror("getnameinfo failed"); + LOGP(DLGLOBAL, LOGL_ERROR, "getnameinfo failed:" + " %s\n", strerror(errno)); return s; } @@ -292,7 +293,8 @@ struct ifaddrs *ifaddr, *ifa; if (getifaddrs(&ifaddr) == -1) { - perror("getifaddrs"); + LOGP(DLGLOBAL, LOGL_ERROR, "getifaddrs:" + " %s\n", strerror(errno)); return -EIO; } @@ -359,7 +361,9 @@ if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - perror("cannot set this socket unblocking"); + LOGP(DLGLOBAL, LOGL_ERROR, + "cannot set this socket unblocking: %s\n", + strerror(errno)); close(sfd); return -EINVAL; } diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c index 75088e5..d7304cf 100644 --- a/tests/socket/socket_test.c +++ b/tests/socket/socket_test.c @@ -28,8 +28,10 @@ #include #include +#include #include #include +#include #include "../config.h" @@ -71,8 +73,19 @@ return 0; } +const struct log_info_cat default_categories[] = { +}; + +static struct log_info info = { + .cat = default_categories, + .num_cat = ARRAY_SIZE(default_categories), +}; + int main(int argc, char *argv[]) { + osmo_init_logging(&info); + test_sockinit(); - return 0; + + return EXIT_SUCCESS; } diff --git a/tests/socket/socket_test.err b/tests/socket/socket_test.err index 5367239..750233a 100644 --- a/tests/socket/socket_test.err +++ b/tests/socket/socket_test.err @@ -1 +1,2 @@ -invalid: both bind and connect flags set: 0.0.0.0:0 +<0000> socket.c:77 invalid: both bind and connect flags set: 0.0.0.0:0 + \ No newline at end of file -- To view, visit https://gerrit.osmocom.org/1782 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 9 15:21:12 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 9 Feb 2017 15:21:12 +0000 Subject: [PATCH] libosmocore[master]: cosmetic: replace fprintf with LOGP In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1782 to look at the new patch set (#3). cosmetic: replace fprintf with LOGP socket.c still uses fprintf to output error messages. This commit replaces the fprintf with proper LOGP messages. Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 --- M src/socket.c M tests/socket/socket_test.c 2 files changed, 28 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1782/3 diff --git a/src/socket.c b/src/socket.c index 3c5548f..2c1b547 100644 --- a/src/socket.c +++ b/src/socket.c @@ -73,7 +73,7 @@ if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) == (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) { - fprintf(stderr, "invalid: both bind and connect flags set:" + LOGP(DLGLOBAL, LOGL_ERROR, "invalid: both bind and connect flags set:" " %s:%u\n", host, port); return -EINVAL; } @@ -97,7 +97,7 @@ rc = getaddrinfo(host, portbuf, &hints, &result); if (rc != 0) { - fprintf(stderr, "getaddrinfo returned NULL: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo returned NULL: %s:%u: %s\n", host, port, strerror(errno)); return -EINVAL; } @@ -114,7 +114,7 @@ continue; if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot set this socket unblocking:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -131,7 +131,7 @@ rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (rc < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot setsockopt socket:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -145,7 +145,7 @@ freeaddrinfo(result); if (rp == NULL) { - fprintf(stderr, "unable to connect/bind socket: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect/bind socket: %s:%u: %s\n", host, port, strerror(errno)); return -ENODEV; } @@ -247,7 +247,8 @@ s = getnameinfo(ss, sa_len, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (s != 0) { - perror("getnameinfo failed"); + LOGP(DLGLOBAL, LOGL_ERROR, "getnameinfo failed:" + " %s\n", strerror(errno)); return s; } @@ -292,7 +293,8 @@ struct ifaddrs *ifaddr, *ifa; if (getifaddrs(&ifaddr) == -1) { - perror("getifaddrs"); + LOGP(DLGLOBAL, LOGL_ERROR, "getifaddrs:" + " %s\n", strerror(errno)); return -EIO; } @@ -359,7 +361,9 @@ if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - perror("cannot set this socket unblocking"); + LOGP(DLGLOBAL, LOGL_ERROR, + "cannot set this socket unblocking: %s\n", + strerror(errno)); close(sfd); return -EINVAL; } diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c index 75088e5..5b6abc4 100644 --- a/tests/socket/socket_test.c +++ b/tests/socket/socket_test.c @@ -28,8 +28,10 @@ #include #include +#include #include #include +#include #include "../config.h" @@ -71,8 +73,21 @@ return 0; } +const struct log_info_cat default_categories[] = { +}; + +static struct log_info info = { + .cat = default_categories, + .num_cat = ARRAY_SIZE(default_categories), +}; + int main(int argc, char *argv[]) { + osmo_init_logging(&info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + test_sockinit(); - return 0; + + return EXIT_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1782 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:05:38 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:05:38 +0000 Subject: [PATCH] osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... Message-ID: Review at https://gerrit.osmocom.org/1783 oml: Fix incorrect usage of const variable abis_nm_att_tlvdef_ipa This bug was introduced during moving oml definitions from osmo-bts to libosmocore, when type of abis_nm_att_tlvdef_ipa was changed from struct tlv_definition to const struct tlv_definition. The following solution is proposed: * create static abis_nm_att_tlvdef_ipa_local variable for oml attribute definitions * copy abis_nm_att_tlvdef_ipa to abis_nm_att_tlvdef_ipa_local * merge abis_nm_att_tlvdef with abis_nm_att_tlvdef_ipa_local * use abis_nm_att_tlvdef_ipa_local in oml_tlv_parse function Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c --- M src/common/oml.c 1 file changed, 8 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/83/1783/1 diff --git a/src/common/oml.c b/src/common/oml.c index 272123e..55c54e5 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -46,13 +46,18 @@ static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg); +static struct tlv_definition abis_nm_att_tlvdef_ipa_local = { + .def = { + }, +}; + /* * support */ static int oml_tlv_parse(struct tlv_parsed *tp, const uint8_t *buf, int len) { - return tlv_parse(tp, &abis_nm_att_tlvdef_ipa, buf, len, 0, 0); + return tlv_parse(tp, &abis_nm_att_tlvdef_ipa_local, buf, len, 0, 0); } struct msgb *oml_msgb_alloc(void) @@ -1247,7 +1252,8 @@ int oml_init(struct gsm_abis_mo *mo) { DEBUGP(DOML, "Initializing OML attribute definitions\n"); - tlv_def_patch(&abis_nm_att_tlvdef_ipa, &abis_nm_att_tlvdef); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef_ipa); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef); osmo_signal_register_handler(SS_FAIL, handle_fail_sig, mo); return 0; -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:35:55 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:35:55 +0000 Subject: [PATCH] osmo-bts[master]: rsl: Output RTP stats before closing the socket. Message-ID: Review at https://gerrit.osmocom.org/1784 rsl: Output RTP stats before closing the socket. It's useful to know RTP statistics (number of packets lost, jitter, etc) when looking at voice call quality issues. Right now this information is not avialable anywhere and this looks like the best place to start. Change-Id: Ife9f27c43157b4a1bf71aba41cd7b0f5f41ac99f --- M src/common/rsl.c 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/84/1784/1 diff --git a/src/common/rsl.c b/src/common/rsl.c index 5c4e4ff..deacdc3 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1023,6 +1023,8 @@ if (lchan->abis_ip.rtp_socket) { rsl_tx_ipac_dlcx_ind(lchan, RSL_ERR_NORMAL_UNSPEC); + osmo_rtp_socket_log_stats(lchan->abis_ip.rtp_socket, DRSL, LOGL_INFO, + "Closing RTP socket on Channel Release "); osmo_rtp_socket_free(lchan->abis_ip.rtp_socket); lchan->abis_ip.rtp_socket = NULL; msgb_queue_flush(&lchan->dl_tch_queue); @@ -1786,6 +1788,8 @@ inc_conn_id = 1; rc = rsl_tx_ipac_dlcx_ack(lchan, inc_conn_id); + osmo_rtp_socket_log_stats(lchan->abis_ip.rtp_socket, DRSL, LOGL_INFO, + "Closing RTP socket on DLCX "); osmo_rtp_socket_free(lchan->abis_ip.rtp_socket); lchan->abis_ip.rtp_socket = NULL; msgb_queue_flush(&lchan->dl_tch_queue); -- To view, visit https://gerrit.osmocom.org/1784 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ife9f27c43157b4a1bf71aba41cd7b0f5f41ac99f Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:35:56 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:35:56 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... Message-ID: Review at https://gerrit.osmocom.org/1785 osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER parameters on second channel (TRX1) of osmo-trx Move rxgain and tx-attenuation (power) parameters from phy_link layer to phy_inst layer. Rxgain and tx-attenuation parameters should be set for each phy_inst and send for each osmo-trx channel accordingly via control commands. Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f --- M include/osmo-bts/phy_link.h M src/osmo-bts-trx/l1_if.c M src/osmo-bts-trx/l1_if.h M src/osmo-bts-trx/main.c M src/osmo-bts-trx/trx_vty.c 5 files changed, 83 insertions(+), 83 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/85/1785/1 diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index a7963d0..e644a91 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -44,15 +44,6 @@ uint32_t clock_advance; uint32_t rts_advance; - - int rxgain_valid; - int rxgain; - int rxgain_sent; - - int power_valid; - int power; - int power_oml; - int power_sent; } osmotrx; struct { /* MAC address of the PHY */ diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index a42d39a..8c5115b 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -203,17 +203,13 @@ } /* after power on */ - if (l1h->phy_inst->num == 0) { - if (plink->u.osmotrx.rxgain_valid && - !plink->u.osmotrx.rxgain_sent) { - trx_if_cmd_setrxgain(l1h, plink->u.osmotrx.rxgain); - plink->u.osmotrx.rxgain_sent = 1; - } - if (plink->u.osmotrx.power_valid && - !plink->u.osmotrx.power_sent) { - trx_if_cmd_setpower(l1h, plink->u.osmotrx.power); - plink->u.osmotrx.power_sent = 1; - } + if (l1h->config.rxgain_valid && !l1h->config.rxgain_sent) { + trx_if_cmd_setrxgain(l1h, l1h->config.rxgain); + l1h->config.rxgain_sent = 1; + } + if (l1h->config.power_valid && !l1h->config.power_sent) { + trx_if_cmd_setpower(l1h, l1h->config.power); + l1h->config.power_sent = 1; } if (l1h->config.maxdly_valid && !l1h->config.maxdly_sent) { trx_if_cmd_setmaxdly(l1h, l1h->config.maxdly); @@ -238,10 +234,8 @@ if (!l1h->config.poweron && !l1h->config.poweron_sent) { trx_if_cmd_poweroff(l1h); l1h->config.poweron_sent = 1; - if (l1h->phy_inst->num == 0) { - plink->u.osmotrx.rxgain_sent = 0; - plink->u.osmotrx.power_sent = 0; - } + l1h->config.rxgain_sent = 0; + l1h->config.power_sent = 0; l1h->config.maxdly_sent = 0; l1h->config.maxdlynb_sent = 0; for (tn = 0; tn < TRX_NR_TS; tn++) @@ -264,11 +258,10 @@ l1h->config.tsc_sent = 0; l1h->config.bsic_sent = 0; l1h->config.poweron_sent = 0; - if (l1h->phy_inst->num == 0) { - plink->u.osmotrx.rxgain_sent = 0; - plink->u.osmotrx.power_sent = 0; - } + l1h->config.rxgain_sent = 0; + l1h->config.power_sent = 0; l1h->config.maxdly_sent = 0; + l1h->config.maxdlynb_sent = 0; for (tn = 0; tn < TRX_NR_TS; tn++) l1h->config.slottype_sent[tn] = 0; l1if_provision_transceiver_trx(l1h); @@ -390,10 +383,10 @@ l1if_provision_transceiver_trx(l1h); } - if (plink->u.osmotrx.power_oml && pinst->num == 0) { - plink->u.osmotrx.power = trx->max_power_red; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + if (l1h->config.power_oml) { + l1h->config.power = trx->max_power_red; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; l1if_provision_transceiver_trx(l1h); } diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index f0b2e67..3f3e08b 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -20,6 +20,15 @@ uint8_t bsic; int bsic_sent; + int rxgain_valid; + int rxgain; + int rxgain_sent; + + int power_valid; + int power; + int power_oml; + int power_sent; + int maxdly_valid; int maxdly; int maxdly_sent; diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index 62e8fe9..dbd8fc4 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -117,7 +117,6 @@ plink->u.osmotrx.base_port_remote = 5700; plink->u.osmotrx.clock_advance = 20; plink->u.osmotrx.rts_advance = 5; - plink->u.osmotrx.power_oml = 1; } void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index ca347e8..3822b0f 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -100,6 +100,17 @@ vty_out(vty, "PHY Instance %s%s", phy_instance_name(pinst), VTY_NEWLINE); + + if (l1h->config.rxgain_valid) + vty_out(vty, " rx-gain : %d dB%s", + l1h->config.rxgain, VTY_NEWLINE); + else + vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); + if (l1h->config.power_valid) + vty_out(vty, " tx-attenuation : %d dB%s", + l1h->config.power, VTY_NEWLINE); + else + vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); if (l1h->config.maxdly_valid) vty_out(vty, " maxdly : %d%s", l1h->config.maxdly, VTY_NEWLINE); @@ -129,17 +140,6 @@ struct phy_instance *pinst; vty_out(vty, "PHY %u%s", plink->num, VTY_NEWLINE); - - if (plink->u.osmotrx.rxgain_valid) - vty_out(vty, " rx-gain : %d dB%s", - plink->u.osmotrx.rxgain, VTY_NEWLINE); - else - vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); - if (plink->u.osmotrx.power_valid) - vty_out(vty, " tx-attenuation : %d dB%s", - plink->u.osmotrx.power, VTY_NEWLINE); - else - vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); llist_for_each_entry(pinst, &plink->instances, list) show_phy_inst_single(vty, pinst); @@ -309,7 +309,7 @@ return CMD_SUCCESS; } -DEFUN(cfg_phy_power_on, cfg_phy_power_on_cmd, +DEFUN(cfg_phyinst_power_on, cfg_phyinst_power_on_cmd, "osmotrx power (on|off)", OSMOTRX_STR "Change TRX state\n" @@ -356,70 +356,78 @@ return CMD_SUCCESS; } -DEFUN(cfg_phy_rxgain, cfg_phy_rxgain_cmd, +DEFUN(cfg_phyinst_rxgain, cfg_phyinst_rxgain_cmd, "osmotrx rx-gain <0-50>", OSMOTRX_STR "Set the receiver gain in dB\n" "Gain in dB\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.rxgain = atoi(argv[0]); - plink->u.osmotrx.rxgain_valid = 1; - plink->u.osmotrx.rxgain_sent = 0; + l1h->config.rxgain = atoi(argv[0]); + l1h->config.rxgain_valid = 1; + l1h->config.rxgain_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_tx_atten, cfg_phy_tx_atten_cmd, +DEFUN(cfg_phyinst_tx_atten, cfg_phyinst_tx_atten_cmd, "osmotrx tx-attenuation <0-50>", OSMOTRX_STR "Set the transmitter attenuation\n" "Fixed attenuation in dB, overriding OML\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power = atoi(argv[0]); - plink->u.osmotrx.power_oml = 0; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + l1h->config.power = atoi(argv[0]); + l1h->config.power_oml = 0; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_tx_atten_oml, cfg_phy_tx_atten_oml_cmd, +DEFUN(cfg_phyinst_tx_atten_oml, cfg_phyinst_tx_atten_oml_cmd, "osmotrx tx-attenuation oml", OSMOTRX_STR "Set the transmitter attenuation\n" "Use NM_ATT_RF_MAXPOWR_R (max power reduction) from BSC via OML\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power_oml = 1; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + l1h->config.power_oml = 1; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_no_rxgain, cfg_phy_no_rxgain_cmd, +DEFUN(cfg_phyinst_no_rxgain, cfg_phyinst_no_rxgain_cmd, "no osmotrx rx-gain", NO_STR OSMOTRX_STR "Unset the receiver gain in dB\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.rxgain_valid = 0; + l1h->config.rxgain_valid = 0; return CMD_SUCCESS; } -DEFUN(cfg_phy_no_tx_atten, cfg_phy_no_tx_atten_cmd, +DEFUN(cfg_phyinst_no_tx_atten, cfg_phyinst_no_tx_atten_cmd, "no osmotrx tx-attenuation", NO_STR OSMOTRX_STR "Unset the transmitter attenuation\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power_valid = 0; + l1h->config.power_valid = 0; return CMD_SUCCESS; } @@ -488,22 +496,22 @@ plink->u.osmotrx.clock_advance, VTY_NEWLINE); vty_out(vty, " osmotrx rts-advance %d%s", plink->u.osmotrx.rts_advance, VTY_NEWLINE); - if (plink->u.osmotrx.rxgain_valid) - vty_out(vty, " osmotrx rx-gain %d%s", - plink->u.osmotrx.rxgain, VTY_NEWLINE); - if (plink->u.osmotrx.power_valid) { - if (plink->u.osmotrx.power_oml) - vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); - else - vty_out(vty, " osmotrx tx-attenuation %d%s", - plink->u.osmotrx.power, VTY_NEWLINE); - } } void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { struct trx_l1h *l1h = pinst->u.osmotrx.hdl; + if (l1h->config.rxgain_valid) + vty_out(vty, " osmotrx rx-gain %d%s", + l1h->config.rxgain, VTY_NEWLINE); + if (l1h->config.power_valid) { + if (l1h->config.power_oml) + vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); + else + vty_out(vty, " osmotrx tx-attenuation %d%s", + l1h->config.power, VTY_NEWLINE); + } if (l1h->config.maxdly_valid) vty_out(vty, " maxdly %d%s", l1h->config.maxdly, VTY_NEWLINE); if (l1h->config.maxdlynb_valid) @@ -560,14 +568,14 @@ install_element(PHY_NODE, &cfg_phy_fn_advance_cmd); install_element(PHY_NODE, &cfg_phy_rts_advance_cmd); install_element(PHY_NODE, &cfg_phy_transc_ip_cmd); - install_element(PHY_NODE, &cfg_phy_rxgain_cmd); - install_element(PHY_NODE, &cfg_phy_tx_atten_cmd); - install_element(PHY_NODE, &cfg_phy_tx_atten_oml_cmd); - install_element(PHY_NODE, &cfg_phy_no_rxgain_cmd); - install_element(PHY_NODE, &cfg_phy_no_tx_atten_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_rxgain_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_oml_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_rxgain_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_tx_atten_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_slotmask_cmd); - install_element(PHY_INST_NODE, &cfg_phy_power_on_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_power_on_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_maxdly_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_no_maxdly_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_maxdlynb_cmd); -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:35:56 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:35:56 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... Message-ID: Review at https://gerrit.osmocom.org/1786 osmo-trx-bts: Fix osmo-bts-trx crash on startup during reading phy instance parameters from config file pinst->u.osmotrx.hdl should be allocated before reading phy_instance parameters from config file and applying them. So allocation of pinst->u.osmotrx.hdl should be moved from l1if_open function to bts_model_phy_instance_set_defaults function, which is proper place for this allocation according start-up procedure of osmo-bts. Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 --- M src/osmo-bts-trx/l1_if.c M src/osmo-bts-trx/main.c 2 files changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/86/1786/1 diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 8c5115b..6c1969c 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -66,10 +66,9 @@ struct trx_l1h *l1h; int rc; - l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); + l1h = pinst->u.osmotrx.hdl; if (!l1h) return NULL; - l1h->phy_inst = pinst; rc = trx_sched_init(&l1h->l1s, pinst->trx); if (rc < 0) { diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index dbd8fc4..98066ca 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -121,6 +121,10 @@ void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) { + struct trx_l1h *l1h; + l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); + l1h->phy_inst = pinst; + pinst->u.osmotrx.hdl = l1h; } int main(int argc, char **argv) -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:35:56 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:35:56 +0000 Subject: [PATCH] osmo-bts[master]: osmo-bts: Fix procedure of writing configuration for each ph... Message-ID: Review at https://gerrit.osmocom.org/1787 osmo-bts: Fix procedure of writing configuration for each phy instance bts_model_config_write_phy_inst function should be called from function config_write_phy_single for writing configuration parameters for each phy inst. Also we should add functions for each bts_model for writing phy inst parameters to configuration (osmo-trx-bts already has implementation of this function). Change-Id: I27a13ff1813688cb30062450d8457a5083ba2a34 --- M src/common/vty.c M src/osmo-bts-litecell15/lc15bts_vty.c M src/osmo-bts-octphy/octphy_vty.c M src/osmo-bts-sysmo/sysmobts_vty.c 4 files changed, 13 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/87/1787/1 diff --git a/src/common/vty.c b/src/common/vty.c index b48afa4..646ac87 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -358,6 +358,7 @@ if (!pinst) break; vty_out(vty, " instance %u%s", pinst->num, VTY_NEWLINE); + bts_model_config_write_phy_inst(vty, pinst); } } diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c index 0ffe663..a76dc85 100644 --- a/src/osmo-bts-litecell15/lc15bts_vty.c +++ b/src/osmo-bts-litecell15/lc15bts_vty.c @@ -354,6 +354,10 @@ write_phy_inst(vty, pinst); } +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ +} + int bts_model_vty_init(struct gsm_bts *bts) { vty_bts = bts; diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index c2d1fbb..abfac1e 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -219,6 +219,10 @@ VTY_NEWLINE); } +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ +} + void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) { } diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index e67d8be..c1056dd 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -477,6 +477,10 @@ write_phy_inst(vty, pinst); } +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ +} + int bts_model_vty_init(struct gsm_bts *bts) { vty_bts = bts; -- To view, visit https://gerrit.osmocom.org/1787 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I27a13ff1813688cb30062450d8457a5083ba2a34 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:35:57 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:35:57 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... Message-ID: Review at https://gerrit.osmocom.org/1788 osmo-trx-bts: Fix incorrect bts shutdown procedure in case of abis connection closure This issue occurs in case of osmo-nitb restart which leads to abis connection closure. Function bts_shutdown from common/bts.c should be used in this case for properly bts shutdown. Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 --- M src/osmo-bts-trx/l1_if.c 1 file changed, 1 insertion(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/88/1788/1 diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 6c1969c..abb16eb 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -326,10 +326,7 @@ /* on RSL failure, deactivate transceiver */ void bts_model_abis_close(struct gsm_bts *bts) { - struct gsm_bts_trx *trx; - - llist_for_each_entry(trx, &bts->trx_list, list) - bts_model_trx_close(trx); + bts_shutdown(bts, "Abis close"); } int bts_model_adjst_ms_pwr(struct gsm_lchan *lchan) -- To view, visit https://gerrit.osmocom.org/1788 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Thu Feb 9 16:35:57 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Thu, 9 Feb 2017 16:35:57 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... Message-ID: Review at https://gerrit.osmocom.org/1789 osmo-trx-bts: Fix incorrect bts shutdown procedure in case of clock loss from osmo-trx This issue occurs in case of osmo-trx restart which leads to losing clock from osmo-trx. Function bts_shutdown from common/bts.c should be used in this case for properly bts shutdown. Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 --- M src/osmo-bts-trx/scheduler_trx.c 1 file changed, 1 insertion(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/89/1789/1 diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index d946ad5..9c676d7 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -1408,19 +1408,7 @@ no_clock: transceiver_available = 0; - /* flush pending messages of transceiver */ - /* close all logical channels and reset timeslots */ - llist_for_each_entry(trx, &bts->trx_list, list) { - struct phy_instance *pinst = trx_phy_instance(trx); - struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - trx_if_flush(l1h); - trx_sched_reset(&l1h->l1s); - if (trx->nr == 0) - trx_if_cmd_poweroff(l1h); - } - - /* tell BSC */ - check_transceiver_availability(bts, 0); + bts_shutdown(bts, "No clock from osmo-trx"); return; } -- To view, visit https://gerrit.osmocom.org/1789 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:32:08 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:32:08 +0000 Subject: [PATCH] openbsc[master]: Expand chan allocation logging Message-ID: Review at https://gerrit.osmocom.org/1790 Expand chan allocation logging Log more data related to channel allocation: - channel type - number of paging attempts - timers fired Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48 --- M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/bsc_api.c M openbsc/src/libbsc/paging.c M openbsc/src/libmsc/gsm_04_08.c 4 files changed, 14 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/90/1790/1 diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 8a6b111..cc190eb 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1659,7 +1659,9 @@ static void t3101_expired(void *data) { struct gsm_lchan *lchan = data; - + LOGP(DRSL, LOGL_NOTICE, + "%s T3101 expired: no response to IMMEDIATE ASSIGN\n", + gsm_lchan_name(lchan)); rsl_rf_chan_release(lchan, 1, SACCH_DEACTIVATE); } @@ -1667,7 +1669,9 @@ static void t3111_expired(void *data) { struct gsm_lchan *lchan = data; - + LOGP(DRSL, LOGL_NOTICE, + "%s T3111 expired: releasing RF Channel\n", + gsm_lchan_name(lchan)); rsl_rf_chan_release(lchan, 0, SACCH_NONE); } diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 8a4c85f..7a48296 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -397,7 +397,8 @@ handle_mr_config(conn, conn->lchan, full_rate); LOGP(DMSC, LOGL_NOTICE, - "Sending ChanModify for speech: %s on channel %s\n", + "Sending %s ChanModify for speech: %s on channel %s\n", + gsm_lchan_name(conn->lchan), get_value_string(gsm48_chan_mode_names, chan_mode), get_value_string(gsm_chan_t_names, conn->lchan->type)); gsm48_lchan_modify(conn->lchan, chan_mode); diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index fcb4deb..8c30637 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -79,8 +79,9 @@ log_set_context(BSC_CTX_SUBSCR, request->subscr); - LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: '%s' tmsi: '0x%x'\n", - request->subscr->imsi, request->subscr->tmsi); + LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " + "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, + request->subscr->tmsi, request->chan_type, request->attempts); if (request->subscr->tmsi == GSM_RESERVED_TMSI) mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi); @@ -376,11 +377,11 @@ req = NULL; if (conn && cbfn) { - LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d, calling cbfn.\n", bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", subscr->imsi, bts->nr); cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED, msg, conn, param); } else - LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d silently.\n", bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", subscr->imsi, bts->nr); break; } } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index e5402d0..1a64731 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1483,7 +1483,7 @@ apdu_len = gh->data[1]; apdu_data = gh->data+2; - DEBUGP(DRR, "RX APPLICATION INFO id/flags=0x%02x apdu_len=%u apdu=%s", + DEBUGP(DRR, "RX APPLICATION INFO id/flags=0x%02x apdu_len=%u apdu=%s\n", apdu_id_flags, apdu_len, osmo_hexdump(apdu_data, apdu_len)); return db_apdu_blob_store(conn->subscr, apdu_id_flags, apdu_len, apdu_data); -- To view, visit https://gerrit.osmocom.org/1790 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:32:09 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:32:09 +0000 Subject: [PATCH] openbsc[master]: Remove duplicating define Message-ID: Review at https://gerrit.osmocom.org/1791 Remove duplicating define Use GSM_MACBLOCK_LEN consistently throughout abis_rsl.c Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5 --- M openbsc/src/libbsc/abis_rsl.c 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/91/1791/1 diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index cc190eb..541a86d 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -181,13 +181,12 @@ "RSL"); } -#define MACBLOCK_SIZE 23 static void pad_macblock(uint8_t *out, const uint8_t *in, int len) { memcpy(out, in, len); - if (len < MACBLOCK_SIZE) - memset(out+len, 0x2b, MACBLOCK_SIZE-len); + if (len < GSM_MACBLOCK_LEN) + memset(out+len, 0x2b, GSM_MACBLOCK_LEN - len); } /* Chapter 9.3.7: Encryption Information */ @@ -1042,7 +1041,7 @@ { struct msgb *msg = rsl_msgb_alloc(); struct abis_rsl_dchan_hdr *dh; - uint8_t buf[MACBLOCK_SIZE]; + uint8_t buf[GSM_MACBLOCK_LEN]; dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh)); init_dchan_hdr(dh, RSL_MT_IMMEDIATE_ASSIGN_CMD); @@ -1055,7 +1054,8 @@ default: /* If phase 2, construct a FULL_IMM_ASS_INFO */ pad_macblock(buf, val, len); - msgb_tlv_put(msg, RSL_IE_FULL_IMM_ASS_INFO, MACBLOCK_SIZE, buf); + msgb_tlv_put(msg, RSL_IE_FULL_IMM_ASS_INFO, GSM_MACBLOCK_LEN, + buf); break; } -- To view, visit https://gerrit.osmocom.org/1791 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:41:18 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:41:18 +0000 Subject: osmo-bts[master]: rsl: Output RTP stats before closing the socket. In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1784 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ife9f27c43157b4a1bf71aba41cd7b0f5f41ac99f Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:46:04 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:46:04 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:47:50 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:47:50 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1786 to look at the new patch set (#2). osmo-trx-bts: Fix osmo-bts-trx crash on startup during reading phy instance parameters from config file pinst->u.osmotrx.hdl should be allocated before reading phy_instance parameters from config file and applying them. So allocation of pinst->u.osmotrx.hdl should be moved from l1if_open function to bts_model_phy_instance_set_defaults function, which is proper place for this allocation according to start-up procedure of osmo-bts. Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 --- M src/osmo-bts-trx/l1_if.c M src/osmo-bts-trx/main.c 2 files changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/86/1786/2 diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 8c5115b..6c1969c 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -66,10 +66,9 @@ struct trx_l1h *l1h; int rc; - l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); + l1h = pinst->u.osmotrx.hdl; if (!l1h) return NULL; - l1h->phy_inst = pinst; rc = trx_sched_init(&l1h->l1s, pinst->trx); if (rc < 0) { diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index dbd8fc4..98066ca 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -121,6 +121,10 @@ void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) { + struct trx_l1h *l1h; + l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); + l1h->phy_inst = pinst; + pinst->u.osmotrx.hdl = l1h; } int main(int argc, char **argv) -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:51:57 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:51:57 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (2 comments) https://gerrit.osmocom.org/#/c/1785/1/src/osmo-bts-trx/l1_if.h File src/osmo-bts-trx/l1_if.h: Line 23: int rxgain_valid; Seems like _valid and _sent are only used as bool. If so then better use bool type. Line 28: int power; Why signed type? Can it have negative value in some case? If not, than better use some unsigned type. -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:52:20 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:52:20 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:54:28 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:54:28 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1789 to look at the new patch set (#2). osmo-trx-bts: Fix incorrect bts shutdown procedure in case of clock loss from osmo-trx This issue occurs in case of osmo-trx restart which leads to losing clock from osmo-trx. Function bts_shutdown from common/bts.c should be used in this case for proper bts shutdown. Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 --- M src/osmo-bts-trx/scheduler_trx.c 1 file changed, 1 insertion(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/89/1789/2 diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index d946ad5..9c676d7 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -1408,19 +1408,7 @@ no_clock: transceiver_available = 0; - /* flush pending messages of transceiver */ - /* close all logical channels and reset timeslots */ - llist_for_each_entry(trx, &bts->trx_list, list) { - struct phy_instance *pinst = trx_phy_instance(trx); - struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - trx_if_flush(l1h); - trx_sched_reset(&l1h->l1s); - if (trx->nr == 0) - trx_if_cmd_poweroff(l1h); - } - - /* tell BSC */ - check_transceiver_availability(bts, 0); + bts_shutdown(bts, "No clock from osmo-trx"); return; } -- To view, visit https://gerrit.osmocom.org/1789 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:55:16 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:55:16 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1788 to look at the new patch set (#2). osmo-trx-bts: Fix incorrect bts shutdown procedure in case of abis connection closure This issue occurs in case of osmo-nitb restart which leads to abis connection closure. Function bts_shutdown from common/bts.c should be used in this case for proper bts shutdown. Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 --- M src/osmo-bts-trx/l1_if.c 1 file changed, 1 insertion(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/88/1788/2 diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 6c1969c..abb16eb 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -326,10 +326,7 @@ /* on RSL failure, deactivate transceiver */ void bts_model_abis_close(struct gsm_bts *bts) { - struct gsm_bts_trx *trx; - - llist_for_each_entry(trx, &bts->trx_list, list) - bts_model_trx_close(trx); + bts_shutdown(bts, "Abis close"); } int bts_model_adjst_ms_pwr(struct gsm_lchan *lchan) -- To view, visit https://gerrit.osmocom.org/1788 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:57:21 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:57:21 +0000 Subject: osmo-bts[master]: osmo-bts: Fix procedure of writing configuration for each ph... In-Reply-To: References: Message-ID: Patch Set 1: How does this relates to 1761? -- To view, visit https://gerrit.osmocom.org/1787 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I27a13ff1813688cb30062450d8457a5083ba2a34 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:58:23 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:58:23 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1789 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 9 18:58:39 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 9 Feb 2017 18:58:39 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1788 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 06:32:27 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 06:32:27 +0000 Subject: osmo-bts[master]: osmo-bts: Fix procedure of writing configuration for each ph... In-Reply-To: References: Message-ID: Patch Set 1: > How does this relates to 1761? I have checked 1761 and it fixes the same issue, so I think we should abandon this patch and apply 1761. -- To view, visit https://gerrit.osmocom.org/1787 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I27a13ff1813688cb30062450d8457a5083ba2a34 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 07:09:48 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 07:09:48 +0000 Subject: [PATCH] osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Hello Max, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1785 to look at the new patch set (#2). osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER parameters on second channel (TRX1) of osmo-trx Move rxgain and tx-attenuation (power) parameters from phy_link layer to phy_inst layer. Rxgain and tx-attenuation parameters should be set for each phy_inst and send for each osmo-trx channel accordingly via control commands. Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f --- M include/osmo-bts/phy_link.h M src/osmo-bts-trx/l1_if.c M src/osmo-bts-trx/l1_if.h M src/osmo-bts-trx/main.c M src/osmo-bts-trx/trx_vty.c 5 files changed, 83 insertions(+), 83 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/85/1785/2 diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index a7963d0..e644a91 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -44,15 +44,6 @@ uint32_t clock_advance; uint32_t rts_advance; - - int rxgain_valid; - int rxgain; - int rxgain_sent; - - int power_valid; - int power; - int power_oml; - int power_sent; } osmotrx; struct { /* MAC address of the PHY */ diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index a42d39a..8c5115b 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -203,17 +203,13 @@ } /* after power on */ - if (l1h->phy_inst->num == 0) { - if (plink->u.osmotrx.rxgain_valid && - !plink->u.osmotrx.rxgain_sent) { - trx_if_cmd_setrxgain(l1h, plink->u.osmotrx.rxgain); - plink->u.osmotrx.rxgain_sent = 1; - } - if (plink->u.osmotrx.power_valid && - !plink->u.osmotrx.power_sent) { - trx_if_cmd_setpower(l1h, plink->u.osmotrx.power); - plink->u.osmotrx.power_sent = 1; - } + if (l1h->config.rxgain_valid && !l1h->config.rxgain_sent) { + trx_if_cmd_setrxgain(l1h, l1h->config.rxgain); + l1h->config.rxgain_sent = 1; + } + if (l1h->config.power_valid && !l1h->config.power_sent) { + trx_if_cmd_setpower(l1h, l1h->config.power); + l1h->config.power_sent = 1; } if (l1h->config.maxdly_valid && !l1h->config.maxdly_sent) { trx_if_cmd_setmaxdly(l1h, l1h->config.maxdly); @@ -238,10 +234,8 @@ if (!l1h->config.poweron && !l1h->config.poweron_sent) { trx_if_cmd_poweroff(l1h); l1h->config.poweron_sent = 1; - if (l1h->phy_inst->num == 0) { - plink->u.osmotrx.rxgain_sent = 0; - plink->u.osmotrx.power_sent = 0; - } + l1h->config.rxgain_sent = 0; + l1h->config.power_sent = 0; l1h->config.maxdly_sent = 0; l1h->config.maxdlynb_sent = 0; for (tn = 0; tn < TRX_NR_TS; tn++) @@ -264,11 +258,10 @@ l1h->config.tsc_sent = 0; l1h->config.bsic_sent = 0; l1h->config.poweron_sent = 0; - if (l1h->phy_inst->num == 0) { - plink->u.osmotrx.rxgain_sent = 0; - plink->u.osmotrx.power_sent = 0; - } + l1h->config.rxgain_sent = 0; + l1h->config.power_sent = 0; l1h->config.maxdly_sent = 0; + l1h->config.maxdlynb_sent = 0; for (tn = 0; tn < TRX_NR_TS; tn++) l1h->config.slottype_sent[tn] = 0; l1if_provision_transceiver_trx(l1h); @@ -390,10 +383,10 @@ l1if_provision_transceiver_trx(l1h); } - if (plink->u.osmotrx.power_oml && pinst->num == 0) { - plink->u.osmotrx.power = trx->max_power_red; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + if (l1h->config.power_oml) { + l1h->config.power = trx->max_power_red; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; l1if_provision_transceiver_trx(l1h); } diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index f0b2e67..1864857 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -20,6 +20,15 @@ uint8_t bsic; int bsic_sent; + int rxgain_valid; + uint8_t rxgain; + int rxgain_sent; + + int power_valid; + uint8_t power; + int power_oml; + int power_sent; + int maxdly_valid; int maxdly; int maxdly_sent; diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index 62e8fe9..dbd8fc4 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -117,7 +117,6 @@ plink->u.osmotrx.base_port_remote = 5700; plink->u.osmotrx.clock_advance = 20; plink->u.osmotrx.rts_advance = 5; - plink->u.osmotrx.power_oml = 1; } void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index ca347e8..3822b0f 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -100,6 +100,17 @@ vty_out(vty, "PHY Instance %s%s", phy_instance_name(pinst), VTY_NEWLINE); + + if (l1h->config.rxgain_valid) + vty_out(vty, " rx-gain : %d dB%s", + l1h->config.rxgain, VTY_NEWLINE); + else + vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); + if (l1h->config.power_valid) + vty_out(vty, " tx-attenuation : %d dB%s", + l1h->config.power, VTY_NEWLINE); + else + vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); if (l1h->config.maxdly_valid) vty_out(vty, " maxdly : %d%s", l1h->config.maxdly, VTY_NEWLINE); @@ -129,17 +140,6 @@ struct phy_instance *pinst; vty_out(vty, "PHY %u%s", plink->num, VTY_NEWLINE); - - if (plink->u.osmotrx.rxgain_valid) - vty_out(vty, " rx-gain : %d dB%s", - plink->u.osmotrx.rxgain, VTY_NEWLINE); - else - vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); - if (plink->u.osmotrx.power_valid) - vty_out(vty, " tx-attenuation : %d dB%s", - plink->u.osmotrx.power, VTY_NEWLINE); - else - vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); llist_for_each_entry(pinst, &plink->instances, list) show_phy_inst_single(vty, pinst); @@ -309,7 +309,7 @@ return CMD_SUCCESS; } -DEFUN(cfg_phy_power_on, cfg_phy_power_on_cmd, +DEFUN(cfg_phyinst_power_on, cfg_phyinst_power_on_cmd, "osmotrx power (on|off)", OSMOTRX_STR "Change TRX state\n" @@ -356,70 +356,78 @@ return CMD_SUCCESS; } -DEFUN(cfg_phy_rxgain, cfg_phy_rxgain_cmd, +DEFUN(cfg_phyinst_rxgain, cfg_phyinst_rxgain_cmd, "osmotrx rx-gain <0-50>", OSMOTRX_STR "Set the receiver gain in dB\n" "Gain in dB\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.rxgain = atoi(argv[0]); - plink->u.osmotrx.rxgain_valid = 1; - plink->u.osmotrx.rxgain_sent = 0; + l1h->config.rxgain = atoi(argv[0]); + l1h->config.rxgain_valid = 1; + l1h->config.rxgain_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_tx_atten, cfg_phy_tx_atten_cmd, +DEFUN(cfg_phyinst_tx_atten, cfg_phyinst_tx_atten_cmd, "osmotrx tx-attenuation <0-50>", OSMOTRX_STR "Set the transmitter attenuation\n" "Fixed attenuation in dB, overriding OML\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power = atoi(argv[0]); - plink->u.osmotrx.power_oml = 0; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + l1h->config.power = atoi(argv[0]); + l1h->config.power_oml = 0; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_tx_atten_oml, cfg_phy_tx_atten_oml_cmd, +DEFUN(cfg_phyinst_tx_atten_oml, cfg_phyinst_tx_atten_oml_cmd, "osmotrx tx-attenuation oml", OSMOTRX_STR "Set the transmitter attenuation\n" "Use NM_ATT_RF_MAXPOWR_R (max power reduction) from BSC via OML\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power_oml = 1; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + l1h->config.power_oml = 1; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_no_rxgain, cfg_phy_no_rxgain_cmd, +DEFUN(cfg_phyinst_no_rxgain, cfg_phyinst_no_rxgain_cmd, "no osmotrx rx-gain", NO_STR OSMOTRX_STR "Unset the receiver gain in dB\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.rxgain_valid = 0; + l1h->config.rxgain_valid = 0; return CMD_SUCCESS; } -DEFUN(cfg_phy_no_tx_atten, cfg_phy_no_tx_atten_cmd, +DEFUN(cfg_phyinst_no_tx_atten, cfg_phyinst_no_tx_atten_cmd, "no osmotrx tx-attenuation", NO_STR OSMOTRX_STR "Unset the transmitter attenuation\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power_valid = 0; + l1h->config.power_valid = 0; return CMD_SUCCESS; } @@ -488,22 +496,22 @@ plink->u.osmotrx.clock_advance, VTY_NEWLINE); vty_out(vty, " osmotrx rts-advance %d%s", plink->u.osmotrx.rts_advance, VTY_NEWLINE); - if (plink->u.osmotrx.rxgain_valid) - vty_out(vty, " osmotrx rx-gain %d%s", - plink->u.osmotrx.rxgain, VTY_NEWLINE); - if (plink->u.osmotrx.power_valid) { - if (plink->u.osmotrx.power_oml) - vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); - else - vty_out(vty, " osmotrx tx-attenuation %d%s", - plink->u.osmotrx.power, VTY_NEWLINE); - } } void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { struct trx_l1h *l1h = pinst->u.osmotrx.hdl; + if (l1h->config.rxgain_valid) + vty_out(vty, " osmotrx rx-gain %d%s", + l1h->config.rxgain, VTY_NEWLINE); + if (l1h->config.power_valid) { + if (l1h->config.power_oml) + vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); + else + vty_out(vty, " osmotrx tx-attenuation %d%s", + l1h->config.power, VTY_NEWLINE); + } if (l1h->config.maxdly_valid) vty_out(vty, " maxdly %d%s", l1h->config.maxdly, VTY_NEWLINE); if (l1h->config.maxdlynb_valid) @@ -560,14 +568,14 @@ install_element(PHY_NODE, &cfg_phy_fn_advance_cmd); install_element(PHY_NODE, &cfg_phy_rts_advance_cmd); install_element(PHY_NODE, &cfg_phy_transc_ip_cmd); - install_element(PHY_NODE, &cfg_phy_rxgain_cmd); - install_element(PHY_NODE, &cfg_phy_tx_atten_cmd); - install_element(PHY_NODE, &cfg_phy_tx_atten_oml_cmd); - install_element(PHY_NODE, &cfg_phy_no_rxgain_cmd); - install_element(PHY_NODE, &cfg_phy_no_tx_atten_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_rxgain_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_oml_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_rxgain_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_tx_atten_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_slotmask_cmd); - install_element(PHY_INST_NODE, &cfg_phy_power_on_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_power_on_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_maxdly_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_no_maxdly_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_maxdlynb_cmd); -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 07:24:25 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 07:24:25 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Patch Set 2: (2 comments) https://gerrit.osmocom.org/#/c/1785/1/src/osmo-bts-trx/l1_if.h File src/osmo-bts-trx/l1_if.h: Line 23: int rxgain_valid; > Seems like _valid and _sent are only used as bool. If so then better use bo Yes, agree, but changing type of _valid and _sent variables to bool requires more changes in the code which are unrelated with this fix, so I think it is better to make separate patch for changing type of all _valid and _sent variables in the code. Does it make sense? Line 28: uint8_t power; > Why signed type? Can it have negative value in some case? If not, than bett Good point, fixed it. -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 10 07:27:51 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 07:27:51 +0000 Subject: [MERGED] osmo-bts[master]: all models: fix vty write: bts_model_config_write_phy In-Reply-To: References: Message-ID: Ivan Kluchnikov has submitted this change and it was merged. Change subject: all models: fix vty write: bts_model_config_write_phy ...................................................................... all models: fix vty write: bts_model_config_write_phy The vty write for phy/inst is broken, leading to a written-out config being unparsable; fix all of these: - in common/vty.c, actually call bts_model_config_write_phy_inst(). - in sysmo and lc15 write the phy instance elements in bts_model_config_write_phy_inst() and not in bts_model_config_write_phy(), which lead to writing the members above their parent 'instance'. - sysmo, lc15 and oct omit the bts_model_config_write_phy_inst() implementation. This did not cause a compilation problem because it was in fact never called. - sysmo writes 'clock-source None' when clk_src is zero, leading to unparsable config (related: OS#1944). Instead omit the 'clock-source' when zero. - osmo-bts-trx seems to be the only part that lacks nothing, yet it also didn't work properly because bts_model_config_write_phy_inst() was never called. This problem existed since commit d784e50747b8cf0ce505489e1451f75be5ccbd4b "Introduce new phy_link and phy_instance abstraction" Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 --- M src/common/vty.c M src/osmo-bts-litecell15/lc15bts_vty.c M src/osmo-bts-octphy/octphy_vty.c M src/osmo-bts-sysmo/sysmobts_vty.c 4 files changed, 19 insertions(+), 21 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/vty.c b/src/common/vty.c index b48afa4..646ac87 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -358,6 +358,7 @@ if (!pinst) break; vty_out(vty, " instance %u%s", pinst->num, VTY_NEWLINE); + bts_model_config_write_phy_inst(vty, pinst); } } diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c index 0ffe663..46f73ab 100644 --- a/src/osmo-bts-litecell15/lc15bts_vty.c +++ b/src/osmo-bts-litecell15/lc15bts_vty.c @@ -329,7 +329,11 @@ vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power,VTY_NEWLINE); } -static void write_phy_inst(struct vty *vty, struct phy_instance *pinst) +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { int i; @@ -344,14 +348,6 @@ if (pinst->u.lc15.calib_path) vty_out(vty, " trx-calibration-path %s%s", pinst->u.lc15.calib_path, VTY_NEWLINE); -} - -void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) -{ - struct phy_instance *pinst; - - llist_for_each_entry(pinst, &plink->instances, list) - write_phy_inst(vty, pinst); } int bts_model_vty_init(struct gsm_bts *bts) diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index c2d1fbb..abfac1e 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -219,6 +219,10 @@ VTY_NEWLINE); } +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) +{ +} + void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts) { } diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index e67d8be..330c9ce 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -443,7 +443,11 @@ VTY_NEWLINE); } -static void write_phy_inst(struct vty *vty, struct phy_instance *pinst) +void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) +{ +} + +void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { int i; @@ -464,17 +468,10 @@ if (pinst->u.sysmobts.calib_path) vty_out(vty, " trx-calibration-path %s%s", pinst->u.sysmobts.calib_path, VTY_NEWLINE); - vty_out(vty, " clock-source %s%s", - get_value_string(femtobts_clksrc_names, - pinst->u.sysmobts.clk_src), VTY_NEWLINE); -} - -void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink) -{ - struct phy_instance *pinst; - - llist_for_each_entry(pinst, &plink->instances, list) - write_phy_inst(vty, pinst); + if (pinst->u.sysmobts.clk_src) + vty_out(vty, " clock-source %s%s", + get_value_string(femtobts_clksrc_names, + pinst->u.sysmobts.clk_src), VTY_NEWLINE); } int bts_model_vty_init(struct gsm_bts *bts) -- To view, visit https://gerrit.osmocom.org/1761 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icc54fa70045c8fa58e78cf9f788c21a437edfbd4 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 10 07:29:59 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 07:29:59 +0000 Subject: [ABANDON] osmo-bts[master]: osmo-bts: Fix procedure of writing configuration for each ph... In-Reply-To: References: Message-ID: Ivan Kluchnikov has abandoned this change. Change subject: osmo-bts: Fix procedure of writing configuration for each phy instance ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1787 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I27a13ff1813688cb30062450d8457a5083ba2a34 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 10 09:14:46 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 10 Feb 2017 09:14:46 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Patch Set 2: > changing type of _valid and _sent variables to bool requires more changes in the code which are unrelated with this fix Could you elaborate on this - which code are you referring to? If it's indeed used as boolean only, than there should be no extra code changes necessary apart from variable initialization and even that is just to avoid warnings. -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 10:02:14 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 10:02:14 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Patch Set 2: > > changing type of _valid and _sent variables to bool requires more > changes in the code which are unrelated with this fix > > Could you elaborate on this - which code are you referring to? If > it's indeed used as boolean only, than there should be no extra > code changes necessary apart from variable initialization and even > that is just to avoid warnings. I mean that we should change type of all _valid, _sent variables in struct trx_config (not only for power and rxgain) and also all assignments (in l1_if.c and trx_vty.c files) to these variables should be change to true/false. I think it is good scope for separate patch. -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 10:58:29 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 10 Feb 2017 10:58:29 +0000 Subject: libosmocore[master]: cosmetic: replace fprintf with LOGP In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1782 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:18:31 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:18:31 +0000 Subject: libosmocore[master]: cosmetic: replace fprintf with LOGP In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1782 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:18:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:18:34 +0000 Subject: [MERGED] libosmocore[master]: cosmetic: replace fprintf with LOGP In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: cosmetic: replace fprintf with LOGP ...................................................................... cosmetic: replace fprintf with LOGP socket.c still uses fprintf to output error messages. This commit replaces the fprintf with proper LOGP messages. Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 --- M src/socket.c M tests/socket/socket_test.c 2 files changed, 28 insertions(+), 9 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/socket.c b/src/socket.c index 3c5548f..2c1b547 100644 --- a/src/socket.c +++ b/src/socket.c @@ -73,7 +73,7 @@ if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) == (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) { - fprintf(stderr, "invalid: both bind and connect flags set:" + LOGP(DLGLOBAL, LOGL_ERROR, "invalid: both bind and connect flags set:" " %s:%u\n", host, port); return -EINVAL; } @@ -97,7 +97,7 @@ rc = getaddrinfo(host, portbuf, &hints, &result); if (rc != 0) { - fprintf(stderr, "getaddrinfo returned NULL: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "getaddrinfo returned NULL: %s:%u: %s\n", host, port, strerror(errno)); return -EINVAL; } @@ -114,7 +114,7 @@ continue; if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot set this socket unblocking:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -131,7 +131,7 @@ rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (rc < 0) { - fprintf(stderr, + LOGP(DLGLOBAL, LOGL_ERROR, "cannot setsockopt socket:" " %s:%u: %s\n", host, port, strerror(errno)); @@ -145,7 +145,7 @@ freeaddrinfo(result); if (rp == NULL) { - fprintf(stderr, "unable to connect/bind socket: %s:%u: %s\n", + LOGP(DLGLOBAL, LOGL_ERROR, "unable to connect/bind socket: %s:%u: %s\n", host, port, strerror(errno)); return -ENODEV; } @@ -247,7 +247,8 @@ s = getnameinfo(ss, sa_len, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); if (s != 0) { - perror("getnameinfo failed"); + LOGP(DLGLOBAL, LOGL_ERROR, "getnameinfo failed:" + " %s\n", strerror(errno)); return s; } @@ -292,7 +293,8 @@ struct ifaddrs *ifaddr, *ifa; if (getifaddrs(&ifaddr) == -1) { - perror("getifaddrs"); + LOGP(DLGLOBAL, LOGL_ERROR, "getifaddrs:" + " %s\n", strerror(errno)); return -EIO; } @@ -359,7 +361,9 @@ if (flags & OSMO_SOCK_F_NONBLOCK) { if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { - perror("cannot set this socket unblocking"); + LOGP(DLGLOBAL, LOGL_ERROR, + "cannot set this socket unblocking: %s\n", + strerror(errno)); close(sfd); return -EINVAL; } diff --git a/tests/socket/socket_test.c b/tests/socket/socket_test.c index 75088e5..5b6abc4 100644 --- a/tests/socket/socket_test.c +++ b/tests/socket/socket_test.c @@ -28,8 +28,10 @@ #include #include +#include #include #include +#include #include "../config.h" @@ -71,8 +73,21 @@ return 0; } +const struct log_info_cat default_categories[] = { +}; + +static struct log_info info = { + .cat = default_categories, + .num_cat = ARRAY_SIZE(default_categories), +}; + int main(int argc, char *argv[]) { + osmo_init_logging(&info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + test_sockinit(); - return 0; + + return EXIT_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1782 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia2993415d5f5c33ccd719af239ff59252d11b764 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:18:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:18:48 +0000 Subject: osmo-bts[master]: cosmetic: lchan_sacch_get: early-exit instead of nested-if In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1779 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1fbf7d7f619cc8194c8094cf4a1826b6114f0e11 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:18:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:18:49 +0000 Subject: [MERGED] osmo-bts[master]: cosmetic: lchan_sacch_get: early-exit instead of nested-if In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: cosmetic: lchan_sacch_get: early-exit instead of nested-if ...................................................................... cosmetic: lchan_sacch_get: early-exit instead of nested-if Change-Id: I1fbf7d7f619cc8194c8094cf4a1826b6114f0e11 --- M src/common/sysinfo.c 1 file changed, 4 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index d0a476d..177ed58 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -151,10 +151,10 @@ uint32_t tmp; for (tmp = lchan->si.last + 1; tmp != lchan->si.last; tmp = (tmp + 1) % _MAX_SYSINFO_TYPE) { - if (lchan->si.valid & (1 << tmp)) { - lchan->si.last = tmp; - return lchan->si.buf[tmp]; - } + if (!(lchan->si.valid & (1 << tmp))) + continue; + lchan->si.last = tmp; + return lchan->si.buf[tmp]; } return NULL; } -- To view, visit https://gerrit.osmocom.org/1779 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1fbf7d7f619cc8194c8094cf4a1826b6114f0e11 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:19:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:19:38 +0000 Subject: osmo-pcu[master]: main, tests: use msgb_talloc_ctx_init() (new) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1773 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:20:00 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:20:00 +0000 Subject: osmo-pcu[master]: tests: edge, tbf: assert return values In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1772 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7f14198cfd747dae68b8aaa3b8d6ff7fc49ab824 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:21:06 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:21:06 +0000 Subject: osmo-pcu[master]: Fix dozens of compiler warnings across the board In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1771 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:21:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:21:17 +0000 Subject: [MERGED] osmo-pcu[master]: Fix dozens of compiler warnings across the board In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Fix dozens of compiler warnings across the board ...................................................................... Fix dozens of compiler warnings across the board Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d --- M src/pcu_vty.c M src/tbf.cpp M tests/alloc/AllocTest.cpp M tests/bitcomp/BitcompTest.cpp M tests/edge/EdgeTest.cpp M tests/llc/LlcTest.cpp M tests/tbf/TbfTest.cpp 7 files changed, 39 insertions(+), 81 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/pcu_vty.c b/src/pcu_vty.c index 535d512..3b5996c 100644 --- a/src/pcu_vty.c +++ b/src/pcu_vty.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/src/tbf.cpp b/src/tbf.cpp index 0d28c5c..820131c 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -171,13 +171,13 @@ bts(bts_), m_tfi(0), m_created_ts(0), + m_ctrs(NULL), m_ms(NULL), m_ta(GSM48_TA_INVALID), m_ms_class(0), m_list(this), m_ms_list(this), - m_egprs_enabled(false), - m_ctrs(NULL) + m_egprs_enabled(false) { /* The classes of these members do not have proper constructors yet. * Just set them to 0 like talloc_zero did */ @@ -854,9 +854,9 @@ gprs_rlcmac_dl_tbf::BandWidth::BandWidth() : dl_bw_octets(0), + dl_throughput(0), dl_loss_lost(0), - dl_loss_received(0), - dl_throughput(0) + dl_loss_received(0) { timerclear(&dl_bw_tv); timerclear(&dl_loss_tv); diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index f7794f7..308c802 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -170,7 +170,7 @@ { for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i) if (tbf->pdch[i]) - printf("PDCH[%d] is used for %s\n", i, dir); + printf("PDCH[%zu] is used for %s\n", i, dir); printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir); printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir); } diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp index fd3b0df..31b6d11 100644 --- a/tests/bitcomp/BitcompTest.cpp +++ b/tests/bitcomp/BitcompTest.cpp @@ -121,7 +121,7 @@ } /* To verify the result with expected result */ -int check_result(bitvec bits, uint8_t *exp_data, int exp_len) +int check_result(bitvec bits, uint8_t *exp_data, unsigned int exp_len) { if (bits.cur_bit != exp_len) return 0; @@ -147,7 +147,7 @@ { bitvec dest; int init_flag = 1; - int itr; + unsigned int itr; int rc; uint8_t bits_data[RLC_EGPRS_MAX_WS/8]; diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 3537aa7..86c08f5 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -40,6 +40,7 @@ #include #include +#include void *tall_pcu_ctx; int16_t spoof_mnc = 0, spoof_mcc = 0; @@ -1001,7 +1002,7 @@ OSMO_ASSERT(rdbi.e == 1); OSMO_ASSERT(rdbi.cv == 0); OSMO_ASSERT(write_offset == (int)rdbi.data_len); - OSMO_ASSERT(count_payload == rdbi.data_len); + OSMO_ASSERT(rdbi.data_len <= INT_MAX && count_payload == (int)rdbi.data_len); OSMO_ASSERT(num_chunks == 1); OSMO_ASSERT(data[0] == 0); @@ -1027,7 +1028,8 @@ OSMO_ASSERT(rdbi.e == 0); OSMO_ASSERT(rdbi.cv == 0); OSMO_ASSERT(write_offset == (int)rdbi.data_len); - OSMO_ASSERT(count_payload == rdbi.data_len - 1); + OSMO_ASSERT((rdbi.data_len - 1) <= INT_MAX + && count_payload == (int)(rdbi.data_len - 1)); OSMO_ASSERT(num_chunks == 1); OSMO_ASSERT(data[0] == (((rdbi.data_len-1) << 1) | (1 << 0))); @@ -1054,7 +1056,8 @@ OSMO_ASSERT(rdbi.e == 0); OSMO_ASSERT(rdbi.cv == 0); OSMO_ASSERT(write_offset == (int)rdbi.data_len); - OSMO_ASSERT(count_payload == rdbi.data_len - 2); + OSMO_ASSERT((rdbi.data_len - 2) <= INT_MAX + && count_payload == (int)(rdbi.data_len - 2)); OSMO_ASSERT(num_chunks == 2); OSMO_ASSERT(data[0] == (((rdbi.data_len-2) << 1) | (0 << 0))); @@ -1194,16 +1197,12 @@ uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, uint8_t ms_class) { - GprsMs *ms; struct pcu_l1_meas meas; int tfi = 0; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; uint8_t data[79] = {0}; struct gprs_rlc_ul_header_egprs_2 *egprs2 = NULL; egprs2 = (struct gprs_rlc_ul_header_egprs_2 *) data; - bts = the_bts->bts_data(); tfi = 1; @@ -1288,10 +1287,7 @@ uint32_t fn = 2654218; uint16_t qta = 31; uint32_t tlli = 0xf1223344; - const char *imsi = "0011223344"; uint8_t ms_class = 1; - gprs_rlcmac_ul_tbf *ul_tbf; - GprsMs *ms; printf("=== start %s ===\n", __func__); setup_bts(&the_bts, ts_no, 10); @@ -1305,18 +1301,14 @@ uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, uint8_t ms_class) { - uint8_t trx_no = 0; int tfi = 0; - struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; uint8_t data[155] = {0}; struct gprs_rlc_ul_header_egprs_1 *egprs1 = NULL; struct gprs_rlc_data_info rlc; GprsCodingScheme cs; - int rc, offs; + int rc; egprs1 = (struct gprs_rlc_ul_header_egprs_1 *) data; - bts = the_bts->bts_data(); tfi = 1; @@ -1409,10 +1401,7 @@ uint32_t fn = 2654218; uint16_t qta = 31; uint32_t tlli = 0xf1223344; - const char *imsi = "0011223344"; uint8_t ms_class = 1; - gprs_rlcmac_ul_tbf *ul_tbf; - GprsMs *ms; printf("=== start %s ===\n", __func__); setup_bts(&the_bts, ts_no, 12); diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp index e972cf4..8df010e 100644 --- a/tests/llc/LlcTest.cpp +++ b/tests/llc/LlcTest.cpp @@ -66,7 +66,7 @@ llc_msg = queue->dequeue(&info_res); OSMO_ASSERT(llc_msg != NULL); - fprintf(stderr, "dequeued msg, length %d (expected %d), data %s\n", + fprintf(stderr, "dequeued msg, length %u (expected %zu), data %s\n", msgb_length(llc_msg), len, msgb_hexdump(llc_msg)); OSMO_ASSERT(msgb_length(llc_msg) == len); @@ -239,7 +239,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index e367ce6..79e49ec 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -633,7 +633,7 @@ uint32_t rach_fn = *fn - 51; uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_pdch *pdch; gprs_rlcmac_bts *bts; @@ -701,7 +701,7 @@ /* send fake data */ uint8_t data_msg[42] = { 0xf << 2, /* GPRS_RLCMAC_DATA_BLOCK << 6, CV = 15 */ - tfi << 1, + (uint8_t)(tfi << 1), 1, /* BSN:7, E:1 */ }; @@ -1222,17 +1222,14 @@ uint8_t ts_no, uint32_t tlli, uint32_t *fn, uint16_t qta, uint8_t ms_class, uint8_t egprs_ms_class) { - GprsMs *ms; uint32_t rach_fn = *fn - 51; uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; - struct gprs_rlcmac_pdch *pdch; gprs_rlcmac_bts *bts; RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; meas.set_rssi(31); @@ -1298,15 +1295,10 @@ OSMO_ASSERT(ul_tbf); OSMO_ASSERT(ul_tbf->ta() == qta / 4); GprsMs *ms; - uint32_t rach_fn = *fn - 51; - uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; @@ -1386,15 +1378,10 @@ OSMO_ASSERT(ul_tbf); OSMO_ASSERT(ul_tbf->ta() == qta / 4); GprsMs *ms; - uint32_t rach_fn = *fn - 51; - uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; check_tbf(ul_tbf); @@ -1473,16 +1460,11 @@ uint8_t ms_class, uint8_t egprs_ms_class) { GprsMs *ms; - uint32_t rach_fn = *fn - 51; - uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_pdch *pdch; - gprs_rlcmac_bts *bts; - RlcMacUplink_t ulreq = {0}; struct pcu_l1_meas meas; - struct gprs_rlc_ul_header_egprs_3 *egprs3 = NULL; GprsCodingScheme cs; @@ -1918,7 +1900,7 @@ fprintf(stderr, "Got '%s', TA=%d\n", ul_tbf->name(), ul_tbf->ta()); send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"RAU_ACCEPT", 10); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); /* Send Packet Downlink Assignment to MS */ @@ -1941,7 +1923,7 @@ /* The PCU cannot know yet, that both TBF belong to the same MS */ OSMO_ASSERT(ms1 != ms2); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); /* Send some downlink data along with the new TLLI and the IMSI so that @@ -1951,7 +1933,7 @@ ms = the_bts.ms_by_imsi(imsi); OSMO_ASSERT(ms == ms2); - fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size()); ms = the_bts.ms_by_tlli(tlli1); @@ -1987,7 +1969,7 @@ send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20); send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); OSMO_ASSERT(ms1->llc_queue()->size() == 2); @@ -2004,7 +1986,7 @@ ms_class, 0); ms2 = ul_tbf->ms(); - fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size()); /* This should be the same MS object */ @@ -2048,7 +2030,7 @@ send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 1 *************", 20); send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)"DATA 2 *************", 20); - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); OSMO_ASSERT(ms1->llc_queue()->size() == 2); @@ -2064,7 +2046,7 @@ ul_tbf = establish_ul_tbf_single_phase(&the_bts, ts_no, tlli1, &fn, qta); ms2 = ul_tbf->ms(); - fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "New MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms2->tlli(), ms2->ta(), ms2->imsi(), ms2->llc_queue()->size()); /* There should be a different MS object */ @@ -2119,7 +2101,7 @@ send_dl_data(&the_bts, tlli1, imsi, (const uint8_t *)buf, rc); } - fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %d\n", + fprintf(stderr, "Old MS: TLLI = 0x%08x, TA = %d, IMSI = %s, LLC = %zu\n", ms1->tlli(), ms1->ta(), ms1->imsi(), ms1->llc_queue()->size()); /* Send Packet Downlink Assignment to MS */ @@ -2370,7 +2352,7 @@ uint32_t rach_fn = *fn - 51; uint32_t sba_fn = *fn + 52; uint8_t trx_no = 0; - int tfi = 0, i = 0; + int tfi = 0; gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_pdch *pdch; gprs_rlcmac_bts *bts; @@ -2742,12 +2724,9 @@ unsigned i; uint8_t ms_class = 11; uint8_t egprs_ms_class = 11; - uint32_t fn = 0; uint8_t trx_no; uint32_t tlli = 0xffeeddcc; uint8_t test_data[512]; - - uint8_t rbb[64/8]; gprs_rlcmac_dl_tbf *dl_tbf; @@ -2777,7 +2756,6 @@ static void tbf_cleanup(gprs_rlcmac_dl_tbf *dl_tbf) { - uint32_t fn = 0; uint8_t rbb[64/8]; /* Receive a final ACK */ @@ -2792,19 +2770,16 @@ } static void egprs_spb_to_normal_validation(BTS *the_bts, - int mcs, int demanded_mcs) + unsigned int mcs, unsigned int demanded_mcs) { uint32_t fn = 0; gprs_rlcmac_dl_tbf *dl_tbf; - uint8_t block_nr = 0; - int index1 = 0; - uint8_t bn; uint16_t bsn1, bsn2, bsn3; struct msgb *msg; struct gprs_rlc_dl_header_egprs_3 *egprs3; struct gprs_rlc_dl_header_egprs_2 *egprs2; - printf("Testing retx for MCS %d to reseg_mcs %d\n", mcs, demanded_mcs); + printf("Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs); dl_tbf = tbf_init(the_bts, mcs); @@ -2886,18 +2861,16 @@ tbf_cleanup(dl_tbf); } + static void establish_and_use_egprs_dl_tbf_for_spb(BTS *the_bts, - int mcs, int demanded_mcs) + unsigned int mcs, unsigned int demanded_mcs) { uint32_t fn = 0; gprs_rlcmac_dl_tbf *dl_tbf; - uint8_t block_nr = 0; - int index1 = 0; - uint8_t bn; struct msgb *msg; struct gprs_rlc_dl_header_egprs_3 *egprs3; - printf("Testing retx for MCS %d to reseg_mcs %d\n", mcs, demanded_mcs); + printf("Testing retx for MCS %u to reseg_mcs %u\n", mcs, demanded_mcs); dl_tbf = tbf_init(the_bts, mcs); @@ -2989,16 +2962,13 @@ } static void establish_and_use_egprs_dl_tbf_for_retx(BTS *the_bts, - int mcs, int demanded_mcs) + unsigned int mcs, unsigned int demanded_mcs) { uint32_t fn = 0; gprs_rlcmac_dl_tbf *dl_tbf; - uint8_t block_nr = 0; - int index1 = 0; - uint8_t bn; struct msgb *msg; - printf("Testing retx for MCS %d - %d\n", mcs, demanded_mcs); + printf("Testing retx for MCS %u - %u\n", mcs, demanded_mcs); dl_tbf = tbf_init(the_bts, mcs); @@ -3137,7 +3107,6 @@ BTS the_bts; gprs_rlcmac_bts *bts; uint8_t ts_no = 4; - int i, j; printf("=== start %s ===\n", __func__); @@ -3167,7 +3136,6 @@ BTS the_bts; gprs_rlcmac_bts *bts; uint8_t ts_no = 4; - int i, j; printf("=== start %s ===\n", __func__); -- To view, visit https://gerrit.osmocom.org/1771 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:21:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:21:18 +0000 Subject: [MERGED] osmo-pcu[master]: tests: edge, tbf: assert return values In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: tests: edge, tbf: assert return values ...................................................................... tests: edge, tbf: assert return values Numerous calls assign a return value without asserting its value. Add assertions and thus also eliminate compiler warnings about unused values. Change-Id: I7f14198cfd747dae68b8aaa3b8d6ff7fc49ab824 --- M tests/edge/EdgeTest.cpp M tests/tbf/TbfTest.cpp 2 files changed, 16 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 86c08f5..16a39e9 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -1226,6 +1226,7 @@ egprs2->pi = 0; data[4] = 0x20; /* Setting E field */ rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 487); offs = rlc.data_offs_bits[0] / 8; OSMO_ASSERT(offs == 4); OSMO_ASSERT(rlc.tfi == 1); @@ -1250,6 +1251,7 @@ egprs2->pi = 0; data[10] = 0x20; /* Setting E field */ rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 679); offs = rlc.data_offs_bits[0] / 8; OSMO_ASSERT(offs == 10); OSMO_ASSERT(rlc.num_data_blocks == 1); @@ -1271,6 +1273,7 @@ egprs2->pi = 0; data[10] = 0x20; /* Setting E field */ rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 679); offs = rlc.data_offs_bits[0] / 8; OSMO_ASSERT(offs == 10); OSMO_ASSERT(rlc.tfi == 1); @@ -1330,6 +1333,7 @@ data[5] = 0xc0; data[5 + 57] = 1; rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 946); OSMO_ASSERT(rlc.num_data_blocks == 2); OSMO_ASSERT(rlc.block_info[0].e == 1); OSMO_ASSERT(rlc.block_info[0].ti == 1); @@ -1357,6 +1361,7 @@ data[5] = 0xc0; data[5 + 69] = 1; rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 1138); OSMO_ASSERT(rlc.num_data_blocks == 2); OSMO_ASSERT(rlc.block_info[0].e == 1); OSMO_ASSERT(rlc.block_info[0].ti == 1); @@ -1384,6 +1389,7 @@ data[5] = 0xc0; data[5 + 75] = 1; rc = Decoding::rlc_parse_ul_data_header(&rlc, data, cs); + OSMO_ASSERT(rc == 1234); OSMO_ASSERT(rlc.num_data_blocks == 2); OSMO_ASSERT(rlc.block_info[0].e == 1); OSMO_ASSERT(rlc.block_info[0].ti == 1); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 79e49ec..7d786b4 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -2985,7 +2985,7 @@ fn = fn_add_blocks(fn, 1); /* Send 2 RLC data block */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); - + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3006,6 +3006,7 @@ fn = fn_add_blocks(fn, 1); /* Retransmit the first RLC data block with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_nacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3014,6 +3015,7 @@ fn = fn_add_blocks(fn, 1); /* Retransmit the second RLC data block with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(1)->cs_current_trans.to_num() @@ -3023,6 +3025,7 @@ fn = fn_add_blocks(fn, 1); /* Send first RLC data block BSN 0 */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() == mcs); @@ -3030,6 +3033,7 @@ fn = fn_add_blocks(fn, 1); /* Send second RLC data block BSN 1 */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(1)->cs_current_trans.to_num() == mcs); @@ -3046,6 +3050,7 @@ fn = fn_add_blocks(fn, 1); /* Send first, second RLC data blocks with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3057,6 +3062,7 @@ fn = fn_add_blocks(fn, 1); /* Send first,second RLC data blocks */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3072,6 +3078,7 @@ fn = fn_add_blocks(fn, 1); /* Send first,second RLC data blocks with demanded_mcs*/ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(1)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() @@ -3084,6 +3091,7 @@ fn = fn_add_blocks(fn, 1); /* Send first RLC data block */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() == mcs); @@ -3094,6 +3102,7 @@ fn = fn_add_blocks(fn, 1); /* Send first RLC data block with demanded_mcs */ msg = dl_tbf->create_dl_acked_block(fn, dl_tbf->control_ts); + OSMO_ASSERT(msg); OSMO_ASSERT(dl_tbf->m_window.m_v_b.is_unacked(0)); OSMO_ASSERT(dl_tbf->m_rlc.block(0)->cs_current_trans.to_num() == mcs); -- To view, visit https://gerrit.osmocom.org/1772 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7f14198cfd747dae68b8aaa3b8d6ff7fc49ab824 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:21:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:21:21 +0000 Subject: [MERGED] osmo-pcu[master]: main, tests: use msgb_talloc_ctx_init() (new) In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: main, tests: use msgb_talloc_ctx_init() (new) ...................................................................... main, tests: use msgb_talloc_ctx_init() (new) msgb_set_talloc_ctx() is deprecated since libosmocore commit f45334be29016a36594aacc07c90e262e4994525 / change-id I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08 --- M src/pcu_main.cpp M tests/alloc/AllocTest.cpp M tests/edge/EdgeTest.cpp M tests/emu/pcu_emu.cpp M tests/ms/MsTest.cpp M tests/tbf/TbfTest.cpp 6 files changed, 6 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 0a0362b..338096b 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -217,7 +217,7 @@ */ bts->dl_arq_type = EGPRS_ARQ1; - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&gprs_log_info); osmo_stats_init(tall_pcu_ctx); diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index 308c802..e26c432 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -848,7 +848,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 16a39e9..73aed37 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -1424,7 +1424,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp index 3725c8d..957ddf6 100644 --- a/tests/emu/pcu_emu.cpp +++ b/tests/emu/pcu_emu.cpp @@ -110,7 +110,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&gprs_log_info); vty_init(&pcu_vty_info); pcu_vty_init(&gprs_log_info); diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp index 0930354..d66f578 100644 --- a/tests/ms/MsTest.cpp +++ b/tests/ms/MsTest.cpp @@ -538,7 +538,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 7d786b4..00aa4a8 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -3361,7 +3361,7 @@ if (!tall_pcu_ctx) abort(); - msgb_set_talloc_ctx(tall_pcu_ctx); + msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_init_logging(&debug_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); -- To view, visit https://gerrit.osmocom.org/1773 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:23:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:23:21 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:23:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:23:37 +0000 Subject: osmo-bts[master]: rsl: Output RTP stats before closing the socket. In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1784 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ife9f27c43157b4a1bf71aba41cd7b0f5f41ac99f Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:23:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:23:38 +0000 Subject: [MERGED] osmo-bts[master]: rsl: Output RTP stats before closing the socket. In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: rsl: Output RTP stats before closing the socket. ...................................................................... rsl: Output RTP stats before closing the socket. It's useful to know RTP statistics (number of packets lost, jitter, etc) when looking at voice call quality issues. Right now this information is not avialable anywhere and this looks like the best place to start. Change-Id: Ife9f27c43157b4a1bf71aba41cd7b0f5f41ac99f --- M src/common/rsl.c 1 file changed, 4 insertions(+), 0 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/rsl.c b/src/common/rsl.c index 2f6c0c6..1d0bcea 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -1026,6 +1026,8 @@ if (lchan->abis_ip.rtp_socket) { rsl_tx_ipac_dlcx_ind(lchan, RSL_ERR_NORMAL_UNSPEC); + osmo_rtp_socket_log_stats(lchan->abis_ip.rtp_socket, DRSL, LOGL_INFO, + "Closing RTP socket on Channel Release "); osmo_rtp_socket_free(lchan->abis_ip.rtp_socket); lchan->abis_ip.rtp_socket = NULL; msgb_queue_flush(&lchan->dl_tch_queue); @@ -1789,6 +1791,8 @@ inc_conn_id = 1; rc = rsl_tx_ipac_dlcx_ack(lchan, inc_conn_id); + osmo_rtp_socket_log_stats(lchan->abis_ip.rtp_socket, DRSL, LOGL_INFO, + "Closing RTP socket on DLCX "); osmo_rtp_socket_free(lchan->abis_ip.rtp_socket); lchan->abis_ip.rtp_socket = NULL; msgb_queue_flush(&lchan->dl_tch_queue); -- To view, visit https://gerrit.osmocom.org/1784 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ife9f27c43157b4a1bf71aba41cd7b0f5f41ac99f Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:24:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:24:20 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:24:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:24:34 +0000 Subject: openbsc[master]: Remove duplicating define In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1791 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:25:23 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:25:23 +0000 Subject: openbsc[master]: Expand chan allocation logging In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1790 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:25:29 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:25:29 +0000 Subject: [MERGED] openbsc[master]: Expand chan allocation logging In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Expand chan allocation logging ...................................................................... Expand chan allocation logging Log more data related to channel allocation: - channel type - number of paging attempts - timers fired Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48 --- M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/bsc_api.c M openbsc/src/libbsc/paging.c M openbsc/src/libmsc/gsm_04_08.c 4 files changed, 14 insertions(+), 8 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 8a6b111..cc190eb 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1659,7 +1659,9 @@ static void t3101_expired(void *data) { struct gsm_lchan *lchan = data; - + LOGP(DRSL, LOGL_NOTICE, + "%s T3101 expired: no response to IMMEDIATE ASSIGN\n", + gsm_lchan_name(lchan)); rsl_rf_chan_release(lchan, 1, SACCH_DEACTIVATE); } @@ -1667,7 +1669,9 @@ static void t3111_expired(void *data) { struct gsm_lchan *lchan = data; - + LOGP(DRSL, LOGL_NOTICE, + "%s T3111 expired: releasing RF Channel\n", + gsm_lchan_name(lchan)); rsl_rf_chan_release(lchan, 0, SACCH_NONE); } diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 8a4c85f..7a48296 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -397,7 +397,8 @@ handle_mr_config(conn, conn->lchan, full_rate); LOGP(DMSC, LOGL_NOTICE, - "Sending ChanModify for speech: %s on channel %s\n", + "Sending %s ChanModify for speech: %s on channel %s\n", + gsm_lchan_name(conn->lchan), get_value_string(gsm48_chan_mode_names, chan_mode), get_value_string(gsm_chan_t_names, conn->lchan->type)); gsm48_lchan_modify(conn->lchan, chan_mode); diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index fcb4deb..8c30637 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -79,8 +79,9 @@ log_set_context(BSC_CTX_SUBSCR, request->subscr); - LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: '%s' tmsi: '0x%x'\n", - request->subscr->imsi, request->subscr->tmsi); + LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " + "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, + request->subscr->tmsi, request->chan_type, request->attempts); if (request->subscr->tmsi == GSM_RESERVED_TMSI) mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi); @@ -376,11 +377,11 @@ req = NULL; if (conn && cbfn) { - LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d, calling cbfn.\n", bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", subscr->imsi, bts->nr); cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED, msg, conn, param); } else - LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d silently.\n", bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", subscr->imsi, bts->nr); break; } } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index e5402d0..1a64731 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1483,7 +1483,7 @@ apdu_len = gh->data[1]; apdu_data = gh->data+2; - DEBUGP(DRR, "RX APPLICATION INFO id/flags=0x%02x apdu_len=%u apdu=%s", + DEBUGP(DRR, "RX APPLICATION INFO id/flags=0x%02x apdu_len=%u apdu=%s\n", apdu_id_flags, apdu_len, osmo_hexdump(apdu_data, apdu_len)); return db_apdu_blob_store(conn->subscr, apdu_id_flags, apdu_len, apdu_data); -- To view, visit https://gerrit.osmocom.org/1790 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:25:30 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:25:30 +0000 Subject: [MERGED] openbsc[master]: Remove duplicating define In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Remove duplicating define ...................................................................... Remove duplicating define Use GSM_MACBLOCK_LEN consistently throughout abis_rsl.c Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5 --- M openbsc/src/libbsc/abis_rsl.c 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index cc190eb..541a86d 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -181,13 +181,12 @@ "RSL"); } -#define MACBLOCK_SIZE 23 static void pad_macblock(uint8_t *out, const uint8_t *in, int len) { memcpy(out, in, len); - if (len < MACBLOCK_SIZE) - memset(out+len, 0x2b, MACBLOCK_SIZE-len); + if (len < GSM_MACBLOCK_LEN) + memset(out+len, 0x2b, GSM_MACBLOCK_LEN - len); } /* Chapter 9.3.7: Encryption Information */ @@ -1042,7 +1041,7 @@ { struct msgb *msg = rsl_msgb_alloc(); struct abis_rsl_dchan_hdr *dh; - uint8_t buf[MACBLOCK_SIZE]; + uint8_t buf[GSM_MACBLOCK_LEN]; dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh)); init_dchan_hdr(dh, RSL_MT_IMMEDIATE_ASSIGN_CMD); @@ -1055,7 +1054,8 @@ default: /* If phase 2, construct a FULL_IMM_ASS_INFO */ pad_macblock(buf, val, len); - msgb_tlv_put(msg, RSL_IE_FULL_IMM_ASS_INFO, MACBLOCK_SIZE, buf); + msgb_tlv_put(msg, RSL_IE_FULL_IMM_ASS_INFO, GSM_MACBLOCK_LEN, + buf); break; } -- To view, visit https://gerrit.osmocom.org/1791 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:26:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:26:28 +0000 Subject: osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/1783/1/src/common/oml.c File src/common/oml.c: Line 51: }, there's no need for this ".def" member with no content, is there? -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:27:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:27:53 +0000 Subject: openbsc[master]: tests: fix leaks by talloc ctx In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 12:30:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 10 Feb 2017 12:30:04 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 8: (1 comment) https://gerrit.osmocom.org/#/c/1198/8/src/input/unixsocket.c File src/input/unixsocket.c: Line 43: #define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/rsl_oml" the default should have a more reasonable name than "rsl_oml" maybe rather something like "/tmp/osmo_abis" (or even be in the abstract namespace?). Also, if you include the line number like "/tmp/osmo_abis_line%u", then we can have multiple lines without interfering each other? -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 8 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:09:06 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 10 Feb 2017 13:09:06 +0000 Subject: [PATCH] libosmocore[master]: utils/conv_gen.py: use optarg instead of argparse for sysmoB... Message-ID: Review at https://gerrit.osmocom.org/1792 utils/conv_gen.py: use optarg instead of argparse for sysmoBTS SDK The poky based sysmoBTS SDK has no argparse in its python, but it does provide optarg. With slight bloat due to optarg avoid adding a dependency to the SDK. Change-Id: Ic301ee3674c8a86add43d1b1410263f8bc8bea07 --- M utils/conv_gen.py 1 file changed, 65 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/1792/1 diff --git a/utils/conv_gen.py b/utils/conv_gen.py index e6eb50c..1a8c1be 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -23,7 +23,7 @@ */ """ -import sys, os, math, argparse +import sys, os, math, getopt from functools import reduce import conv_codes_gsm @@ -281,26 +281,74 @@ code.gen_tables(prefix, f, shared_tables = shared) +# (Using getopt instead of argparse because the sysmoBTS SDK has no argparse) +def usage(): + print '''usage: x.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P TARGET_PATH] + {gen_codes} {gsm} + +positional arguments: + {gen_codes} what to generate + {gsm} convolutional code family + +optional arguments: + -h, --help show this help message and exit + -p PREFIX, --prefix PREFIX + internal naming prefix + -n TARGET_NAME, --target-name TARGET_NAME + target name for generated file + -P TARGET_PATH, --target-path TARGET_PATH + target path for generated file +usage: x.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P TARGET_PATH] + {gen_codes} {gsm}''' + +class CmdlineOpts: + action = None + family = None + prefix = None + target_name = None + target_path = None + def parse_argv(): - parser = argparse.ArgumentParser() + try: + opts, args = getopt.getopt(sys.argv[1:], "hp:n:P:", + ["help", "prefix=", "target-name=", "target-path="]) + except getopt.GetoptError as err: + print str(err) + usage() + sys.exit(2) - # Positional arguments - parser.add_argument("action", - help = "what to generate", - choices = ["gen_codes"]) - parser.add_argument("family", - help = "convolutional code family", - choices = ["gsm"]) + argv = CmdlineOpts() + for o, a in opts: + if o in ("-h", "--help"): + usage() + sys.exit() + elif o in ("-p", "--prefix"): + argv.prefix = a + elif o in ("-n", "--target-name"): + argv.target_name = a + elif o in ("-P", "--target-path"): + argv.target_path = a + else: + assert False, "unknown option: %r" % o - # Optional arguments - parser.add_argument("-p", "--prefix", - help = "internal naming prefix") - parser.add_argument("-n", "--target-name", - help = "target name for generated file") - parser.add_argument("-P", "--target-path", - help = "target path for generated file") + try: + argv.action, argv.family = args + except: + usage() + assert False, "need two arguments gen_codes and gsm, got %d" % len(args) - return parser.parse_args() + action_choices = ('gen_codes', ) + if argv.action not in action_choices: + usage() + assert False, ("argument 'action': invalid choice: %r (choose from %s)" + % (argv.action, ', '.join(action_choices))) + + family_choices = ('gsm', ) + if argv.family not in family_choices: + usage() + assert False, ("argument 'family': invalid choice: %r (choose from %s)" + % (argv.family, ', '.join(family_choices))) + return argv if __name__ == '__main__': # Parse and verify arguments -- To view, visit https://gerrit.osmocom.org/1792 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic301ee3674c8a86add43d1b1410263f8bc8bea07 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:10:37 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 10 Feb 2017 13:10:37 +0000 Subject: [PATCH] libosmocore[master]: utils/conv_gen.py: use getopt instead of argparse for sysmoB... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1792 to look at the new patch set (#2). utils/conv_gen.py: use getopt instead of argparse for sysmoBTS SDK The poky based sysmoBTS SDK has no argparse in its python, but it does provide getopt. With slight bloat due to getopt avoid adding a dependency to the SDK. Change-Id: Ic301ee3674c8a86add43d1b1410263f8bc8bea07 --- M utils/conv_gen.py 1 file changed, 65 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/1792/2 diff --git a/utils/conv_gen.py b/utils/conv_gen.py index e6eb50c..1a8c1be 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -23,7 +23,7 @@ */ """ -import sys, os, math, argparse +import sys, os, math, getopt from functools import reduce import conv_codes_gsm @@ -281,26 +281,74 @@ code.gen_tables(prefix, f, shared_tables = shared) +# (Using getopt instead of argparse because the sysmoBTS SDK has no argparse) +def usage(): + print '''usage: x.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P TARGET_PATH] + {gen_codes} {gsm} + +positional arguments: + {gen_codes} what to generate + {gsm} convolutional code family + +optional arguments: + -h, --help show this help message and exit + -p PREFIX, --prefix PREFIX + internal naming prefix + -n TARGET_NAME, --target-name TARGET_NAME + target name for generated file + -P TARGET_PATH, --target-path TARGET_PATH + target path for generated file +usage: x.py [-h] [-p PREFIX] [-n TARGET_NAME] [-P TARGET_PATH] + {gen_codes} {gsm}''' + +class CmdlineOpts: + action = None + family = None + prefix = None + target_name = None + target_path = None + def parse_argv(): - parser = argparse.ArgumentParser() + try: + opts, args = getopt.getopt(sys.argv[1:], "hp:n:P:", + ["help", "prefix=", "target-name=", "target-path="]) + except getopt.GetoptError as err: + print str(err) + usage() + sys.exit(2) - # Positional arguments - parser.add_argument("action", - help = "what to generate", - choices = ["gen_codes"]) - parser.add_argument("family", - help = "convolutional code family", - choices = ["gsm"]) + argv = CmdlineOpts() + for o, a in opts: + if o in ("-h", "--help"): + usage() + sys.exit() + elif o in ("-p", "--prefix"): + argv.prefix = a + elif o in ("-n", "--target-name"): + argv.target_name = a + elif o in ("-P", "--target-path"): + argv.target_path = a + else: + assert False, "unknown option: %r" % o - # Optional arguments - parser.add_argument("-p", "--prefix", - help = "internal naming prefix") - parser.add_argument("-n", "--target-name", - help = "target name for generated file") - parser.add_argument("-P", "--target-path", - help = "target path for generated file") + try: + argv.action, argv.family = args + except: + usage() + assert False, "need two arguments gen_codes and gsm, got %d" % len(args) - return parser.parse_args() + action_choices = ('gen_codes', ) + if argv.action not in action_choices: + usage() + assert False, ("argument 'action': invalid choice: %r (choose from %s)" + % (argv.action, ', '.join(action_choices))) + + family_choices = ('gsm', ) + if argv.family not in family_choices: + usage() + assert False, ("argument 'family': invalid choice: %r (choose from %s)" + % (argv.family, ', '.join(family_choices))) + return argv if __name__ == '__main__': # Parse and verify arguments -- To view, visit https://gerrit.osmocom.org/1792 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic301ee3674c8a86add43d1b1410263f8bc8bea07 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:12:26 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 10 Feb 2017 13:12:26 +0000 Subject: [ABANDON] libosmocore[master]: utils/conv_gen.py: use getopt instead of argparse for sysmoB... In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: utils/conv_gen.py: use getopt instead of argparse for sysmoBTS SDK ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1792 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ic301ee3674c8a86add43d1b1410263f8bc8bea07 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:17:19 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 13:17:19 +0000 Subject: [PATCH] osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1783 to look at the new patch set (#2). oml: Fix incorrect usage of const variable abis_nm_att_tlvdef_ipa This bug was introduced during moving oml definitions from osmo-bts to libosmocore, when type of abis_nm_att_tlvdef_ipa was changed from struct tlv_definition to const struct tlv_definition. The following solution is proposed: * create static abis_nm_att_tlvdef_ipa_local variable for oml attribute definitions * copy abis_nm_att_tlvdef_ipa to abis_nm_att_tlvdef_ipa_local * merge abis_nm_att_tlvdef with abis_nm_att_tlvdef_ipa_local * use abis_nm_att_tlvdef_ipa_local in oml_tlv_parse function Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c --- M src/common/oml.c 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/83/1783/2 diff --git a/src/common/oml.c b/src/common/oml.c index 272123e..7069377 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -46,13 +46,15 @@ static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg); +static struct tlv_definition abis_nm_att_tlvdef_ipa_local = {}; + /* * support */ static int oml_tlv_parse(struct tlv_parsed *tp, const uint8_t *buf, int len) { - return tlv_parse(tp, &abis_nm_att_tlvdef_ipa, buf, len, 0, 0); + return tlv_parse(tp, &abis_nm_att_tlvdef_ipa_local, buf, len, 0, 0); } struct msgb *oml_msgb_alloc(void) @@ -1247,7 +1249,8 @@ int oml_init(struct gsm_abis_mo *mo) { DEBUGP(DOML, "Initializing OML attribute definitions\n"); - tlv_def_patch(&abis_nm_att_tlvdef_ipa, &abis_nm_att_tlvdef); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef_ipa); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef); osmo_signal_register_handler(SS_FAIL, handle_fail_sig, mo); return 0; -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:17:36 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 13:17:36 +0000 Subject: osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) https://gerrit.osmocom.org/#/c/1783/1/src/common/oml.c File src/common/oml.c: Line 51: /* > there's no need for this ".def" member with no content, is there? yep, fixed -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:35:58 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 13:35:58 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Patch Set 3: Verified+1 -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:36:06 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 13:36:06 +0000 Subject: [MERGED] osmo-bts[master]: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER para... In-Reply-To: References: Message-ID: Ivan Kluchnikov has submitted this change and it was merged. Change subject: osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER parameters on second channel (TRX1) of osmo-trx ...................................................................... osmo-trx-bts: Fix incorrect setting of RXGAIN and POWER parameters on second channel (TRX1) of osmo-trx Move rxgain and tx-attenuation (power) parameters from phy_link layer to phy_inst layer. Rxgain and tx-attenuation parameters should be set for each phy_inst and send for each osmo-trx channel accordingly via control commands. Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f --- M include/osmo-bts/phy_link.h M src/osmo-bts-trx/l1_if.c M src/osmo-bts-trx/l1_if.h M src/osmo-bts-trx/main.c M src/osmo-bts-trx/trx_vty.c 5 files changed, 83 insertions(+), 83 deletions(-) Approvals: Ivan Kluchnikov: Verified Harald Welte: Looks good to me, approved diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index a7963d0..e644a91 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -44,15 +44,6 @@ uint32_t clock_advance; uint32_t rts_advance; - - int rxgain_valid; - int rxgain; - int rxgain_sent; - - int power_valid; - int power; - int power_oml; - int power_sent; } osmotrx; struct { /* MAC address of the PHY */ diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index a42d39a..8c5115b 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -203,17 +203,13 @@ } /* after power on */ - if (l1h->phy_inst->num == 0) { - if (plink->u.osmotrx.rxgain_valid && - !plink->u.osmotrx.rxgain_sent) { - trx_if_cmd_setrxgain(l1h, plink->u.osmotrx.rxgain); - plink->u.osmotrx.rxgain_sent = 1; - } - if (plink->u.osmotrx.power_valid && - !plink->u.osmotrx.power_sent) { - trx_if_cmd_setpower(l1h, plink->u.osmotrx.power); - plink->u.osmotrx.power_sent = 1; - } + if (l1h->config.rxgain_valid && !l1h->config.rxgain_sent) { + trx_if_cmd_setrxgain(l1h, l1h->config.rxgain); + l1h->config.rxgain_sent = 1; + } + if (l1h->config.power_valid && !l1h->config.power_sent) { + trx_if_cmd_setpower(l1h, l1h->config.power); + l1h->config.power_sent = 1; } if (l1h->config.maxdly_valid && !l1h->config.maxdly_sent) { trx_if_cmd_setmaxdly(l1h, l1h->config.maxdly); @@ -238,10 +234,8 @@ if (!l1h->config.poweron && !l1h->config.poweron_sent) { trx_if_cmd_poweroff(l1h); l1h->config.poweron_sent = 1; - if (l1h->phy_inst->num == 0) { - plink->u.osmotrx.rxgain_sent = 0; - plink->u.osmotrx.power_sent = 0; - } + l1h->config.rxgain_sent = 0; + l1h->config.power_sent = 0; l1h->config.maxdly_sent = 0; l1h->config.maxdlynb_sent = 0; for (tn = 0; tn < TRX_NR_TS; tn++) @@ -264,11 +258,10 @@ l1h->config.tsc_sent = 0; l1h->config.bsic_sent = 0; l1h->config.poweron_sent = 0; - if (l1h->phy_inst->num == 0) { - plink->u.osmotrx.rxgain_sent = 0; - plink->u.osmotrx.power_sent = 0; - } + l1h->config.rxgain_sent = 0; + l1h->config.power_sent = 0; l1h->config.maxdly_sent = 0; + l1h->config.maxdlynb_sent = 0; for (tn = 0; tn < TRX_NR_TS; tn++) l1h->config.slottype_sent[tn] = 0; l1if_provision_transceiver_trx(l1h); @@ -390,10 +383,10 @@ l1if_provision_transceiver_trx(l1h); } - if (plink->u.osmotrx.power_oml && pinst->num == 0) { - plink->u.osmotrx.power = trx->max_power_red; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + if (l1h->config.power_oml) { + l1h->config.power = trx->max_power_red; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; l1if_provision_transceiver_trx(l1h); } diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index f0b2e67..1864857 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -20,6 +20,15 @@ uint8_t bsic; int bsic_sent; + int rxgain_valid; + uint8_t rxgain; + int rxgain_sent; + + int power_valid; + uint8_t power; + int power_oml; + int power_sent; + int maxdly_valid; int maxdly; int maxdly_sent; diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index 62e8fe9..dbd8fc4 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -117,7 +117,6 @@ plink->u.osmotrx.base_port_remote = 5700; plink->u.osmotrx.clock_advance = 20; plink->u.osmotrx.rts_advance = 5; - plink->u.osmotrx.power_oml = 1; } void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index ca347e8..3822b0f 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -100,6 +100,17 @@ vty_out(vty, "PHY Instance %s%s", phy_instance_name(pinst), VTY_NEWLINE); + + if (l1h->config.rxgain_valid) + vty_out(vty, " rx-gain : %d dB%s", + l1h->config.rxgain, VTY_NEWLINE); + else + vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); + if (l1h->config.power_valid) + vty_out(vty, " tx-attenuation : %d dB%s", + l1h->config.power, VTY_NEWLINE); + else + vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); if (l1h->config.maxdly_valid) vty_out(vty, " maxdly : %d%s", l1h->config.maxdly, VTY_NEWLINE); @@ -129,17 +140,6 @@ struct phy_instance *pinst; vty_out(vty, "PHY %u%s", plink->num, VTY_NEWLINE); - - if (plink->u.osmotrx.rxgain_valid) - vty_out(vty, " rx-gain : %d dB%s", - plink->u.osmotrx.rxgain, VTY_NEWLINE); - else - vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); - if (plink->u.osmotrx.power_valid) - vty_out(vty, " tx-attenuation : %d dB%s", - plink->u.osmotrx.power, VTY_NEWLINE); - else - vty_out(vty, " tx-attenuation : undefined%s", VTY_NEWLINE); llist_for_each_entry(pinst, &plink->instances, list) show_phy_inst_single(vty, pinst); @@ -309,7 +309,7 @@ return CMD_SUCCESS; } -DEFUN(cfg_phy_power_on, cfg_phy_power_on_cmd, +DEFUN(cfg_phyinst_power_on, cfg_phyinst_power_on_cmd, "osmotrx power (on|off)", OSMOTRX_STR "Change TRX state\n" @@ -356,70 +356,78 @@ return CMD_SUCCESS; } -DEFUN(cfg_phy_rxgain, cfg_phy_rxgain_cmd, +DEFUN(cfg_phyinst_rxgain, cfg_phyinst_rxgain_cmd, "osmotrx rx-gain <0-50>", OSMOTRX_STR "Set the receiver gain in dB\n" "Gain in dB\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.rxgain = atoi(argv[0]); - plink->u.osmotrx.rxgain_valid = 1; - plink->u.osmotrx.rxgain_sent = 0; + l1h->config.rxgain = atoi(argv[0]); + l1h->config.rxgain_valid = 1; + l1h->config.rxgain_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_tx_atten, cfg_phy_tx_atten_cmd, +DEFUN(cfg_phyinst_tx_atten, cfg_phyinst_tx_atten_cmd, "osmotrx tx-attenuation <0-50>", OSMOTRX_STR "Set the transmitter attenuation\n" "Fixed attenuation in dB, overriding OML\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power = atoi(argv[0]); - plink->u.osmotrx.power_oml = 0; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + l1h->config.power = atoi(argv[0]); + l1h->config.power_oml = 0; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_tx_atten_oml, cfg_phy_tx_atten_oml_cmd, +DEFUN(cfg_phyinst_tx_atten_oml, cfg_phyinst_tx_atten_oml_cmd, "osmotrx tx-attenuation oml", OSMOTRX_STR "Set the transmitter attenuation\n" "Use NM_ATT_RF_MAXPOWR_R (max power reduction) from BSC via OML\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power_oml = 1; - plink->u.osmotrx.power_valid = 1; - plink->u.osmotrx.power_sent = 0; + l1h->config.power_oml = 1; + l1h->config.power_valid = 1; + l1h->config.power_sent = 0; + l1if_provision_transceiver_trx(l1h); return CMD_SUCCESS; } -DEFUN(cfg_phy_no_rxgain, cfg_phy_no_rxgain_cmd, +DEFUN(cfg_phyinst_no_rxgain, cfg_phyinst_no_rxgain_cmd, "no osmotrx rx-gain", NO_STR OSMOTRX_STR "Unset the receiver gain in dB\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.rxgain_valid = 0; + l1h->config.rxgain_valid = 0; return CMD_SUCCESS; } -DEFUN(cfg_phy_no_tx_atten, cfg_phy_no_tx_atten_cmd, +DEFUN(cfg_phyinst_no_tx_atten, cfg_phyinst_no_tx_atten_cmd, "no osmotrx tx-attenuation", NO_STR OSMOTRX_STR "Unset the transmitter attenuation\n") { - struct phy_link *plink = vty->index; + struct phy_instance *pinst = vty->index; + struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - plink->u.osmotrx.power_valid = 0; + l1h->config.power_valid = 0; return CMD_SUCCESS; } @@ -488,22 +496,22 @@ plink->u.osmotrx.clock_advance, VTY_NEWLINE); vty_out(vty, " osmotrx rts-advance %d%s", plink->u.osmotrx.rts_advance, VTY_NEWLINE); - if (plink->u.osmotrx.rxgain_valid) - vty_out(vty, " osmotrx rx-gain %d%s", - plink->u.osmotrx.rxgain, VTY_NEWLINE); - if (plink->u.osmotrx.power_valid) { - if (plink->u.osmotrx.power_oml) - vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); - else - vty_out(vty, " osmotrx tx-attenuation %d%s", - plink->u.osmotrx.power, VTY_NEWLINE); - } } void bts_model_config_write_phy_inst(struct vty *vty, struct phy_instance *pinst) { struct trx_l1h *l1h = pinst->u.osmotrx.hdl; + if (l1h->config.rxgain_valid) + vty_out(vty, " osmotrx rx-gain %d%s", + l1h->config.rxgain, VTY_NEWLINE); + if (l1h->config.power_valid) { + if (l1h->config.power_oml) + vty_out(vty, " osmotrx tx-attenuation oml%s", VTY_NEWLINE); + else + vty_out(vty, " osmotrx tx-attenuation %d%s", + l1h->config.power, VTY_NEWLINE); + } if (l1h->config.maxdly_valid) vty_out(vty, " maxdly %d%s", l1h->config.maxdly, VTY_NEWLINE); if (l1h->config.maxdlynb_valid) @@ -560,14 +568,14 @@ install_element(PHY_NODE, &cfg_phy_fn_advance_cmd); install_element(PHY_NODE, &cfg_phy_rts_advance_cmd); install_element(PHY_NODE, &cfg_phy_transc_ip_cmd); - install_element(PHY_NODE, &cfg_phy_rxgain_cmd); - install_element(PHY_NODE, &cfg_phy_tx_atten_cmd); - install_element(PHY_NODE, &cfg_phy_tx_atten_oml_cmd); - install_element(PHY_NODE, &cfg_phy_no_rxgain_cmd); - install_element(PHY_NODE, &cfg_phy_no_tx_atten_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_rxgain_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_tx_atten_oml_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_rxgain_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_no_tx_atten_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_slotmask_cmd); - install_element(PHY_INST_NODE, &cfg_phy_power_on_cmd); + install_element(PHY_INST_NODE, &cfg_phyinst_power_on_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_maxdly_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_no_maxdly_cmd); install_element(PHY_INST_NODE, &cfg_phyinst_maxdlynb_cmd); -- To view, visit https://gerrit.osmocom.org/1785 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4861a59d10d1ef91954e0c6ea265e66dec08844f Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:37:54 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 13:37:54 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... In-Reply-To: References: Message-ID: Patch Set 3: Verified+1 -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 13:38:08 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Fri, 10 Feb 2017 13:38:08 +0000 Subject: [MERGED] osmo-bts[master]: osmo-trx-bts: Fix osmo-bts-trx crash on startup during readi... In-Reply-To: References: Message-ID: Ivan Kluchnikov has submitted this change and it was merged. Change subject: osmo-trx-bts: Fix osmo-bts-trx crash on startup during reading phy instance parameters from config file ...................................................................... osmo-trx-bts: Fix osmo-bts-trx crash on startup during reading phy instance parameters from config file pinst->u.osmotrx.hdl should be allocated before reading phy_instance parameters from config file and applying them. So allocation of pinst->u.osmotrx.hdl should be moved from l1if_open function to bts_model_phy_instance_set_defaults function, which is proper place for this allocation according to start-up procedure of osmo-bts. Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 --- M src/osmo-bts-trx/l1_if.c M src/osmo-bts-trx/main.c 2 files changed, 5 insertions(+), 2 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Ivan Kluchnikov: Verified Harald Welte: Looks good to me, approved diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 8c5115b..6c1969c 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -66,10 +66,9 @@ struct trx_l1h *l1h; int rc; - l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); + l1h = pinst->u.osmotrx.hdl; if (!l1h) return NULL; - l1h->phy_inst = pinst; rc = trx_sched_init(&l1h->l1s, pinst->trx); if (rc < 0) { diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c index dbd8fc4..98066ca 100644 --- a/src/osmo-bts-trx/main.c +++ b/src/osmo-bts-trx/main.c @@ -121,6 +121,10 @@ void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) { + struct trx_l1h *l1h; + l1h = talloc_zero(tall_bts_ctx, struct trx_l1h); + l1h->phy_inst = pinst; + pinst->u.osmotrx.hdl = l1h; } int main(int argc, char **argv) -- To view, visit https://gerrit.osmocom.org/1786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6e23f92644400acb268818c9373a8fb10c003da1 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 15:36:51 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 10 Feb 2017 15:36:51 +0000 Subject: [PATCH] osmo-bts[master]: Fix interleaving table for TCH/H Message-ID: Review at https://gerrit.osmocom.org/1793 Fix interleaving table for TCH/H Fix table to match the one which was computed from Table 4 in 3GPP TS 45.003 using emacs macro and org-mode trickery to avoid data corruption on copy-paste from spec pdf. Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 --- M src/osmo-bts-trx/gsm0503_tables.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/93/1793/1 diff --git a/src/osmo-bts-trx/gsm0503_tables.c b/src/osmo-bts-trx/gsm0503_tables.c index 8d5fa0c..1edaa47 100644 --- a/src/osmo-bts-trx/gsm0503_tables.c +++ b/src/osmo-bts-trx/gsm0503_tables.c @@ -1673,7 +1673,7 @@ { 86 ,0 }, { 87 ,2 }, { 110,0 }, { 111,2 }, { 4 ,0 }, { 5 ,2 }, { 82 ,1 }, { 83 ,3 }, { 52 ,0 }, { 53 ,2 }, { 58 ,1 }, { 59 ,3 }, { 28 ,0 }, { 29 ,2 }, { 34 ,1 }, { 35 ,3 }, { 76 ,0 }, { 77 ,2 }, - { 10 ,1 }, { 12 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 }, + { 10 ,1 }, { 11 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 }, { 106,1 }, { 107,3 }, { 64 ,0 }, { 65 ,2 }, { 70 ,1 }, { 71 ,3 }, { 94 ,1 }, { 95 ,3 }, { 40 ,0 }, { 41 ,2 }, { 46 ,1 }, { 47 ,3 }, { 22 ,1 }, { 23 ,3 }, { 88 ,0 }, { 89 ,2 }, { 112,0 }, { 113,2 }, @@ -1681,7 +1681,7 @@ { 60 ,1 }, { 61 ,3 }, { 30 ,0 }, { 31 ,2 }, { 36 ,1 }, { 37 ,3 }, { 78 ,0 }, { 79 ,2 }, { 12 ,1 }, { 13 ,3 }, { 102,0 }, { 103,2 }, { 18 ,0 }, { 19 ,2 }, { 108,1 }, { 109,3 }, { 66 ,0 }, { 67 ,2 }, - { 72 ,1 }, { 73 ,3 }, { 96 ,1 }, { 97 ,3 }, { 42 ,0 }, { 43 ,2 }, + { 72 ,1 }, { 73 ,3 }, { 97 ,3 }, { 42 ,0 }, { 43 ,2 }, { 48 ,1 }, { 49 ,3 }, { 24 ,1 }, { 25 ,3 }, { 90 ,0 }, { 91 ,2 }, { 0 ,1 }, { 1 ,3 }, { 8 ,0 }, { 9 ,2 }, { 86 ,1 }, { 87 ,3 }, { 56 ,0 }, { 57 ,2 }, { 62 ,1 }, { 63 ,3 }, { 32 ,0 }, { 33 ,2 }, -- To view, visit https://gerrit.osmocom.org/1793 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 10 15:44:03 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 10 Feb 2017 15:44:03 +0000 Subject: [PATCH] osmo-bts[master]: Fix typo in TCH/H interleaving table In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1793 to look at the new patch set (#2). Fix typo in TCH/H interleaving table According to Table 4 in 3GPP TS 45.003 j=11, b=3 case corresponds to k=91 and not j=12 as was previously used. Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 --- M src/osmo-bts-trx/gsm0503_tables.c M tests/bursts/bursts_test.ok 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/93/1793/2 diff --git a/src/osmo-bts-trx/gsm0503_tables.c b/src/osmo-bts-trx/gsm0503_tables.c index 8d5fa0c..1109ff9 100644 --- a/src/osmo-bts-trx/gsm0503_tables.c +++ b/src/osmo-bts-trx/gsm0503_tables.c @@ -1673,7 +1673,7 @@ { 86 ,0 }, { 87 ,2 }, { 110,0 }, { 111,2 }, { 4 ,0 }, { 5 ,2 }, { 82 ,1 }, { 83 ,3 }, { 52 ,0 }, { 53 ,2 }, { 58 ,1 }, { 59 ,3 }, { 28 ,0 }, { 29 ,2 }, { 34 ,1 }, { 35 ,3 }, { 76 ,0 }, { 77 ,2 }, - { 10 ,1 }, { 12 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 }, + { 10 ,1 }, { 11 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 }, { 106,1 }, { 107,3 }, { 64 ,0 }, { 65 ,2 }, { 70 ,1 }, { 71 ,3 }, { 94 ,1 }, { 95 ,3 }, { 40 ,0 }, { 41 ,2 }, { 46 ,1 }, { 47 ,3 }, { 22 ,1 }, { 23 ,3 }, { 88 ,0 }, { 89 ,2 }, { 112,0 }, { 113,2 }, diff --git a/tests/bursts/bursts_test.ok b/tests/bursts/bursts_test.ok index 4136905..5030e4d 100644 --- a/tests/bursts/bursts_test.ok +++ b/tests/bursts/bursts_test.ok @@ -6,7 +6,7 @@ tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02 -tch_hr_decode: n_errors=11 n_bits_total=211 ber=0.05 +tch_hr_decode: n_errors=10 n_bits_total=211 ber=0.05 tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02 -- To view, visit https://gerrit.osmocom.org/1793 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 10 16:07:20 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 10 Feb 2017 16:07:20 +0000 Subject: libosmocore[master]: libosmocoding: migrate transcoding routines from OsmoBTS In-Reply-To: References: Message-ID: Patch Set 14: This should be updated once 1793 is merged. -- To view, visit https://gerrit.osmocom.org/933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1 Gerrit-PatchSet: 14 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 17:12:42 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Fri, 10 Feb 2017 17:12:42 +0000 Subject: osmo-bts[master]: Fix typo in TCH/H interleaving table In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1793 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 10 22:03:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 10 Feb 2017 22:03:47 +0000 Subject: osmo-bts[master]: Fix typo in TCH/H interleaving table In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 I can't seem to figure out how that table 4 works, but if you two agree that it's correct I'm ready to trust you on this one. -- To view, visit https://gerrit.osmocom.org/1793 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 11 03:02:06 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 03:02:06 +0000 Subject: osmo-sip-connector[master]: configure: check for pkg-config presence In-Reply-To: References: Message-ID: Patch Set 1: Do we need 0.20 or is this a random number? >From pkg.m4: dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl So instead of this macro we should use PKG_PROG_PKG_CONFIG([0.20])? -- To view, visit https://gerrit.osmocom.org/1000 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iaca22089bcb21b56048fa541f588c4ad4bed8f6d Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 11 03:56:58 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 03:56:58 +0000 Subject: [PATCH] osmo-sip-connector[master]: sip: Treat SIP 183 as progress too Message-ID: Review at https://gerrit.osmocom.org/1794 sip: Treat SIP 183 as progress too It doesn't fix early media yet but brings us one step closer to it: The 183 (Session Progress) response is used to convey information about the progress of the call that is not otherwise classified. The Reason-Phrase, header fields, or message body MAY be used to convey more details about the call progress. Change-Id: Ibf264f251e41c06a7b4839acc0d0853e6400291c --- M src/sip.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/94/1794/1 diff --git a/src/sip.c b/src/sip.c index 139c620..afff393 100644 --- a/src/sip.c +++ b/src/sip.c @@ -156,7 +156,7 @@ if (leg->state == SIP_CC_INITIAL) leg->state = SIP_CC_DLG_CNFD; - if (status == 180) + if (status == 180 || status == 183) call_progress(leg, sip); else if (status == 200) call_connect(leg, sip); -- To view, visit https://gerrit.osmocom.org/1794 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibf264f251e41c06a7b4839acc0d0853e6400291c Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Sat Feb 11 06:09:31 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 06:09:31 +0000 Subject: [PATCH] osmo-sip-connector[master]: evpoll: Use {} in the middle of the if/else if/else block Message-ID: Review at https://gerrit.osmocom.org/1795 evpoll: Use {} in the middle of the if/else if/else block Curly braces are used the lines above and below, don't make the middle stick out like this. Change-Id: I48a15a8665a47db206f8a7ccbc792f6bec8549c2 --- M src/evpoll.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/95/1795/1 diff --git a/src/evpoll.c b/src/evpoll.c index 9593764..1648080 100644 --- a/src/evpoll.c +++ b/src/evpoll.c @@ -68,9 +68,9 @@ */ if (timeout == 0) { tv = &null_tv; - } else if (timeout == -1) + } else if (timeout == -1) { tv = osmo_timers_nearest(); - else { + } else { poll_tv.tv_sec = timeout / 1000; poll_tv.tv_usec = (timeout % 1000) * 1000; -- To view, visit https://gerrit.osmocom.org/1795 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I48a15a8665a47db206f8a7ccbc792f6bec8549c2 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Sat Feb 11 06:09:32 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 06:09:32 +0000 Subject: [PATCH] osmo-sip-connector[master]: evpoll: Always initialize revents for the output Message-ID: Review at https://gerrit.osmocom.org/1796 evpoll: Always initialize revents for the output Even if we have not selected the fd (e.g. fd < 0), initialize revents to 0. This seems to match gpoll.c:g_poll of glib. Change-Id: I9e16a6d5a74a204c85808ba67a8f0f7af3045059 --- M src/evpoll.c 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/96/1796/1 diff --git a/src/evpoll.c b/src/evpoll.c index 1648080..a4b8a80 100644 --- a/src/evpoll.c +++ b/src/evpoll.c @@ -92,10 +92,11 @@ osmo_fd_disp_fds(&readset, &writeset, &exceptset); for (i = 0; i < nfds; ++i) { + fds[i].revents = 0; + if (fds[i].fd < 0) continue; - fds[i].revents = 0; if (FD_ISSET(fds[i].fd, &readset)) fds[i].revents = POLLIN; if (FD_ISSET(fds[i].fd, &writeset)) -- To view, visit https://gerrit.osmocom.org/1796 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9e16a6d5a74a204c85808ba67a8f0f7af3045059 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Sat Feb 11 06:09:32 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 06:09:32 +0000 Subject: [PATCH] osmo-sip-connector[master]: evpoll: Don't try to be more smart than g_poll Message-ID: Review at https://gerrit.osmocom.org/1797 evpoll: Don't try to be more smart than g_poll gpoll.c:g_poll maps G_IO_PRI (which is POLLPRI) to the errorfds of the select call. Let's do the same. Change-Id: I8c9163f7495e0b237bde2d48beffea3b0776a1dd Related: OS#1934 --- M src/evpoll.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/97/1797/1 diff --git a/src/evpoll.c b/src/evpoll.c index a4b8a80..3273bd0 100644 --- a/src/evpoll.c +++ b/src/evpoll.c @@ -43,15 +43,15 @@ for (i = 0; i < nfds; ++i) { if (fds[i].fd < 0) continue; - if ((fds[i].events & (POLLIN | POLLOUT | POLLERR)) == 0) + if ((fds[i].events & (POLLIN | POLLOUT | POLLPRI)) == 0) continue; - /* copy events, glib seems to map POLLPRI to exceptionset? */ + /* copy events. Not sure why glib maps PRI to exceptionset */ if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &readset); if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &writeset); - if (fds[i].events & POLLERR) + if (fds[i].events & POLLPRI) FD_SET(fds[i].fd, &exceptset); if (fds[i].fd > maxfd) @@ -102,7 +102,7 @@ if (FD_ISSET(fds[i].fd, &writeset)) fds[i].revents |= POLLOUT; if (FD_ISSET(fds[i].fd, &exceptset)) - fds[i].revents |= POLLERR; + fds[i].revents |= POLLPRI; } return rc; -- To view, visit https://gerrit.osmocom.org/1797 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8c9163f7495e0b237bde2d48beffea3b0776a1dd Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Sat Feb 11 10:12:10 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 11 Feb 2017 10:12:10 +0000 Subject: osmo-sip-connector[master]: evpoll: Don't try to be more smart than g_poll In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1797 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8c9163f7495e0b237bde2d48beffea3b0776a1dd Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 11 10:12:39 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 11 Feb 2017 10:12:39 +0000 Subject: osmo-sip-connector[master]: evpoll: Always initialize revents for the output In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1796 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9e16a6d5a74a204c85808ba67a8f0f7af3045059 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 11 10:12:52 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 11 Feb 2017 10:12:52 +0000 Subject: osmo-sip-connector[master]: evpoll: Use {} in the middle of the if/else if/else block In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1795 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I48a15a8665a47db206f8a7ccbc792f6bec8549c2 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 11 10:13:05 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sat, 11 Feb 2017 10:13:05 +0000 Subject: osmo-sip-connector[master]: sip: Treat SIP 183 as progress too In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1794 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ibf264f251e41c06a7b4839acc0d0853e6400291c Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 11 14:56:05 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 14:56:05 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 4: Code-Review-1 (3 comments) I think given we have configs in the wild that include everything.. where it might or might not be intended.. we should have a new name.. "all" maybe? git grep everything -- openbsc/doc/ | wc -l 7 https://gerrit.osmocom.org/#/c/1582/4/include/osmocom/vty/logging.h File include/osmocom/vty/logging.h: Line 7: void logging_vty_add_cmds(const struct log_info *unused_info); then remove it... as long as we don't write (void) the compiler should not complain.. https://gerrit.osmocom.org/#/c/1582/4/src/logging.c File src/logging.c: Line 142: "Log everything (use with extreme care)", What about existing configs that write "everything"? Maybe introduce "all" and have everything as an alias for "XYZ???" Line 356: static inline bool log_to_target(struct log_target *tar, int subsys, int level) But it doesn't look. it is a rather long predicate function.. should_log_to_target? -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 11 14:58:04 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 14:58:04 +0000 Subject: osmo-bts[master]: osmo-bts-trx: cosmetic fixes In-Reply-To: References: Message-ID: Patch Set 3: (1 comment) https://gerrit.osmocom.org/#/c/1776/3//COMMIT_MSG Commit Message: PS3, Line 14: set That doesn't sound that cosmetic? -- To view, visit https://gerrit.osmocom.org/1776 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Tom Tsou Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 11 15:18:57 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 11 Feb 2017 15:18:57 +0000 Subject: osmo-bts[master]: LC15: fix coding style In-Reply-To: References: Message-ID: Patch Set 1: In many projects fixing coding style after the fact is not done. One reason not to do it is that git blame gets more difficult to use.. I have no personal opinion for this subdirectory though. -- To view, visit https://gerrit.osmocom.org/807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I18d07822df1f36a6855b72f83e2d73d221aa8735 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Minh-Quang Nguyen Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Minh-Quang Nguyen Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 12 02:17:06 2017 From: gerrit-no-reply at lists.osmocom.org (Vadim Yanitskiy) Date: Sun, 12 Feb 2017 02:17:06 +0000 Subject: [PATCH] libosmocore[master]: libosmocoding: migrate transcoding routines from OsmoBTS In-Reply-To: References: Message-ID: Hello tnt, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/933 to look at the new patch set (#15). 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 --- M .gitignore A Doxyfile.coding.in M Makefile.am M configure.ac M debian/control M include/Makefile.am A include/osmocom/coding/gsm0503_coding.h A include/osmocom/coding/gsm0503_interleaving.h A include/osmocom/coding/gsm0503_mapping.h A include/osmocom/coding/gsm0503_parity.h A include/osmocom/coding/gsm0503_tables.h M include/osmocom/gsm/gsm0503.h A libosmocoding.pc.in A src/coding/Makefile.am A src/coding/gsm0503_coding.c A src/coding/gsm0503_interleaving.c A src/coding/gsm0503_mapping.c A src/coding/gsm0503_parity.c A src/coding/gsm0503_tables.c A src/coding/libosmocoding.map M src/gsm/libosmogsm.map M tests/Makefile.am A tests/coding/coding_test.c A tests/coding/coding_test.ok M tests/testsuite.at M utils/conv_codes_gsm.py 26 files changed, 8,113 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/33/933/15 -- To view, visit https://gerrit.osmocom.org/933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1 Gerrit-PatchSet: 15 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:20 +0000 Subject: [PATCH] libosmo-sccp[master]: Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first Message-ID: Review at https://gerrit.osmocom.org/1798 Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first Move here unchanged first, so we're able to see the modifications in diffs. Pending changes will follow in subsequent patches. Moved from osmo-iuh 3da8608b6ad014fc74536dbb49019704fd425b8c, which was before the rename of osmo_sua_link and osmo_sua_user to osmo_sccp_link and osmo_sccp_user, so this will not compile. Change-Id: Iae0c58c5f1eb00a685de70add0d5257e4316c6d5 --- M include/osmocom/sigtran/Makefile.am A include/osmocom/sigtran/sccp_helpers.h M src/Makefile.am A src/sccp_helpers.c 4 files changed, 172 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/98/1798/1 diff --git a/include/osmocom/sigtran/Makefile.am b/include/osmocom/sigtran/Makefile.am index adb0997..e168256 100644 --- a/include/osmocom/sigtran/Makefile.am +++ b/include/osmocom/sigtran/Makefile.am @@ -1,4 +1,6 @@ -sigtran_HEADERS = m3ua_types.h xua_types.h xua_msg.h m2ua_types.h sccp_sap.h sua.h sigtran_sap.h +sigtran_HEADERS = m3ua_types.h xua_types.h xua_msg.h m2ua_types.h sccp_sap.h \ + sua.h sigtran_sap.h sccp_helpers.h + sigtrandir = $(includedir)/osmocom/sigtran sigtran_prot_HEADERS = protocol/sua.h diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h new file mode 100644 index 0000000..089d69a --- /dev/null +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -0,0 +1,33 @@ +#pragma once +#include +#include +#include +#include + +int sccp_tx_unitdata(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); + +int sccp_tx_unitdata_msg(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); + +void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); + +int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); + +int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); + +int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len); + +int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, + struct msgb *msg); diff --git a/src/Makefile.am b/src/Makefile.am index 238a840..26482a0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,6 +24,6 @@ # documentation before making any modification LIBVERSION=0:0:0 -libosmo_sigtran_la_SOURCES = sccp_sap.c sua.c xua_msg.c +libosmo_sigtran_la_SOURCES = sccp_sap.c sua.c xua_msg.c sccp_helpers.c libosmo_sigtran_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined -export-symbols-regex '^osmo_' libosmo_sigtran_la_LIBADD = $(LIBOSMOCORE_LIBS) $(LIBOSMONETIF_LIBS) $(LIBSCTP_LIBS) diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c new file mode 100644 index 0000000..cdb26e7 --- /dev/null +++ b/src/sccp_helpers.c @@ -0,0 +1,135 @@ +/* SCCP User SAP helper functions (move to libosmo-sigtran?) */ + +/* (C) 2015 by Harald Welte + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include + +#include "sccp_helpers.h" + +void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) +{ + addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; + addr->ssn = ssn; + addr->pc = pc; +} + +int sccp_tx_unitdata(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "sccp_tx_unitdata"); + struct osmo_scu_prim *prim; + struct osmo_scu_unitdata_param *param; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + param = &prim->u.unitdata; + sccp_make_addr_pc_ssn(¶m->calling_addr, 1, OSMO_SCCP_SSN_RANAP); + sccp_make_addr_pc_ssn(¶m->called_addr, 2, OSMO_SCCP_SSN_RANAP); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_REQUEST, msg); + + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + + return osmo_sua_user_link_down(link, &prim->oph); +} + +int sccp_tx_unitdata_msg(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) +{ + int rc; + + rc = sccp_tx_unitdata(link, calling_addr, called_addr, + msg->data, msgb_length(msg)); + msgb_free(msg); + + return rc; +} + +int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "sccp_tx_conn_req"); + struct osmo_scu_prim *prim; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, + OSMO_SCU_PRIM_N_CONNECT, + PRIM_OP_REQUEST, msg); + sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, OSMO_SCCP_SSN_RANAP); + prim->u.connect.sccp_class = 2; + prim->u.connect.conn_id = conn_id; + + if (data && len) { + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + } + + return osmo_sua_user_link_down(link, &prim->oph); +} + +int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) +{ + int rc; + + rc = sccp_tx_conn_req(link, conn_id, calling_addr, called_addr, + msg->data, msgb_length(msg)); + msgb_free(msg); + + return rc; +} + +int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "sccp_tx_data"); + struct osmo_scu_prim *prim; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, + OSMO_SCU_PRIM_N_DATA, + PRIM_OP_REQUEST, msg); + prim->u.data.conn_id = conn_id; + + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + + return osmo_sua_user_link_down(link, &prim->oph); +} + +int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, + struct msgb *msg) +{ + int rc; + + rc = sccp_tx_data(link, conn_id, msg->data, msgb_length(msg)); + msgb_free(msg); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/1798 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iae0c58c5f1eb00a685de70add0d5257e4316c6d5 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:21 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osm... Message-ID: Review at https://gerrit.osmocom.org/1799 sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osmo_sccp_link Change-Id: If8b09bb05297ebf663b4a04d3cc094a6a8087f53 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 12 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/99/1799/1 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 089d69a..01f7af6 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -4,30 +4,30 @@ #include #include -int sccp_tx_unitdata(struct osmo_sua_link *link, +int sccp_tx_unitdata(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len); -int sccp_tx_unitdata_msg(struct osmo_sua_link *link, +int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg); void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); -int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len); -int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg); -int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, uint8_t *data, unsigned int len); -int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index cdb26e7..d450627 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -32,7 +32,7 @@ addr->pc = pc; } -int sccp_tx_unitdata(struct osmo_sua_link *link, +int sccp_tx_unitdata(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len) @@ -53,7 +53,7 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_unitdata_msg(struct osmo_sua_link *link, +int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg) @@ -67,7 +67,7 @@ return rc; } -int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len) @@ -91,7 +91,7 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg) @@ -105,7 +105,7 @@ return rc; } -int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_data"); @@ -123,7 +123,7 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg) { int rc; -- To view, visit https://gerrit.osmocom.org/1799 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If8b09bb05297ebf663b4a04d3cc094a6a8087f53 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:21 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers: adjust .h include and copyright Message-ID: Review at https://gerrit.osmocom.org/1800 sccp_helpers: adjust .h include and copyright Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc --- M src/sccp_helpers.c 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/00/1800/1 diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index d450627..98c93f3 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -1,6 +1,7 @@ -/* SCCP User SAP helper functions (move to libosmo-sigtran?) */ +/* SCCP User SAP helper functions */ /* (C) 2015 by Harald Welte + * (C) 2016 by sysmocom s.m.f.c. GmbH * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -22,8 +23,7 @@ #include #include - -#include "sccp_helpers.h" +#include void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) { -- To view, visit https://gerrit.osmocom.org/1800 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:21 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers: add osmo_ prefix to all functions Message-ID: Review at https://gerrit.osmocom.org/1801 sccp_helpers: add osmo_ prefix to all functions Change-Id: I839c976f3ac722b955da18216de3df2eaa4c5af3 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 52 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/01/1801/1 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 01f7af6..d5916a9 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -4,30 +4,31 @@ #include #include -int sccp_tx_unitdata(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len); +int osmo_sccp_tx_unitdata(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); -int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg); +int osmo_sccp_tx_unitdata_msg(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); -void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); +void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, + uint32_t pc, uint32_t ssn); -int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len); +int osmo_sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); -int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg); +int osmo_sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); -int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, - uint8_t *data, unsigned int len); +int osmo_sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len); -int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, - struct msgb *msg); +int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, + struct msgb *msg); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index 98c93f3..ce9cd06 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -25,17 +25,17 @@ #include #include -void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) +void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) { addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; addr->ssn = ssn; addr->pc = pc; } -int sccp_tx_unitdata(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len) +int osmo_sccp_tx_unitdata(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_unitdata"); struct osmo_scu_prim *prim; @@ -43,8 +43,8 @@ prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); param = &prim->u.unitdata; - sccp_make_addr_pc_ssn(¶m->calling_addr, 1, OSMO_SCCP_SSN_RANAP); - sccp_make_addr_pc_ssn(¶m->called_addr, 2, OSMO_SCCP_SSN_RANAP); + memcpy(¶m->calling_addr, calling_addr, sizeof(*calling_addr)); + memcpy(¶m->called_addr, called_addr, sizeof(*called_addr)); osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_REQUEST, msg); msg->l2h = msgb_put(msg, len); @@ -53,24 +53,24 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg) +int osmo_sccp_tx_unitdata_msg(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) { int rc; - rc = sccp_tx_unitdata(link, calling_addr, called_addr, - msg->data, msgb_length(msg)); + rc = osmo_sccp_tx_unitdata(link, calling_addr, called_addr, + msg->data, msgb_length(msg)); msgb_free(msg); return rc; } -int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len) +int osmo_sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_conn_req"); struct osmo_scu_prim *prim; @@ -79,7 +79,8 @@ osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_REQUEST, msg); - sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, OSMO_SCCP_SSN_RANAP); + osmo_sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, + OSMO_SCCP_SSN_RANAP); prim->u.connect.sccp_class = 2; prim->u.connect.conn_id = conn_id; @@ -91,22 +92,22 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg) +int osmo_sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) { int rc; - rc = sccp_tx_conn_req(link, conn_id, calling_addr, called_addr, - msg->data, msgb_length(msg)); + rc = osmo_sccp_tx_conn_req(link, conn_id, calling_addr, called_addr, + msg->data, msgb_length(msg)); msgb_free(msg); return rc; } -int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, - uint8_t *data, unsigned int len) +int osmo_sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_data"); struct osmo_scu_prim *prim; @@ -123,12 +124,12 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, - struct msgb *msg) +int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, + struct msgb *msg) { int rc; - rc = sccp_tx_data(link, conn_id, msg->data, msgb_length(msg)); + rc = osmo_sccp_tx_data(link, conn_id, msg->data, msgb_length(msg)); msgb_free(msg); return rc; -- To view, visit https://gerrit.osmocom.org/1801 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I839c976f3ac722b955da18216de3df2eaa4c5af3 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:21 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers: add convenience function for RANAP unitdata Message-ID: Review at https://gerrit.osmocom.org/1802 sccp_helpers: add convenience function for RANAP unitdata Change-Id: Ie96d78512b8e3907753272d75471b882365968c4 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 20 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/02/1802/1 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index d5916a9..3384630 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -17,6 +17,11 @@ void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); +int osmo_sccp_tx_unitdata_ranap(struct osmo_sccp_link *link, + uint32_t src_point_code, + uint32_t dst_point_code, + uint8_t *data, unsigned int len); + int osmo_sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index ce9cd06..c6248de 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -53,6 +53,21 @@ return osmo_sua_user_link_down(link, &prim->oph); } +int osmo_sccp_tx_unitdata_ranap(struct osmo_sccp_link *link, + uint32_t src_point_code, + uint32_t dst_point_code, + uint8_t *data, unsigned int len) +{ + struct osmo_sccp_addr calling_addr; + struct osmo_sccp_addr called_addr; + osmo_sccp_make_addr_pc_ssn(&calling_addr, src_point_code, + OSMO_SCCP_SSN_RANAP); + osmo_sccp_make_addr_pc_ssn(&called_addr, dst_point_code, + OSMO_SCCP_SSN_RANAP); + return osmo_sccp_tx_unitdata(link, &calling_addr, &called_addr, + data, len); +} + int osmo_sccp_tx_unitdata_msg(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, -- To view, visit https://gerrit.osmocom.org/1802 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie96d78512b8e3907753272d75471b882365968c4 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:47 +0000 Subject: [PATCH] libosmo-sccp[master]: migrate some generic XUA helpers from sua.c to xua_msg.c Message-ID: Review at https://gerrit.osmocom.org/1803 migrate some generic XUA helpers from sua.c to xua_msg.c Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 60 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/03/1803/1 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 9cc8632..bb9486a 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -21,6 +21,8 @@ #include +#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) + struct msgb; struct xua_msg { @@ -51,3 +53,8 @@ struct msgb *xua_to_msg(const int version, struct xua_msg *msg); void xua_set_log_area(int log_area); + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); diff --git a/src/sua.c b/src/sua.c index 39afef0..8bbaa58 100644 --- a/src/sua.c +++ b/src/sua.c @@ -120,56 +120,6 @@ * Message encoding helper functions ***********************************************************************/ -#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) - -static int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) -{ - uint8_t *cur; - unsigned int rest; - unsigned int tlv_len = 4 + len + (4 - (len % 4)); - - if (msgb_tailroom(msg) < tlv_len) - return -ENOMEM; - - /* tag */ - msgb_put_u16(msg, tag); - /* length */ - msgb_put_u16(msg, len + 4); - /* value */ - cur = msgb_put(msg, len); - memcpy(cur, data, len); - /* padding */ - rest = (4 - (len % 4)) & 0x3; - if (rest > 0) { - cur = msgb_put(msg, rest); - memset(cur, 0, rest); - } - - return 0; -} - -static int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) -{ - uint32_t val_n = htonl(val); - - return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); -} - -static int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) -{ - uint32_t val_n = htonl(val); - return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); -} - -static uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) -{ - struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; -} - static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) { struct msgb *tmp = msgb_alloc(128, "SCCP Address"); diff --git a/src/xua_msg.c b/src/xua_msg.c index 0ced1f9..67dd6e2 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -182,3 +182,56 @@ { DXUA = log_area; } + + +/*********************************************************************** + * Message encoding helper functions + ***********************************************************************/ + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) +{ + uint8_t *cur; + unsigned int rest; + unsigned int tlv_len = 4 + len + (4 - (len % 4)); + + if (msgb_tailroom(msg) < tlv_len) + return -ENOMEM; + + /* tag */ + msgb_put_u16(msg, tag); + /* length */ + msgb_put_u16(msg, len + 4); + /* value */ + cur = msgb_put(msg, len); + memcpy(cur, data, len); + /* padding */ + rest = (4 - (len % 4)) & 0x3; + if (rest > 0) { + cur = msgb_put(msg, rest); + memset(cur, 0, rest); + } + + return 0; +} + +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) +{ + uint32_t val_n = htonl(val); + + return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); +} + +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) +{ + uint32_t val_n = htonl(val); + return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); +} + +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) +{ + struct xua_msg_part *part = xua_msg_find_tag(xua, iei); + uint32_t rc = 0; + if (part) + rc = ntohl(*(uint32_t *)part->dat); + return rc; +} -- To view, visit https://gerrit.osmocom.org/1803 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:47 +0000 Subject: [PATCH] libosmo-sccp[master]: xua_msg: Make DXUA available to other XUA code Message-ID: Review at https://gerrit.osmocom.org/1804 xua_msg: Make DXUA available to other XUA code Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/04/1804/1 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index bb9486a..4c8fe83 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -42,6 +42,8 @@ }; +extern int DXUA; + struct xua_msg *xua_msg_alloc(void); void xua_msg_free(struct xua_msg *msg); diff --git a/src/xua_msg.c b/src/xua_msg.c index 67dd6e2..21d37ad 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -27,7 +27,7 @@ #include static void *tall_xua; -static int DXUA = -1; +int DXUA = -1; struct xua_msg *xua_msg_alloc(void) { -- To view, visit https://gerrit.osmocom.org/1804 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:48 +0000 Subject: [PATCH] libosmo-sccp[master]: protocol/sua.h: Add #defines for CAUSE group values (from RFC) Message-ID: Review at https://gerrit.osmocom.org/1805 protocol/sua.h: Add #defines for CAUSE group values (from RFC) Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb --- M include/osmocom/sigtran/protocol/sua.h 1 file changed, 7 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/05/1805/1 diff --git a/include/osmocom/sigtran/protocol/sua.h b/include/osmocom/sigtran/protocol/sua.h index d61c85a..d191368 100644 --- a/include/osmocom/sigtran/protocol/sua.h +++ b/include/osmocom/sigtran/protocol/sua.h @@ -118,3 +118,10 @@ #define SUA_RI_SSN_PC 2 #define SUA_RI_HOST 3 #define SUA_RI_SSN_IP 4 + +#define SUA_CAUSE_T_MASK 0xff00 +#define SUA_CAUSE_T_RETURN 0x0100 +#define SUA_CAUSE_T_REFUSAL 0x0200 +#define SUA_CAUSE_T_RELEASE 0x0300 +#define SUA_CAUSE_T_RESET 0x0400 +#define SUA_CAUSE_T_ERROR 0x0500 -- To view, visit https://gerrit.osmocom.org/1805 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:48 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_types.h: Add 'struct sccp_data_unitdata_service' Message-ID: Review at https://gerrit.osmocom.org/1806 sccp_types.h: Add 'struct sccp_data_unitdata_service' We didn't have as struct for UDTS messages so far, let's change that. Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 --- M include/sccp/sccp_types.h 1 file changed, 20 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/06/1806/1 diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index 986de0d..e1c6612 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -400,6 +400,26 @@ uint8_t data[0]; } __attribute__((packed)); +struct sccp_data_unitdata_service { + /* mandantory */ + uint8_t type; + uint8_t return_cause; + + + /* variable */ + uint8_t variable_called; + uint8_t variable_calling; + uint8_t variable_data; + +#if VARIABLE + called party address + calling party address +#endif + + uint8_t data[0]; +} __attribute__((packed)); + + struct sccp_data_it { /* mandantory */ uint8_t type; -- To view, visit https://gerrit.osmocom.org/1806 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:48 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_types.h: Include stdint.h Message-ID: Review at https://gerrit.osmocom.org/1807 sccp_types.h: Include stdint.h We're using types like uint8_t, for whcih we need stdint.h Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad --- M include/sccp/sccp_types.h 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/07/1807/1 diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index e1c6612..e1dcfe7 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -24,6 +24,7 @@ #ifndef SCCP_TYPES_H #define SCCP_TYPES_H +#include #include /* Table 1/Q.713 - SCCP message types */ -- To view, visit https://gerrit.osmocom.org/1807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:48 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp/sccp.h: Add #include to linuxlist.h Message-ID: Review at https://gerrit.osmocom.org/1808 sccp/sccp.h: Add #include to linuxlist.h sccp.h is using 'struct llist_head' so it must include the associated linuxlist.h header. Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 --- M include/sccp/sccp.h 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/08/1808/1 diff --git a/include/sccp/sccp.h b/include/sccp/sccp.h index 36b424f..4293792 100644 --- a/include/sccp/sccp.h +++ b/include/sccp/sccp.h @@ -30,6 +30,8 @@ #include #include +#include + #include "sccp_types.h" struct msgb; -- To view, visit https://gerrit.osmocom.org/1808 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:49 +0000 Subject: [PATCH] libosmo-sccp[master]: Move xua_msg_add_sccp_addr() to xua_msg.h and export it Message-ID: Review at https://gerrit.osmocom.org/1809 Move xua_msg_add_sccp_addr() to xua_msg.h and export it Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 36 insertions(+), 36 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/09/1809/1 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 4c8fe83..5dc3894 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -24,6 +24,7 @@ #define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) struct msgb; +struct osmo_sccp_addr; struct xua_msg { struct xua_common_hdr hdr; @@ -60,3 +61,4 @@ int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/sua.c b/src/sua.c index 8bbaa58..cdc2cf0 100644 --- a/src/sua.c +++ b/src/sua.c @@ -117,42 +117,6 @@ /*********************************************************************** - * Message encoding helper functions - ***********************************************************************/ - -static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -{ - struct msgb *tmp = msgb_alloc(128, "SCCP Address"); - int rc; - - if (!tmp) - return -ENOMEM; - - msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ - msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ - - if (addr->presence & OSMO_SCCP_ADDR_T_GT) { - /* FIXME */ - } - if (addr->presence & OSMO_SCCP_ADDR_T_PC) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); - } - if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); - } - if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { - /* FIXME: IPv4 address */ - } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { - /* FIXME: IPv6 address */ - } - rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); - msgb_free(tmp); - - return rc; -} - - -/*********************************************************************** * SUA Link and Connection handling ***********************************************************************/ diff --git a/src/xua_msg.c b/src/xua_msg.c index 21d37ad..3d335d9 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include @@ -25,6 +27,7 @@ #include #include +#include static void *tall_xua; int DXUA = -1; @@ -235,3 +238,34 @@ rc = ntohl(*(uint32_t *)part->dat); return rc; } + +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) +{ + struct msgb *tmp = msgb_alloc(128, "SCCP Address"); + int rc; + + if (!tmp) + return -ENOMEM; + + msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ + msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ + + if (addr->presence & OSMO_SCCP_ADDR_T_GT) { + /* FIXME */ + } + if (addr->presence & OSMO_SCCP_ADDR_T_PC) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); + } + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); + } + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { + /* FIXME: IPv4 address */ + } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { + /* FIXME: IPv6 address */ + } + rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); + msgb_free(tmp); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/1809 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:49 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers: Add osmo_sccp_{addr, gt}_dump() functions Message-ID: Review at https://gerrit.osmocom.org/1810 sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions They stringify a global title or SCCP address for human consumption Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 74 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/10/1810/1 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 3384630..968c500 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -37,3 +37,6 @@ int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt); +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index c6248de..1fc257c 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -20,6 +20,11 @@ */ #include +#include + +#include +#include +#include #include #include @@ -149,3 +154,69 @@ return rc; } + +static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (*comma == true) { + strcat(buf, ","); + } else + *comma = true; + vsprintf(buf+strlen(buf), fmt, ap); + va_end(ap); +} + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + if (gt->gti == OSMO_SCCP_GTI_NO_GT) { + strcat(buf, "NONE"); + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_NAI_ONLY) { + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_TT_ONLY || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "TT=%u", gt->tt); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NPL=%u", gt->npi); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NAI=%u", gt->nai); + + append_to_buf(buf, &comma, "DIG=%s", gt->digits); + + return buf; +} + +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + append_to_buf(buf, &comma, "RI=7"); + + if (addr->presence & OSMO_SCCP_ADDR_T_PC) + append_to_buf(buf, &comma, "PC=%u", addr->pc); + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) + append_to_buf(buf, &comma, "SSN=%u", addr->ssn); + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) + append_to_buf(buf, &comma, "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, &comma, "GTI=%u", addr->gt.gti); + if (addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); + + return buf; +} -- To view, visit https://gerrit.osmocom.org/1810 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:09:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:09:49 +0000 Subject: [PATCH] libosmo-sccp[master]: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part Message-ID: Review at https://gerrit.osmocom.org/1811 Add xua_msg_part_get_u32() to get U32 value from xua_msg_part Sometimes one already has the xua_msg_part and thus can avoid the lookup that's done by xua_msg_get_u32(). Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 11 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/11/1811/1 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 5dc3894..2a6e3ae 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -60,5 +60,6 @@ int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/xua_msg.c b/src/xua_msg.c index 3d335d9..4a3e013 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -230,13 +231,18 @@ return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); } +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part) +{ + OSMO_ASSERT(part->len >= 4); + return ntohl(*(uint32_t *)part->dat); +} + uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) { struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; + if (!part) + return 0; + return xua_msg_part_get_u32(part); } int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -- To view, visit https://gerrit.osmocom.org/1811 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:40:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:40:57 +0000 Subject: libosmo-sccp[master]: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1811 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:41:27 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:41:27 +0000 Subject: libosmo-sccp[master]: sccp_helpers: Add osmo_sccp_{addr, gt}_dump() functions In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1810 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:41:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:41:35 +0000 Subject: libosmo-sccp[master]: Move xua_msg_add_sccp_addr() to xua_msg.h and export it In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1809 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:42:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:42:01 +0000 Subject: libosmo-sccp[master]: sccp_helpers: add convenience function for RANAP unitdata In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1802 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie96d78512b8e3907753272d75471b882365968c4 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:42:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:42:04 +0000 Subject: libosmo-sccp[master]: sccp_helpers: add osmo_ prefix to all functions In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1801 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I839c976f3ac722b955da18216de3df2eaa4c5af3 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:42:07 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:42:07 +0000 Subject: libosmo-sccp[master]: sccp_helpers: adjust .h include and copyright In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1800 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:44:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:44:48 +0000 Subject: libosmocore[master]: libosmocoding: migrate transcoding routines from OsmoBTS In-Reply-To: References: Message-ID: Patch Set 15: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1 Gerrit-PatchSet: 15 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:45:06 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:45:06 +0000 Subject: libosmocore[master]: tests/conv: separate test logic In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1627 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Idbdc7e19cb9b9a36cd1fccd621cd858e87530d98 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 03:45:39 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 03:45:39 +0000 Subject: libosmocore[master]: gsm0503.h: generate header automatically In-Reply-To: References: Message-ID: Patch Set 7: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1594 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I21caa4e433b2cc1861611e35350a9671da444c2a Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 09:38:19 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 13 Feb 2017 09:38:19 +0000 Subject: osmo-bts[master]: Fix typo in TCH/H interleaving table In-Reply-To: References: Message-ID: Patch Set 2: You've got to put the table from the spec inside-out: the interleaving cycle goes by k [0..228] but it's inside the table which is indexed by j and b. It's such a brain-dead way to describe things that I'm surprised we got only one typo :) -- To view, visit https://gerrit.osmocom.org/1793 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 09:38:30 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 13 Feb 2017 09:38:30 +0000 Subject: [MERGED] osmo-bts[master]: Fix typo in TCH/H interleaving table In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: Fix typo in TCH/H interleaving table ...................................................................... Fix typo in TCH/H interleaving table According to Table 4 in 3GPP TS 45.003 j=11, b=3 case corresponds to k=91 and not j=12 as was previously used. Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 --- M src/osmo-bts-trx/gsm0503_tables.c M tests/bursts/bursts_test.ok 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: Vadim Yanitskiy: Looks good to me, but someone else must approve Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/gsm0503_tables.c b/src/osmo-bts-trx/gsm0503_tables.c index 8d5fa0c..1109ff9 100644 --- a/src/osmo-bts-trx/gsm0503_tables.c +++ b/src/osmo-bts-trx/gsm0503_tables.c @@ -1673,7 +1673,7 @@ { 86 ,0 }, { 87 ,2 }, { 110,0 }, { 111,2 }, { 4 ,0 }, { 5 ,2 }, { 82 ,1 }, { 83 ,3 }, { 52 ,0 }, { 53 ,2 }, { 58 ,1 }, { 59 ,3 }, { 28 ,0 }, { 29 ,2 }, { 34 ,1 }, { 35 ,3 }, { 76 ,0 }, { 77 ,2 }, - { 10 ,1 }, { 12 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 }, + { 10 ,1 }, { 11 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 }, { 106,1 }, { 107,3 }, { 64 ,0 }, { 65 ,2 }, { 70 ,1 }, { 71 ,3 }, { 94 ,1 }, { 95 ,3 }, { 40 ,0 }, { 41 ,2 }, { 46 ,1 }, { 47 ,3 }, { 22 ,1 }, { 23 ,3 }, { 88 ,0 }, { 89 ,2 }, { 112,0 }, { 113,2 }, diff --git a/tests/bursts/bursts_test.ok b/tests/bursts/bursts_test.ok index 4136905..5030e4d 100644 --- a/tests/bursts/bursts_test.ok +++ b/tests/bursts/bursts_test.ok @@ -6,7 +6,7 @@ tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02 -tch_hr_decode: n_errors=11 n_bits_total=211 ber=0.05 +tch_hr_decode: n_errors=10 n_bits_total=211 ber=0.05 tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02 tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02 -- To view, visit https://gerrit.osmocom.org/1793 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iad3cf545b2f7e16276466cc37dd7a1e7858467e5 Gerrit-PatchSet: 2 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:11:49 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:11:49 +0000 Subject: [PATCH] python/osmo-python-tests[master]: vty: Close the vty sockets at the end of each test Message-ID: Review at https://gerrit.osmocom.org/1812 vty: Close the vty sockets at the end of each test In the OpenBSC VTY tests it seems no one is calling the command with close=True. So make sure the socket is released. Modify _close_socket to be idempotent. Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 --- M osmopy/obscvty.py M osmopy/osmotestvty.py 2 files changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/12/1812/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 2654f3d..3c9edb1 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -43,8 +43,9 @@ self.last_node = '' def _close_socket(self): - self.socket.close() - self.socket = None + if self.socket: + self.socket.close() + self.socket = None def _is_end(self, text, ends): """ diff --git a/osmopy/osmotestvty.py b/osmopy/osmotestvty.py index 8d9f3c4..9f8dd0a 100644 --- a/osmopy/osmotestvty.py +++ b/osmopy/osmotestvty.py @@ -48,6 +48,7 @@ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport) def tearDown(self): + self.vty._close_socket() self.vty = None osmoutil.end_proc(self.proc) -- To view, visit https://gerrit.osmocom.org/1812 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:13:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 13 Feb 2017 13:13:46 +0000 Subject: python/osmo-python-tests[master]: vty: Close the vty sockets at the end of each test In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 yay! farewell 'Broken Pipe'! -- To view, visit https://gerrit.osmocom.org/1812 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:14:27 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:14:27 +0000 Subject: libosmo-sccp[master]: migrate some generic XUA helpers from sua.c to xua_msg.c In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1803 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:14:50 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:14:50 +0000 Subject: libosmo-sccp[master]: xua_msg: Make DXUA available to other XUA code In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1804 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:16:21 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:16:21 +0000 Subject: libosmo-sccp[master]: sccp_types.h: Include stdint.h In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:17:04 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:17:04 +0000 Subject: libosmo-sccp[master]: sccp_types.h: Add 'struct sccp_data_unitdata_service' In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1806 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:17:20 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:17:20 +0000 Subject: libosmo-sccp[master]: sccp/sccp.h: Add #include to linuxlist.h In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1808 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:18:41 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:18:41 +0000 Subject: libosmo-sccp[master]: protocol/sua.h: Add #defines for CAUSE group values (from RFC) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1805 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:19:05 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:19:05 +0000 Subject: libosmo-sccp[master]: sccp_helpers: adjust .h include and copyright In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1800 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:30:45 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:30:45 +0000 Subject: python/osmo-python-tests[master]: vty: Close the vty sockets at the end of each test In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1812 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:31:04 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:31:04 +0000 Subject: python/osmo-python-tests[master]: vty: Close the vty sockets at the end of each test In-Reply-To: References: Message-ID: Patch Set 1: Maybe not that quickly but... at least it helps to free resources. -- To view, visit https://gerrit.osmocom.org/1812 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:31:08 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 13 Feb 2017 13:31:08 +0000 Subject: [MERGED] python/osmo-python-tests[master]: vty: Close the vty sockets at the end of each test In-Reply-To: References: Message-ID: Holger Freyther has submitted this change and it was merged. Change subject: vty: Close the vty sockets at the end of each test ...................................................................... vty: Close the vty sockets at the end of each test In the OpenBSC VTY tests it seems no one is calling the command with close=True. So make sure the socket is released. Modify _close_socket to be idempotent. Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 --- M osmopy/obscvty.py M osmopy/osmotestvty.py 2 files changed, 4 insertions(+), 2 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Holger Freyther: Verified diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 2654f3d..3c9edb1 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -43,8 +43,9 @@ self.last_node = '' def _close_socket(self): - self.socket.close() - self.socket = None + if self.socket: + self.socket.close() + self.socket = None def _is_end(self, text, ends): """ diff --git a/osmopy/osmotestvty.py b/osmopy/osmotestvty.py index 8d9f3c4..9f8dd0a 100644 --- a/osmopy/osmotestvty.py +++ b/osmopy/osmotestvty.py @@ -48,6 +48,7 @@ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport) def tearDown(self): + self.vty._close_socket() self.vty = None osmoutil.end_proc(self.proc) -- To view, visit https://gerrit.osmocom.org/1812 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:56:03 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:56:03 +0000 Subject: libosmo-sccp[master]: Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 Verified+1 we want to first import this, despite it not compiling -- To view, visit https://gerrit.osmocom.org/1798 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae0c58c5f1eb00a685de70add0d5257e4316c6d5 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:56:14 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:56:14 +0000 Subject: libosmo-sccp[master]: sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osm... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1799 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If8b09bb05297ebf663b4a04d3cc094a6a8087f53 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:57:33 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:57:33 +0000 Subject: [MERGED] libosmo-sccp[master]: Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first ...................................................................... Add sccp_helpers.[hc] moved from osmo-iuh, 1:1 at first Move here unchanged first, so we're able to see the modifications in diffs. Pending changes will follow in subsequent patches. Moved from osmo-iuh 3da8608b6ad014fc74536dbb49019704fd425b8c, which was before the rename of osmo_sua_link and osmo_sua_user to osmo_sccp_link and osmo_sccp_user, so this will not compile. Change-Id: Iae0c58c5f1eb00a685de70add0d5257e4316c6d5 --- M include/osmocom/sigtran/Makefile.am A include/osmocom/sigtran/sccp_helpers.h M src/Makefile.am A src/sccp_helpers.c 4 files changed, 172 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved; Verified diff --git a/include/osmocom/sigtran/Makefile.am b/include/osmocom/sigtran/Makefile.am index adb0997..e168256 100644 --- a/include/osmocom/sigtran/Makefile.am +++ b/include/osmocom/sigtran/Makefile.am @@ -1,4 +1,6 @@ -sigtran_HEADERS = m3ua_types.h xua_types.h xua_msg.h m2ua_types.h sccp_sap.h sua.h sigtran_sap.h +sigtran_HEADERS = m3ua_types.h xua_types.h xua_msg.h m2ua_types.h sccp_sap.h \ + sua.h sigtran_sap.h sccp_helpers.h + sigtrandir = $(includedir)/osmocom/sigtran sigtran_prot_HEADERS = protocol/sua.h diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h new file mode 100644 index 0000000..089d69a --- /dev/null +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -0,0 +1,33 @@ +#pragma once +#include +#include +#include +#include + +int sccp_tx_unitdata(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); + +int sccp_tx_unitdata_msg(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); + +void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); + +int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); + +int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); + +int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len); + +int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, + struct msgb *msg); diff --git a/src/Makefile.am b/src/Makefile.am index 238a840..26482a0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,6 +24,6 @@ # documentation before making any modification LIBVERSION=0:0:0 -libosmo_sigtran_la_SOURCES = sccp_sap.c sua.c xua_msg.c +libosmo_sigtran_la_SOURCES = sccp_sap.c sua.c xua_msg.c sccp_helpers.c libosmo_sigtran_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined -export-symbols-regex '^osmo_' libosmo_sigtran_la_LIBADD = $(LIBOSMOCORE_LIBS) $(LIBOSMONETIF_LIBS) $(LIBSCTP_LIBS) diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c new file mode 100644 index 0000000..cdb26e7 --- /dev/null +++ b/src/sccp_helpers.c @@ -0,0 +1,135 @@ +/* SCCP User SAP helper functions (move to libosmo-sigtran?) */ + +/* (C) 2015 by Harald Welte + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include + +#include "sccp_helpers.h" + +void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) +{ + addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; + addr->ssn = ssn; + addr->pc = pc; +} + +int sccp_tx_unitdata(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "sccp_tx_unitdata"); + struct osmo_scu_prim *prim; + struct osmo_scu_unitdata_param *param; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + param = &prim->u.unitdata; + sccp_make_addr_pc_ssn(¶m->calling_addr, 1, OSMO_SCCP_SSN_RANAP); + sccp_make_addr_pc_ssn(¶m->called_addr, 2, OSMO_SCCP_SSN_RANAP); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_REQUEST, msg); + + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + + return osmo_sua_user_link_down(link, &prim->oph); +} + +int sccp_tx_unitdata_msg(struct osmo_sua_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) +{ + int rc; + + rc = sccp_tx_unitdata(link, calling_addr, called_addr, + msg->data, msgb_length(msg)); + msgb_free(msg); + + return rc; +} + +int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "sccp_tx_conn_req"); + struct osmo_scu_prim *prim; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, + OSMO_SCU_PRIM_N_CONNECT, + PRIM_OP_REQUEST, msg); + sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, OSMO_SCCP_SSN_RANAP); + prim->u.connect.sccp_class = 2; + prim->u.connect.conn_id = conn_id; + + if (data && len) { + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + } + + return osmo_sua_user_link_down(link, &prim->oph); +} + +int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) +{ + int rc; + + rc = sccp_tx_conn_req(link, conn_id, calling_addr, called_addr, + msg->data, msgb_length(msg)); + msgb_free(msg); + + return rc; +} + +int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len) +{ + struct msgb *msg = msgb_alloc(1024, "sccp_tx_data"); + struct osmo_scu_prim *prim; + + prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); + osmo_prim_init(&prim->oph, SCCP_SAP_USER, + OSMO_SCU_PRIM_N_DATA, + PRIM_OP_REQUEST, msg); + prim->u.data.conn_id = conn_id; + + msg->l2h = msgb_put(msg, len); + memcpy(msg->l2h, data, len); + + return osmo_sua_user_link_down(link, &prim->oph); +} + +int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, + struct msgb *msg) +{ + int rc; + + rc = sccp_tx_data(link, conn_id, msg->data, msgb_length(msg)); + msgb_free(msg); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/1798 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iae0c58c5f1eb00a685de70add0d5257e4316c6d5 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:57:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:57:46 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osm... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osmo_sccp_link ...................................................................... sccp_helpers.h/.c: fix: apply rename of osmo_sua_link to osmo_sccp_link Change-Id: If8b09bb05297ebf663b4a04d3cc094a6a8087f53 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 12 insertions(+), 12 deletions(-) Approvals: Harald Welte: Looks good to me, approved; Verified diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 089d69a..01f7af6 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -4,30 +4,30 @@ #include #include -int sccp_tx_unitdata(struct osmo_sua_link *link, +int sccp_tx_unitdata(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len); -int sccp_tx_unitdata_msg(struct osmo_sua_link *link, +int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg); void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); -int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len); -int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg); -int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, uint8_t *data, unsigned int len); -int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index cdb26e7..d450627 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -32,7 +32,7 @@ addr->pc = pc; } -int sccp_tx_unitdata(struct osmo_sua_link *link, +int sccp_tx_unitdata(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len) @@ -53,7 +53,7 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_unitdata_msg(struct osmo_sua_link *link, +int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg) @@ -67,7 +67,7 @@ return rc; } -int sccp_tx_conn_req(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, uint8_t *data, unsigned int len) @@ -91,7 +91,7 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_conn_req_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg) @@ -105,7 +105,7 @@ return rc; } -int sccp_tx_data(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_data"); @@ -123,7 +123,7 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_data_msg(struct osmo_sua_link *link, uint32_t conn_id, +int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg) { int rc; -- To view, visit https://gerrit.osmocom.org/1799 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If8b09bb05297ebf663b4a04d3cc094a6a8087f53 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:57:54 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:57:54 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_helpers: adjust .h include and copyright In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_helpers: adjust .h include and copyright ...................................................................... sccp_helpers: adjust .h include and copyright Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc --- M src/sccp_helpers.c 1 file changed, 3 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index d450627..98c93f3 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -1,6 +1,7 @@ -/* SCCP User SAP helper functions (move to libosmo-sigtran?) */ +/* SCCP User SAP helper functions */ /* (C) 2015 by Harald Welte + * (C) 2016 by sysmocom s.m.f.c. GmbH * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -22,8 +23,7 @@ #include #include - -#include "sccp_helpers.h" +#include void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) { -- To view, visit https://gerrit.osmocom.org/1800 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id2d9a6c3e9b0928d245580895c78aa7355627adc Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:58:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:58:02 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_helpers: add osmo_ prefix to all functions In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_helpers: add osmo_ prefix to all functions ...................................................................... sccp_helpers: add osmo_ prefix to all functions Change-Id: I839c976f3ac722b955da18216de3df2eaa4c5af3 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 52 insertions(+), 50 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 01f7af6..d5916a9 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -4,30 +4,31 @@ #include #include -int sccp_tx_unitdata(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len); +int osmo_sccp_tx_unitdata(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); -int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg); +int osmo_sccp_tx_unitdata_msg(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); -void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); +void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, + uint32_t pc, uint32_t ssn); -int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len); +int osmo_sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len); -int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg); +int osmo_sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg); -int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, - uint8_t *data, unsigned int len); +int osmo_sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len); -int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, - struct msgb *msg); +int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, + struct msgb *msg); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index 98c93f3..ce9cd06 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -25,17 +25,17 @@ #include #include -void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) +void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn) { addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; addr->ssn = ssn; addr->pc = pc; } -int sccp_tx_unitdata(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len) +int osmo_sccp_tx_unitdata(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_unitdata"); struct osmo_scu_prim *prim; @@ -43,8 +43,8 @@ prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim)); param = &prim->u.unitdata; - sccp_make_addr_pc_ssn(¶m->calling_addr, 1, OSMO_SCCP_SSN_RANAP); - sccp_make_addr_pc_ssn(¶m->called_addr, 2, OSMO_SCCP_SSN_RANAP); + memcpy(¶m->calling_addr, calling_addr, sizeof(*calling_addr)); + memcpy(¶m->called_addr, called_addr, sizeof(*called_addr)); osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_REQUEST, msg); msg->l2h = msgb_put(msg, len); @@ -53,24 +53,24 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_unitdata_msg(struct osmo_sccp_link *link, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg) +int osmo_sccp_tx_unitdata_msg(struct osmo_sccp_link *link, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) { int rc; - rc = sccp_tx_unitdata(link, calling_addr, called_addr, - msg->data, msgb_length(msg)); + rc = osmo_sccp_tx_unitdata(link, calling_addr, called_addr, + msg->data, msgb_length(msg)); msgb_free(msg); return rc; } -int sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - uint8_t *data, unsigned int len) +int osmo_sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_conn_req"); struct osmo_scu_prim *prim; @@ -79,7 +79,8 @@ osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_REQUEST, msg); - sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, OSMO_SCCP_SSN_RANAP); + osmo_sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, + OSMO_SCCP_SSN_RANAP); prim->u.connect.sccp_class = 2; prim->u.connect.conn_id = conn_id; @@ -91,22 +92,22 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, - const struct osmo_sccp_addr *calling_addr, - const struct osmo_sccp_addr *called_addr, - struct msgb *msg) +int osmo_sccp_tx_conn_req_msg(struct osmo_sccp_link *link, uint32_t conn_id, + const struct osmo_sccp_addr *calling_addr, + const struct osmo_sccp_addr *called_addr, + struct msgb *msg) { int rc; - rc = sccp_tx_conn_req(link, conn_id, calling_addr, called_addr, - msg->data, msgb_length(msg)); + rc = osmo_sccp_tx_conn_req(link, conn_id, calling_addr, called_addr, + msg->data, msgb_length(msg)); msgb_free(msg); return rc; } -int sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, - uint8_t *data, unsigned int len) +int osmo_sccp_tx_data(struct osmo_sccp_link *link, uint32_t conn_id, + uint8_t *data, unsigned int len) { struct msgb *msg = msgb_alloc(1024, "sccp_tx_data"); struct osmo_scu_prim *prim; @@ -123,12 +124,12 @@ return osmo_sua_user_link_down(link, &prim->oph); } -int sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, - struct msgb *msg) +int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, + struct msgb *msg) { int rc; - rc = sccp_tx_data(link, conn_id, msg->data, msgb_length(msg)); + rc = osmo_sccp_tx_data(link, conn_id, msg->data, msgb_length(msg)); msgb_free(msg); return rc; -- To view, visit https://gerrit.osmocom.org/1801 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I839c976f3ac722b955da18216de3df2eaa4c5af3 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 13:58:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 13:58:13 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_helpers: add convenience function for RANAP unitdata In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_helpers: add convenience function for RANAP unitdata ...................................................................... sccp_helpers: add convenience function for RANAP unitdata Change-Id: Ie96d78512b8e3907753272d75471b882365968c4 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 20 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index d5916a9..3384630 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -17,6 +17,11 @@ void osmo_sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn); +int osmo_sccp_tx_unitdata_ranap(struct osmo_sccp_link *link, + uint32_t src_point_code, + uint32_t dst_point_code, + uint8_t *data, unsigned int len); + int osmo_sccp_tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index ce9cd06..c6248de 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -53,6 +53,21 @@ return osmo_sua_user_link_down(link, &prim->oph); } +int osmo_sccp_tx_unitdata_ranap(struct osmo_sccp_link *link, + uint32_t src_point_code, + uint32_t dst_point_code, + uint8_t *data, unsigned int len) +{ + struct osmo_sccp_addr calling_addr; + struct osmo_sccp_addr called_addr; + osmo_sccp_make_addr_pc_ssn(&calling_addr, src_point_code, + OSMO_SCCP_SSN_RANAP); + osmo_sccp_make_addr_pc_ssn(&called_addr, dst_point_code, + OSMO_SCCP_SSN_RANAP); + return osmo_sccp_tx_unitdata(link, &calling_addr, &called_addr, + data, len); +} + int osmo_sccp_tx_unitdata_msg(struct osmo_sccp_link *link, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, -- To view, visit https://gerrit.osmocom.org/1802 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie96d78512b8e3907753272d75471b882365968c4 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp/sccp.h: Add #include to linuxlist.h In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1808 to look at the new patch set (#2). sccp/sccp.h: Add #include to linuxlist.h sccp.h is using 'struct llist_head' so it must include the associated linuxlist.h header. Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 --- M include/sccp/sccp.h 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/08/1808/2 diff --git a/include/sccp/sccp.h b/include/sccp/sccp.h index 36b424f..4293792 100644 --- a/include/sccp/sccp.h +++ b/include/sccp/sccp.h @@ -30,6 +30,8 @@ #include #include +#include + #include "sccp_types.h" struct msgb; -- To view, visit https://gerrit.osmocom.org/1808 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: Move xua_msg_add_sccp_addr() to xua_msg.h and export it In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1809 to look at the new patch set (#2). Move xua_msg_add_sccp_addr() to xua_msg.h and export it Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 36 insertions(+), 36 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/09/1809/2 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 4c8fe83..5dc3894 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -24,6 +24,7 @@ #define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) struct msgb; +struct osmo_sccp_addr; struct xua_msg { struct xua_common_hdr hdr; @@ -60,3 +61,4 @@ int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/sua.c b/src/sua.c index 8bbaa58..cdc2cf0 100644 --- a/src/sua.c +++ b/src/sua.c @@ -117,42 +117,6 @@ /*********************************************************************** - * Message encoding helper functions - ***********************************************************************/ - -static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -{ - struct msgb *tmp = msgb_alloc(128, "SCCP Address"); - int rc; - - if (!tmp) - return -ENOMEM; - - msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ - msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ - - if (addr->presence & OSMO_SCCP_ADDR_T_GT) { - /* FIXME */ - } - if (addr->presence & OSMO_SCCP_ADDR_T_PC) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); - } - if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); - } - if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { - /* FIXME: IPv4 address */ - } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { - /* FIXME: IPv6 address */ - } - rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); - msgb_free(tmp); - - return rc; -} - - -/*********************************************************************** * SUA Link and Connection handling ***********************************************************************/ diff --git a/src/xua_msg.c b/src/xua_msg.c index 21d37ad..3d335d9 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include @@ -25,6 +27,7 @@ #include #include +#include static void *tall_xua; int DXUA = -1; @@ -235,3 +238,34 @@ rc = ntohl(*(uint32_t *)part->dat); return rc; } + +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) +{ + struct msgb *tmp = msgb_alloc(128, "SCCP Address"); + int rc; + + if (!tmp) + return -ENOMEM; + + msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ + msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ + + if (addr->presence & OSMO_SCCP_ADDR_T_GT) { + /* FIXME */ + } + if (addr->presence & OSMO_SCCP_ADDR_T_PC) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); + } + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); + } + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { + /* FIXME: IPv4 address */ + } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { + /* FIXME: IPv6 address */ + } + rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); + msgb_free(tmp); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/1809 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers: Add osmo_sccp_{addr, gt}_dump() functions In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1810 to look at the new patch set (#2). sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions They stringify a global title or SCCP address for human consumption Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 74 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/10/1810/2 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 3384630..968c500 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -37,3 +37,6 @@ int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt); +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index c6248de..1fc257c 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -20,6 +20,11 @@ */ #include +#include + +#include +#include +#include #include #include @@ -149,3 +154,69 @@ return rc; } + +static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (*comma == true) { + strcat(buf, ","); + } else + *comma = true; + vsprintf(buf+strlen(buf), fmt, ap); + va_end(ap); +} + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + if (gt->gti == OSMO_SCCP_GTI_NO_GT) { + strcat(buf, "NONE"); + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_NAI_ONLY) { + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_TT_ONLY || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "TT=%u", gt->tt); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NPL=%u", gt->npi); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NAI=%u", gt->nai); + + append_to_buf(buf, &comma, "DIG=%s", gt->digits); + + return buf; +} + +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + append_to_buf(buf, &comma, "RI=7"); + + if (addr->presence & OSMO_SCCP_ADDR_T_PC) + append_to_buf(buf, &comma, "PC=%u", addr->pc); + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) + append_to_buf(buf, &comma, "SSN=%u", addr->ssn); + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) + append_to_buf(buf, &comma, "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, &comma, "GTI=%u", addr->gt.gti); + if (addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); + + return buf; +} -- To view, visit https://gerrit.osmocom.org/1810 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1811 to look at the new patch set (#2). Add xua_msg_part_get_u32() to get U32 value from xua_msg_part Sometimes one already has the xua_msg_part and thus can avoid the lookup that's done by xua_msg_get_u32(). Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 11 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/11/1811/2 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 5dc3894..2a6e3ae 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -60,5 +60,6 @@ int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/xua_msg.c b/src/xua_msg.c index 3d335d9..4a3e013 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -230,13 +231,18 @@ return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); } +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part) +{ + OSMO_ASSERT(part->len >= 4); + return ntohl(*(uint32_t *)part->dat); +} + uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) { struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; + if (!part) + return 0; + return xua_msg_part_get_u32(part); } int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -- To view, visit https://gerrit.osmocom.org/1811 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: migrate some generic XUA helpers from sua.c to xua_msg.c In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1803 to look at the new patch set (#2). migrate some generic XUA helpers from sua.c to xua_msg.c Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 60 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/03/1803/2 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 9cc8632..bb9486a 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -21,6 +21,8 @@ #include +#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) + struct msgb; struct xua_msg { @@ -51,3 +53,8 @@ struct msgb *xua_to_msg(const int version, struct xua_msg *msg); void xua_set_log_area(int log_area); + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); diff --git a/src/sua.c b/src/sua.c index 39afef0..8bbaa58 100644 --- a/src/sua.c +++ b/src/sua.c @@ -120,56 +120,6 @@ * Message encoding helper functions ***********************************************************************/ -#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) - -static int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) -{ - uint8_t *cur; - unsigned int rest; - unsigned int tlv_len = 4 + len + (4 - (len % 4)); - - if (msgb_tailroom(msg) < tlv_len) - return -ENOMEM; - - /* tag */ - msgb_put_u16(msg, tag); - /* length */ - msgb_put_u16(msg, len + 4); - /* value */ - cur = msgb_put(msg, len); - memcpy(cur, data, len); - /* padding */ - rest = (4 - (len % 4)) & 0x3; - if (rest > 0) { - cur = msgb_put(msg, rest); - memset(cur, 0, rest); - } - - return 0; -} - -static int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) -{ - uint32_t val_n = htonl(val); - - return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); -} - -static int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) -{ - uint32_t val_n = htonl(val); - return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); -} - -static uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) -{ - struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; -} - static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) { struct msgb *tmp = msgb_alloc(128, "SCCP Address"); diff --git a/src/xua_msg.c b/src/xua_msg.c index 0ced1f9..67dd6e2 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -182,3 +182,56 @@ { DXUA = log_area; } + + +/*********************************************************************** + * Message encoding helper functions + ***********************************************************************/ + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) +{ + uint8_t *cur; + unsigned int rest; + unsigned int tlv_len = 4 + len + (4 - (len % 4)); + + if (msgb_tailroom(msg) < tlv_len) + return -ENOMEM; + + /* tag */ + msgb_put_u16(msg, tag); + /* length */ + msgb_put_u16(msg, len + 4); + /* value */ + cur = msgb_put(msg, len); + memcpy(cur, data, len); + /* padding */ + rest = (4 - (len % 4)) & 0x3; + if (rest > 0) { + cur = msgb_put(msg, rest); + memset(cur, 0, rest); + } + + return 0; +} + +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) +{ + uint32_t val_n = htonl(val); + + return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); +} + +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) +{ + uint32_t val_n = htonl(val); + return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); +} + +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) +{ + struct xua_msg_part *part = xua_msg_find_tag(xua, iei); + uint32_t rc = 0; + if (part) + rc = ntohl(*(uint32_t *)part->dat); + return rc; +} -- To view, visit https://gerrit.osmocom.org/1803 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: xua_msg: Make DXUA available to other XUA code In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1804 to look at the new patch set (#2). xua_msg: Make DXUA available to other XUA code Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/04/1804/2 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index bb9486a..4c8fe83 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -42,6 +42,8 @@ }; +extern int DXUA; + struct xua_msg *xua_msg_alloc(void); void xua_msg_free(struct xua_msg *msg); diff --git a/src/xua_msg.c b/src/xua_msg.c index 67dd6e2..21d37ad 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -27,7 +27,7 @@ #include static void *tall_xua; -static int DXUA = -1; +int DXUA = -1; struct xua_msg *xua_msg_alloc(void) { -- To view, visit https://gerrit.osmocom.org/1804 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: protocol/sua.h: Add #defines for CAUSE group values (from RFC) In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1805 to look at the new patch set (#2). protocol/sua.h: Add #defines for CAUSE group values (from RFC) Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb --- M include/osmocom/sigtran/protocol/sua.h 1 file changed, 7 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/05/1805/2 diff --git a/include/osmocom/sigtran/protocol/sua.h b/include/osmocom/sigtran/protocol/sua.h index d61c85a..d191368 100644 --- a/include/osmocom/sigtran/protocol/sua.h +++ b/include/osmocom/sigtran/protocol/sua.h @@ -118,3 +118,10 @@ #define SUA_RI_SSN_PC 2 #define SUA_RI_HOST 3 #define SUA_RI_SSN_IP 4 + +#define SUA_CAUSE_T_MASK 0xff00 +#define SUA_CAUSE_T_RETURN 0x0100 +#define SUA_CAUSE_T_REFUSAL 0x0200 +#define SUA_CAUSE_T_RELEASE 0x0300 +#define SUA_CAUSE_T_RESET 0x0400 +#define SUA_CAUSE_T_ERROR 0x0500 -- To view, visit https://gerrit.osmocom.org/1805 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_types.h: Add 'struct sccp_data_unitdata_service' In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1806 to look at the new patch set (#2). sccp_types.h: Add 'struct sccp_data_unitdata_service' We didn't have as struct for UDTS messages so far, let's change that. Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 --- M include/sccp/sccp_types.h 1 file changed, 20 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/06/1806/2 diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index 986de0d..e1c6612 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -400,6 +400,26 @@ uint8_t data[0]; } __attribute__((packed)); +struct sccp_data_unitdata_service { + /* mandantory */ + uint8_t type; + uint8_t return_cause; + + + /* variable */ + uint8_t variable_called; + uint8_t variable_calling; + uint8_t variable_data; + +#if VARIABLE + called party address + calling party address +#endif + + uint8_t data[0]; +} __attribute__((packed)); + + struct sccp_data_it { /* mandantory */ uint8_t type; -- To view, visit https://gerrit.osmocom.org/1806 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:03:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:03:46 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_types.h: Include stdint.h In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1807 to look at the new patch set (#2). sccp_types.h: Include stdint.h We're using types like uint8_t, for whcih we need stdint.h Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad --- M include/sccp/sccp_types.h 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/07/1807/2 diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index e1c6612..e1dcfe7 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -24,6 +24,7 @@ #ifndef SCCP_TYPES_H #define SCCP_TYPES_H +#include #include /* Table 1/Q.713 - SCCP message types */ -- To view, visit https://gerrit.osmocom.org/1807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad Gerrit-PatchSet: 2 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:09:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:09:56 +0000 Subject: [PATCH] libosmo-sccp[master]: Move xua_msg_add_sccp_addr() to xua_msg.h and export it In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1809 to look at the new patch set (#3). Move xua_msg_add_sccp_addr() to xua_msg.h and export it Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 35 insertions(+), 36 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/09/1809/3 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 4c8fe83..5dc3894 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -24,6 +24,7 @@ #define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) struct msgb; +struct osmo_sccp_addr; struct xua_msg { struct xua_common_hdr hdr; @@ -60,3 +61,4 @@ int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/sua.c b/src/sua.c index 8bbaa58..cdc2cf0 100644 --- a/src/sua.c +++ b/src/sua.c @@ -117,42 +117,6 @@ /*********************************************************************** - * Message encoding helper functions - ***********************************************************************/ - -static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -{ - struct msgb *tmp = msgb_alloc(128, "SCCP Address"); - int rc; - - if (!tmp) - return -ENOMEM; - - msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ - msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ - - if (addr->presence & OSMO_SCCP_ADDR_T_GT) { - /* FIXME */ - } - if (addr->presence & OSMO_SCCP_ADDR_T_PC) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); - } - if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); - } - if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { - /* FIXME: IPv4 address */ - } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { - /* FIXME: IPv6 address */ - } - rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); - msgb_free(tmp); - - return rc; -} - - -/*********************************************************************** * SUA Link and Connection handling ***********************************************************************/ diff --git a/src/xua_msg.c b/src/xua_msg.c index 8610621..3d335d9 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include @@ -236,3 +238,34 @@ rc = ntohl(*(uint32_t *)part->dat); return rc; } + +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) +{ + struct msgb *tmp = msgb_alloc(128, "SCCP Address"); + int rc; + + if (!tmp) + return -ENOMEM; + + msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ + msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ + + if (addr->presence & OSMO_SCCP_ADDR_T_GT) { + /* FIXME */ + } + if (addr->presence & OSMO_SCCP_ADDR_T_PC) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); + } + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); + } + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { + /* FIXME: IPv4 address */ + } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { + /* FIXME: IPv6 address */ + } + rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); + msgb_free(tmp); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/1809 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:09:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:09:56 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_helpers: Add osmo_sccp_{addr, gt}_dump() functions In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1810 to look at the new patch set (#3). sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions They stringify a global title or SCCP address for human consumption Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 74 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/10/1810/3 diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 3384630..968c500 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -37,3 +37,6 @@ int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt); +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index c6248de..1fc257c 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -20,6 +20,11 @@ */ #include +#include + +#include +#include +#include #include #include @@ -149,3 +154,69 @@ return rc; } + +static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (*comma == true) { + strcat(buf, ","); + } else + *comma = true; + vsprintf(buf+strlen(buf), fmt, ap); + va_end(ap); +} + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + if (gt->gti == OSMO_SCCP_GTI_NO_GT) { + strcat(buf, "NONE"); + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_NAI_ONLY) { + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_TT_ONLY || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "TT=%u", gt->tt); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NPL=%u", gt->npi); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NAI=%u", gt->nai); + + append_to_buf(buf, &comma, "DIG=%s", gt->digits); + + return buf; +} + +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + append_to_buf(buf, &comma, "RI=7"); + + if (addr->presence & OSMO_SCCP_ADDR_T_PC) + append_to_buf(buf, &comma, "PC=%u", addr->pc); + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) + append_to_buf(buf, &comma, "SSN=%u", addr->ssn); + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) + append_to_buf(buf, &comma, "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, &comma, "GTI=%u", addr->gt.gti); + if (addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); + + return buf; +} -- To view, visit https://gerrit.osmocom.org/1810 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:09:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:09:56 +0000 Subject: [PATCH] libosmo-sccp[master]: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1811 to look at the new patch set (#3). Add xua_msg_part_get_u32() to get U32 value from xua_msg_part Sometimes one already has the xua_msg_part and thus can avoid the lookup that's done by xua_msg_get_u32(). Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 11 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/11/1811/3 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 5dc3894..2a6e3ae 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -60,5 +60,6 @@ int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/xua_msg.c b/src/xua_msg.c index 3d335d9..4a3e013 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -230,13 +231,18 @@ return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); } +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part) +{ + OSMO_ASSERT(part->len >= 4); + return ntohl(*(uint32_t *)part->dat); +} + uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) { struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; + if (!part) + return 0; + return xua_msg_part_get_u32(part); } int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -- To view, visit https://gerrit.osmocom.org/1811 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:09:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:09:56 +0000 Subject: [PATCH] libosmo-sccp[master]: migrate some generic XUA helpers from sua.c to xua_msg.c In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1803 to look at the new patch set (#3). migrate some generic XUA helpers from sua.c to xua_msg.c Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 61 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/03/1803/3 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 9cc8632..bb9486a 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -21,6 +21,8 @@ #include +#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) + struct msgb; struct xua_msg { @@ -51,3 +53,8 @@ struct msgb *xua_to_msg(const int version, struct xua_msg *msg); void xua_set_log_area(int log_area); + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); diff --git a/src/sua.c b/src/sua.c index 39afef0..8bbaa58 100644 --- a/src/sua.c +++ b/src/sua.c @@ -120,56 +120,6 @@ * Message encoding helper functions ***********************************************************************/ -#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) - -static int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) -{ - uint8_t *cur; - unsigned int rest; - unsigned int tlv_len = 4 + len + (4 - (len % 4)); - - if (msgb_tailroom(msg) < tlv_len) - return -ENOMEM; - - /* tag */ - msgb_put_u16(msg, tag); - /* length */ - msgb_put_u16(msg, len + 4); - /* value */ - cur = msgb_put(msg, len); - memcpy(cur, data, len); - /* padding */ - rest = (4 - (len % 4)) & 0x3; - if (rest > 0) { - cur = msgb_put(msg, rest); - memset(cur, 0, rest); - } - - return 0; -} - -static int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) -{ - uint32_t val_n = htonl(val); - - return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); -} - -static int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) -{ - uint32_t val_n = htonl(val); - return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); -} - -static uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) -{ - struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; -} - static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) { struct msgb *tmp = msgb_alloc(128, "SCCP Address"); diff --git a/src/xua_msg.c b/src/xua_msg.c index 0ced1f9..9084513 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -25,6 +25,7 @@ #include #include +#include static void *tall_xua; static int DXUA = -1; @@ -182,3 +183,56 @@ { DXUA = log_area; } + + +/*********************************************************************** + * Message encoding helper functions + ***********************************************************************/ + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) +{ + uint8_t *cur; + unsigned int rest; + unsigned int tlv_len = 4 + len + (4 - (len % 4)); + + if (msgb_tailroom(msg) < tlv_len) + return -ENOMEM; + + /* tag */ + msgb_put_u16(msg, tag); + /* length */ + msgb_put_u16(msg, len + 4); + /* value */ + cur = msgb_put(msg, len); + memcpy(cur, data, len); + /* padding */ + rest = (4 - (len % 4)) & 0x3; + if (rest > 0) { + cur = msgb_put(msg, rest); + memset(cur, 0, rest); + } + + return 0; +} + +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) +{ + uint32_t val_n = htonl(val); + + return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); +} + +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) +{ + uint32_t val_n = htonl(val); + return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); +} + +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) +{ + struct xua_msg_part *part = xua_msg_find_tag(xua, iei); + uint32_t rc = 0; + if (part) + rc = ntohl(*(uint32_t *)part->dat); + return rc; +} -- To view, visit https://gerrit.osmocom.org/1803 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:11:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:11:36 +0000 Subject: libosmo-sccp[master]: migrate some generic XUA helpers from sua.c to xua_msg.c In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1803 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:36 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_types.h: Include stdint.h In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_types.h: Include stdint.h ...................................................................... sccp_types.h: Include stdint.h We're using types like uint8_t, for whcih we need stdint.h Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad --- M include/sccp/sccp_types.h 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index e1c6612..e1dcfe7 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -24,6 +24,7 @@ #ifndef SCCP_TYPES_H #define SCCP_TYPES_H +#include #include /* Table 1/Q.713 - SCCP message types */ -- To view, visit https://gerrit.osmocom.org/1807 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I67a3b94c866e05be32b99566d6f97fbc8a2accad Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:37 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_types.h: Add 'struct sccp_data_unitdata_service' In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_types.h: Add 'struct sccp_data_unitdata_service' ...................................................................... sccp_types.h: Add 'struct sccp_data_unitdata_service' We didn't have as struct for UDTS messages so far, let's change that. Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 --- M include/sccp/sccp_types.h 1 file changed, 20 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index 986de0d..e1c6612 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -400,6 +400,26 @@ uint8_t data[0]; } __attribute__((packed)); +struct sccp_data_unitdata_service { + /* mandantory */ + uint8_t type; + uint8_t return_cause; + + + /* variable */ + uint8_t variable_called; + uint8_t variable_calling; + uint8_t variable_data; + +#if VARIABLE + called party address + calling party address +#endif + + uint8_t data[0]; +} __attribute__((packed)); + + struct sccp_data_it { /* mandantory */ uint8_t type; -- To view, visit https://gerrit.osmocom.org/1806 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9cbd3980fd95d5af6f0fc807ede34aa6b0f64ea7 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:37 +0000 Subject: [MERGED] libosmo-sccp[master]: protocol/sua.h: Add #defines for CAUSE group values (from RFC) In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: protocol/sua.h: Add #defines for CAUSE group values (from RFC) ...................................................................... protocol/sua.h: Add #defines for CAUSE group values (from RFC) Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb --- M include/osmocom/sigtran/protocol/sua.h 1 file changed, 7 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/include/osmocom/sigtran/protocol/sua.h b/include/osmocom/sigtran/protocol/sua.h index d61c85a..d191368 100644 --- a/include/osmocom/sigtran/protocol/sua.h +++ b/include/osmocom/sigtran/protocol/sua.h @@ -118,3 +118,10 @@ #define SUA_RI_SSN_PC 2 #define SUA_RI_HOST 3 #define SUA_RI_SSN_IP 4 + +#define SUA_CAUSE_T_MASK 0xff00 +#define SUA_CAUSE_T_RETURN 0x0100 +#define SUA_CAUSE_T_REFUSAL 0x0200 +#define SUA_CAUSE_T_RELEASE 0x0300 +#define SUA_CAUSE_T_RESET 0x0400 +#define SUA_CAUSE_T_ERROR 0x0500 -- To view, visit https://gerrit.osmocom.org/1805 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5b0af77aab4ba03262c0ecd25a893f170ca9c4bb Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:37 +0000 Subject: [MERGED] libosmo-sccp[master]: xua_msg: Make DXUA available to other XUA code In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: xua_msg: Make DXUA available to other XUA code ...................................................................... xua_msg: Make DXUA available to other XUA code Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 3 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index bb9486a..4c8fe83 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -42,6 +42,8 @@ }; +extern int DXUA; + struct xua_msg *xua_msg_alloc(void); void xua_msg_free(struct xua_msg *msg); diff --git a/src/xua_msg.c b/src/xua_msg.c index 9084513..8610621 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -28,7 +28,7 @@ #include static void *tall_xua; -static int DXUA = -1; +int DXUA = -1; struct xua_msg *xua_msg_alloc(void) { -- To view, visit https://gerrit.osmocom.org/1804 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie5b6492ead2c523de3969134291b2c3f434f92a2 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:37 +0000 Subject: [MERGED] libosmo-sccp[master]: migrate some generic XUA helpers from sua.c to xua_msg.c In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: migrate some generic XUA helpers from sua.c to xua_msg.c ...................................................................... migrate some generic XUA helpers from sua.c to xua_msg.c Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 61 insertions(+), 50 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 9cc8632..bb9486a 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -21,6 +21,8 @@ #include +#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) + struct msgb; struct xua_msg { @@ -51,3 +53,8 @@ struct msgb *xua_to_msg(const int version, struct xua_msg *msg); void xua_set_log_area(int log_area); + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); diff --git a/src/sua.c b/src/sua.c index 39afef0..8bbaa58 100644 --- a/src/sua.c +++ b/src/sua.c @@ -120,56 +120,6 @@ * Message encoding helper functions ***********************************************************************/ -#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) - -static int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) -{ - uint8_t *cur; - unsigned int rest; - unsigned int tlv_len = 4 + len + (4 - (len % 4)); - - if (msgb_tailroom(msg) < tlv_len) - return -ENOMEM; - - /* tag */ - msgb_put_u16(msg, tag); - /* length */ - msgb_put_u16(msg, len + 4); - /* value */ - cur = msgb_put(msg, len); - memcpy(cur, data, len); - /* padding */ - rest = (4 - (len % 4)) & 0x3; - if (rest > 0) { - cur = msgb_put(msg, rest); - memset(cur, 0, rest); - } - - return 0; -} - -static int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) -{ - uint32_t val_n = htonl(val); - - return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); -} - -static int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) -{ - uint32_t val_n = htonl(val); - return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); -} - -static uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) -{ - struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; -} - static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) { struct msgb *tmp = msgb_alloc(128, "SCCP Address"); diff --git a/src/xua_msg.c b/src/xua_msg.c index 0ced1f9..9084513 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -25,6 +25,7 @@ #include #include +#include static void *tall_xua; static int DXUA = -1; @@ -182,3 +183,56 @@ { DXUA = log_area; } + + +/*********************************************************************** + * Message encoding helper functions + ***********************************************************************/ + +int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data) +{ + uint8_t *cur; + unsigned int rest; + unsigned int tlv_len = 4 + len + (4 - (len % 4)); + + if (msgb_tailroom(msg) < tlv_len) + return -ENOMEM; + + /* tag */ + msgb_put_u16(msg, tag); + /* length */ + msgb_put_u16(msg, len + 4); + /* value */ + cur = msgb_put(msg, len); + memcpy(cur, data, len); + /* padding */ + rest = (4 - (len % 4)) & 0x3; + if (rest > 0) { + cur = msgb_put(msg, rest); + memset(cur, 0, rest); + } + + return 0; +} + +int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val) +{ + uint32_t val_n = htonl(val); + + return msgb_t16l16vp_put(msg, tag, sizeof(val_n), (uint8_t *)&val_n); +} + +int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val) +{ + uint32_t val_n = htonl(val); + return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); +} + +uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) +{ + struct xua_msg_part *part = xua_msg_find_tag(xua, iei); + uint32_t rc = 0; + if (part) + rc = ntohl(*(uint32_t *)part->dat); + return rc; +} -- To view, visit https://gerrit.osmocom.org/1803 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:38 +0000 Subject: [MERGED] libosmo-sccp[master]: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add xua_msg_part_get_u32() to get U32 value from xua_msg_part ...................................................................... Add xua_msg_part_get_u32() to get U32 value from xua_msg_part Sometimes one already has the xua_msg_part and thus can avoid the lookup that's done by xua_msg_get_u32(). Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 11 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 5dc3894..2a6e3ae 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -60,5 +60,6 @@ int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data); int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/xua_msg.c b/src/xua_msg.c index 3d335d9..4a3e013 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -230,13 +231,18 @@ return xua_msg_add_data(xua, iei, sizeof(val_n), (uint8_t *) &val_n); } +uint32_t xua_msg_part_get_u32(struct xua_msg_part *part) +{ + OSMO_ASSERT(part->len >= 4); + return ntohl(*(uint32_t *)part->dat); +} + uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei) { struct xua_msg_part *part = xua_msg_find_tag(xua, iei); - uint32_t rc = 0; - if (part) - rc = ntohl(*(uint32_t *)part->dat); - return rc; + if (!part) + return 0; + return xua_msg_part_get_u32(part); } int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -- To view, visit https://gerrit.osmocom.org/1811 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie11c35f9528313d0b35786a361d853addd17364f Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:38 +0000 Subject: [MERGED] libosmo-sccp[master]: Move xua_msg_add_sccp_addr() to xua_msg.h and export it In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Move xua_msg_add_sccp_addr() to xua_msg.h and export it ...................................................................... Move xua_msg_add_sccp_addr() to xua_msg.h and export it Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 --- M include/osmocom/sigtran/xua_msg.h M src/sua.c M src/xua_msg.c 3 files changed, 35 insertions(+), 36 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 4c8fe83..5dc3894 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -24,6 +24,7 @@ #define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) }) struct msgb; +struct osmo_sccp_addr; struct xua_msg { struct xua_common_hdr hdr; @@ -60,3 +61,4 @@ int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val); int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); diff --git a/src/sua.c b/src/sua.c index 8bbaa58..cdc2cf0 100644 --- a/src/sua.c +++ b/src/sua.c @@ -117,42 +117,6 @@ /*********************************************************************** - * Message encoding helper functions - ***********************************************************************/ - -static int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) -{ - struct msgb *tmp = msgb_alloc(128, "SCCP Address"); - int rc; - - if (!tmp) - return -ENOMEM; - - msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ - msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ - - if (addr->presence & OSMO_SCCP_ADDR_T_GT) { - /* FIXME */ - } - if (addr->presence & OSMO_SCCP_ADDR_T_PC) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); - } - if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { - msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); - } - if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { - /* FIXME: IPv4 address */ - } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { - /* FIXME: IPv6 address */ - } - rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); - msgb_free(tmp); - - return rc; -} - - -/*********************************************************************** * SUA Link and Connection handling ***********************************************************************/ diff --git a/src/xua_msg.c b/src/xua_msg.c index 8610621..3d335d9 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -17,6 +17,8 @@ */ #include +#include +#include #include #include @@ -236,3 +238,34 @@ rc = ntohl(*(uint32_t *)part->dat); return rc; } + +int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr) +{ + struct msgb *tmp = msgb_alloc(128, "SCCP Address"); + int rc; + + if (!tmp) + return -ENOMEM; + + msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ + msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ + + if (addr->presence & OSMO_SCCP_ADDR_T_GT) { + /* FIXME */ + } + if (addr->presence & OSMO_SCCP_ADDR_T_PC) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_PC, addr->pc); + } + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { + msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); + } + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { + /* FIXME: IPv4 address */ + } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { + /* FIXME: IPv6 address */ + } + rc = xua_msg_add_data(xua, iei, msgb_length(tmp), tmp->data); + msgb_free(tmp); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/1809 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:38 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp_helpers: Add osmo_sccp_{addr, gt}_dump() functions In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions ...................................................................... sccp_helpers: Add osmo_sccp_{addr,gt}_dump() functions They stringify a global title or SCCP address for human consumption Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 --- M include/osmocom/sigtran/sccp_helpers.h M src/sccp_helpers.c 2 files changed, 74 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/sccp_helpers.h b/include/osmocom/sigtran/sccp_helpers.h index 3384630..968c500 100644 --- a/include/osmocom/sigtran/sccp_helpers.h +++ b/include/osmocom/sigtran/sccp_helpers.h @@ -37,3 +37,6 @@ int osmo_sccp_tx_data_msg(struct osmo_sccp_link *link, uint32_t conn_id, struct msgb *msg); + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt); +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr); diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index c6248de..1fc257c 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -20,6 +20,11 @@ */ #include +#include + +#include +#include +#include #include #include @@ -149,3 +154,69 @@ return rc; } + +static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (*comma == true) { + strcat(buf, ","); + } else + *comma = true; + vsprintf(buf+strlen(buf), fmt, ap); + va_end(ap); +} + +char *osmo_sccp_gt_dump(const struct osmo_sccp_gt *gt) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + if (gt->gti == OSMO_SCCP_GTI_NO_GT) { + strcat(buf, "NONE"); + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_NAI_ONLY) { + return buf; + } + if (gt->gti == OSMO_SCCP_GTI_TT_ONLY || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "TT=%u", gt->tt); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC || + gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NPL=%u", gt->npi); + + if (gt->gti == OSMO_SCCP_GTI_TT_NPL_ENC_NAI) + append_to_buf(buf, &comma, "NAI=%u", gt->nai); + + append_to_buf(buf, &comma, "DIG=%s", gt->digits); + + return buf; +} + +char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) +{ + static char buf[256]; + bool comma = false; + + buf[0] = '\0'; + + append_to_buf(buf, &comma, "RI=7"); + + if (addr->presence & OSMO_SCCP_ADDR_T_PC) + append_to_buf(buf, &comma, "PC=%u", addr->pc); + if (addr->presence & OSMO_SCCP_ADDR_T_SSN) + append_to_buf(buf, &comma, "SSN=%u", addr->ssn); + if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) + append_to_buf(buf, &comma, "IP=%s", inet_ntoa(addr->ip.v4)); + append_to_buf(buf, &comma, "GTI=%u", addr->gt.gti); + if (addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); + + return buf; +} -- To view, visit https://gerrit.osmocom.org/1810 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I630308aa4519c6e9a260419d37a376aac6a1ce28 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 14:36:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 14:36:38 +0000 Subject: [MERGED] libosmo-sccp[master]: sccp/sccp.h: Add #include to linuxlist.h In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sccp/sccp.h: Add #include to linuxlist.h ...................................................................... sccp/sccp.h: Add #include to linuxlist.h sccp.h is using 'struct llist_head' so it must include the associated linuxlist.h header. Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 --- M include/sccp/sccp.h 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/include/sccp/sccp.h b/include/sccp/sccp.h index 36b424f..4293792 100644 --- a/include/sccp/sccp.h +++ b/include/sccp/sccp.h @@ -30,6 +30,8 @@ #include #include +#include + #include "sccp_types.h" struct msgb; -- To view, visit https://gerrit.osmocom.org/1808 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1fc4c34e59c27dce9e8a73abc6e58073f091c978 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 16:06:33 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 13 Feb 2017 16:06:33 +0000 Subject: [PATCH] osmo-hlr[master]: Log error cause as a string Message-ID: Review at https://gerrit.osmocom.org/1813 Log error cause as a string Use gsm48_gmm_cause_names to log error cause instead of numerical code. Change-Id: I846d488ed163e137164976738e55674f0eaee190 --- M src/hlr.c 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/13/1813/1 diff --git a/src/hlr.c b/src/hlr.c index cfd86cc..2fa27c3 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -186,8 +186,9 @@ { struct osmo_gsup_message gsup; - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause=%u)\n", - luop->subscr.imsi, cause); + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); memset(&gsup, 0, sizeof(gsup)); gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR; -- To view, visit https://gerrit.osmocom.org/1813 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I846d488ed163e137164976738e55674f0eaee190 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 13 16:06:33 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 13 Feb 2017 16:06:33 +0000 Subject: [PATCH] osmo-hlr[master]: Move GSUP msg init into separate function Message-ID: Review at https://gerrit.osmocom.org/1814 Move GSUP msg init into separate function * move common copy-pasted code to initialize GSUP message into static function * use osmo_strlcpy() to copy imsi for added safety Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 --- M src/hlr.c 1 file changed, 12 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/14/1814/1 diff --git a/src/hlr.c b/src/hlr.c index 2fa27c3..275b99f 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -181,6 +181,15 @@ msg_out); } +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + osmo_strlcpy(out->imsi, lu->subscr.imsi, GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + /*! Transmit UPD_LOC_ERROR and destroy lu_operation */ void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) { @@ -190,10 +199,7 @@ luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, cause)); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR; - strncpy((char*)&gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)); - gsup.imsi[sizeof(gsup.imsi)-1] = '\0'; + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); gsup.cause = cause; _luop_tx_gsup(luop, &gsup); @@ -227,9 +233,7 @@ { struct osmo_gsup_message gsup; - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); //FIXME gsup.hlr_enc; _luop_tx_gsup(luop, &gsup); @@ -281,9 +285,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || luop->state == LU_S_CANCEL_ACK_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, luop->subscr.msisdn); -- To view, visit https://gerrit.osmocom.org/1814 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 13 16:08:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 13 Feb 2017 16:08:50 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 2: Arvind, do you have more facts/thoughts to confirm your -1? I would prefer not to drag this out any further, this issue has been lurking for long enough now -- unless you have valid reasons to veto this, of course. -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 17:05:18 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 13 Feb 2017 17:05:18 +0000 Subject: [PATCH] osmo-hlr[master]: Move GSUP msg init into separate function In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1814 to look at the new patch set (#2). Move GSUP msg init into separate function * move common copy-pasted code to initialize GSUP message into static function * use osmo_strlcpy() to copy imsi for added safety Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 --- M src/hlr.c 1 file changed, 15 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/14/1814/2 diff --git a/src/hlr.c b/src/hlr.c index 2fa27c3..206ddc1 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -181,6 +181,17 @@ msg_out); } +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + /*! Transmit UPD_LOC_ERROR and destroy lu_operation */ void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) { @@ -190,10 +201,7 @@ luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, cause)); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR; - strncpy((char*)&gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)); - gsup.imsi[sizeof(gsup.imsi)-1] = '\0'; + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); gsup.cause = cause; _luop_tx_gsup(luop, &gsup); @@ -227,9 +235,7 @@ { struct osmo_gsup_message gsup; - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); //FIXME gsup.hlr_enc; _luop_tx_gsup(luop, &gsup); @@ -245,8 +251,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST; + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); //gsup.cause = FIXME; //gsup.cancel_type = FIXME; @@ -281,9 +286,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || luop->state == LU_S_CANCEL_ACK_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, luop->subscr.msisdn); -- To view, visit https://gerrit.osmocom.org/1814 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 17:44:30 2017 From: gerrit-no-reply at lists.osmocom.org (ikostov) Date: Mon, 13 Feb 2017 17:44:30 +0000 Subject: [PATCH] libosmocore[master]: OAP: remove osmocom-authn-protocol.txt Message-ID: Review at https://gerrit.osmocom.org/1815 OAP: remove osmocom-authn-protocol.txt Change-Id: Ie2e09220ab4b21a3c4a88407032d718ff75e0ade --- D doc/osmocom-authn-protocol.txt 1 file changed, 0 insertions(+), 250 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/15/1815/1 diff --git a/doc/osmocom-authn-protocol.txt b/doc/osmocom-authn-protocol.txt deleted file mode 100644 index ad4fba0..0000000 --- a/doc/osmocom-authn-protocol.txt +++ /dev/null @@ -1,250 +0,0 @@ - - Osmocom Authentication Protocol (OAP) - -1. General - -The Osmocom Authentication Protocol employs mutual authentication to register a -client with a server over an IPA connection. Milenage is used as the -authentication algorithm, where client and server have a shared secret. - -For example, an SGSN, as OAP client, may use its SGSN ID to register with a MAP -proxy, an OAP server. - -1.1. Connection - -The protocol expects that a reliable, ordered, packet boundaries preserving -connection is used (e.g. IPA over TCP). - -1.2. Using IPA - -By default, the following identifiers should be used: - - IPA protocol: 0xee (OSMO) - - IPA OSMO protocol extension: 0x06 (OAP) - -2. Procedures - -Ideal communication sequence: - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Challenge (RAND+AUTN) | - |<-----------------------------------| - | | - | Challenge Result (XRES) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -Variation "test setup": - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -Variation "invalid sequence nr": - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Challenge (RAND+AUTN) | - |<-----------------------------------| - | | - | Sync Request (AUTS) | - |----------------------------------->| - | | - | Challenge (RAND'+AUTN') | - |<-----------------------------------| - | | - | Challenge Result (XRES) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -2.1. Register - -The client sends a REGISTER_REQ message containing an identifier number. - -2.2. Challenge - -The OAP server (optionally) sends back a CHALLENGE_REQ, containing random bytes -and a milenage authentication token generated from these random bytes, using a -shared secret, to authenticate itself to the OAP client. The server may omit -this challenge entirely, based on its configuration, and immediately reply with -a Register Result response. If the client cannot be registered (e.g. id is -invalid), the server sends a REGISTER_ERR response. - -2.3. Challenge Result - -When the client has received a Challenge, it may verify the server's -authenticity and validity of the sequence number (included in AUTN), and, if -valid, reply with a CHALLENGE_RES message. This shall contain an XRES -authentication token generated by milenage from the same random bytes received -from the server and the same shared secet. If the client decides to cancel the -registration (e.g. invalid AUTN), it shall not reply to the CHALLENGE_REQ; a -CHALLENGE_ERR message may be sent, but is not mandatory. For example, the -client may directly start with a new REGISTER_REQ message. - -2.4. Sync Request - -When the client has received a Challenge but sees an invalid sequence number -(embedded in AUTN, according to the milenage algorithm), the client may send a -SYNC_REQ message containing an AUTS synchronisation token. - -2.5. Sync Result - -If the server has received a valid Sync Request, it shall answer by directly -sending another Challenge (see 2.2.). If an invalid Sync Request is received, -the server shall reply with a REGISTER_ERR message. - -2.6. Register Result - -The server sends a REGISTER_RES message to indicate that registration has been -successful. If the server cannot register the client (e.g. invalid challenge -response), it shall send a REGISTER_ERR message. - -3. Message Format - -3.1. General - -Every message is based on the following message format - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - -The receiver shall be able to receive IEs in any order. Unknown IEs shall be -ignored. - -3.2.1. Register Request - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 30 Client ID big endian int (2 oct) M TLV 4 - -3.2.2. Register Error - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 02 Cause GMM cause, M TLV 3 - 04.08: 10.5.5.14 - -3.2.3. Register Result - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - -3.2.4. Challenge - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 20 RAND octet string (16) M TLV 18 - 23 AUTN octet string (16) M TLV 18 - -3.2.5. Challenge Error - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 02 Cause GMM cause, M TLV 3 - 04.08: 10.5.5.14 - -3.2.6. Challenge Result - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 21 XRES octet string (8) M TLV 10 - -3.2.7. Sync Request - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 20 AUTS octet string (14) M TLV 16 - -3.2.8. Sync Error - -Not used. - -3.2.9. Sync Result - -Not used. - - -4. Information Elements - -4.1. General - -[...] - -4.2.1. Message Type - - +---------------------------------------------------+ - | 8 7 6 5 4 3 2 1 | - | | - | 0 0 0 0 0 1 0 0 - Register Request | - | 0 0 0 0 0 1 0 1 - Register Error | - | 0 0 0 0 0 1 1 0 - Register Result | - | | - | 0 0 0 0 1 0 0 0 - Challenge Request | - | 0 0 0 0 1 0 0 1 - Challenge Error | - | 0 0 0 0 1 0 1 0 - Challenge Result | - | | - | 0 0 0 0 1 1 0 0 - Sync Request | - | 0 0 0 0 1 1 0 1 - Sync Error (not used) | - | 0 0 0 0 1 1 1 0 - Sync Result (not used) | - | | - +---------------------------------------------------+ - -4.2.2. IE Identifier (informational) - -These are the standard values for the IEI. - - +---------------------------------------------------------+ - | IEI Info Element Type | - | | - | 0x02 Cause GMM cause, 04.08: 10.5.5.14 | - | 0x20 RAND octet string | - | 0x23 AUTN octet string | - | 0x24 XRES octet string | - | 0x25 AUTS octet string | - | 0x30 Client ID big endian int (2 octets) | - +---------------------------------------------------------+ - -4.2.3. Client ID - - 8 7 6 5 4 3 2 1 - +-----------------------------------------------------+ - | | Client ID IEI | octet 1 - +-----------------------------------------------------+ - | Length of Client ID IE contents (2) | octet 2 - +-----------------------------------------------------+ - | Client ID number, most significant byte | octet 3 - +-----------------------------------------------------+ - | Client ID number, least significant byte | octet 4 - +-----------------------------------------------------+ - -The Client ID number shall be interpreted as an unsigned 16bit integer, where 0 -indicates an invalid / unset ID. - -- To view, visit https://gerrit.osmocom.org/1815 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2e09220ab4b21a3c4a88407032d718ff75e0ade Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov From gerrit-no-reply at lists.osmocom.org Mon Feb 13 21:50:21 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Mon, 13 Feb 2017 21:50:21 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 2: -Code-Review (1 comment) Please see if you can address my latest comment. https://gerrit.osmocom.org/#/c/1775/1/src/tbf_dl.cpp File src/tbf_dl.cpp: Line 634: enum egprs_puncturing_values punct[2] = { > ARRAY_SIZE(rlc.block_info) always results in 2. Check if this initialization can be moved to for loop below. With this modification, you may not need to bother about what would be the size of punct. -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:08:23 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:08:23 +0000 Subject: osmo-hlr[master]: Log error cause as a string In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1813 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I846d488ed163e137164976738e55674f0eaee190 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:08:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:08:25 +0000 Subject: [MERGED] osmo-hlr[master]: Log error cause as a string In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Log error cause as a string ...................................................................... Log error cause as a string Use gsm48_gmm_cause_names to log error cause instead of numerical code. Change-Id: I846d488ed163e137164976738e55674f0eaee190 --- M src/hlr.c 1 file changed, 3 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/hlr.c b/src/hlr.c index cfd86cc..2fa27c3 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -186,8 +186,9 @@ { struct osmo_gsup_message gsup; - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause=%u)\n", - luop->subscr.imsi, cause); + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); memset(&gsup, 0, sizeof(gsup)); gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR; -- To view, visit https://gerrit.osmocom.org/1813 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I846d488ed163e137164976738e55674f0eaee190 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:08:59 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:08:59 +0000 Subject: osmo-hlr[master]: Move GSUP msg init into separate function In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1814 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:09:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:09:12 +0000 Subject: [MERGED] osmo-sip-connector[master]: sip: Treat SIP 183 as progress too In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sip: Treat SIP 183 as progress too ...................................................................... sip: Treat SIP 183 as progress too It doesn't fix early media yet but brings us one step closer to it: The 183 (Session Progress) response is used to convey information about the progress of the call that is not otherwise classified. The Reason-Phrase, header fields, or message body MAY be used to convey more details about the call progress. Change-Id: Ibf264f251e41c06a7b4839acc0d0853e6400291c --- M src/sip.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sip.c b/src/sip.c index 139c620..afff393 100644 --- a/src/sip.c +++ b/src/sip.c @@ -156,7 +156,7 @@ if (leg->state == SIP_CC_INITIAL) leg->state = SIP_CC_DLG_CNFD; - if (status == 180) + if (status == 180 || status == 183) call_progress(leg, sip); else if (status == 200) call_connect(leg, sip); -- To view, visit https://gerrit.osmocom.org/1794 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibf264f251e41c06a7b4839acc0d0853e6400291c Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:09:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:09:12 +0000 Subject: [MERGED] osmo-sip-connector[master]: evpoll: Use {} in the middle of the if/else if/else block In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: evpoll: Use {} in the middle of the if/else if/else block ...................................................................... evpoll: Use {} in the middle of the if/else if/else block Curly braces are used the lines above and below, don't make the middle stick out like this. Change-Id: I48a15a8665a47db206f8a7ccbc792f6bec8549c2 --- M src/evpoll.c 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/evpoll.c b/src/evpoll.c index 9593764..1648080 100644 --- a/src/evpoll.c +++ b/src/evpoll.c @@ -68,9 +68,9 @@ */ if (timeout == 0) { tv = &null_tv; - } else if (timeout == -1) + } else if (timeout == -1) { tv = osmo_timers_nearest(); - else { + } else { poll_tv.tv_sec = timeout / 1000; poll_tv.tv_usec = (timeout % 1000) * 1000; -- To view, visit https://gerrit.osmocom.org/1795 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I48a15a8665a47db206f8a7ccbc792f6bec8549c2 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:09:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:09:12 +0000 Subject: [MERGED] osmo-sip-connector[master]: evpoll: Always initialize revents for the output In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: evpoll: Always initialize revents for the output ...................................................................... evpoll: Always initialize revents for the output Even if we have not selected the fd (e.g. fd < 0), initialize revents to 0. This seems to match gpoll.c:g_poll of glib. Change-Id: I9e16a6d5a74a204c85808ba67a8f0f7af3045059 --- M src/evpoll.c 1 file changed, 2 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/evpoll.c b/src/evpoll.c index 1648080..a4b8a80 100644 --- a/src/evpoll.c +++ b/src/evpoll.c @@ -92,10 +92,11 @@ osmo_fd_disp_fds(&readset, &writeset, &exceptset); for (i = 0; i < nfds; ++i) { + fds[i].revents = 0; + if (fds[i].fd < 0) continue; - fds[i].revents = 0; if (FD_ISSET(fds[i].fd, &readset)) fds[i].revents = POLLIN; if (FD_ISSET(fds[i].fd, &writeset)) -- To view, visit https://gerrit.osmocom.org/1796 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9e16a6d5a74a204c85808ba67a8f0f7af3045059 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 13 22:09:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Mon, 13 Feb 2017 22:09:42 +0000 Subject: osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 00:12:07 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Tue, 14 Feb 2017 00:12:07 +0000 Subject: osmo-sip-connector[master]: evpoll: Don't try to be more smart than g_poll In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1797 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8c9163f7495e0b237bde2d48beffea3b0776a1dd Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 00:12:14 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Tue, 14 Feb 2017 00:12:14 +0000 Subject: [MERGED] osmo-sip-connector[master]: evpoll: Don't try to be more smart than g_poll In-Reply-To: References: Message-ID: Holger Freyther has submitted this change and it was merged. Change subject: evpoll: Don't try to be more smart than g_poll ...................................................................... evpoll: Don't try to be more smart than g_poll gpoll.c:g_poll maps G_IO_PRI (which is POLLPRI) to the errorfds of the select call. Let's do the same. Change-Id: I8c9163f7495e0b237bde2d48beffea3b0776a1dd Related: OS#1934 --- M src/evpoll.c 1 file changed, 4 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, but someone else must approve Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/src/evpoll.c b/src/evpoll.c index a4b8a80..3273bd0 100644 --- a/src/evpoll.c +++ b/src/evpoll.c @@ -43,15 +43,15 @@ for (i = 0; i < nfds; ++i) { if (fds[i].fd < 0) continue; - if ((fds[i].events & (POLLIN | POLLOUT | POLLERR)) == 0) + if ((fds[i].events & (POLLIN | POLLOUT | POLLPRI)) == 0) continue; - /* copy events, glib seems to map POLLPRI to exceptionset? */ + /* copy events. Not sure why glib maps PRI to exceptionset */ if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &readset); if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &writeset); - if (fds[i].events & POLLERR) + if (fds[i].events & POLLPRI) FD_SET(fds[i].fd, &exceptset); if (fds[i].fd > maxfd) @@ -102,7 +102,7 @@ if (FD_ISSET(fds[i].fd, &writeset)) fds[i].revents |= POLLOUT; if (FD_ISSET(fds[i].fd, &exceptset)) - fds[i].revents |= POLLERR; + fds[i].revents |= POLLPRI; } return rc; -- To view, visit https://gerrit.osmocom.org/1797 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8c9163f7495e0b237bde2d48beffea3b0776a1dd Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 14 08:22:48 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Tue, 14 Feb 2017 08:22:48 +0000 Subject: osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Patch Set 2: Why drop the assert (or not convert it into a static/compile time assert)? -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 08:25:06 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Tue, 14 Feb 2017 08:25:06 +0000 Subject: libosmocore[master]: OAP: remove osmocom-authn-protocol.txt In-Reply-To: References: Message-ID: Patch Set 1: A commit message should not only explain what (here removal) has been done but provide context and answers (where applicable) to why? how? what other options did exist? -- To view, visit https://gerrit.osmocom.org/1815 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie2e09220ab4b21a3c4a88407032d718ff75e0ade Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 08:30:17 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Tue, 14 Feb 2017 08:30:17 +0000 Subject: osmo-bts[master]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1767 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 11:12:06 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 11:12:06 +0000 Subject: [PATCH] libosmocore[master]: gsup: add osmo_gsup_message_type_name() Message-ID: Review at https://gerrit.osmocom.org/1816 gsup: add osmo_gsup_message_type_name() Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360 --- M include/osmocom/gsm/gsup.h M src/gsm/gsup.c M src/gsm/libosmogsm.map 3 files changed, 35 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/16/1816/1 diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h index e2912a6..04b31d0 100644 --- a/include/osmocom/gsm/gsup.h +++ b/include/osmocom/gsm/gsup.h @@ -95,6 +95,11 @@ #define OSMO_GSUP_IS_MSGT_ERROR(msgt) (((msgt) & 0b00000011) == 0b01) #define OSMO_GSUP_TO_MSGT_ERROR(msgt) (((msgt) & 0b11111100) | 0b01) +extern const struct value_string osmo_gsup_message_type_names[]; +static inline const char * +osmo_gsup_message_type_name(enum osmo_gsup_message_type val) +{ return get_value_string(osmo_gsup_message_type_names, val); } + enum osmo_gsup_cancel_type { OSMO_GSUP_CANCEL_TYPE_UPDATE = 1, /* on wire: 0 */ OSMO_GSUP_CANCEL_TYPE_WITHDRAW = 2, /* on wire: 1 */ diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index b1b97ca..ec1dc90 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -31,6 +31,35 @@ #include +const struct value_string osmo_gsup_message_type_names[] = { + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PURGE_MS_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PURGE_MS_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PURGE_MS_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_INSERT_DATA_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_INSERT_DATA_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_DELETE_DATA_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_DELETE_DATA_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_DELETE_DATA_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT), + { 0, NULL } +}; + static int decode_pdp_info(uint8_t *data, size_t data_len, struct osmo_gsup_pdp_info *pdp_info) { diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index e153d72..78e55df 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -363,6 +363,7 @@ osmo_gsup_encode; osmo_gsup_decode; +osmo_gsup_message_type_names; osmo_oap_encode; osmo_oap_decode; -- To view, visit https://gerrit.osmocom.org/1816 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 14 11:14:27 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 14 Feb 2017 11:14:27 +0000 Subject: [PATCH] libosmocore[master]: Add CTRL port for OsmoHLR Message-ID: Review at https://gerrit.osmocom.org/1817 Add CTRL port for OsmoHLR Change-Id: I1328c89ec8e908bf4b4d2c0a398690278369e0f5 Related: OS#1645 --- M include/osmocom/ctrl/ports.h 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/1817/1 diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h index 4bc2a24..101b894 100644 --- a/include/osmocom/ctrl/ports.h +++ b/include/osmocom/ctrl/ports.h @@ -16,4 +16,5 @@ #define OSMO_CTRL_PORT_CSCN 4255 /* 4256 used by VTY interface */ #define OSMO_CTRL_PORT_GGSN 4257 +#define OSMO_CTRL_PORT_HLR 4259 /* When adding/changing port numbers, keep docs and wiki in sync. See above. */ -- To view, visit https://gerrit.osmocom.org/1817 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1328c89ec8e908bf4b4d2c0a398690278369e0f5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 14 11:15:30 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 11:15:30 +0000 Subject: osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Patch Set 2: > Why drop the assert (or not convert it into a static/compile time > assert)? ah, that's actually an erratic separation of two patches. The assert is replaced in the following patch and doesn't belong here :/ thanks for spotting. -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 11:26:51 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 11:26:51 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/1775/1/src/tbf_dl.cpp File src/tbf_dl.cpp: Line 634: enum egprs_puncturing_values punct[2] = { > Check if this initialization can be moved to for loop below. With this modi This initialization cannot be moved to the for loop. If num_data_blocks is 1, we will not initialize the second punct val and hence will run into the very same sanitizer issue that we're trying to fix. And still, again, and all the time: we are passing *two* arguments to gprs_rlc_mcs_cps(), so we *have* to know that punct has *exactly* two elements. Right? -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 14 11:27:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 11:27:22 +0000 Subject: [PATCH] osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1774 to look at the new patch set (#3). dl tbf: calculate CPS only for EGPRS Patch-by: Aravind Sirsikar Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd --- M src/tbf_dl.cpp 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/74/1774/3 diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 78f06e9..c04a84e 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -762,8 +762,11 @@ msg_data, block_data); } - OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); - rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); + /* Calculate CPS only for EGPRS case */ + if (cs.isEgprs()) { + OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); + rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); + } /* If the TBF has just started, relate frames_since_last_poll to the * current fn */ -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 14 11:27:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 11:27:22 +0000 Subject: [PATCH] osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Hello arvind.sirsikar, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1775 to look at the new patch set (#3). dl tbf: initialize punct values and verify Solves a sanitizer issue where punct2 is unset when passed to gprs_rlc_mcs_cps() and thus takes a value not defined in the enum. Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 --- M src/rlc.cpp M src/tbf_dl.cpp 2 files changed, 38 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/75/1775/3 diff --git a/src/rlc.cpp b/src/rlc.cpp index d13045e..acd4169 100644 --- a/src/rlc.cpp +++ b/src/rlc.cpp @@ -378,6 +378,36 @@ enum egprs_puncturing_values punct, enum egprs_puncturing_values punct2, int with_padding) { + /* validate that punct and punct2 are as expected */ + switch (GprsCodingScheme::Scheme(cs)) { + case GprsCodingScheme::MCS9: + case GprsCodingScheme::MCS8: + case GprsCodingScheme::MCS7: + if (punct2 == EGPRS_PS_INVALID) { + LOGP(DRLCMACDL, LOGL_ERROR, + "Invalid punct2 value for coding scheme %d: %d\n", + GprsCodingScheme::Scheme(cs), punct2); + return -1; + } + /* fall through */ + case GprsCodingScheme::MCS6: + case GprsCodingScheme::MCS5: + case GprsCodingScheme::MCS4: + case GprsCodingScheme::MCS3: + case GprsCodingScheme::MCS2: + case GprsCodingScheme::MCS1: + if (punct == EGPRS_PS_INVALID) { + LOGP(DRLCMACDL, LOGL_ERROR, + "Invalid punct value for coding scheme %d: %d\n", + GprsCodingScheme::Scheme(cs), punct); + return -1; + } + break; + default: + return -1; + } + + /* See 3GPP TS 44.060 10.4.8a.3.1, 10.4.8a.2.1, 10.4.8a.1.1 */ switch (GprsCodingScheme::Scheme(cs)) { case GprsCodingScheme::MCS1: return 0b1011 + punct % EGPRS_MAX_PS_NUM_2; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index c04a84e..d871c4d 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -627,10 +627,16 @@ GprsCodingScheme cs; int bsns[ARRAY_SIZE(rlc.block_info)]; unsigned num_bsns; - enum egprs_puncturing_values punct[ARRAY_SIZE(rlc.block_info)]; bool need_padding = false; enum egprs_rlcmac_dl_spb spb = EGPRS_RLCMAC_DL_NO_RETX; unsigned int spb_status = get_egprs_dl_spb_status(index); + + enum egprs_puncturing_values punct[2] = { + EGPRS_PS_INVALID, EGPRS_PS_INVALID + }; + osmo_static_assert(ARRAY_SIZE(rlc.block_info) == 2, + rlc_block_info_size_is_two); + /* * TODO: This is an experimental work-around to put 2 BSN into * MSC-7 to MCS-9 encoded messages. It just sends the same BSN @@ -763,10 +769,8 @@ } /* Calculate CPS only for EGPRS case */ - if (cs.isEgprs()) { - OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); + if (cs.isEgprs()) rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); - } /* If the TBF has just started, relate frames_since_last_poll to the * current fn */ -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar From gerrit-no-reply at lists.osmocom.org Tue Feb 14 13:12:56 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 14 Feb 2017 13:12:56 +0000 Subject: [PATCH] osmo-gsm-manuals[master]: Add CTRL port for OsmoHLR Message-ID: Review at https://gerrit.osmocom.org/1818 Add CTRL port for OsmoHLR Change-Id: Ic39e48cec9615faaa31079b0faec6ebd7e706b4f Related: OS#1645 --- M common/chapters/port_numbers.adoc 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/18/1818/1 diff --git a/common/chapters/port_numbers.adoc b/common/chapters/port_numbers.adoc index f70462c..f48c8d0 100644 --- a/common/chapters/port_numbers.adoc +++ b/common/chapters/port_numbers.adoc @@ -32,6 +32,7 @@ |TCP|4256|telnet (VTY)|osmo-sip-connector |TCP|4257|Control Interface|ggsn (OpenGGSN) |TCP|4258|telnet (VTY)|osmo-hlr +|TCP|4259|Control Interface|osmo-hlr |UDP|4729|GSMTAP|Almost every osmocom project |TCP|5000|A/IP|osmo-bsc, osmo-bsc_nat |UDP|2427|GSMTAP|osmo-pcu, osmo-bts -- To view, visit https://gerrit.osmocom.org/1818 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic39e48cec9615faaa31079b0faec6ebd7e706b4f Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 14 13:14:01 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 14 Feb 2017 13:14:01 +0000 Subject: libosmocore[master]: gsup: add osmo_gsup_message_type_name() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1816 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 13:37:32 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Tue, 14 Feb 2017 13:37:32 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 13:38:15 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Tue, 14 Feb 2017 13:38:15 +0000 Subject: osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:21:24 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:21:24 +0000 Subject: osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:21:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:21:58 +0000 Subject: osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:22:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:22:25 +0000 Subject: osmo-gsm-manuals[master]: Add CTRL port for OsmoHLR In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1818 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic39e48cec9615faaa31079b0faec6ebd7e706b4f Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:22:27 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:22:27 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: Add CTRL port for OsmoHLR In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add CTRL port for OsmoHLR ...................................................................... Add CTRL port for OsmoHLR Change-Id: Ic39e48cec9615faaa31079b0faec6ebd7e706b4f Related: OS#1645 --- M common/chapters/port_numbers.adoc 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/common/chapters/port_numbers.adoc b/common/chapters/port_numbers.adoc index f70462c..f48c8d0 100644 --- a/common/chapters/port_numbers.adoc +++ b/common/chapters/port_numbers.adoc @@ -32,6 +32,7 @@ |TCP|4256|telnet (VTY)|osmo-sip-connector |TCP|4257|Control Interface|ggsn (OpenGGSN) |TCP|4258|telnet (VTY)|osmo-hlr +|TCP|4259|Control Interface|osmo-hlr |UDP|4729|GSMTAP|Almost every osmocom project |TCP|5000|A/IP|osmo-bsc, osmo-bsc_nat |UDP|2427|GSMTAP|osmo-pcu, osmo-bts -- To view, visit https://gerrit.osmocom.org/1818 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic39e48cec9615faaa31079b0faec6ebd7e706b4f Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:22:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:22:37 +0000 Subject: libosmocore[master]: Add CTRL port for OsmoHLR In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1817 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1328c89ec8e908bf4b4d2c0a398690278369e0f5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:22:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:22:40 +0000 Subject: [MERGED] libosmocore[master]: Add CTRL port for OsmoHLR In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add CTRL port for OsmoHLR ...................................................................... Add CTRL port for OsmoHLR Change-Id: I1328c89ec8e908bf4b4d2c0a398690278369e0f5 Related: OS#1645 --- M include/osmocom/ctrl/ports.h 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h index 4bc2a24..101b894 100644 --- a/include/osmocom/ctrl/ports.h +++ b/include/osmocom/ctrl/ports.h @@ -16,4 +16,5 @@ #define OSMO_CTRL_PORT_CSCN 4255 /* 4256 used by VTY interface */ #define OSMO_CTRL_PORT_GGSN 4257 +#define OSMO_CTRL_PORT_HLR 4259 /* When adding/changing port numbers, keep docs and wiki in sync. See above. */ -- To view, visit https://gerrit.osmocom.org/1817 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1328c89ec8e908bf4b4d2c0a398690278369e0f5 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:24:06 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 14:24:06 +0000 Subject: libosmocore[master]: OAP: remove osmocom-authn-protocol.txt In-Reply-To: References: Message-ID: Patch Set 1: this fails because you didn't remvoe the file from the Makefile.in, so the install scripts still want to install it, but the file is no longer found. -- To view, visit https://gerrit.osmocom.org/1815 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie2e09220ab4b21a3c4a88407032d718ff75e0ade Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:57:59 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 14:57:59 +0000 Subject: [PATCH] libosmocore[master]: utils: add hexparse test Message-ID: Review at https://gerrit.osmocom.org/1819 utils: add hexparse test Change-Id: Ic95ab00b57d54905a235109561c00419161cf4bc --- M tests/utils/utils_test.c M tests/utils/utils_test.ok 2 files changed, 117 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/19/1819/1 diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c index 1a79baa..e3d6221 100644 --- a/tests/utils/utils_test.c +++ b/tests/utils/utils_test.c @@ -43,6 +43,103 @@ printf("%s\n", osmo_hexdump_nospc(data, ARRAY_SIZE(data))); } +static void hexparse_test(void) +{ + int i; + int rc; + uint8_t data[256]; + + printf("\nHexparse 0..255 in lower case\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f" + "505152535455565758595a5b5c5d5e5f" + "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" + "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + + printf("Hexparse 0..255 in upper case\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "000102030405060708090A0B0C0D0E0F" + "101112131415161718191A1B1C1D1E1F" + "202122232425262728292A2B2C2D2E2F" + "303132333435363738393A3B3C3D3E3F" + "404142434445464748494A4B4C4D4E4F" + "505152535455565758595A5B5C5D5E5F" + "606162636465666768696A6B6C6D6E6F" + "707172737475767778797A7B7C7D7E7F" + "808182838485868788898A8B8C8D8E8F" + "909192939495969798999A9B9C9D9E9F" + "A0A1A2A3A4A5A6A7A8A9AAABACADAEAF" + "B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF" + "C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF" + "D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF" + "E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF" + "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + + printf("Hexparse 0..255 in mixed case\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "000102030405060708090A0B0C0D0E0F" + "101112131415161718191A1B1C1D1E1F" + "202122232425262728292A2B2C2D2E2F" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494A4B4C4D4E4F" + "505152535455565758595a5b5c5d5e5f" + "606162636465666768696A6B6C6D6E6F" + "707172737475767778797A7B7C7D7E7F" + "808182838485868788898A8B8C8D8E8F" + "909192939495969798999A9B9C9D9E9F" + "A0A1A2A3a4a5a6a7a8a9AAABACADAEAF" + "B0B1B2B3b4b5b6b7b8b9BABBBCBDBEBF" + "C0C1C2C3c4c5c6c7c8c9CACBCCCDCECF" + "D0D1D2D3d4d5d6d7d8d9DADBDCDDDEDF" + "E0E1E2E3e4e5e6e7e8e9EAEBECEDEEEF" + "F0F1F2F3f4f5f6f7f8f9FAFBFCFDFEFF" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + + printf("Hexparse with buffer too short\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse("000102030405060708090a0b0c0d0e0f", data, 15); + printf("rc = %d\n", rc); + + printf("Hexparse with uneven amount of digits\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse("000102030405060708090a0b0c0d0e0", data, 16); + printf("rc = %d\n", rc); + + printf("Hexparse with invalid char\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse("0001020304050X0708090a0b0c0d0e0f", data, 16); + printf("rc = %d\n", rc); +} + static void test_idtag_parsing(void) { struct tlv_parsed tvp; @@ -103,6 +200,7 @@ log_init(&log_info, NULL); hexdump_test(); + hexparse_test(); test_idtag_parsing(); return 0; } diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok index 50a5747..0f7e7a0 100644 --- a/tests/utils/utils_test.ok +++ b/tests/utils/utils_test.ok @@ -3,3 +3,22 @@ Corner case 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe + +Hexparse 0..255 in lower case +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + +Hexparse 0..255 in upper case +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + +Hexparse 0..255 in mixed case +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + +Hexparse with buffer too short +rc = -1 +Hexparse with uneven amount of digits +rc = -1 +Hexparse with invalid char +rc = -1 -- To view, visit https://gerrit.osmocom.org/1819 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic95ab00b57d54905a235109561c00419161cf4bc Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 14 14:57:59 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 14:57:59 +0000 Subject: [PATCH] libosmocore[master]: osmo_hexparse: allow whitespace in parsed string, add ws test Message-ID: Review at https://gerrit.osmocom.org/1820 osmo_hexparse: allow whitespace in parsed string, add ws test Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 --- M src/utils.c M tests/utils/utils_test.c M tests/utils/utils_test.ok 3 files changed, 51 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/1820/1 diff --git a/src/utils.c b/src/utils.c index 34b2bca..1a4aab4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -127,16 +127,22 @@ int osmo_hexparse(const char *str, uint8_t *b, int max_len) { - int i, l, v; - - l = strlen(str); - if ((l&1) || ((l>>1) > max_len)) - return -1; + char c; + uint8_t v; + const char *strpos; + unsigned int nibblepos = 0; memset(b, 0x00, max_len); - for (i=0; i= (max_len << 1)) + return -1; + if (c >= '0' && c <= '9') v = c - '0'; else if (c >= 'a' && c <= 'f') @@ -145,10 +151,17 @@ v = 10 + (c - 'A'); else return -1; - b[i>>1] |= v << (i&1 ? 0 : 4); + + b[nibblepos >> 1] |= v << (nibblepos & 1 ? 0 : 4); + nibblepos ++; } - return i>>1; + /* In case of uneven amount of digits, the last byte is not complete + * and that's an error. */ + if (nibblepos & 1) + return -1; + + return nibblepos >> 1; } static char hexd_buff[4096]; diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c index e3d6221..cad162d 100644 --- a/tests/utils/utils_test.c +++ b/tests/utils/utils_test.c @@ -124,6 +124,31 @@ for (i = 0; i < sizeof(data); i++) OSMO_ASSERT(data[i] == i); + printf("Hexparse 0..255 with whitespace\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "00 01\t02\r030405060708090A0B0C0D0 E 0 F\n" + "10 11\t12\r131415161718191A1B1C1D1 E 1 F\n" + "20 21\t22\r232425262728292A2B2C2D2 E 2 F\n" + "30 31\t32\r333435363738393a3b3c3d3 e 3 f\n" + "40 41\t42\r434445464748494A4B4C4D4 E 4 F\n" + "50 51\t52\r535455565758595a5b5c5d5 e 5 f\n" + "60 61\t62\r636465666768696A6B6C6D6 E 6 F\n" + "70 71\t72\r737475767778797A7B7C7D7 E 7 F\n" + "80 81\t82\r838485868788898A8B8C8D8 E 8 F\n" + "90 91\t92\r939495969798999A9B9C9D9 E 9 F\n" + "A0 A1\tA2\rA3a4a5a6a7a8a9AAABACADA E A F\n" + "B0 B1\tB2\rB3b4b5b6b7b8b9BABBBCBDB E B F\n" + "C0 C1\tC2\rC3c4c5c6c7c8c9CACBCCCDC E C F \n" + "D0 D1\tD2\rD3d4d5d6d7d8d9DADBDCDDD E D F\t\n" + "E0 E1\tE2\rE3e4e5e6e7e8e9EAEBECEDE E E F \t\n" + "F0 F1\tF2\rF3f4f5f6f7f8f9FAFBFCFDF E F F \t\r\n" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + printf("Hexparse with buffer too short\n"); memset(data, 0, sizeof(data)); rc = osmo_hexparse("000102030405060708090a0b0c0d0e0f", data, 15); diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok index 0f7e7a0..e9be018 100644 --- a/tests/utils/utils_test.ok +++ b/tests/utils/utils_test.ok @@ -16,6 +16,10 @@ rc = 256 --> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff +Hexparse 0..255 with whitespace +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + Hexparse with buffer too short rc = -1 Hexparse with uneven amount of digits -- To view, visit https://gerrit.osmocom.org/1820 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 14 15:02:37 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 15:02:37 +0000 Subject: [PATCH] libosmocore[master]: osmo_hexparse: allow whitespace in parsed string, add ws test In-Reply-To: References: Message-ID: osmo_hexparse: allow whitespace in parsed string, add ws test This is particularly useful for hex dumps containing spaces found in a log (e.g. osmo-nitb authentication rand token), which can now be passed in quotes to osmo-auc-gen without having to edit the spaces away. Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 --- M src/utils.c M tests/utils/utils_test.c M tests/utils/utils_test.ok 3 files changed, 51 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/1820/2 diff --git a/src/utils.c b/src/utils.c index 34b2bca..1a4aab4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -127,16 +127,22 @@ int osmo_hexparse(const char *str, uint8_t *b, int max_len) { - int i, l, v; - - l = strlen(str); - if ((l&1) || ((l>>1) > max_len)) - return -1; + char c; + uint8_t v; + const char *strpos; + unsigned int nibblepos = 0; memset(b, 0x00, max_len); - for (i=0; i= (max_len << 1)) + return -1; + if (c >= '0' && c <= '9') v = c - '0'; else if (c >= 'a' && c <= 'f') @@ -145,10 +151,17 @@ v = 10 + (c - 'A'); else return -1; - b[i>>1] |= v << (i&1 ? 0 : 4); + + b[nibblepos >> 1] |= v << (nibblepos & 1 ? 0 : 4); + nibblepos ++; } - return i>>1; + /* In case of uneven amount of digits, the last byte is not complete + * and that's an error. */ + if (nibblepos & 1) + return -1; + + return nibblepos >> 1; } static char hexd_buff[4096]; diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c index e3d6221..cad162d 100644 --- a/tests/utils/utils_test.c +++ b/tests/utils/utils_test.c @@ -124,6 +124,31 @@ for (i = 0; i < sizeof(data); i++) OSMO_ASSERT(data[i] == i); + printf("Hexparse 0..255 with whitespace\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "00 01\t02\r030405060708090A0B0C0D0 E 0 F\n" + "10 11\t12\r131415161718191A1B1C1D1 E 1 F\n" + "20 21\t22\r232425262728292A2B2C2D2 E 2 F\n" + "30 31\t32\r333435363738393a3b3c3d3 e 3 f\n" + "40 41\t42\r434445464748494A4B4C4D4 E 4 F\n" + "50 51\t52\r535455565758595a5b5c5d5 e 5 f\n" + "60 61\t62\r636465666768696A6B6C6D6 E 6 F\n" + "70 71\t72\r737475767778797A7B7C7D7 E 7 F\n" + "80 81\t82\r838485868788898A8B8C8D8 E 8 F\n" + "90 91\t92\r939495969798999A9B9C9D9 E 9 F\n" + "A0 A1\tA2\rA3a4a5a6a7a8a9AAABACADA E A F\n" + "B0 B1\tB2\rB3b4b5b6b7b8b9BABBBCBDB E B F\n" + "C0 C1\tC2\rC3c4c5c6c7c8c9CACBCCCDC E C F \n" + "D0 D1\tD2\rD3d4d5d6d7d8d9DADBDCDDD E D F\t\n" + "E0 E1\tE2\rE3e4e5e6e7e8e9EAEBECEDE E E F \t\n" + "F0 F1\tF2\rF3f4f5f6f7f8f9FAFBFCFDF E F F \t\r\n" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + printf("Hexparse with buffer too short\n"); memset(data, 0, sizeof(data)); rc = osmo_hexparse("000102030405060708090a0b0c0d0e0f", data, 15); diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok index 0f7e7a0..e9be018 100644 --- a/tests/utils/utils_test.ok +++ b/tests/utils/utils_test.ok @@ -16,6 +16,10 @@ rc = 256 --> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff +Hexparse 0..255 with whitespace +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + Hexparse with buffer too short rc = -1 Hexparse with uneven amount of digits -- To view, visit https://gerrit.osmocom.org/1820 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 14 15:23:34 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 15:23:34 +0000 Subject: [MERGED] osmo-pcu[master]: dl tbf: initialize punct values and verify In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: dl tbf: initialize punct values and verify ...................................................................... dl tbf: initialize punct values and verify Solves a sanitizer issue where punct2 is unset when passed to gprs_rlc_mcs_cps() and thus takes a value not defined in the enum. Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 --- M src/rlc.cpp M src/tbf_dl.cpp 2 files changed, 38 insertions(+), 4 deletions(-) Approvals: arvind.sirsikar: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/rlc.cpp b/src/rlc.cpp index d13045e..acd4169 100644 --- a/src/rlc.cpp +++ b/src/rlc.cpp @@ -378,6 +378,36 @@ enum egprs_puncturing_values punct, enum egprs_puncturing_values punct2, int with_padding) { + /* validate that punct and punct2 are as expected */ + switch (GprsCodingScheme::Scheme(cs)) { + case GprsCodingScheme::MCS9: + case GprsCodingScheme::MCS8: + case GprsCodingScheme::MCS7: + if (punct2 == EGPRS_PS_INVALID) { + LOGP(DRLCMACDL, LOGL_ERROR, + "Invalid punct2 value for coding scheme %d: %d\n", + GprsCodingScheme::Scheme(cs), punct2); + return -1; + } + /* fall through */ + case GprsCodingScheme::MCS6: + case GprsCodingScheme::MCS5: + case GprsCodingScheme::MCS4: + case GprsCodingScheme::MCS3: + case GprsCodingScheme::MCS2: + case GprsCodingScheme::MCS1: + if (punct == EGPRS_PS_INVALID) { + LOGP(DRLCMACDL, LOGL_ERROR, + "Invalid punct value for coding scheme %d: %d\n", + GprsCodingScheme::Scheme(cs), punct); + return -1; + } + break; + default: + return -1; + } + + /* See 3GPP TS 44.060 10.4.8a.3.1, 10.4.8a.2.1, 10.4.8a.1.1 */ switch (GprsCodingScheme::Scheme(cs)) { case GprsCodingScheme::MCS1: return 0b1011 + punct % EGPRS_MAX_PS_NUM_2; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index c04a84e..d871c4d 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -627,10 +627,16 @@ GprsCodingScheme cs; int bsns[ARRAY_SIZE(rlc.block_info)]; unsigned num_bsns; - enum egprs_puncturing_values punct[ARRAY_SIZE(rlc.block_info)]; bool need_padding = false; enum egprs_rlcmac_dl_spb spb = EGPRS_RLCMAC_DL_NO_RETX; unsigned int spb_status = get_egprs_dl_spb_status(index); + + enum egprs_puncturing_values punct[2] = { + EGPRS_PS_INVALID, EGPRS_PS_INVALID + }; + osmo_static_assert(ARRAY_SIZE(rlc.block_info) == 2, + rlc_block_info_size_is_two); + /* * TODO: This is an experimental work-around to put 2 BSN into * MSC-7 to MCS-9 encoded messages. It just sends the same BSN @@ -763,10 +769,8 @@ } /* Calculate CPS only for EGPRS case */ - if (cs.isEgprs()) { - OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); + if (cs.isEgprs()) rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); - } /* If the TBF has just started, relate frames_since_last_poll to the * current fn */ -- To view, visit https://gerrit.osmocom.org/1775 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I004cbbab15e6ffa2749f4b7f1df651517c2ae693 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar From gerrit-no-reply at lists.osmocom.org Tue Feb 14 15:23:34 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 15:23:34 +0000 Subject: [MERGED] osmo-pcu[master]: dl tbf: calculate CPS only for EGPRS In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: dl tbf: calculate CPS only for EGPRS ...................................................................... dl tbf: calculate CPS only for EGPRS Patch-by: Aravind Sirsikar Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd --- M src/tbf_dl.cpp 1 file changed, 5 insertions(+), 2 deletions(-) Approvals: arvind.sirsikar: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 78f06e9..c04a84e 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -762,8 +762,11 @@ msg_data, block_data); } - OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); - rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); + /* Calculate CPS only for EGPRS case */ + if (cs.isEgprs()) { + OSMO_ASSERT(ARRAY_SIZE(punct) >= 2); + rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding); + } /* If the TBF has just started, relate frames_since_last_poll to the * current fn */ -- To view, visit https://gerrit.osmocom.org/1774 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I81b8e1d10bfe9efba3a9f04bced66f87d93285dd Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:21:47 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 14 Feb 2017 16:21:47 +0000 Subject: [PATCH] osmo-hlr[master]: Move lu_operation into separate file Message-ID: Review at https://gerrit.osmocom.org/1821 Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 272 insertions(+), 197 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1821/1 diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..fbb4bae 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,62 +84,6 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - struct lu_operation *lu_op_by_imsi(const char *imsi) { struct lu_operation *luop; @@ -148,66 +93,6 @@ return luop; } return NULL; -} - -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); } /* timer call-back in case LU operation doesn't receive an response */ @@ -230,40 +115,9 @@ lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); } -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +127,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..210dfce --- /dev/null +++ b/src/luop.c @@ -0,0 +1,197 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..1902386 --- /dev/null +++ b/src/luop.h @@ -0,0 +1,71 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:25:29 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 14 Feb 2017 16:25:29 +0000 Subject: [PATCH] osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1821 to look at the new patch set (#2). Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 306 insertions(+), 230 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1821/2 diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..d1a3664 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,62 +84,6 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - struct lu_operation *lu_op_by_imsi(const char *imsi) { struct lu_operation *luop; @@ -150,120 +95,9 @@ return NULL; } -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/* timer call-back in case LU operation doesn't receive an response */ -static void lu_op_timer_cb(void *data) -{ - struct lu_operation *luop = data; - - DEBUGP(DMAIN, "LU OP timer expired in state %s\n", - get_value_string(lu_state_names, luop->state)); - - switch (luop->state) { - case LU_S_CANCEL_SENT: - break; - case LU_S_ISD_SENT: - break; - default: - break; - } - - lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); -} - -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +107,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ @@ -362,19 +147,6 @@ gsup->message_type); break; } -} - -static struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) -{ - struct lu_operation *luop; - - luop = talloc_zero(srv, struct lu_operation); - OSMO_ASSERT(luop); - luop->gsup_server = srv; - luop->timer.cb = lu_op_timer_cb; - luop->timer.data = luop; - - return luop; } /*! Receive Update Location Request, creates new \ref lu_operation */ diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..7c4057e --- /dev/null +++ b/src/luop.c @@ -0,0 +1,230 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +/* timer call-back in case LU operation doesn't receive an response */ +static void lu_op_timer_cb(void *data) +{ + struct lu_operation *luop = data; + + DEBUGP(DMAIN, "LU OP timer expired in state %s\n", + get_value_string(lu_state_names, luop->state)); + + switch (luop->state) { + case LU_S_CANCEL_SENT: + break; + case LU_S_ISD_SENT: + break; + default: + break; + } + + lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); +} + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) +{ + struct lu_operation *luop; + + luop = talloc_zero(srv, struct lu_operation); + OSMO_ASSERT(luop); + luop->gsup_server = srv; + luop->timer.cb = lu_op_timer_cb; + luop->timer.data = luop; + + return luop; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..6985e54 --- /dev/null +++ b/src/luop.h @@ -0,0 +1,72 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv); +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:47:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 16:47:51 +0000 Subject: osmo-bts[master]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1767 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:47:58 2017 From: gerrit-no-reply at lists.osmocom.org (daniel) Date: Tue, 14 Feb 2017 16:47:58 +0000 Subject: [PATCH] osmo-bts[sysmocom/0.3.5-stable]: tx_power: Change PA calibration tables to use delta vales Message-ID: Review at https://gerrit.osmocom.org/1822 tx_power: Change PA calibration tables to use delta vales It seems more user friendly to look at a calibration table in terms of the delta (positive or negative) compared to the nominal gain value, rather than a collection of absolute gain values. It has the added benefit that the (API/data model) user doesn't have to specify a gain value for each ARFCN, but rather can rely on the default nominal gain in absence of a calibration table for this specific unit. Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad --- M include/osmo-bts/tx_power.h M src/common/tx_power.c 2 files changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/22/1822/1 diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h index 1d76864..8d099bc 100644 --- a/include/osmo-bts/tx_power.h +++ b/include/osmo-bts/tx_power.h @@ -8,7 +8,7 @@ /* PA calibration table */ struct pa_calibration { - int gain_mdB[1024]; /* gain provided at given ARFCN */ + int delta_mdB[1024]; /* gain delta at given ARFCN */ /* FIXME: thermal calibration */ }; diff --git a/src/common/tx_power.c b/src/common/tx_power.c index d8c90b2..f3b9e31 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -33,12 +33,12 @@ static int get_pa_drive_level_mdBm(const struct power_amp *pa, int desired_p_out_mdBm, unsigned int arfcn) { - if (arfcn >= ARRAY_SIZE(pa->calib.gain_mdB)) + if (arfcn >= ARRAY_SIZE(pa->calib.delta_mdB)) return INT_MIN; /* FIXME: temperature compensation */ - return desired_p_out_mdBm - pa->calib.gain_mdB[arfcn]; + return desired_p_out_mdBm - pa->nominal_gain_mdB - pa->calib.delta_mdB[arfcn]; } /* maximum output power of the system */ -- To view, visit https://gerrit.osmocom.org/1822 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: sysmocom/0.3.5-stable Gerrit-Owner: daniel From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:47:58 2017 From: gerrit-no-reply at lists.osmocom.org (daniel) Date: Tue, 14 Feb 2017 16:47:58 +0000 Subject: [PATCH] osmo-bts[sysmocom/0.3.5-stable]: sysmobts: fully support trx_power_params Message-ID: Review at https://gerrit.osmocom.org/1823 sysmobts: fully support trx_power_params The simplistic approach of sysmobts_get_nominal_power() is insufficient to cope for devices that have an internal PA. The Actual transceiver board is driven to a certain level (0..23 dBm typically), and the external PA must be handled independent of that. Increasing the return value of sysmobts_get_nominal_power() would result in the sysmoBTS mainboard attempting to reach a higher power, which is wrong. This change affects sysmoBTS 1020 and 1100. It causes power-ramping to be used by default. For 1002 and 2050, no behavior change is expected. Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 --- M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/main.c M src/osmo-bts-sysmo/sysmobts_vty.c M src/osmo-bts-sysmo/utils.c M src/osmo-bts-sysmo/utils.h 5 files changed, 49 insertions(+), 32 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/23/1823/1 diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 0159607..dc97802 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1200,7 +1201,7 @@ LOGP(DL1C, LOGL_INFO, "Using external attenuator.\n"); sysp->u.activateRfReq.rfTrx.u8UseExtAtten = 1; sysp->u.activateRfReq.rfTrx.fMaxTxPower = - sysmobts_get_nominal_power(trx); + (float) get_p_trxout_target_mdBm(trx, 0) / 1000; } #endif /* 2.2.0 */ #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,8,1) diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 1150310..cb8d5a6 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -47,6 +47,7 @@ #include #include #include +#include #define SYSMOBTS_RF_LOCK_PATH "/var/lock/bts_rf_lock" @@ -63,10 +64,46 @@ static unsigned int dsp_trace = 0x71c00020; static int rt_prio = -1; + +static void set_power_param(struct trx_power_params *out, + int trx_p_max_out_dBm, + int int_pa_nominal_gain_dB) +{ + out->trx_p_max_out_mdBm = to_mdB(trx_p_max_out_dBm); + out->pa.nominal_gain_mdB = to_mdB(int_pa_nominal_gain_dB); +} + +static void fill_trx_power_params(struct gsm_bts_trx *trx, + struct femtol1_hdl *fl1h) +{ + switch (fl1h->hw_info.model_nr) { + case 1020: + set_power_param(&trx->power_params, 23, 10); + break; + case 1100: + set_power_param(&trx->power_params, 23, 17); + break; + case 2050: + set_power_param(&trx->power_params, 37, 0); + break; + default: + LOGP(DL1C, LOGL_NOTICE, "Unknown/Unsupported " + "sysmoBTS Model Number %u\n", + fl1h->hw_info.model_nr); + /* fall-through */ + case 0xffff: + /* sysmoBTS 1002 without any setting in EEPROM */ + LOGP(DL1C, LOGL_NOTICE, "Assuming 1002 for sysmoBTS " + "Model number %u\n", fl1h->hw_info.model_nr); + case 1002: + set_power_param(&trx->power_params, 23, 0); + } +} + int bts_model_init(struct gsm_bts *bts) { struct femtol1_hdl *fl1h; - int rc; + int rc, i; fl1h = l1if_open(bts->c0); if (!fl1h) { @@ -77,7 +114,14 @@ bts->c0->role_bts.l1h = fl1h; - rc = sysmobts_get_nominal_power(bts->c0); + + /* Set power params for each trx */ + for (i = 0; i < bts->num_trx; i++) { + struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, i); + fill_trx_power_params(trx, fl1h); + } + + rc = get_p_max_out_mdBm(bts->c0); if (rc < 0) { LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal " "transmit power. Assuming 23dBm.\n"); diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 8b617d7..2d1b57d 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -546,7 +546,7 @@ VTY_NEWLINE); vty_out(vty, " min-qual-norm %.0f%s", fl1h->min_qual_norm * 10.0f, VTY_NEWLINE); - if (trx->nominal_power != sysmobts_get_nominal_power(trx)) + if (trx->nominal_power != get_p_max_out_mdBm(trx)) vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power, VTY_NEWLINE); diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..be6051a 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -112,29 +112,3 @@ /* give up */ return -1; } - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx) -{ - struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); - - switch (fl1h->hw_info.model_nr) { - case 0: - case 0xffff: - /* old units have empty flash where the model number is - * stored in later units */ - case 1002: - /* 200mW (23 dBm) nominal power */ - return 23; - case 2050: - /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) - * if the second TRX is not used. */ - return 37; - default: - LOGP(DL1C, LOGL_ERROR, "Model number %u/0x%x not known.\n", - fl1h->hw_info.model_nr, fl1h->hw_info.model_nr); - break; - } - return -1; -} - - diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h index 58e3324..45908d5 100644 --- a/src/osmo-bts-sysmo/utils.h +++ b/src/osmo-bts-sysmo/utils.h @@ -9,6 +9,4 @@ int band_femto2osmo(GsmL1_FreqBand_t band); int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn); - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx); #endif -- To view, visit https://gerrit.osmocom.org/1823 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: sysmocom/0.3.5-stable Gerrit-Owner: daniel From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:49:30 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 16:49:30 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1788 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 16:50:11 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 16:50:11 +0000 Subject: [MERGED] osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: osmo-trx-bts: Fix incorrect bts shutdown procedure in case of abis connection closure ...................................................................... osmo-trx-bts: Fix incorrect bts shutdown procedure in case of abis connection closure This issue occurs in case of osmo-nitb restart which leads to abis connection closure. Function bts_shutdown from common/bts.c should be used in this case for proper bts shutdown. Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 --- M src/osmo-bts-trx/l1_if.c 1 file changed, 1 insertion(+), 4 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 6c1969c..abb16eb 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -326,10 +326,7 @@ /* on RSL failure, deactivate transceiver */ void bts_model_abis_close(struct gsm_bts *bts) { - struct gsm_bts_trx *trx; - - llist_for_each_entry(trx, &bts->trx_list, list) - bts_model_trx_close(trx); + bts_shutdown(bts, "Abis close"); } int bts_model_adjst_ms_pwr(struct gsm_lchan *lchan) -- To view, visit https://gerrit.osmocom.org/1788 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id025e703dd5c91896d450d200e88e46552f178f0 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:12:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:12:47 +0000 Subject: osmo-bts[sysmocom/0.3.5-stable]: tx_power: Change PA calibration tables to use delta vales In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1822 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: sysmocom/0.3.5-stable Gerrit-Owner: daniel Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:12:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:12:58 +0000 Subject: osmo-bts[sysmocom/0.3.5-stable]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1823 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: sysmocom/0.3.5-stable Gerrit-Owner: daniel Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:13:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:13:01 +0000 Subject: [MERGED] osmo-bts[sysmocom/0.3.5-stable]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sysmobts: fully support trx_power_params ...................................................................... sysmobts: fully support trx_power_params The simplistic approach of sysmobts_get_nominal_power() is insufficient to cope for devices that have an internal PA. The Actual transceiver board is driven to a certain level (0..23 dBm typically), and the external PA must be handled independent of that. Increasing the return value of sysmobts_get_nominal_power() would result in the sysmoBTS mainboard attempting to reach a higher power, which is wrong. This change affects sysmoBTS 1020 and 1100. It causes power-ramping to be used by default. For 1002 and 2050, no behavior change is expected. Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 --- M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/main.c M src/osmo-bts-sysmo/sysmobts_vty.c M src/osmo-bts-sysmo/utils.c M src/osmo-bts-sysmo/utils.h 5 files changed, 49 insertions(+), 32 deletions(-) Approvals: Harald Welte: Looks good to me, approved; Verified diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 0159607..dc97802 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1200,7 +1201,7 @@ LOGP(DL1C, LOGL_INFO, "Using external attenuator.\n"); sysp->u.activateRfReq.rfTrx.u8UseExtAtten = 1; sysp->u.activateRfReq.rfTrx.fMaxTxPower = - sysmobts_get_nominal_power(trx); + (float) get_p_trxout_target_mdBm(trx, 0) / 1000; } #endif /* 2.2.0 */ #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,8,1) diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 1150310..cb8d5a6 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -47,6 +47,7 @@ #include #include #include +#include #define SYSMOBTS_RF_LOCK_PATH "/var/lock/bts_rf_lock" @@ -63,10 +64,46 @@ static unsigned int dsp_trace = 0x71c00020; static int rt_prio = -1; + +static void set_power_param(struct trx_power_params *out, + int trx_p_max_out_dBm, + int int_pa_nominal_gain_dB) +{ + out->trx_p_max_out_mdBm = to_mdB(trx_p_max_out_dBm); + out->pa.nominal_gain_mdB = to_mdB(int_pa_nominal_gain_dB); +} + +static void fill_trx_power_params(struct gsm_bts_trx *trx, + struct femtol1_hdl *fl1h) +{ + switch (fl1h->hw_info.model_nr) { + case 1020: + set_power_param(&trx->power_params, 23, 10); + break; + case 1100: + set_power_param(&trx->power_params, 23, 17); + break; + case 2050: + set_power_param(&trx->power_params, 37, 0); + break; + default: + LOGP(DL1C, LOGL_NOTICE, "Unknown/Unsupported " + "sysmoBTS Model Number %u\n", + fl1h->hw_info.model_nr); + /* fall-through */ + case 0xffff: + /* sysmoBTS 1002 without any setting in EEPROM */ + LOGP(DL1C, LOGL_NOTICE, "Assuming 1002 for sysmoBTS " + "Model number %u\n", fl1h->hw_info.model_nr); + case 1002: + set_power_param(&trx->power_params, 23, 0); + } +} + int bts_model_init(struct gsm_bts *bts) { struct femtol1_hdl *fl1h; - int rc; + int rc, i; fl1h = l1if_open(bts->c0); if (!fl1h) { @@ -77,7 +114,14 @@ bts->c0->role_bts.l1h = fl1h; - rc = sysmobts_get_nominal_power(bts->c0); + + /* Set power params for each trx */ + for (i = 0; i < bts->num_trx; i++) { + struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, i); + fill_trx_power_params(trx, fl1h); + } + + rc = get_p_max_out_mdBm(bts->c0); if (rc < 0) { LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal " "transmit power. Assuming 23dBm.\n"); diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 8b617d7..2d1b57d 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -546,7 +546,7 @@ VTY_NEWLINE); vty_out(vty, " min-qual-norm %.0f%s", fl1h->min_qual_norm * 10.0f, VTY_NEWLINE); - if (trx->nominal_power != sysmobts_get_nominal_power(trx)) + if (trx->nominal_power != get_p_max_out_mdBm(trx)) vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power, VTY_NEWLINE); diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..be6051a 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -112,29 +112,3 @@ /* give up */ return -1; } - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx) -{ - struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); - - switch (fl1h->hw_info.model_nr) { - case 0: - case 0xffff: - /* old units have empty flash where the model number is - * stored in later units */ - case 1002: - /* 200mW (23 dBm) nominal power */ - return 23; - case 2050: - /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) - * if the second TRX is not used. */ - return 37; - default: - LOGP(DL1C, LOGL_ERROR, "Model number %u/0x%x not known.\n", - fl1h->hw_info.model_nr, fl1h->hw_info.model_nr); - break; - } - return -1; -} - - diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h index 58e3324..45908d5 100644 --- a/src/osmo-bts-sysmo/utils.h +++ b/src/osmo-bts-sysmo/utils.h @@ -9,6 +9,4 @@ int band_femto2osmo(GsmL1_FreqBand_t band); int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn); - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx); #endif -- To view, visit https://gerrit.osmocom.org/1823 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: sysmocom/0.3.5-stable Gerrit-Owner: daniel Gerrit-Reviewer: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:13:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:13:02 +0000 Subject: [MERGED] osmo-bts[sysmocom/0.3.5-stable]: tx_power: Change PA calibration tables to use delta vales In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: tx_power: Change PA calibration tables to use delta vales ...................................................................... tx_power: Change PA calibration tables to use delta vales It seems more user friendly to look at a calibration table in terms of the delta (positive or negative) compared to the nominal gain value, rather than a collection of absolute gain values. It has the added benefit that the (API/data model) user doesn't have to specify a gain value for each ARFCN, but rather can rely on the default nominal gain in absence of a calibration table for this specific unit. Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad --- M include/osmo-bts/tx_power.h M src/common/tx_power.c 2 files changed, 3 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved; Verified diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h index 1d76864..8d099bc 100644 --- a/include/osmo-bts/tx_power.h +++ b/include/osmo-bts/tx_power.h @@ -8,7 +8,7 @@ /* PA calibration table */ struct pa_calibration { - int gain_mdB[1024]; /* gain provided at given ARFCN */ + int delta_mdB[1024]; /* gain delta at given ARFCN */ /* FIXME: thermal calibration */ }; diff --git a/src/common/tx_power.c b/src/common/tx_power.c index d8c90b2..f3b9e31 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -33,12 +33,12 @@ static int get_pa_drive_level_mdBm(const struct power_amp *pa, int desired_p_out_mdBm, unsigned int arfcn) { - if (arfcn >= ARRAY_SIZE(pa->calib.gain_mdB)) + if (arfcn >= ARRAY_SIZE(pa->calib.delta_mdB)) return INT_MIN; /* FIXME: temperature compensation */ - return desired_p_out_mdBm - pa->calib.gain_mdB[arfcn]; + return desired_p_out_mdBm - pa->nominal_gain_mdB - pa->calib.delta_mdB[arfcn]; } /* maximum output power of the system */ -- To view, visit https://gerrit.osmocom.org/1822 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7311815902a88d2fc9d211cf4c62fa6fdc5e86ad Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: sysmocom/0.3.5-stable Gerrit-Owner: daniel Gerrit-Reviewer: Harald Welte From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:31:27 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:31:27 +0000 Subject: [MERGED] osmo-bts[master]: sysmobts: fully support trx_power_params In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: sysmobts: fully support trx_power_params ...................................................................... sysmobts: fully support trx_power_params The simplistic approach of sysmobts_get_nominal_power() is insufficient to cope for devices that have an internal PA. The Actual transceiver board is driven to a certain level (0..23 dBm typically), and the external PA must be handled independent of that. Increasing the return value of sysmobts_get_nominal_power() would result in the sysmoBTS mainboard attempting to reach a higher power, which is wrong. This change affects sysmoBTS 1020 and 1100. It causes power-ramping to be used by default. For 1002 and 2050, no behavior change is expected. Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 --- M src/osmo-bts-sysmo/l1_if.c M src/osmo-bts-sysmo/sysmobts_vty.c M src/osmo-bts-sysmo/utils.c M src/osmo-bts-sysmo/utils.h 4 files changed, 44 insertions(+), 32 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified Holger Freyther: Looks good to me, but someone else must approve diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index c021368..8eb6fcc 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1309,7 +1310,7 @@ LOGP(DL1C, LOGL_INFO, "Using external attenuator.\n"); sysp->u.activateRfReq.rfTrx.u8UseExtAtten = 1; sysp->u.activateRfReq.rfTrx.fMaxTxPower = - sysmobts_get_nominal_power(trx); + (float) get_p_trxout_target_mdBm(trx, 0) / 1000; } #endif /* 2.2.0 */ #if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(3,8,1) @@ -1797,6 +1798,44 @@ #endif +static void set_power_param(struct trx_power_params *out, + int trx_p_max_out_dBm, + int int_pa_nominal_gain_dB) +{ + out->trx_p_max_out_mdBm = to_mdB(trx_p_max_out_dBm); + out->pa.nominal_gain_mdB = to_mdB(int_pa_nominal_gain_dB); +} + +static void fill_trx_power_params(struct gsm_bts_trx *trx, + struct phy_instance *pinst) +{ + struct femtol1_hdl *fl1h = pinst->u.sysmobts.hdl; + + switch (fl1h->hw_info.model_nr) { + case 1020: + set_power_param(&trx->power_params, 23, 10); + break; + case 1100: + set_power_param(&trx->power_params, 23, 17); + break; + case 2050: + set_power_param(&trx->power_params, 37, 0); + break; + default: + LOGP(DL1C, LOGL_NOTICE, "Unknown/Unsupported " + "sysmoBTS Model Number %u\n", + fl1h->hw_info.model_nr); + /* fall-through */ + case 0xffff: + /* sysmoBTS 1002 without any setting in EEPROM */ + LOGP(DL1C, LOGL_NOTICE, "Assuming 1002 for sysmoBTS " + "Model number %u\n", fl1h->hw_info.model_nr); + case 1002: + set_power_param(&trx->power_params, 23, 0); + } +} + + int bts_model_phy_link_open(struct phy_link *plink) { struct phy_instance *pinst = phy_instance_by_num(plink, 0); @@ -1812,16 +1851,17 @@ return -EIO; } + fill_trx_power_params(pinst->trx, pinst); + bts = pinst->trx->bts; if (pinst->trx == bts->c0) { int rc; - rc = sysmobts_get_nominal_power(bts->c0); + rc = get_p_max_out_mdBm(bts->c0); if (rc < 0) { LOGP(DL1C, LOGL_NOTICE, "Cannot determine nominal " "transmit power. Assuming 23dBm.\n"); } bts->c0->nominal_power = rc; - bts->c0->power_params.trx_p_max_out_mdBm = to_mdB(rc); } phy_link_state_set(plink, PHY_LINK_CONNECTED); diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 330c9ce..b5940dc 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -438,7 +438,7 @@ void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx) { - if (trx->nominal_power != sysmobts_get_nominal_power(trx)) + if (trx->nominal_power != get_p_max_out_mdBm(trx)) vty_out(vty, " nominal-tx-power %d%s", trx->nominal_power, VTY_NEWLINE); } diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c index a636ae1..be6051a 100644 --- a/src/osmo-bts-sysmo/utils.c +++ b/src/osmo-bts-sysmo/utils.c @@ -112,29 +112,3 @@ /* give up */ return -1; } - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx) -{ - struct femtol1_hdl *fl1h = trx_femtol1_hdl(trx); - - switch (fl1h->hw_info.model_nr) { - case 0: - case 0xffff: - /* old units have empty flash where the model number is - * stored in later units */ - case 1002: - /* 200mW (23 dBm) nominal power */ - return 23; - case 2050: - /* 5W(37dBm) per TRX. This could be raiesd to 10W(40dBm) - * if the second TRX is not used. */ - return 37; - default: - LOGP(DL1C, LOGL_ERROR, "Model number %u/0x%x not known.\n", - fl1h->hw_info.model_nr, fl1h->hw_info.model_nr); - break; - } - return -1; -} - - diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h index 58e3324..45908d5 100644 --- a/src/osmo-bts-sysmo/utils.h +++ b/src/osmo-bts-sysmo/utils.h @@ -9,6 +9,4 @@ int band_femto2osmo(GsmL1_FreqBand_t band); int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn); - -int sysmobts_get_nominal_power(struct gsm_bts_trx *trx); #endif -- To view, visit https://gerrit.osmocom.org/1767 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ieff75d5becaa80a2097b6e744c75c2d16259c9a4 Gerrit-PatchSet: 6 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:32:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:32:25 +0000 Subject: libosmocore[master]: osmo_hexparse: allow whitespace in parsed string, add ws test In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1820 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:32:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:32:28 +0000 Subject: libosmocore[master]: utils: add hexparse test In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1819 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic95ab00b57d54905a235109561c00419161cf4bc Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:33:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:33:04 +0000 Subject: osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 17:33:43 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 14 Feb 2017 17:33:43 +0000 Subject: osmo-hlr[master]: Move GSUP msg init into separate function In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1814 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 14 23:30:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 23:30:45 +0000 Subject: [MERGED] libosmocore[master]: utils: add hexparse test In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: utils: add hexparse test ...................................................................... utils: add hexparse test Change-Id: Ic95ab00b57d54905a235109561c00419161cf4bc --- M tests/utils/utils_test.c M tests/utils/utils_test.ok 2 files changed, 117 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c index 1a79baa..e3d6221 100644 --- a/tests/utils/utils_test.c +++ b/tests/utils/utils_test.c @@ -43,6 +43,103 @@ printf("%s\n", osmo_hexdump_nospc(data, ARRAY_SIZE(data))); } +static void hexparse_test(void) +{ + int i; + int rc; + uint8_t data[256]; + + printf("\nHexparse 0..255 in lower case\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f" + "505152535455565758595a5b5c5d5e5f" + "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" + "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + + printf("Hexparse 0..255 in upper case\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "000102030405060708090A0B0C0D0E0F" + "101112131415161718191A1B1C1D1E1F" + "202122232425262728292A2B2C2D2E2F" + "303132333435363738393A3B3C3D3E3F" + "404142434445464748494A4B4C4D4E4F" + "505152535455565758595A5B5C5D5E5F" + "606162636465666768696A6B6C6D6E6F" + "707172737475767778797A7B7C7D7E7F" + "808182838485868788898A8B8C8D8E8F" + "909192939495969798999A9B9C9D9E9F" + "A0A1A2A3A4A5A6A7A8A9AAABACADAEAF" + "B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF" + "C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF" + "D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF" + "E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF" + "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + + printf("Hexparse 0..255 in mixed case\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "000102030405060708090A0B0C0D0E0F" + "101112131415161718191A1B1C1D1E1F" + "202122232425262728292A2B2C2D2E2F" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494A4B4C4D4E4F" + "505152535455565758595a5b5c5d5e5f" + "606162636465666768696A6B6C6D6E6F" + "707172737475767778797A7B7C7D7E7F" + "808182838485868788898A8B8C8D8E8F" + "909192939495969798999A9B9C9D9E9F" + "A0A1A2A3a4a5a6a7a8a9AAABACADAEAF" + "B0B1B2B3b4b5b6b7b8b9BABBBCBDBEBF" + "C0C1C2C3c4c5c6c7c8c9CACBCCCDCECF" + "D0D1D2D3d4d5d6d7d8d9DADBDCDDDEDF" + "E0E1E2E3e4e5e6e7e8e9EAEBECEDEEEF" + "F0F1F2F3f4f5f6f7f8f9FAFBFCFDFEFF" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + + printf("Hexparse with buffer too short\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse("000102030405060708090a0b0c0d0e0f", data, 15); + printf("rc = %d\n", rc); + + printf("Hexparse with uneven amount of digits\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse("000102030405060708090a0b0c0d0e0", data, 16); + printf("rc = %d\n", rc); + + printf("Hexparse with invalid char\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse("0001020304050X0708090a0b0c0d0e0f", data, 16); + printf("rc = %d\n", rc); +} + static void test_idtag_parsing(void) { struct tlv_parsed tvp; @@ -103,6 +200,7 @@ log_init(&log_info, NULL); hexdump_test(); + hexparse_test(); test_idtag_parsing(); return 0; } diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok index 50a5747..0f7e7a0 100644 --- a/tests/utils/utils_test.ok +++ b/tests/utils/utils_test.ok @@ -3,3 +3,22 @@ Corner case 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe + +Hexparse 0..255 in lower case +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + +Hexparse 0..255 in upper case +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + +Hexparse 0..255 in mixed case +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + +Hexparse with buffer too short +rc = -1 +Hexparse with uneven amount of digits +rc = -1 +Hexparse with invalid char +rc = -1 -- To view, visit https://gerrit.osmocom.org/1819 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic95ab00b57d54905a235109561c00419161cf4bc Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 14 23:30:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 14 Feb 2017 23:30:46 +0000 Subject: [MERGED] libosmocore[master]: osmo_hexparse: allow whitespace in parsed string, add ws test In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmo_hexparse: allow whitespace in parsed string, add ws test ...................................................................... osmo_hexparse: allow whitespace in parsed string, add ws test This is particularly useful for hex dumps containing spaces found in a log (e.g. osmo-nitb authentication rand token), which can now be passed in quotes to osmo-auc-gen without having to edit the spaces away. Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 --- M src/utils.c M tests/utils/utils_test.c M tests/utils/utils_test.ok 3 files changed, 51 insertions(+), 9 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/utils.c b/src/utils.c index 34b2bca..1a4aab4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -127,16 +127,22 @@ int osmo_hexparse(const char *str, uint8_t *b, int max_len) { - int i, l, v; - - l = strlen(str); - if ((l&1) || ((l>>1) > max_len)) - return -1; + char c; + uint8_t v; + const char *strpos; + unsigned int nibblepos = 0; memset(b, 0x00, max_len); - for (i=0; i= (max_len << 1)) + return -1; + if (c >= '0' && c <= '9') v = c - '0'; else if (c >= 'a' && c <= 'f') @@ -145,10 +151,17 @@ v = 10 + (c - 'A'); else return -1; - b[i>>1] |= v << (i&1 ? 0 : 4); + + b[nibblepos >> 1] |= v << (nibblepos & 1 ? 0 : 4); + nibblepos ++; } - return i>>1; + /* In case of uneven amount of digits, the last byte is not complete + * and that's an error. */ + if (nibblepos & 1) + return -1; + + return nibblepos >> 1; } static char hexd_buff[4096]; diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c index e3d6221..cad162d 100644 --- a/tests/utils/utils_test.c +++ b/tests/utils/utils_test.c @@ -124,6 +124,31 @@ for (i = 0; i < sizeof(data); i++) OSMO_ASSERT(data[i] == i); + printf("Hexparse 0..255 with whitespace\n"); + memset(data, 0, sizeof(data)); + rc = osmo_hexparse( + "00 01\t02\r030405060708090A0B0C0D0 E 0 F\n" + "10 11\t12\r131415161718191A1B1C1D1 E 1 F\n" + "20 21\t22\r232425262728292A2B2C2D2 E 2 F\n" + "30 31\t32\r333435363738393a3b3c3d3 e 3 f\n" + "40 41\t42\r434445464748494A4B4C4D4 E 4 F\n" + "50 51\t52\r535455565758595a5b5c5d5 e 5 f\n" + "60 61\t62\r636465666768696A6B6C6D6 E 6 F\n" + "70 71\t72\r737475767778797A7B7C7D7 E 7 F\n" + "80 81\t82\r838485868788898A8B8C8D8 E 8 F\n" + "90 91\t92\r939495969798999A9B9C9D9 E 9 F\n" + "A0 A1\tA2\rA3a4a5a6a7a8a9AAABACADA E A F\n" + "B0 B1\tB2\rB3b4b5b6b7b8b9BABBBCBDB E B F\n" + "C0 C1\tC2\rC3c4c5c6c7c8c9CACBCCCDC E C F \n" + "D0 D1\tD2\rD3d4d5d6d7d8d9DADBDCDDD E D F\t\n" + "E0 E1\tE2\rE3e4e5e6e7e8e9EAEBECEDE E E F \t\n" + "F0 F1\tF2\rF3f4f5f6f7f8f9FAFBFCFDF E F F \t\r\n" + , data, sizeof(data)); + printf("rc = %d\n", rc); + printf("--> %s\n\n", osmo_hexdump(data, sizeof(data))); + for (i = 0; i < sizeof(data); i++) + OSMO_ASSERT(data[i] == i); + printf("Hexparse with buffer too short\n"); memset(data, 0, sizeof(data)); rc = osmo_hexparse("000102030405060708090a0b0c0d0e0f", data, 15); diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok index 0f7e7a0..e9be018 100644 --- a/tests/utils/utils_test.ok +++ b/tests/utils/utils_test.ok @@ -16,6 +16,10 @@ rc = 256 --> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff +Hexparse 0..255 with whitespace +rc = 256 +--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff + Hexparse with buffer too short rc = -1 Hexparse with uneven amount of digits -- To view, visit https://gerrit.osmocom.org/1820 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib7af07f674a2d26c8569acdee98835fb3e626c45 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 00:17:09 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 15 Feb 2017 00:17:09 +0000 Subject: [PATCH] openbsc[master]: cosmetic: prepare for llist_first/_last in libosmocore Message-ID: Review at https://gerrit.osmocom.org/1824 cosmetic: prepare for llist_first/_last in libosmocore I would like to move the llist_first and llist_last macros from gtphub.c to libosmocore with change-id I296b7cf1c7cb07b24c2e17084b03fed321c53a7c. To avoid compiler warnings, encapsulate the gtphub.c definitions in an #ifndef. Change-Id: I8afaad471eb38d897184ea53cb1f4d10850e35eb --- M openbsc/src/gprs/gtphub.c 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/24/1824/1 diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index a1aaed2..03aca74 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -58,6 +58,7 @@ typedef int (*osmo_fd_cb_t)(struct osmo_fd *fd, unsigned int what); /* TODO move this to osmocom/core/linuxlist.h ? */ +#ifndef __llist_first #define __llist_first(head) (((head)->next == (head)) ? NULL : (head)->next) #define llist_first(head, type, entry) \ llist_entry(__llist_first(head), type, entry) @@ -65,6 +66,7 @@ #define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev) #define llist_last(head, type, entry) \ llist_entry(__llist_last(head), type, entry) +#endif /* TODO move GTP header stuff to openggsn/gtp/ ? See gtp_decaps*() */ @@ -611,7 +613,7 @@ OSMO_ASSERT(llist_empty(&exq->items) || (item->expiry - >= llist_last(&exq->items, struct expiring_item, entry)->expiry)); + >= _llist_last(&exq->items, struct expiring_item, entry)->expiry)); /* Add/move to the tail to always sort by expiry, ascending. */ llist_del(&item->entry); @@ -1133,7 +1135,7 @@ if (llist_empty(&peer->addresses)) return "(addressless)"; - struct gtphub_peer_addr *a = llist_first(&peer->addresses, + struct gtphub_peer_addr *a = _llist_first(&peer->addresses, struct gtphub_peer_addr, entry); return gsn_addr_to_strb(&a->addr, buf, buflen); -- To view, visit https://gerrit.osmocom.org/1824 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8afaad471eb38d897184ea53cb1f4d10850e35eb Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 00:17:16 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 15 Feb 2017 00:17:16 +0000 Subject: [PATCH] openbsc[master]: remove llist_first/last from gtphub.c, now in libosmocore Message-ID: Review at https://gerrit.osmocom.org/1825 remove llist_first/last from gtphub.c, now in libosmocore Change-Id: Ie682c681f6a785690b660ca31fae2c3893f49846 Depends: libosmocore change-id I296b7cf1c7cb07b24c2e17084b03fed321c53a7c --- M openbsc/src/gprs/gtphub.c 1 file changed, 0 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/25/1825/1 diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index 03aca74..5cb2ad7 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -57,17 +57,6 @@ /* TODO move this to osmocom/core/select.h ? */ typedef int (*osmo_fd_cb_t)(struct osmo_fd *fd, unsigned int what); -/* TODO move this to osmocom/core/linuxlist.h ? */ -#ifndef __llist_first -#define __llist_first(head) (((head)->next == (head)) ? NULL : (head)->next) -#define llist_first(head, type, entry) \ - llist_entry(__llist_first(head), type, entry) - -#define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev) -#define llist_last(head, type, entry) \ - llist_entry(__llist_last(head), type, entry) -#endif - /* TODO move GTP header stuff to openggsn/gtp/ ? See gtp_decaps*() */ enum gtp_rc { -- To view, visit https://gerrit.osmocom.org/1825 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie682c681f6a785690b660ca31fae2c3893f49846 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 00:17:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 15 Feb 2017 00:17:28 +0000 Subject: [PATCH] libosmocore[master]: linuxlist: add llist_first and llist_last macros Message-ID: Review at https://gerrit.osmocom.org/1826 linuxlist: add llist_first and llist_last macros Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c --- M include/osmocom/core/linuxlist.h 1 file changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/1826/1 diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h index affa827..6b91bc3 100644 --- a/include/osmocom/core/linuxlist.h +++ b/include/osmocom/core/linuxlist.h @@ -367,6 +367,36 @@ return i; } +/*! \brief return the first list item, if any. + * \param head The llist head to take the first item of. + * \returns struct llist_head pointer of first item, or NULL if empty. + */ +#define __llist_first(head) (((head)->next == (head)) ? NULL : (head)->next) + +/*! \brief return the first list item, if any. + * \param head The llist head to take the first item of. + * \param type The struct type of entries kept in this list. + * \param member The name of the \ref llist_head within struct \a pos + * \returns first item, or NULL if empty. + */ +#define llist_first(head, type, member) \ + llist_entry(__llist_first(head), type, member) + +/*! \brief return the last list item, if any. + * \param head The llist head to take the last item of. + * \returns struct llist_head pointer of last item, or NULL if empty. + */ +#define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev) + +/*! \brief return the last list item, if any. + * \param head The llist head to take the last item of. + * \param type The struct type of entries kept in this list. + * \param member The name of the \ref llist_head within struct \a pos + * \returns last item, or NULL if empty. + */ +#define llist_last(head, type, member) \ + llist_entry(__llist_last(head), type, member) + /*! * }@ */ -- To view, visit https://gerrit.osmocom.org/1826 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 00:20:43 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 15 Feb 2017 00:20:43 +0000 Subject: [PATCH] openbsc[master]: cosmetic: prepare for llist_first/_last in libosmocore In-Reply-To: References: Message-ID: cosmetic: prepare for llist_first/_last in libosmocore I would like to move the llist_first and llist_last macros from gtphub.c to libosmocore with change-id I296b7cf1c7cb07b24c2e17084b03fed321c53a7c. To avoid compiler warnings, encapsulate the gtphub.c definitions in an #ifndef. Change-Id: I8afaad471eb38d897184ea53cb1f4d10850e35eb --- M openbsc/src/gprs/gtphub.c 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/24/1824/2 diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index a1aaed2..88cf048 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -58,6 +58,7 @@ typedef int (*osmo_fd_cb_t)(struct osmo_fd *fd, unsigned int what); /* TODO move this to osmocom/core/linuxlist.h ? */ +#ifndef __llist_first #define __llist_first(head) (((head)->next == (head)) ? NULL : (head)->next) #define llist_first(head, type, entry) \ llist_entry(__llist_first(head), type, entry) @@ -65,6 +66,7 @@ #define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev) #define llist_last(head, type, entry) \ llist_entry(__llist_last(head), type, entry) +#endif /* TODO move GTP header stuff to openggsn/gtp/ ? See gtp_decaps*() */ -- To view, visit https://gerrit.osmocom.org/1824 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I8afaad471eb38d897184ea53cb1f4d10850e35eb Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 15 02:03:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 15 Feb 2017 02:03:23 +0000 Subject: [PATCH] libosmocore[master]: linuxlist: add llist_first and llist_last macros In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1826 to look at the new patch set (#2). linuxlist: add llist_first and llist_last macros Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c --- M include/osmocom/core/linuxlist.h 1 file changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/1826/2 diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h index affa827..1d6af17 100644 --- a/include/osmocom/core/linuxlist.h +++ b/include/osmocom/core/linuxlist.h @@ -367,6 +367,36 @@ return i; } +/*! \brief return the first list item, if any. + * \param head The llist head to take the first item of. + * \returns struct llist_head pointer of first item, or NULL if empty. + */ +#define __llist_first(head) (((head)->next == (head)) ? NULL : (head)->next) + +/*! \brief return the first list item, if any. + * \param head The llist head to take the first item of. + * \param type The struct type of entries kept in this list. + * \param member The name of the \ref llist_head within \a type + * \returns first item, or NULL if empty. + */ +#define llist_first(head, type, member) \ + llist_entry(__llist_first(head), type, member) + +/*! \brief return the last list item, if any. + * \param head The llist head to take the last item of. + * \returns struct llist_head pointer of last item, or NULL if empty. + */ +#define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev) + +/*! \brief return the last list item, if any. + * \param head The llist head to take the last item of. + * \param type The struct type of entries kept in this list. + * \param member The name of the \ref llist_head within \a type + * \returns last item, or NULL if empty. + */ +#define llist_last(head, type, member) \ + llist_entry(__llist_last(head), type, member) + /*! * }@ */ -- To view, visit https://gerrit.osmocom.org/1826 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 15 09:23:19 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 09:23:19 +0000 Subject: [MERGED] osmo-hlr[master]: Move GSUP msg init into separate function In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: Move GSUP msg init into separate function ...................................................................... Move GSUP msg init into separate function * move common copy-pasted code to initialize GSUP message into static function * use osmo_strlcpy() to copy imsi for added safety Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 --- M src/hlr.c 1 file changed, 15 insertions(+), 12 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/hlr.c b/src/hlr.c index 2fa27c3..206ddc1 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -181,6 +181,17 @@ msg_out); } +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + /*! Transmit UPD_LOC_ERROR and destroy lu_operation */ void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) { @@ -190,10 +201,7 @@ luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, cause)); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR; - strncpy((char*)&gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)); - gsup.imsi[sizeof(gsup.imsi)-1] = '\0'; + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); gsup.cause = cause; _luop_tx_gsup(luop, &gsup); @@ -227,9 +235,7 @@ { struct osmo_gsup_message gsup; - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); //FIXME gsup.hlr_enc; _luop_tx_gsup(luop, &gsup); @@ -245,8 +251,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST; + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); //gsup.cause = FIXME; //gsup.cancel_type = FIXME; @@ -281,9 +286,7 @@ OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || luop->state == LU_S_CANCEL_ACK_RECEIVED); - memset(&gsup, 0, sizeof(gsup)); - gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST; - strncpy(gsup.imsi, luop->subscr.imsi, sizeof(gsup.imsi)-1); + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, luop->subscr.msisdn); -- To view, visit https://gerrit.osmocom.org/1814 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icd6e2479aa111ff820d53711222d46c6522033e6 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Wed Feb 15 09:26:55 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 09:26:55 +0000 Subject: libosmocore[master]: linuxlist: add llist_first and llist_last macros In-Reply-To: References: Message-ID: Patch Set 2: How will this behave in case of single element list? Shall we add test for list-first(x) == list_last(x)? -- To view, visit https://gerrit.osmocom.org/1826 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 09:51:41 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 09:51:41 +0000 Subject: [PATCH] osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1821 to look at the new patch set (#3). Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 322 insertions(+), 242 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1821/3 diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..8c9eeb8 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,187 +84,9 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - -struct lu_operation *lu_op_by_imsi(const char *imsi) -{ - struct lu_operation *luop; - - llist_for_each_entry(luop, &g_lu_ops, list) { - if (!strcmp(imsi, luop->subscr.imsi)) - return luop; - } - return NULL; -} - -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/* timer call-back in case LU operation doesn't receive an response */ -static void lu_op_timer_cb(void *data) -{ - struct lu_operation *luop = data; - - DEBUGP(DMAIN, "LU OP timer expired in state %s\n", - get_value_string(lu_state_names, luop->state)); - - switch (luop->state) { - case LU_S_CANCEL_SENT: - break; - case LU_S_ISD_SENT: - break; - default: - break; - } - - lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); -} - -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +96,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ @@ -362,19 +136,6 @@ gsup->message_type); break; } -} - -static struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) -{ - struct lu_operation *luop; - - luop = talloc_zero(srv, struct lu_operation); - OSMO_ASSERT(luop); - luop->gsup_server = srv; - luop->timer.cb = lu_op_timer_cb; - luop->timer.data = luop; - - return luop; } /*! Receive Update Location Request, creates new \ref lu_operation */ @@ -508,7 +269,8 @@ case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT: { - struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); + struct lu_operation *luop = lu_op_by_imsi(gsup.imsi, + &g_lu_ops); if (!luop) { LOGP(DMAIN, LOGL_ERROR, "GSUP message %u for " "unknown IMSI %s\n", gsup.message_type, diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..ef845d0 --- /dev/null +++ b/src/luop.c @@ -0,0 +1,242 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +/* timer call-back in case LU operation doesn't receive an response */ +static void lu_op_timer_cb(void *data) +{ + struct lu_operation *luop = data; + + DEBUGP(DMAIN, "LU OP timer expired in state %s\n", + get_value_string(lu_state_names, luop->state)); + + switch (luop->state) { + case LU_S_CANCEL_SENT: + break; + case LU_S_ISD_SENT: + break; + default: + break; + } + + lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); +} + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) +{ + struct lu_operation *luop; + + luop = talloc_zero(srv, struct lu_operation); + OSMO_ASSERT(luop); + luop->gsup_server = srv; + luop->timer.cb = lu_op_timer_cb; + luop->timer.data = luop; + + return luop; +} + +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst) +{ + struct lu_operation *luop; + + llist_for_each_entry(luop, lst, list) { + if (!strcmp(imsi, luop->subscr.imsi)) + return luop; + } + return NULL; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..fea6e2f --- /dev/null +++ b/src/luop.h @@ -0,0 +1,74 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv); +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 10:33:42 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 10:33:42 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface Message-ID: Review at https://gerrit.osmocom.org/1827 Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/gsup_server.c M src/gsup_server.h M src/hlr.c 7 files changed, 160 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/1 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..ad744c6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -19,6 +20,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -32,6 +34,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -48,6 +51,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..55c0b4c --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,78 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "db.h" +#include "ctrl.h" + +static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd) +{ + struct hlr_subscriber *subscr = { 0 }; + + /* check if subscriber is known at all */ + if (db_subscr_get(gs->dbc, cmd->value, subscr) < 0) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = subscr->nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_RO(status_ps, "status-ps"); +static int get_status_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd); +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(gs, addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..95b58be --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs); diff --git a/src/gsup_server.c b/src/gsup_server.c index ea51f7d..90742c5 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -27,6 +27,7 @@ #include "gsup_server.h" #include "gsup_router.h" +#include "ctrl.h" static void osmo_gsup_server_send(struct osmo_gsup_conn *conn, int proto_ext, struct msgb *msg_tx) @@ -245,9 +246,10 @@ } struct osmo_gsup_server * -osmo_gsup_server_create(void *ctx, const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb) +osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, struct db_context *dbc, + struct llist_head *lu_op_lst) { struct osmo_gsup_server *gsups; int rc; @@ -272,6 +274,15 @@ if (rc < 0) goto failed; + gsups->dbc = dbc; + gsups->luop = lu_op_lst; + + if (ctrl_addr) + gsups->ctrl = hlr_controlif_setup(ctrl_addr, gsups); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + return gsups; failed: @@ -286,5 +297,8 @@ ipa_server_link_destroy(gsups->link); gsups->link = NULL; } + + db_close(gsups->dbc); + talloc_free(gsups); } diff --git a/src/gsup_server.h b/src/gsup_server.h index 484a0d7..ae303f5 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -5,6 +5,8 @@ #include #include +#include "db.h" + struct osmo_gsup_conn; /* Expects message in msg->l2h */ @@ -14,9 +16,18 @@ /* list of osmo_gsup_conn */ struct llist_head clients; + /* DB context */ + struct db_context *dbc; + + /* lu_operations list */ + struct llist_head *luop; + struct ipa_server_link *link; osmo_gsup_read_cb_t read_cb; struct llist_head routes; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; @@ -35,10 +46,12 @@ int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr, uint8_t tag); -struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, - const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb); +struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, const char *ip_addr, + uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, + struct db_context *dbc, + struct llist_head *lu_op_lst); void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); diff --git a/src/hlr.c b/src/hlr.c index 8c9eeb8..eb9f31e 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -34,6 +34,7 @@ #include #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -304,16 +305,19 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -i --ctrl address Set address to which Control Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { const char *config_file; const char *db_file; + const char *addr; bool daemonize; } cmdline_opts = { .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", + .addr = "127.0.0.1", .daemonize = false, }; @@ -329,12 +333,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'i'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:i:TV", long_options, &option_index); if (c == -1) break; @@ -349,6 +354,9 @@ break; case 'l': cmdline_opts.db_file = optarg; + break; + case 'i': + cmdline_opts.addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -387,7 +395,6 @@ case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); osmo_gsup_server_destroy(gs); - db_close(g_dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -450,7 +457,8 @@ exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb, + cmdline_opts.addr, g_dbc, &g_lu_ops); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); @@ -472,7 +480,7 @@ osmo_select_main(0); } - db_close(g_dbc); + osmo_gsup_server_destroy(gs); log_fini(); -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Wed Feb 15 12:54:19 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 12:54:19 +0000 Subject: [PATCH] openbsc[master]: Add support for extended SI2q parameters Message-ID: Review at https://gerrit.osmocom.org/1828 Add support for extended SI2q parameters * add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1 * deprecate old command which does not support those parameters Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Fixes: RT#8792 --- M openbsc/src/libbsc/bsc_vty.c 1 file changed, 89 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/28/1828/1 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 00acbc7..8a34591 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -541,6 +541,7 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) { int i; + uint8_t tmp; vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); @@ -694,15 +695,23 @@ } for (i = 0; i < MAX_EARFCN_LIST; i++) { - if (bts->si_common.si2quater_neigh_list.arfcn[i] != - OSMO_EARFCN_INVALID) { - vty_out(vty, " si2quater neighbor-list add earfcn %u threshold %u", - bts->si_common.si2quater_neigh_list.arfcn[i], - bts->si_common.si2quater_neigh_list.thresh_hi); - if (bts->si_common.si2quater_neigh_list.meas_bw[i] != - OSMO_EARFCN_MEAS_INVALID) - vty_out(vty, " %u", - bts->si_common.si2quater_neigh_list.meas_bw[i]); + struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; + if (e->arfcn[i] != OSMO_EARFCN_INVALID) { + vty_out(vty, " si2quater neighbor-list add earfcn %u " + "thresh-hi %u", e->arfcn[i], e->thresh_hi); + + vty_out(vty, " thresh-lo %u", + e->thresh_lo_valid ? e->thresh_lo : 32); + + vty_out(vty, " prio %u", + e->prio_valid ? e->prio : 8); + + vty_out(vty, " qrxlv %u", + e->qrxlm_valid ? e->qrxlm : 32); + + tmp = e->meas_bw[i]; + vty_out(vty, " meas %u", + (tmp != OSMO_EARFCN_MEAS_INVALID) ? tmp : 8); vty_out(vty, "%s", VTY_NEWLINE); } @@ -2746,8 +2755,77 @@ return CMD_SUCCESS; } - DEFUN(cfg_bts_si2quater_neigh_add, cfg_bts_si2quater_neigh_add_cmd, + "si2quater neighbor-list add earfcn <0-65535> thresh-hi <0-31> " + "thresh-lo <0-32> prio <0-8> qrxlv <0-32> meas <0-8>", + "SI2quater Neighbor List\n" "SI2quater Neighbor List\n" + "Add to manual SI2quater neighbor list\n" + "EARFCN of neighbor\n" "EARFCN of neighbor\n" + "threshold high bits\n" "threshold high bits\n" + "threshold low bits\n" "threshold low bits (32 means NA)\n" + "priority\n" "priority (8 means NA)\n" + "QRXLEVMIN\n" "QRXLEVMIN (32 means NA)\n" + "measurement bandwidth\n" "measurement bandwidth (8 means NA)\n") +{ + struct gsm_bts *bts = vty->index; + struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; + uint16_t arfcn = atoi(argv[0]); + uint8_t thresh_hi = atoi(argv[1]), thresh_lo = atoi(argv[2]), + prio = atoi(argv[3]), qrx = atoi(argv[4]), meas = atoi(argv[5]); + int r = osmo_earfcn_add(e, arfcn, + (meas < 8) ? meas : OSMO_EARFCN_MEAS_INVALID); + + if (r < 0) { + vty_out(vty, "Unable to add ARFCN %u: %s%s", arfcn, strerror(-r), + VTY_NEWLINE); + return CMD_WARNING; + } + + if (e->thresh_hi && thresh_hi != e->thresh_hi) + vty_out(vty, "Warning: multiple threshold-high are not " + "supported, overriding previous threshold %u%s", + e->thresh_hi, VTY_NEWLINE); + + e->thresh_hi = thresh_hi; + + if (thresh_lo != 32) { + if (e->thresh_lo_valid && e->thresh_lo != thresh_lo) + vty_out(vty, "Warning: multiple threshold-low are not " + "supported, overriding previous threshold %u%s", + e->thresh_lo, VTY_NEWLINE); + e->thresh_lo = thresh_lo; + e->thresh_lo_valid = true; + } + + if (qrx != 32) { + if (e->qrxlm_valid && e->qrxlm != qrx) + vty_out(vty, "Warning: multiple QRXLEVMIN are not " + "supported, overriding previous value %u%s", + e->qrxlm, VTY_NEWLINE); + e->qrxlm = qrx; + e->qrxlm_valid = true; + } + + if (prio != 8) { + if (e->prio_valid && e->prio != prio) + vty_out(vty, "Warning: multiple priorities are not " + "supported, overriding previous value %u%s", + e->prio, VTY_NEWLINE); + e->prio = prio; + e->prio_valid = true; + } + + if (si2q_size_check(bts)) + return CMD_SUCCESS; + + vty_out(vty, "Warning: not enough space in SI2quater for a given EARFCN " + "%u%s", arfcn, VTY_NEWLINE); + osmo_earfcn_del(e, arfcn); + + return CMD_WARNING; +} + +DEFUN_DEPRECATED(cfg_bts_si2quater_neigh_old, cfg_bts_si2quater_neigh_old_cmd, "si2quater neighbor-list add earfcn <0-65535> threshold <0-31> " "[<0-7>]", "SI2quater Neighbor List\n" "SI2quater Neighbor List\n" "Add to manual SI2quater neighbor list\n" @@ -3981,6 +4059,7 @@ install_element(BTS_NODE, &cfg_bts_neigh_cmd); install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd); install_element(BTS_NODE, &cfg_bts_si2quater_neigh_add_cmd); + install_element(BTS_NODE, &cfg_bts_si2quater_neigh_old_cmd); install_element(BTS_NODE, &cfg_bts_si2quater_neigh_del_cmd); install_element(BTS_NODE, &cfg_bts_si2quater_uarfcn_add_cmd); install_element(BTS_NODE, &cfg_bts_si2quater_uarfcn_del_cmd); -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Wed Feb 15 15:08:48 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 15:08:48 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1827 to look at the new patch set (#2). Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/gsup_server.c M src/gsup_server.h M src/hlr.c 7 files changed, 172 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/2 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..ad744c6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -19,6 +20,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -32,6 +34,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -48,6 +51,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..a0fcfb3 --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,88 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "logging.h" +#include "db.h" +#include "luop.h" +#include "ctrl.h" + +static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd) +{ + struct lu_operation *luop = lu_op_alloc(gs); + + DEBUGP(DMAIN, "Checking status for IMSI %s among %u subscribers\n", + cmd->value, llist_count(gs->luop)); + + if (!luop) { + cmd->reply = "Internal HLR error"; + return CTRL_CMD_ERROR; + } + + /* check if subscriber is known at all */ + if (!lu_op_fill_subscr(luop, gs->dbc, cmd->value)) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = luop->subscr.nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); +static int set_status_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd); +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(gs, addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..95b58be --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs); diff --git a/src/gsup_server.c b/src/gsup_server.c index ea51f7d..90742c5 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -27,6 +27,7 @@ #include "gsup_server.h" #include "gsup_router.h" +#include "ctrl.h" static void osmo_gsup_server_send(struct osmo_gsup_conn *conn, int proto_ext, struct msgb *msg_tx) @@ -245,9 +246,10 @@ } struct osmo_gsup_server * -osmo_gsup_server_create(void *ctx, const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb) +osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, struct db_context *dbc, + struct llist_head *lu_op_lst) { struct osmo_gsup_server *gsups; int rc; @@ -272,6 +274,15 @@ if (rc < 0) goto failed; + gsups->dbc = dbc; + gsups->luop = lu_op_lst; + + if (ctrl_addr) + gsups->ctrl = hlr_controlif_setup(ctrl_addr, gsups); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + return gsups; failed: @@ -286,5 +297,8 @@ ipa_server_link_destroy(gsups->link); gsups->link = NULL; } + + db_close(gsups->dbc); + talloc_free(gsups); } diff --git a/src/gsup_server.h b/src/gsup_server.h index 484a0d7..ae303f5 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -5,6 +5,8 @@ #include #include +#include "db.h" + struct osmo_gsup_conn; /* Expects message in msg->l2h */ @@ -14,9 +16,18 @@ /* list of osmo_gsup_conn */ struct llist_head clients; + /* DB context */ + struct db_context *dbc; + + /* lu_operations list */ + struct llist_head *luop; + struct ipa_server_link *link; osmo_gsup_read_cb_t read_cb; struct llist_head routes; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; @@ -35,10 +46,12 @@ int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr, uint8_t tag); -struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, - const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb); +struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, const char *ip_addr, + uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, + struct db_context *dbc, + struct llist_head *lu_op_lst); void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); diff --git a/src/hlr.c b/src/hlr.c index 36d84b4..f2f6ceb 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -34,6 +34,7 @@ #include #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -210,8 +211,8 @@ bool is_ps = false; int rc; - LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s)\n", gsup->imsi, - is_ps ? "PS" : "CS"); + LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s), %u subscribers left\n", + gsup->imsi, is_ps ? "PS" : "CS", llist_count(&g_lu_ops)); memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi)); @@ -302,16 +303,19 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -i --ctrl address Set address to which Control Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { const char *config_file; const char *db_file; + const char *addr; bool daemonize; } cmdline_opts = { .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", + .addr = "127.0.0.1", .daemonize = false, }; @@ -327,12 +331,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'i'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:i:TV", long_options, &option_index); if (c == -1) break; @@ -347,6 +352,9 @@ break; case 'l': cmdline_opts.db_file = optarg; + break; + case 'i': + cmdline_opts.addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -385,7 +393,6 @@ case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); osmo_gsup_server_destroy(gs); - db_close(g_dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -448,7 +455,8 @@ exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb, + cmdline_opts.addr, g_dbc, &g_lu_ops); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); @@ -470,7 +478,7 @@ osmo_select_main(0); } - db_close(g_dbc); + osmo_gsup_server_destroy(gs); log_fini(); -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 15 15:08:48 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 15:08:48 +0000 Subject: [PATCH] osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1821 to look at the new patch set (#4). Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 344 insertions(+), 249 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1821/4 diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..36d84b4 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -19,7 +19,7 @@ #include #include - +#include #include #include @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,187 +84,9 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - -struct lu_operation *lu_op_by_imsi(const char *imsi) -{ - struct lu_operation *luop; - - llist_for_each_entry(luop, &g_lu_ops, list) { - if (!strcmp(imsi, luop->subscr.imsi)) - return luop; - } - return NULL; -} - -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/* timer call-back in case LU operation doesn't receive an response */ -static void lu_op_timer_cb(void *data) -{ - struct lu_operation *luop = data; - - DEBUGP(DMAIN, "LU OP timer expired in state %s\n", - get_value_string(lu_state_names, luop->state)); - - switch (luop->state) { - case LU_S_CANCEL_SENT: - break; - case LU_S_ISD_SENT: - break; - default: - break; - } - - lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); -} - -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +96,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ @@ -364,26 +138,12 @@ } } -static struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) -{ - struct lu_operation *luop; - - luop = talloc_zero(srv, struct lu_operation); - OSMO_ASSERT(luop); - luop->gsup_server = srv; - luop->timer.cb = lu_op_timer_cb; - luop->timer.data = luop; - - return luop; -} - /*! Receive Update Location Request, creates new \ref lu_operation */ static int rx_upd_loc_req(struct osmo_gsup_conn *conn, const struct osmo_gsup_message *gsup) { int rc; struct lu_operation *luop; - struct hlr_subscriber *subscr; uint8_t *peer_addr; rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); @@ -395,7 +155,7 @@ luop = lu_op_alloc(conn->server); luop->peer = talloc_memdup(luop, peer_addr, rc); lu_op_statechg(luop, LU_S_LU_RECEIVED); - subscr = &luop->subscr; + if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS) luop->is_ps = true; llist_add(&luop->list, &g_lu_ops); @@ -403,8 +163,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - rc = db_subscr_get(g_dbc, gsup->imsi, subscr); - if (rc < 0) { + if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -413,10 +172,10 @@ /* Check if subscriber is generally permitted on CS or PS * service (as requested) */ - if (!luop->is_ps && !subscr->nam_cs) { + if (!luop->is_ps && !luop->subscr.nam_cs) { lu_op_tx_error(luop, GMM_CAUSE_PLMN_NOTALLOWED); return 0; - } else if (luop->is_ps && !subscr->nam_ps) { + } else if (luop->is_ps && !luop->subscr.nam_ps) { lu_op_tx_error(luop, GMM_CAUSE_GPRS_NOTALLOWED); return 0; } @@ -508,7 +267,8 @@ case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT: { - struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); + struct lu_operation *luop = lu_op_by_imsi(gsup.imsi, + &g_lu_ops); if (!luop) { LOGP(DMAIN, LOGL_ERROR, "GSUP message %u for " "unknown IMSI %s\n", gsup.message_type, diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..5c7252b --- /dev/null +++ b/src/luop.c @@ -0,0 +1,254 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +/* timer call-back in case LU operation doesn't receive an response */ +static void lu_op_timer_cb(void *data) +{ + struct lu_operation *luop = data; + + DEBUGP(DMAIN, "LU OP timer expired in state %s\n", + get_value_string(lu_state_names, luop->state)); + + switch (luop->state) { + case LU_S_CANCEL_SENT: + break; + case LU_S_ISD_SENT: + break; + default: + break; + } + + lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); +} + +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi) +{ + struct hlr_subscriber *subscr = &luop->subscr; + + if (db_subscr_get(dbc, imsi, subscr) < 0) + return false; + + return true; +} + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) +{ + struct lu_operation *luop; + + luop = talloc_zero(srv, struct lu_operation); + OSMO_ASSERT(luop); + luop->gsup_server = srv; + luop->timer.cb = lu_op_timer_cb; + luop->timer.data = luop; + + return luop; +} + +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst) +{ + struct lu_operation *luop; + + llist_for_each_entry(luop, lst, list) { + if (!strcmp(imsi, luop->subscr.imsi)) + return luop; + } + return NULL; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..c3b57b5 --- /dev/null +++ b/src/luop.h @@ -0,0 +1,79 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv); +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi); +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 15:51:47 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 15 Feb 2017 15:51:47 +0000 Subject: [PATCH] osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1711 to look at the new patch set (#4). octphy: Fix VTY commands The VTY commands show phy 0 rf-port-stats and show phy 0 clk-sync-stats do not output their results on the VTY console. If one of those commands is entered the user is prompted to view the logtext, which is an uncomfortable solution. This commit adds the missing functionality to print the information in the VTY as well. octphy_hw_api.c contains two value_string structs (radio_std_vals and clocksync_state_vals) which are now exported in octphy_hw_api.h in order to access them from octphy_vty.c Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 --- M src/osmo-bts-octphy/octphy_hw_api.c M src/osmo-bts-octphy/octphy_hw_api.h M src/osmo-bts-octphy/octphy_vty.c 3 files changed, 139 insertions(+), 45 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/11/1711/4 diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c index dc23676..6666f77 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.c +++ b/src/osmo-bts-octphy/octphy_hw_api.c @@ -29,6 +29,7 @@ #include "l1_if.h" #include "l1_oml.h" #include "l1_utils.h" +#include "octphy_hw_api.h" #include #include @@ -105,18 +106,12 @@ return l1if_req_compl(fl1h, msg, rf_port_info_compl_cb, NULL); } -static const struct value_string radio_std_vals[] = { - { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, - { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, - { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, - { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, - { 0, NULL } -}; - /* Chapter 12.10 */ static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h; @@ -136,12 +131,16 @@ psr->TxStats.ulTxAveragePeriodUs, psr->TxStats.ulFrequencyKhz); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.10 */ -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index) +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_RF_PORT_STATS_CMD *psc; @@ -156,7 +155,7 @@ mOCTVC1_HW_MSG_RF_PORT_STATS_CMD_SWAP(psc); - return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, NULL); + return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, cb_data); } static const struct value_string rx_gain_mode_vals[] = { @@ -276,28 +275,6 @@ { 0, NULL } }; -static const struct value_string clocksync_state_vals[] = { - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, - "Uninitialized" }, -/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to - * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef - * statement ensures that older headers still work. */ -#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, -#else - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, -#endif - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, - "No External Clock" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, - "Loss of Ext Clock" }, - { 0, NULL } -}; - /* Chapter 12.15 */ static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) @@ -336,6 +313,8 @@ static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) resp->l2h; @@ -349,12 +328,16 @@ csr->ulPllFractionalFreqHz, csr->ulSlipCnt, csr->ulSyncLosseCnt, csr->ulSourceState, csr->ulDacValue); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.16 */ -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h) +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD *csc; @@ -366,6 +349,6 @@ mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD_SWAP(csc); - return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, NULL); + return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, cb_data); } diff --git a/src/osmo-bts-octphy/octphy_hw_api.h b/src/osmo-bts-octphy/octphy_hw_api.h index bc8ab68..78b7208 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.h +++ b/src/osmo-bts-octphy/octphy_hw_api.h @@ -2,13 +2,53 @@ #include #include "l1_if.h" +#include + +static const struct value_string radio_std_vals[] = { + { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, + { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, + { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, + { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, + { 0, NULL } +}; + +static const struct value_string clocksync_state_vals[] = { + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, + "Uninitialized" }, +/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to + * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef + * statement ensures that older headers still work. */ +#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, +#else + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, +#endif + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, + "No External Clock" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, + "Loss of Ext Clock" }, + { 0, NULL } +}; + +typedef void octphy_hw_get_cb(struct msgb *resp, void *data); + +struct octphy_hw_get_cb_data { + octphy_hw_get_cb* cb; + void *data; +}; int octphy_hw_get_pcb_info(struct octphy_hdl *fl1h); int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index); -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index); +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data); int octphy_hw_get_rf_ant_rx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_rf_ant_tx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h); -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h); +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data); diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index abfac1e..f269b65 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -159,6 +159,45 @@ return CMD_SUCCESS; } +void show_rf_port_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr; + + if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) { + vty_out(vty, + "invalid msgb size (%d bytes, expected %ld bytes)%s", + msgb_l2len(resp), + sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP), VTY_NEWLINE); + return; + } + + psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "RF-PORT-STATS:%s", VTY_NEWLINE); + vty_out(vty, "Idx=%d%s", psr->ulPortIndex, VTY_NEWLINE); + vty_out(vty, "RadioStandard=%s%s", + get_value_string(radio_std_vals, psr->ulRadioStandard), + VTY_NEWLINE); + vty_out(vty, "Rx Bytes=%u%s", psr->RxStats.ulRxByteCnt, VTY_NEWLINE); + vty_out(vty, "Rx Overflow=%u%s", psr->RxStats.ulRxOverflowCnt, + VTY_NEWLINE); + vty_out(vty, "Rx AvgBps=%u%s", psr->RxStats.ulRxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Rx Period=%u%s", psr->RxStats.ulRxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Rx Freq=%u%s", psr->RxStats.ulFrequencyKhz, VTY_NEWLINE); + vty_out(vty, "Tx Bytes=%u%s", psr->TxStats.ulTxByteCnt, VTY_NEWLINE); + vty_out(vty, "Tx Underflow=%u%s", psr->TxStats.ulTxUnderflowCnt, + VTY_NEWLINE); + vty_out(vty, "Tx AvgBps=%u%s", psr->TxStats.ulTxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Tx Period=%u%s", psr->TxStats.ulTxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Tx Freq=%u%s", psr->TxStats.ulFrequencyKhz, VTY_NEWLINE); +} + DEFUN(show_rf_port_stats, show_rf_port_stats_cmd, "show phy <0-255> rf-port-stats <0-1>", "Show statistics for the RF Port\n" @@ -166,14 +205,47 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1])); + cb_data.cb = show_rf_port_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); + octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]), + &cb_data); return CMD_SUCCESS; +} + +void show_clk_sync_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr; + + if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) != + msgb_l2len(resp)) { + vty_out(vty, + "invalid msgb size (%d bytes, expected %ld bytes)%s", + msgb_l2len(resp), + sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP), + VTY_NEWLINE); + return; + } + + csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "CLOCK-SYNC-MGR-STATS:%s", VTY_NEWLINE); + vty_out(vty, "State=%s%s", + get_value_string(clocksync_state_vals, csr->ulState), + VTY_NEWLINE); + vty_out(vty, "ClockError=%d%s", csr->lClockError, VTY_NEWLINE); + vty_out(vty, "DroppedCycles=%d%s", csr->lDroppedCycles, VTY_NEWLINE); + vty_out(vty, "PllFreqHz=%u%s", csr->ulPllFreqHz, VTY_NEWLINE); + vty_out(vty, "PllFract=%u%s", csr->ulPllFractionalFreqHz, VTY_NEWLINE); + vty_out(vty, "SlipCnt=%u%s", csr->ulSlipCnt, VTY_NEWLINE); + vty_out(vty, "SyncLosses=%u%s", csr->ulSyncLosseCnt, VTY_NEWLINE); + vty_out(vty, "SourceState=%u%s", csr->ulSourceState, VTY_NEWLINE); + vty_out(vty, "DacValue=%u%s", csr->ulDacValue, VTY_NEWLINE); } DEFUN(show_clk_sync_stats, show_clk_sync_stats_cmd, @@ -182,13 +254,12 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl); + cb_data.cb = show_clk_sync_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); - + octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl, &cb_data); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 16:32:40 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 15 Feb 2017 16:32:40 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello lynxis lazus, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#9). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 286 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/9 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..5965d39 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,255 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + return ret; + } else if (ret < 0) { + perror("read "); + return ret; + } + msgb_put(msg, ret); + + return e1inp_rx_ts_lapd(&line->ts[0], msg); +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s_%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg, &config->fd, e1inp_dlsap_up, + e1i_ts, &lapd_profile_abis); + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 9 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Wed Feb 15 16:52:48 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 15 Feb 2017 16:52:48 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello lynxis lazus, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#10). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 286 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/10 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..657a564 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,255 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + return ret; + } else if (ret < 0) { + perror("read "); + return ret; + } + msgb_put(msg, ret); + + return e1inp_rx_ts_lapd(&line->ts[0], msg); +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg, &config->fd, e1inp_dlsap_up, + e1i_ts, &lapd_profile_abis); + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 10 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Wed Feb 15 16:56:41 2017 From: gerrit-no-reply at lists.osmocom.org (ikostov) Date: Wed, 15 Feb 2017 16:56:41 +0000 Subject: [PATCH] libosmocore[master]: OAP:remove design doc. osmocom-authn-protocol.txt Message-ID: Review at https://gerrit.osmocom.org/1829 OAP:remove design doc. osmocom-authn-protocol.txt Osmocom Authentication Protocol design document is removed from libosmocore project as this information has been included in the User Manual. It is present in SGSN User Manual. relates to OS#1874 Change-Id: I2d4dc608622a7484e67b15f930efc76e28285045 --- M Makefile.am D doc/osmocom-authn-protocol.txt 2 files changed, 1 insertion(+), 251 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/1829/1 diff --git a/Makefile.am b/Makefile.am index 9c901ea..185127e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,7 @@ dist-hook: echo $(VERSION) > $(distdir)/.tarball-version -EXTRA_DIST = git-version-gen .version doc/osmocom-authn-protocol.txt +EXTRA_DIST = git-version-gen .version if HAVE_DOXYGEN diff --git a/doc/osmocom-authn-protocol.txt b/doc/osmocom-authn-protocol.txt deleted file mode 100644 index ad4fba0..0000000 --- a/doc/osmocom-authn-protocol.txt +++ /dev/null @@ -1,250 +0,0 @@ - - Osmocom Authentication Protocol (OAP) - -1. General - -The Osmocom Authentication Protocol employs mutual authentication to register a -client with a server over an IPA connection. Milenage is used as the -authentication algorithm, where client and server have a shared secret. - -For example, an SGSN, as OAP client, may use its SGSN ID to register with a MAP -proxy, an OAP server. - -1.1. Connection - -The protocol expects that a reliable, ordered, packet boundaries preserving -connection is used (e.g. IPA over TCP). - -1.2. Using IPA - -By default, the following identifiers should be used: - - IPA protocol: 0xee (OSMO) - - IPA OSMO protocol extension: 0x06 (OAP) - -2. Procedures - -Ideal communication sequence: - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Challenge (RAND+AUTN) | - |<-----------------------------------| - | | - | Challenge Result (XRES) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -Variation "test setup": - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -Variation "invalid sequence nr": - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Challenge (RAND+AUTN) | - |<-----------------------------------| - | | - | Sync Request (AUTS) | - |----------------------------------->| - | | - | Challenge (RAND'+AUTN') | - |<-----------------------------------| - | | - | Challenge Result (XRES) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -2.1. Register - -The client sends a REGISTER_REQ message containing an identifier number. - -2.2. Challenge - -The OAP server (optionally) sends back a CHALLENGE_REQ, containing random bytes -and a milenage authentication token generated from these random bytes, using a -shared secret, to authenticate itself to the OAP client. The server may omit -this challenge entirely, based on its configuration, and immediately reply with -a Register Result response. If the client cannot be registered (e.g. id is -invalid), the server sends a REGISTER_ERR response. - -2.3. Challenge Result - -When the client has received a Challenge, it may verify the server's -authenticity and validity of the sequence number (included in AUTN), and, if -valid, reply with a CHALLENGE_RES message. This shall contain an XRES -authentication token generated by milenage from the same random bytes received -from the server and the same shared secet. If the client decides to cancel the -registration (e.g. invalid AUTN), it shall not reply to the CHALLENGE_REQ; a -CHALLENGE_ERR message may be sent, but is not mandatory. For example, the -client may directly start with a new REGISTER_REQ message. - -2.4. Sync Request - -When the client has received a Challenge but sees an invalid sequence number -(embedded in AUTN, according to the milenage algorithm), the client may send a -SYNC_REQ message containing an AUTS synchronisation token. - -2.5. Sync Result - -If the server has received a valid Sync Request, it shall answer by directly -sending another Challenge (see 2.2.). If an invalid Sync Request is received, -the server shall reply with a REGISTER_ERR message. - -2.6. Register Result - -The server sends a REGISTER_RES message to indicate that registration has been -successful. If the server cannot register the client (e.g. invalid challenge -response), it shall send a REGISTER_ERR message. - -3. Message Format - -3.1. General - -Every message is based on the following message format - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - -The receiver shall be able to receive IEs in any order. Unknown IEs shall be -ignored. - -3.2.1. Register Request - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 30 Client ID big endian int (2 oct) M TLV 4 - -3.2.2. Register Error - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 02 Cause GMM cause, M TLV 3 - 04.08: 10.5.5.14 - -3.2.3. Register Result - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - -3.2.4. Challenge - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 20 RAND octet string (16) M TLV 18 - 23 AUTN octet string (16) M TLV 18 - -3.2.5. Challenge Error - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 02 Cause GMM cause, M TLV 3 - 04.08: 10.5.5.14 - -3.2.6. Challenge Result - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 21 XRES octet string (8) M TLV 10 - -3.2.7. Sync Request - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 20 AUTS octet string (14) M TLV 16 - -3.2.8. Sync Error - -Not used. - -3.2.9. Sync Result - -Not used. - - -4. Information Elements - -4.1. General - -[...] - -4.2.1. Message Type - - +---------------------------------------------------+ - | 8 7 6 5 4 3 2 1 | - | | - | 0 0 0 0 0 1 0 0 - Register Request | - | 0 0 0 0 0 1 0 1 - Register Error | - | 0 0 0 0 0 1 1 0 - Register Result | - | | - | 0 0 0 0 1 0 0 0 - Challenge Request | - | 0 0 0 0 1 0 0 1 - Challenge Error | - | 0 0 0 0 1 0 1 0 - Challenge Result | - | | - | 0 0 0 0 1 1 0 0 - Sync Request | - | 0 0 0 0 1 1 0 1 - Sync Error (not used) | - | 0 0 0 0 1 1 1 0 - Sync Result (not used) | - | | - +---------------------------------------------------+ - -4.2.2. IE Identifier (informational) - -These are the standard values for the IEI. - - +---------------------------------------------------------+ - | IEI Info Element Type | - | | - | 0x02 Cause GMM cause, 04.08: 10.5.5.14 | - | 0x20 RAND octet string | - | 0x23 AUTN octet string | - | 0x24 XRES octet string | - | 0x25 AUTS octet string | - | 0x30 Client ID big endian int (2 octets) | - +---------------------------------------------------------+ - -4.2.3. Client ID - - 8 7 6 5 4 3 2 1 - +-----------------------------------------------------+ - | | Client ID IEI | octet 1 - +-----------------------------------------------------+ - | Length of Client ID IE contents (2) | octet 2 - +-----------------------------------------------------+ - | Client ID number, most significant byte | octet 3 - +-----------------------------------------------------+ - | Client ID number, least significant byte | octet 4 - +-----------------------------------------------------+ - -The Client ID number shall be interpreted as an unsigned 16bit integer, where 0 -indicates an invalid / unset ID. - -- To view, visit https://gerrit.osmocom.org/1829 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2d4dc608622a7484e67b15f930efc76e28285045 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov From gerrit-no-reply at lists.osmocom.org Wed Feb 15 17:09:05 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 17:09:05 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1827 to look at the new patch set (#3). Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/gsup_server.c M src/gsup_server.h M src/hlr.c 7 files changed, 162 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/3 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..ad744c6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -19,6 +20,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -32,6 +34,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -48,6 +51,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..b7514c5 --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,78 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "logging.h" +#include "db.h" +#include "luop.h" +#include "ctrl.h" + +CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); +static int set_status_ps(struct ctrl_cmd *cmd, void *data) +{ + struct lu_operation *luop = lu_op_alloc(data); + if (!luop) { + cmd->reply = "Internal HLR error"; + return CTRL_CMD_ERROR; + } + + if (!lu_op_fill_subscr(luop, luop->gsup_server->dbc, cmd->value)) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = luop->subscr.nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(gs, addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..95b58be --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs); diff --git a/src/gsup_server.c b/src/gsup_server.c index ea51f7d..90742c5 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -27,6 +27,7 @@ #include "gsup_server.h" #include "gsup_router.h" +#include "ctrl.h" static void osmo_gsup_server_send(struct osmo_gsup_conn *conn, int proto_ext, struct msgb *msg_tx) @@ -245,9 +246,10 @@ } struct osmo_gsup_server * -osmo_gsup_server_create(void *ctx, const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb) +osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, struct db_context *dbc, + struct llist_head *lu_op_lst) { struct osmo_gsup_server *gsups; int rc; @@ -272,6 +274,15 @@ if (rc < 0) goto failed; + gsups->dbc = dbc; + gsups->luop = lu_op_lst; + + if (ctrl_addr) + gsups->ctrl = hlr_controlif_setup(ctrl_addr, gsups); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + return gsups; failed: @@ -286,5 +297,8 @@ ipa_server_link_destroy(gsups->link); gsups->link = NULL; } + + db_close(gsups->dbc); + talloc_free(gsups); } diff --git a/src/gsup_server.h b/src/gsup_server.h index 484a0d7..ae303f5 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -5,6 +5,8 @@ #include #include +#include "db.h" + struct osmo_gsup_conn; /* Expects message in msg->l2h */ @@ -14,9 +16,18 @@ /* list of osmo_gsup_conn */ struct llist_head clients; + /* DB context */ + struct db_context *dbc; + + /* lu_operations list */ + struct llist_head *luop; + struct ipa_server_link *link; osmo_gsup_read_cb_t read_cb; struct llist_head routes; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; @@ -35,10 +46,12 @@ int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr, uint8_t tag); -struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, - const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb); +struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, const char *ip_addr, + uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, + struct db_context *dbc, + struct llist_head *lu_op_lst); void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); diff --git a/src/hlr.c b/src/hlr.c index 5f76c6a..02dfa86 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -34,6 +34,7 @@ #include #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -204,8 +205,8 @@ bool is_ps = false; int rc; - LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s)\n", gsup->imsi, - is_ps ? "PS" : "CS"); + LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s), %u subscribers left\n", + gsup->imsi, is_ps ? "PS" : "CS", llist_count(&g_lu_ops)); memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi)); @@ -296,16 +297,19 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -i --ctrl address Set address to which Control Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { const char *config_file; const char *db_file; + const char *addr; bool daemonize; } cmdline_opts = { .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", + .addr = "127.0.0.1", .daemonize = false, }; @@ -321,12 +325,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'i'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:i:TV", long_options, &option_index); if (c == -1) break; @@ -341,6 +346,9 @@ break; case 'l': cmdline_opts.db_file = optarg; + break; + case 'i': + cmdline_opts.addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -379,7 +387,6 @@ case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); osmo_gsup_server_destroy(gs); - db_close(g_dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -442,7 +449,8 @@ exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb, + cmdline_opts.addr, g_dbc, &g_lu_ops); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); @@ -464,7 +472,7 @@ osmo_select_main(0); } - db_close(g_dbc); + osmo_gsup_server_destroy(gs); log_fini(); -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 15 17:09:05 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Wed, 15 Feb 2017 17:09:05 +0000 Subject: [PATCH] osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1821 to look at the new patch set (#5). Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 361 insertions(+), 258 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1821/5 diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..5f76c6a 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -19,7 +19,7 @@ #include #include - +#include #include #include @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,187 +84,9 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - -struct lu_operation *lu_op_by_imsi(const char *imsi) -{ - struct lu_operation *luop; - - llist_for_each_entry(luop, &g_lu_ops, list) { - if (!strcmp(imsi, luop->subscr.imsi)) - return luop; - } - return NULL; -} - -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/* timer call-back in case LU operation doesn't receive an response */ -static void lu_op_timer_cb(void *data) -{ - struct lu_operation *luop = data; - - DEBUGP(DMAIN, "LU OP timer expired in state %s\n", - get_value_string(lu_state_names, luop->state)); - - switch (luop->state) { - case LU_S_CANCEL_SENT: - break; - case LU_S_ISD_SENT: - break; - default: - break; - } - - lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); -} - -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +96,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ @@ -364,38 +138,18 @@ } } -static struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) -{ - struct lu_operation *luop; - - luop = talloc_zero(srv, struct lu_operation); - OSMO_ASSERT(luop); - luop->gsup_server = srv; - luop->timer.cb = lu_op_timer_cb; - luop->timer.data = luop; - - return luop; -} - /*! Receive Update Location Request, creates new \ref lu_operation */ static int rx_upd_loc_req(struct osmo_gsup_conn *conn, const struct osmo_gsup_message *gsup) { - int rc; - struct lu_operation *luop; - struct hlr_subscriber *subscr; - uint8_t *peer_addr; - - rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); - if (rc < 0) { + struct lu_operation *luop = lu_op_alloc_conn(conn); + if (!luop) { LOGP(DMAIN, LOGL_ERROR, "LU REQ from conn without addr?\n"); - return rc; + return -EINVAL; } - luop = lu_op_alloc(conn->server); - luop->peer = talloc_memdup(luop, peer_addr, rc); lu_op_statechg(luop, LU_S_LU_RECEIVED); - subscr = &luop->subscr; + if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS) luop->is_ps = true; llist_add(&luop->list, &g_lu_ops); @@ -403,8 +157,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - rc = db_subscr_get(g_dbc, gsup->imsi, subscr); - if (rc < 0) { + if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -413,10 +166,10 @@ /* Check if subscriber is generally permitted on CS or PS * service (as requested) */ - if (!luop->is_ps && !subscr->nam_cs) { + if (!luop->is_ps && !luop->subscr.nam_cs) { lu_op_tx_error(luop, GMM_CAUSE_PLMN_NOTALLOWED); return 0; - } else if (luop->is_ps && !subscr->nam_ps) { + } else if (luop->is_ps && !luop->subscr.nam_ps) { lu_op_tx_error(luop, GMM_CAUSE_GPRS_NOTALLOWED); return 0; } @@ -508,7 +261,8 @@ case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT: { - struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); + struct lu_operation *luop = lu_op_by_imsi(gsup.imsi, + &g_lu_ops); if (!luop) { LOGP(DMAIN, LOGL_ERROR, "GSUP message %u for " "unknown IMSI %s\n", gsup.message_type, diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..6c18a6d --- /dev/null +++ b/src/luop.c @@ -0,0 +1,267 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +/* timer call-back in case LU operation doesn't receive an response */ +static void lu_op_timer_cb(void *data) +{ + struct lu_operation *luop = data; + + DEBUGP(DMAIN, "LU OP timer expired in state %s\n", + get_value_string(lu_state_names, luop->state)); + + switch (luop->state) { + case LU_S_CANCEL_SENT: + break; + case LU_S_ISD_SENT: + break; + default: + break; + } + + lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); +} + +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi) +{ + struct hlr_subscriber *subscr = &luop->subscr; + + if (db_subscr_get(dbc, imsi, subscr) < 0) + return false; + + return true; +} + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) +{ + struct lu_operation *luop; + + luop = talloc_zero(srv, struct lu_operation); + OSMO_ASSERT(luop); + luop->gsup_server = srv; + luop->timer.cb = lu_op_timer_cb; + luop->timer.data = luop; + + return luop; +} + +struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn) +{ + uint8_t *peer_addr; + struct lu_operation *luop = lu_op_alloc(conn->server); + int rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); + if (rc < 0) + return NULL; + + luop->peer = talloc_memdup(luop, peer_addr, rc); + + return luop; +} + +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst) +{ + struct lu_operation *luop; + + llist_for_each_entry(luop, lst, list) { + if (!strcmp(imsi, luop->subscr.imsi)) + return luop; + } + return NULL; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..7e2fbb0 --- /dev/null +++ b/src/luop.h @@ -0,0 +1,80 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv); +struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn); +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi); +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 15 20:56:46 2017 From: gerrit-no-reply at lists.osmocom.org (Alexander Chemeris) Date: Wed, 15 Feb 2017 20:56:46 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1789 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:55 +0000 Subject: [PATCH] libosmo-sccp[master]: sccp_sap: Add osmo_sccp_routing_ind to osmo_sccp_addr Message-ID: Review at https://gerrit.osmocom.org/1830 sccp_sap: Add osmo_sccp_routing_ind to osmo_sccp_addr Somehow we forgot to include the osmo_sccp_routing_ind in osmo_sccp_addr. It was defined, but not unsed anywhere :/ Change-Id: I559bc9a5308a46aa1b1c63557a4aec0effb48a0b --- M include/osmocom/sigtran/sccp_sap.h M src/sua.c M src/xua_msg.c 3 files changed, 26 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/30/1830/1 diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h index 0aa565a..cc26c4e 100644 --- a/include/osmocom/sigtran/sccp_sap.h +++ b/include/osmocom/sigtran/sccp_sap.h @@ -136,6 +136,7 @@ struct osmo_sccp_addr { uint32_t presence; + enum osmo_sccp_routing_ind ri; struct osmo_sccp_gt gt; uint32_t pc; uint32_t ssn; diff --git a/src/sua.c b/src/sua.c index cdc2cf0..36e31fd 100644 --- a/src/sua.c +++ b/src/sua.c @@ -670,7 +670,18 @@ ai = ntohs(*(uint16_t*) ¶m->dat[pos]); pos += 2; - if (ri != SUA_RI_SSN_PC) { + switch (ri) { + case SUA_RI_GT: + out->ri = OSMO_SCCP_RI_GT; + break; + case SUA_RI_SSN_PC: + out->ri = OSMO_SCCP_RI_SSN_PC; + break; + case SUA_RI_SSN_IP: + out->ri = OSMO_SCCP_RI_SSN_IP; + break; + case SUA_RI_HOST: + default: LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Routing Indicator not supported yet: %d\n", iei, ri); return -ENOTSUP; diff --git a/src/xua_msg.c b/src/xua_msg.c index 4a3e013..be3b9a2 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -253,7 +253,19 @@ if (!tmp) return -ENOMEM; - msgb_put_u16(tmp, SUA_RI_SSN_PC); /* route on SSN + PC */ + switch (addr->ri) { + case OSMO_SCCP_RI_GT: + msgb_put_u16(tmp, SUA_RI_GT); + break; + case OSMO_SCCP_RI_SSN_PC: + msgb_put_u16(tmp, SUA_RI_SSN_PC); + break; + case OSMO_SCCP_RI_SSN_IP: + msgb_put_u16(tmp, SUA_RI_SSN_IP); + break; + default: + return -EINVAL; + } msgb_put_u16(tmp, 7); /* always put all addresses on SCCP side */ if (addr->presence & OSMO_SCCP_ADDR_T_GT) { -- To view, visit https://gerrit.osmocom.org/1830 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I559bc9a5308a46aa1b1c63557a4aec0effb48a0b Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:55 +0000 Subject: [PATCH] libosmo-sccp[master]: xua_msg: Add xua_msg_dump() to print parsed XUA message Message-ID: Review at https://gerrit.osmocom.org/1831 xua_msg: Add xua_msg_dump() to print parsed XUA message Change-Id: I2f3ae77f440e0c27f78302cdb80e1d25fe5aebb6 --- M include/osmocom/sigtran/xua_msg.h M src/xua_msg.c 2 files changed, 31 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/31/1831/1 diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 2a6e3ae..949c850 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -63,3 +63,4 @@ uint32_t xua_msg_part_get_u32(struct xua_msg_part *part); uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei); int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr); +char *xua_msg_dump(struct xua_msg *xua); diff --git a/src/xua_msg.c b/src/xua_msg.c index be3b9a2..f7b0386 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -287,3 +287,33 @@ return rc; } + +static void append_to_buf(char *buf, bool *comma, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (!comma || *comma == true) { + strcat(buf, ","); + } else if (comma) + *comma = true; + vsprintf(buf+strlen(buf), fmt, ap); + va_end(ap); +} + +char *xua_msg_dump(struct xua_msg *xua) +{ + static char buf[1024]; + struct xua_msg_part *part; + + buf[0] = '\0'; + + append_to_buf(buf, NULL, "HDR=(V=%u,C=0x%04x,T=0x%04x,LEN=%u)", + xua->hdr.version, xua->hdr.msg_class, + xua->hdr.msg_type, xua->hdr.msg_length); + llist_for_each_entry(part, &xua->headers, entry) + append_to_buf(buf, NULL, "\n\tPART(T=0x%04x,L=%u,D=%s)", + part->tag, part->len, + osmo_hexdump_nospc(part->dat, part->len)); + return buf; +} -- To view, visit https://gerrit.osmocom.org/1831 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2f3ae77f440e0c27f78302cdb80e1d25fe5aebb6 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:56 +0000 Subject: [PATCH] libosmo-sccp[master]: sua: make SUA address parsing available to other code within... Message-ID: Review at https://gerrit.osmocom.org/1832 sua: make SUA address parsing available to other code within library Change-Id: Id824ce1000abbb06592e8edda9c2896ac7d0efb3 --- M src/sua.c A src/xua_internal.h 2 files changed, 28 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/32/1832/1 diff --git a/src/sua.c b/src/sua.c index 36e31fd..fac3de1 100644 --- a/src/sua.c +++ b/src/sua.c @@ -639,11 +639,9 @@ * Receiving SUA messsages from SCTP ***********************************************************************/ -static int sua_parse_addr(struct osmo_sccp_addr *out, - struct xua_msg *xua, - uint16_t iei) +int sua_addr_parse_part(struct osmo_sccp_addr *out, + const struct xua_msg_part *param) { - const struct xua_msg_part *param = xua_msg_find_tag(xua, iei); const struct xua_parameter_hdr *par; uint16_t ri; uint16_t ai; @@ -651,16 +649,13 @@ uint16_t par_tag, par_len, par_datalen; uint32_t *p32; - if (!param) - return -ENODEV; - - LOGP(DSUA, LOGL_DEBUG, "sua_parse_addr(IEI=%d) (%d) %s\n", - iei, param->len, + LOGP(DSUA, LOGL_DEBUG, "%s(IEI=%d) (%d) %s\n", __func__, + param->tag, param->len, osmo_hexdump(param->dat, param->len)); if (param->len < 4) { LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: invalid address length: %d\n", - iei, param->len); + param->tag, param->len); return -EINVAL; } @@ -683,13 +678,13 @@ case SUA_RI_HOST: default: LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Routing Indicator not supported yet: %d\n", - iei, ri); + param->tag, ri); return -ENOTSUP; } if (ai != 7) { LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Address Indicator not supported yet: %x\n", - iei, ai); + param->tag, ai); return -ENOTSUP; } @@ -708,7 +703,7 @@ par_datalen = par_len - sizeof(*par); LOGP(DSUA, LOGL_DEBUG, "SUA IEI %hu pos %hu/%hu: subpart tag %hu, len %hu\n", - iei, pos, param->len, par->tag, par->len); + param->tag, pos, param->len, par->tag, par->len); switch (par_tag) { case SUA_IEI_PC: @@ -731,7 +726,7 @@ break; default: LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Unknown subpart tag %hd\n", - iei, par_tag); + param->tag, par_tag); goto subpar_fail; } @@ -742,8 +737,17 @@ subpar_fail: LOGP(DSUA, LOGL_ERROR, "Failed to parse subparts of address IEI=%d\n", - iei); + param->tag); return -EINVAL; +} + +int sua_addr_parse(struct osmo_sccp_addr *out, struct xua_msg *xua, uint16_t iei) +{ + const struct xua_msg_part *param = xua_msg_find_tag(xua, iei); + if (!param) + return -ENODEV; + + return sua_addr_parse_part(out, param); } static int sua_rx_cldt(struct osmo_sccp_link *link, struct xua_msg *xua) @@ -760,8 +764,8 @@ osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION, upmsg); - sua_parse_addr(¶m->called_addr, xua, SUA_IEI_DEST_ADDR); - sua_parse_addr(¶m->calling_addr, xua, SUA_IEI_SRC_ADDR); + sua_addr_parse(¶m->called_addr, xua, SUA_IEI_DEST_ADDR); + sua_addr_parse(¶m->calling_addr, xua, SUA_IEI_SRC_ADDR); param->in_sequence_control = xua_msg_get_u32(xua, SUA_IEI_SEQ_CTRL); protocol_class = xua_msg_get_u32(xua, SUA_IEI_PROTO_CLASS); param->return_option = protocol_class & 0x80; @@ -810,8 +814,8 @@ /* fill conn */ conn = conn_create(link); - sua_parse_addr(&conn->called_addr, xua, SUA_IEI_DEST_ADDR); - sua_parse_addr(&conn->calling_addr, xua, SUA_IEI_SRC_ADDR); + sua_addr_parse(&conn->called_addr, xua, SUA_IEI_DEST_ADDR); + sua_addr_parse(&conn->calling_addr, xua, SUA_IEI_SRC_ADDR); conn->remote_ref = xua_msg_get_u32(xua, SUA_IEI_SRC_REF); /* fill primitive */ diff --git a/src/xua_internal.h b/src/xua_internal.h new file mode 100644 index 0000000..8c9838e --- /dev/null +++ b/src/xua_internal.h @@ -0,0 +1,5 @@ +#pragma once + +int sua_addr_parse_part(struct osmo_sccp_addr *out, + const struct xua_msg_part *param); +int sua_addr_parse(struct osmo_sccp_addr *out, struct xua_msg *xua, uint16_t iei); -- To view, visit https://gerrit.osmocom.org/1832 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id824ce1000abbb06592e8edda9c2896ac7d0efb3 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:56 +0000 Subject: [PATCH] libosmo-sccp[master]: sua.c: Print xUA IEI always in hex representation Message-ID: Review at https://gerrit.osmocom.org/1833 sua.c: Print xUA IEI always in hex representation ... as that's what used in the IETF RFCs and thus more natural when looking at documentation and logs. Change-Id: I9aa8eac82748c4e7656a12c42d9ff28573d8413b --- M src/sua.c 1 file changed, 7 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/33/1833/1 diff --git a/src/sua.c b/src/sua.c index fac3de1..4f18466 100644 --- a/src/sua.c +++ b/src/sua.c @@ -649,12 +649,12 @@ uint16_t par_tag, par_len, par_datalen; uint32_t *p32; - LOGP(DSUA, LOGL_DEBUG, "%s(IEI=%d) (%d) %s\n", __func__, + LOGP(DSUA, LOGL_DEBUG, "%s(IEI=0x%04x) (%d) %s\n", __func__, param->tag, param->len, osmo_hexdump(param->dat, param->len)); if (param->len < 4) { - LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: invalid address length: %d\n", + LOGP(DSUA, LOGL_ERROR, "SUA IEI 0x%04x: invalid address length: %d\n", param->tag, param->len); return -EINVAL; } @@ -677,13 +677,13 @@ break; case SUA_RI_HOST: default: - LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Routing Indicator not supported yet: %d\n", + LOGP(DSUA, LOGL_ERROR, "SUA IEI 0x%04x: Routing Indicator not supported yet: %d\n", param->tag, ri); return -ENOTSUP; } if (ai != 7) { - LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Address Indicator not supported yet: %x\n", + LOGP(DSUA, LOGL_ERROR, "SUA IEI 0x%04x: Address Indicator not supported yet: %x\n", param->tag, ai); return -ENOTSUP; } @@ -702,7 +702,7 @@ par_len = ntohs(par->len); par_datalen = par_len - sizeof(*par); - LOGP(DSUA, LOGL_DEBUG, "SUA IEI %hu pos %hu/%hu: subpart tag %hu, len %hu\n", + LOGP(DSUA, LOGL_DEBUG, "SUA IEI 0x%04x pos %hu/%hu: subpart tag 0x%04x, len %hu\n", param->tag, pos, param->len, par->tag, par->len); switch (par_tag) { @@ -725,7 +725,7 @@ out->presence |= OSMO_SCCP_ADDR_T_GT; break; default: - LOGP(DSUA, LOGL_ERROR, "SUA IEI %d: Unknown subpart tag %hd\n", + LOGP(DSUA, LOGL_ERROR, "SUA IEI 0x%04x: Unknown subpart tag %hd\n", param->tag, par_tag); goto subpar_fail; } @@ -736,7 +736,7 @@ return 0; subpar_fail: - LOGP(DSUA, LOGL_ERROR, "Failed to parse subparts of address IEI=%d\n", + LOGP(DSUA, LOGL_ERROR, "Failed to parse subparts of address IEI=0x%04x\n", param->tag); return -EINVAL; } -- To view, visit https://gerrit.osmocom.org/1833 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9aa8eac82748c4e7656a12c42d9ff28573d8413b Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:56 +0000 Subject: [PATCH] libosmo-sccp[master]: sua: Fix byte order when printing of embedded IEI Message-ID: Review at https://gerrit.osmocom.org/1834 sua: Fix byte order when printing of embedded IEI Change-Id: Ib9c3ec39cb1e6879fb652fa6fe04e05ad537a958 --- M src/sua.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/34/1834/1 diff --git a/src/sua.c b/src/sua.c index 4f18466..3864587 100644 --- a/src/sua.c +++ b/src/sua.c @@ -703,7 +703,7 @@ par_datalen = par_len - sizeof(*par); LOGP(DSUA, LOGL_DEBUG, "SUA IEI 0x%04x pos %hu/%hu: subpart tag 0x%04x, len %hu\n", - param->tag, pos, param->len, par->tag, par->len); + param->tag, pos, param->len, par_tag, par_len); switch (par_tag) { case SUA_IEI_PC: -- To view, visit https://gerrit.osmocom.org/1834 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib9c3ec39cb1e6879fb652fa6fe04e05ad537a958 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:56 +0000 Subject: [PATCH] libosmo-sccp[master]: sua: Add IPv4 encoding/decoding in SUA SCCP Addresses Message-ID: Review at https://gerrit.osmocom.org/1835 sua: Add IPv4 encoding/decoding in SUA SCCP Addresses Change-Id: Ic5c70360c6bf3a0d12f9ffc83a86d70f34c98f62 --- M src/sua.c M src/xua_msg.c 2 files changed, 9 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/35/1835/1 diff --git a/src/sua.c b/src/sua.c index 3864587..71c7b46 100644 --- a/src/sua.c +++ b/src/sua.c @@ -724,6 +724,14 @@ /* TODO */ out->presence |= OSMO_SCCP_ADDR_T_GT; break; + case SUA_IEI_IPv4: + if (par_datalen != 4) + goto subpar_fail; + p32 = (uint32_t*)par->data; + /* no endian conversion, both network order */ + out->ip.v4.s_addr = *p32; + out->presence |= OSMO_SCCP_ADDR_T_IPv4; + break; default: LOGP(DSUA, LOGL_ERROR, "SUA IEI 0x%04x: Unknown subpart tag %hd\n", param->tag, par_tag); diff --git a/src/xua_msg.c b/src/xua_msg.c index f7b0386..1693b76 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -278,7 +278,7 @@ msgb_t16l16vp_put_u32(tmp, SUA_IEI_SSN, addr->ssn); } if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) { - /* FIXME: IPv4 address */ + msgb_t16l16vp_put_u32(tmp, SUA_IEI_IPv4, ntohl(addr->ip.v4.s_addr)); } else if (addr->presence & OSMO_SCCP_ADDR_T_IPv6) { /* FIXME: IPv6 address */ } -- To view, visit https://gerrit.osmocom.org/1835 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic5c70360c6bf3a0d12f9ffc83a86d70f34c98f62 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:57 +0000 Subject: [PATCH] libosmo-sccp[master]: sua: Parse SUA Global Title (nested in SUA SCCP Addresses) Message-ID: Review at https://gerrit.osmocom.org/1836 sua: Parse SUA Global Title (nested in SUA SCCP Addresses) Change-Id: Id6201362a78f2bc183a27bbc2f19e4de724eb88f --- M src/sua.c 1 file changed, 45 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/36/1836/1 diff --git a/src/sua.c b/src/sua.c index 71c7b46..7fe74cb 100644 --- a/src/sua.c +++ b/src/sua.c @@ -639,6 +639,48 @@ * Receiving SUA messsages from SCTP ***********************************************************************/ + +/*! \brief Decode SUA Global Title according to RFC3868 3.10.2.3 + * \param[out] gt User-allocated structure for decoded output + * \param[in] data binary-encoded data + * \param[in] datalen length of \ref data in octets + */ +static int sua_parse_gt(struct osmo_sccp_gt *gt, const uint8_t *data, + unsigned int datalen) +{ + uint8_t num_digits; + uint8_t *out_digits; + unsigned int i; + + /* 8 byte header at minimum, plus digits */ + if (datalen < 8) + return -EINVAL; + + /* parse header */ + gt->gti = data[3]; + num_digits = data[4]; + gt->tt = data[5]; + gt->npi = data[6]; + gt->nai = data[7]; + + /* parse digits */ + out_digits = gt->digits; + for (i = 0; i < datalen-8; i++) { + uint8_t byte = data[8+i]; + *out_digits++ = osmo_bcd2char(byte & 0x0F); + if (out_digits - gt->digits >= num_digits) + break; + *out_digits++ = osmo_bcd2char(byte >> 4); + if (out_digits - gt->digits >= num_digits) + break; + } + *out_digits++ = '\0'; + + gt->nr_digits = strlen((const char *)gt->digits); + + return 0; +} + int sua_addr_parse_part(struct osmo_sccp_addr *out, const struct xua_msg_part *param) { @@ -721,7 +763,9 @@ out->presence |= OSMO_SCCP_ADDR_T_SSN; break; case SUA_IEI_GT: - /* TODO */ + if (par_datalen < 8) + goto subpar_fail; + sua_parse_gt(&out->gt, par->data, par_datalen); out->presence |= OSMO_SCCP_ADDR_T_GT; break; case SUA_IEI_IPv4: -- To view, visit https://gerrit.osmocom.org/1836 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id6201362a78f2bc183a27bbc2f19e4de724eb88f Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:05:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:05:57 +0000 Subject: [PATCH] libosmo-sccp[master]: sua: Always zero-initialize the output of sua_addr_parse_part() Message-ID: Review at https://gerrit.osmocom.org/1837 sua: Always zero-initialize the output of sua_addr_parse_part() Change-Id: Ia41a3f611dc8bb999db21f4e6fbe626f41aeb66e --- M src/sua.c 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/37/1837/1 diff --git a/src/sua.c b/src/sua.c index 7fe74cb..dec5fa2 100644 --- a/src/sua.c +++ b/src/sua.c @@ -691,6 +691,8 @@ uint16_t par_tag, par_len, par_datalen; uint32_t *p32; + memset(out, 0, sizeof(*out)); + LOGP(DSUA, LOGL_DEBUG, "%s(IEI=0x%04x) (%d) %s\n", __func__, param->tag, param->len, osmo_hexdump(param->dat, param->len)); -- To view, visit https://gerrit.osmocom.org/1837 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia41a3f611dc8bb999db21f4e6fbe626f41aeb66e Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:16:47 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:16:47 +0000 Subject: libosmo-sccp[master]: sua: Always zero-initialize the output of sua_addr_parse_part() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1837 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia41a3f611dc8bb999db21f4e6fbe626f41aeb66e Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:17:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:17:04 +0000 Subject: libosmo-sccp[master]: sua: Parse SUA Global Title (nested in SUA SCCP Addresses) In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1836 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id6201362a78f2bc183a27bbc2f19e4de724eb88f Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:17:06 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:17:06 +0000 Subject: libosmo-sccp[master]: sua: Add IPv4 encoding/decoding in SUA SCCP Addresses In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1835 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic5c70360c6bf3a0d12f9ffc83a86d70f34c98f62 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:17:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:17:13 +0000 Subject: libosmo-sccp[master]: sua: Fix byte order when printing of embedded IEI In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1834 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib9c3ec39cb1e6879fb652fa6fe04e05ad537a958 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:17:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:17:20 +0000 Subject: libosmo-sccp[master]: sua.c: Print xUA IEI always in hex representation In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1833 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9aa8eac82748c4e7656a12c42d9ff28573d8413b Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:17:52 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:17:52 +0000 Subject: libosmo-sccp[master]: sua: make SUA address parsing available to other code within... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-2 -- To view, visit https://gerrit.osmocom.org/1832 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id824ce1000abbb06592e8edda9c2896ac7d0efb3 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:18:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:18:12 +0000 Subject: libosmo-sccp[master]: sccp_sap: Add osmo_sccp_routing_ind to osmo_sccp_addr In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1830 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I559bc9a5308a46aa1b1c63557a4aec0effb48a0b Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:19:30 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:19:30 +0000 Subject: osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:19:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:19:36 +0000 Subject: osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Patch Set 5: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:20:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:20:25 +0000 Subject: libosmocore[master]: OAP:remove design doc. osmocom-authn-protocol.txt In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 you again uploaded the same change with a different Change-Id. This is not how gerrit works. You have to keep the Change-Id identical in subsequent versions of the patch. -- To view, visit https://gerrit.osmocom.org/1829 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2d4dc608622a7484e67b15f930efc76e28285045 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:20:45 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:20:45 +0000 Subject: [ABANDON] libosmocore[master]: OAP: remove osmocom-authn-protocol.txt In-Reply-To: References: Message-ID: Harald Welte has abandoned this change. Change subject: OAP: remove osmocom-authn-protocol.txt ...................................................................... Abandoned patch was submitted again with new change-id, so abandon the old one. -- To view, visit https://gerrit.osmocom.org/1815 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ie2e09220ab4b21a3c4a88407032d718ff75e0ade Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:20:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:20:49 +0000 Subject: [MERGED] libosmocore[master]: OAP:remove design doc. osmocom-authn-protocol.txt In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: OAP:remove design doc. osmocom-authn-protocol.txt ...................................................................... OAP:remove design doc. osmocom-authn-protocol.txt Osmocom Authentication Protocol design document is removed from libosmocore project as this information has been included in the User Manual. It is present in SGSN User Manual. relates to OS#1874 Change-Id: I2d4dc608622a7484e67b15f930efc76e28285045 --- M Makefile.am D doc/osmocom-authn-protocol.txt 2 files changed, 1 insertion(+), 251 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/Makefile.am b/Makefile.am index 9c901ea..185127e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,7 @@ dist-hook: echo $(VERSION) > $(distdir)/.tarball-version -EXTRA_DIST = git-version-gen .version doc/osmocom-authn-protocol.txt +EXTRA_DIST = git-version-gen .version if HAVE_DOXYGEN diff --git a/doc/osmocom-authn-protocol.txt b/doc/osmocom-authn-protocol.txt deleted file mode 100644 index ad4fba0..0000000 --- a/doc/osmocom-authn-protocol.txt +++ /dev/null @@ -1,250 +0,0 @@ - - Osmocom Authentication Protocol (OAP) - -1. General - -The Osmocom Authentication Protocol employs mutual authentication to register a -client with a server over an IPA connection. Milenage is used as the -authentication algorithm, where client and server have a shared secret. - -For example, an SGSN, as OAP client, may use its SGSN ID to register with a MAP -proxy, an OAP server. - -1.1. Connection - -The protocol expects that a reliable, ordered, packet boundaries preserving -connection is used (e.g. IPA over TCP). - -1.2. Using IPA - -By default, the following identifiers should be used: - - IPA protocol: 0xee (OSMO) - - IPA OSMO protocol extension: 0x06 (OAP) - -2. Procedures - -Ideal communication sequence: - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Challenge (RAND+AUTN) | - |<-----------------------------------| - | | - | Challenge Result (XRES) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -Variation "test setup": - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -Variation "invalid sequence nr": - - Client Server - | | - | Register (ID) | - |----------------------------------->| - | | - | Challenge (RAND+AUTN) | - |<-----------------------------------| - | | - | Sync Request (AUTS) | - |----------------------------------->| - | | - | Challenge (RAND'+AUTN') | - |<-----------------------------------| - | | - | Challenge Result (XRES) | - |----------------------------------->| - | | - | Register Result | - |<-----------------------------------| - -2.1. Register - -The client sends a REGISTER_REQ message containing an identifier number. - -2.2. Challenge - -The OAP server (optionally) sends back a CHALLENGE_REQ, containing random bytes -and a milenage authentication token generated from these random bytes, using a -shared secret, to authenticate itself to the OAP client. The server may omit -this challenge entirely, based on its configuration, and immediately reply with -a Register Result response. If the client cannot be registered (e.g. id is -invalid), the server sends a REGISTER_ERR response. - -2.3. Challenge Result - -When the client has received a Challenge, it may verify the server's -authenticity and validity of the sequence number (included in AUTN), and, if -valid, reply with a CHALLENGE_RES message. This shall contain an XRES -authentication token generated by milenage from the same random bytes received -from the server and the same shared secet. If the client decides to cancel the -registration (e.g. invalid AUTN), it shall not reply to the CHALLENGE_REQ; a -CHALLENGE_ERR message may be sent, but is not mandatory. For example, the -client may directly start with a new REGISTER_REQ message. - -2.4. Sync Request - -When the client has received a Challenge but sees an invalid sequence number -(embedded in AUTN, according to the milenage algorithm), the client may send a -SYNC_REQ message containing an AUTS synchronisation token. - -2.5. Sync Result - -If the server has received a valid Sync Request, it shall answer by directly -sending another Challenge (see 2.2.). If an invalid Sync Request is received, -the server shall reply with a REGISTER_ERR message. - -2.6. Register Result - -The server sends a REGISTER_RES message to indicate that registration has been -successful. If the server cannot register the client (e.g. invalid challenge -response), it shall send a REGISTER_ERR message. - -3. Message Format - -3.1. General - -Every message is based on the following message format - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - -The receiver shall be able to receive IEs in any order. Unknown IEs shall be -ignored. - -3.2.1. Register Request - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 30 Client ID big endian int (2 oct) M TLV 4 - -3.2.2. Register Error - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 02 Cause GMM cause, M TLV 3 - 04.08: 10.5.5.14 - -3.2.3. Register Result - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - -3.2.4. Challenge - -Server -> Client - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 20 RAND octet string (16) M TLV 18 - 23 AUTN octet string (16) M TLV 18 - -3.2.5. Challenge Error - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 02 Cause GMM cause, M TLV 3 - 04.08: 10.5.5.14 - -3.2.6. Challenge Result - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 21 XRES octet string (8) M TLV 10 - -3.2.7. Sync Request - -Client -> Server - - IEI Info Element Type Pres. Format Length - Message type 4.2.1 M V 1 - 20 AUTS octet string (14) M TLV 16 - -3.2.8. Sync Error - -Not used. - -3.2.9. Sync Result - -Not used. - - -4. Information Elements - -4.1. General - -[...] - -4.2.1. Message Type - - +---------------------------------------------------+ - | 8 7 6 5 4 3 2 1 | - | | - | 0 0 0 0 0 1 0 0 - Register Request | - | 0 0 0 0 0 1 0 1 - Register Error | - | 0 0 0 0 0 1 1 0 - Register Result | - | | - | 0 0 0 0 1 0 0 0 - Challenge Request | - | 0 0 0 0 1 0 0 1 - Challenge Error | - | 0 0 0 0 1 0 1 0 - Challenge Result | - | | - | 0 0 0 0 1 1 0 0 - Sync Request | - | 0 0 0 0 1 1 0 1 - Sync Error (not used) | - | 0 0 0 0 1 1 1 0 - Sync Result (not used) | - | | - +---------------------------------------------------+ - -4.2.2. IE Identifier (informational) - -These are the standard values for the IEI. - - +---------------------------------------------------------+ - | IEI Info Element Type | - | | - | 0x02 Cause GMM cause, 04.08: 10.5.5.14 | - | 0x20 RAND octet string | - | 0x23 AUTN octet string | - | 0x24 XRES octet string | - | 0x25 AUTS octet string | - | 0x30 Client ID big endian int (2 octets) | - +---------------------------------------------------------+ - -4.2.3. Client ID - - 8 7 6 5 4 3 2 1 - +-----------------------------------------------------+ - | | Client ID IEI | octet 1 - +-----------------------------------------------------+ - | Length of Client ID IE contents (2) | octet 2 - +-----------------------------------------------------+ - | Client ID number, most significant byte | octet 3 - +-----------------------------------------------------+ - | Client ID number, least significant byte | octet 4 - +-----------------------------------------------------+ - -The Client ID number shall be interpreted as an unsigned 16bit integer, where 0 -indicates an invalid / unset ID. - -- To view, visit https://gerrit.osmocom.org/1829 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2d4dc608622a7484e67b15f930efc76e28285045 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: ikostov Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:23:08 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:23:08 +0000 Subject: openbsc[master]: Add support for extended SI2q parameters In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 I woudl simply remove the old command rather than deprecating it. It was present only for a relatively short amount of time, and there re probably not [yet?] many people running combined Osmocom GSM + LTE networks. -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:25:24 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:25:24 +0000 Subject: libosmocore[master]: linuxlist: add llist_first and llist_last macros In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 the header was imported from the Linux kernel, so when extending it, let's check if the kernel has this already. Indeed, it seems the kernel has list_first_entry() and list_lsat_entry(). Please don't introduce api/naming differences without good reason. -- To view, visit https://gerrit.osmocom.org/1826 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:26:06 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:26:06 +0000 Subject: libosmocore[master]: gsup: add osmo_gsup_message_type_name() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1816 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 15 23:26:08 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 15 Feb 2017 23:26:08 +0000 Subject: [MERGED] libosmocore[master]: gsup: add osmo_gsup_message_type_name() In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gsup: add osmo_gsup_message_type_name() ...................................................................... gsup: add osmo_gsup_message_type_name() Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360 --- M include/osmocom/gsm/gsup.h M src/gsm/gsup.c M src/gsm/libosmogsm.map 3 files changed, 35 insertions(+), 0 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h index e2912a6..04b31d0 100644 --- a/include/osmocom/gsm/gsup.h +++ b/include/osmocom/gsm/gsup.h @@ -95,6 +95,11 @@ #define OSMO_GSUP_IS_MSGT_ERROR(msgt) (((msgt) & 0b00000011) == 0b01) #define OSMO_GSUP_TO_MSGT_ERROR(msgt) (((msgt) & 0b11111100) | 0b01) +extern const struct value_string osmo_gsup_message_type_names[]; +static inline const char * +osmo_gsup_message_type_name(enum osmo_gsup_message_type val) +{ return get_value_string(osmo_gsup_message_type_names, val); } + enum osmo_gsup_cancel_type { OSMO_GSUP_CANCEL_TYPE_UPDATE = 1, /* on wire: 0 */ OSMO_GSUP_CANCEL_TYPE_WITHDRAW = 2, /* on wire: 1 */ diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index b1b97ca..ec1dc90 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -31,6 +31,35 @@ #include +const struct value_string osmo_gsup_message_type_names[] = { + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_AUTH_FAIL_REPORT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PURGE_MS_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PURGE_MS_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_PURGE_MS_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_INSERT_DATA_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_INSERT_DATA_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_DELETE_DATA_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_DELETE_DATA_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_DELETE_DATA_RESULT), + + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR), + OSMO_VALUE_STRING(OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT), + { 0, NULL } +}; + static int decode_pdp_info(uint8_t *data, size_t data_len, struct osmo_gsup_pdp_info *pdp_info) { diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index e153d72..78e55df 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -363,6 +363,7 @@ osmo_gsup_encode; osmo_gsup_decode; +osmo_gsup_message_type_names; osmo_oap_encode; osmo_oap_decode; -- To view, visit https://gerrit.osmocom.org/1816 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 11:23:30 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 11:23:30 +0000 Subject: [PATCH] openbsc[master]: Handle DSD from HLR Message-ID: Review at https://gerrit.osmocom.org/1838 Handle DSD from HLR Handle Delete Subscriber Data GSUP message from HLR to disable Packet Services for a given IMSI. Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Related: OS#1645 --- M openbsc/src/gprs/gprs_subscriber.c 1 file changed, 25 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/38/1838/1 diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index d3e2ea7..d4fad7d 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -357,6 +357,26 @@ return 0; } +static int gprs_subscr_handle_gsup_dsd_req(struct gsm_subscriber *subscr, + struct osmo_gsup_message *gsup_msg) +{ + struct osmo_gsup_message gsup_reply = {0}; + + if (gsup_msg->cn_domain != OSMO_GSUP_CN_DOMAIN_PS) { + LOGGSUBSCRP(LOGL_ERROR, subscr, + "Rx GSUP message %s not yet implemented for CS\n", + osmo_gsup_message_type_name(gsup_msg->message_type)); + gsup_reply.cause = GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_ERROR; + } else { + gsm0408_gprs_access_cancelled(subscr->sgsn_data->mm, + GMM_CAUSE_GPRS_NOTALLOWED); + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_RESULT; + } + + return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); +} + static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, struct osmo_gsup_message *gsup_msg) { @@ -644,7 +664,8 @@ } LOGGSUBSCRP(LOGL_INFO, subscr, - "Received GSUP message of type 0x%02x\n", gsup_msg.message_type); + "Received GSUP message %s\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); switch (gsup_msg.message_type) { case OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST: @@ -680,18 +701,13 @@ break; case OSMO_GSUP_MSGT_DELETE_DATA_REQUEST: - LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not yet implemented\n", - gsup_msg.message_type); - gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg, - GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); - rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + rc = gprs_subscr_handle_gsup_dsd_req(subscr, &gsup_msg); break; default: LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not valid at SGSN\n", - gsup_msg.message_type); + "Rx GSUP message %s not valid at SGSN\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type)) gprs_subscr_tx_gsup_error_reply( subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 11:30:36 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 11:30:36 +0000 Subject: [PATCH] osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1821 to look at the new patch set (#6). Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 362 insertions(+), 258 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/21/1821/6 diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 6420cc5..d74d9fb 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -19,7 +19,7 @@ #include #include - +#include #include #include @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,187 +84,9 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - -struct lu_operation *lu_op_by_imsi(const char *imsi) -{ - struct lu_operation *luop; - - llist_for_each_entry(luop, &g_lu_ops, list) { - if (!strcmp(imsi, luop->subscr.imsi)) - return luop; - } - return NULL; -} - -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/* timer call-back in case LU operation doesn't receive an response */ -static void lu_op_timer_cb(void *data) -{ - struct lu_operation *luop = data; - - DEBUGP(DMAIN, "LU OP timer expired in state %s\n", - get_value_string(lu_state_names, luop->state)); - - switch (luop->state) { - case LU_S_CANCEL_SENT: - break; - case LU_S_ISD_SENT: - break; - default: - break; - } - - lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); -} - -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +96,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ @@ -364,38 +138,18 @@ } } -static struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) -{ - struct lu_operation *luop; - - luop = talloc_zero(srv, struct lu_operation); - OSMO_ASSERT(luop); - luop->gsup_server = srv; - luop->timer.cb = lu_op_timer_cb; - luop->timer.data = luop; - - return luop; -} - /*! Receive Update Location Request, creates new \ref lu_operation */ static int rx_upd_loc_req(struct osmo_gsup_conn *conn, const struct osmo_gsup_message *gsup) { - int rc; - struct lu_operation *luop; - struct hlr_subscriber *subscr; - uint8_t *peer_addr; - - rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); - if (rc < 0) { + struct lu_operation *luop = lu_op_alloc_conn(conn); + if (!luop) { LOGP(DMAIN, LOGL_ERROR, "LU REQ from conn without addr?\n"); - return rc; + return -EINVAL; } - luop = lu_op_alloc(conn->server); - luop->peer = talloc_memdup(luop, peer_addr, rc); lu_op_statechg(luop, LU_S_LU_RECEIVED); - subscr = &luop->subscr; + if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS) luop->is_ps = true; llist_add(&luop->list, &g_lu_ops); @@ -403,8 +157,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - rc = db_subscr_get(g_dbc, gsup->imsi, subscr); - if (rc < 0) { + if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -413,10 +166,10 @@ /* Check if subscriber is generally permitted on CS or PS * service (as requested) */ - if (!luop->is_ps && !subscr->nam_cs) { + if (!luop->is_ps && !luop->subscr.nam_cs) { lu_op_tx_error(luop, GMM_CAUSE_PLMN_NOTALLOWED); return 0; - } else if (luop->is_ps && !subscr->nam_ps) { + } else if (luop->is_ps && !luop->subscr.nam_ps) { lu_op_tx_error(luop, GMM_CAUSE_GPRS_NOTALLOWED); return 0; } @@ -508,7 +261,8 @@ case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT: { - struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); + struct lu_operation *luop = lu_op_by_imsi(gsup.imsi, + &g_lu_ops); if (!luop) { LOGP(DMAIN, LOGL_ERROR, "GSUP message %s for " "unknown IMSI %s\n", diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..ecf31b4 --- /dev/null +++ b/src/luop.c @@ -0,0 +1,268 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +/* timer call-back in case LU operation doesn't receive an response */ +static void lu_op_timer_cb(void *data) +{ + struct lu_operation *luop = data; + + DEBUGP(DMAIN, "LU OP timer expired in state %s\n", + get_value_string(lu_state_names, luop->state)); + + switch (luop->state) { + case LU_S_CANCEL_SENT: + break; + case LU_S_ISD_SENT: + break; + default: + break; + } + + lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); +} + +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi) +{ + struct hlr_subscriber *subscr = &luop->subscr; + + if (db_subscr_get(dbc, imsi, subscr) < 0) + return false; + + return true; +} + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) +{ + struct lu_operation *luop; + + luop = talloc_zero(srv, struct lu_operation); + OSMO_ASSERT(luop); + luop->gsup_server = srv; + luop->timer.cb = lu_op_timer_cb; + luop->timer.data = luop; + + return luop; +} + +struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn) +{ + uint8_t *peer_addr; + struct lu_operation *luop = lu_op_alloc(conn->server); + int rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); + if (rc < 0) + return NULL; + + luop->peer = talloc_memdup(luop, peer_addr, rc); + + return luop; +} + +/* FIXME: this doesn't seem to work at all */ +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst) +{ + struct lu_operation *luop; + + llist_for_each_entry(luop, lst, list) { + if (!strcmp(imsi, luop->subscr.imsi)) + return luop; + } + return NULL; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..7e2fbb0 --- /dev/null +++ b/src/luop.h @@ -0,0 +1,80 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv); +struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn); +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi); +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 16 11:30:36 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 11:30:36 +0000 Subject: [PATCH] osmo-hlr[master]: Use strings for GSUP message type Message-ID: Review at https://gerrit.osmocom.org/1839 Use strings for GSUP message type Change-Id: Idf57a314f5c8cfbd4818600c90020e3ed3decc77 --- M src/hlr.c 1 file changed, 5 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/39/1839/1 diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..6420cc5 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -510,8 +510,9 @@ { struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); if (!luop) { - LOGP(DMAIN, LOGL_ERROR, "GSUP message %u for " - "unknown IMSI %s\n", gsup.message_type, + LOGP(DMAIN, LOGL_ERROR, "GSUP message %s for " + "unknown IMSI %s\n", + osmo_gsup_message_type_name(gsup.message_type), gsup.imsi); break; } @@ -519,8 +520,8 @@ } break; default: - LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %u\n", - gsup.message_type); + LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n", + osmo_gsup_message_type_name(gsup.message_type)); break; } msgb_free(msg); -- To view, visit https://gerrit.osmocom.org/1839 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idf57a314f5c8cfbd4818600c90020e3ed3decc77 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 11:38:08 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 11:38:08 +0000 Subject: osmo-bts[master]: osmo-bts-trx: cosmetic fixes In-Reply-To: References: Message-ID: Patch Set 3: It doesn't have any user-visible changes - in theory it might be fixing bug with DTXu but I was unable to construct a test case for such a bug. Shall I split this into separate commit or change commit message? -- To view, visit https://gerrit.osmocom.org/1776 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icb536f951386b9abe34c0dacbb203f3db1e41bb3 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Tom Tsou Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 16 12:00:52 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 12:00:52 +0000 Subject: [PATCH] osmo-hlr[master]: Update DB routines Message-ID: Review at https://gerrit.osmocom.org/1840 Update DB routines * add SQL queries to change nam_ps value * move common cleanup code into separate function * fix printf security warning Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 29 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/1 diff --git a/src/db.c b/src/db.c index 1385502..8e52293 100644 --- a/src/db.c +++ b/src/db.c @@ -19,6 +19,7 @@ #include +#include #include #include "logging.h" @@ -32,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) @@ -46,7 +49,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); @@ -57,6 +60,23 @@ } } +/* remove bindings and reset statement to be re-executed */ +bool db_remove_reset(sqlite3_stmt *stmt) +{ + int rc = sqlite3_clear_bindings(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); + return false; + } + + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); + return false; + } + return true; +} + void db_close(struct db_context *dbc) { unsigned int i; diff --git a/src/db.h b/src/db.h index d569fb0..86c6aed 100644 --- a/src/db.h +++ b/src/db.h @@ -9,8 +9,10 @@ UPD_SGSN_BY_ID = 2, AUC_BY_IMSI = 3, AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -20,6 +22,7 @@ sqlite3_stmt *stmt[_NUM_STMT]; }; +bool db_remove_reset(sqlite3_stmt *stmt); void db_close(struct db_context *dbc); struct db_context *db_open(void *ctx, const char *fname); diff --git a/src/db_hlr.c b/src/db_hlr.c index 1b95556..4f1e0d5 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -73,15 +73,7 @@ subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -123,15 +115,7 @@ goto out; } out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -162,15 +146,7 @@ } /* FIXME: return 0 in case IMSI not known */ out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 12:44:06 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 12:44:06 +0000 Subject: [PATCH] osmo-hlr[master]: Update DB routines In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#2). Update DB routines * add SQL queries to change nam_ps value and function which uses them * move common cleanup code into separate function * add helper function for IMSI binding * fix printf security warning * use errno.h instead of numbers * code cleanup Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 75 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/2 diff --git a/src/db.c b/src/db.c index 1385502..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -19,6 +19,7 @@ #include +#include #include #include "logging.h" @@ -32,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) @@ -46,7 +49,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); @@ -57,6 +60,36 @@ } } +/* remove bindings and reset statement to be re-executed */ +bool db_remove_reset(sqlite3_stmt *stmt) +{ + int rc = sqlite3_clear_bindings(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); + return false; + } + + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); + return false; + } + return true; +} + +/* bind IMSI and do proper cleanup in case of failure */ +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi) +{ + int rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); + db_remove_reset(stmt); + return false; + } + + return true; +} + void db_close(struct db_context *dbc) { unsigned int i; diff --git a/src/db.h b/src/db.h index d569fb0..b441d6a 100644 --- a/src/db.h +++ b/src/db.h @@ -9,8 +9,10 @@ UPD_SGSN_BY_ID = 2, AUC_BY_IMSI = 3, AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -20,6 +22,8 @@ sqlite3_stmt *stmt[_NUM_STMT]; }; +bool db_remove_reset(sqlite3_stmt *stmt); +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi); void db_close(struct db_context *dbc); struct db_context *db_open(void *ctx, const char *fname); @@ -68,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index 1b95556..a2b708f 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -42,17 +43,14 @@ sqlite3_stmt *stmt = dbc->stmt[SEL_BY_IMSI]; int rc, ret = 0; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGHLR(imsi, LOGL_ERROR, "Error binding IMSI: %d\n", rc); - return -1; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_ROW) { LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); - ret = -2; + ret = -ENOEXEC; goto out; } @@ -73,17 +71,29 @@ subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; +} + +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc = 0; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + /* execute the statement */ + rc = sqlite3_step(stmt); + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + db_remove_reset(stmt); + return rc; } int db_subscr_lu(struct db_context *dbc, @@ -105,13 +115,13 @@ rc = sqlite3_bind_int64(stmt, 1, subscr->id); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding ID: %d\n", rc); - return -1; + return -EINVAL; } rc = sqlite3_bind_text(stmt, 2, txt, -1, SQLITE_STATIC); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding VLR/SGSN Number: %d\n", rc); - ret = -2; + ret = -ECHRNG; goto out; } @@ -119,19 +129,10 @@ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error updating SQN: %d\n", rc); - ret = -3; - goto out; + ret = -ENOEXEC; } out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -146,31 +147,18 @@ else stmt = dbc->stmt[UPD_PURGE_CS_BY_IMSI]; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); - ret = -1; - goto out; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error setting Purged: %d\n", rc); - ret = -2; - goto out; + ret = -ENOEXEC; } /* FIXME: return 0 in case IMSI not known */ -out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + + db_remove_reset(stmt); return ret; } -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 16 12:44:06 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 12:44:06 +0000 Subject: [PATCH] osmo-hlr[master]: Expand CTRL interface Message-ID: Review at https://gerrit.osmocom.org/1841 Expand CTRL interface Add commands to enable/disable Packet Service for a given IMSI. Changes are synced to DB and propagated at runtime to SGSN (in case of disable command). Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Related: OS#1645 --- M src/ctrl.c M src/db_hlr.c M src/hlr.c M src/luop.c M src/luop.h 5 files changed, 76 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/41/1841/1 diff --git a/src/ctrl.c b/src/ctrl.c index b7514c5..8165926 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -32,6 +32,47 @@ #include "luop.h" #include "ctrl.h" +static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd, + bool enable) +{ + struct lu_operation *luop = NULL; + struct osmo_gsup_conn *co; + + if (db_subscr_get(gs->dbc, cmd->value, NULL) < 0) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + if (db_subscr_ps(gs->dbc, cmd->value, enable) < 0) { + cmd->reply = "Error updating DB"; + return CTRL_CMD_ERROR; + } + + if (!enable){ /* FIXME: only send to single SGSN where latest update for IMSI came from */ + llist_for_each_entry(co, &gs->clients, list) { + luop = lu_op_alloc_conn(co); + lu_op_fill_subscr(luop, gs->dbc, cmd->value); + lu_op_tx_del_subscr_data(luop); + } + } + + cmd->reply = "OK"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_WO_NOVRF(enable_ps, "enable-ps"); +static int set_enable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, true); +} + +CTRL_CMD_DEFINE_WO_NOVRF(disable_ps, "disable-ps"); +static int set_disable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, false); +} + CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); static int set_status_ps(struct ctrl_cmd *cmd, void *data) { @@ -55,6 +96,8 @@ { int rc = 0; + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_enable_ps); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_disable_ps); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); return rc; diff --git a/src/db_hlr.c b/src/db_hlr.c index a2b708f..8289d86 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -54,22 +54,23 @@ goto out; } - /* obtain the various columns */ - subscr->id = sqlite3_column_int64(stmt, 0); - SL3_TXT(subscr->imsi, stmt, 1); - SL3_TXT(subscr->msisdn, stmt, 2); - /* FIXME: These should all be BLOBs as they might contain NUL */ - SL3_TXT(subscr->vlr_number, stmt, 3); - SL3_TXT(subscr->sgsn_number, stmt, 4); - SL3_TXT(subscr->sgsn_address, stmt, 5); - subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); - subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); - subscr->nam_cs = sqlite3_column_int(stmt, 8); - subscr->nam_ps = sqlite3_column_int(stmt, 9); - subscr->lmsi = sqlite3_column_int(stmt, 10); - subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); - subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); - + if (subscr) { + /* obtain the various columns */ + subscr->id = sqlite3_column_int64(stmt, 0); + SL3_TXT(subscr->imsi, stmt, 1); + SL3_TXT(subscr->msisdn, stmt, 2); + /* FIXME: These should all be BLOBs as they might contain NUL */ + SL3_TXT(subscr->vlr_number, stmt, 3); + SL3_TXT(subscr->sgsn_number, stmt, 4); + SL3_TXT(subscr->sgsn_address, stmt, 5); + subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); + subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); + subscr->nam_cs = sqlite3_column_int(stmt, 8); + subscr->nam_ps = sqlite3_column_int(stmt, 9); + subscr->lmsi = sqlite3_column_int(stmt, 10); + subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); + subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); + } out: db_remove_reset(stmt); diff --git a/src/hlr.c b/src/hlr.c index 5ae5ff3..0a3642c 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -257,6 +257,8 @@ rx_purge_ms_req(conn, &gsup); break; /* responses to requests sent by us */ + case OSMO_GSUP_MSGT_DELETE_DATA_ERROR: + case OSMO_GSUP_MSGT_DELETE_DATA_RESULT: case OSMO_GSUP_MSGT_INSERT_DATA_ERROR: case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: diff --git a/src/luop.c b/src/luop.c index ecf31b4..937c02c 100644 --- a/src/luop.c +++ b/src/luop.c @@ -266,3 +266,16 @@ lu_op_statechg(luop, LU_S_ISD_SENT); osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } + +/*! Transmit Delete Subscriber Data to new VLR/SGSN */ +void lu_op_tx_del_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_DELETE_DATA_REQUEST); + + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); +} diff --git a/src/luop.h b/src/luop.h index 7e2fbb0..ab1bc24 100644 --- a/src/luop.h +++ b/src/luop.h @@ -78,3 +78,4 @@ void lu_op_tx_ack(struct lu_operation *luop); void lu_op_tx_cancel_old(struct lu_operation *luop); void lu_op_tx_insert_subscr_data(struct lu_operation *luop); +void lu_op_tx_del_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 12:57:36 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 12:57:36 +0000 Subject: [PATCH] openbsc[master]: Handle DSD from HLR In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1838 to look at the new patch set (#2). Handle DSD from HLR Handle Delete Subscriber Data GSUP message from HLR to disable Packet Services for a given IMSI. Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Related: OS#1645 --- M openbsc/src/gprs/gprs_subscriber.c M openbsc/tests/sgsn/sgsn_test.c 2 files changed, 27 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/38/1838/2 diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index d3e2ea7..d4fad7d 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -357,6 +357,26 @@ return 0; } +static int gprs_subscr_handle_gsup_dsd_req(struct gsm_subscriber *subscr, + struct osmo_gsup_message *gsup_msg) +{ + struct osmo_gsup_message gsup_reply = {0}; + + if (gsup_msg->cn_domain != OSMO_GSUP_CN_DOMAIN_PS) { + LOGGSUBSCRP(LOGL_ERROR, subscr, + "Rx GSUP message %s not yet implemented for CS\n", + osmo_gsup_message_type_name(gsup_msg->message_type)); + gsup_reply.cause = GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_ERROR; + } else { + gsm0408_gprs_access_cancelled(subscr->sgsn_data->mm, + GMM_CAUSE_GPRS_NOTALLOWED); + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_RESULT; + } + + return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); +} + static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, struct osmo_gsup_message *gsup_msg) { @@ -644,7 +664,8 @@ } LOGGSUBSCRP(LOGL_INFO, subscr, - "Received GSUP message of type 0x%02x\n", gsup_msg.message_type); + "Received GSUP message %s\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); switch (gsup_msg.message_type) { case OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST: @@ -680,18 +701,13 @@ break; case OSMO_GSUP_MSGT_DELETE_DATA_REQUEST: - LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not yet implemented\n", - gsup_msg.message_type); - gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg, - GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); - rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + rc = gprs_subscr_handle_gsup_dsd_req(subscr, &gsup_msg); break; default: LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not valid at SGSN\n", - gsup_msg.message_type); + "Rx GSUP message %s not valid at SGSN\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type)) gprs_subscr_tx_gsup_error_reply( subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 0aa142f..ff07978 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -634,7 +634,8 @@ /* Inject DeleteSubscrData GSUP message */ last_updated_subscr = NULL; rc = rx_gsup_message(delete_data_req, sizeof(delete_data_req)); - OSMO_ASSERT(rc == -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); + if (rc != -GMM_CAUSE_SEM_INCORR_MSG) + printf("Unexpected response to DSD: %d\n", rc); OSMO_ASSERT(last_updated_subscr == NULL); /* Inject wrong LocCancelReq GSUP message */ -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 16 13:00:18 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 13:00:18 +0000 Subject: [PATCH] osmo-hlr[master]: Update DB routines In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#3). Update DB routines * add SQL queries to change nam_ps value and function which uses them * move common cleanup code into separate function * add helper function for IMSI binding * fix printf security warning * use errno.h instead of numbers * code cleanup Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 75 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/3 diff --git a/src/db.c b/src/db.c index 1385502..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -19,6 +19,7 @@ #include +#include #include #include "logging.h" @@ -32,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) @@ -46,7 +49,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); @@ -57,6 +60,36 @@ } } +/* remove bindings and reset statement to be re-executed */ +bool db_remove_reset(sqlite3_stmt *stmt) +{ + int rc = sqlite3_clear_bindings(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); + return false; + } + + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); + return false; + } + return true; +} + +/* bind IMSI and do proper cleanup in case of failure */ +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi) +{ + int rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); + db_remove_reset(stmt); + return false; + } + + return true; +} + void db_close(struct db_context *dbc) { unsigned int i; diff --git a/src/db.h b/src/db.h index d569fb0..b441d6a 100644 --- a/src/db.h +++ b/src/db.h @@ -9,8 +9,10 @@ UPD_SGSN_BY_ID = 2, AUC_BY_IMSI = 3, AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -20,6 +22,8 @@ sqlite3_stmt *stmt[_NUM_STMT]; }; +bool db_remove_reset(sqlite3_stmt *stmt); +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi); void db_close(struct db_context *dbc); struct db_context *db_open(void *ctx, const char *fname); @@ -68,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index 1b95556..4d941e9 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -42,17 +43,14 @@ sqlite3_stmt *stmt = dbc->stmt[SEL_BY_IMSI]; int rc, ret = 0; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGHLR(imsi, LOGL_ERROR, "Error binding IMSI: %d\n", rc); - return -1; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_ROW) { LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); - ret = -2; + ret = -ENOEXEC; goto out; } @@ -73,17 +71,29 @@ subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; +} + +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc = 0; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + /* execute the statement */ + rc = sqlite3_step(stmt); + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + db_remove_reset(stmt); + return rc; } int db_subscr_lu(struct db_context *dbc, @@ -105,13 +115,13 @@ rc = sqlite3_bind_int64(stmt, 1, subscr->id); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding ID: %d\n", rc); - return -1; + return -EINVAL; } rc = sqlite3_bind_text(stmt, 2, txt, -1, SQLITE_STATIC); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding VLR/SGSN Number: %d\n", rc); - ret = -2; + ret = -EBADMSG; goto out; } @@ -119,19 +129,10 @@ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error updating SQN: %d\n", rc); - ret = -3; - goto out; + ret = -ENOEXEC; } out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -146,31 +147,18 @@ else stmt = dbc->stmt[UPD_PURGE_CS_BY_IMSI]; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); - ret = -1; - goto out; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error setting Purged: %d\n", rc); - ret = -2; - goto out; + ret = -ENOEXEC; } /* FIXME: return 0 in case IMSI not known */ -out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + + db_remove_reset(stmt); return ret; } -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 16 13:12:10 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 13:12:10 +0000 Subject: [PATCH] openbsc[master]: Add support for extended SI2q parameters In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1828 to look at the new patch set (#2). Add support for extended SI2q parameters * add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1 * deprecate old command which does not support those parameters Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Fixes: RT#8792 --- M openbsc/src/libbsc/bsc_vty.c 1 file changed, 72 insertions(+), 32 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/28/1828/2 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 00acbc7..73acebd 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -541,6 +541,7 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) { int i; + uint8_t tmp; vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); @@ -694,15 +695,23 @@ } for (i = 0; i < MAX_EARFCN_LIST; i++) { - if (bts->si_common.si2quater_neigh_list.arfcn[i] != - OSMO_EARFCN_INVALID) { - vty_out(vty, " si2quater neighbor-list add earfcn %u threshold %u", - bts->si_common.si2quater_neigh_list.arfcn[i], - bts->si_common.si2quater_neigh_list.thresh_hi); - if (bts->si_common.si2quater_neigh_list.meas_bw[i] != - OSMO_EARFCN_MEAS_INVALID) - vty_out(vty, " %u", - bts->si_common.si2quater_neigh_list.meas_bw[i]); + struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; + if (e->arfcn[i] != OSMO_EARFCN_INVALID) { + vty_out(vty, " si2quater neighbor-list add earfcn %u " + "thresh-hi %u", e->arfcn[i], e->thresh_hi); + + vty_out(vty, " thresh-lo %u", + e->thresh_lo_valid ? e->thresh_lo : 32); + + vty_out(vty, " prio %u", + e->prio_valid ? e->prio : 8); + + vty_out(vty, " qrxlv %u", + e->qrxlm_valid ? e->qrxlm : 32); + + tmp = e->meas_bw[i]; + vty_out(vty, " meas %u", + (tmp != OSMO_EARFCN_MEAS_INVALID) ? tmp : 8); vty_out(vty, "%s", VTY_NEWLINE); } @@ -2746,42 +2755,73 @@ return CMD_SUCCESS; } - DEFUN(cfg_bts_si2quater_neigh_add, cfg_bts_si2quater_neigh_add_cmd, - "si2quater neighbor-list add earfcn <0-65535> threshold <0-31> " - "[<0-7>]", "SI2quater Neighbor List\n" - "SI2quater Neighbor List\n" "Add to manual SI2quater neighbor list\n" - "EARFCN of neighbor\n" "EARFCN of neighbor\n" "threshold high bits\n" - "threshold high bits\n" "measurement bandwidth\n") + "si2quater neighbor-list add earfcn <0-65535> thresh-hi <0-31> " + "thresh-lo <0-32> prio <0-8> qrxlv <0-32> meas <0-8>", + "SI2quater Neighbor List\n" "SI2quater Neighbor List\n" + "Add to manual SI2quater neighbor list\n" + "EARFCN of neighbor\n" "EARFCN of neighbor\n" + "threshold high bits\n" "threshold high bits\n" + "threshold low bits\n" "threshold low bits (32 means NA)\n" + "priority\n" "priority (8 means NA)\n" + "QRXLEVMIN\n" "QRXLEVMIN (32 means NA)\n" + "measurement bandwidth\n" "measurement bandwidth (8 means NA)\n") { struct gsm_bts *bts = vty->index; struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; uint16_t arfcn = atoi(argv[0]); - uint8_t meas = OSMO_EARFCN_MEAS_INVALID, thresh = atoi(argv[1]); - int r; - - if (3 == argc) - meas = atoi(argv[2]); - - r = osmo_earfcn_add(e, arfcn, meas); + uint8_t thresh_hi = atoi(argv[1]), thresh_lo = atoi(argv[2]), + prio = atoi(argv[3]), qrx = atoi(argv[4]), meas = atoi(argv[5]); + int r = osmo_earfcn_add(e, arfcn, + (meas < 8) ? meas : OSMO_EARFCN_MEAS_INVALID); if (r < 0) { - vty_out(vty, "Unable to add arfcn %u: %s%s", arfcn, strerror(-r), + vty_out(vty, "Unable to add ARFCN %u: %s%s", arfcn, strerror(-r), VTY_NEWLINE); return CMD_WARNING; } - if (si2q_size_check(bts)) { - if (e->thresh_hi && thresh != e->thresh_hi) - vty_out(vty, "Warning: multiple thresholds are not " - "supported, overriding previous threshold %u%s", - e->thresh_hi, VTY_NEWLINE); - e->thresh_hi = thresh; - return CMD_SUCCESS; + if (e->thresh_hi && thresh_hi != e->thresh_hi) + vty_out(vty, "Warning: multiple threshold-high are not " + "supported, overriding previous threshold %u%s", + e->thresh_hi, VTY_NEWLINE); + + e->thresh_hi = thresh_hi; + + if (thresh_lo != 32) { + if (e->thresh_lo_valid && e->thresh_lo != thresh_lo) + vty_out(vty, "Warning: multiple threshold-low are not " + "supported, overriding previous threshold %u%s", + e->thresh_lo, VTY_NEWLINE); + e->thresh_lo = thresh_lo; + e->thresh_lo_valid = true; } - vty_out(vty, "Warning: not enough space in si2quater for a given arfcn%s" - , VTY_NEWLINE); + + if (qrx != 32) { + if (e->qrxlm_valid && e->qrxlm != qrx) + vty_out(vty, "Warning: multiple QRXLEVMIN are not " + "supported, overriding previous value %u%s", + e->qrxlm, VTY_NEWLINE); + e->qrxlm = qrx; + e->qrxlm_valid = true; + } + + if (prio != 8) { + if (e->prio_valid && e->prio != prio) + vty_out(vty, "Warning: multiple priorities are not " + "supported, overriding previous value %u%s", + e->prio, VTY_NEWLINE); + e->prio = prio; + e->prio_valid = true; + } + + if (si2q_size_check(bts)) + return CMD_SUCCESS; + + vty_out(vty, "Warning: not enough space in SI2quater for a given EARFCN " + "%u%s", arfcn, VTY_NEWLINE); osmo_earfcn_del(e, arfcn); + return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 16 13:13:01 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 13:13:01 +0000 Subject: openbsc[master]: Add support for extended SI2q parameters In-Reply-To: References: Message-ID: Patch Set 2: Testing by customer confirmed that it works. -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 16 13:21:44 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 16 Feb 2017 13:21:44 +0000 Subject: [ABANDON] libosmocore[master]: linuxlist: add llist_first and llist_last macros In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: linuxlist: add llist_first and llist_last macros ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1826 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 13:22:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 16 Feb 2017 13:22:02 +0000 Subject: [ABANDON] openbsc[master]: remove llist_first/last from gtphub.c, now in libosmocore In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: remove llist_first/last from gtphub.c, now in libosmocore ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1825 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ie682c681f6a785690b660ca31fae2c3893f49846 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 16 13:22:06 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 16 Feb 2017 13:22:06 +0000 Subject: [ABANDON] openbsc[master]: cosmetic: prepare for llist_first/_last in libosmocore In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: cosmetic: prepare for llist_first/_last in libosmocore ...................................................................... Abandoned -- To view, visit https://gerrit.osmocom.org/1824 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I8afaad471eb38d897184ea53cb1f4d10850e35eb Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 16 14:43:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 16 Feb 2017 14:43:04 +0000 Subject: openbsc[master]: add struct gprs_sub, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 6: Verified+1 verified that GPRS still works with this change -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 16 15:21:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 16 Feb 2017 15:21:04 +0000 Subject: openbsc[master]: add struct gprs_sub, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 6: Code-Review-1 (still going to rename gprs_sub to gprs_subscriber though, by request from hwelte) -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 16 16:06:00 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 16:06:00 +0000 Subject: libosmocore[master]: Add osmo_rand() function In-Reply-To: References: Message-ID: Patch Set 2: In glibc 2.25 getentropy() and getrandom() were added which would help. Not sure how long it'll take until it hit all the distributions though. -- To view, visit https://gerrit.osmocom.org/1526 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 16 16:07:43 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 16:07:43 +0000 Subject: libosmocore[master]: Add osmo_rand() function In-Reply-To: References: Message-ID: Patch Set 2: Another point for external crypto library dependency would be that it could replace our AES implementation copy-pasted from hostapd. -- To view, visit https://gerrit.osmocom.org/1526 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 16 16:29:55 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 16:29:55 +0000 Subject: [PATCH] openbsc[master]: Add support for extended SI2q parameters In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1828 to look at the new patch set (#3). Add support for extended SI2q parameters * add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1 * remove old command which does not support those parameters Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Fixes: RT#8792 --- M openbsc/src/libbsc/bsc_vty.c 1 file changed, 72 insertions(+), 32 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/28/1828/3 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 00acbc7..73acebd 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -541,6 +541,7 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) { int i; + uint8_t tmp; vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); @@ -694,15 +695,23 @@ } for (i = 0; i < MAX_EARFCN_LIST; i++) { - if (bts->si_common.si2quater_neigh_list.arfcn[i] != - OSMO_EARFCN_INVALID) { - vty_out(vty, " si2quater neighbor-list add earfcn %u threshold %u", - bts->si_common.si2quater_neigh_list.arfcn[i], - bts->si_common.si2quater_neigh_list.thresh_hi); - if (bts->si_common.si2quater_neigh_list.meas_bw[i] != - OSMO_EARFCN_MEAS_INVALID) - vty_out(vty, " %u", - bts->si_common.si2quater_neigh_list.meas_bw[i]); + struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; + if (e->arfcn[i] != OSMO_EARFCN_INVALID) { + vty_out(vty, " si2quater neighbor-list add earfcn %u " + "thresh-hi %u", e->arfcn[i], e->thresh_hi); + + vty_out(vty, " thresh-lo %u", + e->thresh_lo_valid ? e->thresh_lo : 32); + + vty_out(vty, " prio %u", + e->prio_valid ? e->prio : 8); + + vty_out(vty, " qrxlv %u", + e->qrxlm_valid ? e->qrxlm : 32); + + tmp = e->meas_bw[i]; + vty_out(vty, " meas %u", + (tmp != OSMO_EARFCN_MEAS_INVALID) ? tmp : 8); vty_out(vty, "%s", VTY_NEWLINE); } @@ -2746,42 +2755,73 @@ return CMD_SUCCESS; } - DEFUN(cfg_bts_si2quater_neigh_add, cfg_bts_si2quater_neigh_add_cmd, - "si2quater neighbor-list add earfcn <0-65535> threshold <0-31> " - "[<0-7>]", "SI2quater Neighbor List\n" - "SI2quater Neighbor List\n" "Add to manual SI2quater neighbor list\n" - "EARFCN of neighbor\n" "EARFCN of neighbor\n" "threshold high bits\n" - "threshold high bits\n" "measurement bandwidth\n") + "si2quater neighbor-list add earfcn <0-65535> thresh-hi <0-31> " + "thresh-lo <0-32> prio <0-8> qrxlv <0-32> meas <0-8>", + "SI2quater Neighbor List\n" "SI2quater Neighbor List\n" + "Add to manual SI2quater neighbor list\n" + "EARFCN of neighbor\n" "EARFCN of neighbor\n" + "threshold high bits\n" "threshold high bits\n" + "threshold low bits\n" "threshold low bits (32 means NA)\n" + "priority\n" "priority (8 means NA)\n" + "QRXLEVMIN\n" "QRXLEVMIN (32 means NA)\n" + "measurement bandwidth\n" "measurement bandwidth (8 means NA)\n") { struct gsm_bts *bts = vty->index; struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; uint16_t arfcn = atoi(argv[0]); - uint8_t meas = OSMO_EARFCN_MEAS_INVALID, thresh = atoi(argv[1]); - int r; - - if (3 == argc) - meas = atoi(argv[2]); - - r = osmo_earfcn_add(e, arfcn, meas); + uint8_t thresh_hi = atoi(argv[1]), thresh_lo = atoi(argv[2]), + prio = atoi(argv[3]), qrx = atoi(argv[4]), meas = atoi(argv[5]); + int r = osmo_earfcn_add(e, arfcn, + (meas < 8) ? meas : OSMO_EARFCN_MEAS_INVALID); if (r < 0) { - vty_out(vty, "Unable to add arfcn %u: %s%s", arfcn, strerror(-r), + vty_out(vty, "Unable to add ARFCN %u: %s%s", arfcn, strerror(-r), VTY_NEWLINE); return CMD_WARNING; } - if (si2q_size_check(bts)) { - if (e->thresh_hi && thresh != e->thresh_hi) - vty_out(vty, "Warning: multiple thresholds are not " - "supported, overriding previous threshold %u%s", - e->thresh_hi, VTY_NEWLINE); - e->thresh_hi = thresh; - return CMD_SUCCESS; + if (e->thresh_hi && thresh_hi != e->thresh_hi) + vty_out(vty, "Warning: multiple threshold-high are not " + "supported, overriding previous threshold %u%s", + e->thresh_hi, VTY_NEWLINE); + + e->thresh_hi = thresh_hi; + + if (thresh_lo != 32) { + if (e->thresh_lo_valid && e->thresh_lo != thresh_lo) + vty_out(vty, "Warning: multiple threshold-low are not " + "supported, overriding previous threshold %u%s", + e->thresh_lo, VTY_NEWLINE); + e->thresh_lo = thresh_lo; + e->thresh_lo_valid = true; } - vty_out(vty, "Warning: not enough space in si2quater for a given arfcn%s" - , VTY_NEWLINE); + + if (qrx != 32) { + if (e->qrxlm_valid && e->qrxlm != qrx) + vty_out(vty, "Warning: multiple QRXLEVMIN are not " + "supported, overriding previous value %u%s", + e->qrxlm, VTY_NEWLINE); + e->qrxlm = qrx; + e->qrxlm_valid = true; + } + + if (prio != 8) { + if (e->prio_valid && e->prio != prio) + vty_out(vty, "Warning: multiple priorities are not " + "supported, overriding previous value %u%s", + e->prio, VTY_NEWLINE); + e->prio = prio; + e->prio_valid = true; + } + + if (si2q_size_check(bts)) + return CMD_SUCCESS; + + vty_out(vty, "Warning: not enough space in SI2quater for a given EARFCN " + "%u%s", arfcn, VTY_NEWLINE); osmo_earfcn_del(e, arfcn); + return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 16 16:45:12 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 16 Feb 2017 16:45:12 +0000 Subject: [PATCH] libosmocore[master]: Document ctrl_interface_setup_dynip() function Message-ID: Review at https://gerrit.osmocom.org/1842 Document ctrl_interface_setup_dynip() function Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e --- M src/ctrl/control_if.c 1 file changed, 8 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/42/1842/1 diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index b4afd55..254f9bc 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -654,6 +654,14 @@ return ctrl_interface_setup_dynip(data, "127.0.0.1", port, lookup); } +/*! \brief Setup CTRL interface on a given address + * \param[in] data Pointer which will be made available to each + set_..() get_..() verify_..() control command function + * \param[in] bind_addr Address on which CTRL socket shall listen + * \param[in] port Port on which CTRL socket shall listen + * \param[in] lookup Lookup function pointer, can be NULL + * \returns ctrl_handle pointer or NULL in case of errors + */ struct ctrl_handle *ctrl_interface_setup_dynip(void *data, const char *bind_addr, uint16_t port, -- To view, visit https://gerrit.osmocom.org/1842 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 17 01:06:07 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Fri, 17 Feb 2017 01:06:07 +0000 Subject: [ABANDON] osmo-pcu[master]: Sanitizer fix for invalid value of egprs_puncturing_values In-Reply-To: References: Message-ID: arvind.sirsikar has abandoned this change. Change subject: Sanitizer fix for invalid value of egprs_puncturing_values ...................................................................... Abandoned please see https://gerrit.osmocom.org/1775 for different version of the fix -- To view, visit https://gerrit.osmocom.org/1411 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ice54edc7e4a936eb2f2dd8a243673a30dceef542 Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: arvind.sirsikar Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar From gerrit-no-reply at lists.osmocom.org Fri Feb 17 01:33:58 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Fri, 17 Feb 2017 01:33:58 +0000 Subject: [PATCH] osmo-pcu[master]: PDCH allocation across two TRX In-Reply-To: References: Message-ID: Hello Max, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1512 to look at the new patch set (#4). PDCH allocation across two TRX Implementation: PCU keeps track of number PDCH across all the TRXs at BTS context and also keeps number of active PDCHs in each TRX context. This ratio gives the CAPACITY of each TRX. 1st Phase: While selection of TRX, functions get_possible_trxs(for multiple TS) and get_possible_trxs_sba(Single block allocation, Ex: during RACH) gets possible TRXs based on TFIs availability. 2nd Phase: outcome of TRXs(from get_possible_trxs, get_possible_trxs_sba) will be fed to get_suitable_trx function. Which does actual load balancing on each TRX. And selects the best fit TRX, based on below equation PROBABILITY = MAX_PROBABILITY ? ((LOAD * 100)/CAPACITY); If same PROBABILITY Select the one with higher capacity Else Find the TRX with higher PROBABILITY MAX_PROBABILITY = 65535; LOAD: Initialized to 0, Later gets incremented with number of TS allocated. and decremented while TBF deletion, based on number of TS allocated Below are the test executed on Unit test environment 1) 2 TRXs, with same Capacity 2) 2 TRX with ? capacity 3) 2 TRXs with ? capacity 4) 2 TRX with UL and DL allocation to ensure Tbfs on both direction is hosted on same TRX 5) 2 TRX with same Capacity and DL TBF creation and deletion scenarios to ensure proper load balancing criteria for actual Load. Below are the Test executed on Integration setup with Ettus B200 setup with 2 TRXs with same CAPACITY. 1) TRX allocation during RACH procedure(SBA allocation) 2) TRX allocation during DL TBF creation with multi time slots(4 time slots) 3) TRX allocation while Ping Test 4) TRX allocation while UDP test 5) TRX allocation for web browsing. 6) 2 MS test with each TRX sharing 1 MS. Received aggregate throughput of 446 kbps(223 Kbps each) Limitation: 1) BSSGP flow control needs to be tuned since test with 2 MS with each MS on different TRX runs for 20 mins 2) USF resource availibility is not checked while selecting the TRX as existing implementation Change-Id: I222c3340872ffa1dd6e8fabe5276d793e660f67d Related: OS# 1775 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac_ts_alloc.cpp M src/sba.cpp M src/tbf.cpp M tests/tbf/TbfTest.cpp M tests/tbf/TbfTest.err M tests/tbf/TbfTest.ok 8 files changed, 1,994 insertions(+), 44 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/12/1512/4 diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..0537ef6 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -188,11 +188,13 @@ { memset(&m_bts, 0, sizeof(m_bts)); m_bts.bts = this; - + m_total_pdch = 0; /* initialize back pointers */ for (size_t trx_no = 0; trx_no < ARRAY_SIZE(m_bts.trx); ++trx_no) { struct gprs_rlcmac_trx *trx = &m_bts.trx[trx_no]; trx->trx_no = trx_no; + trx->num_pdch = 0; + trx->current_load = 0; trx->bts = this; for (size_t ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ++ts_no) { @@ -407,19 +409,97 @@ return m_bts.trx[trx].pdch[ts].ul_tbf_by_tfi(tfi); } -/* - * Search for free TFI and return TFI, TRX. - * This method returns the first TFI that is currently not used in any PDCH of - * a TRX. The first TRX that contains such an TFI is returned. Negative values - * indicate errors. +/*! \brief: Return TRX number if available, else returns -EBUSY + * \param[in] dir The TBF direction(DL or UL) + * \param[out] _trx The uint8_t *. It is the selected TRX. + * \param[in] use_trx, if new MS receives -1, else receives current TRX of MS + * \returns -EBUSY if no TRX is available else returns valid trx in *_trx */ int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx) { struct gprs_rlcmac_pdch *pdch; - uint32_t free_tfis; + uint32_t free_tfis = 0xffffffff; + uint8_t ts, tfi; + bool possible_trx[8]; + int ret; + + /* This function will get list of possible TRXs */ + ret = get_possible_trxs(dir, possible_trx, use_trx); + if (ret < 0) + return -EBUSY; + + + if (use_trx >= 0) + *_trx = use_trx; + else + *_trx = get_suitable_trx(possible_trx); + + LOGP(DRLCMAC, LOGL_DEBUG, + "Searching for first unallocated TFI: TRX=%d\n", *_trx); + + for (ts = 0; ts < 8; ts++) { + pdch = &m_bts.trx[*_trx].pdch[ts]; + free_tfis &= ~pdch->assigned_tfi(dir); + } + /* find the first */ + for (tfi = 0; tfi < 32; tfi++) { + if (free_tfis & 1 << tfi) + break; + } + + OSMO_ASSERT(tfi < 32); + + LOGP(DRLCMAC, LOGL_DEBUG, " Found TFI=%d.\n", tfi); + + return tfi; +} + +/*! \brief: Prepares all the TRXs which can be used to host a perticulat TBF + * for single block allocation + * \param[in] *_trx The bool + * \param[in] _trx The bool *. Array of TRXs. initialized to false at caller + * array of size 8 + * \returns -EINVAL if no PDCH available else returns list of valid TRXs + */ +int BTS::get_possible_trxs_sba( + bool *_trx) +{ + uint8_t trx; bool has_pdch = false; - uint8_t trx_from, trx_to, trx, ts, tfi; + + for (trx = 0; trx < 8; trx++) { + if (bts_data()->trx[trx].num_pdch) { + _trx[trx] = true; + has_pdch = true; + LOGP(DRLCMAC, LOGL_DEBUG, " Valid TRX=%d.\n", trx); + } else { + _trx[trx] = false; + LOGP(DRLCMAC, LOGL_DEBUG, " Not valid TRX=%d.\n", trx); + } + } + if (has_pdch) + return 0; + + return -EINVAL; +} + +/*! \brief: Prepares all the TRXs which can be used to host a perticulat TBF + * for multi slots allocation + * \param[in] dir The gprs_rlcmac_tbf_direction + * \param[in] _trx The bool *. Array of TRXs. initialized to false at caller + * array of size 8 + * \returns -EINVAL if no PDCH available or -EBUSY if no TFIs available + * else returns list of valid TRXs + */ +int BTS::get_possible_trxs(enum gprs_rlcmac_tbf_direction dir, + bool *_trx, int8_t use_trx) +{ + struct gprs_rlcmac_pdch *pdch; + uint32_t free_tfis; + uint32_t is_tfis_available = false; + bool has_pdch = false; + uint8_t trx_from, trx_to, trx, ts; if (use_trx >= 0 && use_trx < 8) trx_from = trx_to = use_trx; @@ -442,8 +522,12 @@ trx_has_pdch = true; has_pdch = true; } - if (trx_has_pdch && free_tfis) - break; + if (trx_has_pdch && free_tfis) { + _trx[trx] = true; + is_tfis_available = true; + } else { + _trx[trx] = false; + } free_tfis = 0; } @@ -452,26 +536,68 @@ return -EINVAL; } - if (!free_tfis) { + if (!is_tfis_available) { LOGP(DRLCMAC, LOGL_NOTICE, "No TFI available.\n"); return -EBUSY; } + return 0; +} + +/*! \brief: selects the best TRX which can be used to host a perticulat TBF + * for multi/single slots allocation + * \param[in] avail_trx The bool *. Array of TRXs. initialized to false + * or true at caller. array of size 8 + * \returns selected_trx to host the TBF else returns -1 + */ +int BTS::get_suitable_trx(bool *avail_trx) +{ + uint8_t trx; + uint32_t select_probability = 0; + uint32_t temp_probability = 0; + int selected_trx = -1; + bool is_better_trx = false; - LOGP(DRLCMAC, LOGL_DEBUG, - "Searching for first unallocated TFI: TRX=%d\n", trx); + for (trx = 0; trx <= 7; trx++) { + /* Check if this TRX is in possible list */ + if (!avail_trx[trx]) + continue; - /* find the first */ - for (tfi = 0; tfi < 32; tfi++) { - if (free_tfis & 1 << tfi) - break; + is_better_trx = false; + + temp_probability = MAX_LOAD_PROBABILITY - + (get_num_pdch() * 100 * + m_bts.trx[trx].current_load) + / m_bts.trx[trx].num_pdch; + + LOGP(DRLCMAC, LOGL_DEBUG, "trx(%d) cur load(%d)" + " numpdch(%d) prob1(%u) seleprob(%u)" + " btsnumpdch(%d)\n", trx, + m_bts.trx[trx].current_load, + m_bts.trx[trx].num_pdch, + temp_probability, select_probability, + get_num_pdch()); + + if (temp_probability >= select_probability) { + if (temp_probability > select_probability) + is_better_trx = true; + else if (temp_probability == select_probability) + if (selected_trx >= 0 || selected_trx < 8) + if (m_bts.trx[selected_trx].num_pdch + < m_bts.trx[trx].num_pdch) + is_better_trx = true; + } + if (is_better_trx) { + selected_trx = trx; + select_probability = + temp_probability; + LOGP(DRLCMAC, LOGL_DEBUG, "selected pro(%u)" + "selected_trx(%d)\n", + select_probability, selected_trx); + } } - OSMO_ASSERT(tfi < 32); - - LOGP(DRLCMAC, LOGL_DEBUG, " Found TFI=%d.\n", tfi); - *_trx = trx; - return tfi; + return selected_trx; } int BTS::rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn) @@ -798,13 +924,17 @@ { /* TODO: Check if there are still allocated resources.. */ INIT_LLIST_HEAD(&paging_list); + trx->num_pdch++; m_is_enabled = 1; + bts()->increment_num_pdch(); } void gprs_rlcmac_pdch::disable() { /* TODO.. kick free_resources once we know the TRX/TS we are on */ m_is_enabled = 0; + trx->num_pdch--; + bts()->decrement_num_pdch(); } void gprs_rlcmac_pdch::free_resources() diff --git a/src/bts.h b/src/bts.h index 2932154..f022e5b 100644 --- a/src/bts.h +++ b/src/bts.h @@ -44,6 +44,7 @@ #define LLC_CODEL_USE_DEFAULT (-1) #define MAX_GPRS_CS 9 +#define MAX_LOAD_PROBABILITY 0xffffffff struct BTS; struct GprsMs; @@ -136,7 +137,8 @@ /* back pointers */ struct BTS *bts; uint8_t trx_no; - + uint8_t current_load; + uint8_t num_pdch; #ifdef __cplusplus void reserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots); void unreserve_slots(enum gprs_rlcmac_tbf_direction dir, uint8_t slots); @@ -345,6 +347,9 @@ gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts); int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + int get_possible_trxs(enum gprs_rlcmac_tbf_direction dir, + bool *_trx, int8_t use_trx); + int get_suitable_trx(bool *suitable_trx); int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, @@ -451,6 +456,10 @@ void ms_present(int32_t n); int32_t ms_present_get(); + void increment_num_pdch(); + void decrement_num_pdch(); + uint8_t get_num_pdch() const; + int get_possible_trxs_sba(bool *_trx); /* * Below for C interface for the VTY @@ -476,6 +485,8 @@ /* list of downlink TBFs */ LListHead m_dl_tbfs; + /* The summation of all the PDCH across all TRX for this BTS*/ + uint8_t m_total_pdch; private: /* disable copying to avoid slicing */ BTS(const BTS&); @@ -487,6 +498,21 @@ return m_cur_fn; } +inline void BTS::increment_num_pdch() +{ + m_total_pdch++; +} + +inline void BTS::decrement_num_pdch() +{ + m_total_pdch--; +} + +inline uint8_t BTS::get_num_pdch() const +{ + return m_total_pdch; +} + inline SBAController *BTS::sba() { return &m_sba; diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index 57197b2..7ede192 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -383,8 +383,12 @@ int tfi; uint8_t trx_no; - if (use_trx == -1 && ms->current_trx()) + LOGP(DRLCMAC, LOGL_DEBUG, "use_trx = %d\n", use_trx); + + if (use_trx == -1 && ms->current_trx()) { use_trx = ms->current_trx()->trx_no; + LOGP(DRLCMAC, LOGL_DEBUG, "MS alive = %d\n", use_trx); + } tfi = bts->tfi_find_free(dir, &trx_no, use_trx); if (tfi < 0) @@ -392,6 +396,8 @@ if (trx_no_) *trx_no_ = trx_no; + + LOGP(DRLCMAC, LOGL_DEBUG, "FREE trx = %d TFI = %d\n", *trx_no_, tfi); return tfi; } @@ -479,6 +485,7 @@ } tbf_->trx = trx; + trx->current_load++; /* the only one TS is the common TS */ tbf_->first_ts = tbf_->first_common_ts = ts; ms_->set_reserved_slots(trx, 1 << ts, 1 << ts); @@ -1000,6 +1007,7 @@ if (!(dl_slots & (1 << ts))) continue; + trx->current_load++; LOGP(DRLCMAC, LOGL_DEBUG, "- Assigning DL TS " "%d\n", ts); assign_dlink_tbf(&trx->pdch[ts], dl_tbf, tfi); @@ -1012,6 +1020,7 @@ continue; OSMO_ASSERT(usf[ts] >= 0); + trx->current_load++; LOGP(DRLCMAC, LOGL_DEBUG, "- Assigning UL TS " "%d\n", ts); diff --git a/src/sba.cpp b/src/sba.cpp index 5d75b17..abe75e2 100644 --- a/src/sba.cpp +++ b/src/sba.cpp @@ -49,8 +49,27 @@ struct gprs_rlcmac_pdch *pdch; struct gprs_rlcmac_sba *sba; - int8_t trx, ts; + int8_t ts; uint32_t fn; + bool trxs[8]; + int selected_trx; + int ret; + + ret = m_bts.get_possible_trxs_sba(trxs); + + if (ret == -EINVAL) + return -EINVAL; + + selected_trx = m_bts.get_suitable_trx(trxs); + + for (ts = 7; ts >= 0; ts--) { + pdch = &m_bts.bts_data()->trx[selected_trx].pdch[ts]; + if (!pdch->is_enabled()) + continue; + break; + } + if (ts < 0) + return -EINVAL; sba = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_sba); if (!sba) @@ -59,25 +78,10 @@ if (!gsm48_ta_is_valid(ta)) return -EINVAL; - for (trx = 0; trx < 8; trx++) { - for (ts = 7; ts >= 0; ts--) { - pdch = &m_bts.bts_data()->trx[trx].pdch[ts]; - if (!pdch->is_enabled()) - continue; - break; - } - if (ts >= 0) - break; - } - if (trx == 8) { - LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); - talloc_free(sba); - return -EINVAL; - } fn = (pdch->last_rts_fn + AGCH_START_OFFSET) % 2715648; - sba->trx_no = trx; + sba->trx_no = selected_trx; sba->ts_no = ts; sba->fn = fn; sba->ta = ta; @@ -85,9 +89,12 @@ llist_add(&sba->list, &m_sbas); m_bts.sba_allocated(); - *_trx = trx; + *_trx = selected_trx; *_ts = ts; *_fn = fn; + LOGP(DRLCMAC, LOGL_DEBUG, " sba fn=%d ts = %d trx = %d\n", + fn, ts, selected_trx); + return 0; } diff --git a/src/tbf.cpp b/src/tbf.cpp index 820131c..f05b6d6 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -410,7 +410,7 @@ for (ts = 0; ts < 8; ts++) { if (!tbf->pdch[ts]) continue; - + tbf->trx->current_load--; tbf->pdch[ts]->detach_tbf(tbf); tbf->pdch[ts] = NULL; } diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 00aa4a8..c482d55 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -47,6 +47,12 @@ void *tall_pcu_ctx; int16_t spoof_mnc = 0, spoof_mcc = 0; +#define ASSERT_TBF_ALLOC_ON_TRX(_dl_tbf, _bts, \ + _ms_class, _egprs_ms_class, _trx_num) \ + _dl_tbf = tbf_alloc_dl_tbf(_bts, NULL, -1, \ + _ms_class, _egprs_ms_class, 1); \ + OSMO_ASSERT(_dl_tbf->trx->trx_no == _trx_num); \ + static void check_tbf(gprs_rlcmac_tbf *tbf) { OSMO_ASSERT(tbf); @@ -3255,6 +3261,232 @@ printf("=== end %s ===\n", __func__); } +void test_multi_trx_test_same_capacity() +{ + BTS the_bts; + gprs_rlcmac_dl_tbf *dl_tbf; + struct gprs_rlcmac_bts *bts; + uint8_t ms_class = 1; + uint8_t egprs_ms_class = 1; + + printf("=== start %s ===\n", __func__); + + setup_bts(&the_bts, 4); + + bts = the_bts.bts_data(); + + bts->trx[0].pdch[5].enable(); + bts->alloc_algorithm = alloc_algorithm_b; + bts->trx[1].pdch[4].enable(); + bts->trx[1].pdch[5].enable(); + + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + + printf("=== end %s ===\n", __func__); + +} + +void test_multi_trx_test_1_2_capacity() +{ + BTS the_bts; + gprs_rlcmac_dl_tbf *dl_tbf; + struct gprs_rlcmac_bts *bts; + uint8_t ms_class = 1; + uint8_t egprs_ms_class = 1; + + printf("=== start %s ===\n", __func__); + + setup_bts(&the_bts, 4); + + bts = the_bts.bts_data(); + bts->alloc_algorithm = alloc_algorithm_b; + bts->trx[0].pdch[5].enable(); + bts->trx[1].pdch[4].enable(); + + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + + printf("=== end %s ===\n", __func__); + +} + +void test_multi_trx_test_1_4_capacity() +{ + BTS the_bts; + gprs_rlcmac_dl_tbf *dl_tbf; + struct gprs_rlcmac_bts *bts; + uint8_t ms_class = 1; + uint8_t egprs_ms_class = 1; + + printf("=== start %s ===\n", __func__); + + setup_bts(&the_bts, 4); + bts = the_bts.bts_data(); + + bts->alloc_algorithm = alloc_algorithm_b; + + bts->trx[0].pdch[5].enable(); + bts->trx[0].pdch[6].enable(); + bts->trx[0].pdch[7].enable(); + bts->trx[1].pdch[0].enable(); + + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + + printf("=== end %s ===\n", __func__); +} + +void test_multi_trx_test_release_alloc() +{ + BTS the_bts; + gprs_rlcmac_dl_tbf *dl_tbf; + struct gprs_rlcmac_bts *bts; + uint8_t ms_class = 1; + uint8_t egprs_ms_class = 1; + + printf("=== start %s ===\n", __func__); + + setup_bts(&the_bts, 4); + bts = the_bts.bts_data(); + bts->alloc_algorithm = alloc_algorithm_b; + + bts->trx[0].pdch[5].enable(); + bts->trx[1].pdch[0].enable(); + + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + tbf_free(dl_tbf); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + tbf_free(dl_tbf); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + tbf_free(dl_tbf); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + + printf("=== end %s ===\n", __func__); +} + +void test_multi_trx_test_same_capacity_dl_ul_combined() +{ + BTS the_bts; + gprs_rlcmac_dl_tbf *dl_tbf; + static gprs_rlcmac_ul_tbf *ul_tbf; + struct gprs_rlcmac_bts *bts; + uint8_t ms_class = 1; + uint8_t egprs_ms_class = 1; + + printf("=== start %s ===\n", __func__); + + setup_bts(&the_bts, 4); + bts = the_bts.bts_data(); + + bts->alloc_algorithm = alloc_algorithm_b; + bts->trx[1].pdch[4].enable(); + + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + ul_tbf = tbf_alloc_ul(bts, + dl_tbf->trx->trx_no, + dl_tbf->ms_class(), dl_tbf->ms()->egprs_ms_class(), + dl_tbf->tlli(), dl_tbf->ta(), dl_tbf->ms()); + OSMO_ASSERT(ul_tbf->trx->trx_no == 0); + + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 1); + ASSERT_TBF_ALLOC_ON_TRX(dl_tbf, bts, ms_class, + egprs_ms_class, 0); + + ul_tbf = tbf_alloc_ul(bts, + dl_tbf->trx->trx_no, + dl_tbf->ms_class(), dl_tbf->ms()->egprs_ms_class(), + dl_tbf->tlli(), dl_tbf->ta(), dl_tbf->ms()); + OSMO_ASSERT(ul_tbf->trx->trx_no == 0); + + printf("=== end %s ===\n", __func__); + +} + +void test_multi_trx_test() +{ + printf("=== start %s ===\n", __func__); + test_multi_trx_test_same_capacity(); + test_multi_trx_test_1_2_capacity(); + test_multi_trx_test_1_4_capacity(); + test_multi_trx_test_release_alloc(); + test_multi_trx_test_same_capacity_dl_ul_combined(); + printf("=== end %s ===\n", __func__); + +} + static void test_packet_access_rej_prr() { BTS the_bts; @@ -3400,6 +3632,7 @@ test_packet_access_rej_epdan(); test_packet_access_rej_prr(); test_packet_access_rej_prr_no_other_tbfs(); + test_multi_trx_test(); if (getenv("TALLOC_REPORT_FULL")) talloc_report_full(tall_pcu_ctx, stderr); diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index 3412bde..b1e5bd7 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -35,6 +35,8 @@ The MS object cannot fully confirm an unexpected TLLI: 0x00004232, partly confirmed Modifying MS object, TLLI: 0x00002342 -> 0x00004232, already confirmed partly Modifying MS object, TLLI = 0x00004232, TA 4 -> 6 +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -123,6 +125,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=1 TLLI=0xffeeddcc DIR=DL STATE=RELEASING) ********** TBF ends here ********** Destroying MS object, TLLI = 0xffeeddcc +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -211,6 +215,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING) ********** TBF ends here ********** Destroying MS object, TLLI = 0xffeeddcc +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -514,6 +520,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -535,6 +543,8 @@ Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 Modifying MS object, TLLI = 0x00000000, TA 220 -> 0 TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to FLOW +trx(0) cur load(1) numpdch(1) prob1(4294967195) seleprob(0) btsnumpdch(1) +selected pro(4294967195)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=1. ********** TBF starts here ********** @@ -1508,6 +1518,8 @@ Polling cannot be scheduled in this TS 7 (first control TS 4) msg block (BSN 2, CS-1): 07 01 04 4d 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 MSG = 07 01 04 4d 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. MS requests UL TBF on RACH, so we provide one: ra=0x03 Fn=2654167 qta=31 is_11bit=0: @@ -1586,10 +1598,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -1671,10 +1696,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -1805,10 +1843,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654283 block=11 data=00 01 00 29 52 41 55 5f 41 43 43 45 50 54 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 00 MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654232 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(2) numpdch(1) prob1(4294967095) seleprob(0) btsnumpdch(1) +selected pro(4294967095)selected_trx(0) + sba fn=2654335 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654232 (17,39,22), SBFn=2654335 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8c f6 07 00 c0 0c 68 ab 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(2) numpdch(1) prob1(4294967095) seleprob(0) btsnumpdch(1) +selected pro(4294967095)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=1. TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=FINISHED) poll timeout for FN=2654292, TS=7 (curr FN 2654335) @@ -1881,10 +1932,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -1974,10 +2038,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654275 block=9 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654224 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(1) numpdch(1) prob1(4294967195) seleprob(0) btsnumpdch(1) +selected pro(4294967195)selected_trx(0) + sba fn=2654327 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654224 (17,31,14), SBFn=2654327 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b ee 07 00 c0 0c 60 6b 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(1) numpdch(1) prob1(4294967195) seleprob(0) btsnumpdch(1) +selected pro(4294967195)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -2058,10 +2135,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -2148,6 +2238,8 @@ PDCH(TS 7, TRX 0): Detaching TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW), 0 TBFs, USFs = 00, TFIs = 00000000. Detaching TBF from MS object, TLLI = 0xf1223344, TBF = TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) ********** TBF ends here ********** +trx(0) cur load(1) numpdch(1) prob1(4294967195) seleprob(0) btsnumpdch(1) +selected pro(4294967195)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. MS requests UL TBF on RACH, so we provide one: ra=0x03 Fn=2654275 qta=31 is_11bit=0: @@ -2212,10 +2304,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -3270,8 +3375,10 @@ Allocating DL TBF: MS_CLASS=12/0 Creating MS object, TLLI = 0x00000000 Modifying MS object, TLLI = 0x00000000, MS class 0 -> 12 +use_trx = 0 Searching for first unallocated TFI: TRX=0 Found TFI=0. +FREE trx = 0 TFI = 0 Slot Allocation (Algorithm B) for class 12 - Rx=4 Tx=4 Sum Rx+Tx=5 Tta=2 Ttb=1 Tra=2 Trb=1 Type=1 - Skipping TS 0, because not enabled @@ -3309,8 +3416,10 @@ Modifying MS object, TLLI = 0x00000000, MS class 0 -> 12 Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 12 Enabled EGPRS for TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL EGPRS), mode EGPRS +use_trx = 0 Searching for first unallocated TFI: TRX=0 Found TFI=0. +FREE trx = 0 TFI = 0 Slot Allocation (Algorithm B) for class 12 - Rx=4 Tx=4 Sum Rx+Tx=5 Tta=2 Ttb=1 Tra=2 Trb=1 Type=1 - Skipping TS 0, because not enabled @@ -3347,10 +3456,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -3442,10 +3564,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -3697,6 +3832,8 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=NULL EGPRS) changes state from NULL to ASSIGN TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) starting timer 0. TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) append +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -4032,6 +4169,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -4312,6 +4451,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -4551,6 +4692,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -4754,6 +4897,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -4935,6 +5080,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5097,6 +5244,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5255,6 +5404,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5400,6 +5551,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5546,6 +5699,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5598,6 +5753,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5650,6 +5807,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5702,6 +5861,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5773,6 +5934,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5844,6 +6007,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5915,6 +6080,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -5986,6 +6153,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -6044,6 +6213,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -6102,6 +6273,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -6160,6 +6333,8 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=DL STATE=RELEASING EGPRS) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -6227,10 +6402,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -6355,8 +6543,10 @@ Modifying MS object, TLLI = 0x00000000, MS class 0 -> 11 Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 11 Enabled EGPRS for TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL EGPRS), mode EGPRS +use_trx = 0 Searching for first unallocated TFI: TRX=0 Found TFI=0. +FREE trx = 0 TFI = 0 Slot Allocation (Algorithm B) for class 11 - Rx=4 Tx=3 Sum Rx+Tx=5 Tta=3 Ttb=1 Tra=2 Trb=1 Type=1 - Skipping TS 0, because not enabled @@ -6377,8 +6567,10 @@ DL TBF slots: 0x10, N: 1, WS: 192 ********** TBF update ********** PDCH(TS 4, TRX 0): Detaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL EGPRS), 0 TBFs, USFs = 00, TFIs = 00000000. +use_trx = 0 Searching for first unallocated TFI: TRX=0 Found TFI=0. +FREE trx = 0 TFI = 0 - Selected DL slots: (TS=0)"..DDDD.."(TS=7) Using 4 slots for DL - Assigning DL TS 2 @@ -6404,10 +6596,23 @@ Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -6514,6 +6719,8 @@ TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=NULL EGPRS) changes state from NULL to ASSIGN TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) starting timer 0. TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) append +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -6859,16 +7066,36 @@ Destroying MS object, TLLI = 0x00000000 MS requests UL TBF on RACH, so we provide one: ra=0x70 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation -No PDCH available. + Not valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. No PDCH resource for single block allocation.sending Immediate Assignment Uplink (AGCH) reject Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=4d 06 3a 10 70 8b 29 14 70 8b 29 14 70 8b 29 14 70 8b 29 14 0b 2b 2b Sending data request: trx=0 ts=7 sapi=5 arfcn=0 fn=2654218 block=8 data=47 94 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b MS requests UL TBF on RACH, so we provide one: ra=0x73 Fn=2654167 qta=31 is_11bit=0: MS requests single block allocation + Valid TRX=0. + Not valid TRX=1. + Not valid TRX=2. + Not valid TRX=3. + Not valid TRX=4. + Not valid TRX=5. + Not valid TRX=6. + Not valid TRX=7. +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) + sba fn=2654270 ts = 7 trx = 0 RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x73, Fn=2654167 (17,25,9), SBFn=2654270 TX: Immediate Assignment Uplink (AGCH) - TRX=0 (0) TS=7 TA=7 TSC=0 TFI=-1 USF=7 Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 73 8b 29 07 00 c0 0c 5a 43 2b 2b 2b 2b 2b 2b 2b +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. Got RLC block, coding scheme: CS-1, length: 23 (23)) @@ -8826,6 +9053,8 @@ Got 'TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW EGPRS)', TA=7 Got MS: TLLI = 0xf1223344, TA = 7 TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN EGPRS) append +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(1) +selected pro(4294967295)selected_trx(0) Searching for first unallocated TFI: TRX=0 Found TFI=0. ********** TBF starts here ********** @@ -9070,3 +9299,1307 @@ Detaching TBF from MS object, TLLI = 0xffeeddcc, TBF = TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=ASSIGN) Destroying MS object, TLLI = 0xffeeddcc ********** TBF ends here ********** +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(0) numpdch(2) prob1(4294967295) seleprob(0) btsnumpdch(4) +selected pro(4294967295)selected_trx(0) +trx(1) cur load(0) numpdch(2) prob1(4294967295) seleprob(4294967295) btsnumpdch(4) +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967095) seleprob(0) btsnumpdch(4) +selected pro(4294967095)selected_trx(0) +trx(1) cur load(0) numpdch(2) prob1(4294967295) seleprob(4294967095) btsnumpdch(4) +selected pro(4294967295)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=0. +FREE trx = 1 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967095) seleprob(0) btsnumpdch(4) +selected pro(4294967095)selected_trx(0) +trx(1) cur load(1) numpdch(2) prob1(4294967095) seleprob(4294967095) btsnumpdch(4) +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000002. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(2) prob1(4294966895) seleprob(0) btsnumpdch(4) +selected pro(4294966895)selected_trx(0) +trx(1) cur load(1) numpdch(2) prob1(4294967095) seleprob(4294966895) btsnumpdch(4) +selected pro(4294967095)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=1. +FREE trx = 1 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 1): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000002. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(2) prob1(4294966895) seleprob(0) btsnumpdch(4) +selected pro(4294966895)selected_trx(0) +trx(1) cur load(2) numpdch(2) prob1(4294966895) seleprob(4294966895) btsnumpdch(4) +Searching for first unallocated TFI: TRX=0 + Found TFI=2. +FREE trx = 0 TFI = 2 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000005. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(3) numpdch(2) prob1(4294966695) seleprob(0) btsnumpdch(4) +selected pro(4294966695)selected_trx(0) +trx(1) cur load(2) numpdch(2) prob1(4294966895) seleprob(4294966695) btsnumpdch(4) +selected pro(4294966895)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=2. +FREE trx = 1 TFI = 2 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000005. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(3) numpdch(2) prob1(4294966695) seleprob(0) btsnumpdch(4) +selected pro(4294966695)selected_trx(0) +trx(1) cur load(3) numpdch(2) prob1(4294966695) seleprob(4294966695) btsnumpdch(4) +Searching for first unallocated TFI: TRX=0 + Found TFI=3. +FREE trx = 0 TFI = 3 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 0000000a. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(4) numpdch(2) prob1(4294966495) seleprob(0) btsnumpdch(4) +selected pro(4294966495)selected_trx(0) +trx(1) cur load(3) numpdch(2) prob1(4294966695) seleprob(4294966495) btsnumpdch(4) +selected pro(4294966695)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=3. +FREE trx = 1 TFI = 3 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 1): Attaching TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 0000000a. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(4) numpdch(2) prob1(4294966495) seleprob(0) btsnumpdch(4) +selected pro(4294966495)selected_trx(0) +trx(1) cur load(4) numpdch(2) prob1(4294966495) seleprob(4294966495) btsnumpdch(4) +Searching for first unallocated TFI: TRX=0 + Found TFI=4. +FREE trx = 0 TFI = 4 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 00000015. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(5) numpdch(2) prob1(4294966295) seleprob(0) btsnumpdch(4) +selected pro(4294966295)selected_trx(0) +trx(1) cur load(4) numpdch(2) prob1(4294966495) seleprob(4294966295) btsnumpdch(4) +selected pro(4294966495)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=4. +FREE trx = 1 TFI = 4 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 00000015. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(5) numpdch(2) prob1(4294966295) seleprob(0) btsnumpdch(4) +selected pro(4294966295)selected_trx(0) +trx(1) cur load(5) numpdch(2) prob1(4294966295) seleprob(4294966295) btsnumpdch(4) +Searching for first unallocated TFI: TRX=0 + Found TFI=5. +FREE trx = 0 TFI = 5 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 0000002a. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(0) numpdch(2) prob1(4294967295) seleprob(0) btsnumpdch(3) +selected pro(4294967295)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967295) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967145) seleprob(0) btsnumpdch(3) +selected pro(4294967145)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967145) btsnumpdch(3) +selected pro(4294967295)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=0. +FREE trx = 1 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967145) seleprob(0) btsnumpdch(3) +selected pro(4294967145)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966995) seleprob(4294967145) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000002. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(2) prob1(4294966995) seleprob(0) btsnumpdch(3) +selected pro(4294966995)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966995) seleprob(4294966995) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=2. +FREE trx = 0 TFI = 2 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000005. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(3) numpdch(2) prob1(4294966845) seleprob(0) btsnumpdch(3) +selected pro(4294966845)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966995) seleprob(4294966845) btsnumpdch(3) +selected pro(4294966995)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=1. +FREE trx = 1 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000003. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(3) numpdch(2) prob1(4294966845) seleprob(0) btsnumpdch(3) +selected pro(4294966845)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966695) seleprob(4294966845) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=3. +FREE trx = 0 TFI = 3 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 0000000a. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(4) numpdch(2) prob1(4294966695) seleprob(0) btsnumpdch(3) +selected pro(4294966695)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966695) seleprob(4294966695) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=4. +FREE trx = 0 TFI = 4 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 00000015. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(5) numpdch(2) prob1(4294966545) seleprob(0) btsnumpdch(3) +selected pro(4294966545)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966695) seleprob(4294966545) btsnumpdch(3) +selected pro(4294966695)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=2. +FREE trx = 1 TFI = 2 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 00000007. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(5) numpdch(2) prob1(4294966545) seleprob(0) btsnumpdch(3) +selected pro(4294966545)selected_trx(0) +trx(1) cur load(3) numpdch(1) prob1(4294966395) seleprob(4294966545) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=5. +FREE trx = 0 TFI = 5 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 0000002a. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(6) numpdch(2) prob1(4294966395) seleprob(0) btsnumpdch(3) +selected pro(4294966395)selected_trx(0) +trx(1) cur load(3) numpdch(1) prob1(4294966395) seleprob(4294966395) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=6. +FREE trx = 0 TFI = 6 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=6 TLLI=0x00000000 DIR=DL STATE=NULL), 4 TBFs, USFs = 00, TFIs = 00000055. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=6 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=6 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(7) numpdch(2) prob1(4294966245) seleprob(0) btsnumpdch(3) +selected pro(4294966245)selected_trx(0) +trx(1) cur load(3) numpdch(1) prob1(4294966395) seleprob(4294966245) btsnumpdch(3) +selected pro(4294966395)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=3. +FREE trx = 1 TFI = 3 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL), 4 TBFs, USFs = 00, TFIs = 0000000f. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(0) numpdch(4) prob1(4294967295) seleprob(0) btsnumpdch(5) +selected pro(4294967295)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967295) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(4) prob1(4294967170) seleprob(0) btsnumpdch(5) +selected pro(4294967170)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967170) btsnumpdch(5) +selected pro(4294967295)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=0. +FREE trx = 1 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 4, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"C......."(TS=7) +- Selected DL slots: (TS=0)"D......."(TS=7), single +Using single slot at TS 0 for DL +- Reserved DL/UL slots: (TS=0)"C......."(TS=7) +- Assigning DL TS 0 +PDCH(TS 0, TRX 1): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 0 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 01, dl_slots = 01 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(4) prob1(4294967170) seleprob(0) btsnumpdch(5) +selected pro(4294967170)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966795) seleprob(4294967170) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000002. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(4) prob1(4294967045) seleprob(0) btsnumpdch(5) +selected pro(4294967045)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966795) seleprob(4294967045) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=2. +FREE trx = 0 TFI = 2 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)"......D."(TS=7), single +Using single slot at TS 6 for DL +- Reserved DL/UL slots: (TS=0)"......C."(TS=7) +- Assigning DL TS 6 +PDCH(TS 6, TRX 0): Attaching TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000004. +- Setting Control TS 6 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=2 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 40, dl_slots = 40 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(3) numpdch(4) prob1(4294966920) seleprob(0) btsnumpdch(5) +selected pro(4294966920)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966795) seleprob(4294966920) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=3. +FREE trx = 0 TFI = 3 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)".......D"(TS=7), single +Using single slot at TS 7 for DL +- Reserved DL/UL slots: (TS=0)".......C"(TS=7) +- Assigning DL TS 7 +PDCH(TS 7, TRX 0): Attaching TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000008. +- Setting Control TS 7 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=3 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 80, dl_slots = 80 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(4) numpdch(4) prob1(4294966795) seleprob(0) btsnumpdch(5) +selected pro(4294966795)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966795) seleprob(4294966795) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=4. +FREE trx = 0 TFI = 4 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000011. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=4 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(5) numpdch(4) prob1(4294966670) seleprob(0) btsnumpdch(5) +selected pro(4294966670)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966795) seleprob(4294966670) btsnumpdch(5) +selected pro(4294966795)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=1. +FREE trx = 1 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 4, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"C......."(TS=7) +- Selected DL slots: (TS=0)"D......."(TS=7), single +Using single slot at TS 0 for DL +- Reserved DL/UL slots: (TS=0)"C......."(TS=7) +- Assigning DL TS 0 +PDCH(TS 0, TRX 1): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000003. +- Setting Control TS 0 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 01, dl_slots = 01 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(5) numpdch(4) prob1(4294966670) seleprob(0) btsnumpdch(5) +selected pro(4294966670)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966295) seleprob(4294966670) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=5. +FREE trx = 0 TFI = 5 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000022. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=5 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(6) numpdch(4) prob1(4294966545) seleprob(0) btsnumpdch(5) +selected pro(4294966545)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966295) seleprob(4294966545) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=6. +FREE trx = 0 TFI = 6 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)"......D."(TS=7), single +Using single slot at TS 6 for DL +- Reserved DL/UL slots: (TS=0)"......C."(TS=7) +- Assigning DL TS 6 +PDCH(TS 6, TRX 0): Attaching TBF(TFI=6 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000044. +- Setting Control TS 6 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=6 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=6 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 40, dl_slots = 40 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(7) numpdch(4) prob1(4294966420) seleprob(0) btsnumpdch(5) +selected pro(4294966420)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966295) seleprob(4294966420) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=7. +FREE trx = 0 TFI = 7 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)".......D"(TS=7), single +Using single slot at TS 7 for DL +- Reserved DL/UL slots: (TS=0)".......C"(TS=7) +- Assigning DL TS 7 +PDCH(TS 7, TRX 0): Attaching TBF(TFI=7 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000088. +- Setting Control TS 7 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=7 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=7 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 80, dl_slots = 80 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(8) numpdch(4) prob1(4294966295) seleprob(0) btsnumpdch(5) +selected pro(4294966295)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966295) seleprob(4294966295) btsnumpdch(5) +Searching for first unallocated TFI: TRX=0 + Found TFI=8. +FREE trx = 0 TFI = 8 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Possible DL/UL slots: (TS=0)"....CCCC"(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=8 TLLI=0x00000000 DIR=DL STATE=NULL), 3 TBFs, USFs = 00, TFIs = 00000111. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=8 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=8 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(0) numpdch(2) prob1(4294967295) seleprob(0) btsnumpdch(3) +selected pro(4294967295)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967295) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to RELEASING +TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=RELEASING) free +PDCH(TS 4, TRX 0): Detaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=RELEASING), 0 TBFs, USFs = 00, TFIs = 00000000. +Detaching TBF from MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=RELEASING) +Destroying MS object, TLLI = 0x00000000 +********** TBF ends here ********** +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(0) numpdch(2) prob1(4294967295) seleprob(0) btsnumpdch(3) +selected pro(4294967295)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967295) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967145) seleprob(0) btsnumpdch(3) +selected pro(4294967145)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967145) btsnumpdch(3) +selected pro(4294967295)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=0. +FREE trx = 1 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 4, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"C......."(TS=7) +- Selected DL slots: (TS=0)"D......."(TS=7), single +Using single slot at TS 0 for DL +- Reserved DL/UL slots: (TS=0)"C......."(TS=7) +- Assigning DL TS 0 +PDCH(TS 0, TRX 1): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 0 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 01, dl_slots = 01 +TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to RELEASING +TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=RELEASING) free +PDCH(TS 0, TRX 1): Detaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=RELEASING), 0 TBFs, USFs = 00, TFIs = 00000000. +Detaching TBF from MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=RELEASING) +Destroying MS object, TLLI = 0x00000000 +********** TBF ends here ********** +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967145) seleprob(0) btsnumpdch(3) +selected pro(4294967145)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967145) btsnumpdch(3) +selected pro(4294967295)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=0. +FREE trx = 1 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 4, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"C......."(TS=7) +- Selected DL slots: (TS=0)"D......."(TS=7), single +Using single slot at TS 0 for DL +- Reserved DL/UL slots: (TS=0)"C......."(TS=7) +- Assigning DL TS 0 +PDCH(TS 0, TRX 1): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 0 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 01, dl_slots = 01 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967145) seleprob(0) btsnumpdch(3) +selected pro(4294967145)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966995) seleprob(4294967145) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000002. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) changes state from NULL to RELEASING +TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=RELEASING) free +PDCH(TS 5, TRX 0): Detaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=RELEASING), 0 TBFs, USFs = 00, TFIs = 00000000. +Detaching TBF from MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=RELEASING) +Destroying MS object, TLLI = 0x00000000 +********** TBF ends here ********** +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(1) numpdch(2) prob1(4294967145) seleprob(0) btsnumpdch(3) +selected pro(4294967145)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294966995) seleprob(4294967145) btsnumpdch(3) +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....CC.."(TS=7) +- Selected DL slots: (TS=0)".....D.."(TS=7), single +Using single slot at TS 5 for DL +- Reserved DL/UL slots: (TS=0)".....C.."(TS=7) +- Assigning DL TS 5 +PDCH(TS 5, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000002. +- Setting Control TS 5 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 20, dl_slots = 20 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(0) numpdch(1) prob1(4294967295) seleprob(0) btsnumpdch(2) +selected pro(4294967295)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294967295) btsnumpdch(2) +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating UL TBF: MS_CLASS=1/1 +use_trx = 0 +Searching for first unallocated TFI: TRX=0 + Found TFI=0. +FREE trx = 0 TFI = 0 +- Selected UL slots: (TS=0)"....U..."(TS=7) +Using 1 slots for UL +- Assigning UL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL), 1 TBFs, USFs = 01, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 00 +TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=NULL) changes state from NULL to ASSIGN +TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=ASSIGN) starting timer 3169. +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(1) prob1(4294966895) seleprob(0) btsnumpdch(2) +selected pro(4294966895)selected_trx(0) +trx(1) cur load(0) numpdch(1) prob1(4294967295) seleprob(4294966895) btsnumpdch(2) +selected pro(4294967295)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=0. +FREE trx = 1 TFI = 0 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL), 1 TBFs, USFs = 00, TFIs = 00000001. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(1) prob1(4294966895) seleprob(0) btsnumpdch(2) +selected pro(4294966895)selected_trx(0) +trx(1) cur load(1) numpdch(1) prob1(4294967095) seleprob(4294966895) btsnumpdch(2) +selected pro(4294967095)selected_trx(1) +Searching for first unallocated TFI: TRX=1 + Found TFI=1. +FREE trx = 1 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 1): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 00, TFIs = 00000003. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 1, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating DL TBF: MS_CLASS=1/1 +Creating MS object, TLLI = 0x00000000 +Modifying MS object, TLLI = 0x00000000, MS class 0 -> 1 +Modifying MS object, TLLI = 0x00000000, EGPRS MS class 0 -> 1 +use_trx = -1 +trx(0) cur load(2) numpdch(1) prob1(4294966895) seleprob(0) btsnumpdch(2) +selected pro(4294966895)selected_trx(0) +trx(1) cur load(2) numpdch(1) prob1(4294966895) seleprob(4294966895) btsnumpdch(2) +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +Slot Allocation (Algorithm B) for class 1 +- Rx=1 Tx=1 Sum Rx+Tx=2 Tta=3 Ttb=2 Tra=4 Trb=2 Type=1 +- Skipping TS 0, because not enabled +- Skipping TS 1, because not enabled +- Skipping TS 2, because not enabled +- Skipping TS 3, because not enabled +- Skipping TS 5, because not enabled +- Skipping TS 6, because not enabled +- Skipping TS 7, because not enabled +- Possible DL/UL slots: (TS=0)"....C..."(TS=7) +- Selected DL slots: (TS=0)"....D..."(TS=7), single +Using single slot at TS 4 for DL +- Reserved DL/UL slots: (TS=0)"....C..."(TS=7) +- Assigning DL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL), 2 TBFs, USFs = 01, TFIs = 00000003. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=DL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 10 +********** TBF starts here ********** +Allocating UL TBF: MS_CLASS=1/1 +use_trx = 0 +Searching for first unallocated TFI: TRX=0 + Found TFI=1. +FREE trx = 0 TFI = 1 +- Selected UL slots: (TS=0)"....U..."(TS=7) +Using 1 slots for UL +- Assigning UL TS 4 +PDCH(TS 4, TRX 0): Attaching TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=NULL), 2 TBFs, USFs = 03, TFIs = 00000003. +- Setting Control TS 4 +Attaching TBF to MS object, TLLI = 0x00000000, TBF = TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=NULL) +Allocated TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=NULL): trx = 0, ul_slots = 10, dl_slots = 00 +TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=NULL) changes state from NULL to ASSIGN +TBF(TFI=1 TLLI=0x00000000 DIR=UL STATE=ASSIGN) starting timer 3169. diff --git a/tests/tbf/TbfTest.ok b/tests/tbf/TbfTest.ok index 077ec4e..2a37be2 100644 --- a/tests/tbf/TbfTest.ok +++ b/tests/tbf/TbfTest.ok @@ -81,3 +81,15 @@ === end test_packet_access_rej_prr === === start test_packet_access_rej_prr_no_other_tbfs === === end test_packet_access_rej_prr_no_other_tbfs === +=== start test_multi_trx_test === +=== start test_multi_trx_test_same_capacity === +=== end test_multi_trx_test_same_capacity === +=== start test_multi_trx_test_1_2_capacity === +=== end test_multi_trx_test_1_2_capacity === +=== start test_multi_trx_test_1_4_capacity === +=== end test_multi_trx_test_1_4_capacity === +=== start test_multi_trx_test_release_alloc === +=== end test_multi_trx_test_release_alloc === +=== start test_multi_trx_test_same_capacity_dl_ul_combined === +=== end test_multi_trx_test_same_capacity_dl_ul_combined === +=== end test_multi_trx_test === -- To view, visit https://gerrit.osmocom.org/1512 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I222c3340872ffa1dd6e8fabe5276d793e660f67d Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: arvind.sirsikar Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 01:34:55 2017 From: gerrit-no-reply at lists.osmocom.org (arvind.sirsikar) Date: Fri, 17 Feb 2017 01:34:55 +0000 Subject: osmo-pcu[master]: PDCH allocation across two TRX In-Reply-To: References: Message-ID: Patch Set 4: (1 comment) https://gerrit.osmocom.org/#/c/1512/3/src/bts.cpp File src/bts.cpp: Line 434: *_trx = use_trx; > _trx is marked as [in] but here you assign smth to it - shall it be marked It is the selected TRX for this TBF -- To view, visit https://gerrit.osmocom.org/1512 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I222c3340872ffa1dd6e8fabe5276d793e660f67d Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: arvind.sirsikar Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 17 09:33:17 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 17 Feb 2017 09:33:17 +0000 Subject: osmo-pcu[master]: PDCH allocation across two TRX In-Reply-To: References: Message-ID: Patch Set 4: Code-Review-1 (3 comments) Please double-check that _every_ doxygen header you wrote actually match function behavior and parameters. Please, do it for _every_ single function you wrote in this patch - not just the one you got feedback for. Otherwise we will be in the cycle "review -> fix one function -> review -> fix another function" for months. Thank you for understanding. https://gerrit.osmocom.org/#/c/1512/4/src/bts.cpp File src/bts.cpp: Line 458: /*! \brief: Prepares all the TRXs which can be used to host a perticulat TBF typo: particular Line 460: * \param[in] *_trx The bool this function has 1 parameter but 2 \param entries - fix please Line 463: * \returns -EINVAL if no PDCH available else returns list of valid TRXs this is incorrect too - it returns 0 on success and fills in _trx parameter which should be marked as [out] -- To view, visit https://gerrit.osmocom.org/1512 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I222c3340872ffa1dd6e8fabe5276d793e660f67d Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: arvind.sirsikar Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: arvind.sirsikar Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 17 15:41:24 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 17 Feb 2017 15:41:24 +0000 Subject: [PATCH] libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1582 to look at the new patch set (#5). vty: fix "everything" logging option * clarify use of unused parameters * change internal static function int check_log_to_target() to more appropriate bool log_to_target() * add explicit level for "logging level ... everything" so it really logs everything instead of nothing for a given category * fix "logging level all everything" with explicit global loglevel check Fixes: OS#71 Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c --- M include/osmocom/core/logging.h M include/osmocom/vty/logging.h M src/logging.c M src/vty/logging_vty.c M tests/vty/vty_test.c 5 files changed, 29 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1582/5 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..aef145d 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -88,6 +88,8 @@ #define LOGL_NOTICE 5 /*!< \brief abnormal/unexpected condition */ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ +/* N. B: check that you do not clash with internal LOGL_EVERY from logging.c + before adding anything to above */ #define LOG_FILTER_ALL 0x0001 @@ -299,8 +301,8 @@ void log_del_target(struct log_target *target); /* Generate command string for VTY use */ -const char *log_vty_command_string(const struct log_info *info); -const char *log_vty_command_description(const struct log_info *info); +const char *log_vty_command_string(const struct log_info *unused_info); +const char *log_vty_command_description(const struct log_info *unused_info); struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index 9e4b98f..544d117 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -4,6 +4,6 @@ #define FILTER_STR "Filter log messages\n" struct log_info; -void logging_vty_add_cmds(const struct log_info *cat); +void logging_vty_add_cmds(); struct vty; struct log_target *osmo_log_vty2tgt(struct vty *vty); diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..d170bfa 100644 --- a/src/logging.c +++ b/src/logging.c @@ -55,9 +55,10 @@ LLIST_HEAD(osmo_log_target_list); #define LOGLEVEL_DEFS 6 /* Number of loglevels.*/ +#define LOGL_EVERY 32 /* Special loglevel for "everything". */ static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1] = { - { 0, "EVERYTHING" }, + { LOGL_EVERY, "EVERYTHING" }, { LOGL_DEBUG, "DEBUG" }, { LOGL_INFO, "INFO" }, { LOGL_NOTICE, "NOTICE" }, @@ -138,7 +139,7 @@ /*! \brief descriptive string for each log level */ /* You have to keep this in sync with the structure loglevel_strs. */ const char *loglevel_descriptions[LOGLEVEL_DEFS+1] = { - "Don't use. It doesn't log anything", + "Log everything (use with extreme care)", "Log debug messages and higher levels", "Log informational messages and higher levels", "Log noticeable messages and higher levels", @@ -352,36 +353,45 @@ return subsys; } -static inline int check_log_to_target(struct log_target *tar, int subsys, int level) +static inline bool should_log_to_target(struct log_target *tar, int subsys, + int level) { struct log_category *category; category = &tar->categories[subsys]; + /* Check if special log level "everything" is enabled globally */ + if (tar->loglevel == LOGL_EVERY) + return true; + /* subsystem is not supposed to be logged */ if (!category->enabled) - return 0; + return false; /* Check the global log level */ if (tar->loglevel != 0 && level < tar->loglevel) - return 0; + return true; + + /* Check if special log level "everything" is enabled for category */ + if (category->loglevel == LOGL_EVERY) + return true; /* Check the category log level */ if (tar->loglevel == 0 && category->loglevel != 0 && level < category->loglevel) - return 0; + return false; /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ if ((tar->filter_map & LOG_FILTER_ALL) != 0) - return 1; + return true; if (osmo_log_info->filter_fn) return osmo_log_info->filter_fn(&log_context, tar); /* TODO: Check the filter/selector too? */ - return 1; + return true; } /*! \brief vararg version of logging function @@ -402,7 +412,7 @@ llist_for_each_entry(tar, &osmo_log_target_list, entry) { va_list bp; - if (!check_log_to_target(tar, subsys, level)) + if (!should_log_to_target(tar, subsys, level)) continue; /* According to the manpage, vsnprintf leaves the value of ap @@ -978,7 +988,7 @@ /* TODO: The following could/should be cached (update on config) */ llist_for_each_entry(tar, &osmo_log_target_list, entry) { - if (!check_log_to_target(tar, subsys, level)) + if (!should_log_to_target(tar, subsys, level)) continue; /* This might get logged (ignoring filters) */ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..b3674fb 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -737,7 +737,7 @@ return 1; } -void logging_vty_add_cmds(const struct log_info *cat) +void logging_vty_add_cmds() { install_element_ve(&enable_logging_cmd); install_element_ve(&disable_logging_cmd); @@ -750,8 +750,8 @@ install_element_ve(&logging_set_category_mask_old_cmd); /* Logging level strings are generated dynamically. */ - logging_level_cmd.string = log_vty_command_string(cat); - logging_level_cmd.doc = log_vty_command_description(cat); + logging_level_cmd.string = log_vty_command_string(NULL); + logging_level_cmd.doc = log_vty_command_description(NULL); install_element_ve(&logging_level_cmd); install_element_ve(&show_logging_vty_cmd); install_element_ve(&show_alarms_cmd); diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 865c93e..1e1b495 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -318,7 +318,7 @@ vty_init(&vty_info); /* Setup VTY commands */ - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(); osmo_stats_vty_add_cmds(); test_cmd_string_from_valstr(); -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 17 15:45:46 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 17 Feb 2017 15:45:46 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 5: I'm not sure I get it - this patch does not change logging format: all existing configs should still be readable. All the it does is just make 'everything' logging level and 'all' logging category to actually work as expected: "all" turns on logging of a given level for all categories and "everything" effectively acts as an alias for "debug". If it doesn't than it's a bug which I should fix. -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 17 15:46:29 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 17 Feb 2017 15:46:29 +0000 Subject: [PATCH] libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1582 to look at the new patch set (#6). vty: fix "everything" logging option * clarify use of unused parameters * change internal static function int check_log_to_target() to more appropriate bool should_log_to_target() * add explicit level for "logging level ... everything" so it really logs everything instead of nothing for a given category * fix "logging level all everything" with explicit global loglevel check Fixes: OS#71 Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c --- M include/osmocom/core/logging.h M include/osmocom/vty/logging.h M src/logging.c M src/vty/logging_vty.c M tests/vty/vty_test.c 5 files changed, 29 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1582/6 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..aef145d 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -88,6 +88,8 @@ #define LOGL_NOTICE 5 /*!< \brief abnormal/unexpected condition */ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ +/* N. B: check that you do not clash with internal LOGL_EVERY from logging.c + before adding anything to above */ #define LOG_FILTER_ALL 0x0001 @@ -299,8 +301,8 @@ void log_del_target(struct log_target *target); /* Generate command string for VTY use */ -const char *log_vty_command_string(const struct log_info *info); -const char *log_vty_command_description(const struct log_info *info); +const char *log_vty_command_string(const struct log_info *unused_info); +const char *log_vty_command_description(const struct log_info *unused_info); struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index 9e4b98f..544d117 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -4,6 +4,6 @@ #define FILTER_STR "Filter log messages\n" struct log_info; -void logging_vty_add_cmds(const struct log_info *cat); +void logging_vty_add_cmds(); struct vty; struct log_target *osmo_log_vty2tgt(struct vty *vty); diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..d170bfa 100644 --- a/src/logging.c +++ b/src/logging.c @@ -55,9 +55,10 @@ LLIST_HEAD(osmo_log_target_list); #define LOGLEVEL_DEFS 6 /* Number of loglevels.*/ +#define LOGL_EVERY 32 /* Special loglevel for "everything". */ static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1] = { - { 0, "EVERYTHING" }, + { LOGL_EVERY, "EVERYTHING" }, { LOGL_DEBUG, "DEBUG" }, { LOGL_INFO, "INFO" }, { LOGL_NOTICE, "NOTICE" }, @@ -138,7 +139,7 @@ /*! \brief descriptive string for each log level */ /* You have to keep this in sync with the structure loglevel_strs. */ const char *loglevel_descriptions[LOGLEVEL_DEFS+1] = { - "Don't use. It doesn't log anything", + "Log everything (use with extreme care)", "Log debug messages and higher levels", "Log informational messages and higher levels", "Log noticeable messages and higher levels", @@ -352,36 +353,45 @@ return subsys; } -static inline int check_log_to_target(struct log_target *tar, int subsys, int level) +static inline bool should_log_to_target(struct log_target *tar, int subsys, + int level) { struct log_category *category; category = &tar->categories[subsys]; + /* Check if special log level "everything" is enabled globally */ + if (tar->loglevel == LOGL_EVERY) + return true; + /* subsystem is not supposed to be logged */ if (!category->enabled) - return 0; + return false; /* Check the global log level */ if (tar->loglevel != 0 && level < tar->loglevel) - return 0; + return true; + + /* Check if special log level "everything" is enabled for category */ + if (category->loglevel == LOGL_EVERY) + return true; /* Check the category log level */ if (tar->loglevel == 0 && category->loglevel != 0 && level < category->loglevel) - return 0; + return false; /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ if ((tar->filter_map & LOG_FILTER_ALL) != 0) - return 1; + return true; if (osmo_log_info->filter_fn) return osmo_log_info->filter_fn(&log_context, tar); /* TODO: Check the filter/selector too? */ - return 1; + return true; } /*! \brief vararg version of logging function @@ -402,7 +412,7 @@ llist_for_each_entry(tar, &osmo_log_target_list, entry) { va_list bp; - if (!check_log_to_target(tar, subsys, level)) + if (!should_log_to_target(tar, subsys, level)) continue; /* According to the manpage, vsnprintf leaves the value of ap @@ -978,7 +988,7 @@ /* TODO: The following could/should be cached (update on config) */ llist_for_each_entry(tar, &osmo_log_target_list, entry) { - if (!check_log_to_target(tar, subsys, level)) + if (!should_log_to_target(tar, subsys, level)) continue; /* This might get logged (ignoring filters) */ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..b3674fb 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -737,7 +737,7 @@ return 1; } -void logging_vty_add_cmds(const struct log_info *cat) +void logging_vty_add_cmds() { install_element_ve(&enable_logging_cmd); install_element_ve(&disable_logging_cmd); @@ -750,8 +750,8 @@ install_element_ve(&logging_set_category_mask_old_cmd); /* Logging level strings are generated dynamically. */ - logging_level_cmd.string = log_vty_command_string(cat); - logging_level_cmd.doc = log_vty_command_description(cat); + logging_level_cmd.string = log_vty_command_string(NULL); + logging_level_cmd.doc = log_vty_command_description(NULL); install_element_ve(&logging_level_cmd); install_element_ve(&show_logging_vty_cmd); install_element_ve(&show_alarms_cmd); diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 865c93e..1e1b495 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -318,7 +318,7 @@ vty_init(&vty_info); /* Setup VTY commands */ - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(); osmo_stats_vty_add_cmds(); test_cmd_string_from_valstr(); -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 17 15:47:06 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 17 Feb 2017 15:47:06 +0000 Subject: [PATCH] libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1582 to look at the new patch set (#7). vty: fix "everything" logging option * clarify use of unused parameters * change internal static function int check_log_to_target() to more appropriate bool should_log_to_target() * add explicit level for "logging level ... everything" so it really logs everything instead of nothing for a given category * fix "logging level all ..." with explicit global loglevel check Fixes: OS#71 Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c --- M include/osmocom/core/logging.h M include/osmocom/vty/logging.h M src/logging.c M src/vty/logging_vty.c M tests/vty/vty_test.c 5 files changed, 29 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1582/7 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..aef145d 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -88,6 +88,8 @@ #define LOGL_NOTICE 5 /*!< \brief abnormal/unexpected condition */ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ +/* N. B: check that you do not clash with internal LOGL_EVERY from logging.c + before adding anything to above */ #define LOG_FILTER_ALL 0x0001 @@ -299,8 +301,8 @@ void log_del_target(struct log_target *target); /* Generate command string for VTY use */ -const char *log_vty_command_string(const struct log_info *info); -const char *log_vty_command_description(const struct log_info *info); +const char *log_vty_command_string(const struct log_info *unused_info); +const char *log_vty_command_description(const struct log_info *unused_info); struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index 9e4b98f..544d117 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -4,6 +4,6 @@ #define FILTER_STR "Filter log messages\n" struct log_info; -void logging_vty_add_cmds(const struct log_info *cat); +void logging_vty_add_cmds(); struct vty; struct log_target *osmo_log_vty2tgt(struct vty *vty); diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..d170bfa 100644 --- a/src/logging.c +++ b/src/logging.c @@ -55,9 +55,10 @@ LLIST_HEAD(osmo_log_target_list); #define LOGLEVEL_DEFS 6 /* Number of loglevels.*/ +#define LOGL_EVERY 32 /* Special loglevel for "everything". */ static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1] = { - { 0, "EVERYTHING" }, + { LOGL_EVERY, "EVERYTHING" }, { LOGL_DEBUG, "DEBUG" }, { LOGL_INFO, "INFO" }, { LOGL_NOTICE, "NOTICE" }, @@ -138,7 +139,7 @@ /*! \brief descriptive string for each log level */ /* You have to keep this in sync with the structure loglevel_strs. */ const char *loglevel_descriptions[LOGLEVEL_DEFS+1] = { - "Don't use. It doesn't log anything", + "Log everything (use with extreme care)", "Log debug messages and higher levels", "Log informational messages and higher levels", "Log noticeable messages and higher levels", @@ -352,36 +353,45 @@ return subsys; } -static inline int check_log_to_target(struct log_target *tar, int subsys, int level) +static inline bool should_log_to_target(struct log_target *tar, int subsys, + int level) { struct log_category *category; category = &tar->categories[subsys]; + /* Check if special log level "everything" is enabled globally */ + if (tar->loglevel == LOGL_EVERY) + return true; + /* subsystem is not supposed to be logged */ if (!category->enabled) - return 0; + return false; /* Check the global log level */ if (tar->loglevel != 0 && level < tar->loglevel) - return 0; + return true; + + /* Check if special log level "everything" is enabled for category */ + if (category->loglevel == LOGL_EVERY) + return true; /* Check the category log level */ if (tar->loglevel == 0 && category->loglevel != 0 && level < category->loglevel) - return 0; + return false; /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ if ((tar->filter_map & LOG_FILTER_ALL) != 0) - return 1; + return true; if (osmo_log_info->filter_fn) return osmo_log_info->filter_fn(&log_context, tar); /* TODO: Check the filter/selector too? */ - return 1; + return true; } /*! \brief vararg version of logging function @@ -402,7 +412,7 @@ llist_for_each_entry(tar, &osmo_log_target_list, entry) { va_list bp; - if (!check_log_to_target(tar, subsys, level)) + if (!should_log_to_target(tar, subsys, level)) continue; /* According to the manpage, vsnprintf leaves the value of ap @@ -978,7 +988,7 @@ /* TODO: The following could/should be cached (update on config) */ llist_for_each_entry(tar, &osmo_log_target_list, entry) { - if (!check_log_to_target(tar, subsys, level)) + if (!should_log_to_target(tar, subsys, level)) continue; /* This might get logged (ignoring filters) */ diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..b3674fb 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -737,7 +737,7 @@ return 1; } -void logging_vty_add_cmds(const struct log_info *cat) +void logging_vty_add_cmds() { install_element_ve(&enable_logging_cmd); install_element_ve(&disable_logging_cmd); @@ -750,8 +750,8 @@ install_element_ve(&logging_set_category_mask_old_cmd); /* Logging level strings are generated dynamically. */ - logging_level_cmd.string = log_vty_command_string(cat); - logging_level_cmd.doc = log_vty_command_description(cat); + logging_level_cmd.string = log_vty_command_string(NULL); + logging_level_cmd.doc = log_vty_command_description(NULL); install_element_ve(&logging_level_cmd); install_element_ve(&show_logging_vty_cmd); install_element_ve(&show_alarms_cmd); diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 865c93e..1e1b495 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -318,7 +318,7 @@ vty_init(&vty_info); /* Setup VTY commands */ - logging_vty_add_cmds(&log_info); + logging_vty_add_cmds(); osmo_stats_vty_add_cmds(); test_cmd_string_from_valstr(); -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:30:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:30:08 +0000 Subject: [PATCH] libosmocore[master]: fix: gprs_bssgp_vty: logging filter: wrong constant Message-ID: Review at https://gerrit.osmocom.org/1843 fix: gprs_bssgp_vty: logging filter: wrong constant Setting the BVC log filter to NULL worked only if the NSVC filter was set, use the proper constant instead. Change-Id: Ic1cc268ed20700698c93d3ff8bf85cc0f01d3b1b --- M src/gb/gprs_bssgp_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/1843/1 diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 90e5001..1f382a2 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -49,7 +49,7 @@ if (bctx) { target->filter_map |= (1 << FLT_BVC); target->filter_data[FLT_BVC] = bctx; - } else if (target->filter_data[FLT_NSVC]) { + } else if (target->filter_data[FLT_BVC]) { target->filter_map = ~(1 << FLT_BVC); target->filter_data[FLT_BVC] = NULL; } -- To view, visit https://gerrit.osmocom.org/1843 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic1cc268ed20700698c93d3ff8bf85cc0f01d3b1b Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:30:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:30:08 +0000 Subject: [PATCH] libosmocore[master]: logging: centrally define ctx and filter indexes Message-ID: Review at https://gerrit.osmocom.org/1844 logging: centrally define ctx and filter indexes It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067 --- M include/osmocom/core/logging.h M include/osmocom/gprs/gprs_msgb.h M src/gb/common_vty.c M src/gb/common_vty.h M src/gb/gprs_bssgp.c M src/gb/gprs_bssgp_vty.c M src/gb/gprs_ns.c M src/gb/gprs_ns_vty.c M src/logging.c M src/vty/logging_vty.c 10 files changed, 64 insertions(+), 54 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/44/1844/1 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..509b570 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -89,8 +89,6 @@ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ -#define LOG_FILTER_ALL 0x0001 - /* logging levels defined by the library itself */ #define DLGLOBAL -1 /*!< global logging */ #define DLLAPD -2 /*!< LAPD implementation */ @@ -126,6 +124,21 @@ void *ctx[LOG_MAX_CTX+1]; }; +enum logging_ctx_items { + LOGGING_CTX_GB_NSVC, + LOGGING_CTX_GB_BVC, + LOGGING_CTX_SUBSCR, + _LOGGING_CTX_COUNT +}; + +enum logging_filters { + LOGGING_FILTER_ALL, + LOGGING_FILTER_GB_NSVC, + LOGGING_FILTER_GB_BVC, + LOGGING_FILTER_SUBSCR, + _LOGGING_FILTER_COUNT +}; + struct log_target; /*! \brief Log filter function */ diff --git a/include/osmocom/gprs/gprs_msgb.h b/include/osmocom/gprs/gprs_msgb.h index 06f5cca..9ccc9a5 100644 --- a/include/osmocom/gprs/gprs_msgb.h +++ b/include/osmocom/gprs/gprs_msgb.h @@ -26,10 +26,6 @@ #define msgb_bcid(__x) LIBGB_MSGB_CB(__x)->bssgp_cell_id #define msgb_llch(__x) LIBGB_MSGB_CB(__x)->llch -/* logging contexts */ -#define GPRS_CTX_NSVC 0 -#define GPRS_CTX_BVC 1 - #include int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar); diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c index 5b20fcf..609ab3d 100644 --- a/src/gb/common_vty.c +++ b/src/gb/common_vty.c @@ -70,17 +70,17 @@ int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_bvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_bvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; diff --git a/src/gb/common_vty.h b/src/gb/common_vty.h index d8d0040..8c6b9ab 100644 --- a/src/gb/common_vty.h +++ b/src/gb/common_vty.h @@ -3,12 +3,6 @@ extern int DNS, DBSSGP; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_NSVC = 1, - FLT_BVC = 2, -}; - extern struct cmd_element libgb_exit_cmd; extern struct cmd_element libgb_end_cmd; diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 1ee942f..a402378 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -1049,7 +1049,7 @@ bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); if (bctx) { - log_set_context(GPRS_CTX_BVC, bctx); + log_set_context(LOGGING_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 1f382a2..d8fc840 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -47,11 +47,11 @@ struct bssgp_bvc_ctx *bctx) { if (bctx) { - target->filter_map |= (1 << FLT_BVC); - target->filter_data[FLT_BVC] = bctx; - } else if (target->filter_data[FLT_BVC]) { - target->filter_map = ~(1 << FLT_BVC); - target->filter_data[FLT_BVC] = NULL; + target->filter_map |= (1 << LOGGING_FILTER_GB_BVC); + target->filter_data[LOGGING_FILTER_GB_BVC] = bctx; + } else if (target->filter_data[LOGGING_FILTER_GB_BVC]) { + target->filter_map = ~(1 << LOGGING_FILTER_GB_BVC); + target->filter_data[LOGGING_FILTER_GB_BVC] = NULL; } } diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 18845d4..28f5ff3 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -325,7 +325,7 @@ { int ret; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); /* Increment number of Uplink bytes */ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]); @@ -360,7 +360,7 @@ struct msgb *msg = gprs_ns_msgb_alloc(); struct gprs_ns_hdr *nsh; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -384,7 +384,7 @@ uint16_t nsvci = htons(nsvc->nsvci); uint16_t nsei = htons(nsvc->nsei); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -416,7 +416,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); bvci = htons(bvci); @@ -469,7 +469,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -497,7 +497,7 @@ */ int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -510,7 +510,7 @@ */ int gprs_ns_tx_alive(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -523,7 +523,7 @@ */ int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -548,7 +548,7 @@ enum ns_timeout tout = timer_mode_tout[mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, mode), seconds); @@ -576,7 +576,7 @@ enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode), seconds); @@ -638,7 +638,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci, nsei; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -692,7 +692,7 @@ msgb_free(msg); return rc; } - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); msg->l2h = msgb_push(msg, sizeof(*nsh) + 3); nsh = (struct gprs_ns_hdr *) msg->l2h; @@ -1099,7 +1099,7 @@ struct gprs_nsvc *fallback_nsvc; fallback_nsvc = nsi->unknown_nsvc; - log_set_context(GPRS_CTX_NSVC, fallback_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); fallback_nsvc->ip.bts_addr = *saddr; fallback_nsvc->ll = ll; @@ -1215,7 +1215,7 @@ /* Only the RESET procedure creates a new NSVC */ if (nsh->pdu_type != NS_PDUT_RESET) { /* Since we have no NSVC, we have to use a fake */ - log_set_context(GPRS_CTX_NSVC, fallback_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x " "from %s for non-existing NS-VC\n", nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc)); @@ -1256,7 +1256,7 @@ if (!existing_nsvc) { *new_nsvc = gprs_nsvc_create(nsi, 0xffff); (*new_nsvc)->nsvci_is_valid = 0; - log_set_context(GPRS_CTX_NSVC, *new_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc); gprs_ns_ll_copy(*new_nsvc, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n", gprs_ns_ll_str(fallback_nsvc)); @@ -1299,7 +1299,7 @@ msgb_nsei(msg) = (*nsvc)->nsei; - log_set_context(GPRS_CTX_NSVC, *nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, *nsvc); /* Increment number of Incoming bytes */ rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]); diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index ee305ba..2026c7a 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -61,11 +61,11 @@ struct gprs_nsvc *nsvc) { if (nsvc) { - target->filter_map |= (1 << FLT_NSVC); - target->filter_data[FLT_NSVC] = nsvc; - } else if (target->filter_data[FLT_NSVC]) { - target->filter_map = ~(1 << FLT_NSVC); - target->filter_data[FLT_NSVC] = NULL; + target->filter_map |= (1 << LOGGING_FILTER_GB_NSVC); + target->filter_data[LOGGING_FILTER_GB_NSVC] = nsvc; + } else if (target->filter_data[LOGGING_FILTER_GB_NSVC]) { + target->filter_map = ~(1 << LOGGING_FILTER_GB_NSVC); + target->filter_data[LOGGING_FILTER_GB_NSVC] = NULL; } } diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..b09d684 100644 --- a/src/logging.c +++ b/src/logging.c @@ -48,6 +48,13 @@ #include /* for LOGGING_STR. */ +osmo_static_assert(_LOGGING_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), + enum_logging_ctx_items_fit_in_struct_log_context); +osmo_static_assert(_LOGGING_FILTER_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), + enum_logging_filters_fit_in_log_target_filter_data); +osmo_static_assert(_LOGGING_FILTER_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), + enum_logging_filters_fit_in_log_target_filter_map); + struct log_info *osmo_log_info; static struct log_context log_context; @@ -374,7 +381,7 @@ /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ - if ((tar->filter_map & LOG_FILTER_ALL) != 0) + if ((tar->filter_map & (1 << LOGGING_FILTER_ALL)) != 0) return 1; if (osmo_log_info->filter_fn) @@ -492,20 +499,20 @@ return 0; } -/*! \brief Enable the \ref LOG_FILTER_ALL log filter +/*! \brief Enable the \ref LOGGING_FILTER_ALL log filter * \param[in] target Log target to be affected * \param[in] all enable (1) or disable (0) the ALL filter * - * When the \ref LOG_FILTER_ALL filter is enabled, all log messages will - * be printed. It acts as a wildcard. Setting it to \a 1 means there - * is no filtering. + * When the \ref LOGGING_FILTER_ALL filter is enabled, all log messages will be + * printed. It acts as a wildcard. Setting it to \a 1 means there is no + * filtering. */ void log_set_all_filter(struct log_target *target, int all) { if (all) - target->filter_map |= LOG_FILTER_ALL; + target->filter_map |= (1 << LOGGING_FILTER_ALL); else - target->filter_map &= ~LOG_FILTER_ALL; + target->filter_map &= ~(1 << LOGGING_FILTER_ALL); } /*! \brief Enable or disable the use of colored output diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..30ee455 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -287,7 +287,7 @@ } vty_out(vty, " Log Filter 'ALL': %s%s", - tgt->filter_map & LOG_FILTER_ALL ? "Enabled" : "Disabled", + tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? "Enabled" : "Disabled", VTY_NEWLINE); /* print application specific filters */ @@ -687,7 +687,7 @@ } vty_out(vty, " logging filter all %u%s", - tgt->filter_map & LOG_FILTER_ALL ? 1 : 0, VTY_NEWLINE); + tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? 1 : 0, VTY_NEWLINE); /* save filters outside of libosmocore, i.e. in app code */ if (osmo_log_info->save_fn) osmo_log_info->save_fn(vty, osmo_log_info, tgt); -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:30:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:30:18 +0000 Subject: [PATCH] openbsc[master]: logging: use central filter and ctx consts from libosmocore Message-ID: Review at https://gerrit.osmocom.org/1845 logging: use central filter and ctx consts from libosmocore The LCHAN and BTS filter contexts are actually never used, so drop them until someone adds them properly. Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b --- M openbsc/include/openbsc/debug.h M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/e1_config.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/smpp_openbsc.c 7 files changed, 32 insertions(+), 55 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/45/1845/1 diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index ca3d4ad..ca00fe9 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -41,21 +41,6 @@ Debug_LastEntry, }; -/* context */ -#define BSC_CTX_LCHAN 0 -#define BSC_CTX_SUBSCR 1 -#define BSC_CTX_BTS 2 -#define BSC_CTX_SCCP 3 - -/* target */ - -enum { - //DEBUG_FILTER_ALL = 1 << 0, - LOG_FILTER_IMSI = 1 << 1, - LOG_FILTER_NSVC = 1 << 2, - LOG_FILTER_BVC = 1 << 3, -}; - /* we don't need a header dependency for this... */ struct gprs_nsvc; struct bssgp_bvc_ctx; diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 541a86d..04ff562 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -158,9 +158,8 @@ LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n", gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr); - log_set_context(BSC_CTX_LCHAN, lchan); if (lchan->conn) - log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr); + log_set_context(LOGGING_CTX_SUBSCR, lchan->conn->subscr); return lchan; } diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c index f1962c7..8910d21 100644 --- a/openbsc/src/libbsc/e1_config.c +++ b/openbsc/src/libbsc/e1_config.c @@ -134,7 +134,6 @@ struct e1inp_sign_link *link = msg->dst; struct gsm_bts *bts; - log_set_context(BSC_CTX_BTS, link->trx->bts); switch (link->type) { case E1INP_SIGN_OML: bts = link->trx->bts; diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 8c30637..b4d45c3 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -77,7 +77,7 @@ if (!bts->oml_link) return; - log_set_context(BSC_CTX_SUBSCR, request->subscr); + log_set_context(LOGGING_CTX_SUBSCR, request->subscr); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, @@ -91,7 +91,7 @@ page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(request->subscr->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(BSC_CTX_SUBSCR, NULL); + log_set_context(LOGGING_CTX_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -255,7 +255,7 @@ gsm_cbfn *cbfn; int msg; - log_set_context(BSC_CTX_SUBSCR, req->subscr); + log_set_context(LOGGING_CTX_SUBSCR, req->subscr); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", req, req->subscr->imsi); @@ -394,7 +394,7 @@ { struct gsm_bts *bts; - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_SUBSCR, subscr); /* Stop this first and dispatch the request */ if (_bts) diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index cf5beeb..cd6e5b1 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -177,32 +177,25 @@ }, }; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_IMSI = 1, - FLT_NSVC = 2, - FLT_BVC = 3, -}; - static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - struct gsm_subscriber *subscr = ctx->ctx[BSC_CTX_SUBSCR]; - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_SUBSCR]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; - if ((tar->filter_map & (1 << FLT_IMSI)) != 0 - && subscr && subscr == tar->filter_data[FLT_IMSI]) + if ((tar->filter_map & (1 << LOGGING_FILTER_SUBSCR)) != 0 + && subscr && subscr == tar->filter_data[LOGGING_FILTER_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; @@ -216,16 +209,17 @@ void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) { + struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_SUBSCR]; + /* free the old data */ - if (target->filter_data[FLT_IMSI]) { - subscr_put(target->filter_data[FLT_IMSI]); - target->filter_data[FLT_IMSI] = NULL; + if (*fsub) { + subscr_put(*fsub); + *fsub = NULL; } if (subscr) { - target->filter_map |= (1 << FLT_IMSI); - target->filter_data[FLT_IMSI] = subscr_get(subscr); - } else { - target->filter_map &= ~(1 << FLT_IMSI); - } + target->filter_map |= (1 << LOGGING_FILTER_SUBSCR); + *fsub = subscr_get(subscr); + } else + target->filter_map &= ~(1 << LOGGING_FILTER_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1a64731..f008892 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1457,7 +1457,7 @@ /* FIXME: request id? close channel? */ return -EINVAL; } - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1982,7 +1982,7 @@ return -EIO; /* Which subscriber do we want to track trans1 or trans2? */ - log_set_context(BSC_CTX_SUBSCR, trans1->subscr); + log_set_context(LOGGING_CTX_SUBSCR, trans1->subscr); /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); @@ -2003,7 +2003,7 @@ if (!trans->conn) return 0; - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_SUBSCR, trans->subscr); lchan = trans->conn->lchan; bts = lchan->ts->trx->bts; @@ -3339,7 +3339,7 @@ mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n"); mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); @@ -3395,7 +3395,7 @@ mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n"); mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); @@ -3572,7 +3572,7 @@ LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n"); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n"); return 0; @@ -3646,7 +3646,7 @@ data->imsi); /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_SUBSCR, subscr); /* If subscriber is not found */ if (!subscr) { @@ -3724,7 +3724,7 @@ subscr_put(subscr); } else { /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_SUBSCR, trans->subscr); } if (trans->conn) diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index 657272e..fa564c1 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -67,7 +67,7 @@ } /* tag the context in case we know it */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_SUBSCR, subscr); return subscr; } -- To view, visit https://gerrit.osmocom.org/1845 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:30:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:30:18 +0000 Subject: [PATCH] openbsc[master]: debug.h/c: remove unused cruft / cosmetic tweaks Message-ID: Review at https://gerrit.osmocom.org/1846 debug.h/c: remove unused cruft / cosmetic tweaks Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9 --- M openbsc/include/openbsc/debug.h M openbsc/src/libcommon/debug.c 2 files changed, 2 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/46/1846/1 diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index ca00fe9..6300020 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -1,5 +1,4 @@ -#ifndef _DEBUG_H -#define _DEBUG_H +#pragma once #include #include @@ -41,17 +40,8 @@ Debug_LastEntry, }; -/* we don't need a header dependency for this... */ -struct gprs_nsvc; -struct bssgp_bvc_ctx; struct gsm_subscriber; void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr); -void log_set_nsvc_filter(struct log_target *target, - struct gprs_nsvc *nsvc); -void log_set_bvc_filter(struct log_target *target, - struct bssgp_bvc_ctx *bctx); extern const struct log_info log_info; - -#endif /* _DEBUG_H */ diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index cd6e5b1..0ceea4e 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -177,8 +177,7 @@ }, }; -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) +static int filter_fn(const struct log_context *ctx, struct log_target *tar) { const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_SUBSCR]; const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; -- To view, visit https://gerrit.osmocom.org/1846 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:30:25 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:30:25 +0000 Subject: [PATCH] osmo-pcu[master]: logging: use central filter and ctx consts from libosmocore Message-ID: Review at https://gerrit.osmocom.org/1847 logging: use central filter and ctx consts from libosmocore Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 --- M src/gprs_bssgp_pcu.cpp M src/gprs_debug.cpp M src/gprs_debug.h 3 files changed, 7 insertions(+), 28 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/47/1847/1 diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index da1d26c..f07b3a6 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -365,7 +365,7 @@ if (bctx) { - log_set_context(BSC_CTX_BVC, bctx); + log_set_context(LOGGING_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); } diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp index 3d9b816..6bb35ea 100644 --- a/src/gprs_debug.cpp +++ b/src/gprs_debug.cpp @@ -46,27 +46,20 @@ {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, }; -enum { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_IMSI = 1, - FLT_NSVC = 2, - FLT_BVC = 3, -}; - static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[BSC_CTX_NSVC]; - const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[BSC_CTX_BVC]; + const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the BVC */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; diff --git a/src/gprs_debug.h b/src/gprs_debug.h index 963d841..817c41e 100644 --- a/src/gprs_debug.h +++ b/src/gprs_debug.h @@ -45,20 +45,6 @@ aDebug_LastEntry }; -/* context */ -#define BSC_CTX_SUBSCR 1 -#define BSC_CTX_NSVC 4 -#define BSC_CTX_BVC 5 - -/* target */ - -enum { - //DEBUG_FILTER_ALL = 1 << 0, - LOG_FILTER_IMSI = 1 << 1, - LOG_FILTER_NSVC = 1 << 2, - LOG_FILTER_BVC = 1 << 3, -}; - /* we don't need a header dependency for this... */ struct gprs_nsvc; -- To view, visit https://gerrit.osmocom.org/1847 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:30:26 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:30:26 +0000 Subject: [PATCH] osmo-pcu[master]: grps_debug.h: remove unused cruft / cosmetic tweaks Message-ID: Review at https://gerrit.osmocom.org/1848 grps_debug.h: remove unused cruft / cosmetic tweaks Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 --- M src/gprs_debug.h 1 file changed, 3 insertions(+), 18 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/48/1848/1 diff --git a/src/gprs_debug.h b/src/gprs_debug.h index 817c41e..863d76b 100644 --- a/src/gprs_debug.h +++ b/src/gprs_debug.h @@ -16,9 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef GPRS_DEBUG_H -#define GPRS_DEBUG_H + +#pragma once #include #ifdef __cplusplus @@ -29,6 +28,7 @@ #ifdef __cplusplus }; #endif + /* Debug Areas of the code */ enum { DCSN1, @@ -45,19 +45,4 @@ aDebug_LastEntry }; -/* we don't need a header dependency for this... */ - -struct gprs_nsvc; -struct bssgp_bvc_ctx; - -void log_set_imsi_filter(struct log_target *target, const char *imsi); -void log_set_nsvc_filter(struct log_target *target, - struct gprs_nsvc *nsvc); -void log_set_bvc_filter(struct log_target *target, - struct bssgp_bvc_ctx *bctx); - extern const struct log_info gprs_log_info; - - - -#endif // GPRS_DEBUG_H -- To view, visit https://gerrit.osmocom.org/1848 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 17 16:36:37 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 17 Feb 2017 16:36:37 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/1844/1/src/logging.c File src/logging.c: Line 508: * filtering. this API doc does actually not match the implementation, but a fix does not belong in this patch -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 18 00:52:53 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 18 Feb 2017 00:52:53 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 7: (1 comment) https://gerrit.osmocom.org/#/c/1582/7/include/osmocom/core/logging.h File include/osmocom/core/logging.h: Line 92: before adding anything to above */ Hmm. The loglevel nr space spans 0..255, where 0 is special and means "nothing"; 1 is most verbose and 8 is least verbose. Then out of 0..255 pick LOGL_EVERY=32 to mean "everything"? IMHO most sensible would be to swap so that 0 means everything and 255 means nothing. If we're not going to swap, why not take 255 for "everything"? ... Then again all of this logging code is kind of crooked and historically-grown-like, so actually 32 can't make it much worse either ;) -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 18 01:08:19 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 18 Feb 2017 01:08:19 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 7: Code-Review-1 In general I think it would be best to deprecate the 'logging level all everything' and fix it by adding a different command, to avoid situations where users have this in their conf file, not being aware of it, and suddenly the log explodes because the meaning of it changed (even though it changed to actually doing what it says). I happen to have it in my config files in my test setups, no idea why, and would need to adjust that "out of the blue". So if we really need this functionality, let's make it a different command and print a "% this command no longer exists" for the old one? I like the function rename of should_log_to_target() for code readability, it could be in a separate commit though. -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 18 21:20:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 18 Feb 2017 21:20:23 +0000 Subject: [PATCH] libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1844 to look at the new patch set (#2). logging: centrally define ctx and filter indexes It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Taking this opportunity to also prepare for a split of struct gsm_subscriber in openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter index constants for both subscriber types. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067 --- M include/osmocom/core/logging.h M include/osmocom/gprs/gprs_msgb.h M src/gb/common_vty.c M src/gb/common_vty.h M src/gb/gprs_bssgp.c M src/gb/gprs_bssgp_vty.c M src/gb/gprs_ns.c M src/gb/gprs_ns_vty.c M src/logging.c M src/vty/logging_vty.c 10 files changed, 66 insertions(+), 54 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/44/1844/2 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..b3685b8 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -89,8 +89,6 @@ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ -#define LOG_FILTER_ALL 0x0001 - /* logging levels defined by the library itself */ #define DLGLOBAL -1 /*!< global logging */ #define DLLAPD -2 /*!< LAPD implementation */ @@ -126,6 +124,23 @@ void *ctx[LOG_MAX_CTX+1]; }; +enum logging_ctx_items { + LOGGING_CTX_GB_NSVC, + LOGGING_CTX_GB_BVC, + LOGGING_CTX_BSC_SUBSCR, + LOGGING_CTX_VLR_SUBSCR, + _LOGGING_CTX_COUNT +}; + +enum logging_filters { + LOGGING_FILTER_ALL, + LOGGING_FILTER_GB_NSVC, + LOGGING_FILTER_GB_BVC, + LOGGING_FILTER_BSC_SUBSCR, + LOGGING_FILTER_VLR_SUBSCR, + _LOGGING_FILTER_COUNT +}; + struct log_target; /*! \brief Log filter function */ diff --git a/include/osmocom/gprs/gprs_msgb.h b/include/osmocom/gprs/gprs_msgb.h index 06f5cca..9ccc9a5 100644 --- a/include/osmocom/gprs/gprs_msgb.h +++ b/include/osmocom/gprs/gprs_msgb.h @@ -26,10 +26,6 @@ #define msgb_bcid(__x) LIBGB_MSGB_CB(__x)->bssgp_cell_id #define msgb_llch(__x) LIBGB_MSGB_CB(__x)->llch -/* logging contexts */ -#define GPRS_CTX_NSVC 0 -#define GPRS_CTX_BVC 1 - #include int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar); diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c index 5b20fcf..609ab3d 100644 --- a/src/gb/common_vty.c +++ b/src/gb/common_vty.c @@ -70,17 +70,17 @@ int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_bvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_bvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; diff --git a/src/gb/common_vty.h b/src/gb/common_vty.h index d8d0040..8c6b9ab 100644 --- a/src/gb/common_vty.h +++ b/src/gb/common_vty.h @@ -3,12 +3,6 @@ extern int DNS, DBSSGP; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_NSVC = 1, - FLT_BVC = 2, -}; - extern struct cmd_element libgb_exit_cmd; extern struct cmd_element libgb_end_cmd; diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 1ee942f..a402378 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -1049,7 +1049,7 @@ bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); if (bctx) { - log_set_context(GPRS_CTX_BVC, bctx); + log_set_context(LOGGING_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 1f382a2..d8fc840 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -47,11 +47,11 @@ struct bssgp_bvc_ctx *bctx) { if (bctx) { - target->filter_map |= (1 << FLT_BVC); - target->filter_data[FLT_BVC] = bctx; - } else if (target->filter_data[FLT_BVC]) { - target->filter_map = ~(1 << FLT_BVC); - target->filter_data[FLT_BVC] = NULL; + target->filter_map |= (1 << LOGGING_FILTER_GB_BVC); + target->filter_data[LOGGING_FILTER_GB_BVC] = bctx; + } else if (target->filter_data[LOGGING_FILTER_GB_BVC]) { + target->filter_map = ~(1 << LOGGING_FILTER_GB_BVC); + target->filter_data[LOGGING_FILTER_GB_BVC] = NULL; } } diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 18845d4..28f5ff3 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -325,7 +325,7 @@ { int ret; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); /* Increment number of Uplink bytes */ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]); @@ -360,7 +360,7 @@ struct msgb *msg = gprs_ns_msgb_alloc(); struct gprs_ns_hdr *nsh; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -384,7 +384,7 @@ uint16_t nsvci = htons(nsvc->nsvci); uint16_t nsei = htons(nsvc->nsei); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -416,7 +416,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); bvci = htons(bvci); @@ -469,7 +469,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -497,7 +497,7 @@ */ int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -510,7 +510,7 @@ */ int gprs_ns_tx_alive(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -523,7 +523,7 @@ */ int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -548,7 +548,7 @@ enum ns_timeout tout = timer_mode_tout[mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, mode), seconds); @@ -576,7 +576,7 @@ enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode), seconds); @@ -638,7 +638,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci, nsei; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -692,7 +692,7 @@ msgb_free(msg); return rc; } - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); msg->l2h = msgb_push(msg, sizeof(*nsh) + 3); nsh = (struct gprs_ns_hdr *) msg->l2h; @@ -1099,7 +1099,7 @@ struct gprs_nsvc *fallback_nsvc; fallback_nsvc = nsi->unknown_nsvc; - log_set_context(GPRS_CTX_NSVC, fallback_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); fallback_nsvc->ip.bts_addr = *saddr; fallback_nsvc->ll = ll; @@ -1215,7 +1215,7 @@ /* Only the RESET procedure creates a new NSVC */ if (nsh->pdu_type != NS_PDUT_RESET) { /* Since we have no NSVC, we have to use a fake */ - log_set_context(GPRS_CTX_NSVC, fallback_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x " "from %s for non-existing NS-VC\n", nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc)); @@ -1256,7 +1256,7 @@ if (!existing_nsvc) { *new_nsvc = gprs_nsvc_create(nsi, 0xffff); (*new_nsvc)->nsvci_is_valid = 0; - log_set_context(GPRS_CTX_NSVC, *new_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc); gprs_ns_ll_copy(*new_nsvc, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n", gprs_ns_ll_str(fallback_nsvc)); @@ -1299,7 +1299,7 @@ msgb_nsei(msg) = (*nsvc)->nsei; - log_set_context(GPRS_CTX_NSVC, *nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, *nsvc); /* Increment number of Incoming bytes */ rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]); diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index ee305ba..2026c7a 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -61,11 +61,11 @@ struct gprs_nsvc *nsvc) { if (nsvc) { - target->filter_map |= (1 << FLT_NSVC); - target->filter_data[FLT_NSVC] = nsvc; - } else if (target->filter_data[FLT_NSVC]) { - target->filter_map = ~(1 << FLT_NSVC); - target->filter_data[FLT_NSVC] = NULL; + target->filter_map |= (1 << LOGGING_FILTER_GB_NSVC); + target->filter_data[LOGGING_FILTER_GB_NSVC] = nsvc; + } else if (target->filter_data[LOGGING_FILTER_GB_NSVC]) { + target->filter_map = ~(1 << LOGGING_FILTER_GB_NSVC); + target->filter_data[LOGGING_FILTER_GB_NSVC] = NULL; } } diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..b09d684 100644 --- a/src/logging.c +++ b/src/logging.c @@ -48,6 +48,13 @@ #include /* for LOGGING_STR. */ +osmo_static_assert(_LOGGING_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), + enum_logging_ctx_items_fit_in_struct_log_context); +osmo_static_assert(_LOGGING_FILTER_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), + enum_logging_filters_fit_in_log_target_filter_data); +osmo_static_assert(_LOGGING_FILTER_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), + enum_logging_filters_fit_in_log_target_filter_map); + struct log_info *osmo_log_info; static struct log_context log_context; @@ -374,7 +381,7 @@ /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ - if ((tar->filter_map & LOG_FILTER_ALL) != 0) + if ((tar->filter_map & (1 << LOGGING_FILTER_ALL)) != 0) return 1; if (osmo_log_info->filter_fn) @@ -492,20 +499,20 @@ return 0; } -/*! \brief Enable the \ref LOG_FILTER_ALL log filter +/*! \brief Enable the \ref LOGGING_FILTER_ALL log filter * \param[in] target Log target to be affected * \param[in] all enable (1) or disable (0) the ALL filter * - * When the \ref LOG_FILTER_ALL filter is enabled, all log messages will - * be printed. It acts as a wildcard. Setting it to \a 1 means there - * is no filtering. + * When the \ref LOGGING_FILTER_ALL filter is enabled, all log messages will be + * printed. It acts as a wildcard. Setting it to \a 1 means there is no + * filtering. */ void log_set_all_filter(struct log_target *target, int all) { if (all) - target->filter_map |= LOG_FILTER_ALL; + target->filter_map |= (1 << LOGGING_FILTER_ALL); else - target->filter_map &= ~LOG_FILTER_ALL; + target->filter_map &= ~(1 << LOGGING_FILTER_ALL); } /*! \brief Enable or disable the use of colored output diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..30ee455 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -287,7 +287,7 @@ } vty_out(vty, " Log Filter 'ALL': %s%s", - tgt->filter_map & LOG_FILTER_ALL ? "Enabled" : "Disabled", + tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? "Enabled" : "Disabled", VTY_NEWLINE); /* print application specific filters */ @@ -687,7 +687,7 @@ } vty_out(vty, " logging filter all %u%s", - tgt->filter_map & LOG_FILTER_ALL ? 1 : 0, VTY_NEWLINE); + tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? 1 : 0, VTY_NEWLINE); /* save filters outside of libosmocore, i.e. in app code */ if (osmo_log_info->save_fn) osmo_log_info->save_fn(vty, osmo_log_info, tgt); -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sat Feb 18 21:33:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 18 Feb 2017 21:33:27 +0000 Subject: [PATCH] openbsc[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1845 to look at the new patch set (#2). logging: use central filter and ctx consts from libosmocore The LCHAN and BTS filter contexts are actually never used, so drop them until someone adds them properly. For now use only LOGGING_{FILTER,CTX}_BSC_SUBSCR. Some of these will change to _VLR_SUBSCR once struct vlr_subscr is introduced. Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b --- M openbsc/include/openbsc/debug.h M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/e1_config.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/smpp_openbsc.c 7 files changed, 32 insertions(+), 55 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/45/1845/2 diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index ca3d4ad..ca00fe9 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -41,21 +41,6 @@ Debug_LastEntry, }; -/* context */ -#define BSC_CTX_LCHAN 0 -#define BSC_CTX_SUBSCR 1 -#define BSC_CTX_BTS 2 -#define BSC_CTX_SCCP 3 - -/* target */ - -enum { - //DEBUG_FILTER_ALL = 1 << 0, - LOG_FILTER_IMSI = 1 << 1, - LOG_FILTER_NSVC = 1 << 2, - LOG_FILTER_BVC = 1 << 3, -}; - /* we don't need a header dependency for this... */ struct gprs_nsvc; struct bssgp_bvc_ctx; diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 541a86d..30781d0 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -158,9 +158,8 @@ LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n", gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr); - log_set_context(BSC_CTX_LCHAN, lchan); if (lchan->conn) - log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, lchan->conn->subscr); return lchan; } diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c index f1962c7..8910d21 100644 --- a/openbsc/src/libbsc/e1_config.c +++ b/openbsc/src/libbsc/e1_config.c @@ -134,7 +134,6 @@ struct e1inp_sign_link *link = msg->dst; struct gsm_bts *bts; - log_set_context(BSC_CTX_BTS, link->trx->bts); switch (link->type) { case E1INP_SIGN_OML: bts = link->trx->bts; diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 8c30637..1c0c9c8 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -77,7 +77,7 @@ if (!bts->oml_link) return; - log_set_context(BSC_CTX_SUBSCR, request->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, request->subscr); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, @@ -91,7 +91,7 @@ page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(request->subscr->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(BSC_CTX_SUBSCR, NULL); + log_set_context(LOGGING_CTX_BSC_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -255,7 +255,7 @@ gsm_cbfn *cbfn; int msg; - log_set_context(BSC_CTX_SUBSCR, req->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, req->subscr); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", req, req->subscr->imsi); @@ -394,7 +394,7 @@ { struct gsm_bts *bts; - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, subscr); /* Stop this first and dispatch the request */ if (_bts) diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index cf5beeb..5f623ce 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -177,32 +177,25 @@ }, }; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_IMSI = 1, - FLT_NSVC = 2, - FLT_BVC = 3, -}; - static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - struct gsm_subscriber *subscr = ctx->ctx[BSC_CTX_SUBSCR]; - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_BSC_SUBSCR]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; - if ((tar->filter_map & (1 << FLT_IMSI)) != 0 - && subscr && subscr == tar->filter_data[FLT_IMSI]) + if ((tar->filter_map & (1 << LOGGING_FILTER_BSC_SUBSCR)) != 0 + && subscr && subscr == tar->filter_data[LOGGING_FILTER_BSC_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; @@ -216,16 +209,17 @@ void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) { + struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_BSC_SUBSCR]; + /* free the old data */ - if (target->filter_data[FLT_IMSI]) { - subscr_put(target->filter_data[FLT_IMSI]); - target->filter_data[FLT_IMSI] = NULL; + if (*fsub) { + subscr_put(*fsub); + *fsub = NULL; } if (subscr) { - target->filter_map |= (1 << FLT_IMSI); - target->filter_data[FLT_IMSI] = subscr_get(subscr); - } else { - target->filter_map &= ~(1 << FLT_IMSI); - } + target->filter_map |= (1 << LOGGING_FILTER_BSC_SUBSCR); + *fsub = subscr_get(subscr); + } else + target->filter_map &= ~(1 << LOGGING_FILTER_BSC_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1a64731..bae4590 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1457,7 +1457,7 @@ /* FIXME: request id? close channel? */ return -EINVAL; } - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1982,7 +1982,7 @@ return -EIO; /* Which subscriber do we want to track trans1 or trans2? */ - log_set_context(BSC_CTX_SUBSCR, trans1->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, trans1->subscr); /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); @@ -2003,7 +2003,7 @@ if (!trans->conn) return 0; - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, trans->subscr); lchan = trans->conn->lchan; bts = lchan->ts->trx->bts; @@ -3339,7 +3339,7 @@ mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n"); mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); @@ -3395,7 +3395,7 @@ mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n"); mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); @@ -3572,7 +3572,7 @@ LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n"); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n"); return 0; @@ -3646,7 +3646,7 @@ data->imsi); /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, subscr); /* If subscriber is not found */ if (!subscr) { @@ -3724,7 +3724,7 @@ subscr_put(subscr); } else { /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, trans->subscr); } if (trans->conn) diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index 657272e..ac86230 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -67,7 +67,7 @@ } /* tag the context in case we know it */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, subscr); return subscr; } -- To view, visit https://gerrit.osmocom.org/1845 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 18 22:11:59 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 18 Feb 2017 22:11:59 +0000 Subject: [PATCH] openbsc[master]: remove compiler warning: unused rc in vty_interface_layer3 Message-ID: Review at https://gerrit.osmocom.org/1849 remove compiler warning: unused rc in vty_interface_layer3 Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280 --- M openbsc/src/libmsc/vty_interface_layer3.c 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/49/1849/1 diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 11d9022..ddec2e3 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -517,7 +517,6 @@ "subscriber " SUBSCR_TYPES " ID expire", SUBSCR_HELP "Expire the subscriber Now\n") { - int rc; struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); -- To view, visit https://gerrit.osmocom.org/1849 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 00:45:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 00:45:02 +0000 Subject: [PATCH] openbsc[master]: subscr_update_expire_lu(): fix (obscure) segfault Message-ID: Review at https://gerrit.osmocom.org/1850 subscr_update_expire_lu(): fix (obscure) segfault To be paranoid, catch a NULL subscriber and/or bts in subscr_update_expire_lu(): print an error log and avoid segfault. (I'm not sure this would really happen in a normal situation.) During aggressive testing of Paging timeout, I came across this segfault in msc_release_connection() when conn->expire_timer_stopped is set but conn->subscr is NULL, at the subscr dereference after: if (conn->expire_timer_stopped) subscr_update_expire_lu(conn->subscr, conn->bts); I brought this situation about by a fabricated Paging fault, i.e. in gsm48_rx_rr_pag_resp() return 0 and don't call gsm48_handle_paging_resp() at all. Thus conn->subscr is still NULL when expire_timer_stopped is 1. When looking at CM Service Request handling, the conn->subscr is set before setting expire_timer_stopped = 1, which is a saner thing to do. But without my mad 'return 0', there is in fact no way to have a NULL subscriber there. It looks like all other code paths already do the same, but it's not that obvious (e.g. _gsm48_rx_mm_serv_req_sec_cb()). So rather catch this case of NULL conn->subscr, and while at it catch NULL bts as well. Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395 --- M openbsc/src/libmsc/gsm_subscriber.c 1 file changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/50/1850/1 diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 4ec0ead..568f1c5 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -276,6 +276,16 @@ { int rc; + if (!s) { + LOGP(DMM, LOGL_ERROR, "LU Expiration but NULL subscriber\n"); + return -1; + } + if (!bts) { + LOGP(DMM, LOGL_ERROR, "%s: LU Expiration but NULL bts\n", + subscr_name(s)); + return -1; + } + /* Table 10.5.33: The T3212 timeout value field is coded as the * binary representation of the timeout value for * periodic updating in decihours. Mark the subscriber as -- To view, visit https://gerrit.osmocom.org/1850 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 01:53:24 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 01:53:24 +0000 Subject: [PATCH] openbsc[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1845 to look at the new patch set (#3). logging: use central filter and ctx consts from libosmocore The LCHAN and BTS filter contexts are actually never used, so drop them until someone adds them properly. For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to _BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct gsm_subscriber will be replaced by vlr_subscriber so that the names will match. Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b --- M openbsc/include/openbsc/debug.h M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/e1_config.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/smpp_openbsc.c 7 files changed, 32 insertions(+), 55 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/45/1845/3 diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index ca3d4ad..ca00fe9 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -41,21 +41,6 @@ Debug_LastEntry, }; -/* context */ -#define BSC_CTX_LCHAN 0 -#define BSC_CTX_SUBSCR 1 -#define BSC_CTX_BTS 2 -#define BSC_CTX_SCCP 3 - -/* target */ - -enum { - //DEBUG_FILTER_ALL = 1 << 0, - LOG_FILTER_IMSI = 1 << 1, - LOG_FILTER_NSVC = 1 << 2, - LOG_FILTER_BVC = 1 << 3, -}; - /* we don't need a header dependency for this... */ struct gprs_nsvc; struct bssgp_bvc_ctx; diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 541a86d..58fdaa3 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -158,9 +158,8 @@ LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n", gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr); - log_set_context(BSC_CTX_LCHAN, lchan); if (lchan->conn) - log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, lchan->conn->subscr); return lchan; } diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c index f1962c7..8910d21 100644 --- a/openbsc/src/libbsc/e1_config.c +++ b/openbsc/src/libbsc/e1_config.c @@ -134,7 +134,6 @@ struct e1inp_sign_link *link = msg->dst; struct gsm_bts *bts; - log_set_context(BSC_CTX_BTS, link->trx->bts); switch (link->type) { case E1INP_SIGN_OML: bts = link->trx->bts; diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 8c30637..816d7a6 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -77,7 +77,7 @@ if (!bts->oml_link) return; - log_set_context(BSC_CTX_SUBSCR, request->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, @@ -91,7 +91,7 @@ page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(request->subscr->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(BSC_CTX_SUBSCR, NULL); + log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -255,7 +255,7 @@ gsm_cbfn *cbfn; int msg; - log_set_context(BSC_CTX_SUBSCR, req->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", req, req->subscr->imsi); @@ -394,7 +394,7 @@ { struct gsm_bts *bts; - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); /* Stop this first and dispatch the request */ if (_bts) diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index cf5beeb..51fbb93 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -177,32 +177,25 @@ }, }; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_IMSI = 1, - FLT_NSVC = 2, - FLT_BVC = 3, -}; - static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - struct gsm_subscriber *subscr = ctx->ctx[BSC_CTX_SUBSCR]; - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; - if ((tar->filter_map & (1 << FLT_IMSI)) != 0 - && subscr && subscr == tar->filter_data[FLT_IMSI]) + if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0 + && subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; @@ -216,16 +209,17 @@ void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) { + struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; + /* free the old data */ - if (target->filter_data[FLT_IMSI]) { - subscr_put(target->filter_data[FLT_IMSI]); - target->filter_data[FLT_IMSI] = NULL; + if (*fsub) { + subscr_put(*fsub); + *fsub = NULL; } if (subscr) { - target->filter_map |= (1 << FLT_IMSI); - target->filter_data[FLT_IMSI] = subscr_get(subscr); - } else { - target->filter_map &= ~(1 << FLT_IMSI); - } + target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR); + *fsub = subscr_get(subscr); + } else + target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1a64731..10e2b31 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1457,7 +1457,7 @@ /* FIXME: request id? close channel? */ return -EINVAL; } - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1982,7 +1982,7 @@ return -EIO; /* Which subscriber do we want to track trans1 or trans2? */ - log_set_context(BSC_CTX_SUBSCR, trans1->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans1->subscr); /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); @@ -2003,7 +2003,7 @@ if (!trans->conn) return 0; - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); lchan = trans->conn->lchan; bts = lchan->ts->trx->bts; @@ -3339,7 +3339,7 @@ mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n"); mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); @@ -3395,7 +3395,7 @@ mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n"); mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); @@ -3572,7 +3572,7 @@ LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n"); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n"); return 0; @@ -3646,7 +3646,7 @@ data->imsi); /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); /* If subscriber is not found */ if (!subscr) { @@ -3724,7 +3724,7 @@ subscr_put(subscr); } else { /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); } if (trans->conn) diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index 657272e..fdafa16 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -67,7 +67,7 @@ } /* tag the context in case we know it */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); return subscr; } -- To view, visit https://gerrit.osmocom.org/1845 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sun Feb 19 01:58:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 01:58:38 +0000 Subject: [PATCH] openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1682 to look at the new patch set (#5). add struct bsc_subscr, separating libbsc from gsm_subscriber In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC subscriber: struct bsc_subscr. Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no longer have a backpointer to gsm_network (used to be via subscr->group). Create a separate logging filter for the new BSC subscriber. The implementation of adjusting the filter context is added in libbsc to not introduce bsc_subscr_get/_put() dependencies to libcommon. During Paging Response, fetch a bsc_subscr from the mobile identity, like we do for the gsm_subscriber. It looks like a duplication now, but will make sense for the VLR as well as for future MSC split patches. Naming: it was requested to not name the new struct bsc_sub, because 'sub' is too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast to type, relatively short, unambiguous, and the naming is consistent. Add bsc_subscr unit test. Related: #1592, #1594 Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e --- M openbsc/.gitignore M openbsc/include/openbsc/Makefile.am A openbsc/include/openbsc/bsc_subscriber.h M openbsc/include/openbsc/debug.h M openbsc/include/openbsc/gsm_04_08.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/osmo_bsc_grace.h M openbsc/include/openbsc/paging.h M openbsc/src/libbsc/Makefile.am M openbsc/src/libbsc/abis_rsl.c A openbsc/src/libbsc/bsc_subscriber.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/libbsc/gsm_04_08_utils.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon-cs/common_cs.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/gsm_subscriber.c M openbsc/src/libmsc/vty_interface_layer3.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/tests/channel/Makefile.am M openbsc/tests/channel/channel_test.c M openbsc/tests/subscr/Makefile.am A openbsc/tests/subscr/bsc_subscr_test.c A openbsc/tests/subscr/bsc_subscr_test.err A openbsc/tests/subscr/bsc_subscr_test.ok M openbsc/tests/testsuite.at 30 files changed, 611 insertions(+), 115 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/82/1682/5 diff --git a/openbsc/.gitignore b/openbsc/.gitignore index e3f25cb..4f8e7e6 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -79,6 +79,7 @@ tests/mgcp/mgcp_transcoding_test tests/sgsn/sgsn_test tests/subscr/subscr_test +tests/subscr/bsc_subscr_test tests/oap/oap_test tests/gtphub/gtphub_test tests/mm_auth/mm_auth_test diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index c10accd..0895096 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -10,6 +10,7 @@ bsc_nat_callstats.h \ bsc_nat_sccp.h \ bsc_rll.h \ + bsc_subscriber.h \ bss.h \ bts_ipaccess_nanobts_omlattr.h \ chan_alloc.h \ diff --git a/openbsc/include/openbsc/bsc_subscriber.h b/openbsc/include/openbsc/bsc_subscriber.h new file mode 100644 index 0000000..a750d6e --- /dev/null +++ b/openbsc/include/openbsc/bsc_subscriber.h @@ -0,0 +1,43 @@ +/* GSM subscriber details for use in BSC land */ + +#pragma once + +#include + +#include +#include + +struct log_target; + +struct bsc_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + uint16_t lac; +}; + +const char *bsc_subscr_name(struct bsc_subscr *bsub); + +struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_have_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi); + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line); +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line); +#define bsc_subscr_get(bsub) _bsc_subscr_get(bsub, __BASE_FILE__, __LINE__) +#define bsc_subscr_put(bsub) _bsc_subscr_put(bsub, __BASE_FILE__, __LINE__) + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsub); diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index 6300020..74db723 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -42,6 +42,7 @@ struct gsm_subscriber; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr); +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr); extern const struct log_info log_info; diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index cb632f6..bdf4ed2 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -15,6 +15,7 @@ struct gsm_subscriber_connection; struct amr_multirate_conf; struct amr_mode; +struct bsc_subscr; #define GSM48_ALLOC_SIZE 2048 #define GSM48_ALLOC_HEADROOM 256 @@ -78,7 +79,8 @@ int send_siemens_mrpci(struct gsm_lchan *lchan, uint8_t *classmark2_lv); int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type); int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, uint8_t *mi_type); -int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr); +int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, + struct msgb *msg, struct bsc_subscr *bsub); int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode); int gsm48_rx_rr_modif_ack(struct msgb *msg); diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 460953e..dbc58ac 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -23,6 +23,7 @@ struct mncc_sock_state; struct gsm_subscriber_group; +struct bsc_subscr; #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] @@ -112,6 +113,9 @@ /* To whom we are allocated at the moment */ struct gsm_subscriber *subscr; + + /* libbsc subscriber information */ + struct bsc_subscr *bsub; /* LU expiration handling */ uint8_t expire_timer_stopped; @@ -383,6 +387,11 @@ * BTS|RNC specific timezone overrides for multi-tz networks in * OsmoCSCN, this should be tied to the location area code (LAC). */ struct gsm_tz tz; + + /* List of all struct bsc_subscr used in libbsc. This llist_head is + * allocated so that the llist_head pointer itself can serve as a + * talloc context. */ + struct llist_head *bsc_subscribers; }; struct osmo_esme; diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index af77b2f..50477d7 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -22,10 +22,14 @@ #define OSMO_BSC_GRACE_H #include +#include struct osmo_msc_data; int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts); -int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc); +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc); #endif diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index 689ff51..7dd8500 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -27,7 +27,7 @@ #include #include -#include +#include /** * A pending paging request @@ -36,8 +36,8 @@ /* list_head for list of all paging requests */ struct llist_head entry; /* the subscriber which we're paging. Later gsm_paging_request - * should probably become a part of the gsm_subscriber struct? */ - struct gsm_subscriber *subscr; + * should probably become a part of the bsc_subsrc struct? */ + struct bsc_subscr *bsub; /* back-pointer to the BTS on which we are paging */ struct gsm_bts *bts; /* what kind of channel type do we ask the MS to establish */ @@ -55,13 +55,14 @@ }; /* schedule paging request */ -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data); -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data); +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data); /* stop paging requests */ -void paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg); @@ -71,6 +72,6 @@ /* pending paging requests */ unsigned int paging_pending_requests_nr(struct gsm_bts *bts); -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr); +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub); #endif diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am index b8e77e6..fd8f37a 100644 --- a/openbsc/src/libbsc/Makefile.am +++ b/openbsc/src/libbsc/Makefile.am @@ -24,6 +24,7 @@ abis_om2000_vty.c \ abis_rsl.c \ bsc_rll.c \ + bsc_subscriber.c \ paging.c \ bts_ericsson_rbs2000.c \ bts_ipaccess_nanobts.c \ diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 58fdaa3..8ef178b 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1332,10 +1332,10 @@ static void print_meas_rep(struct gsm_lchan *lchan, struct gsm_meas_rep *mr) { int i; - char *name = ""; + const char *name = ""; if (lchan && lchan->conn) - name = subscr_name(lchan->conn->subscr); + name = bsc_subscr_name(lchan->conn->bsub); DEBUGP(DMEAS, "[%s] MEASUREMENT RESULT NR=%d ", name, mr->nr); diff --git a/openbsc/src/libbsc/bsc_subscriber.c b/openbsc/src/libbsc/bsc_subscriber.c new file mode 100644 index 0000000..205fdea --- /dev/null +++ b/openbsc/src/libbsc/bsc_subscriber.c @@ -0,0 +1,168 @@ +/* GSM subscriber details for use in BSC land */ + +/* + * (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Neels Hofmeyr + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include + +#include +#include + +static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list) +{ + struct bsc_subscr *bsub; + + bsub = talloc_zero(list, struct bsc_subscr); + if (!bsub) + return NULL; + + llist_add_tail(&bsub->entry, list); + bsub->use_count = 1; + + return bsub; +} + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + + if (!imsi || !*imsi) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (!strcmp(bsub->imsi, imsi)) + return bsc_subscr_get(bsub); + } + return NULL; +} + +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + + if (tmsi == GSM_RESERVED_TMSI) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (bsub->tmsi == tmsi) + return bsc_subscr_get(bsub); + } + return NULL; +} + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi) +{ + if (!bsub) + return; + strncpy(bsub->imsi, imsi, sizeof(bsub->imsi)); +} + +struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_imsi(list, imsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsc_subscr_set_imsi(bsub, imsi); + return bsub; +} + +struct bsc_subscr *bsc_subscr_have_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_tmsi(list, tmsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsub->tmsi = tmsi; + return bsub; +} + +const char *bsc_subscr_name(struct bsc_subscr *bsub) +{ + static char buf[32]; + if (!bsub) + return "unknown"; + if (bsub->imsi[0]) + snprintf(buf, sizeof(buf), "IMSI:%s", bsub->imsi); + else + snprintf(buf, sizeof(buf), "TMSI:0x%08x", bsub->tmsi); + return buf; +} + +static void bsc_subscr_free(struct bsc_subscr *bsub) +{ + llist_del(&bsub->entry); + talloc_free(bsub); +} + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line) +{ + OSMO_ASSERT(bsub->use_count < INT_MAX); + bsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "BSC subscr %s usage increases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + return bsub; +} + +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line) +{ + bsub->use_count--; + LOGPSRC(DREF, bsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "BSC subscr %s usage decreases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + if (bsub->use_count <= 0) + bsc_subscr_free(bsub); + return NULL; +} + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsc_subscr) +{ + struct bsc_subscr **fsub = (void*)&target->filter_data[LOGGING_FILTER_BSC_SUBSCR]; + + /* free the old data */ + if (*fsub) { + bsc_subscr_put(*fsub); + *fsub = NULL; + } + + if (bsc_subscr) { + target->filter_map |= (1 << LOGGING_FILTER_BSC_SUBSCR); + *fsub = bsc_subscr_get(bsc_subscr); + } else + target->filter_map &= ~(1 << LOGGING_FILTER_BSC_SUBSCR); +} diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 00acbc7..1464ad3 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1014,6 +1014,16 @@ vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); } +static void bsc_subscr_dump_vty(struct vty *vty, struct bsc_subscr *bsub) +{ + if (strlen(bsub->imsi)) + vty_out(vty, " IMSI: %s%s", bsub->imsi, VTY_NEWLINE); + if (bsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: 0x%08x%s", bsub->tmsi, + VTY_NEWLINE); + vty_out(vty, " Use count: %d%s", bsub->use_count, VTY_NEWLINE); +} + static void meas_rep_dump_uni_vty(struct vty *vty, struct gsm_meas_rep_unidir *mru, const char *prefix, @@ -1309,7 +1319,7 @@ static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag) { vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); - subscr_dump_vty(vty, pag->subscr); + bsc_subscr_dump_vty(vty, pag->bsub); } static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts) diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 98f0790..4a53b31 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -283,7 +283,7 @@ } int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct gsm_subscriber *subscr) + struct msgb *msg, struct bsc_subscr *bsub) { struct gsm_bts *bts = msg->lchan->ts->trx->bts; struct gsm48_hdr *gh = msgb_l3(msg); @@ -292,22 +292,24 @@ if (is_siemens_bts(bts)) send_siemens_mrpci(msg->lchan, classmark2_lv); - if (!conn->subscr) { - conn->subscr = subscr; - } else if (conn->subscr != subscr) { - LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); - subscr_put(subscr); + if (!conn->bsub) { + conn->bsub = bsub; + } else if (conn->bsub != bsub) { + LOGP(DRR, LOGL_ERROR, + "<- Channel already owned by someone else?\n"); + bsc_subscr_put(bsub); return -EINVAL; } else { DEBUGP(DRR, "<- Channel already owned by us\n"); - subscr_put(subscr); - subscr = conn->subscr; + bsc_subscr_put(bsub); + bsub = conn->bsub; } rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_COMPLETED]); /* Stop paging on the bts we received the paging response */ - paging_request_stop(conn->bts, subscr, conn, msg); + paging_request_stop(&bts->network->bts_list, conn->bts, bsub, conn, + msg); return 0; } diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 816d7a6..442e0da 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -58,11 +59,11 @@ * Kill one paging request update the internal list... */ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts, - struct gsm_paging_request *to_be_deleted) + struct gsm_paging_request *to_be_deleted) { osmo_timer_del(&to_be_deleted->T3113); llist_del(&to_be_deleted->entry); - subscr_put(to_be_deleted->subscr); + bsc_subscr_put(to_be_deleted->bsub); talloc_free(to_be_deleted); } @@ -77,21 +78,22 @@ if (!bts->oml_link) return; - log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, request->bsub); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " - "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, - request->subscr->tmsi, request->chan_type, request->attempts); + "0x%08x for ch. type %d (attempt %d)\n", request->bsub->imsi, + request->bsub->tmsi, request->chan_type, request->attempts); - if (request->subscr->tmsi == GSM_RESERVED_TMSI) - mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi); + if (request->bsub->tmsi == GSM_RESERVED_TMSI) + mi_len = gsm48_generate_mid_from_imsi(mi, request->bsub->imsi); else - mi_len = gsm48_generate_mid_from_tmsi(mi, request->subscr->tmsi); + mi_len = gsm48_generate_mid_from_tmsi(mi, request->bsub->tmsi); page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, - str_to_imsi(request->subscr->imsi)); + str_to_imsi(request->bsub->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL); + + log_set_context(LOGGING_CTX_BSC_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -237,11 +239,12 @@ } static int paging_pending_request(struct gsm_bts_paging_state *bts, - struct gsm_subscriber *subscr) { + struct bsc_subscr *bsub) +{ struct gsm_paging_request *req; llist_for_each_entry(req, &bts->pending_requests, entry) { - if (subscr == req->subscr) + if (bsub == req->bsub) return 1; } @@ -255,10 +258,10 @@ gsm_cbfn *cbfn; int msg; - log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, req->bsub); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", - req, req->subscr->imsi); + req, bsc_subscr_name(req->bsub)); /* must be destroyed before calling cbfn, to prevent double free */ rate_ctr_inc(&req->bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_EXPIRED]); @@ -277,21 +280,22 @@ } -static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +static int _paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts_paging_state *bts_entry = &bts->paging; struct gsm_paging_request *req; - if (paging_pending_request(bts_entry, subscr)) { - LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", subscr->imsi); + if (paging_pending_request(bts_entry, bsub)) { + LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", + bsc_subscr_name(bsub)); return -EEXIST; } - LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %llu on bts %d.\n", - subscr->id, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %s on bts %d.\n", + bsc_subscr_name(bsub), bts->nr); req = talloc_zero(tall_paging_ctx, struct gsm_paging_request); - req->subscr = subscr_get(subscr); + req->bsub = bsc_subscr_get(bsub); req->bts = bts; req->chan_type = type; req->cbfn = cbfn; @@ -305,8 +309,8 @@ return 0; } -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { int rc; @@ -317,15 +321,14 @@ /* maybe it is the first time we use it */ paging_init_if_needed(bts); - /* Trigger paging, pass any error to the caller */ - rc = _paging_request(bts, subscr, type, cbfn, data); + rc = _paging_request(bts, bsub, type, cbfn, data); if (rc < 0) return rc; return 1; } -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts *bts = NULL; @@ -337,13 +340,14 @@ do { int rc; - bts = gsm_bts_by_lac(network, subscr->lac, bts); + bts = gsm_bts_by_lac(network, bsub->lac, bts); if (!bts) break; - rc = paging_request_bts(bts, subscr, type, cbfn, data); + rc = paging_request_bts(bts, bsub, type, cbfn, data); if (rc < 0) { - paging_request_stop(NULL, subscr, NULL, NULL); + paging_request_stop(&network->bts_list, NULL, bsub, + NULL, NULL); return rc; } num_pages += rc; @@ -357,7 +361,7 @@ /* we consciously ignore the type of the request here */ -static void _paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +static void _paging_request_stop(struct gsm_bts *bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -367,8 +371,8 @@ paging_init_if_needed(bts); llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests, - entry) { - if (req->subscr == subscr) { + entry) { + if (req->bsub == bsub) { gsm_cbfn *cbfn = req->cbfn; void *param = req->cbfn_param; @@ -377,35 +381,36 @@ req = NULL; if (conn && cbfn) { - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", bsub->imsi, bts->nr); cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED, - msg, conn, param); + msg, conn, param); } else - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", bsub->imsi, bts->nr); break; } } } /* Stop paging on all other bts' */ -void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm_bts *bts; - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, bsub); /* Stop this first and dispatch the request */ if (_bts) - _paging_request_stop(_bts, subscr, conn, msg); + _paging_request_stop(_bts, bsub, conn, msg); /* Make sure to cancel this everywhere else */ - llist_for_each_entry(bts, &subscr->group->net->bts_list, list) { + llist_for_each_entry(bts, bts_list, list) { /* Sort of an optimization. */ if (bts == _bts) continue; - _paging_request_stop(bts, subscr, NULL, NULL); + _paging_request_stop(bts, bsub, NULL, NULL); } } @@ -434,12 +439,12 @@ /** * Find any paging data for the given subscriber at the given BTS. */ -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr) +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub) { struct gsm_paging_request *req; llist_for_each_entry(req, &bts->paging.pending_requests, entry) - if (req->subscr == subscr) + if (req->bsub == bsub) return req->cbfn_param; return NULL; diff --git a/openbsc/src/libcommon-cs/common_cs.c b/openbsc/src/libcommon-cs/common_cs.c index 3149580..7905802 100644 --- a/openbsc/src/libcommon-cs/common_cs.c +++ b/openbsc/src/libcommon-cs/common_cs.c @@ -70,6 +70,9 @@ INIT_LLIST_HEAD(&net->upqueue); INIT_LLIST_HEAD(&net->subscr_conns); + net->bsc_subscribers = talloc_zero(net, struct llist_head); + INIT_LLIST_HEAD(net->bsc_subscribers); + /* init statistics */ net->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, 0); net->active_calls = osmo_counter_alloc("msc.active_calls"); diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 3f3232c..dcd02fa 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -180,11 +180,16 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; + const struct bsc_subscr *bsub = ctx->ctx[LOGGING_CTX_BSC_SUBSCR]; const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0 && subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR]) + return 1; + + if ((tar->filter_map & (1 << LOGGING_FILTER_BSC_SUBSCR)) != 0 + && bsub && bsub == tar->filter_data[LOGGING_FILTER_BSC_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ @@ -206,7 +211,8 @@ .num_cat = ARRAY_SIZE(default_categories), }; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr) { struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; @@ -216,9 +222,9 @@ *fsub = NULL; } - if (subscr) { + if (vlr_subscr) { target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR); - *fsub = subscr_get(subscr); + *fsub = subscr_get(vlr_subscr); } else target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 10e2b31..d5c9d09 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1433,6 +1433,8 @@ uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm_subscriber *subscr = NULL; + struct bsc_subscr *bsub; + uint32_t tmsi; int rc = 0; resp = (struct gsm48_pag_resp *) &gh->data[0]; @@ -1443,8 +1445,8 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_get_by_tmsi(conn->network->subscr_group, - tmsi_from_string(mi_string)); + tmsi = tmsi_from_string(mi_string); + subscr = subscr_get_by_tmsi(conn->network->subscr_group, tmsi); break; case GSM_MI_TYPE_IMSI: subscr = subscr_get_by_imsi(conn->network->subscr_group, @@ -1457,6 +1459,19 @@ /* FIXME: request id? close channel? */ return -EINVAL; } + + if (!conn->subscr) { + conn->subscr = subscr; + } else if (conn->subscr != subscr) { + LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); + subscr_put(subscr); + return -EINVAL; + } else { + DEBUGP(DRR, "<- Channel already owned by us\n"); + subscr_put(subscr); + subscr = conn->subscr; + } + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1465,10 +1480,18 @@ memcpy(subscr->equipment.classmark2, classmark2_lv+1, *classmark2_lv); db_sync_equipment(&subscr->equipment); + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_have_by_imsi(conn->network->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + /* We received a paging */ conn->expire_timer_stopped = 1; - rc = gsm48_handle_paging_resp(conn, msg, subscr); + rc = gsm48_handle_paging_resp(conn, msg, bsub); return rc; } diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 4ec0ead..6d6a6ac 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -82,8 +82,11 @@ struct gsm_subscriber_connection *conn = data; struct gsm_subscriber *subscr = param; struct paging_signal_data sig_data; + struct bsc_subscr *bsub; + struct gsm_network *net; - OSMO_ASSERT(subscr->is_paging); + OSMO_ASSERT(subscr && subscr->is_paging); + net = subscr->group->net; /* * Stop paging on all other BTS. E.g. if this is @@ -91,7 +94,15 @@ * timeout soon as well. Let's just stop everything * and forget we wanted to page. */ - paging_request_stop(NULL, subscr, NULL, NULL); + + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_have_by_imsi(net->bsc_subscribers, subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + paging_request_stop(&net->bts_list, NULL, bsub, NULL, NULL); + bsc_subscr_put(bsub); /* Inform parts of the system we don't know */ sig_data.subscr = subscr; @@ -169,13 +180,23 @@ { int rc; struct subscr_request *request; + struct bsc_subscr *bsub; + struct gsm_network *net = subscr->group->net; /* Start paging.. we know it is async so we can do it before */ if (!subscr->is_paging) { LOGP(DMM, LOGL_DEBUG, "Subscriber %s not paged yet.\n", subscr_name(subscr)); - rc = paging_request(subscr->group->net, subscr, channel_type, - subscr_paging_cb, subscr); + /* TODO MSC split -- creating a BSC subscriber directly from + * MSC data structures in RAM. At some point the MSC will send + * a message to the BSC instead. */ + bsub = bsc_subscr_have_by_imsi(net->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + rc = paging_request(net, bsub, channel_type, subscr_paging_cb, + subscr); + bsc_subscr_put(bsub); if (rc <= 0) { LOGP(DMM, LOGL_ERROR, "Subscriber %s paging failed: %d\n", subscr_name(subscr), rc); diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 11d9022..947f934 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1034,21 +1035,26 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct gsm_subscriber *vlr_subscr; + struct bsc_subscr *bsc_subscr; struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; if (!tgt) return CMD_WARNING; - subscr = subscr_get_by_imsi(gsmnet->subscr_group, argv[0]); - if (!subscr) { + vlr_subscr = subscr_get_by_imsi(gsmnet->subscr_group, imsi); + bsc_subscr = bsc_subscr_find_by_imsi(gsmnet->bsc_subscribers, imsi); + + if (!vlr_subscr && !bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_vlr_subscr(tgt, vlr_subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index f38c97f..efdc9bd 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -20,9 +20,10 @@ #include #include +#include #include #include -#include +#include #include #include @@ -99,7 +100,7 @@ static int bssmap_handle_paging(struct osmo_msc_data *msc, struct msgb *msg, unsigned int payload_length) { - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; struct tlv_parsed tp; char mi_string[GSM48_MI_SIZE]; uint32_t tmsi = GSM_RESERVED_TMSI; @@ -157,7 +158,8 @@ LOGP(DMSC, LOGL_ERROR, "eMLPP is not handled\n"); } - subscr = subscr_get_or_create(msc->network->subscr_group, mi_string); + subscr = bsc_subscr_have_by_imsi(msc->network->bsc_subscribers, + mi_string); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string); return -1; @@ -167,7 +169,8 @@ subscr->tmsi = tmsi; LOGP(DMSC, LOGL_INFO, "Paging request from MSC IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n", mi_string, tmsi, tmsi, lac); - bsc_grace_paging_request(subscr, chan_needed, msc); + bsc_grace_paging_request(msc->network->bsc_data->rf_ctrl->policy, + subscr, chan_needed, msc); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index d5ca2fd..8301bfb 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -54,14 +55,14 @@ } /* extract a subscriber from the paging response */ -static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn, - struct msgb *msg) +static struct bsc_subscr *extract_sub(struct gsm_subscriber_connection *conn, + struct msgb *msg) { uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm48_hdr *gh; struct gsm48_pag_resp *resp; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*resp)) { LOGP(DMSC, LOGL_ERROR, "PagingResponse too small: %u\n", msgb_l3len(msg)); @@ -78,12 +79,12 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = bsc_subscr_find_by_tmsi(conn->network->bsc_subscribers, + tmsi_from_string(mi_string)); break; case GSM_MI_TYPE_IMSI: - subscr = subscr_active_by_imsi(conn->bts->network->subscr_group, - mi_string); + subscr = bsc_subscr_find_by_imsi(conn->network->bsc_subscribers, + mi_string); break; default: subscr = NULL; @@ -96,15 +97,16 @@ /* we will need to stop the paging request */ static int handle_page_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct gsm_subscriber *subscr = extract_sub(conn, msg); + struct bsc_subscr *subscr = extract_sub(conn, msg); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Non active subscriber got paged.\n"); return -1; } - paging_request_stop(conn->bts, subscr, conn, msg); - subscr_put(subscr); + paging_request_stop(&conn->network->bts_list, conn->bts, subscr, conn, + msg); + bsc_subscr_put(subscr); return 0; } @@ -130,7 +132,7 @@ uint8_t mtype; struct osmo_bsc_data *bsc; struct osmo_msc_data *msc, *pag_msc; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; int is_emerg = 0; bsc = conn->bts->network->bsc_data; @@ -183,7 +185,7 @@ } pag_msc = paging_get_data(conn->bts, subscr); - subscr_put(subscr); + bsc_subscr_put(subscr); llist_for_each_entry(msc, &bsc->mscs, entry) { if (msc != pag_msc) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 6409a3a..eef88b4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -34,8 +34,8 @@ } -static int normal_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int normal_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { /* we can't page by lac.. we need to page everything */ if (msc->core_lac != -1) { @@ -47,12 +47,11 @@ return 0; } - return paging_request(subscr->group->net, subscr, chan_needed, NULL, - msc); + return paging_request(msc->network, subscr, chan_needed, NULL, msc); } -static int locked_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int locked_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { struct gsm_bts *bts = NULL; @@ -84,10 +83,12 @@ /** * Try to not page if everything the cell is not on. */ -int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc) { - if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON) + if (rf_policy == S_RF_ON) return normal_paging(subscr, chan_needed, msc); return locked_paging(subscr, chan_needed, msc); } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 86ccec4..9171968 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -861,20 +861,19 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct bsc_subscr *bsc_subscr; struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; - if (!tgt) - return CMD_WARNING; + bsc_subscr = bsc_subscr_find_by_imsi(bsc_gsmnet->bsc_subscribers, imsi); - subscr = subscr_get_or_create(bsc_gsmnet->subscr_group, argv[0]); - if (!subscr) { + if (!bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", - argv[0], VTY_NEWLINE); + imsi, VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am index 5e9583f..ca470ac 100644 --- a/openbsc/tests/channel/Makefile.am +++ b/openbsc/tests/channel/Makefile.am @@ -24,8 +24,8 @@ $(NULL) channel_test_LDADD = \ - $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) \ diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index c69c701..88293d0 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -49,7 +49,7 @@ } /* mock object for testing, directly invoke the cb... maybe later through the timer */ -int paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data) +int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { s_data = data; s_cbfn = cbfn; @@ -72,6 +72,7 @@ exit(1); bts = gsm_bts_alloc(network); bts->location_area_code = 23; + s_conn.network = network; /* Create a dummy subscriber */ struct gsm_subscriber *subscr = subscr_alloc(); diff --git a/openbsc/tests/subscr/Makefile.am b/openbsc/tests/subscr/Makefile.am index ad8b20c..0d6b582 100644 --- a/openbsc/tests/subscr/Makefile.am +++ b/openbsc/tests/subscr/Makefile.am @@ -19,10 +19,12 @@ EXTRA_DIST = \ subscr_test.ok \ + bsc_subscr_test.ok \ $(NULL) noinst_PROGRAMS = \ subscr_test \ + bsc_subscr_test \ $(NULL) subscr_test_SOURCES = \ @@ -40,3 +42,19 @@ $(LIBSMPP34_LIBS) \ $(LIBOSMOVTY_LIBS) \ $(NULL) + +bsc_subscr_test_SOURCES = \ + bsc_subscr_test.c \ + $(NULL) + +bsc_subscr_test_LDADD = \ + $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ + $(top_builddir)/src/libtrau/libtrau.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOABIS_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBSMPP34_LIBS) \ + $(LIBOSMOVTY_LIBS) \ + $(NULL) diff --git a/openbsc/tests/subscr/bsc_subscr_test.c b/openbsc/tests/subscr/bsc_subscr_test.c new file mode 100644 index 0000000..43de723 --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.c @@ -0,0 +1,130 @@ +/* (C) 2008 by Jan Luebbe + * (C) 2009 by Holger Hans Peter Freyther + * (C) 2014 by Alexander Chemeris + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include + +#include +#include +#include +#include + +struct llist_head *bsc_subscribers; + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi) +{ + struct bsc_subscr *sfound; + OSMO_ASSERT(bsub); + OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0); + + sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi); + OSMO_ASSERT(sfound == bsub); + + bsc_subscr_put(sfound); +} + +static void test_bsc_subscr(void) +{ + struct bsc_subscr *s1, *s2, *s3; + const char *imsi1 = "1234567890"; + const char *imsi2 = "9876543210"; + const char *imsi3 = "5656565656"; + + printf("Test BSC subscriber allocation and deletion\n"); + + /* Check for emptiness */ + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + /* Allocate entry 1 */ + s1 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + assert_bsc_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + + /* Allocate entry 2 */ + s2 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi2); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + + /* Allocate entry 3 */ + s3 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi3); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d"); + + /* Check entries */ + assert_bsc_subscr(s1, imsi1); + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 1 */ + bsc_subscr_put(s1); + s1 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 2 */ + bsc_subscr_put(s2); + s2 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 3 */ + bsc_subscr_put(s3); + s3 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + OSMO_ASSERT(llist_empty(bsc_subscribers)); +} + +int main() +{ + printf("Testing BSC subscriber core code.\n"); + osmo_init_logging(&log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + log_set_category_filter(osmo_stderr_target, DREF, 1, LOGL_DEBUG); + + bsc_subscribers = talloc_zero(NULL, struct llist_head); + INIT_LLIST_HEAD(bsc_subscribers); + + test_bsc_subscr(); + + printf("Done\n"); + return 0; +} diff --git a/openbsc/tests/subscr/bsc_subscr_test.err b/openbsc/tests/subscr/bsc_subscr_test.err new file mode 100644 index 0000000..a66317a --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.err @@ -0,0 +1,17 @@ +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage decreases to: 0 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage decreases to: 0 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage decreases to: 0 diff --git a/openbsc/tests/subscr/bsc_subscr_test.ok b/openbsc/tests/subscr/bsc_subscr_test.ok new file mode 100644 index 0000000..0f6a8be --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.ok @@ -0,0 +1,11 @@ +Testing BSC subscriber core code. +Test BSC subscriber allocation and deletion +llist_count(bsc_subscribers) == 0 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 3 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 0 +Done diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 01737a3..280aeb2 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -13,6 +13,13 @@ AT_CHECK([$abs_top_builddir/tests/subscr/subscr_test], [], [expout], [ignore]) AT_CLEANUP +AT_SETUP([bsc_subscr]) +AT_KEYWORDS([bsc_subscr]) +cat $abs_srcdir/subscr/bsc_subscr_test.ok > expout +cat $abs_srcdir/subscr/bsc_subscr_test.err > experr +AT_CHECK([$abs_top_builddir/tests/subscr/bsc_subscr_test], [], [expout], [experr]) +AT_CLEANUP + AT_SETUP([db]) AT_KEYWORDS([db]) cat $abs_srcdir/db/db_test.ok > expout -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 01:58:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 01:58:38 +0000 Subject: [PATCH] openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1684 to look at the new patch set (#7). add struct gprs_subscr, separating gprs from gsm_subscriber Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will not make sense to be used in gprs, so have a dedicated GPRS subscriber struct. (Could change if the gprs code were to use libvlr; is currently independent). Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Related: #1592 --- M openbsc/include/openbsc/Makefile.am M openbsc/include/openbsc/gprs_sgsn.h A openbsc/include/openbsc/gprs_subscriber.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/gsm_subscriber.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/src/gprs/gprs_subscriber.c M openbsc/src/gprs/sgsn_auth.c M openbsc/src/gprs/sgsn_libgtp.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c M openbsc/tests/sgsn/sgsn_test.ok 13 files changed, 268 insertions(+), 150 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/84/1684/7 diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 2466ce8..c10accd 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -31,6 +31,7 @@ gprs_sndcp_dcomp.h \ gprs_sndcp_pcomp.h \ gprs_sndcp_xid.h \ + gprs_subscriber.h \ gprs_utils.h \ gsm_04_08.h \ gsm_04_11.h \ diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 2cc5b0c..c3cac7f 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -18,7 +18,7 @@ struct gprs_llc_lle; struct ctrl_handle; -struct gsm_subscriber; +struct gprs_subscr; enum gsm48_gsm_cause; @@ -225,7 +225,7 @@ /* the current GGSN look-up operation */ struct sgsn_ggsn_lookup *ggsn_lookup; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; }; #define LOGMMCTXP(level, mm, fmt, args...) \ @@ -433,6 +433,7 @@ /* * GPRS subscriber data */ +#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001 #define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16) #define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17) #define GPRS_SUBSCRIBER_CANCELLED (1 << 18) @@ -446,13 +447,13 @@ int gprs_subscr_init(struct sgsn_instance *sgi); int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx); -void gprs_subscr_cleanup(struct gsm_subscriber *subscr); -struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi); -struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); -struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi); -void gprs_subscr_cancel(struct gsm_subscriber *subscr); -void gprs_subscr_update(struct gsm_subscriber *subscr); -void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr); +void gprs_subscr_cleanup(struct gprs_subscr *subscr); +struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi); +struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); +struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi); +void gprs_subscr_cancel(struct gprs_subscr *subscr); +void gprs_subscr_update(struct gprs_subscr *subscr); +void gprs_subscr_update_auth_info(struct gprs_subscr *subscr); int gprs_subscr_rx_gsup_message(struct msgb *msg); /* Called on subscriber data updates */ diff --git a/openbsc/include/openbsc/gprs_subscriber.h b/openbsc/include/openbsc/gprs_subscriber.h new file mode 100644 index 0000000..be78feb --- /dev/null +++ b/openbsc/include/openbsc/gprs_subscriber.h @@ -0,0 +1,31 @@ +/* GPRS subscriber details for use in SGSN land */ +#pragma once + +#include + +#include +#include + +extern struct llist_head * const gprs_subscribers; + +struct gprs_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + char imei[GSM23003_IMEISV_NUM_DIGITS+1]; + bool authorized; + bool keep_in_ram; + uint32_t flags; + uint16_t lac; + + struct sgsn_subscriber_data *sgsn_data; +}; + +struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub, + const char *file, int line); +struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, + const char *file, int line); +#define gprs_subscr_get(gsub) _gprs_subscr_get(gsub, __BASE_FILE__, __LINE__) +#define gprs_subscr_put(gsub) _gprs_subscr_put(gsub, __BASE_FILE__, __LINE__) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index ac573c4..460953e 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -26,6 +26,8 @@ #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] +#define tmsi_from_string(str) strtoul(str, NULL, 10) + enum gsm_security_event { GSM_SECURITY_NOAVAIL, GSM_SECURITY_AUTH_FAILED, diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 314d619..7e65614 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -16,7 +16,6 @@ #define GSM_SUBSCRIBER_FIRST_CONTACT 0x00000001 /* gprs_sgsn.h defines additional flags including and above bit 16 (0x10000) */ -#define tmsi_from_string(str) strtoul(str, NULL, 10) #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 1026474..9efe402 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 260e032..727524e 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -321,9 +321,9 @@ /* Detach from subscriber which is possibly freed then */ if (mm->subscr) { - struct gsm_subscriber *subscr = subscr_get(mm->subscr); + struct gprs_subscr *subscr = gprs_subscr_get(mm->subscr); gprs_subscr_cleanup(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); } sgsn_mm_ctx_free(mm); diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index d3e2ea7..fb0c471 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include #include #include @@ -35,6 +36,7 @@ #include #include +#include #define SGSN_SUBSCR_MAX_RETRIES 3 #define SGSN_SUBSCR_RETRY_INTERVAL 10 @@ -45,6 +47,9 @@ ## args) extern void *tall_bsc_ctx; + +LLIST_HEAD(_gprs_subscribers); +struct llist_head * const gprs_subscribers = &_gprs_subscribers; static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg); @@ -86,7 +91,7 @@ return rc; } -int gprs_subscr_purge(struct gsm_subscriber *subscr); +int gprs_subscr_purge(struct gprs_subscr *subscr); static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx) { @@ -117,28 +122,53 @@ return pdata; } -struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi) +struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi) { - struct gsm_subscriber *subscr; + struct gprs_subscr *gsub; - subscr = subscr_get_or_create(NULL, imsi); - if (!subscr) + if (!imsi || !*imsi) return NULL; - if (!subscr->sgsn_data) - subscr->sgsn_data = sgsn_subscriber_data_alloc(subscr); - return subscr; + llist_for_each_entry(gsub, gprs_subscribers, entry) { + if (!strcmp(gsub->imsi, imsi)) + return gprs_subscr_get(gsub); + } + return NULL; } -struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi) +static struct gprs_subscr *gprs_subscr_alloc(void) { - return subscr_active_by_imsi(NULL, imsi); + struct gprs_subscr *gsub; + gsub = talloc_zero(tall_bsc_ctx, struct gprs_subscr); + if (!gsub) + return NULL; + llist_add_tail(&gsub->entry, gprs_subscribers); + gsub->use_count = 1; + gsub->tmsi = GSM_RESERVED_TMSI; + return gsub; } -void gprs_subscr_cleanup(struct gsm_subscriber *subscr) +struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi) +{ + struct gprs_subscr *gsub; + + gsub = gprs_subscr_get_by_imsi(imsi); + if (!gsub) { + gsub = gprs_subscr_alloc(); + if (!gsub) + return NULL; + strncpy(gsub->imsi, imsi, sizeof(gsub->imsi)); + } + + if (!gsub->sgsn_data) + gsub->sgsn_data = sgsn_subscriber_data_alloc(gsub); + return gsub; +} + +void gprs_subscr_cleanup(struct gprs_subscr *subscr) { if (subscr->sgsn_data->mm) { - subscr_put(subscr->sgsn_data->mm->subscr); + gprs_subscr_put(subscr->sgsn_data->mm->subscr); subscr->sgsn_data->mm->subscr = NULL; subscr->sgsn_data->mm = NULL; } @@ -149,7 +179,7 @@ } } -void gprs_subscr_cancel(struct gsm_subscriber *subscr) +void gprs_subscr_cancel(struct gprs_subscr *subscr) { subscr->authorized = 0; subscr->flags |= GPRS_SUBSCRIBER_CANCELLED; @@ -159,7 +189,7 @@ gprs_subscr_cleanup(subscr); } -static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr, +static int gprs_subscr_tx_gsup_message(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct msgb *msg = gsup_client_msgb_alloc(); @@ -181,7 +211,7 @@ return gsup_client_send(sgsn->gsup_client, msg); } -static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr, +static int gprs_subscr_tx_gsup_error_reply(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_orig, enum gsm48_gmm_cause cause) { @@ -196,7 +226,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); } -static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_auth_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { unsigned idx; @@ -235,7 +265,7 @@ return 0; } -static int gprs_subscr_pdp_data_clear(struct gsm_subscriber *subscr) +static int gprs_subscr_pdp_data_clear(struct gprs_subscr *subscr) { struct sgsn_subscriber_pdp_data *pdp, *pdp2; int count = 0; @@ -250,7 +280,7 @@ } static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id( - struct gsm_subscriber *subscr, unsigned context_id) + struct gprs_subscr *subscr, unsigned context_id) { struct sgsn_subscriber_pdp_data *pdp; @@ -263,7 +293,7 @@ } -static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr, +static void gprs_subscr_gsup_insert_data(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct sgsn_subscriber_data *sdata = subscr->sgsn_data; @@ -340,7 +370,7 @@ } } -static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_upd_loc_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { /* contrary to MAP, we allow piggy-backing subscriber data onto @@ -357,7 +387,7 @@ return 0; } -static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_isd_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -389,7 +419,7 @@ } } -static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_auth_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { unsigned idx; @@ -442,7 +472,7 @@ return -gsup_msg->cause; } -static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_upd_loc_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { int cause_err; @@ -503,7 +533,7 @@ return 0; } -static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_purge_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n"); @@ -515,7 +545,7 @@ return 0; } -static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_purge_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { LOGGSUBSCRP(LOGL_NOTICE, subscr, @@ -548,7 +578,7 @@ return -gsup_msg->cause; } -static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_loc_cancel_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -609,7 +639,7 @@ int rc = 0; struct osmo_gsup_message gsup_msg = {0}; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; rc = osmo_gsup_decode(data, data_len, &gsup_msg); if (rc < 0) { @@ -699,12 +729,12 @@ break; }; - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } -int gprs_subscr_purge(struct gsm_subscriber *subscr) +int gprs_subscr_purge(struct gprs_subscr *subscr) { struct sgsn_subscriber_data *sdata = subscr->sgsn_data; struct osmo_gsup_message gsup_msg = {0}; @@ -720,7 +750,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr) +int gprs_subscr_query_auth_info(struct gprs_subscr *subscr) { struct osmo_gsup_message gsup_msg = {0}; @@ -731,7 +761,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_location_update(struct gsm_subscriber *subscr) +int gprs_subscr_location_update(struct gprs_subscr *subscr) { struct osmo_gsup_message gsup_msg = {0}; @@ -742,60 +772,59 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -void gprs_subscr_update(struct gsm_subscriber *subscr) +void gprs_subscr_update(struct gprs_subscr *subscr) { LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber data\n"); subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; - subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags &= ~GPRS_SUBSCRIBER_FIRST_CONTACT; if (subscr->sgsn_data->mm) sgsn_update_subscriber_data(subscr->sgsn_data->mm); } -void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr) +void gprs_subscr_update_auth_info(struct gprs_subscr *subscr) { LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber authentication info\n"); subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; - subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags &= ~GPRS_SUBSCRIBER_FIRST_CONTACT; if (subscr->sgsn_data->mm) sgsn_update_subscriber_data(subscr->sgsn_data->mm); } -struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) +struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; if (mmctx->subscr) - return subscr_get(mmctx->subscr); + return gprs_subscr_get(mmctx->subscr); if (mmctx->imsi[0]) subscr = gprs_subscr_get_by_imsi(mmctx->imsi); if (!subscr) { subscr = gprs_subscr_get_or_create(mmctx->imsi); - subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE; } - osmo_strlcpy(subscr->equipment.imei, mmctx->imei, - sizeof(subscr->equipment.imei)); + osmo_strlcpy(subscr->imei, mmctx->imei, sizeof(subscr->imei)); if (subscr->lac != mmctx->ra.lac) subscr->lac = mmctx->ra.lac; subscr->sgsn_data->mm = mmctx; - mmctx->subscr = subscr_get(subscr); + mmctx->subscr = gprs_subscr_get(subscr); return subscr; } int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; int rc; LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n"); @@ -805,13 +834,13 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; rc = gprs_subscr_location_update(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; int rc; LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n"); @@ -821,6 +850,40 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; rc = gprs_subscr_query_auth_info(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } + +static void gprs_subscr_free(struct gprs_subscr *gsub) +{ + llist_del(&gsub->entry); + talloc_free(gsub); +} + +struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub, + const char *file, int line) +{ + OSMO_ASSERT(gsub->use_count < INT_MAX); + gsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "subscr %s usage increases to: %d\n", + gsub->imsi, gsub->use_count); + return gsub; +} + +struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, + const char *file, int line) +{ + gsub->use_count--; + LOGPSRC(DREF, gsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "subscr %s usage decreases to: %d%s\n", + gsub->imsi, gsub->use_count, + gsub->keep_in_ram? ", keep-in-ram flag is set" : ""); + if (gsub->use_count > 0) + return gsub; + if (gsub->keep_in_ram) + return gsub; + gprs_subscr_free(gsub); + return NULL; +} diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index 1fa7fc4..df7ee37 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include const struct value_string auth_state_names[] = { @@ -151,7 +151,7 @@ */ int sgsn_auth_request(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; struct gsm_auth_tuple *at; int need_update_location; int rc; @@ -169,7 +169,7 @@ /* This has the side effect of registering the subscr with the mmctx */ subscr = gprs_subscr_get_or_create_by_mmctx(mmctx); - subscr_put(subscr); + gprs_subscr_put(subscr); OSMO_ASSERT(mmctx->subscr != NULL); @@ -207,7 +207,7 @@ void sgsn_auth_update(struct sgsn_mm_ctx *mmctx) { enum sgsn_auth_state auth_state; - struct gsm_subscriber *subscr = mmctx->subscr; + struct gprs_subscr *subscr = mmctx->subscr; struct gsm_auth_tuple *at; int gmm_cause; diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 062de44..dde1e5e 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #ifdef BUILD_IU diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 3ce054f..a730635 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -657,40 +657,37 @@ } /* Subscriber */ -#include +#include -static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr, int pending) +static void subscr_dump_full_vty(struct vty *vty, struct gprs_subscr *gsub, int pending) { +#if 0 char expire_time[200]; +#endif struct gsm_auth_tuple *at; int at_idx; struct sgsn_subscriber_pdp_data *pdp; - vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, - subscr->authorized, VTY_NEWLINE); - if (strlen(subscr->name)) - vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); - if (strlen(subscr->extension)) - vty_out(vty, " Extension: %s%s", subscr->extension, - VTY_NEWLINE); + vty_out(vty, " Authorized: %d%s", + gsub->authorized, VTY_NEWLINE); vty_out(vty, " LAC: %d/0x%x%s", - subscr->lac, subscr->lac, VTY_NEWLINE); - vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); - if (subscr->tmsi != GSM_RESERVED_TMSI) - vty_out(vty, " TMSI: %08X%s", subscr->tmsi, + gsub->lac, gsub->lac, VTY_NEWLINE); + vty_out(vty, " IMSI: %s%s", gsub->imsi, VTY_NEWLINE); + if (gsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: %08X%s", gsub->tmsi, VTY_NEWLINE); - if (subscr->sgsn_data->msisdn_len > 0) + if (gsub->sgsn_data->msisdn_len > 0) vty_out(vty, " MSISDN (BCD): %s%s", - osmo_hexdump(subscr->sgsn_data->msisdn, - subscr->sgsn_data->msisdn_len), + osmo_hexdump(gsub->sgsn_data->msisdn, + gsub->sgsn_data->msisdn_len), VTY_NEWLINE); - if (strlen(subscr->equipment.imei) > 0) - vty_out(vty, " IMEI: %s%s", subscr->equipment.imei, VTY_NEWLINE); + if (strlen(gsub->imei) > 0) + vty_out(vty, " IMEI: %s%s", gsub->imei, VTY_NEWLINE); - for (at_idx = 0; at_idx < ARRAY_SIZE(subscr->sgsn_data->auth_triplets); + for (at_idx = 0; at_idx < ARRAY_SIZE(gsub->sgsn_data->auth_triplets); at_idx++) { - at = &subscr->sgsn_data->auth_triplets[at_idx]; + at = &gsub->sgsn_data->auth_triplets[at_idx]; if (at->key_seq == GSM_KEY_SEQ_INVAL) continue; @@ -722,36 +719,38 @@ } } - llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) { + llist_for_each_entry(pdp, &gsub->sgsn_data->pdp_list, list) { vty_out(vty, " PDP info: Id: %d, Type: 0x%04x, APN: '%s' QoS: %s%s", pdp->context_id, pdp->pdp_type, pdp->apn_str, osmo_hexdump(pdp->qos_subscribed, pdp->qos_subscribed_len), VTY_NEWLINE); } +#if 0 /* print the expiration time of a subscriber */ - if (subscr->expire_lu) { + if (gsub->expire_lu) { strftime(expire_time, sizeof(expire_time), - "%a, %d %b %Y %T %z", localtime(&subscr->expire_lu)); + "%a, %d %b %Y %T %z", localtime(&gsub->expire_lu)); expire_time[sizeof(expire_time) - 1] = '\0'; vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE); } +#endif - if (subscr->flags) + if (gsub->flags) vty_out(vty, " Flags: %s%s%s%s%s%s", - subscr->flags & GSM_SUBSCRIBER_FIRST_CONTACT ? + gsub->flags & GPRS_SUBSCRIBER_FIRST_CONTACT ? "FIRST_CONTACT " : "", - subscr->flags & GPRS_SUBSCRIBER_CANCELLED ? + gsub->flags & GPRS_SUBSCRIBER_CANCELLED ? "CANCELLED " : "", - subscr->flags & GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING ? + gsub->flags & GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING ? "UPDATE_LOCATION_PENDING " : "", - subscr->flags & GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING ? + gsub->flags & GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING ? "AUTH_INFO_PENDING " : "", - subscr->flags & GPRS_SUBSCRIBER_ENABLE_PURGE ? + gsub->flags & GPRS_SUBSCRIBER_ENABLE_PURGE ? "ENABLE_PURGE " : "", VTY_NEWLINE); - vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); + vty_out(vty, " Use count: %u%s", gsub->use_count, VTY_NEWLINE); } DEFUN(show_subscr_cache, @@ -760,9 +759,9 @@ SHOW_STR "Show information about subscribers\n" "Display contents of subscriber cache\n") { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; - llist_for_each_entry(subscr, &active_subscribers, entry) { + llist_for_each_entry(subscr, gprs_subscribers, entry) { vty_out(vty, " Subscriber:%s", VTY_NEWLINE); subscr_dump_full_vty(vty, subscr, 0); } @@ -794,7 +793,7 @@ const char *kc_str = argv[4]; struct gsm_auth_tuple at = {0,}; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -825,12 +824,12 @@ subscr->sgsn_data->auth_triplets[cksn] = at; subscr->sgsn_data->auth_triplets_updated = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; failed: - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -844,7 +843,7 @@ const char *imsi = argv[0]; const char *cancel_type = argv[1]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -859,7 +858,7 @@ subscr->sgsn_data->error_cause = GMM_CAUSE_IMPL_DETACHED; gprs_subscr_cancel(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -871,7 +870,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (subscr) { @@ -882,7 +881,7 @@ subscr = gprs_subscr_get_or_create(imsi); subscr->keep_in_ram = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -894,7 +893,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -909,7 +908,7 @@ if (subscr->use_count > 1) vty_out(vty, "%% subscriber is still in use%s", VTY_NEWLINE); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -934,7 +933,7 @@ const char *imsi = argv[0]; const char *ret_code_str = argv[1]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; const struct value_string cause_mapping[] = { { GMM_CAUSE_NET_FAIL, "system-failure" }, @@ -963,7 +962,7 @@ gprs_subscr_update(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -975,7 +974,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -986,7 +985,7 @@ gprs_subscr_update_auth_info(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 0aa142f..44c886c 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -248,7 +248,7 @@ cleanup_test(); } -struct gsm_subscriber *last_updated_subscr = NULL; +struct gprs_subscr *last_updated_subscr = NULL; void my_dummy_sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx) { OSMO_ASSERT(mmctx); @@ -257,23 +257,23 @@ last_updated_subscr = mmctx->subscr; } -static void assert_subscr(const struct gsm_subscriber *subscr, const char *imsi) +static void assert_subscr(const struct gprs_subscr *subscr, const char *imsi) { - struct gsm_subscriber *sfound; + struct gprs_subscr *sfound; OSMO_ASSERT(subscr); OSMO_ASSERT(strcmp(subscr->imsi, imsi) == 0); sfound = gprs_subscr_get_by_imsi(imsi); OSMO_ASSERT(sfound == subscr); - subscr_put(sfound); + gprs_subscr_put(sfound); } static void show_subscrs(FILE *out) { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; - llist_for_each_entry(subscr, &active_subscribers, entry) { + llist_for_each_entry(subscr, gprs_subscribers, entry) { fprintf(out, " Subscriber: %s, " "use count: %d\n", subscr->imsi, subscr->use_count); @@ -284,12 +284,18 @@ { show_subscrs(stdout); fflush(stdout); - OSMO_ASSERT(llist_empty(&active_subscribers)); + OSMO_ASSERT(llist_empty(gprs_subscribers)); } + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); static void test_subscriber(void) { - struct gsm_subscriber *s1, *s2, *s3, *sfound; + struct gprs_subscr *s1, *s2, *s3; const char *imsi1 = "1234567890"; const char *imsi2 = "9876543210"; const char *imsi3 = "5656565656"; @@ -302,19 +308,24 @@ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d"); /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; assert_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); /* Allocate entry 2 */ s2 = gprs_subscr_get_or_create(imsi2); - s2->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d"); + s2->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; /* Allocate entry 3 */ s3 = gprs_subscr_get_or_create(imsi3); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 3, "%d"); /* Check entries */ assert_subscr(s1, imsi1); @@ -326,33 +337,35 @@ gprs_subscr_update(s1); OSMO_ASSERT(last_updated_subscr == NULL); OSMO_ASSERT(s1->sgsn_data->mm == NULL); - OSMO_ASSERT((s1->flags & GSM_SUBSCRIBER_FIRST_CONTACT) == 0); + OSMO_ASSERT((s1->flags & GPRS_SUBSCRIBER_FIRST_CONTACT) == 0); /* There is no subscriber cache. Verify it */ gprs_subscr_cleanup(s1); - subscr_put(s1); + gprs_subscr_put(s1); s1 = NULL; - sfound = gprs_subscr_get_by_imsi(imsi1); - OSMO_ASSERT(sfound == NULL); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d"); + OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); assert_subscr(s2, imsi2); assert_subscr(s3, imsi3); - /* Free entry 2 (GSM_SUBSCRIBER_FIRST_CONTACT is set) */ + /* Free entry 2 (GPRS_SUBSCRIBER_FIRST_CONTACT is set) */ gprs_subscr_cleanup(s2); - subscr_put(s2); + gprs_subscr_put(s2); s2 = NULL; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); assert_subscr(s3, imsi3); /* Try to delete entry 3 */ gprs_subscr_cleanup(s3); - subscr_put(s3); + gprs_subscr_put(s3); s3 = NULL; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL); - OSMO_ASSERT(llist_empty(&active_subscribers)); + OSMO_ASSERT(llist_empty(gprs_subscribers)); update_subscriber_data_cb = __real_sgsn_update_subscriber_data; @@ -361,7 +374,7 @@ static void test_auth_triplets(void) { - struct gsm_subscriber *s1, *s1found; + struct gprs_subscr *s1, *s1found; const char *imsi1 = "1234567890"; struct gsm_auth_tuple *at; struct sgsn_mm_ctx *ctx; @@ -375,17 +388,17 @@ /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == s1); - subscr_put(s1found); + gprs_subscr_put(s1found); /* Create a context */ OSMO_ASSERT(count(gprs_llme_list()) == 0); ctx = alloc_mm_ctx(local_tlli, &raid); /* Attach s1 to ctx */ - ctx->subscr = subscr_get(s1); + ctx->subscr = gprs_subscr_get(s1); ctx->subscr->sgsn_data->mm = ctx; /* Try to get auth tuple */ @@ -414,7 +427,7 @@ OSMO_ASSERT(at == NULL); /* Free MM context and subscriber */ - subscr_put(s1); + gprs_subscr_put(s1); sgsn_mm_ctx_cleanup_free(ctx); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); @@ -441,7 +454,7 @@ static void test_subscriber_gsup(void) { - struct gsm_subscriber *s1, *s1found; + struct gprs_subscr *s1, *s1found; const char *imsi1 = "1234567890"; struct sgsn_mm_ctx *ctx; struct gprs_ra_id raid = { 0, }; @@ -563,17 +576,17 @@ /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == s1); - subscr_put(s1found); + gprs_subscr_put(s1found); /* Create a context */ OSMO_ASSERT(count(gprs_llme_list()) == 0); ctx = alloc_mm_ctx(local_tlli, &raid); /* Attach s1 to ctx */ - ctx->subscr = subscr_get(s1); + ctx->subscr = gprs_subscr_get(s1); ctx->subscr->sgsn_data->mm = ctx; /* Inject SendAuthInfoReq GSUP message */ @@ -674,7 +687,7 @@ /* Free MM context and subscriber */ OSMO_ASSERT(ctx->subscr == NULL); sgsn_mm_ctx_cleanup_free(ctx); - subscr_put(s1); + gprs_subscr_put(s1); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); @@ -1089,7 +1102,7 @@ static void test_gmm_attach_subscr(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1100,7 +1113,7 @@ printf("Auth policy 'remote': "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1123,7 +1136,7 @@ static void test_gmm_attach_subscr_fake_auth(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1136,7 +1149,7 @@ printf("Auth policy 'remote', auth faked: "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1165,7 +1178,7 @@ static void test_gmm_attach_subscr_real_auth(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1179,7 +1192,7 @@ printf("Auth policy 'remote', triplet based auth: "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1253,7 +1266,7 @@ static void test_gmm_attach_subscr_gsup_auth(int retry) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_gsup_auth; @@ -1267,7 +1280,7 @@ subscr->authorized = 1; sgsn->cfg.require_authentication = 1; sgsn->cfg.require_update_location = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); printf("Auth policy 'remote', GSUP based auth: "); test_gmm_attach(retry); @@ -1336,7 +1349,7 @@ static void test_gmm_attach_subscr_real_gsup_auth(int retry) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; gsup_client_send_cb = my_gsup_client_send; @@ -2227,7 +2240,7 @@ { struct apn_ctx *actxs[4]; struct sgsn_ggsn_ctx *ggc, *ggcs[3]; - struct gsm_subscriber *s1; + struct gprs_subscr *s1; const char *imsi1 = "1234567890"; struct sgsn_mm_ctx *ctx; struct gprs_ra_id raid = { 0, }; @@ -2346,7 +2359,7 @@ /* Cleanup */ - subscr_put(s1); + gprs_subscr_put(s1); sgsn_mm_ctx_cleanup_free(ctx); assert_no_subscrs(); diff --git a/openbsc/tests/sgsn/sgsn_test.ok b/openbsc/tests/sgsn/sgsn_test.ok index c7a53b9..f38d730 100644 --- a/openbsc/tests/sgsn/sgsn_test.ok +++ b/openbsc/tests/sgsn/sgsn_test.ok @@ -1,5 +1,13 @@ Testing LLME allocations Testing core subscriber data API +llist_count(gprs_subscribers) == 0 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 2 +llist_count(gprs_subscribers) == 3 +llist_count(gprs_subscribers) == 2 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 0 Testing authentication triplet handling Testing subscriber GSUP handling Testing GMM detach -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 7 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 02:00:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 02:00:32 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 5: -Code-Review depends on topic logging_filter patches -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 02:00:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 02:00:50 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 7: depends on topic logging_filter patches -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 7 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 02:02:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 02:02:01 +0000 Subject: [ABANDON] openbsc[master]: Introduce subscriber_connection ref-counting In-Reply-To: References: Message-ID: Neels Hofmeyr has abandoned this change. Change subject: Introduce subscriber_connection ref-counting ...................................................................... Abandoned this may or may not come back from the vlr branch -- To view, visit https://gerrit.osmocom.org/1681 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I8c05e6c81f246ff8b5bf91312f80410b1a85f15e Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:51:09 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:51:09 +0000 Subject: openbsc[master]: subscr_update_expire_lu(): fix (obscure) segfault In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1850 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:52:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:52:38 +0000 Subject: openbsc[master]: remove compiler warning: unused rc in vty_interface_layer3 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1849 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:52:48 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:52:48 +0000 Subject: [MERGED] openbsc[master]: remove compiler warning: unused rc in vty_interface_layer3 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: remove compiler warning: unused rc in vty_interface_layer3 ...................................................................... remove compiler warning: unused rc in vty_interface_layer3 Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280 --- M openbsc/src/libmsc/vty_interface_layer3.c 1 file changed, 0 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 11d9022..ddec2e3 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -517,7 +517,6 @@ "subscriber " SUBSCR_TYPES " ID expire", SUBSCR_HELP "Expire the subscriber Now\n") { - int rc; struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); -- To view, visit https://gerrit.osmocom.org/1849 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:53:11 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:53:11 +0000 Subject: libosmocore[master]: fix: gprs_bssgp_vty: logging filter: wrong constant In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1843 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic1cc268ed20700698c93d3ff8bf85cc0f01d3b1b Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:53:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:53:21 +0000 Subject: [MERGED] libosmocore[master]: fix: gprs_bssgp_vty: logging filter: wrong constant In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: fix: gprs_bssgp_vty: logging filter: wrong constant ...................................................................... fix: gprs_bssgp_vty: logging filter: wrong constant Setting the BVC log filter to NULL worked only if the NSVC filter was set, use the proper constant instead. Change-Id: Ic1cc268ed20700698c93d3ff8bf85cc0f01d3b1b --- M src/gb/gprs_bssgp_vty.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 90e5001..1f382a2 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -49,7 +49,7 @@ if (bctx) { target->filter_map |= (1 << FLT_BVC); target->filter_data[FLT_BVC] = bctx; - } else if (target->filter_data[FLT_NSVC]) { + } else if (target->filter_data[FLT_BVC]) { target->filter_map = ~(1 << FLT_BVC); target->filter_data[FLT_BVC] = NULL; } -- To view, visit https://gerrit.osmocom.org/1843 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic1cc268ed20700698c93d3ff8bf85cc0f01d3b1b Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:53:45 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:53:45 +0000 Subject: openbsc[master]: Add support for extended SI2q parameters In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:53:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:53:57 +0000 Subject: [MERGED] openbsc[master]: Add support for extended SI2q parameters In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Add support for extended SI2q parameters ...................................................................... Add support for extended SI2q parameters * add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1 * remove old command which does not support those parameters Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Fixes: RT#8792 --- M openbsc/src/libbsc/bsc_vty.c 1 file changed, 72 insertions(+), 32 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 00acbc7..73acebd 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -541,6 +541,7 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) { int i; + uint8_t tmp; vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); @@ -694,15 +695,23 @@ } for (i = 0; i < MAX_EARFCN_LIST; i++) { - if (bts->si_common.si2quater_neigh_list.arfcn[i] != - OSMO_EARFCN_INVALID) { - vty_out(vty, " si2quater neighbor-list add earfcn %u threshold %u", - bts->si_common.si2quater_neigh_list.arfcn[i], - bts->si_common.si2quater_neigh_list.thresh_hi); - if (bts->si_common.si2quater_neigh_list.meas_bw[i] != - OSMO_EARFCN_MEAS_INVALID) - vty_out(vty, " %u", - bts->si_common.si2quater_neigh_list.meas_bw[i]); + struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; + if (e->arfcn[i] != OSMO_EARFCN_INVALID) { + vty_out(vty, " si2quater neighbor-list add earfcn %u " + "thresh-hi %u", e->arfcn[i], e->thresh_hi); + + vty_out(vty, " thresh-lo %u", + e->thresh_lo_valid ? e->thresh_lo : 32); + + vty_out(vty, " prio %u", + e->prio_valid ? e->prio : 8); + + vty_out(vty, " qrxlv %u", + e->qrxlm_valid ? e->qrxlm : 32); + + tmp = e->meas_bw[i]; + vty_out(vty, " meas %u", + (tmp != OSMO_EARFCN_MEAS_INVALID) ? tmp : 8); vty_out(vty, "%s", VTY_NEWLINE); } @@ -2746,42 +2755,73 @@ return CMD_SUCCESS; } - DEFUN(cfg_bts_si2quater_neigh_add, cfg_bts_si2quater_neigh_add_cmd, - "si2quater neighbor-list add earfcn <0-65535> threshold <0-31> " - "[<0-7>]", "SI2quater Neighbor List\n" - "SI2quater Neighbor List\n" "Add to manual SI2quater neighbor list\n" - "EARFCN of neighbor\n" "EARFCN of neighbor\n" "threshold high bits\n" - "threshold high bits\n" "measurement bandwidth\n") + "si2quater neighbor-list add earfcn <0-65535> thresh-hi <0-31> " + "thresh-lo <0-32> prio <0-8> qrxlv <0-32> meas <0-8>", + "SI2quater Neighbor List\n" "SI2quater Neighbor List\n" + "Add to manual SI2quater neighbor list\n" + "EARFCN of neighbor\n" "EARFCN of neighbor\n" + "threshold high bits\n" "threshold high bits\n" + "threshold low bits\n" "threshold low bits (32 means NA)\n" + "priority\n" "priority (8 means NA)\n" + "QRXLEVMIN\n" "QRXLEVMIN (32 means NA)\n" + "measurement bandwidth\n" "measurement bandwidth (8 means NA)\n") { struct gsm_bts *bts = vty->index; struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list; uint16_t arfcn = atoi(argv[0]); - uint8_t meas = OSMO_EARFCN_MEAS_INVALID, thresh = atoi(argv[1]); - int r; - - if (3 == argc) - meas = atoi(argv[2]); - - r = osmo_earfcn_add(e, arfcn, meas); + uint8_t thresh_hi = atoi(argv[1]), thresh_lo = atoi(argv[2]), + prio = atoi(argv[3]), qrx = atoi(argv[4]), meas = atoi(argv[5]); + int r = osmo_earfcn_add(e, arfcn, + (meas < 8) ? meas : OSMO_EARFCN_MEAS_INVALID); if (r < 0) { - vty_out(vty, "Unable to add arfcn %u: %s%s", arfcn, strerror(-r), + vty_out(vty, "Unable to add ARFCN %u: %s%s", arfcn, strerror(-r), VTY_NEWLINE); return CMD_WARNING; } - if (si2q_size_check(bts)) { - if (e->thresh_hi && thresh != e->thresh_hi) - vty_out(vty, "Warning: multiple thresholds are not " - "supported, overriding previous threshold %u%s", - e->thresh_hi, VTY_NEWLINE); - e->thresh_hi = thresh; - return CMD_SUCCESS; + if (e->thresh_hi && thresh_hi != e->thresh_hi) + vty_out(vty, "Warning: multiple threshold-high are not " + "supported, overriding previous threshold %u%s", + e->thresh_hi, VTY_NEWLINE); + + e->thresh_hi = thresh_hi; + + if (thresh_lo != 32) { + if (e->thresh_lo_valid && e->thresh_lo != thresh_lo) + vty_out(vty, "Warning: multiple threshold-low are not " + "supported, overriding previous threshold %u%s", + e->thresh_lo, VTY_NEWLINE); + e->thresh_lo = thresh_lo; + e->thresh_lo_valid = true; } - vty_out(vty, "Warning: not enough space in si2quater for a given arfcn%s" - , VTY_NEWLINE); + + if (qrx != 32) { + if (e->qrxlm_valid && e->qrxlm != qrx) + vty_out(vty, "Warning: multiple QRXLEVMIN are not " + "supported, overriding previous value %u%s", + e->qrxlm, VTY_NEWLINE); + e->qrxlm = qrx; + e->qrxlm_valid = true; + } + + if (prio != 8) { + if (e->prio_valid && e->prio != prio) + vty_out(vty, "Warning: multiple priorities are not " + "supported, overriding previous value %u%s", + e->prio, VTY_NEWLINE); + e->prio = prio; + e->prio_valid = true; + } + + if (si2q_size_check(bts)) + return CMD_SUCCESS; + + vty_out(vty, "Warning: not enough space in SI2quater for a given EARFCN " + "%u%s", arfcn, VTY_NEWLINE); osmo_earfcn_del(e, arfcn); + return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/1828 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:54:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:54:25 +0000 Subject: libosmocore[master]: Document ctrl_interface_setup_dynip() function In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1842 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:54:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:54:28 +0000 Subject: [MERGED] libosmocore[master]: Document ctrl_interface_setup_dynip() function In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Document ctrl_interface_setup_dynip() function ...................................................................... Document ctrl_interface_setup_dynip() function Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e --- M src/ctrl/control_if.c 1 file changed, 8 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index b4afd55..254f9bc 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -654,6 +654,14 @@ return ctrl_interface_setup_dynip(data, "127.0.0.1", port, lookup); } +/*! \brief Setup CTRL interface on a given address + * \param[in] data Pointer which will be made available to each + set_..() get_..() verify_..() control command function + * \param[in] bind_addr Address on which CTRL socket shall listen + * \param[in] port Port on which CTRL socket shall listen + * \param[in] lookup Lookup function pointer, can be NULL + * \returns ctrl_handle pointer or NULL in case of errors + */ struct ctrl_handle *ctrl_interface_setup_dynip(void *data, const char *bind_addr, uint16_t port, -- To view, visit https://gerrit.osmocom.org/1842 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:54:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:54:58 +0000 Subject: osmo-hlr[master]: Use strings for GSUP message type In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1839 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Idf57a314f5c8cfbd4818600c90020e3ed3decc77 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:55:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:55:04 +0000 Subject: [MERGED] osmo-hlr[master]: Use strings for GSUP message type In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Use strings for GSUP message type ...................................................................... Use strings for GSUP message type Change-Id: Idf57a314f5c8cfbd4818600c90020e3ed3decc77 --- M src/hlr.c 1 file changed, 5 insertions(+), 4 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/hlr.c b/src/hlr.c index 206ddc1..6420cc5 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -510,8 +510,9 @@ { struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); if (!luop) { - LOGP(DMAIN, LOGL_ERROR, "GSUP message %u for " - "unknown IMSI %s\n", gsup.message_type, + LOGP(DMAIN, LOGL_ERROR, "GSUP message %s for " + "unknown IMSI %s\n", + osmo_gsup_message_type_name(gsup.message_type), gsup.imsi); break; } @@ -519,8 +520,8 @@ } break; default: - LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %u\n", - gsup.message_type); + LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n", + osmo_gsup_message_type_name(gsup.message_type)); break; } msgb_free(msg); -- To view, visit https://gerrit.osmocom.org/1839 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idf57a314f5c8cfbd4818600c90020e3ed3decc77 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:55:33 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:55:33 +0000 Subject: osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:57:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:57:04 +0000 Subject: osmo-hlr[master]: Update DB routines In-Reply-To: References: Message-ID: Patch Set 3: Code-Review-1 I think the bind_imsi/remove_reset changes are unrelated to the new database functions, so maybe best to split this up? -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:57:58 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:57:58 +0000 Subject: [MERGED] osmo-hlr[master]: Move lu_operation into separate file In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Move lu_operation into separate file ...................................................................... Move lu_operation into separate file Create luop.(c|h) and move lu_operation and corresponding TX functions there to facilitate re-use in upcoming control interface. Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Related: OS#1645 --- M src/Makefile.am M src/hlr.c A src/luop.c A src/luop.h 4 files changed, 362 insertions(+), 258 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/Makefile.am b/src/Makefile.am index 9bbc13e..56a5670 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ auc.h \ db.h \ + luop.h \ gsup_router.h \ gsup_server.h \ logging.h \ @@ -32,6 +33,7 @@ osmo_hlr_SOURCES = \ auc.c \ db.c \ + luop.c \ db_auc.c \ db_hlr.c \ gsup_router.c \ diff --git a/src/hlr.c b/src/hlr.c index 6420cc5..d74d9fb 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -19,7 +19,7 @@ #include #include - +#include #include #include @@ -38,6 +38,7 @@ #include "gsup_server.h" #include "gsup_router.h" #include "rand.h" +#include "luop.h" #include "hlr_vty.h" static struct db_context *g_dbc; @@ -83,187 +84,9 @@ static LLIST_HEAD(g_lu_ops); -#define CANCEL_TIMEOUT_SECS 30 -#define ISD_TIMEOUT_SECS 30 - -enum lu_state { - LU_S_NULL, - LU_S_LU_RECEIVED, - LU_S_CANCEL_SENT, - LU_S_CANCEL_ACK_RECEIVED, - LU_S_ISD_SENT, - LU_S_ISD_ACK_RECEIVED, - LU_S_COMPLETE, -}; - -static const struct value_string lu_state_names[] = { - { LU_S_NULL, "NULL" }, - { LU_S_LU_RECEIVED, "LU RECEIVED" }, - { LU_S_CANCEL_SENT, "CANCEL SENT" }, - { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, - { LU_S_ISD_SENT, "ISD SENT" }, - { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, - { LU_S_COMPLETE, "COMPLETE" }, - { 0, NULL } -}; - -struct lu_operation { - /*! entry in global list of location update operations */ - struct llist_head list; - /*! to which gsup_server do we belong */ - struct osmo_gsup_server *gsup_server; - /*! state of the location update */ - enum lu_state state; - /*! CS (false) or PS (true) Location Update? */ - bool is_ps; - /*! currently running timer */ - struct osmo_timer_list timer; - - /*! subscriber related to this operation */ - struct hlr_subscriber subscr; - /*! peer VLR/SGSN starting the request */ - uint8_t *peer; -}; - -void lu_op_tx_insert_subscr_data(struct lu_operation *luop); - -void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) -{ - enum lu_state old_state = luop->state; - - DEBUGP(DMAIN, "LU OP state change: %s -> ", - get_value_string(lu_state_names, old_state)); - DEBUGPC(DMAIN, "%s\n", - get_value_string(lu_state_names, new_state)); - - luop->state = new_state; -} - -struct lu_operation *lu_op_by_imsi(const char *imsi) -{ - struct lu_operation *luop; - - llist_for_each_entry(luop, &g_lu_ops, list) { - if (!strcmp(imsi, luop->subscr.imsi)) - return luop; - } - return NULL; -} - -/* Send a msgb to a given address using routing */ -int osmo_gsup_addr_send(struct osmo_gsup_server *gs, - const uint8_t *addr, size_t addrlen, - struct msgb *msg) -{ - struct osmo_gsup_conn *conn; - - conn = gsup_route_find(gs, addr, addrlen); - if (!conn) { - DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); - msgb_free(msg); - return -ENODEV; - } - - return osmo_gsup_conn_send(conn, msg); -} - -/* Transmit a given GSUP message for the given LU operation */ -static void _luop_tx_gsup(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) -{ - struct msgb *msg_out; - - msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); - osmo_gsup_encode(msg_out, gsup); - - osmo_gsup_addr_send(luop->gsup_server, luop->peer, - talloc_total_size(luop->peer), - msg_out); -} - -static inline void fill_gsup_msg(struct osmo_gsup_message *out, - const struct lu_operation *lu, - enum osmo_gsup_message_type mt) -{ - memset(out, 0, sizeof(struct osmo_gsup_message)); - if (lu) - osmo_strlcpy(out->imsi, lu->subscr.imsi, - GSM23003_IMSI_MAX_DIGITS + 1); - out->message_type = mt; -} - -/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ -void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) -{ - struct osmo_gsup_message gsup; - - DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", - luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, - cause)); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); - gsup.cause = cause; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/* timer call-back in case LU operation doesn't receive an response */ -static void lu_op_timer_cb(void *data) -{ - struct lu_operation *luop = data; - - DEBUGP(DMAIN, "LU OP timer expired in state %s\n", - get_value_string(lu_state_names, luop->state)); - - switch (luop->state) { - case LU_S_CANCEL_SENT: - break; - case LU_S_ISD_SENT: - break; - default: - break; - } - - lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); -} - -/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ -void lu_op_tx_ack(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); - //FIXME gsup.hlr_enc; - - _luop_tx_gsup(luop, &gsup); - - llist_del(&luop->list); - talloc_free(luop); -} - -/*! Send Cancel Location to old VLR/SGSN */ -void lu_op_tx_cancel_old(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); - - fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); - //gsup.cause = FIXME; - //gsup.cancel_type = FIXME; - - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_CANCEL_SENT); - osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); -} - /*! Receive Cancel Location Result from old VLR/SGSN */ void lu_op_rx_cancel_old_ack(struct lu_operation *luop, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup) { OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT); /* FIXME: Check for spoofing */ @@ -273,55 +96,6 @@ /* FIXME */ lu_op_tx_insert_subscr_data(luop); -} - -/*! Transmit Insert Subscriber Data to new VLR/SGSN */ -void lu_op_tx_insert_subscr_data(struct lu_operation *luop) -{ - struct osmo_gsup_message gsup; - uint8_t apn[APN_MAXLEN]; - uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ - int l; - - OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || - luop->state == LU_S_CANCEL_ACK_RECEIVED); - - fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); - - l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, - luop->subscr.msisdn); - if (l < 1) { - LOGP(DMAIN, LOGL_ERROR, - "%s: Error: cannot encode MSISDN '%s'\n", - luop->subscr.imsi, luop->subscr.msisdn); - lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); - return; - } - gsup.msisdn_enc = msisdn_enc; - gsup.msisdn_enc_len = l; - - /* FIXME: deal with encoding the following data */ - gsup.hlr_enc; - - if (luop->is_ps) { - /* FIXME: PDP infos - use more fine-grained access control - instead of wildcard APN */ - l = osmo_apn_from_str(apn, sizeof(apn), "*"); - if (l > 0) { - gsup.pdp_infos[0].apn_enc = apn; - gsup.pdp_infos[0].apn_enc_len = l; - gsup.pdp_infos[0].have_info = 1; - gsup.num_pdp_infos = 1; - /* FIXME: use real value: */ - gsup.pdp_infos[0].context_id = 1; - } - } - - /* Send ISD to new VLR/SGSN */ - _luop_tx_gsup(luop, &gsup); - - lu_op_statechg(luop, LU_S_ISD_SENT); - osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } /*! Receive Insert Subscriber Data Result from new VLR/SGSN */ @@ -364,38 +138,18 @@ } } -static struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) -{ - struct lu_operation *luop; - - luop = talloc_zero(srv, struct lu_operation); - OSMO_ASSERT(luop); - luop->gsup_server = srv; - luop->timer.cb = lu_op_timer_cb; - luop->timer.data = luop; - - return luop; -} - /*! Receive Update Location Request, creates new \ref lu_operation */ static int rx_upd_loc_req(struct osmo_gsup_conn *conn, const struct osmo_gsup_message *gsup) { - int rc; - struct lu_operation *luop; - struct hlr_subscriber *subscr; - uint8_t *peer_addr; - - rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); - if (rc < 0) { + struct lu_operation *luop = lu_op_alloc_conn(conn); + if (!luop) { LOGP(DMAIN, LOGL_ERROR, "LU REQ from conn without addr?\n"); - return rc; + return -EINVAL; } - luop = lu_op_alloc(conn->server); - luop->peer = talloc_memdup(luop, peer_addr, rc); lu_op_statechg(luop, LU_S_LU_RECEIVED); - subscr = &luop->subscr; + if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS) luop->is_ps = true; llist_add(&luop->list, &g_lu_ops); @@ -403,8 +157,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - rc = db_subscr_get(g_dbc, gsup->imsi, subscr); - if (rc < 0) { + if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -413,10 +166,10 @@ /* Check if subscriber is generally permitted on CS or PS * service (as requested) */ - if (!luop->is_ps && !subscr->nam_cs) { + if (!luop->is_ps && !luop->subscr.nam_cs) { lu_op_tx_error(luop, GMM_CAUSE_PLMN_NOTALLOWED); return 0; - } else if (luop->is_ps && !subscr->nam_ps) { + } else if (luop->is_ps && !luop->subscr.nam_ps) { lu_op_tx_error(luop, GMM_CAUSE_GPRS_NOTALLOWED); return 0; } @@ -508,7 +261,8 @@ case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT: { - struct lu_operation *luop = lu_op_by_imsi(gsup.imsi); + struct lu_operation *luop = lu_op_by_imsi(gsup.imsi, + &g_lu_ops); if (!luop) { LOGP(DMAIN, LOGL_ERROR, "GSUP message %s for " "unknown IMSI %s\n", diff --git a/src/luop.c b/src/luop.c new file mode 100644 index 0000000..ecf31b4 --- /dev/null +++ b/src/luop.c @@ -0,0 +1,268 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "gsup_server.h" +#include "gsup_router.h" +#include "logging.h" +#include "luop.h" + +const struct value_string lu_state_names[] = { + { LU_S_NULL, "NULL" }, + { LU_S_LU_RECEIVED, "LU RECEIVED" }, + { LU_S_CANCEL_SENT, "CANCEL SENT" }, + { LU_S_CANCEL_ACK_RECEIVED, "CANCEL-ACK RECEIVED" }, + { LU_S_ISD_SENT, "ISD SENT" }, + { LU_S_ISD_ACK_RECEIVED, "ISD-ACK RECEIVED" }, + { LU_S_COMPLETE, "COMPLETE" }, + { 0, NULL } +}; + +/* Transmit a given GSUP message for the given LU operation */ +static void _luop_tx_gsup(struct lu_operation *luop, + const struct osmo_gsup_message *gsup) +{ + struct msgb *msg_out; + + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP LUOP"); + osmo_gsup_encode(msg_out, gsup); + + osmo_gsup_addr_send(luop->gsup_server, luop->peer, + talloc_total_size(luop->peer), + msg_out); +} + +static inline void fill_gsup_msg(struct osmo_gsup_message *out, + const struct lu_operation *lu, + enum osmo_gsup_message_type mt) +{ + memset(out, 0, sizeof(struct osmo_gsup_message)); + if (lu) + osmo_strlcpy(out->imsi, lu->subscr.imsi, + GSM23003_IMSI_MAX_DIGITS + 1); + out->message_type = mt; +} + +/* timer call-back in case LU operation doesn't receive an response */ +static void lu_op_timer_cb(void *data) +{ + struct lu_operation *luop = data; + + DEBUGP(DMAIN, "LU OP timer expired in state %s\n", + get_value_string(lu_state_names, luop->state)); + + switch (luop->state) { + case LU_S_CANCEL_SENT: + break; + case LU_S_ISD_SENT: + break; + default: + break; + } + + lu_op_tx_error(luop, GMM_CAUSE_NET_FAIL); +} + +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi) +{ + struct hlr_subscriber *subscr = &luop->subscr; + + if (db_subscr_get(dbc, imsi, subscr) < 0) + return false; + + return true; +} + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv) +{ + struct lu_operation *luop; + + luop = talloc_zero(srv, struct lu_operation); + OSMO_ASSERT(luop); + luop->gsup_server = srv; + luop->timer.cb = lu_op_timer_cb; + luop->timer.data = luop; + + return luop; +} + +struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn) +{ + uint8_t *peer_addr; + struct lu_operation *luop = lu_op_alloc(conn->server); + int rc = osmo_gsup_conn_ccm_get(conn, &peer_addr, IPAC_IDTAG_SERNR); + if (rc < 0) + return NULL; + + luop->peer = talloc_memdup(luop, peer_addr, rc); + + return luop; +} + +/* FIXME: this doesn't seem to work at all */ +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst) +{ + struct lu_operation *luop; + + llist_for_each_entry(luop, lst, list) { + if (!strcmp(imsi, luop->subscr.imsi)) + return luop; + } + return NULL; +} + +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state) +{ + enum lu_state old_state = luop->state; + + DEBUGP(DMAIN, "LU OP state change: %s -> ", + get_value_string(lu_state_names, old_state)); + DEBUGPC(DMAIN, "%s\n", + get_value_string(lu_state_names, new_state)); + + luop->state = new_state; +} + +/* Send a msgb to a given address using routing */ +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg) +{ + struct osmo_gsup_conn *conn; + + conn = gsup_route_find(gs, addr, addrlen); + if (!conn) { + DEBUGP(DMAIN, "Cannot find route for addr %s\n", addr); + msgb_free(msg); + return -ENODEV; + } + + return osmo_gsup_conn_send(conn, msg); +} + +/*! Transmit UPD_LOC_ERROR and destroy lu_operation */ +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause) +{ + struct osmo_gsup_message gsup; + + DEBUGP(DMAIN, "%s: LU OP Tx Error (cause %s)\n", + luop->subscr.imsi, get_value_string(gsm48_gmm_cause_names, + cause)); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR); + gsup.cause = cause; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Transmit UPD_LOC_RESULT and destroy lu_operation */ +void lu_op_tx_ack(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT); + //FIXME gsup.hlr_enc; + + _luop_tx_gsup(luop, &gsup); + + llist_del(&luop->list); + talloc_free(luop); +} + +/*! Send Cancel Location to old VLR/SGSN */ +void lu_op_tx_cancel_old(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED); + + fill_gsup_msg(&gsup, NULL, OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST); + //gsup.cause = FIXME; + //gsup.cancel_type = FIXME; + + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_CANCEL_SENT); + osmo_timer_schedule(&luop->timer, CANCEL_TIMEOUT_SECS, 0); +} + +/*! Transmit Insert Subscriber Data to new VLR/SGSN */ +void lu_op_tx_insert_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + uint8_t apn[APN_MAXLEN]; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int l; + + OSMO_ASSERT(luop->state == LU_S_LU_RECEIVED || + luop->state == LU_S_CANCEL_ACK_RECEIVED); + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_INSERT_DATA_REQUEST); + + l = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, + luop->subscr.msisdn); + if (l < 1) { + LOGP(DMAIN, LOGL_ERROR, + "%s: Error: cannot encode MSISDN '%s'\n", + luop->subscr.imsi, luop->subscr.msisdn); + lu_op_tx_error(luop, GMM_CAUSE_PROTO_ERR_UNSPEC); + return; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = l; + + /* FIXME: deal with encoding the following data */ + gsup.hlr_enc; + + if (luop->is_ps) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = l; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); + + lu_op_statechg(luop, LU_S_ISD_SENT); + osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); +} diff --git a/src/luop.h b/src/luop.h new file mode 100644 index 0000000..7e2fbb0 --- /dev/null +++ b/src/luop.h @@ -0,0 +1,80 @@ +/* OsmoHLR TX/RX lu operations */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include +#include + +#include "db.h" + +#define CANCEL_TIMEOUT_SECS 30 +#define ISD_TIMEOUT_SECS 30 + +enum lu_state { + LU_S_NULL, + LU_S_LU_RECEIVED, + LU_S_CANCEL_SENT, + LU_S_CANCEL_ACK_RECEIVED, + LU_S_ISD_SENT, + LU_S_ISD_ACK_RECEIVED, + LU_S_COMPLETE, +}; + +extern const struct value_string lu_state_names[]; + +struct lu_operation { + /*! entry in global list of location update operations */ + struct llist_head list; + /*! to which gsup_server do we belong */ + struct osmo_gsup_server *gsup_server; + /*! state of the location update */ + enum lu_state state; + /*! CS (false) or PS (true) Location Update? */ + bool is_ps; + /*! currently running timer */ + struct osmo_timer_list timer; + + /*! subscriber related to this operation */ + struct hlr_subscriber subscr; + /*! peer VLR/SGSN starting the request */ + uint8_t *peer; +}; + +int osmo_gsup_addr_send(struct osmo_gsup_server *gs, + const uint8_t *addr, size_t addrlen, + struct msgb *msg); + +struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv); +struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn); +void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state); +bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc, + const char *imsi); +struct lu_operation *lu_op_by_imsi(const char *imsi, + const struct llist_head *lst); + +void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause); +void lu_op_tx_ack(struct lu_operation *luop); +void lu_op_tx_cancel_old(struct lu_operation *luop); +void lu_op_tx_insert_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1821 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic55a45d56b37be2ba43d96f7da2af43b46af9813 Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:58:09 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:58:09 +0000 Subject: osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1789 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 08:58:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 08:58:20 +0000 Subject: [MERGED] osmo-bts[master]: osmo-trx-bts: Fix incorrect bts shutdown procedure in case o... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: osmo-trx-bts: Fix incorrect bts shutdown procedure in case of clock loss from osmo-trx ...................................................................... osmo-trx-bts: Fix incorrect bts shutdown procedure in case of clock loss from osmo-trx This issue occurs in case of osmo-trx restart which leads to losing clock from osmo-trx. Function bts_shutdown from common/bts.c should be used in this case for proper bts shutdown. Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 --- M src/osmo-bts-trx/scheduler_trx.c 1 file changed, 1 insertion(+), 13 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Alexander Chemeris: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index d946ad5..9c676d7 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -1408,19 +1408,7 @@ no_clock: transceiver_available = 0; - /* flush pending messages of transceiver */ - /* close all logical channels and reset timeslots */ - llist_for_each_entry(trx, &bts->trx_list, list) { - struct phy_instance *pinst = trx_phy_instance(trx); - struct trx_l1h *l1h = pinst->u.osmotrx.hdl; - trx_if_flush(l1h); - trx_sched_reset(&l1h->l1s); - if (trx->nr == 0) - trx_if_cmd_poweroff(l1h); - } - - /* tell BSC */ - check_transceiver_availability(bts, 0); + bts_shutdown(bts, "No clock from osmo-trx"); return; } -- To view, visit https://gerrit.osmocom.org/1789 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie65cf2e8f98cb8bf3314a00048aa53c1f8cd4c25 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Sun Feb 19 09:01:14 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 09:01:14 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 10: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1198/10/src/input/unixsocket.c File src/input/unixsocket.c: Line 251: msgb_put_u32(msg, 0x23004200); this needs to be done properly. Right now we are basically puting some magic value here instead of a LAPD frame, and it' s "pure magic" that this magic value is not interpreted as LAPD on the other side. Rather, we should add an additional header (pushing one or two bytes in front of each message) to allow the receiver to distinguish LAPD payload from control frames. The header should include a version number so we can change the protocol as needed later. -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 10 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sun Feb 19 09:05:07 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Sun, 19 Feb 2017 09:05:07 +0000 Subject: openbsc[master]: Handle DSD from HLR In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 (2 comments) https://gerrit.osmocom.org/#/c/1838/2/openbsc/src/gprs/gprs_subscriber.c File openbsc/src/gprs/gprs_subscriber.c: Line 367: "Rx GSUP message %s not yet implemented for CS\n", a CS message will never be handled in GPRS/SGSN, so the "yet" is a bit misleading here. Line 372: gsm0408_gprs_access_cancelled(subscr->sgsn_data->mm, did you verify that this is sufficient? Basically we need to close any existing/established PDP contexts and detach the subscriber on mobility management. -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sun Feb 19 13:48:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 13:48:32 +0000 Subject: [MERGED] openbsc[master]: subscr_update_expire_lu(): fix (obscure) segfault In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: subscr_update_expire_lu(): fix (obscure) segfault ...................................................................... subscr_update_expire_lu(): fix (obscure) segfault To be paranoid, catch a NULL subscriber and/or bts in subscr_update_expire_lu(): print an error log and avoid segfault. (I'm not sure this would really happen in a normal situation.) During aggressive testing of Paging timeout, I came across this segfault in msc_release_connection() when conn->expire_timer_stopped is set but conn->subscr is NULL, at the subscr dereference after: if (conn->expire_timer_stopped) subscr_update_expire_lu(conn->subscr, conn->bts); I brought this situation about by a fabricated Paging fault, i.e. in gsm48_rx_rr_pag_resp() return 0 and don't call gsm48_handle_paging_resp() at all. Thus conn->subscr is still NULL when expire_timer_stopped is 1. When looking at CM Service Request handling, the conn->subscr is set before setting expire_timer_stopped = 1, which is a saner thing to do. But without my mad 'return 0', there is in fact no way to have a NULL subscriber there. It looks like all other code paths already do the same, but it's not that obvious (e.g. _gsm48_rx_mm_serv_req_sec_cb()). So rather catch this case of NULL conn->subscr, and while at it catch NULL bts as well. Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395 --- M openbsc/src/libmsc/gsm_subscriber.c 1 file changed, 10 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 4ec0ead..568f1c5 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -276,6 +276,16 @@ { int rc; + if (!s) { + LOGP(DMM, LOGL_ERROR, "LU Expiration but NULL subscriber\n"); + return -1; + } + if (!bts) { + LOGP(DMM, LOGL_ERROR, "%s: LU Expiration but NULL bts\n", + subscr_name(s)); + return -1; + } + /* Table 10.5.33: The T3212 timeout value field is coded as the * binary representation of the timeout value for * periodic updating in decihours. Mark the subscriber as -- To view, visit https://gerrit.osmocom.org/1850 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 13:57:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 13:57:22 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 2: It would be nice to get feedback on this because I'm basing my ongoing work on the LOGGING_* constants introduced here. The patch itself is fairly trivial. All the other logging_filter topic patches depend on this and also some are necessary to be merged for a successful build after this; best to get CR+2 on all of them before starting to merge. If this is the wrong way to go it would be good to know sooner rather than later... -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 14:20:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 14:20:08 +0000 Subject: osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Patch Set 4: (2 comments) https://gerrit.osmocom.org/#/c/1711/4/src/osmo-bts-octphy/octphy_vty.c File src/osmo-bts-octphy/octphy_vty.c: Line 169: "invalid msgb size (%d bytes, expected %ld bytes)%s", actually for sizeof()'s return value size_t, "%zu" would be the right format Line 227: "invalid msgb size (%d bytes, expected %ld bytes)%s", "%zu" -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sun Feb 19 14:24:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 14:24:35 +0000 Subject: openbsc[master]: libmsc/update_db_revision_3(): free memleaking db result In-Reply-To: References: Message-ID: Patch Set 1: cherry-pick onto master to merge this before the other patch that appears to be stalling? -- To view, visit https://gerrit.osmocom.org/1750 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 14:43:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 14:43:04 +0000 Subject: [PATCH] osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1783 to look at the new patch set (#3). oml: Fix incorrect usage of const variable abis_nm_att_tlvdef_ipa This bug was introduced during moving oml definitions from osmo-bts to libosmocore in libosmocore 0bee65c0d89f81a4b90aa3d484016d9ba680dd46 and osmo-bts 2cf6b73a4278627331bdbbb4addf1a8bc1d964ce: The type of abis_nm_att_tlvdef_ipa was changed from struct tlv_definition to const struct tlv_definition, so: * create static abis_nm_att_tlvdef_ipa_local variable for oml attribute definitions * copy abis_nm_att_tlvdef_ipa to abis_nm_att_tlvdef_ipa_local * merge abis_nm_att_tlvdef with abis_nm_att_tlvdef_ipa_local * use abis_nm_att_tlvdef_ipa_local in oml_tlv_parse function Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c --- M src/common/oml.c 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/83/1783/3 diff --git a/src/common/oml.c b/src/common/oml.c index 272123e..7069377 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -46,13 +46,15 @@ static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg); +static struct tlv_definition abis_nm_att_tlvdef_ipa_local = {}; + /* * support */ static int oml_tlv_parse(struct tlv_parsed *tp, const uint8_t *buf, int len) { - return tlv_parse(tp, &abis_nm_att_tlvdef_ipa, buf, len, 0, 0); + return tlv_parse(tp, &abis_nm_att_tlvdef_ipa_local, buf, len, 0, 0); } struct msgb *oml_msgb_alloc(void) @@ -1247,7 +1249,8 @@ int oml_init(struct gsm_abis_mo *mo) { DEBUGP(DOML, "Initializing OML attribute definitions\n"); - tlv_def_patch(&abis_nm_att_tlvdef_ipa, &abis_nm_att_tlvdef); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef_ipa); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef); osmo_signal_register_handler(SS_FAIL, handle_fail_sig, mo); return 0; -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Sun Feb 19 14:43:16 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 14:43:16 +0000 Subject: osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 14:50:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 14:50:42 +0000 Subject: osmo-sip-connector[master]: configure: check for pkg-config presence In-Reply-To: References: Message-ID: Patch Set 1: I'm not sure and don't remember the details. I know that I tested that it works for me: instead of failing obscurely it tells me that I need to install pkgconfig. Version 0.20 in particular -- unfortunately I don't remember how that number came about. If you know of improvements, please go ahead. -- To view, visit https://gerrit.osmocom.org/1000 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iaca22089bcb21b56048fa541f588c4ad4bed8f6d Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 15:43:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 15:43:07 +0000 Subject: osmo-hlr[master]: Update DB routines In-Reply-To: References: Message-ID: Patch Set 3: Code-Review-1 (3 comments) what Harald said, and https://gerrit.osmocom.org/#/c/1840/3//COMMIT_MSG Commit Message: Line 7: Update DB routines "Update"? AFAICT this is adding routines. Line 12: * fix printf security warning can't find any 'printf security warning', where is it? https://gerrit.osmocom.org/#/c/1840/3/src/db.h File src/db.h: Line 12: UPD_PURGE_CS_BY_IMSI = 5, above formatting uses tabs before the '=' -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sun Feb 19 15:54:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 15:54:41 +0000 Subject: osmo-hlr[master]: Update DB routines In-Reply-To: References: Message-ID: Patch Set 3: (1 comment) https://gerrit.osmocom.org/#/c/1840/3/src/db_hlr.c File src/db_hlr.c: Line 94: Use int sqlite3_changes(sqlite3*) to verify that one row was modified? https://sqlite.org/c3ref/changes.html -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sun Feb 19 15:56:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 15:56:56 +0000 Subject: osmo-hlr[master]: Expand CTRL interface In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 (4 comments) https://gerrit.osmocom.org/#/c/1841/2//COMMIT_MSG Commit Message: Line 7: Expand CTRL interface ETOOGENERAL: 'CTRL: add enable/disable packet service cmds' ? https://gerrit.osmocom.org/#/c/1841/2/src/ctrl.c File src/ctrl.c: Line 41: if (db_subscr_get(gs->dbc, cmd->value, NULL) < 0) { ah that's why. Rather check the number of modified rows in db_subscr_ps()? https://gerrit.osmocom.org/#/c/1841/2/src/db_hlr.c File src/db_hlr.c: Line 57: if (subscr) { why would I pass a NULL subscr to db_subscr_get()? https://gerrit.osmocom.org/#/c/1841/2/src/luop.c File src/luop.c: Line 271: void lu_op_tx_del_subscr_data(struct lu_operation *luop) this is not related to the ctrl interface, right? -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sun Feb 19 16:02:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 16:02:21 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 7: Verified+1 verified to work with real equipment -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 7 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 16:02:37 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 16:02:37 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 5: Verified+1 verified to work with real equipment -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 16:30:53 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 16:30:53 +0000 Subject: [PATCH] openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1682 to look at the new patch set (#6). add struct bsc_subscr, separating libbsc from gsm_subscriber In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC subscriber: struct bsc_subscr. Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no longer have a backpointer to gsm_network (used to be via subscr->group). Create a separate logging filter for the new BSC subscriber. The implementation of adjusting the filter context is added in libbsc to not introduce bsc_subscr_get/_put() dependencies to libcommon. During Paging Response, fetch a bsc_subscr from the mobile identity, like we do for the gsm_subscriber. It looks like a duplication now, but will make sense for the VLR as well as for future MSC split patches. Naming: it was requested to not name the new struct bsc_sub, because 'sub' is too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast to type, relatively short, unambiguous, and the naming is consistent. Add bsc_subscr unit test. Related: #1592, #1594 Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e --- M openbsc/.gitignore M openbsc/include/openbsc/Makefile.am A openbsc/include/openbsc/bsc_subscriber.h M openbsc/include/openbsc/debug.h M openbsc/include/openbsc/gsm_04_08.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/osmo_bsc_grace.h M openbsc/include/openbsc/paging.h M openbsc/src/libbsc/Makefile.am M openbsc/src/libbsc/abis_rsl.c A openbsc/src/libbsc/bsc_subscriber.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/libbsc/gsm_04_08_utils.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon-cs/common_cs.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/gsm_subscriber.c M openbsc/src/libmsc/vty_interface_layer3.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/tests/channel/Makefile.am M openbsc/tests/channel/channel_test.c M openbsc/tests/subscr/Makefile.am A openbsc/tests/subscr/bsc_subscr_test.c A openbsc/tests/subscr/bsc_subscr_test.err A openbsc/tests/subscr/bsc_subscr_test.ok M openbsc/tests/testsuite.at 30 files changed, 612 insertions(+), 115 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/82/1682/6 diff --git a/openbsc/.gitignore b/openbsc/.gitignore index e3f25cb..4f8e7e6 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -79,6 +79,7 @@ tests/mgcp/mgcp_transcoding_test tests/sgsn/sgsn_test tests/subscr/subscr_test +tests/subscr/bsc_subscr_test tests/oap/oap_test tests/gtphub/gtphub_test tests/mm_auth/mm_auth_test diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index c10accd..0895096 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -10,6 +10,7 @@ bsc_nat_callstats.h \ bsc_nat_sccp.h \ bsc_rll.h \ + bsc_subscriber.h \ bss.h \ bts_ipaccess_nanobts_omlattr.h \ chan_alloc.h \ diff --git a/openbsc/include/openbsc/bsc_subscriber.h b/openbsc/include/openbsc/bsc_subscriber.h new file mode 100644 index 0000000..a750d6e --- /dev/null +++ b/openbsc/include/openbsc/bsc_subscriber.h @@ -0,0 +1,43 @@ +/* GSM subscriber details for use in BSC land */ + +#pragma once + +#include + +#include +#include + +struct log_target; + +struct bsc_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + uint16_t lac; +}; + +const char *bsc_subscr_name(struct bsc_subscr *bsub); + +struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_have_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi); + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line); +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line); +#define bsc_subscr_get(bsub) _bsc_subscr_get(bsub, __BASE_FILE__, __LINE__) +#define bsc_subscr_put(bsub) _bsc_subscr_put(bsub, __BASE_FILE__, __LINE__) + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsub); diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index 6300020..74db723 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -42,6 +42,7 @@ struct gsm_subscriber; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr); +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr); extern const struct log_info log_info; diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index cb632f6..bdf4ed2 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -15,6 +15,7 @@ struct gsm_subscriber_connection; struct amr_multirate_conf; struct amr_mode; +struct bsc_subscr; #define GSM48_ALLOC_SIZE 2048 #define GSM48_ALLOC_HEADROOM 256 @@ -78,7 +79,8 @@ int send_siemens_mrpci(struct gsm_lchan *lchan, uint8_t *classmark2_lv); int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type); int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, uint8_t *mi_type); -int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr); +int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, + struct msgb *msg, struct bsc_subscr *bsub); int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode); int gsm48_rx_rr_modif_ack(struct msgb *msg); diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 460953e..dbc58ac 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -23,6 +23,7 @@ struct mncc_sock_state; struct gsm_subscriber_group; +struct bsc_subscr; #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] @@ -112,6 +113,9 @@ /* To whom we are allocated at the moment */ struct gsm_subscriber *subscr; + + /* libbsc subscriber information */ + struct bsc_subscr *bsub; /* LU expiration handling */ uint8_t expire_timer_stopped; @@ -383,6 +387,11 @@ * BTS|RNC specific timezone overrides for multi-tz networks in * OsmoCSCN, this should be tied to the location area code (LAC). */ struct gsm_tz tz; + + /* List of all struct bsc_subscr used in libbsc. This llist_head is + * allocated so that the llist_head pointer itself can serve as a + * talloc context. */ + struct llist_head *bsc_subscribers; }; struct osmo_esme; diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index af77b2f..50477d7 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -22,10 +22,14 @@ #define OSMO_BSC_GRACE_H #include +#include struct osmo_msc_data; int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts); -int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc); +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc); #endif diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index 689ff51..7dd8500 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -27,7 +27,7 @@ #include #include -#include +#include /** * A pending paging request @@ -36,8 +36,8 @@ /* list_head for list of all paging requests */ struct llist_head entry; /* the subscriber which we're paging. Later gsm_paging_request - * should probably become a part of the gsm_subscriber struct? */ - struct gsm_subscriber *subscr; + * should probably become a part of the bsc_subsrc struct? */ + struct bsc_subscr *bsub; /* back-pointer to the BTS on which we are paging */ struct gsm_bts *bts; /* what kind of channel type do we ask the MS to establish */ @@ -55,13 +55,14 @@ }; /* schedule paging request */ -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data); -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data); +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data); /* stop paging requests */ -void paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg); @@ -71,6 +72,6 @@ /* pending paging requests */ unsigned int paging_pending_requests_nr(struct gsm_bts *bts); -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr); +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub); #endif diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am index b8e77e6..fd8f37a 100644 --- a/openbsc/src/libbsc/Makefile.am +++ b/openbsc/src/libbsc/Makefile.am @@ -24,6 +24,7 @@ abis_om2000_vty.c \ abis_rsl.c \ bsc_rll.c \ + bsc_subscriber.c \ paging.c \ bts_ericsson_rbs2000.c \ bts_ipaccess_nanobts.c \ diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 58fdaa3..8ef178b 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1332,10 +1332,10 @@ static void print_meas_rep(struct gsm_lchan *lchan, struct gsm_meas_rep *mr) { int i; - char *name = ""; + const char *name = ""; if (lchan && lchan->conn) - name = subscr_name(lchan->conn->subscr); + name = bsc_subscr_name(lchan->conn->bsub); DEBUGP(DMEAS, "[%s] MEASUREMENT RESULT NR=%d ", name, mr->nr); diff --git a/openbsc/src/libbsc/bsc_subscriber.c b/openbsc/src/libbsc/bsc_subscriber.c new file mode 100644 index 0000000..205fdea --- /dev/null +++ b/openbsc/src/libbsc/bsc_subscriber.c @@ -0,0 +1,168 @@ +/* GSM subscriber details for use in BSC land */ + +/* + * (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Neels Hofmeyr + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include + +#include +#include + +static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list) +{ + struct bsc_subscr *bsub; + + bsub = talloc_zero(list, struct bsc_subscr); + if (!bsub) + return NULL; + + llist_add_tail(&bsub->entry, list); + bsub->use_count = 1; + + return bsub; +} + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + + if (!imsi || !*imsi) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (!strcmp(bsub->imsi, imsi)) + return bsc_subscr_get(bsub); + } + return NULL; +} + +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + + if (tmsi == GSM_RESERVED_TMSI) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (bsub->tmsi == tmsi) + return bsc_subscr_get(bsub); + } + return NULL; +} + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi) +{ + if (!bsub) + return; + strncpy(bsub->imsi, imsi, sizeof(bsub->imsi)); +} + +struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_imsi(list, imsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsc_subscr_set_imsi(bsub, imsi); + return bsub; +} + +struct bsc_subscr *bsc_subscr_have_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_tmsi(list, tmsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsub->tmsi = tmsi; + return bsub; +} + +const char *bsc_subscr_name(struct bsc_subscr *bsub) +{ + static char buf[32]; + if (!bsub) + return "unknown"; + if (bsub->imsi[0]) + snprintf(buf, sizeof(buf), "IMSI:%s", bsub->imsi); + else + snprintf(buf, sizeof(buf), "TMSI:0x%08x", bsub->tmsi); + return buf; +} + +static void bsc_subscr_free(struct bsc_subscr *bsub) +{ + llist_del(&bsub->entry); + talloc_free(bsub); +} + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line) +{ + OSMO_ASSERT(bsub->use_count < INT_MAX); + bsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "BSC subscr %s usage increases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + return bsub; +} + +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line) +{ + bsub->use_count--; + LOGPSRC(DREF, bsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "BSC subscr %s usage decreases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + if (bsub->use_count <= 0) + bsc_subscr_free(bsub); + return NULL; +} + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsc_subscr) +{ + struct bsc_subscr **fsub = (void*)&target->filter_data[LOGGING_FILTER_BSC_SUBSCR]; + + /* free the old data */ + if (*fsub) { + bsc_subscr_put(*fsub); + *fsub = NULL; + } + + if (bsc_subscr) { + target->filter_map |= (1 << LOGGING_FILTER_BSC_SUBSCR); + *fsub = bsc_subscr_get(bsc_subscr); + } else + target->filter_map &= ~(1 << LOGGING_FILTER_BSC_SUBSCR); +} diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 73acebd..21d0701 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1023,6 +1023,16 @@ vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); } +static void bsc_subscr_dump_vty(struct vty *vty, struct bsc_subscr *bsub) +{ + if (strlen(bsub->imsi)) + vty_out(vty, " IMSI: %s%s", bsub->imsi, VTY_NEWLINE); + if (bsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: 0x%08x%s", bsub->tmsi, + VTY_NEWLINE); + vty_out(vty, " Use count: %d%s", bsub->use_count, VTY_NEWLINE); +} + static void meas_rep_dump_uni_vty(struct vty *vty, struct gsm_meas_rep_unidir *mru, const char *prefix, @@ -1318,7 +1328,7 @@ static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag) { vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); - subscr_dump_vty(vty, pag->subscr); + bsc_subscr_dump_vty(vty, pag->bsub); } static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts) diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 98f0790..4a53b31 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -283,7 +283,7 @@ } int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct gsm_subscriber *subscr) + struct msgb *msg, struct bsc_subscr *bsub) { struct gsm_bts *bts = msg->lchan->ts->trx->bts; struct gsm48_hdr *gh = msgb_l3(msg); @@ -292,22 +292,24 @@ if (is_siemens_bts(bts)) send_siemens_mrpci(msg->lchan, classmark2_lv); - if (!conn->subscr) { - conn->subscr = subscr; - } else if (conn->subscr != subscr) { - LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); - subscr_put(subscr); + if (!conn->bsub) { + conn->bsub = bsub; + } else if (conn->bsub != bsub) { + LOGP(DRR, LOGL_ERROR, + "<- Channel already owned by someone else?\n"); + bsc_subscr_put(bsub); return -EINVAL; } else { DEBUGP(DRR, "<- Channel already owned by us\n"); - subscr_put(subscr); - subscr = conn->subscr; + bsc_subscr_put(bsub); + bsub = conn->bsub; } rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_COMPLETED]); /* Stop paging on the bts we received the paging response */ - paging_request_stop(conn->bts, subscr, conn, msg); + paging_request_stop(&bts->network->bts_list, conn->bts, bsub, conn, + msg); return 0; } diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 816d7a6..442e0da 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -58,11 +59,11 @@ * Kill one paging request update the internal list... */ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts, - struct gsm_paging_request *to_be_deleted) + struct gsm_paging_request *to_be_deleted) { osmo_timer_del(&to_be_deleted->T3113); llist_del(&to_be_deleted->entry); - subscr_put(to_be_deleted->subscr); + bsc_subscr_put(to_be_deleted->bsub); talloc_free(to_be_deleted); } @@ -77,21 +78,22 @@ if (!bts->oml_link) return; - log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, request->bsub); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " - "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, - request->subscr->tmsi, request->chan_type, request->attempts); + "0x%08x for ch. type %d (attempt %d)\n", request->bsub->imsi, + request->bsub->tmsi, request->chan_type, request->attempts); - if (request->subscr->tmsi == GSM_RESERVED_TMSI) - mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi); + if (request->bsub->tmsi == GSM_RESERVED_TMSI) + mi_len = gsm48_generate_mid_from_imsi(mi, request->bsub->imsi); else - mi_len = gsm48_generate_mid_from_tmsi(mi, request->subscr->tmsi); + mi_len = gsm48_generate_mid_from_tmsi(mi, request->bsub->tmsi); page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, - str_to_imsi(request->subscr->imsi)); + str_to_imsi(request->bsub->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL); + + log_set_context(LOGGING_CTX_BSC_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -237,11 +239,12 @@ } static int paging_pending_request(struct gsm_bts_paging_state *bts, - struct gsm_subscriber *subscr) { + struct bsc_subscr *bsub) +{ struct gsm_paging_request *req; llist_for_each_entry(req, &bts->pending_requests, entry) { - if (subscr == req->subscr) + if (bsub == req->bsub) return 1; } @@ -255,10 +258,10 @@ gsm_cbfn *cbfn; int msg; - log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, req->bsub); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", - req, req->subscr->imsi); + req, bsc_subscr_name(req->bsub)); /* must be destroyed before calling cbfn, to prevent double free */ rate_ctr_inc(&req->bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_EXPIRED]); @@ -277,21 +280,22 @@ } -static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +static int _paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts_paging_state *bts_entry = &bts->paging; struct gsm_paging_request *req; - if (paging_pending_request(bts_entry, subscr)) { - LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", subscr->imsi); + if (paging_pending_request(bts_entry, bsub)) { + LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", + bsc_subscr_name(bsub)); return -EEXIST; } - LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %llu on bts %d.\n", - subscr->id, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %s on bts %d.\n", + bsc_subscr_name(bsub), bts->nr); req = talloc_zero(tall_paging_ctx, struct gsm_paging_request); - req->subscr = subscr_get(subscr); + req->bsub = bsc_subscr_get(bsub); req->bts = bts; req->chan_type = type; req->cbfn = cbfn; @@ -305,8 +309,8 @@ return 0; } -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { int rc; @@ -317,15 +321,14 @@ /* maybe it is the first time we use it */ paging_init_if_needed(bts); - /* Trigger paging, pass any error to the caller */ - rc = _paging_request(bts, subscr, type, cbfn, data); + rc = _paging_request(bts, bsub, type, cbfn, data); if (rc < 0) return rc; return 1; } -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts *bts = NULL; @@ -337,13 +340,14 @@ do { int rc; - bts = gsm_bts_by_lac(network, subscr->lac, bts); + bts = gsm_bts_by_lac(network, bsub->lac, bts); if (!bts) break; - rc = paging_request_bts(bts, subscr, type, cbfn, data); + rc = paging_request_bts(bts, bsub, type, cbfn, data); if (rc < 0) { - paging_request_stop(NULL, subscr, NULL, NULL); + paging_request_stop(&network->bts_list, NULL, bsub, + NULL, NULL); return rc; } num_pages += rc; @@ -357,7 +361,7 @@ /* we consciously ignore the type of the request here */ -static void _paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +static void _paging_request_stop(struct gsm_bts *bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -367,8 +371,8 @@ paging_init_if_needed(bts); llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests, - entry) { - if (req->subscr == subscr) { + entry) { + if (req->bsub == bsub) { gsm_cbfn *cbfn = req->cbfn; void *param = req->cbfn_param; @@ -377,35 +381,36 @@ req = NULL; if (conn && cbfn) { - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", bsub->imsi, bts->nr); cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED, - msg, conn, param); + msg, conn, param); } else - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", bsub->imsi, bts->nr); break; } } } /* Stop paging on all other bts' */ -void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm_bts *bts; - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOGGING_CTX_BSC_SUBSCR, bsub); /* Stop this first and dispatch the request */ if (_bts) - _paging_request_stop(_bts, subscr, conn, msg); + _paging_request_stop(_bts, bsub, conn, msg); /* Make sure to cancel this everywhere else */ - llist_for_each_entry(bts, &subscr->group->net->bts_list, list) { + llist_for_each_entry(bts, bts_list, list) { /* Sort of an optimization. */ if (bts == _bts) continue; - _paging_request_stop(bts, subscr, NULL, NULL); + _paging_request_stop(bts, bsub, NULL, NULL); } } @@ -434,12 +439,12 @@ /** * Find any paging data for the given subscriber at the given BTS. */ -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr) +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub) { struct gsm_paging_request *req; llist_for_each_entry(req, &bts->paging.pending_requests, entry) - if (req->subscr == subscr) + if (req->bsub == bsub) return req->cbfn_param; return NULL; diff --git a/openbsc/src/libcommon-cs/common_cs.c b/openbsc/src/libcommon-cs/common_cs.c index 3149580..7905802 100644 --- a/openbsc/src/libcommon-cs/common_cs.c +++ b/openbsc/src/libcommon-cs/common_cs.c @@ -70,6 +70,9 @@ INIT_LLIST_HEAD(&net->upqueue); INIT_LLIST_HEAD(&net->subscr_conns); + net->bsc_subscribers = talloc_zero(net, struct llist_head); + INIT_LLIST_HEAD(net->bsc_subscribers); + /* init statistics */ net->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, 0); net->active_calls = osmo_counter_alloc("msc.active_calls"); diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 3f3232c..dcd02fa 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -180,11 +180,16 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; + const struct bsc_subscr *bsub = ctx->ctx[LOGGING_CTX_BSC_SUBSCR]; const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0 && subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR]) + return 1; + + if ((tar->filter_map & (1 << LOGGING_FILTER_BSC_SUBSCR)) != 0 + && bsub && bsub == tar->filter_data[LOGGING_FILTER_BSC_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ @@ -206,7 +211,8 @@ .num_cat = ARRAY_SIZE(default_categories), }; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr) { struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; @@ -216,9 +222,9 @@ *fsub = NULL; } - if (subscr) { + if (vlr_subscr) { target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR); - *fsub = subscr_get(subscr); + *fsub = subscr_get(vlr_subscr); } else target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 10e2b31..d5c9d09 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1433,6 +1433,8 @@ uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm_subscriber *subscr = NULL; + struct bsc_subscr *bsub; + uint32_t tmsi; int rc = 0; resp = (struct gsm48_pag_resp *) &gh->data[0]; @@ -1443,8 +1445,8 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_get_by_tmsi(conn->network->subscr_group, - tmsi_from_string(mi_string)); + tmsi = tmsi_from_string(mi_string); + subscr = subscr_get_by_tmsi(conn->network->subscr_group, tmsi); break; case GSM_MI_TYPE_IMSI: subscr = subscr_get_by_imsi(conn->network->subscr_group, @@ -1457,6 +1459,19 @@ /* FIXME: request id? close channel? */ return -EINVAL; } + + if (!conn->subscr) { + conn->subscr = subscr; + } else if (conn->subscr != subscr) { + LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); + subscr_put(subscr); + return -EINVAL; + } else { + DEBUGP(DRR, "<- Channel already owned by us\n"); + subscr_put(subscr); + subscr = conn->subscr; + } + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1465,10 +1480,18 @@ memcpy(subscr->equipment.classmark2, classmark2_lv+1, *classmark2_lv); db_sync_equipment(&subscr->equipment); + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_have_by_imsi(conn->network->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + /* We received a paging */ conn->expire_timer_stopped = 1; - rc = gsm48_handle_paging_resp(conn, msg, subscr); + rc = gsm48_handle_paging_resp(conn, msg, bsub); return rc; } diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 568f1c5..73e6d79 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -82,8 +82,11 @@ struct gsm_subscriber_connection *conn = data; struct gsm_subscriber *subscr = param; struct paging_signal_data sig_data; + struct bsc_subscr *bsub; + struct gsm_network *net; - OSMO_ASSERT(subscr->is_paging); + OSMO_ASSERT(subscr && subscr->is_paging); + net = subscr->group->net; /* * Stop paging on all other BTS. E.g. if this is @@ -91,7 +94,15 @@ * timeout soon as well. Let's just stop everything * and forget we wanted to page. */ - paging_request_stop(NULL, subscr, NULL, NULL); + + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_have_by_imsi(net->bsc_subscribers, subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + paging_request_stop(&net->bts_list, NULL, bsub, NULL, NULL); + bsc_subscr_put(bsub); /* Inform parts of the system we don't know */ sig_data.subscr = subscr; @@ -169,13 +180,23 @@ { int rc; struct subscr_request *request; + struct bsc_subscr *bsub; + struct gsm_network *net = subscr->group->net; /* Start paging.. we know it is async so we can do it before */ if (!subscr->is_paging) { LOGP(DMM, LOGL_DEBUG, "Subscriber %s not paged yet.\n", subscr_name(subscr)); - rc = paging_request(subscr->group->net, subscr, channel_type, - subscr_paging_cb, subscr); + /* TODO MSC split -- creating a BSC subscriber directly from + * MSC data structures in RAM. At some point the MSC will send + * a message to the BSC instead. */ + bsub = bsc_subscr_have_by_imsi(net->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + rc = paging_request(net, bsub, channel_type, subscr_paging_cb, + subscr); + bsc_subscr_put(bsub); if (rc <= 0) { LOGP(DMM, LOGL_ERROR, "Subscriber %s paging failed: %d\n", subscr_name(subscr), rc); diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index ddec2e3..c6a8929 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1033,21 +1034,26 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct gsm_subscriber *vlr_subscr; + struct bsc_subscr *bsc_subscr; struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; if (!tgt) return CMD_WARNING; - subscr = subscr_get_by_imsi(gsmnet->subscr_group, argv[0]); - if (!subscr) { + vlr_subscr = subscr_get_by_imsi(gsmnet->subscr_group, imsi); + bsc_subscr = bsc_subscr_find_by_imsi(gsmnet->bsc_subscribers, imsi); + + if (!vlr_subscr && !bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_vlr_subscr(tgt, vlr_subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index f38c97f..efdc9bd 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -20,9 +20,10 @@ #include #include +#include #include #include -#include +#include #include #include @@ -99,7 +100,7 @@ static int bssmap_handle_paging(struct osmo_msc_data *msc, struct msgb *msg, unsigned int payload_length) { - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; struct tlv_parsed tp; char mi_string[GSM48_MI_SIZE]; uint32_t tmsi = GSM_RESERVED_TMSI; @@ -157,7 +158,8 @@ LOGP(DMSC, LOGL_ERROR, "eMLPP is not handled\n"); } - subscr = subscr_get_or_create(msc->network->subscr_group, mi_string); + subscr = bsc_subscr_have_by_imsi(msc->network->bsc_subscribers, + mi_string); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string); return -1; @@ -167,7 +169,8 @@ subscr->tmsi = tmsi; LOGP(DMSC, LOGL_INFO, "Paging request from MSC IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n", mi_string, tmsi, tmsi, lac); - bsc_grace_paging_request(subscr, chan_needed, msc); + bsc_grace_paging_request(msc->network->bsc_data->rf_ctrl->policy, + subscr, chan_needed, msc); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index d5ca2fd..8301bfb 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -54,14 +55,14 @@ } /* extract a subscriber from the paging response */ -static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn, - struct msgb *msg) +static struct bsc_subscr *extract_sub(struct gsm_subscriber_connection *conn, + struct msgb *msg) { uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm48_hdr *gh; struct gsm48_pag_resp *resp; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*resp)) { LOGP(DMSC, LOGL_ERROR, "PagingResponse too small: %u\n", msgb_l3len(msg)); @@ -78,12 +79,12 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = bsc_subscr_find_by_tmsi(conn->network->bsc_subscribers, + tmsi_from_string(mi_string)); break; case GSM_MI_TYPE_IMSI: - subscr = subscr_active_by_imsi(conn->bts->network->subscr_group, - mi_string); + subscr = bsc_subscr_find_by_imsi(conn->network->bsc_subscribers, + mi_string); break; default: subscr = NULL; @@ -96,15 +97,16 @@ /* we will need to stop the paging request */ static int handle_page_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct gsm_subscriber *subscr = extract_sub(conn, msg); + struct bsc_subscr *subscr = extract_sub(conn, msg); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Non active subscriber got paged.\n"); return -1; } - paging_request_stop(conn->bts, subscr, conn, msg); - subscr_put(subscr); + paging_request_stop(&conn->network->bts_list, conn->bts, subscr, conn, + msg); + bsc_subscr_put(subscr); return 0; } @@ -130,7 +132,7 @@ uint8_t mtype; struct osmo_bsc_data *bsc; struct osmo_msc_data *msc, *pag_msc; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; int is_emerg = 0; bsc = conn->bts->network->bsc_data; @@ -183,7 +185,7 @@ } pag_msc = paging_get_data(conn->bts, subscr); - subscr_put(subscr); + bsc_subscr_put(subscr); llist_for_each_entry(msc, &bsc->mscs, entry) { if (msc != pag_msc) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 6409a3a..eef88b4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -34,8 +34,8 @@ } -static int normal_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int normal_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { /* we can't page by lac.. we need to page everything */ if (msc->core_lac != -1) { @@ -47,12 +47,11 @@ return 0; } - return paging_request(subscr->group->net, subscr, chan_needed, NULL, - msc); + return paging_request(msc->network, subscr, chan_needed, NULL, msc); } -static int locked_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int locked_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { struct gsm_bts *bts = NULL; @@ -84,10 +83,12 @@ /** * Try to not page if everything the cell is not on. */ -int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc) { - if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON) + if (rf_policy == S_RF_ON) return normal_paging(subscr, chan_needed, msc); return locked_paging(subscr, chan_needed, msc); } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 86ccec4..9171968 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -861,20 +861,19 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct bsc_subscr *bsc_subscr; struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; - if (!tgt) - return CMD_WARNING; + bsc_subscr = bsc_subscr_find_by_imsi(bsc_gsmnet->bsc_subscribers, imsi); - subscr = subscr_get_or_create(bsc_gsmnet->subscr_group, argv[0]); - if (!subscr) { + if (!bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", - argv[0], VTY_NEWLINE); + imsi, VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am index 5e9583f..ca470ac 100644 --- a/openbsc/tests/channel/Makefile.am +++ b/openbsc/tests/channel/Makefile.am @@ -24,8 +24,8 @@ $(NULL) channel_test_LDADD = \ - $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) \ diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index c69c701..88293d0 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -49,7 +49,7 @@ } /* mock object for testing, directly invoke the cb... maybe later through the timer */ -int paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data) +int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { s_data = data; s_cbfn = cbfn; @@ -72,6 +72,7 @@ exit(1); bts = gsm_bts_alloc(network); bts->location_area_code = 23; + s_conn.network = network; /* Create a dummy subscriber */ struct gsm_subscriber *subscr = subscr_alloc(); diff --git a/openbsc/tests/subscr/Makefile.am b/openbsc/tests/subscr/Makefile.am index ad8b20c..6342444 100644 --- a/openbsc/tests/subscr/Makefile.am +++ b/openbsc/tests/subscr/Makefile.am @@ -19,10 +19,13 @@ EXTRA_DIST = \ subscr_test.ok \ + bsc_subscr_test.ok \ + bsc_subscr_test.err \ $(NULL) noinst_PROGRAMS = \ subscr_test \ + bsc_subscr_test \ $(NULL) subscr_test_SOURCES = \ @@ -40,3 +43,19 @@ $(LIBSMPP34_LIBS) \ $(LIBOSMOVTY_LIBS) \ $(NULL) + +bsc_subscr_test_SOURCES = \ + bsc_subscr_test.c \ + $(NULL) + +bsc_subscr_test_LDADD = \ + $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ + $(top_builddir)/src/libtrau/libtrau.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOABIS_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBSMPP34_LIBS) \ + $(LIBOSMOVTY_LIBS) \ + $(NULL) diff --git a/openbsc/tests/subscr/bsc_subscr_test.c b/openbsc/tests/subscr/bsc_subscr_test.c new file mode 100644 index 0000000..43de723 --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.c @@ -0,0 +1,130 @@ +/* (C) 2008 by Jan Luebbe + * (C) 2009 by Holger Hans Peter Freyther + * (C) 2014 by Alexander Chemeris + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include + +#include +#include +#include +#include + +struct llist_head *bsc_subscribers; + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi) +{ + struct bsc_subscr *sfound; + OSMO_ASSERT(bsub); + OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0); + + sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi); + OSMO_ASSERT(sfound == bsub); + + bsc_subscr_put(sfound); +} + +static void test_bsc_subscr(void) +{ + struct bsc_subscr *s1, *s2, *s3; + const char *imsi1 = "1234567890"; + const char *imsi2 = "9876543210"; + const char *imsi3 = "5656565656"; + + printf("Test BSC subscriber allocation and deletion\n"); + + /* Check for emptiness */ + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + /* Allocate entry 1 */ + s1 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + assert_bsc_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + + /* Allocate entry 2 */ + s2 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi2); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + + /* Allocate entry 3 */ + s3 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi3); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d"); + + /* Check entries */ + assert_bsc_subscr(s1, imsi1); + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 1 */ + bsc_subscr_put(s1); + s1 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 2 */ + bsc_subscr_put(s2); + s2 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 3 */ + bsc_subscr_put(s3); + s3 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + OSMO_ASSERT(llist_empty(bsc_subscribers)); +} + +int main() +{ + printf("Testing BSC subscriber core code.\n"); + osmo_init_logging(&log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + log_set_category_filter(osmo_stderr_target, DREF, 1, LOGL_DEBUG); + + bsc_subscribers = talloc_zero(NULL, struct llist_head); + INIT_LLIST_HEAD(bsc_subscribers); + + test_bsc_subscr(); + + printf("Done\n"); + return 0; +} diff --git a/openbsc/tests/subscr/bsc_subscr_test.err b/openbsc/tests/subscr/bsc_subscr_test.err new file mode 100644 index 0000000..a66317a --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.err @@ -0,0 +1,17 @@ +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage decreases to: 0 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage decreases to: 0 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage decreases to: 0 diff --git a/openbsc/tests/subscr/bsc_subscr_test.ok b/openbsc/tests/subscr/bsc_subscr_test.ok new file mode 100644 index 0000000..0f6a8be --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.ok @@ -0,0 +1,11 @@ +Testing BSC subscriber core code. +Test BSC subscriber allocation and deletion +llist_count(bsc_subscribers) == 0 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 3 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 0 +Done diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 01737a3..280aeb2 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -13,6 +13,13 @@ AT_CHECK([$abs_top_builddir/tests/subscr/subscr_test], [], [expout], [ignore]) AT_CLEANUP +AT_SETUP([bsc_subscr]) +AT_KEYWORDS([bsc_subscr]) +cat $abs_srcdir/subscr/bsc_subscr_test.ok > expout +cat $abs_srcdir/subscr/bsc_subscr_test.err > experr +AT_CHECK([$abs_top_builddir/tests/subscr/bsc_subscr_test], [], [expout], [experr]) +AT_CLEANUP + AT_SETUP([db]) AT_KEYWORDS([db]) cat $abs_srcdir/db/db_test.ok > expout -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sun Feb 19 16:31:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 16:31:32 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 6: Verified+1 -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sun Feb 19 16:31:43 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sun, 19 Feb 2017 16:31:43 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: Verified+1 -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:28:44 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:28:44 +0000 Subject: [PATCH] osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#4). Add routines to update nam_ps Add SQL queries to change nam_ps value and function which uses them. Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 38 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/4 diff --git a/src/db.c b/src/db.c index d20b8b6..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -33,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) diff --git a/src/db.h b/src/db.h index 0fb76a0..0b3df88 100644 --- a/src/db.h +++ b/src/db.h @@ -4,13 +4,15 @@ #include enum stmt_idx { - SEL_BY_IMSI = 0, - UPD_VLR_BY_ID = 1, - UPD_SGSN_BY_ID = 2, - AUC_BY_IMSI = 3, - AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + SEL_BY_IMSI = 0, + UPD_VLR_BY_ID = 1, + UPD_SGSN_BY_ID = 2, + AUC_BY_IMSI = 3, + AUC_UPD_SQN = 4, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -70,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index 09ab6fc..f550141 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -77,6 +77,32 @@ return ret; } +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc = 0; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + rc = sqlite3_step(stmt); /* execute the statement */ + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + rc = sqlite3_changes(dbc); /* verify execution result */ + if (rc != 1) { + LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n", + rc); + rc = -EINVAL; + } + + db_remove_reset(stmt); + return rc; +} + int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, bool lu_is_ps) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:28:44 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:28:44 +0000 Subject: [PATCH] osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1841 to look at the new patch set (#3). CTRL: add enable/disable packet service cmds Add commands to enable/disable Packet Service for a given IMSI. Changes are synced to DB and propagated at runtime to SGSN (in case of disable command). Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Related: OS#1645 --- M src/ctrl.c M src/hlr.c M src/luop.c M src/luop.h 4 files changed, 59 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/41/1841/3 diff --git a/src/ctrl.c b/src/ctrl.c index b7514c5..8165926 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -32,6 +32,47 @@ #include "luop.h" #include "ctrl.h" +static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd, + bool enable) +{ + struct lu_operation *luop = NULL; + struct osmo_gsup_conn *co; + + if (db_subscr_get(gs->dbc, cmd->value, NULL) < 0) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + if (db_subscr_ps(gs->dbc, cmd->value, enable) < 0) { + cmd->reply = "Error updating DB"; + return CTRL_CMD_ERROR; + } + + if (!enable){ /* FIXME: only send to single SGSN where latest update for IMSI came from */ + llist_for_each_entry(co, &gs->clients, list) { + luop = lu_op_alloc_conn(co); + lu_op_fill_subscr(luop, gs->dbc, cmd->value); + lu_op_tx_del_subscr_data(luop); + } + } + + cmd->reply = "OK"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_WO_NOVRF(enable_ps, "enable-ps"); +static int set_enable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, true); +} + +CTRL_CMD_DEFINE_WO_NOVRF(disable_ps, "disable-ps"); +static int set_disable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, false); +} + CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); static int set_status_ps(struct ctrl_cmd *cmd, void *data) { @@ -55,6 +96,8 @@ { int rc = 0; + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_enable_ps); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_disable_ps); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); return rc; diff --git a/src/hlr.c b/src/hlr.c index 5ae5ff3..0a3642c 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -257,6 +257,8 @@ rx_purge_ms_req(conn, &gsup); break; /* responses to requests sent by us */ + case OSMO_GSUP_MSGT_DELETE_DATA_ERROR: + case OSMO_GSUP_MSGT_DELETE_DATA_RESULT: case OSMO_GSUP_MSGT_INSERT_DATA_ERROR: case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: diff --git a/src/luop.c b/src/luop.c index ecf31b4..937c02c 100644 --- a/src/luop.c +++ b/src/luop.c @@ -266,3 +266,16 @@ lu_op_statechg(luop, LU_S_ISD_SENT); osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } + +/*! Transmit Delete Subscriber Data to new VLR/SGSN */ +void lu_op_tx_del_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_DELETE_DATA_REQUEST); + + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); +} diff --git a/src/luop.h b/src/luop.h index 7e2fbb0..ab1bc24 100644 --- a/src/luop.h +++ b/src/luop.h @@ -78,3 +78,4 @@ void lu_op_tx_ack(struct lu_operation *luop); void lu_op_tx_cancel_old(struct lu_operation *luop); void lu_op_tx_insert_subscr_data(struct lu_operation *luop); +void lu_op_tx_del_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:28:45 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:28:45 +0000 Subject: [PATCH] osmo-hlr[master]: Fix printf security warning Message-ID: Review at https://gerrit.osmocom.org/1851 Fix printf security warning Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 --- M src/db.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/51/1851/1 diff --git a/src/db.c b/src/db.c index 1385502..e57d86f 100644 --- a/src/db.c +++ b/src/db.c @@ -46,7 +46,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:28:45 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:28:45 +0000 Subject: [PATCH] osmo-hlr[master]: db: move duplicated code into helper functions Message-ID: Review at https://gerrit.osmocom.org/1852 db: move duplicated code into helper functions * move common cleanup code into separate function * add helper function for IMSI binding * use errno.h instead of numbers Change-Id: Iec81b56ab1ccc948807854a3947b04355a555c10 --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 47 insertions(+), 46 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/52/1852/1 diff --git a/src/db.c b/src/db.c index e57d86f..d20b8b6 100644 --- a/src/db.c +++ b/src/db.c @@ -19,6 +19,7 @@ #include +#include #include #include "logging.h" @@ -57,6 +58,36 @@ } } +/* remove bindings and reset statement to be re-executed */ +bool db_remove_reset(sqlite3_stmt *stmt) +{ + int rc = sqlite3_clear_bindings(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); + return false; + } + + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); + return false; + } + return true; +} + +/* bind IMSI and do proper cleanup in case of failure */ +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi) +{ + int rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); + db_remove_reset(stmt); + return false; + } + + return true; +} + void db_close(struct db_context *dbc) { unsigned int i; diff --git a/src/db.h b/src/db.h index d569fb0..0fb76a0 100644 --- a/src/db.h +++ b/src/db.h @@ -20,6 +20,8 @@ sqlite3_stmt *stmt[_NUM_STMT]; }; +bool db_remove_reset(sqlite3_stmt *stmt); +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi); void db_close(struct db_context *dbc); struct db_context *db_open(void *ctx, const char *fname); diff --git a/src/db_hlr.c b/src/db_hlr.c index 1b95556..b7485f0 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -42,17 +43,14 @@ sqlite3_stmt *stmt = dbc->stmt[SEL_BY_IMSI]; int rc, ret = 0; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGHLR(imsi, LOGL_ERROR, "Error binding IMSI: %d\n", rc); - return -1; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_ROW) { LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); - ret = -2; + ret = -ENOEXEC; goto out; } @@ -73,15 +71,7 @@ subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -105,13 +95,13 @@ rc = sqlite3_bind_int64(stmt, 1, subscr->id); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding ID: %d\n", rc); - return -1; + return -EINVAL; } rc = sqlite3_bind_text(stmt, 2, txt, -1, SQLITE_STATIC); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding VLR/SGSN Number: %d\n", rc); - ret = -2; + ret = -EBADMSG; goto out; } @@ -119,19 +109,10 @@ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error updating SQN: %d\n", rc); - ret = -3; - goto out; + ret = -ENOEXEC; } out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -146,31 +127,18 @@ else stmt = dbc->stmt[UPD_PURGE_CS_BY_IMSI]; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); - ret = -1; - goto out; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error setting Purged: %d\n", rc); - ret = -2; - goto out; + ret = -ENOEXEC; } /* FIXME: return 0 in case IMSI not known */ -out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + + db_remove_reset(stmt); return ret; } -- To view, visit https://gerrit.osmocom.org/1852 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iec81b56ab1ccc948807854a3947b04355a555c10 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:28:45 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:28:45 +0000 Subject: [PATCH] osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional Message-ID: Review at https://gerrit.osmocom.org/1853 Make subscr parameter to db_subscr_get() optional This allows to check for subscriber's presence in DB without the need to bother with unused structure allocation. Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e --- M src/db_hlr.c 1 file changed, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/53/1853/1 diff --git a/src/db_hlr.c b/src/db_hlr.c index b7485f0..09ab6fc 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -54,22 +54,23 @@ goto out; } - /* obtain the various columns */ - subscr->id = sqlite3_column_int64(stmt, 0); - SL3_TXT(subscr->imsi, stmt, 1); - SL3_TXT(subscr->msisdn, stmt, 2); - /* FIXME: These should all be BLOBs as they might contain NUL */ - SL3_TXT(subscr->vlr_number, stmt, 3); - SL3_TXT(subscr->sgsn_number, stmt, 4); - SL3_TXT(subscr->sgsn_address, stmt, 5); - subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); - subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); - subscr->nam_cs = sqlite3_column_int(stmt, 8); - subscr->nam_ps = sqlite3_column_int(stmt, 9); - subscr->lmsi = sqlite3_column_int(stmt, 10); - subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); - subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); - + if (subscr) { + /* obtain the various columns */ + subscr->id = sqlite3_column_int64(stmt, 0); + SL3_TXT(subscr->imsi, stmt, 1); + SL3_TXT(subscr->msisdn, stmt, 2); + /* FIXME: These should all be BLOBs as they might contain NUL */ + SL3_TXT(subscr->vlr_number, stmt, 3); + SL3_TXT(subscr->sgsn_number, stmt, 4); + SL3_TXT(subscr->sgsn_address, stmt, 5); + subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); + subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); + subscr->nam_cs = sqlite3_column_int(stmt, 8); + subscr->nam_ps = sqlite3_column_int(stmt, 9); + subscr->lmsi = sqlite3_column_int(stmt, 10); + subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); + subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); + } out: db_remove_reset(stmt); -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:31:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:31:26 +0000 Subject: osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Patch Set 3: > Rather check the number of modified rows in db_subscr_ps()? Added this check, but it's orthogonal to checking subscriber presence in here. > this is not related to the ctrl interface, right? Wrong: this function is essential for added ctrl commands. -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 10:39:42 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 10:39:42 +0000 Subject: [PATCH] osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#5). Add routines to update nam_ps Add SQL queries to change nam_ps value and function which uses them. Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 38 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/5 diff --git a/src/db.c b/src/db.c index d20b8b6..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -33,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) diff --git a/src/db.h b/src/db.h index 0fb76a0..0b3df88 100644 --- a/src/db.h +++ b/src/db.h @@ -4,13 +4,15 @@ #include enum stmt_idx { - SEL_BY_IMSI = 0, - UPD_VLR_BY_ID = 1, - UPD_SGSN_BY_ID = 2, - AUC_BY_IMSI = 3, - AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + SEL_BY_IMSI = 0, + UPD_VLR_BY_ID = 1, + UPD_SGSN_BY_ID = 2, + AUC_BY_IMSI = 3, + AUC_UPD_SQN = 4, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -70,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index 09ab6fc..a862e8f 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -77,6 +77,32 @@ return ret; } +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc = 0; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + rc = sqlite3_step(stmt); /* execute the statement */ + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + rc = sqlite3_changes(dbc->db); /* verify execution result */ + if (rc != 1) { + LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n", + rc); + rc = -EINVAL; + } + + db_remove_reset(stmt); + return rc; +} + int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, bool lu_is_ps) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 11:02:27 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 11:02:27 +0000 Subject: [PATCH] libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1629 to look at the new patch set (#4). Expand and expose ctrl connection allocation Add function for allocating CTRL connection to public headers and replace call to previous static function with it. Add doxygen docs for this function. Related: OS#1615 Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 --- M include/osmocom/ctrl/control_if.h M src/ctrl/control_if.c 2 files changed, 53 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/1629/4 diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h index 512ae10..f2af1db 100644 --- a/include/osmocom/ctrl/control_if.h +++ b/include/osmocom/ctrl/control_if.h @@ -27,5 +27,5 @@ const char *bind_addr, uint16_t port, ctrl_cmd_lookup lookup); - +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data); int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data); diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index 254f9bc..e266316 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -368,7 +368,14 @@ return rc; } -static struct ctrl_connection *ctrl_connection_alloc(void *ctx) +/*! \brief Allocate CTRL connection + * \param[in] ctx Context from which talloc should allocate it + * \param[in] data caller's private data parameter which should assigned to + write queue's file descriptor data parameter, if NULL than + allocated context itself is assigned. + * \return Allocated CTRL connection structure or NULL in case of errors + */ +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data) { struct ctrl_connection *ccon = talloc_zero(ctx, struct ctrl_connection); if (!ccon) @@ -379,6 +386,9 @@ INIT_LLIST_HEAD(&ccon->cmds); INIT_LLIST_HEAD(&ccon->def_cmds); + + ccon->write_queue.bfd.data = data ? data : ccon; + ccon->write_queue.write_cb = control_write_cb; return ccon; } @@ -412,19 +422,17 @@ return ret; } #endif - ccon = ctrl_connection_alloc(listen_bfd->data); + ctrl = listen_bfd->data; + ccon = osmo_ctrl_conn_alloc(listen_bfd->data, ctrl); if (!ccon) { LOGP(DLCTRL, LOGL_ERROR, "Failed to allocate.\n"); close(fd); return -1; } - ctrl = listen_bfd->data; - ccon->write_queue.bfd.data = ctrl; ccon->write_queue.bfd.fd = fd; ccon->write_queue.bfd.when = BSC_FD_READ; ccon->write_queue.read_cb = handle_control_read; - ccon->write_queue.write_cb = control_write_cb; ret = osmo_fd_register(&ccon->write_queue.bfd); if (ret < 0) { @@ -648,6 +656,45 @@ return 0; } +/*! \brief Setup CTRL interface connection to a given address + * \param[in] data Pointer which will be made available to each + set_..() get_..() verify_..() control command function + * \param[in] addr Address to which we shall connect + * \param[in] port Port to which we shall connect + * \param[in] lookup Lookup function pointer, can be NULL + * \returns ctrl_handle pointer or NULL in case of errors + */ +struct ctrl_handle *ctrl_interface_connect(void *data, const char *addr, + uint16_t port, + ctrl_cmd_lookup lookup) +{ + int ret; + struct ctrl_handle *ctrl; + + ctrl = talloc_zero(data, struct ctrl_handle); + if (!ctrl) + return NULL; + + INIT_LLIST_HEAD(&ctrl->ccon_list); + + ctrl->data = data; + ctrl->lookup = lookup; + + ctrl->listen_fd.cb = NULL; + ctrl->listen_fd.data = ctrl; + ret = osmo_sock_init_ifd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, + IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT); + if (ret < 0) { + LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n", + addr, port); + talloc_free(ctrl); + return NULL; + } + LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to %s:%u\n", addr, port); + + return ctrl; +} + struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, ctrl_cmd_lookup lookup) { -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 20 11:10:58 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 11:10:58 +0000 Subject: osmo-pcu[master]: grps_debug.h: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1848/1/src/gprs_debug.h File src/gprs_debug.h: Line 19: I think it's better to convert all headers to #pragma at the same time (probably in a separate commit too). -- To view, visit https://gerrit.osmocom.org/1848 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 20 11:19:24 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 11:19:24 +0000 Subject: [PATCH] openbsc[master]: Handle DSD from HLR In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1838 to look at the new patch set (#3). Handle DSD from HLR Handle Delete Subscriber Data GSUP message from HLR to disable Packet Services for a given IMSI. Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Related: OS#1645 --- M openbsc/src/gprs/gprs_subscriber.c M openbsc/tests/sgsn/sgsn_test.c 2 files changed, 27 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/38/1838/3 diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index d3e2ea7..57f73c5 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -357,6 +357,26 @@ return 0; } +static int gprs_subscr_handle_gsup_dsd_req(struct gsm_subscriber *subscr, + struct osmo_gsup_message *gsup_msg) +{ + struct osmo_gsup_message gsup_reply = {0}; + + if (gsup_msg->cn_domain != OSMO_GSUP_CN_DOMAIN_PS) { + LOGGSUBSCRP(LOGL_ERROR, subscr, + "Rx GSUP message %s not supported for CS\n", + osmo_gsup_message_type_name(gsup_msg->message_type)); + gsup_reply.cause = GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_ERROR; + } else { + gsm0408_gprs_access_cancelled(subscr->sgsn_data->mm, + GMM_CAUSE_GPRS_NOTALLOWED); + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_RESULT; + } + + return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); +} + static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, struct osmo_gsup_message *gsup_msg) { @@ -644,7 +664,8 @@ } LOGGSUBSCRP(LOGL_INFO, subscr, - "Received GSUP message of type 0x%02x\n", gsup_msg.message_type); + "Received GSUP message %s\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); switch (gsup_msg.message_type) { case OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST: @@ -680,18 +701,13 @@ break; case OSMO_GSUP_MSGT_DELETE_DATA_REQUEST: - LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not yet implemented\n", - gsup_msg.message_type); - gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg, - GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); - rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + rc = gprs_subscr_handle_gsup_dsd_req(subscr, &gsup_msg); break; default: LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not valid at SGSN\n", - gsup_msg.message_type); + "Rx GSUP message %s not valid at SGSN\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type)) gprs_subscr_tx_gsup_error_reply( subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 0aa142f..ff07978 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -634,7 +634,8 @@ /* Inject DeleteSubscrData GSUP message */ last_updated_subscr = NULL; rc = rx_gsup_message(delete_data_req, sizeof(delete_data_req)); - OSMO_ASSERT(rc == -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); + if (rc != -GMM_CAUSE_SEM_INCORR_MSG) + printf("Unexpected response to DSD: %d\n", rc); OSMO_ASSERT(last_updated_subscr == NULL); /* Inject wrong LocCancelReq GSUP message */ -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 20 11:30:22 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 11:30:22 +0000 Subject: openbsc[master]: Handle DSD from HLR In-Reply-To: References: Message-ID: Patch Set 3: I verified that pdp context is deleted as well as GPRS service becomes unavailable to the phone. See update to OS#1645. Not sure if we have to cleanup anything else explicitly. Any ideas? -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 11:42:08 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 11:42:08 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 2: As this likely to be used very often I'd shorten it to LOGCTX_.. and LOGFILTER_.. similar to existing LOGL_.. and LOGP. -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:17:43 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 12:17:43 +0000 Subject: osmo-hlr[master]: Fix printf security warning In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (2 comments) sorry to -1 on a trivial patch, but plz clarify... https://gerrit.osmocom.org/#/c/1851/1//COMMIT_MSG Commit Message: Line 7: Fix printf security warning Please, as asked numerous times before, indicate the general area your patch modifies in the commit log summary. Also: what does "security warning" refer to, a compiler warning? A warning we're printing? https://gerrit.osmocom.org/#/c/1851/1/src/db.c File src/db.c: Line 49: LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); Is the fix the added "\n" character, or are we having two line feeds now? -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:21:06 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 12:21:06 +0000 Subject: osmo-hlr[master]: db: move duplicated code into helper functions In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1852 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iec81b56ab1ccc948807854a3947b04355a555c10 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:24:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 12:24:08 +0000 Subject: osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 IIUC we no longer need this change, because the nam_ps update now uses int sqlite3_changes() to verify that the IMSI exists? -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:26:52 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:26:52 +0000 Subject: osmo-hlr[master]: Fix printf security warning In-Reply-To: References: Message-ID: Patch Set 1: I don't think this code was ever really executed as it requires both: - error of particular type to happen - sqlite to be compiled with SQLITE_ENABLE_SQLLOG option So it's just to make compiler happy and reduce our warning count. -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:27:21 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:27:21 +0000 Subject: [PATCH] osmo-hlr[master]: Fix compiler's warning about printf security In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1851 to look at the new patch set (#2). Fix compiler's warning about printf security Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 --- M src/db.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/51/1851/2 diff --git a/src/db.c b/src/db.c index 1385502..e57d86f 100644 --- a/src/db.c +++ b/src/db.c @@ -46,7 +46,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:29:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 12:29:32 +0000 Subject: osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Patch Set 5: Code-Review+1 (2 comments) https://gerrit.osmocom.org/#/c/1840/5/src/db.h File src/db.h: Line 7: SEL_BY_IMSI = 0, hmm, yes, this is better formatting, but in fact we usually rely on the enums getting sequential values implicitly. If we have a cosmetic change in this patch anyway, we could drop all the numbers instead... what do you think? https://gerrit.osmocom.org/#/c/1840/5/src/db_hlr.c File src/db_hlr.c: Line 84: int rc = 0; (var set but value never used) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:29:46 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:29:46 +0000 Subject: osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Patch Set 1: No, we still need this for handle_cmd_ps() to check for subscriber's absence without calling DB update code. -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:37:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:37:26 +0000 Subject: [PATCH] osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#6). Add routines to update nam_ps Add SQL queries to change nam_ps value and function which uses them. Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 38 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/6 diff --git a/src/db.c b/src/db.c index d20b8b6..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -33,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) diff --git a/src/db.h b/src/db.h index 0fb76a0..0b3df88 100644 --- a/src/db.h +++ b/src/db.h @@ -4,13 +4,15 @@ #include enum stmt_idx { - SEL_BY_IMSI = 0, - UPD_VLR_BY_ID = 1, - UPD_SGSN_BY_ID = 2, - AUC_BY_IMSI = 3, - AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + SEL_BY_IMSI = 0, + UPD_VLR_BY_ID = 1, + UPD_SGSN_BY_ID = 2, + AUC_BY_IMSI = 3, + AUC_UPD_SQN = 4, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -70,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index 09ab6fc..a862e8f 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -77,6 +77,32 @@ return ret; } +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc = 0; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + rc = sqlite3_step(stmt); /* execute the statement */ + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + rc = sqlite3_changes(dbc->db); /* verify execution result */ + if (rc != 1) { + LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n", + rc); + rc = -EINVAL; + } + + db_remove_reset(stmt); + return rc; +} + int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, bool lu_is_ps) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:37:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:37:26 +0000 Subject: [PATCH] osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1841 to look at the new patch set (#5). CTRL: add enable/disable packet service cmds Add commands to enable/disable Packet Service for a given IMSI. Changes are synced to DB and propagated at runtime to SGSN (in case of disable command). Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Related: OS#1645 --- M src/ctrl.c M src/hlr.c M src/luop.c M src/luop.h 4 files changed, 59 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/41/1841/5 diff --git a/src/ctrl.c b/src/ctrl.c index b7514c5..8165926 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -32,6 +32,47 @@ #include "luop.h" #include "ctrl.h" +static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd, + bool enable) +{ + struct lu_operation *luop = NULL; + struct osmo_gsup_conn *co; + + if (db_subscr_get(gs->dbc, cmd->value, NULL) < 0) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + if (db_subscr_ps(gs->dbc, cmd->value, enable) < 0) { + cmd->reply = "Error updating DB"; + return CTRL_CMD_ERROR; + } + + if (!enable){ /* FIXME: only send to single SGSN where latest update for IMSI came from */ + llist_for_each_entry(co, &gs->clients, list) { + luop = lu_op_alloc_conn(co); + lu_op_fill_subscr(luop, gs->dbc, cmd->value); + lu_op_tx_del_subscr_data(luop); + } + } + + cmd->reply = "OK"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_WO_NOVRF(enable_ps, "enable-ps"); +static int set_enable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, true); +} + +CTRL_CMD_DEFINE_WO_NOVRF(disable_ps, "disable-ps"); +static int set_disable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, false); +} + CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); static int set_status_ps(struct ctrl_cmd *cmd, void *data) { @@ -55,6 +96,8 @@ { int rc = 0; + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_enable_ps); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_disable_ps); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); return rc; diff --git a/src/hlr.c b/src/hlr.c index 5ae5ff3..0a3642c 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -257,6 +257,8 @@ rx_purge_ms_req(conn, &gsup); break; /* responses to requests sent by us */ + case OSMO_GSUP_MSGT_DELETE_DATA_ERROR: + case OSMO_GSUP_MSGT_DELETE_DATA_RESULT: case OSMO_GSUP_MSGT_INSERT_DATA_ERROR: case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: diff --git a/src/luop.c b/src/luop.c index ecf31b4..937c02c 100644 --- a/src/luop.c +++ b/src/luop.c @@ -266,3 +266,16 @@ lu_op_statechg(luop, LU_S_ISD_SENT); osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } + +/*! Transmit Delete Subscriber Data to new VLR/SGSN */ +void lu_op_tx_del_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_DELETE_DATA_REQUEST); + + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); +} diff --git a/src/luop.h b/src/luop.h index 7e2fbb0..ab1bc24 100644 --- a/src/luop.h +++ b/src/luop.h @@ -78,3 +78,4 @@ void lu_op_tx_ack(struct lu_operation *luop); void lu_op_tx_cancel_old(struct lu_operation *luop); void lu_op_tx_insert_subscr_data(struct lu_operation *luop); +void lu_op_tx_del_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:37:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:37:26 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1827 to look at the new patch set (#7). Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/gsup_server.c M src/gsup_server.h M src/hlr.c 7 files changed, 162 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/7 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..ad744c6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -19,6 +20,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -32,6 +34,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -48,6 +51,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..b7514c5 --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,78 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "logging.h" +#include "db.h" +#include "luop.h" +#include "ctrl.h" + +CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); +static int set_status_ps(struct ctrl_cmd *cmd, void *data) +{ + struct lu_operation *luop = lu_op_alloc(data); + if (!luop) { + cmd->reply = "Internal HLR error"; + return CTRL_CMD_ERROR; + } + + if (!lu_op_fill_subscr(luop, luop->gsup_server->dbc, cmd->value)) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = luop->subscr.nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(gs, addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..95b58be --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs); diff --git a/src/gsup_server.c b/src/gsup_server.c index ea51f7d..90742c5 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -27,6 +27,7 @@ #include "gsup_server.h" #include "gsup_router.h" +#include "ctrl.h" static void osmo_gsup_server_send(struct osmo_gsup_conn *conn, int proto_ext, struct msgb *msg_tx) @@ -245,9 +246,10 @@ } struct osmo_gsup_server * -osmo_gsup_server_create(void *ctx, const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb) +osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, struct db_context *dbc, + struct llist_head *lu_op_lst) { struct osmo_gsup_server *gsups; int rc; @@ -272,6 +274,15 @@ if (rc < 0) goto failed; + gsups->dbc = dbc; + gsups->luop = lu_op_lst; + + if (ctrl_addr) + gsups->ctrl = hlr_controlif_setup(ctrl_addr, gsups); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + return gsups; failed: @@ -286,5 +297,8 @@ ipa_server_link_destroy(gsups->link); gsups->link = NULL; } + + db_close(gsups->dbc); + talloc_free(gsups); } diff --git a/src/gsup_server.h b/src/gsup_server.h index 484a0d7..ae303f5 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -5,6 +5,8 @@ #include #include +#include "db.h" + struct osmo_gsup_conn; /* Expects message in msg->l2h */ @@ -14,9 +16,18 @@ /* list of osmo_gsup_conn */ struct llist_head clients; + /* DB context */ + struct db_context *dbc; + + /* lu_operations list */ + struct llist_head *luop; + struct ipa_server_link *link; osmo_gsup_read_cb_t read_cb; struct llist_head routes; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; @@ -35,10 +46,12 @@ int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr, uint8_t tag); -struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, - const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb); +struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, const char *ip_addr, + uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, + struct db_context *dbc, + struct llist_head *lu_op_lst); void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); diff --git a/src/hlr.c b/src/hlr.c index d74d9fb..5ae5ff3 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -34,6 +34,7 @@ #include #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -204,8 +205,8 @@ bool is_ps = false; int rc; - LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s)\n", gsup->imsi, - is_ps ? "PS" : "CS"); + LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s), %u subscribers left\n", + gsup->imsi, is_ps ? "PS" : "CS", llist_count(&g_lu_ops)); memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi)); @@ -297,16 +298,19 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -i --ctrl address Set address to which Control Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { const char *config_file; const char *db_file; + const char *addr; bool daemonize; } cmdline_opts = { .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", + .addr = "127.0.0.1", .daemonize = false, }; @@ -322,12 +326,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'i'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:i:TV", long_options, &option_index); if (c == -1) break; @@ -342,6 +347,9 @@ break; case 'l': cmdline_opts.db_file = optarg; + break; + case 'i': + cmdline_opts.addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -380,7 +388,6 @@ case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); osmo_gsup_server_destroy(gs); - db_close(g_dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -443,7 +450,8 @@ exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb, + cmdline_opts.addr, g_dbc, &g_lu_ops); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); @@ -465,7 +473,7 @@ osmo_select_main(0); } - db_close(g_dbc); + osmo_gsup_server_destroy(gs); log_fini(); -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 7 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:37:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:37:26 +0000 Subject: [PATCH] osmo-hlr[master]: Fix printf security warning In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1851 to look at the new patch set (#3). Fix printf security warning Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 --- M src/db.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/51/1851/3 diff --git a/src/db.c b/src/db.c index 92983f9..d20b8b6 100644 --- a/src/db.c +++ b/src/db.c @@ -47,7 +47,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:37:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:37:26 +0000 Subject: [PATCH] osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1853 to look at the new patch set (#2). Make subscr parameter to db_subscr_get() optional This allows to check for subscriber's presence in DB without the need to bother with unused structure allocation. Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e --- M src/db_hlr.c 1 file changed, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/53/1853/2 diff --git a/src/db_hlr.c b/src/db_hlr.c index b7485f0..09ab6fc 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -54,22 +54,23 @@ goto out; } - /* obtain the various columns */ - subscr->id = sqlite3_column_int64(stmt, 0); - SL3_TXT(subscr->imsi, stmt, 1); - SL3_TXT(subscr->msisdn, stmt, 2); - /* FIXME: These should all be BLOBs as they might contain NUL */ - SL3_TXT(subscr->vlr_number, stmt, 3); - SL3_TXT(subscr->sgsn_number, stmt, 4); - SL3_TXT(subscr->sgsn_address, stmt, 5); - subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); - subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); - subscr->nam_cs = sqlite3_column_int(stmt, 8); - subscr->nam_ps = sqlite3_column_int(stmt, 9); - subscr->lmsi = sqlite3_column_int(stmt, 10); - subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); - subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); - + if (subscr) { + /* obtain the various columns */ + subscr->id = sqlite3_column_int64(stmt, 0); + SL3_TXT(subscr->imsi, stmt, 1); + SL3_TXT(subscr->msisdn, stmt, 2); + /* FIXME: These should all be BLOBs as they might contain NUL */ + SL3_TXT(subscr->vlr_number, stmt, 3); + SL3_TXT(subscr->sgsn_number, stmt, 4); + SL3_TXT(subscr->sgsn_address, stmt, 5); + subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); + subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); + subscr->nam_cs = sqlite3_column_int(stmt, 8); + subscr->nam_ps = sqlite3_column_int(stmt, 9); + subscr->lmsi = sqlite3_column_int(stmt, 10); + subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); + subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); + } out: db_remove_reset(stmt); -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:40:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:40:37 +0000 Subject: [PATCH] osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#7). Add routines to update nam_ps Add SQL queries to change nam_ps value and function which uses them. Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 38 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/7 diff --git a/src/db.c b/src/db.c index d20b8b6..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -33,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) diff --git a/src/db.h b/src/db.h index 0fb76a0..0b3df88 100644 --- a/src/db.h +++ b/src/db.h @@ -4,13 +4,15 @@ #include enum stmt_idx { - SEL_BY_IMSI = 0, - UPD_VLR_BY_ID = 1, - UPD_SGSN_BY_ID = 2, - AUC_BY_IMSI = 3, - AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + SEL_BY_IMSI = 0, + UPD_VLR_BY_ID = 1, + UPD_SGSN_BY_ID = 2, + AUC_BY_IMSI = 3, + AUC_UPD_SQN = 4, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -70,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index 09ab6fc..a862e8f 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -77,6 +77,32 @@ return ret; } +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc = 0; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + rc = sqlite3_step(stmt); /* execute the statement */ + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + rc = sqlite3_changes(dbc->db); /* verify execution result */ + if (rc != 1) { + LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n", + rc); + rc = -EINVAL; + } + + db_remove_reset(stmt); + return rc; +} + int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, bool lu_is_ps) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 7 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:40:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:40:37 +0000 Subject: [PATCH] osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1841 to look at the new patch set (#6). CTRL: add enable/disable packet service cmds Add commands to enable/disable Packet Service for a given IMSI. Changes are synced to DB and propagated at runtime to SGSN (in case of disable command). Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Related: OS#1645 --- M src/ctrl.c M src/hlr.c M src/luop.c M src/luop.h 4 files changed, 59 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/41/1841/6 diff --git a/src/ctrl.c b/src/ctrl.c index b7514c5..8165926 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -32,6 +32,47 @@ #include "luop.h" #include "ctrl.h" +static int handle_cmd_ps(struct osmo_gsup_server *gs, struct ctrl_cmd *cmd, + bool enable) +{ + struct lu_operation *luop = NULL; + struct osmo_gsup_conn *co; + + if (db_subscr_get(gs->dbc, cmd->value, NULL) < 0) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + if (db_subscr_ps(gs->dbc, cmd->value, enable) < 0) { + cmd->reply = "Error updating DB"; + return CTRL_CMD_ERROR; + } + + if (!enable){ /* FIXME: only send to single SGSN where latest update for IMSI came from */ + llist_for_each_entry(co, &gs->clients, list) { + luop = lu_op_alloc_conn(co); + lu_op_fill_subscr(luop, gs->dbc, cmd->value); + lu_op_tx_del_subscr_data(luop); + } + } + + cmd->reply = "OK"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_WO_NOVRF(enable_ps, "enable-ps"); +static int set_enable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, true); +} + +CTRL_CMD_DEFINE_WO_NOVRF(disable_ps, "disable-ps"); +static int set_disable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, false); +} + CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); static int set_status_ps(struct ctrl_cmd *cmd, void *data) { @@ -55,6 +96,8 @@ { int rc = 0; + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_enable_ps); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_disable_ps); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); return rc; diff --git a/src/hlr.c b/src/hlr.c index 5ae5ff3..0a3642c 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -257,6 +257,8 @@ rx_purge_ms_req(conn, &gsup); break; /* responses to requests sent by us */ + case OSMO_GSUP_MSGT_DELETE_DATA_ERROR: + case OSMO_GSUP_MSGT_DELETE_DATA_RESULT: case OSMO_GSUP_MSGT_INSERT_DATA_ERROR: case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: diff --git a/src/luop.c b/src/luop.c index ecf31b4..937c02c 100644 --- a/src/luop.c +++ b/src/luop.c @@ -266,3 +266,16 @@ lu_op_statechg(luop, LU_S_ISD_SENT); osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } + +/*! Transmit Delete Subscriber Data to new VLR/SGSN */ +void lu_op_tx_del_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_DELETE_DATA_REQUEST); + + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); +} diff --git a/src/luop.h b/src/luop.h index 7e2fbb0..ab1bc24 100644 --- a/src/luop.h +++ b/src/luop.h @@ -78,3 +78,4 @@ void lu_op_tx_ack(struct lu_operation *luop); void lu_op_tx_cancel_old(struct lu_operation *luop); void lu_op_tx_insert_subscr_data(struct lu_operation *luop); +void lu_op_tx_del_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:40:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:40:37 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1827 to look at the new patch set (#8). Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/gsup_server.c M src/gsup_server.h M src/hlr.c 7 files changed, 162 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/8 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..ad744c6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -19,6 +20,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -32,6 +34,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -48,6 +51,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..b7514c5 --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,78 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "logging.h" +#include "db.h" +#include "luop.h" +#include "ctrl.h" + +CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); +static int set_status_ps(struct ctrl_cmd *cmd, void *data) +{ + struct lu_operation *luop = lu_op_alloc(data); + if (!luop) { + cmd->reply = "Internal HLR error"; + return CTRL_CMD_ERROR; + } + + if (!lu_op_fill_subscr(luop, luop->gsup_server->dbc, cmd->value)) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = luop->subscr.nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(gs, addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..95b58be --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(const char *addr, + struct osmo_gsup_server *gs); diff --git a/src/gsup_server.c b/src/gsup_server.c index ea51f7d..90742c5 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -27,6 +27,7 @@ #include "gsup_server.h" #include "gsup_router.h" +#include "ctrl.h" static void osmo_gsup_server_send(struct osmo_gsup_conn *conn, int proto_ext, struct msgb *msg_tx) @@ -245,9 +246,10 @@ } struct osmo_gsup_server * -osmo_gsup_server_create(void *ctx, const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb) +osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, struct db_context *dbc, + struct llist_head *lu_op_lst) { struct osmo_gsup_server *gsups; int rc; @@ -272,6 +274,15 @@ if (rc < 0) goto failed; + gsups->dbc = dbc; + gsups->luop = lu_op_lst; + + if (ctrl_addr) + gsups->ctrl = hlr_controlif_setup(ctrl_addr, gsups); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + return gsups; failed: @@ -286,5 +297,8 @@ ipa_server_link_destroy(gsups->link); gsups->link = NULL; } + + db_close(gsups->dbc); + talloc_free(gsups); } diff --git a/src/gsup_server.h b/src/gsup_server.h index 484a0d7..ae303f5 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -5,6 +5,8 @@ #include #include +#include "db.h" + struct osmo_gsup_conn; /* Expects message in msg->l2h */ @@ -14,9 +16,18 @@ /* list of osmo_gsup_conn */ struct llist_head clients; + /* DB context */ + struct db_context *dbc; + + /* lu_operations list */ + struct llist_head *luop; + struct ipa_server_link *link; osmo_gsup_read_cb_t read_cb; struct llist_head routes; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; @@ -35,10 +46,12 @@ int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr, uint8_t tag); -struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, - const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb); +struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, const char *ip_addr, + uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + const char *ctrl_addr, + struct db_context *dbc, + struct llist_head *lu_op_lst); void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); diff --git a/src/hlr.c b/src/hlr.c index d74d9fb..5ae5ff3 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -34,6 +34,7 @@ #include #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -204,8 +205,8 @@ bool is_ps = false; int rc; - LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s)\n", gsup->imsi, - is_ps ? "PS" : "CS"); + LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s), %u subscribers left\n", + gsup->imsi, is_ps ? "PS" : "CS", llist_count(&g_lu_ops)); memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi)); @@ -297,16 +298,19 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -i --ctrl address Set address to which Control Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } static struct { const char *config_file; const char *db_file; + const char *addr; bool daemonize; } cmdline_opts = { .config_file = "osmo-hlr.cfg", .db_file = "hlr.db", + .addr = "127.0.0.1", .daemonize = false, }; @@ -322,12 +326,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'i'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:i:TV", long_options, &option_index); if (c == -1) break; @@ -342,6 +347,9 @@ break; case 'l': cmdline_opts.db_file = optarg; + break; + case 'i': + cmdline_opts.addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -380,7 +388,6 @@ case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); osmo_gsup_server_destroy(gs); - db_close(g_dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -443,7 +450,8 @@ exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb, + cmdline_opts.addr, g_dbc, &g_lu_ops); if (!gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); @@ -465,7 +473,7 @@ osmo_select_main(0); } - db_close(g_dbc); + osmo_gsup_server_destroy(gs); log_fini(); -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 8 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:40:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:40:37 +0000 Subject: [PATCH] osmo-hlr[master]: Fix compiler's warning about printf security In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1851 to look at the new patch set (#4). Fix compiler's warning about printf security Also, fix log formatting: SQL statements do not have '\n' at the end. Note: sqlite should be compiled with SQLITE_ENABLE_SQLLOG for this code to work at all. Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 --- M src/db.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/51/1851/4 diff --git a/src/db.c b/src/db.c index 92983f9..d20b8b6 100644 --- a/src/db.c +++ b/src/db.c @@ -47,7 +47,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:40:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:40:37 +0000 Subject: [PATCH] osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1853 to look at the new patch set (#3). Make subscr parameter to db_subscr_get() optional This allows to check for subscriber's presence in DB without the need to bother with unused structure allocation. Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e --- M src/db_hlr.c 1 file changed, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/53/1853/3 diff --git a/src/db_hlr.c b/src/db_hlr.c index b7485f0..09ab6fc 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -54,22 +54,23 @@ goto out; } - /* obtain the various columns */ - subscr->id = sqlite3_column_int64(stmt, 0); - SL3_TXT(subscr->imsi, stmt, 1); - SL3_TXT(subscr->msisdn, stmt, 2); - /* FIXME: These should all be BLOBs as they might contain NUL */ - SL3_TXT(subscr->vlr_number, stmt, 3); - SL3_TXT(subscr->sgsn_number, stmt, 4); - SL3_TXT(subscr->sgsn_address, stmt, 5); - subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); - subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); - subscr->nam_cs = sqlite3_column_int(stmt, 8); - subscr->nam_ps = sqlite3_column_int(stmt, 9); - subscr->lmsi = sqlite3_column_int(stmt, 10); - subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); - subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); - + if (subscr) { + /* obtain the various columns */ + subscr->id = sqlite3_column_int64(stmt, 0); + SL3_TXT(subscr->imsi, stmt, 1); + SL3_TXT(subscr->msisdn, stmt, 2); + /* FIXME: These should all be BLOBs as they might contain NUL */ + SL3_TXT(subscr->vlr_number, stmt, 3); + SL3_TXT(subscr->sgsn_number, stmt, 4); + SL3_TXT(subscr->sgsn_address, stmt, 5); + subscr->periodic_lu_timer = sqlite3_column_int(stmt, 6); + subscr->periodic_rau_tau_timer = sqlite3_column_int(stmt, 7); + subscr->nam_cs = sqlite3_column_int(stmt, 8); + subscr->nam_ps = sqlite3_column_int(stmt, 9); + subscr->lmsi = sqlite3_column_int(stmt, 10); + subscr->ms_purged_cs = sqlite3_column_int(stmt, 11); + subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); + } out: db_remove_reset(stmt); -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:41:06 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 12:41:06 +0000 Subject: [MERGED] osmo-hlr[master]: db: move duplicated code into helper functions In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: db: move duplicated code into helper functions ...................................................................... db: move duplicated code into helper functions * move common cleanup code into separate function * add helper function for IMSI binding * use errno.h instead of numbers Change-Id: Iec81b56ab1ccc948807854a3947b04355a555c10 --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 47 insertions(+), 46 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/db.c b/src/db.c index 1385502..92983f9 100644 --- a/src/db.c +++ b/src/db.c @@ -19,6 +19,7 @@ #include +#include #include #include "logging.h" @@ -57,6 +58,36 @@ } } +/* remove bindings and reset statement to be re-executed */ +bool db_remove_reset(sqlite3_stmt *stmt) +{ + int rc = sqlite3_clear_bindings(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); + return false; + } + + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); + return false; + } + return true; +} + +/* bind IMSI and do proper cleanup in case of failure */ +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi) +{ + int rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); + if (rc != SQLITE_OK) { + LOGP(DDB, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); + db_remove_reset(stmt); + return false; + } + + return true; +} + void db_close(struct db_context *dbc) { unsigned int i; diff --git a/src/db.h b/src/db.h index d569fb0..0fb76a0 100644 --- a/src/db.h +++ b/src/db.h @@ -20,6 +20,8 @@ sqlite3_stmt *stmt[_NUM_STMT]; }; +bool db_remove_reset(sqlite3_stmt *stmt); +bool db_bind_imsi(sqlite3_stmt *stmt, const char *imsi); void db_close(struct db_context *dbc); struct db_context *db_open(void *ctx, const char *fname); diff --git a/src/db_hlr.c b/src/db_hlr.c index 1b95556..b7485f0 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -42,17 +43,14 @@ sqlite3_stmt *stmt = dbc->stmt[SEL_BY_IMSI]; int rc, ret = 0; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGHLR(imsi, LOGL_ERROR, "Error binding IMSI: %d\n", rc); - return -1; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_ROW) { LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); - ret = -2; + ret = -ENOEXEC; goto out; } @@ -73,15 +71,7 @@ subscr->ms_purged_ps = sqlite3_column_int(stmt, 12); out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -105,13 +95,13 @@ rc = sqlite3_bind_int64(stmt, 1, subscr->id); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding ID: %d\n", rc); - return -1; + return -EINVAL; } rc = sqlite3_bind_text(stmt, 2, txt, -1, SQLITE_STATIC); if (rc != SQLITE_OK) { LOGP(DAUC, LOGL_ERROR, "Error binding VLR/SGSN Number: %d\n", rc); - ret = -2; + ret = -EBADMSG; goto out; } @@ -119,19 +109,10 @@ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error updating SQN: %d\n", rc); - ret = -3; - goto out; + ret = -ENOEXEC; } out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clerearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + db_remove_reset(stmt); return ret; } @@ -146,31 +127,18 @@ else stmt = dbc->stmt[UPD_PURGE_CS_BY_IMSI]; - rc = sqlite3_bind_text(stmt, 1, imsi, -1, SQLITE_STATIC); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error binding IMSI %s: %d\n", imsi, rc); - ret = -1; - goto out; - } + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; /* execute the statement */ rc = sqlite3_step(stmt); if (rc != SQLITE_DONE) { LOGP(DAUC, LOGL_ERROR, "Error setting Purged: %d\n", rc); - ret = -2; - goto out; + ret = -ENOEXEC; } /* FIXME: return 0 in case IMSI not known */ -out: - /* remove bindings and reset statement to be re-executed */ - rc = sqlite3_clear_bindings(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error clearing bindings: %d\n", rc); - } - rc = sqlite3_reset(stmt); - if (rc != SQLITE_OK) { - LOGP(DAUC, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc); - } + + db_remove_reset(stmt); return ret; } -- To view, visit https://gerrit.osmocom.org/1852 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iec81b56ab1ccc948807854a3947b04355a555c10 Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 12:49:55 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 12:49:55 +0000 Subject: osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Patch Set 8: Code-Review-1 (3 comments) For my next birthday you can get me a T-shirt that says "That's too general" ;) https://gerrit.osmocom.org/#/c/1827/8/src/gsup_server.h File src/gsup_server.h: Line 30: struct ctrl_handle *ctrl; I would prever to keep the CTRL and DB foo apart from the GSUP server. In openbsc, the GSUP client is also a pretty much standalone implementation. Can we add a global struct hlr_ctx instead, containing an osmo_gsup_server and the ctrl_ and db things alongside and separate, without too much effort? Would also be good to have that for possible future additions to OsmoHLR, which is now becoming more than just a GSUP server. https://gerrit.osmocom.org/#/c/1827/8/src/hlr.c File src/hlr.c: Line 301: printf(" -i --ctrl address Set address to which Control Interface should be bound, defaults to 127.0.0.1.\n"); better break in two lines to stay within 80. IMHO '-i' for 'interface' is too general. I found that the only option letter from 'ctrl' that's still available across Osmocom programs would be '-R'. (osmo-trx already has a '-R' but it won't have a Ctrl interface.) Would you be fine with '-R' instead? Line 308: const char *addr; 'addr' is too general. 'ctrl_bind_addr'? -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 8 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 20 13:28:38 2017 From: gerrit-no-reply at lists.osmocom.org (Ivan Kluchnikov) Date: Mon, 20 Feb 2017 13:28:38 +0000 Subject: [MERGED] osmo-bts[master]: oml: Fix incorrect usage of const variable abis_nm_att_tlvde... In-Reply-To: References: Message-ID: Ivan Kluchnikov has submitted this change and it was merged. Change subject: oml: Fix incorrect usage of const variable abis_nm_att_tlvdef_ipa ...................................................................... oml: Fix incorrect usage of const variable abis_nm_att_tlvdef_ipa This bug was introduced during moving oml definitions from osmo-bts to libosmocore in libosmocore 0bee65c0d89f81a4b90aa3d484016d9ba680dd46 and osmo-bts 2cf6b73a4278627331bdbbb4addf1a8bc1d964ce: The type of abis_nm_att_tlvdef_ipa was changed from struct tlv_definition to const struct tlv_definition, so: * create static abis_nm_att_tlvdef_ipa_local variable for oml attribute definitions * copy abis_nm_att_tlvdef_ipa to abis_nm_att_tlvdef_ipa_local * merge abis_nm_att_tlvdef with abis_nm_att_tlvdef_ipa_local * use abis_nm_att_tlvdef_ipa_local in oml_tlv_parse function Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c --- M src/common/oml.c 1 file changed, 5 insertions(+), 2 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/common/oml.c b/src/common/oml.c index 272123e..7069377 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -46,13 +46,15 @@ static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg); +static struct tlv_definition abis_nm_att_tlvdef_ipa_local = {}; + /* * support */ static int oml_tlv_parse(struct tlv_parsed *tp, const uint8_t *buf, int len) { - return tlv_parse(tp, &abis_nm_att_tlvdef_ipa, buf, len, 0, 0); + return tlv_parse(tp, &abis_nm_att_tlvdef_ipa_local, buf, len, 0, 0); } struct msgb *oml_msgb_alloc(void) @@ -1247,7 +1249,8 @@ int oml_init(struct gsm_abis_mo *mo) { DEBUGP(DOML, "Initializing OML attribute definitions\n"); - tlv_def_patch(&abis_nm_att_tlvdef_ipa, &abis_nm_att_tlvdef); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef_ipa); + tlv_def_patch(&abis_nm_att_tlvdef_ipa_local, &abis_nm_att_tlvdef); osmo_signal_register_handler(SS_FAIL, handle_fail_sig, mo); return 0; -- To view, visit https://gerrit.osmocom.org/1783 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia9f3c94ab247adeecb26a01c3ccd6f3a8c17ba1c Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Ivan Kluchnikov Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Ivan Kluchnikov Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 14:53:44 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 14:53:44 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 2: > As this likely to be used very often I'd shorten it to LOGCTX_.. > and LOGFILTER_.. similar to existing LOGL_.. and LOGP. Each LOGGING_FILTER_ is basically used twice. The LOGGING_CTX_ is used once per code path that would like to indicate an object to log. It's not *that* often but I see your point that we usually use just 'LOG' as prefix. The main reason though to pick this long name was to avoid conflicts with previous names. Now that I look at it that's indeed only LOG_FILTER_ALL. I'd prefer to keep the underscore, so would you be fine with LOG_FLT_ and LOG_CTX_ ? -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 14:54:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 14:54:46 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 2: technically ... would this actually need an OSMO_ prefix as well?? -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:20:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:20:47 +0000 Subject: [PATCH] openbsc[master]: cosmetic: remove unused scall_signal_data.subscr Message-ID: Review at https://gerrit.osmocom.org/1854 cosmetic: remove unused scall_signal_data.subscr Doesn't make sense to switch this to struct vlr_subscr when it isn't used at all. So let's remove it. Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9 --- M openbsc/include/openbsc/signal.h 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/54/1854/1 diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index 8f27b38..c862b21 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -151,7 +151,6 @@ }; struct scall_signal_data { - struct gsm_subscriber *subscr; struct gsm_subscriber_connection *conn; void *data; }; -- To view, visit https://gerrit.osmocom.org/1854 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:30:03 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:30:03 +0000 Subject: osmo-pcu[master]: grps_debug.h: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Patch Set 1: we actually have a quite mixed landscape of #pragma vs. #ifndef FOO_H in osmo-pcu. If changing all headers is necessary I'd prefer to not switch to #pragma in this .h... only doing it because this file is almost completely overhauled. -- To view, visit https://gerrit.osmocom.org/1848 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:30:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:30:21 +0000 Subject: [PATCH] osmo-pcu[master]: gprs_debug.h: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Hello Max, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1848 to look at the new patch set (#2). gprs_debug.h: remove unused cruft / cosmetic tweaks Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 --- M src/gprs_debug.h 1 file changed, 3 insertions(+), 18 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/48/1848/2 diff --git a/src/gprs_debug.h b/src/gprs_debug.h index 817c41e..863d76b 100644 --- a/src/gprs_debug.h +++ b/src/gprs_debug.h @@ -16,9 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef GPRS_DEBUG_H -#define GPRS_DEBUG_H + +#pragma once #include #ifdef __cplusplus @@ -29,6 +28,7 @@ #ifdef __cplusplus }; #endif + /* Debug Areas of the code */ enum { DCSN1, @@ -45,19 +45,4 @@ aDebug_LastEntry }; -/* we don't need a header dependency for this... */ - -struct gprs_nsvc; -struct bssgp_bvc_ctx; - -void log_set_imsi_filter(struct log_target *target, const char *imsi); -void log_set_nsvc_filter(struct log_target *target, - struct gprs_nsvc *nsvc); -void log_set_bvc_filter(struct log_target *target, - struct bssgp_bvc_ctx *bctx); - extern const struct log_info gprs_log_info; - - - -#endif // GPRS_DEBUG_H -- To view, visit https://gerrit.osmocom.org/1848 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:32:53 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:32:53 +0000 Subject: osmo-hlr[master]: Fix compiler's warning about printf security In-Reply-To: References: Message-ID: Patch Set 4: > I don't think this code was ever really executed as it requires > both: > - error of particular type to happen > - sqlite to be compiled with SQLITE_ENABLE_SQLLOG option > So it's just to make compiler happy and reduce our warning count. see also https://osmocom.org/issues/1873 ... setting the log cb fails so far. -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:33:14 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:33:14 +0000 Subject: osmo-hlr[master]: Fix compiler's warning about printf security In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:35:19 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 15:35:19 +0000 Subject: [MERGED] osmo-hlr[master]: Fix compiler's warning about printf security In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: Fix compiler's warning about printf security ...................................................................... Fix compiler's warning about printf security Also, fix log formatting: SQL statements do not have '\n' at the end. Note: sqlite should be compiled with SQLITE_ENABLE_SQLLOG for this code to work at all. Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 --- M src/db.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/db.c b/src/db.c index 92983f9..d20b8b6 100644 --- a/src/db.c +++ b/src/db.c @@ -47,7 +47,7 @@ LOGP(DDB, LOGL_DEBUG, "Opened database\n"); break; case 1: - LOGP(DDB, LOGL_DEBUG, stmt); + LOGP(DDB, LOGL_DEBUG, "%s\n", stmt); break; case 2: LOGP(DDB, LOGL_DEBUG, "Closed database\n"); -- To view, visit https://gerrit.osmocom.org/1851 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5e53de54ad1b9da18e1f414932cfd21be71ab154 Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:40:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:40:22 +0000 Subject: osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Patch Set 6: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1841/6/src/ctrl.c File src/ctrl.c: Line 46: if (db_subscr_ps(gs->dbc, cmd->value, enable) < 0) { This command will fail if the subscriber does not exist. Why is above db_subscr_get() necessary? -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Mon Feb 20 15:41:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 20 Feb 2017 15:41:08 +0000 Subject: osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Patch Set 3: I still think that it is not needed, see comment for #1841 -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 16:55:30 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 16:55:30 +0000 Subject: [PATCH] osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1841 to look at the new patch set (#7). CTRL: add enable/disable packet service cmds Add commands to enable/disable Packet Service for a given IMSI. Changes are synced to DB and propagated at runtime to SGSN (in case of disable command). Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Related: OS#1645 --- M src/ctrl.c M src/gsup_server.c M src/gsup_server.h M src/hlr.c M src/luop.c M src/luop.h 6 files changed, 72 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/41/1841/7 diff --git a/src/ctrl.c b/src/ctrl.c index a167171..ec1a85d 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -33,6 +33,46 @@ #include "luop.h" #include "ctrl.h" +static int handle_cmd_ps(struct hlr *ctx, struct ctrl_cmd *cmd, bool enable) +{ + struct lu_operation *luop = NULL; + struct osmo_gsup_conn *co; + + if (db_subscr_get(ctx->dbc, cmd->value, NULL) < 0) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + if (db_subscr_ps(ctx->dbc, cmd->value, enable) < 0) { + cmd->reply = "Error updating DB"; + return CTRL_CMD_ERROR; + } + + if (!enable){ /* FIXME: only send to single SGSN where latest update for IMSI came from */ + llist_for_each_entry(co, &ctx->gs->clients, list) { + luop = lu_op_alloc_conn(co); + lu_op_fill_subscr(luop, ctx->dbc, cmd->value); + lu_op_tx_del_subscr_data(luop); + } + } + + cmd->reply = "OK"; + + return CTRL_CMD_REPLY; +} + +CTRL_CMD_DEFINE_WO_NOVRF(enable_ps, "enable-ps"); +static int set_enable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, true); +} + +CTRL_CMD_DEFINE_WO_NOVRF(disable_ps, "disable-ps"); +static int set_disable_ps(struct ctrl_cmd *cmd, void *data) +{ + return handle_cmd_ps(data, cmd, false); +} + CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); static int set_status_ps(struct ctrl_cmd *cmd, void *data) { @@ -57,6 +97,8 @@ { int rc = 0; + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_enable_ps); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_disable_ps); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); return rc; diff --git a/src/gsup_server.c b/src/gsup_server.c index ea51f7d..d431637 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -245,9 +245,9 @@ } struct osmo_gsup_server * -osmo_gsup_server_create(void *ctx, const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb) +osmo_gsup_server_create(void *ctx, const char *ip_addr, uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + struct llist_head *lu_op_lst) { struct osmo_gsup_server *gsups; int rc; @@ -272,6 +272,8 @@ if (rc < 0) goto failed; + gsups->luop = lu_op_lst; + return gsups; failed: diff --git a/src/gsup_server.h b/src/gsup_server.h index 484a0d7..885fe52 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -14,6 +14,9 @@ /* list of osmo_gsup_conn */ struct llist_head clients; + /* lu_operations list */ + struct llist_head *luop; + struct ipa_server_link *link; osmo_gsup_read_cb_t read_cb; struct llist_head routes; @@ -36,9 +39,10 @@ uint8_t tag); struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, - const char *ip_addr, - uint16_t tcp_port, - osmo_gsup_read_cb_t read_cb); + const char *ip_addr, + uint16_t tcp_port, + osmo_gsup_read_cb_t read_cb, + struct llist_head *lu_op_lst); void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); diff --git a/src/hlr.c b/src/hlr.c index a22780b..baa69ec 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -259,6 +259,8 @@ rx_purge_ms_req(conn, &gsup); break; /* responses to requests sent by us */ + case OSMO_GSUP_MSGT_DELETE_DATA_ERROR: + case OSMO_GSUP_MSGT_DELETE_DATA_RESULT: case OSMO_GSUP_MSGT_INSERT_DATA_ERROR: case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: @@ -447,7 +449,8 @@ exit(1); } - g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb, + &g_lu_ops); if (!g_hlr->gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); diff --git a/src/luop.c b/src/luop.c index ecf31b4..937c02c 100644 --- a/src/luop.c +++ b/src/luop.c @@ -266,3 +266,16 @@ lu_op_statechg(luop, LU_S_ISD_SENT); osmo_timer_schedule(&luop->timer, ISD_TIMEOUT_SECS, 0); } + +/*! Transmit Delete Subscriber Data to new VLR/SGSN */ +void lu_op_tx_del_subscr_data(struct lu_operation *luop) +{ + struct osmo_gsup_message gsup; + + fill_gsup_msg(&gsup, luop, OSMO_GSUP_MSGT_DELETE_DATA_REQUEST); + + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* Send ISD to new VLR/SGSN */ + _luop_tx_gsup(luop, &gsup); +} diff --git a/src/luop.h b/src/luop.h index 7e2fbb0..ab1bc24 100644 --- a/src/luop.h +++ b/src/luop.h @@ -78,3 +78,4 @@ void lu_op_tx_ack(struct lu_operation *luop); void lu_op_tx_cancel_old(struct lu_operation *luop); void lu_op_tx_insert_subscr_data(struct lu_operation *luop); +void lu_op_tx_del_subscr_data(struct lu_operation *luop); -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 7 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 16:55:30 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 16:55:30 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1827 to look at the new patch set (#9). Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/hlr.c M src/hlr.h 6 files changed, 134 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/9 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 6e7fcdc..9ba3217 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -20,6 +21,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -33,6 +35,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -49,6 +52,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..a167171 --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,81 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "logging.h" +#include "db.h" +#include "hlr.h" +#include "luop.h" +#include "ctrl.h" + +CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); +static int set_status_ps(struct ctrl_cmd *cmd, void *data) +{ + struct hlr *ctx = data; + struct lu_operation *luop = lu_op_alloc(ctx->gs); + if (!luop) { + cmd->reply = "Internal HLR error"; + return CTRL_CMD_ERROR; + } + + if (!lu_op_fill_subscr(luop, ctx->dbc, cmd->value)) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = luop->subscr.nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(struct hlr *ctx, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(ctx, + ctx->ctrl_bind_addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..663de30 --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(struct hlr *ctx, + struct osmo_gsup_server *gs); diff --git a/src/hlr.c b/src/hlr.c index b72e178..a22780b 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -35,6 +35,7 @@ #include "hlr.h" #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -299,6 +300,8 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -R --ctrl address Set address to which Control " + "Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } @@ -314,12 +317,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'R'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:R:TV", long_options, &option_index); if (c == -1) break; @@ -334,6 +338,9 @@ break; case 'l': g_hlr->db_file = optarg; + break; + case 'R': + g_hlr->ctrl_bind_addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -446,6 +453,12 @@ exit(1); } + if (g_hlr->ctrl_bind_addr) + g_hlr->ctrl = hlr_controlif_setup(g_hlr, g_hlr->gs); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + osmo_init_ignore_signals(); signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); diff --git a/src/hlr.h b/src/hlr.h index fb62fc4..c968163 100644 --- a/src/hlr.h +++ b/src/hlr.h @@ -36,4 +36,7 @@ /* DB context */ struct db_context *dbc; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 9 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 20 16:55:31 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 16:55:31 +0000 Subject: [PATCH] osmo-hlr[master]: Add global HLR struct Message-ID: Review at https://gerrit.osmocom.org/1856 Add global HLR struct Introduce g_hlr of type 'struct hlr' which holds pointers to all globally accessible variables. Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Related: OS#1645 --- M src/Makefile.am M src/db_test.c M src/hlr.c A src/hlr.h 4 files changed, 81 insertions(+), 40 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/56/1856/1 diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..6e7fcdc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ noinst_HEADERS = \ auc.h \ + hlr.h \ db.h \ luop.h \ gsup_router.h \ diff --git a/src/db_test.c b/src/db_test.c index 75fcb62..1b4bc92 100644 --- a/src/db_test.c +++ b/src/db_test.c @@ -4,12 +4,13 @@ #include #include "db.h" +#include "hlr.h" #include "rand.h" #include "logging.h" -static struct db_context *g_dbc; +static struct hlr *g_hlr; -static int test(const char *imsi) +static int test(const char *imsi, struct db_context *dbc) { struct osmo_auth_vector vec[3]; int rc, i; @@ -19,7 +20,7 @@ for (i = 0; i < ARRAY_SIZE(vec); i++) vec[i].res_len = 0; - rc = db_get_auc(g_dbc, imsi, vec, ARRAY_SIZE(vec), NULL, NULL); + rc = db_get_auc(dbc, imsi, vec, ARRAY_SIZE(vec), NULL, NULL); if (rc <= 0) { LOGP(DMAIN, LOGL_ERROR, "Cannot obtain auth tuples for '%s'\n", imsi); return rc; @@ -46,6 +47,9 @@ { int rc; + g_hlr = talloc_zero(NULL, struct hlr); + g_hlr->db_file = "hlr.db"; + rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { fprintf(stderr, "Error initializing logging\n"); @@ -59,24 +63,24 @@ exit(1); } - g_dbc = db_open(NULL, "hlr.db"); - if (!g_dbc) { + g_hlr->dbc = db_open(NULL, "hlr.db"); + if (!g_hlr->dbc) { LOGP(DMAIN, LOGL_ERROR, "Error opening database\n"); exit(1); } /* non-existing subscriber */ - rc = test("901990123456789"); + rc = test("901990123456789", g_hlr->dbc); /* 2G only AUC data (COMP128v1 / MILENAGE) */ - rc = test("901990000000001"); + rc = test("901990000000001", g_hlr->dbc); /* 2G + 3G AUC data (COMP128v1 / MILENAGE) */ - rc = test("901990000000002"); + rc = test("901990000000002", g_hlr->dbc); /* 3G AUC data (MILENAGE) */ - rc = test("901990000000003"); + rc = test("901990000000003", g_hlr->dbc); LOGP(DMAIN, LOGL_NOTICE, "Exiting\n"); - db_close(g_dbc); + db_close(g_hlr->dbc); log_fini(); diff --git a/src/hlr.c b/src/hlr.c index d74d9fb..b72e178 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -33,6 +33,7 @@ #include #include +#include "hlr.h" #include "db.h" #include "logging.h" #include "gsup_server.h" @@ -41,7 +42,7 @@ #include "luop.h" #include "hlr_vty.h" -static struct db_context *g_dbc; +static struct hlr *g_hlr; /*********************************************************************** * Send Auth Info handling @@ -49,7 +50,8 @@ /* process an incoming SAI request */ static int rx_send_auth_info(struct osmo_gsup_conn *conn, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup, + struct db_context *dbc) { struct osmo_gsup_message gsup_out; struct msgb *msg_out; @@ -59,7 +61,7 @@ memset(&gsup_out, 0, sizeof(gsup_out)); memcpy(&gsup_out.imsi, &gsup->imsi, sizeof(gsup_out.imsi)); - rc = db_get_auc(g_dbc, gsup->imsi, gsup_out.auth_vectors, + rc = db_get_auc(dbc, gsup->imsi, gsup_out.auth_vectors, ARRAY_SIZE(gsup_out.auth_vectors), gsup->rand, gsup->auts); if (rc < 0) { @@ -157,7 +159,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { + if (!lu_op_fill_subscr(luop, g_hlr->dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -216,7 +218,7 @@ * we have on record. Only update if yes */ /* Perform the actual update of the DB */ - rc = db_subscr_purge(g_dbc, gsup->imsi, is_ps); + rc = db_subscr_purge(g_hlr->dbc, gsup->imsi, is_ps); if (rc == 1) gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT; @@ -247,7 +249,7 @@ switch (gsup.message_type) { /* requests sent to us */ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST: - rx_send_auth_info(conn, &gsup); + rx_send_auth_info(conn, &gsup, g_hlr->dbc); break; case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST: rx_upd_loc_req(conn, &gsup); @@ -300,16 +302,6 @@ printf(" -V --version Print the version of OsmoHLR.\n"); } -static struct { - const char *config_file; - const char *db_file; - bool daemonize; -} cmdline_opts = { - .config_file = "osmo-hlr.cfg", - .db_file = "hlr.db", - .daemonize = false, -}; - static void handle_options(int argc, char **argv) { while (1) { @@ -338,16 +330,16 @@ print_help(); exit(0); case 'c': - cmdline_opts.config_file = optarg; + g_hlr->config_file = optarg; break; case 'l': - cmdline_opts.db_file = optarg; + g_hlr->db_file = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); break; case 'D': - cmdline_opts.daemonize = 1; + g_hlr->daemonize = true; break; case 's': log_set_use_color(osmo_stderr_target, 0); @@ -372,15 +364,14 @@ } static void *hlr_ctx = NULL; -static struct osmo_gsup_server *gs; static void signal_hdlr(int signal) { switch (signal) { case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); - osmo_gsup_server_destroy(gs); - db_close(g_dbc); + osmo_gsup_server_destroy(g_hlr->gs); + db_close(g_hlr->dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -405,6 +396,12 @@ hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); msgb_talloc_ctx_init(hlr_ctx, 0); + g_hlr = talloc_zero(hlr_ctx, struct hlr); + + g_hlr->config_file = "osmo-hlr.cfg"; + g_hlr->db_file = "hlr.db"; + g_hlr->ctrl_bind_addr = "127.0.0.1"; + rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { fprintf(stderr, "Error initializing logging\n"); @@ -415,11 +412,11 @@ handle_options(argc, argv); hlr_vty_init(&hlr_log_info); - rc = vty_read_config_file(cmdline_opts.config_file, NULL); + rc = vty_read_config_file(g_hlr->config_file, NULL); if (rc < 0) { LOGP(DMAIN, LOGL_FATAL, "Failed to parse the config file: '%s'\n", - cmdline_opts.config_file); + g_hlr->config_file); return rc; } @@ -437,14 +434,14 @@ exit(1); } - g_dbc = db_open(hlr_ctx, cmdline_opts.db_file); - if (!g_dbc) { + g_hlr->dbc = db_open(hlr_ctx, g_hlr->db_file); + if (!g_hlr->dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); - if (!gs) { + g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + if (!g_hlr->gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); } @@ -453,7 +450,7 @@ signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); - if (cmdline_opts.daemonize) { + if (g_hlr->daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); @@ -465,7 +462,7 @@ osmo_select_main(0); } - db_close(g_dbc); + db_close(g_hlr->dbc); log_fini(); diff --git a/src/hlr.h b/src/hlr.h new file mode 100644 index 0000000..fb62fc4 --- /dev/null +++ b/src/hlr.h @@ -0,0 +1,39 @@ +/* OsmoHLR generic header */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +struct hlr { + /* command-line options */ + const char *config_file; + const char *db_file; + const char *ctrl_bind_addr; + bool daemonize; + + /* GSUP server pointer */ + struct osmo_gsup_server *gs; + + /* DB context */ + struct db_context *dbc; +}; -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Mon Feb 20 17:01:52 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 17:01:52 +0000 Subject: osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Patch Set 4: I think it's a very bad idea to intermix "check" and "update" logic when it comes to DB. Yes, we can use (feels like abuse actually) SQL UPDATE function to deduce that if update fails than subscriber entry is missing but that makes code unnecessary hard to read and maintain. I'd rather have explicit check for subscriber availability using SQL SELECT. -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 20 17:25:42 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 20 Feb 2017 17:25:42 +0000 Subject: [PATCH] libosmo-abis[master]: Enable sanitize Message-ID: Review at https://gerrit.osmocom.org/1857 Enable sanitize Add ./configure option to enable ASAN checks and use it for jenkins tests. While at it - also move to /bin/sh shebang as we don't use bashisms anyway. Change-Id: Ie26e54ab6b850c9adf124a6bc613ec9bc9e8a6e2 --- M configure.ac M contrib/jenkins.sh 2 files changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/57/1857/1 diff --git a/configure.ac b/configure.ac index f463c2e..99d83f6 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,18 @@ AC_CHECK_HEADERS(dahdi/user.h,,AC_MSG_WARN(DAHDI input driver will not be built)) +AC_ARG_ENABLE(sanitize, + [AS_HELP_STRING( + [--enable-sanitize], + [Compile with address sanitizer enabled], + )], + [sanitize=$enableval], [sanitize="no"]) +if test x"$sanitize" = x"yes" +then + CFLAGS+=" -fsanitize=address -fsanitize=undefined" + CPPFLAGS+=" -fsanitize=address -fsanitize=undefined" +fi + AC_OUTPUT( libosmoabis.pc libosmotrau.pc diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh index 403909b..2ca3f46 100755 --- a/contrib/jenkins.sh +++ b/contrib/jenkins.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh set -ex @@ -24,7 +24,7 @@ set -x autoreconf --install --force -./configure +./configure --enable-sanitize $MAKE $PARALLEL_MAKE $MAKE distcheck \ || cat-testlogs.sh -- To view, visit https://gerrit.osmocom.org/1857 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie26e54ab6b850c9adf124a6bc613ec9bc9e8a6e2 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 21 00:36:39 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 00:36:39 +0000 Subject: [PATCH] openbsc[master]: subscriber conn: add indicator for originating interface Message-ID: Review at https://gerrit.osmocom.org/1858 subscriber conn: add indicator for originating interface Add via_iface to gsm_subscriber_connection to indicate whether a conn is coming in via 2G/GERAN/A-Interface (IFACE_A) or 3G/UTRAN/Iu-Interface (IFACE_IU). Prepares for Iu, but also for libvlr to decide between GSM or UMTS Auth. Until actual Iu support is merged to master, this indicator will aid VLR unit testing. Change-Id: I93b870522f725170e4265a5543f6b680383d7465 --- M openbsc/include/openbsc/gsm_data.h M openbsc/src/libbsc/bsc_api.c 2 files changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/58/1858/1 diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index ac573c4..a776d2d 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -104,6 +104,12 @@ uint8_t last_seen_nr; }; +enum interface_type { + IFACE_UNKNOWN, + IFACE_A, /* 2G / GERAN / A-interface */ + IFACE_IU /* 3G / UTRAN / Iu-interface (IuCS or IuPS) */ +}; + /* active radio connection of a mobile subscriber */ struct gsm_subscriber_connection { struct llist_head entry; @@ -146,6 +152,8 @@ struct osmo_timer_list T10; /* BSC */ struct gsm_lchan *secondary_lchan; /* BSC */ + /* connected via 2G or 3G? */ + enum interface_type via_iface; }; diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 7a48296..83c6c8c 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -251,6 +251,7 @@ conn->network = net; conn->lchan = lchan; conn->bts = lchan->ts->trx->bts; + conn->via_iface = IFACE_A; lchan->conn = conn; llist_add_tail(&conn->entry, &net->subscr_conns); return conn; -- To view, visit https://gerrit.osmocom.org/1858 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I93b870522f725170e4265a5543f6b680383d7465 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 21 09:05:28 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 09:05:28 +0000 Subject: libosmocore[master]: vty: fix "everything" logging option In-Reply-To: References: Message-ID: Patch Set 7: Could you update #71 with your thoughts on logging? I think it would be more appropriate place. -- To view, visit https://gerrit.osmocom.org/1582 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib51987fb2f64a70fca130f3799dc8fd71cc7085c Gerrit-PatchSet: 7 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 10:45:22 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 10:45:22 +0000 Subject: [PATCH] osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1840 to look at the new patch set (#9). Add routines to update nam_ps Add SQL queries to change nam_ps value and function which uses them. Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 38 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/40/1840/9 diff --git a/src/db.c b/src/db.c index d20b8b6..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -33,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) diff --git a/src/db.h b/src/db.h index 0fb76a0..0b3df88 100644 --- a/src/db.h +++ b/src/db.h @@ -4,13 +4,15 @@ #include enum stmt_idx { - SEL_BY_IMSI = 0, - UPD_VLR_BY_ID = 1, - UPD_SGSN_BY_ID = 2, - AUC_BY_IMSI = 3, - AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + SEL_BY_IMSI = 0, + UPD_VLR_BY_ID = 1, + UPD_SGSN_BY_ID = 2, + AUC_BY_IMSI = 3, + AUC_UPD_SQN = 4, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -70,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index b7485f0..2c6b243 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -76,6 +76,32 @@ return ret; } +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + rc = sqlite3_step(stmt); /* execute the statement */ + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + rc = sqlite3_changes(dbc->db); /* verify execution result */ + if (rc != 1) { + LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n", + rc); + rc = -EINVAL; + } + + db_remove_reset(stmt); + return rc; +} + int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, bool lu_is_ps) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 9 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 21 10:47:00 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 10:47:00 +0000 Subject: osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Patch Set 8: I'm a bit reluctant to remove explicit numbers from enum as it's used directly as an array index. Is the numbering guaranteed by C spec or we just rely on implementation-dependent quirk? Do you have corresponding spec reference by any chance? -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 8 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 10:49:03 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 10:49:03 +0000 Subject: openbsc[master]: subscriber conn: add indicator for originating interface In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1858 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I93b870522f725170e4265a5543f6b680383d7465 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 10:49:46 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 10:49:46 +0000 Subject: openbsc[master]: cosmetic: remove unused scall_signal_data.subscr In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1854 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 10:55:28 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 10:55:28 +0000 Subject: libosmocore[master]: utils/conv_gen.py: add test vectors generation feature In-Reply-To: References: Message-ID: Patch Set 8: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1585 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie10c47ee952f253b1ba77ecf6e79f2c033545bc1 Gerrit-PatchSet: 8 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 11:25:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 11:25:21 +0000 Subject: osmo-hlr[master]: Add global HLR struct In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) https://gerrit.osmocom.org/#/c/1856/2/src/hlr.h File src/hlr.h: Line 32: bool daemonize; well, ok ... the cmdline options struct was separate on purpose, because a) they are no longer needed once main() has set things up and "should" remain limited to main(), b) to not have cmdline opt parsing access the server data structures to make semantically obvious that we should have some sort of validation and c) to have a separation between settings coming in via cmdline options and the actual settings used to run things -- there may be modifications or stuff from the VTY config. Historically, and across other Osmocom binaries, the cmd line opts were single global variables in main.c and I usually combine them in a cmdline_opts struct to indicate where it's coming from. OTOH I wouldn't want to delay your work further based on these evangelics, I'll leave it up to you whether to keep it separate now. Once the VTY config starts to overlap these options, we can also separate them back... -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 21 11:26:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 11:26:22 +0000 Subject: osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Patch Set 9: Code-Review+2 nice -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 9 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 11:28:54 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 11:28:54 +0000 Subject: osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Patch Set 10: Code-Review+1 (1 comment) https://gerrit.osmocom.org/#/c/1827/10/src/hlr.c File src/hlr.c: Line 304: "Interface should be bound, defaults to 127.0.0.1.\n"); heh, sorry, I meant particularly break the line in the printed output with \n and indenting. cosmetics... -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 10 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 21 11:31:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 11:31:21 +0000 Subject: osmo-hlr[master]: CTRL: add enable/disable packet service cmds In-Reply-To: References: Message-ID: Patch Set 8: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1841/8/src/ctrl.c File src/ctrl.c: Line 41: if (db_subscr_get(ctx->dbc, cmd->value, NULL) < 0) { I still think that this is not needed, because below db_subscr_ps() checks IMSI existence for free. -- To view, visit https://gerrit.osmocom.org/1841 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I23163ce8667292443ed61cb15c928357dba4b4be Gerrit-PatchSet: 8 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 21 11:42:06 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 11:42:06 +0000 Subject: osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Patch Set 5: > I think it's a very bad idea to intermix "check" and "update" logic > when it comes to DB. You want an indicator to ensure that the IMSI exists. You can get it from the UPDATE operation. It is usually desirable to minimize database hits above all, so when we can halve the database hits needed to set a parameter, that's what we should do. Also I don't really like the "get" API with NULL param, and the code selecting all columns from a table and then not using them at all. So if we want to have a "does it exist" function I'd prefer it to have dedicated SQL in a separate function. ... but at the moment we don't need either, in my opinion. Could we get other reviews to tip the scale? -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 5 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 12:01:10 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 12:01:10 +0000 Subject: libosmo-abis[master]: Enable sanitize In-Reply-To: References: Message-ID: Patch Set 1: (2 comments) https://gerrit.osmocom.org/#/c/1857/1/contrib/jenkins.sh File contrib/jenkins.sh: Line 1: #!/bin/sh completely unrelated change :/ Line 27: ./configure --enable-sanitize Holger had the point that possibly an ASAN build hides bugs that are present in a non-ASAN build. Though I personally wouldn't have thought of that I trust him on that. So we should test both with and without ASAN. Below 'make distcheck' doesn't do --enable-sanitize, right? So we have both covered? -- To view, visit https://gerrit.osmocom.org/1857 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie26e54ab6b850c9adf124a6bc613ec9bc9e8a6e2 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 21 12:05:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 12:05:02 +0000 Subject: libosmo-abis[master]: Enable sanitize In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 yes, from the jenkins console output after 'make distcheck': && ../configure \ \ \ --srcdir=.. --prefix="$dc_install_base" \ && make -- To view, visit https://gerrit.osmocom.org/1857 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie26e54ab6b850c9adf124a6bc613ec9bc9e8a6e2 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 12:05:50 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 12:05:50 +0000 Subject: [MERGED] libosmo-abis[master]: Enable sanitize In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: Enable sanitize ...................................................................... Enable sanitize Add ./configure option to enable ASAN checks and use it for jenkins tests. While at it - also move to /bin/sh shebang as we don't use bashisms anyway. Change-Id: Ie26e54ab6b850c9adf124a6bc613ec9bc9e8a6e2 --- M configure.ac M contrib/jenkins.sh 2 files changed, 14 insertions(+), 2 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/configure.ac b/configure.ac index f463c2e..99d83f6 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,18 @@ AC_CHECK_HEADERS(dahdi/user.h,,AC_MSG_WARN(DAHDI input driver will not be built)) +AC_ARG_ENABLE(sanitize, + [AS_HELP_STRING( + [--enable-sanitize], + [Compile with address sanitizer enabled], + )], + [sanitize=$enableval], [sanitize="no"]) +if test x"$sanitize" = x"yes" +then + CFLAGS+=" -fsanitize=address -fsanitize=undefined" + CPPFLAGS+=" -fsanitize=address -fsanitize=undefined" +fi + AC_OUTPUT( libosmoabis.pc libosmotrau.pc diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh index 403909b..2ca3f46 100755 --- a/contrib/jenkins.sh +++ b/contrib/jenkins.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh set -ex @@ -24,7 +24,7 @@ set -x autoreconf --install --force -./configure +./configure --enable-sanitize $MAKE $PARALLEL_MAKE $MAKE distcheck \ || cat-testlogs.sh -- To view, visit https://gerrit.osmocom.org/1857 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie26e54ab6b850c9adf124a6bc613ec9bc9e8a6e2 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 21 12:06:16 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 12:06:16 +0000 Subject: [MERGED] osmo-hlr[master]: Add routines to update nam_ps In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: Add routines to update nam_ps ...................................................................... Add routines to update nam_ps Add SQL queries to change nam_ps value and function which uses them. Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef --- M src/db.c M src/db.h M src/db_hlr.c 3 files changed, 38 insertions(+), 8 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/db.c b/src/db.c index d20b8b6..aa4726c 100644 --- a/src/db.c +++ b/src/db.c @@ -33,6 +33,8 @@ [AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = ? WHERE subscriber_id = ?", [UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs=1 WHERE imsi = ?", [UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps=1 WHERE imsi = ?", + [SET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=1 WHERE imsi = ?", + [UNSET_NAM_PS_BY_IMSI] = "UPDATE subscriber SET nam_ps=0 WHERE imsi = ?", }; static void sql3_error_log_cb(void *arg, int err_code, const char *msg) diff --git a/src/db.h b/src/db.h index 0fb76a0..0b3df88 100644 --- a/src/db.h +++ b/src/db.h @@ -4,13 +4,15 @@ #include enum stmt_idx { - SEL_BY_IMSI = 0, - UPD_VLR_BY_ID = 1, - UPD_SGSN_BY_ID = 2, - AUC_BY_IMSI = 3, - AUC_UPD_SQN = 4, - UPD_PURGE_CS_BY_IMSI, - UPD_PURGE_PS_BY_IMSI, + SEL_BY_IMSI = 0, + UPD_VLR_BY_ID = 1, + UPD_SGSN_BY_ID = 2, + AUC_BY_IMSI = 3, + AUC_UPD_SQN = 4, + UPD_PURGE_CS_BY_IMSI = 5, + UPD_PURGE_PS_BY_IMSI = 6, + SET_NAM_PS_BY_IMSI = 7, + UNSET_NAM_PS_BY_IMSI = 8, _NUM_STMT }; @@ -70,7 +72,7 @@ int db_subscr_get(struct db_context *dbc, const char *imsi, struct hlr_subscriber *subscr); - +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable); int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, diff --git a/src/db_hlr.c b/src/db_hlr.c index b7485f0..2c6b243 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -76,6 +76,32 @@ return ret; } +int db_subscr_ps(struct db_context *dbc, const char *imsi, bool enable) +{ + sqlite3_stmt *stmt = + dbc->stmt[enable ? SET_NAM_PS_BY_IMSI : UNSET_NAM_PS_BY_IMSI]; + int rc; + + if (!db_bind_imsi(stmt, imsi)) + return -EINVAL; + + rc = sqlite3_step(stmt); /* execute the statement */ + if (rc != SQLITE_DONE) { + LOGHLR(imsi, LOGL_ERROR, "Error executing SQL: %d\n", rc); + rc = -ENOEXEC; + } + + rc = sqlite3_changes(dbc->db); /* verify execution result */ + if (rc != 1) { + LOGHLR(imsi, LOGL_ERROR, "SQL modified %d rows (expected 1)\n", + rc); + rc = -EINVAL; + } + + db_remove_reset(stmt); + return rc; +} + int db_subscr_lu(struct db_context *dbc, const struct hlr_subscriber *subscr, const char *vlr_or_sgsn_number, bool lu_is_ps) -- To view, visit https://gerrit.osmocom.org/1840 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I24fb79e084b2dfa6a81b52f448b94a86e47014ef Gerrit-PatchSet: 9 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 21 12:10:58 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 12:10:58 +0000 Subject: osmo-hlr[master]: Add global HLR struct In-Reply-To: References: Message-ID: Patch Set 2: Could you elaborate on why the separation necessary at all? I mean why vty config could alter those options when they are part of cmdline_opts struct but can't in case of hlr struct? What am I missing in here? -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 14:03:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 14:03:47 +0000 Subject: [PATCH] libosmocore[master]: gsm_04_08.h: add struct with R99 names for SI3 Ctrl Chan Descr Message-ID: Review at https://gerrit.osmocom.org/1859 gsm_04_08.h: add struct with R99 names for SI3 Ctrl Chan Descr Rename current gsm48_control_channel_descr to &_r98, add &_r99 with adjusted naming and add a #define to direct to &_r99; this is like found further below in this file for gsm48_hdr_msg_type(). Assuming that no-one is using the spare bits, redirecting to R99 like this will not cause any code conflicts. In the r99 struct, spare1 and spare2 are in different places, so rather rename them to spare_1 and spare_2 to make sure we get a compiler barf *if* anyone tries to use them with the wrong _r9x struct. Motivation: the R99 Control Channel Description defines MSCR to indicate whether the MSC is R99+ or not. To use UMTS AKA on GSM networks, we want to indicate that our libmsc is capable of R99, like OsmoSGSN already does. Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 --- M include/osmocom/gsm/protocol/gsm_04_08.h 1 file changed, 16 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/1859/1 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index bbc2774..fb38c03 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -619,7 +619,7 @@ } __attribute__ ((packed)); /* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */ -struct gsm48_control_channel_descr { +struct gsm48_control_channel_descr_r98 { uint8_t ccch_conf :3, bs_ag_blks_res :3, att :1, @@ -629,6 +629,21 @@ uint8_t t3212; } __attribute__ ((packed)); +/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */ +struct gsm48_control_channel_descr_r99 { + uint8_t ccch_conf :3, + bs_ag_blks_res :3, + att :1, + mscr :1; + uint8_t bs_pa_mfrms : 3, + spare_1 :2, + cbq3 :2, + spare_2 :1; + uint8_t t3212; +} __attribute__ ((packed)); + +#define gsm48_control_channel_descr gsm48_control_channel_descr_r99 + enum gsm48_dtx_mode { GSM48_DTX_MAY_BE_USED, GSM48_DTX_SHALL_BE_USED, -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 21 14:26:41 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 14:26:41 +0000 Subject: libosmocore[master]: gsm_04_08.h: add struct with R99 names for SI3 Ctrl Chan Descr In-Reply-To: References: Message-ID: Patch Set 1: Why do we need to keep old _r98 at all? I think it would be cleaner to just update the struct to r99, add note to TODO-RELEASE and bump ABI/API versions (if necessary). -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 15:05:33 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 21 Feb 2017 15:05:33 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#11). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 332 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/11 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..6eb2c31 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,301 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + uint8_t version; + uint8_t controldata; + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + goto fail; + } else if (ret < 0) { + perror("read "); + goto fail; + } else if (ret < 2) { + /* packet must be at least 2 byte long to hold version + control/data header */ + LOGP(DLMI, LOGL_ERROR, "received to small packet: %d < 2", ret); + ret = -1; + goto fail; + } + msgb_put(msg, ret); + + /* check version header */ + version = msgb_pull_u8(msg); + controldata = msgb_pull_u8(msg); + + if (version != UNIXSOCKET_PROTO_VERSION) { + LOGP(DLMI, LOGL_ERROR, "received message with invalid version %d. valid: %d", + ret, UNIXSOCKET_PROTO_VERSION); + ret = -1; + goto fail; + } + + if (controldata == UNIXSOCKET_PROTO_DATA) { + return e1inp_rx_ts_lapd(&line->ts[0], msg); + } else if (controldata == UNIXSOCKET_PROTO_CONTROL) { + LOGP(DLMI, LOGL_ERROR, "received (invalid) control message."); + ret = -1; + } else { + LOGP(DLMI, LOGL_ERROR, "received invalid message."); + ret = -1; + } +fail: + msgb_free(msg); + return ret; +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +static void unixsocket_write_msg(struct msgb *msg, struct osmo_fd *bfd) { + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg_lapd_cb(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + + /* add version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_DATA); + + unixsocket_write_msg(msg, bfd); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg_lapd_cb, &config->fd, + e1inp_dlsap_up, e1i_ts, &lapd_profile_abis); + } + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_CONTROL); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} + -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 11 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 21 15:07:43 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 21 Feb 2017 15:07:43 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#12). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 335 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/12 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..1311d0f --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,304 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + uint8_t version; + uint8_t controldata; + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + goto fail; + } else if (ret < 0) { + perror("read "); + goto fail; + } else if (ret < 2) { + /* packet must be at least 2 byte long to hold version + control/data header */ + LOGP(DLMI, LOGL_ERROR, "received to small packet: %d < 2", ret); + ret = -1; + goto fail; + } + msgb_put(msg, ret); + + /* check version header */ + version = msgb_pull_u8(msg); + controldata = msgb_pull_u8(msg); + + if (version != UNIXSOCKET_PROTO_VERSION) { + LOGP(DLMI, LOGL_ERROR, "received message with invalid version %d. valid: %d", + ret, UNIXSOCKET_PROTO_VERSION); + ret = -1; + goto fail; + } + + switch (controldata) { + case UNIXSOCKET_PROTO_DATA: + return e1inp_rx_ts_lapd(&line->ts[0], msg); + case UNIXSOCKET_PROTO_CONTROL: + LOGP(DLMI, LOGL_ERROR, "received (invalid) control message."); + ret = -1; + break; + default: + LOGP(DLMI, LOGL_ERROR, "received invalid message."); + ret = -1; + break; + } +fail: + msgb_free(msg); + return ret; +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +static void unixsocket_write_msg(struct msgb *msg, struct osmo_fd *bfd) { + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg_lapd_cb(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + + /* add version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_DATA); + + unixsocket_write_msg(msg, bfd); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg_lapd_cb, &config->fd, + e1inp_dlsap_up, e1i_ts, &lapd_profile_abis); + } + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_CONTROL); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} + -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 12 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 21 15:14:52 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 21 Feb 2017 15:14:52 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#13). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c 5 files changed, 335 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/13 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..2642e43 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,304 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + uint8_t version; + uint8_t controldata; + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + goto fail; + } else if (ret < 0) { + perror("read "); + goto fail; + } else if (ret < 2) { + /* packet must be at least 2 byte long to hold version + control/data header */ + LOGP(DLMI, LOGL_ERROR, "received to small packet: %d < 2", ret); + ret = -1; + goto fail; + } + msgb_put(msg, ret); + + /* check version header */ + version = msgb_pull_u8(msg); + controldata = msgb_pull_u8(msg); + + if (version != UNIXSOCKET_PROTO_VERSION) { + LOGP(DLMI, LOGL_ERROR, "received message with invalid version %d. valid: %d", + ret, UNIXSOCKET_PROTO_VERSION); + ret = -1; + goto fail; + } + + switch (controldata) { + case UNIXSOCKET_PROTO_DATA: + return e1inp_rx_ts_lapd(&line->ts[0], msg); + case UNIXSOCKET_PROTO_CONTROL: + LOGP(DLMI, LOGL_ERROR, "received (invalid) control message."); + ret = -1; + break; + default: + LOGP(DLMI, LOGL_ERROR, "received invalid message."); + ret = -1; + break; + } +fail: + msgb_free(msg); + return ret; +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +static void unixsocket_write_msg(struct msgb *msg, struct osmo_fd *bfd) { + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg_lapd_cb(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + + /* add version header */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_DATA); + + unixsocket_write_msg(msg, bfd); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg_lapd_cb, &config->fd, + e1inp_dlsap_up, e1i_ts, &lapd_profile_abis); + } + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_CONTROL); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} + -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 13 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 21 15:20:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 21 Feb 2017 15:20:38 +0000 Subject: [PATCH] libosmocore[master]: gsup decode: fix expectation of AUTS length, should be 14 Message-ID: Review at https://gerrit.osmocom.org/1860 gsup decode: fix expectation of AUTS length, should be 14 The wrong expectation caused OsmoHLR to fail on Auth Sync. Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f --- M src/gsm/gsup.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/1860/1 diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index ec1dc90..a813ed8 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -339,9 +339,9 @@ break; case OSMO_GSUP_AUTS_IE: - if (value_len != 16) { + if (value_len != 14) { LOGP(DLGSUP, LOGL_ERROR, - "AUTS length != 16 received\n"); + "AUTS length != 14 received\n"); return -GMM_CAUSE_COND_IE_ERR; } gsup_msg->auts = value; -- To view, visit https://gerrit.osmocom.org/1860 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 21 16:20:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 21 Feb 2017 16:20:57 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 13: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 13 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 16:21:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 21 Feb 2017 16:21:49 +0000 Subject: openbsc[master]: Handle DSD from HLR In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 16:22:11 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 21 Feb 2017 16:22:11 +0000 Subject: osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Patch Set 10: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 10 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 16:24:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 16:24:37 +0000 Subject: [MERGED] openbsc[master]: Handle DSD from HLR In-Reply-To: References: Message-ID: Max has submitted this change and it was merged. Change subject: Handle DSD from HLR ...................................................................... Handle DSD from HLR Handle Delete Subscriber Data GSUP message from HLR to disable Packet Services for a given IMSI. Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Related: OS#1645 --- M openbsc/src/gprs/gprs_subscriber.c M openbsc/tests/sgsn/sgsn_test.c 2 files changed, 27 insertions(+), 10 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index d3e2ea7..57f73c5 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -357,6 +357,26 @@ return 0; } +static int gprs_subscr_handle_gsup_dsd_req(struct gsm_subscriber *subscr, + struct osmo_gsup_message *gsup_msg) +{ + struct osmo_gsup_message gsup_reply = {0}; + + if (gsup_msg->cn_domain != OSMO_GSUP_CN_DOMAIN_PS) { + LOGGSUBSCRP(LOGL_ERROR, subscr, + "Rx GSUP message %s not supported for CS\n", + osmo_gsup_message_type_name(gsup_msg->message_type)); + gsup_reply.cause = GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_ERROR; + } else { + gsm0408_gprs_access_cancelled(subscr->sgsn_data->mm, + GMM_CAUSE_GPRS_NOTALLOWED); + gsup_reply.message_type = OSMO_GSUP_MSGT_DELETE_DATA_RESULT; + } + + return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); +} + static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, struct osmo_gsup_message *gsup_msg) { @@ -644,7 +664,8 @@ } LOGGSUBSCRP(LOGL_INFO, subscr, - "Received GSUP message of type 0x%02x\n", gsup_msg.message_type); + "Received GSUP message %s\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); switch (gsup_msg.message_type) { case OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST: @@ -680,18 +701,13 @@ break; case OSMO_GSUP_MSGT_DELETE_DATA_REQUEST: - LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not yet implemented\n", - gsup_msg.message_type); - gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg, - GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); - rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; + rc = gprs_subscr_handle_gsup_dsd_req(subscr, &gsup_msg); break; default: LOGGSUBSCRP(LOGL_ERROR, subscr, - "Rx GSUP message type %d not valid at SGSN\n", - gsup_msg.message_type); + "Rx GSUP message %s not valid at SGSN\n", + osmo_gsup_message_type_name(gsup_msg.message_type)); if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type)) gprs_subscr_tx_gsup_error_reply( subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 0aa142f..ff07978 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -634,7 +634,8 @@ /* Inject DeleteSubscrData GSUP message */ last_updated_subscr = NULL; rc = rx_gsup_message(delete_data_req, sizeof(delete_data_req)); - OSMO_ASSERT(rc == -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); + if (rc != -GMM_CAUSE_SEM_INCORR_MSG) + printf("Unexpected response to DSD: %d\n", rc); OSMO_ASSERT(last_updated_subscr == NULL); /* Inject wrong LocCancelReq GSUP message */ -- To view, visit https://gerrit.osmocom.org/1838 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 21 16:52:48 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 21 Feb 2017 16:52:48 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#14). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c A src/input/unixsocket_proto.h 6 files changed, 348 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/14 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..e6610f4 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,305 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" +#include "unixsocket_proto.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + LOGP(DLINP, LOGL_ERROR, "unixsocket: closing socket. Exception cb called.\n"); + + close(bfd->fd); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + uint8_t version; + uint8_t controldata; + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + goto fail; + } else if (ret < 0) { + perror("read "); + goto fail; + } else if (ret < 2) { + /* packet must be at least 2 byte long to hold version + control/data header */ + LOGP(DLMI, LOGL_ERROR, "received to small packet: %d < 2", ret); + ret = -1; + goto fail; + } + msgb_put(msg, ret); + + /* check version header */ + version = msgb_pull_u8(msg); + controldata = msgb_pull_u8(msg); + + if (version != UNIXSOCKET_PROTO_VERSION) { + LOGP(DLMI, LOGL_ERROR, "received message with invalid version %d. valid: %d", + ret, UNIXSOCKET_PROTO_VERSION); + ret = -1; + goto fail; + } + + switch (controldata) { + case UNIXSOCKET_PROTO_DATA: + return e1inp_rx_ts_lapd(&line->ts[0], msg); + case UNIXSOCKET_PROTO_CONTROL: + LOGP(DLMI, LOGL_ERROR, "received (invalid) control message."); + ret = -1; + break; + default: + LOGP(DLMI, LOGL_ERROR, "received invalid message."); + ret = -1; + break; + } +fail: + msgb_free(msg); + return ret; +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, "unixsocket: no message available"); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_INFO, "unixsocket: sending: %s", msgb_hexdump(msg)); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +static void unixsocket_write_msg(struct msgb *msg, struct osmo_fd *bfd) { + int ret; + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg_lapd_cb(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + + /* data|control */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_DATA); + /* add version header */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_VERSION); + + unixsocket_write_msg(msg, bfd); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, "unixsocket: OOM in line update\n"); + return -ENOMEM; + } + + config = line->driver_data; + + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, OSMO_SOCK_F_CONNECT); + + if (ret < 0) { + talloc_free(config); + return ret; + } + + config->fd.fd = ret; + if (osmo_fd_register(&config->fd) < 0) { + close(config->fd.fd); + return -EIO; + } + + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + + if (!e1i_ts->lapd) + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg_lapd_cb, &config->fd, + e1inp_dlsap_up, e1i_ts, &lapd_profile_abis); + } + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_CONTROL); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} + diff --git a/src/input/unixsocket_proto.h b/src/input/unixsocket_proto.h new file mode 100644 index 0000000..beba667 --- /dev/null +++ b/src/input/unixsocket_proto.h @@ -0,0 +1,12 @@ + +#ifndef UNIXSOCKET_PROTO_H +#define UNIXSOCKET_PROTO_H + +#define UNIXSOCKET_PROTO_VERSION 0x1 + +enum { + UNIXSOCKET_PROTO_DATA = 0x0, + UNIXSOCKET_PROTO_CONTROL = 0x1, +}; + +#endif /* UNIXSOCKET_PROTO_H */ -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 14 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 21 16:56:43 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 21 Feb 2017 16:56:43 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#15). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c A src/input/unixsocket_proto.h 6 files changed, 386 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/15 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..e6b3f77 --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,343 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" +#include "unixsocket_proto.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int unixsocket_line_update(struct e1inp_line *line); +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + + LOGP(DLINP, LOGL_ERROR, + "Socket connection failure, reconnecting... (line=%p, fd=%d)\n", + line, bfd->fd); + + /* Unregister faulty file descriptor from select loop */ + if(osmo_fd_is_registered(bfd)) { + LOGP(DLINP, LOGL_DEBUG, + "removing inactive socket from select loop... (line=%p, fd=%d)\n", + line, bfd->fd); + osmo_fd_unregister(bfd); + } + + /* Close faulty file descriptor */ + close(bfd->fd); + + unixsocket_line_update(line); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + uint8_t version; + uint8_t controldata; + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + goto fail; + } else if (ret < 0) { + perror("read "); + goto fail; + } else if (ret < 2) { + /* packet must be at least 2 byte long to hold version + control/data header */ + LOGP(DLMI, LOGL_ERROR, "received to small packet: %d < 2", ret); + ret = -1; + goto fail; + } + msgb_put(msg, ret); + + LOGP(DLMI, LOGL_DEBUG, "rx msg: %s (fd=%d)\n", + osmo_hexdump_nospc(msg->data, msg->len), bfd->fd); + + /* check version header */ + version = msgb_pull_u8(msg); + controldata = msgb_pull_u8(msg); + + if (version != UNIXSOCKET_PROTO_VERSION) { + LOGP(DLMI, LOGL_ERROR, "received message with invalid version %d. valid: %d", + ret, UNIXSOCKET_PROTO_VERSION); + ret = -1; + goto fail; + } + + switch (controldata) { + case UNIXSOCKET_PROTO_DATA: + return e1inp_rx_ts_lapd(&line->ts[0], msg); + case UNIXSOCKET_PROTO_CONTROL: + LOGP(DLMI, LOGL_ERROR, "received (invalid) control message."); + ret = -1; + break; + default: + LOGP(DLMI, LOGL_ERROR, "received invalid message."); + ret = -1; + break; + } +fail: + msgb_free(msg); + return ret; +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, + "no message available (line=%p)\n", line); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_DEBUG, "sending: %s (line=%p)\n", + msgb_hexdump(msg), line); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +static void unixsocket_write_msg(struct msgb *msg, struct osmo_fd *bfd) { + int ret; + + LOGP(DLMI, LOGL_DEBUG, "tx msg: %s (fd=%d)\n", + osmo_hexdump_nospc(msg->data, msg->len), bfd->fd); + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg_lapd_cb(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + + /* data|control */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_DATA); + /* add version header */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_VERSION); + + unixsocket_write_msg(msg, bfd); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, + "OOM in line update (line=%p)\n", line); + return -ENOMEM; + } + + config = line->driver_data; + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + + /* Open unix domain socket */ + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, + OSMO_SOCK_F_CONNECT); + if (ret < 0) { + /* Note: We will not free the allocated driver_data memory if + * opening the socket fails. The caller may want to call this + * function multiple times using config->fd.data as line + * parameter. Freeing now would destroy that reference. */ + LOGP(DLINP, LOGL_ERROR, + "unable to open socket: %s (line=%p, fd=%d)\n", sock_path, + line, config->fd.fd); + return ret; + } + LOGP(DLINP, LOGL_DEBUG, + "successfully opend (new) socket: %s (line=%p, fd=%d, ret=%d)\n", + sock_path, line, config->fd.fd, ret); + config->fd.fd = ret; + + /* Register socket in select loop */ + if (osmo_fd_register(&config->fd) < 0) { + LOGP(DLINP, LOGL_ERROR, + "error registering new socket (line=%p, fd=%d)\n", + line, config->fd.fd); + close(config->fd.fd); + return -EIO; + } + + /* Set line parameter */ + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + if (!e1i_ts->lapd) { + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg_lapd_cb, &config->fd, + e1inp_dlsap_up, e1i_ts, &lapd_profile_abis); + } + } + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_CONTROL); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} + diff --git a/src/input/unixsocket_proto.h b/src/input/unixsocket_proto.h new file mode 100644 index 0000000..beba667 --- /dev/null +++ b/src/input/unixsocket_proto.h @@ -0,0 +1,12 @@ + +#ifndef UNIXSOCKET_PROTO_H +#define UNIXSOCKET_PROTO_H + +#define UNIXSOCKET_PROTO_VERSION 0x1 + +enum { + UNIXSOCKET_PROTO_DATA = 0x0, + UNIXSOCKET_PROTO_CONTROL = 0x1, +}; + +#endif /* UNIXSOCKET_PROTO_H */ -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 15 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 21 17:43:19 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 21 Feb 2017 17:43:19 +0000 Subject: libosmocore[master]: gsup decode: fix expectation of AUTS length, should be 14 In-Reply-To: References: Message-ID: Patch Set 1: Don't we have #define somewhere in libosmocore? -- To view, visit https://gerrit.osmocom.org/1860 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 21 18:57:09 2017 From: gerrit-no-reply at lists.osmocom.org (lynxis lazus) Date: Tue, 21 Feb 2017 18:57:09 +0000 Subject: [PATCH] libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1198 to look at the new patch set (#16). add basic unixsocket support Allow to connect to a unix socket for communicating with LAPD. Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a --- M include/osmocom/abis/e1_input.h M src/Makefile.am M src/e1_input.c M src/e1_input_vty.c A src/input/unixsocket.c A src/input/unixsocket_proto.h 6 files changed, 390 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/98/1198/16 diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 4c7f8a0..8501d5c 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -183,6 +183,7 @@ unsigned int num; const char *name; unsigned int port_nr; + char *sock_path; struct rate_ctr_group *rate_ctr; /* keepalive configuration */ @@ -303,6 +304,9 @@ struct gsm_network; int ipaccess_setup(struct gsm_network *gsmnet); +/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */ +void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel); + extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/src/Makefile.am b/src/Makefile.am index b24f2cf..760c1f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ - input/rs232.c + input/rs232.c \ + input/unixsocket.c libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff --git a/src/e1_input.c b/src/e1_input.c index 09fea59..1e1252e 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -807,6 +807,7 @@ void e1inp_dahdi_init(void); void e1inp_ipaccess_init(void); void e1inp_rs232_init(void); +void e1inp_unixsocket_init(void); void e1inp_init(void) { @@ -821,4 +822,5 @@ #endif e1inp_ipaccess_init(); e1inp_rs232_init(); + e1inp_unixsocket_init(); } diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index 5320bb3..9d69586 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -38,12 +38,13 @@ /* CONFIG */ -#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa)" +#define E1_DRIVER_NAMES "(misdn|misdn_lapd|dahdi|ipa|unixsocket)" #define E1_DRIVER_HELP "mISDN supported E1 Card (kernel LAPD)\n" \ "mISDN supported E1 Card (userspace LAPD)\n" \ "DAHDI supported E1/T1/J1 Card\n" \ "IPA TCP/IP input\n" \ - "HSL TCP/IP input" + "HSL TCP/IP input\n" \ + "Unix socket input\n" #define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" @@ -84,6 +85,25 @@ } line->port_nr = atoi(argv[1]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd, + "e1_line <0-255> socket .SOCKET", + E1_LINE_HELP "Set socket path for unixsocket\n" + "socket path\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + line->sock_path = talloc_strdup(line, argv[1]); return CMD_SUCCESS; } @@ -363,6 +383,7 @@ vty_install_default(L_E1INP_NODE); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_port_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd); install_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd); diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c new file mode 100644 index 0000000..cfe4f5c --- /dev/null +++ b/src/input/unixsocket.c @@ -0,0 +1,347 @@ +/* OpenBSC Abis receive lapd over a unix socket */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Alexander Couzens + * Based on other e1_input drivers. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "internal.h" +#include "unixsocket_proto.h" + +void *tall_unixsocket_ctx; +#define UNIXSOCKET_ALLOC_SIZE 1600 +#define UNIXSOCKET_SOCK_PATH_DEFAULT "/tmp/osmo_abis_line_" + +struct unixsocket_line { + struct osmo_fd fd; +}; + +static int unixsocket_line_update(struct e1inp_line *line); +static int ts_want_write(struct e1inp_ts *e1i_ts); + +static int unixsocket_exception_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + + LOGP(DLINP, LOGL_ERROR, + "Socket connection failure, reconnecting... (line=%p, fd=%d)\n", + line, bfd->fd); + + /* Unregister faulty file descriptor from select loop */ + if(osmo_fd_is_registered(bfd)) { + LOGP(DLINP, LOGL_DEBUG, + "removing inactive socket from select loop... (line=%p, fd=%d)\n", + line, bfd->fd); + osmo_fd_unregister(bfd); + } + + /* Close faulty file descriptor */ + close(bfd->fd); + + unixsocket_line_update(line); + + return 0; +} + +static int unixsocket_read_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS"); + uint8_t version; + uint8_t controldata; + int ret; + + if (!msg) + return -ENOMEM; + + ret = read(bfd->fd, msg->data, UNIXSOCKET_ALLOC_SIZE - 16); + if (ret == 0) { + unixsocket_exception_cb(bfd); + goto fail; + } else if (ret < 0) { + perror("read "); + goto fail; + } else if (ret < 2) { + /* packet must be at least 2 byte long to hold version + control/data header */ + LOGP(DLMI, LOGL_ERROR, "received to small packet: %d < 2", ret); + ret = -1; + goto fail; + } + msgb_put(msg, ret); + + LOGP(DLMI, LOGL_DEBUG, "rx msg: %s (fd=%d)\n", + osmo_hexdump_nospc(msg->data, msg->len), bfd->fd); + + /* check version header */ + version = msgb_pull_u8(msg); + controldata = msgb_pull_u8(msg); + + if (version != UNIXSOCKET_PROTO_VERSION) { + LOGP(DLMI, LOGL_ERROR, "received message with invalid version %d. valid: %d", + ret, UNIXSOCKET_PROTO_VERSION); + ret = -1; + goto fail; + } + + switch (controldata) { + case UNIXSOCKET_PROTO_DATA: + return e1inp_rx_ts_lapd(&line->ts[0], msg); + case UNIXSOCKET_PROTO_CONTROL: + LOGP(DLMI, LOGL_ERROR, "received (invalid) control message."); + ret = -1; + break; + default: + LOGP(DLMI, LOGL_ERROR, "received invalid message."); + ret = -1; + break; + } +fail: + msgb_free(msg); + return ret; +} + +static void timeout_ts1_write(void *data) +{ + struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; + + /* trigger write of ts1, due to tx delay timer */ + ts_want_write(e1i_ts); +} + +static int unixsocket_write_cb(struct osmo_fd *bfd) +{ + struct e1inp_line *line = bfd->data; + struct e1inp_ts *e1i_ts = &line->ts[0]; + struct msgb *msg; + struct e1inp_sign_link *sign_link; + + bfd->when &= ~BSC_FD_WRITE; + + /* get the next msg for this timeslot */ + msg = e1inp_tx_ts(e1i_ts, &sign_link); + if (!msg) { + /* no message after tx delay timer */ + LOGP(DLINP, LOGL_INFO, + "no message available (line=%p)\n", line); + return 0; + } + + /* set tx delay timer for next event */ + e1i_ts->sign.tx_timer.cb = timeout_ts1_write; + e1i_ts->sign.tx_timer.data = e1i_ts; + + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + + LOGP(DLINP, LOGL_DEBUG, "sending: %s (line=%p)\n", + msgb_hexdump(msg), line); + lapd_transmit(e1i_ts->lapd, sign_link->tei, + sign_link->sapi, msg); + + return 0; +} + +static int unixsocket_cb(struct osmo_fd *bfd, unsigned int what) +{ + int ret = 0; + + if (what & BSC_FD_READ) + ret = unixsocket_read_cb(bfd); + if (what & BSC_FD_WRITE) + ret = unixsocket_write_cb(bfd); + + return ret; +} + +static int ts_want_write(struct e1inp_ts *e1i_ts) +{ + struct unixsocket_line *line = e1i_ts->line->driver_data; + + line->fd.when |= BSC_FD_WRITE; + + return 0; +} + +static void unixsocket_write_msg(struct msgb *msg, struct osmo_fd *bfd) { + int ret; + + LOGP(DLMI, LOGL_DEBUG, "tx msg: %s (fd=%d)\n", + osmo_hexdump_nospc(msg->data, msg->len), bfd->fd); + + ret = write(bfd->fd, msg->data, msg->len); + msgb_free(msg); + if (ret == -1) + unixsocket_exception_cb(bfd); + else if (ret < 0) + LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); +} + +/*! + * \brief unixsocket_write_msg lapd callback for data to unixsocket + * \param msg + * \param cbdata + */ +static void unixsocket_write_msg_lapd_cb(struct msgb *msg, void *cbdata) +{ + struct osmo_fd *bfd = cbdata; + + /* data|control */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_DATA); + /* add version header */ + msgb_push_u8(msg, UNIXSOCKET_PROTO_VERSION); + + unixsocket_write_msg(msg, bfd); +} + +static int unixsocket_line_update(struct e1inp_line *line) +{ + struct unixsocket_line *config; + char sock_path[PATH_MAX]; + int ret = 0; + int i; + + if (line->sock_path) + strcpy(sock_path, line->sock_path); + else + sprintf(sock_path, "%s%d", UNIXSOCKET_SOCK_PATH_DEFAULT, + line->num); + + LOGP(DLINP, LOGL_NOTICE, "line update (line=%p)\n", line); + + if (!line->driver_data) + line->driver_data = talloc_zero(line, struct unixsocket_line); + + if (!line->driver_data) { + LOGP(DLINP, LOGL_ERROR, + "OOM in line update (line=%p)\n", line); + return -ENOMEM; + } + + config = line->driver_data; + config->fd.data = line; + config->fd.when = BSC_FD_READ; + config->fd.cb = unixsocket_cb; + + /* Open unix domain socket */ + ret = osmo_sock_unix_init(SOCK_SEQPACKET, 0, sock_path, + OSMO_SOCK_F_CONNECT); + if (ret < 0) { + /* Note: We will not free the allocated driver_data memory if + * opening the socket fails. The caller may want to call this + * function multiple times using config->fd.data as line + * parameter. Freeing now would destroy that reference. */ + LOGP(DLINP, LOGL_ERROR, + "unable to open socket: %s (line=%p, fd=%d)\n", sock_path, + line, config->fd.fd); + return ret; + } + LOGP(DLINP, LOGL_DEBUG, + "successfully opend (new) socket: %s (line=%p, fd=%d, ret=%d)\n", + sock_path, line, config->fd.fd, ret); + config->fd.fd = ret; + + /* Register socket in select loop */ + if (osmo_fd_register(&config->fd) < 0) { + LOGP(DLINP, LOGL_ERROR, + "error registering new socket (line=%p, fd=%d)\n", + line, config->fd.fd); + close(config->fd.fd); + return -EIO; + } + + /* Set line parameter */ + for (i = 0; i < ARRAY_SIZE(line->ts); i++) { + struct e1inp_ts *e1i_ts = &line->ts[i]; + if (!e1i_ts->lapd) { + e1i_ts->lapd = lapd_instance_alloc(1, + unixsocket_write_msg_lapd_cb, &config->fd, + e1inp_dlsap_up, e1i_ts, &lapd_profile_abis); + } + } + + /* Ensure ericsson-superchannel is turned of when + * a new connection is made */ + e1inp_ericsson_set_altc(line, 0); + + return ret; +} + +struct e1inp_driver unixsocket_driver = { + .name = "unixsocket", + .want_write = ts_want_write, + .line_update = unixsocket_line_update, + .default_delay = 0, +}; + +void e1inp_unixsocket_init(void) +{ + tall_unixsocket_ctx = talloc_named_const(libosmo_abis_ctx, 1, "unixsocket"); + e1inp_driver_register(&unixsocket_driver); +} + +void e1inp_ericsson_set_altc(struct e1inp_line *unixline, int superchannel) +{ + struct unixsocket_line *config; + struct msgb *msg; + + if (!unixline) + return; + + if (unixline->driver != &unixsocket_driver) { + LOGP(DLMI, LOGL_NOTICE, "altc is only supported by unixsocket\n"); + return; + } + + config = unixline->driver_data; + if (!config) { + LOGP(DLMI, LOGL_NOTICE, "e1inp driver not yet initialized.\n"); + return; + } + + + msg = msgb_alloc_headroom(200, 100, "ALTC"); + + /* version header */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_VERSION); + /* data|control */ + msgb_put_u8(msg, UNIXSOCKET_PROTO_CONTROL); + + /* magic */ + msgb_put_u32(msg, 0x23004200); + msgb_put_u8(msg, superchannel ? 1 : 0); + + unixsocket_write_msg(msg, &config->fd); +} + diff --git a/src/input/unixsocket_proto.h b/src/input/unixsocket_proto.h new file mode 100644 index 0000000..beba667 --- /dev/null +++ b/src/input/unixsocket_proto.h @@ -0,0 +1,12 @@ + +#ifndef UNIXSOCKET_PROTO_H +#define UNIXSOCKET_PROTO_H + +#define UNIXSOCKET_PROTO_VERSION 0x1 + +enum { + UNIXSOCKET_PROTO_DATA = 0x0, + UNIXSOCKET_PROTO_CONTROL = 0x1, +}; + +#endif /* UNIXSOCKET_PROTO_H */ -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 16 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 21 19:11:25 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 21 Feb 2017 19:11:25 +0000 Subject: [PATCH] osmo-pcu[master]: BTS: Convert relative frame numbers to absolute frame numbers Message-ID: Review at https://gerrit.osmocom.org/1861 BTS: Convert relative frame numbers to absolute frame numbers The implementation of the method rcv_rach() in class BTS, restores the absolute frame number of the incoming RACH-Request by using the relative frame number (RFn = Fn mod 42432) from the rach request and the already known internal absolute frame number m_cur_fn, which is continusly updated by the CCU interface. In some rare cases, a RACH request might be received by the BTS, a very short time before the frame number wraps in its 42432. Depending on the PCU location, RACH request might be received by the BSC, which forwards it to the PCU. It is then likely that, while the RACH request is being forwarded to the PCU, the PCU internal absolute frame number wraps before the RACH can be processed. The relative frame number from the rach request would then be interpreted as if it were received after the wrapping of the internal frame number modulos. This commit adds logic to detect and resolve this race condition. Also a unit test is added to check some cornercases. Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 --- M src/bts.cpp M src/bts.h M tests/Makefile.am A tests/fn/FnTest.cpp A tests/fn/FnTest.ok M tests/testsuite.at 6 files changed, 252 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/61/1861/1 diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..c4df164 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -41,6 +41,10 @@ #include #include +#define RFN_MODULUS 42432 +#define RFN_THRESHOLD RFN_MODULUS / 2 +#define MAX_FN 2715648 + extern void *tall_pcu_ctx; static BTS s_bts; @@ -516,6 +520,50 @@ return 0; } +/* Determine the full frame number from a relative frame number */ +uint32_t BTS::rfn_to_fn(uint32_t rfn) +{ + uint32_t m_cur_rfn; + uint32_t fn; + uint32_t fn_rounded; + + /* Note: If a BTS is sending in a rach request it will be fully aware + * of the frame number. If the PCU is used in a BSC-co-located setup. + * The BSC will forward the incoming RACH request. The RACH request + * only contains the relative frame number (Fn % 42432) in its request + * reference. This PCU implementation has to fit both secenarious, so + * we need to assume that Fn is a relative frame number. */ + + /* Ensure that all following calculations are performed with the + * relative frame number */ + rfn = rfn % 42432; + + /* Compute an internal relative frame number from the full internal + frame number */ + m_cur_rfn = m_cur_fn % RFN_MODULUS; + + /* Compute a "rounded" version of the internal frame number, which + * exactly fits in the RFN_MODULUS raster */ + fn_rounded = m_cur_fn - m_cur_rfn; + + /* If the delta between the internal and the external relative frame + * number exceeds a certain limit, we need to assume that the incoming + * rach request belongs to a the previous rfn period. To correct this, + * we roll back the rounded frame number by one RFN_MODULUS */ + if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) { + if (fn_rounded < RFN_MODULUS) + fn_rounded = MAX_FN - (RFN_MODULUS - fn_rounded); + else + fn_rounded -= RFN_MODULUS; + } + + /* The real frame number is the sum of the rounded frame number and the + * relative framenumber computed via RACH */ + fn = fn_rounded + rfn; + + return fn; +} + int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type) { @@ -536,20 +584,8 @@ if (is_11bit) rach_frame_11bit(); - /* Note: If a BTS is sending in a rach request it will be fully aware - * of the frame number. If the PCU is used in a BSC-co-located setup. - * The BSC will forward the incoming RACH request. The RACH request - * only contains the relative frame number (Fn % 42432) in its request - * reference. This PCU implementation has to fit both secenarious, so - * we need to assume that Fn is a relative frame number. */ - - /* Ensure that all following calculations are performed with the - * relative frame number */ - Fn = Fn % 42432; - - /* Restore the full frame number - * (See also 3GPP TS 44.018, section 10.5.2.38) */ - Fn = Fn + m_cur_fn - m_cur_fn % 42432; + /* Determine full frame number */ + Fn = rfn_to_fn(Fn); LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF on RACH, " "so we provide one: ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", diff --git a/src/bts.h b/src/bts.h index 2932154..5d8dc59 100644 --- a/src/bts.h +++ b/src/bts.h @@ -349,6 +349,8 @@ int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority); + + uint32_t rfn_to_fn(uint32_t rfn); int rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type); diff --git a/tests/Makefile.am b/tests/Makefile.am index a24f4ea..a372354 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/ AM_LDFLAGS = -lrt -check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest +check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest fn/FnTest noinst_PROGRAMS = emu/pcu_emu rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp @@ -90,6 +90,14 @@ $(LIBOSMOCORE_LIBS) \ $(COMMON_LA) +fn_FnTest_SOURCES = fn/FnTest.cpp +fn_FnTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ + $(LIBOSMOGB_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBOSMOCORE_LIBS) \ + $(COMMON_LA) + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ @@ -119,7 +127,8 @@ llc/LlcTest.ok llc/LlcTest.err \ llist/LListTest.ok llist/LListTest.err \ codel/codel_test.ok \ - edge/EdgeTest.ok + edge/EdgeTest.ok \ + fn/FnTest.ok fn/FnTest.err DISTCLEANFILES = atconfig diff --git a/tests/fn/FnTest.cpp b/tests/fn/FnTest.cpp new file mode 100644 index 0000000..8983e6a --- /dev/null +++ b/tests/fn/FnTest.cpp @@ -0,0 +1,147 @@ +/* Frame number calculation test */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Philipp Maier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "bts.h" +#include +#include + +extern "C" { +#include +#include +#include +} +#define RFN_MODULUS 42432 +/* globals used by the code */ void *tall_pcu_ctx; +int16_t spoof_mnc = 0, spoof_mcc = 0; + +static uint32_t calc_fn(BTS * bts, uint32_t rfn) +{ + uint32_t fn; + fn = bts->rfn_to_fn(rfn); + printf("rfn=%i ==> fn=%i\n", rfn, fn); + return fn; +} + +static void set_fn(BTS * bts, uint32_t fn) +{ + printf("\n"); + bts->set_current_frame_number(fn); + printf("bts: fn=%i\n", fn); +} + +static void run_test() +{ + BTS bts; + uint32_t fn; + + /* Test with a collection of real world examples, + * all all of them are not critical and do not + * assume the occurence of any race contions */ + set_fn(&bts, 1320462); + fn = calc_fn(&bts, 5066); + OSMO_ASSERT(fn == 1320458); + + set_fn(&bts, 8246); + fn = calc_fn(&bts, 8244); + OSMO_ASSERT(fn == 8244); + + set_fn(&bts, 10270); + fn = calc_fn(&bts, 10269); + OSMO_ASSERT(fn == 10269); + + set_fn(&bts, 311276); + fn = calc_fn(&bts, 14250); + OSMO_ASSERT(fn == 311274); + + /* Now lets assume a case where the frame number + * just wrapped over a little bit above the + * modulo 42432 raster, but the rach request + * occurred before the wrapping */ + set_fn(&bts, RFN_MODULUS + 30); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 42422); + + set_fn(&bts, RFN_MODULUS + 1); + fn = calc_fn(&bts, RFN_MODULUS - 1); + OSMO_ASSERT(fn == 42431); + + set_fn(&bts, RFN_MODULUS * 123 + 16); + fn = calc_fn(&bts, RFN_MODULUS - 4); + OSMO_ASSERT(fn == 5219132); + + set_fn(&bts, RFN_MODULUS * 123 + 451); + fn = calc_fn(&bts, RFN_MODULUS - 175); + OSMO_ASSERT(fn == 5218961); + + /* Lets check a special cornercase. We assume that + * the BTS just wrapped its internal frame number + * but we still get rach requests with high relative + * frame numbers. */ + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS - 13); + OSMO_ASSERT(fn == 2715635); + + set_fn(&bts, 453); + fn = calc_fn(&bts, RFN_MODULUS - 102); + OSMO_ASSERT(fn == 2715546); + + set_fn(&bts, 10); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 2715638); + + set_fn(&bts, 23); + fn = calc_fn(&bts, RFN_MODULUS - 42); + OSMO_ASSERT(fn == 2715606); +} + +int main(int argc, char **argv) +{ + tall_pcu_ctx = talloc_named_const(NULL, 1, "fn test context"); + if (!tall_pcu_ctx) + abort(); + + msgb_talloc_ctx_init(tall_pcu_ctx, 0); + osmo_init_logging(&gprs_log_info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + if (getenv("LOGL_DEBUG")) + log_set_log_level(osmo_stderr_target, LOGL_DEBUG); + + run_test(); + return EXIT_SUCCESS; +} + +/* + * stubs that should not be reached + */ +extern "C" { + void l1if_pdch_req() { + abort(); + } void l1if_connect_pdch() { + abort(); + } + void l1if_close_pdch() { + abort(); + } + void l1if_open_pdch() { + abort(); + } +} diff --git a/tests/fn/FnTest.ok b/tests/fn/FnTest.ok new file mode 100644 index 0000000..6cfc10b --- /dev/null +++ b/tests/fn/FnTest.ok @@ -0,0 +1,36 @@ + +bts: fn=1320462 +rfn=5066 ==> fn=1320458 + +bts: fn=8246 +rfn=8244 ==> fn=8244 + +bts: fn=10270 +rfn=10269 ==> fn=10269 + +bts: fn=311276 +rfn=14250 ==> fn=311274 + +bts: fn=42462 +rfn=42422 ==> fn=42422 + +bts: fn=42433 +rfn=42431 ==> fn=42431 + +bts: fn=5219152 +rfn=42428 ==> fn=5219132 + +bts: fn=5219587 +rfn=42257 ==> fn=5218961 + +bts: fn=0 +rfn=42419 ==> fn=2715635 + +bts: fn=453 +rfn=42330 ==> fn=2715546 + +bts: fn=10 +rfn=42422 ==> fn=2715638 + +bts: fn=23 +rfn=42390 ==> fn=2715606 diff --git a/tests/testsuite.at b/tests/testsuite.at index e42a0fd..d8f8f9a 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -70,3 +70,9 @@ cat $abs_srcdir/codel/codel_test.ok > expout AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/codel/codel_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([fn]) +AT_KEYWORDS([fn]) +cat $abs_srcdir/fn/FnTest.ok > expout +AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/fn/FnTest], [0], [expout], [ignore]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1861 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Wed Feb 22 01:49:44 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 01:49:44 +0000 Subject: libosmocore[master]: gsup decode: fix expectation of AUTS length, should be 14 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 > Don't we have #define somewhere in libosmocore? No, all the code just assumes literally 14 all the time :/ I agree that it should be a constant, but let's not hold up this important fix because of that... Actually I'm fast tracking this now because both MSC's and SGSN's UMTS AKA implementations depend on this to be able to do AUTS resync. Introducing size constants to GSUP shall be a separate cosmetic patch. -- To view, visit https://gerrit.osmocom.org/1860 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 01:49:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 01:49:46 +0000 Subject: [MERGED] libosmocore[master]: gsup decode: fix expectation of AUTS length, should be 14 In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: gsup decode: fix expectation of AUTS length, should be 14 ...................................................................... gsup decode: fix expectation of AUTS length, should be 14 The wrong expectation caused OsmoHLR to fail on Auth Sync. Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f --- M src/gsm/gsup.c 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index ec1dc90..a813ed8 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -339,9 +339,9 @@ break; case OSMO_GSUP_AUTS_IE: - if (value_len != 16) { + if (value_len != 14) { LOGP(DLGSUP, LOGL_ERROR, - "AUTS length != 16 received\n"); + "AUTS length != 14 received\n"); return -GMM_CAUSE_COND_IE_ERR; } gsup_msg->auts = value; -- To view, visit https://gerrit.osmocom.org/1860 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I277fb3d407396dffa5c07a9c5454d87a415d393f Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 01:56:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 01:56:21 +0000 Subject: [PATCH] libosmocore[master]: gsup test: add decoding test for UMTS IEs Message-ID: Review at https://gerrit.osmocom.org/1862 gsup test: add decoding test for UMTS IEs This would have caught the wrong expectation of AUTS' length fixed recently (3a5ca647c531b7761dc6c555e5e0cabc972bd3ac). Besides AUTS, add AUTN, RES, CK, IK which were also not tested yet. Change-Id: I6fddf8d7ce97137b0a585d365807bcaf90a319d0 Related: OS#1593 --- M tests/gsup/gsup_test.c M tests/gsup/gsup_test.ok 2 files changed, 61 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/62/1862/1 diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 7af16b7..42e7b81 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -114,6 +114,60 @@ 0x07, 0x00, }; + static const uint8_t send_auth_info_res_umts[] = { + 0x0a, + TEST_IMSI_IE, + 0x03, 0x62, /* Auth tuple */ + 0x20, 0x10, /* rand */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x21, 0x04, /* sres */ + 0x21, 0x22, 0x23, 0x24, + 0x22, 0x08, /* kc */ + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x23, 0x10, /* IK (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x24, 0x10, /* CK (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x25, 0x10, /* AUTN (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x25, 0x08, /* RES (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x03, 0x22, /* Auth tuple */ + 0x20, 0x10, /* rand */ + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, + 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x10, + 0x21, 0x04, /* sres */ + 0xb1, 0xb2, 0xb3, 0xb4, + 0x22, 0x08, /* kc */ + 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, + 0x23, 0x10, /* IK (UMTS) */ + 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, + 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xd0, + 0x24, 0x10, /* CK (UMTS) */ + 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, + 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xe0, + 0x25, 0x10, /* AUTN (UMTS) */ + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf0, + 0x25, 0x08, /* RES (UMTS) */ + 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + }; + + static const uint8_t send_auth_info_req_auts[] = { + 0x08, + TEST_IMSI_IE, + 0x26, 0x0e, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x20, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + }; + static const struct test { char *name; const uint8_t *data; @@ -143,6 +197,10 @@ purge_ms_err, sizeof(purge_ms_err)}, {"Purge MS Result", purge_ms_res, sizeof(purge_ms_res)}, + {"Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)", + send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, + {"Send Authentication Info Request with AUTS and RAND (UMTS)", + send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, }; printf("Test GSUP message decoding/encoding\n"); @@ -192,7 +250,7 @@ osmo_hexdump(t->data + j, ie_end - j)); OSMO_ASSERT(j <= ie_end - 2); - OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_KC_IE); + OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_CN_DOMAIN_IE); OSMO_ASSERT(t->data[j+1] <= ie_end - j - 2); ie_end = j; diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok index 1285897..a0b3f35 100644 --- a/tests/gsup/gsup_test.ok +++ b/tests/gsup/gsup_test.ok @@ -11,4 +11,6 @@ Testing Purge MS Request Testing Purge MS Error Testing Purge MS Result + Testing Send Authentication Info Result with IK, CK, AUTN and RES (UMTS) + Testing Send Authentication Info Request with AUTS and RAND (UMTS) Done. -- To view, visit https://gerrit.osmocom.org/1862 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6fddf8d7ce97137b0a585d365807bcaf90a319d0 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:12:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:12:13 +0000 Subject: [PATCH] libosmocore[master]: gsup_test: also check stderr Message-ID: Review at https://gerrit.osmocom.org/1863 gsup_test: also check stderr Configure logging to be deterministic and add stderr checking to testuite.at. However, exclude the thousands of message modification log lines from the log to not have a huge test expectation file. Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb --- M tests/gsup/gsup_test.c A tests/gsup/gsup_test.err M tests/testsuite.at 3 files changed, 87 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/1863/1 diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 42e7b81..a950ca3 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -134,9 +134,9 @@ 0x25, 0x10, /* AUTN (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x25, 0x08, /* RES (UMTS) */ + 0x27, 0x08, /* RES (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x03, 0x22, /* Auth tuple */ + 0x03, 0x62, /* Auth tuple */ 0x20, 0x10, /* rand */ 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x10, @@ -153,17 +153,17 @@ 0x25, 0x10, /* AUTN (UMTS) */ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf0, - 0x25, 0x08, /* RES (UMTS) */ + 0x27, 0x08, /* RES (UMTS) */ 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, }; static const uint8_t send_auth_info_req_auts[] = { 0x08, TEST_IMSI_IE, - 0x26, 0x0e, + 0x26, 0x0e, /* AUTS (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, - 0x20, 0x10, + 0x20, 0x10, /* rand */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, }; @@ -198,7 +198,7 @@ {"Purge MS Result", purge_ms_res, sizeof(purge_ms_res)}, {"Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)", - send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, + send_auth_info_res_umts, sizeof(send_auth_info_res_umts)}, {"Send Authentication Info Request with AUTS and RAND (UMTS)", send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, }; @@ -264,6 +264,10 @@ test_idx, counter, parse_err); } + /* Don't log thousands of message modification errors */ + LOGP(DLGSUP, LOGL_NOTICE, "Stopping DLGSUP logging\n"); + log_set_category_filter(osmo_stderr_target, DLGSUP, 0, 0); + /* message modification test (relies on ASAN or valgrind being used) */ for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) { int j; @@ -309,6 +313,10 @@ int main(int argc, char **argv) { osmo_init_logging(&info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); test_gsup_messages_dec_enc(); diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err new file mode 100644 index 0000000..6cd8627 --- /dev/null +++ b/tests/gsup/gsup_test.err @@ -0,0 +1,71 @@ + generated message: 08 01 08 21 43 65 87 09 21 43 f5 + original message: 08 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07 + original message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07 + IMSI: 123456789012345 + generated message: 0a 01 08 21 43 65 87 09 21 43 f5 03 22 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 03 22 20 10 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 21 04 a1 a2 a3 a4 22 08 b1 b2 b3 b4 b5 b6 b7 b8 + original message: 0a 01 08 21 43 65 87 09 21 43 f5 03 22 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 03 22 20 10 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 21 04 a1 a2 a3 a4 22 08 b1 b2 b3 b4 b5 b6 b7 b8 + IMSI: 123456789012345 + generated message: 04 01 08 21 43 65 87 09 21 43 f5 + original message: 04 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 05 01 08 21 43 65 87 09 21 43 f5 02 01 07 + original message: 05 01 08 21 43 65 87 09 21 43 f5 02 01 07 + IMSI: 123456789012345 + generated message: 06 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 09 07 91 83 52 38 48 83 93 04 00 05 15 10 01 01 11 02 f1 21 12 09 04 74 65 73 74 03 61 70 6e 13 01 02 05 11 10 01 02 11 02 f1 21 12 08 03 66 6f 6f 03 61 70 6e + original message: 06 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 09 07 91 83 52 38 48 83 93 04 00 05 15 10 01 01 11 02 f1 21 12 09 04 74 65 73 74 03 61 70 6e 13 01 02 05 11 10 01 02 11 02 f1 21 12 08 03 66 6f 6f 03 61 70 6e + IMSI: 123456789012345 + generated message: 1c 01 08 21 43 65 87 09 21 43 f5 06 01 00 + original message: 1c 01 08 21 43 65 87 09 21 43 f5 06 01 00 + IMSI: 123456789012345 + generated message: 1d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + original message: 1d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + IMSI: 123456789012345 + generated message: 1e 01 08 21 43 65 87 09 21 43 f5 + original message: 1e 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 0c 01 08 21 43 65 87 09 21 43 f5 + original message: 0c 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 0d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + original message: 0d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + IMSI: 123456789012345 + generated message: 0e 01 08 21 43 65 87 09 21 43 f5 07 00 + original message: 0e 01 08 21 43 65 87 09 21 43 f5 07 00 + IMSI: 123456789012345 + generated message: 0a 01 08 21 43 65 87 09 21 43 f5 03 62 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 23 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 24 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 25 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 27 08 01 02 03 04 05 06 07 08 03 62 20 10 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 10 21 04 b1 b2 b3 b4 22 08 c1 c2 c3 c4 c5 c6 c7 c8 23 10 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df d0 24 10 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef e0 25 10 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff f0 27 08 91 92 93 94 95 96 97 98 + original message: 0a 01 08 21 43 65 87 09 21 43 f5 03 62 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 23 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 24 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 25 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 27 08 01 02 03 04 05 06 07 08 03 62 20 10 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 10 21 04 b1 b2 b3 b4 22 08 c1 c2 c3 c4 c5 c6 c7 c8 23 10 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df d0 24 10 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef e0 25 10 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff f0 27 08 91 92 93 94 95 96 97 98 + IMSI: 123456789012345 + generated message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 + original message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 + IMSI: 123456789012345 + message 0: tested 11 truncations, 11 parse failures + message 1: tested 14 truncations, 13 parse failures + message 2: tested 83 truncations, 81 parse failures + message 3: tested 11 truncations, 11 parse failures + message 4: tested 14 truncations, 13 parse failures + message 5: tested 73 truncations, 68 parse failures + message 6: tested 14 truncations, 13 parse failures + message 7: tested 14 truncations, 13 parse failures + message 8: tested 11 truncations, 11 parse failures + message 9: tested 11 truncations, 11 parse failures + message 10: tested 14 truncations, 13 parse failures + message 11: tested 13 truncations, 12 parse failures + message 12: tested 211 truncations, 209 parse failures + message 13: tested 45 truncations, 43 parse failures +DLGSUP Stopping DLGSUP logging + message 0: tested 2816 modifications, 510 parse failures + message 1: tested 3584 modifications, 768 parse failures + message 2: tested 21248 modifications, 2571 parse failures + message 3: tested 2816 modifications, 510 parse failures + message 4: tested 3584 modifications, 768 parse failures + message 5: tested 18688 modifications, 3505 parse failures + message 6: tested 3584 modifications, 769 parse failures + message 7: tested 3584 modifications, 768 parse failures + message 8: tested 2816 modifications, 510 parse failures + message 9: tested 2816 modifications, 510 parse failures + message 10: tested 3584 modifications, 768 parse failures + message 11: tested 3328 modifications, 767 parse failures + message 12: tested 54016 modifications, 4622 parse failures + message 13: tested 11520 modifications, 1026 parse failures diff --git a/tests/testsuite.at b/tests/testsuite.at index d6181c9..a3be0e7 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -212,7 +212,8 @@ AT_SETUP([gsup]) AT_KEYWORDS([gsup]) cat $abs_srcdir/gsup/gsup_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [0], [expout], [ignore]) +cat $abs_srcdir/gsup/gsup_test.err > experr +AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [0], [expout], [experr]) AT_CLEANUP AT_SETUP([fsm]) -- To view, visit https://gerrit.osmocom.org/1863 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:13:10 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:13:10 +0000 Subject: [PATCH] libosmocore[master]: fix osmo_auth_gen_vec_auts: copy rand to auth vector Message-ID: Review at https://gerrit.osmocom.org/1864 fix osmo_auth_gen_vec_auts: copy rand to auth vector Related: OS#1593 Change-Id: If943731a78089f0aac3d55245de80596d01314a4 --- M src/gsm/auth_core.c 1 file changed, 8 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/64/1864/1 diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index 3b1a5c6..acb65f5 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -188,11 +188,18 @@ const uint8_t *_rand) { struct osmo_auth_impl *impl = selected_auths[aud->algo]; + int rc; if (!impl || !impl->gen_vec_auts) return -ENOENT; - return impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); + rc = impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); + if (rc < 0) + return rc; + + memcpy(vec->rand, _rand, sizeof(vec->rand)); + + return 0; } static const struct value_string auth_alg_vals[] = { -- To view, visit https://gerrit.osmocom.org/1864 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If943731a78089f0aac3d55245de80596d01314a4 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:15:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:15:46 +0000 Subject: libosmocore[master]: fix osmo_auth_gen_vec_auts: copy rand to auth vector In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 another fast track candidate ... same code as in osmo_auth_gen_vec() and an obvious fix. -- To view, visit https://gerrit.osmocom.org/1864 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If943731a78089f0aac3d55245de80596d01314a4 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:27 +0000 Subject: [PATCH] osmo-hlr[master]: auc_3g_test: add AUTS resync test Message-ID: Review at https://gerrit.osmocom.org/1865 auc_3g_test: add AUTS resync test Used this to catch a bug where the AUTS process failed to copy RAND to the auth vector (libosmocore). Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4 Change-Id: I06dd8671aa515139bdc3f08883f08276662cf25f --- M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 2 files changed, 87 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/65/1865/1 diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 0923a27..88037a6 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -235,6 +235,8 @@ struct osmo_sub_auth_data aud2g; struct osmo_sub_auth_data aud3g; struct osmo_auth_vector vec; + uint8_t auts[14]; + uint8_t rand_auts[16]; int rc; comment_start(); @@ -303,6 +305,74 @@ " auth_types: 03000000\n" ); + + fprintf(stderr, "- test AUTS resync\n"); + vec = (struct osmo_auth_vector){}; + aud3g.u.umts.sqn = 0; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); + + /* The AUTN sent was 8704f5ba55f30000d2ee44b22c8ea919 + * with the first 6 bytes being SQN ^ AK. + * K = EB215756028D60E3275E613320AEC880 + * OPC = FB2A3D1B360F599ABAB99DB8669F8308 + * RAND = 39fa2f4e3d523d8619a73b4f65c3e14d + * --milenage-f5--> + * AK = 8704f5ba55f3 + * + * The first six bytes are 8704f5ba55f3, + * and 8704f5ba55f3 ^ AK = 0. + * --> SQN = 0. + * + * Say the USIM doesn't like that, let's say it is at SQN 23. + * SQN_MS = 000000000017 + * + * AUTS = Conc(SQN_MS) || MAC-S + * Conc(SQN_MS) = SQN_MS ? f5*[K](RAND) + * MAC-S = f1*[K] (SQN MS || RAND || AMF) + * + * f5*--> Conc(SQN_MS) = 000000000017 ^ 979498b1f73a + * = 979498b1f72d + * AMF = 0000 (TS 33.102 v7.0.0, 6.3.3) + * + * MAC-S = f1*[K] (000000000017 || 39fa2f4e3d523d8619a73b4f65c3e14d || 0000) + * = 3e28c59fa2e72f9c + * + * AUTS = 979498b1f72d || 3e28c59fa2e72f9c + * + * verify valid AUTS resulting in SQN 23 with: + * osmo-auc-gen -3 -a milenage -k EB215756028D60E3275E613320AEC880 \ + * -o FB2A3D1B360F599ABAB99DB8669F8308 \ + * -r 39fa2f4e3d523d8619a73b4f65c3e14d \ + * -A 979498b1f72d3e28c59fa2e72f9c + */ + + /* AUTS response by USIM */ + osmo_hexparse("979498b1f72d3e28c59fa2e72f9c", + auts, sizeof(auts)); + /* RAND sent to USIM, which AUTS was generated from */ + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + rand_auts, sizeof(rand_auts)); + /* new RAND token for the next key */ + osmo_hexparse("897210a0f7de278f0b8213098e098a3f", + fake_rand, sizeof(fake_rand)); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, rand_auts, auts); + VERBOSE_ASSERT(rc, == 1, "%d"); + /* The USIM's last sqn was 23, the calculated vector was 24, hence the + * next one stored should be 25. */ + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 25, "%"PRIu64); + + VEC_IS(&vec, + " rand: 897210a0f7de278f0b8213098e098a3f\n" + " autn: c6b9790dad4b00000cf322869ea6a481\n" + " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" + " ik: f19c20ca863137f8892326d959ec5e01\n" + " res: 9af5a557902d2db80000000000000000\n" + " res_len: 08\n" + " kc: 7526fc13c5976685\n" + " sres: 0ad888ef\n" + " auth_types: 03000000\n" + ); + comment_end(); } diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index ec5ba28..a444f8b 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -102,5 +102,22 @@ sres: 9b36efdf auth_types: 03000000 +- test AUTS resync +aud3g.u.umts.sqn == 0 +DAUC rand 897210a0f7de278f0b8213098e098a3f +DAUC compute vector [0]/1: 3G only +rc == 1 +aud3g.u.umts.sqn == 25 +auth vector == + rand: 897210a0f7de278f0b8213098e098a3f + autn: c6b9790dad4b00000cf322869ea6a481 + ck: e9922bd036718ed9e40bd1d02c3b81a5 + ik: f19c20ca863137f8892326d959ec5e01 + res: 9af5a557902d2db80000000000000000 + res_len: 08 + kc: 7526fc13c5976685 + sres: 0ad888ef + auth_types: 03000000 + ===== test_gen_vectors_3g_only: SUCCESS -- To view, visit https://gerrit.osmocom.org/1865 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06dd8671aa515139bdc3f08883f08276662cf25f Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:27 +0000 Subject: [PATCH] osmo-hlr[master]: auc_gen_vectors(): ensure sane arguments, test Message-ID: Review at https://gerrit.osmocom.org/1866 auc_gen_vectors(): ensure sane arguments, test In auc_gen_vectors(), add various checks that the auth data arguments passed make sense, and add unit test to verify that they work. (Caught a segfault due to NULL dereference with this.) Change-Id: I775652b6a91d382707ce32176a3fe4ef547cbca7 --- M src/auc.c M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 3 files changed, 274 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/66/1866/1 diff --git a/src/auc.c b/src/auc.c index 3f3db34..a307931 100644 --- a/src/auc.c +++ b/src/auc.c @@ -36,13 +36,42 @@ uint8_t rand[16]; int rc; - if (aud2g->algo == OSMO_AUTH_ALG_NONE) + if (aud2g && (aud2g->algo == OSMO_AUTH_ALG_NONE + || aud2g->type == OSMO_AUTH_TYPE_NONE)) aud2g = NULL; - if (aud3g->algo == OSMO_AUTH_ALG_NONE) + if (aud3g && (aud3g->algo == OSMO_AUTH_ALG_NONE + || aud3g->type == OSMO_AUTH_TYPE_NONE)) aud3g = NULL; - if (!aud2g && !aud3g) + if (!aud2g && !aud3g) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() called" + " with neither 2G nor 3G auth data available\n"); return -1; + } + + if (aud2g && aud2g->type != OSMO_AUTH_TYPE_GSM) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() called" + " with non-2G auth data passed for aud2g arg\n"); + return -1; + } + + if (aud3g && aud3g->type != OSMO_AUTH_TYPE_UMTS) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() called" + " with non-3G auth data passed for aud3g arg\n"); + return -1; + } + + if ((rand_auts != NULL) != (auts != NULL)) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() with only one" + " of AUTS and AUTS_RAND given, need both or neither\n"); + return -1; + } + + if (auts && !aud3g) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() with AUTS called" + " but no 3G auth data passed\n"); + return -1; + } /* compute quintuples */ for (i = 0; i < num_vec; i++) { diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 88037a6..f1fa2c2 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -376,6 +376,103 @@ comment_end(); } +void test_gen_vectors_bad_args() +{ + struct osmo_auth_vector vec; + uint8_t auts[14]; + uint8_t rand_auts[16]; + int rc; + int i; + + struct osmo_sub_auth_data aud2g = { + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1, + }; + + struct osmo_sub_auth_data aud3g = { + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + struct osmo_sub_auth_data aud2g_noalg = { + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_NONE, + }; + + struct osmo_sub_auth_data aud3g_noalg = { + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_NONE, + }; + + struct osmo_sub_auth_data aud_notype = { + .type = OSMO_AUTH_TYPE_NONE, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + struct osmo_sub_auth_data no_aud = { + .type = OSMO_AUTH_TYPE_NONE, + .algo = OSMO_AUTH_ALG_NONE, + }; + + struct { + struct osmo_sub_auth_data *aud2g; + struct osmo_sub_auth_data *aud3g; + uint8_t *rand_auts; + uint8_t *auts; + const char *label; + } tests[] = { + { NULL, NULL, NULL, NULL, "no auth data (a)"}, + { NULL, &aud3g_noalg, NULL, NULL, "no auth data (b)"}, + { NULL, &aud_notype, NULL, NULL, "no auth data (c)"}, + { NULL, &no_aud, NULL, NULL, "no auth data (d)"}, + { &aud2g_noalg, NULL, NULL, NULL, "no auth data (e)"}, + { &aud2g_noalg, &aud3g_noalg, NULL, NULL, "no auth data (f)"}, + { &aud2g_noalg, &aud_notype, NULL, NULL, "no auth data (g)"}, + { &aud2g_noalg, &no_aud, NULL, NULL, "no auth data (h)"}, + { &aud_notype, NULL, NULL, NULL, "no auth data (i)"}, + { &aud_notype, &aud3g_noalg, NULL, NULL, "no auth data (j)"}, + { &aud_notype, &aud_notype, NULL, NULL, "no auth data (k)"}, + { &aud_notype, &no_aud, NULL, NULL, "no auth data (l)"}, + { &no_aud, NULL, NULL, NULL, "no auth data (m)"}, + { &no_aud, &aud3g_noalg, NULL, NULL, "no auth data (n)"}, + { &no_aud, &aud_notype, NULL, NULL, "no auth data (o)"}, + { &no_aud, &no_aud, NULL, NULL, "no auth data (p)"}, + { &aud3g, NULL, NULL, NULL, "wrong auth data type (a)"}, + { &aud3g, &aud3g_noalg, NULL, NULL, "wrong auth data type (b)"}, + { &aud3g, &aud_notype, NULL, NULL, "wrong auth data type (c)"}, + { &aud3g, &no_aud, NULL, NULL, "wrong auth data type (d)"}, + { NULL, &aud2g, NULL, NULL, "wrong auth data type (e)"}, + { &aud3g_noalg, &aud2g, NULL, NULL, "wrong auth data type (f)"}, + { &aud_notype, &aud2g, NULL, NULL, "wrong auth data type (g)"}, + { &no_aud, &aud2g, NULL, NULL, "wrong auth data type (h)"}, + { &aud3g, &aud2g, NULL, NULL, "wrong auth data type (i)"}, + { &aud3g, &aud3g, NULL, NULL, "wrong auth data type (j)"}, + { &aud2g, &aud2g, NULL, NULL, "wrong auth data type (k)"}, + { &aud2g, NULL, rand_auts, auts, "AUTS for 2G-only (a)"}, + { &aud2g, &aud3g_noalg, rand_auts, auts, "AUTS for 2G-only (b)"}, + { &aud2g, &aud_notype, rand_auts, auts, "AUTS for 2G-only (c)"}, + { &aud2g, &no_aud, rand_auts, auts, "AUTS for 2G-only (d)"}, + { NULL, &aud3g, NULL, auts, "incomplete AUTS (a)"}, + { NULL, &aud3g, rand_auts, NULL, "incomplete AUTS (b)"}, + { &aud2g, &aud3g, NULL, auts, "incomplete AUTS (c)"}, + { &aud2g, &aud3g, rand_auts, NULL, "incomplete AUTS (d)"}, + }; + + comment_start(); + + for (i = 0; i < ARRAY_SIZE(tests); i++) { + fprintf(stderr, "\n- %s\n", tests[i].label); + rc = auc_compute_vectors(&vec, 1, + tests[i].aud2g, + tests[i].aud3g, + tests[i].rand_auts, + tests[i].auts); + VERBOSE_ASSERT(rc, < 0, "%d"); + } + + comment_end(); +} + int main() { printf("auc_3g_test.c\n"); @@ -388,6 +485,7 @@ test_gen_vectors_2g_only(); test_gen_vectors_2g_plus_3g(); test_gen_vectors_3g_only(); + test_gen_vectors_bad_args(); printf("Done\n"); return 0; diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index a444f8b..5c3dd14 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -121,3 +121,147 @@ ===== test_gen_vectors_3g_only: SUCCESS + +===== test_gen_vectors_bad_args + +- no auth data (a) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (b) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (c) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (d) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (e) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (f) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (g) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (h) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (i) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (j) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (k) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (l) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (m) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (n) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (o) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (p) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- wrong auth data type (a) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (b) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (c) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (d) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (e) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (f) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (g) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (h) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (i) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (j) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (k) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- AUTS for 2G-only (a) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- AUTS for 2G-only (b) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- AUTS for 2G-only (c) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- AUTS for 2G-only (d) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- incomplete AUTS (a) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 + +- incomplete AUTS (b) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 + +- incomplete AUTS (c) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 + +- incomplete AUTS (d) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 +===== test_gen_vectors_bad_args: SUCCESS + -- To view, visit https://gerrit.osmocom.org/1866 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I775652b6a91d382707ce32176a3fe4ef547cbca7 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:27 +0000 Subject: [PATCH] osmo-hlr[master]: auc_3g_test: allow to inc fake rand bytes upon rand request Message-ID: Review at https://gerrit.osmocom.org/1867 auc_3g_test: allow to inc fake rand bytes upon rand request Preparing for upcoming unit test, in a separate commit for cosmetic reasons (setting the flag to false across the code). Change-Id: I6b9899cd898eecc95b244432f416041b194a7187 --- M tests/auc/auc_3g_test.c 1 file changed, 16 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/67/1867/1 diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index f1fa2c2..cb5e412 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -88,11 +88,23 @@ } while (0) uint8_t fake_rand[16] = { 0 }; +bool fake_rand_fixed = true; + +void next_rand(const char *hexstr, bool fixed) +{ + osmo_hexparse(hexstr, fake_rand, sizeof(fake_rand)); + fake_rand_fixed = fixed; +} int rand_get(uint8_t *rand, unsigned int len) { + int i; OSMO_ASSERT(len <= sizeof(fake_rand)); memcpy(rand, fake_rand, len); + if (!fake_rand_fixed) { + for (i = 0; i < len; i++) + fake_rand[i] += 0x11; + } return len; } @@ -115,8 +127,7 @@ aud3g = (struct osmo_sub_auth_data){ 0 }; - osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", - fake_rand, sizeof(fake_rand)); + next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); vec = (struct osmo_auth_vector){ {0} }; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); @@ -184,9 +195,7 @@ aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); - - osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", - fake_rand, sizeof(fake_rand)); + next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); vec = (struct osmo_auth_vector){ {0} }; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); @@ -252,9 +261,7 @@ aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); - - osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", - fake_rand, sizeof(fake_rand)); + next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); vec = (struct osmo_auth_vector){ {0} }; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); @@ -353,8 +360,7 @@ osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", rand_auts, sizeof(rand_auts)); /* new RAND token for the next key */ - osmo_hexparse("897210a0f7de278f0b8213098e098a3f", - fake_rand, sizeof(fake_rand)); + next_rand("897210a0f7de278f0b8213098e098a3f", true); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, rand_auts, auts); VERBOSE_ASSERT(rc, == 1, "%d"); /* The USIM's last sqn was 23, the calculated vector was 24, hence the -- To view, visit https://gerrit.osmocom.org/1867 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6b9899cd898eecc95b244432f416041b194a7187 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:28 +0000 Subject: [PATCH] osmo-hlr[master]: auc_3g_test: add AUTS test with N vectors, to show bug Message-ID: Review at https://gerrit.osmocom.org/1868 auc_3g_test: add AUTS test with N vectors, to show bug Add test that shows how passing AUTS to auc_compute_vectors performs an AUTS sync on each vector and hence produces the same SQN each time. This will generate one working vector as resync result, and then N-1 more with the wrong SQN as far as the USIM is concerned. This causes a resync to be necessary on every authentication. Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4 Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c --- M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 2 files changed, 198 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/68/1868/1 diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index cb5e412..f8ff67a 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -239,11 +239,94 @@ comment_end(); } +void _test_gen_vectors_3g_only__expect_vecs__WRONG(struct osmo_auth_vector vecs[3]) +{ + fprintf(stderr, "THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED\n"); + fprintf(stderr, "The SQN should increment with each new vector.\n"); + fprintf(stderr, "[0]: "); + VEC_IS(&vecs[0], + " rand: 897210a0f7de278f0b8213098e098a3f\n" + " autn: c6b9790dad4b00000cf322869ea6a481\n" + " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" + " ik: f19c20ca863137f8892326d959ec5e01\n" + " res: 9af5a557902d2db80000000000000000\n" + " res_len: 08\n" + " kc: 7526fc13c5976685\n" + " sres: 0ad888ef\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[1]: "); + VEC_IS(&vecs[1], + " rand: 9a8321b108ef38a01c93241a9f1a9b50\n" + " autn: 79a5113eb0900000f7e138537aa0962b\n" + " ck: 3686f05df057d1899c66ae4eb18cf941\n" + " ik: 79f21ed53bcb47787de57d136ff803a5\n" + " res: 43023475cb29292c0000000000000000\n" + " res_len: 08\n" + " kc: aef73dd515e86c15\n" + " sres: 882b1d59\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[2]: "); + VEC_IS(&vecs[2], + " rand: ab9432c2190049b12da4352bb02bac61\n" + " autn: 24b018d46c390000d88e11730d0367ac\n" + " ck: d86c3191a36fc0602e48202ef2080964\n" + " ik: 648dab72016181406243420649e63dc9\n" + " res: 010cab11cc63a6e40000000000000000\n" + " res_len: 08\n" + " kc: f0eaf8cb19e0758d\n" + " sres: cd6f0df5\n" + " auth_types: 03000000\n" + ); +} + +void _test_gen_vectors_3g_only__expect_vecs(struct osmo_auth_vector vecs[3]) +{ + fprintf(stderr, "[0]: "); + VEC_IS(&vecs[0], + " rand: 897210a0f7de278f0b8213098e098a3f\n" + " autn: c6b9790dad4b00000cf322869ea6a481\n" + " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" + " ik: f19c20ca863137f8892326d959ec5e01\n" + " res: 9af5a557902d2db80000000000000000\n" + " res_len: 08\n" + " kc: 7526fc13c5976685\n" + " sres: 0ad888ef\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[1]: "); + VEC_IS(&vecs[1], + " rand: 9a8321b108ef38a01c93241a9f1a9b50\n" + " autn: 79a5113eb0910000be6020540503ffc5\n" + " ck: 3686f05df057d1899c66ae4eb18cf941\n" + " ik: 79f21ed53bcb47787de57d136ff803a5\n" + " res: 43023475cb29292c0000000000000000\n" + " res_len: 08\n" + " kc: aef73dd515e86c15\n" + " sres: 882b1d59\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[2]: "); + VEC_IS(&vecs[2], + " rand: ab9432c2190049b12da4352bb02bac61\n" + " autn: 24b018d46c3b00009c7e1b47f3a19b2b\n" + " ck: d86c3191a36fc0602e48202ef2080964\n" + " ik: 648dab72016181406243420649e63dc9\n" + " res: 010cab11cc63a6e40000000000000000\n" + " res_len: 08\n" + " kc: f0eaf8cb19e0758d\n" + " sres: cd6f0df5\n" + " auth_types: 03000000\n" + ); +} + static void test_gen_vectors_3g_only(void) { struct osmo_sub_auth_data aud2g; struct osmo_sub_auth_data aud3g; struct osmo_auth_vector vec; + struct osmo_auth_vector vecs[3]; uint8_t auts[14]; uint8_t rand_auts[16]; int rc; @@ -379,6 +462,35 @@ " auth_types: 03000000\n" ); + + fprintf(stderr, "- verify N vectors with AUTS resync" + " == N vectors without AUTS\n" + "First just set rand and sqn = 24, and compute 3 vectors\n"); + next_rand("897210a0f7de278f0b8213098e098a3f", false); + aud3g.u.umts.sqn = 24; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 24, "%"PRIu64); + + memset(vecs, 0, sizeof(vecs)); + rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 3, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 27, "%"PRIu64); + + _test_gen_vectors_3g_only__expect_vecs(vecs); + + fprintf(stderr, "Now reach sqn = 24 with AUTS and expect the same\n"); + /* AUTS response by USIM */ + osmo_hexparse("979498b1f72d3e28c59fa2e72f9c", + auts, sizeof(auts)); + /* RAND sent to USIM, which AUTS was generated from */ + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + rand_auts, sizeof(rand_auts)); + next_rand("897210a0f7de278f0b8213098e098a3f", false); + rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, rand_auts, auts); + + /* THIS IS WRONG AND WILL BE FIXED IN A SUBSEQUENT COMMIT: + should be _test_gen_vectors_3g_only__expect_vecs() instead */ + _test_gen_vectors_3g_only__expect_vecs__WRONG(vecs); + comment_end(); } diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index 5c3dd14..db076d7 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -119,6 +119,92 @@ sres: 0ad888ef auth_types: 03000000 +- verify N vectors with AUTS resync == N vectors without AUTS +First just set rand and sqn = 24, and compute 3 vectors +aud3g.u.umts.sqn == 24 +DAUC rand 897210a0f7de278f0b8213098e098a3f +DAUC compute vector [0]/3: 3G only +DAUC rand 9a8321b108ef38a01c93241a9f1a9b50 +DAUC compute vector [1]/3: 3G only +DAUC rand ab9432c2190049b12da4352bb02bac61 +DAUC compute vector [2]/3: 3G only +rc == 3 +aud3g.u.umts.sqn == 27 +[0]: auth vector == + rand: 897210a0f7de278f0b8213098e098a3f + autn: c6b9790dad4b00000cf322869ea6a481 + ck: e9922bd036718ed9e40bd1d02c3b81a5 + ik: f19c20ca863137f8892326d959ec5e01 + res: 9af5a557902d2db80000000000000000 + res_len: 08 + kc: 7526fc13c5976685 + sres: 0ad888ef + auth_types: 03000000 + +[1]: auth vector == + rand: 9a8321b108ef38a01c93241a9f1a9b50 + autn: 79a5113eb0910000be6020540503ffc5 + ck: 3686f05df057d1899c66ae4eb18cf941 + ik: 79f21ed53bcb47787de57d136ff803a5 + res: 43023475cb29292c0000000000000000 + res_len: 08 + kc: aef73dd515e86c15 + sres: 882b1d59 + auth_types: 03000000 + +[2]: auth vector == + rand: ab9432c2190049b12da4352bb02bac61 + autn: 24b018d46c3b00009c7e1b47f3a19b2b + ck: d86c3191a36fc0602e48202ef2080964 + ik: 648dab72016181406243420649e63dc9 + res: 010cab11cc63a6e40000000000000000 + res_len: 08 + kc: f0eaf8cb19e0758d + sres: cd6f0df5 + auth_types: 03000000 + +Now reach sqn = 24 with AUTS and expect the same +DAUC rand 897210a0f7de278f0b8213098e098a3f +DAUC compute vector [0]/3: 3G only +DAUC rand 9a8321b108ef38a01c93241a9f1a9b50 +DAUC compute vector [1]/3: 3G only +DAUC rand ab9432c2190049b12da4352bb02bac61 +DAUC compute vector [2]/3: 3G only +THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED +The SQN should increment with each new vector. +[0]: auth vector == + rand: 897210a0f7de278f0b8213098e098a3f + autn: c6b9790dad4b00000cf322869ea6a481 + ck: e9922bd036718ed9e40bd1d02c3b81a5 + ik: f19c20ca863137f8892326d959ec5e01 + res: 9af5a557902d2db80000000000000000 + res_len: 08 + kc: 7526fc13c5976685 + sres: 0ad888ef + auth_types: 03000000 + +[1]: auth vector == + rand: 9a8321b108ef38a01c93241a9f1a9b50 + autn: 79a5113eb0900000f7e138537aa0962b + ck: 3686f05df057d1899c66ae4eb18cf941 + ik: 79f21ed53bcb47787de57d136ff803a5 + res: 43023475cb29292c0000000000000000 + res_len: 08 + kc: aef73dd515e86c15 + sres: 882b1d59 + auth_types: 03000000 + +[2]: auth vector == + rand: ab9432c2190049b12da4352bb02bac61 + autn: 24b018d46c390000d88e11730d0367ac + ck: d86c3191a36fc0602e48202ef2080964 + ik: 648dab72016181406243420649e63dc9 + res: 010cab11cc63a6e40000000000000000 + res_len: 08 + kc: f0eaf8cb19e0758d + sres: cd6f0df5 + auth_types: 03000000 + ===== test_gen_vectors_3g_only: SUCCESS -- To view, visit https://gerrit.osmocom.org/1868 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:28 +0000 Subject: [PATCH] osmo-hlr[master]: cosmetic: refactor auc_compute_vectors(), add debug log Message-ID: Review at https://gerrit.osmocom.org/1869 cosmetic: refactor auc_compute_vectors(), add debug log Make the generation logic easier to understand (hopefully). Massively extend debug logging, which serves to illustrate the current AUTS failure shown by auc_3g_test. Since DAUC now logs the vectors, there is no need to print the vectors in VEC_IS() in auc_3g_test and auc_ts_55_205_test_sets anymore. Adjust testlog expectations accordingly. Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 --- M src/auc.c M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err M tests/auc/auc_ts_55_205_test_sets.err M tests/auc/gen_ts_55_205_test_sets/main_template.c 5 files changed, 522 insertions(+), 393 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/69/1869/1 diff --git a/src/auc.c b/src/auc.c index a307931..f4d19a0 100644 --- a/src/auc.c +++ b/src/auc.c @@ -18,12 +18,16 @@ */ #include +#include #include #include #include "logging.h" #include "rand.h" + +#define hexb(buf) osmo_hexdump_nospc((void*)buf, sizeof(buf)) +#define hex(buf,sz) osmo_hexdump_nospc((void*)buf, sz) /* compute given number of vectors using either aud2g or aud2g or a combination * of both. Handles re-synchronization if rand_auts and auts are set */ @@ -34,7 +38,16 @@ { unsigned int i; uint8_t rand[16]; + struct osmo_auth_vector vtmp; int rc; + + /* no need to iterate the log categories all the time */ + int dbg = log_check_level(DAUC, LOGL_DEBUG); +#define DBGP(args ...) if (dbg) DEBUGP(DAUC, ##args) +#define DBGVB(member) DBGP("vector [%u]: " #member " = %s\n", \ + i, hexb(vec[i].member)) +#define DBGVV(fmt, member) DBGP("vector [%u]: " #member " = " fmt "\n", \ + i, vec[i].member) if (aud2g && (aud2g->algo == OSMO_AUTH_ALG_NONE || aud2g->type == OSMO_AUTH_TYPE_NONE)) @@ -73,59 +86,100 @@ return -1; } - /* compute quintuples */ + DBGP("Computing %d auth vector%s: %s%s\n", + num_vec, num_vec == 1 ? "" : "s", + aud3g? (aud2g? "3G + separate 2G" + : "3G only (2G derived from 3G keys)") + : "2G only", + auts? ", with AUTS resync" : ""); + if (aud3g) { + DBGP("3G: k = %s\n", hexb(aud3g->u.umts.k)); + DBGP("3G: %s = %s\n", + aud3g->u.umts.opc_is_op? "OP" : "opc", + hexb(aud3g->u.umts.opc)); + } + if (aud2g) + DBGP("2G: ki = %s\n", hexb(aud2g->u.gsm.ki)); + for (i = 0; i < num_vec; i++) { rc = rand_get(rand, sizeof(rand)); - DEBUGP(DAUC, "rand %s\n", osmo_hexdump_nospc(rand, sizeof(rand))); if (rc != sizeof(rand)) { LOGP(DAUC, LOGL_ERROR, "Unable to read %zu random " "bytes: rc=%d\n", sizeof(rand), rc); goto out; } + DBGP("vector [%u]: rand = %s\n", i, hexb(rand)); - if (aud2g && !aud3g) { - /* 2G only case: output directly to vec */ - DEBUGP(DAUC, "compute vector [%u]/%u: 2G only\n", - i, num_vec); - rc = osmo_auth_gen_vec(vec+i, aud2g, rand); - if (rc < 0) { - LOGP(DAUC, LOGL_ERROR, "Error in 2G vector " - "generation: %d\n", rc); - goto out; - } - } else if (aud3g) { + if (aud3g) { /* 3G or 3G + 2G case */ - if (!aud2g) - DEBUGP(DAUC, "compute vector [%u]/%u: 3G only\n", - i, num_vec); - if (rand_auts && auts) - rc = osmo_auth_gen_vec_auts(vec+i, aud3g, - auts, rand_auts, - rand); - else + + if (auts) { + DBGP("vector [%u]: resync: auts = %s\n", + i, hex(auts, 14)); + DBGP("vector [%u]: resync: rand_auts = %s\n", + i, hex(rand_auts, 16)); + + rc = osmo_auth_gen_vec_auts(vec+i, aud3g, auts, + rand_auts, rand); + /* The sqn used for the key is sqn - 1 because + * vector generation has already inc'd it. The + * USIM's sqn sent in AUTS is sqn - 2. */ + DBGP("vector [%u]: resync: sqn = %"PRIu64 "\n", + i, aud3g->u.umts.sqn - 1); + } else { + DBGP("vector [%u]: sqn = %" PRIu64 "\n", + i, aud3g->u.umts.sqn); rc = osmo_auth_gen_vec(vec+i, aud3g, rand); + } if (rc < 0) { LOGP(DAUC, LOGL_ERROR, "Error in 3G vector " - "generation: %d\n", rc); + "generation: [%u]: rc = %d\n", i, rc); goto out; } - } - if (aud2g && aud3g) { - /* separate 2G + 3G case: patch 2G into 3G */ - struct osmo_auth_vector vtmp; - DEBUGP(DAUC, "compute vector [%u]/%u:" - " separate 2G + 3G\n", i, num_vec); + + DBGVB(autn); + DBGVB(ck); + DBGVB(ik); + DBGVB(res); + DBGVV("%u", res_len); + + if (!aud2g) { + /* use the 2G tokens from 3G keys */ + DBGVB(kc); + DBGVB(sres); + DBGVV("0x%x", auth_types); + continue; + } + /* calculate 2G separately */ + + DBGP("vector [%u]: deriving 2G from 3G\n", i); + rc = osmo_auth_gen_vec(&vtmp, aud2g, rand); if (rc < 0) { - LOGP(DAUC, LOGL_ERROR, "Error in 2G vector " - "generation: %d\n", rc); + LOGP(DAUC, LOGL_ERROR, "Error in 2G vector" + "generation: [%u]: rc = %d\n", i, rc); goto out; } memcpy(&vec[i].kc, vtmp.kc, sizeof(vec[i].kc)); memcpy(&vec[i].sres, vtmp.sres, sizeof(vec[i].sres)); vec[i].auth_types |= OSMO_AUTH_TYPE_GSM; + } else { + /* 2G only case */ + rc = osmo_auth_gen_vec(vec+i, aud2g, rand); + if (rc < 0) { + LOGP(DAUC, LOGL_ERROR, "Error in 2G vector " + "generation: [%u]: rc = %d\n", i, rc); + goto out; + } } + + DBGVB(kc); + DBGVB(sres); + DBGVV("0x%x", auth_types); } out: return i; +#undef DBGVV +#undef DBGVB +#undef DBGP } diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index f8ff67a..51184c5 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -69,7 +69,6 @@ #define VEC_IS(vec, expect) do { \ char *_is = vec_str(vec); \ - fprintf(stderr, "auth vector ==\n%s\n", _is); \ if (strcmp(_is, expect)) { \ fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ expect); \ @@ -84,7 +83,8 @@ } \ } \ OSMO_ASSERT(false); \ - } \ + } else \ + fprintf(stderr, "vector matches expectations\n"); \ } while (0) uint8_t fake_rand[16] = { 0 }; diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index db076d7..e8e6f03 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -1,210 +1,209 @@ ===== test_gen_vectors_2g_only aud3g.u.umts.sqn == 0 -DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC compute vector [0]/1: 2G only +DAUC Computing 1 auth vector: 2G only +DAUC 2G: ki = eb215756028d60e3275e613320aec880 +DAUC vector [0]: rand = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: kc = 241a5b16aeb8e400 +DAUC vector [0]: sres = 429d5b27 +DAUC vector [0]: auth_types = 0x1 rc == 1 -auth vector == - rand: 39fa2f4e3d523d8619a73b4f65c3e14d - autn: 00000000000000000000000000000000 - ck: 00000000000000000000000000000000 - ik: 00000000000000000000000000000000 - res: 00000000000000000000000000000000 - res_len: 00 - kc: 241a5b16aeb8e400 - sres: 429d5b27 - auth_types: 01000000 - +vector matches expectations aud3g.u.umts.sqn == 0 -DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC compute vector [0]/1: 2G only +DAUC Computing 1 auth vector: 2G only +DAUC 2G: ki = eb215756028d60e3275e613320aec880 +DAUC vector [0]: rand = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: kc = 241a5b16aeb8e400 +DAUC vector [0]: sres = 429d5b27 +DAUC vector [0]: auth_types = 0x1 rc == 1 -auth vector == - rand: 39fa2f4e3d523d8619a73b4f65c3e14d - autn: 00000000000000000000000000000000 - ck: 00000000000000000000000000000000 - ik: 00000000000000000000000000000000 - res: 00000000000000000000000000000000 - res_len: 00 - kc: 241a5b16aeb8e400 - sres: 429d5b27 - auth_types: 01000000 - +vector matches expectations ===== test_gen_vectors_2g_only: SUCCESS ===== test_gen_vectors_2g_plus_3g aud3g.u.umts.sqn == 0 -DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC compute vector [0]/1: separate 2G + 3G +DAUC Computing 1 auth vector: 3G + separate 2G +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC 2G: ki = eb215756028d60e3275e613320aec880 +DAUC vector [0]: rand = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 8704f5ba55f30000d2ee44b22c8ea919 +DAUC vector [0]: ck = f64735036e5871319c679f4742a75ea1 +DAUC vector [0]: ik = 27497388b6cb044648f396aa155b95ef +DAUC vector [0]: res = e229c19e791f2e410000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: deriving 2G from 3G +DAUC vector [0]: kc = 241a5b16aeb8e400 +DAUC vector [0]: sres = 429d5b27 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 39fa2f4e3d523d8619a73b4f65c3e14d - autn: 8704f5ba55f30000d2ee44b22c8ea919 - ck: f64735036e5871319c679f4742a75ea1 - ik: 27497388b6cb044648f396aa155b95ef - res: e229c19e791f2e410000000000000000 - res_len: 08 - kc: 241a5b16aeb8e400 - sres: 429d5b27 - auth_types: 03000000 - +vector matches expectations aud3g.u.umts.sqn == 1 aud3g.u.umts.sqn == 0 -DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC compute vector [0]/1: separate 2G + 3G +DAUC Computing 1 auth vector: 3G + separate 2G +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC 2G: ki = eb215756028d60e3275e613320aec880 +DAUC vector [0]: rand = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 8704f5ba55f30000d2ee44b22c8ea919 +DAUC vector [0]: ck = f64735036e5871319c679f4742a75ea1 +DAUC vector [0]: ik = 27497388b6cb044648f396aa155b95ef +DAUC vector [0]: res = e229c19e791f2e410000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: deriving 2G from 3G +DAUC vector [0]: kc = 241a5b16aeb8e400 +DAUC vector [0]: sres = 429d5b27 +DAUC vector [0]: auth_types = 0x3 rc == 1 aud3g.u.umts.sqn == 1 -auth vector == - rand: 39fa2f4e3d523d8619a73b4f65c3e14d - autn: 8704f5ba55f30000d2ee44b22c8ea919 - ck: f64735036e5871319c679f4742a75ea1 - ik: 27497388b6cb044648f396aa155b95ef - res: e229c19e791f2e410000000000000000 - res_len: 08 - kc: 241a5b16aeb8e400 - sres: 429d5b27 - auth_types: 03000000 - +vector matches expectations ===== test_gen_vectors_2g_plus_3g: SUCCESS ===== test_gen_vectors_3g_only aud3g.u.umts.sqn == 0 -DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC vector [0]: rand = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 8704f5ba55f30000d2ee44b22c8ea919 +DAUC vector [0]: ck = f64735036e5871319c679f4742a75ea1 +DAUC vector [0]: ik = 27497388b6cb044648f396aa155b95ef +DAUC vector [0]: res = e229c19e791f2e410000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 059a4f668f6fbe39 +DAUC vector [0]: sres = 9b36efdf +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 39fa2f4e3d523d8619a73b4f65c3e14d - autn: 8704f5ba55f30000d2ee44b22c8ea919 - ck: f64735036e5871319c679f4742a75ea1 - ik: 27497388b6cb044648f396aa155b95ef - res: e229c19e791f2e410000000000000000 - res_len: 08 - kc: 059a4f668f6fbe39 - sres: 9b36efdf - auth_types: 03000000 - +vector matches expectations aud3g.u.umts.sqn == 1 aud3g.u.umts.sqn == 0 -DAUC rand 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC vector [0]: rand = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 8704f5ba55f30000d2ee44b22c8ea919 +DAUC vector [0]: ck = f64735036e5871319c679f4742a75ea1 +DAUC vector [0]: ik = 27497388b6cb044648f396aa155b95ef +DAUC vector [0]: res = e229c19e791f2e410000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 059a4f668f6fbe39 +DAUC vector [0]: sres = 9b36efdf +DAUC vector [0]: auth_types = 0x3 rc == 1 aud3g.u.umts.sqn == 1 -auth vector == - rand: 39fa2f4e3d523d8619a73b4f65c3e14d - autn: 8704f5ba55f30000d2ee44b22c8ea919 - ck: f64735036e5871319c679f4742a75ea1 - ik: 27497388b6cb044648f396aa155b95ef - res: e229c19e791f2e410000000000000000 - res_len: 08 - kc: 059a4f668f6fbe39 - sres: 9b36efdf - auth_types: 03000000 - +vector matches expectations - test AUTS resync aud3g.u.umts.sqn == 0 -DAUC rand 897210a0f7de278f0b8213098e098a3f -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys), with AUTS resync +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC vector [0]: rand = 897210a0f7de278f0b8213098e098a3f +DAUC vector [0]: resync: auts = 979498b1f72d3e28c59fa2e72f9c +DAUC vector [0]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: resync: sqn = 24 +DAUC vector [0]: autn = c6b9790dad4b00000cf322869ea6a481 +DAUC vector [0]: ck = e9922bd036718ed9e40bd1d02c3b81a5 +DAUC vector [0]: ik = f19c20ca863137f8892326d959ec5e01 +DAUC vector [0]: res = 9af5a557902d2db80000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 7526fc13c5976685 +DAUC vector [0]: sres = 0ad888ef +DAUC vector [0]: auth_types = 0x3 rc == 1 aud3g.u.umts.sqn == 25 -auth vector == - rand: 897210a0f7de278f0b8213098e098a3f - autn: c6b9790dad4b00000cf322869ea6a481 - ck: e9922bd036718ed9e40bd1d02c3b81a5 - ik: f19c20ca863137f8892326d959ec5e01 - res: 9af5a557902d2db80000000000000000 - res_len: 08 - kc: 7526fc13c5976685 - sres: 0ad888ef - auth_types: 03000000 - +vector matches expectations - verify N vectors with AUTS resync == N vectors without AUTS First just set rand and sqn = 24, and compute 3 vectors aud3g.u.umts.sqn == 24 -DAUC rand 897210a0f7de278f0b8213098e098a3f -DAUC compute vector [0]/3: 3G only -DAUC rand 9a8321b108ef38a01c93241a9f1a9b50 -DAUC compute vector [1]/3: 3G only -DAUC rand ab9432c2190049b12da4352bb02bac61 -DAUC compute vector [2]/3: 3G only +DAUC Computing 3 auth vectors: 3G only (2G derived from 3G keys) +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC vector [0]: rand = 897210a0f7de278f0b8213098e098a3f +DAUC vector [0]: sqn = 24 +DAUC vector [0]: autn = c6b9790dad4b00000cf322869ea6a481 +DAUC vector [0]: ck = e9922bd036718ed9e40bd1d02c3b81a5 +DAUC vector [0]: ik = f19c20ca863137f8892326d959ec5e01 +DAUC vector [0]: res = 9af5a557902d2db80000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 7526fc13c5976685 +DAUC vector [0]: sres = 0ad888ef +DAUC vector [0]: auth_types = 0x3 +DAUC vector [1]: rand = 9a8321b108ef38a01c93241a9f1a9b50 +DAUC vector [1]: sqn = 25 +DAUC vector [1]: autn = 79a5113eb0910000be6020540503ffc5 +DAUC vector [1]: ck = 3686f05df057d1899c66ae4eb18cf941 +DAUC vector [1]: ik = 79f21ed53bcb47787de57d136ff803a5 +DAUC vector [1]: res = 43023475cb29292c0000000000000000 +DAUC vector [1]: res_len = 8 +DAUC vector [1]: kc = aef73dd515e86c15 +DAUC vector [1]: sres = 882b1d59 +DAUC vector [1]: auth_types = 0x3 +DAUC vector [2]: rand = ab9432c2190049b12da4352bb02bac61 +DAUC vector [2]: sqn = 26 +DAUC vector [2]: autn = 24b018d46c3b00009c7e1b47f3a19b2b +DAUC vector [2]: ck = d86c3191a36fc0602e48202ef2080964 +DAUC vector [2]: ik = 648dab72016181406243420649e63dc9 +DAUC vector [2]: res = 010cab11cc63a6e40000000000000000 +DAUC vector [2]: res_len = 8 +DAUC vector [2]: kc = f0eaf8cb19e0758d +DAUC vector [2]: sres = cd6f0df5 +DAUC vector [2]: auth_types = 0x3 rc == 3 aud3g.u.umts.sqn == 27 -[0]: auth vector == - rand: 897210a0f7de278f0b8213098e098a3f - autn: c6b9790dad4b00000cf322869ea6a481 - ck: e9922bd036718ed9e40bd1d02c3b81a5 - ik: f19c20ca863137f8892326d959ec5e01 - res: 9af5a557902d2db80000000000000000 - res_len: 08 - kc: 7526fc13c5976685 - sres: 0ad888ef - auth_types: 03000000 - -[1]: auth vector == - rand: 9a8321b108ef38a01c93241a9f1a9b50 - autn: 79a5113eb0910000be6020540503ffc5 - ck: 3686f05df057d1899c66ae4eb18cf941 - ik: 79f21ed53bcb47787de57d136ff803a5 - res: 43023475cb29292c0000000000000000 - res_len: 08 - kc: aef73dd515e86c15 - sres: 882b1d59 - auth_types: 03000000 - -[2]: auth vector == - rand: ab9432c2190049b12da4352bb02bac61 - autn: 24b018d46c3b00009c7e1b47f3a19b2b - ck: d86c3191a36fc0602e48202ef2080964 - ik: 648dab72016181406243420649e63dc9 - res: 010cab11cc63a6e40000000000000000 - res_len: 08 - kc: f0eaf8cb19e0758d - sres: cd6f0df5 - auth_types: 03000000 - +[0]: vector matches expectations +[1]: vector matches expectations +[2]: vector matches expectations Now reach sqn = 24 with AUTS and expect the same -DAUC rand 897210a0f7de278f0b8213098e098a3f -DAUC compute vector [0]/3: 3G only -DAUC rand 9a8321b108ef38a01c93241a9f1a9b50 -DAUC compute vector [1]/3: 3G only -DAUC rand ab9432c2190049b12da4352bb02bac61 -DAUC compute vector [2]/3: 3G only +DAUC Computing 3 auth vectors: 3G only (2G derived from 3G keys), with AUTS resync +DAUC 3G: k = eb215756028d60e3275e613320aec880 +DAUC 3G: opc = fb2a3d1b360f599abab99db8669f8308 +DAUC vector [0]: rand = 897210a0f7de278f0b8213098e098a3f +DAUC vector [0]: resync: auts = 979498b1f72d3e28c59fa2e72f9c +DAUC vector [0]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [0]: resync: sqn = 24 +DAUC vector [0]: autn = c6b9790dad4b00000cf322869ea6a481 +DAUC vector [0]: ck = e9922bd036718ed9e40bd1d02c3b81a5 +DAUC vector [0]: ik = f19c20ca863137f8892326d959ec5e01 +DAUC vector [0]: res = 9af5a557902d2db80000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 7526fc13c5976685 +DAUC vector [0]: sres = 0ad888ef +DAUC vector [0]: auth_types = 0x3 +DAUC vector [1]: rand = 9a8321b108ef38a01c93241a9f1a9b50 +DAUC vector [1]: resync: auts = 979498b1f72d3e28c59fa2e72f9c +DAUC vector [1]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [1]: resync: sqn = 24 +DAUC vector [1]: autn = 79a5113eb0900000f7e138537aa0962b +DAUC vector [1]: ck = 3686f05df057d1899c66ae4eb18cf941 +DAUC vector [1]: ik = 79f21ed53bcb47787de57d136ff803a5 +DAUC vector [1]: res = 43023475cb29292c0000000000000000 +DAUC vector [1]: res_len = 8 +DAUC vector [1]: kc = aef73dd515e86c15 +DAUC vector [1]: sres = 882b1d59 +DAUC vector [1]: auth_types = 0x3 +DAUC vector [2]: rand = ab9432c2190049b12da4352bb02bac61 +DAUC vector [2]: resync: auts = 979498b1f72d3e28c59fa2e72f9c +DAUC vector [2]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d +DAUC vector [2]: resync: sqn = 24 +DAUC vector [2]: autn = 24b018d46c390000d88e11730d0367ac +DAUC vector [2]: ck = d86c3191a36fc0602e48202ef2080964 +DAUC vector [2]: ik = 648dab72016181406243420649e63dc9 +DAUC vector [2]: res = 010cab11cc63a6e40000000000000000 +DAUC vector [2]: res_len = 8 +DAUC vector [2]: kc = f0eaf8cb19e0758d +DAUC vector [2]: sres = cd6f0df5 +DAUC vector [2]: auth_types = 0x3 THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED The SQN should increment with each new vector. -[0]: auth vector == - rand: 897210a0f7de278f0b8213098e098a3f - autn: c6b9790dad4b00000cf322869ea6a481 - ck: e9922bd036718ed9e40bd1d02c3b81a5 - ik: f19c20ca863137f8892326d959ec5e01 - res: 9af5a557902d2db80000000000000000 - res_len: 08 - kc: 7526fc13c5976685 - sres: 0ad888ef - auth_types: 03000000 - -[1]: auth vector == - rand: 9a8321b108ef38a01c93241a9f1a9b50 - autn: 79a5113eb0900000f7e138537aa0962b - ck: 3686f05df057d1899c66ae4eb18cf941 - ik: 79f21ed53bcb47787de57d136ff803a5 - res: 43023475cb29292c0000000000000000 - res_len: 08 - kc: aef73dd515e86c15 - sres: 882b1d59 - auth_types: 03000000 - -[2]: auth vector == - rand: ab9432c2190049b12da4352bb02bac61 - autn: 24b018d46c390000d88e11730d0367ac - ck: d86c3191a36fc0602e48202ef2080964 - ik: 648dab72016181406243420649e63dc9 - res: 010cab11cc63a6e40000000000000000 - res_len: 08 - kc: f0eaf8cb19e0758d - sres: cd6f0df5 - auth_types: 03000000 - +[0]: vector matches expectations +[1]: vector matches expectations +[2]: vector matches expectations ===== test_gen_vectors_3g_only: SUCCESS diff --git a/tests/auc/auc_ts_55_205_test_sets.err b/tests/auc/auc_ts_55_205_test_sets.err index 9a26922..8bedf46 100644 --- a/tests/auc/auc_ts_55_205_test_sets.err +++ b/tests/auc/auc_ts_55_205_test_sets.err @@ -1,304 +1,380 @@ ===== test_set_1 aud3g.u.umts.sqn == 0 -DAUC rand 23553cbe9637a89d218ae64dae47bf35 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 465b5ce8b199b49faa5f0a2ee238a6bc +DAUC 3G: opc = cd63cb71954a9f4e48a5994e37a02baf +DAUC vector [0]: rand = 23553cbe9637a89d218ae64dae47bf35 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = aa689c64837000000eed35e2ae9e21c0 +DAUC vector [0]: ck = b40ba9a3c58b2a05bbf0d987b21bf8cb +DAUC vector [0]: ik = f769bcd751044604127672711c6d3441 +DAUC vector [0]: res = a54211d5e3ba50bf0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = eae4be823af9a08b +DAUC vector [0]: sres = 46f8416a +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 23553cbe9637a89d218ae64dae47bf35 - ck: b40ba9a3c58b2a05bbf0d987b21bf8cb - ik: f769bcd751044604127672711c6d3441 - res: a54211d5e3ba50bf0000000000000000 - kc: eae4be823af9a08b - sres: 46f8416a - +vector matches expectations ===== test_set_1: SUCCESS ===== test_set_2 aud3g.u.umts.sqn == 0 -DAUC rand 9f7c8d021accf4db213ccff0c7f71a6a -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = fec86ba6eb707ed08905757b1bb44b8f +DAUC 3G: opc = 1006020f0a478bf6b699f15c062e42b3 +DAUC vector [0]: rand = 9f7c8d021accf4db213ccff0c7f71a6a +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 33484dc2136b00009abcd7740cfa799c +DAUC vector [0]: ck = 5dbdbb2954e8f3cde665b046179a5098 +DAUC vector [0]: ik = 59a92d3b476a0443487055cf88b2307b +DAUC vector [0]: res = 8011c48c0c214ed20000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = aa01739b8caa976d +DAUC vector [0]: sres = 8c308a5e +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 9f7c8d021accf4db213ccff0c7f71a6a - ck: 5dbdbb2954e8f3cde665b046179a5098 - ik: 59a92d3b476a0443487055cf88b2307b - res: 8011c48c0c214ed20000000000000000 - kc: aa01739b8caa976d - sres: 8c308a5e - +vector matches expectations ===== test_set_2: SUCCESS ===== test_set_3 aud3g.u.umts.sqn == 0 -DAUC rand ce83dbc54ac0274a157c17f80d017bd6 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 9e5944aea94b81165c82fbf9f32db751 +DAUC 3G: opc = a64a507ae1a2a98bb88eb4210135dc87 +DAUC vector [0]: rand = ce83dbc54ac0274a157c17f80d017bd6 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = f0b9c08ad02e00001b5ca3e1240212be +DAUC vector [0]: ck = e203edb3971574f5a94b0d61b816345d +DAUC vector [0]: ik = 0c4524adeac041c4dd830d20854fc46b +DAUC vector [0]: res = f365cd683cd92e960000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 9a8ec95f408cc507 +DAUC vector [0]: sres = cfbce3fe +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: ce83dbc54ac0274a157c17f80d017bd6 - ck: e203edb3971574f5a94b0d61b816345d - ik: 0c4524adeac041c4dd830d20854fc46b - res: f365cd683cd92e960000000000000000 - kc: 9a8ec95f408cc507 - sres: cfbce3fe - +vector matches expectations ===== test_set_3: SUCCESS ===== test_set_4 aud3g.u.umts.sqn == 0 -DAUC rand 74b0cd6031a1c8339b2b6ce2b8c4a186 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 4ab1deb05ca6ceb051fc98e77d026a84 +DAUC 3G: opc = dcf07cbd51855290b92a07a9891e523e +DAUC vector [0]: rand = 74b0cd6031a1c8339b2b6ce2b8c4a186 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 31e11a6091180000f55f5c8adb793014 +DAUC vector [0]: ck = 7657766b373d1c2138f307e3de9242f9 +DAUC vector [0]: ik = 1c42e960d89b8fa99f2744e0708ccb53 +DAUC vector [0]: res = 5860fc1bce351e7e0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = cdc1dc0841b81a22 +DAUC vector [0]: sres = 9655e265 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 74b0cd6031a1c8339b2b6ce2b8c4a186 - ck: 7657766b373d1c2138f307e3de9242f9 - ik: 1c42e960d89b8fa99f2744e0708ccb53 - res: 5860fc1bce351e7e0000000000000000 - kc: cdc1dc0841b81a22 - sres: 9655e265 - +vector matches expectations ===== test_set_4: SUCCESS ===== test_set_5 aud3g.u.umts.sqn == 0 -DAUC rand ee6466bc96202c5a557abbeff8babf63 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 6c38a116ac280c454f59332ee35c8c4f +DAUC 3G: opc = 3803ef5363b947c6aaa225e58fae3934 +DAUC vector [0]: rand = ee6466bc96202c5a557abbeff8babf63 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 45b0f69ab06c0000a161b2de788f3b3f +DAUC vector [0]: ck = 3f8c7587fe8e4b233af676aede30ba3b +DAUC vector [0]: ik = a7466cc1e6b2a1337d49d3b66e95d7b4 +DAUC vector [0]: res = 16c8233f05a0ac280000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = df75bc5ea899879f +DAUC vector [0]: sres = 13688f17 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: ee6466bc96202c5a557abbeff8babf63 - ck: 3f8c7587fe8e4b233af676aede30ba3b - ik: a7466cc1e6b2a1337d49d3b66e95d7b4 - res: 16c8233f05a0ac280000000000000000 - kc: df75bc5ea899879f - sres: 13688f17 - +vector matches expectations ===== test_set_5: SUCCESS ===== test_set_6 aud3g.u.umts.sqn == 0 -DAUC rand 194aa756013896b74b4a2a3b0af4539e -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 2d609d4db0ac5bf0d2c0de267014de0d +DAUC 3G: opc = c35a0ab0bcbfc9252caff15f24efbde0 +DAUC vector [0]: rand = 194aa756013896b74b4a2a3b0af4539e +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 7e6455f34cf3000040dc9568192ab1c0 +DAUC vector [0]: ck = 4cd0846020f8fa0731dd47cbdc6be411 +DAUC vector [0]: ik = 88ab80a415f15c73711254a1d388f696 +DAUC vector [0]: res = 8c25a16cd918a1df0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 84b417ae3aeab4f3 +DAUC vector [0]: sres = 553d00b3 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 194aa756013896b74b4a2a3b0af4539e - ck: 4cd0846020f8fa0731dd47cbdc6be411 - ik: 88ab80a415f15c73711254a1d388f696 - res: 8c25a16cd918a1df0000000000000000 - kc: 84b417ae3aeab4f3 - sres: 553d00b3 - +vector matches expectations ===== test_set_6: SUCCESS ===== test_set_7 aud3g.u.umts.sqn == 0 -DAUC rand 3a4c2b3245c50eb5c71d08639395764d -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = a530a7fe428fad1082c45eddfce13884 +DAUC 3G: opc = 27953e49bc8af6dcc6e730eb80286be3 +DAUC vector [0]: rand = 3a4c2b3245c50eb5c71d08639395764d +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 88196c47986f000075c2ba7455852c2a +DAUC vector [0]: ck = 10f05bab75a99a5fbb98a9c287679c3b +DAUC vector [0]: ik = f9ec0865eb32f22369cade40c59c3a44 +DAUC vector [0]: res = a63241e1ffc3e5ab0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 3b4e244cdc60ce03 +DAUC vector [0]: sres = 59f1a44a +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 3a4c2b3245c50eb5c71d08639395764d - ck: 10f05bab75a99a5fbb98a9c287679c3b - ik: f9ec0865eb32f22369cade40c59c3a44 - res: a63241e1ffc3e5ab0000000000000000 - kc: 3b4e244cdc60ce03 - sres: 59f1a44a - +vector matches expectations ===== test_set_7: SUCCESS ===== test_set_8 aud3g.u.umts.sqn == 0 -DAUC rand f761e5e93d603feb730e27556cb8a2ca -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = d9151cf04896e25830bf2e08267b8360 +DAUC 3G: opc = c4c93effe8a08138c203d4c27ce4e3d9 +DAUC vector [0]: rand = f761e5e93d603feb730e27556cb8a2ca +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 82a0f5287a71000023563512500d75d9 +DAUC vector [0]: ck = 71236b7129f9b22ab77ea7a54c96da22 +DAUC vector [0]: ik = 90527ebaa5588968db41727325a04d9e +DAUC vector [0]: res = 4a90b2171ac83a760000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 8d4ec01de597acfe +DAUC vector [0]: sres = 50588861 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: f761e5e93d603feb730e27556cb8a2ca - ck: 71236b7129f9b22ab77ea7a54c96da22 - ik: 90527ebaa5588968db41727325a04d9e - res: 4a90b2171ac83a760000000000000000 - kc: 8d4ec01de597acfe - sres: 50588861 - +vector matches expectations ===== test_set_8: SUCCESS ===== test_set_9 aud3g.u.umts.sqn == 0 -DAUC rand 08eff828b13fdb562722c65c7f30a9b2 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = a0e2971b6822e8d354a18cc235624ecb +DAUC 3G: opc = 82a26f22bba9e9488f949a10d98e9cc4 +DAUC vector [0]: rand = 08eff828b13fdb562722c65c7f30a9b2 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = a2f858aa9e5d0000bdd79d9f7c269d1c +DAUC vector [0]: ck = 08cef6d004ec61471a3c3cda048137fa +DAUC vector [0]: ik = ed0318ca5deb9206272f6e8fa64ba411 +DAUC vector [0]: res = 4bc2212d8624910a0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = d8debc4ffbcd60aa +DAUC vector [0]: sres = cde6b027 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 08eff828b13fdb562722c65c7f30a9b2 - ck: 08cef6d004ec61471a3c3cda048137fa - ik: ed0318ca5deb9206272f6e8fa64ba411 - res: 4bc2212d8624910a0000000000000000 - kc: d8debc4ffbcd60aa - sres: cde6b027 - +vector matches expectations ===== test_set_9: SUCCESS ===== test_set_10 aud3g.u.umts.sqn == 0 -DAUC rand 679ac4dbacd7d233ff9d6806f4149ce3 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 0da6f7ba86d5eac8a19cf563ac58642d +DAUC 3G: opc = 0db1071f8767562ca43a0a64c41e8d08 +DAUC vector [0]: rand = 679ac4dbacd7d233ff9d6806f4149ce3 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 4c539a26e1fa000059e7ec99b51f33f3 +DAUC vector [0]: ck = 69b1cae7c7429d975e245cacb05a517c +DAUC vector [0]: ik = 74f24e8c26df58e1b38d7dcd4f1b7fbd +DAUC vector [0]: res = 6fc30fee6d1235230000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = f0eaa50a1edcebb7 +DAUC vector [0]: sres = 02d13acd +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 679ac4dbacd7d233ff9d6806f4149ce3 - ck: 69b1cae7c7429d975e245cacb05a517c - ik: 74f24e8c26df58e1b38d7dcd4f1b7fbd - res: 6fc30fee6d1235230000000000000000 - kc: f0eaa50a1edcebb7 - sres: 02d13acd - +vector matches expectations ===== test_set_10: SUCCESS ===== test_set_11 aud3g.u.umts.sqn == 0 -DAUC rand 4c47eb3076dc55fe5106cb2034b8cd78 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 77b45843c88e58c10d202684515ed430 +DAUC 3G: opc = d483afae562409a326b5bb0b20c4d762 +DAUC vector [0]: rand = 4c47eb3076dc55fe5106cb2034b8cd78 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 30ff25cdadf600003991f8e7e72a5948 +DAUC vector [0]: ck = 908c43f0569cb8f74bc971e706c36c5f +DAUC vector [0]: ik = c251df0d888dd9329bcf46655b226e40 +DAUC vector [0]: res = aefa357beac2a87a0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 82dbab7f83f063da +DAUC vector [0]: sres = 44389d01 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 4c47eb3076dc55fe5106cb2034b8cd78 - ck: 908c43f0569cb8f74bc971e706c36c5f - ik: c251df0d888dd9329bcf46655b226e40 - res: aefa357beac2a87a0000000000000000 - kc: 82dbab7f83f063da - sres: 44389d01 - +vector matches expectations ===== test_set_11: SUCCESS ===== test_set_12 aud3g.u.umts.sqn == 0 -DAUC rand 311c4c929744d675b720f3b7e9b1cbd0 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 729b17729270dd87ccdf1bfe29b4e9bb +DAUC 3G: opc = 228c2f2f06ac3268a9e616ee16db4ba1 +DAUC vector [0]: rand = 311c4c929744d675b720f3b7e9b1cbd0 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 5380d158cfe30000fd10b1f261e825c3 +DAUC vector [0]: ck = 44c0f23c5493cfd241e48f197e1d1012 +DAUC vector [0]: ik = 0c9fb81613884c2535dd0eabf3b440d8 +DAUC vector [0]: res = 98dbbd099b3b408d0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 3c66cb98cab2d33d +DAUC vector [0]: sres = 03e0fd84 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 311c4c929744d675b720f3b7e9b1cbd0 - ck: 44c0f23c5493cfd241e48f197e1d1012 - ik: 0c9fb81613884c2535dd0eabf3b440d8 - res: 98dbbd099b3b408d0000000000000000 - kc: 3c66cb98cab2d33d - sres: 03e0fd84 - +vector matches expectations ===== test_set_12: SUCCESS ===== test_set_13 aud3g.u.umts.sqn == 0 -DAUC rand cf7d0ab1d94306950bf12018fbd46887 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = d32dd23e89dc662354ca12eb79dd32fa +DAUC 3G: opc = d22a4b4180a5325708a5ff70d9f67ec7 +DAUC vector [0]: rand = cf7d0ab1d94306950bf12018fbd46887 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 217af49272ad0000cc1d4642c4476641 +DAUC vector [0]: ck = 5af86b80edb70df5292cc1121cbad50c +DAUC vector [0]: ik = 7f4d6ae7440e18789a8b75ad3f42f03a +DAUC vector [0]: res = af4a411e1139f2c20000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 9612b5d88a4130bb +DAUC vector [0]: sres = be73b3dc +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: cf7d0ab1d94306950bf12018fbd46887 - ck: 5af86b80edb70df5292cc1121cbad50c - ik: 7f4d6ae7440e18789a8b75ad3f42f03a - res: af4a411e1139f2c20000000000000000 - kc: 9612b5d88a4130bb - sres: be73b3dc - +vector matches expectations ===== test_set_13: SUCCESS ===== test_set_14 aud3g.u.umts.sqn == 0 -DAUC rand 1f0f8578464fd59b64bed2d09436b57a -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = af7c65e1927221de591187a2c5987a53 +DAUC 3G: opc = a4cf5c8155c08a7eff418e5443b98e55 +DAUC vector [0]: rand = 1f0f8578464fd59b64bed2d09436b57a +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 837fd7b744190000e4ae3648e1c7770b +DAUC vector [0]: ck = 3f8c3f3ccf7625bf77fc94bcfd22fd26 +DAUC vector [0]: ik = abcbae8fd46115e9961a55d0da5f2078 +DAUC vector [0]: res = 7bffa5c2f41fbc050000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 75a150df3c6aed08 +DAUC vector [0]: sres = 8fe019c7 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 1f0f8578464fd59b64bed2d09436b57a - ck: 3f8c3f3ccf7625bf77fc94bcfd22fd26 - ik: abcbae8fd46115e9961a55d0da5f2078 - res: 7bffa5c2f41fbc050000000000000000 - kc: 75a150df3c6aed08 - sres: 8fe019c7 - +vector matches expectations ===== test_set_14: SUCCESS ===== test_set_15 aud3g.u.umts.sqn == 0 -DAUC rand 59b75f14251c75031d0bcbac1c2c04c7 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 5bd7ecd3d3127a41d12539bed4e7cf71 +DAUC 3G: opc = 76089d3c0ff3efdc6e36721d4fceb747 +DAUC vector [0]: rand = 59b75f14251c75031d0bcbac1c2c04c7 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 5be11495525d00008538a96619c04b01 +DAUC vector [0]: ck = d42b2d615e49a03ac275a5aef97af892 +DAUC vector [0]: ik = 0b3f8d024fe6bfafaa982b8f82e319c2 +DAUC vector [0]: res = 7e3f44c7591f6f450000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = b7f92e426a36fec5 +DAUC vector [0]: sres = 27202b82 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 59b75f14251c75031d0bcbac1c2c04c7 - ck: d42b2d615e49a03ac275a5aef97af892 - ik: 0b3f8d024fe6bfafaa982b8f82e319c2 - res: 7e3f44c7591f6f450000000000000000 - kc: b7f92e426a36fec5 - sres: 27202b82 - +vector matches expectations ===== test_set_15: SUCCESS ===== test_set_16 aud3g.u.umts.sqn == 0 -DAUC rand f69b78f300a0568bce9f0cb93c4be4c9 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 6cd1c6ceb1e01e14f1b82316a90b7f3d +DAUC 3G: opc = a219dc37f1dc7d66738b5843c799f206 +DAUC vector [0]: rand = f69b78f300a0568bce9f0cb93c4be4c9 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 1c408a858b3e0000956596c6cd632f0f +DAUC vector [0]: ck = 6edaf99e5bd9f85d5f36d91c1272fb4b +DAUC vector [0]: ik = d61c853c280dd9c46f297baec386de17 +DAUC vector [0]: res = 70f6bdb9ad21525f0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 88d9de10a22004c5 +DAUC vector [0]: sres = ddd7efe6 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: f69b78f300a0568bce9f0cb93c4be4c9 - ck: 6edaf99e5bd9f85d5f36d91c1272fb4b - ik: d61c853c280dd9c46f297baec386de17 - res: 70f6bdb9ad21525f0000000000000000 - kc: 88d9de10a22004c5 - sres: ddd7efe6 - +vector matches expectations ===== test_set_16: SUCCESS ===== test_set_17 aud3g.u.umts.sqn == 0 -DAUC rand b120f1c1a0102a2f507dd543de68281f -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = b73a90cbcf3afb622dba83c58a8415df +DAUC 3G: opc = df0c67868fa25f748b7044c6e7c245b8 +DAUC vector [0]: rand = b120f1c1a0102a2f507dd543de68281f +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = aefdaa5ddd9900003bf0fbdbbc9d8ecc +DAUC vector [0]: ck = 66195dbed0313274c5ca7766615fa25e +DAUC vector [0]: ik = 66bec707eb2afc476d7408a8f2927b36 +DAUC vector [0]: res = 479dd25c20792d630000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = a819e577a8d6175b +DAUC vector [0]: sres = 67e4ff3f +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: b120f1c1a0102a2f507dd543de68281f - ck: 66195dbed0313274c5ca7766615fa25e - ik: 66bec707eb2afc476d7408a8f2927b36 - res: 479dd25c20792d630000000000000000 - kc: a819e577a8d6175b - sres: 67e4ff3f - +vector matches expectations ===== test_set_17: SUCCESS ===== test_set_18 aud3g.u.umts.sqn == 0 -DAUC rand 81e92b6c0ee0e12ebceba8d92a99dfa5 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 5122250214c33e723a5dd523fc145fc0 +DAUC 3G: opc = 981d464c7c52eb6e5036234984ad0bcf +DAUC vector [0]: rand = 81e92b6c0ee0e12ebceba8d92a99dfa5 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = ada15aeb7bb80000f141568691cccaec +DAUC vector [0]: ck = 5349fbe098649f948f5d2e973a81c00f +DAUC vector [0]: ik = 9744871ad32bf9bbd1dd5ce54e3e2e5a +DAUC vector [0]: res = 28d7b0f2a2ec3de50000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = 9a8d0e883ff0887a +DAUC vector [0]: sres = 8a3b8d17 +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 81e92b6c0ee0e12ebceba8d92a99dfa5 - ck: 5349fbe098649f948f5d2e973a81c00f - ik: 9744871ad32bf9bbd1dd5ce54e3e2e5a - res: 28d7b0f2a2ec3de50000000000000000 - kc: 9a8d0e883ff0887a - sres: 8a3b8d17 - +vector matches expectations ===== test_set_18: SUCCESS ===== test_set_19 aud3g.u.umts.sqn == 0 -DAUC rand 9fddc72092c6ad036b6e464789315b78 -DAUC compute vector [0]/1: 3G only +DAUC Computing 1 auth vector: 3G only (2G derived from 3G keys) +DAUC 3G: k = 90dca4eda45b53cf0f12d7c9c3bc6a89 +DAUC 3G: opc = cb9cccc4b9258e6dca4760379fb82581 +DAUC vector [0]: rand = 9fddc72092c6ad036b6e464789315b78 +DAUC vector [0]: sqn = 0 +DAUC vector [0]: autn = 83cfd54db9130000eb5e0ab0a7c030e6 +DAUC vector [0]: ck = b5f2da03883b69f96bf52e029ed9ac45 +DAUC vector [0]: ik = b4721368bc16ea67875c5598688bb0ef +DAUC vector [0]: res = a95100e2760952cd0000000000000000 +DAUC vector [0]: res_len = 8 +DAUC vector [0]: kc = ed29b2f1c27f9f34 +DAUC vector [0]: sres = df58522f +DAUC vector [0]: auth_types = 0x3 rc == 1 -auth vector == - rand: 9fddc72092c6ad036b6e464789315b78 - ck: b5f2da03883b69f96bf52e029ed9ac45 - ik: b4721368bc16ea67875c5598688bb0ef - res: a95100e2760952cd0000000000000000 - kc: ed29b2f1c27f9f34 - sres: df58522f - +vector matches expectations ===== test_set_19: SUCCESS diff --git a/tests/auc/gen_ts_55_205_test_sets/main_template.c b/tests/auc/gen_ts_55_205_test_sets/main_template.c index c03b820..e917e71 100644 --- a/tests/auc/gen_ts_55_205_test_sets/main_template.c +++ b/tests/auc/gen_ts_55_205_test_sets/main_template.c @@ -70,7 +70,6 @@ #define VEC_IS(vec, expect) do { \ char *_is = vec_str(vec); \ - fprintf(stderr, "auth vector ==\n%s\n", _is); \ if (strcmp(_is, expect)) { \ fprintf(stderr, "MISMATCH! expected ==\n%s\n", \ expect); \ @@ -85,7 +84,8 @@ } \ } \ OSMO_ASSERT(false); \ - } \ + } else \ + fprintf(stderr, "vector matches expectations\n"); \ } while (0) uint8_t fake_rand[16] = { 0 }; -- To view, visit https://gerrit.osmocom.org/1869 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:28 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:28 +0000 Subject: [PATCH] osmo-hlr[master]: auc_compute_vectors(): fix AUTS resync for multiple vectors Message-ID: Review at https://gerrit.osmocom.org/1870 auc_compute_vectors(): fix AUTS resync for multiple vectors Fix bug where AUTS was fed to each vector generation and thus each vector was generated with the same SQN. In auc_3g_test, adjust the bug indicating test expectations to now expect the proper results. Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4 Change-Id: I425a1d92c85896227341f565f5361c0d830ce866 --- M src/auc.c M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 3 files changed, 8 insertions(+), 56 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/70/1870/1 diff --git a/src/auc.c b/src/auc.c index f4d19a0..9c20db2 100644 --- a/src/auc.c +++ b/src/auc.c @@ -113,7 +113,9 @@ if (aud3g) { /* 3G or 3G + 2G case */ - if (auts) { + /* Do AUTS only for the first vector or we would use + * the same SQN for each following key. */ + if ((i == 0) && auts) { DBGP("vector [%u]: resync: auts = %s\n", i, hex(auts, 14)); DBGP("vector [%u]: resync: rand_auts = %s\n", diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 51184c5..7b12358 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -239,48 +239,6 @@ comment_end(); } -void _test_gen_vectors_3g_only__expect_vecs__WRONG(struct osmo_auth_vector vecs[3]) -{ - fprintf(stderr, "THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED\n"); - fprintf(stderr, "The SQN should increment with each new vector.\n"); - fprintf(stderr, "[0]: "); - VEC_IS(&vecs[0], - " rand: 897210a0f7de278f0b8213098e098a3f\n" - " autn: c6b9790dad4b00000cf322869ea6a481\n" - " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" - " ik: f19c20ca863137f8892326d959ec5e01\n" - " res: 9af5a557902d2db80000000000000000\n" - " res_len: 08\n" - " kc: 7526fc13c5976685\n" - " sres: 0ad888ef\n" - " auth_types: 03000000\n" - ); - fprintf(stderr, "[1]: "); - VEC_IS(&vecs[1], - " rand: 9a8321b108ef38a01c93241a9f1a9b50\n" - " autn: 79a5113eb0900000f7e138537aa0962b\n" - " ck: 3686f05df057d1899c66ae4eb18cf941\n" - " ik: 79f21ed53bcb47787de57d136ff803a5\n" - " res: 43023475cb29292c0000000000000000\n" - " res_len: 08\n" - " kc: aef73dd515e86c15\n" - " sres: 882b1d59\n" - " auth_types: 03000000\n" - ); - fprintf(stderr, "[2]: "); - VEC_IS(&vecs[2], - " rand: ab9432c2190049b12da4352bb02bac61\n" - " autn: 24b018d46c390000d88e11730d0367ac\n" - " ck: d86c3191a36fc0602e48202ef2080964\n" - " ik: 648dab72016181406243420649e63dc9\n" - " res: 010cab11cc63a6e40000000000000000\n" - " res_len: 08\n" - " kc: f0eaf8cb19e0758d\n" - " sres: cd6f0df5\n" - " auth_types: 03000000\n" - ); -} - void _test_gen_vectors_3g_only__expect_vecs(struct osmo_auth_vector vecs[3]) { fprintf(stderr, "[0]: "); @@ -487,9 +445,7 @@ next_rand("897210a0f7de278f0b8213098e098a3f", false); rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, rand_auts, auts); - /* THIS IS WRONG AND WILL BE FIXED IN A SUBSEQUENT COMMIT: - should be _test_gen_vectors_3g_only__expect_vecs() instead */ - _test_gen_vectors_3g_only__expect_vecs__WRONG(vecs); + _test_gen_vectors_3g_only__expect_vecs(vecs); comment_end(); } diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index e8e6f03..aff96c9 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -176,10 +176,8 @@ DAUC vector [0]: sres = 0ad888ef DAUC vector [0]: auth_types = 0x3 DAUC vector [1]: rand = 9a8321b108ef38a01c93241a9f1a9b50 -DAUC vector [1]: resync: auts = 979498b1f72d3e28c59fa2e72f9c -DAUC vector [1]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC vector [1]: resync: sqn = 24 -DAUC vector [1]: autn = 79a5113eb0900000f7e138537aa0962b +DAUC vector [1]: sqn = 25 +DAUC vector [1]: autn = 79a5113eb0910000be6020540503ffc5 DAUC vector [1]: ck = 3686f05df057d1899c66ae4eb18cf941 DAUC vector [1]: ik = 79f21ed53bcb47787de57d136ff803a5 DAUC vector [1]: res = 43023475cb29292c0000000000000000 @@ -188,10 +186,8 @@ DAUC vector [1]: sres = 882b1d59 DAUC vector [1]: auth_types = 0x3 DAUC vector [2]: rand = ab9432c2190049b12da4352bb02bac61 -DAUC vector [2]: resync: auts = 979498b1f72d3e28c59fa2e72f9c -DAUC vector [2]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC vector [2]: resync: sqn = 24 -DAUC vector [2]: autn = 24b018d46c390000d88e11730d0367ac +DAUC vector [2]: sqn = 26 +DAUC vector [2]: autn = 24b018d46c3b00009c7e1b47f3a19b2b DAUC vector [2]: ck = d86c3191a36fc0602e48202ef2080964 DAUC vector [2]: ik = 648dab72016181406243420649e63dc9 DAUC vector [2]: res = 010cab11cc63a6e40000000000000000 @@ -199,8 +195,6 @@ DAUC vector [2]: kc = f0eaf8cb19e0758d DAUC vector [2]: sres = cd6f0df5 DAUC vector [2]: auth_types = 0x3 -THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED -The SQN should increment with each new vector. [0]: vector matches expectations [1]: vector matches expectations [2]: vector matches expectations -- To view, visit https://gerrit.osmocom.org/1870 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I425a1d92c85896227341f565f5361c0d830ce866 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:29 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:29 +0000 Subject: [PATCH] osmo-hlr[master]: cosmetic: auc_3g_test: improve test debugging tools Message-ID: Review at https://gerrit.osmocom.org/1871 cosmetic: auc_3g_test: improve test debugging tools In the test failure mismatch printf, better indicate the place of first mismatch. Helpful if some byte within a hexdump differs, the case when debugging AUTS. Copy some optarg code from openbsc's msc_vlr tests to provide verbose mode that prints log statements' source file and line. Change-Id: I1b23da055b5edacba09310411caf43c4cd1c29bc --- M tests/auc/auc_3g_test.c 1 file changed, 66 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/71/1871/1 diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 7b12358..16c87f7 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -76,9 +77,13 @@ char *b = expect; \ for (; *a && *b; a++, b++) { \ if (*a != *b) { \ - while (a > _is && *(a-1) != '\n') a--; \ - fprintf(stderr, "mismatch at %d:\n" \ - "%s", (int)(a - _is), a); \ + fprintf(stderr, "mismatch at %d:\n", \ + (int)(a - _is)); \ + while (a > _is && *(a-1) != '\n') { \ + fprintf(stderr, " "); \ + a--; \ + } \ + fprintf(stderr, "v\n%s", a); \ break; \ } \ } \ @@ -547,11 +552,67 @@ comment_end(); } -int main() +static struct { + bool verbose; +} cmdline_opts = { + .verbose = false, +}; + +static void print_help(const char *program) +{ + printf("Usage:\n" + " %s [-v] [N [N...]]\n" + "Options:\n" + " -h --help show this text.\n" + " -v --verbose print source file and line numbers\n", + program + ); +} + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"verbose", 1, 0, 'v'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "hv", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_help(argv[0]); + exit(0); + case 'v': + cmdline_opts.verbose = true; + break; + default: + /* catch unknown options *as well as* missing arguments. */ + fprintf(stderr, "Error in command line options. Exiting.\n"); + exit(-1); + break; + } + } + + if (optind < argc) { + fprintf(stderr, "too many args\n"); + exit(-1); + } +} + +int main(int argc, char **argv) { printf("auc_3g_test.c\n"); + + handle_options(argc, argv); + osmo_init_logging(&hlr_log_info); - log_set_print_filename(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, cmdline_opts.verbose); log_set_print_timestamp(osmo_stderr_target, 0); log_set_use_color(osmo_stderr_target, 0); log_set_print_category(osmo_stderr_target, 1); -- To view, visit https://gerrit.osmocom.org/1871 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1b23da055b5edacba09310411caf43c4cd1c29bc Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:26:29 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:26:29 +0000 Subject: [PATCH] osmo-hlr[master]: cosmetic: rename auc_3g_test.c to auc_test.c Message-ID: Review at https://gerrit.osmocom.org/1872 cosmetic: rename auc_3g_test.c to auc_test.c The test includes 2G-only tests so the name is misleading. Splitting up makes no sense. Change-Id: I1a5a40413bf6636ead9370fb827aa0338c049e7f --- M tests/auc/Makefile.am R tests/auc/auc_test.c R tests/auc/auc_test.err R tests/auc/auc_test.ok M tests/testsuite.at 5 files changed, 9 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/72/1872/1 diff --git a/tests/auc/Makefile.am b/tests/auc/Makefile.am index 761396b..b3c20f2 100644 --- a/tests/auc/Makefile.am +++ b/tests/auc/Makefile.am @@ -16,23 +16,23 @@ $(NULL) EXTRA_DIST = \ - auc_3g_test.ok \ - auc_3g_test.err \ + auc_test.ok \ + auc_test.err \ auc_ts_55_205_test_sets.ok \ auc_ts_55_205_test_sets.err \ $(NULL) noinst_PROGRAMS = \ - auc_3g_test \ + auc_test \ auc_ts_55_205_test_sets \ $(NULL) -auc_3g_test_SOURCES = \ - auc_3g_test.c \ +auc_test_SOURCES = \ + auc_test.c \ $(NULL) -auc_3g_test_LDADD = \ +auc_test_LDADD = \ $(top_srcdir)/src/auc.c \ $(top_srcdir)/src/logging.c \ $(LIBOSMOCORE_LIBS) \ diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_test.c similarity index 100% rename from tests/auc/auc_3g_test.c rename to tests/auc/auc_test.c diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_test.err similarity index 100% rename from tests/auc/auc_3g_test.err rename to tests/auc/auc_test.err diff --git a/tests/auc/auc_3g_test.ok b/tests/auc/auc_test.ok similarity index 100% rename from tests/auc/auc_3g_test.ok rename to tests/auc/auc_test.ok diff --git a/tests/testsuite.at b/tests/testsuite.at index dc1de33..46d1456 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -3,9 +3,9 @@ AT_SETUP([auc]) AT_KEYWORDS([auc]) -cat $abs_srcdir/auc/auc_3g_test.ok > expout -cat $abs_srcdir/auc/auc_3g_test.err > experr -AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr]) +cat $abs_srcdir/auc/auc_test.ok > expout +cat $abs_srcdir/auc/auc_test.err > experr +AT_CHECK([$abs_top_builddir/tests/auc/auc_test], [], [expout], [experr]) AT_CLEANUP AT_SETUP([auc_ts_55_205_test_sets]) -- To view, visit https://gerrit.osmocom.org/1872 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1a5a40413bf6636ead9370fb827aa0338c049e7f Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:27:52 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:27:52 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: it doesn't make sense to update these before the logging_filter topic is through. -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:28:03 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:28:03 +0000 Subject: openbsc[master]: SGSN: Integrate basic support for UMTS AKA In-Reply-To: References: Message-ID: Patch Set 4: it doesn't make sense to update these before the logging_filter topic is through. -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:28:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:28:17 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 6: it doesn't make sense to update these before the logging_filter topic is through. -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:39:00 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:39:00 +0000 Subject: [PATCH] libosmocore[master]: gsup_test: also check stderr In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1863 to look at the new patch set (#2). gsup_test: also check stderr Configure logging to be deterministic and add stderr checking to testuite.at. However, exclude the thousands of message modification log lines from the log to not have a huge test expectation file. Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb --- M tests/Makefile.am M tests/gsup/gsup_test.c A tests/gsup/gsup_test.err M tests/testsuite.at 4 files changed, 89 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/1863/2 diff --git a/tests/Makefile.am b/tests/Makefile.am index 5731bf8..f6d4db3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -177,7 +177,8 @@ vty/vty_test.ok comp128/comp128_test.ok \ utils/utils_test.ok stats/stats_test.ok \ bitvec/bitvec_test.ok msgb/msgb_test.ok bits/bitcomp_test.ok \ - sim/sim_test.ok tlv/tlv_test.ok gsup/gsup_test.ok \ + sim/sim_test.ok tlv/tlv_test.ok \ + gsup/gsup_test.ok gsup/gsup_test.err \ oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \ write_queue/wqueue_test.ok socket/socket_test.ok \ socket/socket_test.err diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 42e7b81..a950ca3 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -134,9 +134,9 @@ 0x25, 0x10, /* AUTN (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x25, 0x08, /* RES (UMTS) */ + 0x27, 0x08, /* RES (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x03, 0x22, /* Auth tuple */ + 0x03, 0x62, /* Auth tuple */ 0x20, 0x10, /* rand */ 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x10, @@ -153,17 +153,17 @@ 0x25, 0x10, /* AUTN (UMTS) */ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf0, - 0x25, 0x08, /* RES (UMTS) */ + 0x27, 0x08, /* RES (UMTS) */ 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, }; static const uint8_t send_auth_info_req_auts[] = { 0x08, TEST_IMSI_IE, - 0x26, 0x0e, + 0x26, 0x0e, /* AUTS (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, - 0x20, 0x10, + 0x20, 0x10, /* rand */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, }; @@ -198,7 +198,7 @@ {"Purge MS Result", purge_ms_res, sizeof(purge_ms_res)}, {"Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)", - send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, + send_auth_info_res_umts, sizeof(send_auth_info_res_umts)}, {"Send Authentication Info Request with AUTS and RAND (UMTS)", send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, }; @@ -264,6 +264,10 @@ test_idx, counter, parse_err); } + /* Don't log thousands of message modification errors */ + LOGP(DLGSUP, LOGL_NOTICE, "Stopping DLGSUP logging\n"); + log_set_category_filter(osmo_stderr_target, DLGSUP, 0, 0); + /* message modification test (relies on ASAN or valgrind being used) */ for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) { int j; @@ -309,6 +313,10 @@ int main(int argc, char **argv) { osmo_init_logging(&info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); test_gsup_messages_dec_enc(); diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err new file mode 100644 index 0000000..6cd8627 --- /dev/null +++ b/tests/gsup/gsup_test.err @@ -0,0 +1,71 @@ + generated message: 08 01 08 21 43 65 87 09 21 43 f5 + original message: 08 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07 + original message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07 + IMSI: 123456789012345 + generated message: 0a 01 08 21 43 65 87 09 21 43 f5 03 22 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 03 22 20 10 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 21 04 a1 a2 a3 a4 22 08 b1 b2 b3 b4 b5 b6 b7 b8 + original message: 0a 01 08 21 43 65 87 09 21 43 f5 03 22 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 03 22 20 10 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 21 04 a1 a2 a3 a4 22 08 b1 b2 b3 b4 b5 b6 b7 b8 + IMSI: 123456789012345 + generated message: 04 01 08 21 43 65 87 09 21 43 f5 + original message: 04 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 05 01 08 21 43 65 87 09 21 43 f5 02 01 07 + original message: 05 01 08 21 43 65 87 09 21 43 f5 02 01 07 + IMSI: 123456789012345 + generated message: 06 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 09 07 91 83 52 38 48 83 93 04 00 05 15 10 01 01 11 02 f1 21 12 09 04 74 65 73 74 03 61 70 6e 13 01 02 05 11 10 01 02 11 02 f1 21 12 08 03 66 6f 6f 03 61 70 6e + original message: 06 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 09 07 91 83 52 38 48 83 93 04 00 05 15 10 01 01 11 02 f1 21 12 09 04 74 65 73 74 03 61 70 6e 13 01 02 05 11 10 01 02 11 02 f1 21 12 08 03 66 6f 6f 03 61 70 6e + IMSI: 123456789012345 + generated message: 1c 01 08 21 43 65 87 09 21 43 f5 06 01 00 + original message: 1c 01 08 21 43 65 87 09 21 43 f5 06 01 00 + IMSI: 123456789012345 + generated message: 1d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + original message: 1d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + IMSI: 123456789012345 + generated message: 1e 01 08 21 43 65 87 09 21 43 f5 + original message: 1e 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 0c 01 08 21 43 65 87 09 21 43 f5 + original message: 0c 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 0d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + original message: 0d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + IMSI: 123456789012345 + generated message: 0e 01 08 21 43 65 87 09 21 43 f5 07 00 + original message: 0e 01 08 21 43 65 87 09 21 43 f5 07 00 + IMSI: 123456789012345 + generated message: 0a 01 08 21 43 65 87 09 21 43 f5 03 62 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 23 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 24 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 25 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 27 08 01 02 03 04 05 06 07 08 03 62 20 10 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 10 21 04 b1 b2 b3 b4 22 08 c1 c2 c3 c4 c5 c6 c7 c8 23 10 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df d0 24 10 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef e0 25 10 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff f0 27 08 91 92 93 94 95 96 97 98 + original message: 0a 01 08 21 43 65 87 09 21 43 f5 03 62 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 23 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 24 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 25 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 27 08 01 02 03 04 05 06 07 08 03 62 20 10 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 10 21 04 b1 b2 b3 b4 22 08 c1 c2 c3 c4 c5 c6 c7 c8 23 10 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df d0 24 10 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef e0 25 10 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff f0 27 08 91 92 93 94 95 96 97 98 + IMSI: 123456789012345 + generated message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 + original message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 + IMSI: 123456789012345 + message 0: tested 11 truncations, 11 parse failures + message 1: tested 14 truncations, 13 parse failures + message 2: tested 83 truncations, 81 parse failures + message 3: tested 11 truncations, 11 parse failures + message 4: tested 14 truncations, 13 parse failures + message 5: tested 73 truncations, 68 parse failures + message 6: tested 14 truncations, 13 parse failures + message 7: tested 14 truncations, 13 parse failures + message 8: tested 11 truncations, 11 parse failures + message 9: tested 11 truncations, 11 parse failures + message 10: tested 14 truncations, 13 parse failures + message 11: tested 13 truncations, 12 parse failures + message 12: tested 211 truncations, 209 parse failures + message 13: tested 45 truncations, 43 parse failures +DLGSUP Stopping DLGSUP logging + message 0: tested 2816 modifications, 510 parse failures + message 1: tested 3584 modifications, 768 parse failures + message 2: tested 21248 modifications, 2571 parse failures + message 3: tested 2816 modifications, 510 parse failures + message 4: tested 3584 modifications, 768 parse failures + message 5: tested 18688 modifications, 3505 parse failures + message 6: tested 3584 modifications, 769 parse failures + message 7: tested 3584 modifications, 768 parse failures + message 8: tested 2816 modifications, 510 parse failures + message 9: tested 2816 modifications, 510 parse failures + message 10: tested 3584 modifications, 768 parse failures + message 11: tested 3328 modifications, 767 parse failures + message 12: tested 54016 modifications, 4622 parse failures + message 13: tested 11520 modifications, 1026 parse failures diff --git a/tests/testsuite.at b/tests/testsuite.at index d6181c9..a3be0e7 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -212,7 +212,8 @@ AT_SETUP([gsup]) AT_KEYWORDS([gsup]) cat $abs_srcdir/gsup/gsup_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [0], [expout], [ignore]) +cat $abs_srcdir/gsup/gsup_test.err > experr +AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [0], [expout], [experr]) AT_CLEANUP AT_SETUP([fsm]) -- To view, visit https://gerrit.osmocom.org/1863 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 02:39:20 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 02:39:20 +0000 Subject: [MERGED] libosmocore[master]: fix osmo_auth_gen_vec_auts: copy rand to auth vector In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: fix osmo_auth_gen_vec_auts: copy rand to auth vector ...................................................................... fix osmo_auth_gen_vec_auts: copy rand to auth vector Related: OS#1593 Change-Id: If943731a78089f0aac3d55245de80596d01314a4 --- M src/gsm/auth_core.c 1 file changed, 8 insertions(+), 1 deletion(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index 3b1a5c6..acb65f5 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -188,11 +188,18 @@ const uint8_t *_rand) { struct osmo_auth_impl *impl = selected_auths[aud->algo]; + int rc; if (!impl || !impl->gen_vec_auts) return -ENOENT; - return impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); + rc = impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); + if (rc < 0) + return rc; + + memcpy(vec->rand, _rand, sizeof(vec->rand)); + + return 0; } static const struct value_string auth_alg_vals[] = { -- To view, visit https://gerrit.osmocom.org/1864 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If943731a78089f0aac3d55245de80596d01314a4 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:16:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:16:42 +0000 Subject: osmo-hlr[master]: auc_gen_vectors(): ensure sane arguments, test In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1866 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I775652b6a91d382707ce32176a3fe4ef547cbca7 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:17:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:17:51 +0000 Subject: osmo-hlr[master]: auc_3g_test: add AUTS resync test In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1865 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I06dd8671aa515139bdc3f08883f08276662cf25f Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:18:29 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:18:29 +0000 Subject: osmo-hlr[master]: auc_3g_test: allow to inc fake rand bytes upon rand request In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1867 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6b9899cd898eecc95b244432f416041b194a7187 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:18:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:18:53 +0000 Subject: osmo-hlr[master]: auc_3g_test: add AUTS test with N vectors, to show bug In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1868 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:19:00 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:19:00 +0000 Subject: [MERGED] osmo-hlr[master]: auc_3g_test: add AUTS test with N vectors, to show bug In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: auc_3g_test: add AUTS test with N vectors, to show bug ...................................................................... auc_3g_test: add AUTS test with N vectors, to show bug Add test that shows how passing AUTS to auc_compute_vectors performs an AUTS sync on each vector and hence produces the same SQN each time. This will generate one working vector as resync result, and then N-1 more with the wrong SQN as far as the USIM is concerned. This causes a resync to be necessary on every authentication. Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4 Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c --- M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 2 files changed, 198 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index cb5e412..f8ff67a 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -239,11 +239,94 @@ comment_end(); } +void _test_gen_vectors_3g_only__expect_vecs__WRONG(struct osmo_auth_vector vecs[3]) +{ + fprintf(stderr, "THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED\n"); + fprintf(stderr, "The SQN should increment with each new vector.\n"); + fprintf(stderr, "[0]: "); + VEC_IS(&vecs[0], + " rand: 897210a0f7de278f0b8213098e098a3f\n" + " autn: c6b9790dad4b00000cf322869ea6a481\n" + " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" + " ik: f19c20ca863137f8892326d959ec5e01\n" + " res: 9af5a557902d2db80000000000000000\n" + " res_len: 08\n" + " kc: 7526fc13c5976685\n" + " sres: 0ad888ef\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[1]: "); + VEC_IS(&vecs[1], + " rand: 9a8321b108ef38a01c93241a9f1a9b50\n" + " autn: 79a5113eb0900000f7e138537aa0962b\n" + " ck: 3686f05df057d1899c66ae4eb18cf941\n" + " ik: 79f21ed53bcb47787de57d136ff803a5\n" + " res: 43023475cb29292c0000000000000000\n" + " res_len: 08\n" + " kc: aef73dd515e86c15\n" + " sres: 882b1d59\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[2]: "); + VEC_IS(&vecs[2], + " rand: ab9432c2190049b12da4352bb02bac61\n" + " autn: 24b018d46c390000d88e11730d0367ac\n" + " ck: d86c3191a36fc0602e48202ef2080964\n" + " ik: 648dab72016181406243420649e63dc9\n" + " res: 010cab11cc63a6e40000000000000000\n" + " res_len: 08\n" + " kc: f0eaf8cb19e0758d\n" + " sres: cd6f0df5\n" + " auth_types: 03000000\n" + ); +} + +void _test_gen_vectors_3g_only__expect_vecs(struct osmo_auth_vector vecs[3]) +{ + fprintf(stderr, "[0]: "); + VEC_IS(&vecs[0], + " rand: 897210a0f7de278f0b8213098e098a3f\n" + " autn: c6b9790dad4b00000cf322869ea6a481\n" + " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" + " ik: f19c20ca863137f8892326d959ec5e01\n" + " res: 9af5a557902d2db80000000000000000\n" + " res_len: 08\n" + " kc: 7526fc13c5976685\n" + " sres: 0ad888ef\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[1]: "); + VEC_IS(&vecs[1], + " rand: 9a8321b108ef38a01c93241a9f1a9b50\n" + " autn: 79a5113eb0910000be6020540503ffc5\n" + " ck: 3686f05df057d1899c66ae4eb18cf941\n" + " ik: 79f21ed53bcb47787de57d136ff803a5\n" + " res: 43023475cb29292c0000000000000000\n" + " res_len: 08\n" + " kc: aef73dd515e86c15\n" + " sres: 882b1d59\n" + " auth_types: 03000000\n" + ); + fprintf(stderr, "[2]: "); + VEC_IS(&vecs[2], + " rand: ab9432c2190049b12da4352bb02bac61\n" + " autn: 24b018d46c3b00009c7e1b47f3a19b2b\n" + " ck: d86c3191a36fc0602e48202ef2080964\n" + " ik: 648dab72016181406243420649e63dc9\n" + " res: 010cab11cc63a6e40000000000000000\n" + " res_len: 08\n" + " kc: f0eaf8cb19e0758d\n" + " sres: cd6f0df5\n" + " auth_types: 03000000\n" + ); +} + static void test_gen_vectors_3g_only(void) { struct osmo_sub_auth_data aud2g; struct osmo_sub_auth_data aud3g; struct osmo_auth_vector vec; + struct osmo_auth_vector vecs[3]; uint8_t auts[14]; uint8_t rand_auts[16]; int rc; @@ -379,6 +462,35 @@ " auth_types: 03000000\n" ); + + fprintf(stderr, "- verify N vectors with AUTS resync" + " == N vectors without AUTS\n" + "First just set rand and sqn = 24, and compute 3 vectors\n"); + next_rand("897210a0f7de278f0b8213098e098a3f", false); + aud3g.u.umts.sqn = 24; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 24, "%"PRIu64); + + memset(vecs, 0, sizeof(vecs)); + rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, NULL, NULL); + VERBOSE_ASSERT(rc, == 3, "%d"); + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 27, "%"PRIu64); + + _test_gen_vectors_3g_only__expect_vecs(vecs); + + fprintf(stderr, "Now reach sqn = 24 with AUTS and expect the same\n"); + /* AUTS response by USIM */ + osmo_hexparse("979498b1f72d3e28c59fa2e72f9c", + auts, sizeof(auts)); + /* RAND sent to USIM, which AUTS was generated from */ + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + rand_auts, sizeof(rand_auts)); + next_rand("897210a0f7de278f0b8213098e098a3f", false); + rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, rand_auts, auts); + + /* THIS IS WRONG AND WILL BE FIXED IN A SUBSEQUENT COMMIT: + should be _test_gen_vectors_3g_only__expect_vecs() instead */ + _test_gen_vectors_3g_only__expect_vecs__WRONG(vecs); + comment_end(); } diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index 5c3dd14..db076d7 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -119,6 +119,92 @@ sres: 0ad888ef auth_types: 03000000 +- verify N vectors with AUTS resync == N vectors without AUTS +First just set rand and sqn = 24, and compute 3 vectors +aud3g.u.umts.sqn == 24 +DAUC rand 897210a0f7de278f0b8213098e098a3f +DAUC compute vector [0]/3: 3G only +DAUC rand 9a8321b108ef38a01c93241a9f1a9b50 +DAUC compute vector [1]/3: 3G only +DAUC rand ab9432c2190049b12da4352bb02bac61 +DAUC compute vector [2]/3: 3G only +rc == 3 +aud3g.u.umts.sqn == 27 +[0]: auth vector == + rand: 897210a0f7de278f0b8213098e098a3f + autn: c6b9790dad4b00000cf322869ea6a481 + ck: e9922bd036718ed9e40bd1d02c3b81a5 + ik: f19c20ca863137f8892326d959ec5e01 + res: 9af5a557902d2db80000000000000000 + res_len: 08 + kc: 7526fc13c5976685 + sres: 0ad888ef + auth_types: 03000000 + +[1]: auth vector == + rand: 9a8321b108ef38a01c93241a9f1a9b50 + autn: 79a5113eb0910000be6020540503ffc5 + ck: 3686f05df057d1899c66ae4eb18cf941 + ik: 79f21ed53bcb47787de57d136ff803a5 + res: 43023475cb29292c0000000000000000 + res_len: 08 + kc: aef73dd515e86c15 + sres: 882b1d59 + auth_types: 03000000 + +[2]: auth vector == + rand: ab9432c2190049b12da4352bb02bac61 + autn: 24b018d46c3b00009c7e1b47f3a19b2b + ck: d86c3191a36fc0602e48202ef2080964 + ik: 648dab72016181406243420649e63dc9 + res: 010cab11cc63a6e40000000000000000 + res_len: 08 + kc: f0eaf8cb19e0758d + sres: cd6f0df5 + auth_types: 03000000 + +Now reach sqn = 24 with AUTS and expect the same +DAUC rand 897210a0f7de278f0b8213098e098a3f +DAUC compute vector [0]/3: 3G only +DAUC rand 9a8321b108ef38a01c93241a9f1a9b50 +DAUC compute vector [1]/3: 3G only +DAUC rand ab9432c2190049b12da4352bb02bac61 +DAUC compute vector [2]/3: 3G only +THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED +The SQN should increment with each new vector. +[0]: auth vector == + rand: 897210a0f7de278f0b8213098e098a3f + autn: c6b9790dad4b00000cf322869ea6a481 + ck: e9922bd036718ed9e40bd1d02c3b81a5 + ik: f19c20ca863137f8892326d959ec5e01 + res: 9af5a557902d2db80000000000000000 + res_len: 08 + kc: 7526fc13c5976685 + sres: 0ad888ef + auth_types: 03000000 + +[1]: auth vector == + rand: 9a8321b108ef38a01c93241a9f1a9b50 + autn: 79a5113eb0900000f7e138537aa0962b + ck: 3686f05df057d1899c66ae4eb18cf941 + ik: 79f21ed53bcb47787de57d136ff803a5 + res: 43023475cb29292c0000000000000000 + res_len: 08 + kc: aef73dd515e86c15 + sres: 882b1d59 + auth_types: 03000000 + +[2]: auth vector == + rand: ab9432c2190049b12da4352bb02bac61 + autn: 24b018d46c390000d88e11730d0367ac + ck: d86c3191a36fc0602e48202ef2080964 + ik: 648dab72016181406243420649e63dc9 + res: 010cab11cc63a6e40000000000000000 + res_len: 08 + kc: f0eaf8cb19e0758d + sres: cd6f0df5 + auth_types: 03000000 + ===== test_gen_vectors_3g_only: SUCCESS -- To view, visit https://gerrit.osmocom.org/1868 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:19:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:19:01 +0000 Subject: [MERGED] osmo-hlr[master]: auc_3g_test: allow to inc fake rand bytes upon rand request In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: auc_3g_test: allow to inc fake rand bytes upon rand request ...................................................................... auc_3g_test: allow to inc fake rand bytes upon rand request Preparing for upcoming unit test, in a separate commit for cosmetic reasons (setting the flag to false across the code). Change-Id: I6b9899cd898eecc95b244432f416041b194a7187 --- M tests/auc/auc_3g_test.c 1 file changed, 16 insertions(+), 10 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index f1fa2c2..cb5e412 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -88,11 +88,23 @@ } while (0) uint8_t fake_rand[16] = { 0 }; +bool fake_rand_fixed = true; + +void next_rand(const char *hexstr, bool fixed) +{ + osmo_hexparse(hexstr, fake_rand, sizeof(fake_rand)); + fake_rand_fixed = fixed; +} int rand_get(uint8_t *rand, unsigned int len) { + int i; OSMO_ASSERT(len <= sizeof(fake_rand)); memcpy(rand, fake_rand, len); + if (!fake_rand_fixed) { + for (i = 0; i < len; i++) + fake_rand[i] += 0x11; + } return len; } @@ -115,8 +127,7 @@ aud3g = (struct osmo_sub_auth_data){ 0 }; - osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", - fake_rand, sizeof(fake_rand)); + next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); vec = (struct osmo_auth_vector){ {0} }; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); @@ -184,9 +195,7 @@ aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); - - osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", - fake_rand, sizeof(fake_rand)); + next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); vec = (struct osmo_auth_vector){ {0} }; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); @@ -252,9 +261,7 @@ aud3g.u.umts.k, sizeof(aud3g.u.umts.k)); osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)); - - osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", - fake_rand, sizeof(fake_rand)); + next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); vec = (struct osmo_auth_vector){ {0} }; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); @@ -353,8 +360,7 @@ osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", rand_auts, sizeof(rand_auts)); /* new RAND token for the next key */ - osmo_hexparse("897210a0f7de278f0b8213098e098a3f", - fake_rand, sizeof(fake_rand)); + next_rand("897210a0f7de278f0b8213098e098a3f", true); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, rand_auts, auts); VERBOSE_ASSERT(rc, == 1, "%d"); /* The USIM's last sqn was 23, the calculated vector was 24, hence the -- To view, visit https://gerrit.osmocom.org/1867 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6b9899cd898eecc95b244432f416041b194a7187 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:19:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:19:01 +0000 Subject: [MERGED] osmo-hlr[master]: auc_3g_test: add AUTS resync test In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: auc_3g_test: add AUTS resync test ...................................................................... auc_3g_test: add AUTS resync test Used this to catch a bug where the AUTS process failed to copy RAND to the auth vector (libosmocore). Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4 Change-Id: I06dd8671aa515139bdc3f08883f08276662cf25f --- M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 2 files changed, 87 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 0923a27..88037a6 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -235,6 +235,8 @@ struct osmo_sub_auth_data aud2g; struct osmo_sub_auth_data aud3g; struct osmo_auth_vector vec; + uint8_t auts[14]; + uint8_t rand_auts[16]; int rc; comment_start(); @@ -303,6 +305,74 @@ " auth_types: 03000000\n" ); + + fprintf(stderr, "- test AUTS resync\n"); + vec = (struct osmo_auth_vector){}; + aud3g.u.umts.sqn = 0; + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64); + + /* The AUTN sent was 8704f5ba55f30000d2ee44b22c8ea919 + * with the first 6 bytes being SQN ^ AK. + * K = EB215756028D60E3275E613320AEC880 + * OPC = FB2A3D1B360F599ABAB99DB8669F8308 + * RAND = 39fa2f4e3d523d8619a73b4f65c3e14d + * --milenage-f5--> + * AK = 8704f5ba55f3 + * + * The first six bytes are 8704f5ba55f3, + * and 8704f5ba55f3 ^ AK = 0. + * --> SQN = 0. + * + * Say the USIM doesn't like that, let's say it is at SQN 23. + * SQN_MS = 000000000017 + * + * AUTS = Conc(SQN_MS) || MAC-S + * Conc(SQN_MS) = SQN_MS ? f5*[K](RAND) + * MAC-S = f1*[K] (SQN MS || RAND || AMF) + * + * f5*--> Conc(SQN_MS) = 000000000017 ^ 979498b1f73a + * = 979498b1f72d + * AMF = 0000 (TS 33.102 v7.0.0, 6.3.3) + * + * MAC-S = f1*[K] (000000000017 || 39fa2f4e3d523d8619a73b4f65c3e14d || 0000) + * = 3e28c59fa2e72f9c + * + * AUTS = 979498b1f72d || 3e28c59fa2e72f9c + * + * verify valid AUTS resulting in SQN 23 with: + * osmo-auc-gen -3 -a milenage -k EB215756028D60E3275E613320AEC880 \ + * -o FB2A3D1B360F599ABAB99DB8669F8308 \ + * -r 39fa2f4e3d523d8619a73b4f65c3e14d \ + * -A 979498b1f72d3e28c59fa2e72f9c + */ + + /* AUTS response by USIM */ + osmo_hexparse("979498b1f72d3e28c59fa2e72f9c", + auts, sizeof(auts)); + /* RAND sent to USIM, which AUTS was generated from */ + osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", + rand_auts, sizeof(rand_auts)); + /* new RAND token for the next key */ + osmo_hexparse("897210a0f7de278f0b8213098e098a3f", + fake_rand, sizeof(fake_rand)); + rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, rand_auts, auts); + VERBOSE_ASSERT(rc, == 1, "%d"); + /* The USIM's last sqn was 23, the calculated vector was 24, hence the + * next one stored should be 25. */ + VERBOSE_ASSERT(aud3g.u.umts.sqn, == 25, "%"PRIu64); + + VEC_IS(&vec, + " rand: 897210a0f7de278f0b8213098e098a3f\n" + " autn: c6b9790dad4b00000cf322869ea6a481\n" + " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" + " ik: f19c20ca863137f8892326d959ec5e01\n" + " res: 9af5a557902d2db80000000000000000\n" + " res_len: 08\n" + " kc: 7526fc13c5976685\n" + " sres: 0ad888ef\n" + " auth_types: 03000000\n" + ); + comment_end(); } diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index ec5ba28..a444f8b 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -102,5 +102,22 @@ sres: 9b36efdf auth_types: 03000000 +- test AUTS resync +aud3g.u.umts.sqn == 0 +DAUC rand 897210a0f7de278f0b8213098e098a3f +DAUC compute vector [0]/1: 3G only +rc == 1 +aud3g.u.umts.sqn == 25 +auth vector == + rand: 897210a0f7de278f0b8213098e098a3f + autn: c6b9790dad4b00000cf322869ea6a481 + ck: e9922bd036718ed9e40bd1d02c3b81a5 + ik: f19c20ca863137f8892326d959ec5e01 + res: 9af5a557902d2db80000000000000000 + res_len: 08 + kc: 7526fc13c5976685 + sres: 0ad888ef + auth_types: 03000000 + ===== test_gen_vectors_3g_only: SUCCESS -- To view, visit https://gerrit.osmocom.org/1865 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I06dd8671aa515139bdc3f08883f08276662cf25f Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:19:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:19:01 +0000 Subject: [MERGED] osmo-hlr[master]: auc_gen_vectors(): ensure sane arguments, test In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: auc_gen_vectors(): ensure sane arguments, test ...................................................................... auc_gen_vectors(): ensure sane arguments, test In auc_gen_vectors(), add various checks that the auth data arguments passed make sense, and add unit test to verify that they work. (Caught a segfault due to NULL dereference with this.) Change-Id: I775652b6a91d382707ce32176a3fe4ef547cbca7 --- M src/auc.c M tests/auc/auc_3g_test.c M tests/auc/auc_3g_test.err 3 files changed, 274 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/auc.c b/src/auc.c index 3f3db34..a307931 100644 --- a/src/auc.c +++ b/src/auc.c @@ -36,13 +36,42 @@ uint8_t rand[16]; int rc; - if (aud2g->algo == OSMO_AUTH_ALG_NONE) + if (aud2g && (aud2g->algo == OSMO_AUTH_ALG_NONE + || aud2g->type == OSMO_AUTH_TYPE_NONE)) aud2g = NULL; - if (aud3g->algo == OSMO_AUTH_ALG_NONE) + if (aud3g && (aud3g->algo == OSMO_AUTH_ALG_NONE + || aud3g->type == OSMO_AUTH_TYPE_NONE)) aud3g = NULL; - if (!aud2g && !aud3g) + if (!aud2g && !aud3g) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() called" + " with neither 2G nor 3G auth data available\n"); return -1; + } + + if (aud2g && aud2g->type != OSMO_AUTH_TYPE_GSM) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() called" + " with non-2G auth data passed for aud2g arg\n"); + return -1; + } + + if (aud3g && aud3g->type != OSMO_AUTH_TYPE_UMTS) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() called" + " with non-3G auth data passed for aud3g arg\n"); + return -1; + } + + if ((rand_auts != NULL) != (auts != NULL)) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() with only one" + " of AUTS and AUTS_RAND given, need both or neither\n"); + return -1; + } + + if (auts && !aud3g) { + LOGP(DAUC, LOGL_ERROR, "auc_compute_vectors() with AUTS called" + " but no 3G auth data passed\n"); + return -1; + } /* compute quintuples */ for (i = 0; i < num_vec; i++) { diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 88037a6..f1fa2c2 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -376,6 +376,103 @@ comment_end(); } +void test_gen_vectors_bad_args() +{ + struct osmo_auth_vector vec; + uint8_t auts[14]; + uint8_t rand_auts[16]; + int rc; + int i; + + struct osmo_sub_auth_data aud2g = { + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1, + }; + + struct osmo_sub_auth_data aud3g = { + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + struct osmo_sub_auth_data aud2g_noalg = { + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_NONE, + }; + + struct osmo_sub_auth_data aud3g_noalg = { + .type = OSMO_AUTH_TYPE_UMTS, + .algo = OSMO_AUTH_ALG_NONE, + }; + + struct osmo_sub_auth_data aud_notype = { + .type = OSMO_AUTH_TYPE_NONE, + .algo = OSMO_AUTH_ALG_MILENAGE, + }; + + struct osmo_sub_auth_data no_aud = { + .type = OSMO_AUTH_TYPE_NONE, + .algo = OSMO_AUTH_ALG_NONE, + }; + + struct { + struct osmo_sub_auth_data *aud2g; + struct osmo_sub_auth_data *aud3g; + uint8_t *rand_auts; + uint8_t *auts; + const char *label; + } tests[] = { + { NULL, NULL, NULL, NULL, "no auth data (a)"}, + { NULL, &aud3g_noalg, NULL, NULL, "no auth data (b)"}, + { NULL, &aud_notype, NULL, NULL, "no auth data (c)"}, + { NULL, &no_aud, NULL, NULL, "no auth data (d)"}, + { &aud2g_noalg, NULL, NULL, NULL, "no auth data (e)"}, + { &aud2g_noalg, &aud3g_noalg, NULL, NULL, "no auth data (f)"}, + { &aud2g_noalg, &aud_notype, NULL, NULL, "no auth data (g)"}, + { &aud2g_noalg, &no_aud, NULL, NULL, "no auth data (h)"}, + { &aud_notype, NULL, NULL, NULL, "no auth data (i)"}, + { &aud_notype, &aud3g_noalg, NULL, NULL, "no auth data (j)"}, + { &aud_notype, &aud_notype, NULL, NULL, "no auth data (k)"}, + { &aud_notype, &no_aud, NULL, NULL, "no auth data (l)"}, + { &no_aud, NULL, NULL, NULL, "no auth data (m)"}, + { &no_aud, &aud3g_noalg, NULL, NULL, "no auth data (n)"}, + { &no_aud, &aud_notype, NULL, NULL, "no auth data (o)"}, + { &no_aud, &no_aud, NULL, NULL, "no auth data (p)"}, + { &aud3g, NULL, NULL, NULL, "wrong auth data type (a)"}, + { &aud3g, &aud3g_noalg, NULL, NULL, "wrong auth data type (b)"}, + { &aud3g, &aud_notype, NULL, NULL, "wrong auth data type (c)"}, + { &aud3g, &no_aud, NULL, NULL, "wrong auth data type (d)"}, + { NULL, &aud2g, NULL, NULL, "wrong auth data type (e)"}, + { &aud3g_noalg, &aud2g, NULL, NULL, "wrong auth data type (f)"}, + { &aud_notype, &aud2g, NULL, NULL, "wrong auth data type (g)"}, + { &no_aud, &aud2g, NULL, NULL, "wrong auth data type (h)"}, + { &aud3g, &aud2g, NULL, NULL, "wrong auth data type (i)"}, + { &aud3g, &aud3g, NULL, NULL, "wrong auth data type (j)"}, + { &aud2g, &aud2g, NULL, NULL, "wrong auth data type (k)"}, + { &aud2g, NULL, rand_auts, auts, "AUTS for 2G-only (a)"}, + { &aud2g, &aud3g_noalg, rand_auts, auts, "AUTS for 2G-only (b)"}, + { &aud2g, &aud_notype, rand_auts, auts, "AUTS for 2G-only (c)"}, + { &aud2g, &no_aud, rand_auts, auts, "AUTS for 2G-only (d)"}, + { NULL, &aud3g, NULL, auts, "incomplete AUTS (a)"}, + { NULL, &aud3g, rand_auts, NULL, "incomplete AUTS (b)"}, + { &aud2g, &aud3g, NULL, auts, "incomplete AUTS (c)"}, + { &aud2g, &aud3g, rand_auts, NULL, "incomplete AUTS (d)"}, + }; + + comment_start(); + + for (i = 0; i < ARRAY_SIZE(tests); i++) { + fprintf(stderr, "\n- %s\n", tests[i].label); + rc = auc_compute_vectors(&vec, 1, + tests[i].aud2g, + tests[i].aud3g, + tests[i].rand_auts, + tests[i].auts); + VERBOSE_ASSERT(rc, < 0, "%d"); + } + + comment_end(); +} + int main() { printf("auc_3g_test.c\n"); @@ -388,6 +485,7 @@ test_gen_vectors_2g_only(); test_gen_vectors_2g_plus_3g(); test_gen_vectors_3g_only(); + test_gen_vectors_bad_args(); printf("Done\n"); return 0; diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index a444f8b..5c3dd14 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -121,3 +121,147 @@ ===== test_gen_vectors_3g_only: SUCCESS + +===== test_gen_vectors_bad_args + +- no auth data (a) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (b) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (c) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (d) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (e) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (f) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (g) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (h) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (i) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (j) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (k) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (l) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (m) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (n) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (o) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- no auth data (p) +DAUC auc_compute_vectors() called with neither 2G nor 3G auth data available +rc == -1 + +- wrong auth data type (a) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (b) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (c) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (d) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (e) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (f) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (g) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (h) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- wrong auth data type (i) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (j) +DAUC auc_compute_vectors() called with non-2G auth data passed for aud2g arg +rc == -1 + +- wrong auth data type (k) +DAUC auc_compute_vectors() called with non-3G auth data passed for aud3g arg +rc == -1 + +- AUTS for 2G-only (a) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- AUTS for 2G-only (b) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- AUTS for 2G-only (c) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- AUTS for 2G-only (d) +DAUC auc_compute_vectors() with AUTS called but no 3G auth data passed +rc == -1 + +- incomplete AUTS (a) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 + +- incomplete AUTS (b) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 + +- incomplete AUTS (c) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 + +- incomplete AUTS (d) +DAUC auc_compute_vectors() with only one of AUTS and AUTS_RAND given, need both or neither +rc == -1 +===== test_gen_vectors_bad_args: SUCCESS + -- To view, visit https://gerrit.osmocom.org/1866 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I775652b6a91d382707ce32176a3fe4ef547cbca7 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:21:08 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:21:08 +0000 Subject: osmo-hlr[master]: cosmetic: refactor auc_compute_vectors(), add debug log In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 I understand the need for debug logging during development, but I think for normla use this is rather on the excessive side, and I would probably go for a compile-time define for this level of verbosity, to avoid dozens of debug-printing calls during every auth vector generation (which is the most common operations for a HLR/AUC). -- To view, visit https://gerrit.osmocom.org/1869 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:21:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:21:40 +0000 Subject: osmo-hlr[master]: auc_compute_vectors(): fix AUTS resync for multiple vectors In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1870 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I425a1d92c85896227341f565f5361c0d830ce866 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:21:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:21:53 +0000 Subject: osmo-hlr[master]: cosmetic: auc_3g_test: improve test debugging tools In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1871 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1b23da055b5edacba09310411caf43c4cd1c29bc Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:22:10 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:22:10 +0000 Subject: osmo-hlr[master]: cosmetic: rename auc_3g_test.c to auc_test.c In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1872 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I1a5a40413bf6636ead9370fb827aa0338c049e7f Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:29:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:29:15 +0000 Subject: osmo-pcu[master]: BTS: Convert relative frame numbers to absolute frame numbers In-Reply-To: References: Message-ID: Patch Set 1: (3 comments) https://gerrit.osmocom.org/#/c/1861/1/src/bts.cpp File src/bts.cpp: Line 46: #define MAX_FN 2715648 I think this is GSM_MAX_FN from so maybe better to use it? Line 534: * reference. This PCU implementation has to fit both secenarious, so scenarios Line 547: fn_rounded = m_cur_fn - m_cur_rfn; as we are using unsigned integers in a modulus arrithmetic: what happens if m_cur_rfn is larger than m_cur_fn? does the function still work in this case? *If* this case is "imposible" then we should try to fail gracefully and print a related error message (and test for it in the test case). -- To view, visit https://gerrit.osmocom.org/1861 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:29:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:29:35 +0000 Subject: libosmocore[master]: gsup test: add decoding test for UMTS IEs In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1862 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6fddf8d7ce97137b0a585d365807bcaf90a319d0 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:29:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:29:37 +0000 Subject: libosmocore[master]: gsup_test: also check stderr In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1863 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:29:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:29:46 +0000 Subject: [MERGED] libosmocore[master]: gsup_test: also check stderr In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gsup_test: also check stderr ...................................................................... gsup_test: also check stderr Configure logging to be deterministic and add stderr checking to testuite.at. However, exclude the thousands of message modification log lines from the log to not have a huge test expectation file. Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb --- M tests/Makefile.am M tests/gsup/gsup_test.c A tests/gsup/gsup_test.err M tests/testsuite.at 4 files changed, 89 insertions(+), 8 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/Makefile.am b/tests/Makefile.am index 5731bf8..f6d4db3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -177,7 +177,8 @@ vty/vty_test.ok comp128/comp128_test.ok \ utils/utils_test.ok stats/stats_test.ok \ bitvec/bitvec_test.ok msgb/msgb_test.ok bits/bitcomp_test.ok \ - sim/sim_test.ok tlv/tlv_test.ok gsup/gsup_test.ok \ + sim/sim_test.ok tlv/tlv_test.ok \ + gsup/gsup_test.ok gsup/gsup_test.err \ oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \ write_queue/wqueue_test.ok socket/socket_test.ok \ socket/socket_test.err diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 42e7b81..a950ca3 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -134,9 +134,9 @@ 0x25, 0x10, /* AUTN (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - 0x25, 0x08, /* RES (UMTS) */ + 0x27, 0x08, /* RES (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x03, 0x22, /* Auth tuple */ + 0x03, 0x62, /* Auth tuple */ 0x20, 0x10, /* rand */ 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x10, @@ -153,17 +153,17 @@ 0x25, 0x10, /* AUTN (UMTS) */ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf0, - 0x25, 0x08, /* RES (UMTS) */ + 0x27, 0x08, /* RES (UMTS) */ 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, }; static const uint8_t send_auth_info_req_auts[] = { 0x08, TEST_IMSI_IE, - 0x26, 0x0e, + 0x26, 0x0e, /* AUTS (UMTS) */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, - 0x20, 0x10, + 0x20, 0x10, /* rand */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, }; @@ -198,7 +198,7 @@ {"Purge MS Result", purge_ms_res, sizeof(purge_ms_res)}, {"Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)", - send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, + send_auth_info_res_umts, sizeof(send_auth_info_res_umts)}, {"Send Authentication Info Request with AUTS and RAND (UMTS)", send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, }; @@ -264,6 +264,10 @@ test_idx, counter, parse_err); } + /* Don't log thousands of message modification errors */ + LOGP(DLGSUP, LOGL_NOTICE, "Stopping DLGSUP logging\n"); + log_set_category_filter(osmo_stderr_target, DLGSUP, 0, 0); + /* message modification test (relies on ASAN or valgrind being used) */ for (test_idx = 0; test_idx < ARRAY_SIZE(test_messages); test_idx++) { int j; @@ -309,6 +313,10 @@ int main(int argc, char **argv) { osmo_init_logging(&info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); test_gsup_messages_dec_enc(); diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err new file mode 100644 index 0000000..6cd8627 --- /dev/null +++ b/tests/gsup/gsup_test.err @@ -0,0 +1,71 @@ + generated message: 08 01 08 21 43 65 87 09 21 43 f5 + original message: 08 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07 + original message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07 + IMSI: 123456789012345 + generated message: 0a 01 08 21 43 65 87 09 21 43 f5 03 22 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 03 22 20 10 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 21 04 a1 a2 a3 a4 22 08 b1 b2 b3 b4 b5 b6 b7 b8 + original message: 0a 01 08 21 43 65 87 09 21 43 f5 03 22 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 03 22 20 10 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 21 04 a1 a2 a3 a4 22 08 b1 b2 b3 b4 b5 b6 b7 b8 + IMSI: 123456789012345 + generated message: 04 01 08 21 43 65 87 09 21 43 f5 + original message: 04 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 05 01 08 21 43 65 87 09 21 43 f5 02 01 07 + original message: 05 01 08 21 43 65 87 09 21 43 f5 02 01 07 + IMSI: 123456789012345 + generated message: 06 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 09 07 91 83 52 38 48 83 93 04 00 05 15 10 01 01 11 02 f1 21 12 09 04 74 65 73 74 03 61 70 6e 13 01 02 05 11 10 01 02 11 02 f1 21 12 08 03 66 6f 6f 03 61 70 6e + original message: 06 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 43 09 07 91 83 52 38 48 83 93 04 00 05 15 10 01 01 11 02 f1 21 12 09 04 74 65 73 74 03 61 70 6e 13 01 02 05 11 10 01 02 11 02 f1 21 12 08 03 66 6f 6f 03 61 70 6e + IMSI: 123456789012345 + generated message: 1c 01 08 21 43 65 87 09 21 43 f5 06 01 00 + original message: 1c 01 08 21 43 65 87 09 21 43 f5 06 01 00 + IMSI: 123456789012345 + generated message: 1d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + original message: 1d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + IMSI: 123456789012345 + generated message: 1e 01 08 21 43 65 87 09 21 43 f5 + original message: 1e 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 0c 01 08 21 43 65 87 09 21 43 f5 + original message: 0c 01 08 21 43 65 87 09 21 43 f5 + IMSI: 123456789012345 + generated message: 0d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + original message: 0d 01 08 21 43 65 87 09 21 43 f5 02 01 03 + IMSI: 123456789012345 + generated message: 0e 01 08 21 43 65 87 09 21 43 f5 07 00 + original message: 0e 01 08 21 43 65 87 09 21 43 f5 07 00 + IMSI: 123456789012345 + generated message: 0a 01 08 21 43 65 87 09 21 43 f5 03 62 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 23 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 24 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 25 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 27 08 01 02 03 04 05 06 07 08 03 62 20 10 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 10 21 04 b1 b2 b3 b4 22 08 c1 c2 c3 c4 c5 c6 c7 c8 23 10 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df d0 24 10 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef e0 25 10 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff f0 27 08 91 92 93 94 95 96 97 98 + original message: 0a 01 08 21 43 65 87 09 21 43 f5 03 62 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 21 04 21 22 23 24 22 08 31 32 33 34 35 36 37 38 23 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 24 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 25 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 27 08 01 02 03 04 05 06 07 08 03 62 20 10 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 10 21 04 b1 b2 b3 b4 22 08 c1 c2 c3 c4 c5 c6 c7 c8 23 10 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df d0 24 10 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef e0 25 10 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff f0 27 08 91 92 93 94 95 96 97 98 + IMSI: 123456789012345 + generated message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 + original message: 08 01 08 21 43 65 87 09 21 43 f5 26 0e 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 20 10 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 + IMSI: 123456789012345 + message 0: tested 11 truncations, 11 parse failures + message 1: tested 14 truncations, 13 parse failures + message 2: tested 83 truncations, 81 parse failures + message 3: tested 11 truncations, 11 parse failures + message 4: tested 14 truncations, 13 parse failures + message 5: tested 73 truncations, 68 parse failures + message 6: tested 14 truncations, 13 parse failures + message 7: tested 14 truncations, 13 parse failures + message 8: tested 11 truncations, 11 parse failures + message 9: tested 11 truncations, 11 parse failures + message 10: tested 14 truncations, 13 parse failures + message 11: tested 13 truncations, 12 parse failures + message 12: tested 211 truncations, 209 parse failures + message 13: tested 45 truncations, 43 parse failures +DLGSUP Stopping DLGSUP logging + message 0: tested 2816 modifications, 510 parse failures + message 1: tested 3584 modifications, 768 parse failures + message 2: tested 21248 modifications, 2571 parse failures + message 3: tested 2816 modifications, 510 parse failures + message 4: tested 3584 modifications, 768 parse failures + message 5: tested 18688 modifications, 3505 parse failures + message 6: tested 3584 modifications, 769 parse failures + message 7: tested 3584 modifications, 768 parse failures + message 8: tested 2816 modifications, 510 parse failures + message 9: tested 2816 modifications, 510 parse failures + message 10: tested 3584 modifications, 768 parse failures + message 11: tested 3328 modifications, 767 parse failures + message 12: tested 54016 modifications, 4622 parse failures + message 13: tested 11520 modifications, 1026 parse failures diff --git a/tests/testsuite.at b/tests/testsuite.at index d6181c9..a3be0e7 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -212,7 +212,8 @@ AT_SETUP([gsup]) AT_KEYWORDS([gsup]) cat $abs_srcdir/gsup/gsup_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [0], [expout], [ignore]) +cat $abs_srcdir/gsup/gsup_test.err > experr +AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [0], [expout], [experr]) AT_CLEANUP AT_SETUP([fsm]) -- To view, visit https://gerrit.osmocom.org/1863 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:29:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:29:51 +0000 Subject: [MERGED] libosmocore[master]: gsup test: add decoding test for UMTS IEs In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gsup test: add decoding test for UMTS IEs ...................................................................... gsup test: add decoding test for UMTS IEs This would have caught the wrong expectation of AUTS' length fixed recently (3a5ca647c531b7761dc6c555e5e0cabc972bd3ac). Besides AUTS, add AUTN, RES, CK, IK which were also not tested yet. Change-Id: I6fddf8d7ce97137b0a585d365807bcaf90a319d0 Related: OS#1593 --- M tests/gsup/gsup_test.c M tests/gsup/gsup_test.ok 2 files changed, 61 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c index 7af16b7..42e7b81 100644 --- a/tests/gsup/gsup_test.c +++ b/tests/gsup/gsup_test.c @@ -114,6 +114,60 @@ 0x07, 0x00, }; + static const uint8_t send_auth_info_res_umts[] = { + 0x0a, + TEST_IMSI_IE, + 0x03, 0x62, /* Auth tuple */ + 0x20, 0x10, /* rand */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x21, 0x04, /* sres */ + 0x21, 0x22, 0x23, 0x24, + 0x22, 0x08, /* kc */ + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x23, 0x10, /* IK (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x24, 0x10, /* CK (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x25, 0x10, /* AUTN (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x25, 0x08, /* RES (UMTS) */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x03, 0x22, /* Auth tuple */ + 0x20, 0x10, /* rand */ + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, + 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0x10, + 0x21, 0x04, /* sres */ + 0xb1, 0xb2, 0xb3, 0xb4, + 0x22, 0x08, /* kc */ + 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, + 0x23, 0x10, /* IK (UMTS) */ + 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, + 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xd0, + 0x24, 0x10, /* CK (UMTS) */ + 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, + 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xe0, + 0x25, 0x10, /* AUTN (UMTS) */ + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0xf0, + 0x25, 0x08, /* RES (UMTS) */ + 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + }; + + static const uint8_t send_auth_info_req_auts[] = { + 0x08, + TEST_IMSI_IE, + 0x26, 0x0e, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x20, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + }; + static const struct test { char *name; const uint8_t *data; @@ -143,6 +197,10 @@ purge_ms_err, sizeof(purge_ms_err)}, {"Purge MS Result", purge_ms_res, sizeof(purge_ms_res)}, + {"Send Authentication Info Result with IK, CK, AUTN and RES (UMTS)", + send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, + {"Send Authentication Info Request with AUTS and RAND (UMTS)", + send_auth_info_req_auts, sizeof(send_auth_info_req_auts)}, }; printf("Test GSUP message decoding/encoding\n"); @@ -192,7 +250,7 @@ osmo_hexdump(t->data + j, ie_end - j)); OSMO_ASSERT(j <= ie_end - 2); - OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_KC_IE); + OSMO_ASSERT(t->data[j+0] <= OSMO_GSUP_CN_DOMAIN_IE); OSMO_ASSERT(t->data[j+1] <= ie_end - j - 2); ie_end = j; diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok index 1285897..a0b3f35 100644 --- a/tests/gsup/gsup_test.ok +++ b/tests/gsup/gsup_test.ok @@ -11,4 +11,6 @@ Testing Purge MS Request Testing Purge MS Error Testing Purge MS Result + Testing Send Authentication Info Result with IK, CK, AUTN and RES (UMTS) + Testing Send Authentication Info Request with AUTS and RAND (UMTS) Done. -- To view, visit https://gerrit.osmocom.org/1862 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6fddf8d7ce97137b0a585d365807bcaf90a319d0 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:32:09 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:32:09 +0000 Subject: libosmocore[master]: gsm_04_08.h: add struct with R99 names for SI3 Ctrl Chan Descr In-Reply-To: References: Message-ID: Patch Set 1: I'm not sure if it is worth keeping around the old r98 data structure under a separate name. nobody can so far be using it, as the name with r98 suffix is new. What's the rationale to keep it? -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:34:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:34:16 +0000 Subject: openbsc[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1845 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:34:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:34:35 +0000 Subject: openbsc[master]: debug.h/c: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1846 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:37:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:37:25 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: Code-Review+1 (1 comment) https://gerrit.osmocom.org/#/c/1684/8/openbsc/tests/sgsn/sgsn_test.c File openbsc/tests/sgsn/sgsn_test.c: Line 290: #define VERBOSE_ASSERT(val, expect_op, fmt) \ might make sense to have this in libosmocore. like "OSMO_ASSERT_EXPR" or the like? In genreal I think it would be great to see why an assert failed which with particular values, instead of just knowing it failed. -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:41:50 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:41:50 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+1 (1 comment) https://gerrit.osmocom.org/#/c/1682/6/openbsc/src/libbsc/bsc_subscriber.c File openbsc/src/libbsc/bsc_subscriber.c: Line 86: struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, it was not obvious to me what this function is doing (and how it differs from find) before reading the implementation. I believe we used _find_or_alloc or find_or_create in other/previosu code. yes, it's longer. But "have" might easily be read as "do we have one?", IMHO -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:43:27 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:43:27 +0000 Subject: osmo-pcu[master]: gprs_debug.h: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1848 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:44:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:44:04 +0000 Subject: osmo-pcu[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1847 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:46:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:46:40 +0000 Subject: libosmo-abis[master]: add basic unixsocket support In-Reply-To: References: Message-ID: Patch Set 16: Code-Review+1 I would like to see some minimal documentation snipped somewhere on the protocol used over that socket. Otherwise, fine. -- To view, visit https://gerrit.osmocom.org/1198 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a Gerrit-PatchSet: 16 Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: lynxis lazus Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:48:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:48:18 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:52:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:52:16 +0000 Subject: libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Patch Set 2: (1 comment) also, a short explanation as to why we export the function would help. https://gerrit.osmocom.org/#/c/1629/2/src/ctrl/control_if.c File src/ctrl/control_if.c: Line 383: ccon->write_queue.bfd.data = data ? data : ccon; > I think this is a bad decision. Let's plat the game of least surprise. I wa I agree we should not use the private/data pointer with conditionally different types like this. -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 22 07:53:19 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 07:53:19 +0000 Subject: osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+1 let's do the format string fixes and then get it merged. -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 4 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 09:44:31 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 22 Feb 2017 09:44:31 +0000 Subject: [PATCH] osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1711 to look at the new patch set (#5). octphy: Fix VTY commands The VTY commands show phy 0 rf-port-stats and show phy 0 clk-sync-stats do not output their results on the VTY console. If one of those commands is entered the user is prompted to view the logtext, which is an uncomfortable solution. This commit adds the missing functionality to print the information in the VTY as well. octphy_hw_api.c contains two value_string structs (radio_std_vals and clocksync_state_vals) which are now exported in octphy_hw_api.h in order to access them from octphy_vty.c Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 --- M src/osmo-bts-octphy/octphy_hw_api.c M src/osmo-bts-octphy/octphy_hw_api.h M src/osmo-bts-octphy/octphy_vty.c 3 files changed, 139 insertions(+), 45 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/11/1711/5 diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c index dc23676..6666f77 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.c +++ b/src/osmo-bts-octphy/octphy_hw_api.c @@ -29,6 +29,7 @@ #include "l1_if.h" #include "l1_oml.h" #include "l1_utils.h" +#include "octphy_hw_api.h" #include #include @@ -105,18 +106,12 @@ return l1if_req_compl(fl1h, msg, rf_port_info_compl_cb, NULL); } -static const struct value_string radio_std_vals[] = { - { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, - { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, - { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, - { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, - { 0, NULL } -}; - /* Chapter 12.10 */ static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h; @@ -136,12 +131,16 @@ psr->TxStats.ulTxAveragePeriodUs, psr->TxStats.ulFrequencyKhz); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.10 */ -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index) +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_RF_PORT_STATS_CMD *psc; @@ -156,7 +155,7 @@ mOCTVC1_HW_MSG_RF_PORT_STATS_CMD_SWAP(psc); - return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, NULL); + return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, cb_data); } static const struct value_string rx_gain_mode_vals[] = { @@ -276,28 +275,6 @@ { 0, NULL } }; -static const struct value_string clocksync_state_vals[] = { - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, - "Uninitialized" }, -/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to - * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef - * statement ensures that older headers still work. */ -#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, -#else - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, -#endif - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, - "No External Clock" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, - "Loss of Ext Clock" }, - { 0, NULL } -}; - /* Chapter 12.15 */ static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) @@ -336,6 +313,8 @@ static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) resp->l2h; @@ -349,12 +328,16 @@ csr->ulPllFractionalFreqHz, csr->ulSlipCnt, csr->ulSyncLosseCnt, csr->ulSourceState, csr->ulDacValue); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.16 */ -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h) +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD *csc; @@ -366,6 +349,6 @@ mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD_SWAP(csc); - return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, NULL); + return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, cb_data); } diff --git a/src/osmo-bts-octphy/octphy_hw_api.h b/src/osmo-bts-octphy/octphy_hw_api.h index bc8ab68..78b7208 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.h +++ b/src/osmo-bts-octphy/octphy_hw_api.h @@ -2,13 +2,53 @@ #include #include "l1_if.h" +#include + +static const struct value_string radio_std_vals[] = { + { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, + { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, + { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, + { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, + { 0, NULL } +}; + +static const struct value_string clocksync_state_vals[] = { + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, + "Uninitialized" }, +/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to + * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef + * statement ensures that older headers still work. */ +#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, +#else + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, +#endif + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, + "No External Clock" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, + "Loss of Ext Clock" }, + { 0, NULL } +}; + +typedef void octphy_hw_get_cb(struct msgb *resp, void *data); + +struct octphy_hw_get_cb_data { + octphy_hw_get_cb* cb; + void *data; +}; int octphy_hw_get_pcb_info(struct octphy_hdl *fl1h); int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index); -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index); +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data); int octphy_hw_get_rf_ant_rx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_rf_ant_tx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h); -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h); +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data); diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index abfac1e..bc4acd6 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -159,6 +159,45 @@ return CMD_SUCCESS; } +void show_rf_port_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr; + + if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) { + vty_out(vty, + "invalid msgb size (%d bytes, expected %zu bytes)%s", + msgb_l2len(resp), + sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP), VTY_NEWLINE); + return; + } + + psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "RF-PORT-STATS:%s", VTY_NEWLINE); + vty_out(vty, "Idx=%d%s", psr->ulPortIndex, VTY_NEWLINE); + vty_out(vty, "RadioStandard=%s%s", + get_value_string(radio_std_vals, psr->ulRadioStandard), + VTY_NEWLINE); + vty_out(vty, "Rx Bytes=%u%s", psr->RxStats.ulRxByteCnt, VTY_NEWLINE); + vty_out(vty, "Rx Overflow=%u%s", psr->RxStats.ulRxOverflowCnt, + VTY_NEWLINE); + vty_out(vty, "Rx AvgBps=%u%s", psr->RxStats.ulRxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Rx Period=%u%s", psr->RxStats.ulRxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Rx Freq=%u%s", psr->RxStats.ulFrequencyKhz, VTY_NEWLINE); + vty_out(vty, "Tx Bytes=%u%s", psr->TxStats.ulTxByteCnt, VTY_NEWLINE); + vty_out(vty, "Tx Underflow=%u%s", psr->TxStats.ulTxUnderflowCnt, + VTY_NEWLINE); + vty_out(vty, "Tx AvgBps=%u%s", psr->TxStats.ulTxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Tx Period=%u%s", psr->TxStats.ulTxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Tx Freq=%u%s", psr->TxStats.ulFrequencyKhz, VTY_NEWLINE); +} + DEFUN(show_rf_port_stats, show_rf_port_stats_cmd, "show phy <0-255> rf-port-stats <0-1>", "Show statistics for the RF Port\n" @@ -166,14 +205,47 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1])); + cb_data.cb = show_rf_port_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); + octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]), + &cb_data); return CMD_SUCCESS; +} + +void show_clk_sync_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr; + + if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) != + msgb_l2len(resp)) { + vty_out(vty, + "invalid msgb size (%d bytes, expected %zu bytes)%s", + msgb_l2len(resp), + sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP), + VTY_NEWLINE); + return; + } + + csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "CLOCK-SYNC-MGR-STATS:%s", VTY_NEWLINE); + vty_out(vty, "State=%s%s", + get_value_string(clocksync_state_vals, csr->ulState), + VTY_NEWLINE); + vty_out(vty, "ClockError=%d%s", csr->lClockError, VTY_NEWLINE); + vty_out(vty, "DroppedCycles=%d%s", csr->lDroppedCycles, VTY_NEWLINE); + vty_out(vty, "PllFreqHz=%u%s", csr->ulPllFreqHz, VTY_NEWLINE); + vty_out(vty, "PllFract=%u%s", csr->ulPllFractionalFreqHz, VTY_NEWLINE); + vty_out(vty, "SlipCnt=%u%s", csr->ulSlipCnt, VTY_NEWLINE); + vty_out(vty, "SyncLosses=%u%s", csr->ulSyncLosseCnt, VTY_NEWLINE); + vty_out(vty, "SourceState=%u%s", csr->ulSourceState, VTY_NEWLINE); + vty_out(vty, "DacValue=%u%s", csr->ulDacValue, VTY_NEWLINE); } DEFUN(show_clk_sync_stats, show_clk_sync_stats_cmd, @@ -182,13 +254,12 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl); + cb_data.cb = show_clk_sync_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); - + octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl, &cb_data); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 10:23:51 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Wed, 22 Feb 2017 10:23:51 +0000 Subject: osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 6 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 12:20:21 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 22 Feb 2017 12:20:21 +0000 Subject: [PATCH] osmo-pcu[master]: BTS: Convert relative frame numbers to absolute frame numbers In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1861 to look at the new patch set (#2). BTS: Convert relative frame numbers to absolute frame numbers The implementation of the method rcv_rach() in class BTS, restores the absolute frame number of the incoming RACH-Request by using the relative frame number (RFn = Fn mod 42432) from the rach request and the already known internal absolute frame number m_cur_fn, which is continusly updated by the CCU interface. In some rare cases, a RACH request might be received by the BTS, a very short time before the frame number wraps in its 42432. Depending on the PCU location, RACH request might be received by the BSC, which forwards it to the PCU. It is then likely that, while the RACH request is being forwarded to the PCU, the PCU internal absolute frame number wraps before the RACH can be processed. The relative frame number from the rach request would then be interpreted as if it were received after the wrapping of the internal frame number modulos. This commit adds logic to detect and resolve this race condition. Also a unit test is added to check some cornercases. Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 --- M src/bts.cpp M src/bts.h M tests/Makefile.am A tests/fn/FnTest.cpp A tests/fn/FnTest.ok M tests/testsuite.at 6 files changed, 314 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/61/1861/2 diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..13269bf 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -34,12 +34,16 @@ #include #include #include + #include } #include #include #include + +#define RFN_MODULUS 42432 +#define RFN_THRESHOLD RFN_MODULUS / 2 extern void *tall_pcu_ctx; @@ -516,6 +520,70 @@ return 0; } +/* Determine the full frame number from a relative frame number */ +uint32_t BTS::rfn_to_fn(uint32_t rfn) +{ + uint32_t m_cur_rfn; + uint32_t fn; + uint32_t fn_rounded; + + /* Note: If a BTS is sending in a rach request it will be fully aware + * of the frame number. If the PCU is used in a BSC-co-located setup. + * The BSC will forward the incoming RACH request. The RACH request + * only contains the relative frame number (Fn % 42432) in its request + * reference. This PCU implementation has to fit both scenarios, so + * we need to assume that Fn is a relative frame number. */ + + /* Ensure that all following calculations are performed with the + * relative frame number */ + rfn = rfn % 42432; + + /* Compute an internal relative frame number from the full internal + frame number */ + m_cur_rfn = m_cur_fn % RFN_MODULUS; + + /* Compute a "rounded" version of the internal frame number, which + * exactly fits in the RFN_MODULUS raster */ + if (m_cur_fn - m_cur_rfn < 0) { + LOGP(DRLCMAC, LOGL_ERROR, + "Invalid condition detected: m_cur_rfn (%u) larger than m_cur_fn (%u)\n", + m_cur_rfn, m_cur_fn); + } + fn_rounded = m_cur_fn - m_cur_rfn; + + /* If the delta between the internal and the external relative frame + * number exceeds a certain limit, we need to assume that the incoming + * rach request belongs to a the previous rfn period. To correct this, + * we roll back the rounded frame number by one RFN_MODULUS */ + if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) { + LOGP(DRLCMAC, LOGL_DEBUG, + "Race condition between rfn (%u) and m_cur_fn (%u) detected: rfn belongs to the previos modulus %u cycle, wrappng...\n", + rfn, m_cur_fn, RFN_MODULUS); + if (fn_rounded < RFN_MODULUS) { + LOGP(DRLCMAC, LOGL_DEBUG, + "Cornercase detected: wrapping crosses %u border\n", + GSM_MAX_FN); + fn_rounded = GSM_MAX_FN - (RFN_MODULUS - fn_rounded); + } + else + fn_rounded -= RFN_MODULUS; + } + + /* The real frame number is the sum of the rounded frame number and the + * relative framenumber computed via RACH */ + fn = fn_rounded + rfn; + +#if 0 +as we are using unsigned integers in a modulus arrithmetic: what happens if m_cur_rfn is +larger than m_cur_fn? does the function still work in this case? + +*If* this case is "imposible" then we should try to fail gracefully and print a +related error message (and test for it in the test case). +#endif + + return fn; +} + int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type) { @@ -536,20 +604,8 @@ if (is_11bit) rach_frame_11bit(); - /* Note: If a BTS is sending in a rach request it will be fully aware - * of the frame number. If the PCU is used in a BSC-co-located setup. - * The BSC will forward the incoming RACH request. The RACH request - * only contains the relative frame number (Fn % 42432) in its request - * reference. This PCU implementation has to fit both secenarious, so - * we need to assume that Fn is a relative frame number. */ - - /* Ensure that all following calculations are performed with the - * relative frame number */ - Fn = Fn % 42432; - - /* Restore the full frame number - * (See also 3GPP TS 44.018, section 10.5.2.38) */ - Fn = Fn + m_cur_fn - m_cur_fn % 42432; + /* Determine full frame number */ + Fn = rfn_to_fn(Fn); LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF on RACH, " "so we provide one: ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", diff --git a/src/bts.h b/src/bts.h index 2932154..5d8dc59 100644 --- a/src/bts.h +++ b/src/bts.h @@ -349,6 +349,8 @@ int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority); + + uint32_t rfn_to_fn(uint32_t rfn); int rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type); diff --git a/tests/Makefile.am b/tests/Makefile.am index a24f4ea..a372354 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/ AM_LDFLAGS = -lrt -check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest +check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest fn/FnTest noinst_PROGRAMS = emu/pcu_emu rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp @@ -90,6 +90,14 @@ $(LIBOSMOCORE_LIBS) \ $(COMMON_LA) +fn_FnTest_SOURCES = fn/FnTest.cpp +fn_FnTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ + $(LIBOSMOGB_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBOSMOCORE_LIBS) \ + $(COMMON_LA) + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ @@ -119,7 +127,8 @@ llc/LlcTest.ok llc/LlcTest.err \ llist/LListTest.ok llist/LListTest.err \ codel/codel_test.ok \ - edge/EdgeTest.ok + edge/EdgeTest.ok \ + fn/FnTest.ok fn/FnTest.err DISTCLEANFILES = atconfig diff --git a/tests/fn/FnTest.cpp b/tests/fn/FnTest.cpp new file mode 100644 index 0000000..279903c --- /dev/null +++ b/tests/fn/FnTest.cpp @@ -0,0 +1,175 @@ +/* Frame number calculation test */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Philipp Maier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "bts.h" +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#define RFN_MODULUS 42432 + +/* globals used by the code */ void *tall_pcu_ctx; +int16_t spoof_mnc = 0, spoof_mcc = 0; + +static uint32_t calc_fn(BTS * bts, uint32_t rfn) +{ + uint32_t fn; + fn = bts->rfn_to_fn(rfn); + printf("rfn=%i ==> fn=%i\n", rfn, fn); + return fn; +} + +static void set_fn(BTS * bts, uint32_t fn) +{ + printf("\n"); + bts->set_current_frame_number(fn); + printf("bts: fn=%i\n", fn); +} + +static void run_test() +{ + BTS bts; + uint32_t fn; + + printf("RFN_MODULUS=%i\n",RFN_MODULUS); + printf("GSM_MAX_FN=%i\n",GSM_MAX_FN); + + + /* Test with a collection of real world examples, + * all all of them are not critical and do not + * assume the occurence of any race contions */ + set_fn(&bts, 1320462); + fn = calc_fn(&bts, 5066); + OSMO_ASSERT(fn == 1320458); + + set_fn(&bts, 8246); + fn = calc_fn(&bts, 8244); + OSMO_ASSERT(fn == 8244); + + set_fn(&bts, 10270); + fn = calc_fn(&bts, 10269); + OSMO_ASSERT(fn == 10269); + + set_fn(&bts, 311276); + fn = calc_fn(&bts, 14250); + OSMO_ASSERT(fn == 311274); + + + /* Now lets assume a case where the frame number + * just wrapped over a little bit above the + * modulo 42432 raster, but the rach request + * occurred before the wrapping */ + set_fn(&bts, RFN_MODULUS + 30); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 42422); + + set_fn(&bts, RFN_MODULUS + 1); + fn = calc_fn(&bts, RFN_MODULUS - 1); + OSMO_ASSERT(fn == 42431); + + set_fn(&bts, RFN_MODULUS * 123 + 16); + fn = calc_fn(&bts, RFN_MODULUS - 4); + OSMO_ASSERT(fn == 5219132); + + set_fn(&bts, RFN_MODULUS * 123 + 451); + fn = calc_fn(&bts, RFN_MODULUS - 175); + OSMO_ASSERT(fn == 5218961); + + + /* Lets check a special cornercase. We assume that + * the BTS just wrapped its internal frame number + * but we still get rach requests with high relative + * frame numbers. */ + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS - 13); + OSMO_ASSERT(fn == 2715635); + + set_fn(&bts, 453); + fn = calc_fn(&bts, RFN_MODULUS - 102); + OSMO_ASSERT(fn == 2715546); + + set_fn(&bts, 10); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 2715638); + + set_fn(&bts, 23); + fn = calc_fn(&bts, RFN_MODULUS - 42); + OSMO_ASSERT(fn == 2715606); + + + /* Also check with some corner case + * values where Fn and RFn reach its + * maximum/minimum valid range */ + set_fn(&bts, GSM_MAX_FN); + fn = calc_fn(&bts, RFN_MODULUS-1); + OSMO_ASSERT(fn == GSM_MAX_FN-1); + + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS-1); + OSMO_ASSERT(fn == GSM_MAX_FN-1); + + set_fn(&bts, GSM_MAX_FN); + fn = calc_fn(&bts, 0); + OSMO_ASSERT(fn == GSM_MAX_FN); + + set_fn(&bts, 0); + fn = calc_fn(&bts, 0); + OSMO_ASSERT(fn == 0); +} + +int main(int argc, char **argv) +{ + tall_pcu_ctx = talloc_named_const(NULL, 1, "fn test context"); + if (!tall_pcu_ctx) + abort(); + + msgb_talloc_ctx_init(tall_pcu_ctx, 0); + osmo_init_logging(&gprs_log_info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + log_set_log_level(osmo_stderr_target, LOGL_DEBUG); + + run_test(); + return EXIT_SUCCESS; +} + +/* + * stubs that should not be reached + */ +extern "C" { + void l1if_pdch_req() { + abort(); + } void l1if_connect_pdch() { + abort(); + } + void l1if_close_pdch() { + abort(); + } + void l1if_open_pdch() { + abort(); + } +} diff --git a/tests/fn/FnTest.ok b/tests/fn/FnTest.ok new file mode 100644 index 0000000..be6400f --- /dev/null +++ b/tests/fn/FnTest.ok @@ -0,0 +1,50 @@ +RFN_MODULUS=42432 +GSM_MAX_FN=2715648 + +bts: fn=1320462 +rfn=5066 ==> fn=1320458 + +bts: fn=8246 +rfn=8244 ==> fn=8244 + +bts: fn=10270 +rfn=10269 ==> fn=10269 + +bts: fn=311276 +rfn=14250 ==> fn=311274 + +bts: fn=42462 +rfn=42422 ==> fn=42422 + +bts: fn=42433 +rfn=42431 ==> fn=42431 + +bts: fn=5219152 +rfn=42428 ==> fn=5219132 + +bts: fn=5219587 +rfn=42257 ==> fn=5218961 + +bts: fn=0 +rfn=42419 ==> fn=2715635 + +bts: fn=453 +rfn=42330 ==> fn=2715546 + +bts: fn=10 +rfn=42422 ==> fn=2715638 + +bts: fn=23 +rfn=42390 ==> fn=2715606 + +bts: fn=2715648 +rfn=42431 ==> fn=2715647 + +bts: fn=0 +rfn=42431 ==> fn=2715647 + +bts: fn=2715648 +rfn=0 ==> fn=2715648 + +bts: fn=0 +rfn=0 ==> fn=0 diff --git a/tests/testsuite.at b/tests/testsuite.at index e42a0fd..d8f8f9a 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -70,3 +70,9 @@ cat $abs_srcdir/codel/codel_test.ok > expout AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/codel/codel_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([fn]) +AT_KEYWORDS([fn]) +cat $abs_srcdir/fn/FnTest.ok > expout +AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/fn/FnTest], [0], [expout], [ignore]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1861 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 12:21:24 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 22 Feb 2017 12:21:24 +0000 Subject: [PATCH] osmo-pcu[master]: BTS: Convert relative frame numbers to absolute frame numbers In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1861 to look at the new patch set (#3). BTS: Convert relative frame numbers to absolute frame numbers The implementation of the method rcv_rach() in class BTS, restores the absolute frame number of the incoming RACH-Request by using the relative frame number (RFn = Fn mod 42432) from the rach request and the already known internal absolute frame number m_cur_fn, which is continusly updated by the CCU interface. In some rare cases, a RACH request might be received by the BTS, a very short time before the frame number wraps in its 42432. Depending on the PCU location, RACH request might be received by the BSC, which forwards it to the PCU. It is then likely that, while the RACH request is being forwarded to the PCU, the PCU internal absolute frame number wraps before the RACH can be processed. The relative frame number from the rach request would then be interpreted as if it were received after the wrapping of the internal frame number modulos. This commit adds logic to detect and resolve this race condition. Also a unit test is added to check some cornercases. Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 --- M src/bts.cpp M src/bts.h M tests/Makefile.am A tests/fn/FnTest.cpp A tests/fn/FnTest.ok M tests/testsuite.at 6 files changed, 306 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/61/1861/3 diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..553b952 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -34,12 +34,16 @@ #include #include #include + #include } #include #include #include + +#define RFN_MODULUS 42432 +#define RFN_THRESHOLD RFN_MODULUS / 2 extern void *tall_pcu_ctx; @@ -516,6 +520,62 @@ return 0; } +/* Determine the full frame number from a relative frame number */ +uint32_t BTS::rfn_to_fn(uint32_t rfn) +{ + uint32_t m_cur_rfn; + uint32_t fn; + uint32_t fn_rounded; + + /* Note: If a BTS is sending in a rach request it will be fully aware + * of the frame number. If the PCU is used in a BSC-co-located setup. + * The BSC will forward the incoming RACH request. The RACH request + * only contains the relative frame number (Fn % 42432) in its request + * reference. This PCU implementation has to fit both scenarios, so + * we need to assume that Fn is a relative frame number. */ + + /* Ensure that all following calculations are performed with the + * relative frame number */ + rfn = rfn % 42432; + + /* Compute an internal relative frame number from the full internal + frame number */ + m_cur_rfn = m_cur_fn % RFN_MODULUS; + + /* Compute a "rounded" version of the internal frame number, which + * exactly fits in the RFN_MODULUS raster */ + if (m_cur_fn - m_cur_rfn < 0) { + LOGP(DRLCMAC, LOGL_ERROR, + "Invalid condition detected: m_cur_rfn (%u) larger than m_cur_fn (%u)\n", + m_cur_rfn, m_cur_fn); + } + fn_rounded = m_cur_fn - m_cur_rfn; + + /* If the delta between the internal and the external relative frame + * number exceeds a certain limit, we need to assume that the incoming + * rach request belongs to a the previous rfn period. To correct this, + * we roll back the rounded frame number by one RFN_MODULUS */ + if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) { + LOGP(DRLCMAC, LOGL_DEBUG, + "Race condition between rfn (%u) and m_cur_fn (%u) detected: rfn belongs to the previos modulus %u cycle, wrappng...\n", + rfn, m_cur_fn, RFN_MODULUS); + if (fn_rounded < RFN_MODULUS) { + LOGP(DRLCMAC, LOGL_DEBUG, + "Cornercase detected: wrapping crosses %u border\n", + GSM_MAX_FN); + fn_rounded = GSM_MAX_FN - (RFN_MODULUS - fn_rounded); + } + else + fn_rounded -= RFN_MODULUS; + } + + /* The real frame number is the sum of the rounded frame number and the + * relative framenumber computed via RACH */ + fn = fn_rounded + rfn; + + return fn; +} + int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type) { @@ -536,20 +596,8 @@ if (is_11bit) rach_frame_11bit(); - /* Note: If a BTS is sending in a rach request it will be fully aware - * of the frame number. If the PCU is used in a BSC-co-located setup. - * The BSC will forward the incoming RACH request. The RACH request - * only contains the relative frame number (Fn % 42432) in its request - * reference. This PCU implementation has to fit both secenarious, so - * we need to assume that Fn is a relative frame number. */ - - /* Ensure that all following calculations are performed with the - * relative frame number */ - Fn = Fn % 42432; - - /* Restore the full frame number - * (See also 3GPP TS 44.018, section 10.5.2.38) */ - Fn = Fn + m_cur_fn - m_cur_fn % 42432; + /* Determine full frame number */ + Fn = rfn_to_fn(Fn); LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF on RACH, " "so we provide one: ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", diff --git a/src/bts.h b/src/bts.h index 2932154..5d8dc59 100644 --- a/src/bts.h +++ b/src/bts.h @@ -349,6 +349,8 @@ int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority); + + uint32_t rfn_to_fn(uint32_t rfn); int rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type); diff --git a/tests/Makefile.am b/tests/Makefile.am index a24f4ea..a372354 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/ AM_LDFLAGS = -lrt -check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest +check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest fn/FnTest noinst_PROGRAMS = emu/pcu_emu rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp @@ -90,6 +90,14 @@ $(LIBOSMOCORE_LIBS) \ $(COMMON_LA) +fn_FnTest_SOURCES = fn/FnTest.cpp +fn_FnTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ + $(LIBOSMOGB_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBOSMOCORE_LIBS) \ + $(COMMON_LA) + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ @@ -119,7 +127,8 @@ llc/LlcTest.ok llc/LlcTest.err \ llist/LListTest.ok llist/LListTest.err \ codel/codel_test.ok \ - edge/EdgeTest.ok + edge/EdgeTest.ok \ + fn/FnTest.ok fn/FnTest.err DISTCLEANFILES = atconfig diff --git a/tests/fn/FnTest.cpp b/tests/fn/FnTest.cpp new file mode 100644 index 0000000..279903c --- /dev/null +++ b/tests/fn/FnTest.cpp @@ -0,0 +1,175 @@ +/* Frame number calculation test */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Philipp Maier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "bts.h" +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#define RFN_MODULUS 42432 + +/* globals used by the code */ void *tall_pcu_ctx; +int16_t spoof_mnc = 0, spoof_mcc = 0; + +static uint32_t calc_fn(BTS * bts, uint32_t rfn) +{ + uint32_t fn; + fn = bts->rfn_to_fn(rfn); + printf("rfn=%i ==> fn=%i\n", rfn, fn); + return fn; +} + +static void set_fn(BTS * bts, uint32_t fn) +{ + printf("\n"); + bts->set_current_frame_number(fn); + printf("bts: fn=%i\n", fn); +} + +static void run_test() +{ + BTS bts; + uint32_t fn; + + printf("RFN_MODULUS=%i\n",RFN_MODULUS); + printf("GSM_MAX_FN=%i\n",GSM_MAX_FN); + + + /* Test with a collection of real world examples, + * all all of them are not critical and do not + * assume the occurence of any race contions */ + set_fn(&bts, 1320462); + fn = calc_fn(&bts, 5066); + OSMO_ASSERT(fn == 1320458); + + set_fn(&bts, 8246); + fn = calc_fn(&bts, 8244); + OSMO_ASSERT(fn == 8244); + + set_fn(&bts, 10270); + fn = calc_fn(&bts, 10269); + OSMO_ASSERT(fn == 10269); + + set_fn(&bts, 311276); + fn = calc_fn(&bts, 14250); + OSMO_ASSERT(fn == 311274); + + + /* Now lets assume a case where the frame number + * just wrapped over a little bit above the + * modulo 42432 raster, but the rach request + * occurred before the wrapping */ + set_fn(&bts, RFN_MODULUS + 30); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 42422); + + set_fn(&bts, RFN_MODULUS + 1); + fn = calc_fn(&bts, RFN_MODULUS - 1); + OSMO_ASSERT(fn == 42431); + + set_fn(&bts, RFN_MODULUS * 123 + 16); + fn = calc_fn(&bts, RFN_MODULUS - 4); + OSMO_ASSERT(fn == 5219132); + + set_fn(&bts, RFN_MODULUS * 123 + 451); + fn = calc_fn(&bts, RFN_MODULUS - 175); + OSMO_ASSERT(fn == 5218961); + + + /* Lets check a special cornercase. We assume that + * the BTS just wrapped its internal frame number + * but we still get rach requests with high relative + * frame numbers. */ + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS - 13); + OSMO_ASSERT(fn == 2715635); + + set_fn(&bts, 453); + fn = calc_fn(&bts, RFN_MODULUS - 102); + OSMO_ASSERT(fn == 2715546); + + set_fn(&bts, 10); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 2715638); + + set_fn(&bts, 23); + fn = calc_fn(&bts, RFN_MODULUS - 42); + OSMO_ASSERT(fn == 2715606); + + + /* Also check with some corner case + * values where Fn and RFn reach its + * maximum/minimum valid range */ + set_fn(&bts, GSM_MAX_FN); + fn = calc_fn(&bts, RFN_MODULUS-1); + OSMO_ASSERT(fn == GSM_MAX_FN-1); + + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS-1); + OSMO_ASSERT(fn == GSM_MAX_FN-1); + + set_fn(&bts, GSM_MAX_FN); + fn = calc_fn(&bts, 0); + OSMO_ASSERT(fn == GSM_MAX_FN); + + set_fn(&bts, 0); + fn = calc_fn(&bts, 0); + OSMO_ASSERT(fn == 0); +} + +int main(int argc, char **argv) +{ + tall_pcu_ctx = talloc_named_const(NULL, 1, "fn test context"); + if (!tall_pcu_ctx) + abort(); + + msgb_talloc_ctx_init(tall_pcu_ctx, 0); + osmo_init_logging(&gprs_log_info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + log_set_log_level(osmo_stderr_target, LOGL_DEBUG); + + run_test(); + return EXIT_SUCCESS; +} + +/* + * stubs that should not be reached + */ +extern "C" { + void l1if_pdch_req() { + abort(); + } void l1if_connect_pdch() { + abort(); + } + void l1if_close_pdch() { + abort(); + } + void l1if_open_pdch() { + abort(); + } +} diff --git a/tests/fn/FnTest.ok b/tests/fn/FnTest.ok new file mode 100644 index 0000000..be6400f --- /dev/null +++ b/tests/fn/FnTest.ok @@ -0,0 +1,50 @@ +RFN_MODULUS=42432 +GSM_MAX_FN=2715648 + +bts: fn=1320462 +rfn=5066 ==> fn=1320458 + +bts: fn=8246 +rfn=8244 ==> fn=8244 + +bts: fn=10270 +rfn=10269 ==> fn=10269 + +bts: fn=311276 +rfn=14250 ==> fn=311274 + +bts: fn=42462 +rfn=42422 ==> fn=42422 + +bts: fn=42433 +rfn=42431 ==> fn=42431 + +bts: fn=5219152 +rfn=42428 ==> fn=5219132 + +bts: fn=5219587 +rfn=42257 ==> fn=5218961 + +bts: fn=0 +rfn=42419 ==> fn=2715635 + +bts: fn=453 +rfn=42330 ==> fn=2715546 + +bts: fn=10 +rfn=42422 ==> fn=2715638 + +bts: fn=23 +rfn=42390 ==> fn=2715606 + +bts: fn=2715648 +rfn=42431 ==> fn=2715647 + +bts: fn=0 +rfn=42431 ==> fn=2715647 + +bts: fn=2715648 +rfn=0 ==> fn=2715648 + +bts: fn=0 +rfn=0 ==> fn=0 diff --git a/tests/testsuite.at b/tests/testsuite.at index e42a0fd..d8f8f9a 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -70,3 +70,9 @@ cat $abs_srcdir/codel/codel_test.ok > expout AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/codel/codel_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([fn]) +AT_KEYWORDS([fn]) +cat $abs_srcdir/fn/FnTest.ok > expout +AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/fn/FnTest], [0], [expout], [ignore]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1861 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 Gerrit-PatchSet: 3 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 13:13:43 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 22 Feb 2017 13:13:43 +0000 Subject: [PATCH] osmo-sip-connector[master]: dtmf: Start handling the DTMF MNCC messages and respond Message-ID: Review at https://gerrit.osmocom.org/1873 dtmf: Start handling the DTMF MNCC messages and respond Simply respond to the dtmf start/stop with a response and move on. Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5 --- M src/mncc.c 1 file changed, 57 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/73/1873/1 diff --git a/src/mncc.c b/src/mncc.c index 7926f5e..ceb0fc1 100644 --- a/src/mncc.c +++ b/src/mncc.c @@ -102,23 +102,33 @@ return NULL; } -static void mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref) +static void mncc_fill_header(struct gsm_mncc *mncc, uint32_t msg_type, uint32_t callref) +{ + mncc->msg_type = msg_type; + mncc->callref = callref; +} + +static void mncc_write(struct mncc_connection *conn, struct gsm_mncc *mncc, uint32_t callref) { int rc; - struct gsm_mncc mncc = { 0, }; - - mncc.msg_type = msg_type; - mncc.callref = callref; /* * TODO: we need to put cause in here for release or such? shall we return a * static struct? */ - rc = write(conn->fd.fd, &mncc, sizeof(mncc)); - if (rc != sizeof(mncc)) { + rc = write(conn->fd.fd, mncc, sizeof(*mncc)); + if (rc != sizeof(*mncc)) { LOGP(DMNCC, LOGL_ERROR, "Failed to send message call(%u)\n", callref); close_connection(conn); } +} + +static void mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref) +{ + struct gsm_mncc mncc = { 0, }; + + mncc_fill_header(&mncc, msg_type, callref); + mncc_write(conn, &mncc, callref); } static void mncc_rtp_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref) @@ -617,6 +627,40 @@ other_leg->connect_call(other_leg); } +static void check_dtmf_start(struct mncc_connection *conn, char *buf, int rc) +{ + struct gsm_mncc out_mncc = { 0, }; + struct gsm_mncc *data; + struct mncc_call_leg *leg; + + leg = find_leg(conn, buf, rc, &data); + if (!leg) + return; + + LOGP(DMNCC, LOGL_DEBUG, "leg(%u) DTMF key=%c\n", leg->callref, data->keypad); + + mncc_fill_header(&out_mncc, MNCC_START_DTMF_RSP, leg->callref); + out_mncc.keypad = data->keypad; + mncc_write(conn, &out_mncc, leg->callref); +} + +static void check_dtmf_stop(struct mncc_connection *conn, char *buf, int rc) +{ + struct gsm_mncc out_mncc = { 0, }; + struct gsm_mncc *data; + struct mncc_call_leg *leg; + + leg = find_leg(conn, buf, rc, &data); + if (!leg) + return; + + LOGP(DMNCC, LOGL_DEBUG, "leg(%u) DTMF key=%c\n", leg->callref, data->keypad); + + mncc_fill_header(&out_mncc, MNCC_STOP_DTMF_RSP, leg->callref); + out_mncc.keypad = data->keypad; + mncc_write(conn, &out_mncc, leg->callref); +} + static void check_hello(struct mncc_connection *conn, char *buf, int rc) { struct gsm_mncc_hello *hello; @@ -778,6 +822,12 @@ case MNCC_HOLD_IND: check_hold_ind(conn, buf, rc); break; + case MNCC_START_DTMF_IND: + check_dtmf_start(conn, buf, rc); + break; + case MNCC_STOP_DTMF_IND: + check_dtmf_stop(conn, buf, rc); + break; default: LOGP(DMNCC, LOGL_ERROR, "Unhandled message type %d/0x%x\n", msg_type, msg_type); -- To view, visit https://gerrit.osmocom.org/1873 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Wed Feb 22 13:13:44 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 22 Feb 2017 13:13:44 +0000 Subject: [PATCH] osmo-sip-connector[master]: dtmf: Forward DTMF from MNCC to SIP Message-ID: Review at https://gerrit.osmocom.org/1874 dtmf: Forward DTMF from MNCC to SIP We are not using the RTP telephony-event here but the older dtmf relay. We also only have a fixed DTMF duration for now. Change-Id: Icf770fae89f7aedf6eba9a119db9b8acc7f938df --- M src/call.h M src/mncc.c M src/sip.c 3 files changed, 28 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/74/1874/1 diff --git a/src/call.h b/src/call.h index 7cb4932..5a11f6c 100644 --- a/src/call.h +++ b/src/call.h @@ -67,6 +67,11 @@ * by the application to release the call. */ void (*release_call)(struct call_leg *); + + /** + * A DTMF key was entered. Forward it. + */ + void (*dtmf)(struct call_leg *, int keypad); }; enum sip_cc_state { diff --git a/src/mncc.c b/src/mncc.c index ceb0fc1..d28010a 100644 --- a/src/mncc.c +++ b/src/mncc.c @@ -632,6 +632,7 @@ struct gsm_mncc out_mncc = { 0, }; struct gsm_mncc *data; struct mncc_call_leg *leg; + struct call_leg *other_leg; leg = find_leg(conn, buf, rc, &data); if (!leg) @@ -639,6 +640,10 @@ LOGP(DMNCC, LOGL_DEBUG, "leg(%u) DTMF key=%c\n", leg->callref, data->keypad); + other_leg = call_leg_other(&leg->base); + if (other_leg && other_leg->dtmf) + other_leg->dtmf(other_leg, data->keypad); + mncc_fill_header(&out_mncc, MNCC_START_DTMF_RSP, leg->callref); out_mncc.keypad = data->keypad; mncc_write(conn, &out_mncc, leg->callref); diff --git a/src/sip.c b/src/sip.c index afff393..178480c 100644 --- a/src/sip.c +++ b/src/sip.c @@ -37,6 +37,7 @@ static void sip_release_call(struct call_leg *_leg); static void sip_ring_call(struct call_leg *_leg); static void sip_connect_call(struct call_leg *_leg); +static void sip_dtmf_call(struct call_leg *_leg, int keypad); static void call_progress(struct sip_call_leg *leg, const sip_t *sip) { @@ -131,6 +132,7 @@ leg->base.release_call = sip_release_call; leg->base.ring_call = sip_ring_call; leg->base.connect_call = sip_connect_call; + leg->base.dtmf = sip_dtmf_call; leg->agent = agent; leg->nua_handle = nh; nua_handle_bind(nh, leg); @@ -288,6 +290,22 @@ talloc_free(sdp); } +static void sip_dtmf_call(struct call_leg *_leg, int keypad) +{ + struct sip_call_leg *leg; + char *buf; + + OSMO_ASSERT(_leg->type == CALL_TYPE_SIP); + leg = (struct sip_call_leg *) _leg; + + buf = talloc_asprintf(leg, "Signal=%c\nDuration=160\n", keypad); + nua_info(leg->nua_handle, + NUTAG_MEDIA_ENABLE(0), + SIPTAG_CONTENT_TYPE_STR("application/dtmf-relay"), + SIPTAG_PAYLOAD_STR(buf), TAG_END()); + talloc_free(buf); +} + static int send_invite(struct sip_agent *agent, struct sip_call_leg *leg, const char *calling_num, const char *called_num) { -- To view, visit https://gerrit.osmocom.org/1874 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icf770fae89f7aedf6eba9a119db9b8acc7f938df Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Wed Feb 22 13:18:39 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Wed, 22 Feb 2017 13:18:39 +0000 Subject: osmo-sip-connector[master]: dtmf: Start handling the DTMF MNCC messages and respond In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-2 Not tested.. but looks complete.. will merge once i can test it in march -- To view, visit https://gerrit.osmocom.org/1873 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 13:40:44 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Wed, 22 Feb 2017 13:40:44 +0000 Subject: [PATCH] osmo-pcu[master]: BTS: Convert relative frame numbers to absolute frame numbers In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1861 to look at the new patch set (#4). BTS: Convert relative frame numbers to absolute frame numbers The implementation of the method rcv_rach() in class BTS, restores the absolute frame number of the incoming RACH-Request by using the relative frame number (RFn = Fn mod 42432) from the rach request and the already known internal absolute frame number m_cur_fn, which is continusly updated by the CCU interface. In some rare cases, a RACH request might be received by the BTS, a very short time before the frame number wraps in its 42432. Depending on the PCU location, RACH request might be received by the BSC, which forwards it to the PCU. It is then likely that, while the RACH request is being forwarded to the PCU, the PCU internal absolute frame number wraps before the RACH can be processed. The relative frame number from the rach request would then be interpreted as if it were received after the wrapping of the internal frame number modulos. This commit adds logic to detect and resolve this race condition. Also a unit test is added to check some cornercases. Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 --- M src/bts.cpp M src/bts.h M tests/Makefile.am A tests/fn/FnTest.cpp A tests/fn/FnTest.ok M tests/testsuite.at 6 files changed, 306 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/61/1861/4 diff --git a/src/bts.cpp b/src/bts.cpp index 21e9d96..553b952 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -34,12 +34,16 @@ #include #include #include + #include } #include #include #include + +#define RFN_MODULUS 42432 +#define RFN_THRESHOLD RFN_MODULUS / 2 extern void *tall_pcu_ctx; @@ -516,6 +520,62 @@ return 0; } +/* Determine the full frame number from a relative frame number */ +uint32_t BTS::rfn_to_fn(uint32_t rfn) +{ + uint32_t m_cur_rfn; + uint32_t fn; + uint32_t fn_rounded; + + /* Note: If a BTS is sending in a rach request it will be fully aware + * of the frame number. If the PCU is used in a BSC-co-located setup. + * The BSC will forward the incoming RACH request. The RACH request + * only contains the relative frame number (Fn % 42432) in its request + * reference. This PCU implementation has to fit both scenarios, so + * we need to assume that Fn is a relative frame number. */ + + /* Ensure that all following calculations are performed with the + * relative frame number */ + rfn = rfn % 42432; + + /* Compute an internal relative frame number from the full internal + frame number */ + m_cur_rfn = m_cur_fn % RFN_MODULUS; + + /* Compute a "rounded" version of the internal frame number, which + * exactly fits in the RFN_MODULUS raster */ + if (m_cur_fn - m_cur_rfn < 0) { + LOGP(DRLCMAC, LOGL_ERROR, + "Invalid condition detected: m_cur_rfn (%u) larger than m_cur_fn (%u)\n", + m_cur_rfn, m_cur_fn); + } + fn_rounded = m_cur_fn - m_cur_rfn; + + /* If the delta between the internal and the external relative frame + * number exceeds a certain limit, we need to assume that the incoming + * rach request belongs to a the previous rfn period. To correct this, + * we roll back the rounded frame number by one RFN_MODULUS */ + if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) { + LOGP(DRLCMAC, LOGL_DEBUG, + "Race condition between rfn (%u) and m_cur_fn (%u) detected: rfn belongs to the previos modulus %u cycle, wrappng...\n", + rfn, m_cur_fn, RFN_MODULUS); + if (fn_rounded < RFN_MODULUS) { + LOGP(DRLCMAC, LOGL_DEBUG, + "Cornercase detected: wrapping crosses %u border\n", + GSM_MAX_FN); + fn_rounded = GSM_MAX_FN - (RFN_MODULUS - fn_rounded); + } + else + fn_rounded -= RFN_MODULUS; + } + + /* The real frame number is the sum of the rounded frame number and the + * relative framenumber computed via RACH */ + fn = fn_rounded + rfn; + + return fn; +} + int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type) { @@ -536,20 +596,8 @@ if (is_11bit) rach_frame_11bit(); - /* Note: If a BTS is sending in a rach request it will be fully aware - * of the frame number. If the PCU is used in a BSC-co-located setup. - * The BSC will forward the incoming RACH request. The RACH request - * only contains the relative frame number (Fn % 42432) in its request - * reference. This PCU implementation has to fit both secenarious, so - * we need to assume that Fn is a relative frame number. */ - - /* Ensure that all following calculations are performed with the - * relative frame number */ - Fn = Fn % 42432; - - /* Restore the full frame number - * (See also 3GPP TS 44.018, section 10.5.2.38) */ - Fn = Fn + m_cur_fn - m_cur_fn % 42432; + /* Determine full frame number */ + Fn = rfn_to_fn(Fn); LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF on RACH, " "so we provide one: ra=0x%02x Fn=%u qta=%d is_11bit=%d:\n", diff --git a/src/bts.h b/src/bts.h index 2932154..5d8dc59 100644 --- a/src/bts.h +++ b/src/bts.h @@ -349,6 +349,8 @@ int rcv_imm_ass_cnf(const uint8_t *data, uint32_t fn); uint8_t is_single_block(uint16_t ra, enum ph_burst_type burst_type, uint8_t is_11bit, uint16_t *ms_class, uint16_t *priority); + + uint32_t rfn_to_fn(uint32_t rfn); int rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, enum ph_burst_type burst_type); diff --git a/tests/Makefile.am b/tests/Makefile.am index a24f4ea..a03528c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/ AM_LDFLAGS = -lrt -check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest +check_PROGRAMS = rlcmac/RLCMACTest alloc/AllocTest tbf/TbfTest types/TypesTest ms/MsTest llist/LListTest llc/LlcTest codel/codel_test edge/EdgeTest bitcomp/BitcompTest fn/FnTest noinst_PROGRAMS = emu/pcu_emu rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp @@ -90,6 +90,14 @@ $(LIBOSMOCORE_LIBS) \ $(COMMON_LA) +fn_FnTest_SOURCES = fn/FnTest.cpp +fn_FnTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ + $(LIBOSMOGB_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBOSMOCORE_LIBS) \ + $(COMMON_LA) + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac :;{ \ @@ -119,7 +127,8 @@ llc/LlcTest.ok llc/LlcTest.err \ llist/LListTest.ok llist/LListTest.err \ codel/codel_test.ok \ - edge/EdgeTest.ok + edge/EdgeTest.ok \ + fn/FnTest.ok DISTCLEANFILES = atconfig diff --git a/tests/fn/FnTest.cpp b/tests/fn/FnTest.cpp new file mode 100644 index 0000000..279903c --- /dev/null +++ b/tests/fn/FnTest.cpp @@ -0,0 +1,175 @@ +/* Frame number calculation test */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Philipp Maier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "bts.h" +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#define RFN_MODULUS 42432 + +/* globals used by the code */ void *tall_pcu_ctx; +int16_t spoof_mnc = 0, spoof_mcc = 0; + +static uint32_t calc_fn(BTS * bts, uint32_t rfn) +{ + uint32_t fn; + fn = bts->rfn_to_fn(rfn); + printf("rfn=%i ==> fn=%i\n", rfn, fn); + return fn; +} + +static void set_fn(BTS * bts, uint32_t fn) +{ + printf("\n"); + bts->set_current_frame_number(fn); + printf("bts: fn=%i\n", fn); +} + +static void run_test() +{ + BTS bts; + uint32_t fn; + + printf("RFN_MODULUS=%i\n",RFN_MODULUS); + printf("GSM_MAX_FN=%i\n",GSM_MAX_FN); + + + /* Test with a collection of real world examples, + * all all of them are not critical and do not + * assume the occurence of any race contions */ + set_fn(&bts, 1320462); + fn = calc_fn(&bts, 5066); + OSMO_ASSERT(fn == 1320458); + + set_fn(&bts, 8246); + fn = calc_fn(&bts, 8244); + OSMO_ASSERT(fn == 8244); + + set_fn(&bts, 10270); + fn = calc_fn(&bts, 10269); + OSMO_ASSERT(fn == 10269); + + set_fn(&bts, 311276); + fn = calc_fn(&bts, 14250); + OSMO_ASSERT(fn == 311274); + + + /* Now lets assume a case where the frame number + * just wrapped over a little bit above the + * modulo 42432 raster, but the rach request + * occurred before the wrapping */ + set_fn(&bts, RFN_MODULUS + 30); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 42422); + + set_fn(&bts, RFN_MODULUS + 1); + fn = calc_fn(&bts, RFN_MODULUS - 1); + OSMO_ASSERT(fn == 42431); + + set_fn(&bts, RFN_MODULUS * 123 + 16); + fn = calc_fn(&bts, RFN_MODULUS - 4); + OSMO_ASSERT(fn == 5219132); + + set_fn(&bts, RFN_MODULUS * 123 + 451); + fn = calc_fn(&bts, RFN_MODULUS - 175); + OSMO_ASSERT(fn == 5218961); + + + /* Lets check a special cornercase. We assume that + * the BTS just wrapped its internal frame number + * but we still get rach requests with high relative + * frame numbers. */ + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS - 13); + OSMO_ASSERT(fn == 2715635); + + set_fn(&bts, 453); + fn = calc_fn(&bts, RFN_MODULUS - 102); + OSMO_ASSERT(fn == 2715546); + + set_fn(&bts, 10); + fn = calc_fn(&bts, RFN_MODULUS - 10); + OSMO_ASSERT(fn == 2715638); + + set_fn(&bts, 23); + fn = calc_fn(&bts, RFN_MODULUS - 42); + OSMO_ASSERT(fn == 2715606); + + + /* Also check with some corner case + * values where Fn and RFn reach its + * maximum/minimum valid range */ + set_fn(&bts, GSM_MAX_FN); + fn = calc_fn(&bts, RFN_MODULUS-1); + OSMO_ASSERT(fn == GSM_MAX_FN-1); + + set_fn(&bts, 0); + fn = calc_fn(&bts, RFN_MODULUS-1); + OSMO_ASSERT(fn == GSM_MAX_FN-1); + + set_fn(&bts, GSM_MAX_FN); + fn = calc_fn(&bts, 0); + OSMO_ASSERT(fn == GSM_MAX_FN); + + set_fn(&bts, 0); + fn = calc_fn(&bts, 0); + OSMO_ASSERT(fn == 0); +} + +int main(int argc, char **argv) +{ + tall_pcu_ctx = talloc_named_const(NULL, 1, "fn test context"); + if (!tall_pcu_ctx) + abort(); + + msgb_talloc_ctx_init(tall_pcu_ctx, 0); + osmo_init_logging(&gprs_log_info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename(osmo_stderr_target, 0); + log_set_log_level(osmo_stderr_target, LOGL_DEBUG); + + run_test(); + return EXIT_SUCCESS; +} + +/* + * stubs that should not be reached + */ +extern "C" { + void l1if_pdch_req() { + abort(); + } void l1if_connect_pdch() { + abort(); + } + void l1if_close_pdch() { + abort(); + } + void l1if_open_pdch() { + abort(); + } +} diff --git a/tests/fn/FnTest.ok b/tests/fn/FnTest.ok new file mode 100644 index 0000000..be6400f --- /dev/null +++ b/tests/fn/FnTest.ok @@ -0,0 +1,50 @@ +RFN_MODULUS=42432 +GSM_MAX_FN=2715648 + +bts: fn=1320462 +rfn=5066 ==> fn=1320458 + +bts: fn=8246 +rfn=8244 ==> fn=8244 + +bts: fn=10270 +rfn=10269 ==> fn=10269 + +bts: fn=311276 +rfn=14250 ==> fn=311274 + +bts: fn=42462 +rfn=42422 ==> fn=42422 + +bts: fn=42433 +rfn=42431 ==> fn=42431 + +bts: fn=5219152 +rfn=42428 ==> fn=5219132 + +bts: fn=5219587 +rfn=42257 ==> fn=5218961 + +bts: fn=0 +rfn=42419 ==> fn=2715635 + +bts: fn=453 +rfn=42330 ==> fn=2715546 + +bts: fn=10 +rfn=42422 ==> fn=2715638 + +bts: fn=23 +rfn=42390 ==> fn=2715606 + +bts: fn=2715648 +rfn=42431 ==> fn=2715647 + +bts: fn=0 +rfn=42431 ==> fn=2715647 + +bts: fn=2715648 +rfn=0 ==> fn=2715648 + +bts: fn=0 +rfn=0 ==> fn=0 diff --git a/tests/testsuite.at b/tests/testsuite.at index e42a0fd..d8f8f9a 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -70,3 +70,9 @@ cat $abs_srcdir/codel/codel_test.ok > expout AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/codel/codel_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([fn]) +AT_KEYWORDS([fn]) +cat $abs_srcdir/fn/FnTest.ok > expout +AT_CHECK([$OSMO_QEMU $abs_top_builddir/tests/fn/FnTest], [0], [expout], [ignore]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/1861 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 15:06:16 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 15:06:16 +0000 Subject: osmo-hlr[master]: cosmetic: refactor auc_compute_vectors(), add debug log In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) > I understand the need for debug logging during development, but I > think for normla use this is rather on the excessive side, which is why I added the local flag that pre-fetches whether debug logging is enabled, so that we basically just have a dozen "if (0)" in case debug logging is off. Is that not sufficient? https://gerrit.osmocom.org/#/c/1869/1/src/auc.c File src/auc.c: Line 44: /* no need to iterate the log categories all the time */ here: -- To view, visit https://gerrit.osmocom.org/1869 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 22 15:20:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 15:20:01 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 6: > I believe we used _find_or_alloc or find_or_create in other/previosu code. yes, it's longer. But "have" might easily be read as "do we have one?", IMHO ah ok. "have" is probably my personal dialect for find-or-create, I've often used it in private projects and it seemed very clear to me, in the sense of "go on, have a cookie". It's indeed ambiguous like "can I have a cookie?" and "do we have a cookie?" -- Will go for find_or_create instead. -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 15:59:09 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 15:59:09 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: (1 comment) https://gerrit.osmocom.org/#/c/1684/8/openbsc/tests/sgsn/sgsn_test.c File openbsc/tests/sgsn/sgsn_test.c: Line 290: #define VERBOSE_ASSERT(val, expect_op, fmt) \ > might make sense to have this in libosmocore. like "OSMO_ASSERT_EXPR" or th If you're talking about an assert that prints the value only in case of failure, it can print to stderr because the program is aborting anyway. We can add that and start using it, I like the idea. For tests though I particularly like that it prints all expected values unconditionally as the test proceeds -- tremendously clarifies the test log. Publishing an unconditionally printing assert is difficult because of the printf decision. In some tests, I want to printf to stdout, in others to stderr, sometimes with a bit of indenting ... adding ways to redirect this will just bloat. So far I create a tailored VERBOSE_ASSERT for each test.c, and a general OSMO_ASSERT_EXPR will not replace this. -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Wed Feb 22 16:07:44 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 16:07:44 +0000 Subject: libosmocore[master]: gsm_04_08.h: add struct with R99 names for SI3 Ctrl Chan Descr In-Reply-To: References: Message-ID: Patch Set 1: > I'm not sure if it is worth keeping around the old r98 data > structure under a separate name. nobody can so far be using it, as > the name with r98 suffix is new. What's the rationale to keep it? I was trying to follow the _r98 / _r99 pattern seen further below in the file. Besides the spare bits distribution, there are no changes in r99, only additions, but I assume we would like to reflect which is present in which revision. gsm48_hdr_msg_type_r98() is also not used by anyone AFAICT. -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 16:08:39 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 16:08:39 +0000 Subject: [MERGED] libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: logging: centrally define ctx and filter indexes ...................................................................... logging: centrally define ctx and filter indexes It is too easy for calling code to use the same filter and context indexes for different filters and structs. For example, openbsc's IMSI filter and libgb's GPRS_BVC filter both fall on index 1 even though there are plenty more indexes to choose from. To alleviate this, have one central definition here, sort of like ports.h does for VTY and CTRL port numbers. Add static asserts to make sure the indexes fit in the available array and bit mask space. Calling code like openbsc.git and osmo-pcu need adjustments and/or should move to using these enum values instead of their local definitions. Taking this opportunity to also prepare for a split of struct gsm_subscriber in openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter index constants for both subscriber types. Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its use by (1 << LOGGING_FILTER_ALL). Change-Id: I5c343630020f4b108099696fd96c2111614c8067 --- M include/osmocom/core/logging.h M include/osmocom/gprs/gprs_msgb.h M src/gb/common_vty.c M src/gb/common_vty.h M src/gb/gprs_bssgp.c M src/gb/gprs_bssgp_vty.c M src/gb/gprs_ns.c M src/gb/gprs_ns_vty.c M src/logging.c M src/vty/logging_vty.c 10 files changed, 66 insertions(+), 54 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index fcf77f0..b3685b8 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -89,8 +89,6 @@ #define LOGL_ERROR 7 /*!< \brief error condition, requires user action */ #define LOGL_FATAL 8 /*!< \brief fatal, program aborted */ -#define LOG_FILTER_ALL 0x0001 - /* logging levels defined by the library itself */ #define DLGLOBAL -1 /*!< global logging */ #define DLLAPD -2 /*!< LAPD implementation */ @@ -126,6 +124,23 @@ void *ctx[LOG_MAX_CTX+1]; }; +enum logging_ctx_items { + LOGGING_CTX_GB_NSVC, + LOGGING_CTX_GB_BVC, + LOGGING_CTX_BSC_SUBSCR, + LOGGING_CTX_VLR_SUBSCR, + _LOGGING_CTX_COUNT +}; + +enum logging_filters { + LOGGING_FILTER_ALL, + LOGGING_FILTER_GB_NSVC, + LOGGING_FILTER_GB_BVC, + LOGGING_FILTER_BSC_SUBSCR, + LOGGING_FILTER_VLR_SUBSCR, + _LOGGING_FILTER_COUNT +}; + struct log_target; /*! \brief Log filter function */ diff --git a/include/osmocom/gprs/gprs_msgb.h b/include/osmocom/gprs/gprs_msgb.h index 06f5cca..9ccc9a5 100644 --- a/include/osmocom/gprs/gprs_msgb.h +++ b/include/osmocom/gprs/gprs_msgb.h @@ -26,10 +26,6 @@ #define msgb_bcid(__x) LIBGB_MSGB_CB(__x)->bssgp_cell_id #define msgb_llch(__x) LIBGB_MSGB_CB(__x)->llch -/* logging contexts */ -#define GPRS_CTX_NSVC 0 -#define GPRS_CTX_BVC 1 - #include int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar); diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c index 5b20fcf..609ab3d 100644 --- a/src/gb/common_vty.c +++ b/src/gb/common_vty.c @@ -70,17 +70,17 @@ int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_bvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_bvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; diff --git a/src/gb/common_vty.h b/src/gb/common_vty.h index d8d0040..8c6b9ab 100644 --- a/src/gb/common_vty.h +++ b/src/gb/common_vty.h @@ -3,12 +3,6 @@ extern int DNS, DBSSGP; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_NSVC = 1, - FLT_BVC = 2, -}; - extern struct cmd_element libgb_exit_cmd; extern struct cmd_element libgb_end_cmd; diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 1ee942f..a402378 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -1049,7 +1049,7 @@ bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); if (bctx) { - log_set_context(GPRS_CTX_BVC, bctx); + log_set_context(LOGGING_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 1f382a2..d8fc840 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -47,11 +47,11 @@ struct bssgp_bvc_ctx *bctx) { if (bctx) { - target->filter_map |= (1 << FLT_BVC); - target->filter_data[FLT_BVC] = bctx; - } else if (target->filter_data[FLT_BVC]) { - target->filter_map = ~(1 << FLT_BVC); - target->filter_data[FLT_BVC] = NULL; + target->filter_map |= (1 << LOGGING_FILTER_GB_BVC); + target->filter_data[LOGGING_FILTER_GB_BVC] = bctx; + } else if (target->filter_data[LOGGING_FILTER_GB_BVC]) { + target->filter_map = ~(1 << LOGGING_FILTER_GB_BVC); + target->filter_data[LOGGING_FILTER_GB_BVC] = NULL; } } diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 18845d4..28f5ff3 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -325,7 +325,7 @@ { int ret; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); /* Increment number of Uplink bytes */ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]); @@ -360,7 +360,7 @@ struct msgb *msg = gprs_ns_msgb_alloc(); struct gprs_ns_hdr *nsh; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -384,7 +384,7 @@ uint16_t nsvci = htons(nsvc->nsvci); uint16_t nsei = htons(nsvc->nsei); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -416,7 +416,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); bvci = htons(bvci); @@ -469,7 +469,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -497,7 +497,7 @@ */ int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -510,7 +510,7 @@ */ int gprs_ns_tx_alive(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -523,7 +523,7 @@ */ int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc) { - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -548,7 +548,7 @@ enum ns_timeout tout = timer_mode_tout[mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, mode), seconds); @@ -576,7 +576,7 @@ enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode), seconds); @@ -638,7 +638,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci, nsei; - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -692,7 +692,7 @@ msgb_free(msg); return rc; } - log_set_context(GPRS_CTX_NSVC, nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, nsvc); msg->l2h = msgb_push(msg, sizeof(*nsh) + 3); nsh = (struct gprs_ns_hdr *) msg->l2h; @@ -1099,7 +1099,7 @@ struct gprs_nsvc *fallback_nsvc; fallback_nsvc = nsi->unknown_nsvc; - log_set_context(GPRS_CTX_NSVC, fallback_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); fallback_nsvc->ip.bts_addr = *saddr; fallback_nsvc->ll = ll; @@ -1215,7 +1215,7 @@ /* Only the RESET procedure creates a new NSVC */ if (nsh->pdu_type != NS_PDUT_RESET) { /* Since we have no NSVC, we have to use a fake */ - log_set_context(GPRS_CTX_NSVC, fallback_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x " "from %s for non-existing NS-VC\n", nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc)); @@ -1256,7 +1256,7 @@ if (!existing_nsvc) { *new_nsvc = gprs_nsvc_create(nsi, 0xffff); (*new_nsvc)->nsvci_is_valid = 0; - log_set_context(GPRS_CTX_NSVC, *new_nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc); gprs_ns_ll_copy(*new_nsvc, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n", gprs_ns_ll_str(fallback_nsvc)); @@ -1299,7 +1299,7 @@ msgb_nsei(msg) = (*nsvc)->nsei; - log_set_context(GPRS_CTX_NSVC, *nsvc); + log_set_context(LOGGING_CTX_GB_NSVC, *nsvc); /* Increment number of Incoming bytes */ rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]); diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index ee305ba..2026c7a 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -61,11 +61,11 @@ struct gprs_nsvc *nsvc) { if (nsvc) { - target->filter_map |= (1 << FLT_NSVC); - target->filter_data[FLT_NSVC] = nsvc; - } else if (target->filter_data[FLT_NSVC]) { - target->filter_map = ~(1 << FLT_NSVC); - target->filter_data[FLT_NSVC] = NULL; + target->filter_map |= (1 << LOGGING_FILTER_GB_NSVC); + target->filter_data[LOGGING_FILTER_GB_NSVC] = nsvc; + } else if (target->filter_data[LOGGING_FILTER_GB_NSVC]) { + target->filter_map = ~(1 << LOGGING_FILTER_GB_NSVC); + target->filter_data[LOGGING_FILTER_GB_NSVC] = NULL; } } diff --git a/src/logging.c b/src/logging.c index 9b7d6f4..b09d684 100644 --- a/src/logging.c +++ b/src/logging.c @@ -48,6 +48,13 @@ #include /* for LOGGING_STR. */ +osmo_static_assert(_LOGGING_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), + enum_logging_ctx_items_fit_in_struct_log_context); +osmo_static_assert(_LOGGING_FILTER_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), + enum_logging_filters_fit_in_log_target_filter_data); +osmo_static_assert(_LOGGING_FILTER_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), + enum_logging_filters_fit_in_log_target_filter_map); + struct log_info *osmo_log_info; static struct log_context log_context; @@ -374,7 +381,7 @@ /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ - if ((tar->filter_map & LOG_FILTER_ALL) != 0) + if ((tar->filter_map & (1 << LOGGING_FILTER_ALL)) != 0) return 1; if (osmo_log_info->filter_fn) @@ -492,20 +499,20 @@ return 0; } -/*! \brief Enable the \ref LOG_FILTER_ALL log filter +/*! \brief Enable the \ref LOGGING_FILTER_ALL log filter * \param[in] target Log target to be affected * \param[in] all enable (1) or disable (0) the ALL filter * - * When the \ref LOG_FILTER_ALL filter is enabled, all log messages will - * be printed. It acts as a wildcard. Setting it to \a 1 means there - * is no filtering. + * When the \ref LOGGING_FILTER_ALL filter is enabled, all log messages will be + * printed. It acts as a wildcard. Setting it to \a 1 means there is no + * filtering. */ void log_set_all_filter(struct log_target *target, int all) { if (all) - target->filter_map |= LOG_FILTER_ALL; + target->filter_map |= (1 << LOGGING_FILTER_ALL); else - target->filter_map &= ~LOG_FILTER_ALL; + target->filter_map &= ~(1 << LOGGING_FILTER_ALL); } /*! \brief Enable or disable the use of colored output diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 6004c47..30ee455 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -287,7 +287,7 @@ } vty_out(vty, " Log Filter 'ALL': %s%s", - tgt->filter_map & LOG_FILTER_ALL ? "Enabled" : "Disabled", + tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? "Enabled" : "Disabled", VTY_NEWLINE); /* print application specific filters */ @@ -687,7 +687,7 @@ } vty_out(vty, " logging filter all %u%s", - tgt->filter_map & LOG_FILTER_ALL ? 1 : 0, VTY_NEWLINE); + tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? 1 : 0, VTY_NEWLINE); /* save filters outside of libosmocore, i.e. in app code */ if (osmo_log_info->save_fn) osmo_log_info->save_fn(vty, osmo_log_info, tgt); -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 16:16:53 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 16:16:53 +0000 Subject: libosmocore[master]: logging: centrally define ctx and filter indexes In-Reply-To: References: Message-ID: Patch Set 3: ah, there was still the open question about the shorter name; saw the +2 and hit submit, sorry. -- To view, visit https://gerrit.osmocom.org/1844 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I5c343630020f4b108099696fd96c2111614c8067 Gerrit-PatchSet: 3 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 16:26:58 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 16:26:58 +0000 Subject: osmo-pcu[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 verified locally, submit fast to avoid breaking builds -- To view, visit https://gerrit.osmocom.org/1847 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Wed Feb 22 16:27:25 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 16:27:25 +0000 Subject: [MERGED] osmo-pcu[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: logging: use central filter and ctx consts from libosmocore ...................................................................... logging: use central filter and ctx consts from libosmocore Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 --- M src/gprs_bssgp_pcu.cpp M src/gprs_debug.cpp M src/gprs_debug.h 3 files changed, 7 insertions(+), 28 deletions(-) Approvals: Neels Hofmeyr: Verified Harald Welte: Looks good to me, approved Objections: Jenkins Builder: Fails diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index da1d26c..f07b3a6 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -365,7 +365,7 @@ if (bctx) { - log_set_context(BSC_CTX_BVC, bctx); + log_set_context(LOGGING_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); } diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp index 3d9b816..6bb35ea 100644 --- a/src/gprs_debug.cpp +++ b/src/gprs_debug.cpp @@ -46,27 +46,20 @@ {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, }; -enum { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_IMSI = 1, - FLT_NSVC = 2, - FLT_BVC = 3, -}; - static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[BSC_CTX_NSVC]; - const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[BSC_CTX_BVC]; + const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the BVC */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; diff --git a/src/gprs_debug.h b/src/gprs_debug.h index 963d841..817c41e 100644 --- a/src/gprs_debug.h +++ b/src/gprs_debug.h @@ -45,20 +45,6 @@ aDebug_LastEntry }; -/* context */ -#define BSC_CTX_SUBSCR 1 -#define BSC_CTX_NSVC 4 -#define BSC_CTX_BVC 5 - -/* target */ - -enum { - //DEBUG_FILTER_ALL = 1 << 0, - LOG_FILTER_IMSI = 1 << 1, - LOG_FILTER_NSVC = 1 << 2, - LOG_FILTER_BVC = 1 << 3, -}; - /* we don't need a header dependency for this... */ struct gprs_nsvc; -- To view, visit https://gerrit.osmocom.org/1847 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Wed Feb 22 16:28:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 16:28:01 +0000 Subject: [MERGED] openbsc[master]: logging: use central filter and ctx consts from libosmocore In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: logging: use central filter and ctx consts from libosmocore ...................................................................... logging: use central filter and ctx consts from libosmocore The LCHAN and BTS filter contexts are actually never used, so drop them until someone adds them properly. For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to _BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct gsm_subscriber will be replaced by vlr_subscriber so that the names will match. Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b --- M openbsc/include/openbsc/debug.h M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/e1_config.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/smpp_openbsc.c 7 files changed, 32 insertions(+), 55 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index ca3d4ad..ca00fe9 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -41,21 +41,6 @@ Debug_LastEntry, }; -/* context */ -#define BSC_CTX_LCHAN 0 -#define BSC_CTX_SUBSCR 1 -#define BSC_CTX_BTS 2 -#define BSC_CTX_SCCP 3 - -/* target */ - -enum { - //DEBUG_FILTER_ALL = 1 << 0, - LOG_FILTER_IMSI = 1 << 1, - LOG_FILTER_NSVC = 1 << 2, - LOG_FILTER_BVC = 1 << 3, -}; - /* we don't need a header dependency for this... */ struct gprs_nsvc; struct bssgp_bvc_ctx; diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 541a86d..58fdaa3 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -158,9 +158,8 @@ LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n", gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr); - log_set_context(BSC_CTX_LCHAN, lchan); if (lchan->conn) - log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, lchan->conn->subscr); return lchan; } diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c index f1962c7..8910d21 100644 --- a/openbsc/src/libbsc/e1_config.c +++ b/openbsc/src/libbsc/e1_config.c @@ -134,7 +134,6 @@ struct e1inp_sign_link *link = msg->dst; struct gsm_bts *bts; - log_set_context(BSC_CTX_BTS, link->trx->bts); switch (link->type) { case E1INP_SIGN_OML: bts = link->trx->bts; diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 8c30637..816d7a6 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -77,7 +77,7 @@ if (!bts->oml_link) return; - log_set_context(BSC_CTX_SUBSCR, request->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, @@ -91,7 +91,7 @@ page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(request->subscr->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(BSC_CTX_SUBSCR, NULL); + log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -255,7 +255,7 @@ gsm_cbfn *cbfn; int msg; - log_set_context(BSC_CTX_SUBSCR, req->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", req, req->subscr->imsi); @@ -394,7 +394,7 @@ { struct gsm_bts *bts; - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); /* Stop this first and dispatch the request */ if (_bts) diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index cf5beeb..51fbb93 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -177,32 +177,25 @@ }, }; -enum log_filter { - _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */ - FLT_IMSI = 1, - FLT_NSVC = 2, - FLT_BVC = 3, -}; - static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - struct gsm_subscriber *subscr = ctx->ctx[BSC_CTX_SUBSCR]; - const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC]; - const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC]; + const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; - if ((tar->filter_map & (1 << FLT_IMSI)) != 0 - && subscr && subscr == tar->filter_data[FLT_IMSI]) + if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0 + && subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[FLT_NSVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << FLT_BVC)) != 0 - && bvc && (bvc == tar->filter_data[FLT_BVC])) + if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) return 1; return 0; @@ -216,16 +209,17 @@ void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) { + struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; + /* free the old data */ - if (target->filter_data[FLT_IMSI]) { - subscr_put(target->filter_data[FLT_IMSI]); - target->filter_data[FLT_IMSI] = NULL; + if (*fsub) { + subscr_put(*fsub); + *fsub = NULL; } if (subscr) { - target->filter_map |= (1 << FLT_IMSI); - target->filter_data[FLT_IMSI] = subscr_get(subscr); - } else { - target->filter_map &= ~(1 << FLT_IMSI); - } + target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR); + *fsub = subscr_get(subscr); + } else + target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1a64731..10e2b31 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1457,7 +1457,7 @@ /* FIXME: request id? close channel? */ return -EINVAL; } - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1982,7 +1982,7 @@ return -EIO; /* Which subscriber do we want to track trans1 or trans2? */ - log_set_context(BSC_CTX_SUBSCR, trans1->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans1->subscr); /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); @@ -2003,7 +2003,7 @@ if (!trans->conn) return 0; - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); lchan = trans->conn->lchan; bts = lchan->ts->trx->bts; @@ -3339,7 +3339,7 @@ mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n"); mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); @@ -3395,7 +3395,7 @@ mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n"); mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); @@ -3572,7 +3572,7 @@ LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n"); return -EIO; } - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n"); return 0; @@ -3646,7 +3646,7 @@ data->imsi); /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); /* If subscriber is not found */ if (!subscr) { @@ -3724,7 +3724,7 @@ subscr_put(subscr); } else { /* update the subscriber we deal with */ - log_set_context(BSC_CTX_SUBSCR, trans->subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); } if (trans->conn) diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index 657272e..fdafa16 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -67,7 +67,7 @@ } /* tag the context in case we know it */ - log_set_context(BSC_CTX_SUBSCR, subscr); + log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); return subscr; } -- To view, visit https://gerrit.osmocom.org/1845 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Wed Feb 22 17:49:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Wed, 22 Feb 2017 17:49:18 +0000 Subject: [MERGED] osmo-pcu[master]: gprs_debug.h: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: gprs_debug.h: remove unused cruft / cosmetic tweaks ...................................................................... gprs_debug.h: remove unused cruft / cosmetic tweaks Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 --- M src/gprs_debug.h 1 file changed, 3 insertions(+), 18 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gprs_debug.h b/src/gprs_debug.h index 817c41e..863d76b 100644 --- a/src/gprs_debug.h +++ b/src/gprs_debug.h @@ -16,9 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef GPRS_DEBUG_H -#define GPRS_DEBUG_H + +#pragma once #include #ifdef __cplusplus @@ -29,6 +28,7 @@ #ifdef __cplusplus }; #endif + /* Debug Areas of the code */ enum { DCSN1, @@ -45,19 +45,4 @@ aDebug_LastEntry }; -/* we don't need a header dependency for this... */ - -struct gprs_nsvc; -struct bssgp_bvc_ctx; - -void log_set_imsi_filter(struct log_target *target, const char *imsi); -void log_set_nsvc_filter(struct log_target *target, - struct gprs_nsvc *nsvc); -void log_set_bvc_filter(struct log_target *target, - struct bssgp_bvc_ctx *bctx); - extern const struct log_info gprs_log_info; - - - -#endif // GPRS_DEBUG_H -- To view, visit https://gerrit.osmocom.org/1848 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ied1ffc320332a605b140d23910eb0a13ef9a7a75 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 00:48:52 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 00:48:52 +0000 Subject: [MERGED] openbsc[master]: debug.h/c: remove unused cruft / cosmetic tweaks In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: debug.h/c: remove unused cruft / cosmetic tweaks ...................................................................... debug.h/c: remove unused cruft / cosmetic tweaks Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9 --- M openbsc/include/openbsc/debug.h M openbsc/src/libcommon/debug.c 2 files changed, 2 insertions(+), 13 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index ca00fe9..6300020 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -1,5 +1,4 @@ -#ifndef _DEBUG_H -#define _DEBUG_H +#pragma once #include #include @@ -41,17 +40,8 @@ Debug_LastEntry, }; -/* we don't need a header dependency for this... */ -struct gprs_nsvc; -struct bssgp_bvc_ctx; struct gsm_subscriber; void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr); -void log_set_nsvc_filter(struct log_target *target, - struct gprs_nsvc *nsvc); -void log_set_bvc_filter(struct log_target *target, - struct bssgp_bvc_ctx *bctx); extern const struct log_info log_info; - -#endif /* _DEBUG_H */ diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 51fbb93..3f3232c 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -177,8 +177,7 @@ }, }; -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) +static int filter_fn(const struct log_context *ctx, struct log_target *tar) { const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; -- To view, visit https://gerrit.osmocom.org/1846 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9 Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 02:40:24 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 02:40:24 +0000 Subject: [PATCH] libosmocore[master]: gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1859 to look at the new patch set (#2). gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr MSCR and CBQ3 are Release 1999 additions to the Control Channel Description IE of SI3. Assuming that no-one is using the spare bits, this will not cause any code conflicts. In the R99 struct, spare1 and spare2 are in different places, so rather rename them to spare_1 and spare_2 to make sure we get a compiler barf *if* anyone tries to use them with the wrong structure. Adjust the spec reference to TS 44.018; TS 04.08 Figure 10.5.33 is replaced by TS 44.018 Figure 10.5.2.11.1 which is right there in the named Section 10.5.2.11, so drop the explicit reference. Motivation: the R99 Control Channel Description defines MSCR to indicate whether the MSC is R99+ or not. To use UMTS AKA on GSM networks, we want to indicate that our libmsc is capable of R99, like OsmoSGSN already does. CBQ3 is merely added for completeness, no particular use case in mind. Related: OS#1593 Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 --- M include/osmocom/gsm/protocol/gsm_04_08.h 1 file changed, 5 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/1859/2 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index bbc2774..da17755 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -618,14 +618,16 @@ acs:1; } __attribute__ ((packed)); -/* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */ +/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */ struct gsm48_control_channel_descr { uint8_t ccch_conf :3, bs_ag_blks_res :3, att :1, - spare1 :1; + mscr :1; uint8_t bs_pa_mfrms : 3, - spare2 :5; + spare_1 :2, + cbq3 :2, + spare_2 :1; uint8_t t3212; } __attribute__ ((packed)); -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 13:11:45 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 13:11:45 +0000 Subject: [PATCH] openbsc[master]: Add simple CTRL2SOAP proxy Message-ID: Review at https://gerrit.osmocom.org/1875 Add simple CTRL2SOAP proxy Add python client which converts TRAP messages into SOAP requests and perform corresponding actions. It can be used as follows ./soap.py -d -w http://example.com/soapservice/htdocs/wsdl/test.wsdl -l 'http://localhost:8000/soapservice/SoapServer.php' In this case the location of SOAP server from test.wsdl is ignored and requests are dospatched to localhost instead. See ./soap.py -h for additional options. Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Related: SYS#3028 --- A openbsc/contrib/soap.py 1 file changed, 140 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/75/1875/1 diff --git a/openbsc/contrib/soap.py b/openbsc/contrib/soap.py new file mode 100755 index 0000000..19b4fe5 --- /dev/null +++ b/openbsc/contrib/soap.py @@ -0,0 +1,140 @@ +#!/usr/bin/python3 +# -*- mode: python-mode; py-indent-tabs-mode: nil -*- +""" +/* + * 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. + */ +""" + +from twisted.internet import reactor +from twisted_ipa import CTRL, IPAFactory +from ipa import Ctrl +from treq import post, collect +from suds.client import Client +from suds.plugin import MessagePlugin +from functools import partial +import argparse, logging, datetime + +# keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific +oper = { 'inoperational' : 0, 'operational' : 1 } +admin = { 'locked' : 0, 'unlocked' : 1 } +policy = { 'off' : 0, 'on' : 1, 'grace' : 2, 'unknown' : 3 } +# keys from OpenBSC openbsc/src/libbsc/bsc_vty.c +fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 3 } + +class Trap(CTRL): + """ + TRAP handler (agnostic to client object) + """ + def ctrl_TRAP(self, data, op_id, v): + """ + Parse CTRL TRAP and dispatch to appropriate handler after normalization + """ + (l, r) = v.split() + loc = l.split('.') + t_type = loc[-1] + p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse helper + method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: "Unhandled %s trap" % t_type) + method(p(1), p(3), p(5), p(7), r) # we expect net.0.bsc.666.bts.2.trx.1 format for trap prefix + + def handle_locationstate(self, net, bsc, bts, trx, data): + """ + Handle location-state TRAP: parse trap content, build SOAP context and use treq's routines to post it while setting up async handlers + """ + def cback(c, r): + """ + Callback function: takes c (SOAP client's RequestContext) and server's reply, sends set of parsed ctrl commands (in a 'fire and forget' way) + """ + def commands(c, f): + """ + Process OpenBscCommands format from .wsdl + """ + for t in c: + (_, m) = Ctrl().cmd(*t.split()) + f(m) + def keyvals(k, f): + """ + Process OpenBscKeyVal format from .wsdl + """ + for _, m in list(map(lambda x, y: Ctrl().cmd(x.rstrip(), y), k[0].key, k[0].value)): + f(m) + # The 2 options below are mutually exclusive as the information in the reply is duplicated: + commands(c.process_reply(r).commands, self.transport.write) + #keyvals(c.process_reply(r).keysvals, self.transport.write) + (ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',') + tstamp = datetime.datetime.fromtimestamp(float(ts)).strftime('%Y-%m-%d') + self.dbg('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' % (net, bsc, bts, trx, tstamp, mcc, mnc, data)) + ctx = self.factory.soap.service.registerOpenBscLocationAclSupport(bsc, float(lon), float(lat), fix.get(fx, 0), tstamp, oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3)) + handler = partial(cback, ctx) # make closure with context by partial parameter application + post(self.factory.location, ctx.envelope).addCallback(collect, handler) # treq's collect helper is handy to get all reply content at once + + def handle_notificationrejectionv1(self, net, bsc, bts, trx, data): + """ + Handle notification-rejection-v1 TRAP + """ + self.dbg('notification-rejection-v1 at bsc-id %s => %s' % (bsc, data)) + + +class Filter(MessagePlugin): + """ + Workarounds for broken .php SOAP server + """ + def received(self, c): + c.reply = c.reply.replace(b'xsd:OpenBscCommands', b'ns1:OpenBscCommands') + c.reply = c.reply.replace(b'xsd:OpenBscKeyVal', b'ns1:OpenBscKeyVal') + c.reply = c.reply.replace(b'', b'') + c.reply = c.reply.replace(b'value>', b'value>') + c.reply = c.reply.replace(b'item', b'command') + + +class TrapFactory(IPAFactory): + """ + Store SOAP client object so TRAP handler can use it for requests + """ + location = None + soap = None + def __init__(self, proto=None, debug=False, wsdl=None, location=None): + self.location = location.encode() + self.soap = Client(wsdl, location=location, nosend=True, plugins=[Filter()]) # make async SOAP client + if debug: + print(self.soap) + super(TrapFactory, self).__init__(proto, debug) + + +if __name__ == '__main__': + p = argparse.ArgumentParser("SOAP-CTRL proxy") + p.add_argument('-v', '--version', action='version', version='%(prog)s v0.1') + p.add_argument('-p', '--port', type=int, default=4250, help="Port to use for CTRL interface, defaults to 4250") + p.add_argument('-c', '--ctrl', default='localhost', help="Adress to use for CTRL interface, defaults to localhost") + p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP") + p.add_argument('-s', '--size', type=int, default=5, help="Size of thread pool") + p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") + p.add_argument('-l', '--location', help="Override location found in WSDL file") + args = p.parse_args() + + logging.basicConfig(level=logging.ERROR) + if args.debug: + logging.getLogger('suds.client').setLevel(logging.DEBUG) + logging.getLogger('suds.transport').setLevel(logging.DEBUG) + logging.getLogger('suds.xsd').setLevel(logging.DEBUG) + logging.getLogger('suds.umx').setLevel(logging.DEBUG) + + reactor.suggestThreadPoolSize(args.size) + reactor.connectTCP(args.ctrl, args.port, TrapFactory(Trap, args.debug, args.wsdl, args.location)) + reactor.run() -- To view, visit https://gerrit.osmocom.org/1875 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 13:57:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 13:57:20 +0000 Subject: libosmocore[master]: gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 > > I'm not sure if it is worth keeping around the old r98 data > > structure under a separate name. nobody can so far be using it, > as > > the name with r98 suffix is new. What's the rationale to keep > it? > > I was trying to follow the _r98 / _r99 pattern seen further below > in the file. Besides the spare bits distribution, there are no > changes in r99, only additions, but I assume we would like to > reflect which is present in which revision. I think in case there are only additions, there's no need for an additional data type. one can just put a comment there indicating the release of the specs introducing the element, if needed. -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 13:58:21 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 13:58:21 +0000 Subject: libosmo-sccp[master]: xua_msg: Add xua_msg_dump() to print parsed XUA message In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1831/1/src/xua_msg.c File src/xua_msg.c: Line 315: append_to_buf(buf, NULL, "\n\tPART(T=0x%04x,L=%u,D=%s)", on seecond thought, introducing newlines in the log was useful during debugging, but I'm not sure if we should put this in master. -- To view, visit https://gerrit.osmocom.org/1831 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2f3ae77f440e0c27f78302cdb80e1d25fe5aebb6 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:00:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:00:53 +0000 Subject: osmo-pcu[master]: BTS: Convert relative frame numbers to absolute frame numbers In-Reply-To: References: Message-ID: Patch Set 4: (1 comment) https://gerrit.osmocom.org/#/c/1861/4/src/bts.cpp File src/bts.cpp: Line 547: if (m_cur_fn - m_cur_rfn < 0) { is there a test case testing this, as I requested? I'm just wondering because subtracting two unsigned integers from each other should never be below zero, as far as I can tell. You can avoid signed arithmetic by stating "if (m_cur_rfn < m_cur_fn)" - but the test case should have pointed this out. Doesn't even the compiler warn about dead code in case of a check for an unsigned integer < 0? -- To view, visit https://gerrit.osmocom.org/1861 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759 Gerrit-PatchSet: 4 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:01:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:01:18 +0000 Subject: [MERGED] osmo-bts[master]: octphy: Fix VTY commands In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: octphy: Fix VTY commands ...................................................................... octphy: Fix VTY commands The VTY commands show phy 0 rf-port-stats and show phy 0 clk-sync-stats do not output their results on the VTY console. If one of those commands is entered the user is prompted to view the logtext, which is an uncomfortable solution. This commit adds the missing functionality to print the information in the VTY as well. octphy_hw_api.c contains two value_string structs (radio_std_vals and clocksync_state_vals) which are now exported in octphy_hw_api.h in order to access them from octphy_vty.c Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 --- M src/osmo-bts-octphy/octphy_hw_api.c M src/osmo-bts-octphy/octphy_hw_api.h M src/osmo-bts-octphy/octphy_vty.c 3 files changed, 139 insertions(+), 45 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c index dc23676..6666f77 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.c +++ b/src/osmo-bts-octphy/octphy_hw_api.c @@ -29,6 +29,7 @@ #include "l1_if.h" #include "l1_oml.h" #include "l1_utils.h" +#include "octphy_hw_api.h" #include #include @@ -105,18 +106,12 @@ return l1if_req_compl(fl1h, msg, rf_port_info_compl_cb, NULL); } -static const struct value_string radio_std_vals[] = { - { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, - { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, - { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, - { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, - { 0, NULL } -}; - /* Chapter 12.10 */ static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h; @@ -136,12 +131,16 @@ psr->TxStats.ulTxAveragePeriodUs, psr->TxStats.ulFrequencyKhz); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.10 */ -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index) +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_RF_PORT_STATS_CMD *psc; @@ -156,7 +155,7 @@ mOCTVC1_HW_MSG_RF_PORT_STATS_CMD_SWAP(psc); - return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, NULL); + return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, cb_data); } static const struct value_string rx_gain_mode_vals[] = { @@ -276,28 +275,6 @@ { 0, NULL } }; -static const struct value_string clocksync_state_vals[] = { - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, - "Uninitialized" }, -/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to - * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef - * statement ensures that older headers still work. */ -#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, -#else - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, -#endif - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, - "No External Clock" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, - { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, - "Loss of Ext Clock" }, - { 0, NULL } -}; - /* Chapter 12.15 */ static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) @@ -336,6 +313,8 @@ static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp, void *data) { + struct octphy_hw_get_cb_data *get_cb_data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) resp->l2h; @@ -349,12 +328,16 @@ csr->ulPllFractionalFreqHz, csr->ulSlipCnt, csr->ulSyncLosseCnt, csr->ulSourceState, csr->ulDacValue); + get_cb_data = (struct octphy_hw_get_cb_data*) data; + get_cb_data->cb(resp,get_cb_data->data); + msgb_free(resp); return 0; } /* Chapter 12.16 */ -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h) +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data) { struct msgb *msg = l1p_msgb_alloc(); tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD *csc; @@ -366,6 +349,6 @@ mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD_SWAP(csc); - return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, NULL); + return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, cb_data); } diff --git a/src/osmo-bts-octphy/octphy_hw_api.h b/src/osmo-bts-octphy/octphy_hw_api.h index bc8ab68..78b7208 100644 --- a/src/osmo-bts-octphy/octphy_hw_api.h +++ b/src/osmo-bts-octphy/octphy_hw_api.h @@ -2,13 +2,53 @@ #include #include "l1_if.h" +#include + +static const struct value_string radio_std_vals[] = { + { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" }, + { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" }, + { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" }, + { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" }, + { 0, NULL } +}; + +static const struct value_string clocksync_state_vals[] = { + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE, + "Uninitialized" }, +/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to + * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef + * statement ensures that older headers still work. */ +#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" }, +#else + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" }, +#endif + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK, + "No External Clock" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" }, + { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK, + "Loss of Ext Clock" }, + { 0, NULL } +}; + +typedef void octphy_hw_get_cb(struct msgb *resp, void *data); + +struct octphy_hw_get_cb_data { + octphy_hw_get_cb* cb; + void *data; +}; int octphy_hw_get_pcb_info(struct octphy_hdl *fl1h); int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index); -int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index); +int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index, + struct octphy_hw_get_cb_data *cb_data); int octphy_hw_get_rf_ant_rx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_rf_ant_tx_config(struct octphy_hdl *fl1h, uint32_t port_idx, uint32_t ant_idx); int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h); -int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h); +int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h, + struct octphy_hw_get_cb_data *cb_data); diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c index abfac1e..bc4acd6 100644 --- a/src/osmo-bts-octphy/octphy_vty.c +++ b/src/osmo-bts-octphy/octphy_vty.c @@ -159,6 +159,45 @@ return CMD_SUCCESS; } +void show_rf_port_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr; + + if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) { + vty_out(vty, + "invalid msgb size (%d bytes, expected %zu bytes)%s", + msgb_l2len(resp), + sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP), VTY_NEWLINE); + return; + } + + psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "RF-PORT-STATS:%s", VTY_NEWLINE); + vty_out(vty, "Idx=%d%s", psr->ulPortIndex, VTY_NEWLINE); + vty_out(vty, "RadioStandard=%s%s", + get_value_string(radio_std_vals, psr->ulRadioStandard), + VTY_NEWLINE); + vty_out(vty, "Rx Bytes=%u%s", psr->RxStats.ulRxByteCnt, VTY_NEWLINE); + vty_out(vty, "Rx Overflow=%u%s", psr->RxStats.ulRxOverflowCnt, + VTY_NEWLINE); + vty_out(vty, "Rx AvgBps=%u%s", psr->RxStats.ulRxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Rx Period=%u%s", psr->RxStats.ulRxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Rx Freq=%u%s", psr->RxStats.ulFrequencyKhz, VTY_NEWLINE); + vty_out(vty, "Tx Bytes=%u%s", psr->TxStats.ulTxByteCnt, VTY_NEWLINE); + vty_out(vty, "Tx Underflow=%u%s", psr->TxStats.ulTxUnderflowCnt, + VTY_NEWLINE); + vty_out(vty, "Tx AvgBps=%u%s", psr->TxStats.ulTxAverageBytePerSecond, + VTY_NEWLINE); + vty_out(vty, "Tx Period=%u%s", psr->TxStats.ulTxAveragePeriodUs, + VTY_NEWLINE); + vty_out(vty, "Tx Freq=%u%s", psr->TxStats.ulFrequencyKhz, VTY_NEWLINE); +} + DEFUN(show_rf_port_stats, show_rf_port_stats_cmd, "show phy <0-255> rf-port-stats <0-1>", "Show statistics for the RF Port\n" @@ -166,14 +205,47 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1])); + cb_data.cb = show_rf_port_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); + octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]), + &cb_data); return CMD_SUCCESS; +} + +void show_clk_sync_stats_cb(struct msgb *resp, void *data) +{ + struct vty *vty = (struct vty*) data; + tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr; + + if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) != + msgb_l2len(resp)) { + vty_out(vty, + "invalid msgb size (%d bytes, expected %zu bytes)%s", + msgb_l2len(resp), + sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP), + VTY_NEWLINE); + return; + } + + csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) msgb_l2(resp); + + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "CLOCK-SYNC-MGR-STATS:%s", VTY_NEWLINE); + vty_out(vty, "State=%s%s", + get_value_string(clocksync_state_vals, csr->ulState), + VTY_NEWLINE); + vty_out(vty, "ClockError=%d%s", csr->lClockError, VTY_NEWLINE); + vty_out(vty, "DroppedCycles=%d%s", csr->lDroppedCycles, VTY_NEWLINE); + vty_out(vty, "PllFreqHz=%u%s", csr->ulPllFreqHz, VTY_NEWLINE); + vty_out(vty, "PllFract=%u%s", csr->ulPllFractionalFreqHz, VTY_NEWLINE); + vty_out(vty, "SlipCnt=%u%s", csr->ulSlipCnt, VTY_NEWLINE); + vty_out(vty, "SyncLosses=%u%s", csr->ulSyncLosseCnt, VTY_NEWLINE); + vty_out(vty, "SourceState=%u%s", csr->ulSourceState, VTY_NEWLINE); + vty_out(vty, "DacValue=%u%s", csr->ulDacValue, VTY_NEWLINE); } DEFUN(show_clk_sync_stats, show_clk_sync_stats_cmd, @@ -182,13 +254,12 @@ { int phy_nr = atoi(argv[0]); struct phy_link *plink = phy_link_by_num(phy_nr); + static struct octphy_hw_get_cb_data cb_data; - octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl); + cb_data.cb = show_clk_sync_stats_cb; + cb_data.data = vty; - /* FIXME: Actually print to VTY, not just log */ - vty_out(vty, "Please check the log file for the response%s", - VTY_NEWLINE); - + octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl, &cb_data); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/1711 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61 Gerrit-PatchSet: 6 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:01:27 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:01:27 +0000 Subject: [MERGED] libosmocore[master]: gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr ...................................................................... gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr MSCR and CBQ3 are Release 1999 additions to the Control Channel Description IE of SI3. Assuming that no-one is using the spare bits, this will not cause any code conflicts. In the R99 struct, spare1 and spare2 are in different places, so rather rename them to spare_1 and spare_2 to make sure we get a compiler barf *if* anyone tries to use them with the wrong structure. Adjust the spec reference to TS 44.018; TS 04.08 Figure 10.5.33 is replaced by TS 44.018 Figure 10.5.2.11.1 which is right there in the named Section 10.5.2.11, so drop the explicit reference. Motivation: the R99 Control Channel Description defines MSCR to indicate whether the MSC is R99+ or not. To use UMTS AKA on GSM networks, we want to indicate that our libmsc is capable of R99, like OsmoSGSN already does. CBQ3 is merely added for completeness, no particular use case in mind. Related: OS#1593 Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 --- M include/osmocom/gsm/protocol/gsm_04_08.h 1 file changed, 5 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index bbc2774..da17755 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -618,14 +618,16 @@ acs:1; } __attribute__ ((packed)); -/* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */ +/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */ struct gsm48_control_channel_descr { uint8_t ccch_conf :3, bs_ag_blks_res :3, att :1, - spare1 :1; + mscr :1; uint8_t bs_pa_mfrms : 3, - spare2 :5; + spare_1 :2, + cbq3 :2, + spare_2 :1; uint8_t t3212; } __attribute__ ((packed)); -- To view, visit https://gerrit.osmocom.org/1859 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:04:54 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:04:54 +0000 Subject: openbsc[master]: Trigger Deactivate PDP context Request from SGSN VTY In-Reply-To: References: Message-ID: Patch Set 3: I would appreciate Max' feedback on this, to make sure it shares the same code path/mechanism as the GSUP based 'subscriber looses right to access GPRS' functionality. -- To view, visit https://gerrit.osmocom.org/1263 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ide0cd4af828b753d24d2e507967d1c2e652ee05e Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: pravin Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:05:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:05:02 +0000 Subject: openbsc[master]: Trigger Deactivate PDP context Request from SGSN VTY In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1263 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ide0cd4af828b753d24d2e507967d1c2e652ee05e Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: pravin Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:16:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:16:41 +0000 Subject: osmo-hlr[master]: cosmetic: refactor auc_compute_vectors(), add debug log In-Reply-To: References: Message-ID: Patch Set 1: > (1 comment) > > > I understand the need for debug logging during development, but I > > think for normla use this is rather on the excessive side, > > which is why I added the local flag that pre-fetches whether debug > logging is enabled, so that we basically just have a dozen "if (0)" > in case debug logging is off. Is that not sufficient? No. I think "DEBUG" should be for debugging of issues in production, not for debugging issues during initial development of the code. I think it is highly unlikely that anyone would want to see all the nitty-gritty details of the calculation in production use. I think this level of detail goes much beyond the usual level of detail we have with LOGL_DEBUG in other code. But then, maybe my feeling is wrong here? -- To view, visit https://gerrit.osmocom.org/1869 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 14:20:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 14:20:17 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: yes, I was thinking of value printing only on error. But then, printing at that time will encounter the same problems about "what kind of value/type are we printing here" that you described. This could probably be worked around by passing along a format string? like int a, b OSMO_ASSERT(a, =, b, "%d") -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 16:11:12 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 16:11:12 +0000 Subject: openbsc[master]: Trigger Deactivate PDP context Request from SGSN VTY In-Reply-To: References: Message-ID: Patch Set 4: Code-Review-1 It's plain broken: drop_gmm_ctx_for_ms() is used but nowhere to be found. -- To view, visit https://gerrit.osmocom.org/1263 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ide0cd4af828b753d24d2e507967d1c2e652ee05e Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: pravin Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 16:20:08 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 16:20:08 +0000 Subject: [PATCH] libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1629 to look at the new patch set (#5). Expand and expose ctrl connection allocation Add function for allocating CTRL connection to public headers and replace call to previous static function with it. Add doxygen docs for this function. It's useful if we need to allocate ctrl connection but don't need to bind to any interfaces: when we act as ctrl client. Related: OS#1615 Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 --- M include/osmocom/ctrl/control_if.h M src/ctrl/control_if.c 2 files changed, 52 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/1629/5 diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h index 512ae10..f2af1db 100644 --- a/include/osmocom/ctrl/control_if.h +++ b/include/osmocom/ctrl/control_if.h @@ -27,5 +27,5 @@ const char *bind_addr, uint16_t port, ctrl_cmd_lookup lookup); - +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data); int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data); diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index 254f9bc..cf79670 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -368,7 +368,13 @@ return rc; } -static struct ctrl_connection *ctrl_connection_alloc(void *ctx) +/*! \brief Allocate CTRL connection + * \param[in] ctx Context from which talloc should allocate it + * \param[in] data caller's private data parameter which should assigned to + write queue's file descriptor data parameter. + * \return Allocated CTRL connection structure or NULL in case of errors + */ +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data) { struct ctrl_connection *ccon = talloc_zero(ctx, struct ctrl_connection); if (!ccon) @@ -379,6 +385,9 @@ INIT_LLIST_HEAD(&ccon->cmds); INIT_LLIST_HEAD(&ccon->def_cmds); + + ccon->write_queue.bfd.data = data; + ccon->write_queue.write_cb = control_write_cb; return ccon; } @@ -412,19 +421,17 @@ return ret; } #endif - ccon = ctrl_connection_alloc(listen_bfd->data); + ctrl = listen_bfd->data; + ccon = osmo_ctrl_conn_alloc(listen_bfd->data, ctrl); if (!ccon) { LOGP(DLCTRL, LOGL_ERROR, "Failed to allocate.\n"); close(fd); return -1; } - ctrl = listen_bfd->data; - ccon->write_queue.bfd.data = ctrl; ccon->write_queue.bfd.fd = fd; ccon->write_queue.bfd.when = BSC_FD_READ; ccon->write_queue.read_cb = handle_control_read; - ccon->write_queue.write_cb = control_write_cb; ret = osmo_fd_register(&ccon->write_queue.bfd); if (ret < 0) { @@ -648,6 +655,45 @@ return 0; } +/*! \brief Setup CTRL interface connection to a given address + * \param[in] data Pointer which will be made available to each + set_..() get_..() verify_..() control command function + * \param[in] addr Address to which we shall connect + * \param[in] port Port to which we shall connect + * \param[in] lookup Lookup function pointer, can be NULL + * \returns ctrl_handle pointer or NULL in case of errors + */ +struct ctrl_handle *ctrl_interface_connect(void *data, const char *addr, + uint16_t port, + ctrl_cmd_lookup lookup) +{ + int ret; + struct ctrl_handle *ctrl; + + ctrl = talloc_zero(data, struct ctrl_handle); + if (!ctrl) + return NULL; + + INIT_LLIST_HEAD(&ctrl->ccon_list); + + ctrl->data = data; + ctrl->lookup = lookup; + + ctrl->listen_fd.cb = NULL; + ctrl->listen_fd.data = ctrl; + ret = osmo_sock_init_ifd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, + IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT); + if (ret < 0) { + LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n", + addr, port); + talloc_free(ctrl); + return NULL; + } + LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to %s:%u\n", addr, port); + + return ctrl; +} + struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, ctrl_cmd_lookup lookup) { -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 16:24:45 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 16:24:45 +0000 Subject: [PATCH] osmo-bts[master]: Use oml-alert CTRL command for temp report In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1630 to look at the new patch set (#5). Use oml-alert CTRL command for temp report Send temperature reports via OML alert facility exposed by CTRL protocol. Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Related: OS#1615 --- M src/osmo-bts-sysmo/Makefile.am M src/osmo-bts-sysmo/misc/sysmobts_mgr.c M src/osmo-bts-sysmo/misc/sysmobts_mgr.h M src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c 4 files changed, 65 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/30/1630/5 diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am index 8e39a3a..7b27e70 100644 --- a/src/osmo-bts-sysmo/Makefile.am +++ b/src/osmo-bts-sysmo/Makefile.am @@ -29,7 +29,7 @@ misc/sysmobts_mgr_temp.c \ misc/sysmobts_mgr_calib.c \ eeprom.c -sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCTRL_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) +sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c eeprom.c sysmobts_util_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index f126db2..1136b8f 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -21,6 +21,8 @@ */ #include +#include +#include #include #include #include @@ -28,14 +30,19 @@ #include #include #include +#include +#include #include #include #include +#include #include #include #include #include +#include +#include #include "misc/sysmobts_misc.h" #include "misc/sysmobts_mgr.h" @@ -246,10 +253,12 @@ int main(int argc, char **argv) { int rc; - + struct ctrl_connection *ccon; tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager"); msgb_talloc_ctx_init(tall_mgr_ctx, 0); + + srand(time(NULL)); mgr_log_init(); if (classify_bts() != 0) @@ -294,7 +303,23 @@ exit(3); /* Initialize the temperature control */ - sysmobts_mgr_temp_init(&manager); + ccon = osmo_ctrl_conn_alloc(tall_mgr_ctx, NULL); + rc = -1; + if (ccon) { + ccon->write_queue.bfd.data = ccon; + rc = osmo_sock_init_ifd(&ccon->write_queue.bfd, AF_INET, + SOCK_STREAM, IPPROTO_TCP, + "localhost", OSMO_CTRL_PORT_BTS, + OSMO_SOCK_F_CONNECT); + } + if (rc < 0) + LOGP(DLCTRL, LOGL_ERROR, "Can't connect to CTRL @ localhost:%u\n", + OSMO_CTRL_PORT_BTS); + else + LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to locahost:%u\n", + OSMO_CTRL_PORT_BTS); + + sysmobts_mgr_temp_init(&manager, ccon); if (sysmobts_mgr_calib_init(&manager) != 0) exit(3); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h index b393c38..88f4e24 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h @@ -3,7 +3,7 @@ #include #include - +#include #include #include @@ -108,7 +108,8 @@ int sysmobts_mgr_vty_init(void); int sysmobts_mgr_parse_config(struct sysmobts_mgr_instance *mgr); int sysmobts_mgr_nl_init(void); -int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr); +int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr, + struct ctrl_connection *ctrl); const char *sysmobts_mgr_temp_get_state(enum sysmobts_temp_state state); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c index 34af2ab..2a15d2e 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c @@ -28,6 +28,8 @@ #include #include +#include + static struct sysmobts_mgr_instance *s_mgr; static struct osmo_timer_list temp_ctrl_timer; @@ -185,13 +187,24 @@ } static void sysmobts_mgr_temp_handle(struct sysmobts_mgr_instance *manager, - int critical, int warning) + struct ctrl_connection *ctrl, int critical, + int warning) { - int new_state = next_state(manager->state, critical, warning); + int new_state = next_state(manager->state, critical, warning), rc; + struct ctrl_cmd *rep; + bool send = false; /* Nothing changed */ if (new_state < 0) return; + + rep = ctrl_cmd_create(tall_mgr_ctx, CTRL_TYPE_SET); + if (!rep) { + LOGP(DTEMP, LOGL_ERROR, "OML alert creation failed.\n"); + } else { + rep->id = talloc_asprintf(rep, "%d", rand()); + rep->variable = "oml-alert"; + } LOGP(DTEMP, LOGL_NOTICE, "Moving from state %s to %s.\n", get_value_string(state_names, manager->state), @@ -206,14 +219,24 @@ break; case STATE_WARNING: execute_warning_act(manager); + rep->value = "Temperature Warning"; + send = true; break; case STATE_CRITICAL: execute_critical_act(manager); + rep->value = "Temperature Critical"; + send = true; break; }; + + if (send) { + rc = ctrl_cmd_send(&ctrl->write_queue, rep); + LOGP(DTEMP, LOGL_ERROR, "OML alert sent: %d\n", rc); + } + talloc_free(rep); } -static void temp_ctrl_check() +static void temp_ctrl_check(struct ctrl_connection *ctrl) { int rc; int warn_thresh_passed = 0; @@ -275,20 +298,23 @@ } } - sysmobts_mgr_temp_handle(s_mgr, crit_thresh_passed, warn_thresh_passed); + sysmobts_mgr_temp_handle(s_mgr, ctrl, crit_thresh_passed, + warn_thresh_passed); } -static void temp_ctrl_check_cb(void *unused) +static void temp_ctrl_check_cb(void *ctrl) { - temp_ctrl_check(); + temp_ctrl_check(ctrl); /* Check every two minutes? XXX make it configurable! */ osmo_timer_schedule(&temp_ctrl_timer, 2 * 60, 0); } -int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr) +int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr, + struct ctrl_connection *ctrl) { s_mgr = mgr; temp_ctrl_timer.cb = temp_ctrl_check_cb; - temp_ctrl_check_cb(NULL); + temp_ctrl_timer.data = ctrl; + temp_ctrl_check_cb(ctrl); return 0; } -- To view, visit https://gerrit.osmocom.org/1630 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Gerrit-PatchSet: 5 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:12:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 17:12:42 +0000 Subject: [PATCH] libosmocore[master]: logging.h: fix backwards compat broken by recent commit Message-ID: Review at https://gerrit.osmocom.org/1876 logging.h: fix backwards compat broken by recent commit Commit 812ba6dc63a75c39678dd3fe652768e76bf63183 "logging: centrally define ctx and filter indexes" Removed definitions, which causes older e.g. openbsc and osmo-pcu code trees to fail to build against a newer libosmocore. Re-introduce the legacy definitions to redirect to the new ones and re-establish backwards compatibility. The GPRS_* constants used to be defined in gprs_msgb.h, but since that header also includes logging.h, rather place the legacy shims in logging.h next to the other ones. Change-Id: I455bb1bb474d758af0fd5b6397f7e57260ad739d --- M include/osmocom/core/logging.h 1 file changed, 7 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/1876/1 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index b3685b8..7c8a7ef 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -141,6 +141,13 @@ _LOGGING_FILTER_COUNT }; +/*! \brief Compatibility with older libosmocore versions */ +#define LOG_FILTER_ALL (1< From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:12:43 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 17:12:43 +0000 Subject: [PATCH] libosmocore[master]: logging.h: fixup: add API doc for logging enums recently added Message-ID: Review at https://gerrit.osmocom.org/1877 logging.h: fixup: add API doc for logging enums recently added Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2 --- M include/osmocom/core/logging.h 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/77/1877/1 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 7c8a7ef..c4d8006 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -124,6 +124,8 @@ void *ctx[LOG_MAX_CTX+1]; }; +/*! \brief Indexes to indicate the object currently acted upon. + * Array indexes for the global \a log_context array. */ enum logging_ctx_items { LOGGING_CTX_GB_NSVC, LOGGING_CTX_GB_BVC, @@ -132,6 +134,9 @@ _LOGGING_CTX_COUNT }; +/*! \brief Indexes to indicate objects that should be logged. + * Array indexes to log_target->filter_data and bit indexes for + * log_target->filter_map. */ enum logging_filters { LOGGING_FILTER_ALL, LOGGING_FILTER_GB_NSVC, -- To view, visit https://gerrit.osmocom.org/1877 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:12:43 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 17:12:43 +0000 Subject: [PATCH] libosmocore[master]: logging.h: fixup: shorter names for LOGGING_FILTER_* and LOG... Message-ID: Review at https://gerrit.osmocom.org/1878 logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* My recent logging patch was merged to master a bit too soon. Accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING". libosmocore will not be backwards-compatible with the few commits from change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and following commits are backwards compatible with those before that short window. See also: * openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991 * osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93 --- M include/osmocom/core/logging.h M src/gb/common_vty.c M src/gb/gprs_bssgp.c M src/gb/gprs_bssgp_vty.c M src/gb/gprs_ns.c M src/gb/gprs_ns_vty.c M src/logging.c M src/vty/logging_vty.c 8 files changed, 61 insertions(+), 59 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/1878/1 diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index c4d8006..7b28b2c 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -126,32 +126,34 @@ /*! \brief Indexes to indicate the object currently acted upon. * Array indexes for the global \a log_context array. */ -enum logging_ctx_items { - LOGGING_CTX_GB_NSVC, - LOGGING_CTX_GB_BVC, - LOGGING_CTX_BSC_SUBSCR, - LOGGING_CTX_VLR_SUBSCR, - _LOGGING_CTX_COUNT +enum log_ctx_index { + LOG_CTX_GB_NSVC, + LOG_CTX_GB_BVC, + LOG_CTX_BSC_SUBSCR, + LOG_CTX_VLR_SUBSCR, + _LOG_CTX_COUNT }; /*! \brief Indexes to indicate objects that should be logged. * Array indexes to log_target->filter_data and bit indexes for * log_target->filter_map. */ -enum logging_filters { - LOGGING_FILTER_ALL, - LOGGING_FILTER_GB_NSVC, - LOGGING_FILTER_GB_BVC, - LOGGING_FILTER_BSC_SUBSCR, - LOGGING_FILTER_VLR_SUBSCR, - _LOGGING_FILTER_COUNT +enum log_filter_index { + LOG_FLT_ALL, + LOG_FLT_GB_NSVC, + LOG_FLT_GB_BVC, + LOG_FLT_BSC_SUBSCR, + LOG_FLT_VLR_SUBSCR, + _LOG_FLT_COUNT }; /*! \brief Compatibility with older libosmocore versions */ -#define LOG_FILTER_ALL (1<ctx[LOGGING_CTX_GB_NSVC]; - const struct gprs_bvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; + const struct gprs_bvc *bvc = ctx->ctx[LOG_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 - && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) return 1; return 0; diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index a402378..dba4d5c 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -1049,7 +1049,7 @@ bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); if (bctx) { - log_set_context(LOGGING_CTX_GB_BVC, bctx); + log_set_context(LOG_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index d8fc840..f3f354c 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -47,11 +47,11 @@ struct bssgp_bvc_ctx *bctx) { if (bctx) { - target->filter_map |= (1 << LOGGING_FILTER_GB_BVC); - target->filter_data[LOGGING_FILTER_GB_BVC] = bctx; - } else if (target->filter_data[LOGGING_FILTER_GB_BVC]) { - target->filter_map = ~(1 << LOGGING_FILTER_GB_BVC); - target->filter_data[LOGGING_FILTER_GB_BVC] = NULL; + target->filter_map |= (1 << LOG_FLT_GB_BVC); + target->filter_data[LOG_FLT_GB_BVC] = bctx; + } else if (target->filter_data[LOG_FLT_GB_BVC]) { + target->filter_map = ~(1 << LOG_FLT_GB_BVC); + target->filter_data[LOG_FLT_GB_BVC] = NULL; } } diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 28f5ff3..76e70ff 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -325,7 +325,7 @@ { int ret; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); /* Increment number of Uplink bytes */ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]); @@ -360,7 +360,7 @@ struct msgb *msg = gprs_ns_msgb_alloc(); struct gprs_ns_hdr *nsh; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -384,7 +384,7 @@ uint16_t nsvci = htons(nsvc->nsvci); uint16_t nsei = htons(nsvc->nsei); - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -416,7 +416,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); bvci = htons(bvci); @@ -469,7 +469,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -497,7 +497,7 @@ */ int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc) { - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -510,7 +510,7 @@ */ int gprs_ns_tx_alive(struct gprs_nsvc *nsvc) { - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -523,7 +523,7 @@ */ int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc) { - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -548,7 +548,7 @@ enum ns_timeout tout = timer_mode_tout[mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, mode), seconds); @@ -576,7 +576,7 @@ enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode), seconds); @@ -638,7 +638,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci, nsei; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -692,7 +692,7 @@ msgb_free(msg); return rc; } - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); msg->l2h = msgb_push(msg, sizeof(*nsh) + 3); nsh = (struct gprs_ns_hdr *) msg->l2h; @@ -1099,7 +1099,7 @@ struct gprs_nsvc *fallback_nsvc; fallback_nsvc = nsi->unknown_nsvc; - log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); + log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc); fallback_nsvc->ip.bts_addr = *saddr; fallback_nsvc->ll = ll; @@ -1215,7 +1215,7 @@ /* Only the RESET procedure creates a new NSVC */ if (nsh->pdu_type != NS_PDUT_RESET) { /* Since we have no NSVC, we have to use a fake */ - log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); + log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x " "from %s for non-existing NS-VC\n", nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc)); @@ -1256,7 +1256,7 @@ if (!existing_nsvc) { *new_nsvc = gprs_nsvc_create(nsi, 0xffff); (*new_nsvc)->nsvci_is_valid = 0; - log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc); + log_set_context(LOG_CTX_GB_NSVC, *new_nsvc); gprs_ns_ll_copy(*new_nsvc, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n", gprs_ns_ll_str(fallback_nsvc)); @@ -1299,7 +1299,7 @@ msgb_nsei(msg) = (*nsvc)->nsei; - log_set_context(LOGGING_CTX_GB_NSVC, *nsvc); + log_set_context(LOG_CTX_GB_NSVC, *nsvc); /* Increment number of Incoming bytes */ rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]); diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index 2026c7a..6de74dd 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -61,11 +61,11 @@ struct gprs_nsvc *nsvc) { if (nsvc) { - target->filter_map |= (1 << LOGGING_FILTER_GB_NSVC); - target->filter_data[LOGGING_FILTER_GB_NSVC] = nsvc; - } else if (target->filter_data[LOGGING_FILTER_GB_NSVC]) { - target->filter_map = ~(1 << LOGGING_FILTER_GB_NSVC); - target->filter_data[LOGGING_FILTER_GB_NSVC] = NULL; + target->filter_map |= (1 << LOG_FLT_GB_NSVC); + target->filter_data[LOG_FLT_GB_NSVC] = nsvc; + } else if (target->filter_data[LOG_FLT_GB_NSVC]) { + target->filter_map = ~(1 << LOG_FLT_GB_NSVC); + target->filter_data[LOG_FLT_GB_NSVC] = NULL; } } diff --git a/src/logging.c b/src/logging.c index b09d684..6a1e929 100644 --- a/src/logging.c +++ b/src/logging.c @@ -48,11 +48,11 @@ #include /* for LOGGING_STR. */ -osmo_static_assert(_LOGGING_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), +osmo_static_assert(_LOG_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), enum_logging_ctx_items_fit_in_struct_log_context); -osmo_static_assert(_LOGGING_FILTER_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), +osmo_static_assert(_LOG_FLT_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), enum_logging_filters_fit_in_log_target_filter_data); -osmo_static_assert(_LOGGING_FILTER_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), +osmo_static_assert(_LOG_FLT_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), enum_logging_filters_fit_in_log_target_filter_map); struct log_info *osmo_log_info; @@ -381,7 +381,7 @@ /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ - if ((tar->filter_map & (1 << LOGGING_FILTER_ALL)) != 0) + if ((tar->filter_map & (1 << LOG_FLT_ALL)) != 0) return 1; if (osmo_log_info->filter_fn) @@ -499,20 +499,20 @@ return 0; } -/*! \brief Enable the \ref LOGGING_FILTER_ALL log filter +/*! \brief Enable the \ref LOG_FLT_ALL log filter * \param[in] target Log target to be affected * \param[in] all enable (1) or disable (0) the ALL filter * - * When the \ref LOGGING_FILTER_ALL filter is enabled, all log messages will be + * When the \ref LOG_FLT_ALL filter is enabled, all log messages will be * printed. It acts as a wildcard. Setting it to \a 1 means there is no * filtering. */ void log_set_all_filter(struct log_target *target, int all) { if (all) - target->filter_map |= (1 << LOGGING_FILTER_ALL); + target->filter_map |= (1 << LOG_FLT_ALL); else - target->filter_map &= ~(1 << LOGGING_FILTER_ALL); + target->filter_map &= ~(1 << LOG_FLT_ALL); } /*! \brief Enable or disable the use of colored output diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 30ee455..aabcaa7 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -287,7 +287,7 @@ } vty_out(vty, " Log Filter 'ALL': %s%s", - tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? "Enabled" : "Disabled", + tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled", VTY_NEWLINE); /* print application specific filters */ @@ -687,7 +687,7 @@ } vty_out(vty, " logging filter all %u%s", - tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? 1 : 0, VTY_NEWLINE); + tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE); /* save filters outside of libosmocore, i.e. in app code */ if (osmo_log_info->save_fn) osmo_log_info->save_fn(vty, osmo_log_info, tgt); -- To view, visit https://gerrit.osmocom.org/1878 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:13:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 17:13:31 +0000 Subject: [PATCH] openbsc[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... Message-ID: Review at https://gerrit.osmocom.org/1879 logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* In libosmocore, my patch was merged to master a bit too soon. To accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING", a fixup was committed to libosmocore. Adjust for that. Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067 The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93 Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991 --- M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/smpp_openbsc.c 5 files changed, 26 insertions(+), 26 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/79/1879/1 diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 58fdaa3..1cae832 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -159,7 +159,7 @@ gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr); if (lchan->conn) - log_set_context(LOGGING_CTX_VLR_SUBSCR, lchan->conn->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, lchan->conn->subscr); return lchan; } diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 816d7a6..eb37a33 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -77,7 +77,7 @@ if (!bts->oml_link) return; - log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, request->subscr); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, @@ -91,7 +91,7 @@ page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(request->subscr->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL); + log_set_context(LOG_CTX_VLR_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -255,7 +255,7 @@ gsm_cbfn *cbfn; int msg; - log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, req->subscr); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", req, req->subscr->imsi); @@ -394,7 +394,7 @@ { struct gsm_bts *bts; - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); /* Stop this first and dispatch the request */ if (_bts) diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 3f3232c..4d7bfed 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -179,22 +179,22 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; - const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; - const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; + const struct gsm_subscriber *subscr = ctx->ctx[LOG_CTX_VLR_SUBSCR]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = ctx->ctx[LOG_CTX_GB_BVC]; - if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0 - && subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR]) + if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0 + && subscr && subscr == tar->filter_data[LOG_FLT_VLR_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 - && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) return 1; return 0; @@ -208,7 +208,7 @@ void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) { - struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; + struct gsm_subscriber **fsub = (void*)&target->filter_data[LOG_FLT_VLR_SUBSCR]; /* free the old data */ if (*fsub) { @@ -217,8 +217,8 @@ } if (subscr) { - target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR); + target->filter_map |= (1 << LOG_FLT_VLR_SUBSCR); *fsub = subscr_get(subscr); } else - target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR); + target->filter_map &= ~(1 << LOG_FLT_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 10e2b31..be43956 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1457,7 +1457,7 @@ /* FIXME: request id? close channel? */ return -EINVAL; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1982,7 +1982,7 @@ return -EIO; /* Which subscriber do we want to track trans1 or trans2? */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans1->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans1->subscr); /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); @@ -2003,7 +2003,7 @@ if (!trans->conn) return 0; - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); lchan = trans->conn->lchan; bts = lchan->ts->trx->bts; @@ -3339,7 +3339,7 @@ mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); return -EIO; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n"); mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); @@ -3395,7 +3395,7 @@ mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); return -EIO; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n"); mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); @@ -3572,7 +3572,7 @@ LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n"); return -EIO; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n"); return 0; @@ -3646,7 +3646,7 @@ data->imsi); /* update the subscriber we deal with */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); /* If subscriber is not found */ if (!subscr) { @@ -3724,7 +3724,7 @@ subscr_put(subscr); } else { /* update the subscriber we deal with */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); } if (trans->conn) diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index fdafa16..2703a24 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -67,7 +67,7 @@ } /* tag the context in case we know it */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); return subscr; } -- To view, visit https://gerrit.osmocom.org/1879 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:13:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 17:13:56 +0000 Subject: [PATCH] osmo-pcu[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... Message-ID: Review at https://gerrit.osmocom.org/1880 logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* In libosmocore, my patch was merged to master a bit too soon. To accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING", a fixup was committed to libosmocore. Adjust for that. Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067 The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93 Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685 --- M src/gprs_bssgp_pcu.cpp M src/gprs_debug.cpp 2 files changed, 7 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/80/1880/1 diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index f07b3a6..c4ff402 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -365,7 +365,7 @@ if (bctx) { - log_set_context(LOGGING_CTX_GB_BVC, bctx); + log_set_context(LOG_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); } diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp index 6bb35ea..c35eafa 100644 --- a/src/gprs_debug.cpp +++ b/src/gprs_debug.cpp @@ -49,17 +49,17 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_NSVC]; - const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; + const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) return 1; /* Filter on the BVC */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 - && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) return 1; return 0; -- To view, visit https://gerrit.osmocom.org/1880 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:18:00 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 17:18:00 +0000 Subject: libosmocore[master]: logging.h: fixup: add API doc for logging enums recently added In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1877 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:21:19 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 17:21:19 +0000 Subject: libosmocore[master]: logging.h: fix backwards compat broken by recent commit In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1876 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I455bb1bb474d758af0fd5b6397f7e57260ad739d Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:22:39 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 17:22:39 +0000 Subject: libosmocore[master]: logging.h: fixup: shorter names for LOGGING_FILTER_* and LOG... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1878 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:23:46 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 17:23:46 +0000 Subject: openbsc[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1879 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:24:59 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Thu, 23 Feb 2017 17:24:59 +0000 Subject: osmo-pcu[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1880 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:29:22 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:29:22 +0000 Subject: libosmocore[master]: logging.h: fix backwards compat broken by recent commit In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1876 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I455bb1bb474d758af0fd5b6397f7e57260ad739d Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:29:31 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:29:31 +0000 Subject: libosmocore[master]: logging.h: fixup: add API doc for logging enums recently added In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1877 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:29:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:29:53 +0000 Subject: libosmocore[master]: logging.h: fixup: shorter names for LOGGING_FILTER_* and LOG... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1878 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:29:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:29:55 +0000 Subject: [MERGED] libosmocore[master]: logging.h: fixup: shorter names for LOGGING_FILTER_* and LOG... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* ...................................................................... logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* My recent logging patch was merged to master a bit too soon. Accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING". libosmocore will not be backwards-compatible with the few commits from change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and following commits are backwards compatible with those before that short window. See also: * openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991 * osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93 --- M include/osmocom/core/logging.h M src/gb/common_vty.c M src/gb/gprs_bssgp.c M src/gb/gprs_bssgp_vty.c M src/gb/gprs_ns.c M src/gb/gprs_ns_vty.c M src/logging.c M src/vty/logging_vty.c 8 files changed, 61 insertions(+), 59 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index c4d8006..7b28b2c 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -126,32 +126,34 @@ /*! \brief Indexes to indicate the object currently acted upon. * Array indexes for the global \a log_context array. */ -enum logging_ctx_items { - LOGGING_CTX_GB_NSVC, - LOGGING_CTX_GB_BVC, - LOGGING_CTX_BSC_SUBSCR, - LOGGING_CTX_VLR_SUBSCR, - _LOGGING_CTX_COUNT +enum log_ctx_index { + LOG_CTX_GB_NSVC, + LOG_CTX_GB_BVC, + LOG_CTX_BSC_SUBSCR, + LOG_CTX_VLR_SUBSCR, + _LOG_CTX_COUNT }; /*! \brief Indexes to indicate objects that should be logged. * Array indexes to log_target->filter_data and bit indexes for * log_target->filter_map. */ -enum logging_filters { - LOGGING_FILTER_ALL, - LOGGING_FILTER_GB_NSVC, - LOGGING_FILTER_GB_BVC, - LOGGING_FILTER_BSC_SUBSCR, - LOGGING_FILTER_VLR_SUBSCR, - _LOGGING_FILTER_COUNT +enum log_filter_index { + LOG_FLT_ALL, + LOG_FLT_GB_NSVC, + LOG_FLT_GB_BVC, + LOG_FLT_BSC_SUBSCR, + LOG_FLT_VLR_SUBSCR, + _LOG_FLT_COUNT }; /*! \brief Compatibility with older libosmocore versions */ -#define LOG_FILTER_ALL (1<ctx[LOGGING_CTX_GB_NSVC]; - const struct gprs_bvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; + const struct gprs_bvc *bvc = ctx->ctx[LOG_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 - && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) return 1; return 0; diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index a402378..dba4d5c 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -1049,7 +1049,7 @@ bctx = btsctx_by_bvci_nsei(bvci, msgb_nsei(msg)); if (bctx) { - log_set_context(LOGGING_CTX_GB_BVC, bctx); + log_set_context(LOG_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index d8fc840..f3f354c 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -47,11 +47,11 @@ struct bssgp_bvc_ctx *bctx) { if (bctx) { - target->filter_map |= (1 << LOGGING_FILTER_GB_BVC); - target->filter_data[LOGGING_FILTER_GB_BVC] = bctx; - } else if (target->filter_data[LOGGING_FILTER_GB_BVC]) { - target->filter_map = ~(1 << LOGGING_FILTER_GB_BVC); - target->filter_data[LOGGING_FILTER_GB_BVC] = NULL; + target->filter_map |= (1 << LOG_FLT_GB_BVC); + target->filter_data[LOG_FLT_GB_BVC] = bctx; + } else if (target->filter_data[LOG_FLT_GB_BVC]) { + target->filter_map = ~(1 << LOG_FLT_GB_BVC); + target->filter_data[LOG_FLT_GB_BVC] = NULL; } } diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 28f5ff3..76e70ff 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -325,7 +325,7 @@ { int ret; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); /* Increment number of Uplink bytes */ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]); @@ -360,7 +360,7 @@ struct msgb *msg = gprs_ns_msgb_alloc(); struct gprs_ns_hdr *nsh; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -384,7 +384,7 @@ uint16_t nsvci = htons(nsvc->nsvci); uint16_t nsei = htons(nsvc->nsei); - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -416,7 +416,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); bvci = htons(bvci); @@ -469,7 +469,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci = htons(nsvc->nsvci); - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -497,7 +497,7 @@ */ int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc) { - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_INFO, "NSEI=%u Tx NS UNBLOCK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -510,7 +510,7 @@ */ int gprs_ns_tx_alive(struct gprs_nsvc *nsvc) { - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -523,7 +523,7 @@ */ int gprs_ns_tx_alive_ack(struct gprs_nsvc *nsvc) { - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); LOGP(DNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n", nsvc->nsei, nsvc->nsvci); @@ -548,7 +548,7 @@ enum ns_timeout tout = timer_mode_tout[mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Starting timer in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, mode), seconds); @@ -576,7 +576,7 @@ enum ns_timeout tout = timer_mode_tout[nsvc->timer_mode]; unsigned int seconds = nsvc->nsi->timeout[tout]; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); DEBUGP(DNS, "NSEI=%u Timer expired in mode %s (%u seconds)\n", nsvc->nsei, get_value_string(timer_mode_strs, nsvc->timer_mode), seconds); @@ -638,7 +638,7 @@ struct gprs_ns_hdr *nsh; uint16_t nsvci, nsei; - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); if (!msg) return -ENOMEM; @@ -692,7 +692,7 @@ msgb_free(msg); return rc; } - log_set_context(LOGGING_CTX_GB_NSVC, nsvc); + log_set_context(LOG_CTX_GB_NSVC, nsvc); msg->l2h = msgb_push(msg, sizeof(*nsh) + 3); nsh = (struct gprs_ns_hdr *) msg->l2h; @@ -1099,7 +1099,7 @@ struct gprs_nsvc *fallback_nsvc; fallback_nsvc = nsi->unknown_nsvc; - log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); + log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc); fallback_nsvc->ip.bts_addr = *saddr; fallback_nsvc->ll = ll; @@ -1215,7 +1215,7 @@ /* Only the RESET procedure creates a new NSVC */ if (nsh->pdu_type != NS_PDUT_RESET) { /* Since we have no NSVC, we have to use a fake */ - log_set_context(LOGGING_CTX_GB_NSVC, fallback_nsvc); + log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x " "from %s for non-existing NS-VC\n", nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc)); @@ -1256,7 +1256,7 @@ if (!existing_nsvc) { *new_nsvc = gprs_nsvc_create(nsi, 0xffff); (*new_nsvc)->nsvci_is_valid = 0; - log_set_context(LOGGING_CTX_GB_NSVC, *new_nsvc); + log_set_context(LOG_CTX_GB_NSVC, *new_nsvc); gprs_ns_ll_copy(*new_nsvc, fallback_nsvc); LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n", gprs_ns_ll_str(fallback_nsvc)); @@ -1299,7 +1299,7 @@ msgb_nsei(msg) = (*nsvc)->nsei; - log_set_context(LOGGING_CTX_GB_NSVC, *nsvc); + log_set_context(LOG_CTX_GB_NSVC, *nsvc); /* Increment number of Incoming bytes */ rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]); diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index 2026c7a..6de74dd 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -61,11 +61,11 @@ struct gprs_nsvc *nsvc) { if (nsvc) { - target->filter_map |= (1 << LOGGING_FILTER_GB_NSVC); - target->filter_data[LOGGING_FILTER_GB_NSVC] = nsvc; - } else if (target->filter_data[LOGGING_FILTER_GB_NSVC]) { - target->filter_map = ~(1 << LOGGING_FILTER_GB_NSVC); - target->filter_data[LOGGING_FILTER_GB_NSVC] = NULL; + target->filter_map |= (1 << LOG_FLT_GB_NSVC); + target->filter_data[LOG_FLT_GB_NSVC] = nsvc; + } else if (target->filter_data[LOG_FLT_GB_NSVC]) { + target->filter_map = ~(1 << LOG_FLT_GB_NSVC); + target->filter_data[LOG_FLT_GB_NSVC] = NULL; } } diff --git a/src/logging.c b/src/logging.c index b09d684..6a1e929 100644 --- a/src/logging.c +++ b/src/logging.c @@ -48,11 +48,11 @@ #include /* for LOGGING_STR. */ -osmo_static_assert(_LOGGING_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), +osmo_static_assert(_LOG_CTX_COUNT <= ARRAY_SIZE(((struct log_context*)NULL)->ctx), enum_logging_ctx_items_fit_in_struct_log_context); -osmo_static_assert(_LOGGING_FILTER_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), +osmo_static_assert(_LOG_FLT_COUNT <= ARRAY_SIZE(((struct log_target*)NULL)->filter_data), enum_logging_filters_fit_in_log_target_filter_data); -osmo_static_assert(_LOGGING_FILTER_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), +osmo_static_assert(_LOG_FLT_COUNT <= 8*sizeof(((struct log_target*)NULL)->filter_map), enum_logging_filters_fit_in_log_target_filter_map); struct log_info *osmo_log_info; @@ -381,7 +381,7 @@ /* Apply filters here... if that becomes messy we will * need to put filters in a list and each filter will * say stop, continue, output */ - if ((tar->filter_map & (1 << LOGGING_FILTER_ALL)) != 0) + if ((tar->filter_map & (1 << LOG_FLT_ALL)) != 0) return 1; if (osmo_log_info->filter_fn) @@ -499,20 +499,20 @@ return 0; } -/*! \brief Enable the \ref LOGGING_FILTER_ALL log filter +/*! \brief Enable the \ref LOG_FLT_ALL log filter * \param[in] target Log target to be affected * \param[in] all enable (1) or disable (0) the ALL filter * - * When the \ref LOGGING_FILTER_ALL filter is enabled, all log messages will be + * When the \ref LOG_FLT_ALL filter is enabled, all log messages will be * printed. It acts as a wildcard. Setting it to \a 1 means there is no * filtering. */ void log_set_all_filter(struct log_target *target, int all) { if (all) - target->filter_map |= (1 << LOGGING_FILTER_ALL); + target->filter_map |= (1 << LOG_FLT_ALL); else - target->filter_map &= ~(1 << LOGGING_FILTER_ALL); + target->filter_map &= ~(1 << LOG_FLT_ALL); } /*! \brief Enable or disable the use of colored output diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 30ee455..aabcaa7 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -287,7 +287,7 @@ } vty_out(vty, " Log Filter 'ALL': %s%s", - tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? "Enabled" : "Disabled", + tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled", VTY_NEWLINE); /* print application specific filters */ @@ -687,7 +687,7 @@ } vty_out(vty, " logging filter all %u%s", - tgt->filter_map & (1 << LOGGING_FILTER_ALL) ? 1 : 0, VTY_NEWLINE); + tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE); /* save filters outside of libosmocore, i.e. in app code */ if (osmo_log_info->save_fn) osmo_log_info->save_fn(vty, osmo_log_info, tgt); -- To view, visit https://gerrit.osmocom.org/1878 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:29:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:29:55 +0000 Subject: [MERGED] libosmocore[master]: logging.h: fixup: add API doc for logging enums recently added In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: logging.h: fixup: add API doc for logging enums recently added ...................................................................... logging.h: fixup: add API doc for logging enums recently added Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2 --- M include/osmocom/core/logging.h 1 file changed, 5 insertions(+), 0 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 7c8a7ef..c4d8006 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -124,6 +124,8 @@ void *ctx[LOG_MAX_CTX+1]; }; +/*! \brief Indexes to indicate the object currently acted upon. + * Array indexes for the global \a log_context array. */ enum logging_ctx_items { LOGGING_CTX_GB_NSVC, LOGGING_CTX_GB_BVC, @@ -132,6 +134,9 @@ _LOGGING_CTX_COUNT }; +/*! \brief Indexes to indicate objects that should be logged. + * Array indexes to log_target->filter_data and bit indexes for + * log_target->filter_map. */ enum logging_filters { LOGGING_FILTER_ALL, LOGGING_FILTER_GB_NSVC, -- To view, visit https://gerrit.osmocom.org/1877 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:29:55 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:29:55 +0000 Subject: [MERGED] libosmocore[master]: logging.h: fix backwards compat broken by recent commit In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: logging.h: fix backwards compat broken by recent commit ...................................................................... logging.h: fix backwards compat broken by recent commit Commit 812ba6dc63a75c39678dd3fe652768e76bf63183 "logging: centrally define ctx and filter indexes" Removed definitions, which causes older e.g. openbsc and osmo-pcu code trees to fail to build against a newer libosmocore. Re-introduce the legacy definitions to redirect to the new ones and re-establish backwards compatibility. The GPRS_* constants used to be defined in gprs_msgb.h, but since that header also includes logging.h, rather place the legacy shims in logging.h next to the other ones. Change-Id: I455bb1bb474d758af0fd5b6397f7e57260ad739d --- M include/osmocom/core/logging.h 1 file changed, 7 insertions(+), 0 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index b3685b8..7c8a7ef 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -141,6 +141,13 @@ _LOGGING_FILTER_COUNT }; +/*! \brief Compatibility with older libosmocore versions */ +#define LOG_FILTER_ALL (1< Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:30:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:30:38 +0000 Subject: libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 17:30:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 17:30:44 +0000 Subject: [MERGED] libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Expand and expose ctrl connection allocation ...................................................................... Expand and expose ctrl connection allocation Add function for allocating CTRL connection to public headers and replace call to previous static function with it. Add doxygen docs for this function. It's useful if we need to allocate ctrl connection but don't need to bind to any interfaces: when we act as ctrl client. Related: OS#1615 Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 --- M include/osmocom/ctrl/control_if.h M src/ctrl/control_if.c 2 files changed, 52 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h index 512ae10..f2af1db 100644 --- a/include/osmocom/ctrl/control_if.h +++ b/include/osmocom/ctrl/control_if.h @@ -27,5 +27,5 @@ const char *bind_addr, uint16_t port, ctrl_cmd_lookup lookup); - +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data); int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data); diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index 254f9bc..cf79670 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -368,7 +368,13 @@ return rc; } -static struct ctrl_connection *ctrl_connection_alloc(void *ctx) +/*! \brief Allocate CTRL connection + * \param[in] ctx Context from which talloc should allocate it + * \param[in] data caller's private data parameter which should assigned to + write queue's file descriptor data parameter. + * \return Allocated CTRL connection structure or NULL in case of errors + */ +struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data) { struct ctrl_connection *ccon = talloc_zero(ctx, struct ctrl_connection); if (!ccon) @@ -379,6 +385,9 @@ INIT_LLIST_HEAD(&ccon->cmds); INIT_LLIST_HEAD(&ccon->def_cmds); + + ccon->write_queue.bfd.data = data; + ccon->write_queue.write_cb = control_write_cb; return ccon; } @@ -412,19 +421,17 @@ return ret; } #endif - ccon = ctrl_connection_alloc(listen_bfd->data); + ctrl = listen_bfd->data; + ccon = osmo_ctrl_conn_alloc(listen_bfd->data, ctrl); if (!ccon) { LOGP(DLCTRL, LOGL_ERROR, "Failed to allocate.\n"); close(fd); return -1; } - ctrl = listen_bfd->data; - ccon->write_queue.bfd.data = ctrl; ccon->write_queue.bfd.fd = fd; ccon->write_queue.bfd.when = BSC_FD_READ; ccon->write_queue.read_cb = handle_control_read; - ccon->write_queue.write_cb = control_write_cb; ret = osmo_fd_register(&ccon->write_queue.bfd); if (ret < 0) { @@ -648,6 +655,45 @@ return 0; } +/*! \brief Setup CTRL interface connection to a given address + * \param[in] data Pointer which will be made available to each + set_..() get_..() verify_..() control command function + * \param[in] addr Address to which we shall connect + * \param[in] port Port to which we shall connect + * \param[in] lookup Lookup function pointer, can be NULL + * \returns ctrl_handle pointer or NULL in case of errors + */ +struct ctrl_handle *ctrl_interface_connect(void *data, const char *addr, + uint16_t port, + ctrl_cmd_lookup lookup) +{ + int ret; + struct ctrl_handle *ctrl; + + ctrl = talloc_zero(data, struct ctrl_handle); + if (!ctrl) + return NULL; + + INIT_LLIST_HEAD(&ctrl->ccon_list); + + ctrl->data = data; + ctrl->lookup = lookup; + + ctrl->listen_fd.cb = NULL; + ctrl->listen_fd.data = ctrl; + ret = osmo_sock_init_ifd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, + IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT); + if (ret < 0) { + LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n", + addr, port); + talloc_free(ctrl); + return NULL; + } + LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to %s:%u\n", addr, port); + + return ctrl; +} + struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, ctrl_cmd_lookup lookup) { -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Thu Feb 23 19:28:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 19:28:23 +0000 Subject: [PATCH] openbsc[master]: vty: fix subscr ref count leak in 'subscriber name' cmd Message-ID: Review at https://gerrit.osmocom.org/1881 vty: fix subscr ref count leak in 'subscriber name' cmd Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1 --- M openbsc/src/libmsc/vty_interface_layer3.c 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/81/1881/1 diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index ddec2e3..cd5dfb7 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -586,6 +586,7 @@ vty_out(vty, "%% NAME is too long, max. %zu characters are allowed%s", sizeof(subscr->name)-1, VTY_NEWLINE); + subscr_put(subscr); return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/1881 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 19:46:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 19:46:12 +0000 Subject: [PATCH] openggsn[master]: gtp-kernel: Fix tunnel creation/removal for GTP Version 1 Message-ID: Review at https://gerrit.osmocom.org/1882 gtp-kernel: Fix tunnel creation/removal for GTP Version 1 When Linux Kenrel GTP-U support is enabled, OpenGGSN so far only worked with GTPv0,but not with GTPv1, as the TEI values were not correctly configured. This patch fixes the initialzation of the local and remote TEI before using libgtpnl to create a tunnel context in the kernel. Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 --- M ggsn/gtp-kernel.c 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/82/1882/1 diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c index 93dea23..dbe5a9f 100644 --- a/ggsn/gtp-kernel.c +++ b/ggsn/gtp-kernel.c @@ -192,7 +192,10 @@ gtp_tunnel_set_tid(t, pdp_gettid(pdp->imsi, pdp->nsapi)); gtp_tunnel_set_flowid(t, pdp->flru); } else { - gtp_tunnel_set_tid(t, pdp->teid_gn); /* GTPIE_TEI_DI */ + gtp_tunnel_set_i_tei(t, pdp->teid_own); + /* use the TEI advertised by SGSN when sending packets + * towards the SGSN */ + gtp_tunnel_set_o_tei(t, pdp->teid_gn); } ret = gtp_add_tunnel(gtp_nl.genl_id, gtp_nl.nl, t); @@ -221,7 +224,7 @@ gtp_tunnel_set_tid(t, pdp_gettid(pdp->imsi, pdp->nsapi)); gtp_tunnel_set_flowid(t, pdp->flru); } else { - gtp_tunnel_set_tid(t, pdp->teid_gn); /* GTPIE_TEI_DI */ + gtp_tunnel_set_i_tei(t, pdp->teid_own); } ret = gtp_del_tunnel(gtp_nl.genl_id, gtp_nl.nl, t); -- To view, visit https://gerrit.osmocom.org/1882 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 23 19:46:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 19:46:13 +0000 Subject: [PATCH] openggsn[master]: gtp.c: Don't print ""Unknown packet flags" error message in ... Message-ID: Review at https://gerrit.osmocom.org/1883 gtp.c: Don't print ""Unknown packet flags" error message in get_seq() get_seq() is called also from contexts where GTP-U is used, and GTP-U doesn't have sequence numbers. Thus, it is perfectly normal if no sequence number and/or no S flag in the header is present. Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da --- M gtp/gtp.c 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/83/1883/1 diff --git a/gtp/gtp.c b/gtp/gtp.c index 42aa4ea..ade746a 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -210,7 +210,6 @@ } else if ((packet->flags & 0xe2) == 0x22) { /* Version 1 with seq */ return ntoh16(packet->gtp1l.h.seq); } else { - LOGP(DLGTP, LOGL_ERROR, "Unknown packet flags: 0x%02x\n", packet->flags); return 0; } } -- To view, visit https://gerrit.osmocom.org/1883 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 23 19:53:33 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 19:53:33 +0000 Subject: [PATCH] libosmocore[master]: ports.h: rename CSCN to MSC Message-ID: Review at https://gerrit.osmocom.org/1884 ports.h: rename CSCN to MSC See OS#1958 Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d --- M include/osmocom/ctrl/ports.h M include/osmocom/vty/ports.h 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/1884/1 diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h index 101b894..d28066e 100644 --- a/include/osmocom/ctrl/ports.h +++ b/include/osmocom/ctrl/ports.h @@ -13,7 +13,7 @@ #define OSMO_CTRL_PORT_BSC_NAT 4250 #define OSMO_CTRL_PORT_SGSN 4251 /* 4252-4254 used by VTY interface */ -#define OSMO_CTRL_PORT_CSCN 4255 +#define OSMO_CTRL_PORT_MSC 4255 /* 4256 used by VTY interface */ #define OSMO_CTRL_PORT_GGSN 4257 #define OSMO_CTRL_PORT_HLR 4259 diff --git a/include/osmocom/vty/ports.h b/include/osmocom/vty/ports.h index 70dc69c..887e4df 100644 --- a/include/osmocom/vty/ports.h +++ b/include/osmocom/vty/ports.h @@ -20,7 +20,7 @@ /* 4249-4251 used by control interface */ #define OSMO_VTY_PORT_BTSMGR 4252 #define OSMO_VTY_PORT_GTPHUB 4253 -#define OSMO_VTY_PORT_CSCN 4254 +#define OSMO_VTY_PORT_MSC 4254 /* 4255 used by control interface */ #define OSMO_VTY_PORT_MNCC_SIP 4256 /* 4257 used by control interface */ -- To view, visit https://gerrit.osmocom.org/1884 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From admin at opensuse.org Thu Feb 23 19:54:59 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:54:59 +0000 Subject: Build failure of network:osmocom:nightly/osmo-pcu in Debian_8.0/x86_64 In-Reply-To: References: Message-ID: <58af3e1faec39_567ded1c0033358@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-pcu/Debian_8.0/x86_64 Package network:osmocom:nightly/osmo-pcu failed to build in Debian_8.0/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly osmo-pcu Last lines of build log: [ 84s] gprs_debug.cpp:53:66: error: 'LOGGING_CTX_GB_BVC' was not declared in this scope [ 84s] const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; [ 84s] ^ [ 84s] gprs_debug.cpp:56:31: error: 'LOGGING_FILTER_GB_NSVC' was not declared in this scope [ 84s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 [ 84s] ^ [ 84s] gprs_debug.cpp:61:31: error: 'LOGGING_FILTER_GB_BVC' was not declared in this scope [ 84s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 [ 84s] ^ [ 84s] Makefile:767: recipe for target 'gprs_debug.lo' failed [ 84s] make[2]: *** [gprs_debug.lo] Error 1 [ 84s] make[2]: Leaving directory '/usr/src/packages/BUILD/src' [ 84s] Makefile:392: recipe for target 'all-recursive' failed [ 84s] make[1]: *** [all-recursive] Error 1 [ 84s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 84s] dh_auto_build: make -j1 returned exit code 2 [ 84s] debian/rules:12: recipe for target 'build' failed [ 84s] make: *** [build] Error 2 [ 84s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 84s] [ 84s] lamb24 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:54:53 UTC 2017. [ 84s] [ 84s] ### VM INTERACTION START ### [ 85s] Powering off. [ 85s] [ 70.959555] reboot: Power down [ 85s] ### VM INTERACTION END ### [ 85s] [ 85s] lamb24 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:54:55 UTC 2017. [ 85s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:54:41 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:54:41 +0000 Subject: Build failure of network:osmocom:nightly/osmo-pcu in xUbuntu_16.10/i586 In-Reply-To: References: Message-ID: <58af3e1ecbaa6_567ded1c00333457@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-pcu/xUbuntu_16.10/i586 Package network:osmocom:nightly/osmo-pcu failed to build in xUbuntu_16.10/i586 Check out the package for editing: osc checkout network:osmocom:nightly osmo-pcu Last lines of build log: [ 75s] ^~~~~~~~~~~~~~~~~~~ [ 75s] gprs_debug.cpp:53:66: error: 'LOGGING_CTX_GB_BVC' was not declared in this scope [ 75s] const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; [ 75s] ^~~~~~~~~~~~~~~~~~ [ 75s] gprs_debug.cpp:56:31: error: 'LOGGING_FILTER_GB_NSVC' was not declared in this scope [ 75s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 [ 75s] ^~~~~~~~~~~~~~~~~~~~~~ [ 75s] gprs_debug.cpp:61:31: error: 'LOGGING_FILTER_GB_BVC' was not declared in this scope [ 75s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 [ 75s] ^~~~~~~~~~~~~~~~~~~~~ [ 75s] Makefile:778: recipe for target 'gprs_debug.lo' failed [ 75s] make[2]: *** [gprs_debug.lo] Error 1 [ 75s] make[2]: Leaving directory '/usr/src/packages/BUILD/src' [ 75s] Makefile:403: recipe for target 'all-recursive' failed [ 75s] make[1]: *** [all-recursive] Error 1 [ 75s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 75s] dh_auto_build: make -j1 returned exit code 2 [ 75s] debian/rules:12: recipe for target 'build' failed [ 75s] make: *** [build] Error 2 [ 75s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 75s] [ 75s] lamb22 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:54:32 UTC 2017. [ 75s] [ 75s] ### VM INTERACTION START ### [ 78s] [ 65.186688] reboot: Power down [ 78s] ### VM INTERACTION END ### [ 78s] [ 78s] lamb22 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:54:36 UTC 2017. [ 78s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:55:16 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:55:16 +0000 Subject: Build failure of network:osmocom:nightly/osmo-pcu in xUbuntu_16.04/i586 In-Reply-To: References: Message-ID: <58af3e388e899_5684ed1c0035127e@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-pcu/xUbuntu_16.04/i586 Package network:osmocom:nightly/osmo-pcu failed to build in xUbuntu_16.04/i586 Check out the package for editing: osc checkout network:osmocom:nightly osmo-pcu Last lines of build log: [ 89s] ^ [ 89s] gprs_debug.cpp:53:66: error: 'LOGGING_CTX_GB_BVC' was not declared in this scope [ 89s] const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; [ 89s] ^ [ 89s] gprs_debug.cpp:56:31: error: 'LOGGING_FILTER_GB_NSVC' was not declared in this scope [ 89s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 [ 89s] ^ [ 89s] gprs_debug.cpp:61:31: error: 'LOGGING_FILTER_GB_BVC' was not declared in this scope [ 89s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 [ 89s] ^ [ 89s] Makefile:778: recipe for target 'gprs_debug.lo' failed [ 89s] make[2]: *** [gprs_debug.lo] Error 1 [ 89s] make[2]: Leaving directory '/usr/src/packages/BUILD/src' [ 89s] Makefile:403: recipe for target 'all-recursive' failed [ 89s] make[1]: *** [all-recursive] Error 1 [ 89s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 89s] dh_auto_build: make -j1 returned exit code 2 [ 89s] debian/rules:12: recipe for target 'build' failed [ 89s] make: *** [build] Error 2 [ 89s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 89s] [ 89s] lamb16 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:54:57 UTC 2017. [ 89s] [ 89s] ### VM INTERACTION START ### [ 92s] [ 79.972869] reboot: Power down [ 92s] ### VM INTERACTION END ### [ 92s] [ 92s] lamb16 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:55:01 UTC 2017. [ 92s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:55:16 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:55:16 +0000 Subject: Build failure of network:osmocom:nightly/openggsn in Debian_8.0/x86_64 In-Reply-To: References: Message-ID: <58af3e393f673_5684ed1c0035131@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openggsn/Debian_8.0/x86_64 Package network:osmocom:nightly/openggsn failed to build in Debian_8.0/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly openggsn Last lines of build log: [ 97s] cmdline.c:612:7: warning: variable 'check_required' set but not used [-Wunused-but-set-variable] [ 97s] int check_required; [ 97s] ^ [ 97s] CCLD ggsn [ 98s] /usr/lib/x86_64-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 98s] collect2: error: ld returned 1 exit status [ 98s] Makefile:402: recipe for target 'ggsn' failed [ 98s] make[3]: *** [ggsn] Error 1 [ 98s] make[3]: Leaving directory '/usr/src/packages/BUILD/ggsn' [ 98s] Makefile:473: recipe for target 'all-recursive' failed [ 98s] make[2]: *** [all-recursive] Error 1 [ 98s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 98s] Makefile:373: recipe for target 'all' failed [ 98s] make[1]: *** [all] Error 2 [ 98s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 98s] dh_auto_build: make -j1 returned exit code 2 [ 98s] debian/rules:11: recipe for target 'build' failed [ 98s] make: *** [build] Error 2 [ 98s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 98s] [ 98s] lamb27 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:08 UTC 2017. [ 98s] [ 98s] ### VM INTERACTION START ### [ 99s] Powering off. [ 99s] [ 84.886090] reboot: Power down [ 99s] ### VM INTERACTION END ### [ 99s] [ 99s] lamb27 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:10 UTC 2017. [ 99s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:55:16 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:55:16 +0000 Subject: Build failure of network:osmocom:nightly/osmo-pcu in xUbuntu_16.10/x86_64 In-Reply-To: References: Message-ID: <58af3e39a385b_5684ed1c003514b5@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-pcu/xUbuntu_16.10/x86_64 Package network:osmocom:nightly/osmo-pcu failed to build in xUbuntu_16.10/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly osmo-pcu Last lines of build log: [ 74s] const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_NSVC]; [ 74s] ^~~~~~~~~~~~~~~~~~~ [ 74s] gprs_debug.cpp:53:66: error: 'LOGGING_CTX_GB_BVC' was not declared in this scope [ 74s] const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; [ 74s] ^~~~~~~~~~~~~~~~~~ [ 74s] gprs_debug.cpp:56:31: error: 'LOGGING_FILTER_GB_NSVC' was not declared in this scope [ 74s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 [ 74s] ^~~~~~~~~~~~~~~~~~~~~~ [ 74s] gprs_debug.cpp:61:31: error: 'LOGGING_FILTER_GB_BVC' was not declared in this scope [ 74s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 [ 74s] ^~~~~~~~~~~~~~~~~~~~~ [ 74s] Makefile:778: recipe for target 'gprs_debug.lo' failed [ 74s] make[2]: *** [gprs_debug.lo] Error 1 [ 74s] make[2]: Leaving directory '/usr/src/packages/BUILD/src' [ 74s] Makefile:403: recipe for target 'all-recursive' failed [ 74s] make[1]: *** [all-recursive] Error 1 [ 74s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 74s] dh_auto_build: make -j1 returned exit code 2 [ 74s] debian/rules:12: recipe for target 'build' failed [ 74s] make: *** [build] Error 2 [ 74s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 74s] [ 74s] wildcard2 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:55:09 UTC 2017. [ 74s] [ 74s] ### VM INTERACTION START ### [ 78s] ### VM INTERACTION END ### [ 78s] [ 78s] wildcard2 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:55:13 UTC 2017. [ 78s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:55:33 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:55:33 +0000 Subject: Build failure of network:osmocom:nightly/osmo-pcu in xUbuntu_16.04/x86_64 In-Reply-To: References: Message-ID: <58af3e39eeecd_5684ed1c0035158a@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-pcu/xUbuntu_16.04/x86_64 Package network:osmocom:nightly/osmo-pcu failed to build in xUbuntu_16.04/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly osmo-pcu Last lines of build log: [ 91s] ^ [ 91s] gprs_debug.cpp:53:66: error: 'LOGGING_CTX_GB_BVC' was not declared in this scope [ 91s] const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; [ 91s] ^ [ 91s] gprs_debug.cpp:56:31: error: 'LOGGING_FILTER_GB_NSVC' was not declared in this scope [ 91s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 [ 91s] ^ [ 91s] gprs_debug.cpp:61:31: error: 'LOGGING_FILTER_GB_BVC' was not declared in this scope [ 91s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 [ 91s] ^ [ 91s] Makefile:778: recipe for target 'gprs_debug.lo' failed [ 91s] make[2]: *** [gprs_debug.lo] Error 1 [ 91s] make[2]: Leaving directory '/usr/src/packages/BUILD/src' [ 91s] Makefile:403: recipe for target 'all-recursive' failed [ 91s] make[1]: *** [all-recursive] Error 1 [ 91s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 91s] dh_auto_build: make -j1 returned exit code 2 [ 91s] debian/rules:12: recipe for target 'build' failed [ 91s] make: *** [build] Error 2 [ 91s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 91s] [ 91s] lamb10 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:55:13 UTC 2017. [ 91s] [ 91s] ### VM INTERACTION START ### [ 94s] [ 80.936592] reboot: Power down [ 94s] ### VM INTERACTION END ### [ 94s] [ 94s] lamb10 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:55:17 UTC 2017. [ 94s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:55:33 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:55:33 +0000 Subject: Build failure of network:osmocom:nightly/openggsn in xUbuntu_16.04/i586 In-Reply-To: References: Message-ID: <58af3e3aaf07a_5684ed1c00351684@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openggsn/xUbuntu_16.04/i586 Package network:osmocom:nightly/openggsn failed to build in xUbuntu_16.04/i586 Check out the package for editing: osc checkout network:osmocom:nightly openggsn Last lines of build log: [ 106s] cmdline.c:612:7: warning: variable 'check_required' set but not used [-Wunused-but-set-variable] [ 106s] int check_required; [ 106s] ^ [ 107s] /bin/bash ../libtool --tag=CC --mode=link gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR='"/usr/sbin"' -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o ggsn ggsn.o cmdline.o -lgtp -L../gtp ../lib/libmisc.a -ltalloc -losmocore -ltalloc -losmoctrl -losmogsm -losmocore [ 107s] libtool: link: gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR=\"/usr/sbin\" -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -o .libs/ggsn ggsn.o cmdline.o /usr/src/packages/BUILD/gtp/.libs/libgtp.so -L../gtp ../lib/libmisc.a -ltalloc /usr/lib/i386-linux-gnu/libosmoctrl.so /usr/lib/i386-linux-gnu/libosmogsm.so /usr/lib/i386-linux-gnu/libosmocore.so [ 107s] /usr/lib/i386-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 107s] collect2: error: ld returned 1 exit status [ 107s] Makefile:413: recipe for target 'ggsn' failed [ 107s] make[3]: *** [ggsn] Error 1 [ 107s] make[3]: Leaving directory '/usr/src/packages/BUILD/ggsn' [ 107s] Makefile:485: recipe for target 'all-recursive' failed [ 107s] make[2]: *** [all-recursive] Error 1 [ 107s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 107s] Makefile:386: recipe for target 'all' failed [ 107s] make[1]: *** [all] Error 2 [ 107s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 107s] dh_auto_build: make -j1 returned exit code 2 [ 107s] debian/rules:11: recipe for target 'build' failed [ 107s] make: *** [build] Error 2 [ 107s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 107s] [ 107s] lamb27 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:19 UTC 2017. [ 107s] [ 107s] ### VM INTERACTION START ### [ 110s] [ 97.458416] reboot: Power down [ 110s] ### VM INTERACTION END ### [ 110s] [ 110s] lamb27 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:22 UTC 2017. [ 110s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:56:07 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:56:07 +0000 Subject: Build failure of network:osmocom:nightly/openggsn in Debian_8.0/i586 In-Reply-To: References: Message-ID: <58af3e5b613d2_5684ed1c003518d6@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openggsn/Debian_8.0/i586 Package network:osmocom:nightly/openggsn failed to build in Debian_8.0/i586 Check out the package for editing: osc checkout network:osmocom:nightly openggsn Last lines of build log: [ 98s] cmdline.c:612:7: warning: variable 'check_required' set but not used [-Wunused-but-set-variable] [ 98s] int check_required; [ 98s] ^ [ 99s] CCLD ggsn [ 99s] /usr/lib/i386-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 99s] collect2: error: ld returned 1 exit status [ 99s] Makefile:402: recipe for target 'ggsn' failed [ 99s] make[3]: *** [ggsn] Error 1 [ 99s] make[3]: Leaving directory '/usr/src/packages/BUILD/ggsn' [ 99s] Makefile:473: recipe for target 'all-recursive' failed [ 99s] make[2]: *** [all-recursive] Error 1 [ 99s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 99s] Makefile:373: recipe for target 'all' failed [ 99s] make[1]: *** [all] Error 2 [ 99s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 99s] dh_auto_build: make -j1 returned exit code 2 [ 99s] debian/rules:11: recipe for target 'build' failed [ 99s] make: *** [build] Error 2 [ 99s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 99s] [ 99s] lamb23 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:56 UTC 2017. [ 99s] [ 99s] ### VM INTERACTION START ### [ 100s] Powering off. [ 100s] [ 85.747502] reboot: Power down [ 100s] ### VM INTERACTION END ### [ 100s] [ 100s] lamb23 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:58 UTC 2017. [ 100s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:56:07 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:56:07 +0000 Subject: Build failure of network:osmocom:nightly/openggsn in xUbuntu_16.10/x86_64 In-Reply-To: References: Message-ID: <58af3e5bb33b9_5684ed1c003519a6@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openggsn/xUbuntu_16.10/x86_64 Package network:osmocom:nightly/openggsn failed to build in xUbuntu_16.10/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly openggsn Last lines of build log: [ 116s] cmdline.c:612:7: warning: variable 'check_required' set but not used [-Wunused-but-set-variable] [ 116s] int check_required; [ 116s] ^~~~~~~~~~~~~~ [ 116s] /bin/bash ../libtool --tag=CC --mode=link gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR='"/usr/sbin"' -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o ggsn ggsn.o cmdline.o -lgtp -L../gtp ../lib/libmisc.a -ltalloc -losmocore -ltalloc -losmoctrl -losmogsm -losmocore [ 116s] libtool: link: gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR=\"/usr/sbin\" -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -o .libs/ggsn ggsn.o cmdline.o /usr/src/packages/BUILD/gtp/.libs/libgtp.so -L../gtp ../lib/libmisc.a -ltalloc /usr/lib/x86_64-linux-gnu/libosmoctrl.so /usr/lib/x86_64-linux-gnu/libosmogsm.so /usr/lib/x86_64-linux-gnu/libosmocore.so [ 116s] /usr/lib/x86_64-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 116s] collect2: error: ld returned 1 exit status [ 116s] Makefile:413: recipe for target 'ggsn' failed [ 116s] make[3]: *** [ggsn] Error 1 [ 116s] make[3]: Leaving directory '/usr/src/packages/BUILD/ggsn' [ 116s] Makefile:485: recipe for target 'all-recursive' failed [ 116s] make[2]: *** [all-recursive] Error 1 [ 116s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 116s] Makefile:386: recipe for target 'all' failed [ 116s] make[1]: *** [all] Error 2 [ 116s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 116s] dh_auto_build: make -j1 returned exit code 2 [ 116s] debian/rules:11: recipe for target 'build' failed [ 116s] make: *** [build] Error 2 [ 116s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 116s] [ 116s] cloud125 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:55 UTC 2017. [ 116s] [ 116s] ### VM INTERACTION START ### [ 119s] [ 97.230952] reboot: Power down [ 121s] ### VM INTERACTION END ### [ 121s] [ 121s] cloud125 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:55:59 UTC 2017. [ 121s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:56:24 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:56:24 +0000 Subject: Build failure of network:osmocom:nightly/openggsn in xUbuntu_16.04/x86_64 In-Reply-To: References: Message-ID: <58af3e7bd0e92_5676ed1c00334515@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openggsn/xUbuntu_16.04/x86_64 Package network:osmocom:nightly/openggsn failed to build in xUbuntu_16.04/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly openggsn Last lines of build log: [ 140s] cmdline.c:612:7: warning: variable 'check_required' set but not used [-Wunused-but-set-variable] [ 140s] int check_required; [ 140s] ^ [ 141s] /bin/bash ../libtool --tag=CC --mode=link gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR='"/usr/sbin"' -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o ggsn ggsn.o cmdline.o -lgtp -L../gtp ../lib/libmisc.a -ltalloc -losmocore -ltalloc -losmoctrl -losmogsm -losmocore [ 141s] libtool: link: gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR=\"/usr/sbin\" -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -o .libs/ggsn ggsn.o cmdline.o /usr/src/packages/BUILD/gtp/.libs/libgtp.so -L../gtp ../lib/libmisc.a -ltalloc /usr/lib/x86_64-linux-gnu/libosmoctrl.so /usr/lib/x86_64-linux-gnu/libosmogsm.so /usr/lib/x86_64-linux-gnu/libosmocore.so [ 141s] /usr/lib/x86_64-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 141s] collect2: error: ld returned 1 exit status [ 141s] Makefile:413: recipe for target 'ggsn' failed [ 141s] make[3]: *** [ggsn] Error 1 [ 141s] make[3]: Leaving directory '/usr/src/packages/BUILD/ggsn' [ 141s] Makefile:485: recipe for target 'all-recursive' failed [ 141s] make[2]: *** [all-recursive] Error 1 [ 141s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 141s] Makefile:386: recipe for target 'all' failed [ 141s] make[1]: *** [all] Error 2 [ 141s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 141s] dh_auto_build: make -j1 returned exit code 2 [ 141s] debian/rules:11: recipe for target 'build' failed [ 141s] make: *** [build] Error 2 [ 141s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 141s] [ 141s] cloud101 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:56:10 UTC 2017. [ 141s] [ 141s] ### VM INTERACTION START ### [ 144s] [ 119.158455] reboot: Power down [ 146s] ### VM INTERACTION END ### [ 146s] [ 146s] cloud101 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:56:15 UTC 2017. [ 146s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:56:24 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:56:24 +0000 Subject: Build failure of network:osmocom:nightly/osmo-pcu in Debian_8.0/i586 In-Reply-To: References: Message-ID: <58af3e7c7ffce_5676ed1c003346c8@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-pcu/Debian_8.0/i586 Package network:osmocom:nightly/osmo-pcu failed to build in Debian_8.0/i586 Check out the package for editing: osc checkout network:osmocom:nightly osmo-pcu Last lines of build log: [ 114s] gprs_debug.cpp:53:66: error: 'LOGGING_CTX_GB_BVC' was not declared in this scope [ 114s] const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; [ 114s] ^ [ 114s] gprs_debug.cpp:56:31: error: 'LOGGING_FILTER_GB_NSVC' was not declared in this scope [ 114s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 [ 114s] ^ [ 114s] gprs_debug.cpp:61:31: error: 'LOGGING_FILTER_GB_BVC' was not declared in this scope [ 114s] if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 [ 114s] ^ [ 114s] Makefile:767: recipe for target 'gprs_debug.lo' failed [ 114s] make[2]: *** [gprs_debug.lo] Error 1 [ 114s] make[2]: Leaving directory '/usr/src/packages/BUILD/src' [ 114s] Makefile:392: recipe for target 'all-recursive' failed [ 114s] make[1]: *** [all-recursive] Error 1 [ 114s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 114s] dh_auto_build: make -j1 returned exit code 2 [ 114s] debian/rules:12: recipe for target 'build' failed [ 114s] make: *** [build] Error 2 [ 114s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 114s] [ 114s] cloud108 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:56:17 UTC 2017. [ 114s] [ 114s] ### VM INTERACTION START ### [ 115s] Powering off. [ 116s] [ 93.315915] reboot: Power down [ 117s] ### VM INTERACTION END ### [ 117s] [ 117s] cloud108 failed "build osmo-pcu_0.3.20170223.dsc" at Thu Feb 23 19:56:21 UTC 2017. [ 117s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:56:41 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:56:41 +0000 Subject: Build failure of network:osmocom:nightly/openggsn in xUbuntu_16.10/i586 In-Reply-To: References: Message-ID: <58af3e7ce4dcc_5676ed1c0033473c@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openggsn/xUbuntu_16.10/i586 Package network:osmocom:nightly/openggsn failed to build in xUbuntu_16.10/i586 Check out the package for editing: osc checkout network:osmocom:nightly openggsn Last lines of build log: [ 126s] cmdline.c:612:7: warning: variable 'check_required' set but not used [-Wunused-but-set-variable] [ 126s] int check_required; [ 126s] ^~~~~~~~~~~~~~ [ 126s] /bin/bash ../libtool --tag=CC --mode=link gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR='"/usr/sbin"' -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o ggsn ggsn.o cmdline.o -lgtp -L../gtp ../lib/libmisc.a -ltalloc -losmocore -ltalloc -losmoctrl -losmogsm -losmocore [ 127s] libtool: link: gcc -O2 -D_GNU_SOURCE -fno-builtin -Wall -DSBINDIR=\"/usr/sbin\" -ggdb -I/usr/include/ -I/usr/include/ -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z -Wl,relro -Wl,-z -Wl,now -o .libs/ggsn ggsn.o cmdline.o /usr/src/packages/BUILD/gtp/.libs/libgtp.so -L../gtp ../lib/libmisc.a -ltalloc /usr/lib/i386-linux-gnu/libosmoctrl.so /usr/lib/i386-linux-gnu/libosmogsm.so /usr/lib/i386-linux-gnu/libosmocore.so [ 127s] /usr/lib/i386-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 127s] collect2: error: ld returned 1 exit status [ 127s] Makefile:413: recipe for target 'ggsn' failed [ 127s] make[3]: *** [ggsn] Error 1 [ 127s] make[3]: Leaving directory '/usr/src/packages/BUILD/ggsn' [ 127s] Makefile:485: recipe for target 'all-recursive' failed [ 127s] make[2]: *** [all-recursive] Error 1 [ 127s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 127s] Makefile:386: recipe for target 'all' failed [ 127s] make[1]: *** [all] Error 2 [ 127s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 127s] dh_auto_build: make -j1 returned exit code 2 [ 127s] debian/rules:11: recipe for target 'build' failed [ 127s] make: *** [build] Error 2 [ 127s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 127s] [ 127s] cloud133 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:56:19 UTC 2017. [ 127s] [ 127s] ### VM INTERACTION START ### [ 130s] [ 107.426518] reboot: Power down [ 131s] ### VM INTERACTION END ### [ 131s] [ 131s] cloud133 failed "build openggsn_0.93.20170223.dsc" at Thu Feb 23 19:56:24 UTC 2017. [ 131s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 19:59:50 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 19:59:50 +0000 Subject: Build failure of network:osmocom:nightly/openbsc in Debian_8.0/x86_64 In-Reply-To: References: Message-ID: <58af3f3ea8425_5684ed1c003522b@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/Debian_8.0/x86_64 Package network:osmocom:nightly/openbsc failed to build in Debian_8.0/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly openbsc Last lines of build log: [ 92s] debug.c:211:61: error: 'LOGGING_FILTER_VLR_SUBSCR' undeclared (first use in this function) [ 92s] struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; [ 92s] ^ [ 92s] Makefile:437: recipe for target 'debug.o' failed [ 92s] make[4]: *** [debug.o] Error 1 [ 92s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/src/libcommon' [ 92s] Makefile:407: recipe for target 'all-recursive' failed [ 92s] make[3]: *** [all-recursive] Error 1 [ 93s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/src' [ 93s] Makefile:475: recipe for target 'all-recursive' failed [ 93s] make[2]: *** [all-recursive] Error 1 [ 93s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 93s] Makefile:392: recipe for target 'all' failed [ 93s] make[1]: *** [all] Error 2 [ 93s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 93s] dh_auto_build: make -j1 returned exit code 2 [ 93s] debian/rules:13: recipe for target 'build' failed [ 93s] make: *** [build] Error 2 [ 93s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 93s] [ 93s] lamb66 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 19:59:35 UTC 2017. [ 93s] [ 93s] ### VM INTERACTION START ### [ 94s] Powering off. [ 94s] [ 79.095586] reboot: Power down [ 94s] ### VM INTERACTION END ### [ 94s] [ 94s] lamb66 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 19:59:37 UTC 2017. [ 94s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:01:34 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:01:34 +0000 Subject: Build failure of network:osmocom:nightly/osmo-bts in Debian_8.0/x86_64 In-Reply-To: References: Message-ID: <58af3faae85dd_5684ed1c0035236d@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-bts/Debian_8.0/x86_64 Package network:osmocom:nightly/osmo-bts failed to build in Debian_8.0/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly osmo-bts Last lines of build log: [ 93s] CCLD osmo-bts-trx [ 93s] /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 93s] collect2: error: ld returned 1 exit status [ 93s] Makefile:359: recipe for target 'osmo-bts-trx' failed [ 93s] make[4]: *** [osmo-bts-trx] Error 1 [ 93s] make[4]: Leaving directory '/usr/src/packages/BUILD/src/osmo-bts-trx' [ 93s] Makefile:330: recipe for target 'all-recursive' failed [ 93s] make[3]: *** [all-recursive] Error 1 [ 93s] make[3]: Leaving directory '/usr/src/packages/BUILD/src' [ 93s] Makefile:380: recipe for target 'all-recursive' failed [ 93s] make[2]: *** [all-recursive] Error 1 [ 93s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 93s] Makefile:320: recipe for target 'all' failed [ 93s] make[1]: *** [all] Error 2 [ 93s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 93s] dh_auto_build: make -j1 returned exit code 2 [ 93s] debian/rules:12: recipe for target 'build' failed [ 93s] make: *** [build] Error 2 [ 93s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 93s] [ 93s] lamb55 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:01:22 UTC 2017. [ 93s] [ 93s] ### VM INTERACTION START ### [ 95s] Powering off. [ 95s] [ 80.683391] reboot: Power down [ 95s] ### VM INTERACTION END ### [ 95s] [ 95s] lamb55 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:01:24 UTC 2017. [ 95s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:02:11 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:02:11 +0000 Subject: Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.10/x86_64 In-Reply-To: References: Message-ID: <58af3fdca1e16_5684ed1c00352573@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.10/x86_64 Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.10/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly openbsc Last lines of build log: [ 107s] debug.c: In function 'log_set_imsi_filter': [ 107s] debug.c:211:61: error: 'LOGGING_FILTER_VLR_SUBSCR' undeclared (first use in this function) [ 107s] struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; [ 107s] ^~~~~~~~~~~~~~~~~~~~~~~~~ [ 107s] Makefile:447: recipe for target 'debug.o' failed [ 107s] make[4]: *** [debug.o] Error 1 [ 107s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/src/libcommon' [ 107s] Makefile:418: recipe for target 'all-recursive' failed [ 107s] make[3]: *** [all-recursive] Error 1 [ 107s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/src' [ 107s] Makefile:486: recipe for target 'all-recursive' failed [ 107s] make[2]: *** [all-recursive] Error 1 [ 107s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 107s] Makefile:404: recipe for target 'all' failed [ 107s] make[1]: *** [all] Error 2 [ 107s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 107s] dh_auto_build: make -j1 returned exit code 2 [ 107s] debian/rules:13: recipe for target 'build' failed [ 107s] make: *** [build] Error 2 [ 107s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 107s] [ 107s] cloud108 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 20:02:02 UTC 2017. [ 107s] [ 107s] ### VM INTERACTION START ### [ 110s] [ 87.880094] reboot: Power down [ 112s] ### VM INTERACTION END ### [ 112s] [ 112s] cloud108 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 20:02:07 UTC 2017. [ 112s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:02:25 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:02:25 +0000 Subject: Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.10/i586 In-Reply-To: References: Message-ID: <58af3fddb1472_5684ed1c00352647@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.10/i586 Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.10/i586 Check out the package for editing: osc checkout network:osmocom:nightly openbsc Last lines of build log: [ 109s] debug.c: In function 'log_set_imsi_filter': [ 109s] debug.c:211:61: error: 'LOGGING_FILTER_VLR_SUBSCR' undeclared (first use in this function) [ 109s] struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; [ 109s] ^~~~~~~~~~~~~~~~~~~~~~~~~ [ 109s] Makefile:447: recipe for target 'debug.o' failed [ 109s] make[4]: *** [debug.o] Error 1 [ 109s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/src/libcommon' [ 109s] Makefile:418: recipe for target 'all-recursive' failed [ 109s] make[3]: *** [all-recursive] Error 1 [ 109s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/src' [ 109s] Makefile:486: recipe for target 'all-recursive' failed [ 109s] make[2]: *** [all-recursive] Error 1 [ 109s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 109s] Makefile:404: recipe for target 'all' failed [ 109s] make[1]: *** [all] Error 2 [ 109s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 109s] dh_auto_build: make -j1 returned exit code 2 [ 109s] debian/rules:13: recipe for target 'build' failed [ 109s] make: *** [build] Error 2 [ 109s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 109s] [ 109s] cloud109 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 20:02:15 UTC 2017. [ 109s] [ 109s] ### VM INTERACTION START ### [ 112s] [ 89.824532] reboot: Power down [ 114s] ### VM INTERACTION END ### [ 114s] [ 114s] cloud109 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 20:02:20 UTC 2017. [ 114s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:04:41 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:04:41 +0000 Subject: Build failure of network:osmocom:nightly/osmo-bts in xUbuntu_16.10/x86_64 In-Reply-To: References: Message-ID: <58af407dca8fa_567ded1c00333691@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-bts/xUbuntu_16.10/x86_64 Package network:osmocom:nightly/osmo-bts failed to build in xUbuntu_16.10/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly osmo-bts Last lines of build log: [ 108s] loops.c: In function 'trx_loop_amr_input': [ 108s] loops.c:254:6: warning: variable 'c_i' set but not used [-Wunused-but-set-variable] [ 108s] int c_i; [ 108s] ^~~ [ 108s] gcc -Wall -fno-strict-aliasing -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -D_REENTRANT -DORTP_INET6 -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o osmo-bts-trx main.o trx_if.o l1_if.o scheduler_trx.o trx_vty.o gsm0503_parity.o gsm0503_conv.o gsm0503_interleaving.o gsm0503_mapping.o gsm0503_coding.o gsm0503_tables.o loops.o ../../src/common/libbts.a ../../src/common/libl1sched.a -ltalloc -losmocore -ltalloc -losmogsm -losmocore -losmocodec -ltalloc -losmovty -losmocore -losmotrau -losmoabis -ltalloc -losmoctrl -losmogsm -losmocore -lortp -lpthread -lrt [ 108s] /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 108s] collect2: error: ld returned 1 exit status [ 108s] Makefile:369: recipe for target 'osmo-bts-trx' failed [ 108s] make[4]: *** [osmo-bts-trx] Error 1 [ 108s] make[4]: Leaving directory '/usr/src/packages/BUILD/src/osmo-bts-trx' [ 108s] Makefile:341: recipe for target 'all-recursive' failed [ 108s] make[3]: *** [all-recursive] Error 1 [ 108s] make[3]: Leaving directory '/usr/src/packages/BUILD/src' [ 108s] Makefile:390: recipe for target 'all-recursive' failed [ 108s] make[2]: *** [all-recursive] Error 1 [ 108s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 108s] Makefile:331: recipe for target 'all' failed [ 108s] make[1]: *** [all] Error 2 [ 108s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 108s] dh_auto_build: make -j1 returned exit code 2 [ 108s] debian/rules:12: recipe for target 'build' failed [ 108s] make: *** [build] Error 2 [ 108s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 108s] [ 108s] cloud125 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:04:19 UTC 2017. [ 108s] [ 108s] ### VM INTERACTION START ### [ 111s] [ 89.531362] reboot: Power down [ 113s] ### VM INTERACTION END ### -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:05:20 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:05:20 +0000 Subject: Build failure of network:osmocom:nightly/osmo-bts in xUbuntu_16.10/i586 In-Reply-To: References: Message-ID: <58af409521e04_5684ed1c0035278a@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-bts/xUbuntu_16.10/i586 Package network:osmocom:nightly/osmo-bts failed to build in xUbuntu_16.10/i586 Check out the package for editing: osc checkout network:osmocom:nightly osmo-bts Last lines of build log: [ 114s] int c_i; [ 114s] ^~~ [ 114s] gcc -Wall -fno-strict-aliasing -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -D_REENTRANT -DORTP_INET6 -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o osmo-bts-trx main.o trx_if.o l1_if.o scheduler_trx.o trx_vty.o gsm0503_parity.o gsm0503_conv.o gsm0503_interleaving.o gsm0503_mapping.o gsm0503_coding.o gsm0503_tables.o loops.o ../../src/common/libbts.a ../../src/common/libl1sched.a -ltalloc -losmocore -ltalloc -losmogsm -losmocore -losmocodec -ltalloc -losmovty -losmocore -losmotrau -losmoabis -ltalloc -losmoctrl -losmogsm -losmocore -lortp -lpthread -lrt [ 114s] /usr/lib/gcc/i686-linux-gnu/6/../../../i386-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 114s] collect2: error: ld returned 1 exit status [ 114s] Makefile:369: recipe for target 'osmo-bts-trx' failed [ 114s] make[4]: *** [osmo-bts-trx] Error 1 [ 114s] make[4]: Leaving directory '/usr/src/packages/BUILD/src/osmo-bts-trx' [ 114s] Makefile:341: recipe for target 'all-recursive' failed [ 114s] make[3]: *** [all-recursive] Error 1 [ 114s] make[3]: Leaving directory '/usr/src/packages/BUILD/src' [ 114s] Makefile:390: recipe for target 'all-recursive' failed [ 114s] make[2]: *** [all-recursive] Error 1 [ 114s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 114s] Makefile:331: recipe for target 'all' failed [ 114s] make[1]: *** [all] Error 2 [ 114s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 114s] dh_auto_build: make -j1 returned exit code 2 [ 114s] debian/rules:12: recipe for target 'build' failed [ 114s] make: *** [build] Error 2 [ 114s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 114s] [ 114s] cloud124 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:05:03 UTC 2017. [ 114s] [ 114s] ### VM INTERACTION START ### [ 119s] ### VM INTERACTION END ### [ 119s] [ 119s] cloud124 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:05:08 UTC 2017. [ 119s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:05:54 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:05:54 +0000 Subject: Build failure of network:osmocom:nightly/openbsc in xUbuntu_16.04/x86_64 In-Reply-To: References: Message-ID: <58af40b39dcb2_5684ed1c003529f0@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/openbsc/xUbuntu_16.04/x86_64 Package network:osmocom:nightly/openbsc failed to build in xUbuntu_16.04/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly openbsc Last lines of build log: [ 97s] debug.c: In function 'log_set_imsi_filter': [ 97s] debug.c:211:61: error: 'LOGGING_FILTER_VLR_SUBSCR' undeclared (first use in this function) [ 97s] struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; [ 97s] ^ [ 97s] Makefile:447: recipe for target 'debug.o' failed [ 97s] make[4]: *** [debug.o] Error 1 [ 97s] make[4]: Leaving directory '/usr/src/packages/BUILD/openbsc/src/libcommon' [ 97s] Makefile:418: recipe for target 'all-recursive' failed [ 97s] make[3]: *** [all-recursive] Error 1 [ 97s] make[3]: Leaving directory '/usr/src/packages/BUILD/openbsc/src' [ 97s] Makefile:486: recipe for target 'all-recursive' failed [ 97s] make[2]: *** [all-recursive] Error 1 [ 97s] make[2]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 97s] Makefile:404: recipe for target 'all' failed [ 97s] make[1]: *** [all] Error 2 [ 97s] make[1]: Leaving directory '/usr/src/packages/BUILD/openbsc' [ 97s] dh_auto_build: make -j1 returned exit code 2 [ 97s] debian/rules:13: recipe for target 'build' failed [ 97s] make: *** [build] Error 2 [ 97s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 97s] [ 97s] lamb64 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 20:05:47 UTC 2017. [ 97s] [ 97s] ### VM INTERACTION START ### [ 100s] [ 87.125008] reboot: Power down [ 100s] ### VM INTERACTION END ### [ 100s] [ 100s] lamb64 failed "build openbsc_0.15.1.20170223.dsc" at Thu Feb 23 20:05:51 UTC 2017. [ 100s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From admin at opensuse.org Thu Feb 23 20:07:55 2017 From: admin at opensuse.org (OBS Notification) Date: Thu, 23 Feb 2017 20:07:55 +0000 Subject: Build failure of network:osmocom:nightly/osmo-bts in xUbuntu_16.04/x86_64 In-Reply-To: References: Message-ID: <58af412ca274a_567ded1c003338e1@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/osmo-bts/xUbuntu_16.04/x86_64 Package network:osmocom:nightly/osmo-bts failed to build in xUbuntu_16.04/x86_64 Check out the package for editing: osc checkout network:osmocom:nightly osmo-bts Last lines of build log: [ 100s] ^ [ 100s] gcc -Wall -fno-strict-aliasing -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -I/usr/include/ -D_REENTRANT -DORTP_INET6 -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -o osmo-bts-trx main.o trx_if.o l1_if.o scheduler_trx.o trx_vty.o gsm0503_parity.o gsm0503_conv.o gsm0503_interleaving.o gsm0503_mapping.o gsm0503_coding.o gsm0503_tables.o loops.o ../../src/common/libbts.a ../../src/common/libl1sched.a -ltalloc -losmocore -ltalloc -losmogsm -losmocore -losmocodec -ltalloc -losmovty -losmocore -losmotrau -losmoabis -ltalloc -losmoctrl -losmogsm -losmocore -lortp -lpthread -lrt [ 100s] /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libosmoctrl.so: undefined reference to `osmo_sock_init_ifd' [ 100s] collect2: error: ld returned 1 exit status [ 100s] Makefile:369: recipe for target 'osmo-bts-trx' failed [ 100s] make[4]: *** [osmo-bts-trx] Error 1 [ 100s] make[4]: Leaving directory '/usr/src/packages/BUILD/src/osmo-bts-trx' [ 100s] Makefile:341: recipe for target 'all-recursive' failed [ 100s] make[3]: *** [all-recursive] Error 1 [ 100s] make[3]: Leaving directory '/usr/src/packages/BUILD/src' [ 100s] Makefile:390: recipe for target 'all-recursive' failed [ 100s] make[2]: *** [all-recursive] Error 1 [ 100s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 100s] Makefile:331: recipe for target 'all' failed [ 100s] make[1]: *** [all] Error 2 [ 100s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 100s] dh_auto_build: make -j1 returned exit code 2 [ 100s] debian/rules:12: recipe for target 'build' failed [ 100s] make: *** [build] Error 2 [ 100s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 100s] [ 100s] lamb04 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:07:43 UTC 2017. [ 100s] [ 100s] ### VM INTERACTION START ### [ 103s] [ 90.843408] reboot: Power down [ 104s] ### VM INTERACTION END ### [ 104s] [ 104s] lamb04 failed "build osmo-bts_0.5.0.20170223.dsc" at Thu Feb 23 20:07:47 UTC 2017. [ 104s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:08:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:08:13 +0000 Subject: [PATCH] libosmocore[master]: libosmoctrl: Fix typo in ctrl_interface_connect() Message-ID: Review at https://gerrit.osmocom.org/1885 libosmoctrl: Fix typo in ctrl_interface_connect() it's osmo_sock_init_ofd(), not osmo_sock_init_ifd() Change-Id: Ia6a82031a691403f641815862613d99b31a3a159 --- M src/ctrl/control_if.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/1885/1 diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index cf79670..d78b513 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -681,7 +681,7 @@ ctrl->listen_fd.cb = NULL; ctrl->listen_fd.data = ctrl; - ret = osmo_sock_init_ifd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, + ret = osmo_sock_init_ofd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT); if (ret < 0) { LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n", -- To view, visit https://gerrit.osmocom.org/1885 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia6a82031a691403f641815862613d99b31a3a159 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:10:10 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:10:10 +0000 Subject: libosmocore[master]: libosmoctrl: Fix typo in ctrl_interface_connect() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1885 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia6a82031a691403f641815862613d99b31a3a159 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:10:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:10:12 +0000 Subject: [MERGED] libosmocore[master]: libosmoctrl: Fix typo in ctrl_interface_connect() In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: libosmoctrl: Fix typo in ctrl_interface_connect() ...................................................................... libosmoctrl: Fix typo in ctrl_interface_connect() it's osmo_sock_init_ofd(), not osmo_sock_init_ifd() Change-Id: Ia6a82031a691403f641815862613d99b31a3a159 --- M src/ctrl/control_if.c 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index cf79670..d78b513 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -681,7 +681,7 @@ ctrl->listen_fd.cb = NULL; ctrl->listen_fd.data = ctrl; - ret = osmo_sock_init_ifd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, + ret = osmo_sock_init_ofd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT); if (ret < 0) { LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n", -- To view, visit https://gerrit.osmocom.org/1885 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia6a82031a691403f641815862613d99b31a3a159 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:11:26 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:11:26 +0000 Subject: [PATCH] openggsn[master]: gtp-kernel: Fix tunnel creation/removal for GTP Version 1 In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1882 to look at the new patch set (#2). gtp-kernel: Fix tunnel creation/removal for GTP Version 1 When Linux Kernel GTP-U support is enabled, OpenGGSN so far only worked with GTPv0,but not with GTPv1, as the TEI values were not correctly configured. This patch fixes the initialzation of the local and remote TEI before using libgtpnl to create a tunnel context in the kernel. Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 --- M ggsn/gtp-kernel.c 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/82/1882/2 diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c index 93dea23..dbe5a9f 100644 --- a/ggsn/gtp-kernel.c +++ b/ggsn/gtp-kernel.c @@ -192,7 +192,10 @@ gtp_tunnel_set_tid(t, pdp_gettid(pdp->imsi, pdp->nsapi)); gtp_tunnel_set_flowid(t, pdp->flru); } else { - gtp_tunnel_set_tid(t, pdp->teid_gn); /* GTPIE_TEI_DI */ + gtp_tunnel_set_i_tei(t, pdp->teid_own); + /* use the TEI advertised by SGSN when sending packets + * towards the SGSN */ + gtp_tunnel_set_o_tei(t, pdp->teid_gn); } ret = gtp_add_tunnel(gtp_nl.genl_id, gtp_nl.nl, t); @@ -221,7 +224,7 @@ gtp_tunnel_set_tid(t, pdp_gettid(pdp->imsi, pdp->nsapi)); gtp_tunnel_set_flowid(t, pdp->flru); } else { - gtp_tunnel_set_tid(t, pdp->teid_gn); /* GTPIE_TEI_DI */ + gtp_tunnel_set_i_tei(t, pdp->teid_own); } ret = gtp_del_tunnel(gtp_nl.genl_id, gtp_nl.nl, t); -- To view, visit https://gerrit.osmocom.org/1882 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:11:26 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:11:26 +0000 Subject: [PATCH] openggsn[master]: gtp.c: Don't print ""Unknown packet flags" error message in ... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1883 to look at the new patch set (#2). gtp.c: Don't print ""Unknown packet flags" error message in get_seq() get_seq() is called also from contexts where GTP-U is used, and GTP-U doesn't have sequence numbers. Thus, it is perfectly normal if no sequence number and/or no S flag in the header is present. Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da --- M gtp/gtp.c 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/83/1883/2 diff --git a/gtp/gtp.c b/gtp/gtp.c index 42aa4ea..ade746a 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -210,7 +210,6 @@ } else if ((packet->flags & 0xe2) == 0x22) { /* Version 1 with seq */ return ntoh16(packet->gtp1l.h.seq); } else { - LOGP(DLGTP, LOGL_ERROR, "Unknown packet flags: 0x%02x\n", packet->flags); return 0; } } -- To view, visit https://gerrit.osmocom.org/1883 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:12:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:12:57 +0000 Subject: openggsn[master]: gtp-kernel: Fix tunnel creation/removal for GTP Version 1 In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1882 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:13:05 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:13:05 +0000 Subject: openggsn[master]: gtp.c: Don't print ""Unknown packet flags" error message in ... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1883 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:13:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:13:41 +0000 Subject: [MERGED] openggsn[master]: gtp.c: Don't print ""Unknown packet flags" error message in ... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gtp.c: Don't print ""Unknown packet flags" error message in get_seq() ...................................................................... gtp.c: Don't print ""Unknown packet flags" error message in get_seq() get_seq() is called also from contexts where GTP-U is used, and GTP-U doesn't have sequence numbers. Thus, it is perfectly normal if no sequence number and/or no S flag in the header is present. Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da --- M gtp/gtp.c 1 file changed, 0 insertions(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/gtp/gtp.c b/gtp/gtp.c index 42aa4ea..ade746a 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -210,7 +210,6 @@ } else if ((packet->flags & 0xe2) == 0x22) { /* Version 1 with seq */ return ntoh16(packet->gtp1l.h.seq); } else { - LOGP(DLGTP, LOGL_ERROR, "Unknown packet flags: 0x%02x\n", packet->flags); return 0; } } -- To view, visit https://gerrit.osmocom.org/1883 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:13:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:13:41 +0000 Subject: [MERGED] openggsn[master]: gtp-kernel: Fix tunnel creation/removal for GTP Version 1 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: gtp-kernel: Fix tunnel creation/removal for GTP Version 1 ...................................................................... gtp-kernel: Fix tunnel creation/removal for GTP Version 1 When Linux Kernel GTP-U support is enabled, OpenGGSN so far only worked with GTPv0,but not with GTPv1, as the TEI values were not correctly configured. This patch fixes the initialzation of the local and remote TEI before using libgtpnl to create a tunnel context in the kernel. Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 --- M ggsn/gtp-kernel.c 1 file changed, 5 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c index 93dea23..dbe5a9f 100644 --- a/ggsn/gtp-kernel.c +++ b/ggsn/gtp-kernel.c @@ -192,7 +192,10 @@ gtp_tunnel_set_tid(t, pdp_gettid(pdp->imsi, pdp->nsapi)); gtp_tunnel_set_flowid(t, pdp->flru); } else { - gtp_tunnel_set_tid(t, pdp->teid_gn); /* GTPIE_TEI_DI */ + gtp_tunnel_set_i_tei(t, pdp->teid_own); + /* use the TEI advertised by SGSN when sending packets + * towards the SGSN */ + gtp_tunnel_set_o_tei(t, pdp->teid_gn); } ret = gtp_add_tunnel(gtp_nl.genl_id, gtp_nl.nl, t); @@ -221,7 +224,7 @@ gtp_tunnel_set_tid(t, pdp_gettid(pdp->imsi, pdp->nsapi)); gtp_tunnel_set_flowid(t, pdp->flru); } else { - gtp_tunnel_set_tid(t, pdp->teid_gn); /* GTPIE_TEI_DI */ + gtp_tunnel_set_i_tei(t, pdp->teid_own); } ret = gtp_del_tunnel(gtp_nl.genl_id, gtp_nl.nl, t); -- To view, visit https://gerrit.osmocom.org/1882 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3e953ff5b4ab44c26dbbe20d18b61038fa57ff32 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:55:59 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:55:59 +0000 Subject: [PATCH] openggsn[master]: update version to 0.93 Message-ID: Review at https://gerrit.osmocom.org/1886 update version to 0.93 Change-Id: If65b8281933b5833b5ce83239688e775cc267f4c --- M configure.ac 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/86/1886/1 diff --git a/configure.ac b/configure.ac index 1a36357..2422616 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(openggsn, 0.92, laforge at gnumonks.org) +AC_INIT(openggsn, 0.93, laforge at gnumonks.org) AC_CONFIG_SRCDIR([gtp/gtp.c]) AM_CONFIG_HEADER([config.h]) #AC_CONFIG_HEADER([config.h]) -- To view, visit https://gerrit.osmocom.org/1886 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If65b8281933b5833b5ce83239688e775cc267f4c Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 23 20:55:59 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 20:55:59 +0000 Subject: [PATCH] openggsn[master]: remove ChangeLog, it hasn't been updated since 2004 Message-ID: Review at https://gerrit.osmocom.org/1887 remove ChangeLog, it hasn't been updated since 2004 We have a detailed log in git instead. Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 --- D ChangeLog 1 file changed, 0 insertions(+), 142 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/87/1887/1 diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 3beba46..0000000 --- a/ChangeLog +++ /dev/null @@ -1,142 +0,0 @@ -2004-12-30: Jens Jakobsen - Initial MAC OS X support - - Quality assurance and improved error logging - - QoS length bug fix. - -2004-09-11: Jens Jakobsen - Added selection mode option to sgsnemu. - Added charging characteristics option to sgsnemu. - - Only include charging characteristics in create PDP context - request is if flags are set. (Thanks to Loic Bernable - ). - - PPP PCO length bug fix. (Thanks to Loic Bernable - ). - - IP pool hash table bugfix and improved logging. - - Improved configure.in and Makefile.am for compilation under - Solaris. New config.sub and config.guess. - -2004-04-28: Jens Jakobsen - Improved Solaris support. OpenGGSN now correctly initializes - tun/tap driver under Solaris. As a consequence the ggsn network - interface IP address is set to the network address plus one. - - Added routing manipulation and IP address alias capability for - FreeBSD. - -2004-01-19: Jens Jakobsen - Initial FreeBSD port (Thanks to Pavel Andreev ). - - IMSI bugfix. The IMSI encoding used by create PDP context was - missing the leading '1111' to indicate that the 16'nd digit was - unused. (Thanks to Pavel Andreev ). - - -2004-01-15: Jens Jakobsen - Added iptables firewall script. - - -2004-01-14: Jens Jakobsen - Changes to allow compilation under Solaris: u_int8_t changed to uint8_t - and tun api changed for sun platform (#ifdef). - - -2004-01-09: Jens Jakobsen - Fixed bug which included NSAPI in GTPv0 create PDP context messages. - - -2003-11-10: Jens Jakobsen - Added --net option for sgsnemu. Allow user to specify the network - address and mask of the local interface. - - Added --gtpversion option for sgsnemu. Allow user to specify which - GTP version to use. - - Added --nsapi option for sgsnemu. Allow user to specify which - NSAPI to use. - - Changed the functionality for multiple contexts. Previously - contexts were differentiated by nsapi. This limited the number of - contexts to 16. Now each context is established with a new imsi - and msisdn. - - -2003-10-22: Jens Jakobsen - Support for GTP1. Currently without support for the secondary pdp - context activation procedure. - - sgsnemu will first attempt to use GTP1. If that fails it will - proceed with GTP0. - - Various gtplib API changes to allow support for GTP1. - - gtplib now listens to 3 separate UDP ports: GTP0, GTP1 control - plane and GTP1 user plane. A socket for each port has to be - included in the application select loop. - - gtplib now verifies that messages are valid for the particular - type of support node. As an example a received Create PDP Context - Request message is not allowed for an SGSN. - - Standards compliance document. - - -2003-07-07: Jens Jakobsen - Added spec.in file for building binary RPM packages. Now openggsn - will install binaries, man pages as well as scripts. - - Added ggsn and sgsnemu man pages - - Added ggsn Sys V init script - - Added bootstrap script for autotools automation - - -2003-04-11: Jens Jakobsen - Added -ggdb to gtp, sgsnemu and ggsn makefiles in order to include - debugging information. - - Added ippool.c and ippool.h to ggsn. This allows for generic - allocation of dynamic ip addresses based on a / - description of ip address space. The same files are also used in - sgsnemu, but only for hashing IP addresses. At the same time the - corresponding functionality is removed from pdp.c. - - Added syserr.h and syserr.c to ggsn and sgsnemu. These files allow - writing to syslog with file name and line number. Later this - should also be introduced in gtp. - - Added support for DNS protocol configuration options in ggsn for - create context response. This allow the MS to setup DNS - configuration correctly. - - tun.c and tun.h have been updated to allow setting interface IP - addresses and routes by means of ioctl and netlink. This allow - sgsnemu to allocate an interface IP address for each context - established. - - -2003-01-29: Jens Jakobsen - Added -L../gtp to sgsnemu and ggsn makefiles so that make will - work without an installed libgtp. - - Added sgsnemu check to check for valid pointer when deleting tun. - - Removed enabling of ip_forward = 1 from ggsn.c and sgsnemu. From a - security point of view it was not very good that openggsn - automatically enabled routing. - - Added ipup, ipdown and createif to sgsnemu/cmdline.ggo. Now - sgsnemu will set up default route and then execute ipup script - after tun device has been set up. After tun has been deleted the - ipdown script is executed. - - Added support for ping to sgsnemu. - - Added ipup and ipdown to ggsn/cmdline.ggo. - -- To view, visit https://gerrit.osmocom.org/1887 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:02:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:02:18 +0000 Subject: [PATCH] openggsn[master]: Update AUTHORS file to reflect the last 12 years Message-ID: Review at https://gerrit.osmocom.org/1888 Update AUTHORS file to reflect the last 12 years Change-Id: I0a8f5a69f2a943344331d36ba225c02b0209beeb --- M AUTHORS 1 file changed, 14 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/88/1888/1 diff --git a/AUTHORS b/AUTHORS index 1e71784..5f10990 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,9 +1,16 @@ OpenGGSN - Gateway GPRS Support Node -Copyright (C) 2002 Mondru AB. +Copyright (C) 2002-2004 Mondru AB, Author: Jens Jakobsen +Copyright (C) 2010-2017 Harald Welte +Copyright (C) 2012-2016 Holger Hans Peter Freyther +Copyright (C) 2014-2016 Pablo Neira Ayuso +Copyright (C) 2014-2016 sysmocom - s.f.m.c. GmbH -The initial developer of the original code is -Jens Jakobsen - -Contributor(s): - - +Contributors: +Emmanuel Bretelle +Yann BONNAMY +Eric Butler +Michael McTernan +Alexander Huemer +BJovke +Alexander Couzens +Ruben Undheim -- To view, visit https://gerrit.osmocom.org/1888 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a8f5a69f2a943344331d36ba225c02b0209beeb Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:03:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:03:41 +0000 Subject: [PATCH] openbsc[master]: cosmetic: gsm_data.h, README: rename CSCN to MSC Message-ID: Review at https://gerrit.osmocom.org/1889 cosmetic: gsm_data.h, README: rename CSCN to MSC We're discarding the name OsmoCSCN for the benefit of OsmoMSC. But "CSCN" has already crept into the master branch in two places; apply the rename. See OS#1958 Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d --- M openbsc/README M openbsc/include/openbsc/gsm_data.h 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/89/1889/1 diff --git a/openbsc/README b/openbsc/README index 88ea328..d01b2cf 100644 --- a/openbsc/README +++ b/openbsc/README @@ -9,7 +9,7 @@ * OsmoBSC - a pure GSM BSC, speaking Abis/IP to the BTS and A/IP to the MSC * OsmoBSC-MGCP - MGCP helper to the OsmoBSC software * OsmoNITB - a BSC+MSC+VLR+HLR+SMSC "Network in the box". - * OsmoCSCN - a voice CN with A/IP and IuCS/IP towards the BSC and/or HNB-GW + * OsmoMSC - a voice CN with A/IP and IuCS/IP towards the BSC and/or HNB-GW * OsmoSGSN - a GPRS SGSN with Gb/IP and IuPS/IP towards the PCU and/or HNB-GW * Osmo-GbProxy - a Proxy to aggregate many Gb links as one Gb link to the SGSN * OsmoBSCNAT - a gateway aggregating many A links as one A link to the MSC diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index ac573c4..4425a10 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -379,7 +379,7 @@ * contexts. */ /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable * BTS|RNC specific timezone overrides for multi-tz networks in - * OsmoCSCN, this should be tied to the location area code (LAC). */ + * OsmoMSC, this should be tied to the location area code (LAC). */ struct gsm_tz tz; }; -- To view, visit https://gerrit.osmocom.org/1889 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:03:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:03:41 +0000 Subject: [PATCH] openbsc[master]: cosmetic: clarify BSC's remote MSC data vs. OsmoMSC Message-ID: Review at https://gerrit.osmocom.org/1890 cosmetic: clarify BSC's remote MSC data vs. OsmoMSC Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9 --- M openbsc/include/openbsc/osmo_msc_data.h 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/90/1890/1 diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index a5a3f14..3168d91 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -20,6 +20,10 @@ * */ +/* + * NOTE: This is about a *remote* MSC for OsmoBSC and is not part of libmsc. + */ + #ifndef _OSMO_MSC_DATA_H #define _OSMO_MSC_DATA_H @@ -43,6 +47,8 @@ MSC_CON_TYPE_LOCAL, }; +/*! /brief Information on a remote MSC for libbsc. + */ struct osmo_msc_data { struct llist_head entry; -- To view, visit https://gerrit.osmocom.org/1890 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:03:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:03:42 +0000 Subject: [PATCH] openbsc[master]: cosmetic: rename osmo_msc_data.h to bsc_msc_data.h Message-ID: Review at https://gerrit.osmocom.org/1891 cosmetic: rename osmo_msc_data.h to bsc_msc_data.h With the OsmoMSC program coming up, the name osmo_msc_data becomes even more confusing than it already is. Clearly indicate it as libbsc's data of a remote MSC by prefixing with bsc_. Also, the Osmocom community has in the meantime agreed to have the osmo_ prefix only in libosmocore, to avoid naming conflicts in case things are moved there. So while renaming anyway, also drop the osmo_ prefix. Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607 --- M openbsc/include/openbsc/Makefile.am R openbsc/include/openbsc/bsc_msc_data.h M openbsc/src/libbsc/bsc_ctrl_commands.c M openbsc/src/libbsc/bsc_rf_ctrl.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/libbsc/net_init.c M openbsc/src/libcommon/gsm_data.c M openbsc/src/osmo-bsc/osmo_bsc_api.c M openbsc/src/osmo-bsc/osmo_bsc_audio.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_ctrl.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_main.c M openbsc/src/osmo-bsc/osmo_bsc_msc.c M openbsc/src/osmo-bsc/osmo_bsc_sccp.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/src/osmo-nitb/bsc_hack.c M openbsc/tests/bsc/bsc_test.c 19 files changed, 18 insertions(+), 18 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/91/1891/1 diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 2466ce8..5cd5afc 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -60,7 +60,7 @@ osmo_bsc_grace.h \ osmo_bsc_rf.h \ osmo_msc.h \ - osmo_msc_data.h \ + bsc_msc_data.h \ osmux.h \ paging.h \ rest_octets.h \ diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/bsc_msc_data.h similarity index 100% rename from openbsc/include/openbsc/osmo_msc_data.h rename to openbsc/include/openbsc/bsc_msc_data.h diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c index 14e8d71..641fe2b 100644 --- a/openbsc/src/libbsc/bsc_ctrl_commands.c +++ b/openbsc/src/libbsc/bsc_ctrl_commands.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #define CTRL_CMD_VTY_STRING(cmdname, cmdstr, dtype, element) \ CTRL_HELPER_GET_STRING(cmdname, dtype, element) \ diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c index 59fac35..d13c685 100644 --- a/openbsc/src/libbsc/bsc_rf_ctrl.c +++ b/openbsc/src/libbsc/bsc_rf_ctrl.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 73acebd..0a55cf4 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c index f728d3f..bc5ed35 100644 --- a/openbsc/src/libbsc/net_init.c +++ b/openbsc/src/libbsc/net_init.c @@ -19,7 +19,7 @@ #include #include -#include +#include struct gsm_network *bsc_network_init(void *ctx, uint16_t country_code, diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 75475db..3e12430 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include void *tall_bsc_ctx; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index 49e5796..c3d1384 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_audio.c b/openbsc/src/osmo-bsc/osmo_bsc_audio.c index 660d884..1160209 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_audio.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_audio.c @@ -20,7 +20,7 @@ * */ -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index f38c97f..67325b3 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c index 5352bf2..ffde1b8 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index d5ca2fd..5925d11 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 6409a3a..9a63702 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index adce775..982f471 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 0eb3fa9..e596d2a 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index a571438..09efaf4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 86ccec4..8dabf95 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 2bdfada..dd90b8b 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c index 7174828..1e3fdf7 100644 --- a/openbsc/tests/bsc/bsc_test.c +++ b/openbsc/tests/bsc/bsc_test.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include -- To view, visit https://gerrit.osmocom.org/1891 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:03:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:03:42 +0000 Subject: [PATCH] openbsc[master]: cosmetic: rename struct osmo_msc_data to bsc_msc_data Message-ID: Review at https://gerrit.osmocom.org/1892 cosmetic: rename struct osmo_msc_data to bsc_msc_data With the OsmoMSC program coming up, the name osmo_msc_data becomes even more confusing than it already is. Clearly indicate it as libbsc's data of a remote MSC by prefixing with bsc_. Also, the Osmocom community has in the meantime agreed to have the osmo_ prefix only in libosmocore, to avoid naming conflicts in case things are moved there. So while renaming anyway, also drop the osmo_ prefix. Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab --- M openbsc/include/openbsc/bsc_msc_data.h M openbsc/include/openbsc/osmo_bsc.h M openbsc/include/openbsc/osmo_bsc_grace.h M openbsc/include/openbsc/signal.h M openbsc/src/osmo-bsc/osmo_bsc_api.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_ctrl.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_main.c M openbsc/src/osmo-bsc/osmo_bsc_msc.c M openbsc/src/osmo-bsc/osmo_bsc_sccp.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/tests/bsc/bsc_test.c 14 files changed, 107 insertions(+), 107 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/92/1892/1 diff --git a/openbsc/include/openbsc/bsc_msc_data.h b/openbsc/include/openbsc/bsc_msc_data.h index 3168d91..38e87cf 100644 --- a/openbsc/include/openbsc/bsc_msc_data.h +++ b/openbsc/include/openbsc/bsc_msc_data.h @@ -49,7 +49,7 @@ /*! /brief Information on a remote MSC for libbsc. */ -struct osmo_msc_data { +struct bsc_msc_data { struct llist_head entry; /* Back pointer */ @@ -128,15 +128,15 @@ }; -int osmo_bsc_msc_init(struct osmo_msc_data *msc); +int osmo_bsc_msc_init(struct bsc_msc_data *msc); int osmo_bsc_sccp_init(struct gsm_network *gsmnet); int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto); int msc_queue_write_with_ping(struct bsc_msc_connection *, struct msgb *msg, int proto); int osmo_bsc_audio_init(struct gsm_network *network); -struct osmo_msc_data *osmo_msc_data_find(struct gsm_network *, int); -struct osmo_msc_data *osmo_msc_data_alloc(struct gsm_network *, int); +struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *, int); +struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *, int); #endif diff --git a/openbsc/include/openbsc/osmo_bsc.h b/openbsc/include/openbsc/osmo_bsc.h index fd5303d..9e688fd 100644 --- a/openbsc/include/openbsc/osmo_bsc.h +++ b/openbsc/include/openbsc/osmo_bsc.h @@ -16,7 +16,7 @@ }; struct sccp_connection; -struct osmo_msc_data; +struct bsc_msc_data; struct bsc_msc_connection; struct osmo_bsc_sccp_con { @@ -33,7 +33,7 @@ /* SCCP connection realted */ struct sccp_connection *sccp; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct osmo_timer_list sccp_it_timeout; struct osmo_timer_list sccp_cc_timeout; @@ -51,15 +51,15 @@ int bsc_queue_for_msc(struct osmo_bsc_sccp_con *conn, struct msgb *msg); int bsc_open_connection(struct osmo_bsc_sccp_con *sccp, struct msgb *msg); enum bsc_con bsc_create_new_connection(struct gsm_subscriber_connection *conn, - struct osmo_msc_data *msc, int send_ping); + struct bsc_msc_data *msc, int send_ping); int bsc_delete_connection(struct osmo_bsc_sccp_con *sccp); -struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *); +struct bsc_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *); int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg); int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg); int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn); -int bsc_handle_udt(struct osmo_msc_data *msc, struct msgb *msg, unsigned int length); +int bsc_handle_udt(struct bsc_msc_data *msc, struct msgb *msg, unsigned int length); int bsc_handle_dt1(struct osmo_bsc_sccp_con *conn, struct msgb *msg, unsigned int len); int bsc_ctrl_cmds_install(); diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index af77b2f..ea5e4e2 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -23,9 +23,9 @@ #include -struct osmo_msc_data; +struct bsc_msc_data; int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts); -int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc); +int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct bsc_msc_data *msc); #endif diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index 8f27b38..be154a4 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -223,9 +223,9 @@ S_MSC_AUTHENTICATED, }; -struct osmo_msc_data; +struct bsc_msc_data; struct msc_signal_data { - struct osmo_msc_data *data; + struct bsc_msc_data *data; }; /* SS_CCCH signals */ diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index c3d1384..bac5e47 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -49,30 +49,30 @@ static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause); static int complete_layer3(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct osmo_msc_data *msc); + struct msgb *msg, struct bsc_msc_data *msc); -static uint16_t get_network_code_for_msc(struct osmo_msc_data *msc) +static uint16_t get_network_code_for_msc(struct bsc_msc_data *msc) { if (msc->core_mnc != -1) return msc->core_mnc; return msc->network->network_code; } -static uint16_t get_country_code_for_msc(struct osmo_msc_data *msc) +static uint16_t get_country_code_for_msc(struct bsc_msc_data *msc) { if (msc->core_mcc != -1) return msc->core_mcc; return msc->network->country_code; } -static uint16_t get_lac_for_msc(struct osmo_msc_data *msc, struct gsm_bts *bts) +static uint16_t get_lac_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) { if (msc->core_lac != -1) return msc->core_lac; return bts->location_area_code; } -static uint16_t get_ci_for_msc(struct osmo_msc_data *msc, struct gsm_bts *bts) +static uint16_t get_ci_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) { if (msc->core_ci != -1) return msc->core_ci; @@ -98,7 +98,7 @@ } static int bsc_filter_initial(struct osmo_bsc_data *bsc, - struct osmo_msc_data *msc, + struct bsc_msc_data *msc, struct gsm_subscriber_connection *conn, struct msgb *msg, char **imsi, int *con_type, int *lu_cause) @@ -216,7 +216,7 @@ static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; LOGP(DMSC, LOGL_INFO, "Tx MSC COMPL L3\n"); @@ -233,7 +233,7 @@ } static int complete_layer3(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct osmo_msc_data *msc) + struct msgb *msg, struct bsc_msc_data *msc) { int con_type, rc, lu_cause; char *imsi = NULL; @@ -310,7 +310,7 @@ * Plastic surgery... we want to give up the current connection */ static int move_to_msc(struct gsm_subscriber_connection *_conn, - struct msgb *msg, struct osmo_msc_data *msc) + struct msgb *msg, struct bsc_msc_data *msc) { struct osmo_bsc_sccp_con *old_con = _conn->sccp_con; @@ -344,7 +344,7 @@ uint8_t pdisc = gsm48_hdr_pdisc(gh); uint8_t mtype = gsm48_hdr_msg_type(gh); - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm_mncc_number called; struct tlv_parsed tp; unsigned payload_len; @@ -493,7 +493,7 @@ static void bsc_mr_config(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan, int full_rate) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm48_multi_rate_conf *ms_conf, *bts_conf; if (!conn->sccp_con) { diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index 67325b3..dcfef40 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -88,7 +88,7 @@ return GSM48_CMODE_SPEECH_AMR; } -static int bssmap_handle_reset_ack(struct osmo_msc_data *msc, +static int bssmap_handle_reset_ack(struct bsc_msc_data *msc, struct msgb *msg, unsigned int length) { LOGP(DMSC, LOGL_NOTICE, "Reset ACK from MSC\n"); @@ -96,7 +96,7 @@ } /* GSM 08.08 ? 3.2.1.19 */ -static int bssmap_handle_paging(struct osmo_msc_data *msc, +static int bssmap_handle_paging(struct bsc_msc_data *msc, struct msgb *msg, unsigned int payload_length) { struct gsm_subscriber *subscr; @@ -286,7 +286,7 @@ struct msgb *msg, unsigned int length) { struct msgb *resp; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct tlv_parsed tp; uint8_t *data; uint8_t timeslot; @@ -384,7 +384,7 @@ return -1; } -static int bssmap_rcvmsg_udt(struct osmo_msc_data *msc, +static int bssmap_rcvmsg_udt(struct bsc_msc_data *msc, struct msgb *msg, unsigned int length) { int ret = 0; @@ -491,7 +491,7 @@ return dtap_rc; } -int bsc_handle_udt(struct osmo_msc_data *msc, +int bsc_handle_udt(struct bsc_msc_data *msc, struct msgb *msgb, unsigned int length) { struct bssmap_header *bs; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c index ffde1b8..c23ed21 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c @@ -40,9 +40,9 @@ { struct ctrl_cmd *trap; struct ctrl_handle *ctrl; - struct osmo_msc_data *msc_data; + struct bsc_msc_data *msc_data; - msc_data = (struct osmo_msc_data *) msc_con->write_queue.bfd.data; + msc_data = (struct bsc_msc_data *) msc_con->write_queue.bfd.data; ctrl = msc_data->network->ctrl; trap = ctrl_cmd_trap(cmd); @@ -197,7 +197,7 @@ void bsc_gen_location_state_trap(struct gsm_bts *bts) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; llist_for_each_entry(msc, &bts->network->bsc_data->mscs, entry) generate_location_state_trap(bts, msc->msc_con); @@ -517,7 +517,7 @@ static int set_net_inform_msc(struct ctrl_cmd *cmd, void *data) { struct gsm_network *net; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; net = cmd->node; llist_for_each_entry(msc, &net->bsc_data->mscs, entry) { diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 5925d11..3443bbe 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -122,14 +122,14 @@ return cm->cm_service_type == GSM48_CMSERV_EMERGENCY; } -struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, +struct bsc_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh; int8_t pdisc; uint8_t mtype; struct osmo_bsc_data *bsc; - struct osmo_msc_data *msc, *pag_msc; + struct bsc_msc_data *msc, *pag_msc; struct gsm_subscriber *subscr; int is_emerg = 0; @@ -315,7 +315,7 @@ return 0; } -static int has_core_identity(struct osmo_msc_data *msc) +static int has_core_identity(struct bsc_msc_data *msc) { if (msc->core_mnc != -1) return 1; @@ -333,7 +333,7 @@ */ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm_network *net; struct gsm48_loc_area_id *lai; struct gsm48_hdr *gh; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 9a63702..5709eea 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -35,7 +35,7 @@ static int normal_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) + struct bsc_msc_data *msc) { /* we can't page by lac.. we need to page everything */ if (msc->core_lac != -1) { @@ -52,7 +52,7 @@ } static int locked_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) + struct bsc_msc_data *msc) { struct gsm_bts *bts = NULL; @@ -85,7 +85,7 @@ * Try to not page if everything the cell is not on. */ int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) + struct bsc_msc_data *msc) { if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON) return normal_paging(subscr, chan_needed, msc); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 982f471..2f0b96d 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -156,7 +156,7 @@ extern int bsc_shutdown_net(struct gsm_network *net); static void signal_handler(int signal) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; fprintf(stdout, "signal %u received\n", signal); @@ -187,7 +187,7 @@ int main(int argc, char **argv) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct osmo_bsc_data *data; int rc; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index e596d2a..42e8055 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -45,16 +45,16 @@ static void initialize_if_needed(struct bsc_msc_connection *conn); static void send_lacs(struct gsm_network *net, struct bsc_msc_connection *conn); -static void send_id_get_response(struct osmo_msc_data *data, int fd, struct msgb *inp); -static void send_ping(struct osmo_msc_data *data); -static void schedule_ping_pong(struct osmo_msc_data *data); +static void send_id_get_response(struct bsc_msc_data *data, int fd, struct msgb *inp); +static void send_ping(struct bsc_msc_data *data); +static void schedule_ping_pong(struct bsc_msc_data *data); /* * MGCP forwarding code */ static int mgcp_do_read(struct osmo_fd *fd) { - struct osmo_msc_data *data = (struct osmo_msc_data *) fd->data; + struct bsc_msc_data *data = (struct bsc_msc_data *) fd->data; struct msgb *mgcp; int ret; @@ -93,7 +93,7 @@ return ret; } -static void mgcp_forward(struct osmo_msc_data *data, struct msgb *msg) +static void mgcp_forward(struct bsc_msc_data *data, struct msgb *msg) { struct msgb *mgcp; @@ -116,7 +116,7 @@ } } -static int mgcp_create_port(struct osmo_msc_data *data) +static int mgcp_create_port(struct bsc_msc_data *data) { int on; struct sockaddr_in addr; @@ -186,7 +186,7 @@ int msc_queue_write_with_ping(struct bsc_msc_connection *conn, struct msgb *msg, int proto) { - struct osmo_msc_data *data; + struct bsc_msc_data *data; uint8_t val; /* prepend the header */ @@ -201,7 +201,7 @@ val = IPAC_MSGT_PING; msgb_l16tv_put(msg, 1, IPAC_PROTO_IPACCESS, &val); - data = (struct osmo_msc_data *) conn->write_queue.bfd.data; + data = (struct bsc_msc_data *) conn->write_queue.bfd.data; schedule_ping_pong(data); return 0; } @@ -220,7 +220,7 @@ return ret; } -static void handle_ctrl(struct osmo_msc_data *msc, struct msgb *msg) +static void handle_ctrl(struct bsc_msc_data *msc, struct msgb *msg) { int ret; struct ctrl_cmd *cmd; @@ -249,7 +249,7 @@ talloc_free(cmd); } -static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg) +static void osmo_ext_handle(struct bsc_msc_data *msc, struct msgb *msg) { struct ipaccess_head *hh; struct ipaccess_head_ext *hh_ext; @@ -274,7 +274,7 @@ { struct msgb *msg = NULL; struct ipaccess_head *hh; - struct osmo_msc_data *data = (struct osmo_msc_data *) bfd->data; + struct bsc_msc_data *data = (struct bsc_msc_data *) bfd->data; int ret; ret = ipa_msg_recv_buffered(bfd->fd, &msg, &data->msc_con->pending_msg); @@ -319,7 +319,7 @@ return 0; } -static void send_ping(struct osmo_msc_data *data) +static void send_ping(struct bsc_msc_data *data) { struct msgb *msg; @@ -335,7 +335,7 @@ msc_queue_write(data->msc_con, msg, IPAC_PROTO_IPACCESS); } -static void schedule_ping_pong(struct osmo_msc_data *data) +static void schedule_ping_pong(struct bsc_msc_data *data) { /* send another ping in 20 seconds */ osmo_timer_schedule(&data->ping_timer, data->ping_timeout, 0); @@ -346,7 +346,7 @@ static void msc_ping_timeout_cb(void *_data) { - struct osmo_msc_data *data = (struct osmo_msc_data *) _data; + struct bsc_msc_data *data = (struct bsc_msc_data *) _data; if (data->ping_timeout <= 0) return; @@ -356,7 +356,7 @@ static void msc_pong_timeout_cb(void *_data) { - struct osmo_msc_data *data = (struct osmo_msc_data *) _data; + struct bsc_msc_data *data = (struct bsc_msc_data *) _data; LOGP(DMSC, LOGL_ERROR, "MSC didn't answer PING. Closing connection.\n"); bsc_msc_lost(data->msc_con); @@ -365,14 +365,14 @@ static void msc_connection_connected(struct bsc_msc_connection *con) { struct msc_signal_data sig; - struct osmo_msc_data *data; + struct bsc_msc_data *data; int ret, on; on = 1; ret = setsockopt(con->write_queue.bfd.fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); if (ret != 0) LOGP(DMSC, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); - data = (struct osmo_msc_data *) con->write_queue.bfd.data; + data = (struct bsc_msc_data *) con->write_queue.bfd.data; msc_ping_timeout_cb(data); sig.data = data; @@ -386,11 +386,11 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc) { struct msc_signal_data sig; - struct osmo_msc_data *data; + struct bsc_msc_data *data; LOGP(DMSC, LOGL_ERROR, "Lost MSC connection. Freing stuff.\n"); - data = (struct osmo_msc_data *) msc->write_queue.bfd.data; + data = (struct bsc_msc_data *) msc->write_queue.bfd.data; osmo_timer_del(&data->ping_timer); osmo_timer_del(&data->pong_timer); @@ -452,7 +452,7 @@ } } -static int answer_challenge(struct osmo_msc_data *data, struct msgb *inp, struct osmo_auth_vector *vec) +static int answer_challenge(struct bsc_msc_data *data, struct msgb *inp, struct osmo_auth_vector *vec) { int ret; struct tlv_parsed tvp; @@ -495,7 +495,7 @@ } -static void send_id_get_response(struct osmo_msc_data *data, int fd, struct msgb *inp) +static void send_id_get_response(struct bsc_msc_data *data, int fd, struct msgb *inp) { struct msc_signal_data sig; struct msgb *msg; @@ -515,7 +515,7 @@ osmo_signal_dispatch(SS_MSC, S_MSC_AUTHENTICATED, &sig); } -int osmo_bsc_msc_init(struct osmo_msc_data *data) +int osmo_bsc_msc_init(struct bsc_msc_data *data) { if (mgcp_create_port(data) != 0) return -1; @@ -541,9 +541,9 @@ return 0; } -struct osmo_msc_data *osmo_msc_data_find(struct gsm_network *net, int nr) +struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *net, int nr) { - struct osmo_msc_data *msc_data; + struct bsc_msc_data *msc_data; llist_for_each_entry(msc_data, &net->bsc_data->mscs, entry) if (msc_data->nr == nr) @@ -551,16 +551,16 @@ return NULL; } -struct osmo_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr) +struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr) { - struct osmo_msc_data *msc_data; + struct bsc_msc_data *msc_data; /* check if there is already one */ msc_data = osmo_msc_data_find(net, nr); if (msc_data) return msc_data; - msc_data = talloc_zero(net, struct osmo_msc_data); + msc_data = talloc_zero(net, struct bsc_msc_data); if (!msc_data) return NULL; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 09efaf4..970d70e 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -166,7 +166,7 @@ static int msc_sccp_read(struct msgb *msgb, unsigned int length, void *data) { - struct osmo_msc_data *msc = (struct osmo_msc_data *) msgb->cb[0]; + struct bsc_msc_data *msc = (struct bsc_msc_data *) msgb->cb[0]; return bsc_handle_udt(msc, msgb, length); } @@ -194,7 +194,7 @@ } enum bsc_con bsc_create_new_connection(struct gsm_subscriber_connection *conn, - struct osmo_msc_data *msc, int send_ping) + struct bsc_msc_data *msc, int send_ping) { struct osmo_bsc_sccp_con *bsc_con; struct sccp_connection *sccp; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 8dabf95..d59c515 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -41,7 +41,7 @@ return bsc_gsmnet->bsc_data; } -static struct osmo_msc_data *osmo_msc_data(struct vty *vty) +static struct bsc_msc_data *bsc_msc_data(struct vty *vty) { return vty->index; } @@ -62,7 +62,7 @@ "msc [<0-1000>]", "Configure MSC details\n" "MSC connection to configure\n") { int index = argc == 1 ? atoi(argv[0]) : 0; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; msc = osmo_msc_data_alloc(bsc_gsmnet, index); if (!msc) { @@ -82,7 +82,7 @@ return CMD_SUCCESS; } -static void write_msc_amr_options(struct vty *vty, struct osmo_msc_data *msc) +static void write_msc_amr_options(struct vty *vty, struct bsc_msc_data *msc) { #define WRITE_AMR(vty, msc, name, var) \ vty_out(vty, " amr-config %s %s%s", \ @@ -100,7 +100,7 @@ #undef WRITE_AMR } -static void write_msc(struct vty *vty, struct osmo_msc_data *msc) +static void write_msc(struct vty *vty, struct bsc_msc_data *msc) { struct bsc_msc_dest *dest; @@ -188,7 +188,7 @@ static int config_write_msc(struct vty *vty) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct osmo_bsc_data *bsc = osmo_bsc_data(vty); llist_for_each_entry(msc, &bsc->mscs, entry) @@ -228,7 +228,7 @@ "token TOKEN", "A token for the BSC to be sent to the MSC\n" "A token\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); bsc_replace_string(osmo_bsc_data(vty), &data->bsc_token, argv[0]); return CMD_SUCCESS; @@ -240,7 +240,7 @@ "Authentication (secret) key configuration\n" "Security key\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); osmo_hexparse(argv[0], data->bsc_key, sizeof(data->bsc_key)); data->bsc_key_present = 1; @@ -251,7 +251,7 @@ "no auth-key", NO_STR "Authentication (secret) key configuration\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); memset(data->bsc_key, 0, sizeof(data->bsc_key)); data->bsc_key_present = 0; @@ -263,7 +263,7 @@ "core-mobile-network-code <1-999>", "Use this network code for the core network\n" "MNC value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_mnc = atoi(argv[0]); return CMD_SUCCESS; } @@ -273,7 +273,7 @@ "core-mobile-country-code <1-999>", "Use this country code for the core network\n" "MCC value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_mcc = atoi(argv[0]); return CMD_SUCCESS; } @@ -283,7 +283,7 @@ "core-location-area-code <0-65535>", "Use this location area code for the core network\n" "LAC value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_lac = atoi(argv[0]); return CMD_SUCCESS; } @@ -293,7 +293,7 @@ "core-cell-identity <0-65535>", "Use this cell identity for the core network\n" "CI value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_ci = atoi(argv[0]); return CMD_SUCCESS; } @@ -305,7 +305,7 @@ "Set the rtp-base port for the RTP stream\n" "Port number\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->rtp_base = atoi(argv[0]); return CMD_SUCCESS; } @@ -316,7 +316,7 @@ "Set the allowed audio codecs\n" "List of audio codecs, e.g. fr3 fr1 hr3\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); int saw_fr, saw_hr; int i; @@ -377,7 +377,7 @@ "IP Address\n" "Port\n" "DSCP\n") { struct bsc_msc_dest *dest; - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); dest = talloc_zero(osmo_bsc_data(vty), struct bsc_msc_dest); if (!dest) { @@ -405,7 +405,7 @@ "IP Address\n" "Port\n" "DSCP\n") { struct bsc_msc_dest *dest, *tmp; - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); int port = atoi(argv[1]); int dscp = atoi(argv[2]); @@ -427,7 +427,7 @@ "no timeout-ping", NO_STR "Disable the ping/pong handling on A-link\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->ping_timeout = -1; return CMD_SUCCESS; } @@ -438,7 +438,7 @@ "Set the PING interval, negative for not sending PING\n" "Timeout in seconds\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->ping_timeout = atoi(argv[0]); return CMD_SUCCESS; } @@ -448,7 +448,7 @@ "timeout-pong <1-2147483647>", "Set the time to wait for a PONG\n" "Timeout in seconds\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->pong_timeout = atoi(argv[0]); return CMD_SUCCESS; } @@ -458,7 +458,7 @@ "timeout-ping advanced", "Ping timeout handling\nEnable advanced mode during SCCP\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); if (data->ping_timeout == -1) { vty_out(vty, "%%ping handling is disabled. Enable it first.%s", @@ -475,7 +475,7 @@ "no timeout-ping advanced", NO_STR "Ping timeout handling\nEnable advanced mode during SCCP\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->advanced_ping = 0; return CMD_SUCCESS; } @@ -485,7 +485,7 @@ "bsc-welcome-text .TEXT", "Set the USSD notification to be sent\n" "Text to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); char *str = argv_concat(argv, argc, 0); if (!str) return CMD_WARNING; @@ -500,7 +500,7 @@ "no bsc-welcome-text", NO_STR "Clear the USSD notification to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); talloc_free(data->ussd_welcome_txt); data->ussd_welcome_txt = NULL; @@ -513,7 +513,7 @@ "bsc-msc-lost-text .TEXT", "Set the USSD notification to be sent on MSC connection loss\n" "Text to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); char *str = argv_concat(argv, argc, 0); if (!str) return CMD_WARNING; @@ -528,7 +528,7 @@ "no bsc-msc-lost-text", NO_STR "Clear the USSD notification to be sent on MSC connection loss\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); talloc_free(data->ussd_msc_lost_txt); data->ussd_msc_lost_txt = 0; @@ -541,7 +541,7 @@ "bsc-grace-text .TEXT", "Set the USSD notification to be sent when the MSC has entered the grace period\n" "Text to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); char *str = argv_concat(argv, argc, 0); if (!str) return CMD_WARNING; @@ -556,7 +556,7 @@ "no bsc-grace-text", NO_STR "Clear the USSD notification to be sent when the MSC has entered the grace period\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); talloc_free(data->ussd_grace_txt); data->ussd_grace_txt = NULL; @@ -599,7 +599,7 @@ "Select the MSC type\n" "Plain GSM MSC\n" "Special MSC for local call routing\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); if (strcmp(argv[0], "normal") == 0) data->type = MSC_CON_TYPE_NORMAL; @@ -615,7 +615,7 @@ "Allow CM ServiceRequests with type emergency\n" "Allow\n" "Deny\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->allow_emerg = strcmp("allow", argv[0]) == 0; return CMD_SUCCESS; } @@ -625,7 +625,7 @@ "local-prefix REGEXP", "Prefix for local numbers\n" "REGEXP used\n") { - struct osmo_msc_data *msc = osmo_msc_data(vty); + struct bsc_msc_data *msc = bsc_msc_data(vty); if (gsm_parse_reg(msc, &msc->local_pref_reg, &msc->local_pref, argc, argv) != 0) { vty_out(vty, "%%Failed to parse the regexp: '%s'%s", @@ -643,7 +643,7 @@ "amr-config " #name "k (allowed|forbidden)", \ AMR_CONF_STR "Bitrate\n" "Allowed\n" "Forbidden\n") \ { \ - struct osmo_msc_data *msc = osmo_msc_data(vty); \ + struct bsc_msc_data *msc = bsc_msc_data(vty); \ \ msc->amr_conf.m##name = strcmp(argv[0], "allowed") == 0; \ return CMD_SUCCESS; \ @@ -664,7 +664,7 @@ "Set the name of the access list to use.\n" "The name of the to be used access list.") { - struct osmo_msc_data *msc = osmo_msc_data(vty); + struct bsc_msc_data *msc = bsc_msc_data(vty); bsc_replace_string(msc, &msc->acc_lst_name, argv[0]); return CMD_SUCCESS; @@ -675,7 +675,7 @@ "no access-list-name", NO_STR "Remove the access list from the NAT.\n") { - struct osmo_msc_data *msc = osmo_msc_data(vty); + struct bsc_msc_data *msc = bsc_msc_data(vty); if (msc->acc_lst_name) { talloc_free(msc->acc_lst_name); @@ -782,7 +782,7 @@ "show mscs", SHOW_STR "MSC Connections and State\n") { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; llist_for_each_entry(msc, &bsc_gsmnet->bsc_data->mscs, entry) { vty_out(vty, "MSC Nr: %d is connected: %d auth: %d.%s", msc->nr, diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c index 1e3fdf7..20ed5b4 100644 --- a/openbsc/tests/bsc/bsc_test.c +++ b/openbsc/tests/bsc/bsc_test.c @@ -125,13 +125,13 @@ struct gsm_network *net; struct gsm_bts *bts; struct osmo_bsc_sccp_con *sccp_con; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm_subscriber_connection *conn; net = talloc_zero(NULL, struct gsm_network); bts = talloc_zero(net, struct gsm_bts); sccp_con = talloc_zero(net, struct osmo_bsc_sccp_con); - msc = talloc_zero(net, struct osmo_msc_data); + msc = talloc_zero(net, struct bsc_msc_data); conn = talloc_zero(net, struct gsm_subscriber_connection); bts->network = net; -- To view, visit https://gerrit.osmocom.org/1892 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:08:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:08:18 +0000 Subject: libosmocore[master]: ports.h: rename CSCN to MSC In-Reply-To: References: Message-ID: Patch Set 1: note to self to remember updating wiki and manuals as well -- To view, visit https://gerrit.osmocom.org/1884 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:10:59 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:10:59 +0000 Subject: [PATCH] openggsn[master]: remove ChangeLog, it hasn't been updated since 2004 In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1887 to look at the new patch set (#2). remove ChangeLog, it hasn't been updated since 2004 We have a detailed log in git instead. Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 --- D ChangeLog M README M configure.ac M openggsn.spec.in 4 files changed, 4 insertions(+), 147 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/87/1887/2 diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 3beba46..0000000 --- a/ChangeLog +++ /dev/null @@ -1,142 +0,0 @@ -2004-12-30: Jens Jakobsen - Initial MAC OS X support - - Quality assurance and improved error logging - - QoS length bug fix. - -2004-09-11: Jens Jakobsen - Added selection mode option to sgsnemu. - Added charging characteristics option to sgsnemu. - - Only include charging characteristics in create PDP context - request is if flags are set. (Thanks to Loic Bernable - ). - - PPP PCO length bug fix. (Thanks to Loic Bernable - ). - - IP pool hash table bugfix and improved logging. - - Improved configure.in and Makefile.am for compilation under - Solaris. New config.sub and config.guess. - -2004-04-28: Jens Jakobsen - Improved Solaris support. OpenGGSN now correctly initializes - tun/tap driver under Solaris. As a consequence the ggsn network - interface IP address is set to the network address plus one. - - Added routing manipulation and IP address alias capability for - FreeBSD. - -2004-01-19: Jens Jakobsen - Initial FreeBSD port (Thanks to Pavel Andreev ). - - IMSI bugfix. The IMSI encoding used by create PDP context was - missing the leading '1111' to indicate that the 16'nd digit was - unused. (Thanks to Pavel Andreev ). - - -2004-01-15: Jens Jakobsen - Added iptables firewall script. - - -2004-01-14: Jens Jakobsen - Changes to allow compilation under Solaris: u_int8_t changed to uint8_t - and tun api changed for sun platform (#ifdef). - - -2004-01-09: Jens Jakobsen - Fixed bug which included NSAPI in GTPv0 create PDP context messages. - - -2003-11-10: Jens Jakobsen - Added --net option for sgsnemu. Allow user to specify the network - address and mask of the local interface. - - Added --gtpversion option for sgsnemu. Allow user to specify which - GTP version to use. - - Added --nsapi option for sgsnemu. Allow user to specify which - NSAPI to use. - - Changed the functionality for multiple contexts. Previously - contexts were differentiated by nsapi. This limited the number of - contexts to 16. Now each context is established with a new imsi - and msisdn. - - -2003-10-22: Jens Jakobsen - Support for GTP1. Currently without support for the secondary pdp - context activation procedure. - - sgsnemu will first attempt to use GTP1. If that fails it will - proceed with GTP0. - - Various gtplib API changes to allow support for GTP1. - - gtplib now listens to 3 separate UDP ports: GTP0, GTP1 control - plane and GTP1 user plane. A socket for each port has to be - included in the application select loop. - - gtplib now verifies that messages are valid for the particular - type of support node. As an example a received Create PDP Context - Request message is not allowed for an SGSN. - - Standards compliance document. - - -2003-07-07: Jens Jakobsen - Added spec.in file for building binary RPM packages. Now openggsn - will install binaries, man pages as well as scripts. - - Added ggsn and sgsnemu man pages - - Added ggsn Sys V init script - - Added bootstrap script for autotools automation - - -2003-04-11: Jens Jakobsen - Added -ggdb to gtp, sgsnemu and ggsn makefiles in order to include - debugging information. - - Added ippool.c and ippool.h to ggsn. This allows for generic - allocation of dynamic ip addresses based on a / - description of ip address space. The same files are also used in - sgsnemu, but only for hashing IP addresses. At the same time the - corresponding functionality is removed from pdp.c. - - Added syserr.h and syserr.c to ggsn and sgsnemu. These files allow - writing to syslog with file name and line number. Later this - should also be introduced in gtp. - - Added support for DNS protocol configuration options in ggsn for - create context response. This allow the MS to setup DNS - configuration correctly. - - tun.c and tun.h have been updated to allow setting interface IP - addresses and routes by means of ioctl and netlink. This allow - sgsnemu to allocate an interface IP address for each context - established. - - -2003-01-29: Jens Jakobsen - Added -L../gtp to sgsnemu and ggsn makefiles so that make will - work without an installed libgtp. - - Added sgsnemu check to check for valid pointer when deleting tun. - - Removed enabling of ip_forward = 1 from ggsn.c and sgsnemu. From a - security point of view it was not very good that openggsn - automatically enabled routing. - - Added ipup, ipdown and createif to sgsnemu/cmdline.ggo. Now - sgsnemu will set up default route and then execute ipup script - after tun device has been set up. After tun has been deleted the - ipdown script is executed. - - Added support for ping to sgsnemu. - - Added ipup and ipdown to ggsn/cmdline.ggo. - diff --git a/README b/README index 3d55259..9084d8f 100644 --- a/README +++ b/README @@ -257,9 +257,8 @@ 1. txt2html -pm -tf README > README.html 2. txt2html -pm -tf NEWS > NEWS.html - 3. txt2html -pm -tf ChangeLog > ChangeLog.html - 4. man2htm ggsn.8 > ggsn.html - 5. man2htm sgsnemu.8 > sgsnemu.html + 3. man2htm ggsn.8 > ggsn.html + 4. man2htm sgsnemu.8 > sgsnemu.html Installation from binary diff --git a/configure.ac b/configure.ac index 2422616..45ab22b 100644 --- a/configure.ac +++ b/configure.ac @@ -123,7 +123,7 @@ # check for getopt in standard library adl_FUNC_GETOPT_LONG -AM_INIT_AUTOMAKE() +AM_INIT_AUTOMAKE([foreign]) PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.6.4) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0) diff --git a/openggsn.spec.in b/openggsn.spec.in index 93934eb..3ee319e 100644 --- a/openggsn.spec.in +++ b/openggsn.spec.in @@ -63,7 +63,7 @@ %dir /var/lib/ggsn /var/lib/ggsn/gsn_restart -%doc AUTHORS ChangeLog COPYING INSTALL NEWS README +%doc AUTHORS COPYING INSTALL NEWS README %doc examples/ggsn.conf %doc examples/sgsnemu.conf %doc examples/ggsn.init -- To view, visit https://gerrit.osmocom.org/1887 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:11:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:11:44 +0000 Subject: openggsn[master]: update version to 0.93 In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1886 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If65b8281933b5833b5ce83239688e775cc267f4c Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:11:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:11:46 +0000 Subject: [MERGED] openggsn[master]: update version to 0.93 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: update version to 0.93 ...................................................................... update version to 0.93 Change-Id: If65b8281933b5833b5ce83239688e775cc267f4c --- M configure.ac 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/configure.ac b/configure.ac index 1a36357..2422616 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(openggsn, 0.92, laforge at gnumonks.org) +AC_INIT(openggsn, 0.93, laforge at gnumonks.org) AC_CONFIG_SRCDIR([gtp/gtp.c]) AM_CONFIG_HEADER([config.h]) #AC_CONFIG_HEADER([config.h]) -- To view, visit https://gerrit.osmocom.org/1886 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If65b8281933b5833b5ce83239688e775cc267f4c Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:12:33 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:12:33 +0000 Subject: libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Patch Set 6: Funky how the gerrit build didn't catch the osmo_sock_init_ifd() typo -- it just caused a warning on implicit function definition and wasn't caught until trying to link. Max, thus you *definitely* did not test this patch. That's not very nice :P And maybe we want to have some linking test in the gerrit job? difficult to link everything though. Maybe better: disallow the implicit function definition with gcc somehow? -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:13:36 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:13:36 +0000 Subject: osmo-pcu[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1880 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:13:38 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:13:38 +0000 Subject: [MERGED] osmo-pcu[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* ...................................................................... logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* In libosmocore, my patch was merged to master a bit too soon. To accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING", a fixup was committed to libosmocore. Adjust for that. Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067 The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93 Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685 --- M src/gprs_bssgp_pcu.cpp M src/gprs_debug.cpp 2 files changed, 7 insertions(+), 7 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index f07b3a6..c4ff402 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -365,7 +365,7 @@ if (bctx) { - log_set_context(LOGGING_CTX_GB_BVC, bctx); + log_set_context(LOG_CTX_GB_BVC, bctx); rate_ctr_inc(&bctx->ctrg->ctr[BSSGP_CTR_PKTS_IN]); rate_ctr_add(&bctx->ctrg->ctr[BSSGP_CTR_BYTES_IN], msgb_bssgp_len(msg)); } diff --git a/src/gprs_debug.cpp b/src/gprs_debug.cpp index 6bb35ea..c35eafa 100644 --- a/src/gprs_debug.cpp +++ b/src/gprs_debug.cpp @@ -49,17 +49,17 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_NSVC]; - const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOGGING_CTX_GB_BVC]; + const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC]; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) return 1; /* Filter on the BVC */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 - && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) return 1; return 0; -- To view, visit https://gerrit.osmocom.org/1880 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:16:33 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:16:33 +0000 Subject: openbsc[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 needed to fix the build after libosmocore I424fe3f12ea620338902b2bb8230544bde3f1a93 -- To view, visit https://gerrit.osmocom.org/1879 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:18:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:18:12 +0000 Subject: openggsn[master]: remove ChangeLog, it hasn't been updated since 2004 In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1887 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:18:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:18:15 +0000 Subject: openggsn[master]: Update AUTHORS file to reflect the last 12 years In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1888 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0a8f5a69f2a943344331d36ba225c02b0209beeb Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:18:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:18:16 +0000 Subject: [MERGED] openggsn[master]: Update AUTHORS file to reflect the last 12 years In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Update AUTHORS file to reflect the last 12 years ...................................................................... Update AUTHORS file to reflect the last 12 years Change-Id: I0a8f5a69f2a943344331d36ba225c02b0209beeb --- M AUTHORS 1 file changed, 14 insertions(+), 7 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/AUTHORS b/AUTHORS index 1e71784..5f10990 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,9 +1,16 @@ OpenGGSN - Gateway GPRS Support Node -Copyright (C) 2002 Mondru AB. +Copyright (C) 2002-2004 Mondru AB, Author: Jens Jakobsen +Copyright (C) 2010-2017 Harald Welte +Copyright (C) 2012-2016 Holger Hans Peter Freyther +Copyright (C) 2014-2016 Pablo Neira Ayuso +Copyright (C) 2014-2016 sysmocom - s.f.m.c. GmbH -The initial developer of the original code is -Jens Jakobsen - -Contributor(s): - - +Contributors: +Emmanuel Bretelle +Yann BONNAMY +Eric Butler +Michael McTernan +Alexander Huemer +BJovke +Alexander Couzens +Ruben Undheim -- To view, visit https://gerrit.osmocom.org/1888 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0a8f5a69f2a943344331d36ba225c02b0209beeb Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:18:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Thu, 23 Feb 2017 21:18:17 +0000 Subject: [MERGED] openggsn[master]: remove ChangeLog, it hasn't been updated since 2004 In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: remove ChangeLog, it hasn't been updated since 2004 ...................................................................... remove ChangeLog, it hasn't been updated since 2004 We have a detailed log in git instead. Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 --- D ChangeLog M README M configure.ac M openggsn.spec.in 4 files changed, 4 insertions(+), 147 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 3beba46..0000000 --- a/ChangeLog +++ /dev/null @@ -1,142 +0,0 @@ -2004-12-30: Jens Jakobsen - Initial MAC OS X support - - Quality assurance and improved error logging - - QoS length bug fix. - -2004-09-11: Jens Jakobsen - Added selection mode option to sgsnemu. - Added charging characteristics option to sgsnemu. - - Only include charging characteristics in create PDP context - request is if flags are set. (Thanks to Loic Bernable - ). - - PPP PCO length bug fix. (Thanks to Loic Bernable - ). - - IP pool hash table bugfix and improved logging. - - Improved configure.in and Makefile.am for compilation under - Solaris. New config.sub and config.guess. - -2004-04-28: Jens Jakobsen - Improved Solaris support. OpenGGSN now correctly initializes - tun/tap driver under Solaris. As a consequence the ggsn network - interface IP address is set to the network address plus one. - - Added routing manipulation and IP address alias capability for - FreeBSD. - -2004-01-19: Jens Jakobsen - Initial FreeBSD port (Thanks to Pavel Andreev ). - - IMSI bugfix. The IMSI encoding used by create PDP context was - missing the leading '1111' to indicate that the 16'nd digit was - unused. (Thanks to Pavel Andreev ). - - -2004-01-15: Jens Jakobsen - Added iptables firewall script. - - -2004-01-14: Jens Jakobsen - Changes to allow compilation under Solaris: u_int8_t changed to uint8_t - and tun api changed for sun platform (#ifdef). - - -2004-01-09: Jens Jakobsen - Fixed bug which included NSAPI in GTPv0 create PDP context messages. - - -2003-11-10: Jens Jakobsen - Added --net option for sgsnemu. Allow user to specify the network - address and mask of the local interface. - - Added --gtpversion option for sgsnemu. Allow user to specify which - GTP version to use. - - Added --nsapi option for sgsnemu. Allow user to specify which - NSAPI to use. - - Changed the functionality for multiple contexts. Previously - contexts were differentiated by nsapi. This limited the number of - contexts to 16. Now each context is established with a new imsi - and msisdn. - - -2003-10-22: Jens Jakobsen - Support for GTP1. Currently without support for the secondary pdp - context activation procedure. - - sgsnemu will first attempt to use GTP1. If that fails it will - proceed with GTP0. - - Various gtplib API changes to allow support for GTP1. - - gtplib now listens to 3 separate UDP ports: GTP0, GTP1 control - plane and GTP1 user plane. A socket for each port has to be - included in the application select loop. - - gtplib now verifies that messages are valid for the particular - type of support node. As an example a received Create PDP Context - Request message is not allowed for an SGSN. - - Standards compliance document. - - -2003-07-07: Jens Jakobsen - Added spec.in file for building binary RPM packages. Now openggsn - will install binaries, man pages as well as scripts. - - Added ggsn and sgsnemu man pages - - Added ggsn Sys V init script - - Added bootstrap script for autotools automation - - -2003-04-11: Jens Jakobsen - Added -ggdb to gtp, sgsnemu and ggsn makefiles in order to include - debugging information. - - Added ippool.c and ippool.h to ggsn. This allows for generic - allocation of dynamic ip addresses based on a / - description of ip address space. The same files are also used in - sgsnemu, but only for hashing IP addresses. At the same time the - corresponding functionality is removed from pdp.c. - - Added syserr.h and syserr.c to ggsn and sgsnemu. These files allow - writing to syslog with file name and line number. Later this - should also be introduced in gtp. - - Added support for DNS protocol configuration options in ggsn for - create context response. This allow the MS to setup DNS - configuration correctly. - - tun.c and tun.h have been updated to allow setting interface IP - addresses and routes by means of ioctl and netlink. This allow - sgsnemu to allocate an interface IP address for each context - established. - - -2003-01-29: Jens Jakobsen - Added -L../gtp to sgsnemu and ggsn makefiles so that make will - work without an installed libgtp. - - Added sgsnemu check to check for valid pointer when deleting tun. - - Removed enabling of ip_forward = 1 from ggsn.c and sgsnemu. From a - security point of view it was not very good that openggsn - automatically enabled routing. - - Added ipup, ipdown and createif to sgsnemu/cmdline.ggo. Now - sgsnemu will set up default route and then execute ipup script - after tun device has been set up. After tun has been deleted the - ipdown script is executed. - - Added support for ping to sgsnemu. - - Added ipup and ipdown to ggsn/cmdline.ggo. - diff --git a/README b/README index 3d55259..9084d8f 100644 --- a/README +++ b/README @@ -257,9 +257,8 @@ 1. txt2html -pm -tf README > README.html 2. txt2html -pm -tf NEWS > NEWS.html - 3. txt2html -pm -tf ChangeLog > ChangeLog.html - 4. man2htm ggsn.8 > ggsn.html - 5. man2htm sgsnemu.8 > sgsnemu.html + 3. man2htm ggsn.8 > ggsn.html + 4. man2htm sgsnemu.8 > sgsnemu.html Installation from binary diff --git a/configure.ac b/configure.ac index 2422616..45ab22b 100644 --- a/configure.ac +++ b/configure.ac @@ -123,7 +123,7 @@ # check for getopt in standard library adl_FUNC_GETOPT_LONG -AM_INIT_AUTOMAKE() +AM_INIT_AUTOMAKE([foreign]) PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.6.4) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0) diff --git a/openggsn.spec.in b/openggsn.spec.in index 93934eb..3ee319e 100644 --- a/openggsn.spec.in +++ b/openggsn.spec.in @@ -63,7 +63,7 @@ %dir /var/lib/ggsn /var/lib/ggsn/gsn_restart -%doc AUTHORS ChangeLog COPYING INSTALL NEWS README +%doc AUTHORS COPYING INSTALL NEWS README %doc examples/ggsn.conf %doc examples/sgsnemu.conf %doc examples/ggsn.init -- To view, visit https://gerrit.osmocom.org/1887 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6a7fe97995b5f65080a04423fee77030dea26b84 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Harald Welte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:25:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:25:45 +0000 Subject: osmo-hlr[master]: cosmetic: refactor auc_compute_vectors(), add debug log In-Reply-To: References: Message-ID: Patch Set 1: > No. I think "DEBUG" should be for debugging of issues in > production, not for debugging issues during initial development of > the code. I think it is highly unlikely that anyone would want to > see all the nitty-gritty details of the calculation in production > use. Maybe my perspective is skewed because I'm neck deep in the milenage and auth API nitty-gritty, at least at the moment I find it comforting to be able to switch on debugging on a production HLR and see what numbers it actually produced before going over the wire -- without having to recompile first. I think the few 'if (0)' in case debugging is off are sufficient to justify it. I accept though that I may find this too detailed myself once the certainty that all the algorithms and APIs around them are correct has settled. So now we need a decision... if you or anyone else confirms that it's too much for a run-time, I will disagree now (but most probably will never look back either) and change the patch. Make me do it though :) -- To view, visit https://gerrit.osmocom.org/1869 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 21:27:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 21:27:07 +0000 Subject: [MERGED] openbsc[master]: logging fixup: shorter names for LOGGING_FILTER_* and LOGGIN... In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* ...................................................................... logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_* In libosmocore, my patch was merged to master a bit too soon. To accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING", a fixup was committed to libosmocore. Adjust for that. Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067 The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93 Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991 --- M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/smpp_openbsc.c 5 files changed, 26 insertions(+), 26 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Neels Hofmeyr: Looks good to me, approved Objections: Jenkins Builder: Fails diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 58fdaa3..1cae832 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -159,7 +159,7 @@ gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr); if (lchan->conn) - log_set_context(LOGGING_CTX_VLR_SUBSCR, lchan->conn->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, lchan->conn->subscr); return lchan; } diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 816d7a6..eb37a33 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -77,7 +77,7 @@ if (!bts->oml_link) return; - log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, request->subscr); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, @@ -91,7 +91,7 @@ page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, str_to_imsi(request->subscr->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL); + log_set_context(LOG_CTX_VLR_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -255,7 +255,7 @@ gsm_cbfn *cbfn; int msg; - log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, req->subscr); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", req, req->subscr->imsi); @@ -394,7 +394,7 @@ { struct gsm_bts *bts; - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); /* Stop this first and dispatch the request */ if (_bts) diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 3f3232c..4d7bfed 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -179,22 +179,22 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { - const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR]; - const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC]; - const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC]; + const struct gsm_subscriber *subscr = ctx->ctx[LOG_CTX_VLR_SUBSCR]; + const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; + const struct gprs_nsvc *bvc = ctx->ctx[LOG_CTX_GB_BVC]; - if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0 - && subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR]) + if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0 + && subscr && subscr == tar->filter_data[LOG_FLT_VLR_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0 - && nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 + && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) return 1; /* Filter on the NS Virtual Connection */ - if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0 - && bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC])) + if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 + && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) return 1; return 0; @@ -208,7 +208,7 @@ void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) { - struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR]; + struct gsm_subscriber **fsub = (void*)&target->filter_data[LOG_FLT_VLR_SUBSCR]; /* free the old data */ if (*fsub) { @@ -217,8 +217,8 @@ } if (subscr) { - target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR); + target->filter_map |= (1 << LOG_FLT_VLR_SUBSCR); *fsub = subscr_get(subscr); } else - target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR); + target->filter_map &= ~(1 << LOG_FLT_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 10e2b31..be43956 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1457,7 +1457,7 @@ /* FIXME: request id? close channel? */ return -EINVAL; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1982,7 +1982,7 @@ return -EIO; /* Which subscriber do we want to track trans1 or trans2? */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans1->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans1->subscr); /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); @@ -2003,7 +2003,7 @@ if (!trans->conn) return 0; - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); lchan = trans->conn->lchan; bts = lchan->ts->trx->bts; @@ -3339,7 +3339,7 @@ mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); return -EIO; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n"); mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE); @@ -3395,7 +3395,7 @@ mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); return -EIO; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n"); mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT); @@ -3572,7 +3572,7 @@ LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n"); return -EIO; } - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); if (!trans->conn) { LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n"); return 0; @@ -3646,7 +3646,7 @@ data->imsi); /* update the subscriber we deal with */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); /* If subscriber is not found */ if (!subscr) { @@ -3724,7 +3724,7 @@ subscr_put(subscr); } else { /* update the subscriber we deal with */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, trans->subscr); } if (trans->conn) diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c index fdafa16..2703a24 100644 --- a/openbsc/src/libmsc/smpp_openbsc.c +++ b/openbsc/src/libmsc/smpp_openbsc.c @@ -67,7 +67,7 @@ } /* tag the context in case we know it */ - log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); return subscr; } -- To view, visit https://gerrit.osmocom.org/1879 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Thu Feb 23 23:09:39 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Thu, 23 Feb 2017 23:09:39 +0000 Subject: [PATCH] openbsc[master]: cosmetic: add copyright header to bsc_control.py Message-ID: Review at https://gerrit.osmocom.org/1893 cosmetic: add copyright header to bsc_control.py bsc_control.py lacks a copyright header. This commit adds the copyright header from ipa.py to bsc_control.py. Change-Id: Ie70bf686ee9bb157198e02bf8d946abf56adc82a --- M openbsc/contrib/bsc_control.py 1 file changed, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/93/1893/1 diff --git a/openbsc/contrib/bsc_control.py b/openbsc/contrib/bsc_control.py index 3a7964d..c1b09ce 100755 --- a/openbsc/contrib/bsc_control.py +++ b/openbsc/contrib/bsc_control.py @@ -1,5 +1,26 @@ #!/usr/bin/python # -*- mode: python-mode; py-indent-tabs-mode: nil -*- +""" +/* + * 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. + */ +""" from optparse import OptionParser from ipa import Ctrl -- To view, visit https://gerrit.osmocom.org/1893 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie70bf686ee9bb157198e02bf8d946abf56adc82a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Thu Feb 23 23:44:03 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 23:44:03 +0000 Subject: openbsc[master]: cosmetic: remove unused scall_signal_data.subscr In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1854 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Thu Feb 23 23:44:05 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Thu, 23 Feb 2017 23:44:05 +0000 Subject: [MERGED] openbsc[master]: cosmetic: remove unused scall_signal_data.subscr In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: cosmetic: remove unused scall_signal_data.subscr ...................................................................... cosmetic: remove unused scall_signal_data.subscr Doesn't make sense to switch this to struct vlr_subscr when it isn't used at all. So let's remove it. Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9 --- M openbsc/include/openbsc/signal.h 1 file changed, 0 insertions(+), 1 deletion(-) Approvals: Max: Looks good to me, but someone else must approve Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index 8f27b38..c862b21 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -151,7 +151,6 @@ }; struct scall_signal_data { - struct gsm_subscriber *subscr; struct gsm_subscriber_connection *conn; void *data; }; -- To view, visit https://gerrit.osmocom.org/1854 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 00:18:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 00:18:46 +0000 Subject: [PATCH] openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1682 to look at the new patch set (#7). add struct bsc_subscr, separating libbsc from gsm_subscriber In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC subscriber: struct bsc_subscr. Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no longer have a backpointer to gsm_network (used to be via subscr->group). Create a separate logging filter for the new BSC subscriber. The implementation of adjusting the filter context is added in libbsc to not introduce bsc_subscr_get/_put() dependencies to libcommon. During Paging Response, fetch a bsc_subscr from the mobile identity, like we do for the gsm_subscriber. It looks like a duplication now, but will make sense for the VLR as well as for future MSC split patches. Naming: it was requested to not name the new struct bsc_sub, because 'sub' is too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast to type, relatively short, unambiguous, and the naming is consistent. Add bsc_subscr unit test. Related: OS#1592, OS#1594 Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e --- M openbsc/.gitignore M openbsc/include/openbsc/Makefile.am A openbsc/include/openbsc/bsc_subscriber.h M openbsc/include/openbsc/debug.h M openbsc/include/openbsc/gsm_04_08.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/osmo_bsc_grace.h M openbsc/include/openbsc/paging.h M openbsc/src/libbsc/Makefile.am M openbsc/src/libbsc/abis_rsl.c A openbsc/src/libbsc/bsc_subscriber.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/libbsc/gsm_04_08_utils.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon-cs/common_cs.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/gsm_subscriber.c M openbsc/src/libmsc/vty_interface_layer3.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/tests/channel/Makefile.am M openbsc/tests/channel/channel_test.c M openbsc/tests/subscr/Makefile.am A openbsc/tests/subscr/bsc_subscr_test.c A openbsc/tests/subscr/bsc_subscr_test.err A openbsc/tests/subscr/bsc_subscr_test.ok M openbsc/tests/testsuite.at 30 files changed, 611 insertions(+), 115 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/82/1682/7 diff --git a/openbsc/.gitignore b/openbsc/.gitignore index e3f25cb..4f8e7e6 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -79,6 +79,7 @@ tests/mgcp/mgcp_transcoding_test tests/sgsn/sgsn_test tests/subscr/subscr_test +tests/subscr/bsc_subscr_test tests/oap/oap_test tests/gtphub/gtphub_test tests/mm_auth/mm_auth_test diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index c10accd..0895096 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -10,6 +10,7 @@ bsc_nat_callstats.h \ bsc_nat_sccp.h \ bsc_rll.h \ + bsc_subscriber.h \ bss.h \ bts_ipaccess_nanobts_omlattr.h \ chan_alloc.h \ diff --git a/openbsc/include/openbsc/bsc_subscriber.h b/openbsc/include/openbsc/bsc_subscriber.h new file mode 100644 index 0000000..a750d6e --- /dev/null +++ b/openbsc/include/openbsc/bsc_subscriber.h @@ -0,0 +1,43 @@ +/* GSM subscriber details for use in BSC land */ + +#pragma once + +#include + +#include +#include + +struct log_target; + +struct bsc_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + uint16_t lac; +}; + +const char *bsc_subscr_name(struct bsc_subscr *bsub); + +struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_have_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi); + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line); +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line); +#define bsc_subscr_get(bsub) _bsc_subscr_get(bsub, __BASE_FILE__, __LINE__) +#define bsc_subscr_put(bsub) _bsc_subscr_put(bsub, __BASE_FILE__, __LINE__) + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsub); diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index 6300020..74db723 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -42,6 +42,7 @@ struct gsm_subscriber; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr); +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr); extern const struct log_info log_info; diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index cb632f6..bdf4ed2 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -15,6 +15,7 @@ struct gsm_subscriber_connection; struct amr_multirate_conf; struct amr_mode; +struct bsc_subscr; #define GSM48_ALLOC_SIZE 2048 #define GSM48_ALLOC_HEADROOM 256 @@ -78,7 +79,8 @@ int send_siemens_mrpci(struct gsm_lchan *lchan, uint8_t *classmark2_lv); int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type); int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, uint8_t *mi_type); -int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr); +int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, + struct msgb *msg, struct bsc_subscr *bsub); int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode); int gsm48_rx_rr_modif_ack(struct msgb *msg); diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 460953e..dbc58ac 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -23,6 +23,7 @@ struct mncc_sock_state; struct gsm_subscriber_group; +struct bsc_subscr; #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] @@ -112,6 +113,9 @@ /* To whom we are allocated at the moment */ struct gsm_subscriber *subscr; + + /* libbsc subscriber information */ + struct bsc_subscr *bsub; /* LU expiration handling */ uint8_t expire_timer_stopped; @@ -383,6 +387,11 @@ * BTS|RNC specific timezone overrides for multi-tz networks in * OsmoCSCN, this should be tied to the location area code (LAC). */ struct gsm_tz tz; + + /* List of all struct bsc_subscr used in libbsc. This llist_head is + * allocated so that the llist_head pointer itself can serve as a + * talloc context. */ + struct llist_head *bsc_subscribers; }; struct osmo_esme; diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index af77b2f..50477d7 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -22,10 +22,14 @@ #define OSMO_BSC_GRACE_H #include +#include struct osmo_msc_data; int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts); -int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc); +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc); #endif diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index 689ff51..7dd8500 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -27,7 +27,7 @@ #include #include -#include +#include /** * A pending paging request @@ -36,8 +36,8 @@ /* list_head for list of all paging requests */ struct llist_head entry; /* the subscriber which we're paging. Later gsm_paging_request - * should probably become a part of the gsm_subscriber struct? */ - struct gsm_subscriber *subscr; + * should probably become a part of the bsc_subsrc struct? */ + struct bsc_subscr *bsub; /* back-pointer to the BTS on which we are paging */ struct gsm_bts *bts; /* what kind of channel type do we ask the MS to establish */ @@ -55,13 +55,14 @@ }; /* schedule paging request */ -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data); -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data); +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data); /* stop paging requests */ -void paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg); @@ -71,6 +72,6 @@ /* pending paging requests */ unsigned int paging_pending_requests_nr(struct gsm_bts *bts); -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr); +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub); #endif diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am index b8e77e6..fd8f37a 100644 --- a/openbsc/src/libbsc/Makefile.am +++ b/openbsc/src/libbsc/Makefile.am @@ -24,6 +24,7 @@ abis_om2000_vty.c \ abis_rsl.c \ bsc_rll.c \ + bsc_subscriber.c \ paging.c \ bts_ericsson_rbs2000.c \ bts_ipaccess_nanobts.c \ diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 1cae832..5939e75 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1332,10 +1332,10 @@ static void print_meas_rep(struct gsm_lchan *lchan, struct gsm_meas_rep *mr) { int i; - char *name = ""; + const char *name = ""; if (lchan && lchan->conn) - name = subscr_name(lchan->conn->subscr); + name = bsc_subscr_name(lchan->conn->bsub); DEBUGP(DMEAS, "[%s] MEASUREMENT RESULT NR=%d ", name, mr->nr); diff --git a/openbsc/src/libbsc/bsc_subscriber.c b/openbsc/src/libbsc/bsc_subscriber.c new file mode 100644 index 0000000..7dcf1c2 --- /dev/null +++ b/openbsc/src/libbsc/bsc_subscriber.c @@ -0,0 +1,168 @@ +/* GSM subscriber details for use in BSC land */ + +/* + * (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Neels Hofmeyr + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include + +#include +#include + +static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list) +{ + struct bsc_subscr *bsub; + + bsub = talloc_zero(list, struct bsc_subscr); + if (!bsub) + return NULL; + + llist_add_tail(&bsub->entry, list); + bsub->use_count = 1; + + return bsub; +} + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + + if (!imsi || !*imsi) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (!strcmp(bsub->imsi, imsi)) + return bsc_subscr_get(bsub); + } + return NULL; +} + +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + + if (tmsi == GSM_RESERVED_TMSI) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (bsub->tmsi == tmsi) + return bsc_subscr_get(bsub); + } + return NULL; +} + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi) +{ + if (!bsub) + return; + strncpy(bsub->imsi, imsi, sizeof(bsub->imsi)); +} + +struct bsc_subscr *bsc_subscr_have_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_imsi(list, imsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsc_subscr_set_imsi(bsub, imsi); + return bsub; +} + +struct bsc_subscr *bsc_subscr_have_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_tmsi(list, tmsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsub->tmsi = tmsi; + return bsub; +} + +const char *bsc_subscr_name(struct bsc_subscr *bsub) +{ + static char buf[32]; + if (!bsub) + return "unknown"; + if (bsub->imsi[0]) + snprintf(buf, sizeof(buf), "IMSI:%s", bsub->imsi); + else + snprintf(buf, sizeof(buf), "TMSI:0x%08x", bsub->tmsi); + return buf; +} + +static void bsc_subscr_free(struct bsc_subscr *bsub) +{ + llist_del(&bsub->entry); + talloc_free(bsub); +} + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line) +{ + OSMO_ASSERT(bsub->use_count < INT_MAX); + bsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "BSC subscr %s usage increases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + return bsub; +} + +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line) +{ + bsub->use_count--; + LOGPSRC(DREF, bsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "BSC subscr %s usage decreases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + if (bsub->use_count <= 0) + bsc_subscr_free(bsub); + return NULL; +} + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsc_subscr) +{ + struct bsc_subscr **fsub = (void*)&target->filter_data[LOG_FLT_BSC_SUBSCR]; + + /* free the old data */ + if (*fsub) { + bsc_subscr_put(*fsub); + *fsub = NULL; + } + + if (bsc_subscr) { + target->filter_map |= (1 << LOG_FLT_BSC_SUBSCR); + *fsub = bsc_subscr_get(bsc_subscr); + } else + target->filter_map &= ~(1 << LOG_FLT_BSC_SUBSCR); +} diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 73acebd..21d0701 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1023,6 +1023,16 @@ vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); } +static void bsc_subscr_dump_vty(struct vty *vty, struct bsc_subscr *bsub) +{ + if (strlen(bsub->imsi)) + vty_out(vty, " IMSI: %s%s", bsub->imsi, VTY_NEWLINE); + if (bsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: 0x%08x%s", bsub->tmsi, + VTY_NEWLINE); + vty_out(vty, " Use count: %d%s", bsub->use_count, VTY_NEWLINE); +} + static void meas_rep_dump_uni_vty(struct vty *vty, struct gsm_meas_rep_unidir *mru, const char *prefix, @@ -1318,7 +1328,7 @@ static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag) { vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); - subscr_dump_vty(vty, pag->subscr); + bsc_subscr_dump_vty(vty, pag->bsub); } static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts) diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 98f0790..4a53b31 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -283,7 +283,7 @@ } int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct gsm_subscriber *subscr) + struct msgb *msg, struct bsc_subscr *bsub) { struct gsm_bts *bts = msg->lchan->ts->trx->bts; struct gsm48_hdr *gh = msgb_l3(msg); @@ -292,22 +292,24 @@ if (is_siemens_bts(bts)) send_siemens_mrpci(msg->lchan, classmark2_lv); - if (!conn->subscr) { - conn->subscr = subscr; - } else if (conn->subscr != subscr) { - LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); - subscr_put(subscr); + if (!conn->bsub) { + conn->bsub = bsub; + } else if (conn->bsub != bsub) { + LOGP(DRR, LOGL_ERROR, + "<- Channel already owned by someone else?\n"); + bsc_subscr_put(bsub); return -EINVAL; } else { DEBUGP(DRR, "<- Channel already owned by us\n"); - subscr_put(subscr); - subscr = conn->subscr; + bsc_subscr_put(bsub); + bsub = conn->bsub; } rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_COMPLETED]); /* Stop paging on the bts we received the paging response */ - paging_request_stop(conn->bts, subscr, conn, msg); + paging_request_stop(&bts->network->bts_list, conn->bts, bsub, conn, + msg); return 0; } diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index eb37a33..bd23d89 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -58,11 +59,11 @@ * Kill one paging request update the internal list... */ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts, - struct gsm_paging_request *to_be_deleted) + struct gsm_paging_request *to_be_deleted) { osmo_timer_del(&to_be_deleted->T3113); llist_del(&to_be_deleted->entry); - subscr_put(to_be_deleted->subscr); + bsc_subscr_put(to_be_deleted->bsub); talloc_free(to_be_deleted); } @@ -77,21 +78,21 @@ if (!bts->oml_link) return; - log_set_context(LOG_CTX_VLR_SUBSCR, request->subscr); + log_set_context(LOG_CTX_BSC_SUBSCR, request->bsub); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " - "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, - request->subscr->tmsi, request->chan_type, request->attempts); + "0x%08x for ch. type %d (attempt %d)\n", request->bsub->imsi, + request->bsub->tmsi, request->chan_type, request->attempts); - if (request->subscr->tmsi == GSM_RESERVED_TMSI) - mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi); + if (request->bsub->tmsi == GSM_RESERVED_TMSI) + mi_len = gsm48_generate_mid_from_imsi(mi, request->bsub->imsi); else - mi_len = gsm48_generate_mid_from_tmsi(mi, request->subscr->tmsi); + mi_len = gsm48_generate_mid_from_tmsi(mi, request->bsub->tmsi); page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, - str_to_imsi(request->subscr->imsi)); + str_to_imsi(request->bsub->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(LOG_CTX_VLR_SUBSCR, NULL); + log_set_context(LOG_CTX_BSC_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -237,11 +238,12 @@ } static int paging_pending_request(struct gsm_bts_paging_state *bts, - struct gsm_subscriber *subscr) { + struct bsc_subscr *bsub) +{ struct gsm_paging_request *req; llist_for_each_entry(req, &bts->pending_requests, entry) { - if (subscr == req->subscr) + if (bsub == req->bsub) return 1; } @@ -255,10 +257,10 @@ gsm_cbfn *cbfn; int msg; - log_set_context(LOG_CTX_VLR_SUBSCR, req->subscr); + log_set_context(LOG_CTX_BSC_SUBSCR, req->bsub); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", - req, req->subscr->imsi); + req, bsc_subscr_name(req->bsub)); /* must be destroyed before calling cbfn, to prevent double free */ rate_ctr_inc(&req->bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_EXPIRED]); @@ -277,21 +279,22 @@ } -static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +static int _paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts_paging_state *bts_entry = &bts->paging; struct gsm_paging_request *req; - if (paging_pending_request(bts_entry, subscr)) { - LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", subscr->imsi); + if (paging_pending_request(bts_entry, bsub)) { + LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", + bsc_subscr_name(bsub)); return -EEXIST; } - LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %llu on bts %d.\n", - subscr->id, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %s on bts %d.\n", + bsc_subscr_name(bsub), bts->nr); req = talloc_zero(tall_paging_ctx, struct gsm_paging_request); - req->subscr = subscr_get(subscr); + req->bsub = bsc_subscr_get(bsub); req->bts = bts; req->chan_type = type; req->cbfn = cbfn; @@ -305,8 +308,8 @@ return 0; } -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { int rc; @@ -317,15 +320,14 @@ /* maybe it is the first time we use it */ paging_init_if_needed(bts); - /* Trigger paging, pass any error to the caller */ - rc = _paging_request(bts, subscr, type, cbfn, data); + rc = _paging_request(bts, bsub, type, cbfn, data); if (rc < 0) return rc; return 1; } -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts *bts = NULL; @@ -337,13 +339,14 @@ do { int rc; - bts = gsm_bts_by_lac(network, subscr->lac, bts); + bts = gsm_bts_by_lac(network, bsub->lac, bts); if (!bts) break; - rc = paging_request_bts(bts, subscr, type, cbfn, data); + rc = paging_request_bts(bts, bsub, type, cbfn, data); if (rc < 0) { - paging_request_stop(NULL, subscr, NULL, NULL); + paging_request_stop(&network->bts_list, NULL, bsub, + NULL, NULL); return rc; } num_pages += rc; @@ -357,7 +360,7 @@ /* we consciously ignore the type of the request here */ -static void _paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +static void _paging_request_stop(struct gsm_bts *bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -367,8 +370,8 @@ paging_init_if_needed(bts); llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests, - entry) { - if (req->subscr == subscr) { + entry) { + if (req->bsub == bsub) { gsm_cbfn *cbfn = req->cbfn; void *param = req->cbfn_param; @@ -377,35 +380,36 @@ req = NULL; if (conn && cbfn) { - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", bsub->imsi, bts->nr); cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED, - msg, conn, param); + msg, conn, param); } else - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", bsub->imsi, bts->nr); break; } } } /* Stop paging on all other bts' */ -void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm_bts *bts; - log_set_context(LOG_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_BSC_SUBSCR, bsub); /* Stop this first and dispatch the request */ if (_bts) - _paging_request_stop(_bts, subscr, conn, msg); + _paging_request_stop(_bts, bsub, conn, msg); /* Make sure to cancel this everywhere else */ - llist_for_each_entry(bts, &subscr->group->net->bts_list, list) { + llist_for_each_entry(bts, bts_list, list) { /* Sort of an optimization. */ if (bts == _bts) continue; - _paging_request_stop(bts, subscr, NULL, NULL); + _paging_request_stop(bts, bsub, NULL, NULL); } } @@ -434,12 +438,12 @@ /** * Find any paging data for the given subscriber at the given BTS. */ -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr) +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub) { struct gsm_paging_request *req; llist_for_each_entry(req, &bts->paging.pending_requests, entry) - if (req->subscr == subscr) + if (req->bsub == bsub) return req->cbfn_param; return NULL; diff --git a/openbsc/src/libcommon-cs/common_cs.c b/openbsc/src/libcommon-cs/common_cs.c index 3149580..7905802 100644 --- a/openbsc/src/libcommon-cs/common_cs.c +++ b/openbsc/src/libcommon-cs/common_cs.c @@ -70,6 +70,9 @@ INIT_LLIST_HEAD(&net->upqueue); INIT_LLIST_HEAD(&net->subscr_conns); + net->bsc_subscribers = talloc_zero(net, struct llist_head); + INIT_LLIST_HEAD(net->bsc_subscribers); + /* init statistics */ net->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, 0); net->active_calls = osmo_counter_alloc("msc.active_calls"); diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 4d7bfed..0f82211 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -180,11 +180,16 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { const struct gsm_subscriber *subscr = ctx->ctx[LOG_CTX_VLR_SUBSCR]; + const struct bsc_subscr *bsub = ctx->ctx[LOG_CTX_BSC_SUBSCR]; const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; const struct gprs_nsvc *bvc = ctx->ctx[LOG_CTX_GB_BVC]; if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0 && subscr && subscr == tar->filter_data[LOG_FLT_VLR_SUBSCR]) + return 1; + + if ((tar->filter_map & (1 << LOG_FLT_BSC_SUBSCR)) != 0 + && bsub && bsub == tar->filter_data[LOG_FLT_BSC_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ @@ -206,7 +211,8 @@ .num_cat = ARRAY_SIZE(default_categories), }; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr) { struct gsm_subscriber **fsub = (void*)&target->filter_data[LOG_FLT_VLR_SUBSCR]; @@ -216,9 +222,9 @@ *fsub = NULL; } - if (subscr) { + if (vlr_subscr) { target->filter_map |= (1 << LOG_FLT_VLR_SUBSCR); - *fsub = subscr_get(subscr); + *fsub = subscr_get(vlr_subscr); } else target->filter_map &= ~(1 << LOG_FLT_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index be43956..82568a1 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1433,6 +1433,8 @@ uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm_subscriber *subscr = NULL; + struct bsc_subscr *bsub; + uint32_t tmsi; int rc = 0; resp = (struct gsm48_pag_resp *) &gh->data[0]; @@ -1443,8 +1445,8 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_get_by_tmsi(conn->network->subscr_group, - tmsi_from_string(mi_string)); + tmsi = tmsi_from_string(mi_string); + subscr = subscr_get_by_tmsi(conn->network->subscr_group, tmsi); break; case GSM_MI_TYPE_IMSI: subscr = subscr_get_by_imsi(conn->network->subscr_group, @@ -1457,6 +1459,19 @@ /* FIXME: request id? close channel? */ return -EINVAL; } + + if (!conn->subscr) { + conn->subscr = subscr; + } else if (conn->subscr != subscr) { + LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); + subscr_put(subscr); + return -EINVAL; + } else { + DEBUGP(DRR, "<- Channel already owned by us\n"); + subscr_put(subscr); + subscr = conn->subscr; + } + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1465,10 +1480,18 @@ memcpy(subscr->equipment.classmark2, classmark2_lv+1, *classmark2_lv); db_sync_equipment(&subscr->equipment); + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_have_by_imsi(conn->network->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + /* We received a paging */ conn->expire_timer_stopped = 1; - rc = gsm48_handle_paging_resp(conn, msg, subscr); + rc = gsm48_handle_paging_resp(conn, msg, bsub); return rc; } diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 568f1c5..73e6d79 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -82,8 +82,11 @@ struct gsm_subscriber_connection *conn = data; struct gsm_subscriber *subscr = param; struct paging_signal_data sig_data; + struct bsc_subscr *bsub; + struct gsm_network *net; - OSMO_ASSERT(subscr->is_paging); + OSMO_ASSERT(subscr && subscr->is_paging); + net = subscr->group->net; /* * Stop paging on all other BTS. E.g. if this is @@ -91,7 +94,15 @@ * timeout soon as well. Let's just stop everything * and forget we wanted to page. */ - paging_request_stop(NULL, subscr, NULL, NULL); + + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_have_by_imsi(net->bsc_subscribers, subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + paging_request_stop(&net->bts_list, NULL, bsub, NULL, NULL); + bsc_subscr_put(bsub); /* Inform parts of the system we don't know */ sig_data.subscr = subscr; @@ -169,13 +180,23 @@ { int rc; struct subscr_request *request; + struct bsc_subscr *bsub; + struct gsm_network *net = subscr->group->net; /* Start paging.. we know it is async so we can do it before */ if (!subscr->is_paging) { LOGP(DMM, LOGL_DEBUG, "Subscriber %s not paged yet.\n", subscr_name(subscr)); - rc = paging_request(subscr->group->net, subscr, channel_type, - subscr_paging_cb, subscr); + /* TODO MSC split -- creating a BSC subscriber directly from + * MSC data structures in RAM. At some point the MSC will send + * a message to the BSC instead. */ + bsub = bsc_subscr_have_by_imsi(net->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + rc = paging_request(net, bsub, channel_type, subscr_paging_cb, + subscr); + bsc_subscr_put(bsub); if (rc <= 0) { LOGP(DMM, LOGL_ERROR, "Subscriber %s paging failed: %d\n", subscr_name(subscr), rc); diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index ddec2e3..c6a8929 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1033,21 +1034,26 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct gsm_subscriber *vlr_subscr; + struct bsc_subscr *bsc_subscr; struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; if (!tgt) return CMD_WARNING; - subscr = subscr_get_by_imsi(gsmnet->subscr_group, argv[0]); - if (!subscr) { + vlr_subscr = subscr_get_by_imsi(gsmnet->subscr_group, imsi); + bsc_subscr = bsc_subscr_find_by_imsi(gsmnet->bsc_subscribers, imsi); + + if (!vlr_subscr && !bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_vlr_subscr(tgt, vlr_subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index f38c97f..efdc9bd 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -20,9 +20,10 @@ #include #include +#include #include #include -#include +#include #include #include @@ -99,7 +100,7 @@ static int bssmap_handle_paging(struct osmo_msc_data *msc, struct msgb *msg, unsigned int payload_length) { - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; struct tlv_parsed tp; char mi_string[GSM48_MI_SIZE]; uint32_t tmsi = GSM_RESERVED_TMSI; @@ -157,7 +158,8 @@ LOGP(DMSC, LOGL_ERROR, "eMLPP is not handled\n"); } - subscr = subscr_get_or_create(msc->network->subscr_group, mi_string); + subscr = bsc_subscr_have_by_imsi(msc->network->bsc_subscribers, + mi_string); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string); return -1; @@ -167,7 +169,8 @@ subscr->tmsi = tmsi; LOGP(DMSC, LOGL_INFO, "Paging request from MSC IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n", mi_string, tmsi, tmsi, lac); - bsc_grace_paging_request(subscr, chan_needed, msc); + bsc_grace_paging_request(msc->network->bsc_data->rf_ctrl->policy, + subscr, chan_needed, msc); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index d5ca2fd..8301bfb 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -54,14 +55,14 @@ } /* extract a subscriber from the paging response */ -static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn, - struct msgb *msg) +static struct bsc_subscr *extract_sub(struct gsm_subscriber_connection *conn, + struct msgb *msg) { uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm48_hdr *gh; struct gsm48_pag_resp *resp; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*resp)) { LOGP(DMSC, LOGL_ERROR, "PagingResponse too small: %u\n", msgb_l3len(msg)); @@ -78,12 +79,12 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = bsc_subscr_find_by_tmsi(conn->network->bsc_subscribers, + tmsi_from_string(mi_string)); break; case GSM_MI_TYPE_IMSI: - subscr = subscr_active_by_imsi(conn->bts->network->subscr_group, - mi_string); + subscr = bsc_subscr_find_by_imsi(conn->network->bsc_subscribers, + mi_string); break; default: subscr = NULL; @@ -96,15 +97,16 @@ /* we will need to stop the paging request */ static int handle_page_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct gsm_subscriber *subscr = extract_sub(conn, msg); + struct bsc_subscr *subscr = extract_sub(conn, msg); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Non active subscriber got paged.\n"); return -1; } - paging_request_stop(conn->bts, subscr, conn, msg); - subscr_put(subscr); + paging_request_stop(&conn->network->bts_list, conn->bts, subscr, conn, + msg); + bsc_subscr_put(subscr); return 0; } @@ -130,7 +132,7 @@ uint8_t mtype; struct osmo_bsc_data *bsc; struct osmo_msc_data *msc, *pag_msc; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; int is_emerg = 0; bsc = conn->bts->network->bsc_data; @@ -183,7 +185,7 @@ } pag_msc = paging_get_data(conn->bts, subscr); - subscr_put(subscr); + bsc_subscr_put(subscr); llist_for_each_entry(msc, &bsc->mscs, entry) { if (msc != pag_msc) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 6409a3a..eef88b4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -34,8 +34,8 @@ } -static int normal_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int normal_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { /* we can't page by lac.. we need to page everything */ if (msc->core_lac != -1) { @@ -47,12 +47,11 @@ return 0; } - return paging_request(subscr->group->net, subscr, chan_needed, NULL, - msc); + return paging_request(msc->network, subscr, chan_needed, NULL, msc); } -static int locked_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int locked_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { struct gsm_bts *bts = NULL; @@ -84,10 +83,12 @@ /** * Try to not page if everything the cell is not on. */ -int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc) { - if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON) + if (rf_policy == S_RF_ON) return normal_paging(subscr, chan_needed, msc); return locked_paging(subscr, chan_needed, msc); } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 86ccec4..9171968 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -861,20 +861,19 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct bsc_subscr *bsc_subscr; struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; - if (!tgt) - return CMD_WARNING; + bsc_subscr = bsc_subscr_find_by_imsi(bsc_gsmnet->bsc_subscribers, imsi); - subscr = subscr_get_or_create(bsc_gsmnet->subscr_group, argv[0]); - if (!subscr) { + if (!bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", - argv[0], VTY_NEWLINE); + imsi, VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am index 5e9583f..ca470ac 100644 --- a/openbsc/tests/channel/Makefile.am +++ b/openbsc/tests/channel/Makefile.am @@ -24,8 +24,8 @@ $(NULL) channel_test_LDADD = \ - $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) \ diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index c69c701..88293d0 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -49,7 +49,7 @@ } /* mock object for testing, directly invoke the cb... maybe later through the timer */ -int paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data) +int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { s_data = data; s_cbfn = cbfn; @@ -72,6 +72,7 @@ exit(1); bts = gsm_bts_alloc(network); bts->location_area_code = 23; + s_conn.network = network; /* Create a dummy subscriber */ struct gsm_subscriber *subscr = subscr_alloc(); diff --git a/openbsc/tests/subscr/Makefile.am b/openbsc/tests/subscr/Makefile.am index ad8b20c..6342444 100644 --- a/openbsc/tests/subscr/Makefile.am +++ b/openbsc/tests/subscr/Makefile.am @@ -19,10 +19,13 @@ EXTRA_DIST = \ subscr_test.ok \ + bsc_subscr_test.ok \ + bsc_subscr_test.err \ $(NULL) noinst_PROGRAMS = \ subscr_test \ + bsc_subscr_test \ $(NULL) subscr_test_SOURCES = \ @@ -40,3 +43,19 @@ $(LIBSMPP34_LIBS) \ $(LIBOSMOVTY_LIBS) \ $(NULL) + +bsc_subscr_test_SOURCES = \ + bsc_subscr_test.c \ + $(NULL) + +bsc_subscr_test_LDADD = \ + $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ + $(top_builddir)/src/libtrau/libtrau.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOABIS_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBSMPP34_LIBS) \ + $(LIBOSMOVTY_LIBS) \ + $(NULL) diff --git a/openbsc/tests/subscr/bsc_subscr_test.c b/openbsc/tests/subscr/bsc_subscr_test.c new file mode 100644 index 0000000..43de723 --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.c @@ -0,0 +1,130 @@ +/* (C) 2008 by Jan Luebbe + * (C) 2009 by Holger Hans Peter Freyther + * (C) 2014 by Alexander Chemeris + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include + +#include +#include +#include +#include + +struct llist_head *bsc_subscribers; + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi) +{ + struct bsc_subscr *sfound; + OSMO_ASSERT(bsub); + OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0); + + sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi); + OSMO_ASSERT(sfound == bsub); + + bsc_subscr_put(sfound); +} + +static void test_bsc_subscr(void) +{ + struct bsc_subscr *s1, *s2, *s3; + const char *imsi1 = "1234567890"; + const char *imsi2 = "9876543210"; + const char *imsi3 = "5656565656"; + + printf("Test BSC subscriber allocation and deletion\n"); + + /* Check for emptiness */ + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + /* Allocate entry 1 */ + s1 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + assert_bsc_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + + /* Allocate entry 2 */ + s2 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi2); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + + /* Allocate entry 3 */ + s3 = bsc_subscr_have_by_imsi(bsc_subscribers, imsi3); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d"); + + /* Check entries */ + assert_bsc_subscr(s1, imsi1); + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 1 */ + bsc_subscr_put(s1); + s1 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 2 */ + bsc_subscr_put(s2); + s2 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 3 */ + bsc_subscr_put(s3); + s3 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + OSMO_ASSERT(llist_empty(bsc_subscribers)); +} + +int main() +{ + printf("Testing BSC subscriber core code.\n"); + osmo_init_logging(&log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + log_set_category_filter(osmo_stderr_target, DREF, 1, LOGL_DEBUG); + + bsc_subscribers = talloc_zero(NULL, struct llist_head); + INIT_LLIST_HEAD(bsc_subscribers); + + test_bsc_subscr(); + + printf("Done\n"); + return 0; +} diff --git a/openbsc/tests/subscr/bsc_subscr_test.err b/openbsc/tests/subscr/bsc_subscr_test.err new file mode 100644 index 0000000..a66317a --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.err @@ -0,0 +1,17 @@ +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage decreases to: 0 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage decreases to: 0 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage decreases to: 0 diff --git a/openbsc/tests/subscr/bsc_subscr_test.ok b/openbsc/tests/subscr/bsc_subscr_test.ok new file mode 100644 index 0000000..0f6a8be --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.ok @@ -0,0 +1,11 @@ +Testing BSC subscriber core code. +Test BSC subscriber allocation and deletion +llist_count(bsc_subscribers) == 0 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 3 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 0 +Done diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 01737a3..280aeb2 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -13,6 +13,13 @@ AT_CHECK([$abs_top_builddir/tests/subscr/subscr_test], [], [expout], [ignore]) AT_CLEANUP +AT_SETUP([bsc_subscr]) +AT_KEYWORDS([bsc_subscr]) +cat $abs_srcdir/subscr/bsc_subscr_test.ok > expout +cat $abs_srcdir/subscr/bsc_subscr_test.err > experr +AT_CHECK([$abs_top_builddir/tests/subscr/bsc_subscr_test], [], [expout], [experr]) +AT_CLEANUP + AT_SETUP([db]) AT_KEYWORDS([db]) cat $abs_srcdir/db/db_test.ok > expout -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 7 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 00:18:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 00:18:46 +0000 Subject: [PATCH] openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1684 to look at the new patch set (#9). add struct gprs_subscr, separating gprs from gsm_subscriber Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will not make sense to be used in gprs, so have a dedicated GPRS subscriber struct. (Could change if the gprs code were to use libvlr; is currently independent). Related: OS#1592 Change-Id: Ia8b391ee009c8545763cba04505be3947835120e --- M openbsc/include/openbsc/Makefile.am M openbsc/include/openbsc/gprs_sgsn.h A openbsc/include/openbsc/gprs_subscriber.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/gsm_subscriber.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/src/gprs/gprs_subscriber.c M openbsc/src/gprs/sgsn_auth.c M openbsc/src/gprs/sgsn_libgtp.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c M openbsc/tests/sgsn/sgsn_test.ok 13 files changed, 269 insertions(+), 151 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/84/1684/9 diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 2466ce8..c10accd 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -31,6 +31,7 @@ gprs_sndcp_dcomp.h \ gprs_sndcp_pcomp.h \ gprs_sndcp_xid.h \ + gprs_subscriber.h \ gprs_utils.h \ gsm_04_08.h \ gsm_04_11.h \ diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 2cc5b0c..c3cac7f 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -18,7 +18,7 @@ struct gprs_llc_lle; struct ctrl_handle; -struct gsm_subscriber; +struct gprs_subscr; enum gsm48_gsm_cause; @@ -225,7 +225,7 @@ /* the current GGSN look-up operation */ struct sgsn_ggsn_lookup *ggsn_lookup; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; }; #define LOGMMCTXP(level, mm, fmt, args...) \ @@ -433,6 +433,7 @@ /* * GPRS subscriber data */ +#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001 #define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16) #define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17) #define GPRS_SUBSCRIBER_CANCELLED (1 << 18) @@ -446,13 +447,13 @@ int gprs_subscr_init(struct sgsn_instance *sgi); int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx); -void gprs_subscr_cleanup(struct gsm_subscriber *subscr); -struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi); -struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); -struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi); -void gprs_subscr_cancel(struct gsm_subscriber *subscr); -void gprs_subscr_update(struct gsm_subscriber *subscr); -void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr); +void gprs_subscr_cleanup(struct gprs_subscr *subscr); +struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi); +struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); +struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi); +void gprs_subscr_cancel(struct gprs_subscr *subscr); +void gprs_subscr_update(struct gprs_subscr *subscr); +void gprs_subscr_update_auth_info(struct gprs_subscr *subscr); int gprs_subscr_rx_gsup_message(struct msgb *msg); /* Called on subscriber data updates */ diff --git a/openbsc/include/openbsc/gprs_subscriber.h b/openbsc/include/openbsc/gprs_subscriber.h new file mode 100644 index 0000000..be78feb --- /dev/null +++ b/openbsc/include/openbsc/gprs_subscriber.h @@ -0,0 +1,31 @@ +/* GPRS subscriber details for use in SGSN land */ +#pragma once + +#include + +#include +#include + +extern struct llist_head * const gprs_subscribers; + +struct gprs_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + char imei[GSM23003_IMEISV_NUM_DIGITS+1]; + bool authorized; + bool keep_in_ram; + uint32_t flags; + uint16_t lac; + + struct sgsn_subscriber_data *sgsn_data; +}; + +struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub, + const char *file, int line); +struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, + const char *file, int line); +#define gprs_subscr_get(gsub) _gprs_subscr_get(gsub, __BASE_FILE__, __LINE__) +#define gprs_subscr_put(gsub) _gprs_subscr_put(gsub, __BASE_FILE__, __LINE__) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index ac573c4..460953e 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -26,6 +26,8 @@ #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] +#define tmsi_from_string(str) strtoul(str, NULL, 10) + enum gsm_security_event { GSM_SECURITY_NOAVAIL, GSM_SECURITY_AUTH_FAILED, diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 314d619..7e65614 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -16,7 +16,6 @@ #define GSM_SUBSCRIBER_FIRST_CONTACT 0x00000001 /* gprs_sgsn.h defines additional flags including and above bit 16 (0x10000) */ -#define tmsi_from_string(str) strtoul(str, NULL, 10) #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 1026474..9efe402 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 260e032..727524e 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -321,9 +321,9 @@ /* Detach from subscriber which is possibly freed then */ if (mm->subscr) { - struct gsm_subscriber *subscr = subscr_get(mm->subscr); + struct gprs_subscr *subscr = gprs_subscr_get(mm->subscr); gprs_subscr_cleanup(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); } sgsn_mm_ctx_free(mm); diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index 57f73c5..5f426f8 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include #include #include @@ -35,6 +36,7 @@ #include #include +#include #define SGSN_SUBSCR_MAX_RETRIES 3 #define SGSN_SUBSCR_RETRY_INTERVAL 10 @@ -45,6 +47,9 @@ ## args) extern void *tall_bsc_ctx; + +LLIST_HEAD(_gprs_subscribers); +struct llist_head * const gprs_subscribers = &_gprs_subscribers; static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg); @@ -86,7 +91,7 @@ return rc; } -int gprs_subscr_purge(struct gsm_subscriber *subscr); +int gprs_subscr_purge(struct gprs_subscr *subscr); static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx) { @@ -117,28 +122,53 @@ return pdata; } -struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi) +struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi) { - struct gsm_subscriber *subscr; + struct gprs_subscr *gsub; - subscr = subscr_get_or_create(NULL, imsi); - if (!subscr) + if (!imsi || !*imsi) return NULL; - if (!subscr->sgsn_data) - subscr->sgsn_data = sgsn_subscriber_data_alloc(subscr); - return subscr; + llist_for_each_entry(gsub, gprs_subscribers, entry) { + if (!strcmp(gsub->imsi, imsi)) + return gprs_subscr_get(gsub); + } + return NULL; } -struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi) +static struct gprs_subscr *gprs_subscr_alloc(void) { - return subscr_active_by_imsi(NULL, imsi); + struct gprs_subscr *gsub; + gsub = talloc_zero(tall_bsc_ctx, struct gprs_subscr); + if (!gsub) + return NULL; + llist_add_tail(&gsub->entry, gprs_subscribers); + gsub->use_count = 1; + gsub->tmsi = GSM_RESERVED_TMSI; + return gsub; } -void gprs_subscr_cleanup(struct gsm_subscriber *subscr) +struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi) +{ + struct gprs_subscr *gsub; + + gsub = gprs_subscr_get_by_imsi(imsi); + if (!gsub) { + gsub = gprs_subscr_alloc(); + if (!gsub) + return NULL; + strncpy(gsub->imsi, imsi, sizeof(gsub->imsi)); + } + + if (!gsub->sgsn_data) + gsub->sgsn_data = sgsn_subscriber_data_alloc(gsub); + return gsub; +} + +void gprs_subscr_cleanup(struct gprs_subscr *subscr) { if (subscr->sgsn_data->mm) { - subscr_put(subscr->sgsn_data->mm->subscr); + gprs_subscr_put(subscr->sgsn_data->mm->subscr); subscr->sgsn_data->mm->subscr = NULL; subscr->sgsn_data->mm = NULL; } @@ -149,7 +179,7 @@ } } -void gprs_subscr_cancel(struct gsm_subscriber *subscr) +void gprs_subscr_cancel(struct gprs_subscr *subscr) { subscr->authorized = 0; subscr->flags |= GPRS_SUBSCRIBER_CANCELLED; @@ -159,7 +189,7 @@ gprs_subscr_cleanup(subscr); } -static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr, +static int gprs_subscr_tx_gsup_message(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct msgb *msg = gsup_client_msgb_alloc(); @@ -181,7 +211,7 @@ return gsup_client_send(sgsn->gsup_client, msg); } -static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr, +static int gprs_subscr_tx_gsup_error_reply(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_orig, enum gsm48_gmm_cause cause) { @@ -196,7 +226,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); } -static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_auth_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { unsigned idx; @@ -235,7 +265,7 @@ return 0; } -static int gprs_subscr_pdp_data_clear(struct gsm_subscriber *subscr) +static int gprs_subscr_pdp_data_clear(struct gprs_subscr *subscr) { struct sgsn_subscriber_pdp_data *pdp, *pdp2; int count = 0; @@ -250,7 +280,7 @@ } static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id( - struct gsm_subscriber *subscr, unsigned context_id) + struct gprs_subscr *subscr, unsigned context_id) { struct sgsn_subscriber_pdp_data *pdp; @@ -263,7 +293,7 @@ } -static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr, +static void gprs_subscr_gsup_insert_data(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct sgsn_subscriber_data *sdata = subscr->sgsn_data; @@ -340,7 +370,7 @@ } } -static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_upd_loc_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { /* contrary to MAP, we allow piggy-backing subscriber data onto @@ -357,7 +387,7 @@ return 0; } -static int gprs_subscr_handle_gsup_dsd_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_dsd_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -377,7 +407,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); } -static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_isd_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -409,7 +439,7 @@ } } -static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_auth_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { unsigned idx; @@ -462,7 +492,7 @@ return -gsup_msg->cause; } -static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_upd_loc_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { int cause_err; @@ -523,7 +553,7 @@ return 0; } -static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_purge_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n"); @@ -535,7 +565,7 @@ return 0; } -static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_purge_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { LOGGSUBSCRP(LOGL_NOTICE, subscr, @@ -568,7 +598,7 @@ return -gsup_msg->cause; } -static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_loc_cancel_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -629,7 +659,7 @@ int rc = 0; struct osmo_gsup_message gsup_msg = {0}; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; rc = osmo_gsup_decode(data, data_len, &gsup_msg); if (rc < 0) { @@ -715,12 +745,12 @@ break; }; - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } -int gprs_subscr_purge(struct gsm_subscriber *subscr) +int gprs_subscr_purge(struct gprs_subscr *subscr) { struct sgsn_subscriber_data *sdata = subscr->sgsn_data; struct osmo_gsup_message gsup_msg = {0}; @@ -736,7 +766,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr) +int gprs_subscr_query_auth_info(struct gprs_subscr *subscr) { struct osmo_gsup_message gsup_msg = {0}; @@ -747,7 +777,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_location_update(struct gsm_subscriber *subscr) +int gprs_subscr_location_update(struct gprs_subscr *subscr) { struct osmo_gsup_message gsup_msg = {0}; @@ -758,60 +788,59 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -void gprs_subscr_update(struct gsm_subscriber *subscr) +void gprs_subscr_update(struct gprs_subscr *subscr) { LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber data\n"); subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; - subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags &= ~GPRS_SUBSCRIBER_FIRST_CONTACT; if (subscr->sgsn_data->mm) sgsn_update_subscriber_data(subscr->sgsn_data->mm); } -void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr) +void gprs_subscr_update_auth_info(struct gprs_subscr *subscr) { LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber authentication info\n"); subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; - subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags &= ~GPRS_SUBSCRIBER_FIRST_CONTACT; if (subscr->sgsn_data->mm) sgsn_update_subscriber_data(subscr->sgsn_data->mm); } -struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) +struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; if (mmctx->subscr) - return subscr_get(mmctx->subscr); + return gprs_subscr_get(mmctx->subscr); if (mmctx->imsi[0]) subscr = gprs_subscr_get_by_imsi(mmctx->imsi); if (!subscr) { subscr = gprs_subscr_get_or_create(mmctx->imsi); - subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE; } - osmo_strlcpy(subscr->equipment.imei, mmctx->imei, - sizeof(subscr->equipment.imei)); + osmo_strlcpy(subscr->imei, mmctx->imei, sizeof(subscr->imei)); if (subscr->lac != mmctx->ra.lac) subscr->lac = mmctx->ra.lac; subscr->sgsn_data->mm = mmctx; - mmctx->subscr = subscr_get(subscr); + mmctx->subscr = gprs_subscr_get(subscr); return subscr; } int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; int rc; LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n"); @@ -821,13 +850,13 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; rc = gprs_subscr_location_update(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; int rc; LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n"); @@ -837,6 +866,40 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; rc = gprs_subscr_query_auth_info(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } + +static void gprs_subscr_free(struct gprs_subscr *gsub) +{ + llist_del(&gsub->entry); + talloc_free(gsub); +} + +struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub, + const char *file, int line) +{ + OSMO_ASSERT(gsub->use_count < INT_MAX); + gsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "subscr %s usage increases to: %d\n", + gsub->imsi, gsub->use_count); + return gsub; +} + +struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, + const char *file, int line) +{ + gsub->use_count--; + LOGPSRC(DREF, gsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "subscr %s usage decreases to: %d%s\n", + gsub->imsi, gsub->use_count, + gsub->keep_in_ram? ", keep-in-ram flag is set" : ""); + if (gsub->use_count > 0) + return gsub; + if (gsub->keep_in_ram) + return gsub; + gprs_subscr_free(gsub); + return NULL; +} diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index 1fa7fc4..df7ee37 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include const struct value_string auth_state_names[] = { @@ -151,7 +151,7 @@ */ int sgsn_auth_request(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; struct gsm_auth_tuple *at; int need_update_location; int rc; @@ -169,7 +169,7 @@ /* This has the side effect of registering the subscr with the mmctx */ subscr = gprs_subscr_get_or_create_by_mmctx(mmctx); - subscr_put(subscr); + gprs_subscr_put(subscr); OSMO_ASSERT(mmctx->subscr != NULL); @@ -207,7 +207,7 @@ void sgsn_auth_update(struct sgsn_mm_ctx *mmctx) { enum sgsn_auth_state auth_state; - struct gsm_subscriber *subscr = mmctx->subscr; + struct gprs_subscr *subscr = mmctx->subscr; struct gsm_auth_tuple *at; int gmm_cause; diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 062de44..dde1e5e 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #ifdef BUILD_IU diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 3ce054f..a730635 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -657,40 +657,37 @@ } /* Subscriber */ -#include +#include -static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr, int pending) +static void subscr_dump_full_vty(struct vty *vty, struct gprs_subscr *gsub, int pending) { +#if 0 char expire_time[200]; +#endif struct gsm_auth_tuple *at; int at_idx; struct sgsn_subscriber_pdp_data *pdp; - vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, - subscr->authorized, VTY_NEWLINE); - if (strlen(subscr->name)) - vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); - if (strlen(subscr->extension)) - vty_out(vty, " Extension: %s%s", subscr->extension, - VTY_NEWLINE); + vty_out(vty, " Authorized: %d%s", + gsub->authorized, VTY_NEWLINE); vty_out(vty, " LAC: %d/0x%x%s", - subscr->lac, subscr->lac, VTY_NEWLINE); - vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); - if (subscr->tmsi != GSM_RESERVED_TMSI) - vty_out(vty, " TMSI: %08X%s", subscr->tmsi, + gsub->lac, gsub->lac, VTY_NEWLINE); + vty_out(vty, " IMSI: %s%s", gsub->imsi, VTY_NEWLINE); + if (gsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: %08X%s", gsub->tmsi, VTY_NEWLINE); - if (subscr->sgsn_data->msisdn_len > 0) + if (gsub->sgsn_data->msisdn_len > 0) vty_out(vty, " MSISDN (BCD): %s%s", - osmo_hexdump(subscr->sgsn_data->msisdn, - subscr->sgsn_data->msisdn_len), + osmo_hexdump(gsub->sgsn_data->msisdn, + gsub->sgsn_data->msisdn_len), VTY_NEWLINE); - if (strlen(subscr->equipment.imei) > 0) - vty_out(vty, " IMEI: %s%s", subscr->equipment.imei, VTY_NEWLINE); + if (strlen(gsub->imei) > 0) + vty_out(vty, " IMEI: %s%s", gsub->imei, VTY_NEWLINE); - for (at_idx = 0; at_idx < ARRAY_SIZE(subscr->sgsn_data->auth_triplets); + for (at_idx = 0; at_idx < ARRAY_SIZE(gsub->sgsn_data->auth_triplets); at_idx++) { - at = &subscr->sgsn_data->auth_triplets[at_idx]; + at = &gsub->sgsn_data->auth_triplets[at_idx]; if (at->key_seq == GSM_KEY_SEQ_INVAL) continue; @@ -722,36 +719,38 @@ } } - llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) { + llist_for_each_entry(pdp, &gsub->sgsn_data->pdp_list, list) { vty_out(vty, " PDP info: Id: %d, Type: 0x%04x, APN: '%s' QoS: %s%s", pdp->context_id, pdp->pdp_type, pdp->apn_str, osmo_hexdump(pdp->qos_subscribed, pdp->qos_subscribed_len), VTY_NEWLINE); } +#if 0 /* print the expiration time of a subscriber */ - if (subscr->expire_lu) { + if (gsub->expire_lu) { strftime(expire_time, sizeof(expire_time), - "%a, %d %b %Y %T %z", localtime(&subscr->expire_lu)); + "%a, %d %b %Y %T %z", localtime(&gsub->expire_lu)); expire_time[sizeof(expire_time) - 1] = '\0'; vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE); } +#endif - if (subscr->flags) + if (gsub->flags) vty_out(vty, " Flags: %s%s%s%s%s%s", - subscr->flags & GSM_SUBSCRIBER_FIRST_CONTACT ? + gsub->flags & GPRS_SUBSCRIBER_FIRST_CONTACT ? "FIRST_CONTACT " : "", - subscr->flags & GPRS_SUBSCRIBER_CANCELLED ? + gsub->flags & GPRS_SUBSCRIBER_CANCELLED ? "CANCELLED " : "", - subscr->flags & GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING ? + gsub->flags & GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING ? "UPDATE_LOCATION_PENDING " : "", - subscr->flags & GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING ? + gsub->flags & GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING ? "AUTH_INFO_PENDING " : "", - subscr->flags & GPRS_SUBSCRIBER_ENABLE_PURGE ? + gsub->flags & GPRS_SUBSCRIBER_ENABLE_PURGE ? "ENABLE_PURGE " : "", VTY_NEWLINE); - vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); + vty_out(vty, " Use count: %u%s", gsub->use_count, VTY_NEWLINE); } DEFUN(show_subscr_cache, @@ -760,9 +759,9 @@ SHOW_STR "Show information about subscribers\n" "Display contents of subscriber cache\n") { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; - llist_for_each_entry(subscr, &active_subscribers, entry) { + llist_for_each_entry(subscr, gprs_subscribers, entry) { vty_out(vty, " Subscriber:%s", VTY_NEWLINE); subscr_dump_full_vty(vty, subscr, 0); } @@ -794,7 +793,7 @@ const char *kc_str = argv[4]; struct gsm_auth_tuple at = {0,}; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -825,12 +824,12 @@ subscr->sgsn_data->auth_triplets[cksn] = at; subscr->sgsn_data->auth_triplets_updated = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; failed: - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -844,7 +843,7 @@ const char *imsi = argv[0]; const char *cancel_type = argv[1]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -859,7 +858,7 @@ subscr->sgsn_data->error_cause = GMM_CAUSE_IMPL_DETACHED; gprs_subscr_cancel(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -871,7 +870,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (subscr) { @@ -882,7 +881,7 @@ subscr = gprs_subscr_get_or_create(imsi); subscr->keep_in_ram = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -894,7 +893,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -909,7 +908,7 @@ if (subscr->use_count > 1) vty_out(vty, "%% subscriber is still in use%s", VTY_NEWLINE); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -934,7 +933,7 @@ const char *imsi = argv[0]; const char *ret_code_str = argv[1]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; const struct value_string cause_mapping[] = { { GMM_CAUSE_NET_FAIL, "system-failure" }, @@ -963,7 +962,7 @@ gprs_subscr_update(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -975,7 +974,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -986,7 +985,7 @@ gprs_subscr_update_auth_info(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index ff07978..6eabdde 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -248,7 +248,7 @@ cleanup_test(); } -struct gsm_subscriber *last_updated_subscr = NULL; +struct gprs_subscr *last_updated_subscr = NULL; void my_dummy_sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx) { OSMO_ASSERT(mmctx); @@ -257,23 +257,23 @@ last_updated_subscr = mmctx->subscr; } -static void assert_subscr(const struct gsm_subscriber *subscr, const char *imsi) +static void assert_subscr(const struct gprs_subscr *subscr, const char *imsi) { - struct gsm_subscriber *sfound; + struct gprs_subscr *sfound; OSMO_ASSERT(subscr); OSMO_ASSERT(strcmp(subscr->imsi, imsi) == 0); sfound = gprs_subscr_get_by_imsi(imsi); OSMO_ASSERT(sfound == subscr); - subscr_put(sfound); + gprs_subscr_put(sfound); } static void show_subscrs(FILE *out) { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; - llist_for_each_entry(subscr, &active_subscribers, entry) { + llist_for_each_entry(subscr, gprs_subscribers, entry) { fprintf(out, " Subscriber: %s, " "use count: %d\n", subscr->imsi, subscr->use_count); @@ -284,12 +284,18 @@ { show_subscrs(stdout); fflush(stdout); - OSMO_ASSERT(llist_empty(&active_subscribers)); + OSMO_ASSERT(llist_empty(gprs_subscribers)); } + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); static void test_subscriber(void) { - struct gsm_subscriber *s1, *s2, *s3, *sfound; + struct gprs_subscr *s1, *s2, *s3; const char *imsi1 = "1234567890"; const char *imsi2 = "9876543210"; const char *imsi3 = "5656565656"; @@ -302,19 +308,24 @@ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d"); /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; assert_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); /* Allocate entry 2 */ s2 = gprs_subscr_get_or_create(imsi2); - s2->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d"); + s2->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; /* Allocate entry 3 */ s3 = gprs_subscr_get_or_create(imsi3); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 3, "%d"); /* Check entries */ assert_subscr(s1, imsi1); @@ -326,33 +337,35 @@ gprs_subscr_update(s1); OSMO_ASSERT(last_updated_subscr == NULL); OSMO_ASSERT(s1->sgsn_data->mm == NULL); - OSMO_ASSERT((s1->flags & GSM_SUBSCRIBER_FIRST_CONTACT) == 0); + OSMO_ASSERT((s1->flags & GPRS_SUBSCRIBER_FIRST_CONTACT) == 0); /* There is no subscriber cache. Verify it */ gprs_subscr_cleanup(s1); - subscr_put(s1); + gprs_subscr_put(s1); s1 = NULL; - sfound = gprs_subscr_get_by_imsi(imsi1); - OSMO_ASSERT(sfound == NULL); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d"); + OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); assert_subscr(s2, imsi2); assert_subscr(s3, imsi3); - /* Free entry 2 (GSM_SUBSCRIBER_FIRST_CONTACT is set) */ + /* Free entry 2 (GPRS_SUBSCRIBER_FIRST_CONTACT is set) */ gprs_subscr_cleanup(s2); - subscr_put(s2); + gprs_subscr_put(s2); s2 = NULL; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); assert_subscr(s3, imsi3); /* Try to delete entry 3 */ gprs_subscr_cleanup(s3); - subscr_put(s3); + gprs_subscr_put(s3); s3 = NULL; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL); - OSMO_ASSERT(llist_empty(&active_subscribers)); + OSMO_ASSERT(llist_empty(gprs_subscribers)); update_subscriber_data_cb = __real_sgsn_update_subscriber_data; @@ -361,7 +374,7 @@ static void test_auth_triplets(void) { - struct gsm_subscriber *s1, *s1found; + struct gprs_subscr *s1, *s1found; const char *imsi1 = "1234567890"; struct gsm_auth_tuple *at; struct sgsn_mm_ctx *ctx; @@ -375,17 +388,17 @@ /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == s1); - subscr_put(s1found); + gprs_subscr_put(s1found); /* Create a context */ OSMO_ASSERT(count(gprs_llme_list()) == 0); ctx = alloc_mm_ctx(local_tlli, &raid); /* Attach s1 to ctx */ - ctx->subscr = subscr_get(s1); + ctx->subscr = gprs_subscr_get(s1); ctx->subscr->sgsn_data->mm = ctx; /* Try to get auth tuple */ @@ -414,7 +427,7 @@ OSMO_ASSERT(at == NULL); /* Free MM context and subscriber */ - subscr_put(s1); + gprs_subscr_put(s1); sgsn_mm_ctx_cleanup_free(ctx); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); @@ -441,7 +454,7 @@ static void test_subscriber_gsup(void) { - struct gsm_subscriber *s1, *s1found; + struct gprs_subscr *s1, *s1found; const char *imsi1 = "1234567890"; struct sgsn_mm_ctx *ctx; struct gprs_ra_id raid = { 0, }; @@ -563,17 +576,17 @@ /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == s1); - subscr_put(s1found); + gprs_subscr_put(s1found); /* Create a context */ OSMO_ASSERT(count(gprs_llme_list()) == 0); ctx = alloc_mm_ctx(local_tlli, &raid); /* Attach s1 to ctx */ - ctx->subscr = subscr_get(s1); + ctx->subscr = gprs_subscr_get(s1); ctx->subscr->sgsn_data->mm = ctx; /* Inject SendAuthInfoReq GSUP message */ @@ -675,7 +688,7 @@ /* Free MM context and subscriber */ OSMO_ASSERT(ctx->subscr == NULL); sgsn_mm_ctx_cleanup_free(ctx); - subscr_put(s1); + gprs_subscr_put(s1); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); @@ -1090,7 +1103,7 @@ static void test_gmm_attach_subscr(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1101,7 +1114,7 @@ printf("Auth policy 'remote': "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1124,7 +1137,7 @@ static void test_gmm_attach_subscr_fake_auth(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1137,7 +1150,7 @@ printf("Auth policy 'remote', auth faked: "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1166,7 +1179,7 @@ static void test_gmm_attach_subscr_real_auth(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1180,7 +1193,7 @@ printf("Auth policy 'remote', triplet based auth: "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1254,7 +1267,7 @@ static void test_gmm_attach_subscr_gsup_auth(int retry) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_gsup_auth; @@ -1268,7 +1281,7 @@ subscr->authorized = 1; sgsn->cfg.require_authentication = 1; sgsn->cfg.require_update_location = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); printf("Auth policy 'remote', GSUP based auth: "); test_gmm_attach(retry); @@ -1337,7 +1350,7 @@ static void test_gmm_attach_subscr_real_gsup_auth(int retry) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; gsup_client_send_cb = my_gsup_client_send; @@ -2228,7 +2241,7 @@ { struct apn_ctx *actxs[4]; struct sgsn_ggsn_ctx *ggc, *ggcs[3]; - struct gsm_subscriber *s1; + struct gprs_subscr *s1; const char *imsi1 = "1234567890"; struct sgsn_mm_ctx *ctx; struct gprs_ra_id raid = { 0, }; @@ -2347,7 +2360,7 @@ /* Cleanup */ - subscr_put(s1); + gprs_subscr_put(s1); sgsn_mm_ctx_cleanup_free(ctx); assert_no_subscrs(); diff --git a/openbsc/tests/sgsn/sgsn_test.ok b/openbsc/tests/sgsn/sgsn_test.ok index c7a53b9..f38d730 100644 --- a/openbsc/tests/sgsn/sgsn_test.ok +++ b/openbsc/tests/sgsn/sgsn_test.ok @@ -1,5 +1,13 @@ Testing LLME allocations Testing core subscriber data API +llist_count(gprs_subscribers) == 0 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 2 +llist_count(gprs_subscribers) == 3 +llist_count(gprs_subscribers) == 2 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 0 Testing authentication triplet handling Testing subscriber GSUP handling Testing GMM detach -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 9 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 05:44:09 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 05:44:09 +0000 Subject: [PATCH] openbsc[master]: SGSN: Integrate support for UMTS AKA In-Reply-To: References: Message-ID: Hello Max, Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1683 to look at the new patch set (#5). SGSN: Integrate support for UMTS AKA The general infrastructure for UMTS AKA is already in place: * GSUP with capability to send us auth_vectors that contain either triplets or quintuples * mm_context that holds such auth_vectors Add: * capability to send UMTS AUTN in GMM AUTH REQ * parse extended UMTS RES * on auth response, validate expected AKA with vector and received res/sres * add Auth Failure message to receive resync AUTS token and * send to HLR * clear out-of-sync auth tuple * enter new state for when we're waiting for HLR to resync and send new tuples so that the next Auth Request will be handled Original first half of this patch by: Harald Welte Full UMTS AKA procedure including AUTS resync tested to work against OsmoHLR with R99 USIM and Milenage algorithm. Depends: libosmocore change-ids I277fb3d407396dffa5c07a9c5454d87a415d393f If943731a78089f0aac3d55245de80596d01314a4 Related: OS#1956 Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_subscriber.c M openbsc/src/gprs/sgsn_auth.c M openbsc/src/gprs/sgsn_main.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c 7 files changed, 215 insertions(+), 42 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/83/1683/5 diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index c3cac7f..fd86174 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -73,6 +73,7 @@ enum sgsn_auth_state { SGSN_AUTH_UNKNOWN, SGSN_AUTH_AUTHENTICATE, + SGSN_AUTH_UMTS_RESYNC, SGSN_AUTH_ACCEPTED, SGSN_AUTH_REJECTED }; @@ -446,7 +447,11 @@ int gprs_subscr_init(struct sgsn_instance *sgi); int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); -int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx); +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand); +int gprs_subscr_auth_sync(struct gprs_subscr *subscr, + const uint8_t *auts, const uint8_t *auts_rand); void gprs_subscr_cleanup(struct gprs_subscr *subscr); struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi); struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 9efe402..3f59a2b 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -83,6 +83,8 @@ [GSM48_IE_GMM_PTMSI_SIG] = { TLV_TYPE_FIXED, 3 }, [GSM48_IE_GMM_AUTH_RAND] = { TLV_TYPE_FIXED, 16 }, [GSM48_IE_GMM_AUTH_SRES] = { TLV_TYPE_FIXED, 4 }, + [GSM48_IE_GMM_AUTH_RES_EXT] = { TLV_TYPE_TLV, 0 }, + [GSM48_IE_GMM_AUTH_FAIL_PAR] = { TLV_TYPE_TLV, 0 }, [GSM48_IE_GMM_IMEISV] = { TLV_TYPE_TLV, 0 }, [GSM48_IE_GMM_DRX_PARAM] = { TLV_TYPE_FIXED, 2 }, [GSM48_IE_GMM_MS_NET_CAPA] = { TLV_TYPE_TLV, 0 }, @@ -554,8 +556,19 @@ return gsm48_gmm_sendmsg(msg, 1, mm, false); } +/* determine if the MS/UE supports R99 or later */ +static bool mmctx_is_r99(const struct sgsn_mm_ctx *mm) +{ + if (mm->ms_network_capa.len < 1) + return false; + if (mm->ms_network_capa.buf[0] & 0x01) + return true; + return false; +} + /* 3GPP TS 24.008 Section 9.4.9: Authentication and Ciphering Request */ -static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, uint8_t *rnd, +static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, + const struct osmo_auth_vector *vec, uint8_t key_seq, bool force_standby) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 AUTH CIPH REQ"); @@ -563,8 +576,14 @@ struct gsm48_auth_ciph_req *acreq; uint8_t *m_rand, *m_cksn, rbyte; - LOGMMCTXP(LOGL_INFO, mm, "<- GPRS AUTH AND CIPHERING REQ (rand = %s)\n", - osmo_hexdump(rnd, 16)); + LOGMMCTXP(LOGL_INFO, mm, "<- GPRS AUTH AND CIPHERING REQ (rand = %s", + osmo_hexdump(vec->rand, sizeof(vec->rand))); + if (mmctx_is_r99(mm) && vec + && (vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { + LOGPC(DMM, LOGL_INFO, ", autn = %s)\n", + osmo_hexdump(vec->autn, sizeof(vec->autn))); + } else + LOGPC(DMM, LOGL_INFO, ")\n"); mmctx2msgid(msg, mm); @@ -588,16 +607,25 @@ mm->ac_ref_nr_used = acreq->ac_ref_nr; /* Only if authentication is requested we need to set RAND + CKSN */ - if (rnd) { - m_rand = msgb_put(msg, 16+1); + if (vec) { + m_rand = msgb_put(msg, sizeof(vec->rand) + 1); m_rand[0] = GSM48_IE_GMM_AUTH_RAND; - memcpy(m_rand + 1, rnd, 16); + memcpy(m_rand + 1, vec->rand, sizeof(vec->rand)); + /* ? 10.5.1.2: */ m_cksn = msgb_put(msg, 1); m_cksn[0] = (GSM48_IE_GMM_CIPH_CKSN << 4) | (key_seq & 0x07); + + /* A Release99 or higher MS/UE must be able to handle + * the optional AUTN IE. If a classic GSM SIM is + * inserted, it will simply ignore AUTN and just use + * RAND */ + if (mmctx_is_r99(mm) && + (vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { + msgb_tlv_put(msg, GSM48_IE_GMM_AUTN, + sizeof(vec->autn), vec->autn); + } } - /* FIXME: add AUTN for 3g auth according to 3GPP TS 24.008 ? 10.5.3.1.1 */ - /* FIXME: make sure we don't send any other messages to the MS */ return gsm48_gmm_sendmsg(msg, 1, mm, false); } @@ -619,6 +647,62 @@ return gsm48_gmm_sendmsg(msg, 0, mm, false); } +/* check if the received authentication response matches */ +static bool check_auth_resp(struct sgsn_mm_ctx *ctx, + bool is_utran, + const struct osmo_auth_vector *vec, + const uint8_t *res, uint8_t res_len) +{ + const uint8_t *expect_res; + uint8_t expect_res_len; + enum osmo_sub_auth_type expect_type; + const char *expect_str; + + if (!vec) + return true; /* really!? */ + + /* On UTRAN (3G) we always expect UMTS AKA. On GERAN (2G) we sent AUTN + * and expect UMTS AKA if there is R99 capability and our vector + * supports UMTS AKA, otherwise we expect GSM AKA. */ + if (is_utran + || (mmctx_is_r99(ctx) && (vec->auth_types & OSMO_AUTH_TYPE_UMTS))) { + expect_type = OSMO_AUTH_TYPE_UMTS; + expect_str = "UMTS RES"; + expect_res = vec->res; + expect_res_len = vec->res_len; + } else { + expect_type = OSMO_AUTH_TYPE_GSM; + expect_str = "GSM SRES"; + expect_res = vec->sres; + expect_res_len = sizeof(vec->sres); + } + + if (!(vec->auth_types & expect_type)) { + LOGMMCTXP(LOGL_ERROR, ctx, "Auth error: auth vector does" + " not provide the expected auth type:" + " expected %s = 0x%x, auth_types are 0x%x\n", + expect_str, expect_type, vec->auth_types); + return false; + } + + if (!res) + goto auth_mismatch; + + if (res_len != expect_res_len) + goto auth_mismatch; + + if (memcmp(res, expect_res, res_len) != 0) + goto auth_mismatch; + + /* Authorized! */ + return true; + +auth_mismatch: + LOGMMCTXP(LOGL_ERROR, ctx, "Auth mismatch: expected %s = %s\n", + expect_str, osmo_hexdump_nospc(expect_res, expect_res_len)); + return false; +} + /* Section 9.4.10: Authentication and Ciphering Response */ static int gsm48_rx_gmm_auth_ciph_resp(struct sgsn_mm_ctx *ctx, struct msgb *msg) @@ -627,6 +711,9 @@ struct gsm48_auth_ciph_resp *acr = (struct gsm48_auth_ciph_resp *)gh->data; struct tlv_parsed tp; struct gsm_auth_tuple *at; + const char *res_name = "(no response)"; + uint8_t res[16]; + uint8_t res_len; int rc; LOGMMCTXP(LOGL_INFO, ctx, "-> GPRS AUTH AND CIPH RESPONSE\n"); @@ -651,26 +738,34 @@ (msg->data + msg->len) - acr->data, 0, 0); if (!TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_SRES) || - !TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV)) { + !TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV) || + TLVP_LEN(&tp,GSM48_IE_GMM_AUTH_SRES) != 4) { /* TODO: missing mandatory IE, return STATUS or REJ? */ LOGMMCTXP(LOGL_ERROR, ctx, "Missing mandantory IE\n"); return -EINVAL; } - /* Compare SRES with what we expected */ - LOGMMCTXP(LOGL_DEBUG, ctx, "checking received auth info, SRES = %s\n", - osmo_hexdump(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), - TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES))); + /* Start with the good old 4-byte SRES */ + memcpy(res, TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), 4); + res_len = 4; + res_name = "GSM SRES"; + + /* Append extended RES as part of UMTS AKA, if any */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_RES_EXT)) { + unsigned int l = TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_RES_EXT); + if (l > sizeof(res)-4) + l = sizeof(res)-4; + memcpy(res+4, TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_RES_EXT), l); + res_len += l; + res_name = "UMTS RES"; + } at = &ctx->auth_triplet; - if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES) != sizeof(at->vec.sres) || - memcmp(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), at->vec.sres, - sizeof(at->vec.sres)) != 0) { - - LOGMMCTXP(LOGL_NOTICE, ctx, "Received SRES doesn't match " - "expected RES %s\n", osmo_hexdump(at->vec.sres, - sizeof(at->vec.sres))); + LOGMMCTXP(LOGL_DEBUG, ctx, "checking auth: received %s = %s\n", + res_name, osmo_hexdump(res, res_len)); + rc = check_auth_resp(ctx, false, &at->vec, res, res_len); + if (!rc) { rc = gsm48_tx_gmm_auth_ciph_rej(ctx); mm_ctx_cleanup_free(ctx, "GPRS AUTH AND CIPH REJECT"); return rc; @@ -685,6 +780,60 @@ /* Check if we can let the mobile station enter */ return gsm48_gmm_authorize(ctx); +} + +/* Section 9.4.10: Authentication and Ciphering Failure */ +static int gsm48_rx_gmm_auth_ciph_fail(struct sgsn_mm_ctx *ctx, + struct msgb *msg) +{ + struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); + struct tlv_parsed tp; + const uint8_t gmm_cause = gh->data[0]; + const uint8_t *auts; + int rc; + + LOGMMCTXP(LOGL_INFO, ctx, "-> GPRS AUTH AND CIPH FAILURE (cause = %s)\n", + get_value_string(gsm48_gmm_cause_names, gmm_cause)); + + tlv_parse(&tp, &gsm48_gmm_att_tlvdef, gh->data+1, msg->len - 1, 0, 0); + + /* Only if GMM cause is present and the AUTS is provided, we can + * start re-sync procedure */ + if (gmm_cause == GMM_CAUSE_SYNC_FAIL && + TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR)) { + if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR) != 14) { + LOGMMCTXP(LOGL_ERROR, ctx, "AUTS IE has wrong size:" + " expected %d, got %u\n", 14, + TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR)); + return -EINVAL; + } + auts = TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR); + + LOGMMCTXP(LOGL_INFO, ctx, + "R99 AUTHENTICATION SYNCH (AUTS = %s)\n", + osmo_hexdump_nospc(auts, 14)); + + /* make sure we'll refresh the auth_triplet in + * sgsn_auth_update() */ + ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; + + /* make sure we'll retry authentication after the resync */ + ctx->auth_state = SGSN_AUTH_UMTS_RESYNC; + + /* Send AUTS to HLR and wait for new Auth Info Result */ + rc = gprs_subscr_request_auth_info(ctx, auts, + ctx->auth_triplet.vec.rand); + if (!rc) + return 0; + /* on error, fall through to send a reject */ + LOGMMCTXP(LOGL_ERROR, ctx, + "Sending AUTS to HLR failed (rc = %d)\n", rc); + } + + LOGMMCTXP(LOGL_NOTICE, ctx, "Authentication failed\n"); + rc = gsm48_tx_gmm_auth_ciph_rej(ctx); + mm_ctx_cleanup_free(ctx, "GPRS AUTH FAILURE"); + return rc; } static void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx) @@ -865,8 +1014,8 @@ struct gsm_auth_tuple *at = &ctx->auth_triplet; mmctx_timer_start(ctx, 3360, sgsn->cfg.timers.T3360); - return gsm48_tx_gmm_auth_ciph_req(ctx, at->vec.rand, - at->key_seq, false); + return gsm48_tx_gmm_auth_ciph_req(ctx, &at->vec, at->key_seq, + false); } if (ctx->auth_state == SGSN_AUTH_AUTHENTICATE && ctx->is_authenticated && @@ -1911,6 +2060,9 @@ goto null_mmctx; rc = gsm48_rx_gmm_auth_ciph_resp(mmctx, msg); break; + case GSM48_MT_GMM_AUTH_CIPH_FAIL: + rc = gsm48_rx_gmm_auth_ciph_fail(mmctx, msg); + break; default: LOGMMCTXP(LOGL_NOTICE, mmctx, "Unknown GSM 04.08 GMM msg type 0x%02x\n", gh->msg_type); @@ -1979,7 +2131,7 @@ } at = &mm->auth_triplet; - gsm48_tx_gmm_auth_ciph_req(mm, at->vec.rand, at->key_seq, false); + gsm48_tx_gmm_auth_ciph_req(mm, &at->vec, at->key_seq, false); osmo_timer_schedule(&mm->timer, sgsn->cfg.timers.T3360, 0); break; case 3370: /* waiting for IDENTITY RESPONSE */ diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index 5f426f8..2042ec6 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -766,14 +766,21 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_query_auth_info(struct gprs_subscr *subscr) +static int gprs_subscr_query_auth_info(struct gprs_subscr *subscr, + const uint8_t *auts, + const uint8_t *auts_rand) { struct osmo_gsup_message gsup_msg = {0}; - LOGGSUBSCRP(LOGL_INFO, subscr, - "subscriber auth info is not available\n"); + /* Make sure we have a complete resync or clearly no resync. */ + OSMO_ASSERT((auts != NULL) == (auts_rand != NULL)); + + LOGGSUBSCRP(LOGL_INFO, subscr, "requesting auth info%s\n", + auts ? " with AUTS (UMTS Resynch)" : ""); gsup_msg.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST; + gsup_msg.auts = auts; + gsup_msg.rand = auts_rand; return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } @@ -854,7 +861,16 @@ return rc; } -int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) +/*! \brief Send Update Auth Info request via GSUP, with or without resync. + * \param[in] mmctx MM context to request authentication tuples for. + * \param[in] auts 14 octet AUTS token for UMTS resync, or NULL. + * \param[in] auts_rand 16 octet Random token for UMTS resync, or NULL. + * In case of normal Authentication Info request, both \a auts and \a auts_rand + * must be NULL. For resync, both must be non-NULL. + */ +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand) { struct gprs_subscr *subscr = NULL; int rc; @@ -865,7 +881,7 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; - rc = gprs_subscr_query_auth_info(subscr); + rc = gprs_subscr_query_auth_info(subscr, auts, auts_rand); gprs_subscr_put(subscr); return rc; } diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index df7ee37..a64339c 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -32,6 +32,7 @@ { SGSN_AUTH_REJECTED, "rejected"}, { SGSN_AUTH_UNKNOWN, "unknown"}, { SGSN_AUTH_AUTHENTICATE, "authenticate" }, + { SGSN_AUTH_UMTS_RESYNC, "UMTS-resync" }, { 0, NULL } }; @@ -182,7 +183,7 @@ mmctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; LOGMMCTXP(LOGL_INFO, mmctx, "Requesting authentication tuples\n"); - rc = gprs_subscr_request_auth_info(mmctx); + rc = gprs_subscr_request_auth_info(mmctx, NULL, NULL); if (rc >= 0) return 0; diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index af5cced..5cdfb31 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -376,7 +376,7 @@ rc = sgsn_parse_config(sgsn_inst.config_file, &sgsn_inst.cfg); if (rc < 0) { - LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); + LOGP(DGPRS, LOGL_FATAL, "Error in config file\n"); exit(2); } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index a730635..6c8b640 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -638,17 +638,6 @@ { int val = get_string_value(sgsn_auth_pol_strs, argv[0]); OSMO_ASSERT(val >= SGSN_AUTH_POLICY_OPEN && val <= SGSN_AUTH_POLICY_REMOTE); - if (val == SGSN_AUTH_POLICY_REMOTE) { - const char *err = "%% auth-policy remote requires"; - if (!g_cfg->gsup_server_addr.sin_addr.s_addr) { - vty_out(vty, "%s 'gsup remote-ip'%s", err, VTY_NEWLINE); - return CMD_WARNING; - } - if (!g_cfg->gsup_server_port) { - vty_out(vty, "%s 'gsup remote-port'%s", err, VTY_NEWLINE); - return CMD_WARNING; - } - } g_cfg->auth_policy = val; g_cfg->require_authentication = (val == SGSN_AUTH_POLICY_REMOTE); g_cfg->require_update_location = (val == SGSN_AUTH_POLICY_REMOTE); @@ -1311,5 +1300,14 @@ return rc; } + if (g_cfg->auth_policy == SGSN_AUTH_POLICY_REMOTE + && !(g_cfg->gsup_server_addr.sin_addr.s_addr + && g_cfg->gsup_server_port)) { + fprintf(stderr, "Configuration error:" + " 'auth-policy remote' requires both" + " 'gsup remote-ip' and 'gsup remote-port'\n"); + return -EINVAL; + } + return 0; } diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 6eabdde..2f1513a 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -1164,6 +1164,7 @@ { struct gsm_auth_tuple at = { .vec.sres = {0x51, 0xe5, 0x51, 0xe5}, + .vec.auth_types = OSMO_AUTH_TYPE_GSM, .key_seq = 0 }; -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 5 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 05:47:24 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 05:47:24 +0000 Subject: [PATCH] openbsc[master]: SGSN: Integrate support for UMTS AKA In-Reply-To: References: Message-ID: Hello Max, Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1683 to look at the new patch set (#6). SGSN: Integrate support for UMTS AKA The general infrastructure for UMTS AKA is already in place: * GSUP with capability to send us auth_vectors that contain either triplets or quintuples * mm_context that holds such auth_vectors Add: * capability to send UMTS AUTN in GMM AUTH REQ * parse extended UMTS RES * on auth response, validate expected AKA with vector and received res/sres * add Auth Failure message to receive resync AUTS token and * send to HLR * clear out-of-sync auth tuple * enter new state for when we're waiting for HLR to resync and send new tuples so that the next Auth Request will be handled Original first half of this patch by: Harald Welte Full UMTS AKA procedure including AUTS resync tested to work against OsmoHLR with R99 USIM and Milenage algorithm. The sgsn_test.c needs adjustment because we're checking the vector's auth_types now. Depends: libosmocore change-ids I277fb3d407396dffa5c07a9c5454d87a415d393f If943731a78089f0aac3d55245de80596d01314a4 Related: OS#1956 Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_subscriber.c M openbsc/src/gprs/sgsn_auth.c M openbsc/tests/sgsn/sgsn_test.c 5 files changed, 205 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/83/1683/6 diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index c3cac7f..fd86174 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -73,6 +73,7 @@ enum sgsn_auth_state { SGSN_AUTH_UNKNOWN, SGSN_AUTH_AUTHENTICATE, + SGSN_AUTH_UMTS_RESYNC, SGSN_AUTH_ACCEPTED, SGSN_AUTH_REJECTED }; @@ -446,7 +447,11 @@ int gprs_subscr_init(struct sgsn_instance *sgi); int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); -int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx); +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand); +int gprs_subscr_auth_sync(struct gprs_subscr *subscr, + const uint8_t *auts, const uint8_t *auts_rand); void gprs_subscr_cleanup(struct gprs_subscr *subscr); struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi); struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 9efe402..3f59a2b 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -83,6 +83,8 @@ [GSM48_IE_GMM_PTMSI_SIG] = { TLV_TYPE_FIXED, 3 }, [GSM48_IE_GMM_AUTH_RAND] = { TLV_TYPE_FIXED, 16 }, [GSM48_IE_GMM_AUTH_SRES] = { TLV_TYPE_FIXED, 4 }, + [GSM48_IE_GMM_AUTH_RES_EXT] = { TLV_TYPE_TLV, 0 }, + [GSM48_IE_GMM_AUTH_FAIL_PAR] = { TLV_TYPE_TLV, 0 }, [GSM48_IE_GMM_IMEISV] = { TLV_TYPE_TLV, 0 }, [GSM48_IE_GMM_DRX_PARAM] = { TLV_TYPE_FIXED, 2 }, [GSM48_IE_GMM_MS_NET_CAPA] = { TLV_TYPE_TLV, 0 }, @@ -554,8 +556,19 @@ return gsm48_gmm_sendmsg(msg, 1, mm, false); } +/* determine if the MS/UE supports R99 or later */ +static bool mmctx_is_r99(const struct sgsn_mm_ctx *mm) +{ + if (mm->ms_network_capa.len < 1) + return false; + if (mm->ms_network_capa.buf[0] & 0x01) + return true; + return false; +} + /* 3GPP TS 24.008 Section 9.4.9: Authentication and Ciphering Request */ -static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, uint8_t *rnd, +static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, + const struct osmo_auth_vector *vec, uint8_t key_seq, bool force_standby) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 AUTH CIPH REQ"); @@ -563,8 +576,14 @@ struct gsm48_auth_ciph_req *acreq; uint8_t *m_rand, *m_cksn, rbyte; - LOGMMCTXP(LOGL_INFO, mm, "<- GPRS AUTH AND CIPHERING REQ (rand = %s)\n", - osmo_hexdump(rnd, 16)); + LOGMMCTXP(LOGL_INFO, mm, "<- GPRS AUTH AND CIPHERING REQ (rand = %s", + osmo_hexdump(vec->rand, sizeof(vec->rand))); + if (mmctx_is_r99(mm) && vec + && (vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { + LOGPC(DMM, LOGL_INFO, ", autn = %s)\n", + osmo_hexdump(vec->autn, sizeof(vec->autn))); + } else + LOGPC(DMM, LOGL_INFO, ")\n"); mmctx2msgid(msg, mm); @@ -588,16 +607,25 @@ mm->ac_ref_nr_used = acreq->ac_ref_nr; /* Only if authentication is requested we need to set RAND + CKSN */ - if (rnd) { - m_rand = msgb_put(msg, 16+1); + if (vec) { + m_rand = msgb_put(msg, sizeof(vec->rand) + 1); m_rand[0] = GSM48_IE_GMM_AUTH_RAND; - memcpy(m_rand + 1, rnd, 16); + memcpy(m_rand + 1, vec->rand, sizeof(vec->rand)); + /* ? 10.5.1.2: */ m_cksn = msgb_put(msg, 1); m_cksn[0] = (GSM48_IE_GMM_CIPH_CKSN << 4) | (key_seq & 0x07); + + /* A Release99 or higher MS/UE must be able to handle + * the optional AUTN IE. If a classic GSM SIM is + * inserted, it will simply ignore AUTN and just use + * RAND */ + if (mmctx_is_r99(mm) && + (vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { + msgb_tlv_put(msg, GSM48_IE_GMM_AUTN, + sizeof(vec->autn), vec->autn); + } } - /* FIXME: add AUTN for 3g auth according to 3GPP TS 24.008 ? 10.5.3.1.1 */ - /* FIXME: make sure we don't send any other messages to the MS */ return gsm48_gmm_sendmsg(msg, 1, mm, false); } @@ -619,6 +647,62 @@ return gsm48_gmm_sendmsg(msg, 0, mm, false); } +/* check if the received authentication response matches */ +static bool check_auth_resp(struct sgsn_mm_ctx *ctx, + bool is_utran, + const struct osmo_auth_vector *vec, + const uint8_t *res, uint8_t res_len) +{ + const uint8_t *expect_res; + uint8_t expect_res_len; + enum osmo_sub_auth_type expect_type; + const char *expect_str; + + if (!vec) + return true; /* really!? */ + + /* On UTRAN (3G) we always expect UMTS AKA. On GERAN (2G) we sent AUTN + * and expect UMTS AKA if there is R99 capability and our vector + * supports UMTS AKA, otherwise we expect GSM AKA. */ + if (is_utran + || (mmctx_is_r99(ctx) && (vec->auth_types & OSMO_AUTH_TYPE_UMTS))) { + expect_type = OSMO_AUTH_TYPE_UMTS; + expect_str = "UMTS RES"; + expect_res = vec->res; + expect_res_len = vec->res_len; + } else { + expect_type = OSMO_AUTH_TYPE_GSM; + expect_str = "GSM SRES"; + expect_res = vec->sres; + expect_res_len = sizeof(vec->sres); + } + + if (!(vec->auth_types & expect_type)) { + LOGMMCTXP(LOGL_ERROR, ctx, "Auth error: auth vector does" + " not provide the expected auth type:" + " expected %s = 0x%x, auth_types are 0x%x\n", + expect_str, expect_type, vec->auth_types); + return false; + } + + if (!res) + goto auth_mismatch; + + if (res_len != expect_res_len) + goto auth_mismatch; + + if (memcmp(res, expect_res, res_len) != 0) + goto auth_mismatch; + + /* Authorized! */ + return true; + +auth_mismatch: + LOGMMCTXP(LOGL_ERROR, ctx, "Auth mismatch: expected %s = %s\n", + expect_str, osmo_hexdump_nospc(expect_res, expect_res_len)); + return false; +} + /* Section 9.4.10: Authentication and Ciphering Response */ static int gsm48_rx_gmm_auth_ciph_resp(struct sgsn_mm_ctx *ctx, struct msgb *msg) @@ -627,6 +711,9 @@ struct gsm48_auth_ciph_resp *acr = (struct gsm48_auth_ciph_resp *)gh->data; struct tlv_parsed tp; struct gsm_auth_tuple *at; + const char *res_name = "(no response)"; + uint8_t res[16]; + uint8_t res_len; int rc; LOGMMCTXP(LOGL_INFO, ctx, "-> GPRS AUTH AND CIPH RESPONSE\n"); @@ -651,26 +738,34 @@ (msg->data + msg->len) - acr->data, 0, 0); if (!TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_SRES) || - !TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV)) { + !TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV) || + TLVP_LEN(&tp,GSM48_IE_GMM_AUTH_SRES) != 4) { /* TODO: missing mandatory IE, return STATUS or REJ? */ LOGMMCTXP(LOGL_ERROR, ctx, "Missing mandantory IE\n"); return -EINVAL; } - /* Compare SRES with what we expected */ - LOGMMCTXP(LOGL_DEBUG, ctx, "checking received auth info, SRES = %s\n", - osmo_hexdump(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), - TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES))); + /* Start with the good old 4-byte SRES */ + memcpy(res, TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), 4); + res_len = 4; + res_name = "GSM SRES"; + + /* Append extended RES as part of UMTS AKA, if any */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_RES_EXT)) { + unsigned int l = TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_RES_EXT); + if (l > sizeof(res)-4) + l = sizeof(res)-4; + memcpy(res+4, TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_RES_EXT), l); + res_len += l; + res_name = "UMTS RES"; + } at = &ctx->auth_triplet; - if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES) != sizeof(at->vec.sres) || - memcmp(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), at->vec.sres, - sizeof(at->vec.sres)) != 0) { - - LOGMMCTXP(LOGL_NOTICE, ctx, "Received SRES doesn't match " - "expected RES %s\n", osmo_hexdump(at->vec.sres, - sizeof(at->vec.sres))); + LOGMMCTXP(LOGL_DEBUG, ctx, "checking auth: received %s = %s\n", + res_name, osmo_hexdump(res, res_len)); + rc = check_auth_resp(ctx, false, &at->vec, res, res_len); + if (!rc) { rc = gsm48_tx_gmm_auth_ciph_rej(ctx); mm_ctx_cleanup_free(ctx, "GPRS AUTH AND CIPH REJECT"); return rc; @@ -685,6 +780,60 @@ /* Check if we can let the mobile station enter */ return gsm48_gmm_authorize(ctx); +} + +/* Section 9.4.10: Authentication and Ciphering Failure */ +static int gsm48_rx_gmm_auth_ciph_fail(struct sgsn_mm_ctx *ctx, + struct msgb *msg) +{ + struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); + struct tlv_parsed tp; + const uint8_t gmm_cause = gh->data[0]; + const uint8_t *auts; + int rc; + + LOGMMCTXP(LOGL_INFO, ctx, "-> GPRS AUTH AND CIPH FAILURE (cause = %s)\n", + get_value_string(gsm48_gmm_cause_names, gmm_cause)); + + tlv_parse(&tp, &gsm48_gmm_att_tlvdef, gh->data+1, msg->len - 1, 0, 0); + + /* Only if GMM cause is present and the AUTS is provided, we can + * start re-sync procedure */ + if (gmm_cause == GMM_CAUSE_SYNC_FAIL && + TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR)) { + if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR) != 14) { + LOGMMCTXP(LOGL_ERROR, ctx, "AUTS IE has wrong size:" + " expected %d, got %u\n", 14, + TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR)); + return -EINVAL; + } + auts = TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR); + + LOGMMCTXP(LOGL_INFO, ctx, + "R99 AUTHENTICATION SYNCH (AUTS = %s)\n", + osmo_hexdump_nospc(auts, 14)); + + /* make sure we'll refresh the auth_triplet in + * sgsn_auth_update() */ + ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; + + /* make sure we'll retry authentication after the resync */ + ctx->auth_state = SGSN_AUTH_UMTS_RESYNC; + + /* Send AUTS to HLR and wait for new Auth Info Result */ + rc = gprs_subscr_request_auth_info(ctx, auts, + ctx->auth_triplet.vec.rand); + if (!rc) + return 0; + /* on error, fall through to send a reject */ + LOGMMCTXP(LOGL_ERROR, ctx, + "Sending AUTS to HLR failed (rc = %d)\n", rc); + } + + LOGMMCTXP(LOGL_NOTICE, ctx, "Authentication failed\n"); + rc = gsm48_tx_gmm_auth_ciph_rej(ctx); + mm_ctx_cleanup_free(ctx, "GPRS AUTH FAILURE"); + return rc; } static void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx) @@ -865,8 +1014,8 @@ struct gsm_auth_tuple *at = &ctx->auth_triplet; mmctx_timer_start(ctx, 3360, sgsn->cfg.timers.T3360); - return gsm48_tx_gmm_auth_ciph_req(ctx, at->vec.rand, - at->key_seq, false); + return gsm48_tx_gmm_auth_ciph_req(ctx, &at->vec, at->key_seq, + false); } if (ctx->auth_state == SGSN_AUTH_AUTHENTICATE && ctx->is_authenticated && @@ -1911,6 +2060,9 @@ goto null_mmctx; rc = gsm48_rx_gmm_auth_ciph_resp(mmctx, msg); break; + case GSM48_MT_GMM_AUTH_CIPH_FAIL: + rc = gsm48_rx_gmm_auth_ciph_fail(mmctx, msg); + break; default: LOGMMCTXP(LOGL_NOTICE, mmctx, "Unknown GSM 04.08 GMM msg type 0x%02x\n", gh->msg_type); @@ -1979,7 +2131,7 @@ } at = &mm->auth_triplet; - gsm48_tx_gmm_auth_ciph_req(mm, at->vec.rand, at->key_seq, false); + gsm48_tx_gmm_auth_ciph_req(mm, &at->vec, at->key_seq, false); osmo_timer_schedule(&mm->timer, sgsn->cfg.timers.T3360, 0); break; case 3370: /* waiting for IDENTITY RESPONSE */ diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index 5f426f8..2042ec6 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -766,14 +766,21 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_query_auth_info(struct gprs_subscr *subscr) +static int gprs_subscr_query_auth_info(struct gprs_subscr *subscr, + const uint8_t *auts, + const uint8_t *auts_rand) { struct osmo_gsup_message gsup_msg = {0}; - LOGGSUBSCRP(LOGL_INFO, subscr, - "subscriber auth info is not available\n"); + /* Make sure we have a complete resync or clearly no resync. */ + OSMO_ASSERT((auts != NULL) == (auts_rand != NULL)); + + LOGGSUBSCRP(LOGL_INFO, subscr, "requesting auth info%s\n", + auts ? " with AUTS (UMTS Resynch)" : ""); gsup_msg.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST; + gsup_msg.auts = auts; + gsup_msg.rand = auts_rand; return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } @@ -854,7 +861,16 @@ return rc; } -int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) +/*! \brief Send Update Auth Info request via GSUP, with or without resync. + * \param[in] mmctx MM context to request authentication tuples for. + * \param[in] auts 14 octet AUTS token for UMTS resync, or NULL. + * \param[in] auts_rand 16 octet Random token for UMTS resync, or NULL. + * In case of normal Authentication Info request, both \a auts and \a auts_rand + * must be NULL. For resync, both must be non-NULL. + */ +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand) { struct gprs_subscr *subscr = NULL; int rc; @@ -865,7 +881,7 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; - rc = gprs_subscr_query_auth_info(subscr); + rc = gprs_subscr_query_auth_info(subscr, auts, auts_rand); gprs_subscr_put(subscr); return rc; } diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index df7ee37..a64339c 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -32,6 +32,7 @@ { SGSN_AUTH_REJECTED, "rejected"}, { SGSN_AUTH_UNKNOWN, "unknown"}, { SGSN_AUTH_AUTHENTICATE, "authenticate" }, + { SGSN_AUTH_UMTS_RESYNC, "UMTS-resync" }, { 0, NULL } }; @@ -182,7 +183,7 @@ mmctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; LOGMMCTXP(LOGL_INFO, mmctx, "Requesting authentication tuples\n"); - rc = gprs_subscr_request_auth_info(mmctx); + rc = gprs_subscr_request_auth_info(mmctx, NULL, NULL); if (rc >= 0) return 0; diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 6eabdde..2f1513a 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -1164,6 +1164,7 @@ { struct gsm_auth_tuple at = { .vec.sres = {0x51, 0xe5, 0x51, 0xe5}, + .vec.auth_types = OSMO_AUTH_TYPE_GSM, .key_seq = 0 }; -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 05:47:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 05:47:35 +0000 Subject: [PATCH] openbsc[master]: SGSN VTY: make missing GSUP server address+port fatal Message-ID: Review at https://gerrit.osmocom.org/1894 SGSN VTY: make missing GSUP server address+port fatal On 'auth-policy remote', the SGSN requires GSUP server address and port. If it was missing, the SGSN would print a VTY warning and run anyway. Make this error more fatal: print an error (flattened a bit) to stderr and abort the program. Move validation of the GSUP server data presence out of the VTY command itself and into the config reading function. This way the GSUP server config can be given anywhere, including below the auth-policy config (was required above). Don't care about setting the auth-policy to remote with a telnet VTY, because in that case the GSUP client won't be started anyway. Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c --- M openbsc/src/gprs/sgsn_main.c M openbsc/src/gprs/sgsn_vty.c 2 files changed, 10 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/94/1894/1 diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index af5cced..5cdfb31 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -376,7 +376,7 @@ rc = sgsn_parse_config(sgsn_inst.config_file, &sgsn_inst.cfg); if (rc < 0) { - LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); + LOGP(DGPRS, LOGL_FATAL, "Error in config file\n"); exit(2); } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index a730635..6c8b640 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -638,17 +638,6 @@ { int val = get_string_value(sgsn_auth_pol_strs, argv[0]); OSMO_ASSERT(val >= SGSN_AUTH_POLICY_OPEN && val <= SGSN_AUTH_POLICY_REMOTE); - if (val == SGSN_AUTH_POLICY_REMOTE) { - const char *err = "%% auth-policy remote requires"; - if (!g_cfg->gsup_server_addr.sin_addr.s_addr) { - vty_out(vty, "%s 'gsup remote-ip'%s", err, VTY_NEWLINE); - return CMD_WARNING; - } - if (!g_cfg->gsup_server_port) { - vty_out(vty, "%s 'gsup remote-port'%s", err, VTY_NEWLINE); - return CMD_WARNING; - } - } g_cfg->auth_policy = val; g_cfg->require_authentication = (val == SGSN_AUTH_POLICY_REMOTE); g_cfg->require_update_location = (val == SGSN_AUTH_POLICY_REMOTE); @@ -1311,5 +1300,14 @@ return rc; } + if (g_cfg->auth_policy == SGSN_AUTH_POLICY_REMOTE + && !(g_cfg->gsup_server_addr.sin_addr.s_addr + && g_cfg->gsup_server_port)) { + fprintf(stderr, "Configuration error:" + " 'auth-policy remote' requires both" + " 'gsup remote-ip' and 'gsup remote-port'\n"); + return -EINVAL; + } + return 0; } -- To view, visit https://gerrit.osmocom.org/1894 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 09:15:33 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 09:15:33 +0000 Subject: libosmocore[master]: ports.h: rename CSCN to MSC In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1884 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 09:32:37 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 09:32:37 +0000 Subject: libosmocore[master]: Expand and expose ctrl connection allocation In-Reply-To: References: Message-ID: Patch Set 6: Mea culpa - it slipped from earlier version of this patch. Thanks Harald for quick fix! As for gcc options - it's possible and I've merged that into OpenBSC but it's not supported by all gcc versions. Which means we got to check it at configure. But configure check scripts are also not supported by all autoconf versions, so we got to add it manually because our poky is too old. And any mistakes in doing so will break nightly cause sdk is not checked by jenkins yet. All in all - it feels like way too much efforts ATM. I'd like to get back to it after our poky is modernized, but feel free to check OpenBSC patches and make smth similar for other projects if you like. -- To view, visit https://gerrit.osmocom.org/1629 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32 Gerrit-PatchSet: 6 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 13:04:58 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 13:04:58 +0000 Subject: openbsc[master]: SGSN: Integrate support for UMTS AKA In-Reply-To: References: Message-ID: Patch Set 6: this broken pipe thing is really annoying -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 13:41:24 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 13:41:24 +0000 Subject: osmo-hlr[master]: Add global HLR struct In-Reply-To: References: Message-ID: Patch Set 2: My idea is that cmdline_opts contains only exactly the values read from cmdline. The config file parsing would not write to cmdline_opts but (usually) to the global application struct. So, say we're parsing the cmdline options into the global struct. You need that first up, to get the -c config_file option. Then you read the config file into the same global struct. Thus the VTY has higher priority and possibly overwrites cmdline things, where usually the opposite is needed. That's why clear separation might become necessary at some point. Otherwise I like that the results from cmdline parsing are in one place where no magic happens and which no-one touches, so that we can have clear logic on what is coming from where, as well as for clear validation. Also we don't need those in the global context after the program has started. That's just my opinion. -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 2 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 13:52:21 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 13:52:21 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 9: Code-Review-1 argh forgot about the s/have/find_or_create -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 9 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 13:52:51 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 13:52:51 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 9: -Code-Review wrong patch -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 9 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 13:53:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 13:53:01 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 7: Code-Review-1 argh forgot about the s/have/find_or_create -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 7 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 14:04:25 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 14:04:25 +0000 Subject: [PATCH] osmo-bts[master]: Use oml-alert CTRL command for temp report In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1630 to look at the new patch set (#7). Use oml-alert CTRL command for temp report Send temperature reports via OML alert facility exposed by CTRL protocol. Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Related: OS#1615 --- M src/osmo-bts-sysmo/Makefile.am M src/osmo-bts-sysmo/misc/sysmobts_mgr.c M src/osmo-bts-sysmo/misc/sysmobts_mgr.h M src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c 4 files changed, 65 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/30/1630/7 diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am index 8e39a3a..7b27e70 100644 --- a/src/osmo-bts-sysmo/Makefile.am +++ b/src/osmo-bts-sysmo/Makefile.am @@ -29,7 +29,7 @@ misc/sysmobts_mgr_temp.c \ misc/sysmobts_mgr_calib.c \ eeprom.c -sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCTRL_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) +sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c eeprom.c sysmobts_util_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c index f126db2..e9c59bc 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c @@ -21,6 +21,8 @@ */ #include +#include +#include #include #include #include @@ -28,14 +30,19 @@ #include #include #include +#include +#include #include #include #include +#include #include #include #include #include +#include +#include #include "misc/sysmobts_misc.h" #include "misc/sysmobts_mgr.h" @@ -246,10 +253,12 @@ int main(int argc, char **argv) { int rc; - + struct ctrl_connection *ccon; tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager"); msgb_talloc_ctx_init(tall_mgr_ctx, 0); + + srand(time(NULL)); mgr_log_init(); if (classify_bts() != 0) @@ -294,7 +303,23 @@ exit(3); /* Initialize the temperature control */ - sysmobts_mgr_temp_init(&manager); + ccon = osmo_ctrl_conn_alloc(tall_mgr_ctx, NULL); + rc = -1; + if (ccon) { + ccon->write_queue.bfd.data = ccon; + rc = osmo_sock_init_ofd(&ccon->write_queue.bfd, AF_INET, + SOCK_STREAM, IPPROTO_TCP, + "localhost", OSMO_CTRL_PORT_BTS, + OSMO_SOCK_F_CONNECT); + } + if (rc < 0) + LOGP(DLCTRL, LOGL_ERROR, "Can't connect to CTRL @ localhost:%u\n", + OSMO_CTRL_PORT_BTS); + else + LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to locahost:%u\n", + OSMO_CTRL_PORT_BTS); + + sysmobts_mgr_temp_init(&manager, ccon); if (sysmobts_mgr_calib_init(&manager) != 0) exit(3); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h index b393c38..88f4e24 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h @@ -3,7 +3,7 @@ #include #include - +#include #include #include @@ -108,7 +108,8 @@ int sysmobts_mgr_vty_init(void); int sysmobts_mgr_parse_config(struct sysmobts_mgr_instance *mgr); int sysmobts_mgr_nl_init(void); -int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr); +int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr, + struct ctrl_connection *ctrl); const char *sysmobts_mgr_temp_get_state(enum sysmobts_temp_state state); diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c index 34af2ab..2a15d2e 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c @@ -28,6 +28,8 @@ #include #include +#include + static struct sysmobts_mgr_instance *s_mgr; static struct osmo_timer_list temp_ctrl_timer; @@ -185,13 +187,24 @@ } static void sysmobts_mgr_temp_handle(struct sysmobts_mgr_instance *manager, - int critical, int warning) + struct ctrl_connection *ctrl, int critical, + int warning) { - int new_state = next_state(manager->state, critical, warning); + int new_state = next_state(manager->state, critical, warning), rc; + struct ctrl_cmd *rep; + bool send = false; /* Nothing changed */ if (new_state < 0) return; + + rep = ctrl_cmd_create(tall_mgr_ctx, CTRL_TYPE_SET); + if (!rep) { + LOGP(DTEMP, LOGL_ERROR, "OML alert creation failed.\n"); + } else { + rep->id = talloc_asprintf(rep, "%d", rand()); + rep->variable = "oml-alert"; + } LOGP(DTEMP, LOGL_NOTICE, "Moving from state %s to %s.\n", get_value_string(state_names, manager->state), @@ -206,14 +219,24 @@ break; case STATE_WARNING: execute_warning_act(manager); + rep->value = "Temperature Warning"; + send = true; break; case STATE_CRITICAL: execute_critical_act(manager); + rep->value = "Temperature Critical"; + send = true; break; }; + + if (send) { + rc = ctrl_cmd_send(&ctrl->write_queue, rep); + LOGP(DTEMP, LOGL_ERROR, "OML alert sent: %d\n", rc); + } + talloc_free(rep); } -static void temp_ctrl_check() +static void temp_ctrl_check(struct ctrl_connection *ctrl) { int rc; int warn_thresh_passed = 0; @@ -275,20 +298,23 @@ } } - sysmobts_mgr_temp_handle(s_mgr, crit_thresh_passed, warn_thresh_passed); + sysmobts_mgr_temp_handle(s_mgr, ctrl, crit_thresh_passed, + warn_thresh_passed); } -static void temp_ctrl_check_cb(void *unused) +static void temp_ctrl_check_cb(void *ctrl) { - temp_ctrl_check(); + temp_ctrl_check(ctrl); /* Check every two minutes? XXX make it configurable! */ osmo_timer_schedule(&temp_ctrl_timer, 2 * 60, 0); } -int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr) +int sysmobts_mgr_temp_init(struct sysmobts_mgr_instance *mgr, + struct ctrl_connection *ctrl) { s_mgr = mgr; temp_ctrl_timer.cb = temp_ctrl_check_cb; - temp_ctrl_check_cb(NULL); + temp_ctrl_timer.data = ctrl; + temp_ctrl_check_cb(ctrl); return 0; } -- To view, visit https://gerrit.osmocom.org/1630 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Gerrit-PatchSet: 7 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 24 14:04:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 14:04:26 +0000 Subject: [PATCH] libosmocore[master]: Use value_string for ctrl_type Message-ID: Review at https://gerrit.osmocom.org/1895 Use value_string for ctrl_type Use value_string for enum ctrl_type instead of custom code. Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 --- M include/osmocom/ctrl/control_cmd.h M src/ctrl/control_cmd.c 2 files changed, 16 insertions(+), 33 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/95/1895/1 diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h index a63557d..d9092f3 100644 --- a/include/osmocom/ctrl/control_cmd.h +++ b/include/osmocom/ctrl/control_cmd.h @@ -4,7 +4,7 @@ #include #include #include - +#include #include #define CTRL_CMD_ERROR -1 @@ -31,6 +31,8 @@ CTRL_TYPE_ERROR }; +extern const struct value_string ctrl_type_vals[]; + struct ctrl_connection { struct llist_head list_entry; diff --git a/src/ctrl/control_cmd.c b/src/ctrl/control_cmd.c index 2cf66cf..1cc8247 100644 --- a/src/ctrl/control_cmd.c +++ b/src/ctrl/control_cmd.c @@ -33,41 +33,21 @@ #include #include - +#include #include #include extern vector ctrl_node_vec; -static struct ctrl_cmd_map ccm[] = { - {"GET", CTRL_TYPE_GET}, - {"SET", CTRL_TYPE_SET}, - {"GET_REPLY", CTRL_TYPE_GET_REPLY}, - {"SET_REPLY", CTRL_TYPE_SET_REPLY}, - {"TRAP", CTRL_TYPE_TRAP}, - {"ERROR", CTRL_TYPE_ERROR}, - {NULL} +const struct value_string ctrl_type_vals[] = { + { CTRL_TYPE_GET, "GET" }, + { CTRL_TYPE_SET, "SET" }, + { CTRL_TYPE_GET_REPLY, "GET_REPLY" }, + { CTRL_TYPE_SET_REPLY, "SET_REPLY" }, + { CTRL_TYPE_TRAP, "TRAP" }, + { CTRL_TYPE_ERROR, "ERROR" }, + { CTRL_TYPE_UNKNOWN, NULL } }; - -static int ctrl_cmd_str2type(char *s) -{ - int i; - for (i=0; ccm[i].cmd != NULL; i++) { - if (strcasecmp(s, ccm[i].cmd) == 0) - return ccm[i].type; - } - return CTRL_TYPE_UNKNOWN; -} - -static char *ctrl_cmd_type2str(int type) -{ - int i; - for (i=0; ccm[i].cmd != NULL; i++) { - if (ccm[i].type == type) - return ccm[i].cmd; - } - return NULL; -} /* Functions from libosmocom */ extern vector cmd_make_descvec(const char *string, const char *descstr); @@ -308,7 +288,7 @@ goto err; } - cmd->type = ctrl_cmd_str2type(tmp); + cmd->type = get_string_value(ctrl_type_vals, tmp); if (cmd->type == CTRL_TYPE_UNKNOWN) { cmd->type = CTRL_TYPE_ERROR; cmd->id = "err"; @@ -403,7 +383,8 @@ struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd) { struct msgb *msg; - char *type, *tmp; + const char *type; + char *tmp; if (!cmd->id) return NULL; @@ -412,7 +393,7 @@ if (!msg) return NULL; - type = ctrl_cmd_type2str(cmd->type); + type = get_value_string(ctrl_type_vals, cmd->type); switch (cmd->type) { case CTRL_TYPE_GET: -- To view, visit https://gerrit.osmocom.org/1895 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 24 14:04:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 14:04:26 +0000 Subject: [PATCH] libosmocore[master]: Handle replies in ctrl_cmd_handle() Message-ID: Review at https://gerrit.osmocom.org/1896 Handle replies in ctrl_cmd_handle() Previously *_REPLY and ERROR messages were not explicitly handled which would lead to sending error in response to them which in turn would prompt other party to send error as well which would result in infinite cycle. Handle it explicitly by logging message id and other relevant data. Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28 Related: OS#1615 --- M src/ctrl/control_if.c 1 file changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/96/1896/1 diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index d78b513..ac5af87 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -186,6 +186,23 @@ vector vline, cmdvec, cmds_vec; + if (cmd->type == CTRL_TYPE_SET_REPLY || + cmd->type == CTRL_TYPE_GET_REPLY) { + if (strncmp(cmd->reply, "OK", 2) == 0) { + LOGP(DLCTRL, LOGL_DEBUG, "%s <%s> for %s is OK\n", + get_value_string(ctrl_type_vals, cmd->type), + cmd->id, cmd->variable); + return CTRL_CMD_HANDLED; + } + } + + if (cmd->type == CTRL_TYPE_ERROR) { + LOGP(DLCTRL, LOGL_ERROR, "%s <%s> for %s is %s\n", + get_value_string(ctrl_type_vals, cmd->type), + cmd->id, cmd->variable, cmd->reply); + return CTRL_CMD_HANDLED; + } + ret = CTRL_CMD_ERROR; cmd->reply = NULL; node = CTRL_NODE_ROOT; -- To view, visit https://gerrit.osmocom.org/1896 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 24 14:04:26 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 14:04:26 +0000 Subject: [PATCH] libosmocore[master]: Fix client-side ctrl interface helpers Message-ID: Review at https://gerrit.osmocom.org/1897 Fix client-side ctrl interface helpers * remove unused ctrl_interface_connect() which is not part of public API * add default read callback to osmo_ctrl_conn_alloc() Change-Id: Iaa209e34a849ce0dfe2e29b482c3208ade1a32a4 Related: OS#1615 --- M src/ctrl/control_if.c 1 file changed, 1 insertion(+), 39 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/97/1897/1 diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index ac5af87..8bf1ffa 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -405,6 +405,7 @@ ccon->write_queue.bfd.data = data; ccon->write_queue.write_cb = control_write_cb; + ccon->write_queue.read_cb = handle_control_read; return ccon; } @@ -670,45 +671,6 @@ static int verify_counter(struct ctrl_cmd *cmd, const char *value, void *data) { return 0; -} - -/*! \brief Setup CTRL interface connection to a given address - * \param[in] data Pointer which will be made available to each - set_..() get_..() verify_..() control command function - * \param[in] addr Address to which we shall connect - * \param[in] port Port to which we shall connect - * \param[in] lookup Lookup function pointer, can be NULL - * \returns ctrl_handle pointer or NULL in case of errors - */ -struct ctrl_handle *ctrl_interface_connect(void *data, const char *addr, - uint16_t port, - ctrl_cmd_lookup lookup) -{ - int ret; - struct ctrl_handle *ctrl; - - ctrl = talloc_zero(data, struct ctrl_handle); - if (!ctrl) - return NULL; - - INIT_LLIST_HEAD(&ctrl->ccon_list); - - ctrl->data = data; - ctrl->lookup = lookup; - - ctrl->listen_fd.cb = NULL; - ctrl->listen_fd.data = ctrl; - ret = osmo_sock_init_ofd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, - IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT); - if (ret < 0) { - LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n", - addr, port); - talloc_free(ctrl); - return NULL; - } - LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to %s:%u\n", addr, port); - - return ctrl; } struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, -- To view, visit https://gerrit.osmocom.org/1897 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa209e34a849ce0dfe2e29b482c3208ade1a32a4 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 24 14:09:14 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 14:09:14 +0000 Subject: osmo-bts[master]: Use oml-alert CTRL command for temp report In-Reply-To: References: Message-ID: Patch Set 7: Code-Review-1 This should not be merged until 1895-1897 are merged to libosmocore. -- To view, visit https://gerrit.osmocom.org/1630 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If29fbd0ab01fefc76e87b90cf1fbc81b2089ba76 Gerrit-PatchSet: 7 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 14:58:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 14:58:47 +0000 Subject: [PATCH] openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1682 to look at the new patch set (#8). add struct bsc_subscr, separating libbsc from gsm_subscriber In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC subscriber: struct bsc_subscr. Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no longer have a backpointer to gsm_network (used to be via subscr->group). Create a separate logging filter for the new BSC subscriber. The implementation of adjusting the filter context is added in libbsc to not introduce bsc_subscr_get/_put() dependencies to libcommon. During Paging Response, fetch a bsc_subscr from the mobile identity, like we do for the gsm_subscriber. It looks like a duplication now, but will make sense for the VLR as well as for future MSC split patches. Naming: it was requested to not name the new struct bsc_sub, because 'sub' is too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast to type, relatively short, unambiguous, and the naming is consistent. Add bsc_subscr unit test. Related: OS#1592, OS#1594 Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e --- M openbsc/.gitignore M openbsc/include/openbsc/Makefile.am A openbsc/include/openbsc/bsc_subscriber.h M openbsc/include/openbsc/debug.h M openbsc/include/openbsc/gsm_04_08.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/osmo_bsc_grace.h M openbsc/include/openbsc/paging.h M openbsc/src/libbsc/Makefile.am M openbsc/src/libbsc/abis_rsl.c A openbsc/src/libbsc/bsc_subscriber.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/libbsc/gsm_04_08_utils.c M openbsc/src/libbsc/paging.c M openbsc/src/libcommon-cs/common_cs.c M openbsc/src/libcommon/debug.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/gsm_subscriber.c M openbsc/src/libmsc/vty_interface_layer3.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/tests/channel/Makefile.am M openbsc/tests/channel/channel_test.c M openbsc/tests/subscr/Makefile.am A openbsc/tests/subscr/bsc_subscr_test.c A openbsc/tests/subscr/bsc_subscr_test.err A openbsc/tests/subscr/bsc_subscr_test.ok M openbsc/tests/testsuite.at 30 files changed, 612 insertions(+), 115 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/82/1682/8 diff --git a/openbsc/.gitignore b/openbsc/.gitignore index e3f25cb..4f8e7e6 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -79,6 +79,7 @@ tests/mgcp/mgcp_transcoding_test tests/sgsn/sgsn_test tests/subscr/subscr_test +tests/subscr/bsc_subscr_test tests/oap/oap_test tests/gtphub/gtphub_test tests/mm_auth/mm_auth_test diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index c10accd..0895096 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -10,6 +10,7 @@ bsc_nat_callstats.h \ bsc_nat_sccp.h \ bsc_rll.h \ + bsc_subscriber.h \ bss.h \ bts_ipaccess_nanobts_omlattr.h \ chan_alloc.h \ diff --git a/openbsc/include/openbsc/bsc_subscriber.h b/openbsc/include/openbsc/bsc_subscriber.h new file mode 100644 index 0000000..324734f --- /dev/null +++ b/openbsc/include/openbsc/bsc_subscriber.h @@ -0,0 +1,43 @@ +/* GSM subscriber details for use in BSC land */ + +#pragma once + +#include + +#include +#include + +struct log_target; + +struct bsc_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + uint16_t lac; +}; + +const char *bsc_subscr_name(struct bsc_subscr *bsub); + +struct bsc_subscr *bsc_subscr_find_or_create_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_find_or_create_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi); +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi); + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi); + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line); +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line); +#define bsc_subscr_get(bsub) _bsc_subscr_get(bsub, __BASE_FILE__, __LINE__) +#define bsc_subscr_put(bsub) _bsc_subscr_put(bsub, __BASE_FILE__, __LINE__) + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsub); diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h index 6300020..74db723 100644 --- a/openbsc/include/openbsc/debug.h +++ b/openbsc/include/openbsc/debug.h @@ -42,6 +42,7 @@ struct gsm_subscriber; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr); +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr); extern const struct log_info log_info; diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index cb632f6..bdf4ed2 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -15,6 +15,7 @@ struct gsm_subscriber_connection; struct amr_multirate_conf; struct amr_mode; +struct bsc_subscr; #define GSM48_ALLOC_SIZE 2048 #define GSM48_ALLOC_HEADROOM 256 @@ -78,7 +79,8 @@ int send_siemens_mrpci(struct gsm_lchan *lchan, uint8_t *classmark2_lv); int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t *mi_type); int gsm48_paging_extract_mi(struct gsm48_pag_resp *pag, int length, char *mi_string, uint8_t *mi_type); -int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr); +int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, + struct msgb *msg, struct bsc_subscr *bsub); int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode); int gsm48_rx_rr_modif_ack(struct msgb *msg); diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 460953e..dbc58ac 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -23,6 +23,7 @@ struct mncc_sock_state; struct gsm_subscriber_group; +struct bsc_subscr; #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] @@ -112,6 +113,9 @@ /* To whom we are allocated at the moment */ struct gsm_subscriber *subscr; + + /* libbsc subscriber information */ + struct bsc_subscr *bsub; /* LU expiration handling */ uint8_t expire_timer_stopped; @@ -383,6 +387,11 @@ * BTS|RNC specific timezone overrides for multi-tz networks in * OsmoCSCN, this should be tied to the location area code (LAC). */ struct gsm_tz tz; + + /* List of all struct bsc_subscr used in libbsc. This llist_head is + * allocated so that the llist_head pointer itself can serve as a + * talloc context. */ + struct llist_head *bsc_subscribers; }; struct osmo_esme; diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index af77b2f..50477d7 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -22,10 +22,14 @@ #define OSMO_BSC_GRACE_H #include +#include struct osmo_msc_data; int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts); -int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc); +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc); #endif diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index 689ff51..7dd8500 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -27,7 +27,7 @@ #include #include -#include +#include /** * A pending paging request @@ -36,8 +36,8 @@ /* list_head for list of all paging requests */ struct llist_head entry; /* the subscriber which we're paging. Later gsm_paging_request - * should probably become a part of the gsm_subscriber struct? */ - struct gsm_subscriber *subscr; + * should probably become a part of the bsc_subsrc struct? */ + struct bsc_subscr *bsub; /* back-pointer to the BTS on which we are paging */ struct gsm_bts *bts; /* what kind of channel type do we ask the MS to establish */ @@ -55,13 +55,14 @@ }; /* schedule paging request */ -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data); -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data); +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data); /* stop paging requests */ -void paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg); @@ -71,6 +72,6 @@ /* pending paging requests */ unsigned int paging_pending_requests_nr(struct gsm_bts *bts); -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr); +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub); #endif diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am index b8e77e6..fd8f37a 100644 --- a/openbsc/src/libbsc/Makefile.am +++ b/openbsc/src/libbsc/Makefile.am @@ -24,6 +24,7 @@ abis_om2000_vty.c \ abis_rsl.c \ bsc_rll.c \ + bsc_subscriber.c \ paging.c \ bts_ericsson_rbs2000.c \ bts_ipaccess_nanobts.c \ diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 1cae832..5939e75 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1332,10 +1332,10 @@ static void print_meas_rep(struct gsm_lchan *lchan, struct gsm_meas_rep *mr) { int i; - char *name = ""; + const char *name = ""; if (lchan && lchan->conn) - name = subscr_name(lchan->conn->subscr); + name = bsc_subscr_name(lchan->conn->bsub); DEBUGP(DMEAS, "[%s] MEASUREMENT RESULT NR=%d ", name, mr->nr); diff --git a/openbsc/src/libbsc/bsc_subscriber.c b/openbsc/src/libbsc/bsc_subscriber.c new file mode 100644 index 0000000..a5e40cd --- /dev/null +++ b/openbsc/src/libbsc/bsc_subscriber.c @@ -0,0 +1,168 @@ +/* GSM subscriber details for use in BSC land */ + +/* + * (C) 2016 by sysmocom s.f.m.c. GmbH + * + * Author: Neels Hofmeyr + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include + +#include +#include + +#include +#include + +static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list) +{ + struct bsc_subscr *bsub; + + bsub = talloc_zero(list, struct bsc_subscr); + if (!bsub) + return NULL; + + llist_add_tail(&bsub->entry, list); + bsub->use_count = 1; + + return bsub; +} + +struct bsc_subscr *bsc_subscr_find_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + + if (!imsi || !*imsi) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (!strcmp(bsub->imsi, imsi)) + return bsc_subscr_get(bsub); + } + return NULL; +} + +struct bsc_subscr *bsc_subscr_find_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + + if (tmsi == GSM_RESERVED_TMSI) + return NULL; + + llist_for_each_entry(bsub, list, entry) { + if (bsub->tmsi == tmsi) + return bsc_subscr_get(bsub); + } + return NULL; +} + +void bsc_subscr_set_imsi(struct bsc_subscr *bsub, const char *imsi) +{ + if (!bsub) + return; + strncpy(bsub->imsi, imsi, sizeof(bsub->imsi)); +} + +struct bsc_subscr *bsc_subscr_find_or_create_by_imsi(struct llist_head *list, + const char *imsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_imsi(list, imsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsc_subscr_set_imsi(bsub, imsi); + return bsub; +} + +struct bsc_subscr *bsc_subscr_find_or_create_by_tmsi(struct llist_head *list, + uint32_t tmsi) +{ + struct bsc_subscr *bsub; + bsub = bsc_subscr_find_by_tmsi(list, tmsi); + if (bsub) + return bsub; + bsub = bsc_subscr_alloc(list); + bsub->tmsi = tmsi; + return bsub; +} + +const char *bsc_subscr_name(struct bsc_subscr *bsub) +{ + static char buf[32]; + if (!bsub) + return "unknown"; + if (bsub->imsi[0]) + snprintf(buf, sizeof(buf), "IMSI:%s", bsub->imsi); + else + snprintf(buf, sizeof(buf), "TMSI:0x%08x", bsub->tmsi); + return buf; +} + +static void bsc_subscr_free(struct bsc_subscr *bsub) +{ + llist_del(&bsub->entry); + talloc_free(bsub); +} + +struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line) +{ + OSMO_ASSERT(bsub->use_count < INT_MAX); + bsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "BSC subscr %s usage increases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + return bsub; +} + +struct bsc_subscr *_bsc_subscr_put(struct bsc_subscr *bsub, + const char *file, int line) +{ + bsub->use_count--; + LOGPSRC(DREF, bsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "BSC subscr %s usage decreases to: %d\n", + bsc_subscr_name(bsub), bsub->use_count); + if (bsub->use_count <= 0) + bsc_subscr_free(bsub); + return NULL; +} + +void log_set_filter_bsc_subscr(struct log_target *target, + struct bsc_subscr *bsc_subscr) +{ + struct bsc_subscr **fsub = (void*)&target->filter_data[LOG_FLT_BSC_SUBSCR]; + + /* free the old data */ + if (*fsub) { + bsc_subscr_put(*fsub); + *fsub = NULL; + } + + if (bsc_subscr) { + target->filter_map |= (1 << LOG_FLT_BSC_SUBSCR); + *fsub = bsc_subscr_get(bsc_subscr); + } else + target->filter_map &= ~(1 << LOG_FLT_BSC_SUBSCR); +} diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 73acebd..21d0701 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1023,6 +1023,16 @@ vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); } +static void bsc_subscr_dump_vty(struct vty *vty, struct bsc_subscr *bsub) +{ + if (strlen(bsub->imsi)) + vty_out(vty, " IMSI: %s%s", bsub->imsi, VTY_NEWLINE); + if (bsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: 0x%08x%s", bsub->tmsi, + VTY_NEWLINE); + vty_out(vty, " Use count: %d%s", bsub->use_count, VTY_NEWLINE); +} + static void meas_rep_dump_uni_vty(struct vty *vty, struct gsm_meas_rep_unidir *mru, const char *prefix, @@ -1318,7 +1328,7 @@ static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag) { vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); - subscr_dump_vty(vty, pag->subscr); + bsc_subscr_dump_vty(vty, pag->bsub); } static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts) diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 98f0790..4a53b31 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -283,7 +283,7 @@ } int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct gsm_subscriber *subscr) + struct msgb *msg, struct bsc_subscr *bsub) { struct gsm_bts *bts = msg->lchan->ts->trx->bts; struct gsm48_hdr *gh = msgb_l3(msg); @@ -292,22 +292,24 @@ if (is_siemens_bts(bts)) send_siemens_mrpci(msg->lchan, classmark2_lv); - if (!conn->subscr) { - conn->subscr = subscr; - } else if (conn->subscr != subscr) { - LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); - subscr_put(subscr); + if (!conn->bsub) { + conn->bsub = bsub; + } else if (conn->bsub != bsub) { + LOGP(DRR, LOGL_ERROR, + "<- Channel already owned by someone else?\n"); + bsc_subscr_put(bsub); return -EINVAL; } else { DEBUGP(DRR, "<- Channel already owned by us\n"); - subscr_put(subscr); - subscr = conn->subscr; + bsc_subscr_put(bsub); + bsub = conn->bsub; } rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_COMPLETED]); /* Stop paging on the bts we received the paging response */ - paging_request_stop(conn->bts, subscr, conn, msg); + paging_request_stop(&bts->network->bts_list, conn->bts, bsub, conn, + msg); return 0; } diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index eb37a33..bd23d89 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -58,11 +59,11 @@ * Kill one paging request update the internal list... */ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts, - struct gsm_paging_request *to_be_deleted) + struct gsm_paging_request *to_be_deleted) { osmo_timer_del(&to_be_deleted->T3113); llist_del(&to_be_deleted->entry); - subscr_put(to_be_deleted->subscr); + bsc_subscr_put(to_be_deleted->bsub); talloc_free(to_be_deleted); } @@ -77,21 +78,21 @@ if (!bts->oml_link) return; - log_set_context(LOG_CTX_VLR_SUBSCR, request->subscr); + log_set_context(LOG_CTX_BSC_SUBSCR, request->bsub); LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: " - "0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi, - request->subscr->tmsi, request->chan_type, request->attempts); + "0x%08x for ch. type %d (attempt %d)\n", request->bsub->imsi, + request->bsub->tmsi, request->chan_type, request->attempts); - if (request->subscr->tmsi == GSM_RESERVED_TMSI) - mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi); + if (request->bsub->tmsi == GSM_RESERVED_TMSI) + mi_len = gsm48_generate_mid_from_imsi(mi, request->bsub->imsi); else - mi_len = gsm48_generate_mid_from_tmsi(mi, request->subscr->tmsi); + mi_len = gsm48_generate_mid_from_tmsi(mi, request->bsub->tmsi); page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, - str_to_imsi(request->subscr->imsi)); + str_to_imsi(request->bsub->imsi)); gsm0808_page(bts, page_group, mi_len, mi, request->chan_type); - log_set_context(LOG_CTX_VLR_SUBSCR, NULL); + log_set_context(LOG_CTX_BSC_SUBSCR, NULL); } static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) @@ -237,11 +238,12 @@ } static int paging_pending_request(struct gsm_bts_paging_state *bts, - struct gsm_subscriber *subscr) { + struct bsc_subscr *bsub) +{ struct gsm_paging_request *req; llist_for_each_entry(req, &bts->pending_requests, entry) { - if (subscr == req->subscr) + if (bsub == req->bsub) return 1; } @@ -255,10 +257,10 @@ gsm_cbfn *cbfn; int msg; - log_set_context(LOG_CTX_VLR_SUBSCR, req->subscr); + log_set_context(LOG_CTX_BSC_SUBSCR, req->bsub); LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n", - req, req->subscr->imsi); + req, bsc_subscr_name(req->bsub)); /* must be destroyed before calling cbfn, to prevent double free */ rate_ctr_inc(&req->bts->network->bsc_ctrs->ctr[BSC_CTR_PAGING_EXPIRED]); @@ -277,21 +279,22 @@ } -static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +static int _paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts_paging_state *bts_entry = &bts->paging; struct gsm_paging_request *req; - if (paging_pending_request(bts_entry, subscr)) { - LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", subscr->imsi); + if (paging_pending_request(bts_entry, bsub)) { + LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", + bsc_subscr_name(bsub)); return -EEXIST; } - LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %llu on bts %d.\n", - subscr->id, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %s on bts %d.\n", + bsc_subscr_name(bsub), bts->nr); req = talloc_zero(tall_paging_ctx, struct gsm_paging_request); - req->subscr = subscr_get(subscr); + req->bsub = bsc_subscr_get(bsub); req->bts = bts; req->chan_type = type; req->cbfn = cbfn; @@ -305,8 +308,8 @@ return 0; } -int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr, - int type, gsm_cbfn *cbfn, void *data) +int paging_request_bts(struct gsm_bts *bts, struct bsc_subscr *bsub, + int type, gsm_cbfn *cbfn, void *data) { int rc; @@ -317,15 +320,14 @@ /* maybe it is the first time we use it */ paging_init_if_needed(bts); - /* Trigger paging, pass any error to the caller */ - rc = _paging_request(bts, subscr, type, cbfn, data); + rc = _paging_request(bts, bsub, type, cbfn, data); if (rc < 0) return rc; return 1; } -int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, +int paging_request(struct gsm_network *network, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { struct gsm_bts *bts = NULL; @@ -337,13 +339,14 @@ do { int rc; - bts = gsm_bts_by_lac(network, subscr->lac, bts); + bts = gsm_bts_by_lac(network, bsub->lac, bts); if (!bts) break; - rc = paging_request_bts(bts, subscr, type, cbfn, data); + rc = paging_request_bts(bts, bsub, type, cbfn, data); if (rc < 0) { - paging_request_stop(NULL, subscr, NULL, NULL); + paging_request_stop(&network->bts_list, NULL, bsub, + NULL, NULL); return rc; } num_pages += rc; @@ -357,7 +360,7 @@ /* we consciously ignore the type of the request here */ -static void _paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr, +static void _paging_request_stop(struct gsm_bts *bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -367,8 +370,8 @@ paging_init_if_needed(bts); llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests, - entry) { - if (req->subscr == subscr) { + entry) { + if (req->bsub == bsub) { gsm_cbfn *cbfn = req->cbfn; void *param = req->cbfn_param; @@ -377,35 +380,36 @@ req = NULL; if (conn && cbfn) { - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d, calling cbfn.\n", bsub->imsi, bts->nr); cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED, - msg, conn, param); + msg, conn, param); } else - LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", subscr->imsi, bts->nr); + LOGP(DPAG, LOGL_DEBUG, "Stop paging %s on bts %d silently.\n", bsub->imsi, bts->nr); break; } } } /* Stop paging on all other bts' */ -void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr, +void paging_request_stop(struct llist_head *bts_list, + struct gsm_bts *_bts, struct bsc_subscr *bsub, struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm_bts *bts; - log_set_context(LOG_CTX_VLR_SUBSCR, subscr); + log_set_context(LOG_CTX_BSC_SUBSCR, bsub); /* Stop this first and dispatch the request */ if (_bts) - _paging_request_stop(_bts, subscr, conn, msg); + _paging_request_stop(_bts, bsub, conn, msg); /* Make sure to cancel this everywhere else */ - llist_for_each_entry(bts, &subscr->group->net->bts_list, list) { + llist_for_each_entry(bts, bts_list, list) { /* Sort of an optimization. */ if (bts == _bts) continue; - _paging_request_stop(bts, subscr, NULL, NULL); + _paging_request_stop(bts, bsub, NULL, NULL); } } @@ -434,12 +438,12 @@ /** * Find any paging data for the given subscriber at the given BTS. */ -void *paging_get_data(struct gsm_bts *bts, struct gsm_subscriber *subscr) +void *paging_get_data(struct gsm_bts *bts, struct bsc_subscr *bsub) { struct gsm_paging_request *req; llist_for_each_entry(req, &bts->paging.pending_requests, entry) - if (req->subscr == subscr) + if (req->bsub == bsub) return req->cbfn_param; return NULL; diff --git a/openbsc/src/libcommon-cs/common_cs.c b/openbsc/src/libcommon-cs/common_cs.c index 3149580..7905802 100644 --- a/openbsc/src/libcommon-cs/common_cs.c +++ b/openbsc/src/libcommon-cs/common_cs.c @@ -70,6 +70,9 @@ INIT_LLIST_HEAD(&net->upqueue); INIT_LLIST_HEAD(&net->subscr_conns); + net->bsc_subscribers = talloc_zero(net, struct llist_head); + INIT_LLIST_HEAD(net->bsc_subscribers); + /* init statistics */ net->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, 0); net->active_calls = osmo_counter_alloc("msc.active_calls"); diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c index 4d7bfed..0f82211 100644 --- a/openbsc/src/libcommon/debug.c +++ b/openbsc/src/libcommon/debug.c @@ -180,11 +180,16 @@ static int filter_fn(const struct log_context *ctx, struct log_target *tar) { const struct gsm_subscriber *subscr = ctx->ctx[LOG_CTX_VLR_SUBSCR]; + const struct bsc_subscr *bsub = ctx->ctx[LOG_CTX_BSC_SUBSCR]; const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; const struct gprs_nsvc *bvc = ctx->ctx[LOG_CTX_GB_BVC]; if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0 && subscr && subscr == tar->filter_data[LOG_FLT_VLR_SUBSCR]) + return 1; + + if ((tar->filter_map & (1 << LOG_FLT_BSC_SUBSCR)) != 0 + && bsub && bsub == tar->filter_data[LOG_FLT_BSC_SUBSCR]) return 1; /* Filter on the NS Virtual Connection */ @@ -206,7 +211,8 @@ .num_cat = ARRAY_SIZE(default_categories), }; -void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr) +void log_set_filter_vlr_subscr(struct log_target *target, + struct gsm_subscriber *vlr_subscr) { struct gsm_subscriber **fsub = (void*)&target->filter_data[LOG_FLT_VLR_SUBSCR]; @@ -216,9 +222,9 @@ *fsub = NULL; } - if (subscr) { + if (vlr_subscr) { target->filter_map |= (1 << LOG_FLT_VLR_SUBSCR); - *fsub = subscr_get(subscr); + *fsub = subscr_get(vlr_subscr); } else target->filter_map &= ~(1 << LOG_FLT_VLR_SUBSCR); } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index be43956..8908a7f 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1433,6 +1433,8 @@ uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm_subscriber *subscr = NULL; + struct bsc_subscr *bsub; + uint32_t tmsi; int rc = 0; resp = (struct gsm48_pag_resp *) &gh->data[0]; @@ -1443,8 +1445,8 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_get_by_tmsi(conn->network->subscr_group, - tmsi_from_string(mi_string)); + tmsi = tmsi_from_string(mi_string); + subscr = subscr_get_by_tmsi(conn->network->subscr_group, tmsi); break; case GSM_MI_TYPE_IMSI: subscr = subscr_get_by_imsi(conn->network->subscr_group, @@ -1457,6 +1459,19 @@ /* FIXME: request id? close channel? */ return -EINVAL; } + + if (!conn->subscr) { + conn->subscr = subscr; + } else if (conn->subscr != subscr) { + LOGP(DRR, LOGL_ERROR, "<- Channel already owned by someone else?\n"); + subscr_put(subscr); + return -EINVAL; + } else { + DEBUGP(DRR, "<- Channel already owned by us\n"); + subscr_put(subscr); + subscr = conn->subscr; + } + log_set_context(LOG_CTX_VLR_SUBSCR, subscr); DEBUGP(DRR, "<- Channel was requested by %s\n", subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi); @@ -1465,10 +1480,18 @@ memcpy(subscr->equipment.classmark2, classmark2_lv+1, *classmark2_lv); db_sync_equipment(&subscr->equipment); + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_find_or_create_by_imsi(conn->network->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + /* We received a paging */ conn->expire_timer_stopped = 1; - rc = gsm48_handle_paging_resp(conn, msg, subscr); + rc = gsm48_handle_paging_resp(conn, msg, bsub); return rc; } diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 568f1c5..1a03cf7 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -82,8 +82,11 @@ struct gsm_subscriber_connection *conn = data; struct gsm_subscriber *subscr = param; struct paging_signal_data sig_data; + struct bsc_subscr *bsub; + struct gsm_network *net; - OSMO_ASSERT(subscr->is_paging); + OSMO_ASSERT(subscr && subscr->is_paging); + net = subscr->group->net; /* * Stop paging on all other BTS. E.g. if this is @@ -91,7 +94,16 @@ * timeout soon as well. Let's just stop everything * and forget we wanted to page. */ - paging_request_stop(NULL, subscr, NULL, NULL); + + /* TODO MSC split -- creating a BSC subscriber directly from MSC data + * structures in RAM. At some point the MSC will send a message to the + * BSC instead. */ + bsub = bsc_subscr_find_or_create_by_imsi(net->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + paging_request_stop(&net->bts_list, NULL, bsub, NULL, NULL); + bsc_subscr_put(bsub); /* Inform parts of the system we don't know */ sig_data.subscr = subscr; @@ -169,13 +181,23 @@ { int rc; struct subscr_request *request; + struct bsc_subscr *bsub; + struct gsm_network *net = subscr->group->net; /* Start paging.. we know it is async so we can do it before */ if (!subscr->is_paging) { LOGP(DMM, LOGL_DEBUG, "Subscriber %s not paged yet.\n", subscr_name(subscr)); - rc = paging_request(subscr->group->net, subscr, channel_type, - subscr_paging_cb, subscr); + /* TODO MSC split -- creating a BSC subscriber directly from + * MSC data structures in RAM. At some point the MSC will send + * a message to the BSC instead. */ + bsub = bsc_subscr_find_or_create_by_imsi(net->bsc_subscribers, + subscr->imsi); + bsub->tmsi = subscr->tmsi; + bsub->lac = subscr->lac; + rc = paging_request(net, bsub, channel_type, subscr_paging_cb, + subscr); + bsc_subscr_put(bsub); if (rc <= 0) { LOGP(DMM, LOGL_ERROR, "Subscriber %s paging failed: %d\n", subscr_name(subscr), rc); diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index ddec2e3..c6a8929 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1033,21 +1034,26 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct gsm_subscriber *vlr_subscr; + struct bsc_subscr *bsc_subscr; struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; if (!tgt) return CMD_WARNING; - subscr = subscr_get_by_imsi(gsmnet->subscr_group, argv[0]); - if (!subscr) { + vlr_subscr = subscr_get_by_imsi(gsmnet->subscr_group, imsi); + bsc_subscr = bsc_subscr_find_by_imsi(gsmnet->bsc_subscribers, imsi); + + if (!vlr_subscr && !bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_vlr_subscr(tgt, vlr_subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index f38c97f..a7386c0 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -20,9 +20,10 @@ #include #include +#include #include #include -#include +#include #include #include @@ -99,7 +100,7 @@ static int bssmap_handle_paging(struct osmo_msc_data *msc, struct msgb *msg, unsigned int payload_length) { - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; struct tlv_parsed tp; char mi_string[GSM48_MI_SIZE]; uint32_t tmsi = GSM_RESERVED_TMSI; @@ -157,7 +158,8 @@ LOGP(DMSC, LOGL_ERROR, "eMLPP is not handled\n"); } - subscr = subscr_get_or_create(msc->network->subscr_group, mi_string); + subscr = bsc_subscr_find_or_create_by_imsi(msc->network->bsc_subscribers, + mi_string); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string); return -1; @@ -167,7 +169,8 @@ subscr->tmsi = tmsi; LOGP(DMSC, LOGL_INFO, "Paging request from MSC IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n", mi_string, tmsi, tmsi, lac); - bsc_grace_paging_request(subscr, chan_needed, msc); + bsc_grace_paging_request(msc->network->bsc_data->rf_ctrl->policy, + subscr, chan_needed, msc); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index d5ca2fd..8301bfb 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -54,14 +55,14 @@ } /* extract a subscriber from the paging response */ -static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn, - struct msgb *msg) +static struct bsc_subscr *extract_sub(struct gsm_subscriber_connection *conn, + struct msgb *msg) { uint8_t mi_type; char mi_string[GSM48_MI_SIZE]; struct gsm48_hdr *gh; struct gsm48_pag_resp *resp; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*resp)) { LOGP(DMSC, LOGL_ERROR, "PagingResponse too small: %u\n", msgb_l3len(msg)); @@ -78,12 +79,12 @@ switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = bsc_subscr_find_by_tmsi(conn->network->bsc_subscribers, + tmsi_from_string(mi_string)); break; case GSM_MI_TYPE_IMSI: - subscr = subscr_active_by_imsi(conn->bts->network->subscr_group, - mi_string); + subscr = bsc_subscr_find_by_imsi(conn->network->bsc_subscribers, + mi_string); break; default: subscr = NULL; @@ -96,15 +97,16 @@ /* we will need to stop the paging request */ static int handle_page_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct gsm_subscriber *subscr = extract_sub(conn, msg); + struct bsc_subscr *subscr = extract_sub(conn, msg); if (!subscr) { LOGP(DMSC, LOGL_ERROR, "Non active subscriber got paged.\n"); return -1; } - paging_request_stop(conn->bts, subscr, conn, msg); - subscr_put(subscr); + paging_request_stop(&conn->network->bts_list, conn->bts, subscr, conn, + msg); + bsc_subscr_put(subscr); return 0; } @@ -130,7 +132,7 @@ uint8_t mtype; struct osmo_bsc_data *bsc; struct osmo_msc_data *msc, *pag_msc; - struct gsm_subscriber *subscr; + struct bsc_subscr *subscr; int is_emerg = 0; bsc = conn->bts->network->bsc_data; @@ -183,7 +185,7 @@ } pag_msc = paging_get_data(conn->bts, subscr); - subscr_put(subscr); + bsc_subscr_put(subscr); llist_for_each_entry(msc, &bsc->mscs, entry) { if (msc != pag_msc) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 6409a3a..eef88b4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -34,8 +34,8 @@ } -static int normal_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int normal_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { /* we can't page by lac.. we need to page everything */ if (msc->core_lac != -1) { @@ -47,12 +47,11 @@ return 0; } - return paging_request(subscr->group->net, subscr, chan_needed, NULL, - msc); + return paging_request(msc->network, subscr, chan_needed, NULL, msc); } -static int locked_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +static int locked_paging(struct bsc_subscr *subscr, int chan_needed, + struct osmo_msc_data *msc) { struct gsm_bts *bts = NULL; @@ -84,10 +83,12 @@ /** * Try to not page if everything the cell is not on. */ -int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) +int bsc_grace_paging_request(enum signal_rf rf_policy, + struct bsc_subscr *subscr, + int chan_needed, + struct osmo_msc_data *msc) { - if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON) + if (rf_policy == S_RF_ON) return normal_paging(subscr, chan_needed, msc); return locked_paging(subscr, chan_needed, msc); } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 86ccec4..9171968 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -861,20 +861,19 @@ LOGGING_STR FILTER_STR "Filter log messages by IMSI\n" "IMSI to be used as filter\n") { - struct gsm_subscriber *subscr; + struct bsc_subscr *bsc_subscr; struct log_target *tgt = osmo_log_vty2tgt(vty); + const char *imsi = argv[0]; - if (!tgt) - return CMD_WARNING; + bsc_subscr = bsc_subscr_find_by_imsi(bsc_gsmnet->bsc_subscribers, imsi); - subscr = subscr_get_or_create(bsc_gsmnet->subscr_group, argv[0]); - if (!subscr) { + if (!bsc_subscr) { vty_out(vty, "%%no subscriber with IMSI(%s)%s", - argv[0], VTY_NEWLINE); + imsi, VTY_NEWLINE); return CMD_WARNING; } - log_set_imsi_filter(tgt, subscr); + log_set_filter_bsc_subscr(tgt, bsc_subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am index 5e9583f..ca470ac 100644 --- a/openbsc/tests/channel/Makefile.am +++ b/openbsc/tests/channel/Makefile.am @@ -24,8 +24,8 @@ $(NULL) channel_test_LDADD = \ - $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) \ diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index c69c701..88293d0 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -49,7 +49,7 @@ } /* mock object for testing, directly invoke the cb... maybe later through the timer */ -int paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data) +int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data) { s_data = data; s_cbfn = cbfn; @@ -72,6 +72,7 @@ exit(1); bts = gsm_bts_alloc(network); bts->location_area_code = 23; + s_conn.network = network; /* Create a dummy subscriber */ struct gsm_subscriber *subscr = subscr_alloc(); diff --git a/openbsc/tests/subscr/Makefile.am b/openbsc/tests/subscr/Makefile.am index ad8b20c..6342444 100644 --- a/openbsc/tests/subscr/Makefile.am +++ b/openbsc/tests/subscr/Makefile.am @@ -19,10 +19,13 @@ EXTRA_DIST = \ subscr_test.ok \ + bsc_subscr_test.ok \ + bsc_subscr_test.err \ $(NULL) noinst_PROGRAMS = \ subscr_test \ + bsc_subscr_test \ $(NULL) subscr_test_SOURCES = \ @@ -40,3 +43,19 @@ $(LIBSMPP34_LIBS) \ $(LIBOSMOVTY_LIBS) \ $(NULL) + +bsc_subscr_test_SOURCES = \ + bsc_subscr_test.c \ + $(NULL) + +bsc_subscr_test_LDADD = \ + $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libcommon-cs/libcommon-cs.a \ + $(top_builddir)/src/libtrau/libtrau.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOABIS_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(LIBSMPP34_LIBS) \ + $(LIBOSMOVTY_LIBS) \ + $(NULL) diff --git a/openbsc/tests/subscr/bsc_subscr_test.c b/openbsc/tests/subscr/bsc_subscr_test.c new file mode 100644 index 0000000..60d687d --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.c @@ -0,0 +1,130 @@ +/* (C) 2008 by Jan Luebbe + * (C) 2009 by Holger Hans Peter Freyther + * (C) 2014 by Alexander Chemeris + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include + +#include +#include +#include +#include + +struct llist_head *bsc_subscribers; + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); + +static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi) +{ + struct bsc_subscr *sfound; + OSMO_ASSERT(bsub); + OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0); + + sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi); + OSMO_ASSERT(sfound == bsub); + + bsc_subscr_put(sfound); +} + +static void test_bsc_subscr(void) +{ + struct bsc_subscr *s1, *s2, *s3; + const char *imsi1 = "1234567890"; + const char *imsi2 = "9876543210"; + const char *imsi3 = "5656565656"; + + printf("Test BSC subscriber allocation and deletion\n"); + + /* Check for emptiness */ + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + /* Allocate entry 1 */ + s1 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + assert_bsc_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + + /* Allocate entry 2 */ + s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + + /* Allocate entry 3 */ + s3 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi3); + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d"); + + /* Check entries */ + assert_bsc_subscr(s1, imsi1); + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 1 */ + bsc_subscr_put(s1); + s1 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + + assert_bsc_subscr(s2, imsi2); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 2 */ + bsc_subscr_put(s2); + s2 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL); + assert_bsc_subscr(s3, imsi3); + + /* Free entry 3 */ + bsc_subscr_put(s3); + s3 = NULL; + VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d"); + OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL); + + OSMO_ASSERT(llist_empty(bsc_subscribers)); +} + +int main() +{ + printf("Testing BSC subscriber core code.\n"); + osmo_init_logging(&log_info); + log_set_print_filename(osmo_stderr_target, 0); + log_set_print_timestamp(osmo_stderr_target, 0); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + log_set_category_filter(osmo_stderr_target, DREF, 1, LOGL_DEBUG); + + bsc_subscribers = talloc_zero(NULL, struct llist_head); + INIT_LLIST_HEAD(bsc_subscribers); + + test_bsc_subscr(); + + printf("Done\n"); + return 0; +} diff --git a/openbsc/tests/subscr/bsc_subscr_test.err b/openbsc/tests/subscr/bsc_subscr_test.err new file mode 100644 index 0000000..a66317a --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.err @@ -0,0 +1,17 @@ +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage increases to: 2 +DREF BSC subscr IMSI:1234567890 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:1234567890 usage decreases to: 0 +DREF BSC subscr IMSI:9876543210 usage increases to: 2 +DREF BSC subscr IMSI:9876543210 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:9876543210 usage decreases to: 0 +DREF BSC subscr IMSI:5656565656 usage increases to: 2 +DREF BSC subscr IMSI:5656565656 usage decreases to: 1 +DREF BSC subscr IMSI:5656565656 usage decreases to: 0 diff --git a/openbsc/tests/subscr/bsc_subscr_test.ok b/openbsc/tests/subscr/bsc_subscr_test.ok new file mode 100644 index 0000000..0f6a8be --- /dev/null +++ b/openbsc/tests/subscr/bsc_subscr_test.ok @@ -0,0 +1,11 @@ +Testing BSC subscriber core code. +Test BSC subscriber allocation and deletion +llist_count(bsc_subscribers) == 0 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 3 +llist_count(bsc_subscribers) == 2 +llist_count(bsc_subscribers) == 1 +llist_count(bsc_subscribers) == 0 +Done diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 01737a3..280aeb2 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -13,6 +13,13 @@ AT_CHECK([$abs_top_builddir/tests/subscr/subscr_test], [], [expout], [ignore]) AT_CLEANUP +AT_SETUP([bsc_subscr]) +AT_KEYWORDS([bsc_subscr]) +cat $abs_srcdir/subscr/bsc_subscr_test.ok > expout +cat $abs_srcdir/subscr/bsc_subscr_test.err > experr +AT_CHECK([$abs_top_builddir/tests/subscr/bsc_subscr_test], [], [expout], [experr]) +AT_CLEANUP + AT_SETUP([db]) AT_KEYWORDS([db]) cat $abs_srcdir/db/db_test.ok > expout -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 15:00:56 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 15:00:56 +0000 Subject: [PATCH] osmo-hlr[master]: Add global HLR struct In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1856 to look at the new patch set (#3). Add global HLR struct Introduce g_hlr of type 'struct hlr' which holds pointers to all globally accessible variables. Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Related: OS#1645 --- M src/db_test.c M src/hlr.c M src/hlr.h 3 files changed, 36 insertions(+), 24 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/56/1856/3 diff --git a/src/db_test.c b/src/db_test.c index 75fcb62..998a37a 100644 --- a/src/db_test.c +++ b/src/db_test.c @@ -4,12 +4,13 @@ #include #include "db.h" +#include "hlr.h" #include "rand.h" #include "logging.h" -static struct db_context *g_dbc; +static struct hlr *g_hlr; -static int test(const char *imsi) +static int test(const char *imsi, struct db_context *dbc) { struct osmo_auth_vector vec[3]; int rc, i; @@ -19,7 +20,7 @@ for (i = 0; i < ARRAY_SIZE(vec); i++) vec[i].res_len = 0; - rc = db_get_auc(g_dbc, imsi, vec, ARRAY_SIZE(vec), NULL, NULL); + rc = db_get_auc(dbc, imsi, vec, ARRAY_SIZE(vec), NULL, NULL); if (rc <= 0) { LOGP(DMAIN, LOGL_ERROR, "Cannot obtain auth tuples for '%s'\n", imsi); return rc; @@ -46,6 +47,8 @@ { int rc; + g_hlr = talloc_zero(NULL, struct hlr); + rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { fprintf(stderr, "Error initializing logging\n"); @@ -59,24 +62,24 @@ exit(1); } - g_dbc = db_open(NULL, "hlr.db"); - if (!g_dbc) { + g_hlr->dbc = db_open(NULL, "hlr.db"); + if (!g_hlr->dbc) { LOGP(DMAIN, LOGL_ERROR, "Error opening database\n"); exit(1); } /* non-existing subscriber */ - rc = test("901990123456789"); + rc = test("901990123456789", g_hlr->dbc); /* 2G only AUC data (COMP128v1 / MILENAGE) */ - rc = test("901990000000001"); + rc = test("901990000000001", g_hlr->dbc); /* 2G + 3G AUC data (COMP128v1 / MILENAGE) */ - rc = test("901990000000002"); + rc = test("901990000000002", g_hlr->dbc); /* 3G AUC data (MILENAGE) */ - rc = test("901990000000003"); + rc = test("901990000000003", g_hlr->dbc); LOGP(DMAIN, LOGL_NOTICE, "Exiting\n"); - db_close(g_dbc); + db_close(g_hlr->dbc); log_fini(); diff --git a/src/hlr.c b/src/hlr.c index 5c59b88..2bc3125 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -42,7 +42,7 @@ #include "luop.h" #include "hlr_vty.h" -static struct db_context *g_dbc; +static struct hlr *g_hlr; /*********************************************************************** * Send Auth Info handling @@ -50,7 +50,8 @@ /* process an incoming SAI request */ static int rx_send_auth_info(struct osmo_gsup_conn *conn, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup, + struct db_context *dbc) { struct osmo_gsup_message gsup_out; struct msgb *msg_out; @@ -60,7 +61,7 @@ memset(&gsup_out, 0, sizeof(gsup_out)); memcpy(&gsup_out.imsi, &gsup->imsi, sizeof(gsup_out.imsi)); - rc = db_get_auc(g_dbc, gsup->imsi, gsup_out.auth_vectors, + rc = db_get_auc(dbc, gsup->imsi, gsup_out.auth_vectors, ARRAY_SIZE(gsup_out.auth_vectors), gsup->rand, gsup->auts); if (rc < 0) { @@ -158,7 +159,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { + if (!lu_op_fill_subscr(luop, g_hlr->dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -217,7 +218,7 @@ * we have on record. Only update if yes */ /* Perform the actual update of the DB */ - rc = db_subscr_purge(g_dbc, gsup->imsi, is_ps); + rc = db_subscr_purge(g_hlr->dbc, gsup->imsi, is_ps); if (rc == 1) gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT; @@ -248,7 +249,7 @@ switch (gsup.message_type) { /* requests sent to us */ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST: - rx_send_auth_info(conn, &gsup); + rx_send_auth_info(conn, &gsup, g_hlr->dbc); break; case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST: rx_upd_loc_req(conn, &gsup); @@ -363,15 +364,14 @@ } static void *hlr_ctx = NULL; -static struct osmo_gsup_server *gs; static void signal_hdlr(int signal) { switch (signal) { case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); - osmo_gsup_server_destroy(gs); - db_close(g_dbc); + osmo_gsup_server_destroy(g_hlr->gs); + db_close(g_hlr->dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -397,6 +397,7 @@ hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); msgb_talloc_ctx_init(hlr_ctx, 0); + g_hlr = talloc_zero(hlr_ctx, struct hlr); c_opts = talloc_zero(hlr_ctx, struct cmdline_opts); c_opts->config_file = "osmo-hlr.cfg"; @@ -434,14 +435,14 @@ exit(1); } - g_dbc = db_open(hlr_ctx, c_opts->db_file); - if (!g_dbc) { + g_hlr->dbc = db_open(hlr_ctx, c_opts->db_file); + if (!g_hlr->dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); - if (!gs) { + g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + if (!g_hlr->gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); } @@ -462,7 +463,7 @@ osmo_select_main(0); } - db_close(g_dbc); + db_close(g_hlr->dbc); log_fini(); diff --git a/src/hlr.h b/src/hlr.h index 4e296ff..5d52d3b 100644 --- a/src/hlr.h +++ b/src/hlr.h @@ -29,3 +29,11 @@ const char *db_file; bool daemonize; }; + +struct hlr { + /* GSUP server pointer */ + struct osmo_gsup_server *gs; + + /* DB context */ + struct db_context *dbc; +}; -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 15:00:56 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 15:00:56 +0000 Subject: [PATCH] osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1827 to look at the new patch set (#11). Add CTRL interface Add command to query Packet Services (GPRS etc.) for particular IMSI. Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Related: OS#1645 --- M configure.ac M src/Makefile.am A src/ctrl.c A src/ctrl.h M src/hlr.c M src/hlr.h 6 files changed, 134 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/27/1827/11 diff --git a/configure.ac b/configure.ac index bfda9c5..a04185f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.9.0) +PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2) PKG_CHECK_MODULES(SQLITE3, sqlite3) diff --git a/src/Makefile.am b/src/Makefile.am index 6e7fcdc..9ba3217 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,7 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOVTY_CFLAGS) \ + $(LIBOSMOCTRL_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(NULL) @@ -20,6 +21,7 @@ gsup_server.h \ logging.h \ rand.h \ + ctrl.h \ hlr_vty.h \ $(NULL) @@ -33,6 +35,7 @@ osmo_hlr_SOURCES = \ auc.c \ + ctrl.c \ db.c \ luop.c \ db_auc.c \ @@ -49,6 +52,7 @@ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOABIS_LIBS) \ $(SQLITE3_LIBS) \ $(NULL) diff --git a/src/ctrl.c b/src/ctrl.c new file mode 100644 index 0000000..a167171 --- /dev/null +++ b/src/ctrl.c @@ -0,0 +1,81 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include + +#include +#include +#include + +#include "gsup_server.h" +#include "logging.h" +#include "db.h" +#include "hlr.h" +#include "luop.h" +#include "ctrl.h" + +CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps"); +static int set_status_ps(struct ctrl_cmd *cmd, void *data) +{ + struct hlr *ctx = data; + struct lu_operation *luop = lu_op_alloc(ctx->gs); + if (!luop) { + cmd->reply = "Internal HLR error"; + return CTRL_CMD_ERROR; + } + + if (!lu_op_fill_subscr(luop, ctx->dbc, cmd->value)) { + cmd->reply = "Subscriber Unknown in HLR"; + return CTRL_CMD_ERROR; + } + + cmd->reply = luop->subscr.nam_ps ? "1" : "0"; + + return CTRL_CMD_REPLY; +} + +int hlr_ctrl_cmds_install() +{ + int rc = 0; + + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_status_ps); + + return rc; +} + +struct ctrl_handle *hlr_controlif_setup(struct hlr *ctx, + struct osmo_gsup_server *gs) +{ + int rc; + struct ctrl_handle *hdl = ctrl_interface_setup_dynip(ctx, + ctx->ctrl_bind_addr, + OSMO_CTRL_PORT_HLR, + NULL); + if (!hdl) + return NULL; + + rc = hlr_ctrl_cmds_install(); + if (rc) /* FIXME: close control interface? */ + return NULL; + + return hdl; +} diff --git a/src/ctrl.h b/src/ctrl.h new file mode 100644 index 0000000..663de30 --- /dev/null +++ b/src/ctrl.h @@ -0,0 +1,31 @@ +/* OsmoHLR Control Interface implementation */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +#include "gsup_server.h" + +int hlr_ctrl_cmds_install(); +struct ctrl_handle *hlr_controlif_setup(struct hlr *ctx, + struct osmo_gsup_server *gs); diff --git a/src/hlr.c b/src/hlr.c index 2bc3125..216f2a5 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -35,6 +35,7 @@ #include "hlr.h" #include "db.h" +#include "ctrl.h" #include "logging.h" #include "gsup_server.h" #include "gsup_router.h" @@ -299,6 +300,8 @@ printf(" -s --disable-color Do not print ANSI colors in the log\n"); printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); + printf(" -R --ctrl address Set address to which Control " + "Interface should be bound, defaults to 127.0.0.1.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } @@ -314,12 +317,13 @@ {"daemonize", 0, 0, 'D'}, {"disable-color", 0, 0, 's'}, {"log-level", 1, 0, 'e'}, + {"ctrl", 1, 0, 'R'}, {"timestamp", 0, 0, 'T'}, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:l:d:Dse:TV", + c = getopt_long(argc, argv, "hc:l:d:Dse:R:TV", long_options, &option_index); if (c == -1) break; @@ -334,6 +338,9 @@ break; case 'l': cfg->db_file = optarg; + break; + case 'R': + g_hlr->ctrl_bind_addr = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); @@ -447,6 +454,12 @@ exit(1); } + if (g_hlr->ctrl_bind_addr) + g_hlr->ctrl = hlr_controlif_setup(g_hlr, g_hlr->gs); + else + LOGP(DLGSUP, LOGL_NOTICE, "Control Interface is NOT created: " + "bind address missing\n"); + osmo_init_ignore_signals(); signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); diff --git a/src/hlr.h b/src/hlr.h index 5d52d3b..71472bb 100644 --- a/src/hlr.h +++ b/src/hlr.h @@ -36,4 +36,7 @@ /* DB context */ struct db_context *dbc; + + /* Control Interface handle */ + struct ctrl_handle *ctrl; }; -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 11 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 15:00:57 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 15:00:57 +0000 Subject: [PATCH] osmo-hlr[master]: Get rid of global config options struct Message-ID: Review at https://gerrit.osmocom.org/1899 Get rid of global config options struct Make it obvious that the command-line options are only used within main() by removing global static struct and explicitly passing passing it to handle_options() instead. Change-Id: I83f0a352327e6ea659b789c37deacf2f86eb3dde --- M src/Makefile.am M src/hlr.c A src/hlr.h 3 files changed, 48 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/99/1899/1 diff --git a/src/Makefile.am b/src/Makefile.am index 56a5670..6e7fcdc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ noinst_HEADERS = \ auc.h \ + hlr.h \ db.h \ luop.h \ gsup_router.h \ diff --git a/src/hlr.c b/src/hlr.c index d74d9fb..5c59b88 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -33,6 +33,7 @@ #include #include +#include "hlr.h" #include "db.h" #include "logging.h" #include "gsup_server.h" @@ -300,17 +301,7 @@ printf(" -V --version Print the version of OsmoHLR.\n"); } -static struct { - const char *config_file; - const char *db_file; - bool daemonize; -} cmdline_opts = { - .config_file = "osmo-hlr.cfg", - .db_file = "hlr.db", - .daemonize = false, -}; - -static void handle_options(int argc, char **argv) +static void handle_options(struct cmdline_opts *cfg, int argc, char **argv) { while (1) { int option_index = 0, c; @@ -338,16 +329,16 @@ print_help(); exit(0); case 'c': - cmdline_opts.config_file = optarg; + cfg->config_file = optarg; break; case 'l': - cmdline_opts.db_file = optarg; + cfg->db_file = optarg; break; case 'd': log_parse_category_mask(osmo_stderr_target, optarg); break; case 'D': - cmdline_opts.daemonize = 1; + cfg->daemonize = true; break; case 's': log_set_use_color(osmo_stderr_target, 0); @@ -401,9 +392,15 @@ int main(int argc, char **argv) { int rc; + struct cmdline_opts *c_opts; hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); msgb_talloc_ctx_init(hlr_ctx, 0); + + c_opts = talloc_zero(hlr_ctx, struct cmdline_opts); + + c_opts->config_file = "osmo-hlr.cfg"; + c_opts->db_file = "hlr.db"; rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { @@ -412,14 +409,14 @@ } vty_init(&vty_info); - handle_options(argc, argv); + handle_options(c_opts, argc, argv); hlr_vty_init(&hlr_log_info); - rc = vty_read_config_file(cmdline_opts.config_file, NULL); + rc = vty_read_config_file(c_opts->config_file, NULL); if (rc < 0) { LOGP(DMAIN, LOGL_FATAL, "Failed to parse the config file: '%s'\n", - cmdline_opts.config_file); + c_opts->config_file); return rc; } @@ -437,7 +434,7 @@ exit(1); } - g_dbc = db_open(hlr_ctx, cmdline_opts.db_file); + g_dbc = db_open(hlr_ctx, c_opts->db_file); if (!g_dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); @@ -453,7 +450,7 @@ signal(SIGINT, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); - if (cmdline_opts.daemonize) { + if (c_opts->daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); diff --git a/src/hlr.h b/src/hlr.h new file mode 100644 index 0000000..4e296ff --- /dev/null +++ b/src/hlr.h @@ -0,0 +1,31 @@ +/* OsmoHLR generic header */ + +/* (C) 2017 sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Max Suraev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include + +struct cmdline_opts { + const char *config_file; + const char *db_file; + bool daemonize; +}; -- To view, visit https://gerrit.osmocom.org/1899 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I83f0a352327e6ea659b789c37deacf2f86eb3dde Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max From gerrit-no-reply at lists.osmocom.org Fri Feb 24 15:04:20 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Fri, 24 Feb 2017 15:04:20 +0000 Subject: osmo-hlr[master]: Add global HLR struct In-Reply-To: References: Message-ID: Patch Set 3: > Also we don't need those in the global context after the program has started. Than better make it obvious by not using global variable. See 1899. -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 15:36:16 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 15:36:16 +0000 Subject: [PATCH] osmo-gsm-manuals[master]: ports: rename CSCN to MSC Message-ID: Review at https://gerrit.osmocom.org/1900 ports: rename CSCN to MSC See OS#1958 and https://gerrit.osmocom.org/1884 Change-Id: Iac081f5b92f66df68932350492687933c47e4f95 --- M common/chapters/port_numbers.adoc 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/00/1900/1 diff --git a/common/chapters/port_numbers.adoc b/common/chapters/port_numbers.adoc index f48c8d0..4475b0f 100644 --- a/common/chapters/port_numbers.adoc +++ b/common/chapters/port_numbers.adoc @@ -27,8 +27,8 @@ |TCP|4251|Control Interface|osmo-sgsn |TCP|4252|telnet (VTY)|sysmobts-mgr |TCP|4253|telnet (VTY)|osmo-gtphub -|TCP|4254|telnet (VTY)|osmo-cscn -|TCP|4255|Control Interface|osmo-cscn +|TCP|4254|telnet (VTY)|osmo-msc +|TCP|4255|Control Interface|osmo-msc |TCP|4256|telnet (VTY)|osmo-sip-connector |TCP|4257|Control Interface|ggsn (OpenGGSN) |TCP|4258|telnet (VTY)|osmo-hlr -- To view, visit https://gerrit.osmocom.org/1900 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iac081f5b92f66df68932350492687933c47e4f95 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 16:31:43 2017 From: gerrit-no-reply at lists.osmocom.org (Jovan Bunjevacki) Date: Fri, 24 Feb 2017 16:31:43 +0000 Subject: [PATCH] openggsn[master]: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNE... Message-ID: Review at https://gerrit.osmocom.org/1901 Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNEMU to properly delete PDP context and gracefully exit in case of interrupt. Change-Id: Iacfb92cbe796c55119ebbe6c481432442f928f37 --- M sgsnemu/sgsnemu.c 1 file changed, 32 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/01/1901/1 diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index a4d6461..68e8521 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -70,7 +70,7 @@ /* 3: Done */ /* 4: Wait_disconnect */ /* 5: Disconnected */ -int state = 0; +volatile sig_atomic_t state = 0; struct gsn_t *gsn = NULL; /* GSN instance */ struct tun_t *tun = NULL; /* TUN instance */ @@ -153,6 +153,11 @@ int tsum = 0; int pingseq = 0; /* Ping sequence counter */ struct timeval firstping; + +void signal_handler(int signo) +{ + if(state == 2) state = 3; /* Tell main loop to finish. */ +} int ipset(struct iphash_t *ipaddr, struct in_addr *addr) { @@ -1417,10 +1422,15 @@ int starttime = time(NULL); /* Time program was started */ int stoptime = 0; /* Time to exit */ int pingtimeout = 0; /* Time to print ping statistics */ + int signal_received; /* If select() on fd_set is interrupted by signal. */ struct timezone tz; /* Used for calculating ping times */ struct timeval tv; int diff; + + signal(SIGTERM, signal_handler); + signal(SIGHUP, signal_handler); + signal(SIGINT, signal_handler); osmo_init_logging(&log_info); @@ -1676,10 +1686,13 @@ printf("idletime.tv_sec %d, idleTime.tv_usec %d\n", (int)idleTime.tv_sec, (int)idleTime.tv_usec); + signal_received=0; switch (select(maxfd + 1, &fds, NULL, NULL, &idleTime)) { case -1: - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "Select returned -1"); + if(errno == EINTR) signal_received=1; + else + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "Select returned -1"); break; case 0: gtp_retrans(gsn); /* Only retransmit if nothing else */ @@ -1688,19 +1701,23 @@ break; } - if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "TUN decaps failed"); + if(!signal_received) { + + if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "TUN decaps failed"); + } + + if (FD_ISSET(gsn->fd0, &fds)) + gtp_decaps0(gsn); + + if (FD_ISSET(gsn->fd1c, &fds)) + gtp_decaps1c(gsn); + + if (FD_ISSET(gsn->fd1u, &fds)) + gtp_decaps1u(gsn); + } - - if (FD_ISSET(gsn->fd0, &fds)) - gtp_decaps0(gsn); - - if (FD_ISSET(gsn->fd1c, &fds)) - gtp_decaps1c(gsn); - - if (FD_ISSET(gsn->fd1u, &fds)) - gtp_decaps1u(gsn); } gtp_free(gsn); /* Clean up the gsn instance */ -- To view, visit https://gerrit.osmocom.org/1901 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iacfb92cbe796c55119ebbe6c481432442f928f37 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki From gerrit-no-reply at lists.osmocom.org Fri Feb 24 16:36:36 2017 From: gerrit-no-reply at lists.osmocom.org (Jovan Bunjevacki) Date: Fri, 24 Feb 2017 16:36:36 +0000 Subject: [ABANDON] openggsn[master]: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNE... In-Reply-To: References: Message-ID: Jovan Bunjevacki has abandoned this change. Change subject: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNEMU to properly delete PDP context and gracefully exit in case of interrupt. ...................................................................... Abandoned Will try to push to osmo-ggsn -- To view, visit https://gerrit.osmocom.org/1901 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Iacfb92cbe796c55119ebbe6c481432442f928f37 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 24 16:41:02 2017 From: gerrit-no-reply at lists.osmocom.org (Jovan Bunjevacki) Date: Fri, 24 Feb 2017 16:41:02 +0000 Subject: [PATCH] openggsn[master]: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNE... Message-ID: Review at https://gerrit.osmocom.org/1902 Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNEMU to properly delete PDP context and gracefully exit in case of interrupt. Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 --- M sgsnemu/sgsnemu.c 1 file changed, 32 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/02/1902/1 diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index a4d6461..68e8521 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -70,7 +70,7 @@ /* 3: Done */ /* 4: Wait_disconnect */ /* 5: Disconnected */ -int state = 0; +volatile sig_atomic_t state = 0; struct gsn_t *gsn = NULL; /* GSN instance */ struct tun_t *tun = NULL; /* TUN instance */ @@ -153,6 +153,11 @@ int tsum = 0; int pingseq = 0; /* Ping sequence counter */ struct timeval firstping; + +void signal_handler(int signo) +{ + if(state == 2) state = 3; /* Tell main loop to finish. */ +} int ipset(struct iphash_t *ipaddr, struct in_addr *addr) { @@ -1417,10 +1422,15 @@ int starttime = time(NULL); /* Time program was started */ int stoptime = 0; /* Time to exit */ int pingtimeout = 0; /* Time to print ping statistics */ + int signal_received; /* If select() on fd_set is interrupted by signal. */ struct timezone tz; /* Used for calculating ping times */ struct timeval tv; int diff; + + signal(SIGTERM, signal_handler); + signal(SIGHUP, signal_handler); + signal(SIGINT, signal_handler); osmo_init_logging(&log_info); @@ -1676,10 +1686,13 @@ printf("idletime.tv_sec %d, idleTime.tv_usec %d\n", (int)idleTime.tv_sec, (int)idleTime.tv_usec); + signal_received=0; switch (select(maxfd + 1, &fds, NULL, NULL, &idleTime)) { case -1: - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "Select returned -1"); + if(errno == EINTR) signal_received=1; + else + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "Select returned -1"); break; case 0: gtp_retrans(gsn); /* Only retransmit if nothing else */ @@ -1688,19 +1701,23 @@ break; } - if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "TUN decaps failed"); + if(!signal_received) { + + if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "TUN decaps failed"); + } + + if (FD_ISSET(gsn->fd0, &fds)) + gtp_decaps0(gsn); + + if (FD_ISSET(gsn->fd1c, &fds)) + gtp_decaps1c(gsn); + + if (FD_ISSET(gsn->fd1u, &fds)) + gtp_decaps1u(gsn); + } - - if (FD_ISSET(gsn->fd0, &fds)) - gtp_decaps0(gsn); - - if (FD_ISSET(gsn->fd1c, &fds)) - gtp_decaps1c(gsn); - - if (FD_ISSET(gsn->fd1u, &fds)) - gtp_decaps1u(gsn); } gtp_free(gsn); /* Clean up the gsn instance */ -- To view, visit https://gerrit.osmocom.org/1902 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki From gerrit-no-reply at lists.osmocom.org Fri Feb 24 16:43:53 2017 From: gerrit-no-reply at lists.osmocom.org (Jovan Bunjevacki) Date: Fri, 24 Feb 2017 16:43:53 +0000 Subject: openggsn[master]: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNE... In-Reply-To: References: Message-ID: Patch Set 1: > Abandoned > > Will try to push to osmo-ggsn Actually I've made a mistake and will re-create same commit. -- To view, visit https://gerrit.osmocom.org/1901 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iacfb92cbe796c55119ebbe6c481432442f928f37 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Jovan Bunjevacki Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 16:53:40 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 16:53:40 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmotestconfig: fix socket leak Message-ID: Review at https://gerrit.osmocom.org/1903 osmotestconfig: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: If97944a079e901439139161eae39181f5c800200 --- M osmopy/osmotestconfig.py 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/03/1903/1 diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 8e5f253..0d2b2d9 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -48,6 +48,7 @@ def test_config_atest(app_desc, config, run_test, verbose=True): proc = None ret = None + vty = None try: cmd = app_desc[1].split(' ') + [ "-c", config] if verbose: @@ -69,6 +70,8 @@ finally: if proc: osmoutil.end_proc(proc) + if vty: + vty._close_socket() return ret -- To view, visit https://gerrit.osmocom.org/1903 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If97944a079e901439139161eae39181f5c800200 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 16:53:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 16:53:41 +0000 Subject: [PATCH] python/osmo-python-tests[master]: VTYInteract: monitor sockets opening and closing Message-ID: Review at https://gerrit.osmocom.org/1904 VTYInteract: monitor sockets opening and closing Not necessarily for merge, used to find a socket leak that caused 'Broken Pipe' errors on our build slave. Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 --- M osmopy/obscvty.py 1 file changed, 11 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/04/1904/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 3c9edb1..6d615ab 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -32,6 +32,9 @@ name is the name the vty prints for commands, ie OpenBSC host is the hostname to connect to port is the port to connect on""" + + all_sockets = [] + def __init__(self, name, host, port): self.name = name self.host = host @@ -44,6 +47,10 @@ def _close_socket(self): if self.socket: + VTYInteract.all_sockets.remove(self.socket) + print "Socket: closing %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.close() self.socket = None @@ -107,6 +114,10 @@ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setblocking(1) self.socket.connect((self.host, self.port)) + VTYInteract.all_sockets.append(self.socket) + print "Socket: connected to %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.recv(4096) # Now send the command -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 17:00:30 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 17:00:30 +0000 Subject: [PATCH] openbsc[master]: vty_test_runner.py: fix socket leak Message-ID: Review at https://gerrit.osmocom.org/1905 vty_test_runner.py: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30 --- M openbsc/tests/vty_test_runner.py 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/05/1905/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index f434360..8b17397 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -57,6 +57,8 @@ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport) def tearDown(self): + if self.vty: + self.vty._close_socket() self.vty = None osmoutil.end_proc(self.proc) -- To view, visit https://gerrit.osmocom.org/1905 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 17:00:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 17:00:45 +0000 Subject: [PATCH] openbsc[master]: python tests: allow running from separate build dir Message-ID: Review at https://gerrit.osmocom.org/1906 python tests: allow running from separate build dir The VTY tests assume that $top_builddir == $top_srcdir. Use the script's location from sys.path[0] to find the correct locations of example configs even when building in another directory. Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2 --- M openbsc/tests/ctrl_test_runner.py M openbsc/tests/vty_test_runner.py 2 files changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/06/1906/1 diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 9050c09..0e3ddb6 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -30,7 +30,8 @@ import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil -confpath = '.' +# to be able to find $top_srcdir/doc/... +confpath = os.path.join(sys.path[0], '..') verbose = False class TestCtrlBase(unittest.TestCase): diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 8b17397..084fab0 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -24,10 +24,13 @@ import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil -sys.path.append("../contrib") +# add $top_srcdir/contrib to find ipa.py +sys.path.append(os.path.join(sys.path[0], '..', 'contrib')) + from ipa import IPA -confpath = '.' +# to be able to find $top_srcdir/doc/... +confpath = os.path.join(sys.path[0], '..') class TestVTYBase(unittest.TestCase): -- To view, visit https://gerrit.osmocom.org/1906 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 17:02:45 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 17:02:45 +0000 Subject: python/osmo-python-tests[master]: osmotestconfig: fix socket leak In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1903 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If97944a079e901439139161eae39181f5c800200 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 17:04:19 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 17:04:19 +0000 Subject: [PATCH] openbsc[master]: python tests: allow running from separate build dir In-Reply-To: References: Message-ID: python tests: allow running from separate build dir The VTY tests assume that $top_builddir == $top_srcdir. Use the script's location from sys.path[0] to find the correct locations of example configs even when building in another directory. Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2 --- M openbsc/tests/ctrl_test_runner.py M openbsc/tests/smpp_test_runner.py M openbsc/tests/vty_test_runner.py 3 files changed, 9 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/06/1906/2 diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 9050c09..0e3ddb6 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -30,7 +30,8 @@ import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil -confpath = '.' +# to be able to find $top_srcdir/doc/... +confpath = os.path.join(sys.path[0], '..') verbose = False class TestCtrlBase(unittest.TestCase): diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py index 9dc0d13..baacf58 100644 --- a/openbsc/tests/smpp_test_runner.py +++ b/openbsc/tests/smpp_test_runner.py @@ -18,6 +18,7 @@ # along with this program. If not, see . import os +import sys import time import unittest import socket @@ -25,7 +26,7 @@ import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil -confpath = '.' +confpath = os.path.join(sys.path[0], '..') class TestVTYBase(unittest.TestCase): diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 8b17397..084fab0 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -24,10 +24,13 @@ import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil -sys.path.append("../contrib") +# add $top_srcdir/contrib to find ipa.py +sys.path.append(os.path.join(sys.path[0], '..', 'contrib')) + from ipa import IPA -confpath = '.' +# to be able to find $top_srcdir/doc/... +confpath = os.path.join(sys.path[0], '..') class TestVTYBase(unittest.TestCase): -- To view, visit https://gerrit.osmocom.org/1906 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:32:52 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:32:52 +0000 Subject: openbsc[master]: python tests: allow running from separate build dir In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1906 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:33:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:33:28 +0000 Subject: openbsc[master]: vty_test_runner.py: fix socket leak In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1905 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:33:31 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:33:31 +0000 Subject: [MERGED] openbsc[master]: vty_test_runner.py: fix socket leak In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: vty_test_runner.py: fix socket leak ...................................................................... vty_test_runner.py: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30 --- M openbsc/tests/vty_test_runner.py 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index f434360..8b17397 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -57,6 +57,8 @@ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport) def tearDown(self): + if self.vty: + self.vty._close_socket() self.vty = None osmoutil.end_proc(self.proc) -- To view, visit https://gerrit.osmocom.org/1905 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:34:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:34:44 +0000 Subject: python/osmo-python-tests[master]: VTYInteract: monitor sockets opening and closing In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:37:54 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:37:54 +0000 Subject: openggsn[master]: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNE... In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-1 (4 comments) thanks for your patch. Aside from the cosmetic issues outlined below (trivial to fix): What do we actually gain from this? I think adding signal handlers only make sense if we actually do something at those signals, such as sending a DELETE PDP CONTEXT to the GGSN. Maybe I don't understand your patch? https://gerrit.osmocom.org/#/c/1902/1/sgsnemu/sgsnemu.c File sgsnemu/sgsnemu.c: Line 1689: signal_received=0; we typically use 'foo = 0' and not 'foo=0' Line 1692: if(errno == EINTR) signal_received=1; coding style: 'if' is not a function, hence a space. The signal_received=1 belongs in a seprate line Line 1693: else space at EOL Line 1704: if(!signal_received) { if is not a function -- To view, visit https://gerrit.osmocom.org/1902 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:45:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:45:28 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/1682/8/openbsc/include/openbsc/gsm_data.h File openbsc/include/openbsc/gsm_data.h: Line 391: /* List of all struct bsc_subscr used in libbsc. This llist_head is this is highly unusual in the osmocom code base. the llist_head of the master object is always part of a larger data structure. Why can the users/callers not simply use the 'struct gsm_network' as talloc context? How much of the code would have to change? -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:46:07 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:46:07 +0000 Subject: osmo-gsm-manuals[master]: ports: rename CSCN to MSC In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1900 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iac081f5b92f66df68932350492687933c47e4f95 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:48:37 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:48:37 +0000 Subject: libosmocore[master]: Use value_string for ctrl_type In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1895 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:49:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:49:15 +0000 Subject: openbsc[master]: SGSN VTY: make missing GSUP server address+port fatal In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1894 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:51:13 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:51:13 +0000 Subject: openbsc[master]: SGSN: Integrate support for UMTS AKA In-Reply-To: References: Message-ID: Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 6 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:52:41 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:52:41 +0000 Subject: libosmocore[master]: ports.h: rename CSCN to MSC In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1884 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:53:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:53:40 +0000 Subject: openbsc[master]: cosmetic: add copyright header to bsc_control.py In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1893 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie70bf686ee9bb157198e02bf8d946abf56adc82a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:54:02 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:54:02 +0000 Subject: openbsc[master]: vty: fix subscr ref count leak in 'subscriber name' cmd In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1881 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:54:25 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:54:25 +0000 Subject: openbsc[master]: cosmetic: rename struct osmo_msc_data to bsc_msc_data In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1892 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:54:42 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:54:42 +0000 Subject: openbsc[master]: cosmetic: clarify BSC's remote MSC data vs. OsmoMSC In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1890 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:54:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:54:57 +0000 Subject: openbsc[master]: cosmetic: rename osmo_msc_data.h to bsc_msc_data.h In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1891 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:55:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:55:17 +0000 Subject: openbsc[master]: cosmetic: gsm_data.h, README: rename CSCN to MSC In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1889 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 18:57:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 18:57:16 +0000 Subject: openbsc[master]: Add simple CTRL2SOAP proxy In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 as this is developed for a sysmocom customer, let's make sure to only submit this code once the customer has approved of it. I'm not even sure if the code should be present here. But I guess it won't hurt. -- To view, visit https://gerrit.osmocom.org/1875 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:00:38 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:00:38 +0000 Subject: osmo-hlr[master]: Get rid of global config options struct In-Reply-To: References: Message-ID: Patch Set 1: why define the struct in a separate header file, if it's only used from hlr.c? Also, moving the struct from hlr.c to hlr.h doesn't make sysmocom a copyrihgt holder, please keep the original copyright notice in such cases. -- To view, visit https://gerrit.osmocom.org/1899 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83f0a352327e6ea659b789c37deacf2f86eb3dde Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:02:07 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:02:07 +0000 Subject: osmo-hlr[master]: Make subscr parameter to db_subscr_get() optional In-Reply-To: References: Message-ID: Patch Set 6: (1 comment) https://gerrit.osmocom.org/#/c/1853/6/src/db_hlr.c File src/db_hlr.c: Line 57: if (subscr) { the usual strategy in osmocom code (like kernel code) is to leave early. So it should be "if (!subscr) goto out" (as we already have that label) or an explicit call to db_remove_reset() and return. -- To view, visit https://gerrit.osmocom.org/1853 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I83b0f4a5dacb97614721690ef55bc1311624a58e Gerrit-PatchSet: 6 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:04:03 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:04:03 +0000 Subject: osmo-hlr[master]: Add CTRL interface In-Reply-To: References: Message-ID: Patch Set 11: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1827 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id787ef4aa88473c3bbde6ee25117b1fd99dc8fcb Gerrit-PatchSet: 11 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:13:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:13:01 +0000 Subject: osmo-hlr[master]: Add global HLR struct In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 3 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:13:48 2017 From: gerrit-no-reply at lists.osmocom.org (Jovan Bunjevacki) Date: Fri, 24 Feb 2017 19:13:48 +0000 Subject: openggsn[master]: Signal handler for SIGTERM, SIGHUP and SIGINT added to SGSNE... In-Reply-To: References: Message-ID: Patch Set 1: Hello Harald. Thanks for the comment. In function "create_pdp_conf" when everything is set up there's this line: state = 2; /* Connected */ Signal handler changes the value of variable "state" to 3 if it is equal to 2. This has the same effect as if run time of sgsnemu set in options has elapsed. Sorry for "cosmetic" errors, I'm not so familiar with code style you're using. I will correct this. void signal_handler(int signo) { if(state == 2) state = 3; /* Tell main loop to finish. */ } /* Send off disconnect */ if (3 == state) { state = 4; stoptime = time(NULL) + 5; /* Extra seconds to allow disconnect */ for (n = 0; n < options.contexts; n++) { /* Delete context */ printf("Disconnecting PDP context #%d\n", n); gtp_delete_context_req(gsn, iparr[n].pdp, NULL, 1); if ((options.pinghost.s_addr != 0) && ntransmitted) ping_finish(); } } -- To view, visit https://gerrit.osmocom.org/1902 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 Gerrit-PatchSet: 1 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Jovan Bunjevacki Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:14:35 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:14:35 +0000 Subject: libosmocore[master]: Handle replies in ctrl_cmd_handle() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1896 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:17:43 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:17:43 +0000 Subject: openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 9: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 9 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:18:05 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Fri, 24 Feb 2017 19:18:05 +0000 Subject: python/osmo-python-tests[master]: osmotestconfig: fix socket leak In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1903 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If97944a079e901439139161eae39181f5c800200 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:41:51 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:41:51 +0000 Subject: [PATCH] python/osmo-python-tests[master]: debug: monitor used TCP sockets and running osmo processes In-Reply-To: References: Message-ID: Hello Harald Welte, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1904 to look at the new patch set (#2). debug: monitor used TCP sockets and running osmo processes Add global flag debug_tcp_sockets; if true, monitors all open TCP sockets of the system and running processes by regular 'ss' and 'ps' output, and logs which VTY sockets are opened and closed. Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 --- M osmopy/obscvty.py 1 file changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/04/1904/2 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 3c9edb1..4c0803a 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -18,6 +18,7 @@ # import re import socket +import sys, subprocess """VTYInteract: interact with an osmocom vty @@ -25,6 +26,23 @@ Connections will be reestablished as necessary. Methods: __init__, command, enabled_command, verify, w_verify""" +debug_tcp_sockets = True + +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def print_used_tcp_sockets(): + if not debug_tcp_sockets: + return + cmd('ss -tn'); + cmd('ss -tln'); + cmd('ps xua | grep osmo'); class VTYInteract(object): """__init__(self, name, host, port): @@ -32,7 +50,12 @@ name is the name the vty prints for commands, ie OpenBSC host is the hostname to connect to port is the port to connect on""" + + all_sockets = [] + def __init__(self, name, host, port): + print_used_tcp_sockets() + self.name = name self.host = host self.port = port @@ -44,6 +67,11 @@ def _close_socket(self): if self.socket: + if debug_tcp_sockets: + VTYInteract.all_sockets.remove(self.socket) + print "Socket: closing %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.close() self.socket = None @@ -107,6 +135,11 @@ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setblocking(1) self.socket.connect((self.host, self.port)) + if debug_tcp_sockets: + VTYInteract.all_sockets.append(self.socket) + print "Socket: connected to %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.recv(4096) # Now send the command -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 2 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:41:52 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:41:52 +0000 Subject: [PATCH] python/osmo-python-tests[master]: log process launches Message-ID: Review at https://gerrit.osmocom.org/1907 log process launches Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 --- M osmopy/osmoutil.py 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/07/1907/1 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 78465d9..bb03614 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,8 +23,10 @@ """Run a command, with stdout and stderr directed to devnull""" -def popen_devnull(cmd): +def popen_devnull(cmd, verbose=True): devnull = open(os.devnull, 'w') + if verbose: + print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1907 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:41:52 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:41:52 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: try to terminate process instead of killing Message-ID: Review at https://gerrit.osmocom.org/1908 osmoutil: try to terminate process instead of killing Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 --- M osmopy/osmoutil.py 1 file changed, 12 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/08/1908/1 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index bb03614..7b20043 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -18,6 +18,7 @@ import os import sys import importlib +import time """Run a command, with stdout and stderr directed to devnull""" @@ -36,9 +37,18 @@ def end_proc(proc): - if proc: + if not proc: + return + + proc.terminate() + time.sleep(.1) + rc = proc.poll() + if rc is not None: + print "Terminated child process" + else: proc.kill() - proc.wait() + print "Killed child process" + proc.wait() """Add a directory to sys.path, try to import a config file.""" -- To view, visit https://gerrit.osmocom.org/1908 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:41:52 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:41:52 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: open /dev/null only once Message-ID: Review at https://gerrit.osmocom.org/1909 osmoutil: open /dev/null only once Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b --- M osmopy/osmoutil.py 1 file changed, 6 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/09/1909/1 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 7b20043..01f74cc 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,9 +23,14 @@ """Run a command, with stdout and stderr directed to devnull""" +devnull = None def popen_devnull(cmd, verbose=True): - devnull = open(os.devnull, 'w') + global devnull + if devnull is None: + if verbose: + print "Opening /dev/null" + devnull = open(os.devnull, 'w') if verbose: print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1909 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:45:34 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:45:34 +0000 Subject: [PATCH] openbsc[master]: vty_rest_runner.py: remove debug monitoring for TCP sockets Message-ID: Review at https://gerrit.osmocom.org/1912 vty_rest_runner.py: remove debug monitoring for TCP sockets Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8 --- M openbsc/tests/vty_test_runner.py 1 file changed, 0 insertions(+), 22 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/12/1912/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 8b17397..ca4b276 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1240,19 +1240,6 @@ " connected yet: %r %r" % (ip, port)) return conn -def cmd(what): - print '\n> %s' % what - sys.stdout.flush() - subprocess.call(what, shell=True) - sys.stdout.flush() - sys.stderr.flush() - print '' - sys.stdout.flush() - -def checkxxx(): - cmd('cat /proc/net/tcp'); - cmd('ps xua | grep osmo'); - def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1277,10 +1264,6 @@ if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: - if proc: - print "\tproc.poll() = %r" % proc.poll() - print "\tproc.pid = %r" % proc.pid - checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1313,19 +1296,14 @@ if proc: print "\tproc.poll() = %r" % proc.poll() print "\tproc.pid = %r" % proc.pid - checkxxx() ipa_handle_small(bsc, verbose) - checkxxx() ipa_handle_resp(bsc, tk, verbose, proc=proc) if proc: print "\tproc.poll() = %r" % proc.poll() - checkxxx() bsc.recv(27) # MGCP msg if proc: print "\tproc.poll() = %r" % proc.poll() - checkxxx() ipa_handle_small(bsc, verbose) - checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:45:34 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:45:34 +0000 Subject: [PATCH] openbsc[master]: python tests: remove process 'Launch' message, now at osmoutil Message-ID: Review at https://gerrit.osmocom.org/1913 python tests: remove process 'Launch' message, now at osmoutil Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee --- M openbsc/tests/ctrl_test_runner.py M openbsc/tests/smpp_test_runner.py M openbsc/tests/vty_test_runner.py 3 files changed, 0 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/13/1913/1 diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 9050c09..a115488 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -49,7 +49,6 @@ osmo_ctrl_cmd[cfi] = os.path.join(confpath, osmo_ctrl_cmd[cfi]) try: - print "Launch: %s from %s" % (' '.join(osmo_ctrl_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_ctrl_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py index 9dc0d13..b6da86c 100644 --- a/openbsc/tests/smpp_test_runner.py +++ b/openbsc/tests/smpp_test_runner.py @@ -43,7 +43,6 @@ osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi]) try: - print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_vty_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index ca4b276..821c6d3 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -45,7 +45,6 @@ osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi]) try: - print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_vty_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() -- To view, visit https://gerrit.osmocom.org/1913 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:45:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:45:35 +0000 Subject: [PATCH] openbsc[master]: smpp_test_runner.py: fix socket leak Message-ID: Review at https://gerrit.osmocom.org/1914 smpp_test_runner.py: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af --- M openbsc/tests/smpp_test_runner.py 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/14/1914/1 diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py index 339314e..71b9d6c 100644 --- a/openbsc/tests/smpp_test_runner.py +++ b/openbsc/tests/smpp_test_runner.py @@ -55,6 +55,8 @@ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport) def tearDown(self): + if self.vty: + self.vty._close_socket() self.vty = None osmoutil.end_proc(self.proc) -- To view, visit https://gerrit.osmocom.org/1914 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:47:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:47:46 +0000 Subject: [PATCH] python/osmo-python-tests[master]: debug: monitor used TCP sockets and running osmo processes In-Reply-To: References: Message-ID: Hello Harald Welte, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1904 to look at the new patch set (#3). debug: monitor used TCP sockets and running osmo processes Add global flag debug_tcp_sockets; if true, monitors all open TCP sockets of the system and running processes by regular 'ss' and 'ps' output, and logs which VTY sockets are opened and closed. Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 --- M osmopy/obscvty.py 1 file changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/04/1904/3 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 3c9edb1..e4df57d 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -18,6 +18,7 @@ # import re import socket +import sys, subprocess """VTYInteract: interact with an osmocom vty @@ -25,6 +26,23 @@ Connections will be reestablished as necessary. Methods: __init__, command, enabled_command, verify, w_verify""" +debug_tcp_sockets = False + +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def print_used_tcp_sockets(): + if not debug_tcp_sockets: + return + cmd('ss -tn'); + cmd('ss -tln'); + cmd('ps xua | grep osmo'); class VTYInteract(object): """__init__(self, name, host, port): @@ -32,7 +50,12 @@ name is the name the vty prints for commands, ie OpenBSC host is the hostname to connect to port is the port to connect on""" + + all_sockets = [] + def __init__(self, name, host, port): + print_used_tcp_sockets() + self.name = name self.host = host self.port = port @@ -44,6 +67,11 @@ def _close_socket(self): if self.socket: + if debug_tcp_sockets: + VTYInteract.all_sockets.remove(self.socket) + print "Socket: closing %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.close() self.socket = None @@ -107,6 +135,11 @@ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setblocking(1) self.socket.connect((self.host, self.port)) + if debug_tcp_sockets: + VTYInteract.all_sockets.append(self.socket) + print "Socket: connected to %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.recv(4096) # Now send the command -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:47:46 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:47:46 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: centrally log process launches In-Reply-To: References: Message-ID: osmoutil: centrally log process launches Log Popen in osmoutil.py instead of in each python test. Launch message is being removed in openbsc's python tests and added here. (change-id Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee) Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 --- M osmopy/osmoutil.py 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/07/1907/2 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 78465d9..bb03614 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,8 +23,10 @@ """Run a command, with stdout and stderr directed to devnull""" -def popen_devnull(cmd): +def popen_devnull(cmd, verbose=True): devnull = open(os.devnull, 'w') + if verbose: + print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1907 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 Gerrit-PatchSet: 2 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:48:09 2017 From: gerrit-no-reply at lists.osmocom.org (Alexander Chemeris) Date: Fri, 24 Feb 2017 19:48:09 +0000 Subject: [PATCH] openbsc[master]: utils: 'meas_json' utility to convert measurement feed into ... Message-ID: Review at https://gerrit.osmocom.org/1915 utils: 'meas_json' utility to convert measurement feed into a JSON feed. Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 --- M openbsc/src/utils/Makefile.am A openbsc/src/utils/meas_json.c 2 files changed, 205 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/15/1915/1 diff --git a/openbsc/src/utils/Makefile.am b/openbsc/src/utils/Makefile.am index 6fe840c..ab4f3ce 100644 --- a/openbsc/src/utils/Makefile.am +++ b/openbsc/src/utils/Makefile.am @@ -25,6 +25,7 @@ bin_PROGRAMS = \ bs11_config \ isdnsync \ + meas_json \ $(NULL) if HAVE_SQLITE3 bin_PROGRAMS += \ @@ -121,3 +122,19 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(NULL) + +meas_json_SOURCES = \ + meas_json.c \ + $(NULL) + +meas_json_LDADD = \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) + +meas_json_CFLAGS = \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(NULL) + diff --git a/openbsc/src/utils/meas_json.c b/openbsc/src/utils/meas_json.c new file mode 100644 index 0000000..88d713b --- /dev/null +++ b/openbsc/src/utils/meas_json.c @@ -0,0 +1,188 @@ +/* Convert measurement report feed into JSON feed printed to stdout. + * Each measurement report is printed as a separae JSON root entry. + * All measurement reports are separated by a new line. + */ + +/* (C) 2015 by Alexander Chemeris + * With parts of code adopted from different places in OpenBSC. + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +static void print_meas_rep_uni_json(struct gsm_meas_rep_unidir *mru) +{ + printf("\"RXL-FULL\":%d, \"RXL-SUB\":%d, ", + rxlev2dbm(mru->full.rx_lev), + rxlev2dbm(mru->sub.rx_lev)); + printf("\"RXQ-FULL\":%d, \"RXQ-SUB\":%d", + mru->full.rx_qual, mru->sub.rx_qual); +} + +static void print_meas_rep_json(struct gsm_meas_rep *mr) +{ + int i; + + printf("\"NR\":%d", mr->nr); + + if (mr->flags & MEAS_REP_F_DL_DTX) + printf(", \"DTXd\":true"); + + printf(", \"UL_MEAS\":{"); + print_meas_rep_uni_json(&mr->ul); + printf("}"); + printf(", \"BS_POWER\":%d", mr->bs_power); + if (mr->flags & MEAS_REP_F_MS_TO) + printf(", \"MS_TO\":%d", mr->ms_timing_offset); + + if (mr->flags & MEAS_REP_F_MS_L1) { + printf(", \"L1_MS_PWR\":%d", mr->ms_l1.pwr); + printf(", \"L1_FPC\":%s", + mr->flags & MEAS_REP_F_FPC ? "true" : "false"); + printf(", \"L1_TA\":%u", mr->ms_l1.ta); + } + + if (mr->flags & MEAS_REP_F_UL_DTX) + printf(", \"DTXu\":true"); + if (mr->flags & MEAS_REP_F_BA1) + printf(", \"BA1\":true"); + if (mr->flags & MEAS_REP_F_DL_VALID) { + printf(", \"DL_MEAS\":{"); + print_meas_rep_uni_json(&mr->dl); + printf("}"); + } + + if (mr->num_cell == 7) + return; + printf(", \"NUM_NEIGH\":%u, \"NEIGH\":[", mr->num_cell); + for (i = 0; i < mr->num_cell; i++) { + struct gsm_meas_rep_cell *mrc = &mr->cell[i]; + if (i!=0) printf(", "); + printf("\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d", + mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev)); + } + printf("]"); +} + +static void print_chan_info_json(struct meas_feed_meas *mfm) +{ + printf("\"lchan_type\":\"%s\", \"pchan_type\":\"%s\", " + "\"bts_nr\":%d, \"trx_nr\":%d, \"ts_nr\":%d, \"ss_nr\":%d", + gsm_lchant_name(mfm->lchan_type), gsm_pchan_name(mfm->pchan_type), + mfm->bts_nr, mfm->trx_nr, mfm->ts_nr, mfm->ss_nr); +} + +static void print_meas_feed_json(struct meas_feed_meas *mfm) +{ + time_t now = time(NULL); + + printf("{"); + printf("\"time\":%ld, \"imsi\":\"%s\", \"name\":\"%s\", \"scenario\":\"%s\", ", + now, mfm->imsi, mfm->name, mfm->scenario); + + switch (mfm->hdr.version) { + case 1: + printf("\"chan_info\":{"); + print_chan_info_json(mfm); + printf("}, "); + /* no break, fall to version 0 */ + case 0: + printf("\"meas_rep\":{"); + print_meas_rep_json(&mfm->mr); + printf("}"); + break; + } + + printf("}\n"); + +} + +static int handle_meas(struct msgb *msg) +{ + struct meas_feed_meas *mfm = (struct meas_feed_meas *) msgb_data(msg); + + print_meas_feed_json(mfm); + + return 0; +} + +static int handle_msg(struct msgb *msg) +{ + struct meas_feed_hdr *mfh = (struct meas_feed_hdr *) msgb_data(msg); + + if (mfh->version != MEAS_FEED_VERSION) + return -EINVAL; + + switch (mfh->msg_type) { + case MEAS_FEED_MEAS: + handle_meas(msg); + break; + default: + break; + } +} + +static int udp_fd_cb(struct osmo_fd *ofd, unsigned int what) +{ + int rc; + + if (what & BSC_FD_READ) { + struct msgb *msg = msgb_alloc(1024, "UDP Rx"); + + rc = read(ofd->fd, msgb_data(msg), msgb_tailroom(msg)); + if (rc < 0) + return rc; + msgb_put(msg, rc); + handle_msg(msg); + msgb_free(msg); + } + + return 0; +} + +int main(int argc, char **argv) +{ + int rc; + struct osmo_fd udp_ofd; + + udp_ofd.cb = udp_fd_cb; + rc = osmo_sock_init_ofd(&udp_ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 8888, OSMO_SOCK_F_BIND); + if (rc < 0) + exit(1); + + while (1) { + osmo_select_main(0); + }; + + exit(0); +} -- To view, visit https://gerrit.osmocom.org/1915 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Alexander Chemeris From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:50:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:50:07 +0000 Subject: [PATCH] python/osmo-python-tests[master]: debug: monitor used TCP sockets and running osmo processes In-Reply-To: References: Message-ID: Hello Harald Welte, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1904 to look at the new patch set (#4). debug: monitor used TCP sockets and running osmo processes Add global flag debug_tcp_sockets; if true, monitors all open TCP sockets of the system and running processes by regular 'ss' and 'ps' output, and logs which VTY sockets are opened and closed. Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 --- M osmopy/obscvty.py 1 file changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/04/1904/4 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 3c9edb1..e4df57d 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -18,6 +18,7 @@ # import re import socket +import sys, subprocess """VTYInteract: interact with an osmocom vty @@ -25,6 +26,23 @@ Connections will be reestablished as necessary. Methods: __init__, command, enabled_command, verify, w_verify""" +debug_tcp_sockets = False + +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def print_used_tcp_sockets(): + if not debug_tcp_sockets: + return + cmd('ss -tn'); + cmd('ss -tln'); + cmd('ps xua | grep osmo'); class VTYInteract(object): """__init__(self, name, host, port): @@ -32,7 +50,12 @@ name is the name the vty prints for commands, ie OpenBSC host is the hostname to connect to port is the port to connect on""" + + all_sockets = [] + def __init__(self, name, host, port): + print_used_tcp_sockets() + self.name = name self.host = host self.port = port @@ -44,6 +67,11 @@ def _close_socket(self): if self.socket: + if debug_tcp_sockets: + VTYInteract.all_sockets.remove(self.socket) + print "Socket: closing %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.close() self.socket = None @@ -107,6 +135,11 @@ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setblocking(1) self.socket.connect((self.host, self.port)) + if debug_tcp_sockets: + VTYInteract.all_sockets.append(self.socket) + print "Socket: connected to %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.recv(4096) # Now send the command -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 4 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:50:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:50:07 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: centrally log process launches In-Reply-To: References: Message-ID: osmoutil: centrally log process launches Log Popen in osmoutil.py instead of in each python test. Launch message is being removed in openbsc's python tests and added here. (change-id Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee) Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 --- M osmopy/osmoutil.py 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/07/1907/3 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 78465d9..bb03614 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,8 +23,10 @@ """Run a command, with stdout and stderr directed to devnull""" -def popen_devnull(cmd): +def popen_devnull(cmd, verbose=True): devnull = open(os.devnull, 'w') + if verbose: + print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1907 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:50:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:50:07 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: try to terminate process instead of killing In-Reply-To: References: Message-ID: osmoutil: try to terminate process instead of killing Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 --- M osmopy/osmoutil.py 1 file changed, 12 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/08/1908/3 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index bb03614..7b20043 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -18,6 +18,7 @@ import os import sys import importlib +import time """Run a command, with stdout and stderr directed to devnull""" @@ -36,9 +37,18 @@ def end_proc(proc): - if proc: + if not proc: + return + + proc.terminate() + time.sleep(.1) + rc = proc.poll() + if rc is not None: + print "Terminated child process" + else: proc.kill() - proc.wait() + print "Killed child process" + proc.wait() """Add a directory to sys.path, try to import a config file.""" -- To view, visit https://gerrit.osmocom.org/1908 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:50:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:50:07 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: open /dev/null only once In-Reply-To: References: Message-ID: osmoutil: open /dev/null only once Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b --- M osmopy/osmoutil.py 1 file changed, 6 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/09/1909/3 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 7b20043..01f74cc 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,9 +23,14 @@ """Run a command, with stdout and stderr directed to devnull""" +devnull = None def popen_devnull(cmd, verbose=True): - devnull = open(os.devnull, 'w') + global devnull + if devnull is None: + if verbose: + print "Opening /dev/null" + devnull = open(os.devnull, 'w') if verbose: print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1909 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:50:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:50:07 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmotestconfig: fix socket leak In-Reply-To: References: Message-ID: Hello Harald Welte, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1903 to look at the new patch set (#4). osmotestconfig: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: If97944a079e901439139161eae39181f5c800200 --- M osmopy/osmotestconfig.py 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/03/1903/4 diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 8e5f253..0d2b2d9 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -48,6 +48,7 @@ def test_config_atest(app_desc, config, run_test, verbose=True): proc = None ret = None + vty = None try: cmd = app_desc[1].split(' ') + [ "-c", config] if verbose: @@ -69,6 +70,8 @@ finally: if proc: osmoutil.end_proc(proc) + if vty: + vty._close_socket() return ret -- To view, visit https://gerrit.osmocom.org/1903 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: If97944a079e901439139161eae39181f5c800200 Gerrit-PatchSet: 4 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:50:57 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:50:57 +0000 Subject: python/osmo-python-tests[master]: osmotestconfig: fix socket leak In-Reply-To: References: Message-ID: Patch Set 4: Verified+1 -- To view, visit https://gerrit.osmocom.org/1903 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If97944a079e901439139161eae39181f5c800200 Gerrit-PatchSet: 4 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:51:03 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:51:03 +0000 Subject: python/osmo-python-tests[master]: osmoutil: open /dev/null only once In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1909 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:51:17 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:51:17 +0000 Subject: python/osmo-python-tests[master]: osmoutil: try to terminate process instead of killing In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1908 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:51:29 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:51:29 +0000 Subject: python/osmo-python-tests[master]: osmoutil: centrally log process launches In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1907 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:51:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:51:35 +0000 Subject: python/osmo-python-tests[master]: debug: monitor used TCP sockets and running osmo processes In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 Verified+1 -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 4 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:52:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:52:13 +0000 Subject: [MERGED] python/osmo-python-tests[master]: debug: monitor used TCP sockets and running osmo processes In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: debug: monitor used TCP sockets and running osmo processes ...................................................................... debug: monitor used TCP sockets and running osmo processes Add global flag debug_tcp_sockets; if true, monitors all open TCP sockets of the system and running processes by regular 'ss' and 'ps' output, and logs which VTY sockets are opened and closed. Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 --- M osmopy/obscvty.py 1 file changed, 33 insertions(+), 0 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved; Verified diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 3c9edb1..e4df57d 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -18,6 +18,7 @@ # import re import socket +import sys, subprocess """VTYInteract: interact with an osmocom vty @@ -25,6 +26,23 @@ Connections will be reestablished as necessary. Methods: __init__, command, enabled_command, verify, w_verify""" +debug_tcp_sockets = False + +def cmd(what): + print '\n> %s' % what + sys.stdout.flush() + subprocess.call(what, shell=True) + sys.stdout.flush() + sys.stderr.flush() + print '' + sys.stdout.flush() + +def print_used_tcp_sockets(): + if not debug_tcp_sockets: + return + cmd('ss -tn'); + cmd('ss -tln'); + cmd('ps xua | grep osmo'); class VTYInteract(object): """__init__(self, name, host, port): @@ -32,7 +50,12 @@ name is the name the vty prints for commands, ie OpenBSC host is the hostname to connect to port is the port to connect on""" + + all_sockets = [] + def __init__(self, name, host, port): + print_used_tcp_sockets() + self.name = name self.host = host self.port = port @@ -44,6 +67,11 @@ def _close_socket(self): if self.socket: + if debug_tcp_sockets: + VTYInteract.all_sockets.remove(self.socket) + print "Socket: closing %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.close() self.socket = None @@ -107,6 +135,11 @@ self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setblocking(1) self.socket.connect((self.host, self.port)) + if debug_tcp_sockets: + VTYInteract.all_sockets.append(self.socket) + print "Socket: connected to %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) self.socket.recv(4096) # Now send the command -- To view, visit https://gerrit.osmocom.org/1904 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989 Gerrit-PatchSet: 4 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:52:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:52:13 +0000 Subject: [MERGED] python/osmo-python-tests[master]: osmoutil: centrally log process launches In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmoutil: centrally log process launches ...................................................................... osmoutil: centrally log process launches Log Popen in osmoutil.py instead of in each python test. Launch message is being removed in openbsc's python tests and added here. (change-id Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee) Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 --- M osmopy/osmoutil.py 1 file changed, 3 insertions(+), 1 deletion(-) Approvals: Neels Hofmeyr: Looks good to me, approved; Verified diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 78465d9..bb03614 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,8 +23,10 @@ """Run a command, with stdout and stderr directed to devnull""" -def popen_devnull(cmd): +def popen_devnull(cmd, verbose=True): devnull = open(os.devnull, 'w') + if verbose: + print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1907 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:52:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:52:13 +0000 Subject: [MERGED] python/osmo-python-tests[master]: osmoutil: try to terminate process instead of killing In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmoutil: try to terminate process instead of killing ...................................................................... osmoutil: try to terminate process instead of killing Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 --- M osmopy/osmoutil.py 1 file changed, 12 insertions(+), 2 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved; Verified diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index bb03614..7b20043 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -18,6 +18,7 @@ import os import sys import importlib +import time """Run a command, with stdout and stderr directed to devnull""" @@ -36,9 +37,18 @@ def end_proc(proc): - if proc: + if not proc: + return + + proc.terminate() + time.sleep(.1) + rc = proc.poll() + if rc is not None: + print "Terminated child process" + else: proc.kill() - proc.wait() + print "Killed child process" + proc.wait() """Add a directory to sys.path, try to import a config file.""" -- To view, visit https://gerrit.osmocom.org/1908 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7 Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:52:14 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:52:14 +0000 Subject: [MERGED] python/osmo-python-tests[master]: osmoutil: open /dev/null only once In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmoutil: open /dev/null only once ...................................................................... osmoutil: open /dev/null only once Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b --- M osmopy/osmoutil.py 1 file changed, 6 insertions(+), 1 deletion(-) Approvals: Neels Hofmeyr: Looks good to me, approved; Verified diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 7b20043..01f74cc 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,9 +23,14 @@ """Run a command, with stdout and stderr directed to devnull""" +devnull = None def popen_devnull(cmd, verbose=True): - devnull = open(os.devnull, 'w') + global devnull + if devnull is None: + if verbose: + print "Opening /dev/null" + devnull = open(os.devnull, 'w') if verbose: print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) -- To view, visit https://gerrit.osmocom.org/1909 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b Gerrit-PatchSet: 3 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:52:14 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:52:14 +0000 Subject: [MERGED] python/osmo-python-tests[master]: osmotestconfig: fix socket leak In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: osmotestconfig: fix socket leak ...................................................................... osmotestconfig: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: If97944a079e901439139161eae39181f5c800200 --- M osmopy/osmotestconfig.py 1 file changed, 3 insertions(+), 0 deletions(-) Approvals: Neels Hofmeyr: Verified Harald Welte: Looks good to me, approved diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 8e5f253..0d2b2d9 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -48,6 +48,7 @@ def test_config_atest(app_desc, config, run_test, verbose=True): proc = None ret = None + vty = None try: cmd = app_desc[1].split(' ') + [ "-c", config] if verbose: @@ -69,6 +70,8 @@ finally: if proc: osmoutil.end_proc(proc) + if vty: + vty._close_socket() return ret -- To view, visit https://gerrit.osmocom.org/1903 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: If97944a079e901439139161eae39181f5c800200 Gerrit-PatchSet: 4 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:57:49 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:57:49 +0000 Subject: [MERGED] libosmocore[master]: ports.h: rename CSCN to MSC In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: ports.h: rename CSCN to MSC ...................................................................... ports.h: rename CSCN to MSC See OS#1958 Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d --- M include/osmocom/ctrl/ports.h M include/osmocom/vty/ports.h 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h index 101b894..d28066e 100644 --- a/include/osmocom/ctrl/ports.h +++ b/include/osmocom/ctrl/ports.h @@ -13,7 +13,7 @@ #define OSMO_CTRL_PORT_BSC_NAT 4250 #define OSMO_CTRL_PORT_SGSN 4251 /* 4252-4254 used by VTY interface */ -#define OSMO_CTRL_PORT_CSCN 4255 +#define OSMO_CTRL_PORT_MSC 4255 /* 4256 used by VTY interface */ #define OSMO_CTRL_PORT_GGSN 4257 #define OSMO_CTRL_PORT_HLR 4259 diff --git a/include/osmocom/vty/ports.h b/include/osmocom/vty/ports.h index 70dc69c..887e4df 100644 --- a/include/osmocom/vty/ports.h +++ b/include/osmocom/vty/ports.h @@ -20,7 +20,7 @@ /* 4249-4251 used by control interface */ #define OSMO_VTY_PORT_BTSMGR 4252 #define OSMO_VTY_PORT_GTPHUB 4253 -#define OSMO_VTY_PORT_CSCN 4254 +#define OSMO_VTY_PORT_MSC 4254 /* 4255 used by control interface */ #define OSMO_VTY_PORT_MNCC_SIP 4256 /* 4257 used by control interface */ -- To view, visit https://gerrit.osmocom.org/1884 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:57:56 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:57:56 +0000 Subject: [MERGED] osmo-gsm-manuals[master]: ports: rename CSCN to MSC In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: ports: rename CSCN to MSC ...................................................................... ports: rename CSCN to MSC See OS#1958 and https://gerrit.osmocom.org/1884 Change-Id: Iac081f5b92f66df68932350492687933c47e4f95 --- M common/chapters/port_numbers.adoc 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/common/chapters/port_numbers.adoc b/common/chapters/port_numbers.adoc index f48c8d0..4475b0f 100644 --- a/common/chapters/port_numbers.adoc +++ b/common/chapters/port_numbers.adoc @@ -27,8 +27,8 @@ |TCP|4251|Control Interface|osmo-sgsn |TCP|4252|telnet (VTY)|sysmobts-mgr |TCP|4253|telnet (VTY)|osmo-gtphub -|TCP|4254|telnet (VTY)|osmo-cscn -|TCP|4255|Control Interface|osmo-cscn +|TCP|4254|telnet (VTY)|osmo-msc +|TCP|4255|Control Interface|osmo-msc |TCP|4256|telnet (VTY)|osmo-sip-connector |TCP|4257|Control Interface|ggsn (OpenGGSN) |TCP|4258|telnet (VTY)|osmo-hlr -- To view, visit https://gerrit.osmocom.org/1900 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iac081f5b92f66df68932350492687933c47e4f95 Gerrit-PatchSet: 1 Gerrit-Project: osmo-gsm-manuals Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 19:58:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 19:58:07 +0000 Subject: [MERGED] openbsc[master]: vty: fix subscr ref count leak in 'subscriber name' cmd In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: vty: fix subscr ref count leak in 'subscriber name' cmd ...................................................................... vty: fix subscr ref count leak in 'subscriber name' cmd Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1 --- M openbsc/src/libmsc/vty_interface_layer3.c 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index ddec2e3..cd5dfb7 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -586,6 +586,7 @@ vty_out(vty, "%% NAME is too long, max. %zu characters are allowed%s", sizeof(subscr->name)-1, VTY_NEWLINE); + subscr_put(subscr); return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/1881 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Fri Feb 24 20:03:00 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 20:03:00 +0000 Subject: [MERGED] openbsc[master]: cosmetic: rename struct osmo_msc_data to bsc_msc_data In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: cosmetic: rename struct osmo_msc_data to bsc_msc_data ...................................................................... cosmetic: rename struct osmo_msc_data to bsc_msc_data With the OsmoMSC program coming up, the name osmo_msc_data becomes even more confusing than it already is. Clearly indicate it as libbsc's data of a remote MSC by prefixing with bsc_. Also, the Osmocom community has in the meantime agreed to have the osmo_ prefix only in libosmocore, to avoid naming conflicts in case things are moved there. So while renaming anyway, also drop the osmo_ prefix. Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab --- M openbsc/include/openbsc/bsc_msc_data.h M openbsc/include/openbsc/osmo_bsc.h M openbsc/include/openbsc/osmo_bsc_grace.h M openbsc/include/openbsc/signal.h M openbsc/src/osmo-bsc/osmo_bsc_api.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_ctrl.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_main.c M openbsc/src/osmo-bsc/osmo_bsc_msc.c M openbsc/src/osmo-bsc/osmo_bsc_sccp.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/tests/bsc/bsc_test.c 14 files changed, 107 insertions(+), 107 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/include/openbsc/bsc_msc_data.h b/openbsc/include/openbsc/bsc_msc_data.h index 3168d91..38e87cf 100644 --- a/openbsc/include/openbsc/bsc_msc_data.h +++ b/openbsc/include/openbsc/bsc_msc_data.h @@ -49,7 +49,7 @@ /*! /brief Information on a remote MSC for libbsc. */ -struct osmo_msc_data { +struct bsc_msc_data { struct llist_head entry; /* Back pointer */ @@ -128,15 +128,15 @@ }; -int osmo_bsc_msc_init(struct osmo_msc_data *msc); +int osmo_bsc_msc_init(struct bsc_msc_data *msc); int osmo_bsc_sccp_init(struct gsm_network *gsmnet); int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto); int msc_queue_write_with_ping(struct bsc_msc_connection *, struct msgb *msg, int proto); int osmo_bsc_audio_init(struct gsm_network *network); -struct osmo_msc_data *osmo_msc_data_find(struct gsm_network *, int); -struct osmo_msc_data *osmo_msc_data_alloc(struct gsm_network *, int); +struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *, int); +struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *, int); #endif diff --git a/openbsc/include/openbsc/osmo_bsc.h b/openbsc/include/openbsc/osmo_bsc.h index fd5303d..9e688fd 100644 --- a/openbsc/include/openbsc/osmo_bsc.h +++ b/openbsc/include/openbsc/osmo_bsc.h @@ -16,7 +16,7 @@ }; struct sccp_connection; -struct osmo_msc_data; +struct bsc_msc_data; struct bsc_msc_connection; struct osmo_bsc_sccp_con { @@ -33,7 +33,7 @@ /* SCCP connection realted */ struct sccp_connection *sccp; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct osmo_timer_list sccp_it_timeout; struct osmo_timer_list sccp_cc_timeout; @@ -51,15 +51,15 @@ int bsc_queue_for_msc(struct osmo_bsc_sccp_con *conn, struct msgb *msg); int bsc_open_connection(struct osmo_bsc_sccp_con *sccp, struct msgb *msg); enum bsc_con bsc_create_new_connection(struct gsm_subscriber_connection *conn, - struct osmo_msc_data *msc, int send_ping); + struct bsc_msc_data *msc, int send_ping); int bsc_delete_connection(struct osmo_bsc_sccp_con *sccp); -struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *); +struct bsc_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *); int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg); int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg); int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn); -int bsc_handle_udt(struct osmo_msc_data *msc, struct msgb *msg, unsigned int length); +int bsc_handle_udt(struct bsc_msc_data *msc, struct msgb *msg, unsigned int length); int bsc_handle_dt1(struct osmo_bsc_sccp_con *conn, struct msgb *msg, unsigned int len); int bsc_ctrl_cmds_install(); diff --git a/openbsc/include/openbsc/osmo_bsc_grace.h b/openbsc/include/openbsc/osmo_bsc_grace.h index af77b2f..ea5e4e2 100644 --- a/openbsc/include/openbsc/osmo_bsc_grace.h +++ b/openbsc/include/openbsc/osmo_bsc_grace.h @@ -23,9 +23,9 @@ #include -struct osmo_msc_data; +struct bsc_msc_data; int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts); -int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc); +int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct bsc_msc_data *msc); #endif diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h index c862b21..d4ccf80 100644 --- a/openbsc/include/openbsc/signal.h +++ b/openbsc/include/openbsc/signal.h @@ -222,9 +222,9 @@ S_MSC_AUTHENTICATED, }; -struct osmo_msc_data; +struct bsc_msc_data; struct msc_signal_data { - struct osmo_msc_data *data; + struct bsc_msc_data *data; }; /* SS_CCCH signals */ diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index c3d1384..bac5e47 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -49,30 +49,30 @@ static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause); static int complete_layer3(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct osmo_msc_data *msc); + struct msgb *msg, struct bsc_msc_data *msc); -static uint16_t get_network_code_for_msc(struct osmo_msc_data *msc) +static uint16_t get_network_code_for_msc(struct bsc_msc_data *msc) { if (msc->core_mnc != -1) return msc->core_mnc; return msc->network->network_code; } -static uint16_t get_country_code_for_msc(struct osmo_msc_data *msc) +static uint16_t get_country_code_for_msc(struct bsc_msc_data *msc) { if (msc->core_mcc != -1) return msc->core_mcc; return msc->network->country_code; } -static uint16_t get_lac_for_msc(struct osmo_msc_data *msc, struct gsm_bts *bts) +static uint16_t get_lac_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) { if (msc->core_lac != -1) return msc->core_lac; return bts->location_area_code; } -static uint16_t get_ci_for_msc(struct osmo_msc_data *msc, struct gsm_bts *bts) +static uint16_t get_ci_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) { if (msc->core_ci != -1) return msc->core_ci; @@ -98,7 +98,7 @@ } static int bsc_filter_initial(struct osmo_bsc_data *bsc, - struct osmo_msc_data *msc, + struct bsc_msc_data *msc, struct gsm_subscriber_connection *conn, struct msgb *msg, char **imsi, int *con_type, int *lu_cause) @@ -216,7 +216,7 @@ static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; LOGP(DMSC, LOGL_INFO, "Tx MSC COMPL L3\n"); @@ -233,7 +233,7 @@ } static int complete_layer3(struct gsm_subscriber_connection *conn, - struct msgb *msg, struct osmo_msc_data *msc) + struct msgb *msg, struct bsc_msc_data *msc) { int con_type, rc, lu_cause; char *imsi = NULL; @@ -310,7 +310,7 @@ * Plastic surgery... we want to give up the current connection */ static int move_to_msc(struct gsm_subscriber_connection *_conn, - struct msgb *msg, struct osmo_msc_data *msc) + struct msgb *msg, struct bsc_msc_data *msc) { struct osmo_bsc_sccp_con *old_con = _conn->sccp_con; @@ -344,7 +344,7 @@ uint8_t pdisc = gsm48_hdr_pdisc(gh); uint8_t mtype = gsm48_hdr_msg_type(gh); - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm_mncc_number called; struct tlv_parsed tp; unsigned payload_len; @@ -493,7 +493,7 @@ static void bsc_mr_config(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan, int full_rate) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm48_multi_rate_conf *ms_conf, *bts_conf; if (!conn->sccp_con) { diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index 67325b3..dcfef40 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -88,7 +88,7 @@ return GSM48_CMODE_SPEECH_AMR; } -static int bssmap_handle_reset_ack(struct osmo_msc_data *msc, +static int bssmap_handle_reset_ack(struct bsc_msc_data *msc, struct msgb *msg, unsigned int length) { LOGP(DMSC, LOGL_NOTICE, "Reset ACK from MSC\n"); @@ -96,7 +96,7 @@ } /* GSM 08.08 ? 3.2.1.19 */ -static int bssmap_handle_paging(struct osmo_msc_data *msc, +static int bssmap_handle_paging(struct bsc_msc_data *msc, struct msgb *msg, unsigned int payload_length) { struct gsm_subscriber *subscr; @@ -286,7 +286,7 @@ struct msgb *msg, unsigned int length) { struct msgb *resp; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct tlv_parsed tp; uint8_t *data; uint8_t timeslot; @@ -384,7 +384,7 @@ return -1; } -static int bssmap_rcvmsg_udt(struct osmo_msc_data *msc, +static int bssmap_rcvmsg_udt(struct bsc_msc_data *msc, struct msgb *msg, unsigned int length) { int ret = 0; @@ -491,7 +491,7 @@ return dtap_rc; } -int bsc_handle_udt(struct osmo_msc_data *msc, +int bsc_handle_udt(struct bsc_msc_data *msc, struct msgb *msgb, unsigned int length) { struct bssmap_header *bs; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c index ffde1b8..c23ed21 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c @@ -40,9 +40,9 @@ { struct ctrl_cmd *trap; struct ctrl_handle *ctrl; - struct osmo_msc_data *msc_data; + struct bsc_msc_data *msc_data; - msc_data = (struct osmo_msc_data *) msc_con->write_queue.bfd.data; + msc_data = (struct bsc_msc_data *) msc_con->write_queue.bfd.data; ctrl = msc_data->network->ctrl; trap = ctrl_cmd_trap(cmd); @@ -197,7 +197,7 @@ void bsc_gen_location_state_trap(struct gsm_bts *bts) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; llist_for_each_entry(msc, &bts->network->bsc_data->mscs, entry) generate_location_state_trap(bts, msc->msc_con); @@ -517,7 +517,7 @@ static int set_net_inform_msc(struct ctrl_cmd *cmd, void *data) { struct gsm_network *net; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; net = cmd->node; llist_for_each_entry(msc, &net->bsc_data->mscs, entry) { diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 5925d11..3443bbe 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -122,14 +122,14 @@ return cm->cm_service_type == GSM48_CMSERV_EMERGENCY; } -struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, +struct bsc_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh; int8_t pdisc; uint8_t mtype; struct osmo_bsc_data *bsc; - struct osmo_msc_data *msc, *pag_msc; + struct bsc_msc_data *msc, *pag_msc; struct gsm_subscriber *subscr; int is_emerg = 0; @@ -315,7 +315,7 @@ return 0; } -static int has_core_identity(struct osmo_msc_data *msc) +static int has_core_identity(struct bsc_msc_data *msc) { if (msc->core_mnc != -1) return 1; @@ -333,7 +333,7 @@ */ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm_network *net; struct gsm48_loc_area_id *lai; struct gsm48_hdr *gh; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 9a63702..5709eea 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -35,7 +35,7 @@ static int normal_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) + struct bsc_msc_data *msc) { /* we can't page by lac.. we need to page everything */ if (msc->core_lac != -1) { @@ -52,7 +52,7 @@ } static int locked_paging(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) + struct bsc_msc_data *msc) { struct gsm_bts *bts = NULL; @@ -85,7 +85,7 @@ * Try to not page if everything the cell is not on. */ int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed, - struct osmo_msc_data *msc) + struct bsc_msc_data *msc) { if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON) return normal_paging(subscr, chan_needed, msc); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 982f471..2f0b96d 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -156,7 +156,7 @@ extern int bsc_shutdown_net(struct gsm_network *net); static void signal_handler(int signal) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; fprintf(stdout, "signal %u received\n", signal); @@ -187,7 +187,7 @@ int main(int argc, char **argv) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct osmo_bsc_data *data; int rc; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index e596d2a..42e8055 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -45,16 +45,16 @@ static void initialize_if_needed(struct bsc_msc_connection *conn); static void send_lacs(struct gsm_network *net, struct bsc_msc_connection *conn); -static void send_id_get_response(struct osmo_msc_data *data, int fd, struct msgb *inp); -static void send_ping(struct osmo_msc_data *data); -static void schedule_ping_pong(struct osmo_msc_data *data); +static void send_id_get_response(struct bsc_msc_data *data, int fd, struct msgb *inp); +static void send_ping(struct bsc_msc_data *data); +static void schedule_ping_pong(struct bsc_msc_data *data); /* * MGCP forwarding code */ static int mgcp_do_read(struct osmo_fd *fd) { - struct osmo_msc_data *data = (struct osmo_msc_data *) fd->data; + struct bsc_msc_data *data = (struct bsc_msc_data *) fd->data; struct msgb *mgcp; int ret; @@ -93,7 +93,7 @@ return ret; } -static void mgcp_forward(struct osmo_msc_data *data, struct msgb *msg) +static void mgcp_forward(struct bsc_msc_data *data, struct msgb *msg) { struct msgb *mgcp; @@ -116,7 +116,7 @@ } } -static int mgcp_create_port(struct osmo_msc_data *data) +static int mgcp_create_port(struct bsc_msc_data *data) { int on; struct sockaddr_in addr; @@ -186,7 +186,7 @@ int msc_queue_write_with_ping(struct bsc_msc_connection *conn, struct msgb *msg, int proto) { - struct osmo_msc_data *data; + struct bsc_msc_data *data; uint8_t val; /* prepend the header */ @@ -201,7 +201,7 @@ val = IPAC_MSGT_PING; msgb_l16tv_put(msg, 1, IPAC_PROTO_IPACCESS, &val); - data = (struct osmo_msc_data *) conn->write_queue.bfd.data; + data = (struct bsc_msc_data *) conn->write_queue.bfd.data; schedule_ping_pong(data); return 0; } @@ -220,7 +220,7 @@ return ret; } -static void handle_ctrl(struct osmo_msc_data *msc, struct msgb *msg) +static void handle_ctrl(struct bsc_msc_data *msc, struct msgb *msg) { int ret; struct ctrl_cmd *cmd; @@ -249,7 +249,7 @@ talloc_free(cmd); } -static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg) +static void osmo_ext_handle(struct bsc_msc_data *msc, struct msgb *msg) { struct ipaccess_head *hh; struct ipaccess_head_ext *hh_ext; @@ -274,7 +274,7 @@ { struct msgb *msg = NULL; struct ipaccess_head *hh; - struct osmo_msc_data *data = (struct osmo_msc_data *) bfd->data; + struct bsc_msc_data *data = (struct bsc_msc_data *) bfd->data; int ret; ret = ipa_msg_recv_buffered(bfd->fd, &msg, &data->msc_con->pending_msg); @@ -319,7 +319,7 @@ return 0; } -static void send_ping(struct osmo_msc_data *data) +static void send_ping(struct bsc_msc_data *data) { struct msgb *msg; @@ -335,7 +335,7 @@ msc_queue_write(data->msc_con, msg, IPAC_PROTO_IPACCESS); } -static void schedule_ping_pong(struct osmo_msc_data *data) +static void schedule_ping_pong(struct bsc_msc_data *data) { /* send another ping in 20 seconds */ osmo_timer_schedule(&data->ping_timer, data->ping_timeout, 0); @@ -346,7 +346,7 @@ static void msc_ping_timeout_cb(void *_data) { - struct osmo_msc_data *data = (struct osmo_msc_data *) _data; + struct bsc_msc_data *data = (struct bsc_msc_data *) _data; if (data->ping_timeout <= 0) return; @@ -356,7 +356,7 @@ static void msc_pong_timeout_cb(void *_data) { - struct osmo_msc_data *data = (struct osmo_msc_data *) _data; + struct bsc_msc_data *data = (struct bsc_msc_data *) _data; LOGP(DMSC, LOGL_ERROR, "MSC didn't answer PING. Closing connection.\n"); bsc_msc_lost(data->msc_con); @@ -365,14 +365,14 @@ static void msc_connection_connected(struct bsc_msc_connection *con) { struct msc_signal_data sig; - struct osmo_msc_data *data; + struct bsc_msc_data *data; int ret, on; on = 1; ret = setsockopt(con->write_queue.bfd.fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); if (ret != 0) LOGP(DMSC, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); - data = (struct osmo_msc_data *) con->write_queue.bfd.data; + data = (struct bsc_msc_data *) con->write_queue.bfd.data; msc_ping_timeout_cb(data); sig.data = data; @@ -386,11 +386,11 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc) { struct msc_signal_data sig; - struct osmo_msc_data *data; + struct bsc_msc_data *data; LOGP(DMSC, LOGL_ERROR, "Lost MSC connection. Freing stuff.\n"); - data = (struct osmo_msc_data *) msc->write_queue.bfd.data; + data = (struct bsc_msc_data *) msc->write_queue.bfd.data; osmo_timer_del(&data->ping_timer); osmo_timer_del(&data->pong_timer); @@ -452,7 +452,7 @@ } } -static int answer_challenge(struct osmo_msc_data *data, struct msgb *inp, struct osmo_auth_vector *vec) +static int answer_challenge(struct bsc_msc_data *data, struct msgb *inp, struct osmo_auth_vector *vec) { int ret; struct tlv_parsed tvp; @@ -495,7 +495,7 @@ } -static void send_id_get_response(struct osmo_msc_data *data, int fd, struct msgb *inp) +static void send_id_get_response(struct bsc_msc_data *data, int fd, struct msgb *inp) { struct msc_signal_data sig; struct msgb *msg; @@ -515,7 +515,7 @@ osmo_signal_dispatch(SS_MSC, S_MSC_AUTHENTICATED, &sig); } -int osmo_bsc_msc_init(struct osmo_msc_data *data) +int osmo_bsc_msc_init(struct bsc_msc_data *data) { if (mgcp_create_port(data) != 0) return -1; @@ -541,9 +541,9 @@ return 0; } -struct osmo_msc_data *osmo_msc_data_find(struct gsm_network *net, int nr) +struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *net, int nr) { - struct osmo_msc_data *msc_data; + struct bsc_msc_data *msc_data; llist_for_each_entry(msc_data, &net->bsc_data->mscs, entry) if (msc_data->nr == nr) @@ -551,16 +551,16 @@ return NULL; } -struct osmo_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr) +struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr) { - struct osmo_msc_data *msc_data; + struct bsc_msc_data *msc_data; /* check if there is already one */ msc_data = osmo_msc_data_find(net, nr); if (msc_data) return msc_data; - msc_data = talloc_zero(net, struct osmo_msc_data); + msc_data = talloc_zero(net, struct bsc_msc_data); if (!msc_data) return NULL; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 09efaf4..970d70e 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -166,7 +166,7 @@ static int msc_sccp_read(struct msgb *msgb, unsigned int length, void *data) { - struct osmo_msc_data *msc = (struct osmo_msc_data *) msgb->cb[0]; + struct bsc_msc_data *msc = (struct bsc_msc_data *) msgb->cb[0]; return bsc_handle_udt(msc, msgb, length); } @@ -194,7 +194,7 @@ } enum bsc_con bsc_create_new_connection(struct gsm_subscriber_connection *conn, - struct osmo_msc_data *msc, int send_ping) + struct bsc_msc_data *msc, int send_ping) { struct osmo_bsc_sccp_con *bsc_con; struct sccp_connection *sccp; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 8dabf95..d59c515 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -41,7 +41,7 @@ return bsc_gsmnet->bsc_data; } -static struct osmo_msc_data *osmo_msc_data(struct vty *vty) +static struct bsc_msc_data *bsc_msc_data(struct vty *vty) { return vty->index; } @@ -62,7 +62,7 @@ "msc [<0-1000>]", "Configure MSC details\n" "MSC connection to configure\n") { int index = argc == 1 ? atoi(argv[0]) : 0; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; msc = osmo_msc_data_alloc(bsc_gsmnet, index); if (!msc) { @@ -82,7 +82,7 @@ return CMD_SUCCESS; } -static void write_msc_amr_options(struct vty *vty, struct osmo_msc_data *msc) +static void write_msc_amr_options(struct vty *vty, struct bsc_msc_data *msc) { #define WRITE_AMR(vty, msc, name, var) \ vty_out(vty, " amr-config %s %s%s", \ @@ -100,7 +100,7 @@ #undef WRITE_AMR } -static void write_msc(struct vty *vty, struct osmo_msc_data *msc) +static void write_msc(struct vty *vty, struct bsc_msc_data *msc) { struct bsc_msc_dest *dest; @@ -188,7 +188,7 @@ static int config_write_msc(struct vty *vty) { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct osmo_bsc_data *bsc = osmo_bsc_data(vty); llist_for_each_entry(msc, &bsc->mscs, entry) @@ -228,7 +228,7 @@ "token TOKEN", "A token for the BSC to be sent to the MSC\n" "A token\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); bsc_replace_string(osmo_bsc_data(vty), &data->bsc_token, argv[0]); return CMD_SUCCESS; @@ -240,7 +240,7 @@ "Authentication (secret) key configuration\n" "Security key\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); osmo_hexparse(argv[0], data->bsc_key, sizeof(data->bsc_key)); data->bsc_key_present = 1; @@ -251,7 +251,7 @@ "no auth-key", NO_STR "Authentication (secret) key configuration\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); memset(data->bsc_key, 0, sizeof(data->bsc_key)); data->bsc_key_present = 0; @@ -263,7 +263,7 @@ "core-mobile-network-code <1-999>", "Use this network code for the core network\n" "MNC value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_mnc = atoi(argv[0]); return CMD_SUCCESS; } @@ -273,7 +273,7 @@ "core-mobile-country-code <1-999>", "Use this country code for the core network\n" "MCC value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_mcc = atoi(argv[0]); return CMD_SUCCESS; } @@ -283,7 +283,7 @@ "core-location-area-code <0-65535>", "Use this location area code for the core network\n" "LAC value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_lac = atoi(argv[0]); return CMD_SUCCESS; } @@ -293,7 +293,7 @@ "core-cell-identity <0-65535>", "Use this cell identity for the core network\n" "CI value\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->core_ci = atoi(argv[0]); return CMD_SUCCESS; } @@ -305,7 +305,7 @@ "Set the rtp-base port for the RTP stream\n" "Port number\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->rtp_base = atoi(argv[0]); return CMD_SUCCESS; } @@ -316,7 +316,7 @@ "Set the allowed audio codecs\n" "List of audio codecs, e.g. fr3 fr1 hr3\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); int saw_fr, saw_hr; int i; @@ -377,7 +377,7 @@ "IP Address\n" "Port\n" "DSCP\n") { struct bsc_msc_dest *dest; - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); dest = talloc_zero(osmo_bsc_data(vty), struct bsc_msc_dest); if (!dest) { @@ -405,7 +405,7 @@ "IP Address\n" "Port\n" "DSCP\n") { struct bsc_msc_dest *dest, *tmp; - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); int port = atoi(argv[1]); int dscp = atoi(argv[2]); @@ -427,7 +427,7 @@ "no timeout-ping", NO_STR "Disable the ping/pong handling on A-link\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->ping_timeout = -1; return CMD_SUCCESS; } @@ -438,7 +438,7 @@ "Set the PING interval, negative for not sending PING\n" "Timeout in seconds\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->ping_timeout = atoi(argv[0]); return CMD_SUCCESS; } @@ -448,7 +448,7 @@ "timeout-pong <1-2147483647>", "Set the time to wait for a PONG\n" "Timeout in seconds\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->pong_timeout = atoi(argv[0]); return CMD_SUCCESS; } @@ -458,7 +458,7 @@ "timeout-ping advanced", "Ping timeout handling\nEnable advanced mode during SCCP\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); if (data->ping_timeout == -1) { vty_out(vty, "%%ping handling is disabled. Enable it first.%s", @@ -475,7 +475,7 @@ "no timeout-ping advanced", NO_STR "Ping timeout handling\nEnable advanced mode during SCCP\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->advanced_ping = 0; return CMD_SUCCESS; } @@ -485,7 +485,7 @@ "bsc-welcome-text .TEXT", "Set the USSD notification to be sent\n" "Text to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); char *str = argv_concat(argv, argc, 0); if (!str) return CMD_WARNING; @@ -500,7 +500,7 @@ "no bsc-welcome-text", NO_STR "Clear the USSD notification to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); talloc_free(data->ussd_welcome_txt); data->ussd_welcome_txt = NULL; @@ -513,7 +513,7 @@ "bsc-msc-lost-text .TEXT", "Set the USSD notification to be sent on MSC connection loss\n" "Text to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); char *str = argv_concat(argv, argc, 0); if (!str) return CMD_WARNING; @@ -528,7 +528,7 @@ "no bsc-msc-lost-text", NO_STR "Clear the USSD notification to be sent on MSC connection loss\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); talloc_free(data->ussd_msc_lost_txt); data->ussd_msc_lost_txt = 0; @@ -541,7 +541,7 @@ "bsc-grace-text .TEXT", "Set the USSD notification to be sent when the MSC has entered the grace period\n" "Text to be sent\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); char *str = argv_concat(argv, argc, 0); if (!str) return CMD_WARNING; @@ -556,7 +556,7 @@ "no bsc-grace-text", NO_STR "Clear the USSD notification to be sent when the MSC has entered the grace period\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); talloc_free(data->ussd_grace_txt); data->ussd_grace_txt = NULL; @@ -599,7 +599,7 @@ "Select the MSC type\n" "Plain GSM MSC\n" "Special MSC for local call routing\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); if (strcmp(argv[0], "normal") == 0) data->type = MSC_CON_TYPE_NORMAL; @@ -615,7 +615,7 @@ "Allow CM ServiceRequests with type emergency\n" "Allow\n" "Deny\n") { - struct osmo_msc_data *data = osmo_msc_data(vty); + struct bsc_msc_data *data = bsc_msc_data(vty); data->allow_emerg = strcmp("allow", argv[0]) == 0; return CMD_SUCCESS; } @@ -625,7 +625,7 @@ "local-prefix REGEXP", "Prefix for local numbers\n" "REGEXP used\n") { - struct osmo_msc_data *msc = osmo_msc_data(vty); + struct bsc_msc_data *msc = bsc_msc_data(vty); if (gsm_parse_reg(msc, &msc->local_pref_reg, &msc->local_pref, argc, argv) != 0) { vty_out(vty, "%%Failed to parse the regexp: '%s'%s", @@ -643,7 +643,7 @@ "amr-config " #name "k (allowed|forbidden)", \ AMR_CONF_STR "Bitrate\n" "Allowed\n" "Forbidden\n") \ { \ - struct osmo_msc_data *msc = osmo_msc_data(vty); \ + struct bsc_msc_data *msc = bsc_msc_data(vty); \ \ msc->amr_conf.m##name = strcmp(argv[0], "allowed") == 0; \ return CMD_SUCCESS; \ @@ -664,7 +664,7 @@ "Set the name of the access list to use.\n" "The name of the to be used access list.") { - struct osmo_msc_data *msc = osmo_msc_data(vty); + struct bsc_msc_data *msc = bsc_msc_data(vty); bsc_replace_string(msc, &msc->acc_lst_name, argv[0]); return CMD_SUCCESS; @@ -675,7 +675,7 @@ "no access-list-name", NO_STR "Remove the access list from the NAT.\n") { - struct osmo_msc_data *msc = osmo_msc_data(vty); + struct bsc_msc_data *msc = bsc_msc_data(vty); if (msc->acc_lst_name) { talloc_free(msc->acc_lst_name); @@ -782,7 +782,7 @@ "show mscs", SHOW_STR "MSC Connections and State\n") { - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; llist_for_each_entry(msc, &bsc_gsmnet->bsc_data->mscs, entry) { vty_out(vty, "MSC Nr: %d is connected: %d auth: %d.%s", msc->nr, diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c index 1e3fdf7..20ed5b4 100644 --- a/openbsc/tests/bsc/bsc_test.c +++ b/openbsc/tests/bsc/bsc_test.c @@ -125,13 +125,13 @@ struct gsm_network *net; struct gsm_bts *bts; struct osmo_bsc_sccp_con *sccp_con; - struct osmo_msc_data *msc; + struct bsc_msc_data *msc; struct gsm_subscriber_connection *conn; net = talloc_zero(NULL, struct gsm_network); bts = talloc_zero(net, struct gsm_bts); sccp_con = talloc_zero(net, struct osmo_bsc_sccp_con); - msc = talloc_zero(net, struct osmo_msc_data); + msc = talloc_zero(net, struct bsc_msc_data); conn = talloc_zero(net, struct gsm_subscriber_connection); bts->network = net; -- To view, visit https://gerrit.osmocom.org/1892 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 24 20:03:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 20:03:01 +0000 Subject: [MERGED] openbsc[master]: cosmetic: rename osmo_msc_data.h to bsc_msc_data.h In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: cosmetic: rename osmo_msc_data.h to bsc_msc_data.h ...................................................................... cosmetic: rename osmo_msc_data.h to bsc_msc_data.h With the OsmoMSC program coming up, the name osmo_msc_data becomes even more confusing than it already is. Clearly indicate it as libbsc's data of a remote MSC by prefixing with bsc_. Also, the Osmocom community has in the meantime agreed to have the osmo_ prefix only in libosmocore, to avoid naming conflicts in case things are moved there. So while renaming anyway, also drop the osmo_ prefix. Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607 --- M openbsc/include/openbsc/Makefile.am R openbsc/include/openbsc/bsc_msc_data.h M openbsc/src/libbsc/bsc_ctrl_commands.c M openbsc/src/libbsc/bsc_rf_ctrl.c M openbsc/src/libbsc/bsc_vty.c M openbsc/src/libbsc/net_init.c M openbsc/src/libcommon/gsm_data.c M openbsc/src/osmo-bsc/osmo_bsc_api.c M openbsc/src/osmo-bsc/osmo_bsc_audio.c M openbsc/src/osmo-bsc/osmo_bsc_bssap.c M openbsc/src/osmo-bsc/osmo_bsc_ctrl.c M openbsc/src/osmo-bsc/osmo_bsc_filter.c M openbsc/src/osmo-bsc/osmo_bsc_grace.c M openbsc/src/osmo-bsc/osmo_bsc_main.c M openbsc/src/osmo-bsc/osmo_bsc_msc.c M openbsc/src/osmo-bsc/osmo_bsc_sccp.c M openbsc/src/osmo-bsc/osmo_bsc_vty.c M openbsc/src/osmo-nitb/bsc_hack.c M openbsc/tests/bsc/bsc_test.c 19 files changed, 18 insertions(+), 18 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 2466ce8..5cd5afc 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -60,7 +60,7 @@ osmo_bsc_grace.h \ osmo_bsc_rf.h \ osmo_msc.h \ - osmo_msc_data.h \ + bsc_msc_data.h \ osmux.h \ paging.h \ rest_octets.h \ diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/bsc_msc_data.h similarity index 100% rename from openbsc/include/openbsc/osmo_msc_data.h rename to openbsc/include/openbsc/bsc_msc_data.h diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c index 14e8d71..641fe2b 100644 --- a/openbsc/src/libbsc/bsc_ctrl_commands.c +++ b/openbsc/src/libbsc/bsc_ctrl_commands.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #define CTRL_CMD_VTY_STRING(cmdname, cmdstr, dtype, element) \ CTRL_HELPER_GET_STRING(cmdname, dtype, element) \ diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c index 59fac35..d13c685 100644 --- a/openbsc/src/libbsc/bsc_rf_ctrl.c +++ b/openbsc/src/libbsc/bsc_rf_ctrl.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 73acebd..0a55cf4 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c index f728d3f..bc5ed35 100644 --- a/openbsc/src/libbsc/net_init.c +++ b/openbsc/src/libbsc/net_init.c @@ -19,7 +19,7 @@ #include #include -#include +#include struct gsm_network *bsc_network_init(void *ctx, uint16_t country_code, diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 75475db..3e12430 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include void *tall_bsc_ctx; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index 49e5796..c3d1384 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_audio.c b/openbsc/src/osmo-bsc/osmo_bsc_audio.c index 660d884..1160209 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_audio.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_audio.c @@ -20,7 +20,7 @@ * */ -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index f38c97f..67325b3 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c index 5352bf2..ffde1b8 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index d5ca2fd..5925d11 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index 6409a3a..9a63702 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index adce775..982f471 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 0eb3fa9..e596d2a 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index a571438..09efaf4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 86ccec4..8dabf95 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 2bdfada..dd90b8b 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c index 7174828..1e3fdf7 100644 --- a/openbsc/tests/bsc/bsc_test.c +++ b/openbsc/tests/bsc/bsc_test.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include -- To view, visit https://gerrit.osmocom.org/1891 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 24 20:03:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 20:03:02 +0000 Subject: [MERGED] openbsc[master]: cosmetic: clarify BSC's remote MSC data vs. OsmoMSC In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: cosmetic: clarify BSC's remote MSC data vs. OsmoMSC ...................................................................... cosmetic: clarify BSC's remote MSC data vs. OsmoMSC Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9 --- M openbsc/include/openbsc/osmo_msc_data.h 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index a5a3f14..3168d91 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -20,6 +20,10 @@ * */ +/* + * NOTE: This is about a *remote* MSC for OsmoBSC and is not part of libmsc. + */ + #ifndef _OSMO_MSC_DATA_H #define _OSMO_MSC_DATA_H @@ -43,6 +47,8 @@ MSC_CON_TYPE_LOCAL, }; +/*! /brief Information on a remote MSC for libbsc. + */ struct osmo_msc_data { struct llist_head entry; -- To view, visit https://gerrit.osmocom.org/1890 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 24 20:03:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 20:03:02 +0000 Subject: [MERGED] openbsc[master]: cosmetic: gsm_data.h, README: rename CSCN to MSC In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: cosmetic: gsm_data.h, README: rename CSCN to MSC ...................................................................... cosmetic: gsm_data.h, README: rename CSCN to MSC We're discarding the name OsmoCSCN for the benefit of OsmoMSC. But "CSCN" has already crept into the master branch in two places; apply the rename. See OS#1958 Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d --- M openbsc/README M openbsc/include/openbsc/gsm_data.h 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved diff --git a/openbsc/README b/openbsc/README index 88ea328..d01b2cf 100644 --- a/openbsc/README +++ b/openbsc/README @@ -9,7 +9,7 @@ * OsmoBSC - a pure GSM BSC, speaking Abis/IP to the BTS and A/IP to the MSC * OsmoBSC-MGCP - MGCP helper to the OsmoBSC software * OsmoNITB - a BSC+MSC+VLR+HLR+SMSC "Network in the box". - * OsmoCSCN - a voice CN with A/IP and IuCS/IP towards the BSC and/or HNB-GW + * OsmoMSC - a voice CN with A/IP and IuCS/IP towards the BSC and/or HNB-GW * OsmoSGSN - a GPRS SGSN with Gb/IP and IuPS/IP towards the PCU and/or HNB-GW * Osmo-GbProxy - a Proxy to aggregate many Gb links as one Gb link to the SGSN * OsmoBSCNAT - a gateway aggregating many A links as one A link to the MSC diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index ac573c4..4425a10 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -379,7 +379,7 @@ * contexts. */ /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable * BTS|RNC specific timezone overrides for multi-tz networks in - * OsmoCSCN, this should be tied to the location area code (LAC). */ + * OsmoMSC, this should be tied to the location area code (LAC). */ struct gsm_tz tz; }; -- To view, visit https://gerrit.osmocom.org/1889 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Fri Feb 24 20:21:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Fri, 24 Feb 2017 20:21:23 +0000 Subject: openbsc[master]: add struct bsc_subscr, separating libbsc from gsm_subscriber In-Reply-To: References: Message-ID: Patch Set 8: (1 comment) https://gerrit.osmocom.org/#/c/1682/8/openbsc/include/openbsc/gsm_data.h File openbsc/include/openbsc/gsm_data.h: Line 391: /* List of all struct bsc_subscr used in libbsc. This llist_head is > this is highly unusual in the osmocom code base. the llist_head of the mas The idea behind this is to pass to the bsc_subscr API only what it actually uses: instead of the entire gsm_network struct, I want to pass only the bsc_subscribers llist pointer. Hence that's the only hook for talloc ctx and it needs to be talloc'd. In the same way, thinking forward to the bsc-msc split, the MSC's gsm_network will not have a list of bsc_subscribers, and being NULL would indicate that. (Then again we'll probably rename it to msc_ctx and drop the member entirely; but if we want to keep the option of marrying BSC and MSC into a NITB, it would make sense.) Quite nice for the unit test: instead of mocking a gsm_network and pulling in the entire gsm_data.h, we just create an llist and done. Code that needs to change: callers of the bsc_subscr_find_* api need to pass the gsm_network instead of gsm_network->bsc_subscribers. It would be shallow in that no cascades of function arguments need to be adjusted. We could also use the global bsc_gsmnet as talloc ctx, but I'm more for moving away from magic globals and towards explicit arguments. The GPRS subscr uses a static global llist instead. We could also do that. But again, I like to keep globals grouped somewhere visible... I'm aware that it's unusual, but there are some arguments for it. Feel free to say "no" again and I'll change it. -- To view, visit https://gerrit.osmocom.org/1682 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 25 01:25:22 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 01:25:22 +0000 Subject: [MERGED] openbsc[master]: add struct gprs_subscr, separating gprs from gsm_subscriber In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: add struct gprs_subscr, separating gprs from gsm_subscriber ...................................................................... add struct gprs_subscr, separating gprs from gsm_subscriber Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will not make sense to be used in gprs, so have a dedicated GPRS subscriber struct. (Could change if the gprs code were to use libvlr; is currently independent). Related: OS#1592 Change-Id: Ia8b391ee009c8545763cba04505be3947835120e --- M openbsc/include/openbsc/Makefile.am M openbsc/include/openbsc/gprs_sgsn.h A openbsc/include/openbsc/gprs_subscriber.h M openbsc/include/openbsc/gsm_data.h M openbsc/include/openbsc/gsm_subscriber.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/src/gprs/gprs_subscriber.c M openbsc/src/gprs/sgsn_auth.c M openbsc/src/gprs/sgsn_libgtp.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c M openbsc/tests/sgsn/sgsn_test.ok 13 files changed, 269 insertions(+), 151 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 5cd5afc..30c1191 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -31,6 +31,7 @@ gprs_sndcp_dcomp.h \ gprs_sndcp_pcomp.h \ gprs_sndcp_xid.h \ + gprs_subscriber.h \ gprs_utils.h \ gsm_04_08.h \ gsm_04_11.h \ diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 2cc5b0c..c3cac7f 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -18,7 +18,7 @@ struct gprs_llc_lle; struct ctrl_handle; -struct gsm_subscriber; +struct gprs_subscr; enum gsm48_gsm_cause; @@ -225,7 +225,7 @@ /* the current GGSN look-up operation */ struct sgsn_ggsn_lookup *ggsn_lookup; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; }; #define LOGMMCTXP(level, mm, fmt, args...) \ @@ -433,6 +433,7 @@ /* * GPRS subscriber data */ +#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001 #define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16) #define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17) #define GPRS_SUBSCRIBER_CANCELLED (1 << 18) @@ -446,13 +447,13 @@ int gprs_subscr_init(struct sgsn_instance *sgi); int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx); -void gprs_subscr_cleanup(struct gsm_subscriber *subscr); -struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi); -struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); -struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi); -void gprs_subscr_cancel(struct gsm_subscriber *subscr); -void gprs_subscr_update(struct gsm_subscriber *subscr); -void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr); +void gprs_subscr_cleanup(struct gprs_subscr *subscr); +struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi); +struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); +struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi); +void gprs_subscr_cancel(struct gprs_subscr *subscr); +void gprs_subscr_update(struct gprs_subscr *subscr); +void gprs_subscr_update_auth_info(struct gprs_subscr *subscr); int gprs_subscr_rx_gsup_message(struct msgb *msg); /* Called on subscriber data updates */ diff --git a/openbsc/include/openbsc/gprs_subscriber.h b/openbsc/include/openbsc/gprs_subscriber.h new file mode 100644 index 0000000..be78feb --- /dev/null +++ b/openbsc/include/openbsc/gprs_subscriber.h @@ -0,0 +1,31 @@ +/* GPRS subscriber details for use in SGSN land */ +#pragma once + +#include + +#include +#include + +extern struct llist_head * const gprs_subscribers; + +struct gprs_subscr { + struct llist_head entry; + int use_count; + + char imsi[GSM23003_IMSI_MAX_DIGITS+1]; + uint32_t tmsi; + char imei[GSM23003_IMEISV_NUM_DIGITS+1]; + bool authorized; + bool keep_in_ram; + uint32_t flags; + uint16_t lac; + + struct sgsn_subscriber_data *sgsn_data; +}; + +struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub, + const char *file, int line); +struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, + const char *file, int line); +#define gprs_subscr_get(gsub) _gprs_subscr_get(gsub, __BASE_FILE__, __LINE__) +#define gprs_subscr_put(gsub) _gprs_subscr_put(gsub, __BASE_FILE__, __LINE__) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 4425a10..a14e59f 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -26,6 +26,8 @@ #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] +#define tmsi_from_string(str) strtoul(str, NULL, 10) + enum gsm_security_event { GSM_SECURITY_NOAVAIL, GSM_SECURITY_AUTH_FAILED, diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 314d619..7e65614 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -16,7 +16,6 @@ #define GSM_SUBSCRIBER_FIRST_CONTACT 0x00000001 /* gprs_sgsn.h defines additional flags including and above bit 16 (0x10000) */ -#define tmsi_from_string(str) strtoul(str, NULL, 10) #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 1026474..9efe402 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 260e032..727524e 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -321,9 +321,9 @@ /* Detach from subscriber which is possibly freed then */ if (mm->subscr) { - struct gsm_subscriber *subscr = subscr_get(mm->subscr); + struct gprs_subscr *subscr = gprs_subscr_get(mm->subscr); gprs_subscr_cleanup(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); } sgsn_mm_ctx_free(mm); diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index 57f73c5..5f426f8 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include #include #include @@ -35,6 +36,7 @@ #include #include +#include #define SGSN_SUBSCR_MAX_RETRIES 3 #define SGSN_SUBSCR_RETRY_INTERVAL 10 @@ -45,6 +47,9 @@ ## args) extern void *tall_bsc_ctx; + +LLIST_HEAD(_gprs_subscribers); +struct llist_head * const gprs_subscribers = &_gprs_subscribers; static int gsup_read_cb(struct gsup_client *gsupc, struct msgb *msg); @@ -86,7 +91,7 @@ return rc; } -int gprs_subscr_purge(struct gsm_subscriber *subscr); +int gprs_subscr_purge(struct gprs_subscr *subscr); static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx) { @@ -117,28 +122,53 @@ return pdata; } -struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi) +struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi) { - struct gsm_subscriber *subscr; + struct gprs_subscr *gsub; - subscr = subscr_get_or_create(NULL, imsi); - if (!subscr) + if (!imsi || !*imsi) return NULL; - if (!subscr->sgsn_data) - subscr->sgsn_data = sgsn_subscriber_data_alloc(subscr); - return subscr; + llist_for_each_entry(gsub, gprs_subscribers, entry) { + if (!strcmp(gsub->imsi, imsi)) + return gprs_subscr_get(gsub); + } + return NULL; } -struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi) +static struct gprs_subscr *gprs_subscr_alloc(void) { - return subscr_active_by_imsi(NULL, imsi); + struct gprs_subscr *gsub; + gsub = talloc_zero(tall_bsc_ctx, struct gprs_subscr); + if (!gsub) + return NULL; + llist_add_tail(&gsub->entry, gprs_subscribers); + gsub->use_count = 1; + gsub->tmsi = GSM_RESERVED_TMSI; + return gsub; } -void gprs_subscr_cleanup(struct gsm_subscriber *subscr) +struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi) +{ + struct gprs_subscr *gsub; + + gsub = gprs_subscr_get_by_imsi(imsi); + if (!gsub) { + gsub = gprs_subscr_alloc(); + if (!gsub) + return NULL; + strncpy(gsub->imsi, imsi, sizeof(gsub->imsi)); + } + + if (!gsub->sgsn_data) + gsub->sgsn_data = sgsn_subscriber_data_alloc(gsub); + return gsub; +} + +void gprs_subscr_cleanup(struct gprs_subscr *subscr) { if (subscr->sgsn_data->mm) { - subscr_put(subscr->sgsn_data->mm->subscr); + gprs_subscr_put(subscr->sgsn_data->mm->subscr); subscr->sgsn_data->mm->subscr = NULL; subscr->sgsn_data->mm = NULL; } @@ -149,7 +179,7 @@ } } -void gprs_subscr_cancel(struct gsm_subscriber *subscr) +void gprs_subscr_cancel(struct gprs_subscr *subscr) { subscr->authorized = 0; subscr->flags |= GPRS_SUBSCRIBER_CANCELLED; @@ -159,7 +189,7 @@ gprs_subscr_cleanup(subscr); } -static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr, +static int gprs_subscr_tx_gsup_message(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct msgb *msg = gsup_client_msgb_alloc(); @@ -181,7 +211,7 @@ return gsup_client_send(sgsn->gsup_client, msg); } -static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr, +static int gprs_subscr_tx_gsup_error_reply(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_orig, enum gsm48_gmm_cause cause) { @@ -196,7 +226,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); } -static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_auth_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { unsigned idx; @@ -235,7 +265,7 @@ return 0; } -static int gprs_subscr_pdp_data_clear(struct gsm_subscriber *subscr) +static int gprs_subscr_pdp_data_clear(struct gprs_subscr *subscr) { struct sgsn_subscriber_pdp_data *pdp, *pdp2; int count = 0; @@ -250,7 +280,7 @@ } static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id( - struct gsm_subscriber *subscr, unsigned context_id) + struct gprs_subscr *subscr, unsigned context_id) { struct sgsn_subscriber_pdp_data *pdp; @@ -263,7 +293,7 @@ } -static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr, +static void gprs_subscr_gsup_insert_data(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct sgsn_subscriber_data *sdata = subscr->sgsn_data; @@ -340,7 +370,7 @@ } } -static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_upd_loc_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { /* contrary to MAP, we allow piggy-backing subscriber data onto @@ -357,7 +387,7 @@ return 0; } -static int gprs_subscr_handle_gsup_dsd_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_dsd_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -377,7 +407,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); } -static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_isd_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -409,7 +439,7 @@ } } -static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_auth_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { unsigned idx; @@ -462,7 +492,7 @@ return -gsup_msg->cause; } -static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_upd_loc_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { int cause_err; @@ -523,7 +553,7 @@ return 0; } -static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_purge_res(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n"); @@ -535,7 +565,7 @@ return 0; } -static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_gsup_purge_err(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { LOGGSUBSCRP(LOGL_NOTICE, subscr, @@ -568,7 +598,7 @@ return -gsup_msg->cause; } -static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr, +static int gprs_subscr_handle_loc_cancel_req(struct gprs_subscr *subscr, struct osmo_gsup_message *gsup_msg) { struct osmo_gsup_message gsup_reply = {0}; @@ -629,7 +659,7 @@ int rc = 0; struct osmo_gsup_message gsup_msg = {0}; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; rc = osmo_gsup_decode(data, data_len, &gsup_msg); if (rc < 0) { @@ -715,12 +745,12 @@ break; }; - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } -int gprs_subscr_purge(struct gsm_subscriber *subscr) +int gprs_subscr_purge(struct gprs_subscr *subscr) { struct sgsn_subscriber_data *sdata = subscr->sgsn_data; struct osmo_gsup_message gsup_msg = {0}; @@ -736,7 +766,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr) +int gprs_subscr_query_auth_info(struct gprs_subscr *subscr) { struct osmo_gsup_message gsup_msg = {0}; @@ -747,7 +777,7 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_location_update(struct gsm_subscriber *subscr) +int gprs_subscr_location_update(struct gprs_subscr *subscr) { struct osmo_gsup_message gsup_msg = {0}; @@ -758,60 +788,59 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -void gprs_subscr_update(struct gsm_subscriber *subscr) +void gprs_subscr_update(struct gprs_subscr *subscr) { LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber data\n"); subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; - subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags &= ~GPRS_SUBSCRIBER_FIRST_CONTACT; if (subscr->sgsn_data->mm) sgsn_update_subscriber_data(subscr->sgsn_data->mm); } -void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr) +void gprs_subscr_update_auth_info(struct gprs_subscr *subscr) { LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber authentication info\n"); subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; - subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags &= ~GPRS_SUBSCRIBER_FIRST_CONTACT; if (subscr->sgsn_data->mm) sgsn_update_subscriber_data(subscr->sgsn_data->mm); } -struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) +struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; if (mmctx->subscr) - return subscr_get(mmctx->subscr); + return gprs_subscr_get(mmctx->subscr); if (mmctx->imsi[0]) subscr = gprs_subscr_get_by_imsi(mmctx->imsi); if (!subscr) { subscr = gprs_subscr_get_or_create(mmctx->imsi); - subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + subscr->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE; } - osmo_strlcpy(subscr->equipment.imei, mmctx->imei, - sizeof(subscr->equipment.imei)); + osmo_strlcpy(subscr->imei, mmctx->imei, sizeof(subscr->imei)); if (subscr->lac != mmctx->ra.lac) subscr->lac = mmctx->ra.lac; subscr->sgsn_data->mm = mmctx; - mmctx->subscr = subscr_get(subscr); + mmctx->subscr = gprs_subscr_get(subscr); return subscr; } int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; int rc; LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n"); @@ -821,13 +850,13 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; rc = gprs_subscr_location_update(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr = NULL; + struct gprs_subscr *subscr = NULL; int rc; LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n"); @@ -837,6 +866,40 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; rc = gprs_subscr_query_auth_info(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return rc; } + +static void gprs_subscr_free(struct gprs_subscr *gsub) +{ + llist_del(&gsub->entry); + talloc_free(gsub); +} + +struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub, + const char *file, int line) +{ + OSMO_ASSERT(gsub->use_count < INT_MAX); + gsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, + "subscr %s usage increases to: %d\n", + gsub->imsi, gsub->use_count); + return gsub; +} + +struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub, + const char *file, int line) +{ + gsub->use_count--; + LOGPSRC(DREF, gsub->use_count >= 0? LOGL_DEBUG : LOGL_ERROR, + file, line, + "subscr %s usage decreases to: %d%s\n", + gsub->imsi, gsub->use_count, + gsub->keep_in_ram? ", keep-in-ram flag is set" : ""); + if (gsub->use_count > 0) + return gsub; + if (gsub->keep_in_ram) + return gsub; + gprs_subscr_free(gsub); + return NULL; +} diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index 1fa7fc4..df7ee37 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include const struct value_string auth_state_names[] = { @@ -151,7 +151,7 @@ */ int sgsn_auth_request(struct sgsn_mm_ctx *mmctx) { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; struct gsm_auth_tuple *at; int need_update_location; int rc; @@ -169,7 +169,7 @@ /* This has the side effect of registering the subscr with the mmctx */ subscr = gprs_subscr_get_or_create_by_mmctx(mmctx); - subscr_put(subscr); + gprs_subscr_put(subscr); OSMO_ASSERT(mmctx->subscr != NULL); @@ -207,7 +207,7 @@ void sgsn_auth_update(struct sgsn_mm_ctx *mmctx) { enum sgsn_auth_state auth_state; - struct gsm_subscriber *subscr = mmctx->subscr; + struct gprs_subscr *subscr = mmctx->subscr; struct gsm_auth_tuple *at; int gmm_cause; diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 062de44..dde1e5e 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #ifdef BUILD_IU diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 3ce054f..a730635 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -657,40 +657,37 @@ } /* Subscriber */ -#include +#include -static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr, int pending) +static void subscr_dump_full_vty(struct vty *vty, struct gprs_subscr *gsub, int pending) { +#if 0 char expire_time[200]; +#endif struct gsm_auth_tuple *at; int at_idx; struct sgsn_subscriber_pdp_data *pdp; - vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, - subscr->authorized, VTY_NEWLINE); - if (strlen(subscr->name)) - vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); - if (strlen(subscr->extension)) - vty_out(vty, " Extension: %s%s", subscr->extension, - VTY_NEWLINE); + vty_out(vty, " Authorized: %d%s", + gsub->authorized, VTY_NEWLINE); vty_out(vty, " LAC: %d/0x%x%s", - subscr->lac, subscr->lac, VTY_NEWLINE); - vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); - if (subscr->tmsi != GSM_RESERVED_TMSI) - vty_out(vty, " TMSI: %08X%s", subscr->tmsi, + gsub->lac, gsub->lac, VTY_NEWLINE); + vty_out(vty, " IMSI: %s%s", gsub->imsi, VTY_NEWLINE); + if (gsub->tmsi != GSM_RESERVED_TMSI) + vty_out(vty, " TMSI: %08X%s", gsub->tmsi, VTY_NEWLINE); - if (subscr->sgsn_data->msisdn_len > 0) + if (gsub->sgsn_data->msisdn_len > 0) vty_out(vty, " MSISDN (BCD): %s%s", - osmo_hexdump(subscr->sgsn_data->msisdn, - subscr->sgsn_data->msisdn_len), + osmo_hexdump(gsub->sgsn_data->msisdn, + gsub->sgsn_data->msisdn_len), VTY_NEWLINE); - if (strlen(subscr->equipment.imei) > 0) - vty_out(vty, " IMEI: %s%s", subscr->equipment.imei, VTY_NEWLINE); + if (strlen(gsub->imei) > 0) + vty_out(vty, " IMEI: %s%s", gsub->imei, VTY_NEWLINE); - for (at_idx = 0; at_idx < ARRAY_SIZE(subscr->sgsn_data->auth_triplets); + for (at_idx = 0; at_idx < ARRAY_SIZE(gsub->sgsn_data->auth_triplets); at_idx++) { - at = &subscr->sgsn_data->auth_triplets[at_idx]; + at = &gsub->sgsn_data->auth_triplets[at_idx]; if (at->key_seq == GSM_KEY_SEQ_INVAL) continue; @@ -722,36 +719,38 @@ } } - llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) { + llist_for_each_entry(pdp, &gsub->sgsn_data->pdp_list, list) { vty_out(vty, " PDP info: Id: %d, Type: 0x%04x, APN: '%s' QoS: %s%s", pdp->context_id, pdp->pdp_type, pdp->apn_str, osmo_hexdump(pdp->qos_subscribed, pdp->qos_subscribed_len), VTY_NEWLINE); } +#if 0 /* print the expiration time of a subscriber */ - if (subscr->expire_lu) { + if (gsub->expire_lu) { strftime(expire_time, sizeof(expire_time), - "%a, %d %b %Y %T %z", localtime(&subscr->expire_lu)); + "%a, %d %b %Y %T %z", localtime(&gsub->expire_lu)); expire_time[sizeof(expire_time) - 1] = '\0'; vty_out(vty, " Expiration Time: %s%s", expire_time, VTY_NEWLINE); } +#endif - if (subscr->flags) + if (gsub->flags) vty_out(vty, " Flags: %s%s%s%s%s%s", - subscr->flags & GSM_SUBSCRIBER_FIRST_CONTACT ? + gsub->flags & GPRS_SUBSCRIBER_FIRST_CONTACT ? "FIRST_CONTACT " : "", - subscr->flags & GPRS_SUBSCRIBER_CANCELLED ? + gsub->flags & GPRS_SUBSCRIBER_CANCELLED ? "CANCELLED " : "", - subscr->flags & GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING ? + gsub->flags & GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING ? "UPDATE_LOCATION_PENDING " : "", - subscr->flags & GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING ? + gsub->flags & GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING ? "AUTH_INFO_PENDING " : "", - subscr->flags & GPRS_SUBSCRIBER_ENABLE_PURGE ? + gsub->flags & GPRS_SUBSCRIBER_ENABLE_PURGE ? "ENABLE_PURGE " : "", VTY_NEWLINE); - vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); + vty_out(vty, " Use count: %u%s", gsub->use_count, VTY_NEWLINE); } DEFUN(show_subscr_cache, @@ -760,9 +759,9 @@ SHOW_STR "Show information about subscribers\n" "Display contents of subscriber cache\n") { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; - llist_for_each_entry(subscr, &active_subscribers, entry) { + llist_for_each_entry(subscr, gprs_subscribers, entry) { vty_out(vty, " Subscriber:%s", VTY_NEWLINE); subscr_dump_full_vty(vty, subscr, 0); } @@ -794,7 +793,7 @@ const char *kc_str = argv[4]; struct gsm_auth_tuple at = {0,}; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -825,12 +824,12 @@ subscr->sgsn_data->auth_triplets[cksn] = at; subscr->sgsn_data->auth_triplets_updated = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; failed: - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -844,7 +843,7 @@ const char *imsi = argv[0]; const char *cancel_type = argv[1]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -859,7 +858,7 @@ subscr->sgsn_data->error_cause = GMM_CAUSE_IMPL_DETACHED; gprs_subscr_cancel(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -871,7 +870,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (subscr) { @@ -882,7 +881,7 @@ subscr = gprs_subscr_get_or_create(imsi); subscr->keep_in_ram = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -894,7 +893,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -909,7 +908,7 @@ if (subscr->use_count > 1) vty_out(vty, "%% subscriber is still in use%s", VTY_NEWLINE); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -934,7 +933,7 @@ const char *imsi = argv[0]; const char *ret_code_str = argv[1]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; const struct value_string cause_mapping[] = { { GMM_CAUSE_NET_FAIL, "system-failure" }, @@ -963,7 +962,7 @@ gprs_subscr_update(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } @@ -975,7 +974,7 @@ { const char *imsi = argv[0]; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; subscr = gprs_subscr_get_by_imsi(imsi); if (!subscr) { @@ -986,7 +985,7 @@ gprs_subscr_update_auth_info(subscr); - subscr_put(subscr); + gprs_subscr_put(subscr); return CMD_SUCCESS; } diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index ff07978..6eabdde 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -248,7 +248,7 @@ cleanup_test(); } -struct gsm_subscriber *last_updated_subscr = NULL; +struct gprs_subscr *last_updated_subscr = NULL; void my_dummy_sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx) { OSMO_ASSERT(mmctx); @@ -257,23 +257,23 @@ last_updated_subscr = mmctx->subscr; } -static void assert_subscr(const struct gsm_subscriber *subscr, const char *imsi) +static void assert_subscr(const struct gprs_subscr *subscr, const char *imsi) { - struct gsm_subscriber *sfound; + struct gprs_subscr *sfound; OSMO_ASSERT(subscr); OSMO_ASSERT(strcmp(subscr->imsi, imsi) == 0); sfound = gprs_subscr_get_by_imsi(imsi); OSMO_ASSERT(sfound == subscr); - subscr_put(sfound); + gprs_subscr_put(sfound); } static void show_subscrs(FILE *out) { - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; - llist_for_each_entry(subscr, &active_subscribers, entry) { + llist_for_each_entry(subscr, gprs_subscribers, entry) { fprintf(out, " Subscriber: %s, " "use count: %d\n", subscr->imsi, subscr->use_count); @@ -284,12 +284,18 @@ { show_subscrs(stdout); fflush(stdout); - OSMO_ASSERT(llist_empty(&active_subscribers)); + OSMO_ASSERT(llist_empty(gprs_subscribers)); } + +#define VERBOSE_ASSERT(val, expect_op, fmt) \ + do { \ + printf(#val " == " fmt "\n", (val)); \ + OSMO_ASSERT((val) expect_op); \ + } while (0); static void test_subscriber(void) { - struct gsm_subscriber *s1, *s2, *s3, *sfound; + struct gprs_subscr *s1, *s2, *s3; const char *imsi1 = "1234567890"; const char *imsi2 = "9876543210"; const char *imsi3 = "5656565656"; @@ -302,19 +308,24 @@ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d"); /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; assert_subscr(s1, imsi1); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); /* Allocate entry 2 */ s2 = gprs_subscr_get_or_create(imsi2); - s2->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d"); + s2->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; /* Allocate entry 3 */ s3 = gprs_subscr_get_or_create(imsi3); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 3, "%d"); /* Check entries */ assert_subscr(s1, imsi1); @@ -326,33 +337,35 @@ gprs_subscr_update(s1); OSMO_ASSERT(last_updated_subscr == NULL); OSMO_ASSERT(s1->sgsn_data->mm == NULL); - OSMO_ASSERT((s1->flags & GSM_SUBSCRIBER_FIRST_CONTACT) == 0); + OSMO_ASSERT((s1->flags & GPRS_SUBSCRIBER_FIRST_CONTACT) == 0); /* There is no subscriber cache. Verify it */ gprs_subscr_cleanup(s1); - subscr_put(s1); + gprs_subscr_put(s1); s1 = NULL; - sfound = gprs_subscr_get_by_imsi(imsi1); - OSMO_ASSERT(sfound == NULL); + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 2, "%d"); + OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); assert_subscr(s2, imsi2); assert_subscr(s3, imsi3); - /* Free entry 2 (GSM_SUBSCRIBER_FIRST_CONTACT is set) */ + /* Free entry 2 (GPRS_SUBSCRIBER_FIRST_CONTACT is set) */ gprs_subscr_cleanup(s2); - subscr_put(s2); + gprs_subscr_put(s2); s2 = NULL; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 1, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi2) == NULL); assert_subscr(s3, imsi3); /* Try to delete entry 3 */ gprs_subscr_cleanup(s3); - subscr_put(s3); + gprs_subscr_put(s3); s3 = NULL; + VERBOSE_ASSERT(llist_count(gprs_subscribers), == 0, "%d"); OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi3) == NULL); - OSMO_ASSERT(llist_empty(&active_subscribers)); + OSMO_ASSERT(llist_empty(gprs_subscribers)); update_subscriber_data_cb = __real_sgsn_update_subscriber_data; @@ -361,7 +374,7 @@ static void test_auth_triplets(void) { - struct gsm_subscriber *s1, *s1found; + struct gprs_subscr *s1, *s1found; const char *imsi1 = "1234567890"; struct gsm_auth_tuple *at; struct sgsn_mm_ctx *ctx; @@ -375,17 +388,17 @@ /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == s1); - subscr_put(s1found); + gprs_subscr_put(s1found); /* Create a context */ OSMO_ASSERT(count(gprs_llme_list()) == 0); ctx = alloc_mm_ctx(local_tlli, &raid); /* Attach s1 to ctx */ - ctx->subscr = subscr_get(s1); + ctx->subscr = gprs_subscr_get(s1); ctx->subscr->sgsn_data->mm = ctx; /* Try to get auth tuple */ @@ -414,7 +427,7 @@ OSMO_ASSERT(at == NULL); /* Free MM context and subscriber */ - subscr_put(s1); + gprs_subscr_put(s1); sgsn_mm_ctx_cleanup_free(ctx); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); @@ -441,7 +454,7 @@ static void test_subscriber_gsup(void) { - struct gsm_subscriber *s1, *s1found; + struct gprs_subscr *s1, *s1found; const char *imsi1 = "1234567890"; struct sgsn_mm_ctx *ctx; struct gprs_ra_id raid = { 0, }; @@ -563,17 +576,17 @@ /* Allocate entry 1 */ s1 = gprs_subscr_get_or_create(imsi1); - s1->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + s1->flags |= GPRS_SUBSCRIBER_FIRST_CONTACT; s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == s1); - subscr_put(s1found); + gprs_subscr_put(s1found); /* Create a context */ OSMO_ASSERT(count(gprs_llme_list()) == 0); ctx = alloc_mm_ctx(local_tlli, &raid); /* Attach s1 to ctx */ - ctx->subscr = subscr_get(s1); + ctx->subscr = gprs_subscr_get(s1); ctx->subscr->sgsn_data->mm = ctx; /* Inject SendAuthInfoReq GSUP message */ @@ -675,7 +688,7 @@ /* Free MM context and subscriber */ OSMO_ASSERT(ctx->subscr == NULL); sgsn_mm_ctx_cleanup_free(ctx); - subscr_put(s1); + gprs_subscr_put(s1); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); @@ -1090,7 +1103,7 @@ static void test_gmm_attach_subscr(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1101,7 +1114,7 @@ printf("Auth policy 'remote': "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1124,7 +1137,7 @@ static void test_gmm_attach_subscr_fake_auth(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1137,7 +1150,7 @@ printf("Auth policy 'remote', auth faked: "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1166,7 +1179,7 @@ static void test_gmm_attach_subscr_real_auth(void) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_location; @@ -1180,7 +1193,7 @@ printf("Auth policy 'remote', triplet based auth: "); test_gmm_attach(0); - subscr_put(subscr); + gprs_subscr_put(subscr); assert_no_subscrs(); sgsn->cfg.auth_policy = saved_auth_policy; @@ -1254,7 +1267,7 @@ static void test_gmm_attach_subscr_gsup_auth(int retry) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; subscr_request_update_location_cb = my_subscr_request_update_gsup_auth; @@ -1268,7 +1281,7 @@ subscr->authorized = 1; sgsn->cfg.require_authentication = 1; sgsn->cfg.require_update_location = 1; - subscr_put(subscr); + gprs_subscr_put(subscr); printf("Auth policy 'remote', GSUP based auth: "); test_gmm_attach(retry); @@ -1337,7 +1350,7 @@ static void test_gmm_attach_subscr_real_gsup_auth(int retry) { const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy; - struct gsm_subscriber *subscr; + struct gprs_subscr *subscr; sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE; gsup_client_send_cb = my_gsup_client_send; @@ -2228,7 +2241,7 @@ { struct apn_ctx *actxs[4]; struct sgsn_ggsn_ctx *ggc, *ggcs[3]; - struct gsm_subscriber *s1; + struct gprs_subscr *s1; const char *imsi1 = "1234567890"; struct sgsn_mm_ctx *ctx; struct gprs_ra_id raid = { 0, }; @@ -2347,7 +2360,7 @@ /* Cleanup */ - subscr_put(s1); + gprs_subscr_put(s1); sgsn_mm_ctx_cleanup_free(ctx); assert_no_subscrs(); diff --git a/openbsc/tests/sgsn/sgsn_test.ok b/openbsc/tests/sgsn/sgsn_test.ok index c7a53b9..f38d730 100644 --- a/openbsc/tests/sgsn/sgsn_test.ok +++ b/openbsc/tests/sgsn/sgsn_test.ok @@ -1,5 +1,13 @@ Testing LLME allocations Testing core subscriber data API +llist_count(gprs_subscribers) == 0 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 2 +llist_count(gprs_subscribers) == 3 +llist_count(gprs_subscribers) == 2 +llist_count(gprs_subscribers) == 1 +llist_count(gprs_subscribers) == 0 Testing authentication triplet handling Testing subscriber GSUP handling Testing GMM detach -- To view, visit https://gerrit.osmocom.org/1684 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia8b391ee009c8545763cba04505be3947835120e Gerrit-PatchSet: 10 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sat Feb 25 04:12:38 2017 From: gerrit-no-reply at lists.osmocom.org (Alexander Chemeris) Date: Sat, 25 Feb 2017 04:12:38 +0000 Subject: [PATCH] openbsc[master]: utils: 'meas_json' utility to convert measurement feed into ... In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1915 to look at the new patch set (#2). utils: 'meas_json' utility to convert measurement feed into a JSON feed. Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 --- M openbsc/src/utils/Makefile.am A openbsc/src/utils/meas_json.c 2 files changed, 206 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/15/1915/2 diff --git a/openbsc/src/utils/Makefile.am b/openbsc/src/utils/Makefile.am index 6fe840c..ab4f3ce 100644 --- a/openbsc/src/utils/Makefile.am +++ b/openbsc/src/utils/Makefile.am @@ -25,6 +25,7 @@ bin_PROGRAMS = \ bs11_config \ isdnsync \ + meas_json \ $(NULL) if HAVE_SQLITE3 bin_PROGRAMS += \ @@ -121,3 +122,19 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(NULL) + +meas_json_SOURCES = \ + meas_json.c \ + $(NULL) + +meas_json_LDADD = \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) + +meas_json_CFLAGS = \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(NULL) + diff --git a/openbsc/src/utils/meas_json.c b/openbsc/src/utils/meas_json.c new file mode 100644 index 0000000..93203bc --- /dev/null +++ b/openbsc/src/utils/meas_json.c @@ -0,0 +1,189 @@ +/* Convert measurement report feed into JSON feed printed to stdout. + * Each measurement report is printed as a separae JSON root entry. + * All measurement reports are separated by a new line. + */ + +/* (C) 2015 by Alexander Chemeris + * With parts of code adopted from different places in OpenBSC. + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +static void print_meas_rep_uni_json(struct gsm_meas_rep_unidir *mru) +{ + printf("\"RXL-FULL\":%d, \"RXL-SUB\":%d, ", + rxlev2dbm(mru->full.rx_lev), + rxlev2dbm(mru->sub.rx_lev)); + printf("\"RXQ-FULL\":%d, \"RXQ-SUB\":%d", + mru->full.rx_qual, mru->sub.rx_qual); +} + +static void print_meas_rep_json(struct gsm_meas_rep *mr) +{ + int i; + + printf("\"NR\":%d", mr->nr); + + if (mr->flags & MEAS_REP_F_DL_DTX) + printf(", \"DTXd\":true"); + + printf(", \"UL_MEAS\":{"); + print_meas_rep_uni_json(&mr->ul); + printf("}"); + printf(", \"BS_POWER\":%d", mr->bs_power); + if (mr->flags & MEAS_REP_F_MS_TO) + printf(", \"MS_TO\":%d", mr->ms_timing_offset); + + if (mr->flags & MEAS_REP_F_MS_L1) { + printf(", \"L1_MS_PWR\":%d", mr->ms_l1.pwr); + printf(", \"L1_FPC\":%s", + mr->flags & MEAS_REP_F_FPC ? "true" : "false"); + printf(", \"L1_TA\":%u", mr->ms_l1.ta); + } + + if (mr->flags & MEAS_REP_F_UL_DTX) + printf(", \"DTXu\":true"); + if (mr->flags & MEAS_REP_F_BA1) + printf(", \"BA1\":true"); + if (mr->flags & MEAS_REP_F_DL_VALID) { + printf(", \"DL_MEAS\":{"); + print_meas_rep_uni_json(&mr->dl); + printf("}"); + } + + if (mr->num_cell == 7) + return; + printf(", \"NUM_NEIGH\":%u, \"NEIGH\":[", mr->num_cell); + for (i = 0; i < mr->num_cell; i++) { + struct gsm_meas_rep_cell *mrc = &mr->cell[i]; + if (i!=0) printf(", "); + printf("\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d", + mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev)); + } + printf("]"); +} + +static void print_chan_info_json(struct meas_feed_meas *mfm) +{ + printf("\"lchan_type\":\"%s\", \"pchan_type\":\"%s\", " + "\"bts_nr\":%d, \"trx_nr\":%d, \"ts_nr\":%d, \"ss_nr\":%d", + gsm_lchant_name(mfm->lchan_type), gsm_pchan_name(mfm->pchan_type), + mfm->bts_nr, mfm->trx_nr, mfm->ts_nr, mfm->ss_nr); +} + +static void print_meas_feed_json(struct meas_feed_meas *mfm) +{ + time_t now = time(NULL); + + printf("{"); + printf("\"time\":%ld, \"imsi\":\"%s\", \"name\":\"%s\", \"scenario\":\"%s\", ", + now, mfm->imsi, mfm->name, mfm->scenario); + + switch (mfm->hdr.version) { + case 1: + printf("\"chan_info\":{"); + print_chan_info_json(mfm); + printf("}, "); + /* no break, fall to version 0 */ + case 0: + printf("\"meas_rep\":{"); + print_meas_rep_json(&mfm->mr); + printf("}"); + break; + } + + printf("}\n"); + +} + +static int handle_meas(struct msgb *msg) +{ + struct meas_feed_meas *mfm = (struct meas_feed_meas *) msgb_data(msg); + + print_meas_feed_json(mfm); + + return 0; +} + +static int handle_msg(struct msgb *msg) +{ + struct meas_feed_hdr *mfh = (struct meas_feed_hdr *) msgb_data(msg); + + if (mfh->version != MEAS_FEED_VERSION) + return -EINVAL; + + switch (mfh->msg_type) { + case MEAS_FEED_MEAS: + handle_meas(msg); + break; + default: + break; + } +} + +static int udp_fd_cb(struct osmo_fd *ofd, unsigned int what) +{ + int rc; + + if (what & BSC_FD_READ) { + struct msgb *msg = msgb_alloc(1024, "UDP Rx"); + + rc = read(ofd->fd, msgb_data(msg), msgb_tailroom(msg)); + if (rc < 0) + return rc; + msgb_put(msg, rc); + handle_msg(msg); + msgb_free(msg); + } + + return 0; +} + +int main(int argc, char **argv) +{ + int rc; + struct osmo_fd udp_ofd; + + udp_ofd.cb = udp_fd_cb; + rc = osmo_sock_init_ofd(&udp_ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 8888, OSMO_SOCK_F_BIND); + if (rc < 0) + exit(1); + + while (1) { + osmo_select_main(0); + }; + + exit(0); +} -- To view, visit https://gerrit.osmocom.org/1915 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Alexander Chemeris Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 25 05:05:44 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 25 Feb 2017 05:05:44 +0000 Subject: openbsc[master]: smpp_test_runner.py: fix socket leak In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1914 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 25 05:05:52 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 25 Feb 2017 05:05:52 +0000 Subject: openbsc[master]: vty_rest_runner.py: remove debug monitoring for TCP sockets In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 25 05:07:32 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Sat, 25 Feb 2017 05:07:32 +0000 Subject: openbsc[master]: utils: 'meas_json' utility to convert measurement feed into ... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/1915/2/openbsc/src/utils/meas_json.c File openbsc/src/utils/meas_json.c: Line 3: * All measurement reports are separated by a new line. I like summaries like this -- To view, visit https://gerrit.osmocom.org/1915 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Alexander Chemeris Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Sat Feb 25 05:23:22 2017 From: gerrit-no-reply at lists.osmocom.org (Alexander Chemeris) Date: Sat, 25 Feb 2017 05:23:22 +0000 Subject: [MERGED] openbsc[master]: utils: 'meas_json' utility to convert measurement feed into ... In-Reply-To: References: Message-ID: Alexander Chemeris has submitted this change and it was merged. Change subject: utils: 'meas_json' utility to convert measurement feed into a JSON feed. ...................................................................... utils: 'meas_json' utility to convert measurement feed into a JSON feed. Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 --- M openbsc/src/utils/Makefile.am A openbsc/src/utils/meas_json.c 2 files changed, 206 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/utils/Makefile.am b/openbsc/src/utils/Makefile.am index 6fe840c..ab4f3ce 100644 --- a/openbsc/src/utils/Makefile.am +++ b/openbsc/src/utils/Makefile.am @@ -25,6 +25,7 @@ bin_PROGRAMS = \ bs11_config \ isdnsync \ + meas_json \ $(NULL) if HAVE_SQLITE3 bin_PROGRAMS += \ @@ -121,3 +122,19 @@ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(NULL) + +meas_json_SOURCES = \ + meas_json.c \ + $(NULL) + +meas_json_LDADD = \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) \ + $(NULL) + +meas_json_CFLAGS = \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(NULL) + diff --git a/openbsc/src/utils/meas_json.c b/openbsc/src/utils/meas_json.c new file mode 100644 index 0000000..93203bc --- /dev/null +++ b/openbsc/src/utils/meas_json.c @@ -0,0 +1,189 @@ +/* Convert measurement report feed into JSON feed printed to stdout. + * Each measurement report is printed as a separae JSON root entry. + * All measurement reports are separated by a new line. + */ + +/* (C) 2015 by Alexander Chemeris + * With parts of code adopted from different places in OpenBSC. + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +static void print_meas_rep_uni_json(struct gsm_meas_rep_unidir *mru) +{ + printf("\"RXL-FULL\":%d, \"RXL-SUB\":%d, ", + rxlev2dbm(mru->full.rx_lev), + rxlev2dbm(mru->sub.rx_lev)); + printf("\"RXQ-FULL\":%d, \"RXQ-SUB\":%d", + mru->full.rx_qual, mru->sub.rx_qual); +} + +static void print_meas_rep_json(struct gsm_meas_rep *mr) +{ + int i; + + printf("\"NR\":%d", mr->nr); + + if (mr->flags & MEAS_REP_F_DL_DTX) + printf(", \"DTXd\":true"); + + printf(", \"UL_MEAS\":{"); + print_meas_rep_uni_json(&mr->ul); + printf("}"); + printf(", \"BS_POWER\":%d", mr->bs_power); + if (mr->flags & MEAS_REP_F_MS_TO) + printf(", \"MS_TO\":%d", mr->ms_timing_offset); + + if (mr->flags & MEAS_REP_F_MS_L1) { + printf(", \"L1_MS_PWR\":%d", mr->ms_l1.pwr); + printf(", \"L1_FPC\":%s", + mr->flags & MEAS_REP_F_FPC ? "true" : "false"); + printf(", \"L1_TA\":%u", mr->ms_l1.ta); + } + + if (mr->flags & MEAS_REP_F_UL_DTX) + printf(", \"DTXu\":true"); + if (mr->flags & MEAS_REP_F_BA1) + printf(", \"BA1\":true"); + if (mr->flags & MEAS_REP_F_DL_VALID) { + printf(", \"DL_MEAS\":{"); + print_meas_rep_uni_json(&mr->dl); + printf("}"); + } + + if (mr->num_cell == 7) + return; + printf(", \"NUM_NEIGH\":%u, \"NEIGH\":[", mr->num_cell); + for (i = 0; i < mr->num_cell; i++) { + struct gsm_meas_rep_cell *mrc = &mr->cell[i]; + if (i!=0) printf(", "); + printf("\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d", + mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev)); + } + printf("]"); +} + +static void print_chan_info_json(struct meas_feed_meas *mfm) +{ + printf("\"lchan_type\":\"%s\", \"pchan_type\":\"%s\", " + "\"bts_nr\":%d, \"trx_nr\":%d, \"ts_nr\":%d, \"ss_nr\":%d", + gsm_lchant_name(mfm->lchan_type), gsm_pchan_name(mfm->pchan_type), + mfm->bts_nr, mfm->trx_nr, mfm->ts_nr, mfm->ss_nr); +} + +static void print_meas_feed_json(struct meas_feed_meas *mfm) +{ + time_t now = time(NULL); + + printf("{"); + printf("\"time\":%ld, \"imsi\":\"%s\", \"name\":\"%s\", \"scenario\":\"%s\", ", + now, mfm->imsi, mfm->name, mfm->scenario); + + switch (mfm->hdr.version) { + case 1: + printf("\"chan_info\":{"); + print_chan_info_json(mfm); + printf("}, "); + /* no break, fall to version 0 */ + case 0: + printf("\"meas_rep\":{"); + print_meas_rep_json(&mfm->mr); + printf("}"); + break; + } + + printf("}\n"); + +} + +static int handle_meas(struct msgb *msg) +{ + struct meas_feed_meas *mfm = (struct meas_feed_meas *) msgb_data(msg); + + print_meas_feed_json(mfm); + + return 0; +} + +static int handle_msg(struct msgb *msg) +{ + struct meas_feed_hdr *mfh = (struct meas_feed_hdr *) msgb_data(msg); + + if (mfh->version != MEAS_FEED_VERSION) + return -EINVAL; + + switch (mfh->msg_type) { + case MEAS_FEED_MEAS: + handle_meas(msg); + break; + default: + break; + } +} + +static int udp_fd_cb(struct osmo_fd *ofd, unsigned int what) +{ + int rc; + + if (what & BSC_FD_READ) { + struct msgb *msg = msgb_alloc(1024, "UDP Rx"); + + rc = read(ofd->fd, msgb_data(msg), msgb_tailroom(msg)); + if (rc < 0) + return rc; + msgb_put(msg, rc); + handle_msg(msg); + msgb_free(msg); + } + + return 0; +} + +int main(int argc, char **argv) +{ + int rc; + struct osmo_fd udp_ofd; + + udp_ofd.cb = udp_fd_cb; + rc = osmo_sock_init_ofd(&udp_ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, 8888, OSMO_SOCK_F_BIND); + if (rc < 0) + exit(1); + + while (1) { + osmo_select_main(0); + }; + + exit(0); +} -- To view, visit https://gerrit.osmocom.org/1915 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Alexander Chemeris Gerrit-Reviewer: Alexander Chemeris Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 25 12:48:19 2017 From: gerrit-no-reply at lists.osmocom.org (Keith Whyte) Date: Sat, 25 Feb 2017 12:48:19 +0000 Subject: [PATCH] openbsc[master]: meas_json: Make NEIGH an array of Javascript objects, otherw... Message-ID: Review at https://gerrit.osmocom.org/1916 meas_json: Make NEIGH an array of Javascript objects, otherwise the JSON is not parseable when neighbours exist Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 --- M openbsc/src/utils/meas_json.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/16/1916/1 diff --git a/openbsc/src/utils/meas_json.c b/openbsc/src/utils/meas_json.c index 93203bc..2d7a9e8 100644 --- a/openbsc/src/utils/meas_json.c +++ b/openbsc/src/utils/meas_json.c @@ -89,7 +89,7 @@ for (i = 0; i < mr->num_cell; i++) { struct gsm_meas_rep_cell *mrc = &mr->cell[i]; if (i!=0) printf(", "); - printf("\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d", + printf("{\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d}", mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev)); } printf("]"); -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte From gerrit-no-reply at lists.osmocom.org Sat Feb 25 14:30:02 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 14:30:02 +0000 Subject: [PATCH] openbsc[master]: meas_json: fix NEIGH: missing array braces In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1916 to look at the new patch set (#2). meas_json: fix NEIGH: missing array braces Make NEIGH an array of Javascript objects, otherwise the JSON is not parseable when neighbours exist Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 --- M openbsc/src/utils/meas_json.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/16/1916/2 diff --git a/openbsc/src/utils/meas_json.c b/openbsc/src/utils/meas_json.c index 93203bc..2d7a9e8 100644 --- a/openbsc/src/utils/meas_json.c +++ b/openbsc/src/utils/meas_json.c @@ -89,7 +89,7 @@ for (i = 0; i < mr->num_cell; i++) { struct gsm_meas_rep_cell *mrc = &mr->cell[i]; if (i!=0) printf(", "); - printf("\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d", + printf("{\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d}", mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev)); } printf("]"); -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Sat Feb 25 14:30:23 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 14:30:23 +0000 Subject: openbsc[master]: meas_json: fix NEIGH: missing array braces In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 tweaked the commit log to have a short summary on the first line -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 25 17:03:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 17:03:18 +0000 Subject: openbsc[master]: python tests: remove process 'Launch' message, now at osmoutil In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1913 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Sat Feb 25 17:04:09 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 17:04:09 +0000 Subject: [MERGED] openbsc[master]: python tests: remove process 'Launch' message, now at osmoutil In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: python tests: remove process 'Launch' message, now at osmoutil ...................................................................... python tests: remove process 'Launch' message, now at osmoutil Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee --- M openbsc/tests/ctrl_test_runner.py M openbsc/tests/smpp_test_runner.py M openbsc/tests/vty_test_runner.py 3 files changed, 0 insertions(+), 3 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 9050c09..a115488 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -49,7 +49,6 @@ osmo_ctrl_cmd[cfi] = os.path.join(confpath, osmo_ctrl_cmd[cfi]) try: - print "Launch: %s from %s" % (' '.join(osmo_ctrl_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_ctrl_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py index 9dc0d13..b6da86c 100644 --- a/openbsc/tests/smpp_test_runner.py +++ b/openbsc/tests/smpp_test_runner.py @@ -43,7 +43,6 @@ osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi]) try: - print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_vty_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index ca4b276..821c6d3 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -45,7 +45,6 @@ osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi]) try: - print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd()) self.proc = osmoutil.popen_devnull(osmo_vty_cmd) except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() -- To view, visit https://gerrit.osmocom.org/1913 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sat Feb 25 17:04:09 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 17:04:09 +0000 Subject: [MERGED] openbsc[master]: vty_rest_runner.py: remove debug monitoring for TCP sockets In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: vty_rest_runner.py: remove debug monitoring for TCP sockets ...................................................................... vty_rest_runner.py: remove debug monitoring for TCP sockets Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8 --- M openbsc/tests/vty_test_runner.py 1 file changed, 0 insertions(+), 22 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 8b17397..ca4b276 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1240,19 +1240,6 @@ " connected yet: %r %r" % (ip, port)) return conn -def cmd(what): - print '\n> %s' % what - sys.stdout.flush() - subprocess.call(what, shell=True) - sys.stdout.flush() - sys.stderr.flush() - print '' - sys.stdout.flush() - -def checkxxx(): - cmd('cat /proc/net/tcp'); - cmd('ps xua | grep osmo'); - def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) if len(s) != 4*2: @@ -1277,10 +1264,6 @@ if "0023fe040108010701020103010401050101010011" in s: retries = 3 while True: - if proc: - print "\tproc.poll() = %r" % proc.poll() - print "\tproc.pid = %r" % proc.pid - checkxxx() print "\tsending IPA identity(%s) at %s" % (tk, time.strftime("%T")) try: x.send(IPA().id_resp(IPA().identity(name = tk.encode('utf-8')))) @@ -1313,19 +1296,14 @@ if proc: print "\tproc.poll() = %r" % proc.poll() print "\tproc.pid = %r" % proc.pid - checkxxx() ipa_handle_small(bsc, verbose) - checkxxx() ipa_handle_resp(bsc, tk, verbose, proc=proc) if proc: print "\tproc.poll() = %r" % proc.poll() - checkxxx() bsc.recv(27) # MGCP msg if proc: print "\tproc.poll() = %r" % proc.poll() - checkxxx() ipa_handle_small(bsc, verbose) - checkxxx() return bsc def add_bsc_test(suite, workdir): -- To view, visit https://gerrit.osmocom.org/1912 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Sat Feb 25 18:07:18 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Sat, 25 Feb 2017 18:07:18 +0000 Subject: [MERGED] openbsc[master]: smpp_test_runner.py: fix socket leak In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: smpp_test_runner.py: fix socket leak ...................................................................... smpp_test_runner.py: fix socket leak Each running test would open up another socket without ever closing unused ones. Close the sockets after each test is done. Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af --- M openbsc/tests/smpp_test_runner.py 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py index b6da86c..4527ac4 100644 --- a/openbsc/tests/smpp_test_runner.py +++ b/openbsc/tests/smpp_test_runner.py @@ -54,6 +54,8 @@ self.vty = obscvty.VTYInteract(appstring, "127.0.0.1", appport) def tearDown(self): + if self.vty: + self.vty._close_socket() self.vty = None osmoutil.end_proc(self.proc) -- To view, visit https://gerrit.osmocom.org/1914 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:31 +0000 Subject: [PATCH] python/osmo-python-tests[master]: tcp debugging: allow switching on TCP debug by env var Message-ID: Review at https://gerrit.osmocom.org/1917 tcp debugging: allow switching on TCP debug by env var Print monitoring info about TCP sockets when the env var OSMOPY_DEBUG_TCP_SOCKETS is present. Makes it easy to enable it on jenkins without blowing up output of normal runs "at home". Change-Id: I46212d07a2c1be05672a37766457e6c98b68f90d --- M osmopy/obscvty.py 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/17/1917/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index e4df57d..f369527 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -19,6 +19,7 @@ import re import socket import sys, subprocess +import os """VTYInteract: interact with an osmocom vty @@ -26,7 +27,7 @@ Connections will be reestablished as necessary. Methods: __init__, command, enabled_command, verify, w_verify""" -debug_tcp_sockets = False +debug_tcp_sockets = 'OSMOPY_DEBUG_TCP_SOCKETS' in os.environ def cmd(what): print '\n> %s' % what -- To view, visit https://gerrit.osmocom.org/1917 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I46212d07a2c1be05672a37766457e6c98b68f90d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:31 +0000 Subject: [PATCH] python/osmo-python-tests[master]: debug: also output nr of open file descriptors for 'tcp debug' Message-ID: Review at https://gerrit.osmocom.org/1918 debug: also output nr of open file descriptors for 'tcp debug' Change-Id: I8a583df549f3e2b79068fd8cd32b75473539410d --- M osmopy/obscvty.py 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/18/1918/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index f369527..a517a5f 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -41,6 +41,7 @@ def print_used_tcp_sockets(): if not debug_tcp_sockets: return + cmd('ls /proc/self/fd'); cmd('ss -tn'); cmd('ss -tln'); cmd('ps xua | grep osmo'); -- To view, visit https://gerrit.osmocom.org/1918 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8a583df549f3e2b79068fd8cd32b75473539410d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:31 +0000 Subject: [PATCH] python/osmo-python-tests[master]: debug_tcp_sockets: clearly mark as global var Message-ID: Review at https://gerrit.osmocom.org/1919 debug_tcp_sockets: clearly mark as global var Change-Id: I56e26590ea380c7deab7ce132d688b37eb2d11a3 --- M osmopy/obscvty.py 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/19/1919/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index a517a5f..b09d108 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -39,6 +39,7 @@ sys.stdout.flush() def print_used_tcp_sockets(): + global debug_tcp_sockets if not debug_tcp_sockets: return cmd('ls /proc/self/fd'); @@ -68,6 +69,7 @@ self.last_node = '' def _close_socket(self): + global debug_tcp_sockets if self.socket: if debug_tcp_sockets: VTYInteract.all_sockets.remove(self.socket) @@ -131,6 +133,7 @@ return 0 def _common_command(self, request, close=False, ends=None): + global debug_tcp_sockets if not ends: ends = [self.norm_end, self.priv_end] if not self.socket: -- To view, visit https://gerrit.osmocom.org/1919 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I56e26590ea380c7deab7ce132d688b37eb2d11a3 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:31 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:31 +0000 Subject: [PATCH] python/osmo-python-tests[master]: cosmetic: early exit instead of if-cascade Message-ID: Review at https://gerrit.osmocom.org/1920 cosmetic: early exit instead of if-cascade It appears that during some error conditions, the socket will not be in the tcp socket debug tracking list, and on top of an exception this barfs as well. Let's not care about the tcp debug list and avoid confusing error messages. Change-Id: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44 --- M osmopy/obscvty.py 1 file changed, 10 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/20/1920/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index b09d108..420db7d 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -70,14 +70,16 @@ def _close_socket(self): global debug_tcp_sockets - if self.socket: - if debug_tcp_sockets: - VTYInteract.all_sockets.remove(self.socket) - print "Socket: closing %s:%d %r (%d sockets open)" % ( - self.host, self.port, self.socket, - len(VTYInteract.all_sockets)) - self.socket.close() - self.socket = None + if self.socket is None: + return + + if debug_tcp_sockets: + VTYInteract.all_sockets.remove(self.socket) + print "Socket: closing %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) + self.socket.close() + self.socket = None def _is_end(self, text, ends): """ -- To view, visit https://gerrit.osmocom.org/1920 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:32 +0000 Subject: [PATCH] python/osmo-python-tests[master]: tcp_debug: don't abort when socket can't be removed Message-ID: Review at https://gerrit.osmocom.org/1921 tcp_debug: don't abort when socket can't be removed It appears that during some error conditions, the socket will not be in the tcp socket debug tracking list, and on top of an exception this barfs as well. Let's not care about the tcp debug list and avoid confusing error messages. Change-Id: I8daa317fed8fc7e720dccb70fd5f7fc74fde423f --- M osmopy/obscvty.py 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/21/1921/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 420db7d..cb2d06f 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -74,7 +74,10 @@ return if debug_tcp_sockets: - VTYInteract.all_sockets.remove(self.socket) + try: + VTYInteract.all_sockets.remove(self.socket) + except ValueError: + pass print "Socket: closing %s:%d %r (%d sockets open)" % ( self.host, self.port, self.socket, len(VTYInteract.all_sockets)) -- To view, visit https://gerrit.osmocom.org/1921 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8daa317fed8fc7e720dccb70fd5f7fc74fde423f Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:32 +0000 Subject: [PATCH] python/osmo-python-tests[master]: on Exception during test, also print the actual config Message-ID: Review at https://gerrit.osmocom.org/1922 on Exception during test, also print the actual config When a test run encounters an Exception, the test config file name is printed, but that may already be gone when done, so also print the complete actual test config file contents, making it easy to reproduce the failure manually. Change-Id: I9b00f170fb0cdceb35b9231eb1f2c545ba079d1d --- M osmopy/osmotestconfig.py 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/22/1922/1 diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 0d2b2d9..9389647 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -65,6 +65,7 @@ print >> sys.stderr, "Failed to verify %s" % ' '.join(cmd) print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Error was %s" % se + print >> sys.stderr, "Config was\n%s" % open(config).read() raise se finally: -- To view, visit https://gerrit.osmocom.org/1922 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b00f170fb0cdceb35b9231eb1f2c545ba079d1d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:32 +0000 Subject: [PATCH] python/osmo-python-tests[master]: cosmetic: put socket connection code in separate function Message-ID: Review at https://gerrit.osmocom.org/1923 cosmetic: put socket connection code in separate function Prepare for upcoming patch that adds connection retries to speed up tests. Change-Id: I2dddf8794b4241898373178c8a1aa2e98b01095c --- M osmopy/obscvty.py 1 file changed, 15 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/23/1923/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index cb2d06f..1f9db09 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -68,6 +68,19 @@ self.priv_end = re.compile('\r\n%s(?:\(([\w-]*)\))?# $' % self.name) self.last_node = '' + def _connect_socket(self): + if self.socket is not None: + return + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.socket.setblocking(1) + self.socket.connect((self.host, self.port)) + if debug_tcp_sockets: + VTYInteract.all_sockets.append(self.socket) + print "Socket: connected to %s:%d %r (%d sockets open)" % ( + self.host, self.port, self.socket, + len(VTYInteract.all_sockets)) + self.socket.recv(4096) + def _close_socket(self): global debug_tcp_sockets if self.socket is None: @@ -141,16 +154,8 @@ global debug_tcp_sockets if not ends: ends = [self.norm_end, self.priv_end] - if not self.socket: - self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.socket.setblocking(1) - self.socket.connect((self.host, self.port)) - if debug_tcp_sockets: - VTYInteract.all_sockets.append(self.socket) - print "Socket: connected to %s:%d %r (%d sockets open)" % ( - self.host, self.port, self.socket, - len(VTYInteract.all_sockets)) - self.socket.recv(4096) + + self._connect_socket() # Now send the command self.socket.send("%s\r" % request) -- To view, visit https://gerrit.osmocom.org/1923 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2dddf8794b4241898373178c8a1aa2e98b01095c Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:32 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:32 +0000 Subject: [PATCH] python/osmo-python-tests[master]: speed up python tests more than 10 fold by sleeping less Message-ID: Review at https://gerrit.osmocom.org/1924 speed up python tests more than 10 fold by sleeping less The VTYInteract tests gave a constant sleep(1) grace period for the process to startup. This caused the test to take minutes for no reason at all. Add code to VTYInteract._connect_socket() to try and connect right away, retrying up to three seconds in .1 second intervals. This flies through most tests without any sleep() at all. When TCP socket debugging is switched on, also print how many connection tries it took to connect the VTY socket. Note that the openbsc python tests also add some sleep()s that also need to be removed to benefit from this. Change-Id: Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 --- M osmopy/obscvty.py M osmopy/osmodumpdoc.py M osmopy/osmotestconfig.py M osmopy/osmotestvty.py 4 files changed, 22 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/24/1924/1 diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 1f9db09..e5a953d 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -20,6 +20,7 @@ import socket import sys, subprocess import os +import time """VTYInteract: interact with an osmocom vty @@ -71,13 +72,29 @@ def _connect_socket(self): if self.socket is not None: return - self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.socket.setblocking(1) - self.socket.connect((self.host, self.port)) + retries = 30 + took = 0 + while True: + took += 1 + try: + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.socket.setblocking(1) + self.socket.connect((self.host, self.port)) + except IOError: + retries -= 1 + if retries <= 0: + raise + # possibly the binary hasn't launched yet + if debug_tcp_sockets: + print "Connecting socket failed, retrying..." + time.sleep(.1) + continue + break + if debug_tcp_sockets: VTYInteract.all_sockets.append(self.socket) - print "Socket: connected to %s:%d %r (%d sockets open)" % ( - self.host, self.port, self.socket, + print "Socket: in %d tries, connected to %s:%d %r (%d sockets open)" % ( + took, self.host, self.port, self.socket, len(VTYInteract.all_sockets)) self.socket.recv(4096) diff --git a/osmopy/osmodumpdoc.py b/osmopy/osmodumpdoc.py index d9d52b5..0ff1f6b 100644 --- a/osmopy/osmodumpdoc.py +++ b/osmopy/osmodumpdoc.py @@ -48,7 +48,6 @@ print >> sys.stderr, "Skipping app %s" % appname failures += 1 else: - time.sleep(1) try: dump_doc(app[2], app[0], 'doc/%s_vty_reference.xml' % appname) successes += 1 diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 9389647..5e19a40 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -55,7 +55,6 @@ print "Verifying %s, test %s" % (' '.join(cmd), run_test.__name__) proc = osmoutil.popen_devnull(cmd) - time.sleep(1) end = app_desc[2] port = app_desc[0] vty = obscvty.VTYInteract(end, "127.0.0.1", port) diff --git a/osmopy/osmotestvty.py b/osmopy/osmotestvty.py index 9f8dd0a..e513c05 100644 --- a/osmopy/osmotestvty.py +++ b/osmopy/osmotestvty.py @@ -41,7 +41,6 @@ except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Consider setting -b" - time.sleep(1) appstring = osmoappdesc.vty_app[2] appport = osmoappdesc.vty_app[0] -- To view, visit https://gerrit.osmocom.org/1924 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:13:33 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:13:33 +0000 Subject: [PATCH] python/osmo-python-tests[master]: test_all_apps: actually count nr of errors Message-ID: Review at https://gerrit.osmocom.org/1925 test_all_apps: actually count nr of errors Each test run returns 1 on error, so instead of |=, why not count the number of errors with +=. Also print the final error count. Change-Id: I690dde3711555a3447e5ad4cc0a04a7a869a8296 --- M osmopy/osmotestconfig.py 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/25/1925/1 diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 5e19a40..2132c43 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -172,11 +172,13 @@ configs = app_configs[app[3]] for config in configs: config = os.path.join(confpath, config) - errors |= test_config(app, config, tmpdir, verbose) + errors += test_config(app, config, tmpdir, verbose) if rmtmp or not errors: remove_tmpdir(tmpdir) + if errors: + print >> sys.stderr, "ERRORS: %d" % errors return errors -- To view, visit https://gerrit.osmocom.org/1925 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I690dde3711555a3447e5ad4cc0a04a7a869a8296 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:15:12 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:15:12 +0000 Subject: [PATCH] openbsc[master]: ctrl_test_runner: speed up more than 10 fold by sleeping less Message-ID: Review at https://gerrit.osmocom.org/1926 ctrl_test_runner: speed up more than 10 fold by sleeping less Similar to a recent patch in osmo-python-tests for VTY based tests, but this is for the Ctrl tests. The TestCtrlBase tests gave a constant sleep(2) grace period for the process to startup. This causes tests to take minutes for no reason at all. Add code to TestCtrlBase to try and connect right away, retrying up to three seconds in .1 second intervals. This flies through most tests without any sleep() at all. Change-Id: I06569767153838bd9cd3edac001df5f6c567874c --- M openbsc/tests/ctrl_test_runner.py 1 file changed, 13 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/26/1926/1 diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index a115488..5030e8b 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -86,9 +86,19 @@ if verbose: print "Connecting to host %s:%i" % (host, port) - sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sck.setblocking(1) - sck.connect((host, port)) + retries = 30 + while True: + try: + sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sck.setblocking(1) + sck.connect((host, port)) + except IOError: + retries -= 1 + if retries <= 0: + raise + time.sleep(.1) + continue + break self.sock = sck return sck -- To view, visit https://gerrit.osmocom.org/1926 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06569767153838bd9cd3edac001df5f6c567874c Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:15:13 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:15:13 +0000 Subject: [PATCH] openbsc[master]: python tests: vty and smpp: speed up >10 times Message-ID: Review at https://gerrit.osmocom.org/1927 python tests: vty and smpp: speed up >10 times osmo-python-tests now includes code that retries connecting the VTY socket and needs no external sleep()ing. This flies through most tests without any sleep() at all. See osmo-python-tests.git change-id Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a --- M openbsc/tests/smpp_test_runner.py M openbsc/tests/vty_test_runner.py 2 files changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/27/1927/1 diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py index 4527ac4..06fb766 100644 --- a/openbsc/tests/smpp_test_runner.py +++ b/openbsc/tests/smpp_test_runner.py @@ -47,7 +47,6 @@ except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Consider setting -b" - time.sleep(1) appstring = self.vty_app()[2] appport = self.vty_app()[0] diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 821c6d3..ba3db97 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -49,7 +49,6 @@ except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Consider setting -b" - time.sleep(1) appstring = self.vty_app()[2] appport = self.vty_app()[0] -- To view, visit https://gerrit.osmocom.org/1927 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:15:47 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:15:47 +0000 Subject: python/osmo-python-tests[master]: tcp debugging: allow switching on TCP debug by env var In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1917 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I46212d07a2c1be05672a37766457e6c98b68f90d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:01 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:01 +0000 Subject: python/osmo-python-tests[master]: debug: also output nr of open file descriptors for 'tcp debug' In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1918 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8a583df549f3e2b79068fd8cd32b75473539410d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:05 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:05 +0000 Subject: python/osmo-python-tests[master]: debug_tcp_sockets: clearly mark as global var In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1919 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I56e26590ea380c7deab7ce132d688b37eb2d11a3 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:08 +0000 Subject: python/osmo-python-tests[master]: cosmetic: early exit instead of if-cascade In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1920 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:12 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:12 +0000 Subject: python/osmo-python-tests[master]: tcp_debug: don't abort when socket can't be removed In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1921 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8daa317fed8fc7e720dccb70fd5f7fc74fde423f Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:16 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:16 +0000 Subject: python/osmo-python-tests[master]: on Exception during test, also print the actual config In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1922 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9b00f170fb0cdceb35b9231eb1f2c545ba079d1d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:20 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:20 +0000 Subject: python/osmo-python-tests[master]: cosmetic: put socket connection code in separate function In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1923 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2dddf8794b4241898373178c8a1aa2e98b01095c Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:24 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:24 +0000 Subject: python/osmo-python-tests[master]: speed up python tests more than 10 fold by sleeping less In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1924 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:16:35 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:16:35 +0000 Subject: python/osmo-python-tests[master]: test_all_apps: actually count nr of errors In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1925 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I690dde3711555a3447e5ad4cc0a04a7a869a8296 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:43:07 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:43:07 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: end_proc: speed up tests yet a bit more Message-ID: Review at https://gerrit.osmocom.org/1928 osmoutil: end_proc: speed up tests yet a bit more Recent commit b59b677c9b13483aac72b15f4f797863d841d958 called proc.terminate() instead of killing right away, with a .1 second sleep. Reduce this sleep to unnoticeable 0.01 seconds -- for me, all tests terminate, no kill is needed. Print a message only in case of kill, the "Terminated child process" message was bloating the log. Change-Id: I6fd520bae81be129e23a48e3daa122e6bae5630d --- M osmopy/osmoutil.py 1 file changed, 4 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/28/1928/1 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 01f74cc..cb3cb6a 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -46,13 +46,12 @@ return proc.terminate() - time.sleep(.1) + time.sleep(.01) rc = proc.poll() - if rc is not None: - print "Terminated child process" - else: - proc.kill() + if rc is None: + # termination seems to be slower than that, let's just kill print "Killed child process" + proc.kill() proc.wait() -- To view, visit https://gerrit.osmocom.org/1928 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6fd520bae81be129e23a48e3daa122e6bae5630d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:44:27 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:44:27 +0000 Subject: openbsc[master]: python tests: vty and smpp: speed up >10 times In-Reply-To: References: Message-ID: Patch Set 1: will probably be fixed by osmo-python-tests Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 -- To view, visit https://gerrit.osmocom.org/1927 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 01:44:54 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 01:44:54 +0000 Subject: python/osmo-python-tests[master]: osmoutil: end_proc: speed up tests yet a bit more In-Reply-To: References: Message-ID: Patch Set 1: Verified+1 -- To view, visit https://gerrit.osmocom.org/1928 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6fd520bae81be129e23a48e3daa122e6bae5630d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 08:58:52 2017 From: gerrit-no-reply at lists.osmocom.org (Jovan Bunjevacki) Date: Mon, 27 Feb 2017 08:58:52 +0000 Subject: [PATCH] openggsn[master]: Code formatted to be in line with formatting rules. In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1902 to look at the new patch set (#2). Code formatted to be in line with formatting rules. Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 --- M sgsnemu/sgsnemu.c 1 file changed, 34 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openggsn refs/changes/02/1902/2 diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index a4d6461..1567e7e 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -70,7 +70,7 @@ /* 3: Done */ /* 4: Wait_disconnect */ /* 5: Disconnected */ -int state = 0; +volatile sig_atomic_t state = 0; struct gsn_t *gsn = NULL; /* GSN instance */ struct tun_t *tun = NULL; /* TUN instance */ @@ -153,6 +153,12 @@ int tsum = 0; int pingseq = 0; /* Ping sequence counter */ struct timeval firstping; + +void signal_handler(int signo) +{ + if (state == 2) + state = 3; /* Tell main loop to finish. */ +} int ipset(struct iphash_t *ipaddr, struct in_addr *addr) { @@ -1417,10 +1423,15 @@ int starttime = time(NULL); /* Time program was started */ int stoptime = 0; /* Time to exit */ int pingtimeout = 0; /* Time to print ping statistics */ + int signal_received; /* If select() on fd_set is interrupted by signal. */ struct timezone tz; /* Used for calculating ping times */ struct timeval tv; int diff; + + signal(SIGTERM, signal_handler); + signal(SIGHUP, signal_handler); + signal(SIGINT, signal_handler); osmo_init_logging(&log_info); @@ -1676,10 +1687,14 @@ printf("idletime.tv_sec %d, idleTime.tv_usec %d\n", (int)idleTime.tv_sec, (int)idleTime.tv_usec); + signal_received = 0; switch (select(maxfd + 1, &fds, NULL, NULL, &idleTime)) { case -1: - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "Select returned -1"); + if (errno == EINTR) + signal_received = 1; + else + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "Select returned -1"); break; case 0: gtp_retrans(gsn); /* Only retransmit if nothing else */ @@ -1688,19 +1703,23 @@ break; } - if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "TUN decaps failed"); + if (!signal_received) { + + if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "TUN decaps failed"); + } + + if (FD_ISSET(gsn->fd0, &fds)) + gtp_decaps0(gsn); + + if (FD_ISSET(gsn->fd1c, &fds)) + gtp_decaps1c(gsn); + + if (FD_ISSET(gsn->fd1u, &fds)) + gtp_decaps1u(gsn); + } - - if (FD_ISSET(gsn->fd0, &fds)) - gtp_decaps0(gsn); - - if (FD_ISSET(gsn->fd1c, &fds)) - gtp_decaps1c(gsn); - - if (FD_ISSET(gsn->fd1u, &fds)) - gtp_decaps1u(gsn); } gtp_free(gsn); /* Clean up the gsn instance */ -- To view, visit https://gerrit.osmocom.org/1902 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Jovan Bunjevacki From gerrit-no-reply at lists.osmocom.org Mon Feb 27 09:55:57 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Mon, 27 Feb 2017 09:55:57 +0000 Subject: [PATCH] libosmocore[master]: Export comp128 v2 and v3 routines as well Message-ID: Review at https://gerrit.osmocom.org/1929 Export comp128 v2 and v3 routines as well It is in the public header file and allows to easily bind it from other languages (without having to go through the abstraction). Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2 --- M src/gsm/libosmogsm.map 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/1929/1 diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 78e55df..5f2fb8f 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -34,6 +34,8 @@ osmo_c4; bitvec_add_range1024; comp128; +comp128v2; +comp128v3; dbm2rxlev; osmo_earfcn_add; -- To view, visit https://gerrit.osmocom.org/1929 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Holger Freyther From gerrit-no-reply at lists.osmocom.org Mon Feb 27 12:17:54 2017 From: gerrit-no-reply at lists.osmocom.org (Keith Whyte) Date: Mon, 27 Feb 2017 12:17:54 +0000 Subject: [PATCH] openbsc[master]: meas_json: fix NEIGH: missing array braces In-Reply-To: References: Message-ID: Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1916 to look at the new patch set (#3). meas_json: fix NEIGH: missing array braces Make NEIGH an array of Javascript objects, otherwise the JSON is not parseable when neighbours exist Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 --- M openbsc/src/utils/meas_json.c 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/16/1916/3 diff --git a/openbsc/src/utils/meas_json.c b/openbsc/src/utils/meas_json.c index 93203bc..51eb6c7 100644 --- a/openbsc/src/utils/meas_json.c +++ b/openbsc/src/utils/meas_json.c @@ -89,7 +89,7 @@ for (i = 0; i < mr->num_cell; i++) { struct gsm_meas_rep_cell *mrc = &mr->cell[i]; if (i!=0) printf(", "); - printf("\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d", + printf("{\"IDX\":%u, \"ARFCN\":%u, \"BSIC\":%u, \"POWER\":%d}", mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev)); } printf("]"); @@ -151,6 +151,7 @@ default: break; } + return 0; } static int udp_fd_cb(struct osmo_fd *ofd, unsigned int what) -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 14:29:41 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 14:29:41 +0000 Subject: [MERGED] openbsc[master]: SGSN: Integrate support for UMTS AKA In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: SGSN: Integrate support for UMTS AKA ...................................................................... SGSN: Integrate support for UMTS AKA The general infrastructure for UMTS AKA is already in place: * GSUP with capability to send us auth_vectors that contain either triplets or quintuples * mm_context that holds such auth_vectors Add: * capability to send UMTS AUTN in GMM AUTH REQ * parse extended UMTS RES * on auth response, validate expected AKA with vector and received res/sres * add Auth Failure message to receive resync AUTS token and * send to HLR * clear out-of-sync auth tuple * enter new state for when we're waiting for HLR to resync and send new tuples so that the next Auth Request will be handled Original first half of this patch by: Harald Welte Full UMTS AKA procedure including AUTS resync tested to work against OsmoHLR with R99 USIM and Milenage algorithm. The sgsn_test.c needs adjustment because we're checking the vector's auth_types now. Depends: libosmocore change-ids I277fb3d407396dffa5c07a9c5454d87a415d393f If943731a78089f0aac3d55245de80596d01314a4 Related: OS#1956 Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_subscriber.c M openbsc/src/gprs/sgsn_auth.c M openbsc/tests/sgsn/sgsn_test.c 5 files changed, 205 insertions(+), 30 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index c3cac7f..fd86174 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -73,6 +73,7 @@ enum sgsn_auth_state { SGSN_AUTH_UNKNOWN, SGSN_AUTH_AUTHENTICATE, + SGSN_AUTH_UMTS_RESYNC, SGSN_AUTH_ACCEPTED, SGSN_AUTH_REJECTED }; @@ -446,7 +447,11 @@ int gprs_subscr_init(struct sgsn_instance *sgi); int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx); -int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx); +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand); +int gprs_subscr_auth_sync(struct gprs_subscr *subscr, + const uint8_t *auts, const uint8_t *auts_rand); void gprs_subscr_cleanup(struct gprs_subscr *subscr); struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi); struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx( struct sgsn_mm_ctx *mmctx); diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 9efe402..3f59a2b 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -83,6 +83,8 @@ [GSM48_IE_GMM_PTMSI_SIG] = { TLV_TYPE_FIXED, 3 }, [GSM48_IE_GMM_AUTH_RAND] = { TLV_TYPE_FIXED, 16 }, [GSM48_IE_GMM_AUTH_SRES] = { TLV_TYPE_FIXED, 4 }, + [GSM48_IE_GMM_AUTH_RES_EXT] = { TLV_TYPE_TLV, 0 }, + [GSM48_IE_GMM_AUTH_FAIL_PAR] = { TLV_TYPE_TLV, 0 }, [GSM48_IE_GMM_IMEISV] = { TLV_TYPE_TLV, 0 }, [GSM48_IE_GMM_DRX_PARAM] = { TLV_TYPE_FIXED, 2 }, [GSM48_IE_GMM_MS_NET_CAPA] = { TLV_TYPE_TLV, 0 }, @@ -554,8 +556,19 @@ return gsm48_gmm_sendmsg(msg, 1, mm, false); } +/* determine if the MS/UE supports R99 or later */ +static bool mmctx_is_r99(const struct sgsn_mm_ctx *mm) +{ + if (mm->ms_network_capa.len < 1) + return false; + if (mm->ms_network_capa.buf[0] & 0x01) + return true; + return false; +} + /* 3GPP TS 24.008 Section 9.4.9: Authentication and Ciphering Request */ -static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, uint8_t *rnd, +static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, + const struct osmo_auth_vector *vec, uint8_t key_seq, bool force_standby) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 AUTH CIPH REQ"); @@ -563,8 +576,14 @@ struct gsm48_auth_ciph_req *acreq; uint8_t *m_rand, *m_cksn, rbyte; - LOGMMCTXP(LOGL_INFO, mm, "<- GPRS AUTH AND CIPHERING REQ (rand = %s)\n", - osmo_hexdump(rnd, 16)); + LOGMMCTXP(LOGL_INFO, mm, "<- GPRS AUTH AND CIPHERING REQ (rand = %s", + osmo_hexdump(vec->rand, sizeof(vec->rand))); + if (mmctx_is_r99(mm) && vec + && (vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { + LOGPC(DMM, LOGL_INFO, ", autn = %s)\n", + osmo_hexdump(vec->autn, sizeof(vec->autn))); + } else + LOGPC(DMM, LOGL_INFO, ")\n"); mmctx2msgid(msg, mm); @@ -588,16 +607,25 @@ mm->ac_ref_nr_used = acreq->ac_ref_nr; /* Only if authentication is requested we need to set RAND + CKSN */ - if (rnd) { - m_rand = msgb_put(msg, 16+1); + if (vec) { + m_rand = msgb_put(msg, sizeof(vec->rand) + 1); m_rand[0] = GSM48_IE_GMM_AUTH_RAND; - memcpy(m_rand + 1, rnd, 16); + memcpy(m_rand + 1, vec->rand, sizeof(vec->rand)); + /* ? 10.5.1.2: */ m_cksn = msgb_put(msg, 1); m_cksn[0] = (GSM48_IE_GMM_CIPH_CKSN << 4) | (key_seq & 0x07); + + /* A Release99 or higher MS/UE must be able to handle + * the optional AUTN IE. If a classic GSM SIM is + * inserted, it will simply ignore AUTN and just use + * RAND */ + if (mmctx_is_r99(mm) && + (vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { + msgb_tlv_put(msg, GSM48_IE_GMM_AUTN, + sizeof(vec->autn), vec->autn); + } } - /* FIXME: add AUTN for 3g auth according to 3GPP TS 24.008 ? 10.5.3.1.1 */ - /* FIXME: make sure we don't send any other messages to the MS */ return gsm48_gmm_sendmsg(msg, 1, mm, false); } @@ -619,6 +647,62 @@ return gsm48_gmm_sendmsg(msg, 0, mm, false); } +/* check if the received authentication response matches */ +static bool check_auth_resp(struct sgsn_mm_ctx *ctx, + bool is_utran, + const struct osmo_auth_vector *vec, + const uint8_t *res, uint8_t res_len) +{ + const uint8_t *expect_res; + uint8_t expect_res_len; + enum osmo_sub_auth_type expect_type; + const char *expect_str; + + if (!vec) + return true; /* really!? */ + + /* On UTRAN (3G) we always expect UMTS AKA. On GERAN (2G) we sent AUTN + * and expect UMTS AKA if there is R99 capability and our vector + * supports UMTS AKA, otherwise we expect GSM AKA. */ + if (is_utran + || (mmctx_is_r99(ctx) && (vec->auth_types & OSMO_AUTH_TYPE_UMTS))) { + expect_type = OSMO_AUTH_TYPE_UMTS; + expect_str = "UMTS RES"; + expect_res = vec->res; + expect_res_len = vec->res_len; + } else { + expect_type = OSMO_AUTH_TYPE_GSM; + expect_str = "GSM SRES"; + expect_res = vec->sres; + expect_res_len = sizeof(vec->sres); + } + + if (!(vec->auth_types & expect_type)) { + LOGMMCTXP(LOGL_ERROR, ctx, "Auth error: auth vector does" + " not provide the expected auth type:" + " expected %s = 0x%x, auth_types are 0x%x\n", + expect_str, expect_type, vec->auth_types); + return false; + } + + if (!res) + goto auth_mismatch; + + if (res_len != expect_res_len) + goto auth_mismatch; + + if (memcmp(res, expect_res, res_len) != 0) + goto auth_mismatch; + + /* Authorized! */ + return true; + +auth_mismatch: + LOGMMCTXP(LOGL_ERROR, ctx, "Auth mismatch: expected %s = %s\n", + expect_str, osmo_hexdump_nospc(expect_res, expect_res_len)); + return false; +} + /* Section 9.4.10: Authentication and Ciphering Response */ static int gsm48_rx_gmm_auth_ciph_resp(struct sgsn_mm_ctx *ctx, struct msgb *msg) @@ -627,6 +711,9 @@ struct gsm48_auth_ciph_resp *acr = (struct gsm48_auth_ciph_resp *)gh->data; struct tlv_parsed tp; struct gsm_auth_tuple *at; + const char *res_name = "(no response)"; + uint8_t res[16]; + uint8_t res_len; int rc; LOGMMCTXP(LOGL_INFO, ctx, "-> GPRS AUTH AND CIPH RESPONSE\n"); @@ -651,26 +738,34 @@ (msg->data + msg->len) - acr->data, 0, 0); if (!TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_SRES) || - !TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV)) { + !TLVP_PRESENT(&tp, GSM48_IE_GMM_IMEISV) || + TLVP_LEN(&tp,GSM48_IE_GMM_AUTH_SRES) != 4) { /* TODO: missing mandatory IE, return STATUS or REJ? */ LOGMMCTXP(LOGL_ERROR, ctx, "Missing mandantory IE\n"); return -EINVAL; } - /* Compare SRES with what we expected */ - LOGMMCTXP(LOGL_DEBUG, ctx, "checking received auth info, SRES = %s\n", - osmo_hexdump(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), - TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES))); + /* Start with the good old 4-byte SRES */ + memcpy(res, TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), 4); + res_len = 4; + res_name = "GSM SRES"; + + /* Append extended RES as part of UMTS AKA, if any */ + if (TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_RES_EXT)) { + unsigned int l = TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_RES_EXT); + if (l > sizeof(res)-4) + l = sizeof(res)-4; + memcpy(res+4, TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_RES_EXT), l); + res_len += l; + res_name = "UMTS RES"; + } at = &ctx->auth_triplet; - if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES) != sizeof(at->vec.sres) || - memcmp(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), at->vec.sres, - sizeof(at->vec.sres)) != 0) { - - LOGMMCTXP(LOGL_NOTICE, ctx, "Received SRES doesn't match " - "expected RES %s\n", osmo_hexdump(at->vec.sres, - sizeof(at->vec.sres))); + LOGMMCTXP(LOGL_DEBUG, ctx, "checking auth: received %s = %s\n", + res_name, osmo_hexdump(res, res_len)); + rc = check_auth_resp(ctx, false, &at->vec, res, res_len); + if (!rc) { rc = gsm48_tx_gmm_auth_ciph_rej(ctx); mm_ctx_cleanup_free(ctx, "GPRS AUTH AND CIPH REJECT"); return rc; @@ -685,6 +780,60 @@ /* Check if we can let the mobile station enter */ return gsm48_gmm_authorize(ctx); +} + +/* Section 9.4.10: Authentication and Ciphering Failure */ +static int gsm48_rx_gmm_auth_ciph_fail(struct sgsn_mm_ctx *ctx, + struct msgb *msg) +{ + struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); + struct tlv_parsed tp; + const uint8_t gmm_cause = gh->data[0]; + const uint8_t *auts; + int rc; + + LOGMMCTXP(LOGL_INFO, ctx, "-> GPRS AUTH AND CIPH FAILURE (cause = %s)\n", + get_value_string(gsm48_gmm_cause_names, gmm_cause)); + + tlv_parse(&tp, &gsm48_gmm_att_tlvdef, gh->data+1, msg->len - 1, 0, 0); + + /* Only if GMM cause is present and the AUTS is provided, we can + * start re-sync procedure */ + if (gmm_cause == GMM_CAUSE_SYNC_FAIL && + TLVP_PRESENT(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR)) { + if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR) != 14) { + LOGMMCTXP(LOGL_ERROR, ctx, "AUTS IE has wrong size:" + " expected %d, got %u\n", 14, + TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR)); + return -EINVAL; + } + auts = TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_FAIL_PAR); + + LOGMMCTXP(LOGL_INFO, ctx, + "R99 AUTHENTICATION SYNCH (AUTS = %s)\n", + osmo_hexdump_nospc(auts, 14)); + + /* make sure we'll refresh the auth_triplet in + * sgsn_auth_update() */ + ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; + + /* make sure we'll retry authentication after the resync */ + ctx->auth_state = SGSN_AUTH_UMTS_RESYNC; + + /* Send AUTS to HLR and wait for new Auth Info Result */ + rc = gprs_subscr_request_auth_info(ctx, auts, + ctx->auth_triplet.vec.rand); + if (!rc) + return 0; + /* on error, fall through to send a reject */ + LOGMMCTXP(LOGL_ERROR, ctx, + "Sending AUTS to HLR failed (rc = %d)\n", rc); + } + + LOGMMCTXP(LOGL_NOTICE, ctx, "Authentication failed\n"); + rc = gsm48_tx_gmm_auth_ciph_rej(ctx); + mm_ctx_cleanup_free(ctx, "GPRS AUTH FAILURE"); + return rc; } static void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx) @@ -865,8 +1014,8 @@ struct gsm_auth_tuple *at = &ctx->auth_triplet; mmctx_timer_start(ctx, 3360, sgsn->cfg.timers.T3360); - return gsm48_tx_gmm_auth_ciph_req(ctx, at->vec.rand, - at->key_seq, false); + return gsm48_tx_gmm_auth_ciph_req(ctx, &at->vec, at->key_seq, + false); } if (ctx->auth_state == SGSN_AUTH_AUTHENTICATE && ctx->is_authenticated && @@ -1911,6 +2060,9 @@ goto null_mmctx; rc = gsm48_rx_gmm_auth_ciph_resp(mmctx, msg); break; + case GSM48_MT_GMM_AUTH_CIPH_FAIL: + rc = gsm48_rx_gmm_auth_ciph_fail(mmctx, msg); + break; default: LOGMMCTXP(LOGL_NOTICE, mmctx, "Unknown GSM 04.08 GMM msg type 0x%02x\n", gh->msg_type); @@ -1979,7 +2131,7 @@ } at = &mm->auth_triplet; - gsm48_tx_gmm_auth_ciph_req(mm, at->vec.rand, at->key_seq, false); + gsm48_tx_gmm_auth_ciph_req(mm, &at->vec, at->key_seq, false); osmo_timer_schedule(&mm->timer, sgsn->cfg.timers.T3360, 0); break; case 3370: /* waiting for IDENTITY RESPONSE */ diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c index 5f426f8..2042ec6 100644 --- a/openbsc/src/gprs/gprs_subscriber.c +++ b/openbsc/src/gprs/gprs_subscriber.c @@ -766,14 +766,21 @@ return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } -int gprs_subscr_query_auth_info(struct gprs_subscr *subscr) +static int gprs_subscr_query_auth_info(struct gprs_subscr *subscr, + const uint8_t *auts, + const uint8_t *auts_rand) { struct osmo_gsup_message gsup_msg = {0}; - LOGGSUBSCRP(LOGL_INFO, subscr, - "subscriber auth info is not available\n"); + /* Make sure we have a complete resync or clearly no resync. */ + OSMO_ASSERT((auts != NULL) == (auts_rand != NULL)); + + LOGGSUBSCRP(LOGL_INFO, subscr, "requesting auth info%s\n", + auts ? " with AUTS (UMTS Resynch)" : ""); gsup_msg.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST; + gsup_msg.auts = auts; + gsup_msg.rand = auts_rand; return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); } @@ -854,7 +861,16 @@ return rc; } -int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) +/*! \brief Send Update Auth Info request via GSUP, with or without resync. + * \param[in] mmctx MM context to request authentication tuples for. + * \param[in] auts 14 octet AUTS token for UMTS resync, or NULL. + * \param[in] auts_rand 16 octet Random token for UMTS resync, or NULL. + * In case of normal Authentication Info request, both \a auts and \a auts_rand + * must be NULL. For resync, both must be non-NULL. + */ +int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx, + const uint8_t *auts, + const uint8_t *auts_rand) { struct gprs_subscr *subscr = NULL; int rc; @@ -865,7 +881,7 @@ subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; - rc = gprs_subscr_query_auth_info(subscr); + rc = gprs_subscr_query_auth_info(subscr, auts, auts_rand); gprs_subscr_put(subscr); return rc; } diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index df7ee37..a64339c 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -32,6 +32,7 @@ { SGSN_AUTH_REJECTED, "rejected"}, { SGSN_AUTH_UNKNOWN, "unknown"}, { SGSN_AUTH_AUTHENTICATE, "authenticate" }, + { SGSN_AUTH_UMTS_RESYNC, "UMTS-resync" }, { 0, NULL } }; @@ -182,7 +183,7 @@ mmctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; LOGMMCTXP(LOGL_INFO, mmctx, "Requesting authentication tuples\n"); - rc = gprs_subscr_request_auth_info(mmctx); + rc = gprs_subscr_request_auth_info(mmctx, NULL, NULL); if (rc >= 0) return 0; diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 6eabdde..2f1513a 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -1164,6 +1164,7 @@ { struct gsm_auth_tuple at = { .vec.sres = {0x51, 0xe5, 0x51, 0xe5}, + .vec.auth_types = OSMO_AUTH_TYPE_GSM, .key_seq = 0 }; -- To view, visit https://gerrit.osmocom.org/1683 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816 Gerrit-PatchSet: 8 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 14:29:42 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Mon, 27 Feb 2017 14:29:42 +0000 Subject: [MERGED] openbsc[master]: SGSN VTY: make missing GSUP server address+port fatal In-Reply-To: References: Message-ID: Neels Hofmeyr has submitted this change and it was merged. Change subject: SGSN VTY: make missing GSUP server address+port fatal ...................................................................... SGSN VTY: make missing GSUP server address+port fatal On 'auth-policy remote', the SGSN requires GSUP server address and port. If it was missing, the SGSN would print a VTY warning and run anyway. Make this error more fatal: print an error (flattened a bit) to stderr and abort the program. Move validation of the GSUP server data presence out of the VTY command itself and into the config reading function. This way the GSUP server config can be given anywhere, including below the auth-policy config (was required above). Don't care about setting the auth-policy to remote with a telnet VTY, because in that case the GSUP client won't be started anyway. Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c --- M openbsc/src/gprs/sgsn_main.c M openbsc/src/gprs/sgsn_vty.c 2 files changed, 10 insertions(+), 12 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index af5cced..5cdfb31 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -376,7 +376,7 @@ rc = sgsn_parse_config(sgsn_inst.config_file, &sgsn_inst.cfg); if (rc < 0) { - LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); + LOGP(DGPRS, LOGL_FATAL, "Error in config file\n"); exit(2); } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index a730635..6c8b640 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -638,17 +638,6 @@ { int val = get_string_value(sgsn_auth_pol_strs, argv[0]); OSMO_ASSERT(val >= SGSN_AUTH_POLICY_OPEN && val <= SGSN_AUTH_POLICY_REMOTE); - if (val == SGSN_AUTH_POLICY_REMOTE) { - const char *err = "%% auth-policy remote requires"; - if (!g_cfg->gsup_server_addr.sin_addr.s_addr) { - vty_out(vty, "%s 'gsup remote-ip'%s", err, VTY_NEWLINE); - return CMD_WARNING; - } - if (!g_cfg->gsup_server_port) { - vty_out(vty, "%s 'gsup remote-port'%s", err, VTY_NEWLINE); - return CMD_WARNING; - } - } g_cfg->auth_policy = val; g_cfg->require_authentication = (val == SGSN_AUTH_POLICY_REMOTE); g_cfg->require_update_location = (val == SGSN_AUTH_POLICY_REMOTE); @@ -1311,5 +1300,14 @@ return rc; } + if (g_cfg->auth_policy == SGSN_AUTH_POLICY_REMOTE + && !(g_cfg->gsup_server_addr.sin_addr.s_addr + && g_cfg->gsup_server_port)) { + fprintf(stderr, "Configuration error:" + " 'auth-policy remote' requires both" + " 'gsup remote-ip' and 'gsup remote-port'\n"); + return -EINVAL; + } + return 0; } -- To view, visit https://gerrit.osmocom.org/1894 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Mon Feb 27 16:03:47 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Mon, 27 Feb 2017 16:03:47 +0000 Subject: [PATCH] openbsc[master]: silent_call: remove unfinished fuzzer interface Message-ID: Review at https://gerrit.osmocom.org/1930 silent_call: remove unfinished fuzzer interface Remove the fuzzer interface that was partially implemented in gsm_04_08.c and silent_call.c is causing problems when an SMS is sent during an active silent call. The reason for this is that gsm0408_dispatch() in gsm_04_08.c would decide to rout all uplink traffic to silent_call_rx() in silent_call.c. silent_call_rx() is a stub function that discards the data. This patch removes the fuzzer interface code by placing ifdefs around it, so that it can be re-activated by experimentators. Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc --- M openbsc/include/openbsc/silent_call.h M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/silent_call.c 3 files changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/30/1930/1 diff --git a/openbsc/include/openbsc/silent_call.h b/openbsc/include/openbsc/silent_call.h index 2492903..619a543 100644 --- a/openbsc/include/openbsc/silent_call.h +++ b/openbsc/include/openbsc/silent_call.h @@ -6,7 +6,10 @@ extern int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data, int type); extern int gsm_silent_call_stop(struct gsm_subscriber *subscr); + +#if 0 extern int silent_call_rx(struct gsm_subscriber_connection *conn, struct msgb *msg); extern int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg); +#endif #endif /* _SILENT_CALL_H */ diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index be43956..3cc86ba 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -3958,8 +3958,10 @@ OSMO_ASSERT(msg); LOGP(DRLL, LOGL_DEBUG, "Dispatching 04.08 message, pdisc=%d\n", pdisc); +#if 0 if (silent_call_reroute(conn, msg)) return silent_call_rx(conn, msg); +#endif switch (pdisc) { case GSM48_PDISC_CC: diff --git a/openbsc/src/libmsc/silent_call.c b/openbsc/src/libmsc/silent_call.c index 131a178..590d01b 100644 --- a/openbsc/src/libmsc/silent_call.c +++ b/openbsc/src/libmsc/silent_call.c @@ -72,6 +72,7 @@ return rc; } +#if 0 /* receive a layer 3 message from a silent call */ int silent_call_rx(struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -79,6 +80,7 @@ LOGP(DLSMS, LOGL_NOTICE, "Discarding L3 message from a silent call.\n"); return 0; } +#endif struct msg_match { uint8_t pdisc; @@ -91,6 +93,7 @@ { GSM48_PDISC_MM, GSM48_MT_MM_CM_SERV_REQ }, }; +#if 0 /* decide if we need to reroute a message as part of a silent call */ int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -114,6 +117,7 @@ LOGP(DLSMS, LOGL_INFO, "Rerouting L3 message from a silent call.\n"); return 1; } +#endif /* initiate a silent call with a given subscriber */ -- To view, visit https://gerrit.osmocom.org/1930 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Mon Feb 27 16:40:04 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 27 Feb 2017 16:40:04 +0000 Subject: [PATCH] openbsc[master]: Add simple CTRL2SOAP proxy In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1875 to look at the new patch set (#3). Add simple CTRL2SOAP proxy Add python client which converts TRAP messages into SOAP requests and perform corresponding actions. It can be used as follows ./soap.py -d -w http://example.com/soapservice/htdocs/wsdl/test.wsdl -l 'http://localhost:8000/soapservice/SoapServer.php' In this case the location of SOAP server from test.wsdl is ignored and requests are dospatched to localhost instead. See ./soap.py -h for additional options. Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Related: SYS#3028 --- A openbsc/contrib/soap.py 1 file changed, 131 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/75/1875/3 diff --git a/openbsc/contrib/soap.py b/openbsc/contrib/soap.py new file mode 100755 index 0000000..ff66be7 --- /dev/null +++ b/openbsc/contrib/soap.py @@ -0,0 +1,131 @@ +#!/usr/bin/python3 +# -*- mode: python-mode; py-indent-tabs-mode: nil -*- +""" +/* + * 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. + */ +""" + +from twisted.internet import reactor +from twisted_ipa import CTRL, IPAFactory +from ipa import Ctrl +from treq import post, collect +from suds.client import Client +from suds.plugin import MessagePlugin +from functools import partial +import argparse, logging, datetime + +# keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific +oper = { 'inoperational' : 0, 'operational' : 1 } +admin = { 'locked' : 0, 'unlocked' : 1 } +policy = { 'off' : 0, 'on' : 1, 'grace' : 2, 'unknown' : 3 } +# keys from OpenBSC openbsc/src/libbsc/bsc_vty.c +fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 3 } + +class Trap(CTRL): + """ + TRAP handler (agnostic to client object) + """ + def ctrl_TRAP(self, data, op_id, v): + """ + Parse CTRL TRAP and dispatch to appropriate handler after normalization + """ + (l, r) = v.split() + loc = l.split('.') + t_type = loc[-1] + p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse helper + method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: "Unhandled %s trap" % t_type) + method(p(1), p(3), p(5), p(7), r) # we expect net.0.bsc.666.bts.2.trx.1 format for trap prefix + + def handle_locationstate(self, net, bsc, bts, trx, data): + """ + Handle location-state TRAP: parse trap content, build SOAP context and use treq's routines to post it while setting up async handlers + """ + def cback(c, r): + """ + Callback function: takes c (SOAP client's RequestContext) and server's reply, sends set of parsed ctrl commands (in a 'fire and forget' way) + """ + def commands(c, f): + """ + Process OpenBscCommands format from .wsdl + """ + for t in c: + (_, m) = Ctrl().cmd(*t.split()) + f(m) + def keyvals(k, f): + """ + Process OpenBscKeyVal format from .wsdl + """ + for _, m in list(map(lambda x, y: Ctrl().cmd(x.rstrip(), y), k[0].key, k[0].value)): + f(m) + # The 2 options below are mutually exclusive as the information in the reply is duplicated: + commands(c.process_reply(r).commands, self.transport.write) + #keyvals(c.process_reply(r).keysvals, self.transport.write) + (ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',') + tstamp = datetime.datetime.fromtimestamp(float(ts)).strftime('%Y-%m-%d') + self.dbg('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' % (net, bsc, bts, trx, tstamp, mcc, mnc, data)) + ctx = self.factory.soap.service.registerSiteLocation(bsc, float(lon), float(lat), fix.get(fx, 0), tstamp, oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3)) + handler = partial(cback, ctx) # make closure with context by partial parameter application + post(self.factory.location, ctx.envelope).addCallback(collect, handler) # treq's collect helper is handy to get all reply content at once + + def handle_notificationrejectionv1(self, net, bsc, bts, trx, data): + """ + Handle notification-rejection-v1 TRAP + """ + self.dbg('notification-rejection-v1 at bsc-id %s => %s' % (bsc, data)) + + +class TrapFactory(IPAFactory): + """ + Store SOAP client object so TRAP handler can use it for requests + """ + location = None + soap = None + def __init__(self, proto=None, debug=False, wsdl=None, location=None): + self.soap = Client(wsdl, location=location, nosend=True) # make async SOAP client + if location: + self.location = location.encode() + else: + self.location = self.soap.wsdl.services[0].ports[0].location + if debug: + print(self.soap) + super(TrapFactory, self).__init__(proto, debug) + + +if __name__ == '__main__': + p = argparse.ArgumentParser("SOAP-CTRL proxy") + p.add_argument('-v', '--version', action='version', version='%(prog)s v0.2') + p.add_argument('-p', '--port', type=int, default=4250, help="Port to use for CTRL interface, defaults to 4250") + p.add_argument('-c', '--ctrl', default='localhost', help="Adress to use for CTRL interface, defaults to localhost") + p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP") + p.add_argument('-s', '--size', type=int, default=5, help="Size of thread pool") + p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") + p.add_argument('-l', '--location', help="Override location found in WSDL file") + args = p.parse_args() + + logging.basicConfig(level=logging.ERROR) + if args.debug: + logging.getLogger('suds.client').setLevel(logging.DEBUG) + logging.getLogger('suds.transport').setLevel(logging.DEBUG) + logging.getLogger('suds.xsd').setLevel(logging.DEBUG) + logging.getLogger('suds.umx').setLevel(logging.DEBUG) + + reactor.suggestThreadPoolSize(args.size) + reactor.connectTCP(args.ctrl, args.port, TrapFactory(Trap, args.debug, args.wsdl, args.location)) + reactor.run() -- To view, visit https://gerrit.osmocom.org/1875 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Mon Feb 27 16:53:51 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Mon, 27 Feb 2017 16:53:51 +0000 Subject: openbsc[master]: Add simple CTRL2SOAP proxy In-Reply-To: References: Message-ID: Patch Set 3: Code-Review-1 Well, this seems like the easiest way to share it with customer. I'll remove my -1 once it's ready for submission. -- To view, visit https://gerrit.osmocom.org/1875 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Mon Feb 27 17:07:34 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Mon, 27 Feb 2017 17:07:34 +0000 Subject: [PATCH] openbsc[master]: XID: resend xid with pdp-ctx-ack messages Message-ID: Review at https://gerrit.osmocom.org/1931 XID: resend xid with pdp-ctx-ack messages If a pdp context is created a xid request is sent right after the pdp-context-ack message. The sending of the pdp-context-ack and the xid message is triggered from the GGSN via the GTP interface. When the pdp-context-ack message is not received by the MS, it will send the pdp-context-request again. A lost pdp-context-ack is resent by the SGSN directly so that the mechanism described above does not work for pdp-context-ack resents. This commit adds code to trigger the sending of xid messages also for resent pdp-context-ack messages. Change-Id: Ice66790803154310a61a70a54be76cec539c97a7 --- M openbsc/src/gprs/gprs_gmm.c 1 file changed, 15 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/31/1931/1 diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 3f59a2b..da243a4 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -68,6 +68,7 @@ #include #include #include +#include #include @@ -2438,6 +2439,7 @@ char apn_str[GSM_APN_LENGTH] = { 0, }; char *hostname; int rc; + struct gprs_llc_lle *lle; LOGMMCTXP(LOGL_INFO, mmctx, "-> ACTIVATE PDP CONTEXT REQ: SAPI=%u NSAPI=%u ", act_req->req_llc_sapi, act_req->req_nsapi); @@ -2513,7 +2515,19 @@ pdp->ti == transaction_id) { /* This apparently is a re-transmission of a PDP CTX * ACT REQ (our ACT ACK must have got dropped) */ - return gsm48_tx_gsm_act_pdp_acc(pdp); + rc = gsm48_tx_gsm_act_pdp_acc(pdp); + if (rc < 0) + return rc; + + if (pdp->mm->ran_type == MM_CTX_T_GERAN_Gb) { + /* Also re-transmit the SNDCP XID message */ + lle = &pdp->mm->gb.llme->lle[pdp->sapi]; + rc = sndcp_sn_xid_req(lle,pdp->nsapi); + if (rc < 0) + return rc; + } + + return 0; } /* Send reject with GSM_CAUSE_NSAPI_IN_USE */ -- To view, visit https://gerrit.osmocom.org/1931 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ice66790803154310a61a70a54be76cec539c97a7 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter From admin at opensuse.org Mon Feb 27 20:03:34 2017 From: admin at opensuse.org (OBS Notification) Date: Mon, 27 Feb 2017 20:03:34 +0000 Subject: Build failure of network:osmocom:nightly/libosmo-netif in xUbuntu_16.04/i586 In-Reply-To: References: Message-ID: <58b4863186d8d_5684ed1c0058335@build.opensuse.org> Visit https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/libosmo-netif/xUbuntu_16.04/i586 Package network:osmocom:nightly/libosmo-netif failed to build in xUbuntu_16.04/i586 Check out the package for editing: osc checkout network:osmocom:nightly libosmo-netif Last lines of build log: [ 162s] You may investigate any problem if you feel able to do so, in which [ 162s] case the test suite provides a good starting point. Its output may [ 162s] be found below `tests/testsuite.dir'. [ 162s] [ 162s] Makefile:641: recipe for target 'check-local' failed [ 162s] make[4]: *** [check-local] Error 1 [ 162s] make[4]: Leaving directory '/usr/src/packages/BUILD/tests' [ 162s] Makefile:494: recipe for target 'check-am' failed [ 162s] make[3]: *** [check-am] Error 2 [ 162s] make[3]: Leaving directory '/usr/src/packages/BUILD/tests' [ 162s] Makefile:466: recipe for target 'check-recursive' failed [ 162s] make[2]: *** [check-recursive] Error 1 [ 162s] make[2]: Leaving directory '/usr/src/packages/BUILD' [ 162s] Makefile:757: recipe for target 'check' failed [ 162s] make[1]: *** [check] Error 2 [ 162s] make[1]: Leaving directory '/usr/src/packages/BUILD' [ 162s] dh_auto_test: make -j1 check returned exit code 2 [ 162s] debian/rules:13: recipe for target 'build' failed [ 162s] make: *** [build] Error 2 [ 162s] dpkg-buildpackage: error: debian/rules build gave error exit status 2 [ 162s] [ 162s] cloud106 failed "build libosmo-netif_0.0.7.20170227.dsc" at Mon Feb 27 20:03:19 UTC 2017. [ 162s] [ 162s] ### VM INTERACTION START ### [ 165s] [ 141.627420] reboot: Power down [ 166s] ### VM INTERACTION END ### [ 166s] [ 166s] cloud106 failed "build libosmo-netif_0.0.7.20170227.dsc" at Mon Feb 27 20:03:23 UTC 2017. [ 166s] -- Configure notifications at https://build.opensuse.org/user/notifications openSUSE Build Service (https://build.opensuse.org/) From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:08:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:08:04 +0000 Subject: [PATCH] openbsc[master]: vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT ... Message-ID: Review at https://gerrit.osmocom.org/1932 vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems When running the testBSCreload test in close succession, I get a "Connection refused" error because the socket is still in TIME_WAIT state. Passing the SO_REUSEADDR flag allows reusing the addr despite a TIME_WAIT socket. Change-Id: I941851b062999ab4b962430f7b27c19935993e0a --- M openbsc/tests/vty_test_runner.py 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/32/1932/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index ba3db97..b4dec89 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1206,6 +1206,7 @@ def nat_msc_test(x, ip, port, verbose = False): msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + msc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) msc.settimeout(5) msc.bind((ip, port)) msc.listen(5) -- To view, visit https://gerrit.osmocom.org/1932 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I941851b062999ab4b962430f7b27c19935993e0a Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:08:04 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:08:04 +0000 Subject: [PATCH] openbsc[master]: vty tests: allow picking specific tests to run by name Message-ID: Review at https://gerrit.osmocom.org/1933 vty tests: allow picking specific tests to run by name Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920 --- M openbsc/tests/vty_test_runner.py 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/33/1933/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index a663e94..93d1755 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1342,6 +1342,7 @@ help="searchpath for config") parser.add_argument("-w", "--workdir", dest="w", help="Working directory") + parser.add_argument("test_name", nargs="*", help="(parts of) test names to run, case-insensitive") args = parser.parse_args() verbose_level = 1 @@ -1364,6 +1365,10 @@ add_nat_test(suite, workdir) add_gbproxy_test(suite, workdir) add_sgsn_test(suite, workdir) + + if args.test_name: + osmoutil.pick_tests(suite, *args.test_name) + res = unittest.TextTestRunner(verbosity=verbose_level, stream=sys.stdout).run(suite) sys.exit(len(res.errors) + len(res.failures)) -- To view, visit https://gerrit.osmocom.org/1933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:08:05 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:08:05 +0000 Subject: [PATCH] openbsc[master]: vty tests: close msc socket after nat_msc_test Message-ID: Review at https://gerrit.osmocom.org/1934 vty tests: close msc socket after nat_msc_test Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478 --- M openbsc/tests/vty_test_runner.py 1 file changed, 24 insertions(+), 20 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/34/1934/1 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 93d1755..305c956 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -785,28 +785,32 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port, verbose=True) - b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) - b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) - b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) + msc_socket, msc = nat_msc_test(self, ip, port, verbose=True) + try: + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) - self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) - self.assertTrue(3 == nat_bsc_num_con(self)) - self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) + self.assertTrue(3 == nat_bsc_num_con(self)) + self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) - nat_bsc_reload(self) - bscs2 = self.vty.command("show bscs-config") - # check that the reset to initial config succeeded - self.assertEquals(bscs1, bscs2) + nat_bsc_reload(self) + bscs2 = self.vty.command("show bscs-config") + # check that the reset to initial config succeeded + self.assertEquals(bscs1, bscs2) - self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured")) - self.assertTrue(1 == nat_bsc_num_con(self)) - rem = self.vty.command("show bsc connections").split(' ') - # remaining connection is for BSC0 - self.assertEquals('0', rem[2]) - # remaining connection is authorized - self.assertEquals('1', rem[4]) - self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured")) + self.assertTrue(1 == nat_bsc_num_con(self)) + rem = self.vty.command("show bsc connections").split(' ') + # remaining connection is for BSC0 + self.assertEquals('0', rem[2]) + # remaining connection is authorized + self.assertEquals('1', rem[4]) + self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + finally: + msc.close() + msc_socket.close() def testVtyTree(self): self.vty.enable() @@ -1240,7 +1244,7 @@ if not conn: raise Exception("VTY reports MSC is connected, but I haven't" " connected yet: %r %r" % (ip, port)) - return conn + return msc, conn def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) -- To view, visit https://gerrit.osmocom.org/1934 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:10:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:10:50 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: add pick_test() to pick unittest tests by name Message-ID: Review at https://gerrit.osmocom.org/1935 osmoutil: add pick_test() to pick unittest tests by name Change-Id: I92f90c334169f31920c63dd5c5ac8dac215065e6 --- M osmopy/osmoutil.py 1 file changed, 22 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/35/1935/1 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index cb3cb6a..faedc43 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -19,6 +19,7 @@ import sys import importlib import time +import unittest """Run a command, with stdout and stderr directed to devnull""" @@ -68,3 +69,24 @@ else: print >> sys.stderr, "set osmoappdesc location with -p " sys.exit(1) + + +def pick_tests(suite, *name_snippets): + '''for unittest: Non-standard way of picking only selected tests to run, + by name. Kind of stupid of python unittest to not provide this feature + more easily.''' + + new_tests = [] + for t in suite._tests: + if isinstance(t, unittest.suite.TestSuite): + pick_tests(t, *name_snippets) + new_tests.append(t) + continue + + if not isinstance(t, unittest.TestCase): + new_tests.append(t) + continue + + if any([n.lower() in t._testMethodName.lower() for n in name_snippets]): + new_tests.append(t) + suite._tests = new_tests -- To view, visit https://gerrit.osmocom.org/1935 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I92f90c334169f31920c63dd5c5ac8dac215065e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:10:50 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:10:50 +0000 Subject: [PATCH] python/osmo-python-tests[master]: osmoutil: end_proc: wait for term in a loop Message-ID: Review at https://gerrit.osmocom.org/1936 osmoutil: end_proc: wait for term in a loop Allows a minuscule first wait_time, and is tolerant for processes that take longer to terminate. Actually all of our current processes are very fast to terminate. This patch was created while looking for a different problem, now that it's there we might as well keep it. Change-Id: I98849e4550116c5666fdf6f5d4cbb576ffa3e14a --- M osmopy/osmoutil.py 1 file changed, 19 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/36/1936/1 diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index faedc43..8f0369b 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -47,12 +47,27 @@ return proc.terminate() - time.sleep(.01) - rc = proc.poll() - if rc is None: + time_to_wait_for_term = 5 + wait_step = 0.001 + waited_time = 0 + while True: + # poll returns None if proc is still running + rc = proc.poll() + if rc is not None: + break + waited_time += wait_step + # make wait_step approach 1.0 + wait_step = (1. + 5. * wait_step) / 6. + if waited_time >= time_to_wait_for_term: + break + time.sleep(wait_step) + + if proc.poll() is None: # termination seems to be slower than that, let's just kill - print "Killed child process" proc.kill() + print "Killed child process" + elif waited_time > .002: + print "Terminating took %.3fs" % waited_time proc.wait() -- To view, visit https://gerrit.osmocom.org/1936 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I98849e4550116c5666fdf6f5d4cbb576ffa3e14a Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:11:34 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:11:34 +0000 Subject: [PATCH] openbsc[master]: vty tests: allow picking specific tests to run by name In-Reply-To: References: Message-ID: vty tests: allow picking specific tests to run by name Depends: osmo-python-tests change-id I92f90c334169f31920c63dd5c5ac8dac215065e6 Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920 --- M openbsc/tests/vty_test_runner.py 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/33/1933/2 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index a663e94..93d1755 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1342,6 +1342,7 @@ help="searchpath for config") parser.add_argument("-w", "--workdir", dest="w", help="Working directory") + parser.add_argument("test_name", nargs="*", help="(parts of) test names to run, case-insensitive") args = parser.parse_args() verbose_level = 1 @@ -1364,6 +1365,10 @@ add_nat_test(suite, workdir) add_gbproxy_test(suite, workdir) add_sgsn_test(suite, workdir) + + if args.test_name: + osmoutil.pick_tests(suite, *args.test_name) + res = unittest.TextTestRunner(verbosity=verbose_level, stream=sys.stdout).run(suite) sys.exit(len(res.errors) + len(res.failures)) -- To view, visit https://gerrit.osmocom.org/1933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:11:34 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:11:34 +0000 Subject: [PATCH] openbsc[master]: vty tests: close msc socket after nat_msc_test In-Reply-To: References: Message-ID: vty tests: close msc socket after nat_msc_test Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478 --- M openbsc/tests/vty_test_runner.py 1 file changed, 24 insertions(+), 20 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/34/1934/2 diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 93d1755..305c956 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -785,28 +785,32 @@ self.vty.command("end") nat_msc_ip(self, ip, port) - msc = nat_msc_test(self, ip, port, verbose=True) - b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) - b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) - b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) + msc_socket, msc = nat_msc_test(self, ip, port, verbose=True) + try: + b0 = nat_bsc_sock_test(0, "lol", verbose=True, proc=self.proc) + b1 = nat_bsc_sock_test(1, "xyu", verbose=True, proc=self.proc) + b2 = nat_bsc_sock_test(5, "key", verbose=True, proc=self.proc) - self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) - self.assertTrue(3 == nat_bsc_num_con(self)) - self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + self.assertEquals("3 BSCs configured", self.vty.command("show nat num-bscs-configured")) + self.assertTrue(3 == nat_bsc_num_con(self)) + self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) - nat_bsc_reload(self) - bscs2 = self.vty.command("show bscs-config") - # check that the reset to initial config succeeded - self.assertEquals(bscs1, bscs2) + nat_bsc_reload(self) + bscs2 = self.vty.command("show bscs-config") + # check that the reset to initial config succeeded + self.assertEquals(bscs1, bscs2) - self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured")) - self.assertTrue(1 == nat_bsc_num_con(self)) - rem = self.vty.command("show bsc connections").split(' ') - # remaining connection is for BSC0 - self.assertEquals('0', rem[2]) - # remaining connection is authorized - self.assertEquals('1', rem[4]) - self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + self.assertEquals("2 BSCs configured", self.vty.command("show nat num-bscs-configured")) + self.assertTrue(1 == nat_bsc_num_con(self)) + rem = self.vty.command("show bsc connections").split(' ') + # remaining connection is for BSC0 + self.assertEquals('0', rem[2]) + # remaining connection is authorized + self.assertEquals('1', rem[4]) + self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + finally: + msc.close() + msc_socket.close() def testVtyTree(self): self.vty.enable() @@ -1240,7 +1244,7 @@ if not conn: raise Exception("VTY reports MSC is connected, but I haven't" " connected yet: %r %r" % (ip, port)) - return conn + return msc, conn def ipa_handle_small(x, verbose = False): s = data2str(x.recv(4)) -- To view, visit https://gerrit.osmocom.org/1934 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 02:38:51 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 02:38:51 +0000 Subject: [PATCH] libosmocore[master]: fsm: convenience: add inline osmo_fsm_inst_state_name() Message-ID: Review at https://gerrit.osmocom.org/1937 fsm: convenience: add inline osmo_fsm_inst_state_name() Change-Id: If9a6ecc4d6e2beaf716569e9a6053d73488e860b --- M include/osmocom/core/fsm.h 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/1937/1 diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index 952f82f..ef8a135 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -151,6 +151,8 @@ const char *osmo_fsm_event_name(struct osmo_fsm *fsm, uint32_t event); const char *osmo_fsm_inst_name(struct osmo_fsm_inst *fi); const char *osmo_fsm_state_name(struct osmo_fsm *fsm, uint32_t state); +static inline const char *osmo_fsm_inst_state_name(struct osmo_fsm_inst *fi) +{ return osmo_fsm_state_name(fi->fsm, fi->state); } /*! \brief perform a state change of the given FSM instance * -- To view, visit https://gerrit.osmocom.org/1937 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If9a6ecc4d6e2beaf716569e9a6053d73488e860b Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 08:51:27 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 28 Feb 2017 08:51:27 +0000 Subject: openbsc[master]: XID: resend xid with pdp-ctx-ack messages In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1931 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice66790803154310a61a70a54be76cec539c97a7 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 08:56:03 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 28 Feb 2017 08:56:03 +0000 Subject: libosmocore[master]: Export comp128 v2 and v3 routines as well In-Reply-To: References: Message-ID: Patch Set 1: What's wrong with the abstraction? Is there way we can make generic API better? -- To view, visit https://gerrit.osmocom.org/1929 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 12:51:08 2017 From: gerrit-no-reply at lists.osmocom.org (Neels Hofmeyr) Date: Tue, 28 Feb 2017 12:51:08 +0000 Subject: openbsc[master]: python tests: vty and smpp: speed up >10 times In-Reply-To: References: Message-ID: Patch Set 2: this and following patches fail to build because they depend on https://gerrit.osmocom.org/1924 which adds the sleep() in the VTYInteract implementation -- To view, visit https://gerrit.osmocom.org/1927 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 14:00:24 2017 From: gerrit-no-reply at lists.osmocom.org (Holger Freyther) Date: Tue, 28 Feb 2017 14:00:24 +0000 Subject: openbsc[master]: lchan release in error state: SACCH deact only for SACCH pchans In-Reply-To: References: Message-ID: Patch Set 2: How do we run into the error case for a PDCH? -- To view, visit https://gerrit.osmocom.org/1397 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iaf46782329b38ba8f3d438e6c75c2d467b852734 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 16:08:01 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 28 Feb 2017 16:08:01 +0000 Subject: [PATCH] openbsc[master]: sgsn: fix problem with leading-zero-IMSIs Message-ID: Review at https://gerrit.osmocom.org/1938 sgsn: fix problem with leading-zero-IMSIs When the IMSI ACL is maintained via the VTY, users may enter IMSIs without leading zeros. Especially in test environments, where MCC=001 and MNC=01 is common, it is likely that someone enters the corresponding IMSI (001010000000001) without the two zeros at the beginning. This patch fixes the problem by sanitizing the IMSI, eventually missing zeros in the beginning will be automatically added. Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517 --- M openbsc/src/gprs/sgsn_vty.c 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/38/1938/1 diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 6c8b640..9fd5a3d 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -586,9 +586,13 @@ "Remove IMSI from ACL\n" "IMSI of subscriber\n") { + char imsi_sanitized[16]; const char *op = argv[0]; - const char *imsi = argv[1]; + const char *imsi = imsi_sanitized; int rc; + + /* Sanitize IMSI */ + sprintf(imsi_sanitized,"%015li", atol(argv[1])); if (!strcmp(op, "add")) rc = sgsn_acl_add(imsi, g_cfg); @@ -597,7 +601,6 @@ if (rc < 0) { vty_out(vty, "%% unable to %s ACL%s", op, VTY_NEWLINE); - return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/1938 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Tue Feb 28 16:08:01 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 28 Feb 2017 16:08:01 +0000 Subject: [PATCH] openbsc[master]: sgsn: Fix broken ACL based authentication Message-ID: Review at https://gerrit.osmocom.org/1939 sgsn: Fix broken ACL based authentication The function sgsn_auth_state() in sgsn_auth.c checks if a subscriber is allowed to enter the network or not. Depending on the auth policy that is set via the VTY config, different checks apply: SGSN_AUTH_POLICY_CLOSED: requires checking the net (MCC/MNC must match) and also requires to check if the IMSI is inside the ACL list. In this case check_net and check_acl are set to one. SGSN_AUTH_POLICY_ACL_ONLY: only requires the ACL to be correct. Here only check_acl is set to one. In the code at the end of the function we can see that if checking the network is required (check_acl=1) The authentication is granted if MCC/MNC are correct. The function returns at that point, meaning, that an evenually required ACL check is completely ignored. This commit corrects the check logic. Change-Id: I463afa5cc407f5c56d29fb5a501185cd3e7ea5be --- M openbsc/src/gprs/sgsn_auth.c 1 file changed, 8 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/39/1939/1 diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index a64339c..c0954c0 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -51,6 +51,7 @@ if (!strcmp(imsi, acl->imsi)) return acl; } + return NULL; } @@ -135,14 +136,16 @@ * of 'our' network */ snprintf(mccmnc, sizeof(mccmnc), "%03d%02d", mmctx->ra.mcc, mmctx->ra.mnc); - if (strncmp(mccmnc, mmctx->imsi, 5) == 0) - return SGSN_AUTH_ACCEPTED; + if (strncmp(mccmnc, mmctx->imsi, 5) != 0) + return SGSN_AUTH_REJECTED; } - if (check_acl && sgsn_acl_lookup(mmctx->imsi, &sgsn->cfg)) - return SGSN_AUTH_ACCEPTED; + if (check_acl) { + if (sgsn_acl_lookup(mmctx->imsi, &sgsn->cfg) == NULL) + return SGSN_AUTH_REJECTED; + } - return SGSN_AUTH_REJECTED; + return SGSN_AUTH_ACCEPTED; } /* -- To view, visit https://gerrit.osmocom.org/1939 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I463afa5cc407f5c56d29fb5a501185cd3e7ea5be Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter From gerrit-no-reply at lists.osmocom.org Tue Feb 28 17:14:01 2017 From: gerrit-no-reply at lists.osmocom.org (Max) Date: Tue, 28 Feb 2017 17:14:01 +0000 Subject: [PATCH] openbsc[master]: Add simple CTRL2SOAP proxy In-Reply-To: References: Message-ID: Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1875 to look at the new patch set (#4). Add simple CTRL2SOAP proxy Add python client which converts TRAP messages into SOAP requests and perform corresponding actions. It can be used as follows ./soap.py -d -w http://example.com/soapservice/htdocs/wsdl/test.wsdl See ./soap.py -h for additional options. Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Related: SYS#3028 --- A openbsc/contrib/soap.py 1 file changed, 172 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/75/1875/4 diff --git a/openbsc/contrib/soap.py b/openbsc/contrib/soap.py new file mode 100755 index 0000000..96c22c4 --- /dev/null +++ b/openbsc/contrib/soap.py @@ -0,0 +1,172 @@ +#!/usr/bin/python3 +# -*- mode: python-mode; py-indent-tabs-mode: nil -*- +""" +/* + * 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. + */ +""" + +from twisted.internet import reactor +from twisted_ipa import CTRL, IPAFactory +from ipa import Ctrl +from treq import post, collect +from suds.client import Client +from functools import partial +import argparse, datetime, signal, sys, os + + +version = "v0.3" # bump this on every non-trivial change + +# keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific +oper = { 'inoperational' : 0, 'operational' : 1 } +admin = { 'locked' : 0, 'unlocked' : 1 } +policy = { 'off' : 0, 'on' : 1, 'grace' : 2, 'unknown' : 3 } + +# keys from OpenBSC openbsc/src/libbsc/bsc_vty.c +fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 3 } + + +class Trap(CTRL): + """ + TRAP handler (agnostic to factory's client object) + """ + def ctrl_TRAP(self, data, op_id, v): + """ + Parse CTRL TRAP and dispatch to appropriate handler after normalization + """ + (l, r) = v.split() + loc = l.split('.') + t_type = loc[-1] + p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse helper + method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: "Unhandled %s trap" % t_type) + method(p(1), p(3), p(5), p(7), r) # we expect net.0.bsc.666.bts.2.trx.1 format for trap prefix + + def ctrl_SET_REPLY(self, data, _, v): + """ + Debug log for replies to our commands + """ + if self.factory.debug: + print('SET REPLY %s' % v) + + def ctrl_ERROR(self, data, op_id, v): + """ + We want to know if smth went wrong + """ + if self.factory.debug: + print('CTRL ERROR [%s] %s' % (op_id, v)) + + def dbg(*_): + """ + Turn off debug print from lower layers as it's too verbose + """ + pass + + def connectionMade(self): + """ + Logging wrapper, calling super() is necessary not to break reconnection logic + """ + print("Connected to CTRL@%s:%d" % (self.factory.host, self.factory.port)) + super(CTRL, self).connectionMade() + + def handle_locationstate(self, net, bsc, bts, trx, data): + """ + Handle location-state TRAP: parse trap content, build SOAP context and use treq's routines to post it while setting up async handlers + """ + def cback(c, r): + """ + Callback function: takes c (SOAP client's RequestContext) and server's reply, sends set of parsed ctrl commands (in a 'fire and forget' way) + """ + repl = c.process_reply(r) + bsc_id = repl.commands[0].split()[0].split('.')[3] # we expect 1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format + print("Received SOAP response for BSC %s, error status: %s" % (bsc_id, repl.error)) + if self.factory.debug: + print("BSC %s commands: %s" % (bsc_id, repl.commands)) + for t in repl.commands: # Process OpenBscCommands format from .wsdl + (_, m) = Ctrl().cmd(*t.split()) + self.transport.write(m) + (ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',') + tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat() + if self.factory.debug: + print('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' % (net, bsc, bts, trx, tstamp, mcc, mnc, data)) + ctx = self.factory.client.registerSiteLocation(bsc, float(lon), float(lat), fix.get(fx, 0), tstamp, oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3)) + post(self.factory.location, ctx.envelope).addCallback(collect, partial(cback, ctx)) # treq's collect helper is handy to get all reply content at once using closure on ctx + + def handle_notificationrejectionv1(self, net, bsc, bts, trx, data): + """ + Handle notification-rejection-v1 TRAP: just an example to show how more message types can be handled + """ + if self.factory.debug: + print('notification-rejection-v1 at bsc-id %s => %s' % (bsc, data)) + + +class TrapFactory(IPAFactory): + """ + Store SOAP client object so TRAP handler can use it for requests + """ + location = None + client = None + host = None + port = None + debug = None + def __init__(self, host, port, proto=None, debug=False, wsdl=None, location=None): + self.host = host # for logging only, + self.port = port # seems to be no way to get it from ReconnectingClientFactory + self.debug = debug + soap = Client(wsdl, location=location, nosend=True) # make async SOAP client + self.location = location.encode() if location else soap.wsdl.services[0].ports[0].location # necessary for dispatching HTTP POST via treq + self.client = soap.service + if debug: + print("Using IPA %s, SUDS client: %s" % (Ctrl.version, soap)) + super(TrapFactory, self).__init__(proto, debug) + + +def reloader(path, script, dbg, signum, _): + """ + Signal handler: we have to use execl() because twisted's reactor is not restartable due to some bug in twisted implementation + """ + print("Received Signal %s - restarting..." % signal.Signals(signum).name) + if signum == signal.SIGUSR1 and dbg not in sys.argv: + sys.argv.append(dbg) # enforce debug + if signum == signal.SIGUSR2 and dbg in sys.argv: + sys.argv.remove(dbg) # disable debug + os.execl(path, script, *sys.argv[1:]) + + +if __name__ == '__main__': + p = argparse.ArgumentParser() + p.add_argument('-v', '--version', action='version', version=("%(prog)s " + version)) + p.add_argument('-p', '--port', type=int, default=4250, help="Port to use for CTRL interface, defaults to 4250") + p.add_argument('-c', '--ctrl', default='localhost', help="Adress to use for CTRL interface, defaults to localhost") + p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP") + p.add_argument('-s', '--size', type=int, default=5, help="Size of thread pool") + p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") + p.add_argument('-l', '--location', help="Override location found in WSDL file (don't use unless you know what you're doing)") + args = p.parse_args() + fl = os.path.basename(__file__) + + reboot = partial(reloader, os.getcwd() + '/' + fl, fl, '-d') + signal.signal(signal.SIGHUP, reboot) + signal.signal(signal.SIGQUIT, reboot) + signal.signal(signal.SIGUSR1, reboot) # restart and enabled debug output + signal.signal(signal.SIGUSR2, reboot) # restart and disable debug output + + print("SOAP proxy %s starting with PID %d ..." % (version, os.getpid())) + reactor.suggestThreadPoolSize(args.size) + reactor.connectTCP(args.ctrl, args.port, TrapFactory(args.ctrl, args.port, Trap, args.debug, args.wsdl, args.location)) + reactor.run() -- To view, visit https://gerrit.osmocom.org/1875 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 28 17:38:26 2017 From: gerrit-no-reply at lists.osmocom.org (dexter) Date: Tue, 28 Feb 2017 17:38:26 +0000 Subject: [PATCH] openbsc[master]: sgsn: Fix broken ACL based authentication In-Reply-To: References: Message-ID: Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1939 to look at the new patch set (#2). sgsn: Fix broken ACL based authentication The function sgsn_auth_state() in sgsn_auth.c checks if a subscriber is allowed to enter the network or not. Depending on the auth policy that is set via the VTY config, different checks apply: SGSN_AUTH_POLICY_CLOSED: requires checking the net (MCC/MNC must match) and also requires to check if the IMSI is inside the ACL list. In this case check_net and check_acl are set to one. SGSN_AUTH_POLICY_ACL_ONLY: only requires the ACL to be correct. Here only check_acl is set to one. In the code at the end of the function we can see that if checking the network is required (check_acl=1) The authentication is granted if MCC/MNC are correct. The function returns at that point, meaning, that an evenually required ACL check is completely ignored. This commit corrects the check logic. Change-Id: I463afa5cc407f5c56d29fb5a501185cd3e7ea5be --- M openbsc/src/gprs/sgsn_auth.c M openbsc/tests/sgsn/sgsn_test.c 2 files changed, 9 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/39/1939/2 diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c index a64339c..c0954c0 100644 --- a/openbsc/src/gprs/sgsn_auth.c +++ b/openbsc/src/gprs/sgsn_auth.c @@ -51,6 +51,7 @@ if (!strcmp(imsi, acl->imsi)) return acl; } + return NULL; } @@ -135,14 +136,16 @@ * of 'our' network */ snprintf(mccmnc, sizeof(mccmnc), "%03d%02d", mmctx->ra.mcc, mmctx->ra.mnc); - if (strncmp(mccmnc, mmctx->imsi, 5) == 0) - return SGSN_AUTH_ACCEPTED; + if (strncmp(mccmnc, mmctx->imsi, 5) != 0) + return SGSN_AUTH_REJECTED; } - if (check_acl && sgsn_acl_lookup(mmctx->imsi, &sgsn->cfg)) - return SGSN_AUTH_ACCEPTED; + if (check_acl) { + if (sgsn_acl_lookup(mmctx->imsi, &sgsn->cfg) == NULL) + return SGSN_AUTH_REJECTED; + } - return SGSN_AUTH_REJECTED; + return SGSN_AUTH_ACCEPTED; } /* diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 2f1513a..3394584 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -930,7 +930,7 @@ */ static void test_gmm_attach(int retry) { - struct gprs_ra_id raid = { 0, }; + struct gprs_ra_id raid = { 45, 123}; struct sgsn_mm_ctx *ctx = NULL; struct sgsn_mm_ctx *ictx; uint32_t ptmsi1; -- To view, visit https://gerrit.osmocom.org/1939 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I463afa5cc407f5c56d29fb5a501185cd3e7ea5be Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:14:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:14:28 +0000 Subject: openbsc[master]: sgsn: Fix broken ACL based authentication In-Reply-To: References: Message-ID: Patch Set 2: Code-Review-1 There probably is some kind of misunderstandign. "CLOSED" in the SGSN so far meant that all "home" subscribers are implicitly accepted, i.e. the old behavior is "correct' from my point of view. Does the documentation state something else? Then we shuold consider changing the documentation? Please clarify. -- To view, visit https://gerrit.osmocom.org/1939 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I463afa5cc407f5c56d29fb5a501185cd3e7ea5be Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:20:57 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:20:57 +0000 Subject: openbsc[master]: sgsn: fix problem with leading-zero-IMSIs In-Reply-To: References: Message-ID: Patch Set 1: Code-Review-2 (1 comment) https://gerrit.osmocom.org/#/c/1938/1/openbsc/src/gprs/sgsn_vty.c File openbsc/src/gprs/sgsn_vty.c: Line 595: sprintf(imsi_sanitized,"%015li", atol(argv[1])); please always use snprintf to ensure we're not overflowing the buffer here. If a number requires more digits than given in the format string, it will attempt to use more digits, so this is not a sufficient safeguard. Also, 'atol()' converts to 'long', which may very well be only 32bits depending on the architectures. And 32bits is only ~ 10 digits. See https://software.intel.com/en-us/articles/size-of-long-integer-type-on-different-architecture-and-os atoll() might be more safe, or even strtoull() as it is even unsigned. But then, it mgih be best to do this all in the 'string' domain to avoid any integer overflow related issues. -- To view, visit https://gerrit.osmocom.org/1938 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:21:10 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:21:10 +0000 Subject: openbsc[master]: XID: resend xid with pdp-ctx-ack messages In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1931 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice66790803154310a61a70a54be76cec539c97a7 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:21:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:21:12 +0000 Subject: [MERGED] openbsc[master]: XID: resend xid with pdp-ctx-ack messages In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: XID: resend xid with pdp-ctx-ack messages ...................................................................... XID: resend xid with pdp-ctx-ack messages If a pdp context is created a xid request is sent right after the pdp-context-ack message. The sending of the pdp-context-ack and the xid message is triggered from the GGSN via the GTP interface. When the pdp-context-ack message is not received by the MS, it will send the pdp-context-request again. A lost pdp-context-ack is resent by the SGSN directly so that the mechanism described above does not work for pdp-context-ack resents. This commit adds code to trigger the sending of xid messages also for resent pdp-context-ack messages. Change-Id: Ice66790803154310a61a70a54be76cec539c97a7 --- M openbsc/src/gprs/gprs_gmm.c 1 file changed, 15 insertions(+), 1 deletion(-) Approvals: Max: Looks good to me, but someone else must approve Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 3f59a2b..da243a4 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -68,6 +68,7 @@ #include #include #include +#include #include @@ -2438,6 +2439,7 @@ char apn_str[GSM_APN_LENGTH] = { 0, }; char *hostname; int rc; + struct gprs_llc_lle *lle; LOGMMCTXP(LOGL_INFO, mmctx, "-> ACTIVATE PDP CONTEXT REQ: SAPI=%u NSAPI=%u ", act_req->req_llc_sapi, act_req->req_nsapi); @@ -2513,7 +2515,19 @@ pdp->ti == transaction_id) { /* This apparently is a re-transmission of a PDP CTX * ACT REQ (our ACT ACK must have got dropped) */ - return gsm48_tx_gsm_act_pdp_acc(pdp); + rc = gsm48_tx_gsm_act_pdp_acc(pdp); + if (rc < 0) + return rc; + + if (pdp->mm->ran_type == MM_CTX_T_GERAN_Gb) { + /* Also re-transmit the SNDCP XID message */ + lle = &pdp->mm->gb.llme->lle[pdp->sapi]; + rc = sndcp_sn_xid_req(lle,pdp->nsapi); + if (rc < 0) + return rc; + } + + return 0; } /* Send reject with GSM_CAUSE_NSAPI_IN_USE */ -- To view, visit https://gerrit.osmocom.org/1931 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ice66790803154310a61a70a54be76cec539c97a7 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:21:29 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:21:29 +0000 Subject: openbsc[master]: Add simple CTRL2SOAP proxy In-Reply-To: References: Message-ID: Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1875 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46 Gerrit-PatchSet: 4 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:22:04 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:22:04 +0000 Subject: openbsc[master]: vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT ... In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1932 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I941851b062999ab4b962430f7b27c19935993e0a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:22:06 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:22:06 +0000 Subject: [MERGED] openbsc[master]: vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT ... In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems ...................................................................... vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems When running the testBSCreload test in close succession, I get a "Connection refused" error because the socket is still in TIME_WAIT state. Passing the SO_REUSEADDR flag allows reusing the addr despite a TIME_WAIT socket. Change-Id: I941851b062999ab4b962430f7b27c19935993e0a --- M openbsc/tests/vty_test_runner.py 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 821c6d3..5836cd4 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1207,6 +1207,7 @@ def nat_msc_test(x, ip, port, verbose = False): msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + msc.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) msc.settimeout(5) msc.bind((ip, port)) msc.listen(5) -- To view, visit https://gerrit.osmocom.org/1932 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I941851b062999ab4b962430f7b27c19935993e0a Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:22:20 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:22:20 +0000 Subject: openbsc[master]: python tests: vty and smpp: speed up >10 times In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1927 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:22:30 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:22:30 +0000 Subject: openbsc[master]: vty tests: close msc socket after nat_msc_test In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1934 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:23:00 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:23:00 +0000 Subject: libosmocore[master]: Export comp128 v2 and v3 routines as well In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1929 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:23:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:23:01 +0000 Subject: [MERGED] libosmocore[master]: Export comp128 v2 and v3 routines as well In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Export comp128 v2 and v3 routines as well ...................................................................... Export comp128 v2 and v3 routines as well It is in the public header file and allows to easily bind it from other languages (without having to go through the abstraction). Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2 --- M src/gsm/libosmogsm.map 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 78e55df..5f2fb8f 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -34,6 +34,8 @@ osmo_c4; bitvec_add_range1024; comp128; +comp128v2; +comp128v3; dbm2rxlev; osmo_earfcn_add; -- To view, visit https://gerrit.osmocom.org/1929 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0128d529c52ec030cfb87b0aff3c69cadf2c59d2 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:23:16 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:23:16 +0000 Subject: openbsc[master]: vty tests: allow picking specific tests to run by name In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:26:26 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:26:26 +0000 Subject: libosmocore[master]: fsm: convenience: add inline osmo_fsm_inst_state_name() In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/1937/1/include/osmocom/core/fsm.h File include/osmocom/core/fsm.h: Line 154: static inline const char *osmo_fsm_inst_state_name(struct osmo_fsm_inst *fi) it's pretty obvious, but let's try to make sure to document all new API. -- To view, visit https://gerrit.osmocom.org/1937 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If9a6ecc4d6e2beaf716569e9a6053d73488e860b Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:26:44 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:26:44 +0000 Subject: openbsc[master]: ctrl_test_runner: speed up more than 10 fold by sleeping less In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1926 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I06569767153838bd9cd3edac001df5f6c567874c Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:26:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:26:49 +0000 Subject: [MERGED] openbsc[master]: ctrl_test_runner: speed up more than 10 fold by sleeping less In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: ctrl_test_runner: speed up more than 10 fold by sleeping less ...................................................................... ctrl_test_runner: speed up more than 10 fold by sleeping less Similar to a recent patch in osmo-python-tests for VTY based tests, but this is for the Ctrl tests. The TestCtrlBase tests gave a constant sleep(2) grace period for the process to startup. This causes tests to take minutes for no reason at all. Add code to TestCtrlBase to try and connect right away, retrying up to three seconds in .1 second intervals. This flies through most tests without any sleep() at all. Change-Id: I06569767153838bd9cd3edac001df5f6c567874c --- M openbsc/tests/ctrl_test_runner.py 1 file changed, 13 insertions(+), 3 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index a115488..5030e8b 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -86,9 +86,19 @@ if verbose: print "Connecting to host %s:%i" % (host, port) - sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sck.setblocking(1) - sck.connect((host, port)) + retries = 30 + while True: + try: + sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sck.setblocking(1) + sck.connect((host, port)) + except IOError: + retries -= 1 + if retries <= 0: + raise + time.sleep(.1) + continue + break self.sock = sck return sck -- To view, visit https://gerrit.osmocom.org/1926 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I06569767153838bd9cd3edac001df5f6c567874c Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:27:19 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:27:19 +0000 Subject: python/osmo-python-tests[master]: osmoutil: end_proc: wait for term in a loop In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1936 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I98849e4550116c5666fdf6f5d4cbb576ffa3e14a Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:27:40 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:27:40 +0000 Subject: python/osmo-python-tests[master]: osmoutil: add pick_test() to pick unittest tests by name In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1935 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I92f90c334169f31920c63dd5c5ac8dac215065e6 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:28:01 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:28:01 +0000 Subject: openbsc[master]: silent_call: remove unfinished fuzzer interface In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1930 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:28:03 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:28:03 +0000 Subject: [MERGED] openbsc[master]: silent_call: remove unfinished fuzzer interface In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: silent_call: remove unfinished fuzzer interface ...................................................................... silent_call: remove unfinished fuzzer interface Remove the fuzzer interface that was partially implemented in gsm_04_08.c and silent_call.c is causing problems when an SMS is sent during an active silent call. The reason for this is that gsm0408_dispatch() in gsm_04_08.c would decide to rout all uplink traffic to silent_call_rx() in silent_call.c. silent_call_rx() is a stub function that discards the data. This patch removes the fuzzer interface code by placing ifdefs around it, so that it can be re-activated by experimentators. Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc --- M openbsc/include/openbsc/silent_call.h M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/silent_call.c 3 files changed, 9 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/openbsc/include/openbsc/silent_call.h b/openbsc/include/openbsc/silent_call.h index 2492903..619a543 100644 --- a/openbsc/include/openbsc/silent_call.h +++ b/openbsc/include/openbsc/silent_call.h @@ -6,7 +6,10 @@ extern int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data, int type); extern int gsm_silent_call_stop(struct gsm_subscriber *subscr); + +#if 0 extern int silent_call_rx(struct gsm_subscriber_connection *conn, struct msgb *msg); extern int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg); +#endif #endif /* _SILENT_CALL_H */ diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index be43956..3cc86ba 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -3958,8 +3958,10 @@ OSMO_ASSERT(msg); LOGP(DRLL, LOGL_DEBUG, "Dispatching 04.08 message, pdisc=%d\n", pdisc); +#if 0 if (silent_call_reroute(conn, msg)) return silent_call_rx(conn, msg); +#endif switch (pdisc) { case GSM48_PDISC_CC: diff --git a/openbsc/src/libmsc/silent_call.c b/openbsc/src/libmsc/silent_call.c index 131a178..590d01b 100644 --- a/openbsc/src/libmsc/silent_call.c +++ b/openbsc/src/libmsc/silent_call.c @@ -72,6 +72,7 @@ return rc; } +#if 0 /* receive a layer 3 message from a silent call */ int silent_call_rx(struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -79,6 +80,7 @@ LOGP(DLSMS, LOGL_NOTICE, "Discarding L3 message from a silent call.\n"); return 0; } +#endif struct msg_match { uint8_t pdisc; @@ -91,6 +93,7 @@ { GSM48_PDISC_MM, GSM48_MT_MM_CM_SERV_REQ }, }; +#if 0 /* decide if we need to reroute a message as part of a silent call */ int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg) { @@ -114,6 +117,7 @@ LOGP(DLSMS, LOGL_INFO, "Rerouting L3 message from a silent call.\n"); return 1; } +#endif /* initiate a silent call with a given subscriber */ -- To view, visit https://gerrit.osmocom.org/1930 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: dexter Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:28:26 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:28:26 +0000 Subject: openbsc[master]: meas_json: fix NEIGH: missing array braces In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:28:39 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:28:39 +0000 Subject: openbsc[master]: meas_json: fix NEIGH: missing array braces In-Reply-To: References: Message-ID: Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:29:08 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:29:08 +0000 Subject: openbsc[master]: meas_json: fix NEIGH: missing array braces In-Reply-To: References: Message-ID: Patch Set 3: would be great to get Alexanders' input, but he cannot be added, i.e. it seems he has no gerrit account? -- To view, visit https://gerrit.osmocom.org/1916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:30:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:30:53 +0000 Subject: openggsn[master]: Code formatted to be in line with formatting rules. In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1902 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Jovan Bunjevacki Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:30:56 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:30:56 +0000 Subject: [MERGED] openggsn[master]: Code formatted to be in line with formatting rules. In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: Code formatted to be in line with formatting rules. ...................................................................... Code formatted to be in line with formatting rules. Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 --- M sgsnemu/sgsnemu.c 1 file changed, 34 insertions(+), 15 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index a4d6461..1567e7e 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -70,7 +70,7 @@ /* 3: Done */ /* 4: Wait_disconnect */ /* 5: Disconnected */ -int state = 0; +volatile sig_atomic_t state = 0; struct gsn_t *gsn = NULL; /* GSN instance */ struct tun_t *tun = NULL; /* TUN instance */ @@ -153,6 +153,12 @@ int tsum = 0; int pingseq = 0; /* Ping sequence counter */ struct timeval firstping; + +void signal_handler(int signo) +{ + if (state == 2) + state = 3; /* Tell main loop to finish. */ +} int ipset(struct iphash_t *ipaddr, struct in_addr *addr) { @@ -1417,10 +1423,15 @@ int starttime = time(NULL); /* Time program was started */ int stoptime = 0; /* Time to exit */ int pingtimeout = 0; /* Time to print ping statistics */ + int signal_received; /* If select() on fd_set is interrupted by signal. */ struct timezone tz; /* Used for calculating ping times */ struct timeval tv; int diff; + + signal(SIGTERM, signal_handler); + signal(SIGHUP, signal_handler); + signal(SIGINT, signal_handler); osmo_init_logging(&log_info); @@ -1676,10 +1687,14 @@ printf("idletime.tv_sec %d, idleTime.tv_usec %d\n", (int)idleTime.tv_sec, (int)idleTime.tv_usec); + signal_received = 0; switch (select(maxfd + 1, &fds, NULL, NULL, &idleTime)) { case -1: - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "Select returned -1"); + if (errno == EINTR) + signal_received = 1; + else + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "Select returned -1"); break; case 0: gtp_retrans(gsn); /* Only retransmit if nothing else */ @@ -1688,19 +1703,23 @@ break; } - if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { - SYS_ERR(DSGSN, LOGL_ERROR, 0, - "TUN decaps failed"); + if (!signal_received) { + + if ((tun) && FD_ISSET(tun->fd, &fds) && tun_decaps(tun) < 0) { + SYS_ERR(DSGSN, LOGL_ERROR, 0, + "TUN decaps failed"); + } + + if (FD_ISSET(gsn->fd0, &fds)) + gtp_decaps0(gsn); + + if (FD_ISSET(gsn->fd1c, &fds)) + gtp_decaps1c(gsn); + + if (FD_ISSET(gsn->fd1u, &fds)) + gtp_decaps1u(gsn); + } - - if (FD_ISSET(gsn->fd0, &fds)) - gtp_decaps0(gsn); - - if (FD_ISSET(gsn->fd1c, &fds)) - gtp_decaps1c(gsn); - - if (FD_ISSET(gsn->fd1u, &fds)) - gtp_decaps1u(gsn); } gtp_free(gsn); /* Clean up the gsn instance */ -- To view, visit https://gerrit.osmocom.org/1902 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167 Gerrit-PatchSet: 2 Gerrit-Project: openggsn Gerrit-Branch: master Gerrit-Owner: Jovan Bunjevacki Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Jovan Bunjevacki From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:31:12 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:31:12 +0000 Subject: python/osmo-python-tests[master]: osmoutil: end_proc: speed up tests yet a bit more In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1928 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6fd520bae81be129e23a48e3daa122e6bae5630d Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:31:33 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:31:33 +0000 Subject: python/osmo-python-tests[master]: test_all_apps: actually count nr of errors In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1925 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I690dde3711555a3447e5ad4cc0a04a7a869a8296 Gerrit-PatchSet: 1 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:36:34 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:36:34 +0000 Subject: openbsc[master]: libmsc/update_db_revision_3(): free memleaking db result In-Reply-To: References: Message-ID: Patch Set 2: Code-Review+2 (1 comment) https://gerrit.osmocom.org/#/c/1750/2/openbsc/src/libmsc/db.c File openbsc/src/libmsc/db.c: Line 349: } else { we normally put single line blocks without {}, but nevermind. -- To view, visit https://gerrit.osmocom.org/1750 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:36:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:36:36 +0000 Subject: [MERGED] openbsc[master]: libmsc/update_db_revision_3(): free memleaking db result In-Reply-To: References: Message-ID: Harald Welte has submitted this change and it was merged. Change subject: libmsc/update_db_revision_3(): free memleaking db result ...................................................................... libmsc/update_db_revision_3(): free memleaking db result Found by ASAN Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 --- M openbsc/src/libmsc/db.c 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 68dac76..9fa6415 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -346,6 +346,8 @@ LOGP(DDB, LOGL_ERROR, "Failed to commit the transaction (upgrade from rev 3)\n"); return -EINVAL; + } else { + dbi_result_free(result); } /* Shrink DB file size by actually wiping out SMS_3 table data */ -- To view, visit https://gerrit.osmocom.org/1750 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3 Gerrit-PatchSet: 3 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:37:17 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:37:17 +0000 Subject: libosmocore[master]: Handle replies in ctrl_cmd_handle() In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1896 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:39:18 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:39:18 +0000 Subject: libosmocore[master]: Fix client-side ctrl interface helpers In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1897 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iaa209e34a849ce0dfe2e29b482c3208ade1a32a4 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:40:53 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:40:53 +0000 Subject: osmo-hlr[master]: cosmetic: refactor auc_compute_vectors(), add debug log In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/1869 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifb36d010a4ac64c765517e15b9074424ec19cc60 Gerrit-PatchSet: 1 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:48:15 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:48:15 +0000 Subject: osmo-sip-connector[master]: dtmf: Start handling the DTMF MNCC messages and respond In-Reply-To: References: Message-ID: Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/1873 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5 Gerrit-PatchSet: 1 Gerrit-Project: osmo-sip-connector Gerrit-Branch: master Gerrit-Owner: Holger Freyther Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:49:29 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:49:29 +0000 Subject: openbsc[master]: subscriber conn: add indicator for originating interface In-Reply-To: References: Message-ID: Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/1858/1/openbsc/include/openbsc/gsm_data.h File openbsc/include/openbsc/gsm_data.h: Line 107: enum interface_type { interface is a bit generic. let's call it ran_type. Might also be good to call it RAN_TYPE_GERAN_A and RAN_TYPE_UTRAN_IU. According to specs there's also a RAN_TYPE_GERAN_IU, which we don't implement so far. But would be good to have at least the naming in a way that states it clearly. -- To view, visit https://gerrit.osmocom.org/1858 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I93b870522f725170e4265a5543f6b680383d7465 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: Yes From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:51:36 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:51:36 +0000 Subject: libosmocore[master]: Add osmo_rand() function In-Reply-To: References: Message-ID: Patch Set 2: I think it would be best to map this to the linux getrandom(2) syscall by default. It is in mainline linux kernel since 2014, and we should use it by default to avoid any external crypto library dependency. If this syscall exists at compile time (we can check with autoconf if the function getrandom() is defined in linux/random.h), then we should use it. -- To view, visit https://gerrit.osmocom.org/1526 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048 Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:53:50 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:53:50 +0000 Subject: libosmocore[master]: libosmocoding: migrate transcoding routines from OsmoBTS In-Reply-To: References: Message-ID: Patch Set 15: Sylvain, Tom, it would be great to get your input here to see if this patch can be merged. -- To view, visit https://gerrit.osmocom.org/933 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1 Gerrit-PatchSet: 15 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Tom Tsou Gerrit-Reviewer: Vadim Yanitskiy Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:54:49 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:54:49 +0000 Subject: libosmocore[master]: utils/conv_gen.py: add header generation feature In-Reply-To: References: Message-ID: Patch Set 5: tnt? -- To view, visit https://gerrit.osmocom.org/1593 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iae830d716f01810972edbef14fc5383ac647d0ea Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: tnt Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:55:46 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:55:46 +0000 Subject: osmo-pcu[master]: remove pcu own bitvector implementation In-Reply-To: References: Message-ID: Patch Set 2: let's wait for a response on the testing question/ -- To view, visit https://gerrit.osmocom.org/1753 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-HasComments: No From gerrit-no-reply at lists.osmocom.org Tue Feb 28 18:59:28 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 18:59:28 +0000 Subject: [ABANDON] openbsc[master]: tests/bsc & bsc-nat: fix mem leaks of talloc ctx In-Reply-To: References: Message-ID: Harald Welte has abandoned this change. Change subject: tests/bsc & bsc-nat: fix mem leaks of talloc ctx ...................................................................... Abandoned i think for one-shot test cases we don't worry. -- To view, visit https://gerrit.osmocom.org/1752 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: If1f08df7bcfd1d115824dc1f30577f632bb32615 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus From gerrit-no-reply at lists.osmocom.org Tue Feb 28 19:00:10 2017 From: gerrit-no-reply at lists.osmocom.org (Harald Welte) Date: Tue, 28 Feb 2017 19:00:10 +0000 Subject: [ABANDON] openbsc[master]: tests: fix leaks by talloc ctx In-Reply-To: References: Message-ID: Harald Welte has abandoned this change. Change subject: tests: fix leaks by talloc ctx ...................................................................... Abandoned I think for one-shot test cases we dont want to go through the extra effort. It's quite normal not to release memory or not to close all sockets/fds when we are terminating the process anyway. -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr