From holger at freyther.de Fri Mar 4 21:53:33 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 4 Mar 2016 22:53:33 +0100 Subject: Redmine theme In-Reply-To: <20160229092113.GA2199@dub6> References: <20160229092113.GA2199@dub6> Message-ID: <49D9A02C-D183-4EA1-A454-002CC74CBFCD@freyther.de> > On 29 Feb 2016, at 10:21, Neels Hofmeyr wrote: > > On Mon, Feb 29, 2016 at 10:17:43AM +0600, ????? ??????? wrote: >> I suggest to change a stock Redmine theme to something more beautiful, >> for example gitmike: https://github.com/makotokw/redmine-theme-gitmike > > +0.5 for using a different theme. gitmike does look slick but IMHO tends > to have not enough contrast. And whether we want to look like github of > all things is a bikeshed, too ;) https://github.com/openSUSE-Team/redmine-bentoish and https://progress.opensuse.org for an installation/preview. They load the logo through a CSS rule to match on the h1/header... holger From laforge at gnumonks.org Sat Mar 5 04:35:39 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 5 Mar 2016 11:35:39 +0700 Subject: Redmine theme In-Reply-To: <20160229092113.GA2199@dub6> References: <20160229092113.GA2199@dub6> Message-ID: <20160305043539.GB10222@nataraja> On Mon, Feb 29, 2016 at 10:21:13AM +0100, Neels Hofmeyr wrote: > On Mon, Feb 29, 2016 at 10:17:43AM +0600, ????? ??????? wrote: > > I suggest to change a stock Redmine theme to something more beautiful, > > for example gitmike: https://github.com/makotokw/redmine-theme-gitmike > > +0.5 for using a different theme. gitmike does look slick but IMHO tends > to have not enough contrast. And whether we want to look like github of > all things is a bikeshed, too ;) Also, if you replace the small square logo with the osmocom logo, that logo ends up overlapping the entire menu bar. So even the 'gitmike' theme is not really suited for adding a logo on the left hand side :/ -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Sat Mar 5 06:21:38 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Sat, 5 Mar 2016 12:21:38 +0600 Subject: Redmine theme In-Reply-To: <20160305043539.GB10222@nataraja> References: <20160229092113.GA2199@dub6> <20160305043539.GB10222@nataraja> Message-ID: I have tried to replace the logo using srlabs.de site as workground (just for example). I don't know how to make the search bar look fine, so I removed it. But I think it's possible. Changes #header { background-image: url("http://projects.osmocom.org/images/osmocom_logo.png "); background-repeat: no-repeat; background-position: 20px 10px; } See attachment. ? ?????????? ???????????, ??????? ?????. 2016-03-05 10:35 GMT+06:00 Harald Welte : > On Mon, Feb 29, 2016 at 10:21:13AM +0100, Neels Hofmeyr wrote: > > On Mon, Feb 29, 2016 at 10:17:43AM +0600, ????? ??????? wrote: > > > I suggest to change a stock Redmine theme to something more beautiful, > > > for example gitmike: https://github.com/makotokw/redmine-theme-gitmike > > > > +0.5 for using a different theme. gitmike does look slick but IMHO tends > > to have not enough contrast. And whether we want to look like github of > > all things is a bikeshed, too ;) > > Also, if you replace the small square logo with the osmocom logo, that > logo ends up overlapping the entire menu bar. So even the 'gitmike' > theme is not really suited for adding a logo on the left hand side :/ > > -- > - Harald Welte > http://laforge.gnumonks.org/ > > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. > A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: wiki.png Type: image/png Size: 36180 bytes Desc: not available URL: From 246tnt at gmail.com Sat Mar 5 06:34:47 2016 From: 246tnt at gmail.com (Sylvain Munaut) Date: Sat, 5 Mar 2016 07:34:47 +0100 Subject: Redmine theme In-Reply-To: <20160305043539.GB10222@nataraja> References: <20160229092113.GA2199@dub6> <20160305043539.GB10222@nataraja> Message-ID: > Also, if you replace the small square logo with the osmocom logo, that > logo ends up overlapping the entire menu bar. So even the 'gitmike' > theme is not really suited for adding a logo on the left hand side :/ Adjusting the padding works fine : padding: 85px 0px 0px 20px; gives http://i.imgur.com/Uwd0EZf.png Cheers, Sylvain From holger at freyther.de Sat Mar 5 14:17:54 2016 From: holger at freyther.de (Holger Freyther) Date: Sat, 5 Mar 2016 15:17:54 +0100 Subject: Redmine theme In-Reply-To: References: <20160229092113.GA2199@dub6> <20160305043539.GB10222@nataraja> Message-ID: <9FD49B54-9683-4D6F-A024-DC22F1588025@freyther.de> > On 05 Mar 2016, at 07:34, Sylvain Munaut <246tnt at gmail.com> wrote: > >> Also, if you replace the small square logo with the osmocom logo, that >> logo ends up overlapping the entire menu bar. So even the 'gitmike' >> theme is not really suited for adding a logo on the left hand side :/ > > > Adjusting the padding works fine : > > padding: 85px 0px 0px 20px; thanks! I enabled it. At least it looks a bit different than the standard theme. What do you guys think? Not sure I like the SUSE green and the box alignment could be better :) holger From hschmidt at ernw.de Sun Mar 6 10:51:34 2016 From: hschmidt at ernw.de (Hendrik Schmidt) Date: Sun, 6 Mar 2016 11:51:34 +0100 Subject: SMPP Routes Message-ID: <56DC0BB6.4050905@ernw.de> Dear all, I am currently playing around with the new SMPP feature, but struggling a bit on routing in direction of esme. Of course, when using default-route, all customers will be routed to the esme which are not in the database; but what if I just want to route specific prefixes (or single numbers?). Currently, when using "route" and some combinations of international/national prefixes, I dont get it working. Is there a documentation to this, without reading all numbering plans of gsma etc? E.g. what I want to do: - only route number 1234 via SMPP - route everything via SMPP which starts with a "1" Thanks & Best, Hendrik -- Hendrik Schmidt ERNW GmbH - Carl-Bosch-Stra?e 4 - 69115 Heidelberg - www.ernw.de Central Back Office Tel. +49 6221 480390 - Fax 6221 419008 - Cell +49 151 16227562 Handelsregister Mannheim: HRB 337135 Geschaeftsfuehrer: Enno Rey ======================================================= Blog: www.insinuator.net || Conference: www.troopers.de ======================================================= From laforge at gnumonks.org Sun Mar 6 11:40:37 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 6 Mar 2016 18:40:37 +0700 Subject: SMPP Routes In-Reply-To: <56DC0BB6.4050905@ernw.de> References: <56DC0BB6.4050905@ernw.de> Message-ID: <20160306114037.GB5976@nataraja> Hi Hendrik, On Sun, Mar 06, 2016 at 11:51:34AM +0100, Hendrik Schmidt wrote: > I am currently playing around with the new SMPP feature, but struggling > a bit on routing in direction of esme. Of course, when using > default-route, all customers will be routed to the esme which are not in > the database; but what if I just want to route specific prefixes (or > single numbers?). this is very well supported. > Currently, when using "route" and some combinations of > international/national prefixes, I dont get it working. I think the easiest option is to send a SMS from a phone (to another phone on osmonitb) and check the SMS messages in wireshark to determine the numbering-plan / type-of-number from there. Then add a route with matching parameters, and it should end up matching from that point on. > Is there a documentation to this, without reading all numbering plans > of gsma etc? The monday-to-be-publicly-announced user manuals contain a bit on that regard, see chapter 13 of http://ftp.osmocom.org/docs/latest/osmonitb-usermanual.pdf as well as the smpp/esme node part of the auto-generated http://ftp.osmocom.org/docs/latest/osmonitb-vty-reference.pdf > E.g. what I want to do: > - only route number 1234 via SMPP I think this might not even be possible at the moment, as only prefix-routes and default routes are implemented. so if you add a prefix route for 1234, then 1234567 would still match. Patches for single-number routes are welcome :) > - route everything via SMPP which starts with a "1" that's a prefix-route for '1' I think we would also accept a patch that adds a catch-all numbering-plan / type-of-number, if you think it is a useful feature to have. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Mon Mar 7 10:30:40 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 7 Mar 2016 11:30:40 +0100 Subject: Redmine theme In-Reply-To: <49D9A02C-D183-4EA1-A454-002CC74CBFCD@freyther.de> References: <20160229092113.GA2199@dub6> <49D9A02C-D183-4EA1-A454-002CC74CBFCD@freyther.de> Message-ID: <20160307103040.GB1356@dub6> On Fri, Mar 04, 2016 at 10:53:33PM +0100, Holger Freyther wrote: > https://github.com/openSUSE-Team/redmine-bentoish and https://progress.opensuse.org for an installation/preview. They load the logo through a CSS rule to match on the h1/header... For me this has the same quirk of not enough contrast. There I prefer the redmine theme, it has a near black font on the white background: common sensical design choice ... IMHO #808080-on-white is plain stupid. I could clone the theme and modify the font color for contrast, and then I'd be fine with any of the two themes suggested (github or opensuse). For opensuse this would probably suffice: [[[ table.list tr.issue a { color: #000; } span.description, #search-results dd span.description { color: #000; } ]]] And while at it I'd enlarge the font just a tad, but here I'm certainly drifting into deep bikeshed lands again. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Mon Mar 7 13:21:43 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 7 Mar 2016 14:21:43 +0100 Subject: libosmo-sccp: branch sysmocom/iu Message-ID: <20160307132143.GA7244@dub6> I've created a branch sysmocom/iu based on the laforge/wip branch currently used for 3G dev. I've added minor commits and rebased the branch onto current master. The tendency should be to use sysmocom/iu in libosmo-sccp for 3G development (and coverity @Holger). ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Mon Mar 7 16:36:46 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 7 Mar 2016 17:36:46 +0100 Subject: [PATCH] Remove unused auth code and add comment Message-ID: <1457368606-18297-1-git-send-email-nhofmeyr@sysmocom.de> As commented in the code, the GSM_SECURITY_AUTH_FAILED path is never invoked by the gsm48_secure_channel() function as it is today. Note that the upcoming Iu auth will probably add a GSM_SECURITY_AUTH_FAILED status. In that case, sending a LU Reject immediately may be desirable, but arguably a bit of timeout could make life harder for auth attackers. The code removed by this patch doesn't send out a LU Reject ever, since a call to release_loc_updating_req() only releases the connection. To reject, a call to gsm0408_loc_upd_rej() would be necessary, as seen in loc_upd_rej_cb(). And finally, if _gsm0408_authorize_sec_cb() doesn't do anything about anything, the same loc_upd_rej_cb() will be run by a timeout and send a LU Reject properly (as commented in the code). --- openbsc/src/libmsc/gsm_04_08.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index d9d7390..47f3fa7 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -340,10 +340,6 @@ static int _gsm0408_authorize_sec_cb(unsigned int hooknum, unsigned int event, int rc = 0; switch (event) { - case GSM_SECURITY_AUTH_FAILED: - release_loc_updating_req(conn, 1); - break; - case GSM_SECURITY_ALREADY: LOGP(DMM, LOGL_ERROR, "We don't expect LOCATION " "UPDATING after CM SERVICE REQUEST\n"); @@ -354,6 +350,19 @@ static int _gsm0408_authorize_sec_cb(unsigned int hooknum, unsigned int event, rc = finish_lu(conn); break; + case GSM_SECURITY_AUTH_FAILED: + /* + * gsm48_secure_channel() will pass only + * GSM_SECURITY_NOAVAIL in case of failure. If future + * code should add a GSM_SECURITY_AUTH_FAILED status in + * this code path, letting the Location Update time out + * will do all necessary error messaging and logging, + * see loc_upd_rej_cb(). + */ + LOGP(DMM, LOGL_ERROR, + "Authorization failed for subscriber %s\n", + subscr_name(conn->subscr)); + /* fall through */ default: rc = -EINVAL; }; -- 2.1.4 From laforge at gnumonks.org Mon Mar 7 17:48:10 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 8 Mar 2016 00:48:10 +0700 Subject: Public Osmocom User Manuals Message-ID: <20160307174810.GQ5976@nataraja> Dear all, some of you may have already seen it on the RSS feed, on Twitter or on planet.osmocom.org[1]: sysmocom has decided that we will re-release our existing formerly sysmocom-internal User Manuals and VTY reference manuals under GNU GFDL. The hope is that with better documentation we can enable more people to use Osmocom software more easily, leading to more adoption. While those manuals are far from being complete or perfect, I had spent a lot of time in February on further polishing them for the upcoming public release. I do believe they provide a better stasting point than what all of what we had in the wiki (whether old trac or new redmine). The manuals are written in asciidoc[2], with the occasional use of mscgen[3] and graphviz[4], which I believe together are a pretty good set of tools to very efficiently and productively work on documentation, whilst focussing on actual content and not on formatting/syntax like when using docbook-xml or LaTeX. The osmo-gsm-manuals.git repository is pulled by our jenkins installation, which then builds the PDF manuals and pushes them to http://ftp.osmocom.org/docs/latest/ I seriously do hope that we will receive improvements and extensions for the manuals. As the asciidoc source is in yet another git repo, sending patches is as easy as it gets. Holger always states nobody ever contributes to manuals, and I would love to prove him wrong ;) In terms of overlapping information in the wiki and in the manuals: I'm in favor (and in the process) of removing outdated old wiki command line reference and VTY reference sections, and simply referring to the manuals instead. Please do read through the manuals and do send patches, whether it's a spelling fix, improved wording, adding missing information or fixing actual technical mistakes. In tems of further dccumentation improvements, Holger has volunteered to ensure that the Doxygen API of libosmocore is also automatically generated+pushed in a similar fashion to make it publicly web-visible. I'd also encurage everyone to contribute patches to covert those parts of libosmocore.git that don't hve doxygen annotation yet. Thanks in advance! Regards, Harald [1] http://projects.osmocom.org/news/47 [2] http://asciidoc.org/ [3] http://www.mcternan.me.uk/mscgen/ [4] http://www.graphviz.org/ -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Mon Mar 7 19:17:46 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 7 Mar 2016 20:17:46 +0100 Subject: Public Osmocom User Manuals In-Reply-To: <20160307174810.GQ5976@nataraja> References: <20160307174810.GQ5976@nataraja> Message-ID: <093B635E-E9F9-4607-B032-0F4E692F8F24@freyther.de> > On 07 Mar 2016, at 18:48, Harald Welte wrote: > > In tems of further dccumentation improvements, Holger has volunteered to > ensure that the Doxygen API of libosmocore is also automatically > generated+pushed in a similar fashion to make it publicly web-visible. > I'd also encurage everyone to contribute patches to covert those parts > of libosmocore.git that don't hve doxygen annotation yet. http://ftp.osmocom.org/api/latest/libosmocore/ http://ftp.osmocom.org/api/latest/libosmocore/codec/html/index.html http://ftp.osmocom.org/api/latest/libosmocore/core/html/index.html http://ftp.osmocom.org/api/latest/libosmocore/gsm/html/index.html http://ftp.osmocom.org/api/latest/libosmocore/vty/html/index.html If I would use this to find out about the API I would miss an overview page that lists all the libraries and links to them. I think we need some tweaks to the doxygen configuration to link it together? Anyone has experience with that? Like the manuals these documents are updated by jenkins after every change to libosmocore. If there are other projects that would like to update documentation I am happy to add it too. kind regards holger From laforge at gnumonks.org Mon Mar 7 20:06:41 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 8 Mar 2016 03:06:41 +0700 Subject: command for location update In-Reply-To: <6FEFE9A1-D0AE-4866-9960-1313954849A0@gmail.com> References: <6FEFE9A1-D0AE-4866-9960-1313954849A0@gmail.com> Message-ID: <20160307200641.GR5976@nataraja> Hi Robert, On Mon, Feb 29, 2016 at 04:26:22PM +0200, robert wrote: > Is it possible to have the virtual BTS start a location update at a > specific time. In other words, can I add a command that asks all > phones to request a location update at any desired time ? Not at this point. I think for something like this, what would make sense is to a) finish osmo-bts-virtual at all in the first place (it only does downlink at the moment) b) implement GSMTAP virtual UM support in OsmocomBB 'mobile' c) add a scripting-language interface to OsmocoBB 'mobile' d) then trigger the LU from that scripting language based on timers there We're always open for patches and would welcome your contribution to the project. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Mon Mar 7 21:14:10 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 7 Mar 2016 22:14:10 +0100 Subject: patchwork "fork" at freedesktop.org/intel Message-ID: Hi guys, the three issues I have with patch work: 1.) No integration with testing (some machine could apply, build and run make check before I do) 2.) Tracking of patches and not series (we seldomly want a single patch) 3.) No feedback if something has been applied Now Intel[1] seems to have had some of the same concern because: 1.) Their patchwork has a "pull"/"stream" API to wait for changes and execute them. It is in their manual. For us this means we need to somehow figure out where the patch applies to. We can either have the discipline to put this into the subject (git send-email can do it) or we try to see which repository has the specific base commit. It also supports sending back mails with the patch result. 2.) They track series now. 3.) This seems to be unsolved. But we can probably do something ourselves with a little discipline (and in a how-to-contribute documentation). We can use the Change-Id concept that is used by Gerrit. This is a simple local hook that adds a "Change-Id: " line with a unique number. so we will probably end up hosting our own patchwork and try to get intel help/work on 3rd. Could we get a consensus how we know where to apply the patch to? kind regards holger [1] http://damien.lespiau.name/2016/02/augmenting-mailing-lists-with-patchwork.html From nhofmeyr at sysmocom.de Tue Mar 8 13:12:09 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 8 Mar 2016 14:12:09 +0100 Subject: patchwork "fork" at freedesktop.org/intel In-Reply-To: References: Message-ID: <20160308131209.GC1989@dub6> On Mon, Mar 07, 2016 at 10:14:10PM +0100, Holger Freyther wrote: > Could we get a consensus how we know where to apply the patch to? I had basically the same question when I started in the osmocom code a while back. It was mostly for not having to search around to understand the context. That problem is by now pretty much "fixed", I mostly know what's going on and anyway have a ctags file across all the git repositories to find things easily... The based-on-parent-hash approach sounds like a good solution for robots? But I'm not sure how that works in detail. Are we talking about this? index d9d7390..47f3fa7 100644 It seems to be the hash for the file object, not the parent commit. So one could look for this hash in the git objects database...? It should definitely be something that works automatically, because we *will* forget anything that must be remembered manually. ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From holger at freyther.de Tue Mar 8 15:20:27 2016 From: holger at freyther.de (Holger Freyther) Date: Tue, 8 Mar 2016 16:20:27 +0100 Subject: patchwork "fork" at freedesktop.org/intel In-Reply-To: <20160308131209.GC1989@dub6> References: <20160308131209.GC1989@dub6> Message-ID: <7B1AD72B-350C-44B7-A8D9-1E6437946859@freyther.de> > On 08 Mar 2016, at 14:12, Neels Hofmeyr wrote: > > On Mon, Mar 07, 2016 at 10:14:10PM +0100, Holger Freyther wrote: >> Could we get a consensus how we know where to apply the patch to? > > I had basically the same question when I started in the osmocom code a > while back. It was mostly for not having to search around to understand > the context. That problem is by now pretty much "fixed", I mostly know > what's going on and anyway have a ctags file across all the git > repositories to find things easily... I thought we had "From: hash.." or such in git send-email but maybe that was never the case (I wonder how git am -3 patch is implemented then). When using git format-patch there is a from (e.g. From 9b090fd5ab2f6b36a60b41a4f4ac9bd435f18582 Mon Sep 17 00:00:00 2001) but not in the patchwork.. hmm > > The based-on-parent-hash approach sounds like a good solution for robots? > But I'm not sure how that works in detail. Are we talking about this? > > index d9d7390..47f3fa7 100644 > > It seems to be the hash for the file object, not the parent commit. > So one could look for this hash in the git objects database...? openbsc ich$ git cat-file -t d9d7390 blob so that file is in OpenBSC.. now if the _same_ file is in two repositories we have an issue. :) > > It should definitely be something that works automatically, because we > *will* forget anything that must be remembered manually. git config --local format.subjectprefix "libosmocore][PATCH" could be put in the git config of that repository. Sure we will get it wrong once in a while but it might be an alternative. holger From holger at freyther.de Tue Mar 8 15:27:44 2016 From: holger at freyther.de (Holger Freyther) Date: Tue, 8 Mar 2016 16:27:44 +0100 Subject: Redmine theme In-Reply-To: <20160307103040.GB1356@dub6> References: <20160229092113.GA2199@dub6> <49D9A02C-D183-4EA1-A454-002CC74CBFCD@freyther.de> <20160307103040.GB1356@dub6> Message-ID: > On 07 Mar 2016, at 11:30, Neels Hofmeyr wrote: > > > For opensuse this would probably suffice: > [[[ > table.list tr.issue a { > color: #000; > } > span.description, #search-results dd span.description { > color: #000; > } > ]]] the first i could modify.. the second I added.. does it look right now? From holger at freyther.de Tue Mar 8 17:19:27 2016 From: holger at freyther.de (Holger Freyther) Date: Tue, 8 Mar 2016 18:19:27 +0100 Subject: New build.opensuse.org (OBS) project for network:osmocom Message-ID: <2DE9A14D-1DF5-48F7-AF12-7BEBD956DC0D@freyther.de> Hi guys, while I am super happy that people move libosmocore and other libraries and projects into the distributions I think it makes sense to provide some packages ourselves as well (e.g. if we want to add Long Term Support, or make nightly builds available). The OpenSUSE folks created "network:osmocom" for us and currently both Harald and me have the necessary privileges to add packages (and probably subprojects). kind regards holger From holger at freyther.de Tue Mar 8 17:35:18 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 8 Mar 2016 18:35:18 +0100 Subject: [PATCH 1/3] mgcp: Move the transcoding routines into a struct Message-ID: <1457458520-34314-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther We will have the NOOP implementation (e.g. used by the NAT), the SW implementation (using software codecs), a HW assisted one that will use a DSP to do transcoding and in theory the RTP based one (but I will remove that code). --- openbsc/include/openbsc/mgcp.h | 14 ++++++------- openbsc/include/openbsc/mgcp_internal.h | 15 ++++++++++++-- openbsc/include/openbsc/mgcp_transcode.h | 2 ++ openbsc/src/libmgcp/mgcp_network.c | 3 ++- openbsc/src/libmgcp/mgcp_protocol.c | 33 ++++++++++++++++++------------ openbsc/src/libmgcp/mgcp_transcode.c | 12 ++++++++--- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 10 ++++----- openbsc/tests/mgcp/mgcp_transcoding_test.c | 11 ++++++---- 8 files changed, 63 insertions(+), 37 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index b2262bc..a216547 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -1,8 +1,8 @@ /* A Media Gateway Control Protocol Media Gateway: RFC 3435 */ /* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves + * (C) 2009-2016 by Holger Hans Peter Freyther + * (C) 2009-2016 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -69,6 +69,7 @@ struct mgcp_endpoint; struct mgcp_config; struct mgcp_trunk_config; struct mgcp_rtp_end; +struct mgcp_transcoding; #define MGCP_ENDP_CRCX 1 #define MGCP_ENDP_DLCX 2 @@ -158,6 +159,9 @@ struct mgcp_trunk_config { /* spec handling */ int force_realloc; + /* transcoding */ + const struct mgcp_transcoding *transcoder; + /* timer */ struct osmo_timer_list keepalive_timer; @@ -184,12 +188,6 @@ struct mgcp_config { struct in_addr transcoder_in; int transcoder_remote_base; - /* RTP processing */ - mgcp_processing rtp_processing_cb; - mgcp_processing_setup setup_rtp_processing_cb; - - mgcp_get_format get_net_downlink_format_cb; - struct osmo_wqueue gw_fd; struct mgcp_port_range bts_ports; diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 7c89d10..a62dbb2 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -1,8 +1,8 @@ /* MGCP Private Data */ /* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves + * (C) 2009-2016 by Holger Hans Peter Freyther + * (C) 2009-2016 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -150,6 +150,17 @@ enum mgcp_type { MGCP_OSMUX_BSC_NAT, }; +/** + * Function pointers for RTP processing/transcoding + */ +struct mgcp_transcoding { + mgcp_processing processing_cb; + mgcp_processing_setup setup_processing_cb; + mgcp_get_format get_net_downlink_format_cb; +}; + +extern const struct mgcp_transcoding *mgcp_default_transcoder; + #include struct mgcp_endpoint { diff --git a/openbsc/include/openbsc/mgcp_transcode.h b/openbsc/include/openbsc/mgcp_transcode.h index 147e48b..02b039d 100644 --- a/openbsc/include/openbsc/mgcp_transcode.h +++ b/openbsc/include/openbsc/mgcp_transcode.h @@ -37,6 +37,8 @@ enum audio_format { AF_PCMU }; +struct mgcp_transcoding; +extern const struct mgcp_transcoding mgcp_sw_transcoder; struct mgcp_process_rtp_state { /* decoding */ diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index abce6e4..e4f5f7d 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -584,6 +584,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, struct sockaddr_in *addr, char *buf, int rc) { struct mgcp_trunk_config *tcfg = endp->tcfg; + const struct mgcp_transcoding *trans = tcfg->transcoder; struct mgcp_rtp_end *rtp_end; struct mgcp_rtp_state *rtp_state; int tap_idx; @@ -613,7 +614,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, int nbytes = 0; int len = rc; do { - cont = endp->cfg->rtp_processing_cb(endp, rtp_end, + cont = trans->processing_cb(endp, rtp_end, buf, &len, RTP_BUF_SIZE); if (cont < 0) break; diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 1819cea..8017fe8 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -2,8 +2,8 @@ /* The protocol implementation */ /* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves + * (C) 2009-2016 by Holger Hans Peter Freyther + * (C) 2009-2016 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -66,6 +66,14 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); +static const struct mgcp_transcoding no_transcoder = { + .processing_cb = &mgcp_rtp_processing_default, + .setup_processing_cb = &mgcp_setup_rtp_processing_default, + .get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default, +}; + +const struct mgcp_transcoding *mgcp_default_transcoder = &no_transcoder; + static int mgcp_check_param(const struct mgcp_endpoint *endp, const char *line) { const size_t line_len = strlen(line); @@ -197,13 +205,15 @@ static struct msgb *create_err_response(struct mgcp_endpoint *endp, static int write_response_sdp(struct mgcp_endpoint *endp, char *sdp_record, size_t size, const char *addr) { + const struct mgcp_transcoding *trans; const char *fmtp_extra; const char *audio_name; int payload_type; int len; int nchars; - endp->cfg->get_net_downlink_format_cb(endp, &payload_type, + trans = endp->tcfg->transcoder; + trans->get_net_downlink_format_cb(endp, &payload_type, &audio_name, &fmtp_extra); len = snprintf(sdp_record, size, @@ -1200,12 +1210,8 @@ struct mgcp_config *mgcp_config_alloc(void) cfg->bts_ports.base_port = RTP_PORT_DEFAULT; cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT; - cfg->rtp_processing_cb = &mgcp_rtp_processing_default; - cfg->setup_rtp_processing_cb = &mgcp_setup_rtp_processing_default; - - cfg->get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default; - /* default trunk handling */ + cfg->trunk.transcoder = mgcp_default_transcoder; cfg->trunk.cfg = cfg; cfg->trunk.trunk_nr = 0; cfg->trunk.trunk_type = MGCP_TRUNK_VIRTUAL; @@ -1231,6 +1237,7 @@ struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int nr) return NULL; } + trunk->transcoder = mgcp_default_transcoder; trunk->cfg = cfg; trunk->trunk_type = MGCP_TRUNK_E1; trunk->trunk_nr = nr; @@ -1459,7 +1466,7 @@ int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint) static int setup_rtp_processing(struct mgcp_endpoint *endp) { int rc = 0; - struct mgcp_config *cfg = endp->cfg; + const struct mgcp_transcoding *trans = endp->tcfg->transcoder; if (endp->type != MGCP_RTP_DEFAULT) return 0; @@ -1468,14 +1475,14 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp) return 0; if (endp->conn_mode & MGCP_CONN_SEND_ONLY) - rc |= cfg->setup_rtp_processing_cb(endp, &endp->net_end, &endp->bts_end); + rc |= trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); else - rc |= cfg->setup_rtp_processing_cb(endp, &endp->net_end, NULL); + rc |= trans->setup_processing_cb(endp, &endp->net_end, NULL); if (endp->conn_mode & MGCP_CONN_RECV_ONLY) - rc |= cfg->setup_rtp_processing_cb(endp, &endp->bts_end, &endp->net_end); + rc |= trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); else - rc |= cfg->setup_rtp_processing_cb(endp, &endp->bts_end, NULL); + rc |= trans->setup_processing_cb(endp, &endp->bts_end, NULL); return rc; } diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c index c994d32..aaa8863 100644 --- a/openbsc/src/libmgcp/mgcp_transcode.c +++ b/openbsc/src/libmgcp/mgcp_transcode.c @@ -32,6 +32,12 @@ #include #include +const struct mgcp_transcoding mgcp_sw_transcoder = { + .processing_cb = mgcp_transcoding_process_rtp, + .setup_processing_cb = mgcp_transcoding_setup, + .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, +}; + int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst) { struct mgcp_process_rtp_state *state = state_; @@ -470,12 +476,12 @@ struct mgcp_process_rtp_state *check_transcode_state( goto done; /* The matching alternate payload type? Then switch */ if (rtp_hdr->payload_type == src_end->alt_codec.payload_type) { - struct mgcp_config *cfg = endp->cfg; + const struct mgcp_transcoding *trans = endp->tcfg->transcoder; struct mgcp_rtp_codec tmp_codec = src_end->alt_codec; src_end->alt_codec = src_end->codec; src_end->codec = tmp_codec; - cfg->setup_rtp_processing_cb(endp, &endp->net_end, &endp->bts_end); - cfg->setup_rtp_processing_cb(endp, &endp->bts_end, &endp->net_end); + trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); + trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); } done: diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index e226b02..3c968be 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -207,16 +207,14 @@ int main(int argc, char **argv) osmo_init_ignore_signals(); osmo_init_logging(&log_info); +#ifdef BUILD_MGCP_TRANSCODING + mgcp_default_transcoder = &mgcp_sw_transcoder; +#endif + cfg = mgcp_config_alloc(); if (!cfg) return -1; -#ifdef BUILD_MGCP_TRANSCODING - cfg->setup_rtp_processing_cb = &mgcp_transcoding_setup; - cfg->rtp_processing_cb = &mgcp_transcoding_process_rtp; - cfg->get_net_downlink_format_cb = &mgcp_transcoding_net_downlink_format; -#endif - vty_info.copyright = openbsc_copyright; vty_init(&vty_info); logging_vty_add_cmds(&log_info); diff --git a/openbsc/tests/mgcp/mgcp_transcoding_test.c b/openbsc/tests/mgcp/mgcp_transcoding_test.c index c5c0a0b..72c75eb 100644 --- a/openbsc/tests/mgcp/mgcp_transcoding_test.c +++ b/openbsc/tests/mgcp/mgcp_transcoding_test.c @@ -161,6 +161,12 @@ static int audio_name_to_type(const char *name) int mgcp_get_trans_frame_size(void *state_, int nsamples, int dst); +static const struct mgcp_transcoding test_transcoder = { + .setup_processing_cb = mgcp_transcoding_setup, + .processing_cb = mgcp_transcoding_process_rtp, + .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, +}; + static int given_configured_endpoint(int in_samples, int out_samples, const char *srcfmt, const char *dstfmt, void **out_ctx, struct mgcp_endpoint **out_endp) @@ -176,10 +182,7 @@ static int given_configured_endpoint(int in_samples, int out_samples, tcfg = talloc_zero(cfg, struct mgcp_trunk_config); endp = talloc_zero(tcfg, struct mgcp_endpoint); - cfg->setup_rtp_processing_cb = mgcp_transcoding_setup; - cfg->rtp_processing_cb = mgcp_transcoding_process_rtp; - cfg->get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format; - + tcfg->transcoder = &test_transcoder; tcfg->endpoints = endp; tcfg->number_endpoints = 1; tcfg->cfg = cfg; -- 2.6.3 From holger at freyther.de Tue Mar 8 17:35:19 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 8 Mar 2016 18:35:19 +0100 Subject: [PATCH 2/3] mgcp: Simplify and shorten routine names In-Reply-To: <1457458520-34314-1-git-send-email-holger@freyther.de> References: <1457458520-34314-1-git-send-email-holger@freyther.de> Message-ID: <1457458520-34314-2-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther Now they are included in a struct we can just call them setup, process and get_net_downlink_format to manage the lifetime. --- openbsc/include/openbsc/mgcp_internal.h | 6 +++--- openbsc/src/libmgcp/mgcp_network.c | 2 +- openbsc/src/libmgcp/mgcp_protocol.c | 16 ++++++++-------- openbsc/src/libmgcp/mgcp_transcode.c | 10 +++++----- openbsc/tests/mgcp/mgcp_transcoding_test.c | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index a62dbb2..8fb8a45 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -154,9 +154,9 @@ enum mgcp_type { * Function pointers for RTP processing/transcoding */ struct mgcp_transcoding { - mgcp_processing processing_cb; - mgcp_processing_setup setup_processing_cb; - mgcp_get_format get_net_downlink_format_cb; + mgcp_processing process; + mgcp_processing_setup setup; + mgcp_get_format get_net_downlink_format; }; extern const struct mgcp_transcoding *mgcp_default_transcoder; diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index e4f5f7d..ed90d34 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -614,7 +614,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, int nbytes = 0; int len = rc; do { - cont = trans->processing_cb(endp, rtp_end, + cont = trans->process(endp, rtp_end, buf, &len, RTP_BUF_SIZE); if (cont < 0) break; diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 8017fe8..18a25bc 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -67,9 +67,9 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); static const struct mgcp_transcoding no_transcoder = { - .processing_cb = &mgcp_rtp_processing_default, - .setup_processing_cb = &mgcp_setup_rtp_processing_default, - .get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default, + .process = &mgcp_rtp_processing_default, + .setup = &mgcp_setup_rtp_processing_default, + .get_net_downlink_format = &mgcp_get_net_downlink_format_default, }; const struct mgcp_transcoding *mgcp_default_transcoder = &no_transcoder; @@ -213,7 +213,7 @@ static int write_response_sdp(struct mgcp_endpoint *endp, int nchars; trans = endp->tcfg->transcoder; - trans->get_net_downlink_format_cb(endp, &payload_type, + trans->get_net_downlink_format(endp, &payload_type, &audio_name, &fmtp_extra); len = snprintf(sdp_record, size, @@ -1475,14 +1475,14 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp) return 0; if (endp->conn_mode & MGCP_CONN_SEND_ONLY) - rc |= trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); + rc |= trans->setup(endp, &endp->net_end, &endp->bts_end); else - rc |= trans->setup_processing_cb(endp, &endp->net_end, NULL); + rc |= trans->setup(endp, &endp->net_end, NULL); if (endp->conn_mode & MGCP_CONN_RECV_ONLY) - rc |= trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); + rc |= trans->setup(endp, &endp->bts_end, &endp->net_end); else - rc |= trans->setup_processing_cb(endp, &endp->bts_end, NULL); + rc |= trans->setup(endp, &endp->bts_end, NULL); return rc; } diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c index aaa8863..6407cfb 100644 --- a/openbsc/src/libmgcp/mgcp_transcode.c +++ b/openbsc/src/libmgcp/mgcp_transcode.c @@ -33,9 +33,9 @@ #include const struct mgcp_transcoding mgcp_sw_transcoder = { - .processing_cb = mgcp_transcoding_process_rtp, - .setup_processing_cb = mgcp_transcoding_setup, - .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, + .process = mgcp_transcoding_process_rtp, + .setup = mgcp_transcoding_setup, + .get_net_downlink_format = mgcp_transcoding_net_downlink_format, }; int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst) @@ -480,8 +480,8 @@ struct mgcp_process_rtp_state *check_transcode_state( struct mgcp_rtp_codec tmp_codec = src_end->alt_codec; src_end->alt_codec = src_end->codec; src_end->codec = tmp_codec; - trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); - trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); + trans->setup(endp, &endp->net_end, &endp->bts_end); + trans->setup(endp, &endp->bts_end, &endp->net_end); } done: diff --git a/openbsc/tests/mgcp/mgcp_transcoding_test.c b/openbsc/tests/mgcp/mgcp_transcoding_test.c index 72c75eb..02f2817 100644 --- a/openbsc/tests/mgcp/mgcp_transcoding_test.c +++ b/openbsc/tests/mgcp/mgcp_transcoding_test.c @@ -162,9 +162,9 @@ static int audio_name_to_type(const char *name) int mgcp_get_trans_frame_size(void *state_, int nsamples, int dst); static const struct mgcp_transcoding test_transcoder = { - .setup_processing_cb = mgcp_transcoding_setup, - .processing_cb = mgcp_transcoding_process_rtp, - .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, + .setup = mgcp_transcoding_setup, + .process = mgcp_transcoding_process_rtp, + .get_net_downlink_format = mgcp_transcoding_net_downlink_format, }; static int given_configured_endpoint(int in_samples, int out_samples, -- 2.6.3 From holger at freyther.de Tue Mar 8 17:35:20 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 8 Mar 2016 18:35:20 +0100 Subject: [PATCH 3/3] mgcp: Remove the old MGCP based transcoding interface In-Reply-To: <1457458520-34314-1-git-send-email-holger@freyther.de> References: <1457458520-34314-1-git-send-email-holger@freyther.de> Message-ID: <1457458520-34314-3-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther Back in the day we worked around a field proven jitter buffer by transcoding AMR to AMR with the MTN4200 and by this fixing RTP timing as this device had: a.) A working and stable time (generating RTP every N ms) b.) A working jitter buffer The code has probably rotted, it never retried MGCP commands sent to the transcoder and it is not deployed either. Simplify the code by removing it. If we ever need it back we can use the new transcoding API to keep the state there. I think this code will not be missed but the PerformanceTechnology Hard- and Firmware was rather nice. --- openbsc/include/openbsc/mgcp.h | 7 -- openbsc/include/openbsc/mgcp_internal.h | 16 ---- openbsc/src/libmgcp/mgcp_network.c | 105 ---------------------- openbsc/src/libmgcp/mgcp_protocol.c | 141 ------------------------------ openbsc/src/libmgcp/mgcp_vty.c | 72 ++++----------- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 9 -- 6 files changed, 16 insertions(+), 334 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index a216547..dfa41a3 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -183,16 +183,10 @@ struct mgcp_config { struct in_addr bts_in; - /* transcoder handling */ - char *transcoder_ip; - struct in_addr transcoder_in; - int transcoder_remote_base; - struct osmo_wqueue gw_fd; struct mgcp_port_range bts_ports; struct mgcp_port_range net_ports; - struct mgcp_port_range transcoder_ports; int endp_dscp; int bts_force_ptime; @@ -244,7 +238,6 @@ int mgcp_vty_init(void); int mgcp_endpoints_allocate(struct mgcp_trunk_config *cfg); void mgcp_release_endp(struct mgcp_endpoint *endp); void mgcp_initialize_endp(struct mgcp_endpoint *endp); -int mgcp_reset_transcoder(struct mgcp_config *cfg); void mgcp_format_stats(struct mgcp_endpoint *endp, char *stats, size_t size); int mgcp_parse_stats(struct msgb *msg, uint32_t *ps, uint32_t *os, uint32_t *pr, uint32_t *_or, int *loss, uint32_t *jitter); diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 8fb8a45..dd195e0 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -145,7 +145,6 @@ struct mgcp_lco { enum mgcp_type { MGCP_RTP_DEFAULT = 0, - MGCP_RTP_TRANSCODED, MGCP_OSMUX_BSC, MGCP_OSMUX_BSC_NAT, }; @@ -179,13 +178,6 @@ struct mgcp_endpoint { struct mgcp_rtp_end bts_end; struct mgcp_rtp_end net_end; - /* - * For transcoding we will send from the local_port - * of trans_bts and it will arrive at trans_net from - * where we will forward it to the network. - */ - struct mgcp_rtp_end trans_bts; - struct mgcp_rtp_end trans_net; enum mgcp_type type; /* sequence bits */ @@ -268,16 +260,8 @@ struct mgcp_parse_data { int mgcp_send_dummy(struct mgcp_endpoint *endp); int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port); int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port); -int mgcp_bind_trans_bts_rtp_port(struct mgcp_endpoint *enp, int rtp_port); -int mgcp_bind_trans_net_rtp_port(struct mgcp_endpoint *enp, int rtp_port); int mgcp_free_rtp_port(struct mgcp_rtp_end *end); -/* For transcoding we need to manage an in and an output that are connected */ -static inline int endp_back_channel(int endpoint) -{ - return endpoint + 60; -} - struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int index); struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index); diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index ed90d34..1eb87bb 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -553,33 +553,6 @@ static int forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf, int l (struct sockaddr *)&tap->forward, sizeof(tap->forward)); } -static int mgcp_send_transcoder(struct mgcp_rtp_end *end, - struct mgcp_config *cfg, int is_rtp, - const char *buf, int len) -{ - int rc; - int port; - struct sockaddr_in addr; - - port = is_rtp ? end->rtp_port : end->rtcp_port; - - addr.sin_family = AF_INET; - addr.sin_addr = cfg->transcoder_in; - addr.sin_port = port; - - rc = sendto(is_rtp ? - end->rtp.fd : - end->rtcp.fd, buf, len, 0, - (struct sockaddr *) &addr, sizeof(addr)); - - if (rc != len) - LOGP(DMGCP, LOGL_ERROR, - "Failed to send data to the transcoder: %s\n", - strerror(errno)); - - return rc; -} - int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, struct sockaddr_in *addr, char *buf, int rc) { @@ -688,7 +661,6 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) switch(endp->type) { case MGCP_RTP_DEFAULT: - case MGCP_RTP_TRANSCODED: if (endp->net_end.rtp_port != addr.sin_port && endp->net_end.rtcp_port != addr.sin_port) { LOGP(DMGCP, LOGL_ERROR, @@ -719,9 +691,6 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) case MGCP_RTP_DEFAULT: return mgcp_send(endp, MGCP_DEST_BTS, proto == MGCP_PROTO_RTP, &addr, buf, rc); - case MGCP_RTP_TRANSCODED: - return mgcp_send_transcoder(&endp->trans_net, endp->cfg, - proto == MGCP_PROTO_RTP, buf, rc); case MGCP_OSMUX_BSC_NAT: return osmux_xfrm_to_osmux(MGCP_DEST_BTS, buf, rc, endp); case MGCP_OSMUX_BSC: /* Should not happen */ @@ -811,9 +780,6 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) case MGCP_RTP_DEFAULT: return mgcp_send(endp, MGCP_DEST_NET, proto == MGCP_PROTO_RTP, &addr, buf, rc); - case MGCP_RTP_TRANSCODED: - return mgcp_send_transcoder(&endp->trans_bts, endp->cfg, - proto == MGCP_PROTO_RTP, buf, rc); case MGCP_OSMUX_BSC: /* OSMUX translation: BTS -> BSC */ return osmux_xfrm_to_osmux(MGCP_DEST_NET, buf, rc, endp); @@ -826,63 +792,6 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) return 0; } -static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_endp, - int dest, struct osmo_fd *fd) -{ - char buf[RTP_BUF_SIZE]; - struct sockaddr_in addr; - struct mgcp_config *cfg; - int rc, proto; - - cfg = _endp->cfg; - rc = receive_from(_endp, fd->fd, &addr, buf, sizeof(buf)); - if (rc <= 0) - return -1; - - proto = fd == &end->rtp ? MGCP_PROTO_RTP : MGCP_PROTO_RTCP; - - if (memcmp(&addr.sin_addr, &cfg->transcoder_in, sizeof(addr.sin_addr)) != 0) { - LOGP(DMGCP, LOGL_ERROR, - "Data not coming from transcoder dest: %d %s on 0x%x\n", - dest, inet_ntoa(addr.sin_addr), ENDPOINT_NUMBER(_endp)); - return -1; - } - - if (end->rtp_port != addr.sin_port && - end->rtcp_port != addr.sin_port) { - LOGP(DMGCP, LOGL_ERROR, - "Data from wrong transcoder dest %d source port %d on 0x%x\n", - dest, ntohs(addr.sin_port), ENDPOINT_NUMBER(_endp)); - return -1; - } - - /* throw away the dummy message */ - if (rc == 1 && buf[0] == MGCP_DUMMY_LOAD) { - LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from transcoder dest %d on 0x%x\n", - dest, ENDPOINT_NUMBER(_endp)); - return 0; - } - - end->packets += 1; - return mgcp_send(_endp, dest, proto == MGCP_PROTO_RTP, &addr, buf, rc); -} - -static int rtp_data_trans_net(struct osmo_fd *fd, unsigned int what) -{ - struct mgcp_endpoint *endp; - endp = (struct mgcp_endpoint *) fd->data; - - return rtp_data_transcoder(&endp->trans_net, endp, MGCP_DEST_NET, fd); -} - -static int rtp_data_trans_bts(struct osmo_fd *fd, unsigned int what) -{ - struct mgcp_endpoint *endp; - endp = (struct mgcp_endpoint *) fd->data; - - return rtp_data_transcoder(&endp->trans_bts, endp, MGCP_DEST_BTS, fd); -} - int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port) { struct sockaddr_in addr; @@ -998,20 +907,6 @@ int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port) mgcp_net_src_addr(endp), rtp_port); } -int mgcp_bind_trans_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port) -{ - return int_bind("trans-net", &endp->trans_net, - rtp_data_trans_net, endp, - endp->cfg->source_addr, rtp_port); -} - -int mgcp_bind_trans_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port) -{ - return int_bind("trans-bts", &endp->trans_bts, - rtp_data_trans_bts, endp, - endp->cfg->source_addr, rtp_port); -} - int mgcp_free_rtp_port(struct mgcp_rtp_end *end) { if (end->rtp.fd != -1) { diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 18a25bc..c136e31 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -59,9 +59,6 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *data); static struct msgb *handle_rsip(struct mgcp_parse_data *data); static struct msgb *handle_noti_req(struct mgcp_parse_data *data); -static void create_transcoder(struct mgcp_endpoint *endp); -static void delete_transcoder(struct mgcp_endpoint *endp); - static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); @@ -604,28 +601,6 @@ static int allocate_ports(struct mgcp_endpoint *endp) return -1; } - if (endp->cfg->transcoder_ip && endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) { - if (allocate_port(endp, &endp->trans_net, - &endp->cfg->transcoder_ports, - mgcp_bind_trans_net_rtp_port) != 0) { - mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->bts_end); - return -1; - } - - if (allocate_port(endp, &endp->trans_bts, - &endp->cfg->transcoder_ports, - mgcp_bind_trans_bts_rtp_port) != 0) { - mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->bts_end); - mgcp_rtp_end_reset(&endp->trans_net); - return -1; - } - - /* remember that we have set up transcoding */ - endp->type = MGCP_RTP_TRANSCODED; - } - return 0; } @@ -868,7 +843,6 @@ mgcp_header_done: break; case MGCP_POLICY_DEFER: /* stop processing */ - create_transcoder(endp); return NULL; break; case MGCP_POLICY_CONT: @@ -887,7 +861,6 @@ mgcp_header_done: send_dummy(endp); } - create_transcoder(endp); return create_response_with_sdp(endp, "CRCX", p->trans); error2: mgcp_release_endp(endp); @@ -1070,7 +1043,6 @@ static struct msgb *handle_delete_con(struct mgcp_parse_data *p) break; case MGCP_POLICY_DEFER: /* stop processing */ - delete_transcoder(endp); return NULL; break; case MGCP_POLICY_CONT: @@ -1086,7 +1058,6 @@ static struct msgb *handle_delete_con(struct mgcp_parse_data *p) /* save the statistics of the current call */ mgcp_format_stats(endp, stats, sizeof(stats)); - delete_transcoder(endp); mgcp_release_endp(endp); if (p->cfg->change_cb) p->cfg->change_cb(endp->tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX); @@ -1205,8 +1176,6 @@ struct mgcp_config *mgcp_config_alloc(void) cfg->source_addr = talloc_strdup(cfg, "0.0.0.0"); cfg->osmux_addr = talloc_strdup(cfg, "0.0.0.0"); - cfg->transcoder_remote_base = 4000; - cfg->bts_ports.base_port = RTP_PORT_DEFAULT; cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT; @@ -1328,8 +1297,6 @@ int mgcp_endpoints_allocate(struct mgcp_trunk_config *tcfg) tcfg->endpoints[i].tcfg = tcfg; mgcp_rtp_end_init(&tcfg->endpoints[i].net_end); mgcp_rtp_end_init(&tcfg->endpoints[i].bts_end); - mgcp_rtp_end_init(&tcfg->endpoints[i].trans_net); - mgcp_rtp_end_init(&tcfg->endpoints[i].trans_bts); } return 0; @@ -1351,8 +1318,6 @@ void mgcp_release_endp(struct mgcp_endpoint *endp) mgcp_rtp_end_reset(&endp->bts_end); mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->trans_net); - mgcp_rtp_end_reset(&endp->trans_bts); endp->type = MGCP_RTP_DEFAULT; memset(&endp->net_state, 0, sizeof(endp->net_state)); @@ -1374,65 +1339,6 @@ void mgcp_initialize_endp(struct mgcp_endpoint *endp) return mgcp_release_endp(endp); } -static int send_trans(struct mgcp_config *cfg, const char *buf, int len) -{ - struct sockaddr_in addr; - - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr = cfg->transcoder_in; - addr.sin_port = htons(2427); - return sendto(cfg->gw_fd.bfd.fd, buf, len, 0, - (struct sockaddr *) &addr, sizeof(addr)); -} - -static void send_msg(struct mgcp_endpoint *endp, int endpoint, int port, - const char *msg, const char *mode) -{ - char buf[2096]; - int len; - int nchars; - - /* hardcoded to AMR right now, we do not know the real type at this point */ - len = snprintf(buf, sizeof(buf), - "%s 42 %x at mgw MGCP 1.0\r\n" - "C: 4256\r\n" - "M: %s\r\n" - "\r\n", - msg, endpoint, mode); - - if (len < 0) - return; - - nchars = write_response_sdp(endp, buf + len, sizeof(buf) + len - 1, NULL); - if (nchars < 0) - return; - - len += nchars; - - buf[sizeof(buf) - 1] = '\0'; - - send_trans(endp->cfg, buf, len); -} - -static void send_dlcx(struct mgcp_endpoint *endp, int endpoint) -{ - char buf[2096]; - int len; - - len = snprintf(buf, sizeof(buf), - "DLCX 43 %x at mgw MGCP 1.0\r\n" - "C: 4256\r\n" - , endpoint); - - if (len < 0) - return; - - buf[sizeof(buf) - 1] = '\0'; - - send_trans(endp->cfg, buf, len); -} - static int send_agent(struct mgcp_config *cfg, const char *buf, int len) { return write(cfg->gw_fd.bfd.fd, buf, len); @@ -1486,53 +1392,6 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp) return rc; } -static void create_transcoder(struct mgcp_endpoint *endp) -{ - int port; - int in_endp = ENDPOINT_NUMBER(endp); - int out_endp = endp_back_channel(in_endp); - - if (endp->type != MGCP_RTP_TRANSCODED) - return; - - send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "sendrecv"); - send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "sendrecv"); - send_msg(endp, out_endp, endp->trans_net.local_port, "CRCX", "sendrecv"); - send_msg(endp, out_endp, endp->trans_net.local_port, "MDCX", "sendrecv"); - - port = rtp_calculate_port(in_endp, endp->cfg->transcoder_remote_base); - endp->trans_bts.rtp_port = htons(port); - endp->trans_bts.rtcp_port = htons(port + 1); - - port = rtp_calculate_port(out_endp, endp->cfg->transcoder_remote_base); - endp->trans_net.rtp_port = htons(port); - endp->trans_net.rtcp_port = htons(port + 1); -} - -static void delete_transcoder(struct mgcp_endpoint *endp) -{ - int in_endp = ENDPOINT_NUMBER(endp); - int out_endp = endp_back_channel(in_endp); - - if (endp->type != MGCP_RTP_TRANSCODED) - return; - - send_dlcx(endp, in_endp); - send_dlcx(endp, out_endp); -} - -int mgcp_reset_transcoder(struct mgcp_config *cfg) -{ - if (!cfg->transcoder_ip) - return 0; - - static const char mgcp_reset[] = { - "RSIP 1 13 at mgw MGCP 1.0\r\n" - }; - - return send_trans(cfg, mgcp_reset, sizeof mgcp_reset -1); -} - void mgcp_format_stats(struct mgcp_endpoint *endp, char *msg, size_t size) { uint32_t expected, jitter; diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index 13f66c5..d6204b1 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -128,17 +128,8 @@ static int config_write_mgcp(struct vty *vty) g_cfg->trunk.no_audio_transcoding ? "no " : "", VTY_NEWLINE); if (g_cfg->call_agent_addr) vty_out(vty, " call-agent ip %s%s", g_cfg->call_agent_addr, VTY_NEWLINE); - if (g_cfg->transcoder_ip) - vty_out(vty, " transcoder-mgw %s%s", g_cfg->transcoder_ip, VTY_NEWLINE); - - if (g_cfg->transcoder_ports.mode == PORT_ALLOC_STATIC) - vty_out(vty, " rtp transcoder-base %u%s", g_cfg->transcoder_ports.base_port, VTY_NEWLINE); - else - vty_out(vty, " rtp transcoder-range %u %u%s", - g_cfg->transcoder_ports.range_start, g_cfg->transcoder_ports.range_end, VTY_NEWLINE); if (g_cfg->bts_force_ptime > 0) vty_out(vty, " rtp force-ptime %d%s", g_cfg->bts_force_ptime, VTY_NEWLINE); - vty_out(vty, " transcoder-remote-base %u%s", g_cfg->transcoder_remote_base, VTY_NEWLINE); switch (g_cfg->osmux) { case OSMUX_USAGE_ON: @@ -209,13 +200,12 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int verbo struct mgcp_endpoint *endp = &cfg->endpoints[i]; vty_out(vty, " Endpoint 0x%.2x: CI: %d net: %u/%u bts: %u/%u on %s " - "traffic received bts: %u remote: %u transcoder: %u/%u%s", + "traffic received bts: %u remote: %u%s", i, endp->ci, ntohs(endp->net_end.rtp_port), ntohs(endp->net_end.rtcp_port), ntohs(endp->bts_end.rtp_port), ntohs(endp->bts_end.rtcp_port), inet_ntoa(endp->bts_end.addr), endp->bts_end.packets, endp->net_end.packets, - endp->trans_net.packets, endp->trans_bts.packets, VTY_NEWLINE); if (verbose && endp->allocated) { @@ -378,24 +368,24 @@ ALIAS_DEPRECATED(cfg_mgcp_rtp_bts_base_port, cfg_mgcp_rtp_base_port_cmd, "rtp base <0-65534>", RTP_STR BTS_START_STR UDP_PORT_STR) -DEFUN(cfg_mgcp_rtp_transcoder_range, +DEFUN_DEPRECATED(cfg_mgcp_rtp_transcoder_range, cfg_mgcp_rtp_transcoder_range_cmd, "rtp transcoder-range <0-65534> <0-65534>", RTP_STR "Range of ports to use for the Transcoder\n" RANGE_START_STR RANGE_END_STR) { - parse_range(&g_cfg->transcoder_ports, argv); - return CMD_SUCCESS; + vty_out(vty, "%% functionality has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } -DEFUN(cfg_mgcp_rtp_transcoder_base, +DEFUN_DEPRECATED(cfg_mgcp_rtp_transcoder_base, cfg_mgcp_rtp_transcoder_base_cmd, "rtp transcoder-base <0-65534>", RTP_STR "First UDP port allocated for the Transcoder side\n" UDP_PORT_STR) { - parse_base(&g_cfg->transcoder_ports, argv); - return CMD_SUCCESS; + vty_out(vty, "%% functionality has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } DEFUN(cfg_mgcp_rtp_bts_bind_ip, @@ -724,39 +714,32 @@ ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old, "IPv4 Address of the callagent\n") -DEFUN(cfg_mgcp_transcoder, +DEFUN_DEPRECATED(cfg_mgcp_transcoder, cfg_mgcp_transcoder_cmd, "transcoder-mgw A.B.C.D", "Use a MGW to detranscoder RTP\n" "The IP address of the MGW") { - bsc_replace_string(g_cfg, &g_cfg->transcoder_ip, argv[0]); - inet_aton(g_cfg->transcoder_ip, &g_cfg->transcoder_in); - - return CMD_SUCCESS; + vty_out(vty, "%% functionality has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } -DEFUN(cfg_mgcp_no_transcoder, +DEFUN_DEPRECATED(cfg_mgcp_no_transcoder, cfg_mgcp_no_transcoder_cmd, "no transcoder-mgw", NO_STR "Disable the transcoding\n") { - if (g_cfg->transcoder_ip) { - LOGP(DMGCP, LOGL_NOTICE, "Disabling transcoding on future calls.\n"); - talloc_free(g_cfg->transcoder_ip); - g_cfg->transcoder_ip = NULL; - } - - return CMD_SUCCESS; + vty_out(vty, "%% functionality has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } -DEFUN(cfg_mgcp_transcoder_remote_base, +DEFUN_DEPRECATED(cfg_mgcp_transcoder_remote_base, cfg_mgcp_transcoder_remote_base_cmd, "transcoder-remote-base <0-65534>", "Set the base port for the transcoder\n" "The RTP base port on the transcoder") { - g_cfg->transcoder_remote_base = atoi(argv[0]); - return CMD_SUCCESS; + vty_out(vty, "%% functionality has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd, @@ -1466,29 +1449,6 @@ static int allocate_trunk(struct mgcp_trunk_config *trunk) } endp->net_end.local_alloc = PORT_ALLOC_STATIC; } - - if (trunk->trunk_type == MGCP_TRUNK_VIRTUAL && - cfg->transcoder_ip && cfg->transcoder_ports.mode == PORT_ALLOC_STATIC) { - int rtp_port; - - /* network side */ - rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), - cfg->transcoder_ports.base_port); - if (mgcp_bind_trans_net_rtp_port(endp, rtp_port) != 0) { - LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port); - return -1; - } - endp->trans_net.local_alloc = PORT_ALLOC_STATIC; - - /* bts side */ - rtp_port = rtp_calculate_port(endp_back_channel(ENDPOINT_NUMBER(endp)), - cfg->transcoder_ports.base_port); - if (mgcp_bind_trans_bts_rtp_port(endp, rtp_port) != 0) { - LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port); - return -1; - } - endp->trans_bts.local_alloc = PORT_ALLOC_STATIC; - } } return 0; diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index 9fd9967..67149b8 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -1116,15 +1116,6 @@ int bsc_mgcp_nat_init(struct bsc_nat *nat) return -1; } - if (mgcp_reset_transcoder(cfg) < 0) { - LOGP(DMGCP, LOGL_ERROR, "Failed to send packet to the transcoder.\n"); - talloc_free(nat->bsc_endpoints); - nat->bsc_endpoints = NULL; - close(cfg->gw_fd.bfd.fd); - cfg->gw_fd.bfd.fd = -1; - return -1; - } - return 0; } -- 2.6.3 From nhofmeyr at sysmocom.de Wed Mar 9 11:24:15 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 9 Mar 2016 12:24:15 +0100 Subject: [PATCH 3/3] mgcp: Remove the old MGCP based transcoding interface In-Reply-To: <1457458520-34314-3-git-send-email-holger@freyther.de> References: <1457458520-34314-1-git-send-email-holger@freyther.de> <1457458520-34314-3-git-send-email-holger@freyther.de> Message-ID: <20160309112415.GA2168@dub6> On Tue, Mar 08, 2016 at 06:35:20PM +0100, Holger Hans Peter Freyther wrote: > -DEFUN(cfg_mgcp_rtp_transcoder_range, > +DEFUN_DEPRECATED(cfg_mgcp_rtp_transcoder_range, > cfg_mgcp_rtp_transcoder_range_cmd, > "rtp transcoder-range <0-65534> <0-65534>", > RTP_STR "Range of ports to use for the Transcoder\n" > RANGE_START_STR RANGE_END_STR) > { > - parse_range(&g_cfg->transcoder_ports, argv); > - return CMD_SUCCESS; > + vty_out(vty, "%% functionality has been removed.%s", VTY_NEWLINE); > + return CMD_WARNING; > } Imagining a config file with rtp transcoder config items, startup will just say % functionality has been removed. without an indication which of the commands caused the message. Life would then be simpler if the message said % rtp transcoder has been removed. (5 times) ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From msuraev at sysmocom.de Wed Mar 9 11:29:23 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 12:29:23 +0100 Subject: [PATCH 1/3] Add helper function to convert numerical BSSGP PDU type to string Message-ID: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> From: Max --- include/osmocom/gprs/gprs_bssgp.h | 1 + src/gb/gprs_bssgp_util.c | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h index c0b3f65..b70487c 100644 --- a/include/osmocom/gprs/gprs_bssgp.h +++ b/include/osmocom/gprs/gprs_bssgp.h @@ -14,6 +14,7 @@ extern struct gprs_ns_inst *bssgp_nsi; struct msgb *bssgp_msgb_alloc(void); struct msgb *bssgp_msgb_copy(const struct msgb *msg, const char *name); const char *bssgp_cause_str(enum gprs_bssgp_cause cause); +const char *bssgp_pdu_str(enum bssgp_pdu_type pdu); /* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */ int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei, uint16_t bvci, uint16_t ns_bvci); diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c index 19ae23a..6fff362 100644 --- a/src/gb/gprs_bssgp_util.c +++ b/src/gb/gprs_bssgp_util.c @@ -62,11 +62,57 @@ static const struct value_string bssgp_cause_strings[] = { { 0, NULL }, }; +static const struct value_string bssgp_pdu_strings[] = { + { BSSGP_PDUT_DL_UNITDATA, "DL-UNITDATA" }, + { BSSGP_PDUT_UL_UNITDATA, "UL-UNITDATA" }, + { BSSGP_PDUT_RA_CAPABILITY, "RA-CAPABILITY" }, + { BSSGP_PDUT_PTM_UNITDATA, "PTM-UNITDATA" }, + { BSSGP_PDUT_PAGING_PS, "PAGING-PS" }, + { BSSGP_PDUT_PAGING_CS, "PAGING-CS" }, + { BSSGP_PDUT_RA_CAPA_UDPATE, "RA-CAPABILITY-UPDATE" }, + { BSSGP_PDUT_RA_CAPA_UPDATE_ACK, "RA-CAPABILITY-UPDATE-ACK" }, + { BSSGP_PDUT_RADIO_STATUS, "RADIO-STATUS" }, + { BSSGP_PDUT_SUSPEND, "SUSPEND" }, + { BSSGP_PDUT_SUSPEND_ACK, "SUSPEND-ACK" }, + { BSSGP_PDUT_SUSPEND_NACK, "SUSPEND-NACK" }, + { BSSGP_PDUT_RESUME, "RESUME" }, + { BSSGP_PDUT_RESUME_ACK, "RESUME-ACK" }, + { BSSGP_PDUT_RESUME_NACK, "RESUME-NACK" }, + { BSSGP_PDUT_BVC_BLOCK, "BVC-BLOCK" }, + { BSSGP_PDUT_BVC_BLOCK_ACK, "BVC-BLOCK-ACK" }, + { BSSGP_PDUT_BVC_RESET, "BVC-RESET" }, + { BSSGP_PDUT_BVC_RESET_ACK, "BVC-RESET-ACK" }, + { BSSGP_PDUT_BVC_UNBLOCK, "BVC-UNBLOCK" }, + { BSSGP_PDUT_BVC_UNBLOCK_ACK, "BVC-UNBLOCK-ACK" }, + { BSSGP_PDUT_FLOW_CONTROL_BVC, "FLOW-CONTROL-BVC" }, + { BSSGP_PDUT_FLOW_CONTROL_BVC_ACK, "FLOW-CONTROL-BVC-ACK" }, + { BSSGP_PDUT_FLOW_CONTROL_MS, "FLOW-CONTROL-MS" }, + { BSSGP_PDUT_FLOW_CONTROL_MS_ACK, "FLOW-CONTROL-MS-ACK" }, + { BSSGP_PDUT_FLUSH_LL, "FLUSH-LL" }, + { BSSGP_PDUT_FLUSH_LL_ACK, "FLUSH-LL-ACK" }, + { BSSGP_PDUT_LLC_DISCARD, "LLC DISCARDED" }, + { BSSGP_PDUT_SGSN_INVOKE_TRACE, "SGSN-INVOKE-TRACE" }, + { BSSGP_PDUT_STATUS, "STATUS" }, + { BSSGP_PDUT_DOWNLOAD_BSS_PFC, "DOWNLOAD-BSS-PFC" }, + { BSSGP_PDUT_CREATE_BSS_PFC, "CREATE-BSS-PFC" }, + { BSSGP_PDUT_CREATE_BSS_PFC_ACK, "CREATE-BSS-PFC-ACK" }, + { BSSGP_PDUT_CREATE_BSS_PFC_NACK, "CREATE-BSS-PFC-NACK" }, + { BSSGP_PDUT_MODIFY_BSS_PFC, "MODIFY-BSS-PFC" }, + { BSSGP_PDUT_MODIFY_BSS_PFC_ACK, "MODIFY-BSS-PFC-ACK" }, + { BSSGP_PDUT_DELETE_BSS_PFC, "DELETE-BSS-PFC" }, + { BSSGP_PDUT_DELETE_BSS_PFC_ACK, "DELETE-BSS-PFC-ACK" }, + { 0, NULL }, +}; + const char *bssgp_cause_str(enum gprs_bssgp_cause cause) { return get_value_string(bssgp_cause_strings, cause); } +const char *bssgp_pdu_str(enum bssgp_pdu_type pdu) +{ + return get_value_string(bssgp_pdu_strings, pdu); +} struct msgb *bssgp_msgb_alloc(void) { -- 2.7.2 From msuraev at sysmocom.de Wed Mar 9 11:29:24 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 12:29:24 +0100 Subject: [PATCH 2/3] Improve BSSGP debug output In-Reply-To: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> References: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457522965-27238-2-git-send-email-msuraev@sysmocom.de> From: Max Print string representation of Cause IE and PDU type in addition to numerical value. --- src/gb/gprs_bssgp.c | 28 ++++++++++++++-------------- src/gb/gprs_bssgp_bss.c | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index e3e69c9..c19f05a 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -896,8 +896,8 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_CREATE_BSS_PFC_NACK: case BSSGP_PDUT_MODIFY_BSS_PFC: case BSSGP_PDUT_DELETE_BSS_PFC_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] " - "implemented\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) not [yet] " + "implemented\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg); break; /* those only exist in the SGSN -> BSS direction */ @@ -907,14 +907,14 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_RA_CAPA_UPDATE_ACK: case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK: case BSSGP_PDUT_FLOW_CONTROL_MS_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x only exists " - "in DL\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) only exists " + "in DL\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x unknown\n", - bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) unknown\n", + bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -999,14 +999,14 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_BVC_BLOCK_ACK: case BSSGP_PDUT_BVC_UNBLOCK_ACK: case BSSGP_PDUT_SGSN_INVOKE_TRACE: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x only exists " - "in DL\n", bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) only exists " + "in DL\n", bvci, pdu_type, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x unknown\n", - bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) unknown\n", + bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -1066,8 +1066,8 @@ int bssgp_rcvmsg(struct msgb *msg) if (!bctx && bvci != BVCI_SIGNALLING && pdu_type != BSSGP_PDUT_BVC_RESET) { LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU " - "type %u for unknown BVCI\n", msgb_nsei(msg), bvci, - pdu_type); + "type %u (%s) for unknown BVCI\n", msgb_nsei(msg), bvci, + pdu_type, bssgp_pdu_str(pdu_type)); return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg); } @@ -1079,9 +1079,9 @@ int bssgp_rcvmsg(struct msgb *msg) rc = bssgp_rx_ptp(msg, &tp, bctx); else LOGP(DBSSGP, LOGL_NOTICE, - "NSEI=%u/BVCI=%u Cannot handle PDU type %u for " + "NSEI=%u/BVCI=%u Cannot handle PDU type %u (%s) for " "unknown BVCI, NS BVCI %u\n", - msgb_nsei(msg), bvci, pdu_type, ns_bvci); + msgb_nsei(msg), bvci, pdu_type, , bssgp_pdu_str(pdu_type), ns_bvci); return rc; } diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 3a9012e..955e2b4 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -135,7 +135,7 @@ static struct msgb *common_tx_radio_status(struct bssgp_bvc_ctx *bctx) static int common_tx_radio_status2(struct msgb *msg, uint8_t cause) { msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause); - LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u\n", cause); + LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u (%s)\n", cause, bssgp_cause_str(cause)); return gprs_ns_sendmsg(bssgp_nsi, msg); } @@ -247,7 +247,7 @@ int bssgp_tx_bvc_block(struct bssgp_bvc_ctx *bctx, uint8_t cause) uint16_t _bvci = htons(bctx->bvci); LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-BLOCK " - "CAUSE=%u\n", bctx->bvci, cause); + "CAUSE=%u (%s)\n", bctx->bvci, cause, bssgp_cause_str(cause)); msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ @@ -287,7 +287,7 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause) uint16_t _bvci = htons(bvci); LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-RESET " - "CAUSE=%u\n", bvci, cause); + "CAUSE=%u (%s)\n", bvci, cause, bssgp_cause_str(cause)); msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ -- 2.7.2 From msuraev at sysmocom.de Wed Mar 9 11:29:25 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 12:29:25 +0100 Subject: [PATCH 3/3] Add vty command to explicitly reset given BVCI In-Reply-To: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> References: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457522965-27238-3-git-send-email-msuraev@sysmocom.de> From: Max It's useful for debugging and is similar to existing nsvc reset vty command. --- src/gb/gprs_bssgp_vty.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 080867b..4f53ae7 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -113,6 +113,29 @@ static void dump_bssgp(struct vty *vty, int stats) } } +DEFUN(bvc_reset, bvc_reset_cmd, + "bvc reset nsei <0-65535> bvci <0-65535>", + "Initiate BVC RESET procedure for a given NSEI and BVCI\n") +{ + uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]); + struct bssgp_bvc_ctx *bvc; + + if (!strcmp(argv[0], "reset")) + return CMD_WARNING; + + if (argc != 2) + return CMD_WARNING; + + bvc = btsctx_by_bvci_nsei(bvci, nsei); + if (!bvc) { + vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, VTY_NEWLINE); + return CMD_WARNING; + } + int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV); + vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, VTY_NEWLINE); + return CMD_SUCCESS; +} + #define BSSGP_STR "Show information about the BSSGP protocol\n" DEFUN(show_bssgp, show_bssgp_cmd, "show bssgp", @@ -185,6 +208,7 @@ int bssgp_vty_init(void) install_element_ve(&show_bssgp_stats_cmd); install_element_ve(&show_bvc_cmd); install_element_ve(&logging_fltr_bvc_cmd); + install_element_ve(&bvc_reset_cmd); install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd); -- 2.7.2 From holger at freyther.de Wed Mar 9 12:24:23 2016 From: holger at freyther.de (Holger Freyther) Date: Wed, 9 Mar 2016 13:24:23 +0100 Subject: [PATCH 3/3] mgcp: Remove the old MGCP based transcoding interface In-Reply-To: <20160309112415.GA2168@dub6> References: <1457458520-34314-1-git-send-email-holger@freyther.de> <1457458520-34314-3-git-send-email-holger@freyther.de> <20160309112415.GA2168@dub6> Message-ID: <93F22E79-D21C-4D5D-95C8-C554E23D6075@freyther.de> > On 09 Mar 2016, at 12:24, Neels Hofmeyr wrote: > > > % rtp transcoder has been removed. good point From msuraev at sysmocom.de Wed Mar 9 13:14:28 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 14:14:28 +0100 Subject: [PATCH 2/4] OsmoPCU: fix Gb documentation front page In-Reply-To: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> References: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457529270-25058-2-git-send-email-msuraev@sysmocom.de> From: Max Add date and commit refs. Add relevant standards. Fix email typo. --- OsmoPCU/osmopcu-gb-docinfo.xml | 4 ++-- OsmoPCU/osmopcu-gb.adoc | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/OsmoPCU/osmopcu-gb-docinfo.xml b/OsmoPCU/osmopcu-gb-docinfo.xml index 280c6f7..23ec3d1 100644 --- a/OsmoPCU/osmopcu-gb-docinfo.xml +++ b/OsmoPCU/osmopcu-gb-docinfo.xml @@ -4,8 +4,8 @@ February 2016 HW, MS - Initial version, reflecting OsmoPCU master branch as on FIXME - (commit FIXME). + Initial version, reflecting OsmoPCU master branch as on 2016-Mar-02 + (commit 22d7e75e1f160e5337140d9f3dcb2679b621b646). diff --git a/OsmoPCU/osmopcu-gb.adoc b/OsmoPCU/osmopcu-gb.adoc index 261f7db..6ebcf18 100644 --- a/OsmoPCU/osmopcu-gb.adoc +++ b/OsmoPCU/osmopcu-gb.adoc @@ -1,11 +1,11 @@ OsmoPCU Gb Protocol Specification ================================= -Harald Welte +Harald Welte == Introduction This document describes the Gb interface of *OsmoPCU*. Based on 3GPP TS -FIXME and FIXME, this document indicates which of the 3GPP specified Gb +08.16 and 08.18, this document indicates which of the 3GPP specified Gb messages and IEs are implemented according to 3GPP specifications, which of these are not or not fully implemented, as well as OsmoPCU-specific extensions to the Gb interface not specified by 3GPP. @@ -21,6 +21,8 @@ document. For details on the messages and IEs that comply with abovementioned |3GPP TS 08.58 | version 8.6.0 Release 1999 |3GPP TS 08.60 | version 8.2.1 Release 1999 |3GPP TS 12.21 | version 8.0.0 Release 1999 +|3GPP TS 08.16 | version 8.0.1 Release 1999 +|3GPP TS 08.18 | version 8.12.0 Release 1999 |=== .IETF documents referred to by his document -- 2.7.2 From msuraev at sysmocom.de Wed Mar 9 13:14:30 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 14:14:30 +0100 Subject: [PATCH 4/4] OsmoPCU: expand BSSGP documentation In-Reply-To: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> References: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457529270-25058-4-git-send-email-msuraev@sysmocom.de> From: Max --- OsmoPCU/gb/bssgp.adoc | 379 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 376 insertions(+), 3 deletions(-) diff --git a/OsmoPCU/gb/bssgp.adoc b/OsmoPCU/gb/bssgp.adoc index c354fc1..3a49a71 100644 --- a/OsmoPCU/gb/bssgp.adoc +++ b/OsmoPCU/gb/bssgp.adoc @@ -1,3 +1,4 @@ +[[bssgp]] == BSS GPRS Protocol (BSSGP) === List of Messages @@ -11,24 +12,207 @@ level of compliance with 3GPP TS 08.18. [options="header",cols="10%,10%,20%,35%,5%,20%"] |=== | TS 08.18 ? | type code (hex) | This document ? | Message | <-/-> | Received/Sent by OsmoPCU +6+<| *RL and BSSGP SAP Messages:* +| 10.2.1 | 0x00 | <> | DL-UNITDATA | <- | Received +| 10.2.2 | 0x01 | <> | UL-UNITDATA | -> | Sent +| 10.2.3 | 0x02 | <> | RA-CAPABILITY | <- | Received +6+<| *GMM SAP Messages:* +| 10.3.1 | 0x06 | <> | PAGING PS | <- | Received +| 10.3.2 | 0x07 | <> | PAGING CS | <- | Received +| 10.3.7 | 0x0c | <> | SUSPEND-ACK | <- | Received +| 10.3.8 | 0x0d | <> | SUSPEND-NACK | <- | Received +| 10.3.10 | 0x0f | <> | RESUME-ACK | <- | Received +| 10.3.11 | 0x10 | <> | RESUME-NACK | <- | Received +6+<| *NM SAP Messages:* +| 10.4.9 | 0x21 | <> | BVC-BLOCK-ACK | <- | Received +| 10.4.12 | 0x22 | <> | BVC-RESET | <-/-> | Received/Sent +| 10.4.13 | 0x23 | <> | BVC-RESET-ACK | <- | Received +| 10.4.10 | 0x24 | <> | BVC-UNBLOCK | -> | Sent +| 10.4.11 | 0x25 | <> | BVC-UNBLOCK-ACK | <- | Received +| 10.4.4 | 0x26 | <> | FLOW-CONTROL-BVC | -> | Sent +| 10.4.5 | 0x27 | <> | FLOW-CONTROL-BVC-ACK | <- | Received +| 10.4.7 | 0x29 | <> | FLOW-CONTROL-MS-ACK | <- | Received +| 10.4.1 | 0x2a | <> | FLUSH-LL | <- | Received +| 10.4.15 | 0x40 | <> | SGSN-INVOKE-TRACE | <- | Received +| 10.4.14 | 0x41 | <> | STATUS | <-/-> | Received/Sent |=== ==== Messages Specific to OsmoPCU There are no OsmoPCU specific BSSGP messages. +[[not_impl]] ==== Messages Not Implemented by OsmoPCU .3GPP TS 08.18 messages not implemented by OsmoPCU [options="header",cols="10%,10%,80%"] |=== | TS 08.18 ? | type code (hex) | Message +3+<| *RL (relay) and BSSGP SAP Messages:* +| 10.2.4 | 0x03 | PTM-UNITDATA +3+<| *GMM (GPRS mobility management) SAP Messages:* +| 10.3.3 | 0x08 | RA-CAPABILITY-UPDATE +| 10.3.4 | 0x09 | RA-CAPABILITY-UPDATE-ACK +| 10.3.5 | 0x0a | RADIO-STATUS +| 10.3.6 | 0x0b | SUSPEND +| 10.3.9 | 0x0e | RESUME +3+<| *NM (network management) SAP Messages:* +| 10.4.8 | 0x20 | BVC-BLOCK +| 10.4.6 | 0x28 | FLOW-CONTROL-MS +| 10.4.2 | 0x2b | FLUSH-LL-ACK +| 10.4.3 | 0x2c | LLC-DISCARDED +3+<| *PFM (packet flow management) SAP Messages:* +| 10.4.16 | 0x50 | DOWNLOAD-BSS-PFC +| 10.4.17 | 0x51 | CREATE-BSS-PFC +| 10.4.18 | 0x52 | CREATE-BSS-PFC-ACK +| 10.4.19 | 0x53 | CREATE-BSS-PFC-NACK +| 10.4.20 | 0x54 | MODIFY-BSS-PFC +| 10.4.21 | 0x55 | MODIFY-BSS-PFC-ACK +| 10.4.22 | 0x56 | DELETE-BSS-PFC +| 10.4.23 | 0x57 | DELETE-BSS-PFC-ACK |=== === Details on Compliant BSSGP Messages -FIXME +[[dl_unit_data]] +==== DL-UNITDATA + +This message conforms to 3GPP TS 08.18 ? 10.2.1, with the following limitations: OsmoPCU does not support QoS, +all optional IEs except for IMSI and old TLLI are ignored. + +._DL-UNITDATA_ IE limitations +[options="header",cols="10%,30%,60%"] +|=== +| TS 08.18 ? | IE Name | Handling +| 11.3.28 | QoS Profile | _ignored_ +| 11.3.22 | MS Radio Access Capability | _ignored_ +| 11.3.27 | Priority | _ignored_ +| 11.3.11 | DRX Parameters | _ignored_ +| 1.3.42 | PFI | _ignored_ +| 11.3.19 | LSA Information | _ignored_ +| 11.3.47 | Service UTRAN CCO | _ignored_ +|=== + +[[ul_unit_data]] +==== UL-UNITDATA + +This message conforms to 3GPP TS 08.18 ? 10.2.2, with the following limitations: +OsmoPCU does not send optional IEs - PFI (? 12.3.42) and LSA Identifier List (? 11.3.18). +QoS Profile (? 11.3.28) IE is always set to 0x04. + +[[ra_capab]] +==== RA-CAPABILITY + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[paging_ps]] +==== PAGING PS + +This message conforms to 3GPP TS 08.18 ? 10.3.1, with the following limitations: +only IMSI and P-TMSI are parsed by OsmoPCU. + +._DL-UNITDATA_ IE limitations +[options="header",cols="10%,30%,60%"] +|=== +| TS 08.18 ? | IE Name | Handling +| 11.3.11 | DRX Parameters | _ignored_ +| 11.3.6 | BVCI | _ignored_ +| 11.3.17 | Location Are | _ignored_ +| 11.3.31 | Routeing Area | _ignored_ +| 11.3.3 | BSS Area Indication | _ignored_ +| 1.3.42 | PFI | _ignored_ +| 11.3.43 | ABQP | _ignored_ +| 11.3.28 | QoS Profile | _ignored_ +| 11.3.36 | P-TMSI | treated as mandatory (in case of absence paging with 0-length P-TMSI will be sent) +|=== + + +[[paging_cs]] +==== PAGING CS + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[susp_ack]] +==== SUSPEND-ACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[susp_nack]] +==== SUSPEND-NACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[res_ack]] +==== RESUME-ACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[res_nack]] +==== RESUME-NACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[block_ack]] +==== BVC-BLOCK-ACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[bvc_reset]] +==== BVC-RESET + +OsmoPCU never transmits optional Feature bitmap (3GPP TS 08.18 ? 11.3.40) IE. +Receiving BVC RESET will cause OsmoPCU to respond with "Unknown BVCI" status message. + +[[reset_ack]] +==== BVC-RESET-ACK + +This message conforms to 3GPP TS 08.18 ? 10.4.13. +After receiving it OsmoPCU completes the RESET procedure for BVC according to 3GPP TS 08.18 ? 8.4. + +[[unblock_ack]] +==== BVC-UNBLOCK-ACK + +This message conforms to 3GPP TS 08.18 ? 10.4.11. +After receiving it OsmoPCU completes the RESET procedure for BVC according to 3GPP TS 08.18 ? 8.3. + +[[bvc_unblock]] +==== BVC-UNBLOCK + +This message conforms to 3GPP TS 08.18 ? 10.4.10 and is send by OsmoPCU as part of UNBLOCK procedure +described in 3GPP TS 08.18 ? 8.3. + +[[flow_ms_ack]] +==== FLOW-CONTROL-MS-ACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[flow_bvc_ack]] +==== FLOW-CONTROL-BVC-ACK + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[flow_bvc]] +==== FLOW-CONTROL-BVC + +This message conforms to 3GPP TS 08.18 ? 10.4.4, with the following limitations: +OsmoPCU does not support Current Bucket Level (CBL) feature so Bucket_Full Ratio (TS 08.18 ? 11.3.46) IE +is not transmitted as part of this message. + +[[flush_ll]] +==== FLUSH-LL + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[invoke_trace]] +==== SGSN-INVOKE-TRACE + +This message is received and logged but ignored by OsmoPCU at the moment. + +[[bssgp_status]] +==== STATUS + +This message conforms to 3GPP TS 08.18 ? 10.4.14. === Information Elements Overview @@ -44,6 +228,50 @@ actually evaluated. [options="header",cols="5%,10%,40%,5%,40%"] |=== | tag (hex) | TS 08.18 ? | IE name | <-/-> | Received/Sent by OsmoPCU +| 0x00 | 11.3.1 | Alignment Octets | <-/-> | Received/Sent +| 0x01 | 11.3.2 | Bmax default MS | -> | Sent +| 0x02 | 11.3.3 | BSS Area Indication | <- | Received +| 0x03 | 11.3.4 | Bucket Leak Rate | -> | Sent +| 0x04 | 11.3.6 | BVCI | <-/-> | Received/Sent +| 0x05 | 11.3.5 | BVC Bucket Size | -> | Sent +| 0x06 | 11.3.7 | BVC Measurement | -> | Sent +| 0x07 | 11.3.8 | Cause | <-/-> | Received/Sent +| 0x08 | 11.3.9 | Cell Identifier | -> | Sent +| 0x09 | 11.3.10 | Channel needed | <- | Received +| 0x0a | 11.3.11 | DRX Parameters | <- | Received +| 0x0b | 11.3.12 | eMLPP-Priority | <- | Received +| 0x0c | 11.3.13 | Flush Action | <- | Received +| 0x0d | 11.3.14 | IMSI | <-/-> | Received/Sent +| 0x0e | 11.3.15 | LLC-PDU | <-/-> | Received/Sent +| 0x0f | 11.3.16 | LLC Frames Discarded | -> | Sent +| 0x10 | 11.3.17 | Location Area | <- | Received +| 0x11 | 11.3.20 | Mobile Id | <- | Received +| 0x12 | 11.3.21 | MS Bucket Size | -> | Sent +| 0x13 | 11.3.22 | MS Radio Access Capability | <- | Received +| 0x14 | 11.3.23 | OMC Id | <- | Received +| 0x15 | 11.3.24 | PDU In Error | <-/-> | Received/Sent +| 0x16 | 11.3.25 | PDU Lifetime | <- | Received +| 0x17 | 11.3.27 | Priority | <- | Received +| 0x19 | 11.3.29 | Radio Cause | -> | Sent +| 0x1a | 11.3.30 | RA-Cap-UPD-Cause | -> | Sent +| 0x1b | 11.3.31 | Routeing Area | <-/-> | Received/Sent +| 0x1c | 11.3.32 | R_default_MS | -> | Sent +| 0x1d | 11.3.33 | Suspend Reference Number | <-/-> | Received/Sent +| 0x1e | 11.3.34 | Tag | <-/-> | Received/Sent +| 0x1f | 11.3.35 | TLLI | <-/-> | Received/Sent +| 0x20 | 11.3.36 | TMSI | <-/-> | Received/Sent +| 0x21 | 11.3.37 | Trace Reference | <- | Received +| 0x22 | 11.3.38 | Trace Type | <- | Received +| 0x23 | 11.3.39 | TransactionId | <- | Received +| 0x24 | 11.3.40 | Trigger Id | <- | Received +| 0x25 | 11.3.41 | Number of octets affected | -> | Sent +| 0x26 | 11.3.18 | LSA Identifier List | -> | Sent +| 0x27 | 11.3.19 | LSA Information | <- | Received +| 0x28 | 11.3.42 | Packet Flow Identifier | <-/-> | Received/Sent +| 0x3a | 11.3.43 | Aggregate BSS QoS Profile (ABQP) | <-/-> | Received/Sent +| 0x3b | 11.3.45 | Feature Bitmap | <-/-> | Received/Sent +| 0x3c | 11.3.46 | Bucket_Full Ratio | -> | Sent +| 0x3d | 11.3.47 | Service UTRAN CCO (Cell Change Order) | <- | Received |=== ==== IEs Not Conforming to TS 08.18 @@ -52,6 +280,7 @@ actually evaluated. [options="header",cols="5%,10%,30%,55%"] |=== | tag (hex) | TS 08.18 ? | IE name | Description +| 0x18 | 11.3.28 | QoS Profile | Received value is ignored. Sent value is hardcoded to 0x4 (3 octets). |=== ==== Additional Attributes and Parameters @@ -60,8 +289,152 @@ There are no OsmoPCU specific additional Attributes and Parameters. === Details on IEs -FIXME +==== BSS Area Indication + +This IE is ignored by OsmoPCU. + +==== Bucket Leak Rate + +The value used by OsmoPCU for this IE can be set through configuration file or vty via +"flow-control force-ms-leak-rate <1-6553500>" command. + +==== BVC Bucket Size + +The value used by OsmoPCU for this IE can be set through configuration file or vty via +"flow-control force-bvc-bucket-size <1-6553500>" command. + +==== Channel needed + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== DRX Parameters + +This IE is ignored by OsmoPCU. + +==== eMLPP-Priority + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== Flush Action + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== LLC Frames Discarded + +This IE is not available because entire message which contains it (LLC-DISCARDED) is not implemented by +OsmoPCU - see for <> details. + +==== Location Area + +This IE is ignored by OsmoPCU. + +==== Mobile Id + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== MS Bucket Size + +The value used by OsmoPCU for this IE can be set through configuration file or vty via +"flow-control force-ms-bucket-size <1-6553500>" command. + +==== MS Radio Access Capability + +This IE is ignored by OsmoPCU. + +==== OMC Id + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== Priority + +This IE is ignored by OsmoPCU. + +==== QoS Profile + +No QoS is supported by OsmoPCU so this IE is ignored or safe default used when mandatory. + +==== Radio Cause + +This IE is not available because entire message which contains it (RADIO-STATUS) is not implemented by +OsmoPCU - see for <> details. + +==== RA-Cap-UPD-Cause + +This IE is not available because entire message which contains it (RA-CAPABILITY-UPDATE-ACK) is not implemented by +OsmoPCU - see for <> details. + +==== Routeing Area + +This IE is ignored by OsmoPCU upon receiving. +The messages which might require this IE to be send are not implemented by OsmoPCU - see for <> details. + +==== Suspend Reference Number + +This IE is ignored by OsmoPCU upon receiving. +The messages which might require this IE to be send are not implemented by OsmoPCU - see for <> details. + +==== Tag + +This IE currently only used by OsmoPCU for Flow Control procedure (TS 08.18 ? 8.2). In other cases it's either ignored or unavailable. + +==== Trace Reference + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== Trace Type + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== TransactionId + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== Trigger Id + +This IE is ignored because entire message which contains it is ignored by OsmoPCU - see <> for details. + +==== Number of octets affected + +This IE is not available because the messages which contains it (FLUSH-LL-ACK and LLC-DISCARDE) are not implemented by +OsmoPCU - see for <> details. + +==== LSA Information + +This IE is ignored by OsmoPCU. + +==== LSA Identifier List + +This IE is not implemented by OsmoPCU. + +==== Packet Flow Identifier + +This IE is ignored by OsmoPCU upon receiving. +The messages which might require this IE to be send are not implemented by OsmoPCU - see for <> details. + +==== Aggregate BSS QoS Profile (ABQP) + +This IE is ignored by OsmoPCU upon receiving. +The messages which might require this IE to be send are not implemented by OsmoPCU - see for <> details. + +==== Feature Bitmap + +This IE is not implemented by OsmoPCU. +This IE is ignored by OsmoPCU when received. +Absence of Feature Bitmap automatically disables optional features for Network Service Entity (NSE) communicating with OsmoPCU. + +==== Bucket_Full Ratio + +This IE is not implemented by OsmoPCU. + +==== Service UTRAN CCO (Cell Change Order) + +This IE is ignored by OsmoPCU. === Gb BSSGP Initialization / PCU bring-up -FIXME +The BSSGP initialization directly follows NS connection establishment described in <>. +OsmoPCU allocates BVC context for BVCI given by OsmoBTS which in turn gets it from OpenBSC. +In addition to BVCI identifying OsmoPCU side of BSSGP connection there is also special BVCI which is accepted by OsmoPCU +in accordance with TS 08.18 ? 5.4.1: BVCI = 0 represents signaling data between SGSN and PCU in contrast +to PTP (Peer-To-Peer) user's data. +The mapping between BSSGP PDUs and signaling or PTP BVCIs is available in TS 08.18 Table 5.4. -- 2.7.2 From msuraev at sysmocom.de Wed Mar 9 13:14:27 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 14:14:27 +0100 Subject: [PATCH 1/4] Initial place-holder for the new Gb/IP interface documentation Message-ID: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> From: Harald Welte --- OsmoPCU/Makefile | 3 +- OsmoPCU/gb/bssgp.adoc | 67 +++++++++++++++++++++++++++++++ OsmoPCU/gb/gb-startup.msc | 0 OsmoPCU/gb/ns.adoc | 67 +++++++++++++++++++++++++++++++ OsmoPCU/osmopcu-gb-docinfo.xml | 58 +++++++++++++++++++++++++++ OsmoPCU/osmopcu-gb.adoc | 89 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 OsmoPCU/gb/bssgp.adoc create mode 100644 OsmoPCU/gb/gb-startup.msc create mode 100644 OsmoPCU/gb/ns.adoc create mode 100644 OsmoPCU/osmopcu-gb-docinfo.xml create mode 100644 OsmoPCU/osmopcu-gb.adoc diff --git a/OsmoPCU/Makefile b/OsmoPCU/Makefile index f742e07..ef80327 100644 --- a/OsmoPCU/Makefile +++ b/OsmoPCU/Makefile @@ -14,11 +14,12 @@ docbooktotypes = pdf # htmlcss = TOPDIR := .. -ASCIIDOCS := osmopcu-usermanual +ASCIIDOCS := osmopcu-usermanual osmopcu-gb include $(TOPDIR)/build/Makefile.asciidoc.inc include $(TOPDIR)/build/Makefile.inc +osmopcu-gb.pdf: gb/*.adoc gb/*.msc osmopcu-usermanual.pdf: chapters/*.adoc clean: diff --git a/OsmoPCU/gb/bssgp.adoc b/OsmoPCU/gb/bssgp.adoc new file mode 100644 index 0000000..c354fc1 --- /dev/null +++ b/OsmoPCU/gb/bssgp.adoc @@ -0,0 +1,67 @@ +== BSS GPRS Protocol (BSSGP) + +=== List of Messages + +The following tables list the BSSGP messages used by OsmoPCU, grouped by their +level of compliance with 3GPP TS 08.18. + +==== Messages Compliant With TS 08.18 + +.Messages compliant with TS 08.18 +[options="header",cols="10%,10%,20%,35%,5%,20%"] +|=== +| TS 08.18 ? | type code (hex) | This document ? | Message | <-/-> | Received/Sent by OsmoPCU +|=== + +==== Messages Specific to OsmoPCU + +There are no OsmoPCU specific BSSGP messages. + +==== Messages Not Implemented by OsmoPCU + +.3GPP TS 08.18 messages not implemented by OsmoPCU +[options="header",cols="10%,10%,80%"] +|=== +| TS 08.18 ? | type code (hex) | Message +|=== + + +=== Details on Compliant BSSGP Messages + +FIXME + +=== Information Elements Overview + +All of the IEs handled by OsmoPCU are listed below, with limitations and +additions to TS 08.18 specified in more detail. + +==== IEs Conforming to TS 08.18 + +The following Information Elements are accepted by OsmoPCU. Not all IEs are +actually evaluated. + +.IEs conforming to TS 08.18 +[options="header",cols="5%,10%,40%,5%,40%"] +|=== +| tag (hex) | TS 08.18 ? | IE name | <-/-> | Received/Sent by OsmoPCU +|=== + +==== IEs Not Conforming to TS 08.18 + +.IEs not conforming to TS 08.18 +[options="header",cols="5%,10%,30%,55%"] +|=== +| tag (hex) | TS 08.18 ? | IE name | Description +|=== + +==== Additional Attributes and Parameters + +There are no OsmoPCU specific additional Attributes and Parameters. + +=== Details on IEs + +FIXME + +=== Gb BSSGP Initialization / PCU bring-up + +FIXME diff --git a/OsmoPCU/gb/gb-startup.msc b/OsmoPCU/gb/gb-startup.msc new file mode 100644 index 0000000..e69de29 diff --git a/OsmoPCU/gb/ns.adoc b/OsmoPCU/gb/ns.adoc new file mode 100644 index 0000000..0cc073b --- /dev/null +++ b/OsmoPCU/gb/ns.adoc @@ -0,0 +1,67 @@ +== Network Service (NS) + +=== List of Messages + +The following tables list the NS messages used by OsmoPCU, grouped by their +level of compliance with 3GPP TS 08.16. + +==== Messages Compliant With TS 08.16 + +.Messages compliant with TS 08.16 +[options="header",cols="10%,10%,20%,35%,5%,20%"] +|=== +| TS 08.16 ? | type code (hex) | This document ? | Message | <-/-> | Received/Sent by OsmoPCU +|=== + +==== Messages Specific to OsmoPCU + +There are no OsmoPCU specific NS messages. + +==== Messages Not Implemented by OsmoPCU + +.3GPP TS 08.16 messages not implemented by OsmoPCU +[options="header",cols="10%,10%,80%"] +|=== +| TS 08.16 ? | type code (hex) | Message +|=== + + +=== Details on Compliant NS Messages + +FIXME + +=== Information Elements Overview + +All of the IEs handled by OsmoPCU are listed below, with limitations and +additions to TS 08.16 specified in more detail. + +==== IEs Conforming to TS 08.16 + +The following Information Elements are accepted by OsmoPCU. Not all IEs are +actually evaluated. + +.IEs conforming to TS 08.16 +[options="header",cols="5%,10%,40%,5%,40%"] +|=== +| tag (hex) | TS 08.16 ? | IE name | <-/-> | Received/Sent by OsmoPCU +|=== + +==== IEs Not Conforming to TS 08.16 + +.IEs not conforming to TS 08.16 +[options="header",cols="5%,10%,30%,55%"] +|=== +| tag (hex) | TS 08.16 ? | IE name | Description +|=== + +==== Additional Attributes and Parameters + +There are no OsmoPCU specific additional Attributes and Parameters. + +=== Details on IEs + +FIXME + +=== Gb NS Initialization / PCU bring-up + +FIXME diff --git a/OsmoPCU/osmopcu-gb-docinfo.xml b/OsmoPCU/osmopcu-gb-docinfo.xml new file mode 100644 index 0000000..280c6f7 --- /dev/null +++ b/OsmoPCU/osmopcu-gb-docinfo.xml @@ -0,0 +1,58 @@ + + + 0 + February 2016 + HW, MS + + Initial version, reflecting OsmoPCU master branch as on FIXME + (commit FIXME). + + + + + + + Max + Suraev + msuraev at sysmocom.de + MS + + sysmocom + sysmocom - s.f.m.c. GmbH + Software Developer + + + + Harald + Welte + hwelte at sysmocom.de + HW + + sysmocom + sysmocom - s.f.m.c. GmbH + Managing Director + + + + + + 2015-2016 + sysmocom - s.f.m.c. GmbH + + + + + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU Free Documentation License, + Version 1.3 or any later version published by the Free Software + Foundation; with no Invariant Sections, no Front-Cover Texts, + and no Back-Cover Texts. A copy of the license is included in + the section entitled "GNU Free Documentation License". + + + The Asciidoc source code of this manual can be found at + + http://git.osmocom.org/osmo-gsm-manuals/ + + + diff --git a/OsmoPCU/osmopcu-gb.adoc b/OsmoPCU/osmopcu-gb.adoc new file mode 100644 index 0000000..261f7db --- /dev/null +++ b/OsmoPCU/osmopcu-gb.adoc @@ -0,0 +1,89 @@ +OsmoPCU Gb Protocol Specification +================================= +Harald Welte + +== Introduction + +This document describes the Gb interface of *OsmoPCU*. Based on 3GPP TS +FIXME and FIXME, this document indicates which of the 3GPP specified Gb +messages and IEs are implemented according to 3GPP specifications, which of +these are not or not fully implemented, as well as OsmoPCU-specific extensions +to the Gb interface not specified by 3GPP. + +Extensions to the Gb interface specific to OsmoPCU are detailed in this +document. For details on the messages and IEs that comply with abovementioned +3GPP specifications, please refer to those documents. + +.3GPP document versions referred to by this document +[cols="20%,80%"] +|=== +|3GPP TS 08.56 | version 8.0.1 Release 1999 +|3GPP TS 08.58 | version 8.6.0 Release 1999 +|3GPP TS 08.60 | version 8.2.1 Release 1999 +|3GPP TS 12.21 | version 8.0.0 Release 1999 +|=== + +.IETF documents referred to by his document +[cols="20%,80%"] +|=== +|IETF RFC 768 | User Datagram Protocol +|IETF RFC 791 | Internet Protocol +|=== + +== Overview + +The OsmoPCU Gb interface consists of the NS (Network Services) and +BSSGP (Base Station Subsystem Gateway Protocol), encapsulated in UDP +(User Datagram Protocol) and IP (Internet Protocol) version 4. + +.UDP port numbers used by OsmoPCU Gb/IP +[options="header",width="50%",cols="35%,65%"] +|=== +|TCP Port Number|Usage +|23000|NS over UDP +|=== + +The NS-over-UDP link is established in the PCU -> SGSN direction, i.e. +the PCU is running as client while the SGSN is running as server. + +Establishment of the NS-over-UDP link is only possible after OsmoPCU +has been configured viat the *PCU socket* interface from OsmoBTS. + +OsmoBTS in turn receives relevant configuration parameters from +OsmoBSC or the BSC component inside OsmoNITB. + +.Overview of Gb link establishment +["mscgen"] +---- +include::gb/gb-startup.msc[] +---- + +=== Identities + +The Gb interface identities of the PCU are configured via BSC -> +OsmoBTS -> PCU Socket. They consist of + +NSEI:: NS Equipment Identifier +NSVCI:: NS Virtual Connection Identifier +BVCI:: BSSGP Virtual Connection Identifier + +For an explanation of those identifiers and their use in the NS and +BSSGP protocols, please see the reelvant 3GPP specifications for NS +and BSSGP. + +In most cases, all above identities belong to different namespaces and +must be unique within their respective namespace and within the SGSN +they connect to. + +This means that typically each OsmoPCU has one unique set of NSEI, +NSVCI and BVCI in your network. + +include::gb/ns.adoc[] + +include::gb/bssgp.adoc[] + +include::../common/chapters/port_numbers.adoc[] + +include::../common/chapters/glossary.adoc[] + +include::../common/chapters/gfdl.adoc[] -- 2.7.2 From msuraev at sysmocom.de Wed Mar 9 13:14:29 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 9 Mar 2016 14:14:29 +0100 Subject: [PATCH 3/4] OsmoPCU: expand NS documentation In-Reply-To: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> References: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457529270-25058-3-git-send-email-msuraev@sysmocom.de> From: Max Add table with NS messages. Add corresponding sections. Clarify spec numbers. --- OsmoPCU/gb/ns.adoc | 153 +++++++++++++++++++++++++++++++++++++++++++----- OsmoPCU/osmopcu-gb.adoc | 6 +- 2 files changed, 141 insertions(+), 18 deletions(-) diff --git a/OsmoPCU/gb/ns.adoc b/OsmoPCU/gb/ns.adoc index 0cc073b..3788389 100644 --- a/OsmoPCU/gb/ns.adoc +++ b/OsmoPCU/gb/ns.adoc @@ -7,10 +7,24 @@ level of compliance with 3GPP TS 08.16. ==== Messages Compliant With TS 08.16 +The NS protocol is implemented inside libosmocore so none of the messages below are sent by OsmoPCU explicitly. +Instead corresponding functions from libosmocore are called which send and receive messages as necessary. See <> for details +on establishing NS connection. + .Messages compliant with TS 08.16 [options="header",cols="10%,10%,20%,35%,5%,20%"] |=== | TS 08.16 ? | type code (hex) | This document ? | Message | <-/-> | Received/Sent by OsmoPCU +| 9.2.10 | 0x00 | <> | NS-UNITDATA | <-/-> | Received/Sent +| 9.2.5 | 0x02 | <> | NS-RESET | <-/-> | Received/Sent +| 9.2.6 | 0x03 | <> | NS-RESET-ACK | <-/-> | Received/Sent +| 9.2.3 | 0x04 | <> | NS-BLOCK | <-/-> | Received/Sent +| 9.2.4 | 0x05 | <> | NS-BLOCK-ACK | <-/-> | Received/Sent +| 9.2.8 | 0x06 | <> | NS-UNBLOCK | <-/-> | Received/Sent +| 9.2.9 | 0x07 | <> | NS-UNBLOCK-ACK | <-/-> | Received/Sent +| 9.2.7 | 0x08 | <> | NS-STATUS | <-/-> | Received/Sent +| 9.2.1 | 0x0a | <> | NS-ALIVE | <-/-> | Received/Sent +| 9.2.2 | 0x0b | <> | NS-ALIVE-ACK | <-/-> | Received/Sent |=== ==== Messages Specific to OsmoPCU @@ -19,16 +33,92 @@ There are no OsmoPCU specific NS messages. ==== Messages Not Implemented by OsmoPCU -.3GPP TS 08.16 messages not implemented by OsmoPCU -[options="header",cols="10%,10%,80%"] -|=== -| TS 08.16 ? | type code (hex) | Message -|=== - +All the NS protocol messages from 3GPP TS 08.16 are implemented in OsmoPCU. === Details on Compliant NS Messages -FIXME +[[ns_unit_data]] +==== NS-UNITDATA + +This PDU transfers one NS SDU (specified in 3GPP TS 08.18) between OsmoPCU and SGSN. Upon receiving it OsmoPCU passes it to BSSGP +implementaton to handle. It is also sent by BSSGP as necessary - see <> for details. +It contains BVCI (<>) and NS SDU (<>) IEs. + +[[ns_reset]] +==== NS-RESET + +This message is send by OsmoPCU in order to initiate reset procedure described in 3GPP TS 08.16 ? 7.3. The expected reply is +NS-RESET-ACK (<>) message. If no expected reply is received in 3 seconds than the sending is retried up to 3 times. +When this message is received it is replied with NS-RESET-ACK (<>). +It might be ignored under conditions described in 3GPP TS 08.16 ? 7.3.1. +The message conforms to 3GPP TS 08.16 ? 9.2.5 specification. +It contains Cause (<>), NSVCI (<>) and NSEI (<>) IEs. + +[[ns_reset_ack]] +==== NS-RESET-ACK + +This message is sent as a response to proper NS-RESET (<>) message initiating reset procedure. +The message conforms to 3GPP TS 08.16 ? 9.2.6 specification. +It contains NSVCI (<>) and NSEI (<>) IEs. + +[[ns_block]] +==== NS-BLOCK + +Upon receiving this message corresponding NS-VC is marked as blocked by OsmoPCU and NS-BLOCK-ACK (<>) reply is +transmitted. +When this message is sent by OsmoPCU corresponding NS-BLOCK-ACK (<>) reply is expected before NS-VC is actually marked +as blocked. +This behavior follows the blocking procedure described in 3GPP TS 08.16 ? 7.2. +The message conforms to 3GPP TS 08.16 ? 9.2.3 specification. +It contains Cause (<>) and NSVCI (<>) IEs. + +[[ns_block_ack]] +==== NS-BLOCK-ACK + +This message is sent by OsmoPCU automatically upon reception of correct NS-BLOCK (<>) message. +It is expected as a reply for NS-BLOCK (<>) message sent by OsmoPCU. +The message conforms to 3GPP TS 08.16 ? 9.2.4 specification. +It contains NSVCI (<>) IE. + +[[ns_unblock]] +==== NS-UNBLOCK + +Upon receiving this message corresponding NS-VC is unblocked by OsmoPCU and NS-UNBLOCK-ACK (<>) reply is sent. +When this message is sent by OsmoPCU corresponding NS-UNBLOCK-ACK (<>) reply is expected before NS-VC is actually +marked as unblocked. +This behavior follows the blocking procedure described in 3GPP TS 08.16 ? 7.2. +The message conforms to 3GPP TS 08.16 ? 9.2.8 specification. + +[[ns_unblock_ack]] +==== NS-UNBLOCK-ACK + +Receiving this message notifies OsmoPCU that NS-VC unblocking request is confirmed and thus NS-VC is marked as unblocked. +This message is also sent as a reply to NS-UNBLOCK (<>) message. +The message conforms to 3GPP TS 08.16 ? 9.2.9 specification. + +[[ns_status]] +==== NS-STATUS + +This message is sent to inform other party about error conditions as a response to various unexpected PDUs or PDUs with +unexpected/missing data. If this message is received for unknown NS-VC it is ignored in accordance with 3GPP TS +08.16 ? 7.5.1, otherwise the error cause is logged if present in NS-STATUS. +The message conforms to 3GPP TS 08.16 ? 9.2.7 specification. +It contains Cause (<>) and might (depending on actual error) contain NSVCI (<>), NS PDU (<>) and BVCI (<>) IEs. + +[[ns_alive]] +==== NS-ALIVE + +This message is sent periodically to test connectivity according to 3GPP TS 08.16 ? 4.5.3. The expected response is +NS-ALIVE-ACK (<>). If no such response arrives within given amount of time (3 seconds) than another +NS-ALIVE message is sent and failed test attempt is recorded. +After 10 failed attempts NS connection is considered dead and OsmoPCU tries to reconnect. +The message conforms to 3GPP TS 08.16 ? 9.2.1 specification. + +[[ns_alive_ack]] +==== NS-ALIVE-ACK + +This message is sent automatically in reply to NS-ALIVE (<>) message. +The message conforms to 3GPP TS 08.16 ? 9.2.2 specification. === Information Elements Overview @@ -37,22 +127,22 @@ additions to TS 08.16 specified in more detail. ==== IEs Conforming to TS 08.16 -The following Information Elements are accepted by OsmoPCU. Not all IEs are -actually evaluated. +The following Information Elements are accepted by OsmoPCU. .IEs conforming to TS 08.16 [options="header",cols="5%,10%,40%,5%,40%"] |=== | tag (hex) | TS 08.16 ? | IE name | <-/-> | Received/Sent by OsmoPCU +| 0x00 | 10.3.2 | Cause | <-/-> | Received/Sent +| 0x01 | 10.3.5 | NSVCI | <-/-> | Received/Sent +| 0x02 | 10.3.3 | NS PDU | <-/-> | Received/Sent +| 0x03 | 10.3.1 | BVCI | <-/-> | Received/Sent +| 0x04 | 10.3.6 | NSEI | <-/-> | Received/Sent |=== ==== IEs Not Conforming to TS 08.16 -.IEs not conforming to TS 08.16 -[options="header",cols="5%,10%,30%,55%"] -|=== -| tag (hex) | TS 08.16 ? | IE name | Description -|=== +All IEs defined in TS 08.16 ? 10.3 are supported by OsmoPCU. ==== Additional Attributes and Parameters @@ -60,8 +150,39 @@ There are no OsmoPCU specific additional Attributes and Parameters. === Details on IEs -FIXME +[[ie_cause]] +==== Cause + +This IE contains reason for a procedure or error as described in TS 08.16 ? 10.3.2. + +[[ie_nsvci]] +==== NSVCI + +This IE represents NSVCI identity described in <> and TS 08.16 ? 10.3.5. + +[[ie_nspdu]] +==== NS PDU + +This IE contains PDU (possibly truncated) which cause error described in NS-STATUS message (<>) as described in TS 08.16 ? 10.3.3. + +[[ie_nssdu]] +==== NS SDU + +This IE contains BSSGP data - see <> for details. + +[[ie_bvci]] +==== BVCI + +This IE represents BSSGP identity described in <> and TS 08.16 ? 10.3.1. + +[[ie_nsei]] +==== NSEI + +This IE represents NSEI identity described in <> and TS 08.16 ? 10.3.6. +[[ns_init]] === Gb NS Initialization / PCU bring-up -FIXME +OsmoPCU create NS listening socket using UDP port given by OsmoBTS via PCU socket. OsmoBTS in turn receive it from BSC. +After that OsmoPCU tried to connect to remote NS ip:port over UDP using parameters received from BTS. +Following successful connection the reset procedure is initiated as described in <>. diff --git a/OsmoPCU/osmopcu-gb.adoc b/OsmoPCU/osmopcu-gb.adoc index 6ebcf18..620d336 100644 --- a/OsmoPCU/osmopcu-gb.adoc +++ b/OsmoPCU/osmopcu-gb.adoc @@ -37,6 +37,7 @@ document. For details on the messages and IEs that comply with abovementioned The OsmoPCU Gb interface consists of the NS (Network Services) and BSSGP (Base Station Subsystem Gateway Protocol), encapsulated in UDP (User Datagram Protocol) and IP (Internet Protocol) version 4. +Use of other underlying protocols (e. g. FrameRelay) is not supported. .UDP port numbers used by OsmoPCU Gb/IP [options="header",width="50%",cols="35%,65%"] @@ -60,6 +61,7 @@ OsmoBSC or the BSC component inside OsmoNITB. include::gb/gb-startup.msc[] ---- +[[ident]] === Identities The Gb interface identities of the PCU are configured via BSC -> @@ -70,8 +72,8 @@ NSVCI:: NS Virtual Connection Identifier BVCI:: BSSGP Virtual Connection Identifier For an explanation of those identifiers and their use in the NS and -BSSGP protocols, please see the reelvant 3GPP specifications for NS -and BSSGP. +BSSGP protocols, please see the reelvant 3GPP specifications for NS (TS 08.16) +and BSSGP (TS 08.18). In most cases, all above identities belong to different namespaces and must be unique within their respective namespace and within the SGSN -- 2.7.2 From laforge at gnumonks.org Thu Mar 10 06:08:44 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 10 Mar 2016 13:08:44 +0700 Subject: [PATCH 2/4] OsmoPCU: fix Gb documentation front page In-Reply-To: <1457529270-25058-2-git-send-email-msuraev@sysmocom.de> References: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> <1457529270-25058-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160310060844.GB26794@nataraja> Hi Max, I merged your OsmoPCU documentation changes, and performed some additional clean-up / spelling fixes and clarifications. It's now part of master and has already been built and deployed automatically at http://ftp.osmocom.org/docs/latest/osmopcu-gb.pdf Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Thu Mar 10 07:00:34 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 10 Mar 2016 08:00:34 +0100 Subject: [PATCH 2/4] OsmoPCU: fix Gb documentation front page In-Reply-To: <20160310060844.GB26794@nataraja> References: <1457529270-25058-1-git-send-email-msuraev@sysmocom.de> <1457529270-25058-2-git-send-email-msuraev@sysmocom.de> <20160310060844.GB26794@nataraja> Message-ID: <35F8B6C7-B414-49B9-9916-E2EC49E1456C@freyther.de> > On 10 Mar 2016, at 07:08, Harald Welte wrote: > > Hi Max, Hi, > I merged your OsmoPCU documentation changes, and performed some > additional clean-up / spelling fixes and clarifications. It's now part > of master and has already been built and deployed automatically at > http://ftp.osmocom.org/docs/latest/osmopcu-gb.pdf could you please change the status on the patches to something like "Accepted" so that they are removed from the patchwork view. thank you holger From nhofmeyr at sysmocom.de Thu Mar 10 21:51:45 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 10 Mar 2016 22:51:45 +0100 Subject: Authentication Response msg type: 0x14 in spec, 0x94 from a 3G phone Message-ID: <20160310215145.GA2124@dub6> Hi list, today I saw an MM Authentication Response sent from a 3G UE that mismatches the GSM 04.08 spec. The spec says 0x14, the 3G phone sent 0x94. And wireshark agrees that 0x94 is an Authentication Response. The spec ETSI TS 100 940 V7.21.0 (2003-12) chapter 10.4 defines the MM Authentication Response message type as 8 7 6 5 4 3 2 1 0 x 0 1 - - - - Security messages: 0 1 0 0 AUTHENTICATION RESPONSE So this would be 0x14 or 0x54, depending on the don't-care bit 7. The Osmocom code acts according to spec by applying a bitmask of 0xbf (0b10111111) before comparing to 0x14, caring about bit 8. However, the 3G phone sent an Authentication Response message type of 0x94 (0b10010100) with bit 8 set. Interestingly enough, wireshark interprets this as a 0x14 with the highest two bits as sequence nr. So it seems the reality in the field differs from the spec in that bit 8 should be masked away before comparing to the MM message type code. In consequence, I need to adjust the MM message type bitmask to 0x3f in upcoming patches. The thing is, our code has the apparently wrong 0xbf bitmask hardcoded in numerous places. So as a first step, I will introduce bitmask #defines in libosmocore and apply these in openbsc. I will introduce separate bitmask defines for MM and CC messages, because I'm not sure yet whether CC message types should also be masked with 0x3f in the field and will leave the CC mask as 0xbf for now. While doing that, I also noticed that some places apply a 0xbf bitmask even though the message types in question aren't defined as having any don't-care bit in TS 100 940. I'll adjust those in a separate patch. - So at first, I will replace 0xbf with GSM48_MT_MM_MSG_TYPE_MASK or GSM48_MT_CC_MSG_TYPE_MASK. - Then I'll adjust the MM mask to 0x3f to allow testing 3G auth. - Finally I'll remove bit masks where they shouldn't be applicable, which could use a second opinion by you guys. Are the upper bits always some sequence number, and the spec simply doesn't reflect the field? The patch submissions will follow right up... ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Thu Mar 10 21:55:48 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 10 Mar 2016 22:55:48 +0100 Subject: [PATCH 1/2] Add defines for MM and CC message type bitmasks Message-ID: <1457646949-26303-1-git-send-email-nhofmeyr@sysmocom.de> The bitmasks are 0xbf according to ETSI 3GPP TS 100 940 chapter 10.4 --- include/osmocom/gsm/protocol/gsm_04_08.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 9fcdddc..43571b9 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -820,6 +820,7 @@ struct gsm48_rr_status { #define GSM48_MT_RR_APP_INFO 0x38 /* Table 10.2/3GPP TS 04.08 */ +#define GSM48_MT_MM_MSG_TYPE_MASK 0xbf #define GSM48_MT_MM_IMSI_DETACH_IND 0x01 #define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02 #define GSM48_MT_MM_LOC_UPD_REJECT 0x04 @@ -846,6 +847,7 @@ struct gsm48_rr_status { #define GSM48_MT_MM_INFO 0x32 /* Table 10.3/3GPP TS 04.08 */ +#define GSM48_MT_CC_MSG_TYPE_MASK 0xbf #define GSM48_MT_CC_ALERTING 0x01 #define GSM48_MT_CC_CALL_CONF 0x08 #define GSM48_MT_CC_CALL_PROC 0x02 -- 2.1.4 From nhofmeyr at sysmocom.de Thu Mar 10 21:55:49 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 10 Mar 2016 22:55:49 +0100 Subject: [PATCH 2/2] Adjust MM message type bitmask according to field testing In-Reply-To: <1457646949-26303-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457646949-26303-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457646949-26303-2-git-send-email-nhofmeyr@sysmocom.de> Though ETSI 3GPP TS 100 940 chapter 10.4 defines the message bitmask to be 0xbf, the message types observed in the field need a bitmask of 0x3f instead. Our 3G UE as well as the wireshark bisector for MM messages both agree that the upper bits (bit 8 and 7 == 0xc0) are used as sequence number. --- include/osmocom/gsm/protocol/gsm_04_08.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 43571b9..2a6f348 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -820,7 +820,7 @@ struct gsm48_rr_status { #define GSM48_MT_RR_APP_INFO 0x38 /* Table 10.2/3GPP TS 04.08 */ -#define GSM48_MT_MM_MSG_TYPE_MASK 0xbf +#define GSM48_MT_MM_MSG_TYPE_MASK 0x3f #define GSM48_MT_MM_IMSI_DETACH_IND 0x01 #define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02 #define GSM48_MT_MM_LOC_UPD_REJECT 0x04 -- 2.1.4 From nhofmeyr at sysmocom.de Thu Mar 10 22:22:19 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 10 Mar 2016 23:22:19 +0100 Subject: [PATCH 1/2] GSM 04.08 message types: apply bitmask makros Message-ID: <1457648540-3481-1-git-send-email-nhofmeyr@sysmocom.de> In libosmocore, MM and CC message type bitmask makros were introduced. Replace hardcoded bitmasks with these makros. Also replace the protocol discriminator mask 0x0f with GSM48_PDISC_MASK. Note: in some places, use of the bitmask is doubtful. This commit so far applies the makros without changing anything. Also note: the MM bitmask is hardcoded as 0xbf, but libosmocore also adjusts the mask to the apparent de-facto standard of 0x3f, while the CC bitmask is so far left unchanged at 0xbf. So where in doubt, use the CC bitmask. --- openbsc/src/libfilter/bsc_msg_filter.c | 8 ++++---- openbsc/src/libmsc/gsm_04_08.c | 8 ++++---- openbsc/src/osmo-bsc/osmo_bsc_api.c | 8 ++++---- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 8 ++++---- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/openbsc/src/libfilter/bsc_msg_filter.c b/openbsc/src/libfilter/bsc_msg_filter.c index eafeff4..25674e1 100644 --- a/openbsc/src/libfilter/bsc_msg_filter.c +++ b/openbsc/src/libfilter/bsc_msg_filter.c @@ -339,8 +339,8 @@ int bsc_msg_filter_initial(struct gsm48_hdr *hdr48, size_t hdr48_len, cause->lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED; *imsi = NULL; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = hdr48->proto_discr & GSM48_PDISC_MASK; + msg_type = hdr48->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; if (proto == GSM48_PDISC_MM && msg_type == GSM48_MT_MM_LOC_UPD_REQUEST) { *con_type = FLT_CON_TYPE_LU; @@ -388,8 +388,8 @@ int bsc_msg_filter_data(struct gsm48_hdr *hdr48, size_t len, if (state->imsi_checked) return 0; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = hdr48->proto_discr & GSM48_PDISC_MASK; + msg_type = hdr48->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; if (proto != GSM48_PDISC_MM || msg_type != GSM48_MT_MM_ID_RESP) return 0; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index d9d7390..3279835 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1131,7 +1131,7 @@ static int gsm0408_rcv_mm(struct gsm_subscriber_connection *conn, struct msgb *m struct gsm48_hdr *gh = msgb_l3(msg); int rc = 0; - switch (gh->msg_type & 0xbf) { + switch (gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK) { case GSM48_MT_MM_LOC_UPD_REQUEST: DEBUGP(DMM, "LOCATION UPDATING REQUEST: "); rc = mm_rx_loc_upd_req(conn, msg); @@ -1860,7 +1860,7 @@ static void gsm48_start_cc_timer(struct gsm_trans *trans, int current, static int gsm48_cc_rx_setup(struct gsm_trans *trans, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t msg_type = gh->msg_type & 0xbf; + uint8_t msg_type = gh->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; unsigned int payload_len = msgb_l3len(msg) - sizeof(*gh); struct tlv_parsed tp; struct gsm_mncc setup; @@ -3487,7 +3487,7 @@ static struct datastate { static int gsm0408_rcv_cc(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t msg_type = gh->msg_type & 0xbf; + uint8_t msg_type = gh->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; uint8_t transaction_id = ((gh->proto_discr & 0xf0) ^ 0x80) >> 4; /* flip */ struct gsm_trans *trans = NULL; int i, rc = 0; @@ -3578,7 +3578,7 @@ int gsm0408_new_conn(struct gsm_subscriber_connection *conn) int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; + uint8_t pdisc = gh->proto_discr & GSM48_PDISC_MASK; int rc = 0; LOGP(DRLL, LOGL_DEBUG, "Dispatching 04.08 message, pdisc=%d\n", pdisc); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index fbeed77..fde3566 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -180,8 +180,8 @@ static void bsc_send_ussd_no_srv(struct gsm_subscriber_connection *conn, return; gh = msgb_l3(msg); - pdisc = gh->proto_discr & 0x0f; - mtype = gh->msg_type & 0xbf; + pdisc = gh->proto_discr & GSM48_PDISC_MASK; + mtype = gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; /* Is CM service request? */ if (pdisc == GSM48_PDISC_MM && mtype == GSM48_MT_MM_CM_SERV_REQ) { @@ -341,8 +341,8 @@ static int handle_cc_setup(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; - uint8_t mtype = gh->msg_type & 0xbf; + uint8_t pdisc = gh->proto_discr & GSM48_PDISC_MASK; + uint8_t mtype = gh->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; struct osmo_msc_data *msc; struct gsm_mncc_number called; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 389a124..e1e948b 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -141,8 +141,8 @@ struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, } gh = msgb_l3(msg); - pdisc = gh->proto_discr & 0x0f; - mtype = gh->msg_type & 0xbf; + pdisc = gh->proto_discr & GSM48_PDISC_MASK; + mtype = gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; /* * We are asked to select a MSC here but they are not equal. We @@ -213,7 +213,7 @@ int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); uint8_t pdisc = gh->proto_discr & 0x0f; - uint8_t mtype = gh->msg_type & 0xbf; + uint8_t mtype = gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; if (pdisc == GSM48_PDISC_MM) { if (mtype == GSM48_MT_MM_LOC_UPD_REQUEST) @@ -347,7 +347,7 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) gh = (struct gsm48_hdr *) msgb_l3(msg); length -= (const char *)&gh->data[0] - (const char *)gh; - mtype = gh->msg_type & 0xbf; + mtype = gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; net = conn->bts->network; msc = conn->sccp_con->msc; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index cdab406..cbfb091 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -670,8 +670,8 @@ static void update_con_authorize(struct nat_sccp_connection *con, if (!hdr48) return; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = hdr48->proto_discr & GSM48_PDISC_MASK; + msg_type = hdr48->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; if (proto == GSM48_PDISC_MM && msg_type == GSM48_MT_MM_CM_SERV_ACC) con->authorized = 1; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c index ca5670c..ce7dfb8 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c @@ -594,8 +594,8 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b return msg; link_id = msg->l3h[1]; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = hdr48->proto_discr & GSM48_PDISC_MASK; + msg_type = hdr48->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; if (proto == GSM48_PDISC_CC && msg_type == GSM48_MT_CC_SETUP) new_msg = rewrite_setup(nat, msg, parsed, imsi, hdr48, len); diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 1082414..8954ac1 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -407,8 +407,8 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse if (!hdr48) return 0; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = hdr48->proto_discr & GSM48_PDISC_MASK; + msg_type = hdr48->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; ti = (hdr48->proto_discr & 0x70) >> 4; if (proto != GSM48_PDISC_NC_SS) return 0; -- 2.1.4 From nhofmeyr at sysmocom.de Thu Mar 10 22:22:20 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 10 Mar 2016 23:22:20 +0100 Subject: [PATCH 2/2] GSM 04.08 message types: fix use of bitmasks In-Reply-To: <1457648540-3481-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457648540-3481-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457648540-3481-2-git-send-email-nhofmeyr@sysmocom.de> According to spec, the bitmasks for message types apply only for MM and CC messages. However, various code used the bitmask even though no MM or CC messages are involved: bsc_msg_filter.c: bsc_msg_filter_initial(): use bitmasked msg_type_mm for MM messages, use unmasked msg_type for RR. osmo_bsc_filter.c: bsc_find_msc() and bsc_scan_bts_msg(): use msg_type_mm for MM, unmasked for RR. bsc_nat_rewrite.c: bsc_nat_rewrite_msg(): use msg_type_cc for CC, unmasked for SMS. bsc_ussd.c: don't mask, no MM nor CC involved. --- openbsc/src/libfilter/bsc_msg_filter.c | 9 +++++---- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 11 +++++++---- openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c | 7 ++++--- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/openbsc/src/libfilter/bsc_msg_filter.c b/openbsc/src/libfilter/bsc_msg_filter.c index 25674e1..581bba1 100644 --- a/openbsc/src/libfilter/bsc_msg_filter.c +++ b/openbsc/src/libfilter/bsc_msg_filter.c @@ -332,7 +332,7 @@ int bsc_msg_filter_initial(struct gsm48_hdr *hdr48, size_t hdr48_len, char **imsi, struct bsc_filter_reject_cause *cause) { int ret = 0; - uint8_t msg_type, proto; + uint8_t msg_type, msg_type_mm, proto; *con_type = FLT_CON_TYPE_NONE; cause->cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED; @@ -340,14 +340,15 @@ int bsc_msg_filter_initial(struct gsm48_hdr *hdr48, size_t hdr48_len, *imsi = NULL; proto = hdr48->proto_discr & GSM48_PDISC_MASK; - msg_type = hdr48->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; + msg_type = hdr48->msg_type; + msg_type_mm = msg_type & GSM48_MT_MM_MSG_TYPE_MASK; if (proto == GSM48_PDISC_MM && - msg_type == GSM48_MT_MM_LOC_UPD_REQUEST) { + msg_type_mm == GSM48_MT_MM_LOC_UPD_REQUEST) { *con_type = FLT_CON_TYPE_LU; ret = _cr_check_loc_upd(req->ctx, &hdr48->data[0], hdr48_len - sizeof(*hdr48), imsi); } else if (proto == GSM48_PDISC_MM && - msg_type == GSM48_MT_MM_CM_SERV_REQ) { + msg_type_mm == GSM48_MT_MM_CM_SERV_REQ) { *con_type = FLT_CON_TYPE_CM_SERV_REQ; ret = _cr_check_cm_serv_req(req->ctx, &hdr48->data[0], hdr48_len - sizeof(*hdr48), diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index e1e948b..017db57 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -128,6 +128,7 @@ struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct gsm48_hdr *gh; int8_t pdisc; uint8_t mtype; + uint8_t mtype_mm; struct osmo_bsc_data *bsc; struct osmo_msc_data *msc, *pag_msc; struct gsm_subscriber *subscr; @@ -142,7 +143,8 @@ struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, gh = msgb_l3(msg); pdisc = gh->proto_discr & GSM48_PDISC_MASK; - mtype = gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; + mtype = gh->msg_type; + mtype_mm = mtype & GSM48_MT_MM_MSG_TYPE_MASK; /* * We are asked to select a MSC here but they are not equal. We @@ -152,7 +154,7 @@ struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, */ if (pdisc == GSM48_PDISC_RR && mtype == GSM48_MT_RR_PAG_RESP) goto paging; - else if (pdisc == GSM48_PDISC_MM && mtype == GSM48_MT_MM_CM_SERV_REQ) { + else if (pdisc == GSM48_PDISC_MM && mtype_mm == GSM48_MT_MM_CM_SERV_REQ) { is_emerg = is_cm_service_for_emerg(msg); goto round_robin; } else @@ -213,10 +215,11 @@ int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); uint8_t pdisc = gh->proto_discr & 0x0f; - uint8_t mtype = gh->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; + uint8_t mtype = gh->msg_type; + uint8_t mtype_mm = mtype & GSM48_MT_MM_MSG_TYPE_MASK; if (pdisc == GSM48_PDISC_MM) { - if (mtype == GSM48_MT_MM_LOC_UPD_REQUEST) + if (mtype_mm == GSM48_MT_MM_LOC_UPD_REQUEST) handle_lu_request(conn, msg); } else if (pdisc == GSM48_PDISC_RR) { if (mtype == GSM48_MT_RR_PAG_RESP) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c index ce7dfb8..97d5e3d 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c @@ -576,7 +576,7 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b { struct gsm48_hdr *hdr48; uint32_t len; - uint8_t msg_type, proto; + uint8_t msg_type, msg_type_cc, proto; struct msgb *new_msg = NULL, *sccp; uint8_t link_id; @@ -595,9 +595,10 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b link_id = msg->l3h[1]; proto = hdr48->proto_discr & GSM48_PDISC_MASK; - msg_type = hdr48->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; + msg_type = hdr48->msg_type; + msg_type_cc = msg_type & GSM48_MT_CC_MSG_TYPE_MASK; - if (proto == GSM48_PDISC_CC && msg_type == GSM48_MT_CC_SETUP) + if (proto == GSM48_PDISC_CC && msg_type_cc == GSM48_MT_CC_SETUP) new_msg = rewrite_setup(nat, msg, parsed, imsi, hdr48, len); else if (proto == GSM48_PDISC_SMS && msg_type == GSM411_MT_CP_DATA) new_msg = rewrite_sms(nat, msg, parsed, imsi, hdr48, len); diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 8954ac1..96d4a84 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -408,7 +408,7 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse return 0; proto = hdr48->proto_discr & GSM48_PDISC_MASK; - msg_type = hdr48->msg_type & GSM48_MT_CC_MSG_TYPE_MASK; + msg_type = hdr48->msg_type; ti = (hdr48->proto_discr & 0x70) >> 4; if (proto != GSM48_PDISC_NC_SS) return 0; -- 2.1.4 From nhofmeyr at sysmocom.de Thu Mar 10 22:30:37 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 10 Mar 2016 23:30:37 +0100 Subject: [PATCH] fix confusing typo in constant (THAN -> THEN) Message-ID: <1457649037-4868-1-git-send-email-nhofmeyr@sysmocom.de> --- openbsc/include/openbsc/auth.h | 2 +- openbsc/src/libmsc/auth.c | 2 +- openbsc/src/libmsc/gsm_04_08.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index 2364fb3..d41d141 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -6,7 +6,7 @@ struct gsm_subscriber; enum auth_action { AUTH_NOT_AVAIL = 0, /* No auth tuple available */ - AUTH_DO_AUTH_THAN_CIPH = 1, /* Firsth authenticate, then cipher */ + AUTH_DO_AUTH_THEN_CIPH = 1, /* Firsth authenticate, then cipher */ AUTH_DO_CIPH = 2, /* Only ciphering */ AUTH_DO_AUTH = 3, /* Only authentication, no ciphering */ }; diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 0a2f59e..65a9b03 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -132,6 +132,6 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, db_sync_lastauthtuple_for_subscr(atuple, subscr); DEBUGP(DMM, "Need to do authentication and ciphering\n"); - return AUTH_DO_AUTH_THAN_CIPH; + return AUTH_DO_AUTH_THEN_CIPH; } diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 9b903ee..8fcb6cf 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -192,7 +192,7 @@ int gsm48_secure_channel(struct gsm_subscriber_connection *conn, int key_seq, /* FIXME: Should start a timer for completion ... */ /* Then do whatever is needed ... */ - if (rc == AUTH_DO_AUTH_THAN_CIPH) { + if (rc == AUTH_DO_AUTH_THEN_CIPH) { /* Start authentication */ return gsm48_tx_mm_auth_req(conn, op->atuple.rand, op->atuple.key_seq); } else if (rc == AUTH_DO_CIPH) { -- 2.1.4 From msuraev at sysmocom.de Fri Mar 11 11:21:24 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 11 Mar 2016 12:21:24 +0100 Subject: [PATCH] Fix copy-paste issue Message-ID: <1457695284-26469-1-git-send-email-msuraev@sysmocom.de> From: Max This issue prevented scheduling of SI 2quater messages. --- src/common/sysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index e08ffca..f079199 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -82,7 +82,7 @@ uint8_t *bts_sysinfo_get(struct gsm_bts *bts, struct gsm_time *g_time) } if (BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) && (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) || - BTS_HAS_SI(bts, SYSINFO_TYPE_2bis))) { + BTS_HAS_SI(bts, SYSINFO_TYPE_2ter))) { tc4_sub[tc4_cnt] = SYSINFO_TYPE_2quater; tc4_cnt += 1; } -- 2.7.2 From msuraev at sysmocom.de Fri Mar 11 11:24:04 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 11 Mar 2016 12:24:04 +0100 Subject: [PATCH] Add support for SI2quater messages Message-ID: <1457695444-27754-1-git-send-email-msuraev@sysmocom.de> From: Max Add basic data structure for System information Type 2quater. --- include/osmocom/gsm/protocol/gsm_04_08.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 9fcdddc..eefaf2b 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -514,6 +514,12 @@ struct gsm48_system_information_type_2ter { uint8_t rest_octets[0]; } __attribute__ ((packed)); +/* Section 9.1.34a System information Type 2quater */ +struct gsm48_system_information_type_2quater { + struct gsm48_system_information_type_header header; + uint8_t rest_octets[0]; +} __attribute__ ((packed)); + /* Section 9.1.35 System information Type 3 */ struct gsm48_system_information_type_3 { struct gsm48_system_information_type_header header; @@ -792,6 +798,7 @@ struct gsm48_rr_status { #define GSM48_MT_RR_SYSINFO_2bis 0x02 #define GSM48_MT_RR_SYSINFO_2ter 0x03 +#define GSM48_MT_RR_SYSINFO_2quater 0x07 #define GSM48_MT_RR_SYSINFO_5bis 0x05 #define GSM48_MT_RR_SYSINFO_5ter 0x06 #define GSM48_MT_RR_SYSINFO_9 0x04 -- 2.7.2 From robert.steve07 at gmail.com Fri Mar 11 14:05:15 2016 From: robert.steve07 at gmail.com (robert) Date: Fri, 11 Mar 2016 16:05:15 +0200 Subject: Silent-call Message-ID: Hi, I would like to know what are the capabilities of the silent-call implemented in OpenBSC. When I try the command from VTY, I do not get any useful information from the target. Should it be like a normal call where I can listen to the called number but without having the target notified? Best regards, Robert, From msuraev at sysmocom.de Fri Mar 11 14:15:12 2016 From: msuraev at sysmocom.de (Max) Date: Fri, 11 Mar 2016 15:15:12 +0100 Subject: Silent-call In-Reply-To: References: Message-ID: <56E2D2F0.5050708@sysmocom.de> Hi. No, the silent call has nothing to do with audio - getting access to target's mic without it noticing is not part of GSM spec so in order to implement it you've got to exploit some bug in phone's baseband. I think it's being done couple of times successfully. Silent call in OpenBSC is about initiating "pre-call" signaling so phone "wakes up", allocates the channel to BTS and waits for further instructions. Normally, the instructions to start ringing, display caller number etc would follow but not in this case. This is perfectly within GSM spec. The point is to get low-level connection to the phone so, for example, it's current position could be requested over RRLP. Or to test smth. Out of curiosity - what kind of information would you find useful in this case? On 03/11/2016 03:05 PM, robert wrote: > Hi, > > I would like to know what are the capabilities of the silent-call implemented in OpenBSC. When I try the command from VTY, I do not get any useful information from the target. Should it be like a normal call where I can listen to the called number but without having the target notified? > > > Best regards, > Robert, -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From laforge at gnumonks.org Fri Mar 11 15:04:41 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:04:41 +0700 Subject: Silent-call In-Reply-To: References: Message-ID: <20160311150441.GX26794@nataraja> Hi Robert, On Fri, Mar 11, 2016 at 04:05:15PM +0200, robert wrote: > I would like to know what are the capabilities of the silent-call > implemented in OpenBSC. When I try the command from VTY, I do not get > any useful information from the target. Should it be like a normal > call where I can listen to the called number but without having the > target notified? a silent call is a pure signalling connection, it does not have any actual voice data. It serves primarily the purpose of turning the MS into a permanently (on one TS) transmitting beacon that can be localized using various radio-localization techniques. We implemented the feature in order to demonstrate/show-case some of the GSM "mis-features" that are being abused by signalling intelligence / law enforcement devices. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Fri Mar 11 15:10:41 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:10:41 +0700 Subject: [PATCH] Fix copy-paste issue In-Reply-To: <1457695284-26469-1-git-send-email-msuraev@sysmocom.de> References: <1457695284-26469-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160311151041.GZ26794@nataraja> On Fri, Mar 11, 2016 at 12:21:24PM +0100, msuraev at sysmocom.de wrote: > This issue prevented scheduling of SI 2quater messages. thanks, merged. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Fri Mar 11 15:06:29 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:06:29 +0700 Subject: [PATCH] Add support for SI2quater messages In-Reply-To: <1457695444-27754-1-git-send-email-msuraev@sysmocom.de> References: <1457695444-27754-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160311150629.GY26794@nataraja> On Fri, Mar 11, 2016 at 12:24:04PM +0100, msuraev at sysmocom.de wrote: > Add basic data structure for System information Type 2quater. thanks, merged. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Fri Mar 11 15:18:57 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:18:57 +0700 Subject: Authentication Response msg type: 0x14 in spec, 0x94 from a 3G phone In-Reply-To: <20160310215145.GA2124@dub6> References: <20160310215145.GA2124@dub6> Message-ID: <20160311151857.GA26794@nataraja> Hi Neels, On Thu, Mar 10, 2016 at 10:51:45PM +0100, Neels Hofmeyr wrote: > today I saw an MM Authentication Response sent from a 3G UE that > mismatches the GSM 04.08 spec. The spec says 0x14, the 3G phone sent 0x94. > And wireshark agrees that 0x94 is an Authentication Response. Please see 11.2.3.2.1 and 11.2.3.2.2 of 3GPP TS 24.007, e.g. the latest version 12.0.0 Release 12 as available from http://www.etsi.org/deliver/etsi_ts/124000_124099/124007/12.00.00_60/ts_124007v120000p.pdf There you can see that in Release99 and later networks, the message type for MM, CC and SS is defined as having the upper two bits as "N (SD)", whereas other protocols have other definitions for those bits. "N (SD)" is described in 11.2.3.2.3 of the same spec -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Fri Mar 11 15:24:27 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:24:27 +0700 Subject: [PATCH 1/2] GSM 04.08 message types: apply bitmask makros In-Reply-To: <1457648540-3481-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457648540-3481-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160311152427.GB26794@nataraja> On Thu, Mar 10, 2016 at 11:22:19PM +0100, Neels Hofmeyr wrote: > - msg_type = hdr48->msg_type & 0xbf; > + proto = hdr48->proto_discr & GSM48_PDISC_MASK; > + msg_type = hdr48->msg_type & GSM48_MT_MM_MSG_TYPE_MASK; maybe it is a good idea to provide an (inline?) function for this, which determines the mask based on the rules of TS 24.007 (see my other mail). Something like msg_type = gsm48hdr_get_msgtype(hdr48); which would then use the proper mask based on hdr48->proto_discr and the rules from 24.007. This way the user (developer) cannot really do anything wrong and the correct mask is chosen. Similarly, gsm48hdr_get_proto(hdr48) could be used for the proto_discr. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From robert.steve07 at gmail.com Fri Mar 11 15:35:59 2016 From: robert.steve07 at gmail.com (robert) Date: Fri, 11 Mar 2016 17:35:59 +0200 Subject: Silent-call In-Reply-To: <20160311150441.GX26794@nataraja> References: <20160311150441.GX26794@nataraja> Message-ID: <4A6ECFC3-E06C-4D2A-A84B-4254729D72EA@gmail.com> Hi, Thank you for this explanation. Best regards, Robert, On Mar 11, 2016, at 5:04 PM, Harald Welte wrote: > Hi Robert, > > On Fri, Mar 11, 2016 at 04:05:15PM +0200, robert wrote: >> I would like to know what are the capabilities of the silent-call >> implemented in OpenBSC. When I try the command from VTY, I do not get >> any useful information from the target. Should it be like a normal >> call where I can listen to the called number but without having the >> target notified? > > a silent call is a pure signalling connection, it does not have any > actual voice data. It serves primarily the purpose of turning the MS > into a permanently (on one TS) transmitting beacon that can be localized > using various radio-localization techniques. > > We implemented the feature in order to demonstrate/show-case some of the > GSM "mis-features" that are being abused by signalling intelligence / > law enforcement devices. > -- > - Harald Welte http://laforge.gnumonks.org/ > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. A6) From Bindhu.Anjaneya at radisys.com Fri Mar 11 12:49:12 2016 From: Bindhu.Anjaneya at radisys.com (Bindhu Anjaneya) Date: Fri, 11 Mar 2016 12:49:12 +0000 Subject: Support of AoverIP (AOIP) in osmo-bsc Message-ID: Hello All, We are planning to implement A-Interface Over IP 3GPP Release8 compliant(3GPP TS 43.903 V8.3.0, 3GPP TS 48.006 v8.0.0) in osmo-bsc (bsc only mode). We will be communicating further on the design approach. Request you all to provide your inputs and suggestions. Regards, Bindhu -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Fri Mar 11 16:02:03 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 11 Mar 2016 17:02:03 +0100 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: References: Message-ID: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> > On 11 Mar 2016, at 13:49, Bindhu Anjaneya wrote: > > Hello All, Hi! > > We are planning to implement A-Interface Over IP 3GPP Release8 compliant(3GPP TS 43.903 V8.3.0, 3GPP TS 48.006 v8.0.0) in osmo-bsc (bsc only mode). > We will be communicating further on the design approach. Request you all to provide your inputs and suggestions. great. What is the reason for targeting older releases? Or phrased differently how was this specific release picked? kind regards holger From msuraev at sysmocom.de Fri Mar 11 16:07:27 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 11 Mar 2016 17:07:27 +0100 Subject: [PATCH 2/2] Refactor SI-related code In-Reply-To: <1457712447-28789-1-git-send-email-msuraev@sysmocom.de> References: <1457712447-28789-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457712447-28789-2-git-send-email-msuraev@sysmocom.de> From: Max Move define to header file. Use inline functions where appropriate. Change int variables which are used as boolean into actual bool to make code easier to follow. --- openbsc/include/openbsc/abis_rsl.h | 1 + openbsc/src/libbsc/abis_rsl.c | 2 -- openbsc/src/libbsc/system_information.c | 37 +++++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/openbsc/include/openbsc/abis_rsl.h b/openbsc/include/openbsc/abis_rsl.h index b27595e..100a6d1 100644 --- a/openbsc/include/openbsc/abis_rsl.h +++ b/openbsc/include/openbsc/abis_rsl.h @@ -31,6 +31,7 @@ struct gsm_lchan; struct gsm_subscriber; struct gsm_bts_trx_ts; +#define GSM48_LEN2PLEN(a) (((a) << 2) | 1) int rsl_bcch_info(struct gsm_bts_trx *trx, uint8_t type, const uint8_t *data, int len); diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 8e9258c..df76788 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1332,8 +1332,6 @@ static void t3109_expired(void *data) rsl_rf_chan_release(lchan, 1, SACCH_NONE); } -#define GSM48_LEN2PLEN(a) (((a) << 2) | 1) - /* Format an IMM ASS REJ according to 04.08 Chapter 9.1.20 */ static int rsl_send_imm_ass_rej(struct gsm_bts *bts, unsigned int num_req_refs, diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c index 62ee306..5490c83 100644 --- a/openbsc/src/libbsc/system_information.c +++ b/openbsc/src/libbsc/system_information.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -67,8 +68,8 @@ static int is_dcs_net(const struct gsm_bts *bts) return 1; } -static int use_arfcn(const struct gsm_bts *bts, const int bis, const int ter, - const int pgsm, const int arfcn) +static inline int use_arfcn(const struct gsm_bts *bts, const bool bis, const bool ter, + const bool pgsm, const int arfcn) { if (bts->force_combined_si) return !bis && !ter; @@ -135,9 +136,9 @@ static int freq_list_bmrel_set_arfcn(uint8_t *chan_list, unsigned int arfcn) } /* generate a variable bitmap */ -static int enc_freq_lst_var_bitmap(uint8_t *chan_list, +static inline int enc_freq_lst_var_bitmap(uint8_t *chan_list, struct bitvec *bv, const struct gsm_bts *bts, - int bis, int ter, int min, int pgsm) + bool bis, bool ter, int min, bool pgsm) { int i; @@ -164,9 +165,9 @@ static int enc_freq_lst_var_bitmap(uint8_t *chan_list, } /* generate a frequency list with the range 512 format */ -static int enc_freq_lst_range(uint8_t *chan_list, +static inline int enc_freq_lst_range(uint8_t *chan_list, struct bitvec *bv, const struct gsm_bts *bts, - int bis, int ter, int pgsm) + bool bis, bool ter, bool pgsm) { int arfcns[RANGE_ENC_MAX_ARFCNS]; int w[RANGE_ENC_MAX_ARFCNS]; @@ -226,15 +227,15 @@ static int enc_freq_lst_range(uint8_t *chan_list, /* generate a cell channel list as per Section 10.5.2.1b of 04.08 */ static int bitvec2freq_list(uint8_t *chan_list, struct bitvec *bv, - const struct gsm_bts *bts, int bis, int ter) + const struct gsm_bts *bts, bool bis, bool ter) { - int i, rc, min = -1, max = -1, pgsm = 0, arfcns = 0; - + int i, rc, min = -1, max = -1, arfcns = 0; + bool pgsm = false; memset(chan_list, 0, 16); if (bts->band == GSM_BAND_900 && bts->c0->arfcn >= 1 && bts->c0->arfcn <= 124) - pgsm = 1; + pgsm = true; /* P-GSM-only handsets only support 'bit map 0 format' */ if (!bis && !ter && pgsm) { chan_list[0] = 0; @@ -327,12 +328,12 @@ static int bitvec2freq_list(uint8_t *chan_list, struct bitvec *bv, } /* then we generate a GSM 04.08 frequency list from the bitvec */ - return bitvec2freq_list(chan_list, bv, bts, 0, 0); + return bitvec2freq_list(chan_list, bv, bts, false, false); } /* generate a cell channel list as per Section 10.5.2.1b of 04.08 */ static int generate_bcch_chan_list(uint8_t *chan_list, struct gsm_bts *bts, - int si5, int bis, int ter) + bool si5, bool bis, bool ter) { struct gsm_bts *cur_bts; struct bitvec *bv; @@ -422,7 +423,7 @@ static int generate_si2(uint8_t *output, struct gsm_bts *bts) si2->header.skip_indicator = 0; si2->header.system_information = GSM48_MT_RR_SYSINFO_2; - rc = generate_bcch_chan_list(si2->bcch_frequency_list, bts, 0, 0, 0); + rc = generate_bcch_chan_list(si2->bcch_frequency_list, bts, false, false, false); if (rc < 0) return rc; list_arfcn(si2->bcch_frequency_list, 0xce, @@ -448,7 +449,7 @@ static int generate_si2bis(uint8_t *output, struct gsm_bts *bts) si2b->header.skip_indicator = 0; si2b->header.system_information = GSM48_MT_RR_SYSINFO_2bis; - rc = generate_bcch_chan_list(si2b->bcch_frequency_list, bts, 0, 1, 0); + rc = generate_bcch_chan_list(si2b->bcch_frequency_list, bts, false, true, false); if (rc < 0) return rc; n = list_arfcn(si2b->bcch_frequency_list, 0xce, @@ -482,7 +483,7 @@ static int generate_si2ter(uint8_t *output, struct gsm_bts *bts) si2t->header.skip_indicator = 0; si2t->header.system_information = GSM48_MT_RR_SYSINFO_2ter; - rc = generate_bcch_chan_list(si2t->ext_bcch_frequency_list, bts, 0, 0, 1); + rc = generate_bcch_chan_list(si2t->ext_bcch_frequency_list, bts, false, false, true); if (rc < 0) return rc; n = list_arfcn(si2t->ext_bcch_frequency_list, 0x8e, @@ -630,7 +631,7 @@ static int generate_si5(uint8_t *output, struct gsm_bts *bts) si5->rr_protocol_discriminator = GSM48_PDISC_RR; si5->skip_indicator = 0; si5->system_information = GSM48_MT_RR_SYSINFO_5; - rc = generate_bcch_chan_list(si5->bcch_frequency_list, bts, 1, 0, 0); + rc = generate_bcch_chan_list(si5->bcch_frequency_list, bts, true, false, false); if (rc < 0) return rc; list_arfcn(si5->bcch_frequency_list, 0xce, @@ -665,7 +666,7 @@ static int generate_si5bis(uint8_t *output, struct gsm_bts *bts) si5b->rr_protocol_discriminator = GSM48_PDISC_RR; si5b->skip_indicator = 0; si5b->system_information = GSM48_MT_RR_SYSINFO_5bis; - rc = generate_bcch_chan_list(si5b->bcch_frequency_list, bts, 1, 1, 0); + rc = generate_bcch_chan_list(si5b->bcch_frequency_list, bts, true, true, false); if (rc < 0) return rc; n = list_arfcn(si5b->bcch_frequency_list, 0xce, @@ -709,7 +710,7 @@ static int generate_si5ter(uint8_t *output, struct gsm_bts *bts) si5t->rr_protocol_discriminator = GSM48_PDISC_RR; si5t->skip_indicator = 0; si5t->system_information = GSM48_MT_RR_SYSINFO_5ter; - rc = generate_bcch_chan_list(si5t->bcch_frequency_list, bts, 1, 0, 1); + rc = generate_bcch_chan_list(si5t->bcch_frequency_list, bts, true, false, true); if (rc < 0) return rc; n = list_arfcn(si5t->bcch_frequency_list, 0x8e, -- 2.7.2 From msuraev at sysmocom.de Fri Mar 11 16:07:26 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 11 Mar 2016 17:07:26 +0100 Subject: [PATCH 1/2] Add SI2quater support to SI3 Message-ID: <1457712447-28789-1-git-send-email-msuraev@sysmocom.de> From: Max Advertise SI2 quater presence and location (if available) using SI3 according to 3GPP TS 44.018 ? 10.5.2.34 --- openbsc/include/openbsc/rest_octets.h | 3 ++- openbsc/src/libbsc/bsc_init.c | 1 + openbsc/src/libbsc/rest_octets.c | 7 +++++++ openbsc/src/libbsc/system_information.c | 8 +++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/openbsc/include/openbsc/rest_octets.h b/openbsc/include/openbsc/rest_octets.h index 963b010..9560b14 100644 --- a/openbsc/include/openbsc/rest_octets.h +++ b/openbsc/include/openbsc/rest_octets.h @@ -43,7 +43,8 @@ struct gsm48_si_ro_info { present:1; } scheduling; struct gsm48_si3_gprs_ind gprs_ind; - + /* SI 3 specific */ + uint8_t si2quater_indicator; /* SI 4 specific */ struct gsm48_lsa_params lsa_params; uint16_t cell_id; diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index 859d999..6557b41 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -140,6 +140,7 @@ int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx) gen_si[n_si++] = SYSINFO_TYPE_2; gen_si[n_si++] = SYSINFO_TYPE_2bis; gen_si[n_si++] = SYSINFO_TYPE_2ter; + gen_si[n_si++] = SYSINFO_TYPE_2quater; gen_si[n_si++] = SYSINFO_TYPE_3; gen_si[n_si++] = SYSINFO_TYPE_4; diff --git a/openbsc/src/libbsc/rest_octets.c b/openbsc/src/libbsc/rest_octets.c index 4545794..fa35f21 100644 --- a/openbsc/src/libbsc/rest_octets.c +++ b/openbsc/src/libbsc/rest_octets.c @@ -129,6 +129,13 @@ int rest_octets_si3(uint8_t *data, const struct gsm48_si_ro_info *si3) /* GPRS Indicator */ append_gprs_ind(&bv, &si3->gprs_ind); + bitvec_set_bit(&bv, H); /* 3G Early Classmark Sending Restriction controlled by early_cm_ctrl above */ + + if (si3->si2quater_indicator) { + bitvec_set_bit(&bv, H); /* indicator struct present */ + bitvec_set_uint(&bv, 0, 1); /* message is sent on BCCH Norm */ + } + bitvec_spare_padding(&bv, (bv.data_len*8)-1); return bv.data_len; } diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c index 1ee9d41..62ee306 100644 --- a/openbsc/src/libbsc/system_information.c +++ b/openbsc/src/libbsc/system_information.c @@ -510,6 +510,7 @@ static struct gsm48_si_ro_info si_info = { .ra_colour = 0, .present = 1, }, + .si2quater_indicator = 0, .lsa_params = { .present = 0, }, @@ -545,7 +546,12 @@ static int generate_si3(uint8_t *output, struct gsm_bts *bts) } else { si_info.si2ter_indicator = 0; } - + if ((bts->si_valid & (1 << SYSINFO_TYPE_2quater))) { + LOGP(DRR, LOGL_INFO, "SI 2quater is included.\n"); + si_info.si2quater_indicator = 1; + } else { + si_info.si2quater_indicator = 0; + } /* SI3 Rest Octets (10.5.2.34), containing CBQ, CELL_RESELECT_OFFSET, TEMPORARY_OFFSET, PENALTY_TIME Power Offset, 2ter Indicator, Early Classmark Sending, -- 2.7.2 From laforge at gnumonks.org Fri Mar 11 15:32:55 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:32:55 +0700 Subject: [PATCH 1/3] Add helper function to convert numerical BSSGP PDU type to string In-Reply-To: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> References: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160311153255.GD26794@nataraja> thanks, applied. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Fri Mar 11 15:32:41 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:32:41 +0700 Subject: [PATCH 2/3] Improve BSSGP debug output In-Reply-To: <1457522965-27238-2-git-send-email-msuraev@sysmocom.de> References: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> <1457522965-27238-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160311153241.GC26794@nataraja> On Wed, Mar 09, 2016 at 12:29:24PM +0100, msuraev at sysmocom.de wrote: > Print string representation of Cause IE and PDU type in addition to > numerical value. thanks. I'd like to merge, but > - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] " > - "implemented\n", bctx->bvci, pdu_type); > + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) not [yet] " > + "implemented\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); pleaes remove the 0x%02x numeric printing. The %s via bssgp_pdu_str() will automatically fall back to printing the numeric type as "unknown 0x%x" when it is unknown, as part of the value_string implementation, IIRC. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Fri Mar 11 15:47:36 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 11 Mar 2016 22:47:36 +0700 Subject: [PATCH 3/3] Add vty command to explicitly reset given BVCI In-Reply-To: <1457522965-27238-3-git-send-email-msuraev@sysmocom.de> References: <1457522965-27238-1-git-send-email-msuraev@sysmocom.de> <1457522965-27238-3-git-send-email-msuraev@sysmocom.de> Message-ID: <20160311154736.GE26794@nataraja> Hi Max, On Wed, Mar 09, 2016 at 12:29:25PM +0100, msuraev at sysmocom.de wrote: > + vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, VTY_NEWLINE); > + vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, VTY_NEWLINE); * long lines were not wrapped * compilation causes warning: gprs_bssgp_vty.c: In function 'bvc_reset': gprs_bssgp_vty.c:134:10: warning: implicit declaration of function 'bssgp_tx_bvc_reset' [-Wimplicit-function-declaration] int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV); please always make sure to check if patches cause new warnings before submitting them. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From msuraev at sysmocom.de Fri Mar 11 16:28:25 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 11 Mar 2016 17:28:25 +0100 Subject: [PATCH] Update configuration examples Message-ID: <1457713705-5940-1-git-send-email-msuraev@sysmocom.de> From: Max Add SysmoBTS-specific example. Remove outdated generic example which is no longer working. --- doc/examples/osmo-bts.cfg | 26 -------------------------- doc/examples/sysmo/osmo-bts-new.cfg | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 26 deletions(-) delete mode 100644 doc/examples/osmo-bts.cfg create mode 100644 doc/examples/sysmo/osmo-bts-new.cfg diff --git a/doc/examples/osmo-bts.cfg b/doc/examples/osmo-bts.cfg deleted file mode 100644 index 057a7ff..0000000 --- a/doc/examples/osmo-bts.cfg +++ /dev/null @@ -1,26 +0,0 @@ -! -! OsmoBTS () configuration saved from vty -!! -! -log stderr - logging color 0 - logging timestamp 0 - logging level all everything - logging level rsl info - logging level oml info - logging level rll notice - logging level rr notice - logging level meas notice - logging level pag info - logging level l1c info - logging level l1p info - logging level dsp debug - logging level abis notice -! -line vty - no login -! -bts 0 - band 1800 - ipa unit-id 1234 0 - oml remote-ip 192.168.100.11 diff --git a/doc/examples/sysmo/osmo-bts-new.cfg b/doc/examples/sysmo/osmo-bts-new.cfg new file mode 100644 index 0000000..35142f7 --- /dev/null +++ b/doc/examples/sysmo/osmo-bts-new.cfg @@ -0,0 +1,30 @@ +! +! OsmoBTS () configuration saved from vty +!! +! +log stderr + logging color 1 + logging timestamp 0 + logging level all everything + logging level rsl info + logging level oml info + logging level rll notice + logging level rr notice + logging level meas notice + logging level pag info + logging level l1c info + logging level l1p info + logging level dsp info + logging level abis notice +! +line vty + no login +! +phy 0 + instance 0 +bts 0 + band 1800 + ipa unit-id 666 0 + oml remote-ip 10.1.2.3 + trx 0 + phy 0 instance 0 -- 2.7.2 From holger at freyther.de Fri Mar 11 20:16:28 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 11 Mar 2016 21:16:28 +0100 Subject: test? Message-ID: virtual delivery and aliases? From holger at freyther.de Fri Mar 11 20:51:47 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 11 Mar 2016 21:51:47 +0100 Subject: test? In-Reply-To: References: Message-ID: > On 11 Mar 2016, at 21:16, Holger Freyther wrote: > > virtual delivery and aliases? passed? From holger at freyther.de Sun Mar 13 20:56:16 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 13 Mar 2016 21:56:16 +0100 Subject: osmo-trx packaging Message-ID: <9B9019A9-4CA5-4285-A910-A6CFBF7A3847@freyther.de> Dear Tom, I would like to move the debian/ directory from the fairwaves/master branch to master. Do you have objections of doing that or did you have a general look at the few commits that are in there? In terms of packaging the only issue I see is that -march=native is being used which is likely to completely disable SSEX support. Did you look at ifunc for GCC[1]? Would you be open to explore such[2] a solution or would even have time to try it? Is there a way to benchmark the effect easily? kind regards holger [1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes [2] http://pasky.or.cz/dev/glibc/ifunc.c From nhofmeyr at sysmocom.de Sun Mar 13 23:38:35 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 00:38:35 +0100 Subject: [PATCH 1/2] GSM 04.08 message types: apply bitmask makros In-Reply-To: <20160311152427.GB26794@nataraja> References: <1457648540-3481-1-git-send-email-nhofmeyr@sysmocom.de> <20160311152427.GB26794@nataraja> Message-ID: <20160313233835.GB10039@dub6> On Fri, Mar 11, 2016 at 10:24:27PM +0700, Harald Welte wrote: > msg_type = gsm48hdr_get_msgtype(hdr48); Yes, excellent! Will adjust the patch. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Mon Mar 14 01:05:11 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 02:05:11 +0100 Subject: Authentication Response msg type: 0x14 in spec, 0x94 from a 3G phone In-Reply-To: <20160311151857.GA26794@nataraja> References: <20160310215145.GA2124@dub6> <20160311151857.GA26794@nataraja> Message-ID: <20160314010511.GA14267@dub6> On Fri, Mar 11, 2016 at 10:18:57PM +0700, Harald Welte wrote: > Please see 11.2.3.2.1 and 11.2.3.2.2 of 3GPP TS 24.007, e.g. the latest > version 12.0.0 Release 12 as available from > http://www.etsi.org/deliver/etsi_ts/124000_124099/124007/12.00.00_60/ts_124007v120000p.pdf > > There you can see that in Release99 and later networks, the message type > for MM, CC and SS is defined as having the upper two bits as "N (SD)", > whereas other protocols have other definitions for those bits. > > "N (SD)" is described in 11.2.3.2.3 of the same spec Ah, interesting! I'm not entirely sure how we want to handle whether we're Release99 or not ... is all our code Release99 per se (that's 17 years ago, right!?), or should that be decided at compile or run time? Here, I'd use the 0x3f mask for MM and CC, period; particularly because none of our message type definitions use bit 8 anyway. Opinions? ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Mon Mar 14 09:33:39 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 14 Mar 2016 10:33:39 +0100 Subject: Authentication Response msg type: 0x14 in spec, 0x94 from a 3G phone In-Reply-To: <20160314010511.GA14267@dub6> References: <20160310215145.GA2124@dub6> <20160311151857.GA26794@nataraja> <20160314010511.GA14267@dub6> Message-ID: <20160314093339.GB22585@nataraja> Hi Neels, On Mon, Mar 14, 2016 at 02:05:11AM +0100, Neels Hofmeyr wrote: > I'm not entirely sure how we want to handle whether we're Release99 or not > ... is all our code Release99 per se (that's 17 years ago, right!?), or > should that be decided at compile or run time? We should aim at implementing later releases, so the question is rather 'do we want rel 4, rel 5, rel 7' and not 'do we want rel 98 or 99'. As all the later releases >= R99 use the two upper bits as sequence numbers, the question is simple: simply use the >= R99 definition. IIRC, there is a bit somewhere where the GPRS core network (SGSN) indicates to the MS whether it is a R98 or R99 core network. I think we have to make sure to set this bit right, and apart from that use the >= R99 definitions. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Mon Mar 14 10:34:25 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 11:34:25 +0100 Subject: GSM48_PDISC_USSD 0x11 Message-ID: <20160314103425.GA1222@dub6> Hi, GSM48_PDISC_USSD == 0x11 puzzles me slightly. It doesn't match the landscape described in 3GPP TS 24.007 version 12.0.0 Release 12, chapter 11.2.3.1.1, and it seems our osmo code base isn't using it anywhere. Granted, I don't have all reposes cloned here... It has been there ever since the initial checkin of libosmocore. Thanks for any hints, ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From holger at freyther.de Mon Mar 14 13:50:12 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 14 Mar 2016 14:50:12 +0100 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> Message-ID: <05DC65E9-38CF-4E9A-A59A-2D673A3EDFE0@freyther.de> > On 14 Mar 2016, at 14:20, Bindhu Anjaneya wrote: > > Hi, Hi! > > The AoIP implementation will be in compliance to the latest Release (Release 13), Note that there is no technical change from Release 8 to Release 13. that is good to know. > As part of design consideration, we are analyzing Erlang osmo-ss7 SIGTRAN Stack(SCCP,M3UA,SCTP) to integrate with osmo-bsc (bsc only mode), > We are also analyzing the option of retaining the currently used libosmo-SCCP, kernel SCTP and use the M3UA from the osmo-ss7. libosmo-sccp gained SUA support. What is generally missing for anything than SCCP is to add the statemachines for M3UA, SUA (including resending, vty to set the wanted AS/ASP state, etc). holger From Bindhu.Anjaneya at radisys.com Mon Mar 14 13:20:11 2016 From: Bindhu.Anjaneya at radisys.com (Bindhu Anjaneya) Date: Mon, 14 Mar 2016 13:20:11 +0000 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> Message-ID: Hi, The AoIP implementation will be in compliance to the latest Release (Release 13), Note that there is no technical change from Release 8 to Release 13. As part of design consideration, we are analyzing Erlang osmo-ss7 SIGTRAN Stack(SCCP,M3UA,SCTP) to integrate with osmo-bsc (bsc only mode), We are also analyzing the option of retaining the currently used libosmo-SCCP, kernel SCTP and use the M3UA from the osmo-ss7. Regards, Bindhu Anjaneya -----Original Message----- From: Holger Freyther [mailto:holger at freyther.de] Sent: Friday, March 11, 2016 9:32 PM To: Bindhu Anjaneya Cc: openbsc at lists.osmocom.org Subject: Re: Support of AoverIP (AOIP) in osmo-bsc > On 11 Mar 2016, at 13:49, Bindhu Anjaneya wrote: > > Hello All, Hi! > > We are planning to implement A-Interface Over IP 3GPP Release8 compliant(3GPP TS 43.903 V8.3.0, 3GPP TS 48.006 v8.0.0) in osmo-bsc (bsc only mode). > We will be communicating further on the design approach. Request you all to provide your inputs and suggestions. great. What is the reason for targeting older releases? Or phrased differently how was this specific release picked? kind regards holger From nhofmeyr at sysmocom.de Mon Mar 14 15:06:45 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:06:45 +0100 Subject: [PATCH 0/3] v2 and extension of "Add defines for MM and CC message type bitmasks" Message-ID: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> Changes to the patch set: * Instead of using the bitmask constants, introduce inline functions. * Apply in src/gsm/gsm0480.c. * Also add functions for the transaction ID, encoded in the protocol discriminator octet. Neels Hofmeyr (3): 04.08: add inline funcs for pdisc + msg type bitmasks 04.08: switch to r99 msg type bitmasks by default 04.08: add inline funcs for transaction id bits include/osmocom/gsm/protocol/gsm_04_08.h | 83 ++++++++++++++++++++++++++++++++ src/gsm/gsm0480.c | 4 +- 2 files changed, 85 insertions(+), 2 deletions(-) -- 2.1.4 From nhofmeyr at sysmocom.de Mon Mar 14 15:06:46 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:06:46 +0100 Subject: [PATCH 1/3] 04.08: add inline funcs for pdisc + msg type bitmasks In-Reply-To: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457968008-15769-2-git-send-email-nhofmeyr@sysmocom.de> Add inline functions for both release <= 98 and release >= 99 as well as a default define. Use the release 98 by default since the current code base uses the r98 bitmasks. These inline functions relieve callers of the decision on masking bits of the protocol discriminator and message type octets. Also add a define for the protocol discriminator extension to one octet length (GSM48_PDISC_EXTEND). Apply new pdisc function in gsm0480.c. --- include/osmocom/gsm/protocol/gsm_04_08.h | 56 ++++++++++++++++++++++++++++++++ src/gsm/gsm0480.c | 4 +-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index eefaf2b..9930032 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -747,9 +747,65 @@ struct gsm48_rr_status { #define GSM48_PDISC_SM_GPRS 0x0a #define GSM48_PDISC_NC_SS 0x0b #define GSM48_PDISC_LOC 0x0c +#define GSM48_PDISC_EXTEND 0x0e #define GSM48_PDISC_MASK 0x0f #define GSM48_PDISC_USSD 0x11 +static inline uint8_t gsm48_hdr_pdisc(struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.1.1 Protocol discriminator + */ + uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK; + if (pdisc == GSM48_PDISC_EXTEND) + return hdr->proto_discr; + return pdisc; +} + +static inline uint8_t gsm48_hdr_msg_type_r98(struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.2.1 Message type octet (when accessing Release 98 and older + * networks only) + */ + switch (gsm48_hdr_pdisc(hdr)) { + case GSM48_PDISC_MM: + case GSM48_PDISC_CC: + case GSM48_PDISC_NC_SS: + case GSM48_PDISC_GROUP_CC: + case GSM48_PDISC_BCAST_CC: + case GSM48_PDISC_LOC: + return hdr->msg_type & 0xbf; + default: + return hdr->msg_type; + } +} + +static inline uint8_t gsm48_hdr_msg_type_r99(struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer + * networks) + */ + switch (gsm48_hdr_pdisc(hdr)) { + case GSM48_PDISC_MM: + case GSM48_PDISC_CC: + return hdr->msg_type & 0x3f; + case GSM48_PDISC_NC_SS: + case GSM48_PDISC_GROUP_CC: + case GSM48_PDISC_BCAST_CC: + case GSM48_PDISC_LOC: + return hdr->msg_type & 0xbf; + default: + return hdr->msg_type; + } +} + +#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r98 + /* Section 10.4 */ #define GSM48_MT_RR_INIT_REQ 0x3c #define GSM48_MT_RR_ADD_ASS 0x3b diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c index 952604b..8963b78 100644 --- a/src/gsm/gsm0480.c +++ b/src/gsm/gsm0480.c @@ -220,7 +220,7 @@ int gsm0480_decode_ussd_request(const struct gsm48_hdr *hdr, uint16_t len, return 0; } - if ((hdr->proto_discr & 0x0f) == GSM48_PDISC_NC_SS) { + if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) { req->transaction_id = hdr->proto_discr & 0x70; ss.transaction_id = req->transaction_id; @@ -254,7 +254,7 @@ int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len, return 0; } - if ((hdr->proto_discr & 0x0f) == GSM48_PDISC_NC_SS) { + if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) { req->transaction_id = hdr->proto_discr & 0x70; rc = parse_ss(hdr, len, req); } -- 2.1.4 From nhofmeyr at sysmocom.de Mon Mar 14 15:06:47 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:06:47 +0100 Subject: [PATCH 2/3] 04.08: switch to r99 msg type bitmasks by default In-Reply-To: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457968008-15769-3-git-send-email-nhofmeyr@sysmocom.de> --- include/osmocom/gsm/protocol/gsm_04_08.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 9930032..08f32b7 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -804,7 +804,7 @@ static inline uint8_t gsm48_hdr_msg_type_r99(struct gsm48_hdr *hdr) } } -#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r98 +#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99 /* Section 10.4 */ #define GSM48_MT_RR_INIT_REQ 0x3c -- 2.1.4 From nhofmeyr at sysmocom.de Mon Mar 14 15:06:48 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:06:48 +0100 Subject: [PATCH 3/3] 04.08: add inline funcs for transaction id bits In-Reply-To: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457968008-15769-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457968008-15769-4-git-send-email-nhofmeyr@sysmocom.de> Various users of gsm48_hdr apply the same hardcoded shifts/bitmasks to obtain the transaction ID encoded in the upper nibble of the protocol discriminator. Centralize. Patch for openbsc.git will follow. --- include/osmocom/gsm/protocol/gsm_04_08.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 08f32b7..af9c2e9 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -763,6 +763,33 @@ static inline uint8_t gsm48_hdr_pdisc(struct gsm48_hdr *hdr) return pdisc; } +static inline uint8_t gsm48_hdr_trans_id(struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.1.3 Transaction identifier + */ + return (hdr->proto_discr & 0xf0) >> 4; +} + +static inline uint8_t gsm48_hdr_trans_id_flip_ti(struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.1.3 Transaction identifier + */ + return gsm48_hdr_trans_id(hdr) ^ 0x08; +} + +static inline uint8_t gsm48_hdr_trans_id_no_ti(struct gsm48_hdr *hdr) +{ + /* + * 3GPP TS 24.007 version 12.0.0 Release 12, + * 11.2.3.1.3 Transaction identifier + */ + return gsm48_hdr_trans_id(hdr) & 0x07; +} + static inline uint8_t gsm48_hdr_msg_type_r98(struct gsm48_hdr *hdr) { /* -- 2.1.4 From laforge at gnumonks.org Mon Mar 14 15:10:31 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 14 Mar 2016 16:10:31 +0100 Subject: [PATCH] Update configuration examples In-Reply-To: <1457713705-5940-1-git-send-email-msuraev@sysmocom.de> References: <1457713705-5940-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160314151031.GB22557@nataraja> On Fri, Mar 11, 2016 at 05:28:25PM +0100, msuraev at sysmocom.de wrote: > From: Max > > Add SysmoBTS-specific example. > Remove outdated generic example which is no longer working. > --- > doc/examples/osmo-bts.cfg | 26 -------------------------- > doc/examples/sysmo/osmo-bts-new.cfg | 30 ++++++++++++++++++++++++++++++ why the 'new' in the name? It should be called osmo-bts.cfg, like all the other examples, too... -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Mon Mar 14 15:09:32 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 14 Mar 2016 16:09:32 +0100 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> Message-ID: <20160314150932.GA22557@nataraja> Hi Bindhu, On Mon, Mar 14, 2016 at 01:20:11PM +0000, Bindhu Anjaneya wrote: > As part of design consideration, we are analyzing Erlang osmo-ss7 > SIGTRAN Stack(SCCP,M3UA,SCTP) to integrate with osmo-bsc (bsc only > mode). > We are also analyzing the option of retaining the currently used > libosmo-SCCP, kernel SCTP and use the M3UA from the osmo-ss7. in terms of the encapsulation of the A-over-IP, I would suggest to not rely on the Erlang implementations that we have. This would import a dependency on a rather large code base for a limited functionality, and it doesn't really resolve the question on how to interface the osmo-ss7 erlang code from C code such as OsmoBSC. The better way to do this, from my point-of-view, is to follow what we have done for the Osmo-Iuh code (osmo-hnbgw, and IuCS/PS for OsmoCSCN/OsmoSGSN): * use the SUA support of libosmo-sccp, including its SCCP-User-SAP that it provides towards applications This way, OsmoBSC uses the most simple SIGTRAN variant SUA towards an external signalling gateway, and doesn't have to bother with the more complex stacks like M3UA, M2UA, M2PA (all including SCCP). In this way, * osmo-bsc has a clean interface, and re-uses the code from the Iu related projects * you can use osmo-ss7 or any other signalling gateway (FOSS or proprietary) to move towards M3UA or any other transport stack. Let me know what you think about the above-mentioned approach. Please note the SUA code in libosmo-sccp is also still limited at this point, in a sense that it doesn't implement the ASP-Management state machines yet. This would still have to be added. If it is added to libosmo-sccp, then all useres, whether IuCS, IuPS or AoIP will benefit from that. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Mon Mar 14 15:13:23 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:13:23 +0100 Subject: [PATCH 0/2] v2 of "GSM 04.08 message types: apply bitmask makros" Message-ID: <1457968405-15933-1-git-send-email-nhofmeyr@sysmocom.de> changes to the patch: * use functions, not mask defines (as changed in libosmocore patch). * caught a few more hardcoded bitmasks. * add one log notice in case of unknown message type (see commit log). * previously two commits to apply masks / fix mask usage are combined in one commit that applies the new gsm48_hdr_* functions. * also apply transaction id bitmasks. Neels Hofmeyr (2): 04.08: apply new bitmask functions, fix bitmask use 04.08: apply new transaction id inline functions openbsc/src/gprs/gb_proxy.c | 4 ++-- openbsc/src/gprs/gprs_gb_parse.c | 13 ++++++++++--- openbsc/src/gprs/gprs_gmm.c | 10 +++++----- openbsc/src/libbsc/bsc_api.c | 8 +++++--- openbsc/src/libfilter/bsc_msg_filter.c | 10 +++++----- openbsc/src/libmsc/gsm_04_08.c | 13 ++++++------- openbsc/src/libmsc/gsm_04_11.c | 2 +- openbsc/src/libmsc/silent_call.c | 5 +++-- openbsc/src/osmo-bsc/osmo_bsc_api.c | 8 ++++---- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 10 +++++----- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 6 +++--- 13 files changed, 53 insertions(+), 44 deletions(-) -- 2.1.4 From nhofmeyr at sysmocom.de Mon Mar 14 15:13:24 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:13:24 +0100 Subject: [PATCH 1/2] 04.08: apply new bitmask functions, fix bitmask use In-Reply-To: <1457968405-15933-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457968405-15933-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457968405-15933-2-git-send-email-nhofmeyr@sysmocom.de> Replace hardcoded protocol discriminator and message type bitmasks with function calls recently introduced in libosmocore. Note that the release 98 bitmasks slightly differ from the release 99 bitmasks. This patch uses the "default" gsm48_hdr_msg_type invocation, thus it depends on libosmocore whether 98 or 99 bitmasks are used. In some places, use of the bitmask was erratic. Fix these implicitly by employing the bitmask functions: * silent_call.c: silent_call_reroute(): add missing bitmask for MM. * bsc_msg_filter.c: bsc_msg_filter_initial(): RR vs. MM messages. * osmo_bsc_filter.c: bsc_find_msc() and bsc_scan_bts_msg(): RR vs. MM messages. * bsc_nat_rewrite.c: bsc_nat_rewrite_msg(): SMS vs. CC messages. * bsc_ussd.c: no bitmask is applicable for the message types used here. * gb_proxy.c: gbproxy_imsi_acquisition(): missing bit mask for pdisc. In gprs_gb_parse.c: gprs_gb_parse_dtap(), add a log notice for unexpected message types. --- openbsc/src/gprs/gb_proxy.c | 4 ++-- openbsc/src/gprs/gprs_gb_parse.c | 13 ++++++++++--- openbsc/src/gprs/gprs_gmm.c | 2 +- openbsc/src/libbsc/bsc_api.c | 8 +++++--- openbsc/src/libfilter/bsc_msg_filter.c | 10 +++++----- openbsc/src/libmsc/gsm_04_08.c | 11 +++++------ openbsc/src/libmsc/silent_call.c | 5 +++-- openbsc/src/osmo-bsc/osmo_bsc_api.c | 8 ++++---- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 10 +++++----- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 4 ++-- 12 files changed, 46 insertions(+), 37 deletions(-) diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c index 9551335..6e6b03b 100644 --- a/openbsc/src/gprs/gb_proxy.c +++ b/openbsc/src/gprs/gb_proxy.c @@ -462,8 +462,8 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, if (link_info->imsi_acq_pending && link_info->imsi_len > 0) { int is_ident_resp = parse_ctx->g48_hdr && - parse_ctx->g48_hdr->proto_discr == GSM48_PDISC_MM_GPRS && - parse_ctx->g48_hdr->msg_type == GSM48_MT_GMM_ID_RESP; + gsm48_hdr_pdisc(parse_ctx->g48_hdr) == GSM48_PDISC_MM_GPRS && + gsm48_hdr_msg_type(parse_ctx->g48_hdr) == GSM48_MT_GMM_ID_RESP; /* The IMSI is now available */ gbproxy_flush_stored_messages(peer, msg, now, link_info, diff --git a/openbsc/src/gprs/gprs_gb_parse.c b/openbsc/src/gprs/gprs_gb_parse.c index 6096854..63ac902 100644 --- a/openbsc/src/gprs/gprs_gb_parse.c +++ b/openbsc/src/gprs/gprs_gb_parse.c @@ -329,17 +329,20 @@ int gprs_gb_parse_dtap(uint8_t *data, size_t data_len, struct gprs_gb_parse_context *parse_ctx) { struct gsm48_hdr *g48h; + uint8_t pdisc; + uint8_t msg_type; if (gprs_shift_v_fixed(&data, &data_len, sizeof(*g48h), (uint8_t **)&g48h) <= 0) return 0; parse_ctx->g48_hdr = g48h; - if ((g48h->proto_discr & 0x0f) != GSM48_PDISC_MM_GPRS && - (g48h->proto_discr & 0x0f) != GSM48_PDISC_SM_GPRS) + pdisc = gsm48_hdr_pdisc(g48h); + if (pdisc != GSM48_PDISC_MM_GPRS && pdisc != GSM48_PDISC_SM_GPRS) return 1; - switch (g48h->msg_type) { + msg_type = gsm48_hdr_msg_type(g48h); + switch (msg_type) { case GSM48_MT_GMM_ATTACH_REQ: return gprs_gb_parse_gmm_attach_req(data, data_len, parse_ctx); @@ -376,6 +379,10 @@ int gprs_gb_parse_dtap(uint8_t *data, size_t data_len, break; default: + LOGP(DLLC, LOGL_NOTICE, + "Unknown GSM 04.08 message type 0x%02hhx for protocol" + " discriminator 0x%02hhx.\n", + msg_type, pdisc); break; }; diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index d93ba3f..9d94c24 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -2089,7 +2089,7 @@ int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx) int gsm0408_gprs_rcvmsg(struct msgb *msg, struct gprs_llc_llme *llme) { struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; + uint8_t pdisc = gsm48_hdr_pdisc(gh); struct sgsn_mm_ctx *mmctx; struct gprs_ra_id ra_id; int rc = -EINVAL; diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 504f044..e6d820d 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -563,6 +563,7 @@ static void dispatch_dtap(struct gsm_subscriber_connection *conn, struct bsc_api *api = msg->lchan->ts->trx->bts->network->bsc_api; struct gsm48_hdr *gh; uint8_t pdisc; + uint8_t msg_type; int rc; if (msgb_l3len(msg) < sizeof(*gh)) { @@ -571,7 +572,8 @@ static void dispatch_dtap(struct gsm_subscriber_connection *conn, } gh = msgb_l3(msg); - pdisc = gh->proto_discr & 0x0f; + pdisc = gsm48_hdr_pdisc(gh); + msg_type = gsm48_hdr_msg_type(gh); /* the idea is to handle all RR messages here, and only hand * MM/CC/SMS-CP/LCS up to the MSC. Some messages like PAGING @@ -581,7 +583,7 @@ static void dispatch_dtap(struct gsm_subscriber_connection *conn, * will call api->compl_l3() for it */ switch (pdisc) { case GSM48_PDISC_RR: - switch (gh->msg_type) { + switch (msg_type) { case GSM48_MT_RR_GPRS_SUSP_REQ: DEBUGP(DRR, "GRPS SUSPEND REQUEST\n"); break; @@ -640,7 +642,7 @@ static void dispatch_dtap(struct gsm_subscriber_connection *conn, * messages, but we'd rather forward what we * don't know than drop it... */ LOGP(DRR, LOGL_NOTICE, "BSC: Passing unknown 04.08 " - "RR message type 0x%02x to MSC\n", gh->msg_type); + "RR message type 0x%02x to MSC\n", msg_type); if (api->dtap) api->dtap(conn, link_id, msg); } diff --git a/openbsc/src/libfilter/bsc_msg_filter.c b/openbsc/src/libfilter/bsc_msg_filter.c index eafeff4..115d376 100644 --- a/openbsc/src/libfilter/bsc_msg_filter.c +++ b/openbsc/src/libfilter/bsc_msg_filter.c @@ -339,15 +339,15 @@ int bsc_msg_filter_initial(struct gsm48_hdr *hdr48, size_t hdr48_len, cause->lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED; *imsi = NULL; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = gsm48_hdr_pdisc(hdr48); + msg_type = gsm48_hdr_msg_type(hdr48); if (proto == GSM48_PDISC_MM && msg_type == GSM48_MT_MM_LOC_UPD_REQUEST) { *con_type = FLT_CON_TYPE_LU; ret = _cr_check_loc_upd(req->ctx, &hdr48->data[0], hdr48_len - sizeof(*hdr48), imsi); } else if (proto == GSM48_PDISC_MM && - msg_type == GSM48_MT_MM_CM_SERV_REQ) { + msg_type == GSM48_MT_MM_CM_SERV_REQ) { *con_type = FLT_CON_TYPE_CM_SERV_REQ; ret = _cr_check_cm_serv_req(req->ctx, &hdr48->data[0], hdr48_len - sizeof(*hdr48), @@ -388,8 +388,8 @@ int bsc_msg_filter_data(struct gsm48_hdr *hdr48, size_t len, if (state->imsi_checked) return 0; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = gsm48_hdr_pdisc(hdr48); + msg_type = gsm48_hdr_msg_type(hdr48); if (proto != GSM48_PDISC_MM || msg_type != GSM48_MT_MM_ID_RESP) return 0; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 47f3fa7..a1759f9 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -124,13 +124,12 @@ static int gsm48_conn_sendmsg(struct msgb *msg, struct gsm_subscriber_connection msg->lchan = trans->conn->lchan; } - if (msg->lchan) { struct e1inp_sign_link *sign_link = msg->lchan->ts->trx->rsl_link; msg->dst = sign_link; - if ((gh->proto_discr & GSM48_PDISC_MASK) == GSM48_PDISC_CC) + if (gsm48_hdr_pdisc(gh) == GSM48_PDISC_CC) DEBUGP(DCC, "(bts %d trx %d ts %d ti %02x) " "Sending '%s' to MS.\n", sign_link->trx->bts->nr, @@ -1140,7 +1139,7 @@ static int gsm0408_rcv_mm(struct gsm_subscriber_connection *conn, struct msgb *m struct gsm48_hdr *gh = msgb_l3(msg); int rc = 0; - switch (gh->msg_type & 0xbf) { + switch (gsm48_hdr_msg_type(gh)) { case GSM48_MT_MM_LOC_UPD_REQUEST: DEBUGP(DMM, "LOCATION UPDATING REQUEST: "); rc = mm_rx_loc_upd_req(conn, msg); @@ -1869,7 +1868,7 @@ static void gsm48_start_cc_timer(struct gsm_trans *trans, int current, static int gsm48_cc_rx_setup(struct gsm_trans *trans, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t msg_type = gh->msg_type & 0xbf; + uint8_t msg_type = gsm48_hdr_msg_type(gh); unsigned int payload_len = msgb_l3len(msg) - sizeof(*gh); struct tlv_parsed tp; struct gsm_mncc setup; @@ -3496,7 +3495,7 @@ static struct datastate { static int gsm0408_rcv_cc(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t msg_type = gh->msg_type & 0xbf; + uint8_t msg_type = gsm48_hdr_msg_type(gh); uint8_t transaction_id = ((gh->proto_discr & 0xf0) ^ 0x80) >> 4; /* flip */ struct gsm_trans *trans = NULL; int i, rc = 0; @@ -3587,7 +3586,7 @@ int gsm0408_new_conn(struct gsm_subscriber_connection *conn) int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; + uint8_t pdisc = gsm48_hdr_pdisc(gh); int rc = 0; LOGP(DRLL, LOGL_DEBUG, "Dispatching 04.08 message, pdisc=%d\n", pdisc); diff --git a/openbsc/src/libmsc/silent_call.c b/openbsc/src/libmsc/silent_call.c index e9ece18..131a178 100644 --- a/openbsc/src/libmsc/silent_call.c +++ b/openbsc/src/libmsc/silent_call.c @@ -95,7 +95,8 @@ static const struct msg_match silent_call_accept[] = { int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; + uint8_t pdisc = gsm48_hdr_pdisc(gh); + uint8_t msg_type = gsm48_hdr_msg_type(gh); int i; /* if we're not part of a silent call, never reroute */ @@ -105,7 +106,7 @@ int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg /* check if we are a special message that is handled in openbsc */ for (i = 0; i < ARRAY_SIZE(silent_call_accept); i++) { if (silent_call_accept[i].pdisc == pdisc && - silent_call_accept[i].msg_type == gh->msg_type) + silent_call_accept[i].msg_type == msg_type) return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index fbeed77..d31e6c1 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -180,8 +180,8 @@ static void bsc_send_ussd_no_srv(struct gsm_subscriber_connection *conn, return; gh = msgb_l3(msg); - pdisc = gh->proto_discr & 0x0f; - mtype = gh->msg_type & 0xbf; + pdisc = gsm48_hdr_pdisc(gh); + mtype = gsm48_hdr_msg_type(gh); /* Is CM service request? */ if (pdisc == GSM48_PDISC_MM && mtype == GSM48_MT_MM_CM_SERV_REQ) { @@ -341,8 +341,8 @@ static int handle_cc_setup(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; - uint8_t mtype = gh->msg_type & 0xbf; + uint8_t pdisc = gsm48_hdr_pdisc(gh); + uint8_t mtype = gsm48_hdr_msg_type(gh); struct osmo_msc_data *msc; struct gsm_mncc_number called; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 389a124..a71871f 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -141,8 +141,8 @@ struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, } gh = msgb_l3(msg); - pdisc = gh->proto_discr & 0x0f; - mtype = gh->msg_type & 0xbf; + pdisc = gsm48_hdr_pdisc(gh); + mtype = gsm48_hdr_msg_type(gh); /* * We are asked to select a MSC here but they are not equal. We @@ -212,8 +212,8 @@ paging: int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; - uint8_t mtype = gh->msg_type & 0xbf; + uint8_t pdisc = gsm48_hdr_pdisc(gh); + uint8_t mtype = gsm48_hdr_msg_type(gh); if (pdisc == GSM48_PDISC_MM) { if (mtype == GSM48_MT_MM_LOC_UPD_REQUEST) @@ -347,7 +347,7 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) gh = (struct gsm48_hdr *) msgb_l3(msg); length -= (const char *)&gh->data[0] - (const char *)gh; - mtype = gh->msg_type & 0xbf; + mtype = gsm48_hdr_msg_type(gh); net = conn->bts->network; msc = conn->sccp_con->msc; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index cdab406..cacb919 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -670,8 +670,8 @@ static void update_con_authorize(struct nat_sccp_connection *con, if (!hdr48) return; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = gsm48_hdr_pdisc(hdr48); + msg_type = gsm48_hdr_msg_type(hdr48); if (proto == GSM48_PDISC_MM && msg_type == GSM48_MT_MM_CM_SERV_ACC) con->authorized = 1; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c index ca5670c..58667fe 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_rewrite.c @@ -594,8 +594,8 @@ struct msgb *bsc_nat_rewrite_msg(struct bsc_nat *nat, struct msgb *msg, struct b return msg; link_id = msg->l3h[1]; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = gsm48_hdr_pdisc(hdr48); + msg_type = gsm48_hdr_msg_type(hdr48); if (proto == GSM48_PDISC_CC && msg_type == GSM48_MT_CC_SETUP) new_msg = rewrite_setup(nat, msg, parsed, imsi, hdr48, len); diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 1082414..2905c85 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -407,8 +407,8 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse if (!hdr48) return 0; - proto = hdr48->proto_discr & 0x0f; - msg_type = hdr48->msg_type & 0xbf; + proto = gsm48_hdr_pdisc(hdr48); + msg_type = gsm48_hdr_msg_type(hdr48); ti = (hdr48->proto_discr & 0x70) >> 4; if (proto != GSM48_PDISC_NC_SS) return 0; -- 2.1.4 From nhofmeyr at sysmocom.de Mon Mar 14 15:13:25 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:13:25 +0100 Subject: [PATCH 2/2] 04.08: apply new transaction id inline functions In-Reply-To: <1457968405-15933-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457968405-15933-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1457968405-15933-3-git-send-email-nhofmeyr@sysmocom.de> libosmocore recently added inline functions to relieve callers from applying bitmasks and bit shifts to access the transaction id of a GSM 04.08 header. Apply these functions. --- openbsc/src/gprs/gprs_gmm.c | 8 ++++---- openbsc/src/libmsc/gsm_04_08.c | 2 +- openbsc/src/libmsc/gsm_04_11.c | 2 +- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 9d94c24..5f0a5fd 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -1753,7 +1753,7 @@ static int do_act_pdp_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg) uint8_t req_qos_len, req_pdpa_len; uint8_t *req_qos, *req_pdpa; struct tlv_parsed tp; - uint8_t transaction_id = (gh->proto_discr >> 4); + uint8_t transaction_id = gsm48_hdr_trans_id(gh); struct sgsn_ggsn_ctx *ggsn; struct sgsn_pdp_ctx *pdp; enum gsm48_gsm_cause gsm_cause; @@ -1923,7 +1923,7 @@ static int gsm48_rx_gsm_act_pdp_req(struct sgsn_mm_ctx *mmctx, msg = gprs_msgb_copy(_msg, __func__); if (!msg) { struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(_msg); - uint8_t transaction_id = (gh->proto_discr >> 4); + uint8_t transaction_id = gsm48_hdr_trans_id(gh); LOGMMCTXP(LOGL_ERROR, mmctx, "-> ACTIVATE PDP CONTEXT REQ failed copy.\n"); /* Send reject with GSM_CAUSE_INV_MAND_INFO */ @@ -1941,7 +1941,7 @@ static int gsm48_rx_gsm_act_pdp_req(struct sgsn_mm_ctx *mmctx, static int gsm48_rx_gsm_deact_pdp_req(struct sgsn_mm_ctx *mm, struct msgb *msg) { struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); - uint8_t transaction_id = (gh->proto_discr >> 4); + uint8_t transaction_id = gsm48_hdr_trans_id(gh); struct sgsn_pdp_ctx *pdp; LOGMMCTXP(LOGL_INFO, mm, "-> DEACTIVATE PDP CONTEXT REQ (cause: %s)\n", @@ -1962,7 +1962,7 @@ static int gsm48_rx_gsm_deact_pdp_req(struct sgsn_mm_ctx *mm, struct msgb *msg) static int gsm48_rx_gsm_deact_pdp_ack(struct sgsn_mm_ctx *mm, struct msgb *msg) { struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); - uint8_t transaction_id = (gh->proto_discr >> 4); + uint8_t transaction_id = gsm48_hdr_trans_id(gh); struct sgsn_pdp_ctx *pdp; LOGMMCTXP(LOGL_INFO, mm, "-> DEACTIVATE PDP CONTEXT ACK\n"); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index a1759f9..c69ab69 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -3496,7 +3496,7 @@ static int gsm0408_rcv_cc(struct gsm_subscriber_connection *conn, struct msgb *m { struct gsm48_hdr *gh = msgb_l3(msg); uint8_t msg_type = gsm48_hdr_msg_type(gh); - uint8_t transaction_id = ((gh->proto_discr & 0xf0) ^ 0x80) >> 4; /* flip */ + uint8_t transaction_id = gsm48_hdr_trans_id_flip_ti(gh); struct gsm_trans *trans = NULL; int i, rc = 0; diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index bf256c3..20d18a9 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -780,7 +780,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn, { struct gsm48_hdr *gh = msgb_l3(msg); uint8_t msg_type = gh->msg_type; - uint8_t transaction_id = ((gh->proto_discr >> 4) ^ 0x8); /* flip */ + uint8_t transaction_id = gsm48_hdr_trans_id_flip_ti(gh); struct gsm_trans *trans; int new_trans = 0; int rc = 0; diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 2905c85..e080905 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -409,7 +409,7 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse proto = gsm48_hdr_pdisc(hdr48); msg_type = gsm48_hdr_msg_type(hdr48); - ti = (hdr48->proto_discr & 0x70) >> 4; + ti = gsm48_hdr_trans_id_no_ti(hdr48); if (proto != GSM48_PDISC_NC_SS) return 0; -- 2.1.4 From nhofmeyr at sysmocom.de Mon Mar 14 15:15:02 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 16:15:02 +0100 Subject: [PATCH] bsc_scan_msc_msg: check protocol discriminator Message-ID: <1457968502-16019-1-git-send-email-nhofmeyr@sysmocom.de> The function assumed an MM protocol discriminator without verifying it. --- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index a71871f..14e0b71 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -336,6 +336,7 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) struct gsm_network *net; struct gsm48_loc_area_id *lai; struct gsm48_hdr *gh; + uint8_t pdisc; uint8_t mtype; int length = msgb_l3len(msg); @@ -347,6 +348,10 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) gh = (struct gsm48_hdr *) msgb_l3(msg); length -= (const char *)&gh->data[0] - (const char *)gh; + pdisc = gsm48_hdr_pdisc(gh); + if (pdisc != GSM48_PDISC_MM) + return 0; + mtype = gsm48_hdr_msg_type(gh); net = conn->bts->network; msc = conn->sccp_con->msc; -- 2.1.4 From holger at freyther.de Mon Mar 14 17:00:13 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 14 Mar 2016 18:00:13 +0100 Subject: [PATCH] bsc_scan_msc_msg: check protocol discriminator In-Reply-To: <1457968502-16019-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457968502-16019-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <407E326A-ED38-4B75-A22F-2E7489F53455@freyther.de> > On 14 Mar 2016, at 16:15, Neels Hofmeyr wrote: > > The function assumed an MM protocol discriminator without verifying it. test? From msuraev at sysmocom.de Mon Mar 14 17:00:52 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Mon, 14 Mar 2016 18:00:52 +0100 Subject: [PATCH] Add function to add bits from array to bitvec Message-ID: <1457974852-24878-1-git-send-email-msuraev@sysmocom.de> From: Max Add function which adds specified number of bits from each element of array to the bit vector prefixing each addition with one and finishing entire sequence with adding 0. This is very common patter for various repetitive data structures described with CSN.1 in 3GPP standards. Corresponding test vectors and doxygen headers are added too. --- include/osmocom/core/bitvec.h | 2 ++ src/bitvec.c | 37 +++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.c | 41 +++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.ok | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 5314cf2..623f9b4 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -91,5 +91,7 @@ void bitvec_zero(struct bitvec *bv); unsigned bitvec_rl(const struct bitvec *bv, bool b); void bitvec_shiftl(struct bitvec *bv, unsigned int n); int16_t bitvec_get_int16_msb(const struct bitvec *bv, unsigned int num_bits); +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, unsigned int array_len, + bool estimate, unsigned int num_bits); /*! @} */ diff --git a/src/bitvec.c b/src/bitvec.c index 00ae150..f212043 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -570,4 +570,41 @@ void bitvec_shiftl(struct bitvec *bv, unsigned n) bv->cur_bit -= n; } +/*! \brief Add given array to bitvec + * \param[in,out] bv bit vector to work with + * \param[in] array elements to be added + * \param[in] array_len length of array + * \param[in] estimate indicates whether to return number of bits required instead of actually changing bv + * \param[in] num_bits number of bits to consider in each element of array + * \returns number of bits necessary to add given PCIDs if estimate is true, 0 otherwise + * + * N. B: no length checks are performed on bv - it's callee's job to ensure + * enough space is available - for example by calling with estimate == true first. + * + * Useful for common pattern in CSN.1 spec which looks like: + * { 1 < XXX : bit (num_bits) > } ** 0 + * which means repeat any times (between 0 and infinity), + * start each repetition with 1, mark end of repetitions with 0 bit + * see app. note in 3GPP TS 24.007 ? B.2.1 Rule A2 + */ +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, unsigned int array_len, + bool estimate, unsigned int num_bits) +{ + unsigned i, bits = 1; /* account for stop bit */ + for (i = 0; i < array_len; i++) { + if (estimate) { + bits += (1 + num_bits); + } else { + bitvec_set_bit(bv, 1); + bitvec_set_uint(bv, array[i], num_bits); + } + } + + if (estimate) + return bits; + + bitvec_set_bit(bv, 0); /* stop bit - end of the sequence */ + return 0; +} + /*! @} */ diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c index 76d6773..a0cae73 100644 --- a/tests/bitvec/bitvec_test.c +++ b/tests/bitvec/bitvec_test.c @@ -132,6 +132,41 @@ static void test_unhex(const char *hex) printf("%s\n", hex); } +static inline void test_array_item(unsigned t, struct bitvec *b, unsigned int n, uint32_t *array, unsigned int p) +{ + unsigned int i, x, y; + bitvec_zero(b); + x = b->cur_bit; + i = bitvec_add_array(b, array, n, true, t); + y = b->cur_bit; + bitvec_add_array(b, array, n, false, t); + printf("\nbits: %u, est: %u, real: %u, x: %u, y: %u\n", t, i, b->cur_bit, x, y); + for (i = 0; i < p; i++) { + printf(OSMO_BIT_SPEC " ", OSMO_BIT_PRINT(b->data[i])); + if (0 == (i + 1) % 15) + printf("\n"); + } +} + +static void test_array() +{ + struct bitvec b; + uint8_t d[4096]; + b.data = d; + b.data_len = sizeof(d); + + unsigned int i, n = 64; + uint32_t array[n]; + for (i = 0; i < n; i++) { + array[i] = i * i * i + i; + printf("0x%x ", array[i]); + } + + test_array_item(3, &b, n, array, n); + test_array_item(9, &b, n, array, n * 2); + test_array_item(17, &b, n, array, n * 3); +} + int main(int argc, char **argv) { struct bitvec bv; @@ -204,5 +239,11 @@ int main(int argc, char **argv) test_unhex("DEADFACE000000000000000000000000000000BEEFFEED"); test_unhex("FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); + printf("arrr...\n"); + + test_array(); + + printf("\nbitvec ok.\n"); + return 0; } diff --git a/tests/bitvec/bitvec_test.ok b/tests/bitvec/bitvec_test.ok index 1c993d3..e256108 100644 --- a/tests/bitvec/bitvec_test.ok +++ b/tests/bitvec/bitvec_test.ok @@ -134,3 +134,36 @@ DEADFACE000000000000000000000000000000BEEFFEED 0 -=> cur_bit=512 fffffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +arrr... +0x0 0x2 0xa 0x1e 0x44 0x82 0xde 0x15e 0x208 0x2e2 0x3f2 0x53e 0x6cc 0x8a2 0xac6 0xd3e 0x1010 0x1342 0x16da 0x1ade 0x1f54 0x2442 0x29ae 0x2f9e 0x3618 0x3d22 0x44c2 0x4cfe 0x55dc 0x5f62 0x6996 0x747e 0x8020 0x8c82 0x99aa 0xa79e 0xb664 0xc602 0xd67e 0xe7de 0xfa28 0x10d62 0x12192 0x136be 0x14cec 0x16422 0x17c66 0x195be 0x1b030 0x1cbc2 0x1e87a 0x2065e 0x22574 0x245c2 0x2674e 0x28a1e 0x2ae38 0x2d3a2 0x2fa62 0x3227e 0x34bfc 0x376e2 0x3a336 0x3d0fe +bits: 3, est: 257, real: 257, x: 0, y: 0 +1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. +111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. +11..1.1. 111.111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ +bits: 9, est: 641, real: 641, x: 0, y: 0 +1....... ..1..... ..1.1... ..1.1.1. ...1111. 1..1...1 ..1.1... ..1.1.11 .1111.11 .1.1111. 1.....1. ..1.111. ..1.1111 11..1.11 ..11111. +1.11..11 ..1.1.1. ..1.1.11 ...11.11 ..11111. 1....1.. ..11.1.. ..1.1.11 .11.1.1. 11.1111. 11.1.1.1 ..1..1.. ..1.111. 1.111.11 1..1111. +1....11. ..11..1. ..1.1.11 ....1.1. 1111111. 1111.111 ..11.11. ..1.111. .1.11.1. .111111. 1...1... ..1.1... ..1.111. 1.1.1.11 1..1111. +1..11..1 ..1..... ..1.1..1 11111.11 11.1111. 1...1.1. ..11.11. ..1.111. .1..1.1. 1.11111. 1.111.11 ..1...1. ..1.1..1 1..11.11 1.11111. +1...11.. ..1111.. ..1.1..1 111.1.1. .1.1111. 11.111.1 ..1111.. ..1.11.1 ..111.1. ...1111. 1...111. ..111.1. ..1.1..1 1...1.1. .111111. +11111111 ..1.111. ..1.11.. 11.11.1. 1111111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ +bits: 17, est: 1153, real: 1153, x: 0, y: 0 +1....... ........ ..1..... ........ ..1.1... ........ ..1.1.1. ........ ...1111. 1....... ...1...1 ..1..... ....1... ..1.1... ......11 +.1111.1. .......1 .1.1111. 1....... 1.....1. ..1..... ..1.111. ..1.1... ....1111 11..1.1. .....1.1 ..11111. 1......1 1.11..11 ..1..... +1...1.1. ..1.1... ..1.1.11 ...11.1. ....11.1 ..11111. 1....1.. .....1.. ..1....1 ..11.1.. ..1.1... .1.11.11 .11.1.1. ...11.1. 11.1111. +1....111 11.1.1.1 ..1...1. .1...1.. ..1.1... 1.1..11. 1.111.1. ..1.1111 1..1111. 1...11.1 1....11. ..1...11 11.1..1. ..1.1..1 ...1..11 +....1.1. .1..11.. 1111111. 1..1.1.1 .111.111 ..1..1.1 1111.11. ..1.1..1 1.1..11. .1.11.1. .111.1.. .111111. 1.1..... ....1... ..1.1... +11..1... ..1.1.1. .11..11. 1.1.1.1. 1.1..111 1..1111. 1.1.11.1 1..11..1 ..1.11.. .11..... ..1.1.11 .1.11..1 11111.1. 111..111 11.1111. +1.11111. 1...1.1. ..11.... 11.1.11. ..1.11.. 1....11. .1..1.11 ..11.11. 1.11111. 11.1..11 ..111.11 ..11.11. .1....1. ..1.11.1 1111...1 +1..11.11 1..1.1.1 1.11111. 111.11.. ....11.. ..1111.. 1.1111.. ..1.1111 1.1....1 111.1.1. .....11. .1.1111. 1...1..1 .1.111.1 ..1..1.. +.1.111.. ..1.1..1 1..111.1 ..111.1. 1...1.1. ...1111. 1.1.1.11 1...111. ..1.11.1 ..111.1. ..1.1.11 111.1..1 1...1.11 ..1...1. .111111. +11.1..1. 11111111 ..11.111 .11.111. ..1.111. 1...11.. 11.11.11 11.1.... 1111111. ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +bitvec ok. -- 2.7.3 From msuraev at sysmocom.de Mon Mar 14 17:05:17 2016 From: msuraev at sysmocom.de (Max) Date: Mon, 14 Mar 2016 18:05:17 +0100 Subject: [PATCH] Update configuration examples In-Reply-To: <20160314151031.GB22557@nataraja> References: <1457713705-5940-1-git-send-email-msuraev@sysmocom.de> <20160314151031.GB22557@nataraja> Message-ID: <56E6EF4D.5070403@sysmocom.de> Oops, forgot to rename it. Should be fixed in attached patch. On 03/14/2016 04:10 PM, Harald Welte wrote: > On Fri, Mar 11, 2016 at 05:28:25PM +0100, msuraev at sysmocom.de wrote: >> From: Max >> >> Add SysmoBTS-specific example. >> Remove outdated generic example which is no longer working. >> --- >> doc/examples/osmo-bts.cfg | 26 -------------------------- >> doc/examples/sysmo/osmo-bts-new.cfg | 30 ++++++++++++++++++++++++++++++ > why the 'new' in the name? It should be called osmo-bts.cfg, like all > the other examples, too... -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: Update-configuration-examples.patch Type: text/x-patch Size: 1424 bytes Desc: not available URL: From msuraev at sysmocom.de Mon Mar 14 17:27:55 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Mon, 14 Mar 2016 18:27:55 +0100 Subject: [PATCH 2/2] Add vty command to explicitly reset given BVCI In-Reply-To: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> References: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1457976475-8357-2-git-send-email-msuraev@sysmocom.de> From: Max It's useful for debugging and is similar to existing nsvc reset vty command. --- src/gb/gprs_bssgp_vty.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 080867b..2725d1f 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,31 @@ static void dump_bssgp(struct vty *vty, int stats) } } +DEFUN(bvc_reset, bvc_reset_cmd, + "bvc reset nsei <0-65535> bvci <0-65535>", + "Initiate BVC RESET procedure for a given NSEI and BVCI\n") +{ + uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]); + struct bssgp_bvc_ctx *bvc; + + if (!strcmp(argv[0], "reset")) + return CMD_WARNING; + + if (argc != 2) + return CMD_WARNING; + + bvc = btsctx_by_bvci_nsei(bvci, nsei); + if (!bvc) { + vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, + VTY_NEWLINE); + return CMD_WARNING; + } + int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV); + vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, + VTY_NEWLINE); + return CMD_SUCCESS; +} + #define BSSGP_STR "Show information about the BSSGP protocol\n" DEFUN(show_bssgp, show_bssgp_cmd, "show bssgp", @@ -185,6 +211,7 @@ int bssgp_vty_init(void) install_element_ve(&show_bssgp_stats_cmd); install_element_ve(&show_bvc_cmd); install_element_ve(&logging_fltr_bvc_cmd); + install_element_ve(&bvc_reset_cmd); install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd); -- 2.7.3 From msuraev at sysmocom.de Mon Mar 14 17:27:54 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Mon, 14 Mar 2016 18:27:54 +0100 Subject: [PATCH 1/2] Improve BSSGP debug output Message-ID: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> From: Max Print string representation of Cause IE and PDU type in addition to numerical value. --- src/gb/gprs_bssgp.c | 28 ++++++++++++++-------------- src/gb/gprs_bssgp_bss.c | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index e3e69c9..e724d00 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -896,8 +896,8 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_CREATE_BSS_PFC_NACK: case BSSGP_PDUT_MODIFY_BSS_PFC: case BSSGP_PDUT_DELETE_BSS_PFC_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] " - "implemented\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s not [yet] " + "implemented\n", bctx->bvci, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg); break; /* those only exist in the SGSN -> BSS direction */ @@ -907,14 +907,14 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_RA_CAPA_UPDATE_ACK: case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK: case BSSGP_PDUT_FLOW_CONTROL_MS_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x only exists " - "in DL\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) only exists " + "in DL\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x unknown\n", - bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) unknown\n", + bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -999,14 +999,14 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_BVC_BLOCK_ACK: case BSSGP_PDUT_BVC_UNBLOCK_ACK: case BSSGP_PDUT_SGSN_INVOKE_TRACE: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x only exists " - "in DL\n", bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) only exists " + "in DL\n", bvci, pdu_type, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x unknown\n", - bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) unknown\n", + bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -1066,8 +1066,8 @@ int bssgp_rcvmsg(struct msgb *msg) if (!bctx && bvci != BVCI_SIGNALLING && pdu_type != BSSGP_PDUT_BVC_RESET) { LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU " - "type %u for unknown BVCI\n", msgb_nsei(msg), bvci, - pdu_type); + "type %u (%s) for unknown BVCI\n", msgb_nsei(msg), bvci, + pdu_type, bssgp_pdu_str(pdu_type)); return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg); } @@ -1079,9 +1079,9 @@ int bssgp_rcvmsg(struct msgb *msg) rc = bssgp_rx_ptp(msg, &tp, bctx); else LOGP(DBSSGP, LOGL_NOTICE, - "NSEI=%u/BVCI=%u Cannot handle PDU type %u for " + "NSEI=%u/BVCI=%u Cannot handle PDU type %u (%s) for " "unknown BVCI, NS BVCI %u\n", - msgb_nsei(msg), bvci, pdu_type, ns_bvci); + msgb_nsei(msg), bvci, pdu_type, bssgp_pdu_str(pdu_type), ns_bvci); return rc; } diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 3a9012e..955e2b4 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -135,7 +135,7 @@ static struct msgb *common_tx_radio_status(struct bssgp_bvc_ctx *bctx) static int common_tx_radio_status2(struct msgb *msg, uint8_t cause) { msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause); - LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u\n", cause); + LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u (%s)\n", cause, bssgp_cause_str(cause)); return gprs_ns_sendmsg(bssgp_nsi, msg); } @@ -247,7 +247,7 @@ int bssgp_tx_bvc_block(struct bssgp_bvc_ctx *bctx, uint8_t cause) uint16_t _bvci = htons(bctx->bvci); LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-BLOCK " - "CAUSE=%u\n", bctx->bvci, cause); + "CAUSE=%u (%s)\n", bctx->bvci, cause, bssgp_cause_str(cause)); msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ @@ -287,7 +287,7 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause) uint16_t _bvci = htons(bvci); LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-RESET " - "CAUSE=%u\n", bvci, cause); + "CAUSE=%u (%s)\n", bvci, cause, bssgp_cause_str(cause)); msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ -- 2.7.3 From holger at freyther.de Mon Mar 14 17:41:37 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 14 Mar 2016 18:41:37 +0100 Subject: [PATCH 1/3] mgcp: Move the transcoding routines into a struct Message-ID: <1457977299-66630-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther We will have the NOOP implementation (e.g. used by the NAT), the SW implementation (using software codecs), a HW assisted one that will use a DSP to do transcoding and in theory the RTP based one (but I will remove that code). --- openbsc/include/openbsc/mgcp.h | 14 ++++++------- openbsc/include/openbsc/mgcp_internal.h | 15 ++++++++++++-- openbsc/include/openbsc/mgcp_transcode.h | 2 ++ openbsc/src/libmgcp/mgcp_network.c | 3 ++- openbsc/src/libmgcp/mgcp_protocol.c | 33 ++++++++++++++++++------------ openbsc/src/libmgcp/mgcp_transcode.c | 12 ++++++++--- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 10 ++++----- openbsc/tests/mgcp/mgcp_transcoding_test.c | 11 ++++++---- 8 files changed, 63 insertions(+), 37 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index b2262bc..a216547 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -1,8 +1,8 @@ /* A Media Gateway Control Protocol Media Gateway: RFC 3435 */ /* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves + * (C) 2009-2016 by Holger Hans Peter Freyther + * (C) 2009-2016 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -69,6 +69,7 @@ struct mgcp_endpoint; struct mgcp_config; struct mgcp_trunk_config; struct mgcp_rtp_end; +struct mgcp_transcoding; #define MGCP_ENDP_CRCX 1 #define MGCP_ENDP_DLCX 2 @@ -158,6 +159,9 @@ struct mgcp_trunk_config { /* spec handling */ int force_realloc; + /* transcoding */ + const struct mgcp_transcoding *transcoder; + /* timer */ struct osmo_timer_list keepalive_timer; @@ -184,12 +188,6 @@ struct mgcp_config { struct in_addr transcoder_in; int transcoder_remote_base; - /* RTP processing */ - mgcp_processing rtp_processing_cb; - mgcp_processing_setup setup_rtp_processing_cb; - - mgcp_get_format get_net_downlink_format_cb; - struct osmo_wqueue gw_fd; struct mgcp_port_range bts_ports; diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 7c89d10..a62dbb2 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -1,8 +1,8 @@ /* MGCP Private Data */ /* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves + * (C) 2009-2016 by Holger Hans Peter Freyther + * (C) 2009-2016 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -150,6 +150,17 @@ enum mgcp_type { MGCP_OSMUX_BSC_NAT, }; +/** + * Function pointers for RTP processing/transcoding + */ +struct mgcp_transcoding { + mgcp_processing processing_cb; + mgcp_processing_setup setup_processing_cb; + mgcp_get_format get_net_downlink_format_cb; +}; + +extern const struct mgcp_transcoding *mgcp_default_transcoder; + #include struct mgcp_endpoint { diff --git a/openbsc/include/openbsc/mgcp_transcode.h b/openbsc/include/openbsc/mgcp_transcode.h index 147e48b..02b039d 100644 --- a/openbsc/include/openbsc/mgcp_transcode.h +++ b/openbsc/include/openbsc/mgcp_transcode.h @@ -37,6 +37,8 @@ enum audio_format { AF_PCMU }; +struct mgcp_transcoding; +extern const struct mgcp_transcoding mgcp_sw_transcoder; struct mgcp_process_rtp_state { /* decoding */ diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index abce6e4..e4f5f7d 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -584,6 +584,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, struct sockaddr_in *addr, char *buf, int rc) { struct mgcp_trunk_config *tcfg = endp->tcfg; + const struct mgcp_transcoding *trans = tcfg->transcoder; struct mgcp_rtp_end *rtp_end; struct mgcp_rtp_state *rtp_state; int tap_idx; @@ -613,7 +614,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, int nbytes = 0; int len = rc; do { - cont = endp->cfg->rtp_processing_cb(endp, rtp_end, + cont = trans->processing_cb(endp, rtp_end, buf, &len, RTP_BUF_SIZE); if (cont < 0) break; diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 1819cea..8017fe8 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -2,8 +2,8 @@ /* The protocol implementation */ /* - * (C) 2009-2012 by Holger Hans Peter Freyther - * (C) 2009-2012 by On-Waves + * (C) 2009-2016 by Holger Hans Peter Freyther + * (C) 2009-2016 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -66,6 +66,14 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); +static const struct mgcp_transcoding no_transcoder = { + .processing_cb = &mgcp_rtp_processing_default, + .setup_processing_cb = &mgcp_setup_rtp_processing_default, + .get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default, +}; + +const struct mgcp_transcoding *mgcp_default_transcoder = &no_transcoder; + static int mgcp_check_param(const struct mgcp_endpoint *endp, const char *line) { const size_t line_len = strlen(line); @@ -197,13 +205,15 @@ static struct msgb *create_err_response(struct mgcp_endpoint *endp, static int write_response_sdp(struct mgcp_endpoint *endp, char *sdp_record, size_t size, const char *addr) { + const struct mgcp_transcoding *trans; const char *fmtp_extra; const char *audio_name; int payload_type; int len; int nchars; - endp->cfg->get_net_downlink_format_cb(endp, &payload_type, + trans = endp->tcfg->transcoder; + trans->get_net_downlink_format_cb(endp, &payload_type, &audio_name, &fmtp_extra); len = snprintf(sdp_record, size, @@ -1200,12 +1210,8 @@ struct mgcp_config *mgcp_config_alloc(void) cfg->bts_ports.base_port = RTP_PORT_DEFAULT; cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT; - cfg->rtp_processing_cb = &mgcp_rtp_processing_default; - cfg->setup_rtp_processing_cb = &mgcp_setup_rtp_processing_default; - - cfg->get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default; - /* default trunk handling */ + cfg->trunk.transcoder = mgcp_default_transcoder; cfg->trunk.cfg = cfg; cfg->trunk.trunk_nr = 0; cfg->trunk.trunk_type = MGCP_TRUNK_VIRTUAL; @@ -1231,6 +1237,7 @@ struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int nr) return NULL; } + trunk->transcoder = mgcp_default_transcoder; trunk->cfg = cfg; trunk->trunk_type = MGCP_TRUNK_E1; trunk->trunk_nr = nr; @@ -1459,7 +1466,7 @@ int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint) static int setup_rtp_processing(struct mgcp_endpoint *endp) { int rc = 0; - struct mgcp_config *cfg = endp->cfg; + const struct mgcp_transcoding *trans = endp->tcfg->transcoder; if (endp->type != MGCP_RTP_DEFAULT) return 0; @@ -1468,14 +1475,14 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp) return 0; if (endp->conn_mode & MGCP_CONN_SEND_ONLY) - rc |= cfg->setup_rtp_processing_cb(endp, &endp->net_end, &endp->bts_end); + rc |= trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); else - rc |= cfg->setup_rtp_processing_cb(endp, &endp->net_end, NULL); + rc |= trans->setup_processing_cb(endp, &endp->net_end, NULL); if (endp->conn_mode & MGCP_CONN_RECV_ONLY) - rc |= cfg->setup_rtp_processing_cb(endp, &endp->bts_end, &endp->net_end); + rc |= trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); else - rc |= cfg->setup_rtp_processing_cb(endp, &endp->bts_end, NULL); + rc |= trans->setup_processing_cb(endp, &endp->bts_end, NULL); return rc; } diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c index c994d32..aaa8863 100644 --- a/openbsc/src/libmgcp/mgcp_transcode.c +++ b/openbsc/src/libmgcp/mgcp_transcode.c @@ -32,6 +32,12 @@ #include #include +const struct mgcp_transcoding mgcp_sw_transcoder = { + .processing_cb = mgcp_transcoding_process_rtp, + .setup_processing_cb = mgcp_transcoding_setup, + .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, +}; + int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst) { struct mgcp_process_rtp_state *state = state_; @@ -470,12 +476,12 @@ struct mgcp_process_rtp_state *check_transcode_state( goto done; /* The matching alternate payload type? Then switch */ if (rtp_hdr->payload_type == src_end->alt_codec.payload_type) { - struct mgcp_config *cfg = endp->cfg; + const struct mgcp_transcoding *trans = endp->tcfg->transcoder; struct mgcp_rtp_codec tmp_codec = src_end->alt_codec; src_end->alt_codec = src_end->codec; src_end->codec = tmp_codec; - cfg->setup_rtp_processing_cb(endp, &endp->net_end, &endp->bts_end); - cfg->setup_rtp_processing_cb(endp, &endp->bts_end, &endp->net_end); + trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); + trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); } done: diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index e226b02..3c968be 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -207,16 +207,14 @@ int main(int argc, char **argv) osmo_init_ignore_signals(); osmo_init_logging(&log_info); +#ifdef BUILD_MGCP_TRANSCODING + mgcp_default_transcoder = &mgcp_sw_transcoder; +#endif + cfg = mgcp_config_alloc(); if (!cfg) return -1; -#ifdef BUILD_MGCP_TRANSCODING - cfg->setup_rtp_processing_cb = &mgcp_transcoding_setup; - cfg->rtp_processing_cb = &mgcp_transcoding_process_rtp; - cfg->get_net_downlink_format_cb = &mgcp_transcoding_net_downlink_format; -#endif - vty_info.copyright = openbsc_copyright; vty_init(&vty_info); logging_vty_add_cmds(&log_info); diff --git a/openbsc/tests/mgcp/mgcp_transcoding_test.c b/openbsc/tests/mgcp/mgcp_transcoding_test.c index c5c0a0b..72c75eb 100644 --- a/openbsc/tests/mgcp/mgcp_transcoding_test.c +++ b/openbsc/tests/mgcp/mgcp_transcoding_test.c @@ -161,6 +161,12 @@ static int audio_name_to_type(const char *name) int mgcp_get_trans_frame_size(void *state_, int nsamples, int dst); +static const struct mgcp_transcoding test_transcoder = { + .setup_processing_cb = mgcp_transcoding_setup, + .processing_cb = mgcp_transcoding_process_rtp, + .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, +}; + static int given_configured_endpoint(int in_samples, int out_samples, const char *srcfmt, const char *dstfmt, void **out_ctx, struct mgcp_endpoint **out_endp) @@ -176,10 +182,7 @@ static int given_configured_endpoint(int in_samples, int out_samples, tcfg = talloc_zero(cfg, struct mgcp_trunk_config); endp = talloc_zero(tcfg, struct mgcp_endpoint); - cfg->setup_rtp_processing_cb = mgcp_transcoding_setup; - cfg->rtp_processing_cb = mgcp_transcoding_process_rtp; - cfg->get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format; - + tcfg->transcoder = &test_transcoder; tcfg->endpoints = endp; tcfg->number_endpoints = 1; tcfg->cfg = cfg; -- 2.6.3 From holger at freyther.de Mon Mar 14 17:41:38 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 14 Mar 2016 18:41:38 +0100 Subject: [PATCH 2/3] mgcp: Simplify and shorten routine names In-Reply-To: <1457977299-66630-1-git-send-email-holger@freyther.de> References: <1457977299-66630-1-git-send-email-holger@freyther.de> Message-ID: <1457977299-66630-2-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther Now they are included in a struct we can just call them setup, process and get_net_downlink_format to manage the lifetime. --- openbsc/include/openbsc/mgcp_internal.h | 6 +++--- openbsc/src/libmgcp/mgcp_network.c | 2 +- openbsc/src/libmgcp/mgcp_protocol.c | 16 ++++++++-------- openbsc/src/libmgcp/mgcp_transcode.c | 10 +++++----- openbsc/tests/mgcp/mgcp_transcoding_test.c | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index a62dbb2..8fb8a45 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -154,9 +154,9 @@ enum mgcp_type { * Function pointers for RTP processing/transcoding */ struct mgcp_transcoding { - mgcp_processing processing_cb; - mgcp_processing_setup setup_processing_cb; - mgcp_get_format get_net_downlink_format_cb; + mgcp_processing process; + mgcp_processing_setup setup; + mgcp_get_format get_net_downlink_format; }; extern const struct mgcp_transcoding *mgcp_default_transcoder; diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index e4f5f7d..ed90d34 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -614,7 +614,7 @@ int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, int nbytes = 0; int len = rc; do { - cont = trans->processing_cb(endp, rtp_end, + cont = trans->process(endp, rtp_end, buf, &len, RTP_BUF_SIZE); if (cont < 0) break; diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 8017fe8..18a25bc 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -67,9 +67,9 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); static const struct mgcp_transcoding no_transcoder = { - .processing_cb = &mgcp_rtp_processing_default, - .setup_processing_cb = &mgcp_setup_rtp_processing_default, - .get_net_downlink_format_cb = &mgcp_get_net_downlink_format_default, + .process = &mgcp_rtp_processing_default, + .setup = &mgcp_setup_rtp_processing_default, + .get_net_downlink_format = &mgcp_get_net_downlink_format_default, }; const struct mgcp_transcoding *mgcp_default_transcoder = &no_transcoder; @@ -213,7 +213,7 @@ static int write_response_sdp(struct mgcp_endpoint *endp, int nchars; trans = endp->tcfg->transcoder; - trans->get_net_downlink_format_cb(endp, &payload_type, + trans->get_net_downlink_format(endp, &payload_type, &audio_name, &fmtp_extra); len = snprintf(sdp_record, size, @@ -1475,14 +1475,14 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp) return 0; if (endp->conn_mode & MGCP_CONN_SEND_ONLY) - rc |= trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); + rc |= trans->setup(endp, &endp->net_end, &endp->bts_end); else - rc |= trans->setup_processing_cb(endp, &endp->net_end, NULL); + rc |= trans->setup(endp, &endp->net_end, NULL); if (endp->conn_mode & MGCP_CONN_RECV_ONLY) - rc |= trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); + rc |= trans->setup(endp, &endp->bts_end, &endp->net_end); else - rc |= trans->setup_processing_cb(endp, &endp->bts_end, NULL); + rc |= trans->setup(endp, &endp->bts_end, NULL); return rc; } diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c index aaa8863..6407cfb 100644 --- a/openbsc/src/libmgcp/mgcp_transcode.c +++ b/openbsc/src/libmgcp/mgcp_transcode.c @@ -33,9 +33,9 @@ #include const struct mgcp_transcoding mgcp_sw_transcoder = { - .processing_cb = mgcp_transcoding_process_rtp, - .setup_processing_cb = mgcp_transcoding_setup, - .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, + .process = mgcp_transcoding_process_rtp, + .setup = mgcp_transcoding_setup, + .get_net_downlink_format = mgcp_transcoding_net_downlink_format, }; int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst) @@ -480,8 +480,8 @@ struct mgcp_process_rtp_state *check_transcode_state( struct mgcp_rtp_codec tmp_codec = src_end->alt_codec; src_end->alt_codec = src_end->codec; src_end->codec = tmp_codec; - trans->setup_processing_cb(endp, &endp->net_end, &endp->bts_end); - trans->setup_processing_cb(endp, &endp->bts_end, &endp->net_end); + trans->setup(endp, &endp->net_end, &endp->bts_end); + trans->setup(endp, &endp->bts_end, &endp->net_end); } done: diff --git a/openbsc/tests/mgcp/mgcp_transcoding_test.c b/openbsc/tests/mgcp/mgcp_transcoding_test.c index 72c75eb..02f2817 100644 --- a/openbsc/tests/mgcp/mgcp_transcoding_test.c +++ b/openbsc/tests/mgcp/mgcp_transcoding_test.c @@ -162,9 +162,9 @@ static int audio_name_to_type(const char *name) int mgcp_get_trans_frame_size(void *state_, int nsamples, int dst); static const struct mgcp_transcoding test_transcoder = { - .setup_processing_cb = mgcp_transcoding_setup, - .processing_cb = mgcp_transcoding_process_rtp, - .get_net_downlink_format_cb = mgcp_transcoding_net_downlink_format, + .setup = mgcp_transcoding_setup, + .process = mgcp_transcoding_process_rtp, + .get_net_downlink_format = mgcp_transcoding_net_downlink_format, }; static int given_configured_endpoint(int in_samples, int out_samples, -- 2.6.3 From holger at freyther.de Mon Mar 14 17:41:39 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 14 Mar 2016 18:41:39 +0100 Subject: [PATCH 3/3] mgcp: Remove the old MGCP based transcoding interface In-Reply-To: <1457977299-66630-1-git-send-email-holger@freyther.de> References: <1457977299-66630-1-git-send-email-holger@freyther.de> Message-ID: <1457977299-66630-3-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther Back in the day we worked around a field proven jitter buffer by transcoding AMR to AMR with the MTN4200 and by this fixing RTP timing as this device had: a.) A working and stable time (generating RTP every N ms) b.) A working jitter buffer The code has probably rotted, it never retried MGCP commands sent to the transcoder and it is not deployed either. Simplify the code by removing it. If we ever need it back we can use the new transcoding API to keep the state there. I think this code will not be missed but the PerformanceTechnology Hard- and Firmware was rather nice. --- openbsc/include/openbsc/mgcp.h | 7 -- openbsc/include/openbsc/mgcp_internal.h | 16 ---- openbsc/src/libmgcp/mgcp_network.c | 105 ---------------------- openbsc/src/libmgcp/mgcp_protocol.c | 141 ------------------------------ openbsc/src/libmgcp/mgcp_vty.c | 77 +++++----------- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 9 -- 6 files changed, 21 insertions(+), 334 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index a216547..dfa41a3 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -183,16 +183,10 @@ struct mgcp_config { struct in_addr bts_in; - /* transcoder handling */ - char *transcoder_ip; - struct in_addr transcoder_in; - int transcoder_remote_base; - struct osmo_wqueue gw_fd; struct mgcp_port_range bts_ports; struct mgcp_port_range net_ports; - struct mgcp_port_range transcoder_ports; int endp_dscp; int bts_force_ptime; @@ -244,7 +238,6 @@ int mgcp_vty_init(void); int mgcp_endpoints_allocate(struct mgcp_trunk_config *cfg); void mgcp_release_endp(struct mgcp_endpoint *endp); void mgcp_initialize_endp(struct mgcp_endpoint *endp); -int mgcp_reset_transcoder(struct mgcp_config *cfg); void mgcp_format_stats(struct mgcp_endpoint *endp, char *stats, size_t size); int mgcp_parse_stats(struct msgb *msg, uint32_t *ps, uint32_t *os, uint32_t *pr, uint32_t *_or, int *loss, uint32_t *jitter); diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 8fb8a45..dd195e0 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -145,7 +145,6 @@ struct mgcp_lco { enum mgcp_type { MGCP_RTP_DEFAULT = 0, - MGCP_RTP_TRANSCODED, MGCP_OSMUX_BSC, MGCP_OSMUX_BSC_NAT, }; @@ -179,13 +178,6 @@ struct mgcp_endpoint { struct mgcp_rtp_end bts_end; struct mgcp_rtp_end net_end; - /* - * For transcoding we will send from the local_port - * of trans_bts and it will arrive at trans_net from - * where we will forward it to the network. - */ - struct mgcp_rtp_end trans_bts; - struct mgcp_rtp_end trans_net; enum mgcp_type type; /* sequence bits */ @@ -268,16 +260,8 @@ struct mgcp_parse_data { int mgcp_send_dummy(struct mgcp_endpoint *endp); int mgcp_bind_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port); int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port); -int mgcp_bind_trans_bts_rtp_port(struct mgcp_endpoint *enp, int rtp_port); -int mgcp_bind_trans_net_rtp_port(struct mgcp_endpoint *enp, int rtp_port); int mgcp_free_rtp_port(struct mgcp_rtp_end *end); -/* For transcoding we need to manage an in and an output that are connected */ -static inline int endp_back_channel(int endpoint) -{ - return endpoint + 60; -} - struct mgcp_trunk_config *mgcp_trunk_alloc(struct mgcp_config *cfg, int index); struct mgcp_trunk_config *mgcp_trunk_num(struct mgcp_config *cfg, int index); diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index ed90d34..1eb87bb 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -553,33 +553,6 @@ static int forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf, int l (struct sockaddr *)&tap->forward, sizeof(tap->forward)); } -static int mgcp_send_transcoder(struct mgcp_rtp_end *end, - struct mgcp_config *cfg, int is_rtp, - const char *buf, int len) -{ - int rc; - int port; - struct sockaddr_in addr; - - port = is_rtp ? end->rtp_port : end->rtcp_port; - - addr.sin_family = AF_INET; - addr.sin_addr = cfg->transcoder_in; - addr.sin_port = port; - - rc = sendto(is_rtp ? - end->rtp.fd : - end->rtcp.fd, buf, len, 0, - (struct sockaddr *) &addr, sizeof(addr)); - - if (rc != len) - LOGP(DMGCP, LOGL_ERROR, - "Failed to send data to the transcoder: %s\n", - strerror(errno)); - - return rc; -} - int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, struct sockaddr_in *addr, char *buf, int rc) { @@ -688,7 +661,6 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) switch(endp->type) { case MGCP_RTP_DEFAULT: - case MGCP_RTP_TRANSCODED: if (endp->net_end.rtp_port != addr.sin_port && endp->net_end.rtcp_port != addr.sin_port) { LOGP(DMGCP, LOGL_ERROR, @@ -719,9 +691,6 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) case MGCP_RTP_DEFAULT: return mgcp_send(endp, MGCP_DEST_BTS, proto == MGCP_PROTO_RTP, &addr, buf, rc); - case MGCP_RTP_TRANSCODED: - return mgcp_send_transcoder(&endp->trans_net, endp->cfg, - proto == MGCP_PROTO_RTP, buf, rc); case MGCP_OSMUX_BSC_NAT: return osmux_xfrm_to_osmux(MGCP_DEST_BTS, buf, rc, endp); case MGCP_OSMUX_BSC: /* Should not happen */ @@ -811,9 +780,6 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) case MGCP_RTP_DEFAULT: return mgcp_send(endp, MGCP_DEST_NET, proto == MGCP_PROTO_RTP, &addr, buf, rc); - case MGCP_RTP_TRANSCODED: - return mgcp_send_transcoder(&endp->trans_bts, endp->cfg, - proto == MGCP_PROTO_RTP, buf, rc); case MGCP_OSMUX_BSC: /* OSMUX translation: BTS -> BSC */ return osmux_xfrm_to_osmux(MGCP_DEST_NET, buf, rc, endp); @@ -826,63 +792,6 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) return 0; } -static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_endp, - int dest, struct osmo_fd *fd) -{ - char buf[RTP_BUF_SIZE]; - struct sockaddr_in addr; - struct mgcp_config *cfg; - int rc, proto; - - cfg = _endp->cfg; - rc = receive_from(_endp, fd->fd, &addr, buf, sizeof(buf)); - if (rc <= 0) - return -1; - - proto = fd == &end->rtp ? MGCP_PROTO_RTP : MGCP_PROTO_RTCP; - - if (memcmp(&addr.sin_addr, &cfg->transcoder_in, sizeof(addr.sin_addr)) != 0) { - LOGP(DMGCP, LOGL_ERROR, - "Data not coming from transcoder dest: %d %s on 0x%x\n", - dest, inet_ntoa(addr.sin_addr), ENDPOINT_NUMBER(_endp)); - return -1; - } - - if (end->rtp_port != addr.sin_port && - end->rtcp_port != addr.sin_port) { - LOGP(DMGCP, LOGL_ERROR, - "Data from wrong transcoder dest %d source port %d on 0x%x\n", - dest, ntohs(addr.sin_port), ENDPOINT_NUMBER(_endp)); - return -1; - } - - /* throw away the dummy message */ - if (rc == 1 && buf[0] == MGCP_DUMMY_LOAD) { - LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from transcoder dest %d on 0x%x\n", - dest, ENDPOINT_NUMBER(_endp)); - return 0; - } - - end->packets += 1; - return mgcp_send(_endp, dest, proto == MGCP_PROTO_RTP, &addr, buf, rc); -} - -static int rtp_data_trans_net(struct osmo_fd *fd, unsigned int what) -{ - struct mgcp_endpoint *endp; - endp = (struct mgcp_endpoint *) fd->data; - - return rtp_data_transcoder(&endp->trans_net, endp, MGCP_DEST_NET, fd); -} - -static int rtp_data_trans_bts(struct osmo_fd *fd, unsigned int what) -{ - struct mgcp_endpoint *endp; - endp = (struct mgcp_endpoint *) fd->data; - - return rtp_data_transcoder(&endp->trans_bts, endp, MGCP_DEST_BTS, fd); -} - int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, int port) { struct sockaddr_in addr; @@ -998,20 +907,6 @@ int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port) mgcp_net_src_addr(endp), rtp_port); } -int mgcp_bind_trans_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port) -{ - return int_bind("trans-net", &endp->trans_net, - rtp_data_trans_net, endp, - endp->cfg->source_addr, rtp_port); -} - -int mgcp_bind_trans_bts_rtp_port(struct mgcp_endpoint *endp, int rtp_port) -{ - return int_bind("trans-bts", &endp->trans_bts, - rtp_data_trans_bts, endp, - endp->cfg->source_addr, rtp_port); -} - int mgcp_free_rtp_port(struct mgcp_rtp_end *end) { if (end->rtp.fd != -1) { diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 18a25bc..c136e31 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -59,9 +59,6 @@ static struct msgb *handle_modify_con(struct mgcp_parse_data *data); static struct msgb *handle_rsip(struct mgcp_parse_data *data); static struct msgb *handle_noti_req(struct mgcp_parse_data *data); -static void create_transcoder(struct mgcp_endpoint *endp); -static void delete_transcoder(struct mgcp_endpoint *endp); - static int setup_rtp_processing(struct mgcp_endpoint *endp); static int mgcp_analyze_header(struct mgcp_parse_data *parse, char *data); @@ -604,28 +601,6 @@ static int allocate_ports(struct mgcp_endpoint *endp) return -1; } - if (endp->cfg->transcoder_ip && endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) { - if (allocate_port(endp, &endp->trans_net, - &endp->cfg->transcoder_ports, - mgcp_bind_trans_net_rtp_port) != 0) { - mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->bts_end); - return -1; - } - - if (allocate_port(endp, &endp->trans_bts, - &endp->cfg->transcoder_ports, - mgcp_bind_trans_bts_rtp_port) != 0) { - mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->bts_end); - mgcp_rtp_end_reset(&endp->trans_net); - return -1; - } - - /* remember that we have set up transcoding */ - endp->type = MGCP_RTP_TRANSCODED; - } - return 0; } @@ -868,7 +843,6 @@ mgcp_header_done: break; case MGCP_POLICY_DEFER: /* stop processing */ - create_transcoder(endp); return NULL; break; case MGCP_POLICY_CONT: @@ -887,7 +861,6 @@ mgcp_header_done: send_dummy(endp); } - create_transcoder(endp); return create_response_with_sdp(endp, "CRCX", p->trans); error2: mgcp_release_endp(endp); @@ -1070,7 +1043,6 @@ static struct msgb *handle_delete_con(struct mgcp_parse_data *p) break; case MGCP_POLICY_DEFER: /* stop processing */ - delete_transcoder(endp); return NULL; break; case MGCP_POLICY_CONT: @@ -1086,7 +1058,6 @@ static struct msgb *handle_delete_con(struct mgcp_parse_data *p) /* save the statistics of the current call */ mgcp_format_stats(endp, stats, sizeof(stats)); - delete_transcoder(endp); mgcp_release_endp(endp); if (p->cfg->change_cb) p->cfg->change_cb(endp->tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX); @@ -1205,8 +1176,6 @@ struct mgcp_config *mgcp_config_alloc(void) cfg->source_addr = talloc_strdup(cfg, "0.0.0.0"); cfg->osmux_addr = talloc_strdup(cfg, "0.0.0.0"); - cfg->transcoder_remote_base = 4000; - cfg->bts_ports.base_port = RTP_PORT_DEFAULT; cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT; @@ -1328,8 +1297,6 @@ int mgcp_endpoints_allocate(struct mgcp_trunk_config *tcfg) tcfg->endpoints[i].tcfg = tcfg; mgcp_rtp_end_init(&tcfg->endpoints[i].net_end); mgcp_rtp_end_init(&tcfg->endpoints[i].bts_end); - mgcp_rtp_end_init(&tcfg->endpoints[i].trans_net); - mgcp_rtp_end_init(&tcfg->endpoints[i].trans_bts); } return 0; @@ -1351,8 +1318,6 @@ void mgcp_release_endp(struct mgcp_endpoint *endp) mgcp_rtp_end_reset(&endp->bts_end); mgcp_rtp_end_reset(&endp->net_end); - mgcp_rtp_end_reset(&endp->trans_net); - mgcp_rtp_end_reset(&endp->trans_bts); endp->type = MGCP_RTP_DEFAULT; memset(&endp->net_state, 0, sizeof(endp->net_state)); @@ -1374,65 +1339,6 @@ void mgcp_initialize_endp(struct mgcp_endpoint *endp) return mgcp_release_endp(endp); } -static int send_trans(struct mgcp_config *cfg, const char *buf, int len) -{ - struct sockaddr_in addr; - - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr = cfg->transcoder_in; - addr.sin_port = htons(2427); - return sendto(cfg->gw_fd.bfd.fd, buf, len, 0, - (struct sockaddr *) &addr, sizeof(addr)); -} - -static void send_msg(struct mgcp_endpoint *endp, int endpoint, int port, - const char *msg, const char *mode) -{ - char buf[2096]; - int len; - int nchars; - - /* hardcoded to AMR right now, we do not know the real type at this point */ - len = snprintf(buf, sizeof(buf), - "%s 42 %x at mgw MGCP 1.0\r\n" - "C: 4256\r\n" - "M: %s\r\n" - "\r\n", - msg, endpoint, mode); - - if (len < 0) - return; - - nchars = write_response_sdp(endp, buf + len, sizeof(buf) + len - 1, NULL); - if (nchars < 0) - return; - - len += nchars; - - buf[sizeof(buf) - 1] = '\0'; - - send_trans(endp->cfg, buf, len); -} - -static void send_dlcx(struct mgcp_endpoint *endp, int endpoint) -{ - char buf[2096]; - int len; - - len = snprintf(buf, sizeof(buf), - "DLCX 43 %x at mgw MGCP 1.0\r\n" - "C: 4256\r\n" - , endpoint); - - if (len < 0) - return; - - buf[sizeof(buf) - 1] = '\0'; - - send_trans(endp->cfg, buf, len); -} - static int send_agent(struct mgcp_config *cfg, const char *buf, int len) { return write(cfg->gw_fd.bfd.fd, buf, len); @@ -1486,53 +1392,6 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp) return rc; } -static void create_transcoder(struct mgcp_endpoint *endp) -{ - int port; - int in_endp = ENDPOINT_NUMBER(endp); - int out_endp = endp_back_channel(in_endp); - - if (endp->type != MGCP_RTP_TRANSCODED) - return; - - send_msg(endp, in_endp, endp->trans_bts.local_port, "CRCX", "sendrecv"); - send_msg(endp, in_endp, endp->trans_bts.local_port, "MDCX", "sendrecv"); - send_msg(endp, out_endp, endp->trans_net.local_port, "CRCX", "sendrecv"); - send_msg(endp, out_endp, endp->trans_net.local_port, "MDCX", "sendrecv"); - - port = rtp_calculate_port(in_endp, endp->cfg->transcoder_remote_base); - endp->trans_bts.rtp_port = htons(port); - endp->trans_bts.rtcp_port = htons(port + 1); - - port = rtp_calculate_port(out_endp, endp->cfg->transcoder_remote_base); - endp->trans_net.rtp_port = htons(port); - endp->trans_net.rtcp_port = htons(port + 1); -} - -static void delete_transcoder(struct mgcp_endpoint *endp) -{ - int in_endp = ENDPOINT_NUMBER(endp); - int out_endp = endp_back_channel(in_endp); - - if (endp->type != MGCP_RTP_TRANSCODED) - return; - - send_dlcx(endp, in_endp); - send_dlcx(endp, out_endp); -} - -int mgcp_reset_transcoder(struct mgcp_config *cfg) -{ - if (!cfg->transcoder_ip) - return 0; - - static const char mgcp_reset[] = { - "RSIP 1 13 at mgw MGCP 1.0\r\n" - }; - - return send_trans(cfg, mgcp_reset, sizeof mgcp_reset -1); -} - void mgcp_format_stats(struct mgcp_endpoint *endp, char *msg, size_t size) { uint32_t expected, jitter; diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index 13f66c5..5300ffc 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -128,17 +128,8 @@ static int config_write_mgcp(struct vty *vty) g_cfg->trunk.no_audio_transcoding ? "no " : "", VTY_NEWLINE); if (g_cfg->call_agent_addr) vty_out(vty, " call-agent ip %s%s", g_cfg->call_agent_addr, VTY_NEWLINE); - if (g_cfg->transcoder_ip) - vty_out(vty, " transcoder-mgw %s%s", g_cfg->transcoder_ip, VTY_NEWLINE); - - if (g_cfg->transcoder_ports.mode == PORT_ALLOC_STATIC) - vty_out(vty, " rtp transcoder-base %u%s", g_cfg->transcoder_ports.base_port, VTY_NEWLINE); - else - vty_out(vty, " rtp transcoder-range %u %u%s", - g_cfg->transcoder_ports.range_start, g_cfg->transcoder_ports.range_end, VTY_NEWLINE); if (g_cfg->bts_force_ptime > 0) vty_out(vty, " rtp force-ptime %d%s", g_cfg->bts_force_ptime, VTY_NEWLINE); - vty_out(vty, " transcoder-remote-base %u%s", g_cfg->transcoder_remote_base, VTY_NEWLINE); switch (g_cfg->osmux) { case OSMUX_USAGE_ON: @@ -209,13 +200,12 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int verbo struct mgcp_endpoint *endp = &cfg->endpoints[i]; vty_out(vty, " Endpoint 0x%.2x: CI: %d net: %u/%u bts: %u/%u on %s " - "traffic received bts: %u remote: %u transcoder: %u/%u%s", + "traffic received bts: %u remote: %u%s", i, endp->ci, ntohs(endp->net_end.rtp_port), ntohs(endp->net_end.rtcp_port), ntohs(endp->bts_end.rtp_port), ntohs(endp->bts_end.rtcp_port), inet_ntoa(endp->bts_end.addr), endp->bts_end.packets, endp->net_end.packets, - endp->trans_net.packets, endp->trans_bts.packets, VTY_NEWLINE); if (verbose && endp->allocated) { @@ -378,24 +368,26 @@ ALIAS_DEPRECATED(cfg_mgcp_rtp_bts_base_port, cfg_mgcp_rtp_base_port_cmd, "rtp base <0-65534>", RTP_STR BTS_START_STR UDP_PORT_STR) -DEFUN(cfg_mgcp_rtp_transcoder_range, +DEFUN_DEPRECATED(cfg_mgcp_rtp_transcoder_range, cfg_mgcp_rtp_transcoder_range_cmd, "rtp transcoder-range <0-65534> <0-65534>", RTP_STR "Range of ports to use for the Transcoder\n" RANGE_START_STR RANGE_END_STR) { - parse_range(&g_cfg->transcoder_ports, argv); - return CMD_SUCCESS; + vty_out(vty, + "%% MGCP RTP transcoding has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } -DEFUN(cfg_mgcp_rtp_transcoder_base, +DEFUN_DEPRECATED(cfg_mgcp_rtp_transcoder_base, cfg_mgcp_rtp_transcoder_base_cmd, "rtp transcoder-base <0-65534>", RTP_STR "First UDP port allocated for the Transcoder side\n" UDP_PORT_STR) { - parse_base(&g_cfg->transcoder_ports, argv); - return CMD_SUCCESS; + vty_out(vty, + "%% MGCP RTP transcoding has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } DEFUN(cfg_mgcp_rtp_bts_bind_ip, @@ -724,39 +716,35 @@ ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old, "IPv4 Address of the callagent\n") -DEFUN(cfg_mgcp_transcoder, +DEFUN_DEPRECATED(cfg_mgcp_transcoder, cfg_mgcp_transcoder_cmd, "transcoder-mgw A.B.C.D", "Use a MGW to detranscoder RTP\n" "The IP address of the MGW") { - bsc_replace_string(g_cfg, &g_cfg->transcoder_ip, argv[0]); - inet_aton(g_cfg->transcoder_ip, &g_cfg->transcoder_in); - - return CMD_SUCCESS; + vty_out(vty, + "%% MGCP RTP transcoding has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } -DEFUN(cfg_mgcp_no_transcoder, +DEFUN_DEPRECATED(cfg_mgcp_no_transcoder, cfg_mgcp_no_transcoder_cmd, "no transcoder-mgw", NO_STR "Disable the transcoding\n") { - if (g_cfg->transcoder_ip) { - LOGP(DMGCP, LOGL_NOTICE, "Disabling transcoding on future calls.\n"); - talloc_free(g_cfg->transcoder_ip); - g_cfg->transcoder_ip = NULL; - } - - return CMD_SUCCESS; + vty_out(vty, + "%% MGCP RTP transcoding has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } -DEFUN(cfg_mgcp_transcoder_remote_base, +DEFUN_DEPRECATED(cfg_mgcp_transcoder_remote_base, cfg_mgcp_transcoder_remote_base_cmd, "transcoder-remote-base <0-65534>", "Set the base port for the transcoder\n" "The RTP base port on the transcoder") { - g_cfg->transcoder_remote_base = atoi(argv[0]); - return CMD_SUCCESS; + vty_out(vty, + "%% MGCP RTP transcoding has been removed.%s", VTY_NEWLINE); + return CMD_WARNING; } DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd, @@ -1466,29 +1454,6 @@ static int allocate_trunk(struct mgcp_trunk_config *trunk) } endp->net_end.local_alloc = PORT_ALLOC_STATIC; } - - if (trunk->trunk_type == MGCP_TRUNK_VIRTUAL && - cfg->transcoder_ip && cfg->transcoder_ports.mode == PORT_ALLOC_STATIC) { - int rtp_port; - - /* network side */ - rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), - cfg->transcoder_ports.base_port); - if (mgcp_bind_trans_net_rtp_port(endp, rtp_port) != 0) { - LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port); - return -1; - } - endp->trans_net.local_alloc = PORT_ALLOC_STATIC; - - /* bts side */ - rtp_port = rtp_calculate_port(endp_back_channel(ENDPOINT_NUMBER(endp)), - cfg->transcoder_ports.base_port); - if (mgcp_bind_trans_bts_rtp_port(endp, rtp_port) != 0) { - LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port); - return -1; - } - endp->trans_bts.local_alloc = PORT_ALLOC_STATIC; - } } return 0; diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index 9fd9967..67149b8 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -1116,15 +1116,6 @@ int bsc_mgcp_nat_init(struct bsc_nat *nat) return -1; } - if (mgcp_reset_transcoder(cfg) < 0) { - LOGP(DMGCP, LOGL_ERROR, "Failed to send packet to the transcoder.\n"); - talloc_free(nat->bsc_endpoints); - nat->bsc_endpoints = NULL; - close(cfg->gw_fd.bfd.fd); - cfg->gw_fd.bfd.fd = -1; - return -1; - } - return 0; } -- 2.6.3 From laforge at gnumonks.org Mon Mar 14 17:36:59 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 14 Mar 2016 18:36:59 +0100 Subject: [PATCH] Update configuration examples In-Reply-To: <56E6EF4D.5070403@sysmocom.de> References: <1457713705-5940-1-git-send-email-msuraev@sysmocom.de> <20160314151031.GB22557@nataraja> <56E6EF4D.5070403@sysmocom.de> Message-ID: <20160314173659.GH22557@nataraja> On Mon, Mar 14, 2016 at 06:05:17PM +0100, Max wrote: > Should be fixed in attached patch. was not in format understandable by 'git am', so now the author info is lost. Applied. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Mon Mar 14 18:06:43 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 14 Mar 2016 19:06:43 +0100 Subject: [PATCH 1/2] Improve BSSGP debug output In-Reply-To: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> References: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> Message-ID: <023DF540-01D2-4195-80F0-A46DA2DC5932@freyther.de> > On 14 Mar 2016, at 18:27, msuraev at sysmocom.de wrote: > > From: Max > > Print string representation of Cause IE and PDU type in addition to > numerical value. and this has no test output change? holger From laforge at gnumonks.org Mon Mar 14 18:04:07 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 14 Mar 2016 19:04:07 +0100 Subject: [PATCH 1/2] Improve BSSGP debug output In-Reply-To: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> References: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160314180407.GL22557@nataraja> Hi Max, On Mon, Mar 14, 2016 at 06:27:54PM +0100, msuraev at sysmocom.de wrote: > - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x only exists " > - "in DL\n", bctx->bvci, pdu_type); > + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) only exists " > + "in DL\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); Sorry, but did you read my last feedback? There are still lots of places where you print the 0x%02x _and_ the value_string... -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Mon Mar 14 18:06:37 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 14 Mar 2016 19:06:37 +0100 Subject: [PATCH] Add function to add bits from array to bitvec In-Reply-To: <1457974852-24878-1-git-send-email-msuraev@sysmocom.de> References: <1457974852-24878-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160314180637.GM22557@nataraja> Hi Max, > +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, unsigned int array_len, > + * \param[in] estimate indicates whether to return number of bits required instead of actually changing bv > + * \returns number of bits necessary to add given PCIDs if estimate is true, 0 otherwise > +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, unsigned int array_len, > +static inline void test_array_item(unsigned t, struct bitvec *b, unsigned int n, uint32_t *array, unsigned int p) > + printf("\nbits: %u, est: %u, real: %u, x: %u, y: %u\n", t, i, b->cur_bit, x, y); you often seem to submit code with line lengths in excess of 80 characters. Please configure your editor accordingly and save us some time and review cycles just for cosmetic issues. Thanks! -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Mon Mar 14 19:46:31 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Tue, 15 Mar 2016 01:46:31 +0600 Subject: libosmocore: gsm48_mi_to_string() TMSI parsing Message-ID: Hello all! I just quickly looked at the gsm48_mi_to_string() method in gsm48.c. I found that it is used in several projects like OsmocomBB and OpenBSC, but it seems a bit strange to me that the TMSI represented in decimal... > ... > uint32_t tmsi; > ... > return snprintf(string, str_len, "%u", tmsi); > ... Can we move to use a hex representation instead of decimal? And why if not? > ... > uint32_t tmsi; > ... > return snprintf(string, str_len, "%x", tmsi); > ... ? ?????????? ???????????, ??????? ?????. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nhofmeyr at sysmocom.de Mon Mar 14 22:52:39 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 14 Mar 2016 23:52:39 +0100 Subject: [PATCH] gsm0480.c: squelch compiler warning due to const (caused recently) Message-ID: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> The introduction of gsm48_hdr_pdisc() caused a new compiler warning. In gsm0480_decode_*(), the gsm48_hdr is const, which we can safely cast away to avoid the warning. --- src/gsm/gsm0480.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c index 8963b78..bb47cc6 100644 --- a/src/gsm/gsm0480.c +++ b/src/gsm/gsm0480.c @@ -220,7 +220,7 @@ int gsm0480_decode_ussd_request(const struct gsm48_hdr *hdr, uint16_t len, return 0; } - if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) { + if (gsm48_hdr_pdisc((struct gsm48_hdr*)hdr) == GSM48_PDISC_NC_SS) { req->transaction_id = hdr->proto_discr & 0x70; ss.transaction_id = req->transaction_id; @@ -254,7 +254,7 @@ int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len, return 0; } - if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) { + if (gsm48_hdr_pdisc((struct gsm48_hdr*)hdr) == GSM48_PDISC_NC_SS) { req->transaction_id = hdr->proto_discr & 0x70; rc = parse_ss(hdr, len, req); } -- 2.1.4 From Bindhu.Anjaneya at radisys.com Tue Mar 15 11:33:01 2016 From: Bindhu.Anjaneya at radisys.com (Bindhu Anjaneya) Date: Tue, 15 Mar 2016 11:33:01 +0000 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: <20160314150932.GA22557@nataraja> References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> <20160314150932.GA22557@nataraja> Message-ID: Hi, >The better way to do this, from my point-of-view, is to follow what we have done for the Osmo-Iuh code (osmo-hnbgw, and IuCS/PS for >OsmoCSCN/OsmoSGSN): > >* use the SUA support of libosmo-sccp, including its SCCP-User-SAP > that it provides towards applications > >This way, OsmoBSC uses the most simple SIGTRAN variant SUA towards an external signalling gateway, and doesn't have to bother with the more complex stacks like M3UA, M2UA, M2PA (all including SCCP). Though the above approach is the simplest way, this implementation will not be in compliance with 3GPP specification, this would also introduce a hop between BSC and MSC on the A-Interface. So my suggestion is for Osmo-bsc to be 3GPP compliance, the SIGTRAN stack BSSAP/SCCP/M3UA/SCTP/IP need to be implemented in Osmo-bsc. To achieve this:- Existing SCCP - need to be upgraded if needed M3UA - need to be developed may be as a separate library We can introduce a compile time flag if we need to differentiate between the support for SCCP/M3UA and SUA. Let me know your inputs Regards, Bindhu -----Original Message----- From: Harald Welte [mailto:laforge at gnumonks.org] Sent: Monday, March 14, 2016 8:40 PM To: Bindhu Anjaneya Cc: Holger Freyther ; openbsc at lists.osmocom.org Subject: Re: Support of AoverIP (AOIP) in osmo-bsc Hi Bindhu, On Mon, Mar 14, 2016 at 01:20:11PM +0000, Bindhu Anjaneya wrote: > As part of design consideration, we are analyzing Erlang osmo-ss7 > SIGTRAN Stack(SCCP,M3UA,SCTP) to integrate with osmo-bsc (bsc only > mode). > We are also analyzing the option of retaining the currently used > libosmo-SCCP, kernel SCTP and use the M3UA from the osmo-ss7. in terms of the encapsulation of the A-over-IP, I would suggest to not rely on the Erlang implementations that we have. This would import a dependency on a rather large code base for a limited functionality, and it doesn't really resolve the question on how to interface the osmo-ss7 erlang code from C code such as OsmoBSC. The better way to do this, from my point-of-view, is to follow what we have done for the Osmo-Iuh code (osmo-hnbgw, and IuCS/PS for OsmoCSCN/OsmoSGSN): * use the SUA support of libosmo-sccp, including its SCCP-User-SAP that it provides towards applications This way, OsmoBSC uses the most simple SIGTRAN variant SUA towards an external signalling gateway, and doesn't have to bother with the more complex stacks like M3UA, M2UA, M2PA (all including SCCP). In this way, * osmo-bsc has a clean interface, and re-uses the code from the Iu related projects * you can use osmo-ss7 or any other signalling gateway (FOSS or proprietary) to move towards M3UA or any other transport stack. Let me know what you think about the above-mentioned approach. Please note the SUA code in libosmo-sccp is also still limited at this point, in a sense that it doesn't implement the ASP-Management state machines yet. This would still have to be added. If it is added to libosmo-sccp, then all useres, whether IuCS, IuPS or AoIP will benefit from that. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Tue Mar 15 12:28:10 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 15 Mar 2016 13:28:10 +0100 Subject: [PATCH] gsm48: factor out MCC+MNC BCD parsing for re-use in UMTS Message-ID: <1458044890-3541-1-git-send-email-nhofmeyr@sysmocom.de> For 3G, I need a BCD composer/parser similar to gsm48_generate_lai()/ gsm48_decode_lai(). Those functions also handle a trivial extra member (lac) which I don't need in this way for 3G. So create new functions to take on the MCC+MNC BCD handling and call those from gsm48_generate_lai() and gsm48_decode_lai(). In this way, the 3G code in openbsc can use only the BCD functionality without code duplication. --- include/osmocom/gsm/gsm48.h | 3 +++ src/gsm/gsm48.c | 55 ++++++++++++++++++++++++++++----------------- src/gsm/libosmogsm.map | 2 ++ 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h index 74ac52c..d6e58c2 100644 --- a/include/osmocom/gsm/gsm48.h +++ b/include/osmocom/gsm/gsm48.h @@ -39,3 +39,6 @@ void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf); int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid); int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc); + +void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc); +void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc); diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index 60937cb..d0a2286 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -278,25 +278,50 @@ static void to_bcd(uint8_t *bcd, uint16_t val) val = val / 10; } -void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc, - uint16_t mnc, uint16_t lac) +/* Convert given mcc and mnc to BCD and write to *bcd_dst, which must be an + * allocated buffer of (at least) 3 bytes length. */ +void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc) { uint8_t bcd[3]; to_bcd(bcd, mcc); - lai48->digits[0] = bcd[0] | (bcd[1] << 4); - lai48->digits[1] = bcd[2]; + bcd_dst[0] = bcd[0] | (bcd[1] << 4); + bcd_dst[1] = bcd[2]; to_bcd(bcd, mnc); /* FIXME: do we need three-digit MNC? See Table 10.5.3 */ if (mnc > 99) { - lai48->digits[1] |= bcd[2] << 4; - lai48->digits[2] = bcd[0] | (bcd[1] << 4); + bcd_dst[1] |= bcd[2] << 4; + bcd_dst[2] = bcd[0] | (bcd[1] << 4); + } else { + bcd_dst[1] |= 0xf << 4; + bcd_dst[2] = bcd[1] | (bcd[2] << 4); + } +} + +/* Convert given 3-byte BCD buffer to integers and write results to *mcc and + * *mnc. The first three BCD digits result in the MCC and the remaining ones in + * the MNC. */ +void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc) +{ + *mcc = (bcd_src[0] & 0x0f) * 100 + + (bcd_src[0] >> 4) * 10 + + (bcd_src[1] & 0x0f); + + if ((bcd_src[1] & 0xf0) == 0xf0) { + *mnc = (bcd_src[2] & 0x0f) * 10 + + (bcd_src[2] >> 4); } else { - lai48->digits[1] |= 0xf << 4; - lai48->digits[2] = bcd[1] | (bcd[2] << 4); + *mnc = (bcd_src[2] & 0x0f) * 100 + + (bcd_src[2] >> 4) * 10 + + (bcd_src[1] >> 4); } +} +void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc, + uint16_t mnc, uint16_t lac) +{ + gsm48_mcc_mnc_to_bcd(&lai48->digits[0], mcc, mnc); lai48->lac = htons(lac); } @@ -304,20 +329,8 @@ void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc, int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc, uint16_t *mnc, uint16_t *lac) { - *mcc = (lai->digits[0] & 0x0f) * 100 - + (lai->digits[0] >> 4) * 10 - + (lai->digits[1] & 0x0f); - - if ((lai->digits[1] & 0xf0) == 0xf0) { - *mnc = (lai->digits[2] & 0x0f) * 10 - + (lai->digits[2] >> 4); - } else { - *mnc = (lai->digits[2] & 0x0f) * 100 - + (lai->digits[2] >> 4) * 10 - + (lai->digits[1] >> 4); - } + gsm48_mcc_mnc_from_bcd(&lai->digits[0], mcc, mnc); *lac = ntohs(lai->lac); - return 0; } diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 7eebe7f..0aeefbb 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -138,6 +138,8 @@ gsm48_number_of_paging_subchannels; gsm48_parse_ra; gsm48_rr_att_tlvdef; gsm48_mi_type_name; +gsm48_mcc_mnc_to_bcd; +gsm48_mcc_mnc_from_bcd; gsm_7bit_decode; gsm_7bit_decode_ussd; -- 2.1.4 From msuraev at sysmocom.de Tue Mar 15 13:51:08 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 15 Mar 2016 14:51:08 +0100 Subject: [PATCH] Add function to add bits from array to bitvec Message-ID: <1458049868-14129-1-git-send-email-msuraev@sysmocom.de> From: Max Add function which adds specified number of bits from each element of array to the bit vector prefixing each addition with one and finishing entire sequence with adding 0. This is very common patter for various repetitive data structures described with CSN.1 in 3GPP standards. Corresponding test vectors and doxygen headers are added too. --- include/osmocom/core/bitvec.h | 3 +++ src/bitvec.c | 40 ++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.c | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.ok | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+) diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 5314cf2..a49d178 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -91,5 +91,8 @@ void bitvec_zero(struct bitvec *bv); unsigned bitvec_rl(const struct bitvec *bv, bool b); void bitvec_shiftl(struct bitvec *bv, unsigned int n); int16_t bitvec_get_int16_msb(const struct bitvec *bv, unsigned int num_bits); +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, + unsigned int array_len, bool estimate, + unsigned int num_bits); /*! @} */ diff --git a/src/bitvec.c b/src/bitvec.c index 00ae150..7cd2f06 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -570,4 +570,44 @@ void bitvec_shiftl(struct bitvec *bv, unsigned n) bv->cur_bit -= n; } +/*! \brief Add given array to bitvec + * \param[in,out] bv bit vector to work with + * \param[in] array elements to be added + * \param[in] array_len length of array + * \param[in] estimate indicates whether to return number of bits required + * instead of actually changing bv + * \param[in] num_bits number of bits to consider in each element of array + * \returns number of bits necessary to add given PCIDs if estimate is true, + * 0 otherwise + * + * N. B: no length checks are performed on bv - it's callee's job to ensure + * enough space is available - for example by calling with estimate = true first. + * + * Useful for common pattern in CSN.1 spec which looks like: + * { 1 < XXX : bit (num_bits) > } ** 0 + * which means repeat any times (between 0 and infinity), + * start each repetition with 1, mark end of repetitions with 0 bit + * see app. note in 3GPP TS 24.007 ? B.2.1 Rule A2 + */ +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, + unsigned int array_len, bool estimate, + unsigned int num_bits) +{ + unsigned i, bits = 1; /* account for stop bit */ + for (i = 0; i < array_len; i++) { + if (estimate) { + bits += (1 + num_bits); + } else { + bitvec_set_bit(bv, 1); + bitvec_set_uint(bv, array[i], num_bits); + } + } + + if (estimate) + return bits; + + bitvec_set_bit(bv, 0); /* stop bit - end of the sequence */ + return 0; +} + /*! @} */ diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c index 76d6773..a98a91c 100644 --- a/tests/bitvec/bitvec_test.c +++ b/tests/bitvec/bitvec_test.c @@ -132,6 +132,43 @@ static void test_unhex(const char *hex) printf("%s\n", hex); } +static inline void test_array_item(unsigned t, struct bitvec *b, unsigned int n, + uint32_t *array, unsigned int p) +{ + unsigned int i, x, y; + bitvec_zero(b); + x = b->cur_bit; + i = bitvec_add_array(b, array, n, true, t); + y = b->cur_bit; + bitvec_add_array(b, array, n, false, t); + printf("\nbits: %u, est: %u, real: %u, x: %u, y: %u\n", + t, i, b->cur_bit, x, y); + for (i = 0; i < p; i++) { + printf(OSMO_BIT_SPEC " ", OSMO_BIT_PRINT(b->data[i])); + if (0 == (i + 1) % 15) + printf("\n"); + } +} + +static void test_array() +{ + struct bitvec b; + uint8_t d[4096]; + b.data = d; + b.data_len = sizeof(d); + + unsigned int i, n = 64; + uint32_t array[n]; + for (i = 0; i < n; i++) { + array[i] = i * i * i + i; + printf("0x%x ", array[i]); + } + + test_array_item(3, &b, n, array, n); + test_array_item(9, &b, n, array, n * 2); + test_array_item(17, &b, n, array, n * 3); +} + int main(int argc, char **argv) { struct bitvec bv; @@ -204,5 +241,11 @@ int main(int argc, char **argv) test_unhex("DEADFACE000000000000000000000000000000BEEFFEED"); test_unhex("FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); + printf("arrr...\n"); + + test_array(); + + printf("\nbitvec ok.\n"); + return 0; } diff --git a/tests/bitvec/bitvec_test.ok b/tests/bitvec/bitvec_test.ok index 1c993d3..e256108 100644 --- a/tests/bitvec/bitvec_test.ok +++ b/tests/bitvec/bitvec_test.ok @@ -134,3 +134,36 @@ DEADFACE000000000000000000000000000000BEEFFEED 0 -=> cur_bit=512 fffffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +arrr... +0x0 0x2 0xa 0x1e 0x44 0x82 0xde 0x15e 0x208 0x2e2 0x3f2 0x53e 0x6cc 0x8a2 0xac6 0xd3e 0x1010 0x1342 0x16da 0x1ade 0x1f54 0x2442 0x29ae 0x2f9e 0x3618 0x3d22 0x44c2 0x4cfe 0x55dc 0x5f62 0x6996 0x747e 0x8020 0x8c82 0x99aa 0xa79e 0xb664 0xc602 0xd67e 0xe7de 0xfa28 0x10d62 0x12192 0x136be 0x14cec 0x16422 0x17c66 0x195be 0x1b030 0x1cbc2 0x1e87a 0x2065e 0x22574 0x245c2 0x2674e 0x28a1e 0x2ae38 0x2d3a2 0x2fa62 0x3227e 0x34bfc 0x376e2 0x3a336 0x3d0fe +bits: 3, est: 257, real: 257, x: 0, y: 0 +1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. +111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. +11..1.1. 111.111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ +bits: 9, est: 641, real: 641, x: 0, y: 0 +1....... ..1..... ..1.1... ..1.1.1. ...1111. 1..1...1 ..1.1... ..1.1.11 .1111.11 .1.1111. 1.....1. ..1.111. ..1.1111 11..1.11 ..11111. +1.11..11 ..1.1.1. ..1.1.11 ...11.11 ..11111. 1....1.. ..11.1.. ..1.1.11 .11.1.1. 11.1111. 11.1.1.1 ..1..1.. ..1.111. 1.111.11 1..1111. +1....11. ..11..1. ..1.1.11 ....1.1. 1111111. 1111.111 ..11.11. ..1.111. .1.11.1. .111111. 1...1... ..1.1... ..1.111. 1.1.1.11 1..1111. +1..11..1 ..1..... ..1.1..1 11111.11 11.1111. 1...1.1. ..11.11. ..1.111. .1..1.1. 1.11111. 1.111.11 ..1...1. ..1.1..1 1..11.11 1.11111. +1...11.. ..1111.. ..1.1..1 111.1.1. .1.1111. 11.111.1 ..1111.. ..1.11.1 ..111.1. ...1111. 1...111. ..111.1. ..1.1..1 1...1.1. .111111. +11111111 ..1.111. ..1.11.. 11.11.1. 1111111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ +bits: 17, est: 1153, real: 1153, x: 0, y: 0 +1....... ........ ..1..... ........ ..1.1... ........ ..1.1.1. ........ ...1111. 1....... ...1...1 ..1..... ....1... ..1.1... ......11 +.1111.1. .......1 .1.1111. 1....... 1.....1. ..1..... ..1.111. ..1.1... ....1111 11..1.1. .....1.1 ..11111. 1......1 1.11..11 ..1..... +1...1.1. ..1.1... ..1.1.11 ...11.1. ....11.1 ..11111. 1....1.. .....1.. ..1....1 ..11.1.. ..1.1... .1.11.11 .11.1.1. ...11.1. 11.1111. +1....111 11.1.1.1 ..1...1. .1...1.. ..1.1... 1.1..11. 1.111.1. ..1.1111 1..1111. 1...11.1 1....11. ..1...11 11.1..1. ..1.1..1 ...1..11 +....1.1. .1..11.. 1111111. 1..1.1.1 .111.111 ..1..1.1 1111.11. ..1.1..1 1.1..11. .1.11.1. .111.1.. .111111. 1.1..... ....1... ..1.1... +11..1... ..1.1.1. .11..11. 1.1.1.1. 1.1..111 1..1111. 1.1.11.1 1..11..1 ..1.11.. .11..... ..1.1.11 .1.11..1 11111.1. 111..111 11.1111. +1.11111. 1...1.1. ..11.... 11.1.11. ..1.11.. 1....11. .1..1.11 ..11.11. 1.11111. 11.1..11 ..111.11 ..11.11. .1....1. ..1.11.1 1111...1 +1..11.11 1..1.1.1 1.11111. 111.11.. ....11.. ..1111.. 1.1111.. ..1.1111 1.1....1 111.1.1. .....11. .1.1111. 1...1..1 .1.111.1 ..1..1.. +.1.111.. ..1.1..1 1..111.1 ..111.1. 1...1.1. ...1111. 1.1.1.11 1...111. ..1.11.1 ..111.1. ..1.1.11 111.1..1 1...1.11 ..1...1. .111111. +11.1..1. 11111111 ..11.111 .11.111. ..1.111. 1...11.. 11.11.11 11.1.... 1111111. ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +bitvec ok. -- 2.7.3 From msuraev at sysmocom.de Tue Mar 15 13:54:16 2016 From: msuraev at sysmocom.de (Max) Date: Tue, 15 Mar 2016 14:54:16 +0100 Subject: [PATCH 1/2] Improve BSSGP debug output In-Reply-To: <023DF540-01D2-4195-80F0-A46DA2DC5932@freyther.de> References: <1457976475-8357-1-git-send-email-msuraev@sysmocom.de> <023DF540-01D2-4195-80F0-A46DA2DC5932@freyther.de> Message-ID: <56E81408.30106@sysmocom.de> The "make check" passes just fine in libosmocore so I think it's not used by tests. On 03/14/2016 07:06 PM, Holger Freyther wrote: >> On 14 Mar 2016, at 18:27, msuraev at sysmocom.de wrote: >> >> From: Max >> >> Print string representation of Cause IE and PDU type in addition to >> numerical value. > and this has no test output change? > > holger > -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From laforge at gnumonks.org Tue Mar 15 13:57:54 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 15 Mar 2016 14:57:54 +0100 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> <20160314150932.GA22557@nataraja> Message-ID: <20160315135754.GC15482@nataraja> Hi Bindhu, On Tue, Mar 15, 2016 at 11:33:01AM +0000, Bindhu Anjaneya wrote: > Though the above approach is the simplest way, this implementation > will not be in compliance with 3GPP specification, this would also > introduce a hop between BSC and MSC on the A-Interface. I don't think the extra hop would be a problem. It reduces the implementation complexity and a SUA-capable BSC is an initial, functional implementation that could already be deployed. Real M3UA support could be a second, incremental step at a later point. We prefer to do development in smaller, more easily digestable chunks rather than having a too large scope for a task from the beginnign. Also, on the BSSAP/BSSMAP level, the A interface exposed by OsmoBSC is also limited in many ways. It only implements Intra-BSC hand-overs, and no Inter-BSC hand-overs at that point. With a limited set of resources available, I would always rather spend the resources on making the BSC and BSSAP/BSSMAP more complete, than spend time on a new M3UA implementation - which doesn't add new functionality, as an existing external signalling gateway could do the SUA-M3UA translation with no R&D involved. > So my suggestion is for Osmo-bsc to be 3GPP compliance, the SIGTRAN > stack BSSAP/SCCP/M3UA/SCTP/IP need to be implemented in Osmo-bsc. > To achieve this:- > Existing SCCP - need to be upgraded if needed It will definitely need to be, as there is no code for connection-oriented SCCP at all. libosmo-sccp only contans code for encoding/decoding some SCCP frames. > M3UA - need to be developed may be as a separate library should be part of libosmo-netif, as is the current SUA code. The applications should all simply use the sccp-user-sap that we already offer and use from the IuCS/IuPS side, and not worry about the underlying protocol stack. This way we ensure that later on, any added M3UA or other SIGTRAN protocol stack will not require modifications to the applications on top. > We can introduce a compile time flag if we need to differentiate > between the support for SCCP/M3UA and SUA. We don't like that. When supporting multiple protocol stacks, we introduce one common/shared interface abstraction and we switch at run-time based on configuration. For example, osmo-gbproxy supports NS-over-IP as well as NS-over-FR-over-GRE as two alternative stacks. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From Bindhu.Anjaneya at radisys.com Wed Mar 16 08:16:44 2016 From: Bindhu.Anjaneya at radisys.com (Bindhu Anjaneya) Date: Wed, 16 Mar 2016 08:16:44 +0000 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: <20160315135754.GC15482@nataraja> References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> <20160314150932.GA22557@nataraja> <20160315135754.GC15482@nataraja> Message-ID: Hi Harald, > With a limited set of resources available, I would always rather spend the resources on making the BSC and BSSAP/BSSMAP more complete, than spend time on a new M3UA implementation - which doesn't add >new functionality, as an existing external signalling gateway could do the SUA-M3UA translation with no R&D involved. We went through the OsmoSS7 Erlang code base and the webpage " https://projects.osmocom.org/news/30", we see no activity done on osmo-ss7 for 3 years. Considering the use of osmo-ss7 as the signaling gateway for SUA to SCCP/M3UA translation, we have following concerns: a. Is osmo-ss7 compliant to latest specifications of SCCP and M3UA? b. Does osmo-ss7 implement the complete functionality of the signaling gateway. c. Is osmo-ss7 inter-op tested with 3rd party 3GPP compliant MSC and osmo-BSC. d. After upgrading SUA and the BSSAP, can the osmo-bsc be tested with 3rd party MSC by using the osmo-ss7 as signaling gateway? Do you see some changes on OsmoSS7 codebase? e. If osmo-ss7 does the complete functionality of the signaling gateway that is translation from SUA to SCCP/M3UA then why to upgrade the SCCP and implement M3UA in osmo-bsc even in future. Regards, Bindhu -----Original Message----- From: OpenBSC [mailto:openbsc-bounces at lists.osmocom.org] On Behalf Of Harald Welte Sent: Tuesday, March 15, 2016 7:28 PM To: Bindhu Anjaneya Cc: openbsc at lists.osmocom.org Subject: Re: Support of AoverIP (AOIP) in osmo-bsc Hi Bindhu, On Tue, Mar 15, 2016 at 11:33:01AM +0000, Bindhu Anjaneya wrote: > Though the above approach is the simplest way, this implementation > will not be in compliance with 3GPP specification, this would also > introduce a hop between BSC and MSC on the A-Interface. I don't think the extra hop would be a problem. It reduces the implementation complexity and a SUA-capable BSC is an initial, functional implementation that could already be deployed. Real M3UA support could be a second, incremental step at a later point. We prefer to do development in smaller, more easily digestable chunks rather than having a too large scope for a task from the beginnign. Also, on the BSSAP/BSSMAP level, the A interface exposed by OsmoBSC is also limited in many ways. It only implements Intra-BSC hand-overs, and no Inter-BSC hand-overs at that point. With a limited set of resources available, I would always rather spend the resources on making the BSC and BSSAP/BSSMAP more complete, than spend time on a new M3UA implementation - which doesn't add new functionality, as an existing external signalling gateway could do the SUA-M3UA translation with no R&D involved. > So my suggestion is for Osmo-bsc to be 3GPP compliance, the SIGTRAN > stack BSSAP/SCCP/M3UA/SCTP/IP need to be implemented in Osmo-bsc. > To achieve this:- > Existing SCCP - need to be upgraded if needed It will definitely need to be, as there is no code for connection-oriented SCCP at all. libosmo-sccp only contans code for encoding/decoding some SCCP frames. > M3UA - need to be developed may be as a separate library should be part of libosmo-netif, as is the current SUA code. The applications should all simply use the sccp-user-sap that we already offer and use from the IuCS/IuPS side, and not worry about the underlying protocol stack. This way we ensure that later on, any added M3UA or other SIGTRAN protocol stack will not require modifications to the applications on top. > We can introduce a compile time flag if we need to differentiate > between the support for SCCP/M3UA and SUA. We don't like that. When supporting multiple protocol stacks, we introduce one common/shared interface abstraction and we switch at run-time based on configuration. For example, osmo-gbproxy supports NS-over-IP as well as NS-over-FR-over-GRE as two alternative stacks. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed Mar 16 09:51:20 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 10:51:20 +0100 Subject: Support of AoverIP (AOIP) in osmo-bsc In-Reply-To: References: <6A676B38-7437-4D1E-BA8C-B6BEEB185C37@freyther.de> <20160314150932.GA22557@nataraja> <20160315135754.GC15482@nataraja> Message-ID: <20160316095120.GJ15482@nataraja> Hi Bindhu, On Wed, Mar 16, 2016 at 08:16:44AM +0000, Bindhu Anjaneya wrote: > We went through the OsmoSS7 Erlang code base and the webpage " > https://projects.osmocom.org/news/30", we see no activity done on > osmo-ss7 for 3 years. This is correct. There are some users that use the code as-is, and there are some other users we know who have unfortunately still not found the time to contribute their changes back. They might even read this very e-mail... > Considering the use of osmo-ss7 as the signaling gateway for SUA to > SCCP/M3UA translation, we have following concerns: > > a. Is osmo-ss7 compliant to latest specifications of SCCP and M3UA? I would never make such a claim, as it has never been formally tested against the test suites. I know for SCCP there are comprehensive tests in the ITU specs. In the Osmocom project, with almost no resources (look at the size of the team and the wide area of tasks we work on), we never had a chance to neither implement those tests nor to verify the implementation against those tests. > b. Does osmo-ss7 implement the complete functionality of the signaling gateway. It probably depends on what you consider the "complete functionality". > c. Is osmo-ss7 inter-op tested with 3rd party 3GPP compliant MSC and osmo-BSC. It has been used in production with several 3rd-party STP and SIGTRAN implementation. Specifically, I remember Yate interop with M2PA, Zynetix interop with SUA, as well as several constellations involving Cisco ITP. There were some others, but in that use case, it was never disclosed what the equipment was that we talk to at the other end. Those use cases all related to the MAP/CAP over TCAP over SCCP stackings on the core network interfaces, and never related to the A interface. How can it be tested with Osmo-BSC, if Osmo-BSC has no SIGTRAN interface so ar? > d. After upgrading SUA and the BSSAP, can the osmo-bsc be tested with > 3rd party MSC by using the osmo-ss7 as signaling gateway? Do you see > some changes on OsmoSS7 codebase? This configuration should be possible. There might be some issues or bug fixes to osmo-ss7. The configuration of osmo_ss7 currently also happens in erlang, so there are no external configuration files or the like. Basically you use a erlang 'main' program to stitch together the respective parts of the > e. If osmo-ss7 does the complete functionality of the signaling > gateway that is translation from SUA to SCCP/M3UA then why to upgrade > the SCCP and implement M3UA in osmo-bsc even in future. Because you complained in your last message about the fact that this introduces an extra hop and you prefer M3UA inside OsmoBSC. I personally don't see the need for that, as I don't mind the one extra hop. My primary focus is to have as much functionality within the limited resources available. Implementing M3UA yet another time doesn't seem like a good use of those limited resources. Using the existing C-language SUA code and the Erlang-language SUA/SG/SCCP/M3UA/M2PA/M2UA code sounds like a more efficient use - even if there still might be bugs or interoperability issues in this code that might need to be resolved. For "urgent" users, they might simply meanwhile use an existing non-free SG to translate SUA to whatever other flavor of CS7 or SIGTRAN they prefer. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Wed Mar 16 10:18:46 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 16 Mar 2016 11:18:46 +0100 Subject: Authentication Response msg type: 0x14 in spec, 0x94 from a 3G phone In-Reply-To: <20160314093339.GB22585@nataraja> References: <20160310215145.GA2124@dub6> <20160311151857.GA26794@nataraja> <20160314010511.GA14267@dub6> <20160314093339.GB22585@nataraja> Message-ID: <20160316101846.GA6815@dub6> On Mon, Mar 14, 2016 at 10:33:39AM +0100, Harald Welte wrote: > We should aim at implementing later releases, so the question is rather > 'do we want rel 4, rel 5, rel 7' and not 'do we want rel 98 or 99'. As > all the later releases >= R99 use the two upper bits as sequence numbers, the question is simple: simply use the >= R99 definition. Nice, I like simple ;) > IIRC, there is a bit somewhere where the GPRS core network (SGSN) > indicates to the MS whether it is a R98 or R99 core network. I think we > have to make sure to set this bit right, and apart from that use the >= > R99 definitions. Daniel / Max, have you come across that bit yet? Thanks! ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Wed Mar 16 10:28:30 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 11:28:30 +0100 Subject: [PATCH] gsm0480.c: squelch compiler warning due to const (caused recently) In-Reply-To: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> References: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160316102830.GM15482@nataraja> Hi Neels, On Mon, Mar 14, 2016 at 11:52:39PM +0100, Neels Hofmeyr wrote: > The introduction of gsm48_hdr_pdisc() caused a new compiler warning. > In gsm0480_decode_*(), the gsm48_hdr is const, which we can safely cast > away to avoid the warning. Why does gsm48_hdr_pdisc() not take a 'const struct gsm48_hdr *' argument in the first place? I don't think it modifies the contents of the structure... -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed Mar 16 10:26:56 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 11:26:56 +0100 Subject: [PATCH] Add function to add bits from array to bitvec In-Reply-To: <1458049868-14129-1-git-send-email-msuraev@sysmocom.de> References: <1458049868-14129-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160316102656.GL15482@nataraja> Hi Max, On Tue, Mar 15, 2016 at 02:51:08PM +0100, msuraev at sysmocom.de wrote: > + * \param[in] estimate indicates whether to return number of bits required > + * instead of actually changing bv is it actually just estimating (i.e. taking a guess) of how many bits were needed, or is it actually computing a definitive amount of output bits? Also, I would prefer to call it 'estimate_ownly' or 'determine_bits_only'. Or even something like 'dry_run', which is used a lot in command-line arguments to indicate that it will not actually perform the operation. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed Mar 16 10:22:31 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 11:22:31 +0100 Subject: libosmocore: gsm48_mi_to_string() TMSI parsing In-Reply-To: References: Message-ID: <20160316102231.GK15482@nataraja> Hi Vadim, On Tue, Mar 15, 2016 at 01:46:31AM +0600, ????? ??????? wrote: > I found that it is used in several projects like OsmocomBB and OpenBSC, > but it seems a bit strange to me that the TMSI represented in decimal... yes, indeed this seems highly unusual. It reflects on the fact how little we knew about the usual representation of TMSIs back when we started to write that code. > Can we move to use a hex representation instead of decimal? And why if not? yes, I would merge an associated patch. Preferrably together with patches for other locations where we print an IMSI and use the decimal representation at this point. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From msuraev at sysmocom.de Wed Mar 16 10:40:59 2016 From: msuraev at sysmocom.de (Max) Date: Wed, 16 Mar 2016 11:40:59 +0100 Subject: [PATCH] Add function to add bits from array to bitvec In-Reply-To: <20160316102656.GL15482@nataraja> References: <1458049868-14129-1-git-send-email-msuraev@sysmocom.de> <20160316102656.GL15482@nataraja> Message-ID: <56E9383B.20604@sysmocom.de> Yes, with estimate set to true it does not change anything - only computes number of necessary bits. I'll send updated patch later on. On 03/16/2016 11:26 AM, Harald Welte wrote: > Hi Max, > > On Tue, Mar 15, 2016 at 02:51:08PM +0100, msuraev at sysmocom.de wrote: >> + * \param[in] estimate indicates whether to return number of bits required >> + * instead of actually changing bv > is it actually just estimating (i.e. taking a guess) of how many bits > were needed, or is it actually computing a definitive amount of output > bits? > > Also, I would prefer to call it 'estimate_ownly' or > 'determine_bits_only'. Or even something like 'dry_run', which is used > a lot in command-line arguments to indicate that it will not actually > perform the operation. > -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From laforge at gnumonks.org Wed Mar 16 10:42:57 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 11:42:57 +0100 Subject: Authentication Response msg type: 0x14 in spec, 0x94 from a 3G phone In-Reply-To: <20160316101846.GA6815@dub6> References: <20160310215145.GA2124@dub6> <20160311151857.GA26794@nataraja> <20160314010511.GA14267@dub6> <20160314093339.GB22585@nataraja> <20160316101846.GA6815@dub6> Message-ID: <20160316104257.GN15482@nataraja> Hi Neels, On Wed, Mar 16, 2016 at 11:18:46AM +0100, Neels Hofmeyr wrote: > > IIRC, there is a bit somewhere where the GPRS core network (SGSN) > > indicates to the MS whether it is a R98 or R99 core network. I think we > > have to make sure to set this bit right, and apart from that use the >= > > R99 definitions. > > Daniel / Max, have you come across that bit yet? It's the SGSNR bit of the SI13 rest octets. It is already set to H, indicating "R99 or later". See line 430 of src/libbsc/rest_octets.c. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed Mar 16 10:46:01 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 11:46:01 +0100 Subject: [PATCH] gsm48: factor out MCC+MNC BCD parsing for re-use in UMTS In-Reply-To: <1458044890-3541-1-git-send-email-nhofmeyr@sysmocom.de> References: <1458044890-3541-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160316104601.GO15482@nataraja> Hi Neels, On Tue, Mar 15, 2016 at 01:28:10PM +0100, Neels Hofmeyr wrote: > So create new functions to take on the MCC+MNC BCD handling and call those > from gsm48_generate_lai() and gsm48_decode_lai(). In this way, the 3G code > in openbsc can use only the BCD functionality without code duplication. fine. As this kind of bit/nibble shifting is something that can easily get wrong, and we don't have a test case yet, it should be best to add a test case testing gsm48_generate_lai() first, then perform the factoring-out and confirm that the test result doesn't change. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Wed Mar 16 14:41:27 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 16 Mar 2016 15:41:27 +0100 Subject: [PATCH 1/3] abis: Send the message without enforcing to wait for a response Message-ID: <1458139289-75555-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther The user might issue restarts while no BTS is connected and we should not block the abis queue because of these messages. --- openbsc/src/libbsc/abis_nm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c index c05e2f9..3afc4c4 100644 --- a/openbsc/src/libbsc/abis_nm.c +++ b/openbsc/src/libbsc/abis_nm.c @@ -2598,7 +2598,7 @@ int abis_nm_ipaccess_restart(struct gsm_bts_trx *trx) fill_om_fom_hdr(oh, 0, NM_MT_IPACC_RESTART, NM_OC_BASEB_TRANSC, trx->bts->nr, trx->nr, 0xff); - return abis_nm_sendmsg(trx->bts, msg); + return abis_nm_sendmsg_direct(trx->bts, msg); } int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, uint8_t obj_class, -- 2.6.3 From holger at freyther.de Wed Mar 16 14:41:28 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 16 Mar 2016 15:41:28 +0100 Subject: [PATCH 2/3] bsc: Add code to send ip.access reboot command to nanoBTS In-Reply-To: <1458139289-75555-1-git-send-email-holger@freyther.de> References: <1458139289-75555-1-git-send-email-holger@freyther.de> Message-ID: <1458139289-75555-2-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther The nanoBTS continues to be buggy and seems to have broken BSSGP when changing SIs across new OML connections. Add an easy command to force the reboot of the system through OML. --- openbsc/src/libbsc/bsc_vty.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 7fdee05..29f2501 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -3596,6 +3596,44 @@ DEFUN(drop_bts, return CMD_SUCCESS; } +DEFUN(restart_bts, restart_bts_cmd, + "restart-bts <0-65535>", + "Restart ip.access nanoBTS through OML\n" + "BTS Number\n") +{ + struct gsm_network *gsmnet; + struct gsm_bts_trx *trx; + struct gsm_bts *bts; + unsigned int bts_nr; + + gsmnet = gsmnet_from_vty(vty); + + bts_nr = atoi(argv[0]); + if (bts_nr >= gsmnet->num_bts) { + vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s", + gsmnet->num_bts, bts_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + bts = gsm_bts_num(gsmnet, bts_nr); + if (!bts) { + vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE); + return CMD_WARNING; + } + + if (!is_ipaccess_bts(bts) || is_sysmobts_v2(bts)) { + vty_out(vty, "This command only works for ipaccess nanoBTS.%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + /* go from last TRX to c0 */ + llist_for_each_entry_reverse(trx, &bts->trx_list, list) + abis_nm_ipaccess_restart(trx); + + return CMD_SUCCESS; +} + DEFUN(smscb_cmd, smscb_cmd_cmd, "bts <0-255> smscb-command <1-4> HEXSTRING", "BTS related commands\n" "BTS Number\n" @@ -3895,6 +3933,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(TS_NODE, &cfg_ts_e1_subslot_cmd); install_element(ENABLE_NODE, &drop_bts_cmd); + install_element(ENABLE_NODE, &restart_bts_cmd); install_element(ENABLE_NODE, &pdch_act_cmd); install_element(ENABLE_NODE, &smscb_cmd_cmd); -- 2.6.3 From holger at freyther.de Wed Mar 16 14:41:29 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 16 Mar 2016 15:41:29 +0100 Subject: [PATCH 3/3] bsc: Add parameter to restart a bts In-Reply-To: <1458139289-75555-1-git-send-email-holger@freyther.de> References: <1458139289-75555-1-git-send-email-holger@freyther.de> Message-ID: <1458139289-75555-3-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther The ip.access nanoBTS seems to have severe issues with BSSGP when changing the country code and/or network code. It is unlikely that the proprietary code is getting fixed so we extend the parameter for the apply-configuration command to carry the 'restart' param. --- openbsc/src/libbsc/bsc_ctrl_commands.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c index b6b1c9a..7e84797 100644 --- a/openbsc/src/libbsc/bsc_ctrl_commands.c +++ b/openbsc/src/libbsc/bsc_ctrl_commands.c @@ -90,7 +90,17 @@ static int set_net_apply_config(struct ctrl_cmd *cmd, void *data) if (!is_ipaccess_bts(bts)) continue; - ipaccess_drop_oml(bts); + /* + * The ip.access nanoBTS seems to be unrelaible on BSSGP + * so let's us just reboot it. For the sysmoBTS we can just + * restart the process as all state is gone. + */ + if (!is_sysmobts_v2(bts) && strcmp(cmd->value, "restart") == 0) { + struct gsm_bts_trx *trx; + llist_for_each_entry_reverse(trx, &bts->trx_list, list) + abis_nm_ipaccess_restart(trx); + } else + ipaccess_drop_oml(bts); } cmd->reply = "Tried to drop the BTS"; -- 2.6.3 From axilirator at gmail.com Wed Mar 16 15:12:22 2016 From: axilirator at gmail.com (axilirator at gmail.com) Date: Wed, 16 Mar 2016 21:12:22 +0600 Subject: [PATCH] gsm48: move to hex TMSI representation In-Reply-To: <20160316102231.GK15482@nataraja> References: <20160316102231.GK15482@nataraja> Message-ID: <1458141142-8157-1-git-send-email-axilirator@gmail.com> From: Vadim Yanitskiy Signed-off-by: Vadim Yanitskiy --- src/gsm/gsm48.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index d0a2286..e4a98d6 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -394,7 +394,7 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi, if (mi_len == GSM48_TMSI_LEN && mi[0] == (0xf0 | GSM_MI_TYPE_TMSI)) { memcpy(&tmsi, &mi[1], 4); tmsi = ntohl(tmsi); - return snprintf(string, str_len, "%u", tmsi); + return snprintf(string, str_len, "0x%08x", tmsi); } break; case GSM_MI_TYPE_IMSI: -- 1.9.1 From axilirator at gmail.com Wed Mar 16 15:14:03 2016 From: axilirator at gmail.com (axilirator at gmail.com) Date: Wed, 16 Mar 2016 21:14:03 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: <20160316102231.GK15482@nataraja> References: <20160316102231.GK15482@nataraja> Message-ID: <1458141243-8236-1-git-send-email-axilirator@gmail.com> From: Vadim Yanitskiy Signed-off-by: Vadim Yanitskiy --- openbsc/include/openbsc/gsm_subscriber.h | 2 +- openbsc/src/libmsc/db.c | 15 ++++++++------- openbsc/tests/db/db_test.c | 4 ++-- openbsc/tests/gsm0408/gsm0408_test.c | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 7d6c776..785dc36 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -14,7 +14,7 @@ #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 tmsi_from_string(str) strtoul(str + 2, NULL, 16) #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 0935fc5..952151e 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -893,9 +893,10 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, subscr->id = dbi_result_get_ulonglong(result, "id"); db_set_from_query(subscr, result); - DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', TMSI %u, EXTEN '%s', LAC %hu, AUTH %u\n", - subscr->id, subscr->imsi, subscr->name, subscr->tmsi, subscr->extension, - subscr->lac, subscr->authorized); + DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', " + "TMSI 0x%08x, EXTEN '%s', LAC %hu, AUTH %u\n", + subscr->id, subscr->imsi, subscr->name, subscr->tmsi, + subscr->extension, subscr->lac, subscr->authorized); dbi_result_free(result); get_equipment_by_subscr(subscr); @@ -935,7 +936,7 @@ int db_subscriber_update(struct gsm_subscriber *subscr) int db_sync_subscriber(struct gsm_subscriber *subscriber) { dbi_result result; - char tmsi[14]; + char tmsi[11]; char *q_tmsi, *q_name, *q_extension; dbi_conn_quote_string_copy(conn, @@ -944,7 +945,7 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber) subscriber->extension, &q_extension); if (subscriber->tmsi != GSM_RESERVED_TMSI) { - sprintf(tmsi, "%u", subscriber->tmsi); + sprintf(tmsi, "0x%08x", subscriber->tmsi); dbi_conn_quote_string_copy(conn, tmsi, &q_tmsi); @@ -1194,7 +1195,7 @@ int db_subscriber_expire(void *priv, void (*callback)(void *priv, long long unsi int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) { dbi_result result = NULL; - char tmsi[14]; + char tmsi[11]; char *tmsi_quoted; for (;;) { @@ -1205,7 +1206,7 @@ int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) if (subscriber->tmsi == GSM_RESERVED_TMSI) continue; - sprintf(tmsi, "%u", subscriber->tmsi); + sprintf(tmsi, "0x%08x", subscriber->tmsi); dbi_conn_quote_string_copy(conn, tmsi, &tmsi_quoted); result = dbi_conn_queryf(conn, "SELECT * FROM Subscriber " diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c index a02d1f8..faea820 100644 --- a/openbsc/tests/db/db_test.c +++ b/openbsc/tests/db/db_test.c @@ -200,7 +200,7 @@ int main() alice->lac=42; db_sync_subscriber(alice); /* Get by TMSI */ - snprintf(scratch_str, sizeof(scratch_str), "%"PRIu32, alice->tmsi); + snprintf(scratch_str, sizeof(scratch_str), "0x%08x", alice->tmsi); alice_db = db_get_subscriber(GSM_SUBSCRIBER_TMSI, scratch_str); COMPARE(alice, alice_db); SUBSCR_PUT(alice_db); @@ -227,7 +227,7 @@ int main() db_subscriber_assoc_imei(alice, "1234567890"); db_subscriber_assoc_imei(alice, "6543560920"); /* Get by TMSI */ - snprintf(scratch_str, sizeof(scratch_str), "%"PRIu32, alice->tmsi); + snprintf(scratch_str, sizeof(scratch_str), "0x%08x", alice->tmsi); alice_db = db_get_subscriber(GSM_SUBSCRIBER_TMSI, scratch_str); COMPARE(alice, alice_db); SUBSCR_PUT(alice_db); diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c index 781ef61..8ed57ca 100644 --- a/openbsc/tests/gsm0408/gsm0408_test.c +++ b/openbsc/tests/gsm0408/gsm0408_test.c @@ -93,7 +93,7 @@ static void test_mi_functionality(void) /* tmsi code */ mi_len = gsm48_generate_mid_from_tmsi(mi, tmsi); gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len - 2); - COMPARE((uint32_t)strtoul(mi_parsed, NULL, 10), ==, tmsi); + COMPARE((uint32_t)tmsi_from_string(mi_parsed), ==, tmsi); /* imsi code */ mi_len = gsm48_generate_mid_from_imsi(mi, imsi_odd); -- 1.9.1 From axilirator at gmail.com Wed Mar 16 15:26:57 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Wed, 16 Mar 2016 21:26:57 +0600 Subject: libosmocore: gsm48_mi_to_string() TMSI parsing In-Reply-To: <20160316102231.GK15482@nataraja> References: <20160316102231.GK15482@nataraja> Message-ID: Hello, Harald! There are two patches. One for libosmocore, another one for OpenBSC (sorry for a little bit of mess). Right now I have no opportunity to test it, but the output of 'make check' seems ok. ? ?????????? ???????????, ??????? ?????. 2016-03-16 16:22 GMT+06:00 Harald Welte : > Hi Vadim, > > On Tue, Mar 15, 2016 at 01:46:31AM +0600, ????? ??????? wrote: > > I found that it is used in several projects like OsmocomBB and OpenBSC, > > but it seems a bit strange to me that the TMSI represented in decimal... > > yes, indeed this seems highly unusual. It reflects on the fact how > little we knew about the usual representation of TMSIs back when we > started to write that code. > > > Can we move to use a hex representation instead of decimal? And why if > not? > > yes, I would merge an associated patch. Preferrably together with > patches for other locations where we print an IMSI and use the decimal > representation at this point. > > -- > - Harald Welte > http://laforge.gnumonks.org/ > > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. > A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From msuraev at sysmocom.de Wed Mar 16 16:11:52 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 16 Mar 2016 17:11:52 +0100 Subject: [PATCH] Add explicit check for SI2quater index and count Message-ID: <1458144712-16068-1-git-send-email-msuraev@sysmocom.de> From: Max Right now we do not support multiple SI2quater messages, so return error if either index or count is non-zero. --- src/common/rsl.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/common/rsl.c b/src/common/rsl.c index a503355..ed8cced 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -298,9 +298,10 @@ static int rsl_rx_bcch_info(struct gsm_bts_trx *trx, struct msgb *msg) { struct gsm_bts *bts = trx->bts; struct tlv_parsed tp; - uint8_t rsl_si; + uint8_t rsl_si, si2q_index, si2q_count; enum osmo_sysinfo_type osmo_si; - + struct gsm48_system_information_type_2quater *si2q; + struct bitvec bv; rsl_tlv_parse(&tp, msgb_l3(msg), msgb_l3len(msg)); /* 9.3.30 System Info Type */ @@ -327,6 +328,22 @@ static int rsl_rx_bcch_info(struct gsm_bts_trx *trx, struct msgb *msg) TLVP_VAL(&tp, RSL_IE_FULL_BCCH_INFO), len); LOGP(DRSL, LOGL_INFO, " Rx RSL BCCH INFO (SI%s)\n", get_value_string(osmo_sitype_strs, osmo_si)); + + if (SYSINFO_TYPE_2quater == osmo_si) { + si2q = (struct gsm48_system_information_type_2quater *) + bts->si_buf[SYSINFO_TYPE_2quater]; + bv.data = si2q->rest_octets; + bv.data_len = 20; + bv.cur_bit = 3; + si2q_index = (uint8_t) bitvec_get_uint(&bv, 4); + si2q_count = (uint8_t) bitvec_get_uint(&bv, 4); + if (si2q_index || si2q_count) { + LOGP(DRSL, LOGL_ERROR, + " Rx RSL SI2quater witn unsupported index %u, count %u\n", + si2q_index, si2q_count); + return rsl_tx_error_report(trx, RSL_ERR_IE_CONTENT); + } + } } else if (TLVP_PRESENT(&tp, RSL_IE_L3_INFO)) { uint16_t len = TLVP_LEN(&tp, RSL_IE_L3_INFO); if (len > sizeof(sysinfo_buf_t)) -- 2.7.3 From msuraev at sysmocom.de Wed Mar 16 16:34:58 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 16 Mar 2016 17:34:58 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> References: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458146098-26896-2-git-send-email-msuraev@sysmocom.de> From: Max Add structure representing group of EARFCNs with common priority, threshold etc. Add functions to populate this structure. --- include/osmocom/gsm/sysinfo.h | 32 ++++++++++++++++++++++++++++- src/gsm/libosmogsm.map | 4 ++++ src/gsm/sysinfo.c | 47 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h index 7d1fe2b..dcac08f 100644 --- a/include/osmocom/gsm/sysinfo.h +++ b/include/osmocom/gsm/sysinfo.h @@ -3,6 +3,9 @@ #include #include +#define OSMO_EARFCN_INVALID 666 +#define OSMO_EARFCN_MEAS_INVALID 0xff + enum osmo_sysinfo_type { SYSINFO_TYPE_NONE, SYSINFO_TYPE_1, @@ -32,9 +35,36 @@ enum osmo_sysinfo_type { _MAX_SYSINFO_TYPE }; +struct earfcn { +/* EARFCN (16 bits) array */ + uint16_t *arfcn; +/* Measurement Bandwidth (3 bits), might be absent +(OSMO_EARFCN_MEAS_INVALID is stored in this case) */ + uint8_t *meas_bw; +/* length of arfcn and meas_bw arrays (got to be the same) */ + size_t length; +/* THRESH_E-UTRAN_high (5 bits) */ + uint8_t thresh_hi; +/* THRESH_E-UTRAN_low (5 bits) */ + uint8_t thresh_lo; +/* E-UTRAN_PRIORITY (3 bits) */ + uint8_t prio; +/* E-UTRAN_QRXLEVMIN */ + uint8_t qrxlm; +/* indicates whether thresh_lo value is valid +thresh_hi is mandatory and hence always considered valid */ + bool thresh_lo_valid; +/* indicates whether prio value is valid */ + bool prio_valid; +/* indicates whether qrxlm value is valid */ + bool qrxlm_valid; +}; + typedef uint8_t sysinfo_buf_t[GSM_MACBLOCK_LEN]; extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE]; - +int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw); +int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn); +void osmo_earfcn_init(struct earfcn *e); uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type); enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si); diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 7eebe7f..9b6e8ea 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -29,6 +29,10 @@ osmo_sitype_strs; comp128; dbm2rxlev; +osmo_earfcn_add; +osmo_earfcn_del; +osmo_earfcn_init; + gprs_cipher_gen_input_i; gprs_cipher_gen_input_ui; gprs_cipher_load; diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index 1408f6b..d56282f 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -125,6 +125,53 @@ const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { { 0, NULL } }; +/*! \brief Add pair of arfcn and measurement bandwith value to earfcn struct + * \param[in,out] e earfcn struct + * \param[in] arfcn EARFCN value, 16 bits + * \param[in] meas_bw measurement bandwith value + * \returns 0 on success, error otherwise + */ +int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) +{ + size_t i; + for (i = 0; i < e->length; i++) + if (OSMO_EARFCN_INVALID == e->arfcn[i]) { + e->arfcn[i] = arfcn; + e->meas_bw[i] = meas_bw; + return 0; + } + return ENOMEM; +} + +/*! \brief Delete arfcn (and corresponding measurement bandwith) from earfcn + * struct + * \param[in,out] e earfcn struct + * \param[in] arfcn EARFCN value, 16 bits + * \returns 0 on success, error otherwise + */ +int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) +{ + size_t i; + for (i = 0; i < e->length; i++) + if (arfcn == e->arfcn[i]) { + e->arfcn[i] = OSMO_EARFCN_INVALID; + e->meas_bw[i] = OSMO_EARFCN_MEAS_INVALID; + } + return ENOENT; +} + +/*! \brief Initialize earfcn struct + * \param[in,out] e earfcn struct + */ +void osmo_earfcn_init(struct earfcn *e) +{ + size_t i; + for (i = 0; i < e->length; i++) { + e->arfcn[i] = OSMO_EARFCN_INVALID; + e->meas_bw[i] = OSMO_EARFCN_MEAS_INVALID; + } +} + uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type) { return sitype2rsl[si_type]; -- 2.7.3 From msuraev at sysmocom.de Wed Mar 16 16:34:57 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 16 Mar 2016 17:34:57 +0100 Subject: [PATCH 1/2] Add function to add bits from array to bitvec Message-ID: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> From: Max Add function which adds specified number of bits from each element of array to the bit vector prefixing each addition with one and finishing entire sequence with adding 0. This is very common patter for various repetitive data structures described with CSN.1 in 3GPP standards. Corresponding test vectors and doxygen headers are added too. --- include/osmocom/core/bitvec.h | 3 +++ src/bitvec.c | 40 ++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.c | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.ok | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+) diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 5314cf2..c3c1153 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -91,5 +91,8 @@ void bitvec_zero(struct bitvec *bv); unsigned bitvec_rl(const struct bitvec *bv, bool b); void bitvec_shiftl(struct bitvec *bv, unsigned int n); int16_t bitvec_get_int16_msb(const struct bitvec *bv, unsigned int num_bits); +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, + unsigned int array_len, bool dry_run, + unsigned int num_bits); /*! @} */ diff --git a/src/bitvec.c b/src/bitvec.c index 00ae150..6f0c15a 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -570,4 +570,44 @@ void bitvec_shiftl(struct bitvec *bv, unsigned n) bv->cur_bit -= n; } +/*! \brief Add given array to bitvec + * \param[in,out] bv bit vector to work with + * \param[in] array elements to be added + * \param[in] array_len length of array + * \param[in] dry_run indicates whether to return number of bits required + * instead of adding anything to bv for real + * \param[in] num_bits number of bits to consider in each element of array + * \returns number of bits necessary to add array elements if dry_run is true, + * 0 otherwise (only in this case bv is actually changed) + * + * N. B: no length checks are performed on bv - it's callee's job to ensure + * enough space is available - for example by calling with dry_run = true first. + * + * Useful for common pattern in CSN.1 spec which looks like: + * { 1 < XXX : bit (num_bits) > } ** 0 + * which means repeat any times (between 0 and infinity), + * start each repetition with 1, mark end of repetitions with 0 bit + * see app. note in 3GPP TS 24.007 ? B.2.1 Rule A2 + */ +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, + unsigned int array_len, bool dry_run, + unsigned int num_bits) +{ + unsigned i, bits = 1; /* account for stop bit */ + for (i = 0; i < array_len; i++) { + if (dry_run) { + bits += (1 + num_bits); + } else { + bitvec_set_bit(bv, 1); + bitvec_set_uint(bv, array[i], num_bits); + } + } + + if (dry_run) + return bits; + + bitvec_set_bit(bv, 0); /* stop bit - end of the sequence */ + return 0; +} + /*! @} */ diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c index 76d6773..a98a91c 100644 --- a/tests/bitvec/bitvec_test.c +++ b/tests/bitvec/bitvec_test.c @@ -132,6 +132,43 @@ static void test_unhex(const char *hex) printf("%s\n", hex); } +static inline void test_array_item(unsigned t, struct bitvec *b, unsigned int n, + uint32_t *array, unsigned int p) +{ + unsigned int i, x, y; + bitvec_zero(b); + x = b->cur_bit; + i = bitvec_add_array(b, array, n, true, t); + y = b->cur_bit; + bitvec_add_array(b, array, n, false, t); + printf("\nbits: %u, est: %u, real: %u, x: %u, y: %u\n", + t, i, b->cur_bit, x, y); + for (i = 0; i < p; i++) { + printf(OSMO_BIT_SPEC " ", OSMO_BIT_PRINT(b->data[i])); + if (0 == (i + 1) % 15) + printf("\n"); + } +} + +static void test_array() +{ + struct bitvec b; + uint8_t d[4096]; + b.data = d; + b.data_len = sizeof(d); + + unsigned int i, n = 64; + uint32_t array[n]; + for (i = 0; i < n; i++) { + array[i] = i * i * i + i; + printf("0x%x ", array[i]); + } + + test_array_item(3, &b, n, array, n); + test_array_item(9, &b, n, array, n * 2); + test_array_item(17, &b, n, array, n * 3); +} + int main(int argc, char **argv) { struct bitvec bv; @@ -204,5 +241,11 @@ int main(int argc, char **argv) test_unhex("DEADFACE000000000000000000000000000000BEEFFEED"); test_unhex("FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); + printf("arrr...\n"); + + test_array(); + + printf("\nbitvec ok.\n"); + return 0; } diff --git a/tests/bitvec/bitvec_test.ok b/tests/bitvec/bitvec_test.ok index 1c993d3..e256108 100644 --- a/tests/bitvec/bitvec_test.ok +++ b/tests/bitvec/bitvec_test.ok @@ -134,3 +134,36 @@ DEADFACE000000000000000000000000000000BEEFFEED 0 -=> cur_bit=512 fffffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +arrr... +0x0 0x2 0xa 0x1e 0x44 0x82 0xde 0x15e 0x208 0x2e2 0x3f2 0x53e 0x6cc 0x8a2 0xac6 0xd3e 0x1010 0x1342 0x16da 0x1ade 0x1f54 0x2442 0x29ae 0x2f9e 0x3618 0x3d22 0x44c2 0x4cfe 0x55dc 0x5f62 0x6996 0x747e 0x8020 0x8c82 0x99aa 0xa79e 0xb664 0xc602 0xd67e 0xe7de 0xfa28 0x10d62 0x12192 0x136be 0x14cec 0x16422 0x17c66 0x195be 0x1b030 0x1cbc2 0x1e87a 0x2065e 0x22574 0x245c2 0x2674e 0x28a1e 0x2ae38 0x2d3a2 0x2fa62 0x3227e 0x34bfc 0x376e2 0x3a336 0x3d0fe +bits: 3, est: 257, real: 257, x: 0, y: 0 +1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. +111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. +11..1.1. 111.111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ +bits: 9, est: 641, real: 641, x: 0, y: 0 +1....... ..1..... ..1.1... ..1.1.1. ...1111. 1..1...1 ..1.1... ..1.1.11 .1111.11 .1.1111. 1.....1. ..1.111. ..1.1111 11..1.11 ..11111. +1.11..11 ..1.1.1. ..1.1.11 ...11.11 ..11111. 1....1.. ..11.1.. ..1.1.11 .11.1.1. 11.1111. 11.1.1.1 ..1..1.. ..1.111. 1.111.11 1..1111. +1....11. ..11..1. ..1.1.11 ....1.1. 1111111. 1111.111 ..11.11. ..1.111. .1.11.1. .111111. 1...1... ..1.1... ..1.111. 1.1.1.11 1..1111. +1..11..1 ..1..... ..1.1..1 11111.11 11.1111. 1...1.1. ..11.11. ..1.111. .1..1.1. 1.11111. 1.111.11 ..1...1. ..1.1..1 1..11.11 1.11111. +1...11.. ..1111.. ..1.1..1 111.1.1. .1.1111. 11.111.1 ..1111.. ..1.11.1 ..111.1. ...1111. 1...111. ..111.1. ..1.1..1 1...1.1. .111111. +11111111 ..1.111. ..1.11.. 11.11.1. 1111111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ +bits: 17, est: 1153, real: 1153, x: 0, y: 0 +1....... ........ ..1..... ........ ..1.1... ........ ..1.1.1. ........ ...1111. 1....... ...1...1 ..1..... ....1... ..1.1... ......11 +.1111.1. .......1 .1.1111. 1....... 1.....1. ..1..... ..1.111. ..1.1... ....1111 11..1.1. .....1.1 ..11111. 1......1 1.11..11 ..1..... +1...1.1. ..1.1... ..1.1.11 ...11.1. ....11.1 ..11111. 1....1.. .....1.. ..1....1 ..11.1.. ..1.1... .1.11.11 .11.1.1. ...11.1. 11.1111. +1....111 11.1.1.1 ..1...1. .1...1.. ..1.1... 1.1..11. 1.111.1. ..1.1111 1..1111. 1...11.1 1....11. ..1...11 11.1..1. ..1.1..1 ...1..11 +....1.1. .1..11.. 1111111. 1..1.1.1 .111.111 ..1..1.1 1111.11. ..1.1..1 1.1..11. .1.11.1. .111.1.. .111111. 1.1..... ....1... ..1.1... +11..1... ..1.1.1. .11..11. 1.1.1.1. 1.1..111 1..1111. 1.1.11.1 1..11..1 ..1.11.. .11..... ..1.1.11 .1.11..1 11111.1. 111..111 11.1111. +1.11111. 1...1.1. ..11.... 11.1.11. ..1.11.. 1....11. .1..1.11 ..11.11. 1.11111. 11.1..11 ..111.11 ..11.11. .1....1. ..1.11.1 1111...1 +1..11.11 1..1.1.1 1.11111. 111.11.. ....11.. ..1111.. 1.1111.. ..1.1111 1.1....1 111.1.1. .....11. .1.1111. 1...1..1 .1.111.1 ..1..1.. +.1.111.. ..1.1..1 1..111.1 ..111.1. 1...1.1. ...1111. 1.1.1.11 1...111. ..1.11.1 ..111.1. ..1.1.11 111.1..1 1...1.11 ..1...1. .111111. +11.1..1. 11111111 ..11.111 .11.111. ..1.111. 1...11.. 11.11.11 11.1.... 1111111. ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +bitvec ok. -- 2.7.3 From laforge at gnumonks.org Wed Mar 16 18:50:07 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 19:50:07 +0100 Subject: [PATCH] Add explicit check for SI2quater index and count In-Reply-To: <1458144712-16068-1-git-send-email-msuraev@sysmocom.de> References: <1458144712-16068-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160316185007.GL8342@nataraja> Hi Max, On Wed, Mar 16, 2016 at 05:11:52PM +0100, msuraev at sysmocom.de wrote: > + LOGP(DRSL, LOGL_ERROR, > + " Rx RSL SI2quater witn unsupported index %u, count %u\n", please watch the line length, thanks. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed Mar 16 18:49:37 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 19:49:37 +0100 Subject: [PATCH 1/2] Add function to add bits from array to bitvec In-Reply-To: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> References: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160316184937.GK8342@nataraja> Hi Max, On Wed, Mar 16, 2016 at 05:34:57PM +0100, msuraev at sysmocom.de wrote: > + * N. B: no length checks are performed on bv - it's callee's job to ensure > + * enough space is available - for example by calling with dry_run = true first. callee == the function being called, i.e. your function. caller == the 'parent' function calling this function. I suppos you mean "It's callers jub to ensure..." -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed Mar 16 18:48:08 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 16 Mar 2016 19:48:08 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <1458146098-26896-2-git-send-email-msuraev@sysmocom.de> References: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> <1458146098-26896-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160316184808.GJ8342@nataraja> Hi Max, On Wed, Mar 16, 2016 at 05:34:58PM +0100, msuraev at sysmocom.de wrote: > +/* EARFCN (16 bits) array */ > + uint16_t *arfcn; comment should have same indent as the struct member > + for (i = 0; i < e->length; i++) > + if (OSMO_EARFCN_INVALID == e->arfcn[i]) { missing {} around the indented if block. The rule is (please check Linux kernel coding style) that only if there is a single line inside the block, we dont use curly braces. > + return ENOMEM; generally we return negative values for errors, so it should be -ENOMEM. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Wed Mar 16 22:22:11 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 16 Mar 2016 23:22:11 +0100 Subject: const question, take II In-Reply-To: <20160316102830.GM15482@nataraja> References: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> <20160316102830.GM15482@nataraja> Message-ID: <20160316222211.GA14207@dub6> On Wed, Mar 16, 2016 at 11:28:30AM +0100, Harald Welte wrote: > Why does gsm48_hdr_pdisc() not take a 'const struct gsm48_hdr *' > argument in the first place? I don't think it modifies the contents of > the structure... Yes, Holger has applied the patch with exactly that change. Yet this has me confused. A while back I concluded that C doesn't allow passing non-const instances to functions that expect a const arg. That was discussed on this list in January: http://lists.osmocom.org/pipermail/openbsc/2016-January/001051.html http://lists.osmocom.org/pipermail/openbsc/2016-January/001055.html How is this different from the conclusion that Jacob confirmed two months ago? Is it int (primitives) vs. struct?? Thanks! ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Wed Mar 16 22:40:45 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 16 Mar 2016 23:40:45 +0100 Subject: [PATCH] gsm48: factor out MCC+MNC BCD parsing for re-use in UMTS In-Reply-To: <20160316104601.GO15482@nataraja> References: <1458044890-3541-1-git-send-email-nhofmeyr@sysmocom.de> <20160316104601.GO15482@nataraja> Message-ID: <20160316224045.GB14207@dub6> On Wed, Mar 16, 2016 at 11:46:01AM +0100, Harald Welte wrote: > Hi Neels, > > On Tue, Mar 15, 2016 at 01:28:10PM +0100, Neels Hofmeyr wrote: > > So create new functions to take on the MCC+MNC BCD handling and call those > > from gsm48_generate_lai() and gsm48_decode_lai(). In this way, the 3G code > > in openbsc can use only the BCD functionality without code duplication. > > fine. As this kind of bit/nibble shifting is something that can easily > get wrong, and we don't have a test case yet, it should be best to add a > test case testing gsm48_generate_lai() first, then perform the > factoring-out and confirm that the test result doesn't change. I agree on that. I didn't check hence wasn't aware that no test for gsm48_generate_lai() exists. Nevertheless, when Holger and I went thru the patch review, we broke the BCD generation/parsing code on purpose and actually managed to provoke a test failure with that. So these functions seem to be tested, at least indirectly. I hope that's sufficient...? ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Wed Mar 16 22:49:02 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 16 Mar 2016 23:49:02 +0100 Subject: [PATCH 1/2] Add function to add bits from array to bitvec In-Reply-To: <20160316184937.GK8342@nataraja> References: <1458146098-26896-1-git-send-email-msuraev@sysmocom.de> <20160316184937.GK8342@nataraja> Message-ID: <20160316224902.GC14207@dub6> On Wed, Mar 16, 2016 at 07:49:37PM +0100, Harald Welte wrote: > Hi Max, > > On Wed, Mar 16, 2016 at 05:34:57PM +0100, msuraev at sysmocom.de wrote: > > + * N. B: no length checks are performed on bv - it's callee's job to ensure > > + * enough space is available - for example by calling with dry_run = true first. > > callee == the function being called, i.e. your function. > caller == the 'parent' function calling this function. > > I suppos you mean "It's callers jub to ensure..." "It's the caller's job to ensure..." sorry, I promised not to language nitpick, but it does hurt ;) ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Thu Mar 17 01:05:32 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 17 Mar 2016 02:05:32 +0100 Subject: Iu: flimsy TMSI Message-ID: <20160317010532.GA15711@dub6> Hi Daniel and 3G folks, about our difficulty in maintaining a prolonged link with the UE, I found a bit of discrepancy concerning the TMSIs used. When looking at a pcap where we authenticate and MM LU / GMM Attach successfully on CS / PS, and with TMSI assignment enabled in CSCN, I see TMSIs in these places: 1) UE sends TMSI in "(GMM) Attach Request" (PS) 2) SGSN sends TMSI in "(GMM) Attach Accept" (PS) 3) CSCN sends TMSI in "Location Update Accept" (CS) All these TMSIs differ. When I look in the RRC log of the hnb, it is logging a TMSI for pretty much every received message on CS and PS domains. But it is always and only logging the TMSI matching 1), i.e. the TMSI originally sent on the PS domain. To rephrase, the same TMSI is logged for PS and CS domain messages; for the MM LU Accept as well as the GMM Attach Accept, the hnb logs TMSI 1) even though the CN sent TMSIs 3) and 2), respectively. For 1) and 2), it seems that the SGSN should accept and use the TMSI sent by the UE during the Attach Request, right? For 3), according to the RRC log, it seems that the UE expects to see the very same TMSI in CS that it sent to PS -- that'd be a problem. On the other hand, when noting that, in the Location Updating Request, the UE identified itself using the IMSI and not a TMSI, it may be indeed the correct choice to disable TMSI use for CS? I must admit that I'm not firm in the IMSI/TMSI realm, and staring at 3GPP 04.08 doesn't clarify it right away, so I'd appreciate some feedback from this list. I can stare some more, but maybe you guys are quicker. Thanks! ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Thu Mar 17 07:06:32 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 08:06:32 +0100 Subject: const question, take II In-Reply-To: <20160316222211.GA14207@dub6> References: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> <20160316102830.GM15482@nataraja> <20160316222211.GA14207@dub6> Message-ID: <20160317070632.GP8342@nataraja> Hi Neels, On Wed, Mar 16, 2016 at 11:22:11PM +0100, Neels Hofmeyr wrote: > On Wed, Mar 16, 2016 at 11:28:30AM +0100, Harald Welte wrote: > > Why does gsm48_hdr_pdisc() not take a 'const struct gsm48_hdr *' > > argument in the first place? I don't think it modifies the contents of > > the structure... > > Yes, Holger has applied the patch with exactly that change. > > Yet this has me confused. A while back I concluded that C doesn't allow > passing non-const instances to functions that expect a const arg. We do that all the time in Osmocom projects. Especially for functions that have input pointers (should be "const foo *") and output pointers (should be "foo *), you can easily safeguard agaist some common cases where the caller swaps the arguments this way. This is standard practise, see the definition of memcpy: void *memcpy(void *dest, const void *src, size_t n); > http://lists.osmocom.org/pipermail/openbsc/2016-January/001051.html > http://lists.osmocom.org/pipermail/openbsc/2016-January/001055.html > > How is this different from the conclusion that Jacob confirmed two months > ago? Is it int (primitives) vs. struct?? from a quick look, the above discussion was about passing the address of a pointer, and of course if you pass that into a function, you expect the function to be able to modify the pointer stored at that address? -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From osmocom at zeflo.com Thu Mar 17 08:24:24 2016 From: osmocom at zeflo.com (zeflo) Date: Thu, 17 Mar 2016 09:24:24 +0100 Subject: Status of osmo-ganc Message-ID: Hi, i was wondering how is the status of osmo-ganc? Is there a working implementation? As far as i understand it, to test GAN + OpenBSC i would need a GAN capable mobile phone, or a modified version of OsmocomBB. Greetings, Florian -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Thu Mar 17 10:11:37 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 11:11:37 +0100 Subject: Iu: flimsy TMSI In-Reply-To: <20160317010532.GA15711@dub6> References: <20160317010532.GA15711@dub6> Message-ID: <20160317101137.GZ8342@nataraja> Hi Neels, On Thu, Mar 17, 2016 at 02:05:32AM +0100, Neels Hofmeyr wrote: > about our difficulty in maintaining a prolonged link with the UE, I found > a bit of discrepancy concerning the TMSIs used. > > 1) UE sends TMSI in "(GMM) Attach Request" (PS) > 2) SGSN sends TMSI in "(GMM) Attach Accept" (PS) PS uses P-TMSI > 3) CSCN sends TMSI in "Location Update Accept" (CS) CS uses TMSI P-TMSI and TMSI are in completely different namespaces. > All these TMSIs differ. 1+2 should be the same. '3' should be different. > For 3), according to the RRC log, it seems that the UE expects to see the > very same TMSI in CS that it sent to PS -- that'd be a problem. On the > other hand, when noting that, in the Location Updating Request, the UE > identified itself using the IMSI and not a TMSI, it may be indeed the > correct choice to disable TMSI use for CS? It might be the case that our network does something that implies we support a 'combined CS+PS attach', which we don't. In an (unsupported) combind CS+PS attach, the SGSN would send an ATTACH ACCEPT with IEs for both TMSI and P-TMSI. If you're looking for more information on TMSI/IMSI/P-TMSI, 04.08 is the wrong place. Check 23.003, it contains thins like "In areas where both MSC-based services and SGSN-based services are provided, some discrimination is needed between the allocation of TMSIs for MSC-based services and the allocation of TMSIs for SGSN-based services. The discrimination shall be done on the 2 most significant bits, with values 00, 01, and 10 being used by the VLR, and 11 being used by the SGSN." Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Thu Mar 17 10:14:07 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 11:14:07 +0100 Subject: Status of osmo-ganc In-Reply-To: References: Message-ID: <20160317101407.GA8342@nataraja> Hi zeflo, On Thu, Mar 17, 2016 at 09:24:24AM +0100, zeflo wrote: > Hi, i was wondering how is the status of osmo-ganc? Is there a working > implementation? we had it working as a big and ugly hack at some point, but never cleaned it up or merged it, as the project was discontinued due to lack of interest. If you'd want to invest time to clean it up, forward-port it to current master and merge it, we'd be happy to accept your patches. > As far as i understand it, to test GAN + OpenBSC i would need a GAN capable > mobile phone, or a modified version of OsmocomBB. You normally also nee a SEGW (can be constructed from StrongSwan) and have the proper CA root certificate installed in your phone to accept the SEGW certificate. The SEGW needs to support EAP-SIM or EAP-AKA with the SIM insid the phone. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From msuraev at sysmocom.de Thu Mar 17 10:37:23 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 11:37:23 +0100 Subject: [PATCH 2/3] Ignore binary and backup files In-Reply-To: <1458211044-11184-1-git-send-email-msuraev@sysmocom.de> References: <1458211044-11184-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458211044-11184-2-git-send-email-msuraev@sysmocom.de> From: Max Add missing entries to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3950377..f11bc4d 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ src/osmo-bts-sysmo/l1fwd-proxy src/osmo-bts-sysmo/osmo-bts-sysmo src/osmo-bts-sysmo/osmo-bts-sysmo-remote src/osmo-bts-sysmo/sysmobts-mgr +src/osmo-bts-sysmo/sysmobts-util src/osmo-bts-trx/osmo-bts-trx @@ -49,6 +50,7 @@ tests/testsuite.log doc/vty_reference.xml # Backups, vi, merges +*~ *.sw? *.orig *.sav -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 10:37:22 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 11:37:22 +0100 Subject: [PATCH 1/3] Add explicit check for SI2quater index and count Message-ID: <1458211044-11184-1-git-send-email-msuraev@sysmocom.de> From: Max Right now we do not support multiple SI2quater messages, so return error if either index or count is non-zero. --- src/common/rsl.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/common/rsl.c b/src/common/rsl.c index a503355..ecf570c 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -298,9 +298,10 @@ static int rsl_rx_bcch_info(struct gsm_bts_trx *trx, struct msgb *msg) { struct gsm_bts *bts = trx->bts; struct tlv_parsed tp; - uint8_t rsl_si; + uint8_t rsl_si, si2q_index, si2q_count; enum osmo_sysinfo_type osmo_si; - + struct gsm48_system_information_type_2quater *si2q; + struct bitvec bv; rsl_tlv_parse(&tp, msgb_l3(msg), msgb_l3len(msg)); /* 9.3.30 System Info Type */ @@ -327,6 +328,24 @@ static int rsl_rx_bcch_info(struct gsm_bts_trx *trx, struct msgb *msg) TLVP_VAL(&tp, RSL_IE_FULL_BCCH_INFO), len); LOGP(DRSL, LOGL_INFO, " Rx RSL BCCH INFO (SI%s)\n", get_value_string(osmo_sitype_strs, osmo_si)); + + if (SYSINFO_TYPE_2quater == osmo_si) { + si2q = (struct gsm48_system_information_type_2quater *) + bts->si_buf[SYSINFO_TYPE_2quater]; + bv.data = si2q->rest_octets; + bv.data_len = 20; + bv.cur_bit = 3; + si2q_index = (uint8_t) bitvec_get_uint(&bv, 4); + si2q_count = (uint8_t) bitvec_get_uint(&bv, 4); + if (si2q_index || si2q_count) { + LOGP(DRSL, LOGL_ERROR, + " Rx RSL SI2quater witn unsupported " + "index %u, count %u\n", + si2q_index, si2q_count); + return rsl_tx_error_report(trx, + RSL_ERR_IE_CONTENT); + } + } } else if (TLVP_PRESENT(&tp, RSL_IE_L3_INFO)) { uint16_t len = TLVP_LEN(&tp, RSL_IE_L3_INFO); if (len > sizeof(sysinfo_buf_t)) -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 10:37:24 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 11:37:24 +0100 Subject: [PATCH 3/3] Add utility to check proper scheduling of SI In-Reply-To: <1458211044-11184-1-git-send-email-msuraev@sysmocom.de> References: <1458211044-11184-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458211044-11184-3-git-send-email-msuraev@sysmocom.de> From: Max There are several types of System Information messages with tricky scheduling rules described in 3GPP TS 05.02 ? 6.3.1.3. This GNU Awk script takes in .csv file with sequence of scheduled SI messages (for example generated using tshark from GSMTAP capture - see usage note inside the script) and check the scheduling rules compliance. --- contrib/si_check.gawk | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 contrib/si_check.gawk diff --git a/contrib/si_check.gawk b/contrib/si_check.gawk new file mode 100755 index 0000000..0a54ed4 --- /dev/null +++ b/contrib/si_check.gawk @@ -0,0 +1,91 @@ +#!/usr/bin/gawk -f + +# Usage example: +# tshark -2 -t r -E 'header=n' -E 'separator=,' -E 'quote=n' -T fields -e gsmtap.frame_nr -e gsmtap.ts -e gsmtap.arfcn -e _ws.col.Info -Y 'gsmtap' -r test.pcapng.gz | grep Information | env ARFCN=878 ./si_check.gawk +# read summary on number of bis/ter messages and adjust BT_BOTH and BT_NONE environment variables accordingly + +BEGIN { + FS = "," + FAILED = 0 + IGNORE = 0 + BIS = 0 + TER = 0 + QUA = 0 + BT_BOTH = ENVIRON["BOTH"] + BT_NONE = ENVIRON["NONE"] + TC_INDEX = 0 + TC4[4] = 0 +} + +{ # expected .csv input as follows: gsmtap.frame_nr,gsmtap.ts,gsmtap.arfcn,_ws.col.Info + if ("ARFCN" in ENVIRON) { # ARFCN filtering is enabled + if (ENVIRON["ARFCN"] != $3) { # ignore other ARFCNs + IGNORE++ + next + } + } + type = get_si_type($4) + tc = get_tc($1) + result = "FAIL" + + if (1 == check_si_tc(tc, type)) { result = "OK" } + else { FAILED++ } + + if (4 == tc) { + TC4[TC_INDEX] = type + TC_INDEX = int((TC_INDEX + 1) % 4) + if (0 == check_tc4c(type) && "OK" == result) { + result = "FAIL" + FAILED++ + } + } + if (type == "2bis") { BIS++ } + if (type == "2ter") { TER++ } + if (type == "2quater") { QUA++ } + # for (i in TC4) print TC4[i] # debugging + printf "ARFCN=%d FN=%d TS=%d TC=%d TYPE=%s %s\n", $3, $1, $2, tc, type, result +} + +END { + printf "check completed: total %d, failed %d, ignored %d, ok %d\nSI2bis = %d, SI2ter = %d, SI2quater = %d\n", NR, FAILED, IGNORE, NR - FAILED - IGNORE, BIS, TER, QUA + if ((BIS > 0 || TER > 0) && BT_NONE) { printf "please re-run with correct environment: unset 'NONE' variable\n" } + if ((BIS > 0 && TER > 0) && !BT_BOTH) { printf "please re-run with correct environment: set 'BOTH' variable\n" } +} + +func get_si_type(s, x) { # we rely on format of Info column in wireshark output - if it's changed we're screwed + return x[split(s, x, " ")] +} + +func get_tc(f) { # N. B: all numbers in awk are float + return int(int(f / 51) % 8) +} + +func check_tc4c(si, count) { # check for "once in 4 consecutive occurrences" rule + count = 0 + if ("2quater" != si || "2ter" != si) { return 1 } # rules is not applicable to other types + if (BT_NONE && "2quater" == si) { return 0 } # should be on TC=5 instead + if (!BT_BOTH && "2ter" == si) { return 0 } # should be on TC=5 instead + if (0 in TC4 && 1 in TC4 && 2 in TC4 && 3 in TC4) { # only check if we have 4 consecutive occurrences already + if (si == TC4[0]) { count++ } + if (si == TC4[1]) { count++ } + if (si == TC4[2]) { count++ } + if (si == TC4[3]) { count++ } + if (0 == count) { return 0 } + } + return 1 +} + +func check_si_tc(tc, si) { # check that SI scheduling on BCCH Norm is matching rules from 3GPP TS 05.02 ? 6.3.1.3 + switch (si) { + case "1": return (0 == tc) ? 1 : 0 + case "2": return (1 == tc) ? 1 : 0 + case "2bis": return (5 == tc) ? 1 : 0 + case "13": return (4 == tc) ? 1 : 0 + case "9": return (4 == tc) ? 1 : 0 + case "2ter": if (BT_BOTH) { return (4 == tc) ? 1 : 0 } else { return (5 == tc) ? 1 : 0 } + case "2quater": if (BT_NONE) { return (5 == tc) ? 1 : 0 } else { return (4 == tc) ? 1 : 0 } + case "3": return (2 == tc || 6 == tc) ? 1 : 0 + case "4": return (3 == tc || 7 == tc) ? 1 : 0 + } + return 0 +} -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 10:51:08 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 11:51:08 +0100 Subject: [PATCH 1/2] Add function to add bits from array to bitvec Message-ID: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> From: Max Add function which adds specified number of bits from each element of array to the bit vector prefixing each addition with one and finishing entire sequence with adding 0. This is very common patter for various repetitive data structures described with CSN.1 in 3GPP standards. Corresponding test vectors and doxygen headers are added too. --- include/osmocom/core/bitvec.h | 3 +++ src/bitvec.c | 40 ++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.c | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/bitvec/bitvec_test.ok | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+) diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 5314cf2..c3c1153 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -91,5 +91,8 @@ void bitvec_zero(struct bitvec *bv); unsigned bitvec_rl(const struct bitvec *bv, bool b); void bitvec_shiftl(struct bitvec *bv, unsigned int n); int16_t bitvec_get_int16_msb(const struct bitvec *bv, unsigned int num_bits); +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, + unsigned int array_len, bool dry_run, + unsigned int num_bits); /*! @} */ diff --git a/src/bitvec.c b/src/bitvec.c index 00ae150..a92fd71 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -570,4 +570,44 @@ void bitvec_shiftl(struct bitvec *bv, unsigned n) bv->cur_bit -= n; } +/*! \brief Add given array to bitvec + * \param[in,out] bv bit vector to work with + * \param[in] array elements to be added + * \param[in] array_len length of array + * \param[in] dry_run indicates whether to return number of bits required + * instead of adding anything to bv for real + * \param[in] num_bits number of bits to consider in each element of array + * \returns number of bits necessary to add array elements if dry_run is true, + * 0 otherwise (only in this case bv is actually changed) + * + * N. B: no length checks are performed on bv - it's caller's job to ensure + * enough space is available - for example by calling with dry_run = true first. + * + * Useful for common pattern in CSN.1 spec which looks like: + * { 1 < XXX : bit (num_bits) > } ** 0 + * which means repeat any times (between 0 and infinity), + * start each repetition with 1, mark end of repetitions with 0 bit + * see app. note in 3GPP TS 24.007 ? B.2.1 Rule A2 + */ +unsigned int bitvec_add_array(struct bitvec *bv, const uint32_t *array, + unsigned int array_len, bool dry_run, + unsigned int num_bits) +{ + unsigned i, bits = 1; /* account for stop bit */ + for (i = 0; i < array_len; i++) { + if (dry_run) { + bits += (1 + num_bits); + } else { + bitvec_set_bit(bv, 1); + bitvec_set_uint(bv, array[i], num_bits); + } + } + + if (dry_run) + return bits; + + bitvec_set_bit(bv, 0); /* stop bit - end of the sequence */ + return 0; +} + /*! @} */ diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c index 76d6773..a98a91c 100644 --- a/tests/bitvec/bitvec_test.c +++ b/tests/bitvec/bitvec_test.c @@ -132,6 +132,43 @@ static void test_unhex(const char *hex) printf("%s\n", hex); } +static inline void test_array_item(unsigned t, struct bitvec *b, unsigned int n, + uint32_t *array, unsigned int p) +{ + unsigned int i, x, y; + bitvec_zero(b); + x = b->cur_bit; + i = bitvec_add_array(b, array, n, true, t); + y = b->cur_bit; + bitvec_add_array(b, array, n, false, t); + printf("\nbits: %u, est: %u, real: %u, x: %u, y: %u\n", + t, i, b->cur_bit, x, y); + for (i = 0; i < p; i++) { + printf(OSMO_BIT_SPEC " ", OSMO_BIT_PRINT(b->data[i])); + if (0 == (i + 1) % 15) + printf("\n"); + } +} + +static void test_array() +{ + struct bitvec b; + uint8_t d[4096]; + b.data = d; + b.data_len = sizeof(d); + + unsigned int i, n = 64; + uint32_t array[n]; + for (i = 0; i < n; i++) { + array[i] = i * i * i + i; + printf("0x%x ", array[i]); + } + + test_array_item(3, &b, n, array, n); + test_array_item(9, &b, n, array, n * 2); + test_array_item(17, &b, n, array, n * 3); +} + int main(int argc, char **argv) { struct bitvec bv; @@ -204,5 +241,11 @@ int main(int argc, char **argv) test_unhex("DEADFACE000000000000000000000000000000BEEFFEED"); test_unhex("FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); + printf("arrr...\n"); + + test_array(); + + printf("\nbitvec ok.\n"); + return 0; } diff --git a/tests/bitvec/bitvec_test.ok b/tests/bitvec/bitvec_test.ok index 1c993d3..e256108 100644 --- a/tests/bitvec/bitvec_test.ok +++ b/tests/bitvec/bitvec_test.ok @@ -134,3 +134,36 @@ DEADFACE000000000000000000000000000000BEEFFEED 0 -=> cur_bit=512 fffffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +arrr... +0x0 0x2 0xa 0x1e 0x44 0x82 0xde 0x15e 0x208 0x2e2 0x3f2 0x53e 0x6cc 0x8a2 0xac6 0xd3e 0x1010 0x1342 0x16da 0x1ade 0x1f54 0x2442 0x29ae 0x2f9e 0x3618 0x3d22 0x44c2 0x4cfe 0x55dc 0x5f62 0x6996 0x747e 0x8020 0x8c82 0x99aa 0xa79e 0xb664 0xc602 0xd67e 0xe7de 0xfa28 0x10d62 0x12192 0x136be 0x14cec 0x16422 0x17c66 0x195be 0x1b030 0x1cbc2 0x1e87a 0x2065e 0x22574 0x245c2 0x2674e 0x28a1e 0x2ae38 0x2d3a2 0x2fa62 0x3227e 0x34bfc 0x376e2 0x3a336 0x3d0fe +bits: 3, est: 257, real: 257, x: 0, y: 0 +1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. +111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. 11..1.1. 111.111. 1...1.1. 1.1.111. +11..1.1. 111.111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ +bits: 9, est: 641, real: 641, x: 0, y: 0 +1....... ..1..... ..1.1... ..1.1.1. ...1111. 1..1...1 ..1.1... ..1.1.11 .1111.11 .1.1111. 1.....1. ..1.111. ..1.1111 11..1.11 ..11111. +1.11..11 ..1.1.1. ..1.1.11 ...11.11 ..11111. 1....1.. ..11.1.. ..1.1.11 .11.1.1. 11.1111. 11.1.1.1 ..1..1.. ..1.111. 1.111.11 1..1111. +1....11. ..11..1. ..1.1.11 ....1.1. 1111111. 1111.111 ..11.11. ..1.111. .1.11.1. .111111. 1...1... ..1.1... ..1.111. 1.1.1.11 1..1111. +1..11..1 ..1..... ..1.1..1 11111.11 11.1111. 1...1.1. ..11.11. ..1.111. .1..1.1. 1.11111. 1.111.11 ..1...1. ..1.1..1 1..11.11 1.11111. +1...11.. ..1111.. ..1.1..1 111.1.1. .1.1111. 11.111.1 ..1111.. ..1.11.1 ..111.1. ...1111. 1...111. ..111.1. ..1.1..1 1...1.1. .111111. +11111111 ..1.111. ..1.11.. 11.11.1. 1111111. ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ +bits: 17, est: 1153, real: 1153, x: 0, y: 0 +1....... ........ ..1..... ........ ..1.1... ........ ..1.1.1. ........ ...1111. 1....... ...1...1 ..1..... ....1... ..1.1... ......11 +.1111.1. .......1 .1.1111. 1....... 1.....1. ..1..... ..1.111. ..1.1... ....1111 11..1.1. .....1.1 ..11111. 1......1 1.11..11 ..1..... +1...1.1. ..1.1... ..1.1.11 ...11.1. ....11.1 ..11111. 1....1.. .....1.. ..1....1 ..11.1.. ..1.1... .1.11.11 .11.1.1. ...11.1. 11.1111. +1....111 11.1.1.1 ..1...1. .1...1.. ..1.1... 1.1..11. 1.111.1. ..1.1111 1..1111. 1...11.1 1....11. ..1...11 11.1..1. ..1.1..1 ...1..11 +....1.1. .1..11.. 1111111. 1..1.1.1 .111.111 ..1..1.1 1111.11. ..1.1..1 1.1..11. .1.11.1. .111.1.. .111111. 1.1..... ....1... ..1.1... +11..1... ..1.1.1. .11..11. 1.1.1.1. 1.1..111 1..1111. 1.1.11.1 1..11..1 ..1.11.. .11..... ..1.1.11 .1.11..1 11111.1. 111..111 11.1111. +1.11111. 1...1.1. ..11.... 11.1.11. ..1.11.. 1....11. .1..1.11 ..11.11. 1.11111. 11.1..11 ..111.11 ..11.11. .1....1. ..1.11.1 1111...1 +1..11.11 1..1.1.1 1.11111. 111.11.. ....11.. ..1111.. 1.1111.. ..1.1111 1.1....1 111.1.1. .....11. .1.1111. 1...1..1 .1.111.1 ..1..1.. +.1.111.. ..1.1..1 1..111.1 ..111.1. 1...1.1. ...1111. 1.1.1.11 1...111. ..1.11.1 ..111.1. ..1.1.11 111.1..1 1...1.11 ..1...1. .111111. +11.1..1. 11111111 ..11.111 .11.111. ..1.111. 1...11.. 11.11.11 11.1.... 1111111. ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ ........ +bitvec ok. -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 10:51:09 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 11:51:09 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> From: Max Add structure representing group of EARFCNs with common priority, threshold etc. Add functions to populate this structure. --- include/osmocom/gsm/sysinfo.h | 32 ++++++++++++++++++++++++++- src/gsm/libosmogsm.map | 4 ++++ src/gsm/sysinfo.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h index 7d1fe2b..346194e 100644 --- a/include/osmocom/gsm/sysinfo.h +++ b/include/osmocom/gsm/sysinfo.h @@ -3,6 +3,9 @@ #include #include +#define OSMO_EARFCN_INVALID 666 +#define OSMO_EARFCN_MEAS_INVALID 0xff + enum osmo_sysinfo_type { SYSINFO_TYPE_NONE, SYSINFO_TYPE_1, @@ -32,9 +35,36 @@ enum osmo_sysinfo_type { _MAX_SYSINFO_TYPE }; +struct earfcn { + /* EARFCN (16 bits) array */ + uint16_t *arfcn; + /* Measurement Bandwidth (3 bits), might be absent + (OSMO_EARFCN_MEAS_INVALID is stored in this case) */ + uint8_t *meas_bw; + /* length of arfcn and meas_bw arrays (got to be the same) */ + size_t length; + /* THRESH_E-UTRAN_high (5 bits) */ + uint8_t thresh_hi; + /* THRESH_E-UTRAN_low (5 bits) */ + uint8_t thresh_lo; + /* E-UTRAN_PRIORITY (3 bits) */ + uint8_t prio; + /* E-UTRAN_QRXLEVMIN */ + uint8_t qrxlm; + /* indicates whether thresh_lo value is valid + thresh_hi is mandatory and hence always considered valid */ + bool thresh_lo_valid; + /* indicates whether prio value is valid */ + bool prio_valid; + /* indicates whether qrxlm value is valid */ + bool qrxlm_valid; +}; + typedef uint8_t sysinfo_buf_t[GSM_MACBLOCK_LEN]; extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE]; - +int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw); +int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn); +void osmo_earfcn_init(struct earfcn *e); uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type); enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si); diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 7eebe7f..9b6e8ea 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -29,6 +29,10 @@ osmo_sitype_strs; comp128; dbm2rxlev; +osmo_earfcn_add; +osmo_earfcn_del; +osmo_earfcn_init; + gprs_cipher_gen_input_i; gprs_cipher_gen_input_ui; gprs_cipher_load; diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index 1408f6b..e4d0ddf 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -125,6 +125,56 @@ const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { { 0, NULL } }; +/*! \brief Add pair of arfcn and measurement bandwith value to earfcn struct + * \param[in,out] e earfcn struct + * \param[in] arfcn EARFCN value, 16 bits + * \param[in] meas_bw measurement bandwith value + * \returns 0 on success, error otherwise + */ +int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) +{ + size_t i; + for (i = 0; i < e->length; i++) { + if (OSMO_EARFCN_INVALID == e->arfcn[i]) { + e->arfcn[i] = arfcn; + e->meas_bw[i] = meas_bw; + return 0; + } + } + return -ENOMEM; +} + +/*! \brief Delete arfcn (and corresponding measurement bandwith) from earfcn + * struct + * \param[in,out] e earfcn struct + * \param[in] arfcn EARFCN value, 16 bits + * \returns 0 on success, error otherwise + */ +int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) +{ + size_t i; + for (i = 0; i < e->length; i++) { + if (arfcn == e->arfcn[i]) { + e->arfcn[i] = OSMO_EARFCN_INVALID; + e->meas_bw[i] = OSMO_EARFCN_MEAS_INVALID; + return 0; + } + } + return -ENOENT; +} + +/*! \brief Initialize earfcn struct + * \param[in,out] e earfcn struct + */ +void osmo_earfcn_init(struct earfcn *e) +{ + size_t i; + for (i = 0; i < e->length; i++) { + e->arfcn[i] = OSMO_EARFCN_INVALID; + e->meas_bw[i] = OSMO_EARFCN_MEAS_INVALID; + } +} + uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type) { return sitype2rsl[si_type]; -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 11:32:12 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 12:32:12 +0100 Subject: [PATCH] Fix SI2ter scheduling Message-ID: <1458214332-23726-1-git-send-email-msuraev@sysmocom.de> From: Max According to 3GPP TS 05.02 ? 6.3.1.3 SI2ter messages should be scheduled in FN with TC=4 only if SI2bis messages are also available. --- src/common/sysinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index f079199..ee42da2 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -76,9 +76,10 @@ uint8_t *bts_sysinfo_get(struct gsm_bts *bts, struct gsm_time *g_time) /* iterate over 2ter, 2quater, 9, 13 */ /* determine how many SI we need to send on TC=4, * and which of them we send when */ - if (BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) { + if (BTS_HAS_SI(bts, SYSINFO_TYPE_2ter) && + BTS_HAS_SI(bts, SYSINFO_TYPE_2bis)) { tc4_sub[tc4_cnt] = SYSINFO_TYPE_2ter; - tc4_cnt += 1; /* 2bis */ + tc4_cnt += 1; } if (BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) && (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) || -- 2.7.3 From laforge at gnumonks.org Thu Mar 17 13:03:24 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 14:03:24 +0100 Subject: [PATCH 3/3] Add utility to check proper scheduling of SI In-Reply-To: <1458211044-11184-3-git-send-email-msuraev@sysmocom.de> References: <1458211044-11184-1-git-send-email-msuraev@sysmocom.de> <1458211044-11184-3-git-send-email-msuraev@sysmocom.de> Message-ID: <20160317130324.GK8342@nataraja> Hi Max, I merged all three of your patches in this series. On Thu, Mar 17, 2016 at 11:37:24AM +0100, msuraev at sysmocom.de wrote: > There are several types of System Information messages with tricky > scheduling rules described in 3GPP TS 05.02 ? 6.3.1.3. This GNU Awk > script takes in .csv file with sequence of scheduled SI messages (for > example generated using tshark from GSMTAP capture - see usage note > inside the script) and check the scheduling rules compliance. I think this is overly complicatd and it requires tshark, relies on tshark string output stays constant/backwards-compatible/... I would have preferred if this was a simple C program that parses the GSMTAP header to detemine frame number and other derived timing information, simply checks for frames sent on BCCH and then checks the L3 msg_type to determine whcih SI message is being sent. Such a small C-language program could/should be compiled alongside with the other test programs, and wouldn't have any external dependencies or depend on implementation details of those dependencies not changing over time. I understand that one advantage of using a different tool like tshark is of course that they parse the messages with a different implementation. But then, we only need to extract very few fields, like * arfcn * gsm frame number * channel type BCCH * L3 message ID and there's no real parsing of the SI message content involved. So next time for similar tasks, please try to avoid constructs like tshark+gawk, particularly if all that's neded would pe possible to do in one relatively simple C source file using the osmocom abstraction for sockets, definition of gsmtap messages, etc. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Thu Mar 17 13:11:05 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 14:11:05 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160317131105.GL8342@nataraja> Hi Max, I have already merged the patch, but now have one more comment that should definitely be addressed ASAP: On Thu, Mar 17, 2016 at 11:51:09AM +0100, msuraev at sysmocom.de wrote: > +struct earfcn { 1) this misses the osmo_ prefix which must be used for all new data types and symbols in the libraries 2) it is not just an EARFCN (which is an integer), but it is actually some SI-specific EARFCN parameters. So please let's give it a proper name. like osmo_earfcn_meas_pars (for measurement parameters) or the like. Please provide a follow-up patch quickly so we can resolve this before any users rely on the old naming. Thanks. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Thu Mar 17 12:48:46 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 13:48:46 +0100 Subject: [PATCH] Fix SI2ter scheduling In-Reply-To: <1458214332-23726-1-git-send-email-msuraev@sysmocom.de> References: <1458214332-23726-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160317124846.GJ8342@nataraja> On Thu, Mar 17, 2016 at 12:32:12PM +0100, msuraev at sysmocom.de wrote: > According to 3GPP TS 05.02 ? 6.3.1.3 SI2ter messages should be scheduled > in FN with TC=4 only if SI2bis messages are also available. thanks, merged -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Thu Mar 17 13:17:13 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 14:17:13 +0100 Subject: [PATCH] move to hex TMSI representation In-Reply-To: <1458141243-8236-1-git-send-email-axilirator@gmail.com> References: <20160316102231.GK15482@nataraja> <1458141243-8236-1-git-send-email-axilirator@gmail.com> Message-ID: <20160317131713.GM8342@nataraja> Hi Vadim, I've merged both of your patches, thanks! If you have time, please check if there are other occurrences in OpenBSC or OsmocomBB where the TMSI is printed as integer. Thanks! Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Thu Mar 17 13:29:33 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 17 Mar 2016 14:29:33 +0100 Subject: [PATCH] move to hex TMSI representation In-Reply-To: <20160317131713.GM8342@nataraja> References: <20160316102231.GK15482@nataraja> <1458141243-8236-1-git-send-email-axilirator@gmail.com> <20160317131713.GM8342@nataraja> Message-ID: > On 17 Mar 2016, at 14:17, Harald Welte wrote: > > Hi Vadim, Hi Guys, > I've merged both of your patches, thanks! I think it was a bit too quick. I foresee one problem. Let's assume someone is using TMSIs and now upgrade the sourcecode. All CM Service Requests will fail because the TMSI is not known. What is the migration/mitigation plan? -#define tmsi_from_string(str) strtoul(str, NULL, 10) +#define tmsi_from_string(str) strtoul(str + 2, NULL, 16) is problematic too: 1.) E.g. gsm48_mi_to_string(mi_string, sizeof(mi_string), idi->mi, idi->mi_len); ... subscr = subscr_get_by_tmsi(bts->network->subscr_group, tmsi_from_string(mi_string)); tmsi_from_string will not work for this anymore. 2.) there is no length check but that doesn't seem to be a big issue right now. * I think the above hunk should be reverted * a DB schema upgrade and store the TMSI as uint32_t * Use hex presentation in VTY What do you think? From msuraev at sysmocom.de Thu Mar 17 13:46:19 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 14:46:19 +0100 Subject: [PATCH] Rename struct to better match libosmocore conventions Message-ID: <1458222379-24053-1-git-send-email-msuraev@sysmocom.de> From: Max --- include/osmocom/gsm/sysinfo.h | 8 ++++---- src/gsm/sysinfo.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h index 346194e..e2fc09d 100644 --- a/include/osmocom/gsm/sysinfo.h +++ b/include/osmocom/gsm/sysinfo.h @@ -35,7 +35,7 @@ enum osmo_sysinfo_type { _MAX_SYSINFO_TYPE }; -struct earfcn { +struct osmo_earfcn_si2q { /* EARFCN (16 bits) array */ uint16_t *arfcn; /* Measurement Bandwidth (3 bits), might be absent @@ -63,8 +63,8 @@ struct earfcn { typedef uint8_t sysinfo_buf_t[GSM_MACBLOCK_LEN]; extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE]; -int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw); -int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn); -void osmo_earfcn_init(struct earfcn *e); +int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw); +int osmo_earfcn_del(struct osmo_earfcn_si2q *e, uint16_t arfcn); +void osmo_earfcn_init(struct osmo_earfcn_si2q *e); uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type); enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si); diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index e4d0ddf..42e717f 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -131,7 +131,7 @@ const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { * \param[in] meas_bw measurement bandwith value * \returns 0 on success, error otherwise */ -int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) +int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw) { size_t i; for (i = 0; i < e->length; i++) { @@ -150,7 +150,7 @@ int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) * \param[in] arfcn EARFCN value, 16 bits * \returns 0 on success, error otherwise */ -int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) +int osmo_earfcn_del(struct osmo_earfcn_si2q *e, uint16_t arfcn) { size_t i; for (i = 0; i < e->length; i++) { @@ -166,7 +166,7 @@ int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) /*! \brief Initialize earfcn struct * \param[in,out] e earfcn struct */ -void osmo_earfcn_init(struct earfcn *e) +void osmo_earfcn_init(struct osmo_earfcn_si2q *e) { size_t i; for (i = 0; i < e->length; i++) { -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 14:08:39 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 15:08:39 +0100 Subject: [PATCH] Fix earfcn struct header Message-ID: <1458223719-2238-1-git-send-email-msuraev@sysmocom.de> From: Max Rename struct to better match libosmocore naming conventions. Add missing header. --- include/osmocom/gsm/sysinfo.h | 9 +++++---- src/gsm/sysinfo.c | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h index 346194e..cb7e10d 100644 --- a/include/osmocom/gsm/sysinfo.h +++ b/include/osmocom/gsm/sysinfo.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -35,7 +36,7 @@ enum osmo_sysinfo_type { _MAX_SYSINFO_TYPE }; -struct earfcn { +struct osmo_earfcn_si2q { /* EARFCN (16 bits) array */ uint16_t *arfcn; /* Measurement Bandwidth (3 bits), might be absent @@ -63,8 +64,8 @@ struct earfcn { typedef uint8_t sysinfo_buf_t[GSM_MACBLOCK_LEN]; extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE]; -int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw); -int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn); -void osmo_earfcn_init(struct earfcn *e); +int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw); +int osmo_earfcn_del(struct osmo_earfcn_si2q *e, uint16_t arfcn); +void osmo_earfcn_init(struct osmo_earfcn_si2q *e); uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type); enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si); diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index e4d0ddf..42e717f 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -131,7 +131,7 @@ const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { * \param[in] meas_bw measurement bandwith value * \returns 0 on success, error otherwise */ -int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) +int osmo_earfcn_add(struct osmo_earfcn_si2q *e, uint16_t arfcn, uint8_t meas_bw) { size_t i; for (i = 0; i < e->length; i++) { @@ -150,7 +150,7 @@ int osmo_earfcn_add(struct earfcn *e, uint16_t arfcn, uint8_t meas_bw) * \param[in] arfcn EARFCN value, 16 bits * \returns 0 on success, error otherwise */ -int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) +int osmo_earfcn_del(struct osmo_earfcn_si2q *e, uint16_t arfcn) { size_t i; for (i = 0; i < e->length; i++) { @@ -166,7 +166,7 @@ int osmo_earfcn_del(struct earfcn *e, uint16_t arfcn) /*! \brief Initialize earfcn struct * \param[in,out] e earfcn struct */ -void osmo_earfcn_init(struct earfcn *e) +void osmo_earfcn_init(struct osmo_earfcn_si2q *e) { size_t i; for (i = 0; i < e->length; i++) { -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 14:10:05 2016 From: msuraev at sysmocom.de (Max) Date: Thu, 17 Mar 2016 15:10:05 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <20160317131105.GL8342@nataraja> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> <20160317131105.GL8342@nataraja> Message-ID: <56EABABD.50201@sysmocom.de> Done - see Fix earfcn struct header patch. On 03/17/2016 02:11 PM, Harald Welte wrote: > Hi Max, > > I have already merged the patch, but now have one more comment that > should definitely be addressed ASAP: > > On Thu, Mar 17, 2016 at 11:51:09AM +0100, msuraev at sysmocom.de wrote: >> +struct earfcn { > 1) this misses the osmo_ prefix which must be used for all new data > types and symbols in the libraries > > 2) it is not just an EARFCN (which is an integer), but it is actually > some SI-specific EARFCN parameters. So please let's give it a proper > name. like osmo_earfcn_meas_pars (for measurement parameters) or the > like. > > Please provide a follow-up patch quickly so we can resolve this before > any users rely on the old naming. Thanks. > > Regards, > Harald -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Thu Mar 17 13:43:35 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 14:43:35 +0100 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: <20160316102231.GK15482@nataraja> <1458141243-8236-1-git-send-email-axilirator@gmail.com> <20160317131713.GM8342@nataraja> Message-ID: <20160317134335.GA2085@nataraja> Hi Holger, On Thu, Mar 17, 2016 at 02:29:33PM +0100, Holger Freyther wrote: > I think it was a bit too quick. I foresee one problem. Let's assume > someone is using TMSIs and now upgrade the sourcecode. All CM Service > Requests will fail because the TMSI is not known. What is the > migration/mitigation plan? ugh. I failed to see that for some strange reason we store the TMSI as "TEXT" in the database. That's really odd, especailly as we use %u formatting when searching for TMSIs in the database. > * I think the above hunk should be reverted done. > * a DB schema upgrade and store the TMSI as uint32_t correct. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From msuraev at sysmocom.de Thu Mar 17 14:42:26 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 15:42:26 +0100 Subject: [PATCH 1/2] Improve BSSGP debug output Message-ID: <1458225747-19222-1-git-send-email-msuraev@sysmocom.de> From: Max Print string representation of Cause IE and PDU type instead of numerical value. --- src/gb/gprs_bssgp.c | 28 ++++++++++++++-------------- src/gb/gprs_bssgp_bss.c | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index e3e69c9..d9d8ccd 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -896,8 +896,8 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_CREATE_BSS_PFC_NACK: case BSSGP_PDUT_MODIFY_BSS_PFC: case BSSGP_PDUT_DELETE_BSS_PFC_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] " - "implemented\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s not [yet] " + "implemented\n", bctx->bvci, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg); break; /* those only exist in the SGSN -> BSS direction */ @@ -907,14 +907,14 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_RA_CAPA_UPDATE_ACK: case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK: case BSSGP_PDUT_FLOW_CONTROL_MS_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x only exists " - "in DL\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type %s only exists in DL\n", + bctx->bvci, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x unknown\n", - bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type %s unknown\n", + bctx->bvci, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -999,14 +999,14 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_BVC_BLOCK_ACK: case BSSGP_PDUT_BVC_UNBLOCK_ACK: case BSSGP_PDUT_SGSN_INVOKE_TRACE: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x only exists " - "in DL\n", bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s only exists in DL\n", + bvci, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x unknown\n", - bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type %s unknown\n", + bvci, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -1066,8 +1066,8 @@ int bssgp_rcvmsg(struct msgb *msg) if (!bctx && bvci != BVCI_SIGNALLING && pdu_type != BSSGP_PDUT_BVC_RESET) { LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU " - "type %u for unknown BVCI\n", msgb_nsei(msg), bvci, - pdu_type); + "type %s for unknown BVCI\n", msgb_nsei(msg), bvci, + bssgp_pdu_str(pdu_type)); return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg); } @@ -1079,9 +1079,9 @@ int bssgp_rcvmsg(struct msgb *msg) rc = bssgp_rx_ptp(msg, &tp, bctx); else LOGP(DBSSGP, LOGL_NOTICE, - "NSEI=%u/BVCI=%u Cannot handle PDU type %u for " + "NSEI=%u/BVCI=%u Cannot handle PDU type %s for " "unknown BVCI, NS BVCI %u\n", - msgb_nsei(msg), bvci, pdu_type, ns_bvci); + msgb_nsei(msg), bvci, bssgp_pdu_str(pdu_type), ns_bvci); return rc; } diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 3a9012e..61ed0c4 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -135,7 +135,7 @@ static struct msgb *common_tx_radio_status(struct bssgp_bvc_ctx *bctx) static int common_tx_radio_status2(struct msgb *msg, uint8_t cause) { msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause); - LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u\n", cause); + LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%s\n", bssgp_cause_str(cause)); return gprs_ns_sendmsg(bssgp_nsi, msg); } @@ -247,7 +247,7 @@ int bssgp_tx_bvc_block(struct bssgp_bvc_ctx *bctx, uint8_t cause) uint16_t _bvci = htons(bctx->bvci); LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-BLOCK " - "CAUSE=%u\n", bctx->bvci, cause); + "CAUSE=%s\n", bctx->bvci, bssgp_cause_str(cause)); msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ @@ -287,7 +287,7 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause) uint16_t _bvci = htons(bvci); LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-RESET " - "CAUSE=%u\n", bvci, cause); + "CAUSE=%s\n", bvci, bssgp_cause_str(cause)); msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ -- 2.7.3 From msuraev at sysmocom.de Thu Mar 17 14:42:27 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 15:42:27 +0100 Subject: [PATCH 2/2] Add vty command to explicitly reset given BVCI In-Reply-To: <1458225747-19222-1-git-send-email-msuraev@sysmocom.de> References: <1458225747-19222-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458225747-19222-2-git-send-email-msuraev@sysmocom.de> From: Max It's useful for debugging and is similar to existing nsvc reset vty command. --- src/gb/gprs_bssgp_vty.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 080867b..2725d1f 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,31 @@ static void dump_bssgp(struct vty *vty, int stats) } } +DEFUN(bvc_reset, bvc_reset_cmd, + "bvc reset nsei <0-65535> bvci <0-65535>", + "Initiate BVC RESET procedure for a given NSEI and BVCI\n") +{ + uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]); + struct bssgp_bvc_ctx *bvc; + + if (!strcmp(argv[0], "reset")) + return CMD_WARNING; + + if (argc != 2) + return CMD_WARNING; + + bvc = btsctx_by_bvci_nsei(bvci, nsei); + if (!bvc) { + vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, + VTY_NEWLINE); + return CMD_WARNING; + } + int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV); + vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, + VTY_NEWLINE); + return CMD_SUCCESS; +} + #define BSSGP_STR "Show information about the BSSGP protocol\n" DEFUN(show_bssgp, show_bssgp_cmd, "show bssgp", @@ -185,6 +211,7 @@ int bssgp_vty_init(void) install_element_ve(&show_bssgp_stats_cmd); install_element_ve(&show_bvc_cmd); install_element_ve(&logging_fltr_bvc_cmd); + install_element_ve(&bvc_reset_cmd); install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd); -- 2.7.3 From holger at freyther.de Thu Mar 17 14:50:52 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 17 Mar 2016 15:50:52 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> Message-ID: <405B8765-E8B2-4C01-B5F1-491D32BA5301@freyther.de> > On 17 Mar 2016, at 11:51, msuraev at sysmocom.de wrote: > > +struct earfcn { > + /* EARFCN (16 bits) array */ > + uint16_t *arfcn; Who do you write the comments for? If for a developer, have you checked they turn up in doxygen? > + bool thresh_lo_valid; this breaks the osmo-bts build: http://jenkins.osmocom.org/jenkins/job/osmo-bts/2029/ In file included from sysinfo.c:23: /home/builder/source/workspace/osmo-bts/FIRMWARE_VERSION/master/label/linux_i386_debian_squeeze/deps/libosmocore/../install/include/osmocom/gsm/sysinfo.h:56: error: expected specifier-qualifier-list before 'bool' From nhofmeyr at sysmocom.de Thu Mar 17 15:02:07 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 17 Mar 2016 16:02:07 +0100 Subject: const question, take II In-Reply-To: <20160317070632.GP8342@nataraja> References: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> <20160316102830.GM15482@nataraja> <20160316222211.GA14207@dub6> <20160317070632.GP8342@nataraja> Message-ID: <20160317150207.GB1095@ass40.sysmocom.de> On Thu, Mar 17, 2016 at 08:06:32AM +0100, Harald Welte wrote: > This is standard practise, see the definition of memcpy: > > void *memcpy(void *dest, const void *src, size_t n); I'm very familiar with that and want to use this everywhere and always, which is why my conclusion that it apparently didn't work was quite a disappointment. Glad to see that it does work after all... What bugs me is that I don't understand the apparent corner case where it doesn't work. > > http://lists.osmocom.org/pipermail/openbsc/2016-January/001051.html > > http://lists.osmocom.org/pipermail/openbsc/2016-January/001055.html > > > > How is this different from the conclusion that Jacob confirmed two months > > ago? Is it int (primitives) vs. struct?? > > from a quick look, the above discussion was about passing the address of > a pointer, and of course if you pass that into a function, you expect > the function to be able to modify the pointer stored at that address? First, let's clarify: const int * const x; the pointer x can't be modified, neither can the int at *x be modified. const int *x; pointer x can be modified, but the int at *x can't be modified. const int **x; x can be modified, *x can be modified, but the int at **x can't be modified. right? Let's look at a simple example that works without warning: I only want to modify a pointer, not the ints. const int *func(const int *yy) { return yy + 1; } int main(void) { int y[2] = {23, 42}; int *yy = y; return *func(yy); // returns 42 } This works perfectly. I pass a pointer to a mutable int, though the function expects a pointer to a const int. No compiler warning. And the failing example again; it does the exact same thing, only it returns the modified pointer in an output-argument, using a pointer to a pointer to a const int: void func(const int **yyy) { (*yyy) ++; } int main(void) { int y[2] = {23, 42}; int *yy = y; func(&yy); return *yy; // returns 42 } And here I get the warning: cc check.c -o check check.c: In function ?main?: check.c:11:14: warning: passing argument 1 of ?func? from incompatible pointer type func(yyy); ^ check.c:1:6: note: expected ?const int **? but argument is of type ?int **? void func(const int **yyy) ^ I'm quite happy that it seems to be only a corner case, and I'll be consting aggressively and happily ever after :) Yet it's a stupid corner case. Would be great if someone had an explanation to this odd gcc behavior. Maybe it's rather a question for another mailing list, too... ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From msuraev at sysmocom.de Thu Mar 17 15:04:06 2016 From: msuraev at sysmocom.de (Max) Date: Thu, 17 Mar 2016 16:04:06 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <405B8765-E8B2-4C01-B5F1-491D32BA5301@freyther.de> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> <405B8765-E8B2-4C01-B5F1-491D32BA5301@freyther.de> Message-ID: <56EAC766.3030602@sysmocom.de> On 03/17/2016 03:50 PM, Holger Freyther wrote: >> On 17 Mar 2016, at 11:51, msuraev at sysmocom.de wrote: >> >> +struct earfcn { >> + /* EARFCN (16 bits) array */ >> + uint16_t *arfcn; > > Who do you write the comments for? If for a developer, have you checked they turn up in doxygen? For myself mostly. > > >> + bool thresh_lo_valid; > this breaks the osmo-bts build: > > http://jenkins.osmocom.org/jenkins/job/osmo-bts/2029/ > > In file included from sysinfo.c:23: > /home/builder/source/workspace/osmo-bts/FIRMWARE_VERSION/master/label/linux_i386_debian_squeeze/deps/libosmocore/../install/include/osmocom/gsm/sysinfo.h:56: error: expected specifier-qualifier-list before 'bool' > > > Fixed in "Fix earfcn struct header" patch. -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From nhofmeyr at sysmocom.de Thu Mar 17 15:33:32 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 17 Mar 2016 16:33:32 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <405B8765-E8B2-4C01-B5F1-491D32BA5301@freyther.de> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> <405B8765-E8B2-4C01-B5F1-491D32BA5301@freyther.de> Message-ID: <20160317153332.GD1095@ass40.sysmocom.de> On Thu, Mar 17, 2016 at 03:50:52PM +0100, Holger Freyther wrote: > > + bool thresh_lo_valid; why don't we have a bool type though? is there a bool in linux kernel code? ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From msuraev at sysmocom.de Thu Mar 17 15:36:35 2016 From: msuraev at sysmocom.de (Max) Date: Thu, 17 Mar 2016 16:36:35 +0100 Subject: [PATCH 2/2] Add basic EARFCN support In-Reply-To: <20160317153332.GD1095@ass40.sysmocom.de> References: <1458211869-16586-1-git-send-email-msuraev@sysmocom.de> <1458211869-16586-2-git-send-email-msuraev@sysmocom.de> <405B8765-E8B2-4C01-B5F1-491D32BA5301@freyther.de> <20160317153332.GD1095@ass40.sysmocom.de> Message-ID: <56EACF03.7080302@sysmocom.de> I've forgot to add stdbool.h to header - fixed in separate patch already. On 03/17/2016 04:33 PM, Neels Hofmeyr wrote: > On Thu, Mar 17, 2016 at 03:50:52PM +0100, Holger Freyther wrote: >>> + bool thresh_lo_valid; > why don't we have a bool type though? is there a bool in linux kernel > code? > > ~Neels > -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From laforge at gnumonks.org Thu Mar 17 15:25:48 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 16:25:48 +0100 Subject: const question, take II In-Reply-To: <20160317150207.GB1095@ass40.sysmocom.de> References: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> <20160316102830.GM15482@nataraja> <20160316222211.GA14207@dub6> <20160317070632.GP8342@nataraja> <20160317150207.GB1095@ass40.sysmocom.de> Message-ID: <20160317152548.GB2085@nataraja> Hi Neels, On Thu, Mar 17, 2016 at 04:02:07PM +0100, Neels Hofmeyr wrote: > What bugs me is that I don't understand the apparent corner case where it > doesn't work. I'm sorry, I cannot help you there. My knowledge about the corner cases is limited, and I'm happy to accept it as it hasn't been an issue yet. we rarely use pointers to pointers in the osmocom code, luckily ;) Call me ignorant, if you'd like :) -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Thu Mar 17 15:54:58 2016 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 17 Mar 2016 16:54:58 +0100 Subject: [PATCH 2/2] Add vty command to explicitly reset given BVCI In-Reply-To: <1458225747-19222-2-git-send-email-msuraev@sysmocom.de> References: <1458225747-19222-1-git-send-email-msuraev@sysmocom.de> <1458225747-19222-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160317155458.GC2085@nataraja> Hi Max, On Thu, Mar 17, 2016 at 03:42:27PM +0100, msuraev at sysmocom.de wrote: > +DEFUN(bvc_reset, bvc_reset_cmd, > + "bvc reset nsei <0-65535> bvci <0-65535>", [...] > + if (!strcmp(argv[0], "reset")) > + return CMD_WARNING; no need to do this. the generic vty parser code will make sure that you don't end up here if the command doesn't match the synfax above. > + if (argc != 2) > + return CMD_WARNING; same here. If the number of arguments is not the number of mandatory arguments, you will never get called. So while defensive programming is generally a good idea, in the VTY case it doesn't add any benefit and just makes the functions longer. We never do this kind of checking in other functions, as we rely on libosmovty to handle this. The only places where you need to check for argc is when you have optional arguments, and !strcmp() is only needed if you have something like "bvc (start|stop)" in order to determien if start or stop was stated. Also, it might make sense to prefix the entire command with bssgp so that it becomes "bssgp bvc reset ...." -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Thu Mar 17 16:21:52 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Thu, 17 Mar 2016 22:21:52 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: <20160317134335.GA2085@nataraja> References: <20160316102231.GK15482@nataraja> <1458141243-8236-1-git-send-email-axilirator@gmail.com> <20160317131713.GM8342@nataraja> <20160317134335.GA2085@nataraja> Message-ID: Hi Guys! > If you have time, please check if there are other occurrences in OpenBSC > or OsmocomBB where the TMSI is printed as integer. Thanks! No problem! :) > I think it was a bit too quick. I foresee one problem. Let's assume someone > is using TMSIs and now upgrade the sourcecode. All CM Service Requests > will fail because the TMSI is not known. What is the migration/mitigation plan? I absolutely agree with Holger. Maybe we can add some code that will check if database still stores TMSIs in old representation style and convert them to uint32_t? We can change the libmsc/db.c:db_prepare() for this purpose. > tmsi_from_string will not work for this anymore. Yes, I forgot to change the gsm_subscriber.c ... Sorry. > there is no length check but that doesn't seem to be a big issue right now. We can just write a function that will do this check instead of using #define. > * a DB schema upgrade and store the TMSI as uint32_t > * Use hex presentation in VTY +1 ? ?????????? ???????????, ??????? ?????. 2016-03-17 19:43 GMT+06:00 Harald Welte : > Hi Holger, > > On Thu, Mar 17, 2016 at 02:29:33PM +0100, Holger Freyther wrote: > > I think it was a bit too quick. I foresee one problem. Let's assume > > someone is using TMSIs and now upgrade the sourcecode. All CM Service > > Requests will fail because the TMSI is not known. What is the > > migration/mitigation plan? > > ugh. I failed to see that for some strange reason we store the TMSI as > "TEXT" in the database. That's really odd, especailly as we use %u > formatting when searching for TMSIs in the database. > > > * I think the above hunk should be reverted > > done. > > > * a DB schema upgrade and store the TMSI as uint32_t > > correct. > > -- > - Harald Welte > http://laforge.gnumonks.org/ > > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. > A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Thu Mar 17 16:34:40 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 17 Mar 2016 17:34:40 +0100 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: <20160316102231.GK15482@nataraja> <1458141243-8236-1-git-send-email-axilirator@gmail.com> <20160317131713.GM8342@nataraja> <20160317134335.GA2085@nataraja> Message-ID: <9ED6A5D4-2045-45A2-BB10-AAF0540DF432@freyther.de> > On 17 Mar 2016, at 17:21, ????? ??????? wrote: > > Hi Guys! > > > If you have time, please check if there are other occurrences in OpenBSC > > or OsmocomBB where the TMSI is printed as integer. Thanks! > > No problem! :) > > > I think it was a bit too quick. I foresee one problem. Let's assume someone > > is using TMSIs and now upgrade the sourcecode. All CM Service Requests > > will fail because the TMSI is not known. What is the migration/mitigation plan? > > I absolutely agree with Holger. Maybe we can add some code that will check > if database still stores TMSIs in old representation style and convert them to > uint32_t? We can change the libmsc/db.c:db_prepare() for this purpose. yes, we have a schema version and can just increase it. E.g. have a look at how we migrate SMS. > > > tmsi_from_string will not work for this anymore. > > Yes, I forgot to change the gsm_subscriber.c ... Sorry. it happens. thanks for contributing > > > there is no length check but that doesn't seem to be a big issue right now. > > We can just write a function that will do this check instead of using #define. I think you will not need to touch this define at all. We might want to change the name to _from_mi_string. > > > * a DB schema upgrade and store the TMSI as uint32_t > > * Use hex presentation in VTY > > +1 looking forward for the follow up. holger From msuraev at sysmocom.de Thu Mar 17 17:24:38 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 17 Mar 2016 18:24:38 +0100 Subject: [PATCH] Fix typo in error message Message-ID: <1458235478-4203-1-git-send-email-msuraev@sysmocom.de> From: Max --- src/common/vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/vty.c b/src/common/vty.c index bba6af1..b4aa616 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -222,7 +222,7 @@ DEFUN(cfg_bts_trx, cfg_bts_trx_cmd, trx = gsm_bts_trx_num(bts, trx_nr); if (!trx) { - vty_out(vty, "Unknown TRX %u. Aavialable TRX are: 0..%u%s", + vty_out(vty, "Unknown TRX %u. Available TRX are: 0..%u%s", trx_nr, bts->num_trx - 1, VTY_NEWLINE); return CMD_WARNING; } -- 2.7.3 From ruben.undheim at gmail.com Thu Mar 17 17:53:37 2016 From: ruben.undheim at gmail.com (Ruben Undheim) Date: Thu, 17 Mar 2016 18:53:37 +0100 Subject: OpenBSC now in Debian! Message-ID: <20160317175337.GA15384@macbookair> Hi, It might interest you that OpenBSC has entered Debian unstable today! https://tracker.debian.org/news/755641 Please test the package and file bugs as you find them. I haven't added init/service files yet to the package, since it needs some careful thought around what default is the best for the general users. Best regards, Ruben From nhofmeyr at sysmocom.de Fri Mar 18 10:08:53 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Fri, 18 Mar 2016 11:08:53 +0100 Subject: const question, take II In-Reply-To: <20160317152548.GB2085@nataraja> References: <1457995959-12157-1-git-send-email-nhofmeyr@sysmocom.de> <20160316102830.GM15482@nataraja> <20160316222211.GA14207@dub6> <20160317070632.GP8342@nataraja> <20160317150207.GB1095@ass40.sysmocom.de> <20160317152548.GB2085@nataraja> Message-ID: <20160318100853.GA1323@ass40.sysmocom.de> On Thu, Mar 17, 2016 at 04:25:48PM +0100, Harald Welte wrote: > Hi Neels, > > On Thu, Mar 17, 2016 at 04:02:07PM +0100, Neels Hofmeyr wrote: > > > What bugs me is that I don't understand the apparent corner case where it > > doesn't work. > > I'm sorry, I cannot help you there. My knowledge about the corner cases > is limited, and I'm happy to accept it as it hasn't been an issue yet. > we rarely use pointers to pointers in the osmocom code, luckily ;) > > Call me ignorant, if you'd like :) Heh, good answer :) At least I know now that it's a corner case. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Fri Mar 18 10:17:39 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Fri, 18 Mar 2016 11:17:39 +0100 Subject: [PATCH 2/2] Add vty command to explicitly reset given BVCI In-Reply-To: <20160317155458.GC2085@nataraja> References: <1458225747-19222-1-git-send-email-msuraev@sysmocom.de> <1458225747-19222-2-git-send-email-msuraev@sysmocom.de> <20160317155458.GC2085@nataraja> Message-ID: <20160318101739.GB1323@ass40.sysmocom.de> On Thu, Mar 17, 2016 at 04:54:58PM +0100, Harald Welte wrote: > Hi Max, > > On Thu, Mar 17, 2016 at 03:42:27PM +0100, msuraev at sysmocom.de wrote: > > +DEFUN(bvc_reset, bvc_reset_cmd, > > + "bvc reset nsei <0-65535> bvci <0-65535>", > > [...] > > > + if (!strcmp(argv[0], "reset")) > > + return CMD_WARNING; > > no need to do this. the generic vty parser code will make sure that you > don't end up here if the command doesn't match the synfax above. > > > + if (argc != 2) > > + return CMD_WARNING; > > same here. If the number of arguments is not the number of mandatory > arguments, you will never get called. I used to do the same kind of checking for my first VTY commands, until I figured out that all of the formatting is already checked ;) Quite handy. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Fri Mar 18 10:34:10 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Fri, 18 Mar 2016 11:34:10 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160317175337.GA15384@macbookair> References: <20160317175337.GA15384@macbookair> Message-ID: <20160318103410.GD1323@ass40.sysmocom.de> On Thu, Mar 17, 2016 at 06:53:37PM +0100, Ruben Undheim wrote: > Hi, > > It might interest you that OpenBSC has entered Debian unstable today! > > https://tracker.debian.org/news/755641 Nice! Thanks, Ruben!! > Please test the package and file bugs as you find them. I haven't added init/service files > yet to the package, since it needs some careful thought around what default is the best > for the general users. I agree. Also, the binaries by default typically look in ./ for config files, not using /etc/osmocom/ or something. Makes sense to me to not have service files. ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From msuraev at sysmocom.de Fri Mar 18 10:43:15 2016 From: msuraev at sysmocom.de (Max) Date: Fri, 18 Mar 2016 11:43:15 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160318103410.GD1323@ass40.sysmocom.de> References: <20160317175337.GA15384@macbookair> <20160318103410.GD1323@ass40.sysmocom.de> Message-ID: <56EBDBC3.5000307@sysmocom.de> I disagree - having .service files is a perfect way to make sure that openbsc by default use .config and hlr files in locations supplied by the package. Also it helps to improve security of the setup by using options like /"PrivateTmp", "/InaccessibleDirectories/", "/ReadOnlyDirectories/" etc. /On a related note - if there were some changes made to /debian directories while packaging it probably make sense to merge them back to upstream. Thanks for great work. ////// On 03/18/2016 11:34 AM, Neels Hofmeyr wrote: > On Thu, Mar 17, 2016 at 06:53:37PM +0100, Ruben Undheim wrote: >> Hi, >> >> It might interest you that OpenBSC has entered Debian unstable today! >> >> https://tracker.debian.org/news/755641 > Nice! Thanks, Ruben!! > > >> Please test the package and file bugs as you find them. I haven't added init/service files >> yet to the package, since it needs some careful thought around what default is the best >> for the general users. > I agree. Also, the binaries by default typically look in ./ for config > files, not using /etc/osmocom/ or something. Makes sense to me to not have > service files. > > ~Neels > -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- An HTML attachment was scrubbed... URL: From msuraev at sysmocom.de Fri Mar 18 14:31:51 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 18 Mar 2016 15:31:51 +0100 Subject: [PATCH 1/2] octphy: use octasic's routines for debug output Message-ID: <1458311512-20942-1-git-send-email-msuraev@sysmocom.de> From: Max --- src/osmo-bts-octphy/l1_if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c index 3f6cfa9..51a1c61 100644 --- a/src/osmo-bts-octphy/l1_if.c +++ b/src/osmo-bts-octphy/l1_if.c @@ -53,6 +53,8 @@ #include #define OCTVC1_RC2STRING_DECLARE #include +#define OCTVC1_ID2STRING_DECLARE +#include #include #define OCTVC1_OPT_DECLARE_DEFAULTS #include @@ -258,7 +260,7 @@ int l1if_req_compl(struct octphy_hdl *fl1h, struct msgb *msg, uint32_t cmd_id = (type_r_cmdid >> cOCTVC1_MSG_ID_BIT_OFFSET) & cOCTVC1_MSG_ID_BIT_MASK; LOGP(DL1C, LOGL_DEBUG, "l1if_req_compl(msg_len=%u, cmd_id=%s, trans_id=%u)\n", - msgb_length(msg), get_value_string(octphy_cid_vals, cmd_id), + msgb_length(msg), octvc1_id2string(cmd_id), ntohl(msg_hdr->ulTransactionId)); /* push the two common headers in front */ @@ -1171,7 +1173,7 @@ static int rx_octvc1_resp(struct msgb *msg, uint32_t msg_id, uint32_t trans_id) int rc; LOGP(DL1C, LOGL_DEBUG, "rx_octvc1_resp(msg_id=%s, trans_id=%u)\n", - get_value_string(octphy_cid_vals, msg_id), trans_id); + octvc1_rc2string(msg_id), trans_id); /* check if the response is for the oldest (first) entry in wlc_list */ first = llist_first(&fl1h->wlc_list); -- 2.7.4 From msuraev at sysmocom.de Fri Mar 18 14:31:52 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 18 Mar 2016 15:31:52 +0100 Subject: [PATCH 2/2] octphy: add support for multiple trx ids In-Reply-To: <1458311512-20942-1-git-send-email-msuraev@sysmocom.de> References: <1458311512-20942-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458311512-20942-2-git-send-email-msuraev@sysmocom.de> From: Max --- src/osmo-bts-octphy/l1_if.c | 1 + src/osmo-bts-octphy/l1_oml.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c index 51a1c61..ec61d6b 100644 --- a/src/osmo-bts-octphy/l1_if.c +++ b/src/osmo-bts-octphy/l1_if.c @@ -1550,6 +1550,7 @@ void bts_model_phy_link_set_defaults(struct phy_link *plink) void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) { + pinst->u.octphy.trx_id = pinst->num; } /*********************************************************************** diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c index 6870c52..bdf39bf 100644 --- a/src/osmo-bts-octphy/l1_oml.c +++ b/src/osmo-bts-octphy/l1_oml.c @@ -1304,6 +1304,7 @@ int l1if_trx_open(struct gsm_bts_trx *trx) oc->TrxId.byTrxId = pinst->u.octphy.trx_id; oc->Config.ulBand = osmocom_to_octphy_band(trx->bts->band, trx->arfcn); oc->Config.usArfcn = trx->arfcn; + oc->Config.usCentreArfcn = trx->bts->c0->arfcn; oc->Config.usTsc = trx->bts->bsic & 0x7; oc->Config.usBcchArfcn = trx->bts->c0->arfcn; oc->RfConfig.ulRxGainDb = plink->u.octphy.rx_gain_db; @@ -1311,9 +1312,9 @@ int l1if_trx_open(struct gsm_bts_trx *trx) oc->RfConfig.ulTxAttndB = plink->u.octphy.tx_atten_db; LOGP(DL1C, LOGL_INFO, "Tx TRX-OPEN.req(trx=%u, rf_port=%u, arfcn=%u, " - "tsc=%u, rx_gain=%u, tx_atten=%u)\n", + "center=%u, tsc=%u, rx_gain=%u, tx_atten=%u)\n", oc->TrxId.byTrxId, oc->ulRfPortIndex, oc->Config.usArfcn, - oc->Config.usTsc, oc->RfConfig.ulRxGainDb, + oc->Config.usCentreArfcn, oc->Config.usTsc, oc->RfConfig.ulRxGainDb, oc->RfConfig.ulTxAttndB); mOCTVC1_GSM_MSG_TRX_OPEN_CMD_SWAP(oc); -- 2.7.4 From msuraev at sysmocom.de Fri Mar 18 14:46:13 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Fri, 18 Mar 2016 15:46:13 +0100 Subject: [PATCH] octphy: add example configuration with 2 trx Message-ID: <1458312373-26228-1-git-send-email-msuraev@sysmocom.de> From: Max --- doc/examples/octphy/osmo-bts-trx2dsp1.cfg | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 doc/examples/octphy/osmo-bts-trx2dsp1.cfg diff --git a/doc/examples/octphy/osmo-bts-trx2dsp1.cfg b/doc/examples/octphy/osmo-bts-trx2dsp1.cfg new file mode 100644 index 0000000..48db79d --- /dev/null +++ b/doc/examples/octphy/osmo-bts-trx2dsp1.cfg @@ -0,0 +1,35 @@ +! +! OsmoBTS () configuration saved from vty +!! +! +log stderr + logging color 1 + logging timestamp 0 + logging level all everything + logging level rsl info + logging level oml info + logging level rll notice + logging level rr notice + logging level meas notice + logging level pag info + logging level l1c info + logging level l1p info + logging level dsp info + logging level abis notice +! +line vty + no login +! +phy 0 + octphy hw-addr 00:0c:de:ad:fa:ce + octphy net-device eth2 + instance 0 + instance 1 +bts 0 + band 1800 + ipa unit-id 1234 0 + oml remote-ip 127.0.0.1 + trx 0 + phy 0 instance 0 + trx 1 + phy 0 instance 1 -- 2.7.4 From holger at freyther.de Fri Mar 18 17:28:45 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 18 Mar 2016 18:28:45 +0100 Subject: Fwd: New Defects reported by Coverity Scan for Osmocom References: <56ec3452e3e2b_df54db318625d@ss1435.mail> Message-ID: > Begin forwarded message: > > From: scan-admin at coverity.com > Subject: New Defects reported by Coverity Scan for Osmocom > Date: 18 March 2016 at 18:01:06 GMT+1 > To: holger at freyther.de > > > Hi, > > Please find the latest report on new defect(s) introduced to Osmocom found with Coverity Scan. > > 2 new defect(s) introduced to Osmocom found with Coverity Scan. > > > New defect(s) Reported-by: Coverity Scan > Showing 2 of 2 defect(s) > > ________________________________________________________________________________________________________ > *** CID 76332: API usage errors (PW.TOO_MANY_PRINTF_ARGS) > /source-iuh/openbsc/openbsc/src/gprs/gprs_gmm.c: 120 in () > 114 case IU_EVENT_RAB_ASSIGN: > 115 rc = sgsn_ranap_rab_ass_resp(mm, (RANAP_RAB_SetupOrModifiedItemIEs_t *)data); > 116 break; > 117 case IU_EVENT_IU_RELEASE: > 118 mm->iu.integrity_active = 0; > 119 /* Clean up ue_conn_ctx here */ >>>> CID 76332: API usage errors (PW.TOO_MANY_PRINTF_ARGS) >>>> the format string ends before this argument > 120 LOGMMCTXP(LOGL_INFO, mm, "IU release\n", type); harmless, but easy to fix and the compiler already warns > > 46 llist_for_each_entry(conn, &network->subscr_conns, entry) { >>>> CID 76331: API usage errors (PW.PRINTF_ARG_MISMATCH) >>>> argument is incompatible with corresponding format string conversion > 47 DEBUGP(DIUCS, "%3d: %s", i++, subscr_name(conn->subscr)); please avoid side-effects like this in DEBUGP. It might be completely off but with recent changes it might or might not be evaluated depending on your logging settings. holger From laforge at gnumonks.org Fri Mar 18 18:13:26 2016 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 18 Mar 2016 19:13:26 +0100 Subject: [PATCH] Fix typo in error message In-Reply-To: <1458235478-4203-1-git-send-email-msuraev@sysmocom.de> References: <1458235478-4203-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160318181326.GN17291@nataraja> Hi Max, On Thu, Mar 17, 2016 at 06:24:38PM +0100, msuraev at sysmocom.de wrote: > From: Max Thanks, merged together with the two other octphy multi-trx related patches. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Fri Mar 18 18:45:03 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 18 Mar 2016 19:45:03 +0100 Subject: [PATCH 1/2] octphy: use octasic's routines for debug output In-Reply-To: <1458311512-20942-1-git-send-email-msuraev@sysmocom.de> References: <1458311512-20942-1-git-send-email-msuraev@sysmocom.de> Message-ID: > On 18 Mar 2016, at 15:31, msuraev at sysmocom.de wrote: > > From: Max > > > - msgb_length(msg), get_value_string(octphy_cid_vals, cmd_id), > + msgb_length(msg), octvc1_id2string(cmd_id), so what happens if you remove octphy_cid_vals fields? Is it used somewhere else? From holger at freyther.de Fri Mar 18 19:16:11 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 18 Mar 2016 20:16:11 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master Message-ID: <1458328571-87908-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther There doesn't seem to be a reason why this shouldn't be in master. The fairwaves/master branch is removing --march=native as well that looks like a good idea as well. --- debian/changelog | 11 +++++++++++ debian/compat | 1 + debian/control | 24 ++++++++++++++++++++++++ debian/copyright | 25 +++++++++++++++++++++++++ debian/osmo-trx.install | 1 + debian/rules | 15 +++++++++++++++ debian/source/format | 1 + 7 files changed, 78 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/osmo-trx.install create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..511fcb7 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +osmo-trx (0.1.9) trusty; urgency=medium + + * Ask Ivan, really + + -- Kirill Zakharenko Thu, 16 Jul 2015 12:13:46 +0000 + +osmo-trx (0.1.8) precise; urgency=low + + * Initial release (Closes: #nnnn) Sun, 9 Mar 2014 14:10:10 +0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..0aef88e --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: osmo-trx +Maintainer: Ivan Klyuchnikov +Section: net +Priority: optional +Standards-Version: 3.9.3 +Build-Depends: debhelper (>= 9), autotools-dev, libdbd-sqlite3, pkg-config, dh-autoreconf, libuhd-dev, libusb-1.0-0-dev, libboost-all-dev, hardening-wrapper +Homepage: http://openbsc.osmocom.org/trac/wiki/OsmoTRX +Vcs-Git: git://git.osmocom.org/osmo-trx +Vcs-Browser: http://cgit.osmocom.org/osmo-trx + +Package: osmo-trx +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libdbd-sqlite3 +Description: OsmoTRX is a software-defined radio transceiver that implements the Layer 1 physical layer of a BTS + +Package: osmo-trx-dbg +Architecture: any +Section: debug +Priority: extra +Depends: osmo-trx (= ${binary:Version}), ${misc:Depends} +Description: Debug symbols for the osmo-trx + Make debugging possible + + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..5f8836d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,25 @@ +The Debian packaging is: + + Copyright (C) 2014 Max + +It was downloaded from: + + git://git.osmocom.org/osmo-trx + +Upstream Authors: + + Thomas Tsou + David A. Burgess + Harvind S. Samra + Raffi Sevlian + +Copyright: + + Copyright (C) 2012-2013 Thomas Tsou + Copyright (C) 2011 Range Networks, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. + +License: + + GNU Affero General Public License, Version 3 + diff --git a/debian/osmo-trx.install b/debian/osmo-trx.install new file mode 100644 index 0000000..574e915 --- /dev/null +++ b/debian/osmo-trx.install @@ -0,0 +1 @@ +/usr/bin/osmo-trx diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4f7cf6c --- /dev/null +++ b/debian/rules @@ -0,0 +1,15 @@ +#!/usr/bin/make -f + +DEB_BUILD_HARDENING=1 + +%: + dh $@ --with autoreconf + +override_dh_auto_configure: + dh_auto_configure -- --without-sse CFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" CXXFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" + +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info + +override_dh_strip: + dh_strip --dbg-package=osmo-trx-dbg diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..9f67427 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file -- 2.6.3 From 246tnt at gmail.com Fri Mar 18 19:18:21 2016 From: 246tnt at gmail.com (Sylvain Munaut) Date: Fri, 18 Mar 2016 20:18:21 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: <1458328571-87908-1-git-send-email-holger@freyther.de> References: <1458328571-87908-1-git-send-email-holger@freyther.de> Message-ID: > dh_auto_configure -- --without-sse CFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" CXXFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" This seem awfully specific. Cheers, Sylvain From holger at freyther.de Fri Mar 18 19:22:04 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 18 Mar 2016 20:22:04 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: References: <1458328571-87908-1-git-send-email-holger@freyther.de> Message-ID: <103757C9-07E8-43C0-AF41-E3597909B297@freyther.de> > On 18 Mar 2016, at 20:18, Sylvain Munaut <246tnt at gmail.com> wrote: Hi! >> dh_auto_configure -- --without-sse CFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" CXXFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" > > This seem awfully specific. you are right. To make it worse the Makefile.am is having an -march=native in it as well. I should probably post without these flags and for now we will end up by the caps whatever the kvm builder has. I had sent a separate mail in regard to using the ifunc function attribute to determine which routines to you. holger From holger at freyther.de Fri Mar 18 19:26:52 2016 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 18 Mar 2016 20:26:52 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: <1458328519-87862-1-git-send-email-holger@moiji-mobile.com> References: <1458328519-87862-1-git-send-email-holger@moiji-mobile.com> Message-ID: <1458329212-88103-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther There doesn't seem to be a reason why this shouldn't be in master. The fairwaves/master branch is removing --march=native as well that looks like a good idea as well. --- debian/changelog | 11 +++++++++++ debian/compat | 1 + debian/control | 24 ++++++++++++++++++++++++ debian/copyright | 25 +++++++++++++++++++++++++ debian/osmo-trx.install | 1 + debian/rules | 12 ++++++++++++ debian/source/format | 1 + 7 files changed, 75 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/osmo-trx.install create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..511fcb7 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +osmo-trx (0.1.9) trusty; urgency=medium + + * Ask Ivan, really + + -- Kirill Zakharenko Thu, 16 Jul 2015 12:13:46 +0000 + +osmo-trx (0.1.8) precise; urgency=low + + * Initial release (Closes: #nnnn) Sun, 9 Mar 2014 14:10:10 +0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..0aef88e --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: osmo-trx +Maintainer: Ivan Klyuchnikov +Section: net +Priority: optional +Standards-Version: 3.9.3 +Build-Depends: debhelper (>= 9), autotools-dev, libdbd-sqlite3, pkg-config, dh-autoreconf, libuhd-dev, libusb-1.0-0-dev, libboost-all-dev, hardening-wrapper +Homepage: http://openbsc.osmocom.org/trac/wiki/OsmoTRX +Vcs-Git: git://git.osmocom.org/osmo-trx +Vcs-Browser: http://cgit.osmocom.org/osmo-trx + +Package: osmo-trx +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libdbd-sqlite3 +Description: OsmoTRX is a software-defined radio transceiver that implements the Layer 1 physical layer of a BTS + +Package: osmo-trx-dbg +Architecture: any +Section: debug +Priority: extra +Depends: osmo-trx (= ${binary:Version}), ${misc:Depends} +Description: Debug symbols for the osmo-trx + Make debugging possible + + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..5f8836d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,25 @@ +The Debian packaging is: + + Copyright (C) 2014 Max + +It was downloaded from: + + git://git.osmocom.org/osmo-trx + +Upstream Authors: + + Thomas Tsou + David A. Burgess + Harvind S. Samra + Raffi Sevlian + +Copyright: + + Copyright (C) 2012-2013 Thomas Tsou + Copyright (C) 2011 Range Networks, Inc. + Copyright (C) 2008-2011 Free Software Foundation, Inc. + +License: + + GNU Affero General Public License, Version 3 + diff --git a/debian/osmo-trx.install b/debian/osmo-trx.install new file mode 100644 index 0000000..574e915 --- /dev/null +++ b/debian/osmo-trx.install @@ -0,0 +1 @@ +/usr/bin/osmo-trx diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..9ec67e5 --- /dev/null +++ b/debian/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f + +DEB_BUILD_HARDENING=1 + +%: + dh $@ --with autoreconf + +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info + +override_dh_strip: + dh_strip --dbg-package=osmo-trx-dbg diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..9f67427 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file -- 2.6.3 From holger at freyther.de Fri Mar 18 19:42:39 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 18 Mar 2016 20:42:39 +0100 Subject: Introducing nightly debian builds Message-ID: <8EA504F4-8D3F-4A19-B8FD-E3F693997E71@freyther.de> Hi, it is my pleasure to announce that sysmocom has setup nightly debian source package builds for Osmocom. Starting from today there are daily builds for Debian7.0 (i586, amd64) and Debian8.0 (amd64). The Osmocom jenkins will build source packages once a day and upload them to the Open(SUSE) Build Service (OBS). The nice people of SuSE have created the "network:osmocom" project for us and I have created the "network:osmocom:nightly" sub-project. The Jenkins will upload source packages for: libosmocore libosmo-abis libosmo-netif libosmo-sccp libsmpp34 openbsc openggsn osmo-pcap osmo-stp (cellmgr-ng) What is missing is: osmo-bts osmo-pcu osmo-trx (in progress) The OBS page: https://build.opensuse.org/project/show/network:osmocom:nightly The Debian 7.0 repository: http://download.opensuse.org/repositories/network:/osmocom:/nightly/Debian_7.0 The Debian 8.0 repository: http://download.opensuse.org/repositories/network:/osmocom:/nightly/Debian_8.0/ Adding the repository to your system Debian 7.0 wget http://download.opensuse.org/repositories/network:/osmocom:/nightly/Debian_7.0/Release.key sha256sum Release.key => 487d3c309facae16e83b3863bc042033fd02c41eb7183ced196d83225abb5729 echo "deb http://download.opensuse.org/repositories/network:/osmocom:/nightly/Debian_7.0/ ./" > /etc/apt/sources.list.d/osmocom-nightly.list Adding the repository to your system Debian 8.0 wget http://download.opensuse.org/repositories/network:/osmocom:/nightly/Debian_8.0/Release.key sha256sum Release.key => 487d3c309facae16e83b3863bc042033fd02c41eb7183ced196d83225abb5729 echo "deb http://download.opensuse.org/repositories/network:/osmocom:/nightly/Debian_8.0/ ./" > /etc/apt/sources.list.d/osmocom-nightly.list this content will be migrated to the wiki, if you have any questions or comments I am looking forward to hear them. have a nice weekend holger From holger at freyther.de Fri Mar 18 19:59:26 2016 From: holger at freyther.de (Holger Freyther) Date: Fri, 18 Mar 2016 20:59:26 +0100 Subject: Time to rename projects.osmocom.org to osmocom.org Message-ID: Hi, I think we all liked tnt's proposal to just call it osmocom.org. Are we ready to make the redmine available as osmocom.org (and redirect www.osmocom.org, projects.osmocom.org to it)? As first step of redirects I propose: http://bb.osmocom.org/ -> http://osmocom.org/projects/baseband http://openbsc.osmocom.org/ -> http://osmocom.org/projects/openbsc http://tetra.osmocom.org/ -> http://osmocom.org/projects/tetra http://simtrace.osmocom.org/ -> http://osmocom.org/projects/simtrace http://security.osmocom.org/ -> http://osmocom.org/projects/security http://gmr.osmocom.org/ -> http://osmocom.org/projects/gmr http://sdr.osmocom.org/ -> http://osmocom.org/projects/sdr any objections or corrections to that? kind regards holger From ruben.undheim at gmail.com Sat Mar 19 06:46:07 2016 From: ruben.undheim at gmail.com (Ruben Undheim) Date: Sat, 19 Mar 2016 07:46:07 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160317175337.GA15384@macbookair> References: <20160317175337.GA15384@macbookair> Message-ID: <20160319064607.GA13873@macbookair> Some tests are unfortunately failing for several architectures (even for i386). Please see here: https://buildd.debian.org/status/package.php?p=openbsc For i386, the "db" test is failing. For powerpc, the "gsm0408" test is failing. For mips, both the "db" test and the "gsm0408" test are failing. I would appreciate any hints! Cheers, Ruben On Thu, Mar 17, 2016 at 06:53:37PM +0100, Ruben Undheim wrote: > Hi, > > It might interest you that OpenBSC has entered Debian unstable today! > > https://tracker.debian.org/news/755641 > > Please test the package and file bugs as you find them. I haven't added init/service files > yet to the package, since it needs some careful thought around what default is the best > for the general users. > > Best regards, > Ruben > From ruben.undheim at gmail.com Sat Mar 19 07:00:45 2016 From: ruben.undheim at gmail.com (Ruben Undheim) Date: Sat, 19 Mar 2016 08:00:45 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160319064607.GA13873@macbookair> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> Message-ID: <20160319070045.GA14155@macbookair> This is the error for i386 when it fails the "db" test: 3. testsuite.at:16: testing db ... ./testsuite.at:21: $abs_top_builddir/tests/db/db_test --- experr 2016-03-19 06:58:27.308000000 +0000 +++ /tmp/buildd/openbsc-0.15.0/openbsc/tests/testsuite.dir/at-groups/3/stderr 2016-03-19 06:58:27.332000000 +0000 @@ -1,2 +1,2 @@ Going to migrate from revision 3 - \ No newline at end of file +/tmp/buildd/openbsc-0.15.0/openbsc/tests/testsuite.dir/at-groups/3/test-source: line 27: 3806 Segmentation fault $abs_top_builddir/tests/db/db_test --- expout 2016-03-19 06:58:27.308000000 +0000 +++ /tmp/buildd/openbsc-0.15.0/openbsc/tests/testsuite.dir/at-groups/3/stdout 2016-03-19 06:58:27.308000000 +0000 @@ -1,4 +0,0 @@ -Testing subscriber database code. -DB: Database initialized. -DB: Database prepared. -Done ./testsuite.at:21: exit code was 139, expected 0 3. testsuite.at:16: 3. db (testsuite.at:16): FAILED (testsuite.at:21) Ruben On Sat, Mar 19, 2016 at 07:46:07AM +0100, Ruben Undheim wrote: > Some tests are unfortunately failing for several architectures (even for i386). > > Please see here: > https://buildd.debian.org/status/package.php?p=openbsc > > For i386, the "db" test is failing. > For powerpc, the "gsm0408" test is failing. > For mips, both the "db" test and the "gsm0408" test are failing. > > > I would appreciate any hints! > > Cheers, > Ruben > > On Thu, Mar 17, 2016 at 06:53:37PM +0100, Ruben Undheim wrote: > > Hi, > > > > It might interest you that OpenBSC has entered Debian unstable today! > > > > https://tracker.debian.org/news/755641 > > > > Please test the package and file bugs as you find them. I haven't added init/service files > > yet to the package, since it needs some careful thought around what default is the best > > for the general users. > > > > Best regards, > > Ruben > > From holger at freyther.de Sat Mar 19 08:23:50 2016 From: holger at freyther.de (Holger Freyther) Date: Sat, 19 Mar 2016 09:23:50 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160319064607.GA13873@macbookair> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> Message-ID: <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> > On 19 Mar 2016, at 07:46, Ruben Undheim wrote: > > Some tests are unfortunately failing for several architectures (even for i386). > > Please see here: > https://buildd.debian.org/status/package.php?p=openbsc > > For i386, the "db" test is failing. yes, libdbi and libdbd-sqlite3 has memory issues. They have been reported two years and remain unfixed. It is best to migrate away from this library. See https://sourceforge.net/p/libdbi/mailman/message/32607036/ > For powerpc, the "gsm0408" test is failing. properly byte ordering. Is GCC6 already in debian unstable? It might be easier to use gcc's new pragma that mirroring the definition. > For mips, both the "db" test and the "gsm0408" test are failing. probably combination of the BE and memory corruption From alexander.chemeris at gmail.com Sat Mar 19 21:48:24 2016 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sun, 20 Mar 2016 00:48:24 +0300 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: <103757C9-07E8-43C0-AF41-E3597909B297@freyther.de> References: <1458328571-87908-1-git-send-email-holger@freyther.de> <103757C9-07E8-43C0-AF41-E3597909B297@freyther.de> Message-ID: On Fri, Mar 18, 2016 at 10:22 PM, Holger Freyther wrote: > >> On 18 Mar 2016, at 20:18, Sylvain Munaut <246tnt at gmail.com> wrote: >>> dh_auto_configure -- --without-sse CFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" CXXFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" >> >> This seem awfully specific. > > > you are right. To make it worse the Makefile.am is having an -march=native in it as well. I should probably post without these flags and for now we will end up by the caps whatever the kvm builder has. AFAIR the detection of capabilities in osmo-trx is based on CPUID, so you'll get whatever your real CPU is having. If you're running on anything decent, you'll get SSE4.1 detected and it'll crash on Atoms. That's why we had those flags built in. With those flags it builds without SSE4.1 optimizations and can run on both Atoms and Core's, since Atom is a kind of a lowest common denominator. So I suggest you leave them until a runtime detection is implemented. Also I should probably add my copyright into relevant places. -- Regards, Alexander Chemeris. CEO, Fairwaves, Inc. https://fairwaves.co From ruben.undheim at gmail.com Sun Mar 20 11:00:03 2016 From: ruben.undheim at gmail.com (Ruben Undheim) Date: Sun, 20 Mar 2016 12:00:03 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> Message-ID: <20160320110003.GA15008@macbookair> Thanks > yes, libdbi and libdbd-sqlite3 has memory issues. They have been reported two years and remain unfixed. It is best to migrate away from this library. > > See https://sourceforge.net/p/libdbi/mailman/message/32607036/ It seems like the memory issue is there only for 32 bits architectures. Does this mean that OpenBSC does not support 32 bits architectures? or is the test case just a bit conservative? What do you propose we do? Should we ignore that test when building the Debian package, or should we not provide packages for 32 bits architectures? > > For powerpc, the "gsm0408" test is failing. > > properly byte ordering. Is GCC6 already in debian unstable? It might be easier to use gcc's new pragma that mirroring the definition. I'll try to figure out this one. Ruben From holger at freyther.de Sun Mar 20 11:04:34 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 20 Mar 2016 12:04:34 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160320110003.GA15008@macbookair> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> <20160320110003.GA15008@macbookair> Message-ID: <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> > On 20 Mar 2016, at 12:00, Ruben Undheim wrote: > > Thanks > >> yes, libdbi and libdbd-sqlite3 has memory issues. They have been reported two years and remain unfixed. It is best to migrate away from this library. >> >> See https://sourceforge.net/p/libdbi/mailman/message/32607036/ > > It seems like the memory issue is there only for 32 bits architectures. > Does this mean that OpenBSC does not support 32 bits architectures? or is the test case > just a bit conservative? > > What do you propose we do? Should we ignore that test when building the Debian package, or > should we not provide packages for 32 bits architectures? it has nothing to do with 32bit bits.. we are just lucky on memory allocations with 64bit that the out of bounds memory access does not cause a crash. The compiler or glibc might change alignment and then there will be crashes on AMD64 as well. a.) Somebody fixes libdbi/libdbd-sqlite3 b.) Somebody changes OpenBSC to not use libdbi (preferred) c.) One downgrades to libdbi 0.8.x d.) One doesn't build 32bit package kind regards holger From holger at freyther.de Sun Mar 20 17:26:30 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 20 Mar 2016 18:26:30 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: References: <1458328571-87908-1-git-send-email-holger@freyther.de> <103757C9-07E8-43C0-AF41-E3597909B297@freyther.de> Message-ID: > On 19 Mar 2016, at 22:48, Alexander Chemeris wrote: > > On Fri, Mar 18, 2016 at 10:22 PM, Holger Freyther wrote: >> >>> On 18 Mar 2016, at 20:18, Sylvain Munaut <246tnt at gmail.com> wrote: >>>> dh_auto_configure -- --without-sse CFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" CXXFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" >>> >>> This seem awfully specific. >> >> >> you are right. To make it worse the Makefile.am is having an -march=native in it as well. I should probably post without these flags and for now we will end up by the caps whatever the kvm builder has. > > AFAIR the detection of capabilities in osmo-trx is based on CPUID, so > you'll get whatever your real CPU is having. If you're running on > anything decent, you'll get SSE4.1 detected and it'll crash on Atoms. > That's why we had those flags built in. With those flags it builds > without SSE4.1 optimizations and can run on both Atoms and Core's, > since Atom is a kind of a lowest common denominator. So I suggest you > leave them until a runtime detection is implemented. #ifdef HAVE_SSE3 doesn't look like a lot like runtime detection based on CPU capabilities, my interest right now is limited to make packages available to a greater community, performance will then probably come next. holger From ruben.undheim at gmail.com Sun Mar 20 20:45:42 2016 From: ruben.undheim at gmail.com (Ruben Undheim) Date: Sun, 20 Mar 2016 21:45:42 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> <20160320110003.GA15008@macbookair> <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> Message-ID: <20160320204542.GA23664@macbookair> > it has nothing to do with 32bit bits.. we are just lucky on memory allocations with 64bit that the out of bounds memory access does not cause a crash. The compiler or glibc might change alignment and then there will be crashes on AMD64 as well. > > a.) Somebody fixes libdbi/libdbd-sqlite3 > b.) Somebody changes OpenBSC to not use libdbi (preferred) > c.) One downgrades to libdbi 0.8.x > d.) One doesn't build 32bit package I tried to rebuild libdbi-drivers (it was last built for Debian in 2014), and then the test suite for OpenBSC pass both on i386 and amd64.. That may be a temporary workaround, although probably not very safe.. Regards, Ruben From laforge at gnumonks.org Mon Mar 21 06:53:08 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 21 Mar 2016 07:53:08 +0100 Subject: Time to rename projects.osmocom.org to osmocom.org In-Reply-To: References: Message-ID: <20160321065308.GD10371@nataraja> Hi Holger, On Fri, Mar 18, 2016 at 08:59:26PM +0100, Holger Freyther wrote: > I think we all liked tnt's proposal to just call it osmocom.org. Are > we ready to make the redmine available as osmocom.org (and redirect > www.osmocom.org, projects.osmocom.org to it)? yes, and also yes for the redirects. > any objections or corrections to that? none, please go ahead. Thanks a lot! I wonder if it is worth to make the old wiki/issue trac databases (without the user password hashes!) publicly available, in case somebody has a need for old content. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Mon Mar 21 09:30:26 2016 From: holger at freyther.de (Holger hans Peter Freyther) Date: Mon, 21 Mar 2016 10:30:26 +0100 Subject: [PATCH] select: Externalize fd_set filling and dispatch Message-ID: <1458552626-1358-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther To integrate with an external event loop (in this case glib) we need to allow an application to get a filled out fd_set and then dispatch it. osmo_fds and maxfds is static and I decided to keep it that way and instead create two routines to fill the fdset and then one to dispatch the result. The public header file does not include sys/select.h and we can compile the library without select so I didn't want to require having to include this file and used void * for the parameter. --- include/osmocom/core/select.h | 6 ++++ src/select.c | 83 ++++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index b6b9e82..d71e903 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -39,4 +39,10 @@ int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); +/* + * foreign event loop integration + */ +int osmo_fd_fill_fds(void *readset, void *writeset, void *exceptset); +int osmo_fd_disp_fds(void *readset, void *writeset, void *exceptset); + /*! @} */ diff --git a/src/select.c b/src/select.c index 5421c77..c3bac2f 100644 --- a/src/select.c +++ b/src/select.c @@ -98,62 +98,49 @@ void osmo_fd_unregister(struct osmo_fd *fd) llist_del(&fd->list); } -/*! \brief select main loop integration - * \param[in] polling should we pollonly (1) or block on select (0) - */ -int osmo_select_main(int polling) +int osmo_fd_fill_fds(void *_rset, void *_wset, void *_eset) { - struct osmo_fd *ufd, *tmp; - fd_set readset, writeset, exceptset; - int work = 0, rc; - struct timeval no_time = {0, 0}; + fd_set *readset = _rset, *writeset = _wset, *exceptset = _eset; + struct osmo_fd *ufd; - FD_ZERO(&readset); - FD_ZERO(&writeset); - FD_ZERO(&exceptset); - - /* prepare read and write fdsets */ llist_for_each_entry(ufd, &osmo_fds, list) { if (ufd->when & BSC_FD_READ) - FD_SET(ufd->fd, &readset); + FD_SET(ufd->fd, readset); if (ufd->when & BSC_FD_WRITE) - FD_SET(ufd->fd, &writeset); + FD_SET(ufd->fd, writeset); if (ufd->when & BSC_FD_EXCEPT) - FD_SET(ufd->fd, &exceptset); + FD_SET(ufd->fd, exceptset); } - osmo_timers_check(); - - if (!polling) - osmo_timers_prepare(); - rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : osmo_timers_nearest()); - if (rc < 0) - return 0; + return maxfd; +} - /* fire timers */ - osmo_timers_update(); +int osmo_fd_disp_fds(void *_rset, void *_wset, void *_eset) +{ + struct osmo_fd *ufd, *tmp; + int work = 0; + fd_set *readset = _rset, *writeset = _wset, *exceptset = _eset; - /* call registered callback functions */ restart: unregistered_count = 0; llist_for_each_entry_safe(ufd, tmp, &osmo_fds, list) { int flags = 0; - if (FD_ISSET(ufd->fd, &readset)) { + if (FD_ISSET(ufd->fd, readset)) { flags |= BSC_FD_READ; - FD_CLR(ufd->fd, &readset); + FD_CLR(ufd->fd, readset); } - if (FD_ISSET(ufd->fd, &writeset)) { + if (FD_ISSET(ufd->fd, writeset)) { flags |= BSC_FD_WRITE; - FD_CLR(ufd->fd, &writeset); + FD_CLR(ufd->fd, writeset); } - if (FD_ISSET(ufd->fd, &exceptset)) { + if (FD_ISSET(ufd->fd, exceptset)) { flags |= BSC_FD_EXCEPT; - FD_CLR(ufd->fd, &exceptset); + FD_CLR(ufd->fd, exceptset); } if (flags) { @@ -167,9 +154,41 @@ restart: if (unregistered_count >= 1) goto restart; } + return work; } +/*! \brief select main loop integration + * \param[in] polling should we pollonly (1) or block on select (0) + */ +int osmo_select_main(int polling) +{ + fd_set readset, writeset, exceptset; + int rc; + struct timeval no_time = {0, 0}; + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + + /* prepare read and write fdsets */ + osmo_fd_fill_fds(&readset, &writeset, &exceptset); + + osmo_timers_check(); + + if (!polling) + osmo_timers_prepare(); + rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : osmo_timers_nearest()); + if (rc < 0) + return 0; + + /* fire timers */ + osmo_timers_update(); + + /* call registered callback functions */ + return osmo_fd_disp_fds(&readset, &writeset, &exceptset); +} + /*! @} */ #endif /* _HAVE_SYS_SELECT_H */ -- 2.6.3 From holger at freyther.de Mon Mar 21 09:55:38 2016 From: holger at freyther.de (Holger hans Peter Freyther) Date: Mon, 21 Mar 2016 10:55:38 +0100 Subject: [PATCH v2] select: Externalize fd_set filling and dispatch Message-ID: <1458554138-2040-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther To integrate with an external event loop (in this case glib) we need to allow an application to get a filled out fd_set and then dispatch it. osmo_fds and maxfds is static and I decided to keep it that way and instead create two routines to fill the fdset and then one to dispatch the result. The public header file does not include sys/select.h and we can compile the library without select so I didn't want to require having to include this file and used void * for the parameter. Mark the routines as inline to avoid a call from the select function. Confirmed that inlining has an effect on x86 using Debian's gcc-4.9.2-10 compiler --- include/osmocom/core/select.h | 6 ++++ src/select.c | 83 ++++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index b6b9e82..d71e903 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -39,4 +39,10 @@ int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); +/* + * foreign event loop integration + */ +int osmo_fd_fill_fds(void *readset, void *writeset, void *exceptset); +int osmo_fd_disp_fds(void *readset, void *writeset, void *exceptset); + /*! @} */ diff --git a/src/select.c b/src/select.c index 5421c77..5826a4d 100644 --- a/src/select.c +++ b/src/select.c @@ -98,62 +98,49 @@ void osmo_fd_unregister(struct osmo_fd *fd) llist_del(&fd->list); } -/*! \brief select main loop integration - * \param[in] polling should we pollonly (1) or block on select (0) - */ -int osmo_select_main(int polling) +inline int osmo_fd_fill_fds(void *_rset, void *_wset, void *_eset) { - struct osmo_fd *ufd, *tmp; - fd_set readset, writeset, exceptset; - int work = 0, rc; - struct timeval no_time = {0, 0}; + fd_set *readset = _rset, *writeset = _wset, *exceptset = _eset; + struct osmo_fd *ufd; - FD_ZERO(&readset); - FD_ZERO(&writeset); - FD_ZERO(&exceptset); - - /* prepare read and write fdsets */ llist_for_each_entry(ufd, &osmo_fds, list) { if (ufd->when & BSC_FD_READ) - FD_SET(ufd->fd, &readset); + FD_SET(ufd->fd, readset); if (ufd->when & BSC_FD_WRITE) - FD_SET(ufd->fd, &writeset); + FD_SET(ufd->fd, writeset); if (ufd->when & BSC_FD_EXCEPT) - FD_SET(ufd->fd, &exceptset); + FD_SET(ufd->fd, exceptset); } - osmo_timers_check(); - - if (!polling) - osmo_timers_prepare(); - rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : osmo_timers_nearest()); - if (rc < 0) - return 0; + return maxfd; +} - /* fire timers */ - osmo_timers_update(); +inline int osmo_fd_disp_fds(void *_rset, void *_wset, void *_eset) +{ + struct osmo_fd *ufd, *tmp; + int work = 0; + fd_set *readset = _rset, *writeset = _wset, *exceptset = _eset; - /* call registered callback functions */ restart: unregistered_count = 0; llist_for_each_entry_safe(ufd, tmp, &osmo_fds, list) { int flags = 0; - if (FD_ISSET(ufd->fd, &readset)) { + if (FD_ISSET(ufd->fd, readset)) { flags |= BSC_FD_READ; - FD_CLR(ufd->fd, &readset); + FD_CLR(ufd->fd, readset); } - if (FD_ISSET(ufd->fd, &writeset)) { + if (FD_ISSET(ufd->fd, writeset)) { flags |= BSC_FD_WRITE; - FD_CLR(ufd->fd, &writeset); + FD_CLR(ufd->fd, writeset); } - if (FD_ISSET(ufd->fd, &exceptset)) { + if (FD_ISSET(ufd->fd, exceptset)) { flags |= BSC_FD_EXCEPT; - FD_CLR(ufd->fd, &exceptset); + FD_CLR(ufd->fd, exceptset); } if (flags) { @@ -167,9 +154,41 @@ restart: if (unregistered_count >= 1) goto restart; } + return work; } +/*! \brief select main loop integration + * \param[in] polling should we pollonly (1) or block on select (0) + */ +int osmo_select_main(int polling) +{ + fd_set readset, writeset, exceptset; + int rc; + struct timeval no_time = {0, 0}; + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + + /* prepare read and write fdsets */ + osmo_fd_fill_fds(&readset, &writeset, &exceptset); + + osmo_timers_check(); + + if (!polling) + osmo_timers_prepare(); + rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : osmo_timers_nearest()); + if (rc < 0) + return 0; + + /* fire timers */ + osmo_timers_update(); + + /* call registered callback functions */ + return osmo_fd_disp_fds(&readset, &writeset, &exceptset); +} + /*! @} */ #endif /* _HAVE_SYS_SELECT_H */ -- 2.6.3 From nhofmeyr at sysmocom.de Mon Mar 21 11:05:50 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 21 Mar 2016 12:05:50 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> <20160320110003.GA15008@macbookair> <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> Message-ID: <20160321110550.GA4069@dub6> On Sun, Mar 20, 2016 at 12:04:34PM +0100, Holger Freyther wrote: > b.) Somebody changes OpenBSC to not use libdbi (preferred) The alternative being to use libsqlite directly? Or would you prefer a different db-wrapper lib? I also get the "deprecated" warnings about some db function calls in my compiles, so I there's a tiny incentive to fix that, too. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Mon Mar 21 11:15:32 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 21 Mar 2016 12:15:32 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: <1458328571-87908-1-git-send-email-holger@freyther.de> References: <1458328571-87908-1-git-send-email-holger@freyther.de> Message-ID: <20160321111532.GB4069@dub6> On Fri, Mar 18, 2016 at 08:16:11PM +0100, Holger Hans Peter Freyther wrote: > There doesn't seem to be a reason why this shouldn't be in master. > The fairwaves/master branch is removing --march=native as well that > looks like a good idea as well. This log message is really hard to read. > --- /dev/null > +++ b/debian/changelog > @@ -0,0 +1,11 @@ > +osmo-trx (0.1.9) trusty; urgency=medium > + > + * Ask Ivan, really this is not changelog worthy > + -- Kirill Zakharenko Thu, 16 Jul 2015 12:13:46 +0000 > + > +osmo-trx (0.1.8) precise; urgency=low > + > + * Initial release (Closes: #nnnn) + #nnnn and a truncated line?? I would appreciate if you would at least read the English in your commits once. There's a point in not wasting too much time on these details, but it's not balanced if N people have to figure out what the author meant :) ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From msuraev at sysmocom.de Mon Mar 21 14:39:02 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Mon, 21 Mar 2016 15:39:02 +0100 Subject: [PATCH] octphy: fix for multiple trx with more than 1 dsp Message-ID: <1458571142-19217-1-git-send-email-msuraev@sysmocom.de> From: Max Explicitly store and use "center" arfcn used by each dsp (1 dsp corresponds to 1 phy link). --- include/osmo-bts/phy_link.h | 3 ++- src/osmo-bts-octphy/l1_oml.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index e31971e..a559aa3 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -62,7 +62,8 @@ struct phy_link { uint32_t rf_port_index; uint32_t rx_gain_db; uint32_t tx_atten_db; - + /* arfcn used by TRX with id 0 */ + uint16_t center_arfcn; struct octphy_hdl *hdl; } octphy; } u; diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c index bdf39bf..14181dc 100644 --- a/src/osmo-bts-octphy/l1_oml.c +++ b/src/osmo-bts-octphy/l1_oml.c @@ -1304,7 +1304,14 @@ int l1if_trx_open(struct gsm_bts_trx *trx) oc->TrxId.byTrxId = pinst->u.octphy.trx_id; oc->Config.ulBand = osmocom_to_octphy_band(trx->bts->band, trx->arfcn); oc->Config.usArfcn = trx->arfcn; - oc->Config.usCentreArfcn = trx->bts->c0->arfcn; + + if (pinst->u.octphy.trx_id) + oc->Config.usCentreArfcn = plink->u.octphy.center_arfcn; + else { + oc->Config.usCentreArfcn = trx->arfcn; + plink->u.octphy.center_arfcn = trx->arfcn; + } + oc->Config.usTsc = trx->bts->bsic & 0x7; oc->Config.usBcchArfcn = trx->bts->c0->arfcn; oc->RfConfig.ulRxGainDb = plink->u.octphy.rx_gain_db; -- 2.7.4 From holger at freyther.de Mon Mar 21 14:59:36 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 21 Mar 2016 15:59:36 +0100 Subject: [PATCH] debian: Add packaging to master taken from fairwaves/master In-Reply-To: <20160321111532.GB4069@dub6> References: <1458328571-87908-1-git-send-email-holger@freyther.de> <20160321111532.GB4069@dub6> Message-ID: <7C45BF28-EFFD-4485-9149-EF9EE357A553@freyther.de> > On 21 Mar 2016, at 12:15, Neels Hofmeyr wrote: > > On Fri, Mar 18, 2016 at 08:16:11PM +0100, Holger Hans Peter Freyther wrote: >> There doesn't seem to be a reason why this shouldn't be in master. >> The fairwaves/master branch is removing --march=native as well that >> looks like a good idea as well. > > This log message is really hard to read. Okay, I had pushed this morning but I see the double negations. "There is no reason to keep this in a vendor branch" is more clear. > >> --- /dev/null >> +++ b/debian/changelog >> @@ -0,0 +1,11 @@ >> +osmo-trx (0.1.9) trusty; urgency=medium >> + >> + * Ask Ivan, really > > this is not changelog worthy Well, I had the option to start with a clean slate or takes this from Fairwaves as well. It is not a great changelog entry but I thought it is better than omitting it. > I would appreciate if you would at least read the English in your commits > once. There's a point in not wasting too much time on these details, but > it's not balanced if N people have to figure out what the author meant :) sure. From holger at freyther.de Mon Mar 21 15:01:31 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 21 Mar 2016 16:01:31 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160321110550.GA4069@dub6> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> <20160320110003.GA15008@macbookair> <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> <20160321110550.GA4069@dub6> Message-ID: <4686E856-34BC-412C-9F69-1460397D5164@freyther.de> > On 21 Mar 2016, at 12:05, Neels Hofmeyr wrote: > > On Sun, Mar 20, 2016 at 12:04:34PM +0100, Holger Freyther wrote: >> b.) Somebody changes OpenBSC to not use libdbi (preferred) > > The alternative being to use libsqlite directly? > Or would you prefer a different db-wrapper lib? Use sqlite3 directly (and preferable change the interface at the same time) > I also get the "deprecated" warnings about some db function calls in my > compiles, so I there's a tiny incentive to fix that, too. I disagree, you will force everyone to use a broken version of libdbi. holger From nhofmeyr at sysmocom.de Mon Mar 21 16:38:24 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Mon, 21 Mar 2016 17:38:24 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <4686E856-34BC-412C-9F69-1460397D5164@freyther.de> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> <20160320110003.GA15008@macbookair> <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> <20160321110550.GA4069@dub6> <4686E856-34BC-412C-9F69-1460397D5164@freyther.de> Message-ID: <20160321163824.GC14236@dub6> On Mon, Mar 21, 2016 at 04:01:31PM +0100, Holger Freyther wrote: > > I also get the "deprecated" warnings about some db function calls in my > > compiles, so I there's a tiny incentive to fix that, too. > > I disagree, you will force everyone to use a broken version of libdbi. I meant, if we move away from libdbi, I will in consequence not see those deprecation warnings anymore, which would be nice. That's all. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Mon Mar 21 16:20:43 2016 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 21 Mar 2016 17:20:43 +0100 Subject: [PATCH] octphy: fix for multiple trx with more than 1 dsp In-Reply-To: <1458571142-19217-1-git-send-email-msuraev@sysmocom.de> References: <1458571142-19217-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160321162043.GQ10371@nataraja> On Mon, Mar 21, 2016 at 03:39:02PM +0100, msuraev at sysmocom.de wrote: > Explicitly store and use "center" arfcn used by each dsp (1 dsp > corresponds to 1 phy link). thanks, merged. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Mon Mar 21 20:08:56 2016 From: holger at freyther.de (Holger Freyther) Date: Mon, 21 Mar 2016 21:08:56 +0100 Subject: OpenBSC now in Debian! In-Reply-To: <20160321163824.GC14236@dub6> References: <20160317175337.GA15384@macbookair> <20160319064607.GA13873@macbookair> <7F2C52C8-5596-45A4-937E-028E692B3326@freyther.de> <20160320110003.GA15008@macbookair> <59873589-C9A0-4BFA-AC7A-93BB5D959E70@freyther.de> <20160321110550.GA4069@dub6> <4686E856-34BC-412C-9F69-1460397D5164@freyther.de> <20160321163824.GC14236@dub6> Message-ID: > On 21 Mar 2016, at 17:38, Neels Hofmeyr wrote: > > > I meant, if we move away from libdbi, I will in consequence not see those > deprecation warnings anymore, which would be nice. That's all. ah, true. From axilirator at gmail.com Tue Mar 22 13:54:32 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Tue, 22 Mar 2016 19:54:32 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: <20160316102231.GK15482@nataraja> <1458141243-8236-1-git-send-email-axilirator@gmail.com> <20160317131713.GM8342@nataraja> <20160317134335.GA2085@nataraja> <9ED6A5D4-2045-45A2-BB10-AAF0540DF432@freyther.de> Message-ID: I just fixed some things (gsm_subscriber.c, VTY tmsi parsing) and did some tests. It works! Location Update Request with TMSI from previous network: <0002> gsm_04_08.c:1127 LOCATION UPDATING REQUEST: MI(TMSI)=0x68044a6c type=NORMAL <0001> gsm_04_08.c:144 (bts 0 trx 0 ts 0 pd 05) Sending 0x18 to MS. <0001> gsm_04_08.c:144 (bts 0 trx 0 ts 0 pd 05) Sending 0x18 to MS. Outgoing SMS from OpenBSC VTY: OpenBSC> subscriber tmsi 0xb7f861b6 sms sender tmsi 0xb7f861b6 send TEST <0002> gsm_subscriber.c:175 Subscriber not paged yet. <0004> abis_rsl.c:1465 (bts=0,trx=0,ts=0,ss=0) Activating ARFCN(***) SS(0) lctype SDCCH r=OTHER ra=0x1a ta=1 <0004> abis_rsl.c:1199 (bts=0,trx=0,ts=0,ss=0) CHANNEL ACTIVATE ACK <0000> abis_rsl.c:1653 (bts=0,trx=0,ts=0,ss=0) SAPI=0 ESTABLISH INDICATION <0000> gsm_04_08.c:3573 Dispatching 04.08 message, pdisc=6 <0003> gsm_04_08.c:1180 PAGING RESPONSE: MI(TMSI)=0xb7f861b6 <0003> gsm_04_08.c:1198 <- Channel was requested by <0003> gsm_04_08.c:1259 TX APPLICATION INFO id=0x00, len=4 <0001> gsm_04_08.c:144 (bts 0 trx 0 ts 0 pd 06) Sending 0x38 to MS. <0001> transaction.c:71 subscr=0x2363f00, net=0x2333e90 USSD request also works: <0002> gsm_04_08.c:956 <- CM SERVICE REQUEST serv_type=0x08 MI(TMSI)=0xb7f861b6 <0002> gsm_04_08_utils.c:692 -> CM SERVICE ACK As you can see, now TMSI displays in hex. I'll provide a new patch soon. ? ?????????? ???????????, ??????? ?????. 2016-03-22 18:58 GMT+06:00 ????? ??????? : > Hello, Harald! Good day, Holger! > > It looks like SQLite3 doesn't have support of unsigned 64-bit integers. :( > Of course, we can write some custom functions, which can emulate it, > but it isn't good solution, I think. > > My suggestion is to keep the TMSI column type in string format: 0xffffffff. > I need to know your opinions before starting to write a new patch. > > > ? ?????????? ???????????, > ??????? ?????. > > 2016-03-17 22:34 GMT+06:00 Holger Freyther : > >> >> > On 17 Mar 2016, at 17:21, ????? ??????? wrote: >> > >> > Hi Guys! >> > >> > > If you have time, please check if there are other occurrences in >> OpenBSC >> > > or OsmocomBB where the TMSI is printed as integer. Thanks! >> > >> > No problem! :) >> > >> > > I think it was a bit too quick. I foresee one problem. Let's assume >> someone >> > > is using TMSIs and now upgrade the sourcecode. All CM Service Requests >> > > will fail because the TMSI is not known. What is the >> migration/mitigation plan? >> > >> > I absolutely agree with Holger. Maybe we can add some code that will >> check >> > if database still stores TMSIs in old representation style and convert >> them to >> > uint32_t? We can change the libmsc/db.c:db_prepare() for this purpose. >> >> >> yes, we have a schema version and can just increase it. E.g. have a look >> at how we migrate SMS. >> >> >> >> > >> > > tmsi_from_string will not work for this anymore. >> > >> > Yes, I forgot to change the gsm_subscriber.c ... Sorry. >> >> >> it happens. thanks for contributing >> >> >> >> > >> > > there is no length check but that doesn't seem to be a big issue >> right now. >> > >> > We can just write a function that will do this check instead of using >> #define. >> >> I think you will not need to touch this define at all. We might want to >> change the name to _from_mi_string. >> >> >> > >> > > * a DB schema upgrade and store the TMSI as uint32_t >> > > * Use hex presentation in VTY >> > >> > +1 >> >> >> looking forward for the follow up. >> >> >> holger > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From msuraev at sysmocom.de Tue Mar 22 14:40:08 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 22 Mar 2016 15:40:08 +0100 Subject: [PATCH 1/5] LC15: ignore build byproducts Message-ID: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> From: Max --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f11bc4d..349cfb0 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,11 @@ src/osmo-bts-sysmo/osmo-bts-sysmo-remote src/osmo-bts-sysmo/sysmobts-mgr src/osmo-bts-sysmo/sysmobts-util +src/osmo-bts-litecell15/lc15bts-mgr +src/osmo-bts-litecell15/lc15bts-util +src/osmo-bts-litecell15/misc/.dirstamp +src/osmo-bts-litecell15/osmo-bts-lc15 + src/osmo-bts-trx/osmo-bts-trx src/osmo-bts-octphy/osmo-bts-octphy -- 2.7.4 From msuraev at sysmocom.de Tue Mar 22 14:40:09 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 22 Mar 2016 15:40:09 +0100 Subject: [PATCH 2/5] LC15: add stubs for phy link/instance defaults In-Reply-To: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458657612-12669-2-git-send-email-msuraev@sysmocom.de> From: Max --- src/osmo-bts-litecell15/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/osmo-bts-litecell15/main.c b/src/osmo-bts-litecell15/main.c index 5f2d052..ef132f8 100644 --- a/src/osmo-bts-litecell15/main.c +++ b/src/osmo-bts-litecell15/main.c @@ -93,6 +93,14 @@ int bts_model_init(struct gsm_bts *bts) return 0; } +void bts_model_phy_link_set_defaults(struct phy_link *plink) +{ +} + +void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) +{ +} + int bts_model_oml_estab(struct gsm_bts *bts) { return 0; -- 2.7.4 From msuraev at sysmocom.de Tue Mar 22 14:40:11 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 22 Mar 2016 15:40:11 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> From: Max Use bool type for boolean values. Make if order more natural. --- src/osmo-bts-litecell15/l1_if.c | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index d89cc29..d810248 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -28,7 +28,7 @@ #include #include #include - +#include #include #include @@ -96,7 +96,7 @@ static void l1if_req_timeout(void *data) } static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, - int is_system_prim, l1if_compl_cb *cb, void *data) + bool is_system_prim, l1if_compl_cb *cb, void *data) { struct wait_l1_conf *wlc; struct osmo_wqueue *wqueue; @@ -108,23 +108,7 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, wlc->cb_data = data; /* Make sure we actually have received a REQUEST type primitive */ - if (is_system_prim == 0) { - GsmL1_Prim_t *l1p = msgb_l1prim(msg); - - LOGP(DL1P, LOGL_INFO, "Tx L1 prim %s\n", - get_value_string(lc15bts_l1prim_names, l1p->id)); - - if (lc15bts_get_l1prim_type(l1p->id) != L1P_T_REQ) { - LOGP(DL1C, LOGL_ERROR, "L1 Prim %s is not a Request!\n", - get_value_string(lc15bts_l1prim_names, l1p->id)); - talloc_free(wlc); - return -EINVAL; - } - wlc->is_sys_prim = 0; - wlc->conf_prim_id = lc15bts_get_l1prim_conf(l1p->id); - wqueue = &fl1h->write_q[MQ_L1_WRITE]; - timeout_secs = 30; - } else { + if (is_system_prim) { Litecell15_Prim_t *sysp = msgb_sysprim(msg); LOGP(DL1C, LOGL_INFO, "Tx SYS prim %s\n", @@ -139,9 +123,25 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, wlc->is_sys_prim = 1; wlc->conf_prim_id = lc15bts_get_sysprim_conf(sysp->id); wqueue = &fl1h->write_q[MQ_SYS_WRITE]; - timeout_secs = 30; + } else { + GsmL1_Prim_t *l1p = msgb_l1prim(msg); + + LOGP(DL1P, LOGL_INFO, "Tx L1 prim %s\n", + get_value_string(lc15bts_l1prim_names, l1p->id)); + + if (lc15bts_get_l1prim_type(l1p->id) != L1P_T_REQ) { + LOGP(DL1C, LOGL_ERROR, "L1 Prim %s is not a Request!\n", + get_value_string(lc15bts_l1prim_names, l1p->id)); + talloc_free(wlc); + return -EINVAL; + } + wlc->is_sys_prim = 0; + wlc->conf_prim_id = lc15bts_get_l1prim_conf(l1p->id); + wqueue = &fl1h->write_q[MQ_L1_WRITE]; } + timeout_secs = 30; + /* enqueue the message in the queue and add wsc to list */ if (osmo_wqueue_enqueue(wqueue, msg) != 0) { /* So we will get a timeout but the log message might help */ @@ -163,13 +163,13 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, int l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 1, cb, data); + return _l1if_req_compl(fl1h, msg, true, cb, data); } int l1if_gsm_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 0, cb, data); + return _l1if_req_compl(fl1h, msg, false, cb, data); } /* allocate a msgb containing a GsmL1_Prim_t */ -- 2.7.4 From msuraev at sysmocom.de Tue Mar 22 14:40:12 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 22 Mar 2016 15:40:12 +0100 Subject: [PATCH 5/5] LC15: properly initialize unmapped phy instances In-Reply-To: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458657612-12669-5-git-send-email-msuraev@sysmocom.de> From: Max Fixes: OS#1665 --- src/osmo-bts-litecell15/l1_if.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index d810248..3ef2588 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -1388,6 +1388,11 @@ int bts_model_phy_link_open(struct phy_link *plink) OSMO_ASSERT(pinst); + if (!pinst->trx) { + LOGP(DL1C, LOGL_NOTICE, "Ignoring phy link %d instance %d " + "because no TRX associated with it\n", plink->num, pinst->num); + return 0; + } phy_link_state_set(plink, PHY_LINK_CONNECTING); pinst->u.lc15.hdl = l1if_open(pinst); @@ -1399,5 +1404,7 @@ int bts_model_phy_link_open(struct phy_link *plink) l1if_reset(pinst->u.lc15.hdl); phy_link_state_set(plink, PHY_LINK_CONNECTED); + + return 0; } -- 2.7.4 From msuraev at sysmocom.de Tue Mar 22 14:40:10 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 22 Mar 2016 15:40:10 +0100 Subject: [PATCH 3/5] LC15: fix segfault In-Reply-To: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458657612-12669-3-git-send-email-msuraev@sysmocom.de> From: Max Add null pointer check and propagate error. --- include/osmo-bts/phy_link.h | 5 ++++- src/osmo-bts-litecell15/l1_if.c | 6 ++++++ src/osmo-bts-litecell15/l1_if.h | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index a559aa3..5ab5d49 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -125,7 +125,10 @@ void phy_user_statechg_notif(struct phy_instance *pinst, enum phy_link_state lin static inline struct phy_instance *trx_phy_instance(struct gsm_bts_trx *trx) { - return trx->role_bts.l1h; + if (trx) + return trx->role_bts.l1h; + + return NULL; } int bts_model_phy_link_open(struct phy_link *plink); diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index f625968..d89cc29 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -1242,6 +1242,12 @@ static int reset_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp, Litecell15_Prim_t *sysp = msgb_sysprim(resp); GsmL1_Status_t status = sysp->u.layer1ResetCnf.status; + if (!fl1h) { + LOGP(DL1C, LOGL_ERROR, "reset_compl_cb() is unable to get fl1h" + " from trx\n"); + return 1; + } + LOGP(DL1C, LOGL_NOTICE, "Rx L1-RESET.conf (status=%s)\n", get_value_string(lc15bts_l1status_names, status)); diff --git a/src/osmo-bts-litecell15/l1_if.h b/src/osmo-bts-litecell15/l1_if.h index 0c8843b..773840d 100644 --- a/src/osmo-bts-litecell15/l1_if.h +++ b/src/osmo-bts-litecell15/l1_if.h @@ -117,8 +117,10 @@ int l1if_ms_pwr_ctrl(struct gsm_lchan *lchan, const int uplink_target, static inline struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx) { struct phy_instance *pinst = trx_phy_instance(trx); - OSMO_ASSERT(pinst); - return pinst->u.lc15.hdl; + if (pinst) + return pinst->u.lc15.hdl; + + return NULL; } static inline struct gsm_bts_trx *lc15l1_hdl_trx(struct lc15l1_hdl *fl1h) -- 2.7.4 From nhofmeyr at sysmocom.de Tue Mar 22 15:27:09 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 22 Mar 2016 16:27:09 +0100 Subject: [PATCH 3/5] LC15: fix segfault In-Reply-To: <1458657612-12669-3-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-3-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322152709.GD7525@ass40.sysmocom.de> On Tue, Mar 22, 2016 at 03:40:10PM +0100, msuraev at sysmocom.de wrote: > --- a/src/osmo-bts-litecell15/l1_if.h > +++ b/src/osmo-bts-litecell15/l1_if.h > @@ -117,8 +117,10 @@ int l1if_ms_pwr_ctrl(struct gsm_lchan *lchan, const int uplink_target, > static inline struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx) > { > struct phy_instance *pinst = trx_phy_instance(trx); > - OSMO_ASSERT(pinst); > - return pinst->u.lc15.hdl; > + if (pinst) > + return pinst->u.lc15.hdl; > + > + return NULL; So, an OSMO_ASSERT() is typically there to ensure that the code never ends up breaking the assertion. If the OSMO_ASSERT() ever hits, it would mean that there's something fatally wrong elsewhere in the code. Have you checked in this instance that a NULL pinst may be a valid situation that doesn't need to be asserted upon? If so, I would welcome if that were mentioned in the log message. The other chunks above look like pretty obvious improvements, yet maybe the reasons why they cause segfaults are also elsewhere in the code? (We don't always check all pointers because we "know" they are fine.) I have no idea, really, just poking / provoking verbosity ;) ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Tue Mar 22 15:39:07 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 22 Mar 2016 16:39:07 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322153907.GE7525@ass40.sysmocom.de> On Tue, Mar 22, 2016 at 03:40:11PM +0100, msuraev at sysmocom.de wrote: > - int is_system_prim, l1if_compl_cb *cb, void *data) > + bool is_system_prim, l1if_compl_cb *cb, void *data) Hey, if Max is using bool, I also want to use bool! The stance a few months ago was that I would be the first to use the bool type instead of int to indicate boolean values. Is there a consensus that using bool is fine? Thanks! ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Tue Mar 22 15:42:38 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 22 Mar 2016 16:42:38 +0100 Subject: [PATCH 5/5] LC15: properly initialize unmapped phy instances In-Reply-To: <1458657612-12669-5-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-5-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322154238.GF7525@ass40.sysmocom.de> On Tue, Mar 22, 2016 at 03:40:12PM +0100, msuraev at sysmocom.de wrote: > + LOGP(DL1C, LOGL_NOTICE, "Ignoring phy link %d instance %d " > + "because no TRX associated with it\n", plink->num, pinst->num); "no TRX is associated" ? ^^ oh well, I'm starting to split hairs again. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From msuraev at sysmocom.de Tue Mar 22 16:22:04 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Tue, 22 Mar 2016 17:22:04 +0100 Subject: [PATCH] Add helper function to convert enums to string Message-ID: <1458663724-24082-1-git-send-email-msuraev@sysmocom.de> From: Max Add convertors for gsm48_chan_mode and gsm_chan_t types which are useful for debugging. --- include/osmocom/gsm/gsm_utils.h | 2 ++ include/osmocom/gsm/protocol/gsm_04_08.h | 2 ++ src/gsm/gsm48.c | 17 +++++++++++++++++ src/gsm/gsm_utils.c | 17 +++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6458447..c9c565e 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -199,6 +199,8 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +const char * osmo_gsm48_chan_type2str(enum gsm_chan_t type); + /* Deprectated functions */ /* Limit encoding and decoding to use no more than this amount of buffer bytes */ #define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index d49b77f..78aaef2 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -347,6 +347,8 @@ enum gsm48_chan_mode { GSM48_CMODE_DATA_3k6 = 0x13, }; +const char * osmo_gsm48_chan_mode2str(enum gsm48_chan_mode); + /* Chapter 9.1.2 */ struct gsm48_ass_cmd { /* Semantic is from 10.5.2.5a */ diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index d0a2286..494c013 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -197,6 +197,23 @@ static const char *cc_state_names[32] = { "illegal state 31", }; +static const struct value_string gsm48_chan_modes[] = { + {GSM48_CMODE_SIGN, "SIGNALLING"}, + {GSM48_CMODE_SPEECH_V1, "SPEECH_V1"}, + {GSM48_CMODE_SPEECH_EFR, "SPEECH_EFR"}, + {GSM48_CMODE_SPEECH_AMR, "SPEECH_AMR"}, + {GSM48_CMODE_DATA_14k5, "DATA_14k5"}, + {GSM48_CMODE_DATA_12k0, "DATA_12k0"}, + {GSM48_CMODE_DATA_6k0, "DATA_6k0"}, + {GSM48_CMODE_DATA_3k6, "DATA_3k6"}, + { 0, NULL }, +}; + +const char * osmo_gsm48_chan_mode2str(enum gsm48_chan_mode mode) +{ + return get_value_string(gsm48_chan_modes, mode); +} + const char *gsm48_cc_state_name(uint8_t state) { if (state < ARRAY_SIZE(cc_state_names)) diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index e8e452f..16a4117 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -691,6 +691,23 @@ uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type) return tlli; } +static const struct value_string gsm48_chan_types[] = { + { GSM_LCHAN_NONE, "NONE"}, + { GSM_LCHAN_SDCCH, "SDCCH"}, + { GSM_LCHAN_TCH_F, "TCH_F"}, + { GSM_LCHAN_TCH_H, "TCH_H"}, + { GSM_LCHAN_UNKNOWN, "UNKNOWN"}, + { GSM_LCHAN_CCCH, "CCCH"}, + { GSM_LCHAN_PDTCH, "PDTCH"}, + { GSM_LCHAN_CBCH, "CBCH"}, + { 0, NULL }, +}; + +const char * osmo_gsm48_chan_type2str(enum gsm_chan_t type) +{ + return get_value_string(gsm48_chan_types, type); +} + /* Wrappers for deprecated functions: */ int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) -- 2.7.4 From nhofmeyr at sysmocom.de Tue Mar 22 17:03:55 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 22 Mar 2016 18:03:55 +0100 Subject: 3G update: stable IuCS Location Update Message-ID: <20160322170355.GA12037@ass40.sysmocom.de> Dear 3G Folks, after various problems with obtaining a stable Location Update of a 3G subscriber on our hNodeB femto-cell, we've finally succeeded today! Basically, after both MM Authentication and Integrity Protection were in place today, the phone finally started to reply to the Location Updating Accept with the expected TMSI Reallocation Complete message. After that, the phone was still cycling new Location Update Requests every half minute or so, because we were replying with the wrong LAC id = 0; Osmo-CSCN (Circuit-Switched Core Network) needs to know which RNC (like a BSC in 2G) has which Location Area Code. The RNC tells us its global RNC ID when it first connects, and the CSCN needs to match the LAC properly from prior knowledge (aka config). Now that both Integrity Protection and the matching LAC are in place during the Location Updating Accept message from the CSCN, the UE happily stays subscribed to the CSCN! It's about time, too. The reasons why it took this long to reach this admittedly meagre sounding milestone were mostly: - The fact that Osmocom did not feature a standalone MSC, which first had to be surgically separated from the BSC part (used to be the NITB). I introduced and then eradicated a few build problems in the process. - Osmocom's libmsc previously was not able to do mere MM Authentication without also enabling Ciphering, so to test MM Authentication on its own I needed a new path in the auth and ciph code. - Osmocom's libmsc so far expected to have precisely one BSC, as part of the NITB, so it simply telepathically knew "the" LAC. Now, libmsc has to figure out the LAC from a table instead. (VTY configuration to match RNCs with LACs is in the making, as well as the RNC and BSC registry itself.) So, in fact, this milestone has much more under the hood than the layman would expect. Now that we have all of these fleas numbered and in the same matchbox, the long overdue stable 3G Location Update on IuCS using the new osmo-cscn finally arrived this afternoon. As soon as this code is configurable and peer reviewed, I will move on to implement 3G paging. I do hope to shift up a gear on that, with new confidence and by now much firmer knowledge of 3G and the "Osmoverse". Lively greetings from sysmocom's open 3G lab in Berlin! Stay tuned for more Updates, soon at this Location. ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Tue Mar 22 17:40:58 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 22 Mar 2016 18:40:58 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322174058.GV10371@nataraja> Hi Max, please refrain from refactoring litecell15 code without also refactoring the osmo-bts-sysmo code (whihc was used as a template for osmo-bts-litecell15) at the same time, too. We don't want those two to diverge any more than absolutely neccessary. Thanks! -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Tue Mar 22 17:41:12 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 22 Mar 2016 18:41:12 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <20160322153907.GE7525@ass40.sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> <20160322153907.GE7525@ass40.sysmocom.de> Message-ID: <20160322174112.GW10371@nataraja> On Tue, Mar 22, 2016 at 04:39:07PM +0100, Neels Hofmeyr wrote: > Is there a consensus that using bool is fine? true. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Tue Mar 22 18:01:59 2016 From: holger at freyther.de (Holger Freyther) Date: Tue, 22 Mar 2016 19:01:59 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <20160322174058.GV10371@nataraja> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> <20160322174058.GV10371@nataraja> Message-ID: <452E31A2-749B-4281-8F4E-2EB8139CECF6@freyther.de> > On 22 Mar 2016, at 18:40, Harald Welte wrote: > > Hi Max, > > please refrain from refactoring litecell15 code without also refactoring > the osmo-bts-sysmo code (whihc was used as a template for > osmo-bts-litecell15) at the same time, too. We don't want those two to > diverge any more than absolutely neccessary. Thanks! and I prefer a minimal diff even if you change it to if (!is..) else to avoid moving the two branches. holger From laforge at gnumonks.org Tue Mar 22 18:41:04 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 22 Mar 2016 19:41:04 +0100 Subject: [PATCH 5/5] LC15: properly initialize unmapped phy instances In-Reply-To: <1458657612-12669-5-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-5-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322184104.GD10371@nataraja> Hi Max, On Tue, Mar 22, 2016 at 03:40:12PM +0100, msuraev at sysmocom.de wrote: > Fixes: OS#1665 thanks, applied. Patches 3 and 4 out of the series remain up for discussion. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Tue Mar 22 18:40:11 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 22 Mar 2016 19:40:11 +0100 Subject: [PATCH 1/5] LC15: ignore build byproducts In-Reply-To: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322184011.GB10371@nataraja> On Tue, Mar 22, 2016 at 03:40:08PM +0100, msuraev at sysmocom.de wrote: > +src/osmo-bts-litecell15/lc15bts-mgr > +src/osmo-bts-litecell15/lc15bts-util > +src/osmo-bts-litecell15/misc/.dirstamp > +src/osmo-bts-litecell15/osmo-bts-lc15 thanks, applied. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Tue Mar 22 18:40:25 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 22 Mar 2016 19:40:25 +0100 Subject: [PATCH 2/5] LC15: add stubs for phy link/instance defaults In-Reply-To: <1458657612-12669-2-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160322184025.GC10371@nataraja> On Tue, Mar 22, 2016 at 03:40:09PM +0100, msuraev at sysmocom.de wrote: > +void bts_model_phy_link_set_defaults(struct phy_link *plink) > +void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) thanks, applied. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From msuraev at sysmocom.de Wed Mar 23 14:44:08 2016 From: msuraev at sysmocom.de (Max) Date: Wed, 23 Mar 2016 15:44:08 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <20160322174058.GV10371@nataraja> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> <20160322174058.GV10371@nataraja> Message-ID: <56F2ABB8.9060205@sysmocom.de> Shouldn't we move the code in question to src/common than? On 03/22/2016 06:40 PM, Harald Welte wrote: > Hi Max, > > please refrain from refactoring litecell15 code without also refactoring > the osmo-bts-sysmo code (whihc was used as a template for > osmo-bts-litecell15) at the same time, too. We don't want those two to > diverge any more than absolutely neccessary. Thanks! > -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From msuraev at sysmocom.de Wed Mar 23 15:02:29 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 23 Mar 2016 16:02:29 +0100 Subject: [PATCH] Add helper function to convert enums to string Message-ID: <1458745349-4848-1-git-send-email-msuraev@sysmocom.de> From: Max Add convertors for gsm48_chan_mode and gsm_chan_t types which are useful for debugging. --- include/osmocom/gsm/gsm_utils.h | 2 ++ include/osmocom/gsm/protocol/gsm_04_08.h | 2 ++ src/gsm/gsm48.c | 17 +++++++++++++++++ src/gsm/gsm_utils.c | 17 +++++++++++++++++ src/gsm/libosmogsm.map | 2 ++ 5 files changed, 40 insertions(+) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6458447..c9c565e 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -199,6 +199,8 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +const char * osmo_gsm48_chan_type2str(enum gsm_chan_t type); + /* Deprectated functions */ /* Limit encoding and decoding to use no more than this amount of buffer bytes */ #define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index d49b77f..78aaef2 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -347,6 +347,8 @@ enum gsm48_chan_mode { GSM48_CMODE_DATA_3k6 = 0x13, }; +const char * osmo_gsm48_chan_mode2str(enum gsm48_chan_mode); + /* Chapter 9.1.2 */ struct gsm48_ass_cmd { /* Semantic is from 10.5.2.5a */ diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index d0a2286..494c013 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -197,6 +197,23 @@ static const char *cc_state_names[32] = { "illegal state 31", }; +static const struct value_string gsm48_chan_modes[] = { + {GSM48_CMODE_SIGN, "SIGNALLING"}, + {GSM48_CMODE_SPEECH_V1, "SPEECH_V1"}, + {GSM48_CMODE_SPEECH_EFR, "SPEECH_EFR"}, + {GSM48_CMODE_SPEECH_AMR, "SPEECH_AMR"}, + {GSM48_CMODE_DATA_14k5, "DATA_14k5"}, + {GSM48_CMODE_DATA_12k0, "DATA_12k0"}, + {GSM48_CMODE_DATA_6k0, "DATA_6k0"}, + {GSM48_CMODE_DATA_3k6, "DATA_3k6"}, + { 0, NULL }, +}; + +const char * osmo_gsm48_chan_mode2str(enum gsm48_chan_mode mode) +{ + return get_value_string(gsm48_chan_modes, mode); +} + const char *gsm48_cc_state_name(uint8_t state) { if (state < ARRAY_SIZE(cc_state_names)) diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index e8e452f..16a4117 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -691,6 +691,23 @@ uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type) return tlli; } +static const struct value_string gsm48_chan_types[] = { + { GSM_LCHAN_NONE, "NONE"}, + { GSM_LCHAN_SDCCH, "SDCCH"}, + { GSM_LCHAN_TCH_F, "TCH_F"}, + { GSM_LCHAN_TCH_H, "TCH_H"}, + { GSM_LCHAN_UNKNOWN, "UNKNOWN"}, + { GSM_LCHAN_CCCH, "CCCH"}, + { GSM_LCHAN_PDTCH, "PDTCH"}, + { GSM_LCHAN_CBCH, "CBCH"}, + { 0, NULL }, +}; + +const char * osmo_gsm48_chan_type2str(enum gsm_chan_t type) +{ + return get_value_string(gsm48_chan_types, type); +} + /* Wrappers for deprecated functions: */ int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index a6908a2..411daf2 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -25,6 +25,8 @@ abis_nm_osmo_magic; abis_nm_ipa_magic; osmo_sitype_strs; +osmo_gsm48_chan_type2str; +osmo_gsm48_chan_mode2str; comp128; dbm2rxlev; -- 2.7.4 From laforge at gnumonks.org Wed Mar 23 16:55:23 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 23 Mar 2016 17:55:23 +0100 Subject: [PATCH 4/5] LC15: refactor code to simplify understanding In-Reply-To: <56F2ABB8.9060205@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-4-git-send-email-msuraev@sysmocom.de> <20160322174058.GV10371@nataraja> <56F2ABB8.9060205@sysmocom.de> Message-ID: <20160323165522.GI10371@nataraja> Hi Max, On Wed, Mar 23, 2016 at 03:44:08PM +0100, Max wrote: > Shouldn't we move the code in question to src/common than? No, the code is similar but not identical, and the L1 interfaces of the underlying PHY are not guaranteed to stay as similar as they are. So some of the general structure can probably be further common-ized, but the details regarding the L1 interface primitives will still stay PHY (bts-model-)specific. Also, the point is that so far nobody has volunteered to do (or fund) such an effort. It is typically relatively easy for companies to take care / ownership / funding of the driver for their specific hardware, rather it is for refactoring and general code improvement. This is not specific to OsmoBTS, but you can also see this quite a lot if you look at Linux kernel development until fairly recently. It takes both an interest in long-term effects as well as a deep understanding about the nature of collaborative free software development processes to invest in the improvement of the (core/common) code. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From msuraev at sysmocom.de Wed Mar 23 18:14:50 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 23 Mar 2016 19:14:50 +0100 Subject: [PATCH 1/2] Refactor internal mncc code Message-ID: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> From: Max Consistently use enums instead of (u)int, char etc. Use bool for boolean types. Add extra debug output with channel mode and type to simplify troubleshooting. --- openbsc/include/openbsc/bsc_api.h | 4 +++- openbsc/include/openbsc/gsm_04_08.h | 2 +- openbsc/include/openbsc/mncc.h | 6 ++++-- openbsc/include/openbsc/mncc_int.h | 5 ++++- openbsc/src/libbsc/bsc_api.c | 21 ++++++++++++--------- openbsc/src/libbsc/gsm_04_08_utils.c | 12 +++--------- openbsc/src/libmsc/gsm_04_08.c | 22 +++++++++++++++++----- openbsc/src/libmsc/mncc_builtin.c | 15 +++++++++++---- openbsc/src/osmo-nitb/bsc_hack.c | 4 +++- 9 files changed, 58 insertions(+), 33 deletions(-) diff --git a/openbsc/include/openbsc/bsc_api.h b/openbsc/include/openbsc/bsc_api.h index a3d12f2..d0a0164 100644 --- a/openbsc/include/openbsc/bsc_api.h +++ b/openbsc/include/openbsc/bsc_api.h @@ -3,6 +3,8 @@ #ifndef OPENBSC_BSC_API_H #define OPENBSC_BSC_API_H +#include + #include "gsm_data.h" #define BSC_API_CONN_POL_ACCEPT 0 @@ -45,7 +47,7 @@ struct bsc_api { int bsc_api_init(struct gsm_network *network, struct bsc_api *api); int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg, int link_id, int allow_sacch); -int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate); +int gsm0808_assign_req(struct gsm_subscriber_connection *conn, enum gsm48_chan_mode chan_mode, bool full_rate); int gsm0808_cipher_mode(struct gsm_subscriber_connection *conn, int cipher, const uint8_t *key, int len, int include_imeisv); int gsm0808_page(struct gsm_bts *bts, unsigned int page_group, diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index fd0b89d..d333e13 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -79,7 +79,7 @@ int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t * 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_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode); +int gsm48_lchan_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode lchan_mode); int gsm48_rx_rr_modif_ack(struct msgb *msg); int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg); diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h index 49f0c8b..ce2f87d 100644 --- a/openbsc/include/openbsc/mncc.h +++ b/openbsc/include/openbsc/mncc.h @@ -26,6 +26,8 @@ #include #include +#include +#include #include @@ -156,8 +158,8 @@ struct gsm_mncc { int emergency; char imsi[16]; - unsigned char lchan_type; - unsigned char lchan_mode; + enum gsm_chan_t lchan_type; + enum gsm48_chan_mode lchan_mode; }; struct gsm_data_frame { diff --git a/openbsc/include/openbsc/mncc_int.h b/openbsc/include/openbsc/mncc_int.h index 213ce14..dafef25 100644 --- a/openbsc/include/openbsc/mncc_int.h +++ b/openbsc/include/openbsc/mncc_int.h @@ -3,12 +3,15 @@ #include +#include +#include + struct mncc_int { uint8_t def_codec[2]; }; extern struct mncc_int mncc_int; -uint8_t mncc_codec_for_mode(int lchan_type); +enum gsm48_chan_mode mncc_codec_for_mode(enum gsm_chan_t lchan_type); #endif diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index e6d820d..dadb082 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -21,6 +21,8 @@ * */ +#include + #include #include #include @@ -34,7 +36,7 @@ #include #include - +#include #include #define GSM0808_T10_VALUE 6, 0 @@ -155,7 +157,7 @@ static void assignment_t10_timeout(void *_conn) * Handle the multirate config */ static void handle_mr_config(struct gsm_subscriber_connection *conn, - struct gsm_lchan *lchan, int full_rate) + struct gsm_lchan *lchan, bool full_rate) { struct bsc_api *api; api = conn->bts->network->bsc_api; @@ -197,12 +199,10 @@ static void handle_mr_config(struct gsm_subscriber_connection *conn, * -> Assignment Complete/Assignment Failure * 5.) Release the SDCCH, continue signalling on the new link */ -static int handle_new_assignment(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate) +static int handle_new_assignment(struct gsm_subscriber_connection *conn, enum gsm48_chan_mode chan_mode, bool full_rate) { struct gsm_lchan *new_lchan; - int chan_type; - - chan_type = full_rate ? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H; + enum gsm_chan_t chan_type = full_rate ? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H; new_lchan = lchan_alloc(conn->bts, chan_type, 0); @@ -337,7 +337,7 @@ int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, /* * \brief Check if the given channel is compatible with the mode/fullrate */ -static int chan_compat_with_mode(struct gsm_lchan *lchan, int chan_mode, int full_rate) +static int chan_compat_with_mode(struct gsm_lchan *lchan, enum gsm48_chan_mode chan_mode, bool full_rate) { switch (chan_mode) { case GSM48_CMODE_SIGN: @@ -384,7 +384,8 @@ static int chan_compat_with_mode(struct gsm_lchan *lchan, int chan_mode, int ful * * TODO: Add multirate configuration, make it work for more than audio. */ -int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate) +int gsm0808_assign_req(struct gsm_subscriber_connection *conn, + enum gsm48_chan_mode chan_mode, bool full_rate) { struct bsc_api *api; api = conn->bts->network->bsc_api; @@ -394,7 +395,9 @@ int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, in goto error; } else { LOGP(DMSC, LOGL_NOTICE, - "Sending ChanModify for speech %d %d\n", chan_mode, full_rate); + "Sending ChanModify for speech: %s on channel %s, " + "full_rate %d\n", osmo_gsm48_chan_mode2str(chan_mode), + osmo_gsm48_chan_type2str(conn->lchan->type), full_rate); if (chan_mode == GSM48_CMODE_SPEECH_AMR) handle_mr_config(conn, conn->lchan, full_rate); diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 8c6dbef..79a8547 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -488,7 +488,7 @@ int gsm48_send_rr_ass_cmd(struct gsm_lchan *dest_lchan, struct gsm_lchan *lchan, } /* 9.1.5 Channel mode modify: Modify the mode on the MS side */ -int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, uint8_t mode) +int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode mode) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 CHN MOD"); struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); @@ -513,15 +513,9 @@ int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, uint8_t mode) return gsm48_sendmsg(msg); } -int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode) +int gsm48_lchan_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode lchan_mode) { - int rc; - - rc = gsm48_tx_chan_mode_modify(lchan, lchan_mode); - if (rc < 0) - return rc; - - return rc; + return gsm48_tx_chan_mode_modify(lchan, lchan_mode); } int gsm48_rx_rr_modif_ack(struct msgb *msg) diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1524ec4..95dd647 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -1598,11 +1599,15 @@ static int tch_map(struct gsm_lchan *lchan, struct gsm_lchan *remote_lchan) { struct gsm_bts *bts = lchan->ts->trx->bts; struct gsm_bts *remote_bts = remote_lchan->ts->trx->bts; + enum gsm_chan_t lt = lchan->type, rt = remote_lchan->type; int rc; - DEBUGP(DCC, "Setting up TCH map between (bts=%u,trx=%u,ts=%u) and (bts=%u,trx=%u,ts=%u)\n", - bts->nr, lchan->ts->trx->nr, lchan->ts->nr, - remote_bts->nr, remote_lchan->ts->trx->nr, remote_lchan->ts->nr); + DEBUGP(DCC, "Setting up TCH map between (bts=%u,trx=%u,ts=%u,%s) and " + "(bts=%u,trx=%u,ts=%u,%s)\n", + bts->nr, lchan->ts->trx->nr, lchan->ts->nr, + osmo_gsm48_chan_type2str(lt), + remote_bts->nr, remote_lchan->ts->trx->nr, remote_lchan->ts->nr, + osmo_gsm48_chan_type2str(rt)); if (bts->type != remote_bts->type) { LOGP(DCC, LOGL_ERROR, "Cannot switch calls between different BTS types yet\n"); @@ -2999,6 +3004,7 @@ static int tch_rtp_create(struct gsm_network *net, uint32_t callref) struct gsm_bts *bts; struct gsm_lchan *lchan; struct gsm_trans *trans; + enum gsm48_chan_mode m; /* Find callref */ trans = trans_find_by_callref(net, callref); @@ -3038,8 +3044,11 @@ static int tch_rtp_create(struct gsm_network *net, uint32_t callref) */ if (lchan->tch_mode == GSM48_CMODE_SIGN) { trans->conn->mncc_rtp_create_pending = 1; - return gsm0808_assign_req(trans->conn, - mncc_codec_for_mode(lchan->type), + m = mncc_codec_for_mode(lchan->type); + LOGP(DMNCC, LOGL_DEBUG, "RTP create: codec=%s, chan_type=%s\n", + osmo_gsm48_chan_mode2str(m), + osmo_gsm48_chan_type2str(lchan->type)); + return gsm0808_assign_req(trans->conn, m, lchan->type != GSM_LCHAN_TCH_H); } @@ -3068,6 +3077,9 @@ static int tch_rtp_connect(struct gsm_network *net, void *arg) } lchan = trans->conn->lchan; + LOGP(DMNCC, LOGL_DEBUG, "RTP connect: codec=%s, chan_type=%s\n", + osmo_gsm48_chan_mode2str(mncc_codec_for_mode(lchan->type)), + osmo_gsm48_chan_type2str(lchan->type)); /* TODO: Check if payload_msg_type is compatible with what we have */ if (rtp->payload_type != lchan->abis_ip.rtp_payload) { diff --git a/openbsc/src/libmsc/mncc_builtin.c b/openbsc/src/libmsc/mncc_builtin.c index 77df6fb..b1993ca 100644 --- a/openbsc/src/libmsc/mncc_builtin.c +++ b/openbsc/src/libmsc/mncc_builtin.c @@ -27,6 +27,9 @@ #include #include +#include +#include + #include #include #include @@ -65,7 +68,7 @@ static struct gsm_call *get_call_ref(uint32_t callref) return NULL; } -uint8_t mncc_codec_for_mode(int lchan_type) +enum gsm48_chan_mode mncc_codec_for_mode(enum gsm_chan_t lchan_type) { /* FIXME: check codec capabilities of the phone */ @@ -75,7 +78,7 @@ uint8_t mncc_codec_for_mode(int lchan_type) return mncc_int.def_codec[1]; } -static uint8_t determine_lchan_mode(struct gsm_mncc *setup) +static enum gsm48_chan_mode determine_lchan_mode(struct gsm_mncc *setup) { return mncc_codec_for_mode(setup->lchan_type); } @@ -138,7 +141,8 @@ static int mncc_setup_ind(struct gsm_call *call, int msg_type, memset(&mncc, 0, sizeof(struct gsm_mncc)); mncc.callref = call->callref; mncc.lchan_mode = determine_lchan_mode(setup); - DEBUGP(DMNCC, "(call %x) Modify channel mode.\n", call->callref); + DEBUGP(DMNCC, "(call %x) Modify channel mode: %s\n", call->callref, + osmo_gsm48_chan_mode2str(mncc.lchan_mode)); mncc_tx_to_cc(call->net, MNCC_LCHAN_MODIFY, &mncc); /* send setup to remote */ @@ -207,13 +211,16 @@ static int mncc_setup_cnf(struct gsm_call *call, int msg_type, DEBUGP(DMNCC, "(call %x) Bridging with remote.\n", call->callref); /* in direct mode, we always have to bridge the channels */ - if (ipacc_rtp_direct) + if (ipacc_rtp_direct) { + DEBUGP(DMNCC, "Bridging: direct RTP.\n"); return mncc_tx_to_cc(call->net, MNCC_BRIDGE, &bridge); + } /* proxy mode */ if (!net->handover.active) { /* in the no-handover case, we can bridge, i.e. use * the old RTP proxy code */ + DEBUGP(DMNCC, "Bridging: no handover is active.\n"); return mncc_tx_to_cc(call->net, MNCC_BRIDGE, &bridge); } else { /* in case of handover, we need to re-write the RTP diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index dffe642..0b360dc 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -288,8 +288,10 @@ int main(int argc, char **argv) rc = bsc_bootstrap_network(mncc_sock_from_cc, config_file); if (rc >= 0) mncc_sock_init(bsc_gsmnet, mncc_sock_path); - } else + } else { + DEBUGP(DMNCC, "Using internal MNCC handler.\n"); rc = bsc_bootstrap_network(int_mncc_recv, config_file); + } if (rc < 0) exit(1); #ifdef BUILD_SMPP -- 2.7.4 From msuraev at sysmocom.de Wed Mar 23 18:14:51 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 23 Mar 2016 19:14:51 +0100 Subject: [PATCH 2/2] Don't connect channels of incompatible voice codec In-Reply-To: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> References: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458756891-28335-2-git-send-email-msuraev@sysmocom.de> From: Max Note: ideally this situation should not happen - we should check channel compatibility before paging 2nd leg of the call. Fixes: OS#1663 --- openbsc/src/libmsc/gsm_04_08.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 95dd647..2f03f75 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1614,6 +1614,13 @@ static int tch_map(struct gsm_lchan *lchan, struct gsm_lchan *remote_lchan) return -EINVAL; } + if (lt != rt) { + LOGP(DCC, LOGL_ERROR, "Cannot patch through call with different" + " channel types: local = %s, remote = %s\n", + osmo_gsm48_chan_type2str(lt), osmo_gsm48_chan_type2str(rt)); + return -EBADSLT; + } + // todo: map between different bts types switch (bts->type) { case GSM_BTS_TYPE_NANOBTS: @@ -1851,6 +1858,26 @@ static void gsm48_cc_timeout(void *arg) } +static inline void disconnect_bridge(struct gsm_network *net, + struct gsm_mncc_bridge *bridge) +{ + struct gsm_trans *trans0 = trans_find_by_callref(net, bridge->callref[0]); + struct gsm_trans *trans1 = trans_find_by_callref(net, bridge->callref[1]); + struct gsm_mncc mx_rel; + if (!trans0 || !trans1) + return; + + memset(&mx_rel, 0, sizeof(struct gsm_mncc)); + mncc_set_cause(&mx_rel, GSM48_CAUSE_LOC_INN_NET, + GSM48_CC_CAUSE_CHAN_UNACCEPT); + + mx_rel.callref = trans0->callref; + gsm48_cc_tx_disconnect(trans0, &mx_rel); + + mx_rel.callref = trans1->callref; + gsm48_cc_tx_disconnect(trans1, &mx_rel); +} + static void gsm48_start_cc_timer(struct gsm_trans *trans, int current, int sec, int micro) { @@ -3220,7 +3247,12 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg) /* handle special messages */ switch(msg_type) { case MNCC_BRIDGE: - return tch_bridge(net, arg); + rc = tch_bridge(net, arg); + if (rc < 0) { + DEBUGP(DCC, "Failed to bridge TCH: %s\n", strerror(-rc)); + disconnect_bridge(net, arg); + } + return rc; case MNCC_FRAME_DROP: return tch_recv_mncc(net, data->callref, 0); case MNCC_FRAME_RECV: -- 2.7.4 From holger at freyther.de Wed Mar 23 18:35:16 2016 From: holger at freyther.de (Holger Freyther) Date: Wed, 23 Mar 2016 19:35:16 +0100 Subject: [PATCH 1/2] Refactor internal mncc code In-Reply-To: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> References: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> Message-ID: <2DD093EE-9C13-4960-89C1-C43A816845DC@freyther.de> > On 23 Mar 2016, at 19:14, msuraev at sysmocom.de wrote: > > From: Max > > Consistently use enums instead of (u)int, char etc. > Use bool for boolean types. > Add extra debug output with channel mode and type to simplify > troubleshooting. Nack. * You touch an external protocol that is versioned. Does the size of the structure change? Either way it needs to be in the commit messages. * You are mixing "add debug messages" and "change types". There is no connection between these two logical changes and they should not be in the same commit. From holger at freyther.de Wed Mar 23 19:05:25 2016 From: holger at freyther.de (Holger Freyther) Date: Wed, 23 Mar 2016 20:05:25 +0100 Subject: [PATCH 2/2] Don't connect channels of incompatible voice codec In-Reply-To: <1458756891-28335-2-git-send-email-msuraev@sysmocom.de> References: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> <1458756891-28335-2-git-send-email-msuraev@sysmocom.de> Message-ID: <6F4EAA9C-0414-4D6C-B592-6B7416A8DCC8@freyther.de> > On 23 Mar 2016, at 19:14, msuraev at sysmocom.de wrote: > > From: Max > > Note: ideally this situation should not happen - we should check > channel compatibility before paging 2nd leg of the call. > > > > + if (lt != rt) { lt / rt is not declared in this patch (and yes, it belongs into this one. But channel type is still not good enough. Let's assume I have a TCH/H and a TCH/F and I use AMR5.9 on both of these channels. Then the voice codec (and its parameters) are compatible. I don't know the specific ticket and ultimate goal but I think either you check for codec compatibility or change the wording to refer only to channel type and leave the actual voice codec incompat for another day. > + LOGP(DCC, LOGL_ERROR, "Cannot patch through call with different" > + " channel types: local = %s, remote = %s\n", > + osmo_gsm48_chan_type2str(lt), osmo_gsm48_chan_type2str(rt)); > + return -EBADSLT; > + } > + > // todo: map between different bts types > switch (bts->type) { > case GSM_BTS_TYPE_NANOBTS: > @@ -1851,6 +1858,26 @@ static void gsm48_cc_timeout(void *arg) > > } > > +static inline void disconnect_bridge(struct gsm_network *net, > + struct gsm_mncc_bridge *bridge) > +{ > + struct gsm_trans *trans0 = trans_find_by_callref(net, bridge->callref[0]); > + struct gsm_trans *trans1 = trans_find_by_callref(net, bridge->callref[1]); > + struct gsm_mncc mx_rel; > + if (!trans0 || !trans1) > + return; Can you please elaborate about the intention of this method? You try to undo a failed mapping and do this by disconnecting the call? Is that the right thing to do? Has there been any side effect by the call of tch_map? In the long run should there be a MNCC_BRIDGE_REJ answer to the MNCC_BRIDGE call? > @@ -3220,7 +3247,12 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg) > /* handle special messages */ > switch(msg_type) { > case MNCC_BRIDGE: > - return tch_bridge(net, arg); > + rc = tch_bridge(net, arg); > + if (rc < 0) { > + DEBUGP(DCC, "Failed to bridge TCH: %s\n", strerror(-rc)); Do you think it makes sense to include both callrefs? holger From msuraev at sysmocom.de Thu Mar 24 09:41:29 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 24 Mar 2016 10:41:29 +0100 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode Message-ID: <1458812489-21767-1-git-send-email-msuraev@sysmocom.de> From: Max This can be used with get_value_string() to improve debugging output. --- include/osmocom/gsm/gsm_utils.h | 12 ++++++++++++ include/osmocom/gsm/protocol/gsm_04_08.h | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6458447..fbe0ba0 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -199,6 +199,18 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +static const struct value_string gsm_chan_t_names[] = { + { GSM_LCHAN_NONE, "NONE" }, + { GSM_LCHAN_SDCCH, "SDCCH" }, + { GSM_LCHAN_TCH_F, "TCH_F" }, + { GSM_LCHAN_TCH_H, "TCH_H" }, + { GSM_LCHAN_UNKNOWN, "UNKNOWN" }, + { GSM_LCHAN_CCCH, "CCCH" }, + { GSM_LCHAN_PDTCH, "PDTCH" }, + { GSM_LCHAN_CBCH, "CBCH" }, + { 0, NULL }, +}; + /* Deprectated functions */ /* Limit encoding and decoding to use no more than this amount of buffer bytes */ #define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index d49b77f..87748d3 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -347,6 +347,18 @@ enum gsm48_chan_mode { GSM48_CMODE_DATA_3k6 = 0x13, }; +static const struct value_string gsm48_chan_mode_names[] = { + { GSM48_CMODE_SIGN, "SIGNALLING" }, + { GSM48_CMODE_SPEECH_V1, "SPEECH_V1" }, + { GSM48_CMODE_SPEECH_EFR, "SPEECH_EFR" }, + { GSM48_CMODE_SPEECH_AMR, "SPEECH_AMR" }, + { GSM48_CMODE_DATA_14k5, "DATA_14k5" }, + { GSM48_CMODE_DATA_12k0, "DATA_12k0" }, + { GSM48_CMODE_DATA_6k0, "DATA_6k0" }, + { GSM48_CMODE_DATA_3k6, "DATA_3k6" }, + { 0, NULL }, +}; + /* Chapter 9.1.2 */ struct gsm48_ass_cmd { /* Semantic is from 10.5.2.5a */ -- 2.7.4 From msuraev at sysmocom.de Thu Mar 24 10:54:59 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 24 Mar 2016 11:54:59 +0100 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode Message-ID: <1458816899-30771-1-git-send-email-msuraev@sysmocom.de> From: Max This can be used with get_value_string() to improve debugging output. --- include/osmocom/gsm/gsm_utils.h | 13 +++++++++++++ include/osmocom/gsm/protocol/gsm_04_08.h | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6458447..dcbee36 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -28,6 +28,7 @@ #include #include +#include #define ADD_MODULO(sum, delta, modulo) do { \ if ((sum += delta) >= modulo) \ @@ -199,6 +200,18 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +static const struct value_string gsm_chan_t_names[] = { + { GSM_LCHAN_NONE, "NONE" }, + { GSM_LCHAN_SDCCH, "SDCCH" }, + { GSM_LCHAN_TCH_F, "TCH_F" }, + { GSM_LCHAN_TCH_H, "TCH_H" }, + { GSM_LCHAN_UNKNOWN, "UNKNOWN" }, + { GSM_LCHAN_CCCH, "CCCH" }, + { GSM_LCHAN_PDTCH, "PDTCH" }, + { GSM_LCHAN_CBCH, "CBCH" }, + { 0, NULL }, +}; + /* Deprectated functions */ /* Limit encoding and decoding to use no more than this amount of buffer bytes */ #define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index d49b77f..604c86d 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -2,6 +2,8 @@ #include +#include + /* GSM TS 04.08 definitions */ struct gsm_lchan; @@ -347,6 +349,18 @@ enum gsm48_chan_mode { GSM48_CMODE_DATA_3k6 = 0x13, }; +static const struct value_string gsm48_chan_mode_names[] = { + { GSM48_CMODE_SIGN, "SIGNALLING" }, + { GSM48_CMODE_SPEECH_V1, "SPEECH_V1" }, + { GSM48_CMODE_SPEECH_EFR, "SPEECH_EFR" }, + { GSM48_CMODE_SPEECH_AMR, "SPEECH_AMR" }, + { GSM48_CMODE_DATA_14k5, "DATA_14k5" }, + { GSM48_CMODE_DATA_12k0, "DATA_12k0" }, + { GSM48_CMODE_DATA_6k0, "DATA_6k0" }, + { GSM48_CMODE_DATA_3k6, "DATA_3k6" }, + { 0, NULL }, +}; + /* Chapter 9.1.2 */ struct gsm48_ass_cmd { /* Semantic is from 10.5.2.5a */ -- 2.7.4 From msuraev at sysmocom.de Thu Mar 24 11:05:44 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 24 Mar 2016 12:05:44 +0100 Subject: [PATCH 1/2] Refactor mncc code Message-ID: <1458817545-2039-1-git-send-email-msuraev@sysmocom.de> From: Max Use bool for boolean types. Consistently use enums instead of (u)int, char etc. Note: because actual enum representation is up to compiler this might change the size of gsm_mncc struct. --- openbsc/include/openbsc/bsc_api.h | 4 +++- openbsc/include/openbsc/gsm_04_08.h | 2 +- openbsc/include/openbsc/mncc.h | 6 ++++-- openbsc/include/openbsc/mncc_int.h | 5 ++++- openbsc/src/libbsc/bsc_api.c | 17 +++++++++-------- openbsc/src/libbsc/gsm_04_08_utils.c | 12 +++--------- openbsc/src/libmsc/mncc_builtin.c | 7 +++++-- 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/openbsc/include/openbsc/bsc_api.h b/openbsc/include/openbsc/bsc_api.h index a3d12f2..d0a0164 100644 --- a/openbsc/include/openbsc/bsc_api.h +++ b/openbsc/include/openbsc/bsc_api.h @@ -3,6 +3,8 @@ #ifndef OPENBSC_BSC_API_H #define OPENBSC_BSC_API_H +#include + #include "gsm_data.h" #define BSC_API_CONN_POL_ACCEPT 0 @@ -45,7 +47,7 @@ struct bsc_api { int bsc_api_init(struct gsm_network *network, struct bsc_api *api); int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg, int link_id, int allow_sacch); -int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate); +int gsm0808_assign_req(struct gsm_subscriber_connection *conn, enum gsm48_chan_mode chan_mode, bool full_rate); int gsm0808_cipher_mode(struct gsm_subscriber_connection *conn, int cipher, const uint8_t *key, int len, int include_imeisv); int gsm0808_page(struct gsm_bts *bts, unsigned int page_group, diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index fd0b89d..d333e13 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -79,7 +79,7 @@ int gsm48_extract_mi(uint8_t *classmark2, int length, char *mi_string, uint8_t * 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_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode); +int gsm48_lchan_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode lchan_mode); int gsm48_rx_rr_modif_ack(struct msgb *msg); int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg); diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h index 49f0c8b..ce2f87d 100644 --- a/openbsc/include/openbsc/mncc.h +++ b/openbsc/include/openbsc/mncc.h @@ -26,6 +26,8 @@ #include #include +#include +#include #include @@ -156,8 +158,8 @@ struct gsm_mncc { int emergency; char imsi[16]; - unsigned char lchan_type; - unsigned char lchan_mode; + enum gsm_chan_t lchan_type; + enum gsm48_chan_mode lchan_mode; }; struct gsm_data_frame { diff --git a/openbsc/include/openbsc/mncc_int.h b/openbsc/include/openbsc/mncc_int.h index 213ce14..dafef25 100644 --- a/openbsc/include/openbsc/mncc_int.h +++ b/openbsc/include/openbsc/mncc_int.h @@ -3,12 +3,15 @@ #include +#include +#include + struct mncc_int { uint8_t def_codec[2]; }; extern struct mncc_int mncc_int; -uint8_t mncc_codec_for_mode(int lchan_type); +enum gsm48_chan_mode mncc_codec_for_mode(enum gsm_chan_t lchan_type); #endif diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index e6d820d..9ddd647 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -21,6 +21,8 @@ * */ +#include + #include #include #include @@ -34,7 +36,7 @@ #include #include - +#include #include #define GSM0808_T10_VALUE 6, 0 @@ -155,7 +157,7 @@ static void assignment_t10_timeout(void *_conn) * Handle the multirate config */ static void handle_mr_config(struct gsm_subscriber_connection *conn, - struct gsm_lchan *lchan, int full_rate) + struct gsm_lchan *lchan, bool full_rate) { struct bsc_api *api; api = conn->bts->network->bsc_api; @@ -197,12 +199,10 @@ static void handle_mr_config(struct gsm_subscriber_connection *conn, * -> Assignment Complete/Assignment Failure * 5.) Release the SDCCH, continue signalling on the new link */ -static int handle_new_assignment(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate) +static int handle_new_assignment(struct gsm_subscriber_connection *conn, enum gsm48_chan_mode chan_mode, bool full_rate) { struct gsm_lchan *new_lchan; - int chan_type; - - chan_type = full_rate ? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H; + enum gsm_chan_t chan_type = full_rate ? GSM_LCHAN_TCH_F : GSM_LCHAN_TCH_H; new_lchan = lchan_alloc(conn->bts, chan_type, 0); @@ -337,7 +337,7 @@ int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, /* * \brief Check if the given channel is compatible with the mode/fullrate */ -static int chan_compat_with_mode(struct gsm_lchan *lchan, int chan_mode, int full_rate) +static int chan_compat_with_mode(struct gsm_lchan *lchan, enum gsm48_chan_mode chan_mode, bool full_rate) { switch (chan_mode) { case GSM48_CMODE_SIGN: @@ -384,7 +384,8 @@ static int chan_compat_with_mode(struct gsm_lchan *lchan, int chan_mode, int ful * * TODO: Add multirate configuration, make it work for more than audio. */ -int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate) +int gsm0808_assign_req(struct gsm_subscriber_connection *conn, + enum gsm48_chan_mode chan_mode, bool full_rate) { struct bsc_api *api; api = conn->bts->network->bsc_api; diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 8c6dbef..79a8547 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -488,7 +488,7 @@ int gsm48_send_rr_ass_cmd(struct gsm_lchan *dest_lchan, struct gsm_lchan *lchan, } /* 9.1.5 Channel mode modify: Modify the mode on the MS side */ -int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, uint8_t mode) +int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode mode) { struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 CHN MOD"); struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); @@ -513,15 +513,9 @@ int gsm48_tx_chan_mode_modify(struct gsm_lchan *lchan, uint8_t mode) return gsm48_sendmsg(msg); } -int gsm48_lchan_modify(struct gsm_lchan *lchan, uint8_t lchan_mode) +int gsm48_lchan_modify(struct gsm_lchan *lchan, enum gsm48_chan_mode lchan_mode) { - int rc; - - rc = gsm48_tx_chan_mode_modify(lchan, lchan_mode); - if (rc < 0) - return rc; - - return rc; + return gsm48_tx_chan_mode_modify(lchan, lchan_mode); } int gsm48_rx_rr_modif_ack(struct msgb *msg) diff --git a/openbsc/src/libmsc/mncc_builtin.c b/openbsc/src/libmsc/mncc_builtin.c index 77df6fb..0942304 100644 --- a/openbsc/src/libmsc/mncc_builtin.c +++ b/openbsc/src/libmsc/mncc_builtin.c @@ -27,6 +27,9 @@ #include #include +#include +#include + #include #include #include @@ -65,7 +68,7 @@ static struct gsm_call *get_call_ref(uint32_t callref) return NULL; } -uint8_t mncc_codec_for_mode(int lchan_type) +enum gsm48_chan_mode mncc_codec_for_mode(enum gsm_chan_t lchan_type) { /* FIXME: check codec capabilities of the phone */ @@ -75,7 +78,7 @@ uint8_t mncc_codec_for_mode(int lchan_type) return mncc_int.def_codec[1]; } -static uint8_t determine_lchan_mode(struct gsm_mncc *setup) +static enum gsm48_chan_mode determine_lchan_mode(struct gsm_mncc *setup) { return mncc_codec_for_mode(setup->lchan_type); } -- 2.7.4 From msuraev at sysmocom.de Thu Mar 24 11:05:45 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 24 Mar 2016 12:05:45 +0100 Subject: [PATCH 2/2] Add extra debug output with channel mode and type In-Reply-To: <1458817545-2039-1-git-send-email-msuraev@sysmocom.de> References: <1458817545-2039-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1458817545-2039-2-git-send-email-msuraev@sysmocom.de> From: Max This provides helpful information for debugging internal MNCC handler. --- openbsc/src/libbsc/bsc_api.c | 6 ++++-- openbsc/src/libmsc/gsm_04_08.c | 23 ++++++++++++++++++----- openbsc/src/libmsc/mncc_builtin.c | 3 ++- openbsc/src/osmo-nitb/bsc_hack.c | 4 +++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 9ddd647..2607cb6 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -394,11 +394,13 @@ int gsm0808_assign_req(struct gsm_subscriber_connection *conn, if (handle_new_assignment(conn, chan_mode, full_rate) != 0) goto error; } else { - LOGP(DMSC, LOGL_NOTICE, - "Sending ChanModify for speech %d %d\n", chan_mode, full_rate); if (chan_mode == GSM48_CMODE_SPEECH_AMR) handle_mr_config(conn, conn->lchan, full_rate); + LOGP(DMSC, LOGL_NOTICE, + "Sending ChanModify for speech: %s on channel %s\n", + 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/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1524ec4..7b78d48 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -1598,11 +1599,15 @@ static int tch_map(struct gsm_lchan *lchan, struct gsm_lchan *remote_lchan) { struct gsm_bts *bts = lchan->ts->trx->bts; struct gsm_bts *remote_bts = remote_lchan->ts->trx->bts; + enum gsm_chan_t lt = lchan->type, rt = remote_lchan->type; int rc; - DEBUGP(DCC, "Setting up TCH map between (bts=%u,trx=%u,ts=%u) and (bts=%u,trx=%u,ts=%u)\n", - bts->nr, lchan->ts->trx->nr, lchan->ts->nr, - remote_bts->nr, remote_lchan->ts->trx->nr, remote_lchan->ts->nr); + DEBUGP(DCC, "Setting up TCH map between (bts=%u,trx=%u,ts=%u,%s) and " + "(bts=%u,trx=%u,ts=%u,%s)\n", + bts->nr, lchan->ts->trx->nr, lchan->ts->nr, + get_value_string(gsm_chan_t_names, lt), + remote_bts->nr, remote_lchan->ts->trx->nr, remote_lchan->ts->nr, + get_value_string(gsm_chan_t_names, rt)); if (bts->type != remote_bts->type) { LOGP(DCC, LOGL_ERROR, "Cannot switch calls between different BTS types yet\n"); @@ -2999,6 +3004,7 @@ static int tch_rtp_create(struct gsm_network *net, uint32_t callref) struct gsm_bts *bts; struct gsm_lchan *lchan; struct gsm_trans *trans; + enum gsm48_chan_mode m; /* Find callref */ trans = trans_find_by_callref(net, callref); @@ -3038,8 +3044,11 @@ static int tch_rtp_create(struct gsm_network *net, uint32_t callref) */ if (lchan->tch_mode == GSM48_CMODE_SIGN) { trans->conn->mncc_rtp_create_pending = 1; - return gsm0808_assign_req(trans->conn, - mncc_codec_for_mode(lchan->type), + m = mncc_codec_for_mode(lchan->type); + LOGP(DMNCC, LOGL_DEBUG, "RTP create: codec=%s, chan_type=%s\n", + get_value_string(gsm48_chan_mode_names, m), + get_value_string(gsm_chan_t_names, lchan->type)); + return gsm0808_assign_req(trans->conn, m, lchan->type != GSM_LCHAN_TCH_H); } @@ -3068,6 +3077,10 @@ static int tch_rtp_connect(struct gsm_network *net, void *arg) } lchan = trans->conn->lchan; + LOGP(DMNCC, LOGL_DEBUG, "RTP connect: codec=%s, chan_type=%s\n", + get_value_string(gsm48_chan_mode_names, + mncc_codec_for_mode(lchan->type)), + get_value_string(gsm_chan_t_names, lchan->type)); /* TODO: Check if payload_msg_type is compatible with what we have */ if (rtp->payload_type != lchan->abis_ip.rtp_payload) { diff --git a/openbsc/src/libmsc/mncc_builtin.c b/openbsc/src/libmsc/mncc_builtin.c index 0942304..b879756 100644 --- a/openbsc/src/libmsc/mncc_builtin.c +++ b/openbsc/src/libmsc/mncc_builtin.c @@ -141,7 +141,8 @@ static int mncc_setup_ind(struct gsm_call *call, int msg_type, memset(&mncc, 0, sizeof(struct gsm_mncc)); mncc.callref = call->callref; mncc.lchan_mode = determine_lchan_mode(setup); - DEBUGP(DMNCC, "(call %x) Modify channel mode.\n", call->callref); + DEBUGP(DMNCC, "(call %x) Modify channel mode: %s\n", call->callref, + get_value_string(gsm48_chan_mode_names, mncc.lchan_mode)); mncc_tx_to_cc(call->net, MNCC_LCHAN_MODIFY, &mncc); /* send setup to remote */ diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index dffe642..0b360dc 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -288,8 +288,10 @@ int main(int argc, char **argv) rc = bsc_bootstrap_network(mncc_sock_from_cc, config_file); if (rc >= 0) mncc_sock_init(bsc_gsmnet, mncc_sock_path); - } else + } else { + DEBUGP(DMNCC, "Using internal MNCC handler.\n"); rc = bsc_bootstrap_network(int_mncc_recv, config_file); + } if (rc < 0) exit(1); #ifdef BUILD_SMPP -- 2.7.4 From msuraev at sysmocom.de Thu Mar 24 11:14:34 2016 From: msuraev at sysmocom.de (Max) Date: Thu, 24 Mar 2016 12:14:34 +0100 Subject: [PATCH 2/2] Don't connect channels of incompatible voice codec In-Reply-To: <6F4EAA9C-0414-4D6C-B592-6B7416A8DCC8@freyther.de> References: <1458756891-28335-1-git-send-email-msuraev@sysmocom.de> <1458756891-28335-2-git-send-email-msuraev@sysmocom.de> <6F4EAA9C-0414-4D6C-B592-6B7416A8DCC8@freyther.de> Message-ID: <56F3CC1A.20009@sysmocom.de> Comments are inline. On 03/23/2016 08:05 PM, Holger Freyther wrote: > > > Can you please elaborate about the intention of this method? You try to undo a failed mapping and do this by disconnecting the call? Is that the right thing to do? Has there been any side effect by the call of tch_map? Right now the call with incompatible channels is patched through and we hear broken audio. This method instead disconnects the call for both subscribers as bug suggested. > In the long run should there be a MNCC_BRIDGE_REJ answer to the MNCC_BRIDGE call? I don't think it's worth changing the protocol - this situation only happens with internal MNCC handler on particular configuration (mixed TCH/F and H) because we do not support transcoding. We can assume that all the external MNCC handlers can hadnle it just fine - otherwise there's no point in using them. We should document that mixing F and H channels is discouraged when no external MNCC handler is available. -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From msuraev at sysmocom.de Thu Mar 24 11:31:51 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 24 Mar 2016 12:31:51 +0100 Subject: [PATCH] Disconnect calls with incompatible channel types Message-ID: <1458819111-11887-1-git-send-email-msuraev@sysmocom.de> From: Max In case both TCH/H and TCH/F are configured and internal MNCC handler is used we might end up in a situation where call legs with incompatible channel types would be connected resulting in a broken audio. Disconnect such calls with appropriate error message. Fixes: OS#1663 --- openbsc/src/libmsc/gsm_04_08.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 7b78d48..2507d74 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1614,6 +1614,14 @@ static int tch_map(struct gsm_lchan *lchan, struct gsm_lchan *remote_lchan) return -EINVAL; } + if (lt != rt) { + LOGP(DCC, LOGL_ERROR, "Cannot patch through call with different" + " channel types: local = %s, remote = %s\n", + get_value_string(gsm_chan_t_names, lt), + get_value_string(gsm_chan_t_names, rt)); + return -EBADSLT; + } + // todo: map between different bts types switch (bts->type) { case GSM_BTS_TYPE_NANOBTS: @@ -1851,6 +1859,30 @@ static void gsm48_cc_timeout(void *arg) } +/* disconnect both calls from the bridge */ +static inline void disconnect_bridge(struct gsm_network *net, + struct gsm_mncc_bridge *bridge, int err) +{ + struct gsm_trans *trans0 = trans_find_by_callref(net, bridge->callref[0]); + struct gsm_trans *trans1 = trans_find_by_callref(net, bridge->callref[1]); + struct gsm_mncc mx_rel; + if (!trans0 || !trans1) + return; + + DEBUGP(DCC, "Failed to bridge TCH for calls %x <-> %x :: %s \n", + trans0->callref, trans1->callref, strerror(err)); + + memset(&mx_rel, 0, sizeof(struct gsm_mncc)); + mncc_set_cause(&mx_rel, GSM48_CAUSE_LOC_INN_NET, + GSM48_CC_CAUSE_CHAN_UNACCEPT); + + mx_rel.callref = trans0->callref; + gsm48_cc_tx_disconnect(trans0, &mx_rel); + + mx_rel.callref = trans1->callref; + gsm48_cc_tx_disconnect(trans1, &mx_rel); +} + static void gsm48_start_cc_timer(struct gsm_trans *trans, int current, int sec, int micro) { @@ -3221,7 +3253,10 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg) /* handle special messages */ switch(msg_type) { case MNCC_BRIDGE: - return tch_bridge(net, arg); + rc = tch_bridge(net, arg); + if (rc < 0) + disconnect_bridge(net, arg, -rc); + return rc; case MNCC_FRAME_DROP: return tch_recv_mncc(net, data->callref, 0); case MNCC_FRAME_RECV: -- 2.7.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:11 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:11 +0100 Subject: [PATCH] osmo-bsc: fix compiler warning: store struct in vty->index Message-ID: <1459024511-31381-1-git-send-email-nhofmeyr@sysmocom.de> Don't store an MSC index number in the vty->index void* value. Instead, store the osmo_msc_data struct directly. Thus avoid warnings about differences in int vs void* sizes, and save some index lookups. --- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index d871f01..e623c9c 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -43,7 +43,7 @@ static struct osmo_bsc_data *osmo_bsc_data(struct vty *vty) static struct osmo_msc_data *osmo_msc_data(struct vty *vty) { - return osmo_msc_data_find(bsc_gsmnet, (int) vty->index); + return vty->index; } static struct cmd_node bsc_node = { @@ -70,7 +70,7 @@ DEFUN(cfg_net_msc, cfg_net_msc_cmd, return CMD_WARNING; } - vty->index = (void *) index; + vty->index = msc; vty->node = MSC_NODE; return CMD_SUCCESS; } -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:32 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:32 +0100 Subject: [PATCH 0/7] Introduce MM Auth test suite and fix two issues Message-ID: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Though MM Auth might be tested implicitly, it is acutely lacking a dedicated test suite. I found two problems in the MM Auth logic, and to have regression tests for those, I need an actual test suite. So, at first I add a bread-and-butter test suite for MM Auth. Then, I cosmetically improve use of constants in return values. Finally, I fix the two issues with reflection in the new tests. Neels Hofmeyr (7): Add MM Auth test; add auth_action_str() function MM Auth test: add two tests for AUTH_THEN_CIPH MM Auth test: add test to re-use existing auth MM Auth: introduce AUTH_ERROR constant. MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero Fix MM Auth: disallow key_seq mismatch Fix MM Auth: zero-initialize auth tuple before first use openbsc/.gitignore | 1 + openbsc/configure.ac | 1 + openbsc/include/openbsc/auth.h | 18 ++ openbsc/src/libmsc/auth.c | 24 ++- openbsc/tests/Makefile.am | 2 +- openbsc/tests/mm_auth/Makefile.am | 21 +++ openbsc/tests/mm_auth/mm_auth_test.c | 340 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 40 ++++ openbsc/tests/testsuite.at | 7 + 9 files changed, 446 insertions(+), 8 deletions(-) create mode 100644 openbsc/tests/mm_auth/Makefile.am create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:33 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:33 +0100 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-2-git-send-email-nhofmeyr@sysmocom.de> Add basic MM Authentication test setup, with fake DB access and RAND_bytes(). So far implement simple tests for IO error during DB access and missing auth entry. To print the auth action during tests, implement auth_action_str() inline function. --- openbsc/.gitignore | 1 + openbsc/configure.ac | 1 + openbsc/include/openbsc/auth.h | 18 +++++ openbsc/tests/Makefile.am | 2 +- openbsc/tests/mm_auth/Makefile.am | 21 ++++++ openbsc/tests/mm_auth/mm_auth_test.c | 119 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 8 +++ openbsc/tests/testsuite.at | 7 ++ 8 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 openbsc/tests/mm_auth/Makefile.am create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok diff --git a/openbsc/.gitignore b/openbsc/.gitignore index 55f4a31..28fdcc8 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -80,6 +80,7 @@ tests/sgsn/sgsn_test tests/subscr/subscr_test tests/oap/oap_test tests/gtphub/gtphub_test +tests/mm_auth/mm_auth_test tests/atconfig tests/atlocal diff --git a/openbsc/configure.ac b/openbsc/configure.ac index 24dbc30..60601fe 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -216,6 +216,7 @@ AC_OUTPUT( tests/subscr/Makefile tests/oap/Makefile tests/gtphub/Makefile + tests/mm_auth/Makefile doc/Makefile doc/examples/Makefile Makefile) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index d41d141..6c463d4 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -11,6 +11,24 @@ enum auth_action { AUTH_DO_AUTH = 3, /* Only authentication, no ciphering */ }; +static inline const char *auth_action_str(enum auth_action a) +{ +#define AUTH_CASE(X) \ + case X: return #X + + switch (a) { + AUTH_CASE(AUTH_NOT_AVAIL); + AUTH_CASE(AUTH_DO_AUTH_THEN_CIPH); + AUTH_CASE(AUTH_DO_CIPH); + AUTH_CASE(AUTH_DO_AUTH); + case -1: + return "(internal error)"; + default: + return "(unknown auth_action)"; + } +#undef AUTH_CASE +} + int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, struct gsm_subscriber *subscr, int key_seq); diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am index 04b8e34..09298a3 100644 --- a/openbsc/tests/Makefile.am +++ b/openbsc/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau subscr +SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau subscr mm_auth if BUILD_NAT SUBDIRS += bsc-nat bsc-nat-trie diff --git a/openbsc/tests/mm_auth/Makefile.am b/openbsc/tests/mm_auth/Makefile.am new file mode 100644 index 0000000..516df00 --- /dev/null +++ b/openbsc/tests/mm_auth/Makefile.am @@ -0,0 +1,21 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(LIBCRYPTO_CFLAGS) + +noinst_PROGRAMS = mm_auth_test + +EXTRA_DIST = mm_auth_test.ok + +mm_auth_test_SOURCES = mm_auth_test.c + +mm_auth_test_LDFLAGS = \ + -Wl,--wrap=db_get_authinfo_for_subscr \ + -Wl,--wrap=db_get_lastauthtuple_for_subscr \ + -Wl,--wrap=db_sync_lastauthtuple_for_subscr + +mm_auth_test_LDADD = $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c new file mode 100644 index 0000000..d8e4475 --- /dev/null +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -0,0 +1,119 @@ +#include + +#include +#include + +#include +#include +#include +#include + +/* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */ +int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, + struct gsm_subscriber *subscr); + +int test_get_authinfo_rc = 0; +struct gsm_auth_info test_auth_info = {0}; +struct gsm_auth_info default_auth_info = { + .auth_algo = AUTH_ALGO_COMP128v1, + .a3a8_ki_len = 16, + .a3a8_ki = { 0 } +}; + +int __wrap_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, + struct gsm_subscriber *subscr) +{ + *ainfo = test_auth_info; + printf("wrapped: db_get_authinfo_for_subscr(): rc = %d\n", test_get_authinfo_rc); + return test_get_authinfo_rc; +} + +/* override, requires '-Wl,--wrap=db_get_lastauthtuple_for_subscr' */ +int __real_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr); + +int test_get_lastauthtuple_rc = 0; +struct gsm_auth_tuple test_last_auth_tuple = { 0 }; +struct gsm_auth_tuple default_auth_tuple = { 0 }; + +int __wrap_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr) +{ + *atuple = test_last_auth_tuple; + printf("wrapped: db_get_lastauthtuple_for_subscr(): rc = %d\n", test_get_lastauthtuple_rc); + return test_get_lastauthtuple_rc; +} + +/* override, requires '-Wl,--wrap=db_sync_lastauthtuple_for_subscr' */ +int __real_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr); +int test_sync_lastauthtuple_rc = 0; +int __wrap_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr) +{ + test_last_auth_tuple = *atuple; + printf("wrapped: db_sync_lastauthtuple_for_subscr(): rc = %d\n", test_sync_lastauthtuple_rc); + return test_sync_lastauthtuple_rc; +} + +int auth_get_tuple_for_subscr_verbose(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr, + int key_seq) +{ + int auth_action; + auth_action = auth_get_tuple_for_subscr(atuple, subscr, key_seq); + printf("auth_get_tuple_for_subscr(key_seq=%d) --> auth_action == %s\n", + key_seq, auth_action_str(auth_action)); + return auth_action; +} + +/* override libssl RAND_bytes() to get testable crypto results */ +int RAND_bytes(uint8_t *rand, int len) +{ + memset(rand, 23, len); + return 1; +} + +static void test_error() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq = 0; + + printf("\n* test_error()\n"); + + /* any error (except -ENOENT) */ + test_get_authinfo_rc = -EIO; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == -1); +} + +static void test_auth_not_avail() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq = 0; + + printf("\n* test_auth_not_avail()\n"); + + /* no entry */ + test_get_authinfo_rc = -ENOENT; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL); +} + +int main(void) +{ + osmo_init_logging(&log_info); + log_set_log_level(osmo_stderr_target, LOGL_INFO); + + test_error(); + test_auth_not_avail(); + return 0; +} diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok new file mode 100644 index 0000000..5efb3de --- /dev/null +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -0,0 +1,8 @@ + +* test_error() +wrapped: db_get_authinfo_for_subscr(): rc = -5 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) + +* test_auth_not_avail() +wrapped: db_get_authinfo_for_subscr(): rc = -2 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 6a1c77f..dab9568 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -117,3 +117,10 @@ AT_CHECK([test "$enable_gtphub_test" != no || exit 77]) cat $abs_srcdir/gtphub/gtphub_test.ok > expout AT_CHECK([$abs_top_builddir/tests/gtphub/gtphub_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([mm_auth]) +AT_KEYWORDS([mm_auth]) +cat $abs_srcdir/mm_auth/mm_auth_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/mm_auth/mm_auth_test], [], [expout], [ignore]) +AT_CLEANUP + -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:34 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:34 +0100 Subject: [PATCH 2/7] MM Auth test: add two tests for AUTH_THEN_CIPH In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-3-git-send-email-nhofmeyr@sysmocom.de> Test two situations for AUTH_DO_AUTH_THEN_CIPH: - when no auth tuple is available - when the key sequence from LU is marked invalid Add convenience auth tuple comparison function using stringification. --- openbsc/tests/mm_auth/mm_auth_test.c | 136 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 16 ++++ 2 files changed, 152 insertions(+) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index d8e4475..c0b8da4 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -8,6 +8,59 @@ #include #include +#define min(A,B) ((A)>(B)? (B) : (A)) + +static char *auth_tuple_str(struct gsm_auth_tuple *atuple) +{ + static char buf[256]; + char *pos = buf; + int len = sizeof(buf); + int l; + +#define print2buf(FMT, args...) do {\ + l = snprintf(pos, len, FMT, ## args); \ + pos += l;\ + len -= l;\ + } while (0) + + print2buf("gsm_auth_tuple {\n"); + print2buf(" .use_count = %d\n", atuple->use_count); + print2buf(" .key_seq = %d\n", atuple->key_seq); + print2buf(" .rand = %s\n", osmo_hexdump(atuple->rand, sizeof(atuple->rand))); + print2buf(" .sres = %s\n", osmo_hexdump(atuple->sres, sizeof(atuple->sres))); + print2buf(" .kc = %s\n", osmo_hexdump(atuple->kc, sizeof(atuple->kc))); + print2buf("}\n"); +#undef print2buf + + return buf; +} + +static bool auth_tuple_is(struct gsm_auth_tuple *atuple, + const char *expect_str) +{ + int l, l1, l2; + int i; + char *tuple_str = auth_tuple_str(atuple); + bool same = (strcmp(expect_str, tuple_str) == 0); + if (!same) { + l1 = strlen(expect_str); + l2 = strlen(tuple_str); + printf("Expected %d:\n%s\nGot %d:\n%s\n", + l1, expect_str, l2, tuple_str); + l = min(l1, l2); + for (i = 0; i < l; i++) { + if (expect_str[i] != tuple_str[i]) { + printf("Difference at pos %d" + " (%c 0x%0x != %c 0x%0x)\n", + i, expect_str[i], expect_str[i], + tuple_str[i], tuple_str[i]); + break; + } + } + } + return same; +} + /* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */ int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, struct gsm_subscriber *subscr); @@ -108,6 +161,87 @@ static void test_auth_not_avail() OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL); } +static void test_auth_then_ciph1() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_then_ciph1()\n"); + + /* Ki entry, but no auth tuple negotiated yet */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = -ENOENT; + key_seq = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 1\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + +static void test_auth_then_ciph2() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_then_ciph2()\n"); + + /* Ki entry, auth tuple negotiated, but invalid incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 2; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + key_seq = GSM_KEY_SEQ_INVAL; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 3\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); + + /* Change the last saved key_seq, expect last_auth_tuple.key_seq + 1 */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + key_seq = GSM_KEY_SEQ_INVAL; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 4\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -115,5 +249,7 @@ int main(void) test_error(); test_auth_not_avail(); + test_auth_then_ciph1(); + test_auth_then_ciph2(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 5efb3de..52feb36 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -6,3 +6,19 @@ auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) * test_auth_not_avail() wrapped: db_get_authinfo_for_subscr(): rc = -2 auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL + +* test_auth_then_ciph1() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH + +* test_auth_then_ciph2() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:35 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:35 +0100 Subject: [PATCH 3/7] MM Auth test: add test to re-use existing auth In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-4-git-send-email-nhofmeyr@sysmocom.de> --- openbsc/tests/mm_auth/mm_auth_test.c | 31 +++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index c0b8da4..e541898 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -242,6 +242,36 @@ static void test_auth_then_ciph2() )); } +static void test_auth_reuse() +{ + int auth_action; + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_reuse()\n"); + + /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = key_seq = 3; + test_last_auth_tuple.use_count = 1; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 2\n" + " .key_seq = 3\n" + " .rand = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n" + " .sres = 00 00 00 00 \n" + " .kc = 00 00 00 00 00 00 00 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -251,5 +281,6 @@ int main(void) test_auth_not_avail(); test_auth_then_ciph1(); test_auth_then_ciph2(); + test_auth_reuse(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 52feb36..cc0e769 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -22,3 +22,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH + +* test_auth_reuse() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:36 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:36 +0100 Subject: [PATCH 4/7] MM Auth: introduce AUTH_ERROR constant. In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-5-git-send-email-nhofmeyr@sysmocom.de> Instead of using hardcoded -1 for errors, include -1 in the enum auth_action type; apply its use. In effect remove a compiler warning recently introduced in auth_action_str() about int value not represented in enum definition. In the mm_auth test, the string output changes from '(internal error)' to 'AUTH_ERROR'. --- openbsc/include/openbsc/auth.h | 4 ++-- openbsc/src/libmsc/auth.c | 4 ++-- openbsc/tests/mm_auth/mm_auth_test.c | 2 +- openbsc/tests/mm_auth/mm_auth_test.ok | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index 6c463d4..d8312c3 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -5,6 +5,7 @@ struct gsm_auth_tuple; struct gsm_subscriber; enum auth_action { + AUTH_ERROR = -1, /* Internal error */ AUTH_NOT_AVAIL = 0, /* No auth tuple available */ AUTH_DO_AUTH_THEN_CIPH = 1, /* Firsth authenticate, then cipher */ AUTH_DO_CIPH = 2, /* Only ciphering */ @@ -17,12 +18,11 @@ static inline const char *auth_action_str(enum auth_action a) case X: return #X switch (a) { + AUTH_CASE(AUTH_ERROR); AUTH_CASE(AUTH_NOT_AVAIL); AUTH_CASE(AUTH_DO_AUTH_THEN_CIPH); AUTH_CASE(AUTH_DO_CIPH); AUTH_CASE(AUTH_DO_AUTH); - case -1: - return "(internal error)"; default: return "(unknown auth_action)"; } diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 65a9b03..68ba8c3 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -84,7 +84,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, if (rc < 0) { LOGP(DMM, LOGL_NOTICE, "No retrievable Ki for subscriber, skipping auth\n"); - return rc == -ENOENT ? AUTH_NOT_AVAIL : -1; + return rc == -ENOENT ? AUTH_NOT_AVAIL : AUTH_ERROR; } /* If possible, re-use the last tuple and skip auth */ @@ -105,7 +105,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); - return -1; + return AUTH_ERROR; } switch (ainfo.auth_algo) { diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index e541898..1d65984 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -141,7 +141,7 @@ static void test_error() test_get_authinfo_rc = -EIO; auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, key_seq); - OSMO_ASSERT(auth_action == -1); + OSMO_ASSERT(auth_action == AUTH_ERROR); } static void test_auth_not_avail() diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index cc0e769..7dedadc 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -1,7 +1,7 @@ * test_error() wrapped: db_get_authinfo_for_subscr(): rc = -5 -auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_ERROR * test_auth_not_avail() wrapped: db_get_authinfo_for_subscr(): rc = -2 -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:37 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:37 +0100 Subject: [PATCH 5/7] MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-6-git-send-email-nhofmeyr@sysmocom.de> AUTH_NOT_AVAIL == 0, so this is no functional change. --- openbsc/src/libmsc/auth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 68ba8c3..0a8fbf4 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -111,22 +111,22 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, switch (ainfo.auth_algo) { case AUTH_ALGO_NONE: DEBUGP(DMM, "No authentication for subscriber\n"); - return 0; + return AUTH_NOT_AVAIL; case AUTH_ALGO_XOR: if (_use_xor(&ainfo, atuple)) - return 0; + return AUTH_NOT_AVAIL; break; case AUTH_ALGO_COMP128v1: if (_use_comp128_v1(&ainfo, atuple)) - return 0; + return AUTH_NOT_AVAIL; break; default: DEBUGP(DMM, "Unsupported auth type algo_id=%d\n", ainfo.auth_algo); - return 0; + return AUTH_NOT_AVAIL; } db_sync_lastauthtuple_for_subscr(atuple, subscr); -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:38 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:38 +0100 Subject: [PATCH 6/7] Fix MM Auth: disallow key_seq mismatch In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-7-git-send-email-nhofmeyr@sysmocom.de> In auth_get_tuple_for_subscr(), add missing condition to match incoming key_seq with stored key_seq, so that re-authentication is requested for mismatching key_seqs. Add test for this issue. --- openbsc/src/libmsc/auth.c | 1 + openbsc/tests/mm_auth/mm_auth_test.c | 32 ++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 6 ++++++ 3 files changed, 39 insertions(+) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 0a8fbf4..e4d33f0 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -91,6 +91,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, rc = db_get_lastauthtuple_for_subscr(atuple, subscr); if ((rc == 0) && (key_seq != GSM_KEY_SEQ_INVAL) && + (key_seq == atuple->key_seq) && (atuple->use_count < 3)) { atuple->use_count++; diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index 1d65984..2b45861 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -272,6 +272,37 @@ static void test_auth_reuse() )); } +static void test_auth_reuse_key_seq_mismatch() +{ + int auth_action; + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_reuse_key_seq_mismatch()\n"); + + /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + key_seq = 4; + test_last_auth_tuple.use_count = 1; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 4\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -282,5 +313,6 @@ int main(void) test_auth_then_ciph1(); test_auth_then_ciph2(); test_auth_reuse(); + test_auth_reuse_key_seq_mismatch(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 7dedadc..9d89bfb 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -28,3 +28,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH + +* test_auth_reuse_key_seq_mismatch() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=4) --> auth_action == AUTH_DO_AUTH_THEN_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Sat Mar 26 20:35:39 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Sat, 26 Mar 2016 21:35:39 +0100 Subject: [PATCH 7/7] Fix MM Auth: zero-initialize auth tuple before first use In-Reply-To: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459024539-31433-8-git-send-email-nhofmeyr@sysmocom.de> Make sure a new auth tuple is initialized after db_get_lastauthtuple_for_subscr() returns an error. In effect, the first key_seq used no longer depends on how the auth tuple was initialized before the call. Before this patch, the first key_seq depended on the value was present in auth tuple's key_seq. --- openbsc/src/libmsc/auth.c | 11 ++++++++++- openbsc/tests/mm_auth/mm_auth_test.c | 24 +++++++++++++++++++++++- openbsc/tests/mm_auth/mm_auth_test.ok | 4 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index e4d33f0..53eb717 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -101,8 +101,17 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, } /* Generate a new one */ + if (rc != 0) { + /* If db_get_lastauthtuple_for_subscr() returned nothing, make + * sure the atuple memory is initialized to zero and thus start + * off with key_seq = 0. */ + memset(atuple, 0, sizeof(*atuple)); + } else { + /* If db_get_lastauthtuple_for_subscr() returned a previous + * tuple, use the next key_seq. */ + atuple->key_seq = (atuple->key_seq + 1) % 7; + } atuple->use_count = 1; - atuple->key_seq = (atuple->key_seq + 1) % 7; if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index 2b45861..34d96f1 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -183,7 +183,29 @@ static void test_auth_then_ciph1() OSMO_ASSERT(auth_tuple_is(&atuple, "gsm_auth_tuple {\n" " .use_count = 1\n" - " .key_seq = 1\n" + " .key_seq = 0\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); + + /* With a different last saved key_seq stored in the out-arg of + * db_get_lastauthtuple_for_subscr() by coincidence, expect absolutely + * the same as above. */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = -ENOENT; + key_seq = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 0\n" " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" " .sres = a1 ab c6 90 \n" " .kc = 0f 27 ed f3 ac 97 ac 00 \n" diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 9d89bfb..6c49f97 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -12,6 +12,10 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH * test_auth_then_ciph2() wrapped: db_get_authinfo_for_subscr(): rc = 0 -- 2.1.4 From laforge at gnumonks.org Sun Mar 27 08:48:30 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 27 Mar 2016 10:48:30 +0200 Subject: [PATCH] osmo-bsc: fix compiler warning: store struct in vty->index In-Reply-To: <1459024511-31381-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459024511-31381-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160327084830.GS27418@nataraja> On Sat, Mar 26, 2016 at 09:35:11PM +0100, Neels Hofmeyr wrote: > Don't store an MSC index number in the vty->index void* value. Instead, > store the osmo_msc_data struct directly. Thus avoid warnings about > differences in int vs void* sizes, and save some index lookups. thanks, merged. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun Mar 27 08:53:53 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 27 Mar 2016 10:53:53 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <1459024539-31433-2-git-send-email-nhofmeyr@sysmocom.de> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> <1459024539-31433-2-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160327085353.GT27418@nataraja> Hi Neels, On Sat, Mar 26, 2016 at 09:35:33PM +0100, Neels Hofmeyr wrote: > +static inline const char *auth_action_str(enum auth_action a) we normally try to avoid introducing some custom value/string converter code like this and use 'struct value_string' for this. > +#define AUTH_CASE(X) \ > + case X: return #X you can also define a macro like this that generates a { X, #X }, for struct value_string > + case -1: > + return "(internal error)"; this would be an ugly { -1, "(internal error") } which is soon replaced by your #define AUTH_ERROR anyway. ... and please refrain from having non-trivial functions (or data definitions), and particularly non-performance-critical functions like this inline in a header file. I think I know why you do that (to use it in the test case and in the main code) but this still doesn't rectify it, sorry ;) I would merge the entire patch-set, if you could address that one issue. Thanks! -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun Mar 27 08:46:04 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 27 Mar 2016 10:46:04 +0200 Subject: [PATCH 2/2] Add extra debug output with channel mode and type In-Reply-To: <1458817545-2039-2-git-send-email-msuraev@sysmocom.de> References: <1458817545-2039-1-git-send-email-msuraev@sysmocom.de> <1458817545-2039-2-git-send-email-msuraev@sysmocom.de> Message-ID: <20160327084604.GR27418@nataraja> Hi Max, On Thu, Mar 24, 2016 at 12:05:45PM +0100, msuraev at sysmocom.de wrote: > This provides helpful information for debugging internal MNCC handler. this patch depends on the export of gsm48_chan_mode_names, so it will hav to wait for the resolution of the feedback on that part. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun Mar 27 08:26:53 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 27 Mar 2016 10:26:53 +0200 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode In-Reply-To: <1458816899-30771-1-git-send-email-msuraev@sysmocom.de> References: <1458816899-30771-1-git-send-email-msuraev@sysmocom.de> Message-ID: <20160327082653.GO27418@nataraja> On Thu, Mar 24, 2016 at 11:54:59AM +0100, msuraev at sysmocom.de wrote: > This can be used with get_value_string() to improve debugging output. Great, but... > +static const struct value_string gsm_chan_t_names[] = { a static symbol can certainly not be used by get_value_string. Oh, you put it in the header file, no that's not how we do things, sorry. What you're doing means that every application that links the library will end up having it's own copy of the data structures, somewhat defeating the purpose of a shared library. Data structures like this have to go into a .c file, and you need a forward-declaration in the header. So either you a) have the value_string non-static and exported in the symbol table, and directly add a forward-declaration of the 'const struct value_string' array like in th example of 'abis_nm_msg_disc_names' or b) you have a static value_string array but an exported accessor functions and those functions are forward-declared in the header (like your original patch) theoretically, there could also be a 'c' where the accessor function is an inline function or a macro, as it basicall is just a one-liner. Sorry, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun Mar 27 08:40:58 2016 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 27 Mar 2016 10:40:58 +0200 Subject: [PATCH 3/5] LC15: fix segfault In-Reply-To: <20160322152709.GD7525@ass40.sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> <1458657612-12669-3-git-send-email-msuraev@sysmocom.de> <20160322152709.GD7525@ass40.sysmocom.de> Message-ID: <20160327084058.GQ27418@nataraja> Hi Max, regarding the original patch: * the commit message fails to explain why this fixes a segfault, and when that segfault occurs * if Neels provides some feedback like the one he did, please follow-up to that to keep progress on this patch going. If the OSMO_ASSERT() in the original code was wrong, then please explain why it was wrong. This explanation belongs in the commit log message. Also, as trx_lc15l1_hdl() can now return NULL, did you verify that all callers of that function can actually deal with a NULL return value? Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Sun Mar 27 12:17:10 2016 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Sun, 27 Mar 2016 18:17:10 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: Message-ID: <1459081030-23070-1-git-send-email-axilirator@gmail.com> In OpenBSC, we traditionally displayed a TMSI in its integer representation, which is quite unusual in the telecom world. A TMSI is normally printed as a series of 8 hex digits. This patch aligns OpenBSC with the telecom industry standard. - Use hex representation in VTY - Increased DB SCHEMA_REVISION - Implemented DB migration code Signed-off-by: Vadim Yanitskiy --- openbsc/include/openbsc/gsm_subscriber.h | 6 +- openbsc/src/libcommon/gsm_subscriber_base.c | 5 +- openbsc/src/libmsc/db.c | 96 ++++++++++++++++++++++++++--- openbsc/src/libmsc/gsm_04_08.c | 30 +++------ openbsc/src/libmsc/gsm_subscriber.c | 10 ++- openbsc/src/libmsc/vty_interface_layer3.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 4 +- openbsc/tests/db/db_test.c | 4 +- openbsc/tests/gsm0408/gsm0408_test.c | 2 +- 10 files changed, 115 insertions(+), 46 deletions(-) diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 7d6c776..de80530 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -14,7 +14,7 @@ #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 tmsi_from_string(str) strtoul(str + 2, NULL, 16) #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 @@ -93,7 +93,7 @@ struct gsm_subscriber *subscr_put(struct gsm_subscriber *subscr); struct gsm_subscriber *subscr_create_subscriber(struct gsm_subscriber_group *sgrp, const char *imsi); struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_subscriber_group *sgrp, - uint32_t tmsi); + const char *tmsi); struct gsm_subscriber *subscr_get_by_imsi(struct gsm_subscriber_group *sgrp, const char *imsi); struct gsm_subscriber *subscr_get_by_extension(struct gsm_subscriber_group *sgrp, @@ -104,7 +104,7 @@ struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp, const char *imsi); int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason); struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp, - uint32_t tmsi); + const char *tmsi); struct gsm_subscriber *subscr_active_by_imsi(struct gsm_subscriber_group *sgrp, const char *imsi); diff --git a/openbsc/src/libcommon/gsm_subscriber_base.c b/openbsc/src/libcommon/gsm_subscriber_base.c index a455824..c7fb831 100644 --- a/openbsc/src/libcommon/gsm_subscriber_base.c +++ b/openbsc/src/libcommon/gsm_subscriber_base.c @@ -118,12 +118,13 @@ struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp, } struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp, - uint32_t tmsi) + const char *tmsi) { struct gsm_subscriber *subscr; + uint8_t tmsi_val = tmsi_from_string(tmsi); llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) { - if (subscr->tmsi == tmsi && subscr->group == sgrp) + if (subscr->tmsi == tmsi_val && subscr->group == sgrp) return subscr_get(subscr); } diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 0935fc5..56b5a08 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -47,7 +47,7 @@ static char *db_basename = NULL; static char *db_dirname = NULL; static dbi_conn conn; -#define SCHEMA_REVISION "4" +#define SCHEMA_REVISION "5" enum { SCHEMA_META, @@ -212,6 +212,7 @@ static int update_db_revision_2(void) } dbi_result_free(result); + LOGP(DDB, LOGL_NOTICE, "Migration complete.\n"); return 0; } @@ -357,6 +358,7 @@ static int update_db_revision_3(void) else dbi_result_free(result); + LOGP(DDB, LOGL_NOTICE, "Migration complete.\n"); return 0; rollback: @@ -369,6 +371,77 @@ rollback: return -EINVAL; } +static int update_db_revision_4(void) +{ + dbi_result select; + dbi_result update; + long long unsigned int id; + const char *tmsi_old; + uint32_t tmsi_new; + + LOGP(DDB, LOGL_NOTICE, "Going to migrate from revision 4\n"); + + /* Cycle through old TMSIs and convert them to the new format */ + select = dbi_conn_query(conn, "SELECT * FROM Subscriber"); + if (!select) { + LOGP(DDB, LOGL_ERROR, + "Failed fetch subscriber data the old Subscriber table " + "(upgrade from rev 4).\n"); + return -EINVAL; + } + + while (dbi_result_next_row(select)) { + /* Fetch the subscriber ID */ + id = dbi_result_get_ulonglong(select, "id"); + + /* Fetch an old TMSI value */ + tmsi_old = dbi_result_get_string(select, "tmsi"); + tmsi_new = atoi(tmsi_old); + + if (tmsi_new <= 0) { + LOGP(DDB, LOGL_ERROR, + "Failed to convert an old TMSI '%s', ignoring " + "(upgrade from rev 4).\n", tmsi_old); + continue; + } + + /* Update old TMSI */ + update = dbi_conn_queryf(conn, + "UPDATE Subscriber " + "SET tmsi = '0x%08x' " + "WHERE id = %llu", + tmsi_new, id); + + if (!update) { + LOGP(DDB, LOGL_ERROR, + "Failed update subscriber's TMSI " + "(upgrade from rev 4).\n"); + + dbi_result_free(select); + return -EINVAL; + } + + dbi_result_free(update); + } + dbi_result_free(select); + + /* We're done. Bump DB Meta revision to 5 */ + update = dbi_conn_query(conn, + "UPDATE Meta " + "SET value = '5' " + "WHERE key = 'revision'"); + if (!update) { + LOGP(DDB, LOGL_ERROR, + "Failed to update DB schema revision " + "(upgrade from rev 4).\n"); + return -EINVAL; + } + + dbi_result_free(update); + LOGP(DDB, LOGL_NOTICE, "Migration complete.\n"); + return 0; +} + static int check_db_revision(void) { dbi_result result; @@ -400,6 +473,12 @@ static int check_db_revision(void) dbi_result_free(result); return -EINVAL; } + } else if (!strcmp(rev_s, "4")) { + if (update_db_revision_4()) { + LOGP(DDB, LOGL_FATAL, "Failed to update database from schema revision '%s'.\n", rev_s); + dbi_result_free(result); + return -EINVAL; + } } else if (!strcmp(rev_s, SCHEMA_REVISION)) { /* everything is fine */ } else { @@ -893,9 +972,10 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, subscr->id = dbi_result_get_ulonglong(result, "id"); db_set_from_query(subscr, result); - DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', TMSI %u, EXTEN '%s', LAC %hu, AUTH %u\n", - subscr->id, subscr->imsi, subscr->name, subscr->tmsi, subscr->extension, - subscr->lac, subscr->authorized); + DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', " + "TMSI 0x%08x, EXTEN '%s', LAC %hu, AUTH %u\n", + subscr->id, subscr->imsi, subscr->name, subscr->tmsi, + subscr->extension, subscr->lac, subscr->authorized); dbi_result_free(result); get_equipment_by_subscr(subscr); @@ -935,7 +1015,7 @@ int db_subscriber_update(struct gsm_subscriber *subscr) int db_sync_subscriber(struct gsm_subscriber *subscriber) { dbi_result result; - char tmsi[14]; + char tmsi[11]; char *q_tmsi, *q_name, *q_extension; dbi_conn_quote_string_copy(conn, @@ -944,7 +1024,7 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber) subscriber->extension, &q_extension); if (subscriber->tmsi != GSM_RESERVED_TMSI) { - sprintf(tmsi, "%u", subscriber->tmsi); + sprintf(tmsi, "0x%08x", subscriber->tmsi); dbi_conn_quote_string_copy(conn, tmsi, &q_tmsi); @@ -1194,7 +1274,7 @@ int db_subscriber_expire(void *priv, void (*callback)(void *priv, long long unsi int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) { dbi_result result = NULL; - char tmsi[14]; + char tmsi[11]; char *tmsi_quoted; for (;;) { @@ -1205,7 +1285,7 @@ int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) if (subscriber->tmsi == GSM_RESERVED_TMSI) continue; - sprintf(tmsi, "%u", subscriber->tmsi); + sprintf(tmsi, "0x%08x", subscriber->tmsi); dbi_conn_quote_string_copy(conn, tmsi, &tmsi_quoted); result = dbi_conn_queryf(conn, "SELECT * FROM Subscriber " diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 1524ec4..c9f1b66 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -653,8 +653,7 @@ static int mm_rx_loc_upd_req(struct gsm_subscriber_connection *conn, struct msgb case GSM_MI_TYPE_TMSI: DEBUGPC(DMM, "\n"); /* look up the subscriber based on TMSI, request IMSI if it fails */ - subscr = subscr_get_by_tmsi(bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = subscr_get_by_tmsi(bts->network->subscr_group, mi_string); if (!subscr) { /* send IDENTITY REQUEST message to get IMSI */ mm_tx_identity_req(conn, GSM_MI_TYPE_IMSI); @@ -972,20 +971,15 @@ static int gsm48_rx_mm_serv_req(struct gsm_subscriber_connection *conn, struct m if (mi_type == GSM_MI_TYPE_IMSI) { DEBUGPC(DMM, "serv_type=0x%02x MI(%s)=%s\n", - req->cm_service_type, gsm48_mi_type_name(mi_type), - mi_string); - subscr = subscr_get_by_imsi(bts->network->subscr_group, - mi_string); + req->cm_service_type, gsm48_mi_type_name(mi_type), mi_string); + subscr = subscr_get_by_imsi(bts->network->subscr_group, mi_string); } else if (mi_type == GSM_MI_TYPE_TMSI) { DEBUGPC(DMM, "serv_type=0x%02x MI(%s)=%s\n", - req->cm_service_type, gsm48_mi_type_name(mi_type), - mi_string); - subscr = subscr_get_by_tmsi(bts->network->subscr_group, - tmsi_from_string(mi_string)); + req->cm_service_type, gsm48_mi_type_name(mi_type), mi_string); + subscr = subscr_get_by_tmsi(bts->network->subscr_group, mi_string); } else { DEBUGPC(DMM, "mi_type is not expected: %d\n", mi_type); - return gsm48_tx_mm_serv_rej(conn, - GSM48_REJECT_INCORRECT_MESSAGE); + return gsm48_tx_mm_serv_rej(conn, GSM48_REJECT_INCORRECT_MESSAGE); } osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_IDENTITY, (classmark2 + classmark2_len)); @@ -1038,13 +1032,11 @@ static int gsm48_rx_mm_imsi_detach_ind(struct gsm_subscriber_connection *conn, s switch (mi_type) { case GSM_MI_TYPE_TMSI: DEBUGPC(DMM, "\n"); - subscr = subscr_get_by_tmsi(bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = subscr_get_by_tmsi(bts->network->subscr_group, mi_string); break; case GSM_MI_TYPE_IMSI: DEBUGPC(DMM, "\n"); - subscr = subscr_get_by_imsi(bts->network->subscr_group, - mi_string); + subscr = subscr_get_by_imsi(bts->network->subscr_group, mi_string); break; case GSM_MI_TYPE_IMEI: case GSM_MI_TYPE_IMEISV: @@ -1189,12 +1181,10 @@ static int gsm48_rx_rr_pag_resp(struct gsm_subscriber_connection *conn, struct m switch (mi_type) { case GSM_MI_TYPE_TMSI: - subscr = subscr_get_by_tmsi(bts->network->subscr_group, - tmsi_from_string(mi_string)); + subscr = subscr_get_by_tmsi(bts->network->subscr_group, mi_string); break; case GSM_MI_TYPE_IMSI: - subscr = subscr_get_by_imsi(bts->network->subscr_group, - mi_string); + subscr = subscr_get_by_imsi(bts->network->subscr_group, mi_string); break; } diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index 57c10cf..d9761d9 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -46,7 +46,6 @@ extern struct llist_head *subscr_bsc_active_subscribers(void); int gsm48_secure_channel(struct gsm_subscriber_connection *conn, int key_seq, gsm_cbfn *cb, void *cb_data); - /* * Struct for pending channel requests. This is managed in the * llist_head requests of each subscriber. The reference counting @@ -212,19 +211,18 @@ struct gsm_subscriber *subscr_create_subscriber(struct gsm_subscriber_group *sgr } struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_subscriber_group *sgrp, - uint32_t tmsi) + const char *tmsi) { - char tmsi_string[14]; struct gsm_subscriber *subscr; + uint32_t tmsi_val = tmsi_from_string(tmsi); /* we might have a record in memory already */ llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) { - if (tmsi == subscr->tmsi) + if (tmsi_val == subscr->tmsi) return subscr_get(subscr); } - sprintf(tmsi_string, "%u", tmsi); - return get_subscriber(sgrp, GSM_SUBSCRIBER_TMSI, tmsi_string); + return get_subscriber(sgrp, GSM_SUBSCRIBER_TMSI, tmsi); } struct gsm_subscriber *subscr_get_by_imsi(struct gsm_subscriber_group *sgrp, diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index f49c53a..19c15e1 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -189,7 +189,7 @@ static struct gsm_subscriber *get_subscr_by_argv(struct gsm_network *gsmnet, else if (!strcmp(type, "imsi")) return subscr_get_by_imsi(gsmnet->subscr_group, id); else if (!strcmp(type, "tmsi")) - return subscr_get_by_tmsi(gsmnet->subscr_group, atoi(id)); + return subscr_get_by_tmsi(gsmnet->subscr_group, id); else if (!strcmp(type, "id")) return subscr_get_by_id(gsmnet->subscr_group, atoi(id)); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 14e0b71..88db15e 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -79,7 +79,7 @@ static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn switch (mi_type) { case GSM_MI_TYPE_TMSI: subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group, - tmsi_from_string(mi_string)); + mi_string); break; case GSM_MI_TYPE_IMSI: subscr = subscr_active_by_imsi(conn->bts->network->subscr_group, diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index e623c9c..d871f01 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -43,7 +43,7 @@ static struct osmo_bsc_data *osmo_bsc_data(struct vty *vty) static struct osmo_msc_data *osmo_msc_data(struct vty *vty) { - return vty->index; + return osmo_msc_data_find(bsc_gsmnet, (int) vty->index); } static struct cmd_node bsc_node = { @@ -70,7 +70,7 @@ DEFUN(cfg_net_msc, cfg_net_msc_cmd, return CMD_WARNING; } - vty->index = msc; + vty->index = (void *) index; vty->node = MSC_NODE; return CMD_SUCCESS; } diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c index a02d1f8..faea820 100644 --- a/openbsc/tests/db/db_test.c +++ b/openbsc/tests/db/db_test.c @@ -200,7 +200,7 @@ int main() alice->lac=42; db_sync_subscriber(alice); /* Get by TMSI */ - snprintf(scratch_str, sizeof(scratch_str), "%"PRIu32, alice->tmsi); + snprintf(scratch_str, sizeof(scratch_str), "0x%08x", alice->tmsi); alice_db = db_get_subscriber(GSM_SUBSCRIBER_TMSI, scratch_str); COMPARE(alice, alice_db); SUBSCR_PUT(alice_db); @@ -227,7 +227,7 @@ int main() db_subscriber_assoc_imei(alice, "1234567890"); db_subscriber_assoc_imei(alice, "6543560920"); /* Get by TMSI */ - snprintf(scratch_str, sizeof(scratch_str), "%"PRIu32, alice->tmsi); + snprintf(scratch_str, sizeof(scratch_str), "0x%08x", alice->tmsi); alice_db = db_get_subscriber(GSM_SUBSCRIBER_TMSI, scratch_str); COMPARE(alice, alice_db); SUBSCR_PUT(alice_db); diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c index 781ef61..8ed57ca 100644 --- a/openbsc/tests/gsm0408/gsm0408_test.c +++ b/openbsc/tests/gsm0408/gsm0408_test.c @@ -93,7 +93,7 @@ static void test_mi_functionality(void) /* tmsi code */ mi_len = gsm48_generate_mid_from_tmsi(mi, tmsi); gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len - 2); - COMPARE((uint32_t)strtoul(mi_parsed, NULL, 10), ==, tmsi); + COMPARE((uint32_t)tmsi_from_string(mi_parsed), ==, tmsi); /* imsi code */ mi_len = gsm48_generate_mid_from_imsi(mi, imsi_odd); -- 2.7.4 From holger at freyther.de Sun Mar 27 13:35:25 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 27 Mar 2016 15:35:25 +0200 Subject: Time to rename projects.osmocom.org to osmocom.org In-Reply-To: References: Message-ID: <79493EC9-B340-4207-8CF3-1AA4EBFE4373@freyther.de> > On 18 Mar 2016, at 20:59, Holger Freyther wrote: > > Hi, > > any objections or corrections to that? this is now in place and the old domains are now using X509 certs of letsencrypt. holger From 246tnt at gmail.com Sun Mar 27 14:30:31 2016 From: 246tnt at gmail.com (Sylvain Munaut) Date: Sun, 27 Mar 2016 16:30:31 +0200 Subject: Time to rename projects.osmocom.org to osmocom.org In-Reply-To: <79493EC9-B340-4207-8CF3-1AA4EBFE4373@freyther.de> References: <79493EC9-B340-4207-8CF3-1AA4EBFE4373@freyther.de> Message-ID: > this is now in place and the old domains are now using X509 certs of letsencrypt. Do you know if redmine supports going to HTTPS only (i.e. redir http to https). I changed the "protocol" to HTTPS in the admin panel but that had no effect afaict. I would prefer to be HTTPS only and also have the session cookie have the "Secure" flag (so they're never sent over plain HTTP) Cheers, Sylvain From holger at freyther.de Sun Mar 27 16:40:33 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 27 Mar 2016 18:40:33 +0200 Subject: Time to rename projects.osmocom.org to osmocom.org In-Reply-To: References: <79493EC9-B340-4207-8CF3-1AA4EBFE4373@freyther.de> Message-ID: <7F92EBB5-3188-4E81-854C-B9DF70DBD64D@freyther.de> > On 27 Mar 2016, at 16:30, Sylvain Munaut <246tnt at gmail.com> wrote: > >> this is now in place and the old domains are now using X509 certs of letsencrypt. > > Do you know if redmine supports going to HTTPS only (i.e. redir http > to https). I changed the "protocol" to HTTPS in the admin panel but > that had no effect afaict. I don't know. > I would prefer to be HTTPS only and also have the session cookie have > the "Secure" flag (so they're never sent over plain HTTP) I added: proxy_set_header X-Forwarded-Ssl on; to the nginx config in the hope that redmine makes use of that instead of the X-Forwarded-Proto. If it matters to you deeply we can make a general http -> https redirect. holger From holger at freyther.de Sun Mar 27 16:44:15 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 27 Mar 2016 18:44:15 +0200 Subject: [PATCH] move to hex TMSI representation In-Reply-To: <1459081030-23070-1-git-send-email-axilirator@gmail.com> References: <1459081030-23070-1-git-send-email-axilirator@gmail.com> Message-ID: > On 27 Mar 2016, at 14:17, Vadim Yanitskiy wrote: Dear Vadim, > > In OpenBSC, we traditionally displayed a TMSI in its integer > representation, which is quite unusual in the telecom world. A TMSI is > normally printed as a series of 8 hex digits. > > This patch aligns OpenBSC with the telecom industry standard. thanks a lot, I am afraid we need one more round. > -#define tmsi_from_string(str) strtoul(str, NULL, 10) > +#define tmsi_from_string(str) strtoul(str + 2, NULL, 16) this macro is used for parsing strings from the network. We should not modify it. > struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp, > - uint32_t tmsi) > + const char *tmsi) why? the number of bytes needed fit in uint32_t so we should remain with this internal storage. We should just make sure to always print it as hex. > -#define SCHEMA_REVISION "4" > +#define SCHEMA_REVISION "5" good, but I think we should change the schema to use uint32_t/INTEGER for the TMSI instead of text. > + /* Update old TMSI */ > + update = dbi_conn_queryf(conn, > + "UPDATE Subscriber " > + "SET tmsi = '0x%08x' " > + "WHERE id = %llu", but to int :) kind regards holger From holger at freyther.de Sun Mar 27 16:46:40 2016 From: holger at freyther.de (Holger Freyther) Date: Sun, 27 Mar 2016 18:46:40 +0200 Subject: Time to rename projects.osmocom.org to osmocom.org In-Reply-To: <7F92EBB5-3188-4E81-854C-B9DF70DBD64D@freyther.de> References: <79493EC9-B340-4207-8CF3-1AA4EBFE4373@freyther.de> <7F92EBB5-3188-4E81-854C-B9DF70DBD64D@freyther.de> Message-ID: <24432F59-2C05-4B90-8EF1-72048E9CEEB0@freyther.de> > On 27 Mar 2016, at 18:40, Holger Freyther wrote: > > > > to the nginx config in the hope that redmine makes use of that instead of the X-Forwarded-Proto. If it matters to you deeply we can make a general http -> https redirect. > ah lol... http://www.redmine.org/projects/redmine/wiki/RedmineSettings#Protocol says it is for http vs. https in email notifications. :} From axilirator at gmail.com Mon Mar 28 00:39:11 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Mon, 28 Mar 2016 06:39:11 +0600 Subject: Time to rename projects.osmocom.org to osmocom.org Message-ID: > I added: > proxy_set_header X-Forwarded-Ssl on; I think if nginx is used as main back-end (without Apache), this header means nothing. In this case just refer this guide: https://scotthelme.co.uk/setting-up-hsts-in-nginx/ If I'm not right, and there is also Apache server, follow: http://stackoverflow.com/questions/16042647/whats-the-de-facto-standard-for-a-reverse-proxy-to-tell-the-backend-ssl-is-used ? ?????????? ???????????, ??????? ?????. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nhofmeyr at sysmocom.de Tue Mar 29 10:05:19 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 29 Mar 2016 12:05:19 +0200 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode In-Reply-To: <20160327082653.GO27418@nataraja> References: <1458816899-30771-1-git-send-email-msuraev@sysmocom.de> <20160327082653.GO27418@nataraja> Message-ID: <20160329100519.GA1922@ass40.sysmocom.de> On Sun, Mar 27, 2016 at 10:26:53AM +0200, Harald Welte wrote: > theoretically, there could also be a 'c' where the accessor function is an > inline function or a macro, as it basicall is just a one-liner. I tend to use static inline functions with a switch(){} (I recently submitted a patch like that in "[PATCH 1/7] Add MM Auth test; add auth_action_str() function"). Is the get_value_string() way preferred to a switch? Thanks, ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Tue Mar 29 10:16:01 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Tue, 29 Mar 2016 12:16:01 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <20160327085353.GT27418@nataraja> References: <1459024539-31433-1-git-send-email-nhofmeyr@sysmocom.de> <1459024539-31433-2-git-send-email-nhofmeyr@sysmocom.de> <20160327085353.GT27418@nataraja> Message-ID: <20160329101601.GB1922@ass40.sysmocom.de> On Sun, Mar 27, 2016 at 10:53:53AM +0200, Harald Welte wrote: > Hi Neels, > > On Sat, Mar 26, 2016 at 09:35:33PM +0100, Neels Hofmeyr wrote: > > +static inline const char *auth_action_str(enum auth_action a) > > we normally try to avoid introducing some custom value/string converter > code like this and use 'struct value_string' for this. ah :) (sorry for the noise from previous mail) > > +#define AUTH_CASE(X) \ > > + case X: return #X > > you can also define a macro like this that generates a > { X, #X }, > for struct value_string > > + case -1: > > + return "(internal error)"; > > this would be an ugly > > { -1, "(internal error") } > > which is soon replaced by your #define AUTH_ERROR anyway. yes, I preferred to first have the test suite in place before introducing more enum values... > ... and please refrain from having non-trivial functions (or data > definitions), and particularly non-performance-critical functions like > this inline in a header file. ack > I would merge the entire patch-set, if you could address that one issue. Thanks! great, am onto it! ~Neels -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Tue Mar 29 10:21:09 2016 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 29 Mar 2016 12:21:09 +0200 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode In-Reply-To: <20160329100519.GA1922@ass40.sysmocom.de> References: <1458816899-30771-1-git-send-email-msuraev@sysmocom.de> <20160327082653.GO27418@nataraja> <20160329100519.GA1922@ass40.sysmocom.de> Message-ID: <20160329102109.GF27418@nataraja> On Tue, Mar 29, 2016 at 12:05:19PM +0200, Neels Hofmeyr wrote: > On Sun, Mar 27, 2016 at 10:26:53AM +0200, Harald Welte wrote: > > theoretically, there could also be a 'c' where the accessor function is an > > inline function or a macro, as it basicall is just a one-liner. > > I tend to use static inline functions with a switch(){} (I recently > submitted a patch like that in "[PATCH 1/7] Add MM Auth test; add > auth_action_str() function"). Yes, and AFAIR I already provided feedback about this particular issues. > Is the get_value_string() way preferred to a switch? yes, it is the general way how we map numbers to ascii strings and vice-versa. It is not as effcient as it iterates the list, but * as it is used for debug statements and from VTY, performance is not the utmost concern * I prefer to have one way that all code uses over everyone inventing their own methods. That helps in terms of reducing code duplication and also helps if we ever want to migrate to something more efficient (wireshark is the source of value_string, and they have a hashed version now, AFAIK). Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Tue Mar 29 16:10:42 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Tue, 29 Mar 2016 22:10:42 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: <1459081030-23070-1-git-send-email-axilirator@gmail.com> Message-ID: Hello! > thanks a lot, I am afraid we need one more round. No problem :) > -#define tmsi_from_string(str) strtoul(str, NULL, 10) > +#define tmsi_from_string(str) strtoul(str + 2, NULL, 16) > > this macro is used for parsing strings from the network. We should not modify it. I cannot find where... Searching 420 files for "tmsi_from_string" (regex) /home/wmn/openbsc/openbsc/include/openbsc/gsm_subscriber.h: 15 #define GSM_SUBSCRIBER_FIRST_CONTACT 0x00000001 16 /* gprs_sgsn.h defines additional flags including and above bit 16 (0x10000) */ 17: #define tmsi_from_string(str) strtoul(str + 2, NULL, 16) 18 19 #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 /home/wmn/openbsc/openbsc/src/libcommon/gsm_subscriber_base.c: 122 { 123 struct gsm_subscriber *subscr; 124: uint8_t tmsi_val = tmsi_from_string(tmsi); 125 126 llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) { /home/wmn/openbsc/openbsc/src/libmsc/db.c: 890 string = dbi_result_get_string(result, "tmsi"); 891 if (string) 892: subscr->tmsi = tmsi_from_string(string); 893 894 string = dbi_result_get_string(result, "name"); /home/wmn/openbsc/openbsc/src/libmsc/gsm_subscriber.c: 215 { 216 struct gsm_subscriber *subscr; 217: uint32_t tmsi_val = tmsi_from_string(tmsi); 218 219 /* we might have a record in memory already */ /home/wmn/openbsc/openbsc/tests/gsm0408/gsm0408_test.c: 94 mi_len = gsm48_generate_mid_from_tmsi(mi, tmsi); 95 gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len - 2); 96: COMPARE((uint32_t)tmsi_from_string(mi_parsed), ==, tmsi); 97 98 /* imsi code */ 5 matches across 5 files > struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp, > - uint32_t tmsi) > + const char *tmsi) > > why? the number of bytes needed fit in uint32_t so we should remain with this internal storage. We should just make sure to always print it as hex. Ok, I'll revert this changes. > -#define SCHEMA_REVISION "4" > +#define SCHEMA_REVISION "5" > > good, but I think we should change the schema to use uint32_t/INTEGER for the TMSI instead of text. I'll do it in db.c. ? ?????????? ???????????, ??????? ?????. 2016-03-27 22:44 GMT+06:00 Holger Freyther : > > > On 27 Mar 2016, at 14:17, Vadim Yanitskiy wrote: > > Dear Vadim, > > > > > > In OpenBSC, we traditionally displayed a TMSI in its integer > > representation, which is quite unusual in the telecom world. A TMSI is > > normally printed as a series of 8 hex digits. > > > > This patch aligns OpenBSC with the telecom industry standard. > > thanks a lot, I am afraid we need one more round. > > > > -#define tmsi_from_string(str) strtoul(str, NULL, 10) > > +#define tmsi_from_string(str) strtoul(str + 2, NULL, 16) > > this macro is used for parsing strings from the network. We should not > modify it. > > > > > struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group > *sgrp, > > - uint32_t tmsi) > > + const char *tmsi) > > > why? the number of bytes needed fit in uint32_t so we should remain with > this internal storage. We should just make sure to always print it as hex. > > > > -#define SCHEMA_REVISION "4" > > +#define SCHEMA_REVISION "5" > > good, but I think we should change the schema to use uint32_t/INTEGER for > the TMSI instead of text. > > > > > + /* Update old TMSI */ > > + update = dbi_conn_queryf(conn, > > + "UPDATE Subscriber " > > + "SET tmsi = '0x%08x' " > > + "WHERE id = %llu", > > but to int :) > > > kind regards > holger -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Tue Mar 29 16:39:16 2016 From: holger at freyther.de (Holger Freyther) Date: Tue, 29 Mar 2016 18:39:16 +0200 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: <1459081030-23070-1-git-send-email-axilirator@gmail.com> Message-ID: > On 29 Mar 2016, at 18:10, ????? ??????? wrote: > > Hello! > > > thanks a lot, I am afraid we need one more round. > > No problem :) > > > -#define tmsi_from_string(str) strtoul(str, NULL, 10) > > +#define tmsi_from_string(str) strtoul(str + 2, NULL, 16) > > > > this macro is used for parsing strings from the network. We should not modify it. > > I cannot find where... ah I see. You change the invocations in gsm_04_08.c. I would prefer if the name of this method is changed but once we work with uint32_t it will mostly go away anyway? holger From axilirator at gmail.com Tue Mar 29 18:42:08 2016 From: axilirator at gmail.com (=?UTF-8?B?0JLQsNC00LjQvCDQr9C90LjRhtC60LjQuQ==?=) Date: Wed, 30 Mar 2016 00:42:08 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: <1459081030-23070-1-git-send-email-axilirator@gmail.com> Message-ID: Yes, we needn't this macro now. The only place it can be used is vty_interface_layer3.c: static struct gsm_subscriber *get_subscr_by_argv(struct gsm_network *gsmnet, const char *type, const char *id) { if (!strcmp(type, "extension")) return subscr_get_by_extension(gsmnet->subscr_group, id); else if (!strcmp(type, "imsi")) return subscr_get_by_imsi(gsmnet->subscr_group, id); else if (!strcmp(type, "tmsi")) return subscr_get_by_tmsi(gsmnet->subscr_group, id); else if (!strcmp(type, "id")) return subscr_get_by_id(gsmnet->subscr_group, atoi(id)); return NULL; } In this place we have to convert a string (written from VTY) to uint32_t and then call the subscr_get_by_tmsi() with converted value. User input can be unexpected, so we should check/limit the length and check if there is '0x' sequence or not. ? ?????????? ???????????, ??????? ?????. 2016-03-29 22:39 GMT+06:00 Holger Freyther : > > > On 29 Mar 2016, at 18:10, ????? ??????? wrote: > > > > Hello! > > > > > thanks a lot, I am afraid we need one more round. > > > > No problem :) > > > > > -#define tmsi_from_string(str) strtoul(str, NULL, 10) > > > +#define tmsi_from_string(str) strtoul(str + 2, NULL, 16) > > > > > > this macro is used for parsing strings from the network. We should not > modify it. > > > > I cannot find where... > > > ah I see. You change the invocations in gsm_04_08.c. I would prefer if the > name of this method is changed but once we work with uint32_t it will > mostly go away anyway? > > holger -------------- next part -------------- An HTML attachment was scrubbed... URL: From nhofmeyr at sysmocom.de Tue Mar 29 22:45:35 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:35 +0200 Subject: [PATCH 0/7] v2 of: Introduce MM Auth test suite and fix two issues Message-ID: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Changes to previous version: * Use struct value_string[] instead of switch{} for auth_action_str(). * Tweak first and last patch's log message. Neels Hofmeyr (7): Add MM Auth test; add auth_action_str() function MM Auth test: add two tests for AUTH_THEN_CIPH MM Auth test: add test to re-use existing auth MM Auth: introduce AUTH_ERROR constant. MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero Fix MM Auth: disallow key_seq mismatch Fix MM Auth: zero-initialize auth tuple before first use openbsc/.gitignore | 1 + openbsc/configure.ac | 1 + openbsc/include/openbsc/auth.h | 18 ++ openbsc/src/libmsc/auth.c | 24 ++- openbsc/tests/Makefile.am | 2 +- openbsc/tests/mm_auth/Makefile.am | 21 +++ openbsc/tests/mm_auth/mm_auth_test.c | 340 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 40 ++++ openbsc/tests/testsuite.at | 7 + 9 files changed, 446 insertions(+), 8 deletions(-) create mode 100644 openbsc/tests/mm_auth/Makefile.am create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:36 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:36 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-2-git-send-email-nhofmeyr@sysmocom.de> Add basic MM Authentication test setup, with fake DB access and RAND_bytes(). So far implement simple tests for IO error during DB access and missing auth entry. To print the auth action during tests, implement auth_action_str() inline function. --- openbsc/.gitignore | 1 + openbsc/configure.ac | 1 + openbsc/include/openbsc/auth.h | 18 +++++ openbsc/tests/Makefile.am | 2 +- openbsc/tests/mm_auth/Makefile.am | 21 ++++++ openbsc/tests/mm_auth/mm_auth_test.c | 119 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 8 +++ openbsc/tests/testsuite.at | 7 ++ 8 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 openbsc/tests/mm_auth/Makefile.am create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok diff --git a/openbsc/.gitignore b/openbsc/.gitignore index 55f4a31..28fdcc8 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -80,6 +80,7 @@ tests/sgsn/sgsn_test tests/subscr/subscr_test tests/oap/oap_test tests/gtphub/gtphub_test +tests/mm_auth/mm_auth_test tests/atconfig tests/atlocal diff --git a/openbsc/configure.ac b/openbsc/configure.ac index 24dbc30..60601fe 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -216,6 +216,7 @@ AC_OUTPUT( tests/subscr/Makefile tests/oap/Makefile tests/gtphub/Makefile + tests/mm_auth/Makefile doc/Makefile doc/examples/Makefile Makefile) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index d41d141..6c463d4 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -11,6 +11,24 @@ enum auth_action { AUTH_DO_AUTH = 3, /* Only authentication, no ciphering */ }; +static inline const char *auth_action_str(enum auth_action a) +{ +#define AUTH_CASE(X) \ + case X: return #X + + switch (a) { + AUTH_CASE(AUTH_NOT_AVAIL); + AUTH_CASE(AUTH_DO_AUTH_THEN_CIPH); + AUTH_CASE(AUTH_DO_CIPH); + AUTH_CASE(AUTH_DO_AUTH); + case -1: + return "(internal error)"; + default: + return "(unknown auth_action)"; + } +#undef AUTH_CASE +} + int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, struct gsm_subscriber *subscr, int key_seq); diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am index 04b8e34..09298a3 100644 --- a/openbsc/tests/Makefile.am +++ b/openbsc/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau subscr +SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau subscr mm_auth if BUILD_NAT SUBDIRS += bsc-nat bsc-nat-trie diff --git a/openbsc/tests/mm_auth/Makefile.am b/openbsc/tests/mm_auth/Makefile.am new file mode 100644 index 0000000..516df00 --- /dev/null +++ b/openbsc/tests/mm_auth/Makefile.am @@ -0,0 +1,21 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(LIBCRYPTO_CFLAGS) + +noinst_PROGRAMS = mm_auth_test + +EXTRA_DIST = mm_auth_test.ok + +mm_auth_test_SOURCES = mm_auth_test.c + +mm_auth_test_LDFLAGS = \ + -Wl,--wrap=db_get_authinfo_for_subscr \ + -Wl,--wrap=db_get_lastauthtuple_for_subscr \ + -Wl,--wrap=db_sync_lastauthtuple_for_subscr + +mm_auth_test_LDADD = $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c new file mode 100644 index 0000000..d8e4475 --- /dev/null +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -0,0 +1,119 @@ +#include + +#include +#include + +#include +#include +#include +#include + +/* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */ +int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, + struct gsm_subscriber *subscr); + +int test_get_authinfo_rc = 0; +struct gsm_auth_info test_auth_info = {0}; +struct gsm_auth_info default_auth_info = { + .auth_algo = AUTH_ALGO_COMP128v1, + .a3a8_ki_len = 16, + .a3a8_ki = { 0 } +}; + +int __wrap_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, + struct gsm_subscriber *subscr) +{ + *ainfo = test_auth_info; + printf("wrapped: db_get_authinfo_for_subscr(): rc = %d\n", test_get_authinfo_rc); + return test_get_authinfo_rc; +} + +/* override, requires '-Wl,--wrap=db_get_lastauthtuple_for_subscr' */ +int __real_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr); + +int test_get_lastauthtuple_rc = 0; +struct gsm_auth_tuple test_last_auth_tuple = { 0 }; +struct gsm_auth_tuple default_auth_tuple = { 0 }; + +int __wrap_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr) +{ + *atuple = test_last_auth_tuple; + printf("wrapped: db_get_lastauthtuple_for_subscr(): rc = %d\n", test_get_lastauthtuple_rc); + return test_get_lastauthtuple_rc; +} + +/* override, requires '-Wl,--wrap=db_sync_lastauthtuple_for_subscr' */ +int __real_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr); +int test_sync_lastauthtuple_rc = 0; +int __wrap_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr) +{ + test_last_auth_tuple = *atuple; + printf("wrapped: db_sync_lastauthtuple_for_subscr(): rc = %d\n", test_sync_lastauthtuple_rc); + return test_sync_lastauthtuple_rc; +} + +int auth_get_tuple_for_subscr_verbose(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr, + int key_seq) +{ + int auth_action; + auth_action = auth_get_tuple_for_subscr(atuple, subscr, key_seq); + printf("auth_get_tuple_for_subscr(key_seq=%d) --> auth_action == %s\n", + key_seq, auth_action_str(auth_action)); + return auth_action; +} + +/* override libssl RAND_bytes() to get testable crypto results */ +int RAND_bytes(uint8_t *rand, int len) +{ + memset(rand, 23, len); + return 1; +} + +static void test_error() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq = 0; + + printf("\n* test_error()\n"); + + /* any error (except -ENOENT) */ + test_get_authinfo_rc = -EIO; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == -1); +} + +static void test_auth_not_avail() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq = 0; + + printf("\n* test_auth_not_avail()\n"); + + /* no entry */ + test_get_authinfo_rc = -ENOENT; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL); +} + +int main(void) +{ + osmo_init_logging(&log_info); + log_set_log_level(osmo_stderr_target, LOGL_INFO); + + test_error(); + test_auth_not_avail(); + return 0; +} diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok new file mode 100644 index 0000000..5efb3de --- /dev/null +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -0,0 +1,8 @@ + +* test_error() +wrapped: db_get_authinfo_for_subscr(): rc = -5 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) + +* test_auth_not_avail() +wrapped: db_get_authinfo_for_subscr(): rc = -2 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 6a1c77f..dab9568 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -117,3 +117,10 @@ AT_CHECK([test "$enable_gtphub_test" != no || exit 77]) cat $abs_srcdir/gtphub/gtphub_test.ok > expout AT_CHECK([$abs_top_builddir/tests/gtphub/gtphub_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([mm_auth]) +AT_KEYWORDS([mm_auth]) +cat $abs_srcdir/mm_auth/mm_auth_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/mm_auth/mm_auth_test], [], [expout], [ignore]) +AT_CLEANUP + -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:37 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:37 +0200 Subject: [PATCH 2/7] MM Auth test: add two tests for AUTH_THEN_CIPH In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-3-git-send-email-nhofmeyr@sysmocom.de> Test two situations for AUTH_DO_AUTH_THEN_CIPH: - when no auth tuple is available - when the key sequence from LU is marked invalid Add convenience auth tuple comparison function using stringification. --- openbsc/tests/mm_auth/mm_auth_test.c | 136 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 16 ++++ 2 files changed, 152 insertions(+) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index d8e4475..c0b8da4 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -8,6 +8,59 @@ #include #include +#define min(A,B) ((A)>(B)? (B) : (A)) + +static char *auth_tuple_str(struct gsm_auth_tuple *atuple) +{ + static char buf[256]; + char *pos = buf; + int len = sizeof(buf); + int l; + +#define print2buf(FMT, args...) do {\ + l = snprintf(pos, len, FMT, ## args); \ + pos += l;\ + len -= l;\ + } while (0) + + print2buf("gsm_auth_tuple {\n"); + print2buf(" .use_count = %d\n", atuple->use_count); + print2buf(" .key_seq = %d\n", atuple->key_seq); + print2buf(" .rand = %s\n", osmo_hexdump(atuple->rand, sizeof(atuple->rand))); + print2buf(" .sres = %s\n", osmo_hexdump(atuple->sres, sizeof(atuple->sres))); + print2buf(" .kc = %s\n", osmo_hexdump(atuple->kc, sizeof(atuple->kc))); + print2buf("}\n"); +#undef print2buf + + return buf; +} + +static bool auth_tuple_is(struct gsm_auth_tuple *atuple, + const char *expect_str) +{ + int l, l1, l2; + int i; + char *tuple_str = auth_tuple_str(atuple); + bool same = (strcmp(expect_str, tuple_str) == 0); + if (!same) { + l1 = strlen(expect_str); + l2 = strlen(tuple_str); + printf("Expected %d:\n%s\nGot %d:\n%s\n", + l1, expect_str, l2, tuple_str); + l = min(l1, l2); + for (i = 0; i < l; i++) { + if (expect_str[i] != tuple_str[i]) { + printf("Difference at pos %d" + " (%c 0x%0x != %c 0x%0x)\n", + i, expect_str[i], expect_str[i], + tuple_str[i], tuple_str[i]); + break; + } + } + } + return same; +} + /* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */ int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, struct gsm_subscriber *subscr); @@ -108,6 +161,87 @@ static void test_auth_not_avail() OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL); } +static void test_auth_then_ciph1() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_then_ciph1()\n"); + + /* Ki entry, but no auth tuple negotiated yet */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = -ENOENT; + key_seq = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 1\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + +static void test_auth_then_ciph2() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_then_ciph2()\n"); + + /* Ki entry, auth tuple negotiated, but invalid incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 2; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + key_seq = GSM_KEY_SEQ_INVAL; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 3\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); + + /* Change the last saved key_seq, expect last_auth_tuple.key_seq + 1 */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + key_seq = GSM_KEY_SEQ_INVAL; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 4\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -115,5 +249,7 @@ int main(void) test_error(); test_auth_not_avail(); + test_auth_then_ciph1(); + test_auth_then_ciph2(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 5efb3de..52feb36 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -6,3 +6,19 @@ auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) * test_auth_not_avail() wrapped: db_get_authinfo_for_subscr(): rc = -2 auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL + +* test_auth_then_ciph1() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH + +* test_auth_then_ciph2() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:38 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:38 +0200 Subject: [PATCH 3/7] MM Auth test: add test to re-use existing auth In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-4-git-send-email-nhofmeyr@sysmocom.de> --- openbsc/tests/mm_auth/mm_auth_test.c | 31 +++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index c0b8da4..e541898 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -242,6 +242,36 @@ static void test_auth_then_ciph2() )); } +static void test_auth_reuse() +{ + int auth_action; + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_reuse()\n"); + + /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = key_seq = 3; + test_last_auth_tuple.use_count = 1; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 2\n" + " .key_seq = 3\n" + " .rand = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n" + " .sres = 00 00 00 00 \n" + " .kc = 00 00 00 00 00 00 00 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -251,5 +281,6 @@ int main(void) test_auth_not_avail(); test_auth_then_ciph1(); test_auth_then_ciph2(); + test_auth_reuse(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 52feb36..cc0e769 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -22,3 +22,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH + +* test_auth_reuse() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:39 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:39 +0200 Subject: [PATCH 4/7] MM Auth: introduce AUTH_ERROR constant. In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-5-git-send-email-nhofmeyr@sysmocom.de> Instead of using hardcoded -1 for errors, include -1 in the enum auth_action type; apply its use. In effect remove a compiler warning recently introduced in auth_action_str() about int value not represented in enum definition. In the mm_auth test, the string output changes from '(internal error)' to 'AUTH_ERROR'. --- openbsc/include/openbsc/auth.h | 4 ++-- openbsc/src/libmsc/auth.c | 4 ++-- openbsc/tests/mm_auth/mm_auth_test.c | 2 +- openbsc/tests/mm_auth/mm_auth_test.ok | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index 6c463d4..d8312c3 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -5,6 +5,7 @@ struct gsm_auth_tuple; struct gsm_subscriber; enum auth_action { + AUTH_ERROR = -1, /* Internal error */ AUTH_NOT_AVAIL = 0, /* No auth tuple available */ AUTH_DO_AUTH_THEN_CIPH = 1, /* Firsth authenticate, then cipher */ AUTH_DO_CIPH = 2, /* Only ciphering */ @@ -17,12 +18,11 @@ static inline const char *auth_action_str(enum auth_action a) case X: return #X switch (a) { + AUTH_CASE(AUTH_ERROR); AUTH_CASE(AUTH_NOT_AVAIL); AUTH_CASE(AUTH_DO_AUTH_THEN_CIPH); AUTH_CASE(AUTH_DO_CIPH); AUTH_CASE(AUTH_DO_AUTH); - case -1: - return "(internal error)"; default: return "(unknown auth_action)"; } diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 65a9b03..68ba8c3 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -84,7 +84,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, if (rc < 0) { LOGP(DMM, LOGL_NOTICE, "No retrievable Ki for subscriber, skipping auth\n"); - return rc == -ENOENT ? AUTH_NOT_AVAIL : -1; + return rc == -ENOENT ? AUTH_NOT_AVAIL : AUTH_ERROR; } /* If possible, re-use the last tuple and skip auth */ @@ -105,7 +105,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); - return -1; + return AUTH_ERROR; } switch (ainfo.auth_algo) { diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index e541898..1d65984 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -141,7 +141,7 @@ static void test_error() test_get_authinfo_rc = -EIO; auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, key_seq); - OSMO_ASSERT(auth_action == -1); + OSMO_ASSERT(auth_action == AUTH_ERROR); } static void test_auth_not_avail() diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index cc0e769..7dedadc 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -1,7 +1,7 @@ * test_error() wrapped: db_get_authinfo_for_subscr(): rc = -5 -auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_ERROR * test_auth_not_avail() wrapped: db_get_authinfo_for_subscr(): rc = -2 -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:40 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:40 +0200 Subject: [PATCH 5/7] MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-6-git-send-email-nhofmeyr@sysmocom.de> AUTH_NOT_AVAIL == 0, so this is no functional change. --- openbsc/src/libmsc/auth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 68ba8c3..0a8fbf4 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -111,22 +111,22 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, switch (ainfo.auth_algo) { case AUTH_ALGO_NONE: DEBUGP(DMM, "No authentication for subscriber\n"); - return 0; + return AUTH_NOT_AVAIL; case AUTH_ALGO_XOR: if (_use_xor(&ainfo, atuple)) - return 0; + return AUTH_NOT_AVAIL; break; case AUTH_ALGO_COMP128v1: if (_use_comp128_v1(&ainfo, atuple)) - return 0; + return AUTH_NOT_AVAIL; break; default: DEBUGP(DMM, "Unsupported auth type algo_id=%d\n", ainfo.auth_algo); - return 0; + return AUTH_NOT_AVAIL; } db_sync_lastauthtuple_for_subscr(atuple, subscr); -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:41 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:41 +0200 Subject: [PATCH 6/7] Fix MM Auth: disallow key_seq mismatch In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-7-git-send-email-nhofmeyr@sysmocom.de> In auth_get_tuple_for_subscr(), add missing condition to match incoming key_seq with stored key_seq, so that re-authentication is requested for mismatching key_seqs. Add test for this issue. --- openbsc/src/libmsc/auth.c | 1 + openbsc/tests/mm_auth/mm_auth_test.c | 32 ++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 6 ++++++ 3 files changed, 39 insertions(+) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 0a8fbf4..e4d33f0 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -91,6 +91,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, rc = db_get_lastauthtuple_for_subscr(atuple, subscr); if ((rc == 0) && (key_seq != GSM_KEY_SEQ_INVAL) && + (key_seq == atuple->key_seq) && (atuple->use_count < 3)) { atuple->use_count++; diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index 1d65984..2b45861 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -272,6 +272,37 @@ static void test_auth_reuse() )); } +static void test_auth_reuse_key_seq_mismatch() +{ + int auth_action; + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_reuse_key_seq_mismatch()\n"); + + /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + key_seq = 4; + test_last_auth_tuple.use_count = 1; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 4\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -282,5 +313,6 @@ int main(void) test_auth_then_ciph1(); test_auth_then_ciph2(); test_auth_reuse(); + test_auth_reuse_key_seq_mismatch(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 7dedadc..9d89bfb 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -28,3 +28,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH + +* test_auth_reuse_key_seq_mismatch() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=4) --> auth_action == AUTH_DO_AUTH_THEN_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Tue Mar 29 22:45:42 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 00:45:42 +0200 Subject: [PATCH 7/7] Fix MM Auth: zero-initialize auth tuple before first use In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459291542-2505-8-git-send-email-nhofmeyr@sysmocom.de> Make sure a new auth tuple is initialized after db_get_lastauthtuple_for_subscr() returns an error. In effect, the first key_seq used no longer depends on how the auth tuple was initialized before the call. Before this patch, the first key_seq depended on the value was present in auth tuple's key_seq. --- openbsc/src/libmsc/auth.c | 11 ++++++++++- openbsc/tests/mm_auth/mm_auth_test.c | 24 +++++++++++++++++++++++- openbsc/tests/mm_auth/mm_auth_test.ok | 4 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index e4d33f0..53eb717 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -101,8 +101,17 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, } /* Generate a new one */ + if (rc != 0) { + /* If db_get_lastauthtuple_for_subscr() returned nothing, make + * sure the atuple memory is initialized to zero and thus start + * off with key_seq = 0. */ + memset(atuple, 0, sizeof(*atuple)); + } else { + /* If db_get_lastauthtuple_for_subscr() returned a previous + * tuple, use the next key_seq. */ + atuple->key_seq = (atuple->key_seq + 1) % 7; + } atuple->use_count = 1; - atuple->key_seq = (atuple->key_seq + 1) % 7; if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index 2b45861..34d96f1 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -183,7 +183,29 @@ static void test_auth_then_ciph1() OSMO_ASSERT(auth_tuple_is(&atuple, "gsm_auth_tuple {\n" " .use_count = 1\n" - " .key_seq = 1\n" + " .key_seq = 0\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); + + /* With a different last saved key_seq stored in the out-arg of + * db_get_lastauthtuple_for_subscr() by coincidence, expect absolutely + * the same as above. */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = -ENOENT; + key_seq = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 0\n" " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" " .sres = a1 ab c6 90 \n" " .kc = 0f 27 ed f3 ac 97 ac 00 \n" diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 9d89bfb..6c49f97 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -12,6 +12,10 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH * test_auth_then_ciph2() wrapped: db_get_authinfo_for_subscr(): rc = 0 -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:13:08 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:13:08 +0200 Subject: PLEASE IGNORE: Re: [PATCH 0/7] v2 of: Introduce MM Auth test suite and fix two issues In-Reply-To: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160330091308.GA1894@dub6> Since recently I have two boxes I work with and have repositories on, so yesterday I reposted the same patch as the first time and marked it as v2. v2 was still waiting in remote and I failed to pull it before submitting. And ... I'd have submitted v2 yesterday noon, but some mail setup on the other box was still broken :P Well, I hope this teaches me to pay more attention now. Sorry for the noise! ~Neels On Wed, Mar 30, 2016 at 12:45:35AM +0200, Neels Hofmeyr wrote: > Changes to previous version: > > * Use struct value_string[] instead of switch{} for auth_action_str(). > * Tweak first and last patch's log message. > > Neels Hofmeyr (7): > Add MM Auth test; add auth_action_str() function > MM Auth test: add two tests for AUTH_THEN_CIPH > MM Auth test: add test to re-use existing auth > MM Auth: introduce AUTH_ERROR constant. > MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero > Fix MM Auth: disallow key_seq mismatch > Fix MM Auth: zero-initialize auth tuple before first use > > openbsc/.gitignore | 1 + > openbsc/configure.ac | 1 + > openbsc/include/openbsc/auth.h | 18 ++ > openbsc/src/libmsc/auth.c | 24 ++- > openbsc/tests/Makefile.am | 2 +- > openbsc/tests/mm_auth/Makefile.am | 21 +++ > openbsc/tests/mm_auth/mm_auth_test.c | 340 ++++++++++++++++++++++++++++++++++ > openbsc/tests/mm_auth/mm_auth_test.ok | 40 ++++ > openbsc/tests/testsuite.at | 7 + > 9 files changed, 446 insertions(+), 8 deletions(-) > create mode 100644 openbsc/tests/mm_auth/Makefile.am > create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c > create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok > > -- > 2.1.4 > -- - Neels Hofmeyr http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Gesch?ftsf?hrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From laforge at gnumonks.org Wed Mar 30 08:41:11 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 30 Mar 2016 10:41:11 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <1459291542-2505-2-git-send-email-nhofmeyr@sysmocom.de> References: <1459291542-2505-1-git-send-email-nhofmeyr@sysmocom.de> <1459291542-2505-2-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160330084111.GC27418@nataraja> Hi Neels, > * Use struct value_string[] instead of switch{} for auth_action_str(). thanks, but... On Wed, Mar 30, 2016 at 12:45:36AM +0200, Neels Hofmeyr wrote: > +static inline const char *auth_action_str(enum auth_action a) > +{ > +#define AUTH_CASE(X) \ > + case X: return #X am I missing something? Cheers, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From nhofmeyr at sysmocom.de Wed Mar 30 09:22:23 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:23 +0200 Subject: [PATCH 0/7] v3 of: Introduce MM Auth test suite and fix two issues Message-ID: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> v2 was an accidental re-post of the same patches, this time for real: Changes to first version: * Use struct value_string[] instead of switch{} for auth_action_str(). * Tweak first and last patch's log message. Neels Hofmeyr (7): Add MM Auth test; add auth_action_str() function MM Auth test: add two tests for AUTH_THEN_CIPH MM Auth test: add test to re-use existing auth MM Auth: introduce AUTH_ERROR constant. MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero Fix MM Auth: disallow key_seq mismatch Fix MM Auth: zero-initialize auth tuple before first use openbsc/.gitignore | 1 + openbsc/configure.ac | 1 + openbsc/include/openbsc/auth.h | 9 + openbsc/src/libmsc/auth.c | 33 +++- openbsc/tests/Makefile.am | 2 +- openbsc/tests/mm_auth/Makefile.am | 21 +++ openbsc/tests/mm_auth/mm_auth_test.c | 340 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 40 ++++ openbsc/tests/testsuite.at | 7 + 9 files changed, 446 insertions(+), 8 deletions(-) create mode 100644 openbsc/tests/mm_auth/Makefile.am create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:24 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:24 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-2-git-send-email-nhofmeyr@sysmocom.de> Add basic MM Authentication test setup, with fake DB access and RAND_bytes(). So far implement simple tests for IO error during DB access and missing auth entry. To print the auth action during tests, add struct auth_action_names and auth_action_str() inline function in auth.[hc]. --- openbsc/.gitignore | 1 + openbsc/configure.ac | 1 + openbsc/include/openbsc/auth.h | 8 +++ openbsc/src/libmsc/auth.c | 9 +++ openbsc/tests/Makefile.am | 2 +- openbsc/tests/mm_auth/Makefile.am | 21 ++++++ openbsc/tests/mm_auth/mm_auth_test.c | 119 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 8 +++ openbsc/tests/testsuite.at | 7 ++ 9 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 openbsc/tests/mm_auth/Makefile.am create mode 100644 openbsc/tests/mm_auth/mm_auth_test.c create mode 100644 openbsc/tests/mm_auth/mm_auth_test.ok diff --git a/openbsc/.gitignore b/openbsc/.gitignore index 55f4a31..28fdcc8 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -80,6 +80,7 @@ tests/sgsn/sgsn_test tests/subscr/subscr_test tests/oap/oap_test tests/gtphub/gtphub_test +tests/mm_auth/mm_auth_test tests/atconfig tests/atlocal diff --git a/openbsc/configure.ac b/openbsc/configure.ac index 24dbc30..60601fe 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -216,6 +216,7 @@ AC_OUTPUT( tests/subscr/Makefile tests/oap/Makefile tests/gtphub/Makefile + tests/mm_auth/Makefile doc/Makefile doc/examples/Makefile Makefile) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index d41d141..90495bb 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -1,6 +1,8 @@ #ifndef _AUTH_H #define _AUTH_H +#include + struct gsm_auth_tuple; struct gsm_subscriber; @@ -11,6 +13,12 @@ enum auth_action { AUTH_DO_AUTH = 3, /* Only authentication, no ciphering */ }; +extern const struct value_string auth_action_names[]; +static inline const char *auth_action_str(enum auth_action a) +{ + return get_value_string(auth_action_names, a); +} + int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, struct gsm_subscriber *subscr, int key_seq); diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 65a9b03..8512316 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -31,6 +31,15 @@ #include +const struct value_string auth_action_names[] = { +#define AUTH_ACTION_STR(X) { X, #X } + { -1, "(internal error)" }, /* soon to be fixed with an enum val */ + AUTH_ACTION_STR(AUTH_NOT_AVAIL), + AUTH_ACTION_STR(AUTH_DO_AUTH_THEN_CIPH), + AUTH_ACTION_STR(AUTH_DO_CIPH), + AUTH_ACTION_STR(AUTH_DO_AUTH), +#undef AUTH_ACTION_STR +}; static int _use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am index 04b8e34..09298a3 100644 --- a/openbsc/tests/Makefile.am +++ b/openbsc/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau subscr +SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau subscr mm_auth if BUILD_NAT SUBDIRS += bsc-nat bsc-nat-trie diff --git a/openbsc/tests/mm_auth/Makefile.am b/openbsc/tests/mm_auth/Makefile.am new file mode 100644 index 0000000..516df00 --- /dev/null +++ b/openbsc/tests/mm_auth/Makefile.am @@ -0,0 +1,21 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall \ + $(LIBOSMOCORE_CFLAGS) \ + $(LIBOSMOGSM_CFLAGS) \ + $(LIBCRYPTO_CFLAGS) + +noinst_PROGRAMS = mm_auth_test + +EXTRA_DIST = mm_auth_test.ok + +mm_auth_test_SOURCES = mm_auth_test.c + +mm_auth_test_LDFLAGS = \ + -Wl,--wrap=db_get_authinfo_for_subscr \ + -Wl,--wrap=db_get_lastauthtuple_for_subscr \ + -Wl,--wrap=db_sync_lastauthtuple_for_subscr + +mm_auth_test_LDADD = $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOGSM_LIBS) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c new file mode 100644 index 0000000..d8e4475 --- /dev/null +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -0,0 +1,119 @@ +#include + +#include +#include + +#include +#include +#include +#include + +/* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */ +int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, + struct gsm_subscriber *subscr); + +int test_get_authinfo_rc = 0; +struct gsm_auth_info test_auth_info = {0}; +struct gsm_auth_info default_auth_info = { + .auth_algo = AUTH_ALGO_COMP128v1, + .a3a8_ki_len = 16, + .a3a8_ki = { 0 } +}; + +int __wrap_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, + struct gsm_subscriber *subscr) +{ + *ainfo = test_auth_info; + printf("wrapped: db_get_authinfo_for_subscr(): rc = %d\n", test_get_authinfo_rc); + return test_get_authinfo_rc; +} + +/* override, requires '-Wl,--wrap=db_get_lastauthtuple_for_subscr' */ +int __real_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr); + +int test_get_lastauthtuple_rc = 0; +struct gsm_auth_tuple test_last_auth_tuple = { 0 }; +struct gsm_auth_tuple default_auth_tuple = { 0 }; + +int __wrap_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr) +{ + *atuple = test_last_auth_tuple; + printf("wrapped: db_get_lastauthtuple_for_subscr(): rc = %d\n", test_get_lastauthtuple_rc); + return test_get_lastauthtuple_rc; +} + +/* override, requires '-Wl,--wrap=db_sync_lastauthtuple_for_subscr' */ +int __real_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr); +int test_sync_lastauthtuple_rc = 0; +int __wrap_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr) +{ + test_last_auth_tuple = *atuple; + printf("wrapped: db_sync_lastauthtuple_for_subscr(): rc = %d\n", test_sync_lastauthtuple_rc); + return test_sync_lastauthtuple_rc; +} + +int auth_get_tuple_for_subscr_verbose(struct gsm_auth_tuple *atuple, + struct gsm_subscriber *subscr, + int key_seq) +{ + int auth_action; + auth_action = auth_get_tuple_for_subscr(atuple, subscr, key_seq); + printf("auth_get_tuple_for_subscr(key_seq=%d) --> auth_action == %s\n", + key_seq, auth_action_str(auth_action)); + return auth_action; +} + +/* override libssl RAND_bytes() to get testable crypto results */ +int RAND_bytes(uint8_t *rand, int len) +{ + memset(rand, 23, len); + return 1; +} + +static void test_error() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq = 0; + + printf("\n* test_error()\n"); + + /* any error (except -ENOENT) */ + test_get_authinfo_rc = -EIO; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == -1); +} + +static void test_auth_not_avail() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq = 0; + + printf("\n* test_auth_not_avail()\n"); + + /* no entry */ + test_get_authinfo_rc = -ENOENT; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL); +} + +int main(void) +{ + osmo_init_logging(&log_info); + log_set_log_level(osmo_stderr_target, LOGL_INFO); + + test_error(); + test_auth_not_avail(); + return 0; +} diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok new file mode 100644 index 0000000..5efb3de --- /dev/null +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -0,0 +1,8 @@ + +* test_error() +wrapped: db_get_authinfo_for_subscr(): rc = -5 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) + +* test_auth_not_avail() +wrapped: db_get_authinfo_for_subscr(): rc = -2 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index 6a1c77f..dab9568 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -117,3 +117,10 @@ AT_CHECK([test "$enable_gtphub_test" != no || exit 77]) cat $abs_srcdir/gtphub/gtphub_test.ok > expout AT_CHECK([$abs_top_builddir/tests/gtphub/gtphub_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([mm_auth]) +AT_KEYWORDS([mm_auth]) +cat $abs_srcdir/mm_auth/mm_auth_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/mm_auth/mm_auth_test], [], [expout], [ignore]) +AT_CLEANUP + -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:25 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:25 +0200 Subject: [PATCH 2/7] MM Auth test: add two tests for AUTH_THEN_CIPH In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-3-git-send-email-nhofmeyr@sysmocom.de> Test two situations for AUTH_DO_AUTH_THEN_CIPH: - when no auth tuple is available - when the key sequence from LU is marked invalid Add convenience auth tuple comparison function using stringification. --- openbsc/tests/mm_auth/mm_auth_test.c | 136 ++++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 16 ++++ 2 files changed, 152 insertions(+) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index d8e4475..c0b8da4 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -8,6 +8,59 @@ #include #include +#define min(A,B) ((A)>(B)? (B) : (A)) + +static char *auth_tuple_str(struct gsm_auth_tuple *atuple) +{ + static char buf[256]; + char *pos = buf; + int len = sizeof(buf); + int l; + +#define print2buf(FMT, args...) do {\ + l = snprintf(pos, len, FMT, ## args); \ + pos += l;\ + len -= l;\ + } while (0) + + print2buf("gsm_auth_tuple {\n"); + print2buf(" .use_count = %d\n", atuple->use_count); + print2buf(" .key_seq = %d\n", atuple->key_seq); + print2buf(" .rand = %s\n", osmo_hexdump(atuple->rand, sizeof(atuple->rand))); + print2buf(" .sres = %s\n", osmo_hexdump(atuple->sres, sizeof(atuple->sres))); + print2buf(" .kc = %s\n", osmo_hexdump(atuple->kc, sizeof(atuple->kc))); + print2buf("}\n"); +#undef print2buf + + return buf; +} + +static bool auth_tuple_is(struct gsm_auth_tuple *atuple, + const char *expect_str) +{ + int l, l1, l2; + int i; + char *tuple_str = auth_tuple_str(atuple); + bool same = (strcmp(expect_str, tuple_str) == 0); + if (!same) { + l1 = strlen(expect_str); + l2 = strlen(tuple_str); + printf("Expected %d:\n%s\nGot %d:\n%s\n", + l1, expect_str, l2, tuple_str); + l = min(l1, l2); + for (i = 0; i < l; i++) { + if (expect_str[i] != tuple_str[i]) { + printf("Difference at pos %d" + " (%c 0x%0x != %c 0x%0x)\n", + i, expect_str[i], expect_str[i], + tuple_str[i], tuple_str[i]); + break; + } + } + } + return same; +} + /* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */ int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo, struct gsm_subscriber *subscr); @@ -108,6 +161,87 @@ static void test_auth_not_avail() OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL); } +static void test_auth_then_ciph1() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_then_ciph1()\n"); + + /* Ki entry, but no auth tuple negotiated yet */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = -ENOENT; + key_seq = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 1\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + +static void test_auth_then_ciph2() +{ + int auth_action; + + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_then_ciph2()\n"); + + /* Ki entry, auth tuple negotiated, but invalid incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 2; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + key_seq = GSM_KEY_SEQ_INVAL; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 3\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); + + /* Change the last saved key_seq, expect last_auth_tuple.key_seq + 1 */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + key_seq = GSM_KEY_SEQ_INVAL; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 4\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -115,5 +249,7 @@ int main(void) test_error(); test_auth_not_avail(); + test_auth_then_ciph1(); + test_auth_then_ciph2(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 5efb3de..52feb36 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -6,3 +6,19 @@ auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) * test_auth_not_avail() wrapped: db_get_authinfo_for_subscr(): rc = -2 auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL + +* test_auth_then_ciph1() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH + +* test_auth_then_ciph2() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:26 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:26 +0200 Subject: [PATCH 3/7] MM Auth test: add test to re-use existing auth In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-4-git-send-email-nhofmeyr@sysmocom.de> --- openbsc/tests/mm_auth/mm_auth_test.c | 31 +++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index c0b8da4..e541898 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -242,6 +242,36 @@ static void test_auth_then_ciph2() )); } +static void test_auth_reuse() +{ + int auth_action; + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_reuse()\n"); + + /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = key_seq = 3; + test_last_auth_tuple.use_count = 1; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 2\n" + " .key_seq = 3\n" + " .rand = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n" + " .sres = 00 00 00 00 \n" + " .kc = 00 00 00 00 00 00 00 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -251,5 +281,6 @@ int main(void) test_auth_not_avail(); test_auth_then_ciph1(); test_auth_then_ciph2(); + test_auth_reuse(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 52feb36..cc0e769 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -22,3 +22,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH + +* test_auth_reuse() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:27 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:27 +0200 Subject: [PATCH 4/7] MM Auth: introduce AUTH_ERROR constant. In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-5-git-send-email-nhofmeyr@sysmocom.de> Instead of using hardcoded -1 for errors, include -1 in the enum auth_action type; apply its use. In the mm_auth test, the string output changes from '(internal error)' to 'AUTH_ERROR', since now the proper enum value is used in auth_action_names[]. --- openbsc/include/openbsc/auth.h | 1 + openbsc/src/libmsc/auth.c | 6 +++--- openbsc/tests/mm_auth/mm_auth_test.c | 2 +- openbsc/tests/mm_auth/mm_auth_test.ok | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openbsc/include/openbsc/auth.h b/openbsc/include/openbsc/auth.h index 90495bb..6181131 100644 --- a/openbsc/include/openbsc/auth.h +++ b/openbsc/include/openbsc/auth.h @@ -7,6 +7,7 @@ struct gsm_auth_tuple; struct gsm_subscriber; enum auth_action { + AUTH_ERROR = -1, /* Internal error */ AUTH_NOT_AVAIL = 0, /* No auth tuple available */ AUTH_DO_AUTH_THEN_CIPH = 1, /* Firsth authenticate, then cipher */ AUTH_DO_CIPH = 2, /* Only ciphering */ diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 8512316..99e3a24 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -33,7 +33,7 @@ const struct value_string auth_action_names[] = { #define AUTH_ACTION_STR(X) { X, #X } - { -1, "(internal error)" }, /* soon to be fixed with an enum val */ + AUTH_ACTION_STR(AUTH_ERROR), AUTH_ACTION_STR(AUTH_NOT_AVAIL), AUTH_ACTION_STR(AUTH_DO_AUTH_THEN_CIPH), AUTH_ACTION_STR(AUTH_DO_CIPH), @@ -93,7 +93,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, if (rc < 0) { LOGP(DMM, LOGL_NOTICE, "No retrievable Ki for subscriber, skipping auth\n"); - return rc == -ENOENT ? AUTH_NOT_AVAIL : -1; + return rc == -ENOENT ? AUTH_NOT_AVAIL : AUTH_ERROR; } /* If possible, re-use the last tuple and skip auth */ @@ -114,7 +114,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); - return -1; + return AUTH_ERROR; } switch (ainfo.auth_algo) { diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index e541898..1d65984 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -141,7 +141,7 @@ static void test_error() test_get_authinfo_rc = -EIO; auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, key_seq); - OSMO_ASSERT(auth_action == -1); + OSMO_ASSERT(auth_action == AUTH_ERROR); } static void test_auth_not_avail() diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index cc0e769..7dedadc 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -1,7 +1,7 @@ * test_error() wrapped: db_get_authinfo_for_subscr(): rc = -5 -auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error) +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_ERROR * test_auth_not_avail() wrapped: db_get_authinfo_for_subscr(): rc = -2 -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:28 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:28 +0200 Subject: [PATCH 5/7] MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-6-git-send-email-nhofmeyr@sysmocom.de> AUTH_NOT_AVAIL == 0, so this is no functional change. --- openbsc/src/libmsc/auth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 99e3a24..4ce1839 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -120,22 +120,22 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, switch (ainfo.auth_algo) { case AUTH_ALGO_NONE: DEBUGP(DMM, "No authentication for subscriber\n"); - return 0; + return AUTH_NOT_AVAIL; case AUTH_ALGO_XOR: if (_use_xor(&ainfo, atuple)) - return 0; + return AUTH_NOT_AVAIL; break; case AUTH_ALGO_COMP128v1: if (_use_comp128_v1(&ainfo, atuple)) - return 0; + return AUTH_NOT_AVAIL; break; default: DEBUGP(DMM, "Unsupported auth type algo_id=%d\n", ainfo.auth_algo); - return 0; + return AUTH_NOT_AVAIL; } db_sync_lastauthtuple_for_subscr(atuple, subscr); -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:29 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:29 +0200 Subject: [PATCH 6/7] Fix MM Auth: disallow key_seq mismatch In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-7-git-send-email-nhofmeyr@sysmocom.de> In auth_get_tuple_for_subscr(), add missing condition to match incoming key_seq with stored key_seq, so that re-authentication is requested for mismatching key_seqs. Add test for this issue. --- openbsc/src/libmsc/auth.c | 1 + openbsc/tests/mm_auth/mm_auth_test.c | 32 ++++++++++++++++++++++++++++++++ openbsc/tests/mm_auth/mm_auth_test.ok | 6 ++++++ 3 files changed, 39 insertions(+) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 4ce1839..ca39d01 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -100,6 +100,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, rc = db_get_lastauthtuple_for_subscr(atuple, subscr); if ((rc == 0) && (key_seq != GSM_KEY_SEQ_INVAL) && + (key_seq == atuple->key_seq) && (atuple->use_count < 3)) { atuple->use_count++; diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index 1d65984..2b45861 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -272,6 +272,37 @@ static void test_auth_reuse() )); } +static void test_auth_reuse_key_seq_mismatch() +{ + int auth_action; + struct gsm_auth_tuple atuple = {0}; + struct gsm_subscriber subscr = {0}; + int key_seq; + + printf("\n* test_auth_reuse_key_seq_mismatch()\n"); + + /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + key_seq = 4; + test_last_auth_tuple.use_count = 1; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 4\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); +} + int main(void) { osmo_init_logging(&log_info); @@ -282,5 +313,6 @@ int main(void) test_auth_then_ciph1(); test_auth_then_ciph2(); test_auth_reuse(); + test_auth_reuse_key_seq_mismatch(); return 0; } diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 7dedadc..9d89bfb 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -28,3 +28,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH + +* test_auth_reuse_key_seq_mismatch() +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = 0 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=4) --> auth_action == AUTH_DO_AUTH_THEN_CIPH -- 2.1.4 From nhofmeyr at sysmocom.de Wed Mar 30 09:22:30 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Wed, 30 Mar 2016 11:22:30 +0200 Subject: [PATCH 7/7] Fix MM Auth: zero-initialize auth tuple before first use In-Reply-To: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <1459329750-2318-8-git-send-email-nhofmeyr@sysmocom.de> Make sure a new auth tuple is initialized after db_get_lastauthtuple_for_subscr() returns an error, i.e. if no tuple is present for the subscriber yet. Before this patch, the first key_seq depended on the typically uninitialized value that was present in auth tuple's key_seq upon calling auth_get_tuple_for_subscr(). The very first key_seq used for a new subscriber will now always be 0. Before, it used to be mostly 1 ("(0 + 1) % 7"), but depended on whether the key_seq was indeed initialized with 0, actually by random. --- openbsc/src/libmsc/auth.c | 11 ++++++++++- openbsc/tests/mm_auth/mm_auth_test.c | 24 +++++++++++++++++++++++- openbsc/tests/mm_auth/mm_auth_test.ok | 4 ++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index ca39d01..f30d56d 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -110,8 +110,17 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, } /* Generate a new one */ + if (rc != 0) { + /* If db_get_lastauthtuple_for_subscr() returned nothing, make + * sure the atuple memory is initialized to zero and thus start + * off with key_seq = 0. */ + memset(atuple, 0, sizeof(*atuple)); + } else { + /* If db_get_lastauthtuple_for_subscr() returned a previous + * tuple, use the next key_seq. */ + atuple->key_seq = (atuple->key_seq + 1) % 7; + } atuple->use_count = 1; - atuple->key_seq = (atuple->key_seq + 1) % 7; if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c index 2b45861..34d96f1 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.c +++ b/openbsc/tests/mm_auth/mm_auth_test.c @@ -183,7 +183,29 @@ static void test_auth_then_ciph1() OSMO_ASSERT(auth_tuple_is(&atuple, "gsm_auth_tuple {\n" " .use_count = 1\n" - " .key_seq = 1\n" + " .key_seq = 0\n" + " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" + " .sres = a1 ab c6 90 \n" + " .kc = 0f 27 ed f3 ac 97 ac 00 \n" + "}\n" + )); + + /* With a different last saved key_seq stored in the out-arg of + * db_get_lastauthtuple_for_subscr() by coincidence, expect absolutely + * the same as above. */ + test_auth_info = default_auth_info; + test_last_auth_tuple = default_auth_tuple; + test_last_auth_tuple.key_seq = 3; + test_get_authinfo_rc = 0; + test_get_lastauthtuple_rc = -ENOENT; + key_seq = 0; + auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr, + key_seq); + OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH); + OSMO_ASSERT(auth_tuple_is(&atuple, + "gsm_auth_tuple {\n" + " .use_count = 1\n" + " .key_seq = 0\n" " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n" " .sres = a1 ab c6 90 \n" " .kc = 0f 27 ed f3 ac 97 ac 00 \n" diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok index 9d89bfb..6c49f97 100644 --- a/openbsc/tests/mm_auth/mm_auth_test.ok +++ b/openbsc/tests/mm_auth/mm_auth_test.ok @@ -12,6 +12,10 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0 wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH +wrapped: db_get_authinfo_for_subscr(): rc = 0 +wrapped: db_get_lastauthtuple_for_subscr(): rc = -2 +wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0 +auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH * test_auth_then_ciph2() wrapped: db_get_authinfo_for_subscr(): rc = 0 -- 2.1.4 From msuraev at sysmocom.de Wed Mar 30 12:58:17 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 30 Mar 2016 14:58:17 +0200 Subject: [PATCH 4/4] Extend apps attribute In-Reply-To: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> References: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1459342697-1041-4-git-send-email-msuraev@sysmocom.de> From: Max In addition to binary name it's now possible to provide extra command-line arguments in osmoappdesc.py for application under test. This change is fully optional and backward compatible. --- osmopy/osmotestconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 808048d..b020d86 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -49,7 +49,7 @@ def test_config_atest(app_desc, config, run_test, verbose=True): proc = None ret = None try: - cmd = [app_desc[1], "-c", config] + cmd = app_desc[1].split(' ') + [ "-c", config] if verbose: print "Verifying %s, test %s" % (' '.join(cmd), run_test.__name__) @@ -128,7 +128,7 @@ def verify_doc(vty): # Skip testing the configurations of anything that hasn't been compiled def app_exists(app_desc): - cmd = app_desc[1] + cmd = app_desc[1].split(' ')[0] return os.path.exists(cmd) -- 2.8.0 From msuraev at sysmocom.de Wed Mar 30 12:58:14 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 30 Mar 2016 14:58:14 +0200 Subject: [PATCH 1/4] Add .gitignore Message-ID: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> From: Max Ignore install leftovers. --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..766f495 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +osmopython.egg-info/ -- 2.8.0 From msuraev at sysmocom.de Wed Mar 30 12:58:15 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 30 Mar 2016 14:58:15 +0200 Subject: [PATCH 2/4] Expand installation instructions In-Reply-To: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> References: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1459342697-1041-2-git-send-email-msuraev@sysmocom.de> From: Max --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index c4b7830..b85f7c9 100644 --- a/README +++ b/README @@ -2,6 +2,7 @@ Building/installation: sudo python setup.py install If you prefer to have it cleanly removable, install checkinstall and run sudo checkinstall python setup.py install +Alternatively, just run 'pip install --user -e ./' Use There are currently 3 scripts in this package: -- 2.8.0 From msuraev at sysmocom.de Wed Mar 30 12:58:16 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Wed, 30 Mar 2016 14:58:16 +0200 Subject: [PATCH 3/4] Add optional ignore_configs attribute In-Reply-To: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> References: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1459342697-1041-3-git-send-email-msuraev@sysmocom.de> From: Max This attribute in osmoappdesc.py allows to ignore certain configs while running vty tests. It's handy for hardware-specific or otherwise special configuration examples. --- osmopy/osmotestconfig.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index ce47cf3..808048d 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -139,11 +139,11 @@ def remove_tmpdir(tmpdir): os.rmdir(tmpdir) -def check_configs_tested(basedir, app_configs): +def check_configs_tested(basedir, app_configs, ignore_configs): configs = [] for root, dirs, files in os.walk(basedir): for f in files: - if f.endswith(".cfg"): + if f.endswith(".cfg") and f not in ignore_configs: configs.append(os.path.join(root, f)) for config in configs: found = False @@ -155,8 +155,8 @@ def check_configs_tested(basedir, app_configs): def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True, - confpath=".", rmtmp=False): - check_configs_tested("doc/examples/", app_configs) + confpath=".", rmtmp=False, ignore_configs=[]): + check_configs_tested("doc/examples/", app_configs, ignore_configs) errors = 0 for app in apps: if not app_exists(app): @@ -202,10 +202,11 @@ if __name__ == '__main__': apps = osmoappdesc.apps configs = osmoappdesc.app_configs + ignores = getattr(osmoappdesc, 'ignore_configs', []) if args.e1nitb: configs['nitb'].extend(osmoappdesc.nitb_e1_configs) os.chdir(workdir) - sys.exit(test_all_apps(apps, configs, confpath=confpath, - verbose=args.verbose)) + sys.exit(test_all_apps(apps, configs, ignore_configs=ignores, + confpath=confpath, verbose=args.verbose)) -- 2.8.0 From laforge at gnumonks.org Wed Mar 30 12:21:52 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 30 Mar 2016 14:21:52 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <1459329750-2318-2-git-send-email-nhofmeyr@sysmocom.de> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> <1459329750-2318-2-git-send-email-nhofmeyr@sysmocom.de> Message-ID: <20160330122152.GB23309@nataraja> On Wed, Mar 30, 2016 at 11:22:24AM +0200, Neels Hofmeyr wrote: > Add basic MM Authentication test setup, with fake DB access and RAND_bytes(). I'm sorry, but it doesn't seem to apply to current master ? -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From suraev at alumni.ntnu.no Wed Mar 30 19:14:53 2016 From: suraev at alumni.ntnu.no (suraev at alumni.ntnu.no) Date: Wed, 30 Mar 2016 21:14:53 +0200 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode Message-ID: <1459365293-18224-1-git-send-email-suraev@alumni.ntnu.no> From: Max This can be used with get_value_string() to improve debugging output. --- include/osmocom/gsm/gsm_utils.h | 3 +++ include/osmocom/gsm/protocol/gsm_04_08.h | 4 ++++ src/gsm/gsm48.c | 26 +++++++++++++++++++++++++- src/gsm/libosmogsm.map | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6458447..99aae65 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -28,6 +28,7 @@ #include #include +#include #define ADD_MODULO(sum, delta, modulo) do { \ if ((sum += delta) >= modulo) \ @@ -199,6 +200,8 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +extern const struct value_string gsm_chan_t_names[]; + /* Deprectated functions */ /* Limit encoding and decoding to use no more than this amount of buffer bytes */ #define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index d49b77f..3282bc1 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -2,6 +2,8 @@ #include +#include + /* GSM TS 04.08 definitions */ struct gsm_lchan; @@ -347,6 +349,8 @@ enum gsm48_chan_mode { GSM48_CMODE_DATA_3k6 = 0x13, }; +extern const struct value_string gsm48_chan_mode_names[]; + /* Chapter 9.1.2 */ struct gsm48_ass_cmd { /* Semantic is from 10.5.2.5a */ diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index d0a2286..ab62605 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -32,7 +32,7 @@ #include #include #include - +#include #include #include @@ -254,6 +254,30 @@ const char *rr_cause_name(uint8_t cause) return get_value_string(rr_cause_names, cause); } +const struct value_string gsm48_chan_mode_names[] = { + { GSM48_CMODE_SIGN, "SIGNALLING" }, + { GSM48_CMODE_SPEECH_V1, "SPEECH_V1" }, + { GSM48_CMODE_SPEECH_EFR, "SPEECH_EFR" }, + { GSM48_CMODE_SPEECH_AMR, "SPEECH_AMR" }, + { GSM48_CMODE_DATA_14k5, "DATA_14k5" }, + { GSM48_CMODE_DATA_12k0, "DATA_12k0" }, + { GSM48_CMODE_DATA_6k0, "DATA_6k0" }, + { GSM48_CMODE_DATA_3k6, "DATA_3k6" }, + { 0, NULL }, +}; + +const struct value_string gsm_chan_t_names[] = { + { GSM_LCHAN_NONE, "NONE" }, + { GSM_LCHAN_SDCCH, "SDCCH" }, + { GSM_LCHAN_TCH_F, "TCH_F" }, + { GSM_LCHAN_TCH_H, "TCH_H" }, + { GSM_LCHAN_UNKNOWN, "UNKNOWN" }, + { GSM_LCHAN_CCCH, "CCCH" }, + { GSM_LCHAN_PDTCH, "PDTCH" }, + { GSM_LCHAN_CBCH, "CBCH" }, + { 0, NULL }, +}; + static const struct value_string mi_type_names[] = { { GSM_MI_TYPE_NONE, "NONE" }, { GSM_MI_TYPE_IMSI, "IMSI" }, diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index a6908a2..a3e4e14 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -144,6 +144,8 @@ gsm48_rr_att_tlvdef; gsm48_mi_type_name; gsm48_mcc_mnc_to_bcd; gsm48_mcc_mnc_from_bcd; +gsm48_chan_mode_names; +gsm_chan_t_names; gsm_7bit_decode; gsm_7bit_decode_ussd; -- 2.5.0 From laforge at gnumonks.org Wed Mar 30 19:51:50 2016 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 30 Mar 2016 21:51:50 +0200 Subject: [PATCH] Export names for gsm_chan_t and gsm48_chan_mode In-Reply-To: <1459365293-18224-1-git-send-email-suraev@alumni.ntnu.no> References: <1459365293-18224-1-git-send-email-suraev@alumni.ntnu.no> Message-ID: <20160330195150.GH23309@nataraja> On Wed, Mar 30, 2016 at 09:14:53PM +0200, suraev at alumni.ntnu.no wrote: > This can be used with get_value_string() to improve debugging output. thanks, applied. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From axilirator at gmail.com Thu Mar 31 07:23:56 2016 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Thu, 31 Mar 2016 13:23:56 +0600 Subject: [PATCH] move to hex TMSI representation In-Reply-To: References: Message-ID: <1459409036-15607-1-git-send-email-axilirator@gmail.com> In OpenBSC, we traditionally displayed a TMSI in its integer representation, which is quite unusual in the telecom world. A TMSI is normally printed as a series of 8 hex digits. This patch aligns OpenBSC with the telecom industry standard and should be applied with corresponding patch for libosmocore. - Use hex representation in VTY - Increased DB SCHEMA_REVISION - Implemented DB migration code db_test is temporary broken because incremental migration isn't implemented yet (WIP). Signed-off-by: Vadim Yanitskiy --- openbsc/include/openbsc/gsm_subscriber.h | 2 +- openbsc/src/libmsc/db.c | 155 +++++++++++++++++++++++++----- openbsc/src/libmsc/vty_interface_layer3.c | 3 +- openbsc/tests/gsm0408/gsm0408_test.c | 2 +- 4 files changed, 133 insertions(+), 29 deletions(-) diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h index 7d6c776..785dc36 100644 --- a/openbsc/include/openbsc/gsm_subscriber.h +++ b/openbsc/include/openbsc/gsm_subscriber.h @@ -14,7 +14,7 @@ #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 tmsi_from_string(str) strtoul(str + 2, NULL, 16) #define GSM_SUBSCRIBER_NO_EXPIRATION 0x0 diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 0935fc5..04aee79 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -47,7 +47,7 @@ static char *db_basename = NULL; static char *db_dirname = NULL; static dbi_conn conn; -#define SCHEMA_REVISION "4" +#define SCHEMA_REVISION "5" enum { SCHEMA_META, @@ -83,7 +83,7 @@ static const char *create_stmts[] = { "name TEXT, " "extension TEXT UNIQUE, " "authorized INTEGER NOT NULL DEFAULT 0, " - "tmsi TEXT UNIQUE, " + "tmsi INTEGER UNIQUE, " "lac INTEGER NOT NULL DEFAULT 0, " "expire_lu TIMESTAMP DEFAULT NULL" ")", @@ -212,6 +212,7 @@ static int update_db_revision_2(void) } dbi_result_free(result); + LOGP(DDB, LOGL_NOTICE, "Migration complete.\n"); return 0; } @@ -357,6 +358,7 @@ static int update_db_revision_3(void) else dbi_result_free(result); + LOGP(DDB, LOGL_NOTICE, "Migration complete.\n"); return 0; rollback: @@ -369,6 +371,108 @@ rollback: return -EINVAL; } +static int update_db_revision_4(void) +{ + dbi_result result; + + LOGP(DDB, LOGL_NOTICE, "Going to migrate from revision 4\n"); + + result = dbi_conn_query(conn, "BEGIN EXCLUSIVE TRANSACTION"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to begin transaction " + "(upgrade from rev 4)\n"); + return -EINVAL; + } + dbi_result_free(result); + + /* Rename old Subscriber table to be able create a new one */ + result = dbi_conn_query(conn, + "ALTER TABLE Subscriber RENAME TO Subscriber_4"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to rename the old Subscriber table " + "(upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + /* Create new Subscriber table */ + result = dbi_conn_query(conn, create_stmts[SCHEMA_SUBSCRIBER]); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to create a new Subscriber table " + "(upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + /* Copy subscriber data into the new table */ + result = dbi_conn_query(conn, + "INSERT INTO Subscriber " + "SELECT * FROM Subscriber_4"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to copy subscriber data into the new table " + "(upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + /* Remove the temporary table */ + result = dbi_conn_query(conn, "DROP TABLE Subscriber_4"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to drop the old Subscriber table " + "(upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + /* We're done. Bump DB Meta revision to 5 */ + result = dbi_conn_query(conn, + "UPDATE Meta " + "SET value = '5' " + "WHERE key = 'revision'"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to update DB schema revision " + "(upgrade from rev 4).\n"); + goto rollback; + } + dbi_result_free(result); + + result = dbi_conn_query(conn, "COMMIT TRANSACTION"); + if (!result) { + LOGP(DDB, LOGL_ERROR, + "Failed to commit the transaction " + "(upgrade from rev 4)\n"); + return -EINVAL; + } + + /* Shrink DB file size by actually wiping out Subscriber_4 table data */ + result = dbi_conn_query(conn, "VACUUM"); + if (!result) + LOGP(DDB, LOGL_ERROR, + "VACUUM failed. Ignoring it " + "(upgrade from rev 4).\n"); + else + dbi_result_free(result); + + LOGP(DDB, LOGL_NOTICE, "Migration complete.\n"); + return 0; + +rollback: + result = dbi_conn_query(conn, "ROLLBACK TRANSACTION"); + if (!result) + LOGP(DDB, LOGL_ERROR, + "Rollback failed " + "(upgrade from rev 4).\n"); + else + dbi_result_free(result); + return -EINVAL; +} + static int check_db_revision(void) { dbi_result result; @@ -388,20 +492,18 @@ static int check_db_revision(void) dbi_result_free(result); return -EINVAL; } - if (!strcmp(rev_s, "2")) { - if (update_db_revision_2()) { - LOGP(DDB, LOGL_FATAL, "Failed to update database from schema revision '%s'.\n", rev_s); - dbi_result_free(result); - return -EINVAL; - } - } else if (!strcmp(rev_s, "3")) { - if (update_db_revision_3()) { - LOGP(DDB, LOGL_FATAL, "Failed to update database from schema revision '%s'.\n", rev_s); - dbi_result_free(result); - return -EINVAL; - } - } else if (!strcmp(rev_s, SCHEMA_REVISION)) { + + if (!strcmp(rev_s, SCHEMA_REVISION)) { /* everything is fine */ + } else if (!strcmp(rev_s, "2")) { + if (update_db_revision_2()) + goto error; + } else if (!strcmp(rev_s, "3")) { + if (update_db_revision_3()) + goto error; + } else if (!strcmp(rev_s, "4")) { + if (update_db_revision_4()) + goto error; } else { LOGP(DDB, LOGL_FATAL, "Invalid database schema revision '%s'.\n", rev_s); dbi_result_free(result); @@ -410,6 +512,11 @@ static int check_db_revision(void) dbi_result_free(result); return 0; + +error: + LOGP(DDB, LOGL_FATAL, "Failed to update database from schema revision '%s'.\n", rev_s); + dbi_result_free(result); + return -EINVAL; } static int db_configure(void) @@ -808,10 +915,6 @@ static void db_set_from_query(struct gsm_subscriber *subscr, dbi_conn result) if (string) strncpy(subscr->imsi, string, GSM_IMSI_LENGTH-1); - string = dbi_result_get_string(result, "tmsi"); - if (string) - subscr->tmsi = tmsi_from_string(string); - string = dbi_result_get_string(result, "name"); if (string) strncpy(subscr->name, string, GSM_NAME_LENGTH); @@ -820,7 +923,8 @@ static void db_set_from_query(struct gsm_subscriber *subscr, dbi_conn result) if (string) strncpy(subscr->extension, string, GSM_EXTENSION_LENGTH); - subscr->lac = dbi_result_get_ulonglong(result, "lac"); + subscr->tmsi = dbi_result_get_ulonglong(result, "tmsi"); + subscr->lac = dbi_result_get_ulonglong(result, "lac"); if (!dbi_result_field_is_null(result, "expire_lu")) subscr->expire_lu = dbi_result_get_datetime(result, "expire_lu"); @@ -828,7 +932,6 @@ static void db_set_from_query(struct gsm_subscriber *subscr, dbi_conn result) subscr->expire_lu = GSM_SUBSCRIBER_NO_EXPIRATION; subscr->authorized = dbi_result_get_ulonglong(result, "authorized"); - } #define BASE_QUERY "SELECT * FROM Subscriber " @@ -893,9 +996,10 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field, subscr->id = dbi_result_get_ulonglong(result, "id"); db_set_from_query(subscr, result); - DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', TMSI %u, EXTEN '%s', LAC %hu, AUTH %u\n", - subscr->id, subscr->imsi, subscr->name, subscr->tmsi, subscr->extension, - subscr->lac, subscr->authorized); + DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', " + "TMSI 0x%08x, EXTEN '%s', LAC %hu, AUTH %u\n", + subscr->id, subscr->imsi, subscr->name, subscr->tmsi, + subscr->extension, subscr->lac, subscr->authorized); dbi_result_free(result); get_equipment_by_subscr(subscr); @@ -998,7 +1102,6 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber) } dbi_result_free(result); - return 0; } @@ -1225,7 +1328,7 @@ int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) } if (!dbi_result_next_row(result)) { dbi_result_free(result); - DEBUGP(DDB, "Allocated TMSI %u for IMSI %s.\n", + DEBUGP(DDB, "Allocated TMSI 0x%08x for IMSI %s.\n", subscriber->tmsi, subscriber->imsi); return db_sync_subscriber(subscriber); } diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index f49c53a..9879a53 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -189,7 +189,8 @@ static struct gsm_subscriber *get_subscr_by_argv(struct gsm_network *gsmnet, else if (!strcmp(type, "imsi")) return subscr_get_by_imsi(gsmnet->subscr_group, id); else if (!strcmp(type, "tmsi")) - return subscr_get_by_tmsi(gsmnet->subscr_group, atoi(id)); + return subscr_get_by_tmsi(gsmnet->subscr_group, + tmsi_from_string(id)); else if (!strcmp(type, "id")) return subscr_get_by_id(gsmnet->subscr_group, atoi(id)); diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c index 781ef61..8ed57ca 100644 --- a/openbsc/tests/gsm0408/gsm0408_test.c +++ b/openbsc/tests/gsm0408/gsm0408_test.c @@ -93,7 +93,7 @@ static void test_mi_functionality(void) /* tmsi code */ mi_len = gsm48_generate_mid_from_tmsi(mi, tmsi); gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len - 2); - COMPARE((uint32_t)strtoul(mi_parsed, NULL, 10), ==, tmsi); + COMPARE((uint32_t)tmsi_from_string(mi_parsed), ==, tmsi); /* imsi code */ mi_len = gsm48_generate_mid_from_imsi(mi, imsi_odd); -- 2.8.0 From nhofmeyr at sysmocom.de Thu Mar 31 09:37:45 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 31 Mar 2016 11:37:45 +0200 Subject: [PATCH 1/7] Add MM Auth test; add auth_action_str() function In-Reply-To: <20160330122152.GB23309@nataraja> References: <1459329750-2318-1-git-send-email-nhofmeyr@sysmocom.de> <1459329750-2318-2-git-send-email-nhofmeyr@sysmocom.de> <20160330122152.GB23309@nataraja> Message-ID: <20160331093745.GB1149@ass40.sysmocom.de> On Wed, Mar 30, 2016 at 02:21:52PM +0200, Harald Welte wrote: > On Wed, Mar 30, 2016 at 11:22:24AM +0200, Neels Hofmeyr wrote: > > Add basic MM Authentication test setup, with fake DB access and RAND_bytes(). > > I'm sorry, but it doesn't seem to apply to current master ? I get a warning about a (super dangerous!) blank line at EOF, which is in openbsc/tests/testuite.at, otherwise it applies: ? git am /tmp/m Applying: Add MM Auth test; add auth_action_str() function /n/s/osmo/git/openbsc/.git/rebase-apply/patch:276: new blank line at EOF. + warning: 1 line adds whitespace errors. Applying: MM Auth test: add two tests for AUTH_THEN_CIPH Applying: MM Auth test: add test to re-use existing auth Applying: MM Auth: introduce AUTH_ERROR constant. Applying: MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero Applying: Fix MM Auth: disallow key_seq mismatch Applying: Fix MM Auth: zero-initialize auth tuple before first use I can re-post without that blank line if you like. Let me know... ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From nhofmeyr at sysmocom.de Thu Mar 31 10:00:24 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Thu, 31 Mar 2016 12:00:24 +0200 Subject: [PATCH 3/4] Add optional ignore_configs attribute In-Reply-To: <1459342697-1041-3-git-send-email-msuraev@sysmocom.de> References: <1459342697-1041-1-git-send-email-msuraev@sysmocom.de> <1459342697-1041-3-git-send-email-msuraev@sysmocom.de> Message-ID: <20160331100024.GC1149@ass40.sysmocom.de> On Wed, Mar 30, 2016 at 02:58:16PM +0200, msuraev at sysmocom.de wrote: > From: Max > > This attribute in osmoappdesc.py allows to ignore certain configs while > running vty tests. It's handy for hardware-specific or otherwise special > configuration examples. > --- > osmopy/osmotestconfig.py | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py > index ce47cf3..808048d 100644 > --- a/osmopy/osmotestconfig.py > +++ b/osmopy/osmotestconfig.py [...] > @@ -155,8 +155,8 @@ def check_configs_tested(basedir, app_configs): > > > def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True, > - confpath=".", rmtmp=False): > - check_configs_tested("doc/examples/", app_configs) > + confpath=".", rmtmp=False, ignore_configs=[]): > + check_configs_tested("doc/examples/", app_configs, ignore_configs) > errors = 0 > for app in apps: > if not app_exists(app): > @@ -202,10 +202,11 @@ if __name__ == '__main__': > > apps = osmoappdesc.apps > configs = osmoappdesc.app_configs > + ignores = getattr(osmoappdesc, 'ignore_configs', []) > > if args.e1nitb: > configs['nitb'].extend(osmoappdesc.nitb_e1_configs) > > os.chdir(workdir) > - sys.exit(test_all_apps(apps, configs, confpath=confpath, > - verbose=args.verbose)) > + sys.exit(test_all_apps(apps, configs, ignore_configs=ignores, > + confpath=confpath, verbose=args.verbose)) would have been slightly more beautiful to put ignore_configs at the end like in the def above, and would have made for a slightly smaller diff, too... but whatever. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From axilirator at gmail.com Thu Mar 31 10:51:45 2016 From: axilirator at gmail.com (Vadim Yanitskiy) Date: Thu, 31 Mar 2016 16:51:45 +0600 Subject: [PATCH] db.c: implemented incremental migration Message-ID: <1459421505-25727-1-git-send-email-axilirator@gmail.com> In the past normal migration was possible only if the actual schema version differed from the version used in DB by 1. For example, if DB uses an old version 3 and you need to use it with the code written for version 5, the check_db_revision() will convert it to 4 and DB will still use incompatible schema version during Osmo-NITB running time. After next run it will be converted to version 5. This patch replaces a set of 'else-if' checks by a 'switch' without 'break' statements between 'case' labels (waterfall). It makes you able to migrate from current version to the latest despite any difference between them. Also fixed the sms_from_result_v3() to avoid large depth of function calls, because they can be changed in the future and lose compatibility with old table schemas. Also fixed db_test and now it is successful. Signed-off-by: Vadim Yanitskiy --- openbsc/src/libmsc/db.c | 65 ++++++++++++++++++++++++++++---------------- openbsc/tests/db/db_test.c | 1 + openbsc/tests/db/db_test.err | 3 ++ 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 04aee79..ad5afca 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -225,23 +225,27 @@ static struct gsm_sms *sms_from_result_v3(dbi_result result) { struct gsm_sms *sms = sms_alloc(); long long unsigned int sender_id; - struct gsm_subscriber *sender; - const char *text, *daddr; + const char *text, *daddr, *extension; const unsigned char *user_data; - char buf[32]; + dbi_result sender_result; if (!sms) return NULL; - sms->id = dbi_result_get_ulonglong(result, "id"); - sender_id = dbi_result_get_ulonglong(result, "sender_id"); - snprintf(buf, sizeof(buf), "%llu", sender_id); - sender = db_get_subscriber(GSM_SUBSCRIBER_ID, buf); - OSMO_ASSERT(sender); - strncpy(sms->src.addr, sender->extension, sizeof(sms->src.addr)-1); - subscr_direct_free(sender); - sender = NULL; + sms->id = dbi_result_get_ulonglong(result, "id"); + + sender_result = dbi_conn_queryf(conn, + "SELECT * FROM Subscriber " + "WHERE id = %llu", sender_id); + + if (sender_result) { + if (dbi_result_next_row(sender_result)) { + extension = dbi_result_get_string(sender_result, "extension"); + strncpy(sms->src.addr, extension, sizeof(sms->src.addr) - 1); + } + dbi_result_free(sender_result); + } sms->reply_path_req = dbi_result_get_ulonglong(result, "reply_path_req"); sms->status_rep_req = dbi_result_get_ulonglong(result, "status_rep_req"); @@ -477,16 +481,20 @@ static int check_db_revision(void) { dbi_result result; const char *rev_s; + int db_rev = 0; + /* Make a query */ result = dbi_conn_query(conn, - "SELECT value FROM Meta WHERE key='revision'"); + "SELECT value FROM Meta " + "WHERE key = 'revision'"); if (!result) return -EINVAL; - if (!dbi_result_next_row(result)) { dbi_result_free(result); return -EINVAL; } + + /* Fetch the DB schema revision */ rev_s = dbi_result_get_string(result, "value"); if (!rev_s) { dbi_result_free(result); @@ -494,28 +502,37 @@ static int check_db_revision(void) } if (!strcmp(rev_s, SCHEMA_REVISION)) { - /* everything is fine */ - } else if (!strcmp(rev_s, "2")) { + /* Everything is fine */ + dbi_result_free(result); + return 0; + } + + db_rev = atoi(rev_s); + dbi_result_free(result); + + /* Incremental migration waterfall */ + switch (db_rev) { + case 2: if (update_db_revision_2()) goto error; - } else if (!strcmp(rev_s, "3")) { + case 3: if (update_db_revision_3()) goto error; - } else if (!strcmp(rev_s, "4")) { + case 4: if (update_db_revision_4()) - goto error; - } else { - LOGP(DDB, LOGL_FATAL, "Invalid database schema revision '%s'.\n", rev_s); - dbi_result_free(result); + goto error; + + /* The end of waterfall */ + break; + default: + LOGP(DDB, LOGL_FATAL, "Invalid database schema revision '%d'.\n", db_rev); return -EINVAL; } - dbi_result_free(result); return 0; error: - LOGP(DDB, LOGL_FATAL, "Failed to update database from schema revision '%s'.\n", rev_s); - dbi_result_free(result); + LOGP(DDB, LOGL_FATAL, "Failed to update database from schema revision '%d'.\n", db_rev); return -EINVAL; } diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c index a02d1f8..2fdd830 100644 --- a/openbsc/tests/db/db_test.c +++ b/openbsc/tests/db/db_test.c @@ -187,6 +187,7 @@ int main() char *alice_imsi = "3243245432345"; alice = db_create_subscriber(alice_imsi); + db_subscriber_alloc_tmsi(alice); db_sync_subscriber(alice); alice_db = db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice->imsi); COMPARE(alice, alice_db); diff --git a/openbsc/tests/db/db_test.err b/openbsc/tests/db/db_test.err index fa9a54c..d8a3e7f 100644 --- a/openbsc/tests/db/db_test.err +++ b/openbsc/tests/db/db_test.err @@ -1,2 +1,5 @@ Going to migrate from revision 3 +Migration complete. +Going to migrate from revision 4 +Migration complete.  \ No newline at end of file -- 2.8.0 From msuraev at sysmocom.de Thu Mar 31 13:23:16 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 31 Mar 2016 15:23:16 +0200 Subject: [PATCH] Add optional copy_files attribute Message-ID: <1459430596-9066-1-git-send-email-msuraev@sysmocom.de> From: Max This allows to specify additional files which shall be copied into temporary directory where tests are executed. --- osmopy/osmotestconfig.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index b020d86..1e72d4b 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -18,20 +18,20 @@ import os import os.path import time import sys -import tempfile +import tempfile, shutil import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil # Return true iff all the tests for the given config pass -def test_config(app_desc, config, tmpdir, verbose=True): +def test_config(app_desc, config, tmpdir, copy_files, verbose=True): try: err = 0 if test_config_atest(app_desc, config, verify_doc, verbose)[0] > 0: err += 1 - newconfig = copy_config(tmpdir, config) + newconfig = copy_config(tmpdir, config, copy_files) if test_config_atest(app_desc, newconfig, write_config, verbose) > 0: err += 1 @@ -73,7 +73,7 @@ def test_config_atest(app_desc, config, run_test, verbose=True): return ret -def copy_config(dirname, config): +def copy_config(dirname, config, copy_files): try: os.stat(dirname) except OSError: @@ -82,6 +82,9 @@ def copy_config(dirname, config): remove_tmpdir(dirname) os.mkdir(dirname) + for f in copy_files: + shutil.copy(f, dirname) + prefix = os.path.basename(config) tmpfile = tempfile.NamedTemporaryFile( dir=dirname, prefix=prefix, delete=False) @@ -155,9 +158,10 @@ def check_configs_tested(basedir, app_configs, ignore_configs): def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True, - confpath=".", rmtmp=False, ignore_configs=[]): + confpath=".", rmtmp=False, ignore_configs=[], copy_files=[]): check_configs_tested("doc/examples/", app_configs, ignore_configs) errors = 0 + for app in apps: if not app_exists(app): print >> sys.stderr, "Skipping app %s (not found)" % app[1] @@ -166,7 +170,7 @@ def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True, 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, copy_files, verbose) if rmtmp or not errors: remove_tmpdir(tmpdir) @@ -203,10 +207,12 @@ if __name__ == '__main__': apps = osmoappdesc.apps configs = osmoappdesc.app_configs ignores = getattr(osmoappdesc, 'ignore_configs', []) + copycat = getattr(osmoappdesc, 'copy_files', []) if args.e1nitb: configs['nitb'].extend(osmoappdesc.nitb_e1_configs) os.chdir(workdir) sys.exit(test_all_apps(apps, configs, ignore_configs=ignores, - confpath=confpath, verbose=args.verbose)) + confpath=confpath, copy_files=copycat, + verbose=args.verbose)) -- 2.8.0 From msuraev at sysmocom.de Thu Mar 31 13:26:23 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 31 Mar 2016 15:26:23 +0200 Subject: [PATCH 1/2] NAT: move BSC config into separate file Message-ID: <1459430784-11266-1-git-send-email-msuraev@sysmocom.de> From: Max Introduce new configuration option bscs-config-file which includes BSC configuration from the given file. Both absolute and relative (to the main config file) paths are supported. Add 'show bsc-config' command to display current BSC configuration. Note: it is still possible to have BSC configuration in the main file (provided proper index number is used) and in runtime but BSC configuration is no longer saved automatically. The management of included configuration file is left to external tools. Update configuration examples. Fixes: OS#1669 --- openbsc/doc/examples/osmo-bsc_nat/bscs.config | 13 ++++++++ openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg | 8 +---- openbsc/include/openbsc/bsc_nat.h | 4 +++ openbsc/osmoappdesc.py | 3 ++ openbsc/src/osmo-bsc_nat/bsc_nat.c | 5 ++- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 39 +++++++++++++++++++++- 6 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 openbsc/doc/examples/osmo-bsc_nat/bscs.config diff --git a/openbsc/doc/examples/osmo-bsc_nat/bscs.config b/openbsc/doc/examples/osmo-bsc_nat/bscs.config new file mode 100644 index 0000000..a10a565 --- /dev/null +++ b/openbsc/doc/examples/osmo-bsc_nat/bscs.config @@ -0,0 +1,13 @@ +nat + bsc 0 + token lol + location_area_code 1234 + description bsc + max-endpoints 32 + paging forbidden 0 + bsc 1 + token what + location_area_code 5678 + description bsc + max-endpoints 32 + paging forbidden 0 diff --git a/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg b/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg index 737d104..2e00bc2 100644 --- a/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg +++ b/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg @@ -62,11 +62,5 @@ nat timeout ping 20 timeout pong 5 ip-dscp 0 + bscs-config-file bscs.config access-list bla imsi-allow ^11$ - - bsc 0 - token bla - location_area_code 1234 - description bsc - max-endpoints 32 - paging forbidden 0 diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 309adb1..adc6bce 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -264,6 +264,10 @@ struct bsc_nat { struct bsc_endpoint *bsc_endpoints; + /* path to file with BSC config */ + char *include_file; + char *include_path; + /* filter */ char *acc_lst_name; diff --git a/openbsc/osmoappdesc.py b/openbsc/osmoappdesc.py index 76f03fc..d10ecae 100644 --- a/openbsc/osmoappdesc.py +++ b/openbsc/osmoappdesc.py @@ -26,6 +26,9 @@ nitb_e1_configs = [ "doc/examples/osmo-nitb/rbs2308/openbsc.cfg" ] +copy_files = [ + "doc/examples/osmo-bsc_nat/bscs.config" +] app_configs = { "osmo-bsc": ["doc/examples/osmo-bsc/osmo-bsc.cfg"], diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index cacb919..68d237c 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -34,6 +34,7 @@ #include #include #include +#include #define _GNU_SOURCE #include @@ -1626,6 +1627,8 @@ int main(int argc, char **argv) local_addr.s_addr = INADDR_ANY; handle_options(argc, argv); + nat->include_path = dirname(talloc_strdup(tall_bsc_ctx, config_file)); + rate_ctr_init(tall_bsc_ctx); osmo_stats_init(tall_bsc_ctx); @@ -1651,7 +1654,7 @@ int main(int argc, char **argv) /* seed the PRNG */ srand(time(NULL)); - + LOGP(DNAT, LOGL_NOTICE, "BSCs configured from %s\n", nat->include_path); /* * Setup the MGCP code.. diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index cd8293c..8d727d2 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -96,6 +96,8 @@ static int config_write_nat(struct vty *vty) vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE); vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE); vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE); + if (_nat->include_file) + vty_out(vty, " bscs-config-file %s%s", _nat->include_file, VTY_NEWLINE); if (_nat->token) vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE); vty_out(vty, " ip-dscp %d%s", _nat->bsc_ip_dscp, VTY_NEWLINE); @@ -181,6 +183,12 @@ static int config_write_bsc(struct vty *vty) return CMD_SUCCESS; } +DEFUN(show_bscs, show_bscs_cmd, "show bsc-config", + SHOW_STR "Show configured BSCs\n" + "Both from included file and vty\n") +{ + return config_write_bsc(vty); +} DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", SHOW_STR "Display information about SCCP\n" @@ -487,6 +495,33 @@ DEFUN(cfg_nat_acc_lst_name, return CMD_SUCCESS; } +DEFUN(cfg_nat_include, + cfg_nat_include_cmd, + "bscs-config-file NAME", + "Set the filename of the BSC configuration to include.\n" + "The filename to be included.") +{ + const char *conf = argv[0]; + + if ('/' == conf[0]) + bsc_replace_string(_nat, &_nat->include_path, conf); + else { + _nat->include_path = talloc_strdup_append(_nat->include_path, + "/"); + _nat->include_path = talloc_strdup_append(_nat->include_path, + conf); + } + + if (vty_read_config_file(_nat->include_path, NULL) < 0) { + vty_out(vty, "Failed to parse the config file %s%s", + _nat->include_path, + VTY_NEWLINE); + return CMD_WARNING; + } + bsc_replace_string(_nat, &_nat->include_file, conf); + return CMD_SUCCESS; +} + DEFUN(cfg_nat_no_acc_lst_name, cfg_nat_no_acc_lst_name_cmd, "no access-list-name", @@ -1176,6 +1211,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element_ve(&show_msc_cmd); install_element_ve(&test_regex_cmd); install_element_ve(&show_bsc_mgcp_cmd); + install_element_ve(&show_bscs_cmd); install_element_ve(&show_bar_lst_cmd); install_element_ve(&show_prefix_tree_cmd); install_element_ve(&show_ussd_connection_cmd); @@ -1197,6 +1233,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd); install_element(NAT_NODE, &cfg_nat_acc_lst_name_cmd); install_element(NAT_NODE, &cfg_nat_no_acc_lst_name_cmd); + install_element(NAT_NODE, &cfg_nat_include_cmd); install_element(NAT_NODE, &cfg_nat_imsi_black_list_fn_cmd); install_element(NAT_NODE, &cfg_nat_no_imsi_black_list_fn_cmd); install_element(NAT_NODE, &cfg_nat_ussd_lst_name_cmd); @@ -1233,7 +1270,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) /* BSC subgroups */ install_element(NAT_NODE, &cfg_bsc_cmd); - install_node(&bsc_node, config_write_bsc); + install_node(&bsc_node, NULL); vty_install_default(NAT_BSC_NODE); install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); install_element(NAT_BSC_NODE, &cfg_bsc_auth_key_cmd); -- 2.8.0 From msuraev at sysmocom.de Thu Mar 31 13:26:24 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 31 Mar 2016 15:26:24 +0200 Subject: [PATCH 2/2] Ignore vty test byproducts In-Reply-To: <1459430784-11266-1-git-send-email-msuraev@sysmocom.de> References: <1459430784-11266-1-git-send-email-msuraev@sysmocom.de> Message-ID: <1459430784-11266-2-git-send-email-msuraev@sysmocom.de> From: Max --- openbsc/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openbsc/.gitignore b/openbsc/.gitignore index 55f4a31..09a4174 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -89,3 +89,5 @@ tests/testsuite.log src/openbsc.cfg* +writtenconfig/ +gtphub_restart_count -- 2.8.0 From holger at freyther.de Thu Mar 31 14:19:39 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 31 Mar 2016 16:19:39 +0200 Subject: [PATCH] Add optional copy_files attribute In-Reply-To: <1459430596-9066-1-git-send-email-msuraev@sysmocom.de> References: <1459430596-9066-1-git-send-email-msuraev@sysmocom.de> Message-ID: <9969441B-9173-4C4A-A168-9BA384556DC2@freyther.de> > On 31 Mar 2016, at 15:23, msuraev at sysmocom.de wrote: > > From: Max > > This allows to specify additional files which shall be copied into > temporary directory where tests are executed. when we chatted I had something like this in make make_tmp_dir copy_recursively(orig, tmp_dir) run(tmp_dir/cfg_file) was your approach more simple? From holger at freyther.de Thu Mar 31 14:21:03 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 31 Mar 2016 16:21:03 +0200 Subject: [PATCH 1/2] NAT: move BSC config into separate file In-Reply-To: <1459430784-11266-1-git-send-email-msuraev@sysmocom.de> References: <1459430784-11266-1-git-send-email-msuraev@sysmocom.de> Message-ID: > On 31 Mar 2016, at 15:26, msuraev at sysmocom.de wrote: > > > +DEFUN(cfg_nat_include, > + cfg_nat_include_cmd, > + "bscs-config-file NAME", > + "Set the filename of the BSC configuration to include.\n" > + "The filename to be included.") > +{ > + const char *conf = argv[0]; > + > + if ('/' == conf[0]) > + bsc_replace_string(_nat, &_nat->include_path, conf); > + else { > + _nat->include_path = talloc_strdup_append(_nat->include_path, > + "/"); > + _nat->include_path = talloc_strdup_append(_nat->include_path, > + conf); > + } so If I write bscs-config-file bla.cfg bscs-config-file bla2.cfg How will nat->include_path look after this? From msuraev at sysmocom.de Thu Mar 31 15:37:29 2016 From: msuraev at sysmocom.de (msuraev at sysmocom.de) Date: Thu, 31 Mar 2016 17:37:29 +0200 Subject: [PATCH] NAT: move BSC config into separate file Message-ID: <1459438649-28463-1-git-send-email-msuraev@sysmocom.de> From: Max Introduce new configuration option bscs-config-file which includes BSC configuration from the given file. Both absolute and relative (to the main config file) paths are supported. Add 'show bsc-config' command to display current BSC configuration. Note: it is still possible to have BSC configuration in the main file (provided proper index number is used) and in runtime but BSC configuration is no longer saved automatically. The management of included configuration file is left to external tools. Update configuration examples. Fixes: OS#1669 --- openbsc/doc/examples/osmo-bsc_nat/bscs.config | 13 ++++++++ openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg | 8 +---- openbsc/include/openbsc/bsc_nat.h | 5 ++++ openbsc/osmoappdesc.py | 3 ++ openbsc/src/osmo-bsc_nat/bsc_nat.c | 5 +++- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 35 +++++++++++++++++++++- 6 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 openbsc/doc/examples/osmo-bsc_nat/bscs.config diff --git a/openbsc/doc/examples/osmo-bsc_nat/bscs.config b/openbsc/doc/examples/osmo-bsc_nat/bscs.config new file mode 100644 index 0000000..a10a565 --- /dev/null +++ b/openbsc/doc/examples/osmo-bsc_nat/bscs.config @@ -0,0 +1,13 @@ +nat + bsc 0 + token lol + location_area_code 1234 + description bsc + max-endpoints 32 + paging forbidden 0 + bsc 1 + token what + location_area_code 5678 + description bsc + max-endpoints 32 + paging forbidden 0 diff --git a/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg b/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg index 737d104..2e00bc2 100644 --- a/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg +++ b/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg @@ -62,11 +62,5 @@ nat timeout ping 20 timeout pong 5 ip-dscp 0 + bscs-config-file bscs.config access-list bla imsi-allow ^11$ - - bsc 0 - token bla - location_area_code 1234 - description bsc - max-endpoints 32 - paging forbidden 0 diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 309adb1..ff7f1dd 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -264,6 +264,11 @@ struct bsc_nat { struct bsc_endpoint *bsc_endpoints; + /* path to file with BSC config */ + char *include_file; + char *include_path; + char *include_base; + /* filter */ char *acc_lst_name; diff --git a/openbsc/osmoappdesc.py b/openbsc/osmoappdesc.py index 76f03fc..d10ecae 100644 --- a/openbsc/osmoappdesc.py +++ b/openbsc/osmoappdesc.py @@ -26,6 +26,9 @@ nitb_e1_configs = [ "doc/examples/osmo-nitb/rbs2308/openbsc.cfg" ] +copy_files = [ + "doc/examples/osmo-bsc_nat/bscs.config" +] app_configs = { "osmo-bsc": ["doc/examples/osmo-bsc/osmo-bsc.cfg"], diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index cacb919..54f5189 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -34,6 +34,7 @@ #include #include #include +#include #define _GNU_SOURCE #include @@ -1626,6 +1627,8 @@ int main(int argc, char **argv) local_addr.s_addr = INADDR_ANY; handle_options(argc, argv); + nat->include_base = dirname(talloc_strdup(tall_bsc_ctx, config_file)); + rate_ctr_init(tall_bsc_ctx); osmo_stats_init(tall_bsc_ctx); @@ -1651,7 +1654,7 @@ int main(int argc, char **argv) /* seed the PRNG */ srand(time(NULL)); - + LOGP(DNAT, LOGL_NOTICE, "BSCs configured from %s\n", nat->include_path); /* * Setup the MGCP code.. diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index cd8293c..6c50e29 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -96,6 +96,8 @@ static int config_write_nat(struct vty *vty) vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE); vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE); vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE); + if (_nat->include_file) + vty_out(vty, " bscs-config-file %s%s", _nat->include_file, VTY_NEWLINE); if (_nat->token) vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE); vty_out(vty, " ip-dscp %d%s", _nat->bsc_ip_dscp, VTY_NEWLINE); @@ -181,6 +183,12 @@ static int config_write_bsc(struct vty *vty) return CMD_SUCCESS; } +DEFUN(show_bscs, show_bscs_cmd, "show bsc-config", + SHOW_STR "Show configured BSCs\n" + "Both from included file and vty\n") +{ + return config_write_bsc(vty); +} DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", SHOW_STR "Display information about SCCP\n" @@ -487,6 +495,29 @@ DEFUN(cfg_nat_acc_lst_name, return CMD_SUCCESS; } +DEFUN(cfg_nat_include, + cfg_nat_include_cmd, + "bscs-config-file NAME", + "Set the filename of the BSC configuration to include.\n" + "The filename to be included.") +{ + const char *conf = argv[0]; + + if ('/' == conf[0]) + bsc_replace_string(_nat, &_nat->include_path, conf); + else + _nat->include_path = talloc_asprintf(_nat, "%s/%s", _nat->include_base, conf); + + if (vty_read_config_file(_nat->include_path, NULL) < 0) { + vty_out(vty, "Failed to parse the config file %s%s", + _nat->include_path, + VTY_NEWLINE); + return CMD_WARNING; + } + bsc_replace_string(_nat, &_nat->include_file, conf); + return CMD_SUCCESS; +} + DEFUN(cfg_nat_no_acc_lst_name, cfg_nat_no_acc_lst_name_cmd, "no access-list-name", @@ -1176,6 +1207,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element_ve(&show_msc_cmd); install_element_ve(&test_regex_cmd); install_element_ve(&show_bsc_mgcp_cmd); + install_element_ve(&show_bscs_cmd); install_element_ve(&show_bar_lst_cmd); install_element_ve(&show_prefix_tree_cmd); install_element_ve(&show_ussd_connection_cmd); @@ -1197,6 +1229,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd); install_element(NAT_NODE, &cfg_nat_acc_lst_name_cmd); install_element(NAT_NODE, &cfg_nat_no_acc_lst_name_cmd); + install_element(NAT_NODE, &cfg_nat_include_cmd); install_element(NAT_NODE, &cfg_nat_imsi_black_list_fn_cmd); install_element(NAT_NODE, &cfg_nat_no_imsi_black_list_fn_cmd); install_element(NAT_NODE, &cfg_nat_ussd_lst_name_cmd); @@ -1233,7 +1266,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) /* BSC subgroups */ install_element(NAT_NODE, &cfg_bsc_cmd); - install_node(&bsc_node, config_write_bsc); + install_node(&bsc_node, NULL); vty_install_default(NAT_BSC_NODE); install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); install_element(NAT_BSC_NODE, &cfg_bsc_auth_key_cmd); -- 2.8.0 From msuraev at sysmocom.de Thu Mar 31 15:38:10 2016 From: msuraev at sysmocom.de (Max) Date: Thu, 31 Mar 2016 17:38:10 +0200 Subject: [PATCH 1/2] NAT: move BSC config into separate file In-Reply-To: References: <1459430784-11266-1-git-send-email-msuraev@sysmocom.de> Message-ID: <56FD4462.2020701@sysmocom.de> Updated version sent. Thanks for review. On 03/31/2016 04:21 PM, Holger Freyther wrote: >> On 31 Mar 2016, at 15:26, msuraev at sysmocom.de wrote: >> >> >> +DEFUN(cfg_nat_include, >> + cfg_nat_include_cmd, >> + "bscs-config-file NAME", >> + "Set the filename of the BSC configuration to include.\n" >> + "The filename to be included.") >> +{ >> + const char *conf = argv[0]; >> + >> + if ('/' == conf[0]) >> + bsc_replace_string(_nat, &_nat->include_path, conf); >> + else { >> + _nat->include_path = talloc_strdup_append(_nat->include_path, >> + "/"); >> + _nat->include_path = talloc_strdup_append(_nat->include_path, >> + conf); >> + } > > so If I write > > bscs-config-file bla.cfg > bscs-config-file bla2.cfg > > How will nat->include_path look after this? > > > -- Max Suraev http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Alt-Moabit 93 * 10559 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From holger at freyther.de Thu Mar 31 15:44:25 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 31 Mar 2016 17:44:25 +0200 Subject: [PATCH] NAT: move BSC config into separate file In-Reply-To: <1459438649-28463-1-git-send-email-msuraev@sysmocom.de> References: <1459438649-28463-1-git-send-email-msuraev@sysmocom.de> Message-ID: <752C1A9C-0390-4592-B49E-7CCF5E842417@freyther.de> > On 31 Mar 2016, at 17:37, msuraev at sysmocom.de wrote: > > + else > + _nat->include_path = talloc_asprintf(_nat, "%s/%s", _nat->include_base, conf); and this will leak the previous include_path. Please try to get in the habbit of checking memory consumption. My standard approaches for these are: 1.) use the talloc leak report, it is triggered by SIGUSR1 in many of our apps and the output is printed to stdout 2.) Write a script to exercise the new code. E.g. a crazy shell script like this.. ( sleep 5s; echo "configure terminal"; echo "nat"; while true; do echo "bsc-co.."') | nc ... and use top -p `pidof ..nat` to watch how the memory changes 3.) Use valgrind and the leak check holger From holger at freyther.de Thu Mar 31 17:55:43 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 31 Mar 2016 19:55:43 +0200 Subject: ANN: https://patchwork.osmocom.org Message-ID: Hi, we are now running our own copy of patchwork at https://patchwork.osmocom.org. In addition to single patches this version can track series and has a REST API and git-pw client support. The system is currently subscribed to the GPRS, OpenBSC and OsmocomBB mailinglist. The installation is running offlineimap every couple of minutes to fetch new mail, this means it can take some minutes for your comment or patch to be visible. kind regards holger From holger at freyther.de Thu Mar 31 18:29:23 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 31 Mar 2016 20:29:23 +0200 Subject: ANN: osmo-sip-connector Message-ID: Hi, it is my pleasure to announce the osmo-sip-connector. It is a pure connector/translator/bridge from our NITB MNCC protocol to SIP (and vice versa). The sourcecode can be found here[1] and Debian 8.0 packages are available as part of the nightly packages[2] we are building. To run it a config file needs to be placed in /etc/osmocom/osmo-sip-connector.cfg. An example configuration can be found in doc/examples/ of the git repository. The system is meant to contact (and be contacted) from a single SIP PBX, the system will not do RTP proxying and transcoding is left as exercise to the PBX. The system is using libosmocore/libosmovty and sofia-sip(-glib) for SIP. There is a custom evpoll.c that integrates Osmocore's event loop with glib. As with every (new) software there is a long list of TODOs and we will address them: * Review logging and make sure enough context about call handling is present * Add VTY show commands (e.g. list calls and legs) * Add Stats/Counters to measure events and timing * Find a testing strategy * Implement a codec selection scheme that is good * IMSI based addressing * Release cause mapping * DTMF handling * Create a manual for it. In the long run we might want to consider mapping LUs to SIP REGISTER and SMPP to SIP as well. But that is quite far away and just a vague idea right now. kind regards holger [1] http://git.osmocom.org/osmo-sip-connector/ [2] https://build.opensuse.org/package/show/network:osmocom:nightly/osmo-sip-connector From suraev at alumni.ntnu.no Thu Mar 31 19:40:26 2016 From: suraev at alumni.ntnu.no (suraev at alumni.ntnu.no) Date: Thu, 31 Mar 2016 21:40:26 +0200 Subject: [PATCH] Add vty command to explicitly reset given BVCI Message-ID: <1459453226-8966-1-git-send-email-suraev@alumni.ntnu.no> From: Max It's useful for debugging and is similar to existing reset command for nsvc. --- src/gb/gprs_bssgp_vty.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 080867b..a3af69b 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,24 @@ static void dump_bssgp(struct vty *vty, int stats) } } +DEFUN(bvc_reset, bvc_reset_cmd, + "bssgp bvc nsei <0-65535> bvci <0-65535> reset", + "Initiate BVC RESET procedure for a given NSEI and BVCI\n") +{ + int r; + uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]); + struct bssgp_bvc_ctx *bvc = btsctx_by_bvci_nsei(bvci, nsei); + if (!bvc) { + vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, + VTY_NEWLINE); + return CMD_WARNING; + } + r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV); + vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, + VTY_NEWLINE); + return CMD_SUCCESS; +} + #define BSSGP_STR "Show information about the BSSGP protocol\n" DEFUN(show_bssgp, show_bssgp_cmd, "show bssgp", @@ -185,6 +204,7 @@ int bssgp_vty_init(void) install_element_ve(&show_bssgp_stats_cmd); install_element_ve(&show_bvc_cmd); install_element_ve(&logging_fltr_bvc_cmd); + install_element_ve(&bvc_reset_cmd); install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd); -- 2.5.0 From holger at freyther.de Thu Mar 31 19:54:27 2016 From: holger at freyther.de (Holger Freyther) Date: Thu, 31 Mar 2016 21:54:27 +0200 Subject: Interesting msgb (resize) issue when building Debian packages Message-ID: <6685BF16-6C72-4836-949A-26FC57923081@freyther.de> Hi, this only happens when building a debian package, valgrind doesn't show anything crazy. It is a bit difficult to see which test it is. Any ideas? holger Output: +++ /media/sf_source/gsm/libosmocore/tests/testsuite.dir/at-groups/7/stdout 2016-03-31 20:03:51.000000000 +0200 @@ -24,7 +24,7 @@ Src: [L1]> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 [L2]> 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 [L3]> 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b [L4]> 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f Dst: [L1]> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 [L2]> 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 [L3]> 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b [L4]> 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f msgb(%p): Sub area is not fully contained in the msg data -msgb(%p): Sub area is not fully contained in the msg data +msgb(%p): Negative sizes are not allowed msgb(%p): Sub area is not fully contained in the msg data msgb(%p): Negative sizes are not allowed msgb(%p): Negative sizes are not allowed 7. testsuite.at:42: 7. msgb (testsuite.at:42): FAILED (testsuite.at:45) From nhofmeyr at sysmocom.de Thu Mar 31 22:49:13 2016 From: nhofmeyr at sysmocom.de (Neels Hofmeyr) Date: Fri, 1 Apr 2016 00:49:13 +0200 Subject: sccp_helpers: osmo_prim_init() and msgb Message-ID: <20160331224913.GA17974@dub6> Hi list, osmo_prim_init() and msgb use firstly confuses me, and secondly is apparently "inefficient" in sccp_helpers.c. First, let's look at osmo_sccp_tx_unitdata() (libosmo-sccp branch sysmocom/iu): int osmo_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; 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); memcpy(msg->l2h, data, len); return osmo_sua_user_link_down(link, &prim->oph); } First off, we allocate 1024 bytes of msgb. Into it goes an osmo_scu_prim struct (here 'prim'). We set some parameters in prim, fair enough. But now what, prim->oph, the prim header, has a msg pointer, which points back at the msgb that contains the prim. really?? The msgb containing a struct pointing back at the same msgb has my head spinning. Finally we add the data, l2h pointing at the start of it. I'm confused ... how large is the msgb supposed to be? Is it len + sizeof(*prim)? Secondly, let's look at: int osmo_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 = osmo_sccp_tx_unitdata(link, calling_addr, called_addr, msg->data, msgb_length(msg)); msgb_free(msg); return rc; } So, something out there has a msgb containing data. For example, from ranap_new_msg_paging_cmd(). That msgb has probably been allocated specifically to compose a message to go over the sccp link. We go on, though, to allocate *another* msgb (size 1024, remember), and memcpy the first msgb into the second msgb, behind the osmo_scu_prim struct. I'll first use this as-is, talking about premature optimization. But I'd prefer to have neither the wicked cunning nor the blunt dumbness in there; the combination strikes me as jolly mad ;) Are there good reasons for this? I would have envisioned something like: tell ranap_new_msg_paging_cmd() to allocate sizeof(*prim) of headroom; or first create a msgb of fixed known-max size, and add first the prim header and then compose the data. And, given the union prim->u has "unknown" size, why not point at the data from prim->oph directly, instead of pointing back at the msgb? Or have that union first? That would be easier to understand. If some code needs to know the msgb that contains the prim->oph, I find it weird to pass it the prim->oph with a backpointer, instead of just passing the msgb right away. ~Neels -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From domi at tomcsanyi.net Mon Mar 21 08:31:19 2016 From: domi at tomcsanyi.net (=?utf-8?B?VG9tY3PDoW55aSwgRG9tb25rb3M=?=) Date: Mon, 21 Mar 2016 08:31:19 -0000 Subject: Time to rename projects.osmocom.org to osmocom.org In-Reply-To: <20160321065308.GD10371@nataraja> References: <20160321065308.GD10371@nataraja> Message-ID: Hi Harald, > I wonder if it is worth to make the old wiki/issue trac databases > (without the user password hashes!) publicly available, in case somebody > has a need for old content. I think this would be great. Thanks! Domi Tomcsanyi From marco.heumann at posteo.de Wed Mar 30 21:26:06 2016 From: marco.heumann at posteo.de (Marco Heumann) Date: Wed, 30 Mar 2016 23:26:06 +0200 Subject: [osmo-sim-auth] Only AUTS returning Message-ID: <56FC446E.8010209@posteo.de> Hello everyone, a student college and me are using the osmo-sim-auth tool for a student project. We have valid data for our SIM card since it's a special ordered test SIM card. In 2G mode we get the correct RES value, but in 3G mode we always get only an AUTS value. We calculated the SQN value from the AUTS to verify that we have the correct SQN value, but still we only get AUTS as return. I would be grateful to hear if any of you have an idea why this is happening. Best regards Marco